mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-10-20 13:15:00 +00:00
packages/cli compiles against ink frame-controller types that only patches/ink+7.0.3.patch adds; pristine ink@7.0.3 exports none of them. That patch reaches node_modules through the root postinstall, so an install that skipped lifecycle scripts (--ignore-scripts, or ignore-scripts=true in the user's npm/pnpm config) leaves pristine ink in place and the build fails with ~50 errors that all blame ink -- which sends a reporter to compare ink versions on npm instead of to the missing patch. Because noEmitOnError is unset, tsc still emitted a dist that runs with text selection broken. scripts/build.js already heals a missing node_modules; heal a missing patch the same way. frame-controller.d.ts is created by that patch and absent from pristine ink@7.0.3, so its absence is the signal. If re-applying still does not produce it, name the patch rather than letting tsc point at ink. Fixes #14110 Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
93 lines
3 KiB
JavaScript
93 lines
3 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
import { execSync } from 'node:child_process';
|
|
import { existsSync } from 'node:fs';
|
|
import { dirname, join } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const root = join(__dirname, '..');
|
|
|
|
// Install if node_modules was removed (e.g. via npm run clean or scripts/clean.js)
|
|
if (!existsSync(join(root, 'node_modules'))) {
|
|
execSync('corepack pnpm install --frozen-lockfile', {
|
|
stdio: 'inherit',
|
|
cwd: root,
|
|
});
|
|
}
|
|
|
|
// The root postinstall applies patches/ink+7.0.3.patch, and packages/cli
|
|
// compiles against ink types only that patch adds: an install that skipped
|
|
// lifecycle scripts fails the build with ~50 errors that all blame ink. The
|
|
// patch creates frame-controller.d.ts, which pristine ink@7.0.3 lacks.
|
|
const inkFrameController = join(
|
|
root,
|
|
'node_modules/ink/build/frame-controller.d.ts',
|
|
);
|
|
if (!existsSync(inkFrameController)) {
|
|
execSync('npm run postinstall', { stdio: 'inherit', cwd: root });
|
|
if (!existsSync(inkFrameController)) {
|
|
console.error(
|
|
'build: patches/ink+7.0.3.patch is not applied to node_modules/ink, so\n' +
|
|
'packages/cli cannot typecheck against it. Run "npm run postinstall"\n' +
|
|
'and resolve what patch-package reports.',
|
|
);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
// build all workspaces/packages in dependency order
|
|
execSync('npm run generate', { stdio: 'inherit', cwd: root });
|
|
|
|
// Select the CLI by path: the repository root has the same package name.
|
|
const cliOnly = process.argv.includes('--cli-only');
|
|
// Mobile MCP has an independent build and was never part of the root build.
|
|
const filter = cliOnly
|
|
? '--filter "{./packages/cli}..." --filter @qwen-code/node-repl-mcp --filter @qwen-code/channel-plugin-example'
|
|
: '--filter "!@qwen-code/mobile-mcp"';
|
|
execSync(`corepack pnpm -r ${filter} run build`, {
|
|
stdio: 'inherit',
|
|
cwd: root,
|
|
});
|
|
|
|
execSync('node --import tsx/esm scripts/generate-settings-schema.ts', {
|
|
stdio: 'inherit',
|
|
cwd: root,
|
|
});
|
|
|
|
// also build container image if sandboxing is enabled
|
|
// skip (-s) npm install + build since we did that above
|
|
try {
|
|
execSync('node scripts/sandbox_command.js -q', {
|
|
stdio: 'inherit',
|
|
cwd: root,
|
|
});
|
|
if (
|
|
process.env.BUILD_SANDBOX === '1' ||
|
|
process.env.BUILD_SANDBOX === 'true'
|
|
) {
|
|
execSync('node scripts/build_sandbox.js -s', {
|
|
stdio: 'inherit',
|
|
cwd: root,
|
|
});
|
|
}
|
|
} catch {
|
|
// ignore
|
|
}
|