@azerothjs/language-server 0.4.0-beta.1 → 0.4.0-beta.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/README.md +17 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/tsc-cli.d.ts +3 -0
- package/dist/tsc-cli.d.ts.map +1 -0
- package/dist/tsc-cli.js +9 -0
- package/dist/tsc-cli.js.map +1 -0
- package/dist/tsc.d.ts +31 -0
- package/dist/tsc.d.ts.map +1 -0
- package/dist/tsc.js +81 -0
- package/dist/tsc.js.map +1 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -35,7 +35,23 @@ back any other host without this package.
|
|
|
35
35
|
| --- | --- |
|
|
36
36
|
| `server.ts` | LSP wiring: connection, capabilities, document sync, settings, and one handler per request. |
|
|
37
37
|
| `cli.ts` | Executable entry point (`azeroth-language-server`); starts the server over stdio. |
|
|
38
|
-
| `
|
|
38
|
+
| `tsc.ts` | `runTsc`: the batch type-checker behind the `azeroth-tsc` binary. |
|
|
39
|
+
| `tsc-cli.ts` | Executable entry point (`azeroth-tsc`); runs one check and sets the exit code. |
|
|
40
|
+
| `index.ts` | Library entry point; exports `startServer` and `runTsc`. |
|
|
41
|
+
|
|
42
|
+
### `azeroth-tsc` (command-line type checking)
|
|
43
|
+
|
|
44
|
+
`tsc` cannot parse `.azeroth`, so this package ships `azeroth-tsc`, the `vue-tsc`
|
|
45
|
+
equivalent. It reuses the language service to compile each `.azeroth` file to its
|
|
46
|
+
virtual TypeScript module, type-check it against the project's tsconfig, and print
|
|
47
|
+
`tsc`-style diagnostics mapped back to the original `.azeroth` positions, exiting
|
|
48
|
+
non-zero on the first error. It is a `--noEmit` gate (the Vite plugin / compiler
|
|
49
|
+
owns code emit), meant to run in CI and pre-commit beside `tsc`:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
npx azeroth-tsc # check every .azeroth file under the cwd
|
|
53
|
+
npx azeroth-tsc -p tsconfig.json
|
|
54
|
+
```
|
|
39
55
|
|
|
40
56
|
### Settings
|
|
41
57
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
// re-exports it so the server can also be embedded (e.g. in a web worker host
|
|
6
6
|
// or an integration test that drives it through an in-memory connection).
|
|
7
7
|
export { startServer } from "./server.js";
|
|
8
|
+
export { runTsc, parseArgs } from "./tsc.js";
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,EAAE;AACF,4EAA4E;AAC5E,gFAAgF;AAChF,8EAA8E;AAC9E,0EAA0E;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,EAAE;AACF,4EAA4E;AAC5E,gFAAgF;AAChF,8EAA8E;AAC9E,0EAA0E;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAmC,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsc-cli.d.ts","sourceRoot":"","sources":["../src/tsc-cli.ts"],"names":[],"mappings":""}
|
package/dist/tsc-cli.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Binary entry point for `azeroth-tsc`. Runs one batch type-check and exits
|
|
3
|
+
// non-zero when any `.azeroth` file has an error, so it drops into CI and
|
|
4
|
+
// pre-commit the same way `tsc --noEmit` does. All behaviour lives in the
|
|
5
|
+
// testable `runTsc`.
|
|
6
|
+
import { runTsc, parseArgs } from "./tsc.js";
|
|
7
|
+
const { errorCount } = runTsc(parseArgs(process.argv.slice(2)));
|
|
8
|
+
process.exit(errorCount > 0 ? 1 : 0);
|
|
9
|
+
//# sourceMappingURL=tsc-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsc-cli.js","sourceRoot":"","sources":["../src/tsc-cli.ts"],"names":[],"mappings":";AACA,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,qBAAqB;AAErB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,OAAO,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/tsc.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Options controlling a single check run. */
|
|
2
|
+
export interface TscOptions {
|
|
3
|
+
/** Directory to search for `.azeroth` files (default: cwd). */
|
|
4
|
+
cwd?: string;
|
|
5
|
+
/** Explicit tsconfig path; otherwise the nearest one is used. */
|
|
6
|
+
project?: string;
|
|
7
|
+
/** Sink for formatted output (default: stdout). */
|
|
8
|
+
write?: (text: string) => void;
|
|
9
|
+
}
|
|
10
|
+
/** Outcome of a check run. */
|
|
11
|
+
export interface TscResult {
|
|
12
|
+
/** Number of `.azeroth` files checked. */
|
|
13
|
+
fileCount: number;
|
|
14
|
+
/** Number of error-severity diagnostics found. */
|
|
15
|
+
errorCount: number;
|
|
16
|
+
}
|
|
17
|
+
/** Parses the argv subset this CLI understands into {@link TscOptions}. */
|
|
18
|
+
export declare function parseArgs(argv: string[]): TscOptions;
|
|
19
|
+
/**
|
|
20
|
+
* Type-checks every `.azeroth` file under `cwd` against the project's tsconfig,
|
|
21
|
+
* printing `tsc`-style diagnostics. Returns the file/error counts; the caller
|
|
22
|
+
* decides the process exit code.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const { errorCount } = runTsc({ cwd: 'app' });
|
|
27
|
+
* process.exit(errorCount > 0 ? 1 : 0);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function runTsc(options?: TscOptions): TscResult;
|
|
31
|
+
//# sourceMappingURL=tsc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsc.d.ts","sourceRoot":"","sources":["../src/tsc.ts"],"names":[],"mappings":"AAcA,8CAA8C;AAC9C,MAAM,WAAW,UAAU;IAEvB,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,mDAAmD;IACnD,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,8BAA8B;AAC9B,MAAM,WAAW,SAAS;IAEtB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAElB,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAoBpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,OAAO,GAAE,UAAe,GAAG,SAAS,CAiD1D"}
|
package/dist/tsc.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// azeroth-tsc: a batch type-checker for `.azeroth` files, the vue-tsc
|
|
2
|
+
// equivalent for this framework. `tsc` itself cannot parse `.azeroth` markup,
|
|
3
|
+
// so this driver reuses the language service (which compiles each file to a
|
|
4
|
+
// virtual TypeScript module and maps diagnostics back to original positions)
|
|
5
|
+
// and prints them in the familiar `tsc` format. It is meant to run in CI and
|
|
6
|
+
// pre-commit, alongside `tsc` for the surrounding `.ts`.
|
|
7
|
+
//
|
|
8
|
+
// Scope: this reports type errors in `.azeroth` files. It does not emit `.js`
|
|
9
|
+
// (the Vite plugin / compiler does that) - like `tsc --noEmit`, it is a gate.
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import ts from 'typescript';
|
|
12
|
+
import { AzerothLanguageService, pathToUri, DiagnosticSeverity } from '@azerothjs/language-service';
|
|
13
|
+
/** Parses the argv subset this CLI understands into {@link TscOptions}. */
|
|
14
|
+
export function parseArgs(argv) {
|
|
15
|
+
const options = {};
|
|
16
|
+
for (let i = 0; i < argv.length; i++) {
|
|
17
|
+
const arg = argv[i];
|
|
18
|
+
if (arg === '--project' || arg === '-p') {
|
|
19
|
+
options.project = argv[++i];
|
|
20
|
+
}
|
|
21
|
+
else if (arg.startsWith('--project=')) {
|
|
22
|
+
options.project = arg.slice('--project='.length);
|
|
23
|
+
}
|
|
24
|
+
else if (!arg.startsWith('-')) {
|
|
25
|
+
options.cwd = arg;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return options;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Type-checks every `.azeroth` file under `cwd` against the project's tsconfig,
|
|
32
|
+
* printing `tsc`-style diagnostics. Returns the file/error counts; the caller
|
|
33
|
+
* decides the process exit code.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const { errorCount } = runTsc({ cwd: 'app' });
|
|
38
|
+
* process.exit(errorCount > 0 ? 1 : 0);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function runTsc(options = {}) {
|
|
42
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
43
|
+
const write = options.write ?? ((text) => {
|
|
44
|
+
process.stdout.write(text);
|
|
45
|
+
});
|
|
46
|
+
const files = ts.sys.readDirectory(cwd, ['.azeroth'], ['**/node_modules/**', '**/dist/**', '**/.git/**'], ['**/*.azeroth']);
|
|
47
|
+
const service = new AzerothLanguageService(cwd, options.project);
|
|
48
|
+
let errorCount = 0;
|
|
49
|
+
for (const file of files) {
|
|
50
|
+
const source = ts.sys.readFile(file);
|
|
51
|
+
if (source === undefined) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const uri = pathToUri(file);
|
|
55
|
+
service.didOpen(uri, source);
|
|
56
|
+
for (const diag of service.getDiagnostics(uri)) {
|
|
57
|
+
const isError = diag.severity === DiagnosticSeverity.Error;
|
|
58
|
+
if (isError) {
|
|
59
|
+
errorCount++;
|
|
60
|
+
}
|
|
61
|
+
write(formatDiagnostic(cwd, file, diag, isError) + '\n');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (errorCount === 0) {
|
|
65
|
+
write(`Checked ${files.length} .azeroth file(s); no type errors.\n`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
write(`\nFound ${errorCount} error(s) in ${files.length} .azeroth file(s).\n`);
|
|
69
|
+
}
|
|
70
|
+
return { fileCount: files.length, errorCount };
|
|
71
|
+
}
|
|
72
|
+
/** Formats one diagnostic in `tsc`'s `file(line,col): error TSxxxx: msg` shape. */
|
|
73
|
+
function formatDiagnostic(cwd, file, diag, isError) {
|
|
74
|
+
const rel = path.relative(cwd, file).replace(/\\/g, '/');
|
|
75
|
+
const line = diag.range.start.line + 1;
|
|
76
|
+
const column = diag.range.start.character + 1;
|
|
77
|
+
const severity = isError ? 'error' : 'warning';
|
|
78
|
+
const code = typeof diag.code === 'number' ? ` TS${diag.code}` : '';
|
|
79
|
+
return `${rel}(${line},${column}): ${severity}${code}: ${diag.message}`;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=tsc.js.map
|
package/dist/tsc.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsc.js","sourceRoot":"","sources":["../src/tsc.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,8EAA8E;AAC9E,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,yDAAyD;AACzD,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAE9E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAyBpG,2EAA2E;AAC3E,MAAM,UAAU,SAAS,CAAC,IAAc;IAEpC,MAAM,OAAO,GAAe,EAAE,CAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EACpC,CAAC;QACG,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,IAAI,EACvC,CAAC;YACG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAChC,CAAC;aACI,IAAI,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,EACrC,CAAC;YACG,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACrD,CAA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AAC;AACxF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azerothjs/language-server",
|
|
3
|
-
"version": "0.4.0-beta.
|
|
3
|
+
"version": "0.4.0-beta.2",
|
|
4
4
|
"description": "AzerothJS language server — a Language Server Protocol front-end for .azeroth files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"bin":
|
|
10
10
|
{
|
|
11
|
-
"azeroth-language-server": "./dist/cli.js"
|
|
11
|
+
"azeroth-language-server": "./dist/cli.js",
|
|
12
|
+
"azeroth-tsc": "./dist/tsc-cli.js"
|
|
12
13
|
},
|
|
13
14
|
"exports":
|
|
14
15
|
{
|
|
@@ -18,7 +19,8 @@
|
|
|
18
19
|
"import": "./dist/index.js",
|
|
19
20
|
"default": "./dist/index.js"
|
|
20
21
|
},
|
|
21
|
-
"./cli": "./dist/cli.js"
|
|
22
|
+
"./cli": "./dist/cli.js",
|
|
23
|
+
"./tsc": "./dist/tsc.js"
|
|
22
24
|
},
|
|
23
25
|
"files":
|
|
24
26
|
[
|
|
@@ -26,7 +28,7 @@
|
|
|
26
28
|
],
|
|
27
29
|
"dependencies":
|
|
28
30
|
{
|
|
29
|
-
"@azerothjs/language-service": "0.4.0-beta.
|
|
31
|
+
"@azerothjs/language-service": "0.4.0-beta.2",
|
|
30
32
|
"typescript": ">=5",
|
|
31
33
|
"vscode-languageserver": "^9",
|
|
32
34
|
"vscode-languageserver-textdocument": "^1"
|