Publish VSCode extension

This commit is contained in:
Ashcon Partovi
2024-09-23 16:04:44 -07:00
parent 33075394a4
commit 7d94c59545
6 changed files with 46 additions and 18 deletions

View File

@@ -1,3 +1,10 @@
node_modules
extension
example/.vscode
# Project files
/node_modules
/extension
/example/.vscode
/.vscode-test
# macOS files
.DS_Store

Binary file not shown.

View File

@@ -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"
},

View File

@@ -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"],

View File

@@ -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,
});

View File

@@ -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",
});