Skip to content

Commit 70baf43

Browse files
authored
CLI-ify (#1)
Converts the extension to a CLI that can be run independent of VS Code, by shimming the use of `vscode` APIs and adding a new entrypoint.
1 parent cb5d419 commit 70baf43

21 files changed

+1356
-363
lines changed

.esbuild.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ const watch = process.argv.includes('--watch');
44
const minify = watch ? process.argv.includes('--minify') : !process.argv.includes('--no-minify');
55

66
const ctx = esbuild.context({
7-
entryPoints: ['src/extension.ts'],
7+
entryPoints: ['src/cli.ts'],
88
tsconfig: './tsconfig.json',
99
bundle: true,
10-
external: ['vscode'],
10+
external: [],
1111
sourcemap: !minify,
1212
minify,
1313
platform: 'node',
14-
outdir: 'out',
15-
packages: 'bundle',
14+
outfile: 'out/cli.js',
1615
});
1716

1817
ctx

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [20.x, latest]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Run tests
29+
run: npm test

.mocharc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extension": ["ts"],
3+
"spec": "test/**/*.test.ts",
4+
"node-option": ["import=tsx"]
5+
}

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
# js-debug-companion
1+
# js-debug-companion-cli
2+
3+
This is a fork of the original [vscode-js-debug-companion](https://github.com/microsoft/vscode-js-debug-companion) project, which allows running the same code as a standalone process instead of a VS Code extension. It's used by [Zed](https://zed.dev) to support browser debugging in SSH and WSL projects.
4+
5+
The CLI is launched as follows:
6+
7+
```bash
8+
node out/cli.js --listen=localhost:3000 --state=/path/to/state/dir
9+
```
10+
11+
This launches a process that will listen for HTTP requests on the specified address. There are two endpoints:
12+
13+
- `POST /launch-and-attach`: Corresponds to the VS Code `js-debug-companion.launchAndAttach` command.
14+
- `POST /kill`: Corresponds to the VS Code `js-debug-companion.kill` command.
15+
16+
The body for each request should be the same JSON payload that's provided to the corresponding command by vscode-js-debug. The process can handle launching and killing multiple browsers during its lifetime.
17+
18+
## Original vscode-js-debug-companion README
219

320
A companion extension to [js-debug](https://github.com/microsoft/vscode-js-debug) to enable remote Chrome debugging. You probably don't want to install this extension by itself, but for your interest, this is what it does.
421

SECURITY.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

ci.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import eslint from '@eslint/js';
22
import tseslint from 'typescript-eslint';
33

4-
export default tseslint.config(
5-
eslint.configs.recommended,
6-
...tseslint.configs.recommended,
7-
);
4+
export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.recommended, {
5+
rules: {
6+
'@typescript-eslint/no-explicit-any': 'off',
7+
},
8+
});

0 commit comments

Comments
 (0)