@mudah-cli/mudah 0.7.0 → 0.9.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/LICENSE +21 -0
- package/README.md +70 -0
- package/dist/autocomplete.d.ts +8 -0
- package/dist/autocomplete.js +38 -0
- package/dist/autocomplete.js.map +1 -0
- package/dist/built-ins.d.ts +9 -0
- package/dist/built-ins.js +144 -0
- package/dist/built-ins.js.map +1 -0
- package/dist/commands/autocomplete.command.d.ts +11 -0
- package/dist/commands/autocomplete.command.js +16 -0
- package/dist/commands/autocomplete.command.js.map +1 -0
- package/dist/commands/build.command.d.ts +1 -0
- package/dist/commands/build.command.js +2 -1
- package/dist/commands/build.command.js.map +1 -1
- package/dist/commands/cache.command.d.ts +11 -0
- package/dist/commands/cache.command.js +47 -0
- package/dist/commands/cache.command.js.map +1 -0
- package/dist/commands/complete.command.d.ts +13 -0
- package/dist/commands/complete.command.js +23 -0
- package/dist/commands/complete.command.js.map +1 -0
- package/dist/commands/config.diff.command.d.ts +8 -0
- package/dist/commands/config.diff.command.js +96 -0
- package/dist/commands/config.diff.command.js.map +1 -0
- package/dist/commands/config.set.command.d.ts +8 -0
- package/dist/commands/config.set.command.js +66 -0
- package/dist/commands/config.set.command.js.map +1 -0
- package/dist/commands/config.show.command.d.ts +8 -0
- package/dist/commands/config.show.command.js +38 -0
- package/dist/commands/config.show.command.js.map +1 -0
- package/dist/commands/config.source.command.d.ts +8 -0
- package/dist/commands/config.source.command.js +42 -0
- package/dist/commands/config.source.command.js.map +1 -0
- package/dist/commands/config.validate.command.d.ts +14 -0
- package/dist/commands/config.validate.command.js +63 -0
- package/dist/commands/config.validate.command.js.map +1 -0
- package/dist/commands/dev.command.d.ts +1 -0
- package/dist/commands/dev.command.js +1 -0
- package/dist/commands/dev.command.js.map +1 -1
- package/dist/commands/docs.widgets.command.d.ts +11 -0
- package/dist/commands/docs.widgets.command.js +17 -0
- package/dist/commands/docs.widgets.command.js.map +1 -0
- package/dist/commands/doctor.command.d.ts +1 -0
- package/dist/commands/doctor.command.js +36 -6
- package/dist/commands/doctor.command.js.map +1 -1
- package/dist/commands/graph.command.d.ts +10 -0
- package/dist/commands/graph.command.js +21 -0
- package/dist/commands/graph.command.js.map +1 -0
- package/dist/commands/help.command.d.ts +1 -0
- package/dist/commands/help.command.js +2 -2
- package/dist/commands/help.command.js.map +1 -1
- package/dist/commands/info.command.d.ts +8 -0
- package/dist/commands/info.command.js +61 -0
- package/dist/commands/info.command.js.map +1 -0
- package/dist/commands/lsp.command.d.ts +12 -0
- package/dist/commands/lsp.command.js +57 -0
- package/dist/commands/lsp.command.js.map +1 -0
- package/dist/commands/make.command.d.ts +2 -0
- package/dist/commands/make.command.js +75 -4
- package/dist/commands/make.command.js.map +1 -1
- package/dist/commands/plugins.list.command.d.ts +12 -0
- package/dist/commands/plugins.list.command.js +29 -0
- package/dist/commands/plugins.list.command.js.map +1 -0
- package/dist/commands/plugins.update.command.d.ts +29 -0
- package/dist/commands/plugins.update.command.js +78 -0
- package/dist/commands/plugins.update.command.js.map +1 -0
- package/dist/commands/plugins.watch.command.d.ts +10 -0
- package/dist/commands/plugins.watch.command.js +37 -0
- package/dist/commands/plugins.watch.command.js.map +1 -0
- package/dist/commands/replay.command.d.ts +10 -0
- package/dist/commands/replay.command.js +50 -0
- package/dist/commands/replay.command.js.map +1 -0
- package/dist/commands/storybook.command.d.ts +11 -0
- package/dist/commands/storybook.command.js +84 -0
- package/dist/commands/storybook.command.js.map +1 -0
- package/dist/commands/telemetry.command.d.ts +12 -0
- package/dist/commands/telemetry.command.js +55 -0
- package/dist/commands/telemetry.command.js.map +1 -0
- package/dist/commands/test.command.d.ts +13 -0
- package/dist/commands/test.command.js +83 -0
- package/dist/commands/test.command.js.map +1 -0
- package/dist/commands/tutorial.command.d.ts +12 -0
- package/dist/commands/tutorial.command.js +57 -0
- package/dist/commands/tutorial.command.js.map +1 -0
- package/dist/commands/version.command.d.ts +1 -0
- package/dist/commands/version.command.js +1 -0
- package/dist/commands/version.command.js.map +1 -1
- package/dist/commands/watch.command.d.ts +13 -0
- package/dist/commands/watch.command.js +62 -0
- package/dist/commands/watch.command.js.map +1 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/lsp.d.ts +147 -0
- package/dist/lsp.js +497 -0
- package/dist/lsp.js.map +1 -0
- package/dist/run.d.ts +4 -2
- package/dist/run.js +372 -37
- package/dist/run.js.map +1 -1
- package/dist/watcher.d.ts +20 -1
- package/dist/watcher.js +41 -4
- package/dist/watcher.js.map +1 -1
- package/package.json +27 -10
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { Command } from '@mudah-cli/console';
|
|
4
|
+
import { clearTelemetryLog, readTelemetryLog, TELEMETRY_FILE, t } from '@mudah-cli/core';
|
|
5
|
+
/**
|
|
6
|
+
* Built-in `telemetry` — summarize the events written to
|
|
7
|
+
* `.mudah/telemetry.jsonl` (see `telemetry: true` in `mudah.json`), or clear
|
|
8
|
+
* the log. Under `--json` the summary is emitted as a data payload.
|
|
9
|
+
*/
|
|
10
|
+
export default class TelemetryCommand extends Command {
|
|
11
|
+
signature = 'telemetry [--clear]';
|
|
12
|
+
description = 'Summarize or clear the local telemetry log';
|
|
13
|
+
descriptionKey = 'cmd.telemetry.description';
|
|
14
|
+
async handle() {
|
|
15
|
+
const file = join(this.app.basePath, TELEMETRY_FILE);
|
|
16
|
+
if (this.option('clear') === true) {
|
|
17
|
+
const removed = clearTelemetryLog(file);
|
|
18
|
+
this.output.success(removed ? `Cleared ${file}` : t('telemetry.empty'));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (!existsSync(file)) {
|
|
22
|
+
this.output.info(t('telemetry.absent'));
|
|
23
|
+
this.output.hint('Set "telemetry": true in mudah.json (or MUDAH_TELEMETRY=1) and run a command.');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const summary = readTelemetryLog(file);
|
|
27
|
+
if (this.output.isMachineReadable) {
|
|
28
|
+
this.output.emit('data', 'telemetry', summary);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (summary.events === 0) {
|
|
32
|
+
this.output.info(t('telemetry.empty'));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
this.output.section('Telemetry');
|
|
36
|
+
this.output.keyValue('file', file);
|
|
37
|
+
this.output.keyValue('events', String(summary.events));
|
|
38
|
+
this.output.keyValue('span', `${summary.spanMs}ms`);
|
|
39
|
+
this.output.line();
|
|
40
|
+
this.output.table([
|
|
41
|
+
{ header: 'name', align: 'left' },
|
|
42
|
+
{ header: 'count', align: 'right' },
|
|
43
|
+
{ header: 'total', align: 'right' },
|
|
44
|
+
{ header: 'max', align: 'right' },
|
|
45
|
+
{ header: 'mean', align: 'right' },
|
|
46
|
+
], summary.rows.map((row) => [
|
|
47
|
+
row.name,
|
|
48
|
+
String(row.count),
|
|
49
|
+
`${row.totalMs}ms`,
|
|
50
|
+
`${row.maxMs}ms`,
|
|
51
|
+
`${row.meanMs}ms`,
|
|
52
|
+
]));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=telemetry.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.command.js","sourceRoot":"","sources":["../../src/commands/telemetry.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAEzF;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,OAAO;IACnD,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C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACvD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,KAAK,CACf;YACE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;YACjC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YACnC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YACnC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;YACjC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;SACnC,EACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;YACxB,GAAG,CAAC,IAAI;YACR,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;YACjB,GAAG,GAAG,CAAC,OAAO,IAAI;YAClB,GAAG,GAAG,CAAC,KAAK,IAAI;YAChB,GAAG,GAAG,CAAC,MAAM,IAAI;SAClB,CAAC,CACH,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from '@mudah-cli/console';
|
|
2
|
+
/**
|
|
3
|
+
* Built-in `test` command: spawn vitest, or list matching `*.test.ts` files.
|
|
4
|
+
*/
|
|
5
|
+
export default class TestCommand extends Command {
|
|
6
|
+
signature: string;
|
|
7
|
+
description: string;
|
|
8
|
+
descriptionKey: string;
|
|
9
|
+
static exitCodes: {
|
|
10
|
+
1: string;
|
|
11
|
+
};
|
|
12
|
+
handle(): Promise<number>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { readdir } from 'node:fs/promises';
|
|
3
|
+
import { join, relative } from 'node:path';
|
|
4
|
+
import { Command } from '@mudah-cli/console';
|
|
5
|
+
async function walkTests(dir, pattern, acc) {
|
|
6
|
+
let entries;
|
|
7
|
+
try {
|
|
8
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
if (entry.name === 'node_modules' || entry.name === 'dist' || entry.name === '.git')
|
|
15
|
+
continue;
|
|
16
|
+
const full = join(dir, entry.name);
|
|
17
|
+
if (entry.isDirectory()) {
|
|
18
|
+
await walkTests(full, pattern, acc);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (!entry.name.endsWith('.test.ts'))
|
|
22
|
+
continue;
|
|
23
|
+
if (pattern !== undefined && !full.includes(pattern) && !entry.name.includes(pattern))
|
|
24
|
+
continue;
|
|
25
|
+
acc.push(full);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function runVitest(cwd, pattern, flags) {
|
|
29
|
+
return new Promise((resolve) => {
|
|
30
|
+
const args = ['vitest', flags.watch ? 'watch' : 'run'];
|
|
31
|
+
if (pattern !== undefined)
|
|
32
|
+
args.push(pattern);
|
|
33
|
+
if (flags.coverage)
|
|
34
|
+
args.push('--coverage');
|
|
35
|
+
if (process.env['UPDATE_SNAPSHOT'] === '1')
|
|
36
|
+
args.push('--update');
|
|
37
|
+
const child = spawn('npx', ['--no-install', ...args], {
|
|
38
|
+
cwd,
|
|
39
|
+
stdio: 'inherit',
|
|
40
|
+
env: process.env,
|
|
41
|
+
});
|
|
42
|
+
child.on('error', () => resolve(undefined));
|
|
43
|
+
child.on('close', (code) => resolve(code ?? 1));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Built-in `test` command: spawn vitest, or list matching `*.test.ts` files.
|
|
48
|
+
*/
|
|
49
|
+
export default class TestCommand extends Command {
|
|
50
|
+
signature = 'test {pattern?} [--watch] [--coverage] [--fail-empty] [--update]';
|
|
51
|
+
description = 'Discover *.test.ts files and run vitest';
|
|
52
|
+
descriptionKey = 'cmd.test.description';
|
|
53
|
+
static exitCodes = { 1: 'No tests found (--fail-empty) or vitest failed' };
|
|
54
|
+
async handle() {
|
|
55
|
+
const pattern = this.arg('pattern');
|
|
56
|
+
const base = this.app.basePath;
|
|
57
|
+
const files = [];
|
|
58
|
+
await walkTests(base, pattern, files);
|
|
59
|
+
this.output.section('Tests');
|
|
60
|
+
this.output.keyValue('files', String(files.length));
|
|
61
|
+
if (this.option('update') === true) {
|
|
62
|
+
process.env['UPDATE_SNAPSHOT'] = '1';
|
|
63
|
+
}
|
|
64
|
+
if (files.length === 0) {
|
|
65
|
+
this.output.warn('No *.test.ts files found.');
|
|
66
|
+
return this.option('fail-empty') === true ? 1 : 0;
|
|
67
|
+
}
|
|
68
|
+
if (process.env['VITEST'] === undefined) {
|
|
69
|
+
const code = await runVitest(base, pattern, {
|
|
70
|
+
watch: this.option('watch') === true,
|
|
71
|
+
coverage: this.option('coverage') === true,
|
|
72
|
+
});
|
|
73
|
+
if (code !== undefined)
|
|
74
|
+
return code;
|
|
75
|
+
}
|
|
76
|
+
for (const file of files) {
|
|
77
|
+
this.output.raw(` ${relative(base, file)}\n`);
|
|
78
|
+
}
|
|
79
|
+
this.output.muted(process.env['VITEST'] ? 'listed (already inside vitest)' : 'vitest not available — listed files');
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=test.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.command.js","sourceRoot":"","sources":["../../src/commands/test.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE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AC,qCAAqC,CACjG,CAAC;QACF,OAAO,CAAC,CAAC;IACX,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from '@mudah-cli/console';
|
|
2
|
+
/**
|
|
3
|
+
* Built-in `tutorial` command: an interactive walkthrough.
|
|
4
|
+
* Non-TTY or `--plain` prints every step and exits.
|
|
5
|
+
*/
|
|
6
|
+
export default class TutorialCommand extends Command {
|
|
7
|
+
signature: string;
|
|
8
|
+
description: string;
|
|
9
|
+
descriptionKey: string;
|
|
10
|
+
handle(): Promise<number>;
|
|
11
|
+
private printStep;
|
|
12
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Command } from '@mudah-cli/console';
|
|
2
|
+
const STEPS = [
|
|
3
|
+
{
|
|
4
|
+
title: 'create app',
|
|
5
|
+
body: 'npm create @mudah-cli/mudah my-app && cd my-app && npm install',
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
title: 'make command',
|
|
9
|
+
body: 'node bin/my-app.js make command hello\n# or: make tui picker | make plugin audit',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
title: 'TestTui',
|
|
13
|
+
body: "import { TestTui } from '@mudah-cli/mudah/testing';\nconst tui = TestTui.mount(screen.root, { cols: 80, rows: 24 });\ntui.send('down').send('enter');\nexpect(tui.snapshot()).toContain('title');",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
title: 'doctor',
|
|
17
|
+
body: 'node bin/my-app.js doctor\n# prints runtime, manifest, terminal caps, and a TUI dumpTree sample',
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Built-in `tutorial` command: an interactive walkthrough.
|
|
22
|
+
* Non-TTY or `--plain` prints every step and exits.
|
|
23
|
+
*/
|
|
24
|
+
export default class TutorialCommand extends Command {
|
|
25
|
+
signature = 'tutorial';
|
|
26
|
+
description = 'Interactive walkthrough: create app, make command, TestTui, doctor';
|
|
27
|
+
descriptionKey = 'cmd.tutorial.description';
|
|
28
|
+
async handle() {
|
|
29
|
+
const plain = this.output.mode === 'plain' || process.stdin.isTTY !== true;
|
|
30
|
+
this.output.section('Mudah tutorial');
|
|
31
|
+
if (plain) {
|
|
32
|
+
for (const [i, step] of STEPS.entries())
|
|
33
|
+
this.printStep(i, step);
|
|
34
|
+
this.output.success('tutorial complete');
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
for (const [i, step] of STEPS.entries()) {
|
|
38
|
+
this.printStep(i, step);
|
|
39
|
+
const more = i < STEPS.length - 1;
|
|
40
|
+
if (more) {
|
|
41
|
+
const ok = await this.confirm('Continue?', true);
|
|
42
|
+
if (!ok) {
|
|
43
|
+
this.output.muted('Stopped. Re-run tutorial to continue.');
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
this.output.success('tutorial complete');
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
printStep(index, step) {
|
|
52
|
+
this.output.line();
|
|
53
|
+
this.output.info(`${index + 1}. ${step.title}`);
|
|
54
|
+
this.output.raw(`${step.body}\n`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=tutorial.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tutorial.command.js","sourceRoot":"","sources":["../../src/commands/tutorial.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAO7C,MAAM,KAAK,GAA4B;IACrC;QACE,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,gEAAgE;KACvE;IACD;QACE,KAAK,EAAE,cAAc;QACrB,IAAI,EAAE,kFAAkF;KACzF;IACD;QACE,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,mMAAmM;KAC1M;IACD;QACE,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,iGAAiG;KACxG;CACF,CAAC;AAEF;;;GA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KAAa,EAAE,IAAkB;QACjD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -3,6 +3,7 @@ import { Command } from '@mudah-cli/console';
|
|
|
3
3
|
export default class VersionCommand extends Command {
|
|
4
4
|
signature = 'version';
|
|
5
5
|
description = 'Show the application version';
|
|
6
|
+
descriptionKey = 'cmd.version.description';
|
|
6
7
|
async handle() {
|
|
7
8
|
this.output.info(`${this.app.manifest.name} v${this.app.manifest.version}`);
|
|
8
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.command.js","sourceRoot":"","sources":["../../src/commands/version.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,kCAAkC;AAClC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IACjD,SAAS,GAAG,SAAS,CAAC;IACtB,WAAW,GAAG,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"version.command.js","sourceRoot":"","sources":["../../src/commands/version.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,kCAAkC;AAClC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IACjD,SAAS,GAAG,SAAS,CAAC;IACtB,WAAW,GAAG,8BAA8B,CAAC;IAC7C,cAAc,GAAG,yBAAyB,CAAC;IAE3C,KAAK,CAAC,MAAM;QACV,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command, type ConsoleKernel } from '@mudah-cli/console';
|
|
2
|
+
/**
|
|
3
|
+
* Built-in `watch` command: re-run a command when files change.
|
|
4
|
+
* Reads `mudah.json` `watch` defaults when args are omitted.
|
|
5
|
+
*/
|
|
6
|
+
export default class WatchCommand extends Command {
|
|
7
|
+
private readonly kernel;
|
|
8
|
+
signature: string;
|
|
9
|
+
description: string;
|
|
10
|
+
descriptionKey: string;
|
|
11
|
+
constructor(kernel: ConsoleKernel);
|
|
12
|
+
handle(): Promise<number>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Command } from '@mudah-cli/console';
|
|
2
|
+
import { createWatcher, pathsFromGlob } from '../watcher.js';
|
|
3
|
+
/**
|
|
4
|
+
* Built-in `watch` command: re-run a command when files change.
|
|
5
|
+
* Reads `mudah.json` `watch` defaults when args are omitted.
|
|
6
|
+
*/
|
|
7
|
+
export default class WatchCommand extends Command {
|
|
8
|
+
kernel;
|
|
9
|
+
signature = 'watch {command?} {glob?} [--once] [--debounce=]';
|
|
10
|
+
description = 'Watch files and re-run a command';
|
|
11
|
+
descriptionKey = 'cmd.watch.description';
|
|
12
|
+
constructor(kernel) {
|
|
13
|
+
super();
|
|
14
|
+
this.kernel = kernel;
|
|
15
|
+
}
|
|
16
|
+
async handle() {
|
|
17
|
+
const configured = this.app.manifest.watch;
|
|
18
|
+
const target = this.arg('command') ?? configured?.command;
|
|
19
|
+
const glob = this.arg('glob') ?? configured?.glob ?? 'src/**';
|
|
20
|
+
const once = this.option('once') === true;
|
|
21
|
+
const debounce = Number(this.option('debounce') ?? configured?.debounceMs ?? 150) || 150;
|
|
22
|
+
this.output.info(`watch glob=${glob} debounce=${debounce}ms`);
|
|
23
|
+
if (target === undefined) {
|
|
24
|
+
this.output.muted('Pass a command to re-run, e.g. watch doctor src/**');
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
if (!this.kernel.has(target)) {
|
|
28
|
+
throw this.usageError(`Unknown command "${target}".`, 'Run "help" to list all commands.');
|
|
29
|
+
}
|
|
30
|
+
const runOnce = async () => {
|
|
31
|
+
try {
|
|
32
|
+
return await this.kernel.dispatch([target]);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
36
|
+
this.output.error(message);
|
|
37
|
+
return 1;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const code = await runOnce();
|
|
41
|
+
if (once || process.stdin.isTTY !== true) {
|
|
42
|
+
this.output.muted('not watching (non-TTY or --once)');
|
|
43
|
+
return code;
|
|
44
|
+
}
|
|
45
|
+
const base = this.app.basePath;
|
|
46
|
+
const stop = createWatcher(pathsFromGlob(base, glob), (filename) => {
|
|
47
|
+
if (filename)
|
|
48
|
+
process.env['MUDAH_WATCH_FILE'] = filename;
|
|
49
|
+
this.output.muted('change detected — re-running…');
|
|
50
|
+
void runOnce();
|
|
51
|
+
}, { debounceMs: debounce, ignore: configured?.ignore });
|
|
52
|
+
this.output.muted('watching for changes (ctrl+c to stop)');
|
|
53
|
+
await new Promise((resolve) => {
|
|
54
|
+
process.once('SIGINT', () => {
|
|
55
|
+
stop();
|
|
56
|
+
resolve();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=watch.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.command.js","sourceRoot":"","sources":["../../src/commands/watch.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAsB,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,S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C;QACH,OAAO,CAAC,CAAC;IACX,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { Command } from '@mudah-cli/console';
|
|
4
|
-
export { Application, EventBus, ServiceProvider, UsageError, ExitError, CommandCancelled, checkForUpdate, clearUpdateCache, compareSemVer, discoverPlugins, findPluginPackages, formatUpdateNudge, loadManifest, loadPlugin, parseSemVer, type MudahManifest, type LazyProviderOptions, type PluginDiscoveryOptions, type PluginInfo, type ProviderClass, type AppEvents, type UpdateCheckOptions, type UpdateCheckResult, } from '@mudah-cli/core';
|
|
5
|
-
export { ConfigRepository, ConfigValidationError, assertSchema, defineConfig, env, loadEnvFile, loadConfigFiles, s, validateSchema, type Schema, type SchemaIssue, type SchemaResult, } from '@mudah-cli/config';
|
|
1
|
+
export { assertRemoteUrl, assertSchema, type ConfigLayer, ConfigRepository, type ConfigSource, ConfigValidationError, createSecretStore, defineConfig, env, envSecretDriver, fileSecretDriver, formatPrecedence, installConfigReloadSignal, keyringSecretDriver, loadConfigFiles, loadEnvFile, loadRemoteConfig, type PrecedenceRow, REDACT_KEYS, type RedactOptions, redactSecrets, resolveSecret, type Schema, type SchemaIssue, type SchemaResult, SecretStore, s, schemaAt, validateSchema, watchConfig, } from '@mudah-cli/config';
|
|
2
|
+
export { ArgumentParseError, type CoercionType, Command, type ParsedInput, type ParsedSignature, parseInput, parseSignature, } from '@mudah-cli/console';
|
|
6
3
|
export { Container } from '@mudah-cli/container';
|
|
4
|
+
export { type AppEvents, Application, addMessages, CommandCancelled, checkForUpdate, clearUpdateCache, compareSemVer, createTelemetry, defaultCacheDir, discoverPlugins, EventBus, ExitError, findPluginPackages, formatGraph, formatUpdateNudge, gatePlugin, getLocale, hasLocale, hasMessage, type LazyProviderOptions, loadManifest, loadMessages, loadPlugin, localeFromEnv, locales, type MudahManifest, type PluginDiscoveryOptions, type PluginInfo, type ProviderClass, parseSemVer, pluginGraph, ServiceProvider, setLocale, setLocaleFromEnv, type Telemetry, type TelemetryEvent, type TelemetryOptions, type TelemetrySink, t, type UpdateCheckOptions, type UpdateCheckResult, UsageError, } from '@mudah-cli/core';
|
|
7
5
|
export { detectCapabilities, type TerminalCapabilities } from '@mudah-cli/terminal';
|
|
6
|
+
export { type AutocompleteShell, normalizeAutocompleteShell, renderAutocompleteScript, } from './autocomplete.js';
|
|
7
|
+
export { applyPluginUpdate, fetchLatestVersion } from './commands/plugins.update.command.js';
|
|
8
|
+
export { clearWorkspaceIndex, commandFileDiagnostics, commandSignatureItems, completionItems, decodeLspFrames, diagnosticsFor, encodeLspFrame, extractSignatures, filePathToUri, fileUriToPath, handleLspMessage, hoverContents, type IndexedCommand, indexWorkspaceCommands, initializeResult, type LspDiagnostic, type LspMessage, mudahJsonDiagnostics, publishDiagnostics, workspaceCommandItems, workspaceCommandsIndex, } from './lsp.js';
|
|
9
|
+
export { type RunOptions, run } from './run.js';
|
|
10
|
+
export { createWatcher, hotReloadPlugins, pathsFromGlob, type WatcherOptions, watchPlugins, } from './watcher.js';
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { createWatcher } from './watcher.js';
|
|
1
|
+
export { assertRemoteUrl, assertSchema, ConfigRepository, ConfigValidationError, createSecretStore, defineConfig, env, envSecretDriver, fileSecretDriver, formatPrecedence, installConfigReloadSignal, keyringSecretDriver, loadConfigFiles, loadEnvFile, loadRemoteConfig, REDACT_KEYS, redactSecrets, resolveSecret, SecretStore, s, schemaAt, validateSchema, watchConfig, } from '@mudah-cli/config';
|
|
3
2
|
// App-facing re-exports: `import { Command } from '@mudah-cli/mudah'` is all users need.
|
|
4
|
-
export { Command } from '@mudah-cli/console';
|
|
5
|
-
export { Application, EventBus, ServiceProvider, UsageError, ExitError, CommandCancelled, checkForUpdate, clearUpdateCache, compareSemVer, discoverPlugins, findPluginPackages, formatUpdateNudge, loadManifest, loadPlugin, parseSemVer, } from '@mudah-cli/core';
|
|
6
|
-
export { ConfigRepository, ConfigValidationError, assertSchema, defineConfig, env, loadEnvFile, loadConfigFiles, s, validateSchema, } from '@mudah-cli/config';
|
|
3
|
+
export { ArgumentParseError, Command, parseInput, parseSignature, } from '@mudah-cli/console';
|
|
7
4
|
export { Container } from '@mudah-cli/container';
|
|
5
|
+
export { Application, addMessages, CommandCancelled, checkForUpdate, clearUpdateCache, compareSemVer, createTelemetry, defaultCacheDir, discoverPlugins, EventBus, ExitError, findPluginPackages, formatGraph, formatUpdateNudge, gatePlugin, getLocale, hasLocale, hasMessage, loadManifest, loadMessages, loadPlugin, localeFromEnv, locales, parseSemVer, pluginGraph, ServiceProvider, setLocale, setLocaleFromEnv, t, UsageError, } from '@mudah-cli/core';
|
|
8
6
|
export { detectCapabilities } from '@mudah-cli/terminal';
|
|
7
|
+
export { normalizeAutocompleteShell, renderAutocompleteScript, } from './autocomplete.js';
|
|
8
|
+
export { applyPluginUpdate, fetchLatestVersion } from './commands/plugins.update.command.js';
|
|
9
|
+
export { clearWorkspaceIndex, commandFileDiagnostics, commandSignatureItems, completionItems, decodeLspFrames, diagnosticsFor, encodeLspFrame, extractSignatures, filePathToUri, fileUriToPath, handleLspMessage, hoverContents, indexWorkspaceCommands, initializeResult, mudahJsonDiagnostics, publishDiagnostics, workspaceCommandItems, workspaceCommandsIndex, } from './lsp.js';
|
|
10
|
+
export { run } from './run.js';
|
|
11
|
+
export { createWatcher, hotReloadPlugins, pathsFromGlob, watchPlugins, } from './watcher.js';
|
|
9
12
|
//# 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,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,YAAY,EAEZ,gBAAgB,EAEh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qBAAqB,EACrB,sBAAsB,GACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAmB,GAAG,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,EAEb,YAAY,GACb,MAAM,cAAc,CAAC"}
|
package/dist/lsp.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/** Mudah JSON-RPC LSP: initialize, completion, hover, diagnostics, document sync. */
|
|
2
|
+
export interface LspMessage {
|
|
3
|
+
jsonrpc: '2.0';
|
|
4
|
+
id?: number | string;
|
|
5
|
+
method?: string;
|
|
6
|
+
params?: unknown;
|
|
7
|
+
result?: unknown;
|
|
8
|
+
error?: {
|
|
9
|
+
code: number;
|
|
10
|
+
message: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface CompletionItem {
|
|
14
|
+
label: string;
|
|
15
|
+
kind?: number;
|
|
16
|
+
detail?: string;
|
|
17
|
+
documentation?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const MANIFEST_KEYS: readonly [{
|
|
20
|
+
readonly label: 'name';
|
|
21
|
+
readonly detail: 'Application name';
|
|
22
|
+
}, {
|
|
23
|
+
readonly label: 'version';
|
|
24
|
+
readonly detail: 'Semver version';
|
|
25
|
+
}, {
|
|
26
|
+
readonly label: 'bin';
|
|
27
|
+
readonly detail: 'Binary name';
|
|
28
|
+
}, {
|
|
29
|
+
readonly label: 'description';
|
|
30
|
+
readonly detail: 'One-line description';
|
|
31
|
+
}, {
|
|
32
|
+
readonly label: 'ui';
|
|
33
|
+
readonly detail: 'Theme / motion / color';
|
|
34
|
+
}, {
|
|
35
|
+
readonly label: 'updates';
|
|
36
|
+
readonly detail: 'Update nudge (default true)';
|
|
37
|
+
}, {
|
|
38
|
+
readonly label: 'commands';
|
|
39
|
+
readonly detail: 'Extra command module paths';
|
|
40
|
+
}, {
|
|
41
|
+
readonly label: 'providers';
|
|
42
|
+
readonly detail: 'Extra provider module paths';
|
|
43
|
+
}, {
|
|
44
|
+
readonly label: 'telemetry';
|
|
45
|
+
readonly detail: 'Opt-in boot/perf telemetry';
|
|
46
|
+
}, {
|
|
47
|
+
readonly label: 'watch';
|
|
48
|
+
readonly detail: 'Declarative file watcher';
|
|
49
|
+
}];
|
|
50
|
+
export declare const SIGNATURE_SNIPPETS: CompletionItem[];
|
|
51
|
+
/** A command found on disk by {@link indexWorkspaceCommands}. */
|
|
52
|
+
export interface IndexedCommand {
|
|
53
|
+
/** Command name from the signature (`db:status`). */
|
|
54
|
+
name: string;
|
|
55
|
+
/** The full signature string. */
|
|
56
|
+
signature: string;
|
|
57
|
+
description: string;
|
|
58
|
+
/** Absolute path to the `*.command.ts` file. */
|
|
59
|
+
file: string;
|
|
60
|
+
/** 1-based line of the `signature` assignment. */
|
|
61
|
+
line: number;
|
|
62
|
+
}
|
|
63
|
+
/** Convert a `file://` URI to a filesystem path (best effort). */
|
|
64
|
+
export declare function fileUriToPath(uri: string): string;
|
|
65
|
+
/** Convert an absolute path to a `file://` URI. */
|
|
66
|
+
export declare function filePathToUri(path: string): string;
|
|
67
|
+
interface RawSignature {
|
|
68
|
+
signature: string;
|
|
69
|
+
index: number;
|
|
70
|
+
}
|
|
71
|
+
/** Every `signature = '...'` assignment in a command source file. */
|
|
72
|
+
export declare function extractSignatures(text: string): RawSignature[];
|
|
73
|
+
/**
|
|
74
|
+
* Scan a directory tree for `*.command.ts` files and index their signatures.
|
|
75
|
+
* Replaces any previous index. Returns the indexed commands sorted by name.
|
|
76
|
+
*/
|
|
77
|
+
export declare function indexWorkspaceCommands(rootDir: string): IndexedCommand[];
|
|
78
|
+
/** The current workspace command index. */
|
|
79
|
+
export declare function workspaceCommandsIndex(): readonly IndexedCommand[];
|
|
80
|
+
/** Drop the workspace index (tests, or when the root changes). */
|
|
81
|
+
export declare function clearWorkspaceIndex(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Completion items for workspace commands, annotated with the file they came
|
|
84
|
+
* from so the editor can show a useful detail line.
|
|
85
|
+
*/
|
|
86
|
+
export declare function workspaceCommandItems(root?: string): CompletionItem[];
|
|
87
|
+
export declare function initializeResult(): {
|
|
88
|
+
capabilities: {
|
|
89
|
+
textDocumentSync: number;
|
|
90
|
+
completionProvider: {
|
|
91
|
+
triggerCharacters: string[];
|
|
92
|
+
};
|
|
93
|
+
hoverProvider: boolean;
|
|
94
|
+
diagnosticProvider: {
|
|
95
|
+
interFileDependencies: boolean;
|
|
96
|
+
workspaceDiagnostics: boolean;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
serverInfo: {
|
|
100
|
+
name: string;
|
|
101
|
+
version: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export declare function uriOf(params: unknown): string;
|
|
105
|
+
export declare function completionItems(params: unknown): CompletionItem[];
|
|
106
|
+
/** Pull `signature = '...'` strings from an open `*.command.ts` buffer. */
|
|
107
|
+
export declare function commandSignatureItems(text: string): CompletionItem[];
|
|
108
|
+
export interface LspDiagnostic {
|
|
109
|
+
range: {
|
|
110
|
+
start: {
|
|
111
|
+
line: number;
|
|
112
|
+
character: number;
|
|
113
|
+
};
|
|
114
|
+
end: {
|
|
115
|
+
line: number;
|
|
116
|
+
character: number;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
severity: 1 | 2 | 3 | 4;
|
|
120
|
+
source: 'mudah';
|
|
121
|
+
message: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Signature diagnostics for an open `*.command.ts` buffer: each declared
|
|
125
|
+
* signature is validated with the real parser, and duplicate command names
|
|
126
|
+
* across the workspace are flagged.
|
|
127
|
+
*/
|
|
128
|
+
export declare function commandFileDiagnostics(uri: string, text: string): LspDiagnostic[];
|
|
129
|
+
/** Schema diagnostics for an open `mudah.json` buffer. */
|
|
130
|
+
export declare function mudahJsonDiagnostics(uri: string, text: string): LspDiagnostic[];
|
|
131
|
+
/** Diagnostics for whichever document type this URI is, if any. */
|
|
132
|
+
export declare function diagnosticsFor(uri: string, text: string): LspDiagnostic[];
|
|
133
|
+
/** LSP notification for the current buffer, if it is a manifest or command file. */
|
|
134
|
+
export declare function publishDiagnostics(uri: string): LspMessage | undefined;
|
|
135
|
+
export declare function hoverContents(params: unknown): {
|
|
136
|
+
kind: 'markdown';
|
|
137
|
+
value: string;
|
|
138
|
+
} | null;
|
|
139
|
+
/** Handle one JSON-RPC request. Notifications (no id) may return undefined. */
|
|
140
|
+
export declare function handleLspMessage(msg: LspMessage): LspMessage | undefined;
|
|
141
|
+
/** LSP Content-Length framing. */
|
|
142
|
+
export declare function encodeLspFrame(message: LspMessage): string;
|
|
143
|
+
export declare function decodeLspFrames(buffer: string): {
|
|
144
|
+
messages: LspMessage[];
|
|
145
|
+
rest: string;
|
|
146
|
+
};
|
|
147
|
+
export {};
|