qwen-code/scripts/workspaces.js
易良 baf0ff41f7
refactor(build,release): Use pnpm workspace builds and publishing (#12400)
* refactor(release): Use pnpm for workspace publishing and versioning

* fix(ci): revert desktop-release install to npm ci for Windows compatibility

The pnpm migration added a bash conditional to check for pnpm-lock.yaml,
but the step did not specify shell: 'bash'. Windows runners default to
PowerShell, which cannot parse bash syntax, causing the build to fail
with a ParserError.

Since desktop-release always checks out the same commit and the root
lockfile is now pnpm-lock.yaml, the conditional is unnecessary. Revert
to the simple npm ci command that works on all platforms.

Fixes the Windows build failure in Desktop release v0.24.2.

* refactor(build): Schedule workspace builds with pnpm

* fix(ci): Preserve Windows release installation and version filters

---------

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-09-21 15:38:36 +00:00

49 lines
1.3 KiB
JavaScript

/**
* @license
* Copyright 2026 Qwen Team
* SPDX-License-Identifier: Apache-2.0
*/
import { globSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
function toGlobPath(filePath) {
return filePath.replaceAll('\\', '/');
}
export function getWorkspacePackageJsonPaths(root, workspaces) {
const packageJsonPaths = new Set();
for (const workspace of workspaces) {
const isExcluded = workspace.startsWith('!');
const pattern = toGlobPath(isExcluded ? workspace.slice(1) : workspace);
const matches = globSync(`${pattern}/package.json`, { cwd: root });
for (const match of matches) {
const packageJsonPath = toGlobPath(match);
if (isExcluded) {
packageJsonPaths.delete(packageJsonPath);
} else {
packageJsonPaths.add(packageJsonPath);
}
}
}
return [...packageJsonPaths].sort();
}
export function getTestCiWorkspacePackageJsonPaths(root) {
const { workspaces } = JSON.parse(
readFileSync(join(root, 'package.json'), 'utf8'),
);
return getWorkspacePackageJsonPaths(root, workspaces).filter(
(packageJsonPath) => {
const { scripts } = JSON.parse(
readFileSync(join(root, packageJsonPath), 'utf8'),
);
return Boolean(scripts?.['test:ci']);
},
);
}