@atcute/lex-cli 2.6.1 → 2.8.0
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/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +38 -4
- package/dist/codegen.js.map +1 -1
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +6 -2
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +60 -27
- package/dist/commands/generate.js.map +1 -1
- package/dist/config.d.ts +30 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +56 -12
- package/dist/config.js.map +1 -1
- package/dist/lsp-client.d.ts.map +1 -1
- package/dist/lsp-client.js +10 -1
- package/dist/lsp-client.js.map +1 -1
- package/dist/pull-sources/git.d.ts.map +1 -1
- package/dist/pull-sources/git.js +61 -58
- package/dist/pull-sources/git.js.map +1 -1
- package/package.json +6 -6
- package/src/codegen.ts +48 -4
- package/src/commands/export.ts +7 -2
- package/src/commands/generate.ts +71 -29
- package/src/config.ts +77 -23
- package/src/lsp-client.ts +10 -1
- package/src/pull-sources/git.ts +64 -63
package/src/lsp-client.ts
CHANGED
|
@@ -112,6 +112,9 @@ export const createLspClient = async (command: string, root: string): Promise<Ls
|
|
|
112
112
|
// are handled by the close/error handlers below
|
|
113
113
|
child.stdin.on('error', () => {});
|
|
114
114
|
|
|
115
|
+
// drain stderr so a chatty server doesn't block on a full pipe buffer
|
|
116
|
+
child.stderr.resume();
|
|
117
|
+
|
|
115
118
|
// #region JSON-RPC framing
|
|
116
119
|
|
|
117
120
|
const pending = new Map<number, PromiseWithResolvers<unknown>>();
|
|
@@ -188,7 +191,6 @@ export const createLspClient = async (command: string, root: string): Promise<Ls
|
|
|
188
191
|
continue;
|
|
189
192
|
}
|
|
190
193
|
|
|
191
|
-
// dispatch responses to pending requests, ignore everything else
|
|
192
194
|
if (message.id != null) {
|
|
193
195
|
const entry = pending.get(message.id);
|
|
194
196
|
if (entry) {
|
|
@@ -199,6 +201,13 @@ export const createLspClient = async (command: string, root: string): Promise<Ls
|
|
|
199
201
|
} else {
|
|
200
202
|
entry.resolve(message.result);
|
|
201
203
|
}
|
|
204
|
+
} else if (message.method != null) {
|
|
205
|
+
// server-initiated request — reply with MethodNotFound so it doesn't hang
|
|
206
|
+
sendMessage({
|
|
207
|
+
jsonrpc: '2.0',
|
|
208
|
+
id: message.id,
|
|
209
|
+
error: { code: -32601, message: `method not found` },
|
|
210
|
+
});
|
|
202
211
|
}
|
|
203
212
|
}
|
|
204
213
|
}
|
package/src/pull-sources/git.ts
CHANGED
|
@@ -26,80 +26,81 @@ export const pullGitSource = async (
|
|
|
26
26
|
const cloneDir = path.join(tempParent, 'repo');
|
|
27
27
|
|
|
28
28
|
try {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
try {
|
|
30
|
+
await runGit(
|
|
31
|
+
[
|
|
32
|
+
'clone',
|
|
33
|
+
'--filter=blob:none',
|
|
34
|
+
'--depth',
|
|
35
|
+
'1',
|
|
36
|
+
'--sparse',
|
|
37
|
+
...(source.ref ? ['--branch', source.ref, '--single-branch'] : []),
|
|
38
|
+
source.remote,
|
|
39
|
+
cloneDir,
|
|
40
|
+
],
|
|
41
|
+
{ timeoutMs: 60_000 },
|
|
42
|
+
);
|
|
43
|
+
} catch (err) {
|
|
44
|
+
if (err instanceof GitError) {
|
|
45
|
+
console.error(pc.bold(pc.red(`git clone failed for ${source.remote}:`)));
|
|
46
|
+
console.error(err.stderr || err.message);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
throw err;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
try {
|
|
54
|
+
await runGit(['-C', cloneDir, 'sparse-checkout', 'set', '--no-cone', ...source.pattern], {
|
|
55
|
+
timeoutMs: 30_000,
|
|
56
|
+
});
|
|
57
|
+
} catch (err) {
|
|
58
|
+
if (err instanceof GitError) {
|
|
59
|
+
console.error(pc.bold(pc.red(`git sparse-checkout failed for ${source.remote}:`)));
|
|
60
|
+
console.error(err.stderr || err.message);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
throw err;
|
|
61
65
|
}
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const pulled = new Map<string, PulledLexicon>();
|
|
67
|
+
const pulled = new Map<string, PulledLexicon>();
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
for await (const filename of fs.glob(source.pattern, { cwd: cloneDir })) {
|
|
70
|
+
const absolute = path.join(cloneDir, filename);
|
|
71
|
+
const stat = await fs.stat(absolute);
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
if (!stat.isFile()) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
const location: SourceLocation = {
|
|
78
|
+
absolutePath: absolute,
|
|
79
|
+
relativePath: filename,
|
|
80
|
+
sourceDescription: source.remote,
|
|
81
|
+
};
|
|
81
82
|
|
|
82
|
-
|
|
83
|
+
const doc = await parseLexiconFile(location);
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
pulled.set(doc.id, { nsid: doc.id, doc, location });
|
|
86
|
+
}
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
let rev: string;
|
|
89
|
+
try {
|
|
90
|
+
const result = await runGit(['-C', cloneDir, 'rev-parse', 'HEAD'], { timeoutMs: 10_000 });
|
|
91
|
+
rev = result.stdout.trim();
|
|
92
|
+
} catch (err) {
|
|
93
|
+
if (err instanceof GitError) {
|
|
94
|
+
console.error(pc.bold(pc.red(`git rev-parse failed for ${source.remote}:`)));
|
|
95
|
+
console.error(err.stderr || err.message);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
throw err;
|
|
97
100
|
}
|
|
98
101
|
|
|
99
|
-
|
|
102
|
+
return { pulled, rev };
|
|
103
|
+
} finally {
|
|
104
|
+
await fs.rm(tempParent, { recursive: true, force: true });
|
|
100
105
|
}
|
|
101
|
-
|
|
102
|
-
await fs.rm(tempParent, { recursive: true, force: true });
|
|
103
|
-
|
|
104
|
-
return { pulled, rev };
|
|
105
106
|
};
|