diff --git a/packages/bun-vscode/.gitignore b/packages/bun-vscode/.gitignore index cafc85cea7..792cb949ab 100644 --- a/packages/bun-vscode/.gitignore +++ b/packages/bun-vscode/.gitignore @@ -1,3 +1,10 @@ -node_modules -extension -example/.vscode +# Project files + +/node_modules +/extension +/example/.vscode +/.vscode-test + +# macOS files + +.DS_Store diff --git a/packages/bun-vscode/bun.lockb b/packages/bun-vscode/bun.lockb index 9433b0c6de..b5dfde26d3 100755 Binary files a/packages/bun-vscode/bun.lockb and b/packages/bun-vscode/bun.lockb differ diff --git a/packages/bun-vscode/package.json b/packages/bun-vscode/package.json index cdaecb9099..23ace8a229 100644 --- a/packages/bun-vscode/package.json +++ b/packages/bun-vscode/package.json @@ -1,6 +1,6 @@ { "name": "bun-vscode", - "version": "0.0.13", + "version": "0.0.15", "author": "oven", "repository": { "type": "git", @@ -8,11 +8,13 @@ }, "main": "dist/extension.js", "devDependencies": { + "@types/bun": "^1.1.10", "@types/vscode": "^1.60.0", "@vscode/debugadapter": "^1.56.0", "@vscode/debugadapter-testsupport": "^1.56.0", + "@vscode/test-cli": "^0.0.10", + "@vscode/test-electron": "^2.4.1", "@vscode/vsce": "^2.20.1", - "bun-types": "^0.7.3", "esbuild": "^0.19.2", "typescript": "^5.0.0" }, @@ -43,6 +45,7 @@ "build": "node scripts/build.mjs", "pretest": "bun run build", "test": "node scripts/test.mjs", + "dev": "vscode-test --config scripts/dev.mjs", "prepublish": "npm version patch && bun run build", "publish": "cd extension && bunx vsce publish" }, diff --git a/packages/bun-vscode/scripts/build.mjs b/packages/bun-vscode/scripts/build.mjs index 73f88b014c..24fc6497c4 100644 --- a/packages/bun-vscode/scripts/build.mjs +++ b/packages/bun-vscode/scripts/build.mjs @@ -1,13 +1,9 @@ import { buildSync } from "esbuild"; import { execSync } from "node:child_process"; import { cpSync, mkdirSync, rmSync } from "node:fs"; -import path from "node:path"; +import { dirname } from "node:path"; -let { pathname } = new URL("..", import.meta.url); -if (process.platform === "win32") { - pathname = path.normalize(pathname).substring(1); // remove leading slash -} -process.chdir(pathname); +process.chdir(dirname(import.meta.dirname)); buildSync({ entryPoints: ["src/extension.ts", "src/web-extension.ts"], diff --git a/packages/bun-vscode/scripts/dev.mjs b/packages/bun-vscode/scripts/dev.mjs new file mode 100644 index 0000000000..33fe719583 --- /dev/null +++ b/packages/bun-vscode/scripts/dev.mjs @@ -0,0 +1,26 @@ +import { defineConfig } from "@vscode/test-cli"; +import { dirname, join } from "node:path"; +import { existsSync, mkdirSync, writeFileSync } from "node:fs"; + +const workspacePath = dirname(import.meta.dirname); +const vscodePath = join(workspacePath, ".vscode-test"); +const vscodeTestPath = join(vscodePath, "launch.test.js"); + +if(!existsSync(vscodeTestPath)) { + mkdirSync(vscodePath, { recursive: true }); + writeFileSync(vscodeTestPath, `// Generated by ${import.meta.filename} +// A test that intentionally waits forever and does nothing, +// so you can debug and test the VSCode extension in a clean environment. +suite("VSCode extension", function () { + this.timeout(Number.MAX_SAFE_INTEGER); + test("wait forever", (done) => {}); +}); +`); +} + +export default defineConfig({ + workspaceFolder: join(workspacePath, "example"), + extensionDevelopmentPath: workspacePath, + skipExtensionDependencies: true, + files: vscodeTestPath, +}); diff --git a/packages/bun-vscode/scripts/test.mjs b/packages/bun-vscode/scripts/test.mjs index 105f577ac0..505e93ef42 100644 --- a/packages/bun-vscode/scripts/test.mjs +++ b/packages/bun-vscode/scripts/test.mjs @@ -1,12 +1,8 @@ import { exec } from "node:child_process"; import { readdirSync } from "node:fs"; -import path from "node:path"; +import { dirname } from "node:path"; -let { pathname } = new URL("..", import.meta.url); -if (process.platform === "win32") { - pathname = path.normalize(pathname).substring(1); // remove leading slash -} -process.chdir(pathname); +process.chdir(dirname(import.meta.dirname)); let extPath; for (const filename of readdirSync("extension")) { @@ -20,6 +16,6 @@ if (!extPath) { throw new Error("No .vsix file found"); } -exec(`code --new-window --install-extension=${path} --extensionDevelopmentPath=${pathname} example`, { +exec(`code --new-window --install-extension=${extPath} --extensionDevelopmentPath=${process.cwd()} example`, { stdio: "inherit", });