Skip to content

Commit 660a961

Browse files
pokeypre-commit-ci[bot]Will-SommersAndreasArvidsson
authored
Create local extension sandbox (#691)
* Create local extension sandbox * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * docstring * Update docs/contributing/CONTRIBUTING.md Co-authored-by: Will Sommers <[email protected]> * Update CONTRIBUTING.md * Update docs/contributing/CONTRIBUTING.md Co-authored-by: Will Sommers <[email protected]> * Use exec * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Support fully compositional modifiers Fixes #69 * Bunch et weeks * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix licenses * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Will Sommers <[email protected]> Co-authored-by: Andreas Arvidsson <[email protected]>
1 parent 011d8c7 commit 660a961

10 files changed

+121
-28
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ docs/contributing/api/
1111

1212
# Generated docs hub
1313
gh-pages-root/docs/
14+
15+
# Local extension / data sandbox for debug launch task
16+
/.vscode-sandbox

.vscode/launch.json

+28-17
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
"type": "extensionHost",
1111
"request": "launch",
1212
"args": [
13-
"--disable-extension",
14-
"asvetliakov.vscode-neovim",
15-
"--disable-extension",
16-
"pokey.cursorless-local",
17-
"--extensionDevelopmentPath=${workspaceFolder}"
13+
"--extensionDevelopmentPath=${workspaceFolder}",
14+
"--extensions-dir=${workspaceFolder}/.vscode-sandbox/extensions"
1815
],
1916
"outFiles": ["${workspaceFolder}/out/**/*.js"],
20-
"preLaunchTask": "${defaultBuildTask}"
17+
"preLaunchTask": "${defaultBuildTask}",
18+
"resolveSourceMapLocations": [
19+
"${workspaceFolder}/**",
20+
"!${workspaceFolder}/.vscode-sandbox/**",
21+
"!**/node_modules/**"
22+
]
2123
},
2224
{
2325
"name": "Extension Tests",
@@ -27,15 +29,17 @@
2729
"CURSORLESS_TEST": "true"
2830
},
2931
"args": [
30-
"--disable-extension",
31-
"asvetliakov.vscode-neovim",
32-
"--disable-extension",
33-
"pokey.cursorless-local",
32+
"--extensions-dir=${workspaceFolder}/.vscode-sandbox/extensions",
3433
"--extensionDevelopmentPath=${workspaceFolder}",
3534
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
3635
],
3736
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
38-
"preLaunchTask": "${defaultBuildTask}"
37+
"preLaunchTask": "${defaultBuildTask}",
38+
"resolveSourceMapLocations": [
39+
"${workspaceFolder}/**",
40+
"!${workspaceFolder}/.vscode-sandbox/**",
41+
"!**/node_modules/**"
42+
]
3943
},
4044
{
4145
"name": "Update fixtures",
@@ -46,23 +50,30 @@
4650
"CURSORLESS_TEST_UPDATE_FIXTURES": "true"
4751
},
4852
"args": [
49-
"--disable-extension",
50-
"asvetliakov.vscode-neovim",
51-
"--disable-extension",
52-
"pokey.cursorless-local",
53+
"--extensions-dir=${workspaceFolder}/.vscode-sandbox/extensions",
5354
"--extensionDevelopmentPath=${workspaceFolder}",
5455
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
5556
],
5657
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
57-
"preLaunchTask": "${defaultBuildTask}"
58+
"preLaunchTask": "${defaultBuildTask}",
59+
"resolveSourceMapLocations": [
60+
"${workspaceFolder}/**",
61+
"!${workspaceFolder}/.vscode-sandbox/**",
62+
"!**/node_modules/**"
63+
]
5864
},
5965
{
6066
"name": "Docusaurus Start (Debug)",
6167
"type": "node",
6268
"request": "launch",
6369
"cwd": "${workspaceFolder}/website",
6470
"runtimeExecutable": "npm",
65-
"runtimeArgs": ["run", "start"]
71+
"runtimeArgs": ["run", "start"],
72+
"resolveSourceMapLocations": [
73+
"${workspaceFolder}/**",
74+
"!${workspaceFolder}/.vscode-sandbox/**",
75+
"!**/node_modules/**"
76+
]
6677
}
6778
]
6879
}

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"editor.defaultFormatter": "esbenp.prettier-vscode",
1111
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
1212
"typescript.tsc.autoDetect": "off",
13+
"npm.exclude": "**/.sandbox/**/*",
1314
"cSpell.words": [
1415
"Autoformatting",
1516
"camelize",

.vscodeignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ vsc-extension-quickstart.md
99
**/*.map
1010
**/*.ts
1111
node_modules/**
12+
.vscode-sandbox/**
1213
out/**
1314
dist/**
1415
!dist/extension.js

docs/contributing/CONTRIBUTING.md

+29-5
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,20 @@ extension](#running--testing-extension-locally), you may want to check out the
1212
- [Git](https://git-scm.com/)
1313
- [Node.js](https://nodejs.org/en/)
1414
- [yarn](https://yarnpkg.com/)
15-
- In order to run unit tests locally, you'll need to install the following extensions
16-
- [Scala (Metals)](https://marketplace.visualstudio.com/items?itemName=scalameta.metals)
1715

1816
### Steps
1917

2018
1. Clone [`cursorless`](https://github.com/cursorless-dev/cursorless)
2119
2. Open the newly created `cursorless` directory in VSCode
22-
3. Run `yarn` in the terminal
20+
3. Run the following in the terminal:
21+
22+
```bash
23+
yarn
24+
yarn compile
25+
yarn init-launch-sandbox
26+
```
27+
28+
The `yarn init-launch-sandbox` command creates a local sandbox containing a specific set of VSCode extensions that will be run alongside Cursorless when you launch Cursorless in debug or test mode. Please file an issue if you'd like to use additional extensions when debugging locally.
2329

2430
## Running / testing extension locally
2531

@@ -44,14 +50,32 @@ Run the `workbench.action.debug.selectandstart` command and then select
4450

4551
See [test-case-recorder.md](./test-case-recorder.md).
4652

47-
## Adding a new programming language
53+
## Parse tree support
54+
55+
### Adding a new programming language
4856

4957
See [docs](./adding-a-new-language.md).
5058

51-
## Adding syntactic scope types to an existing language
59+
### Adding syntactic scope types to an existing language
5260

5361
See [parse-tree-patterns.md](./parse-tree-patterns.md).
5462

63+
### Testing Cursorless with a local version of the VSCode parse tree extension
64+
65+
First bundle the parse tree extension into a `.vsix`, using something like the following:
66+
67+
```
68+
cd ../vscode-parse-tree
69+
vsce package -o bundle.vsix
70+
```
71+
72+
Once you have your package then you can install it into the sandbox using the following command:
73+
74+
```
75+
cd ../cursorless
76+
code --extensions-dir .vscode-sandbox/extensions --install-extension ../vscode-parse-tree/bundle.vsix
77+
```
78+
5579
## Changing SVGs
5680

5781
### SVG preprocessing script

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@
508508
"pretest": "yarn run compile && yarn run lint && yarn run esbuild",
509509
"lint": "eslint src --ext ts",
510510
"test": "env CURSORLESS_TEST=true node ./out/test/runTest.js",
511+
"init-launch-sandbox": "node ./out/test/initLaunchSandbox.js",
511512
"prepare-for-extension-publish": "node ./out/scripts/prepareForExtensionPublish.js"
512513
},
513514
"devDependencies": {

src/test/extensionDependencies.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const extensionDependencies = [
2+
"pokey.parse-tree",
3+
"ms-toolsai.jupyter",
4+
"scalameta.metals",
5+
];

src/test/initLaunchSandbox.ts

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* This script creates a local sandbox directory containing extensions that
3+
* will run alongside Cursorless during local development.
4+
*/
5+
import * as path from "path";
6+
import * as cp from "child_process";
7+
import { promisify } from "util";
8+
import { extensionDependencies } from "./extensionDependencies";
9+
import { mkdir } from "fs/promises";
10+
11+
const extraExtensions = ["pokey.command-server", "pokey.talon"];
12+
13+
async function main() {
14+
try {
15+
// The folder containing the Extension Manifest package.json
16+
const extensionDevelopmentPath = path.resolve(__dirname, "../../");
17+
const extensionSandboxDir = path.join(
18+
extensionDevelopmentPath,
19+
".vscode-sandbox",
20+
"extensions"
21+
);
22+
await mkdir(extensionSandboxDir, { recursive: true });
23+
24+
const command = [
25+
"code",
26+
"--extensions-dir",
27+
extensionSandboxDir,
28+
...[...extensionDependencies, ...extraExtensions].flatMap(
29+
(dependency) => ["--install-extension", dependency]
30+
),
31+
].join(" ");
32+
33+
// Install extension dependencies
34+
const results = await promisify(cp.exec)(command);
35+
36+
console.log(results.stdout);
37+
console.log(results.stderr);
38+
} catch (err) {
39+
console.error("Failed to init launch sandbox");
40+
console.error(err);
41+
process.exit(1);
42+
}
43+
}
44+
45+
main();

src/test/runTest.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ import {
66
resolveCliPathFromVSCodeExecutablePath,
77
downloadAndUnzipVSCode,
88
} from "vscode-test";
9-
10-
const extensionDependencies = [
11-
"pokey.parse-tree",
12-
"ms-toolsai.jupyter",
13-
"scalameta.metals",
14-
];
9+
import { extensionDependencies } from "./extensionDependencies";
1510

1611
async function main() {
1712
try {

third-party-licenses.csv

+7
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
"@docusaurus/[email protected]","MIT","https://github.com/facebook/docusaurus","https://github.com/facebook/docusaurus/raw/master/LICENSE","website"
44
"@mdx-js/[email protected]","MIT","https://github.com/mdx-js/mdx","https://github.com/mdx-js/mdx/raw/master/license","website"
55
"@types/[email protected]","MIT","https://github.com/DefinitelyTyped/DefinitelyTyped","https://github.com/DefinitelyTyped/DefinitelyTyped/raw/master/LICENSE","cursorless"
6+
"[email protected]","Unlicense","https://github.com/xpl/ansicolor","https://github.com/xpl/ansicolor/raw/master/LICENSE","metals"
7+
"[email protected]","MIT","https://github.com/juliangruber/brace-expansion","https://github.com/juliangruber/brace-expansion/raw/master/LICENSE","vscode-fileutils"
68
"[email protected]","MIT","https://github.com/lukeed/clsx","https://github.com/lukeed/clsx/raw/master/license","website"
79
"[email protected]","MIT","https://github.com/kolodny/immutability-helper","https://github.com/kolodny/immutability-helper/raw/master/LICENSE","cursorless"
10+
"[email protected]","MIT","https://github.com/microsoft/node-jsonc-parser","https://github.com/microsoft/node-jsonc-parser/raw/master/LICENSE.md","parse-tree"
811
"[email protected]","MIT","https://github.com/syntax-tree/mdast-util-find-and-replace","https://github.com/syntax-tree/mdast-util-find-and-replace/raw/master/license","website"
12+
"[email protected]","Apache-2.0","https://github.com/scalameta/metals-languageclient","https://github.com/scalameta/metals-languageclient/raw/master/LICENSE","metals"
913
"[email protected]","MIT","https://github.com/FormidableLabs/prism-react-renderer","https://github.com/FormidableLabs/prism-react-renderer/raw/master/LICENSE","website"
14+
"[email protected]","MIT","https://github.com/jcoreio/promisify-child-process","https://github.com/jcoreio/promisify-child-process/raw/master/LICENSE.md","metals"
1015
"[email protected]","MIT","https://github.com/facebook/react","https://github.com/facebook/react/raw/master/LICENSE","website"
1116
"[email protected]","MIT","https://github.com/facebook/react","https://github.com/facebook/react/raw/master/LICENSE","website"
17+
"[email protected]","ISC","https://github.com/npm/node-tar","https://github.com/npm/node-tar/raw/master/LICENSE","parse-tree"
1218
"[email protected]","MIT","https://github.com/syntax-tree/unist-util-visit","https://github.com/syntax-tree/unist-util-visit/raw/master/license","website"
19+
"[email protected]","MIT","https://github.com/Microsoft/vscode-languageserver-node","https://github.com/Microsoft/vscode-languageserver-node/raw/master/License.txt","metals"

0 commit comments

Comments
 (0)