diff --git a/editors/vscode/.eslintrc.json b/editors/vscode/.eslintrc.json new file mode 100644 index 0000000..32fc39d --- /dev/null +++ b/editors/vscode/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + "@typescript-eslint/semi": "warn", + "curly": "warn", + "eqeqeq": "warn", + "no-throw-literal": "warn", + "semi": "off" + }, + "ignorePatterns": [ + "out", + "dist", + "**/*.d.ts" + ] +} diff --git a/editors/vscode/package.json b/editors/vscode/package.json index 28382ee..5321087 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -19,10 +19,11 @@ ], "main": "./dist/extension.js", "scripts": { - "vscode:prepublish": "npm run package", + "vscode:prepublish": "npm run build", + "build": "npm run check-types && npm run lint && node esbuild.js --production", "compile": "npm run check-types && npm run lint && node esbuild.js", "watch": "npm run check-types && npm run lint && node esbuild.js --watch", - "package": "npm run check-types && npm run lint && node esbuild.js --production", + "package": "vsce package", "check-types": "tsc --noEmit", "lint": "eslint src --ext ts", "test": "npm run compile && node ./dist/test/runTest.js" diff --git a/editors/vscode/src/bootstrap.ts b/editors/vscode/src/bootstrap.ts index 2973709..6aa710e 100644 --- a/editors/vscode/src/bootstrap.ts +++ b/editors/vscode/src/bootstrap.ts @@ -4,10 +4,16 @@ import * as path from 'path'; import * as https from 'https'; import * as os from 'os'; import { IncomingMessage } from 'http'; +import { exec } from 'child_process'; +import { promisify } from 'util'; + +const execAsync = promisify(exec); const BINARY_NAME = 'naviscope'; const REPO_OWNER = 'biuld'; const REPO_NAME = 'naviscope'; +// Update this version when bundling a new version of the extension +const EXPECTED_VERSION = '0.1.0'; export async function bootstrap(context: vscode.ExtensionContext): Promise { const naviscopeHome = path.join(os.homedir(), '.naviscope'); @@ -23,31 +29,63 @@ export async function bootstrap(context: vscode.ExtensionContext): Promise { try { - await downloadBinary(binaryPath); - vscode.window.showInformationMessage(`Naviscope installed successfully!`); - return binaryPath; - } catch (error) { - vscode.window.showErrorMessage(`Failed to download Naviscope: ${error}`); - if (fs.existsSync(binaryPath)) { - fs.unlinkSync(binaryPath); - } - return undefined; + const { stdout } = await execAsync(`"${binaryPath}" --version`); + // Expected output: "naviscope 0.1.0" + return stdout.includes(EXPECTED_VERSION); + } catch (e) { + console.warn('Failed to check version:', e); + return false; } } @@ -112,7 +150,6 @@ function getPlatformIdentifier(): string | null { if (arch === 'arm64') { return 'macos-aarch64'; } - // Intel Mac is not supported } return null; }