mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 01:07:46 +00:00
chore: fix ide installer
This commit is contained in:
@@ -6,15 +6,13 @@
|
||||
|
||||
import * as child_process from 'child_process';
|
||||
import * as process from 'process';
|
||||
import { glob } from 'glob';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { DetectedIde } from './detect-ide.js';
|
||||
import { QWEN_CODE_COMPANION_EXTENSION_NAME } from './constants.js';
|
||||
|
||||
const VSCODE_COMMAND = process.platform === 'win32' ? 'code.cmd' : 'code';
|
||||
const VSCODE_COMPANION_EXTENSION_FOLDER = 'vscode-ide-companion';
|
||||
|
||||
export interface IdeInstaller {
|
||||
install(): Promise<InstallResult>;
|
||||
@@ -103,34 +101,7 @@ class VsCodeInstaller implements IdeInstaller {
|
||||
};
|
||||
}
|
||||
|
||||
const bundleDir = path.dirname(fileURLToPath(import.meta.url));
|
||||
// The VSIX file is copied to the bundle directory as part of the build.
|
||||
let vsixFiles = glob.sync(path.join(bundleDir, '*.vsix'));
|
||||
if (vsixFiles.length === 0) {
|
||||
// If the VSIX file is not in the bundle, it might be a dev
|
||||
// environment running with `npm start`. Look for it in the original
|
||||
// package location, relative to the bundle dir.
|
||||
const devPath = path.join(
|
||||
bundleDir, // .../packages/core/dist/src/ide
|
||||
'..', // .../packages/core/dist/src
|
||||
'..', // .../packages/core/dist
|
||||
'..', // .../packages/core
|
||||
'..', // .../packages
|
||||
VSCODE_COMPANION_EXTENSION_FOLDER,
|
||||
'*.vsix',
|
||||
);
|
||||
vsixFiles = glob.sync(devPath);
|
||||
}
|
||||
if (vsixFiles.length === 0) {
|
||||
return {
|
||||
success: false,
|
||||
message:
|
||||
'Could not find the required VS Code companion extension. Please file a bug via /bug.',
|
||||
};
|
||||
}
|
||||
|
||||
const vsixPath = vsixFiles[0];
|
||||
const command = `"${commandPath}" --install-extension "${vsixPath}" --force`;
|
||||
const command = `"${commandPath}" --install-extension qwenlm.qwen-code-vscode-ide-companion --force`;
|
||||
try {
|
||||
child_process.execSync(command, { stdio: 'pipe' });
|
||||
return {
|
||||
@@ -141,27 +112,7 @@ class VsCodeInstaller implements IdeInstaller {
|
||||
} catch (_error) {
|
||||
return {
|
||||
success: false,
|
||||
message: `Failed to install VS Code companion extension. Please try installing it manually from the VS Code marketplace.`,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OpenVSXInstaller implements IdeInstaller {
|
||||
async install(): Promise<InstallResult> {
|
||||
// TODO: Use the correct extension path.
|
||||
const command = `npx ovsx get qwenlm.qwen-code-vscode-ide-companion`;
|
||||
try {
|
||||
child_process.execSync(command, { stdio: 'pipe' });
|
||||
return {
|
||||
success: true,
|
||||
message:
|
||||
'VS Code companion extension was installed successfully from OpenVSX. Please restart your terminal to complete the setup.',
|
||||
};
|
||||
} catch (_error) {
|
||||
return {
|
||||
success: false,
|
||||
message: `Failed to install VS Code companion extension from OpenVSX. Please try installing it manually.`,
|
||||
message: `Failed to install VS Code companion extension. Please try installing '${QWEN_CODE_COMPANION_EXTENSION_NAME}' manually from the VS Code extension marketplace.`,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -172,6 +123,6 @@ export function getIdeInstaller(ide: DetectedIde): IdeInstaller | null {
|
||||
case DetectedIde.VSCode:
|
||||
return new VsCodeInstaller();
|
||||
default:
|
||||
return new OpenVSXInstaller();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user