Skip to content

Commit dbcb672

Browse files
authored
chore: update vsce to 4 and fix the msal-node advisory (#1927)
## Motivation Two Dependabot alerts cannot be fixed automatically: - `@azure/msal-node` [GHSA-xcx6-jx8p-x3h5](GHSA-xcx6-jx8p-x3h5) (fixed in 7.1.0), pulled in by `@vscode/vsce` and `ovsx` through `@azure/identity@4.13.3`. - `minimatch` [GHSA-g3hv-75wg-m249](GHSA-g3hv-75wg-m249) (affects `>=7.0.0 <11.0.1`, no fixed 10.x release). ## Changes - Update `@azure/identity` in the lockfile to 4.14.1. It depends on `@azure/msal-node` `^7.1.0`, so `@azure/msal-node` is now 7.2.1. This fixes the msal-node alert without changing any version range in `package.json`. - Update `@vscode/vsce` from `^3.6.0` to `^4.1.0`. `ovsx@1.3.0` already depends on vsce 4, so two vsce trees were installed. vsce 4 needs Node.js 22 or later (CI uses 24). It replaces glob with tinyglobby and no longer depends on `keytar`, so `keytar` is removed from `allowBuilds`. The lockfile loses about 1,000 lines. - Remove `src/test/suite/index.ts`. It is the old Mocha runner from before `@vscode/test-cli`, and `.vscode-test.mjs` does not use it. The root `glob` dev dependency was only used there, so it is removed too. - TypeScript 7 defaults `types` to `[]`. The removed runner's `import Mocha from 'mocha'` was what loaded the Mocha globals (`suite`, `test`) for the other test files, so `tsconfig.json` now lists `mocha` and `node` in `types`. No CHANGELOG entry, as this is an internal change. ## Notes: minimatch alert stays open This PR does not fix the minimatch alert, and it cannot be fixed with an `overrides` entry: - `vscode-languageclient` (10.1.2, and also the latest 11.0.0) depends on `minimatch ^10.2.6` and calls `Minimatch#makeRe()`. minimatch 11 removes `makeRe()`, so forcing 11 would throw a `TypeError` at runtime in the bundled extension. Upstream tracks this in `microsoft/vscode-languageserver-node#1938` (the fix PR `microsoft/vscode-languageserver-node#1935` currently fails CI). - glob 10 and 13 (via mocha, `@vscode/test-cli` and `test-exclude`) need glob 14 for minimatch 11, so the dev tools would need several more overrides. The alert would still stay open because of `vscode-languageclient`. The vulnerable code (`firstPhasePreProcess`) only runs with `optimizationLevel >= 2`. `vscode-languageclient` uses the default level 1, and its patterns come from the R language server. glob uses level 2, but only with the repository's own test globs. Once `vscode-languageclient` releases a version on minimatch 11, the alert should be fixable with a normal update. ## Update: debugging extension tests The **Extension Tests** launch configuration in `.vscode/launch.json` still pointed at the removed runner (`out/test/suite/index`), so it could no longer run any tests. It now uses js-debug's `testConfiguration` option (VS Code 1.87+) with `.vscode-test.mjs`: - After the `pretest` pre-launch task, js-debug runs `vscode-test --list-configuration`, asks which configuration to run, and launches `@vscode/test-cli`'s own runner with that configuration's files, Mocha options and launch arguments. F5 debugging works as before, without a second hand-written runner or the `glob` dependency. - This is also more accurate than the old runner, which ran every `src/test/suite/` file in one window without `out/test/common/extensionSetup.js` or the per-suite profiles. - Unlike the CLI, it runs in the current VS Code and does not install extension dependencies, so R Syntax must already be installed. `CONTRIBUTING.md` says this. [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner) (`ms-vscode.extension-test-runner`) is added to the workspace recommendations as an optional way to run or debug individual tests from the Testing view. Neither the debugger nor the CLI requires it. The `sess-install-tasks` configuration is removed. Its only test (`src/test/integration/sessInstall.test.ts`) was removed in #1856, so it ran 0 tests. Its temporary workspace was also deleted on process exit, so it was gone when a separate `--list-configuration` process (as used by the debugger and Extension Test Runner) exited. ## Update: working-directory-independent test profiles Test profile directories in `.vscode-test.mjs` now resolve relative to the configuration file's `import.meta.url`, using `fileURLToPath` for native filesystem paths. js-debug can load the configuration from a working directory outside the checkout, including the VS Code installation directory on Windows. Profiles now consistently stay under the checkout's `.vscode-test/user-data` directory.
1 parent ee60128 commit dbcb672

9 files changed

Lines changed: 74 additions & 1155 deletions

File tree

‎.vscode-test.mjs‎

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
import { defineConfig } from '@vscode/test-cli';
2-
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
3-
import { tmpdir } from 'node:os';
2+
import { mkdirSync, writeFileSync } from 'node:fs';
43
import * as path from 'node:path';
5-
6-
// A separate window keeps the real multi-folder task tests isolated from mocks.
7-
const taskRoot = mkdtempSync(path.join(tmpdir(), 'vscode-r sess tasks '));
8-
for (const project of ['project A', 'project B']) {
9-
mkdirSync(path.join(taskRoot, project));
10-
}
11-
const workspaceFile = path.join(taskRoot, 'projects.code-workspace');
12-
writeFileSync(workspaceFile, JSON.stringify({
13-
folders: [{ path: 'project A' }, { path: 'project B' }]
14-
}));
15-
process.on('exit', () => rmSync(taskRoot, { recursive: true, force: true }));
4+
import { fileURLToPath } from 'node:url';
165

176
const common = {
187
mocha: {
@@ -26,7 +15,7 @@ const common = {
2615
// command tests also need a fresh window after fixtures create terminals and
2716
// webviews. The real Interactive suite has its own window with the LSP enabled.
2817
function testProfile(name, lspEnabled) {
29-
const directory = path.resolve('.vscode-test/user-data', name);
18+
const directory = fileURLToPath(new URL(`.vscode-test/user-data/${name}/`, import.meta.url));
3019
mkdirSync(path.join(directory, 'User'), { recursive: true });
3120
writeFileSync(path.join(directory, 'User/settings.json'), JSON.stringify({ 'r.lsp.enabled': lspEnabled }));
3221
// Unattended runs can be occluded by another app. Keep browser paint and
@@ -62,15 +51,5 @@ export default defineConfig([
6251
label: 'interactive-integration',
6352
files: 'out/test/suite/interactiveEditor.test.js',
6453
launchArgs: testProfile('interactive-tests', true)
65-
},
66-
{
67-
...common,
68-
label: 'sess-install-tasks',
69-
files: 'out/test/integration/**/*.test.js',
70-
workspaceFolder: workspaceFile,
71-
launchArgs: ['--disable-workspace-trust'],
72-
// Let each project's .Rprofile select its library, even when the caller
73-
// runs from an existing managed R terminal with R_PROFILE_USER set.
74-
env: { R_PROFILE_USER: undefined, VSCODE_R_SESS_PKG_PATH: undefined, VSCODE_R_SESS_REPO: undefined }
7554
}
7655
]);

‎.vscode/extensions.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["oxc.oxc-vscode", "TypeScriptTeam.native-preview"]
2+
"recommendations": ["oxc.oxc-vscode", "TypeScriptTeam.native-preview", "ms-vscode.extension-test-runner"]
33
}

‎.vscode/launch.json‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@
3939
"type": "extensionHost",
4040
"request": "launch",
4141
"runtimeExecutable": "${execPath}",
42-
"args": [
43-
"--extensionDevelopmentPath=${workspaceFolder}",
44-
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
45-
],
42+
"testConfiguration": "${workspaceFolder}/.vscode-test.mjs",
4643
"outFiles": [
4744
"${workspaceFolder}/dist/**/*.js",
4845
"${workspaceFolder}/out/**/*.js"

‎CONTRIBUTING.md‎

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ If a command reports `pnpm: command not found`, ensure pnpm's installation direc
1717
2. Select **Launch Extension** in Run and Debug, then press **F5**. The pre-launch task runs `pnpm run compile` to build the extension and webviews in `dist`, including source maps for TypeScript breakpoints.
1818
3. Open an R file or run an R command in the Extension Development Host to activate vscode-R. Ensure the **R Syntax** extension (`REditorSupport.r-syntax`) is installed and enabled there.
1919

20-
For continuous rebuilding, run `pnpm run watch`. `pnpm run build` additionally installs the bundled `sess` R package; this is not required just to launch the extension debugger. **Extension Tests** builds both the bundle and the TypeScript test files before launching.
20+
For continuous rebuilding, run `pnpm run watch`. `pnpm run build` additionally installs the bundled `sess` R package; this is not required just to launch the extension debugger.
2121

2222
VS Code 1.140.0 bundles [JavaScript Debugger 1.140.0](https://github.com/microsoft/vscode-js-debug/releases/tag/v1.140.0), which fixes the [extension host attach regression in VS Code 1.139](https://github.com/microsoft/vscode-js-debug/issues/2420). Use the built-in **JavaScript Debugger** on VS Code 1.140.0 or newer. If you previously used **JavaScript Debugger Nightly**, disable Nightly, re-enable the built-in debugger (`ms-vscode.js-debug`) in the Extensions view, and run **Developer: Reload Window**.
2323

@@ -100,17 +100,31 @@ VSCR_TEST_TMUX=1 pnpm exec mocha out/test/node/interactiveRuntime.test.js --ui t
100100
The provider is arf. `ARF_PATH` selects its executable; `VSCR_TEST_STATIC=1` selects standard graphics. The tmux variant needs tmux and exercises a real supervised agent, as Linux CI does. These variables can be combined. Check skipped tests when assessing coverage: a missing optional runtime or package is not a verified pass for that feature.
101101

102102
`pnpm run test` prepares the bundle and test files, runs `src/test/node/` directly
103-
in Node/Mocha, then runs the extension-host suites and isolated sess task tests.
103+
in Node/Mocha, then runs the extension-host suites.
104104
`pnpm run test:interactive` prepares and runs only the Node suites, including
105105
supervision. After preparing once with `pnpm run pretest`, use `pnpm run test:node`
106-
and `pnpm run test:extension` to rerun either layer without rebuilding. The
107-
**Extension Tests** debugger configuration runs only `src/test/suite/`; use the
108-
CLI for the isolated multi-folder sess task tests.
106+
and `pnpm run test:extension` to rerun either layer without rebuilding.
107+
108+
To debug extension-host tests, select **Extension Tests** in Run and Debug and
109+
press **F5**. The pre-launch task runs `pnpm run pretest`, and the debugger then
110+
asks which `.vscode-test.mjs` configuration to run (`provider-tests`,
111+
`editor-command-tests` or `interactive-integration`). One launch runs only the
112+
selected configuration, with the same files, Mocha options and launch arguments
113+
as `pnpm run test:extension`. Unlike the CLI, it runs in the current VS Code and
114+
does not install extension dependencies, so the **R Syntax** extension must
115+
already be installed. `interactive-integration` also needs the R and arf setup
116+
described above.
117+
118+
Alternatively, the optional
119+
[Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner)
120+
extension (`ms-vscode.extension-test-runner`, in the workspace recommendations)
121+
lists the same configurations in the Testing view, so individual tests or suites
122+
can be run or debugged from there after `pnpm run pretest`.
109123

110124
PR CI, main pushes and manual runs execute the full supported suites on every
111-
OS. Linux and macOS run the same Node, Interactive editor and isolated sess task
112-
tests, including the actual VS Code Electron runtime check with no Node executable
113-
on PATH and successful session creation using the default VS Code runtime.
125+
OS. Linux and macOS run the same Node and Interactive editor tests, including
126+
the actual VS Code Electron runtime check with no Node executable on PATH and
127+
successful session creation using the default VS Code runtime.
114128
Windows skips the Interactive runtime/editor suites because persistent
115129
supervision currently requires Linux/macOS. Linux additionally runs the tmux launcher survival case
116130
once with tmux enabled and uses Xvfb for extension-host tests. Source/bootstrap
@@ -123,7 +137,7 @@ pnpm run pretest
123137
pnpm exec vscode-test --run out/test/suite/interactiveEditor.test.js
124138
```
125139

126-
On headless Linux, run the editor command under `xvfb-run -a`. The test configuration installs R Syntax in the test profile. [runtime-lifecycle.cjs](src/test/examples/README.md#editor-runtime-lifecycle) separately checks persistence across full application exit and different editor versions. Use it with the minimum VS Code version from `package.json` and current stable when changing runtime launch or reconnection.
140+
On headless Linux, run the editor command under `xvfb-run -a`. When run from the CLI, the test configuration installs R Syntax in the test profile. [runtime-lifecycle.cjs](src/test/examples/README.md#editor-runtime-lifecycle) separately checks persistence across full application exit and different editor versions. Use it with the minimum VS Code version from `package.json` and current stable when changing runtime launch or reconnection.
127141

128142
### Browser renderer
129143

‎package.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,10 +2626,9 @@
26262626
"@types/winreg": "^1.2.36",
26272627
"@vscode/test-cli": "^0.0.15",
26282628
"@vscode/test-electron": "^3.1.0",
2629-
"@vscode/vsce": "^3.6.0",
2629+
"@vscode/vsce": "^4.1.0",
26302630
"esbuild": "^0.28.1",
26312631
"git-cliff": "^2.12.0",
2632-
"glob": "^13.0.6",
26332632
"mocha": "^12.0.3",
26342633
"ovsx": "^1.3.0",
26352634
"oxfmt": "0.73.0",

0 commit comments

Comments
 (0)