mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
sync gemini-cli 0.1.17
Co-Authored-By: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
51
scripts/test-windows-paths.js
Normal file
51
scripts/test-windows-paths.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
// Test how paths are normalized
|
||||
function testPathNormalization() {
|
||||
// Use platform-agnostic path construction instead of hardcoded paths
|
||||
const testPath = path.join('test', 'project', 'src', 'file.md');
|
||||
const absoluteTestPath = path.resolve('test', 'project', 'src', 'file.md');
|
||||
|
||||
console.log('Testing path normalization:');
|
||||
console.log('Relative path:', testPath);
|
||||
console.log('Absolute path:', absoluteTestPath);
|
||||
|
||||
// Test path.join with different segments
|
||||
const joinedPath = path.join('test', 'project', 'src', 'file.md');
|
||||
console.log('Joined path:', joinedPath);
|
||||
|
||||
// Test path.normalize
|
||||
console.log('Normalized relative path:', path.normalize(testPath));
|
||||
console.log('Normalized absolute path:', path.normalize(absoluteTestPath));
|
||||
|
||||
// Test how the test would see these paths
|
||||
const testContent = `--- File: ${absoluteTestPath} ---\nContent\n--- End of File: ${absoluteTestPath} ---`;
|
||||
console.log('\nTest content with platform-agnostic paths:');
|
||||
console.log(testContent);
|
||||
|
||||
// Try to match with different patterns
|
||||
const marker = `--- File: ${absoluteTestPath} ---`;
|
||||
console.log('\nTrying to match:', marker);
|
||||
console.log('Direct match:', testContent.includes(marker));
|
||||
|
||||
// Test with normalized path in marker
|
||||
const normalizedMarker = `--- File: ${path.normalize(absoluteTestPath)} ---`;
|
||||
console.log(
|
||||
'Normalized marker match:',
|
||||
testContent.includes(normalizedMarker),
|
||||
);
|
||||
|
||||
// Test path resolution
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
console.log('\nCurrent file path:', __filename);
|
||||
console.log('Directory name:', path.dirname(__filename));
|
||||
}
|
||||
|
||||
testPathNormalization();
|
||||
@@ -39,15 +39,28 @@ const npmVersionArg = isSpecificVersion ? versionArg : versionArg;
|
||||
|
||||
// 3. Bump the version in the root and all workspace package.json files.
|
||||
run(`npm version ${npmVersionArg} --no-git-tag-version --allow-same-version`);
|
||||
run(
|
||||
`npm version ${npmVersionArg} --workspaces --no-git-tag-version --allow-same-version`,
|
||||
|
||||
// 4. Get all workspaces and filter out the one we don't want to version.
|
||||
const workspacesToExclude = ['qwen-code-vscode-ide-companion'];
|
||||
const lsOutput = JSON.parse(
|
||||
execSync('npm ls --workspaces --json --depth=0').toString(),
|
||||
);
|
||||
const allWorkspaces = Object.keys(lsOutput.dependencies || {});
|
||||
const workspacesToVersion = allWorkspaces.filter(
|
||||
(wsName) => !workspacesToExclude.includes(wsName),
|
||||
);
|
||||
|
||||
// 3. Get the new version number from the root package.json
|
||||
for (const workspaceName of workspacesToVersion) {
|
||||
run(
|
||||
`npm version ${npmVersionArg} --workspace ${workspaceName} --no-git-tag-version --allow-same-version`,
|
||||
);
|
||||
}
|
||||
|
||||
// 5. Get the new version number from the root package.json
|
||||
const rootPackageJsonPath = resolve(process.cwd(), 'package.json');
|
||||
const newVersion = readJson(rootPackageJsonPath).version;
|
||||
|
||||
// 4. Update the sandboxImageUri in the root package.json
|
||||
// 6. Update the sandboxImageUri in the root package.json
|
||||
const rootPackageJson = readJson(rootPackageJsonPath);
|
||||
if (rootPackageJson.config?.sandboxImageUri) {
|
||||
rootPackageJson.config.sandboxImageUri =
|
||||
@@ -56,7 +69,7 @@ if (rootPackageJson.config?.sandboxImageUri) {
|
||||
writeJson(rootPackageJsonPath, rootPackageJson);
|
||||
}
|
||||
|
||||
// 5. Update the sandboxImageUri in the cli package.json
|
||||
// 7. Update the sandboxImageUri in the cli package.json
|
||||
const cliPackageJsonPath = resolve(process.cwd(), 'packages/cli/package.json');
|
||||
const cliPackageJson = readJson(cliPackageJsonPath);
|
||||
if (cliPackageJson.config?.sandboxImageUri) {
|
||||
@@ -68,7 +81,7 @@ if (cliPackageJson.config?.sandboxImageUri) {
|
||||
writeJson(cliPackageJsonPath, cliPackageJson);
|
||||
}
|
||||
|
||||
// 6. Run `npm install` to update package-lock.json.
|
||||
// 8. Run `npm install` to update package-lock.json.
|
||||
run('npm install');
|
||||
|
||||
console.log(`Successfully bumped versions to v${newVersion}.`);
|
||||
|
||||
Reference in New Issue
Block a user