astro-vscode 2.15.0 → 2.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +12 -0
- package/.vscodeignore +10 -0
- package/CHANGELOG.md +1405 -0
- package/dist/node/client.js +24 -24
- package/dist/node/server.js +468 -911
- package/package.json +1 -7
- package/scripts/build-grammar.mjs +45 -0
- package/scripts/build.mjs +79 -0
- package/scripts/shared.mjs +29 -0
- package/src/client.ts +149 -0
- package/test/grammar/README.md +5 -0
- package/test/grammar/dummy/css.tmLanguage-dummy.json +4 -0
- package/test/grammar/dummy/html.tmLanguage-dummy.json +4 -0
- package/test/grammar/dummy/js.tmLanguage-dummy.json +4 -0
- package/test/grammar/dummy/json.tmLanguage-dummy.json +4 -0
- package/test/grammar/dummy/less.tsLanguage-dummy.json +4 -0
- package/test/grammar/dummy/postcss.tmLanguage-dummy.json +4 -0
- package/test/grammar/dummy/sass.tmLanguage-dummy.json +4 -0
- package/test/grammar/dummy/scss.tsLanguage-dummy.json +4 -0
- package/test/grammar/dummy/stylus.tmLanguage-dummy.json +4 -0
- package/test/grammar/dummy/ts.tmLanguage-dummy.json +4 -0
- package/test/grammar/dummy/tsx.tmLanguage-dummy.json +4 -0
- package/test/grammar/dummy/unknown.tmLanguage-dummy.json +4 -0
- package/test/grammar/fixtures/attributes.astro +14 -0
- package/test/grammar/fixtures/attributes.astro.snap +102 -0
- package/test/grammar/fixtures/components/component.astro +3 -0
- package/test/grammar/fixtures/components/component.astro.snap +17 -0
- package/test/grammar/fixtures/constant-entities.astro +7 -0
- package/test/grammar/fixtures/constant-entities.astro.snap +80 -0
- package/test/grammar/fixtures/raw/israw.astro +15 -0
- package/test/grammar/fixtures/raw/israw.astro.snap +68 -0
- package/test/grammar/fixtures/script/events.astro +3 -0
- package/test/grammar/fixtures/script/events.astro.snap +30 -0
- package/test/grammar/fixtures/script/israw.astro +3 -0
- package/test/grammar/fixtures/script/israw.astro.snap +13 -0
- package/test/grammar/fixtures/script/json.astro +14 -0
- package/test/grammar/fixtures/script/json.astro.snap +39 -0
- package/test/grammar/fixtures/script/jstypes.astro +15 -0
- package/test/grammar/fixtures/script/jstypes.astro.snap +68 -0
- package/test/grammar/fixtures/script/module.astro +3 -0
- package/test/grammar/fixtures/script/module.astro.snap +17 -0
- package/test/grammar/fixtures/script/script.astro +3 -0
- package/test/grammar/fixtures/script/script.astro.snap +11 -0
- package/test/grammar/fixtures/script/unknowntype.astro +3 -0
- package/test/grammar/fixtures/script/unknowntype.astro.snap +17 -0
- package/test/grammar/fixtures/style/israw.astro +5 -0
- package/test/grammar/fixtures/style/israw.astro.snap +17 -0
- package/test/grammar/fixtures/style/less.astro +9 -0
- package/test/grammar/fixtures/style/less.astro.snap +28 -0
- package/test/grammar/fixtures/style/sass.astro +8 -0
- package/test/grammar/fixtures/style/sass.astro.snap +26 -0
- package/test/grammar/fixtures/style/scss.astro +9 -0
- package/test/grammar/fixtures/style/scss.astro.snap +28 -0
- package/test/grammar/fixtures/style/style.astro +3 -0
- package/test/grammar/fixtures/style/style.astro.snap +11 -0
- package/test/grammar/fixtures/style/stylus.astro +9 -0
- package/test/grammar/fixtures/style/stylus.astro.snap +38 -0
- package/test/grammar/fixtures/text.astro +15 -0
- package/test/grammar/fixtures/text.astro.snap +58 -0
- package/test/grammar/test.mjs +59 -0
- package/test/runTest.js +27 -0
- package/test/suite/extension.test.js +15 -0
- package/test/suite/index.js +40 -0
- package/test/tsconfig.json +14 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
>---
|
|
2
|
+
#^^^ source.astro comment
|
|
3
|
+
>const cool = "our frontmatter"
|
|
4
|
+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.astro source.ts
|
|
5
|
+
>console.log("Hello, World!")
|
|
6
|
+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.astro source.ts
|
|
7
|
+
>console.log(`This is ${cool}!`)
|
|
8
|
+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.astro source.ts
|
|
9
|
+
>---
|
|
10
|
+
#^^^ source.astro comment
|
|
11
|
+
>
|
|
12
|
+
>This is some text<div>
|
|
13
|
+
#^^^^^^^^^^^^^^^^^ source.astro text.astro
|
|
14
|
+
# ^ source.astro meta.scope.tag.div.astro meta.tag.start.astro punctuation.definition.tag.begin.astro
|
|
15
|
+
# ^^^ source.astro meta.scope.tag.div.astro meta.tag.start.astro entity.name.tag.astro
|
|
16
|
+
# ^ source.astro meta.scope.tag.div.astro meta.tag.start.astro punctuation.definition.tag.end.astro
|
|
17
|
+
> <p>
|
|
18
|
+
#^^ source.astro text.astro
|
|
19
|
+
# ^ source.astro meta.scope.tag.p.astro meta.tag.start.astro punctuation.definition.tag.begin.astro
|
|
20
|
+
# ^ source.astro meta.scope.tag.p.astro meta.tag.start.astro entity.name.tag.astro
|
|
21
|
+
# ^ source.astro meta.scope.tag.p.astro meta.tag.start.astro punctuation.definition.tag.end.astro
|
|
22
|
+
> Some text in HTML tags
|
|
23
|
+
#^^^^^^^^^^^^^^^^^^^^^^^^^^ source.astro text.astro
|
|
24
|
+
> <strong> and some text in nested tags </strong>
|
|
25
|
+
#^^^^ source.astro text.astro
|
|
26
|
+
# ^ source.astro meta.scope.tag.strong.astro meta.tag.start.astro punctuation.definition.tag.begin.astro
|
|
27
|
+
# ^^^^^^ source.astro meta.scope.tag.strong.astro meta.tag.start.astro entity.name.tag.astro
|
|
28
|
+
# ^ source.astro meta.scope.tag.strong.astro meta.tag.start.astro punctuation.definition.tag.end.astro
|
|
29
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.astro text.astro
|
|
30
|
+
# ^^ source.astro meta.scope.tag.strong.astro meta.tag.end.astro punctuation.definition.tag.begin.astro
|
|
31
|
+
# ^^^^^^ source.astro meta.scope.tag.strong.astro meta.tag.end.astro entity.name.tag.astro
|
|
32
|
+
# ^ source.astro meta.scope.tag.strong.astro meta.tag.end.astro punctuation.definition.tag.end.astro
|
|
33
|
+
> </p>
|
|
34
|
+
#^^ source.astro text.astro
|
|
35
|
+
# ^^ source.astro meta.scope.tag.p.astro meta.tag.end.astro punctuation.definition.tag.begin.astro
|
|
36
|
+
# ^ source.astro meta.scope.tag.p.astro meta.tag.end.astro entity.name.tag.astro
|
|
37
|
+
# ^ source.astro meta.scope.tag.p.astro meta.tag.end.astro punctuation.definition.tag.end.astro
|
|
38
|
+
> Watch this html entity!
|
|
39
|
+
#^^^^^^^^^^^^^ source.astro text.astro
|
|
40
|
+
# ^ source.astro text.astro constant.character.entity.named.nbsp.astro punctuation.definition.entity.astro
|
|
41
|
+
# ^^^^ source.astro text.astro constant.character.entity.named.nbsp.astro
|
|
42
|
+
# ^ source.astro text.astro constant.character.entity.named.nbsp.astro punctuation.definition.entity.astro
|
|
43
|
+
# ^^^^^^^^^^^^^ source.astro text.astro
|
|
44
|
+
> {true && <p>Some more text in expression</p>}
|
|
45
|
+
#^^ source.astro text.astro
|
|
46
|
+
# ^ source.astro punctuation.section.embedded.begin.astro
|
|
47
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.astro meta.embedded.expression.astro source.tsx
|
|
48
|
+
# ^ source.astro punctuation.section.embedded.end.astro
|
|
49
|
+
> <!-- Wow, we even have an HTML comment -->
|
|
50
|
+
#^^ source.astro text.astro
|
|
51
|
+
# ^^^^ source.astro comment.block.astro punctuation.definition.comment.astro
|
|
52
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.astro comment.block.astro
|
|
53
|
+
# ^^^ source.astro comment.block.astro punctuation.definition.comment.astro
|
|
54
|
+
></div>This is the final text
|
|
55
|
+
#^^ source.astro meta.scope.tag.div.astro meta.tag.end.astro punctuation.definition.tag.begin.astro
|
|
56
|
+
# ^^^ source.astro meta.scope.tag.div.astro meta.tag.end.astro entity.name.tag.astro
|
|
57
|
+
# ^ source.astro meta.scope.tag.div.astro meta.tag.end.astro punctuation.definition.tag.end.astro
|
|
58
|
+
# ^^^^^^^^^^^^^^^^^^^^^^ source.astro text.astro
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import { readdirSync } from 'fs';
|
|
3
|
+
import { dirname, join, resolve } from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
|
|
8
|
+
const dummyGrammarDir = resolve(__dirname, './dummy');
|
|
9
|
+
const dummyGrammars = readdirSync(dummyGrammarDir).map((file) => join(dummyGrammarDir, file));
|
|
10
|
+
|
|
11
|
+
const grammarDir = resolve(__dirname, '../../syntaxes');
|
|
12
|
+
const grammars = readdirSync(grammarDir)
|
|
13
|
+
.filter((file) => file.endsWith('.json'))
|
|
14
|
+
.map((file) => join(grammarDir, file));
|
|
15
|
+
|
|
16
|
+
const allGrammars = [...grammars, ...dummyGrammars];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {Parameters<typeof spawn>} arg
|
|
20
|
+
* @returns {Promise<number | null>}
|
|
21
|
+
*/
|
|
22
|
+
function promisifySpawn(...arg) {
|
|
23
|
+
const childProcess = spawn(...arg);
|
|
24
|
+
return new Promise((cb) => {
|
|
25
|
+
childProcess.on('exit', (code) => {
|
|
26
|
+
cb(code);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
childProcess.on('error', (err) => {
|
|
30
|
+
console.error(err);
|
|
31
|
+
cb(1);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function snapShotTest() {
|
|
37
|
+
const extraArgs = process.argv.slice(2);
|
|
38
|
+
const isWindows = process.platform === 'win32';
|
|
39
|
+
|
|
40
|
+
const args = [
|
|
41
|
+
'vscode-tmgrammar-snap',
|
|
42
|
+
'-s',
|
|
43
|
+
'source.astro',
|
|
44
|
+
'./test/grammar/fixtures/**/*.astro',
|
|
45
|
+
...allGrammars.reduce((/** @type string[] */ previous, path) => [...previous, '-g', path], []),
|
|
46
|
+
...extraArgs,
|
|
47
|
+
].map((arg) => (isWindows && arg.includes(' ') ? `"${arg}"` : arg));
|
|
48
|
+
|
|
49
|
+
const code = await promisifySpawn(isWindows ? 'pnpm.cmd' : 'pnpm', args, {
|
|
50
|
+
stdio: 'inherit',
|
|
51
|
+
shell: isWindows,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (code && code > 0) {
|
|
55
|
+
process.exit(code);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
snapShotTest();
|
package/test/runTest.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { runTests } = require('@vscode/test-electron');
|
|
3
|
+
|
|
4
|
+
async function main() {
|
|
5
|
+
// NOTE: Those tests are very flaky on Windows and macOS, so we'll skip them for now
|
|
6
|
+
if (process.platform === 'win32' || process.platform === 'darwin') {
|
|
7
|
+
process.exit(0);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
// The folder containing the Extension Manifest package.json
|
|
12
|
+
// Passed to `--extensionDevelopmentPath`
|
|
13
|
+
const extensionDevelopmentPath = path.resolve(__dirname, '../');
|
|
14
|
+
|
|
15
|
+
// The path to the extension test script
|
|
16
|
+
// Passed to --extensionTestsPath
|
|
17
|
+
const extensionTestsPath = path.resolve(__dirname, './suite/index.js');
|
|
18
|
+
|
|
19
|
+
// Download VS Code, unzip it and run the integration test
|
|
20
|
+
await runTests({ extensionDevelopmentPath, extensionTestsPath });
|
|
21
|
+
} catch {
|
|
22
|
+
console.error('Failed to run tests');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const vscode = require('vscode');
|
|
3
|
+
|
|
4
|
+
suite('Extension Test Suite', () => {
|
|
5
|
+
vscode.window.showInformationMessage('Start all tests.');
|
|
6
|
+
|
|
7
|
+
test('can activate the extension', async function () {
|
|
8
|
+
// This can be slow in CI.
|
|
9
|
+
this.timeout(10000);
|
|
10
|
+
const ext = vscode.extensions.getExtension('astro-build.astro-vscode');
|
|
11
|
+
const activate = await ext?.activate();
|
|
12
|
+
|
|
13
|
+
assert.notStrictEqual(activate, undefined);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const Mocha = require('mocha');
|
|
3
|
+
const glob = require('glob');
|
|
4
|
+
|
|
5
|
+
exports.run = function () {
|
|
6
|
+
// Create the mocha test
|
|
7
|
+
const mocha = new Mocha({
|
|
8
|
+
ui: 'tdd',
|
|
9
|
+
color: true,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const testsRoot = path.resolve(__dirname, '..');
|
|
13
|
+
|
|
14
|
+
return /** @type {Promise<void>} */ (
|
|
15
|
+
new Promise((c, e) => {
|
|
16
|
+
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
|
|
17
|
+
if (err) {
|
|
18
|
+
return e(err);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Add files to the test suite
|
|
22
|
+
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
// Run the mocha test
|
|
26
|
+
mocha.run((failures) => {
|
|
27
|
+
if (failures > 0) {
|
|
28
|
+
e(new Error(`${failures} tests failed.`));
|
|
29
|
+
} else {
|
|
30
|
+
c();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
34
|
+
} catch (err) {
|
|
35
|
+
e(err);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "ES2020",
|
|
5
|
+
"target": "ES2020",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
"checkJs": true,
|
|
9
|
+
"rootDir": ".",
|
|
10
|
+
"emitDeclarationOnly": false,
|
|
11
|
+
"noEmit": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["**/*.js", "grammar/test.mjs"]
|
|
14
|
+
}
|