@mudah-cli/mudah 0.1.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.
Files changed (40) hide show
  1. package/dist/animation.d.ts +1 -0
  2. package/dist/animation.js +2 -0
  3. package/dist/animation.js.map +1 -0
  4. package/dist/commands/build.command.d.ts +10 -0
  5. package/dist/commands/build.command.js +43 -0
  6. package/dist/commands/build.command.js.map +1 -0
  7. package/dist/commands/dev.command.d.ts +12 -0
  8. package/dist/commands/dev.command.js +45 -0
  9. package/dist/commands/dev.command.js.map +1 -0
  10. package/dist/commands/doctor.command.d.ts +10 -0
  11. package/dist/commands/doctor.command.js +53 -0
  12. package/dist/commands/doctor.command.js.map +1 -0
  13. package/dist/commands/help.command.d.ts +11 -0
  14. package/dist/commands/help.command.js +30 -0
  15. package/dist/commands/help.command.js.map +1 -0
  16. package/dist/commands/make.command.d.ts +10 -0
  17. package/dist/commands/make.command.js +86 -0
  18. package/dist/commands/make.command.js.map +1 -0
  19. package/dist/commands/version.command.d.ts +7 -0
  20. package/dist/commands/version.command.js +10 -0
  21. package/dist/commands/version.command.js.map +1 -0
  22. package/dist/index.d.ts +7 -0
  23. package/dist/index.js +9 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/run.d.ts +32 -0
  26. package/dist/run.js +114 -0
  27. package/dist/run.js.map +1 -0
  28. package/dist/terminal.d.ts +1 -0
  29. package/dist/terminal.js +2 -0
  30. package/dist/terminal.js.map +1 -0
  31. package/dist/testing.d.ts +1 -0
  32. package/dist/testing.js +2 -0
  33. package/dist/testing.js.map +1 -0
  34. package/dist/ui.d.ts +1 -0
  35. package/dist/ui.js +2 -0
  36. package/dist/ui.js.map +1 -0
  37. package/dist/watcher.d.ts +10 -0
  38. package/dist/watcher.js +37 -0
  39. package/dist/watcher.js.map +1 -0
  40. package/package.json +50 -0
@@ -0,0 +1 @@
1
+ export * from '@mudah-cli/animation';
@@ -0,0 +1,2 @@
1
+ export * from '@mudah-cli/animation';
2
+ //# sourceMappingURL=animation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation.js","sourceRoot":"","sources":["../src/animation.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Command } from '@mudah-cli/console';
2
+ /**
3
+ * Built-in `build` command: runs the app's `build` script (bun when the
4
+ * app is running under Bun, npm otherwise), streaming output.
5
+ */
6
+ export default class BuildCommand extends Command {
7
+ signature: string;
8
+ description: string;
9
+ handle(): Promise<number | undefined>;
10
+ }
@@ -0,0 +1,43 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { spawn } from 'node:child_process';
3
+ import { Command } from '@mudah-cli/console';
4
+ function runChild(command, args, cwd) {
5
+ return new Promise((resolve) => {
6
+ const child = spawn(command, args, { cwd, stdio: 'inherit' });
7
+ child.on('error', () => resolve(1));
8
+ child.on('close', (code) => resolve(code ?? 1));
9
+ });
10
+ }
11
+ /**
12
+ * Built-in `build` command: runs the app's `build` script (bun when the
13
+ * app is running under Bun, npm otherwise), streaming output.
14
+ */
15
+ export default class BuildCommand extends Command {
16
+ signature = 'build';
17
+ description = 'Build the application (runs the package.json build script)';
18
+ async handle() {
19
+ const pkgPath = `${this.app.basePath}/package.json`;
20
+ let pkg;
21
+ try {
22
+ pkg = JSON.parse(await readFile(pkgPath, 'utf8'));
23
+ }
24
+ catch {
25
+ throw this.usageError('No package.json found in the app directory.');
26
+ }
27
+ const script = pkg.scripts?.['build'];
28
+ if (!script) {
29
+ this.output.warn('No "build" script in package.json — nothing to do.');
30
+ return;
31
+ }
32
+ const runner = process.versions.bun ? 'bun' : 'npm';
33
+ this.output.info(`Running: ${runner} run build`);
34
+ const code = await runChild(runner, ['run', 'build'], this.app.basePath);
35
+ if (code === 0) {
36
+ this.output.success('Build complete.');
37
+ return 0;
38
+ }
39
+ this.output.error(`Build failed with exit code ${code}.`);
40
+ return code;
41
+ }
42
+ }
43
+ //# sourceMappingURL=build.command.js.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,CAAC,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;YACvE,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QACpD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,MAAM,YAAY,CAAC,CAAC;QACjD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACzE,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YACvC,OAAO,CAAC,CAAC;QACX,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,IAAI,GAAG,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import { Command, type ConsoleKernel } from '@mudah-cli/console';
2
+ /**
3
+ * Built-in `dev` command: run a command, then re-run it whenever
4
+ * src/, config/, or mudah.json change (150ms debounce). Exits on SIGINT.
5
+ */
6
+ export default class DevCommand extends Command {
7
+ signature: string;
8
+ description: string;
9
+ private kernel;
10
+ constructor(kernel: ConsoleKernel);
11
+ handle(): Promise<void>;
12
+ }
@@ -0,0 +1,45 @@
1
+ import { join } from 'node:path';
2
+ import { Command } from '@mudah-cli/console';
3
+ import { createWatcher } from '../watcher.js';
4
+ /**
5
+ * Built-in `dev` command: run a command, then re-run it whenever
6
+ * src/, config/, or mudah.json change (150ms debounce). Exits on SIGINT.
7
+ */
8
+ export default class DevCommand extends Command {
9
+ signature = 'dev {command}';
10
+ description = 'Watch mode: re-run a command when files change';
11
+ kernel;
12
+ constructor(kernel) {
13
+ super();
14
+ this.kernel = kernel;
15
+ }
16
+ async handle() {
17
+ const target = this.arg('command');
18
+ if (!this.kernel.has(target)) {
19
+ throw this.usageError(`Unknown command "${target}".`, 'Run "help" to list all commands.');
20
+ }
21
+ const runOnce = async () => {
22
+ try {
23
+ await this.kernel.dispatch([target]);
24
+ }
25
+ catch (error) {
26
+ const message = error instanceof Error ? error.message : String(error);
27
+ this.output.error(message);
28
+ }
29
+ };
30
+ await runOnce();
31
+ const base = this.app.basePath;
32
+ const stop = createWatcher([join(base, 'src'), join(base, 'config'), join(base, 'mudah.json')], () => {
33
+ this.output.muted('change detected — re-running…');
34
+ void runOnce();
35
+ });
36
+ this.output.muted('watching for changes (ctrl+c to stop)');
37
+ await new Promise((resolve) => {
38
+ process.once('SIGINT', () => {
39
+ stop();
40
+ resolve();
41
+ });
42
+ });
43
+ }
44
+ }
45
+ //# sourceMappingURL=dev.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.command.js","sourceRoot":"","sources":["../../src/commands/dev.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAsB,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,OAAO;IAC7C,SAAS,GAAG,eAAe,CAAC;IAC5B,WAAW,GAAG,gDAAgD,CAAC;IAEvD,MAAM,CAAgB;IAE9B,YAAY,MAAqB;QAC/B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CA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@mudah-cli/console';
2
+ /**
3
+ * Built-in `doctor` command: a quick health check of the runtime, manifest,
4
+ * scaffolding, and terminal capabilities.
5
+ */
6
+ export default class DoctorCommand extends Command {
7
+ signature: string;
8
+ description: string;
9
+ handle(): Promise<void>;
10
+ }
@@ -0,0 +1,53 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { Command } from '@mudah-cli/console';
4
+ import { detectCapabilities } from '@mudah-cli/terminal';
5
+ /**
6
+ * Built-in `doctor` command: a quick health check of the runtime, manifest,
7
+ * scaffolding, and terminal capabilities.
8
+ */
9
+ export default class DoctorCommand extends Command {
10
+ signature = 'doctor';
11
+ description = 'Check the runtime, app, and terminal setup';
12
+ async handle() {
13
+ const caps = detectCapabilities();
14
+ this.output.section('Runtime');
15
+ const nodeMajor = Number(process.versions.node.split('.')[0]);
16
+ if (nodeMajor >= 26) {
17
+ this.output.success(`Node.js ${process.versions.node}`);
18
+ }
19
+ else if (process.versions.bun) {
20
+ this.output.success(`Bun ${process.versions.bun}`);
21
+ }
22
+ else {
23
+ this.output.warn(`Node.js ${process.versions.node} (Mudah targets Node >= 26)`);
24
+ }
25
+ this.output.section('Application');
26
+ this.output.keyValue('name', this.app.manifest.name);
27
+ this.output.keyValue('version', this.app.manifest.version);
28
+ const binDir = join(this.app.basePath, 'bin');
29
+ if (existsSync(join(binDir, this.app.manifest.bin)) || existsSync(binDir)) {
30
+ this.output.success(`bin/${this.app.manifest.bin} present`);
31
+ }
32
+ else {
33
+ this.output.warn(`bin/${this.app.manifest.bin} missing — add the bin stub`);
34
+ }
35
+ const modules = await this.app.discoverCommandModules();
36
+ if (modules.length > 0) {
37
+ this.output.success(`${modules.length} command(s) discovered`);
38
+ }
39
+ else {
40
+ this.output.warn('no commands discovered in src/commands');
41
+ }
42
+ this.output.section('Terminal');
43
+ this.output.keyValue('brand', caps.brand);
44
+ this.output.keyValue('color', caps.trueColor ? 'truecolor' : caps.colorLevel === 8 ? '256' : caps.colorLevel === 1 ? '16' : 'off');
45
+ this.output.keyValue('unicode', String(caps.unicode));
46
+ this.output.keyValue('animations', String(caps.animations));
47
+ this.output.keyValue('notifications', caps.osc9 ? 'osc 9' : 'none');
48
+ this.output.keyValue('semantic prompts', caps.osc133 ? 'osc 133' : 'none');
49
+ this.output.line();
50
+ this.output.success('doctor complete');
51
+ }
52
+ }
53
+ //# sourceMappingURL=doctor.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.command.js","sourceRoot":"","sources":["../../src/commands/doctor.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,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAChD,SAAS,GAAG,QAAQ,CAAC;IACrB,WAAW,GAAG,4CAA4C,CAAC;IAE3D,KAAK,CAAC,MAAM;QACV,MAAM,IAAI,GAAG,kBAAkB,EAAE,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAE/B,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,IAAI,SAAS,IAAI,EAAE,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;aAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YAChC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CA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AAC;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACnI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACpE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAE3E,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACzC,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ import { Command, type ConsoleKernel } from '@mudah-cli/console';
2
+ /**
3
+ * Built-in `help` command: lists all commands, or shows details for one.
4
+ */
5
+ export default class HelpCommand extends Command {
6
+ signature: string;
7
+ description: string;
8
+ private kernel;
9
+ constructor(kernel: ConsoleKernel);
10
+ handle(): Promise<void>;
11
+ }
@@ -0,0 +1,30 @@
1
+ import { Command } from '@mudah-cli/console';
2
+ import { renderCommandHelp, renderCommandList } from '@mudah-cli/console';
3
+ /**
4
+ * Built-in `help` command: lists all commands, or shows details for one.
5
+ */
6
+ export default class HelpCommand extends Command {
7
+ signature = 'help {command?}';
8
+ description = 'Show help for the CLI or a specific command';
9
+ kernel;
10
+ constructor(kernel) {
11
+ super();
12
+ this.kernel = kernel;
13
+ }
14
+ async handle() {
15
+ const target = this.arg('command');
16
+ const lines = [];
17
+ if (target !== undefined) {
18
+ const entry = this.kernel.get(target);
19
+ if (!entry) {
20
+ throw this.usageError(`Unknown command "${target}".`, 'Run "help" to list all commands.');
21
+ }
22
+ renderCommandHelp(this.app.manifest.name, entry, lines);
23
+ }
24
+ else {
25
+ renderCommandList(this.app.manifest.name, this.app.manifest.version, this.kernel.list(), lines);
26
+ }
27
+ this.output.raw(lines.join('\n'));
28
+ }
29
+ }
30
+ //# sourceMappingURL=help.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.command.js","sourceRoot":"","sources":["../../src/commands/help.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAsB,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE1E;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,OAAO;IAC9C,SAAS,GAAG,iBAAiB,CAAC;IAC9B,WAAW,GAAG,6CAA6C,CAAC;IAEpD,MAAM,CAAgB;IAE9B,YAAY,MAAqB;QAC/B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACnC,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACtC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,CAAC,UAAU,CAAC,oBAAoB,MAAM,IAAI,EAAE,kCAAkC,CAAC,CAAC;YAC5F,CAAC;YACD,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACN,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;QAClG,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import { Command } from '@mudah-cli/console';
2
+ /**
3
+ * Built-in `make` command: scaffold commands, providers, and config files
4
+ * with the right structure and imports.
5
+ */
6
+ export default class MakeCommand extends Command {
7
+ signature: string;
8
+ description: string;
9
+ handle(): Promise<void>;
10
+ }
@@ -0,0 +1,86 @@
1
+ import { mkdir, writeFile } from 'node:fs/promises';
2
+ import { isAbsolute, join, relative } from 'node:path';
3
+ import { Command } from '@mudah-cli/console';
4
+ function kebab(name) {
5
+ return name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
6
+ }
7
+ function pascal(name) {
8
+ return kebab(name)
9
+ .split('-')
10
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
11
+ .join('');
12
+ }
13
+ const COMMAND_TEMPLATE = (command, className) => `import { Command } from '@mudah-cli/mudah';
14
+
15
+ export default class ${className} extends Command {
16
+ signature = '${command} {target?}';
17
+ description = 'Describe ${command} in one line.';
18
+
19
+ async handle() {
20
+ this.output.success('Hello from ${command}!');
21
+ }
22
+ }
23
+ `;
24
+ const PROVIDER_TEMPLATE = (className) => `import { ServiceProvider } from '@mudah-cli/mudah';
25
+
26
+ export default class ${className} extends ServiceProvider {
27
+ register(): void {}
28
+
29
+ boot(): void {}
30
+ }
31
+ `;
32
+ const CONFIG_TEMPLATE = `import { defineConfig } from '@mudah-cli/mudah';
33
+
34
+ export default defineConfig({
35
+ // Add configuration for this component.
36
+ });
37
+ `;
38
+ /**
39
+ * Built-in `make` command: scaffold commands, providers, and config files
40
+ * with the right structure and imports.
41
+ */
42
+ export default class MakeCommand extends Command {
43
+ signature = 'make {type} {name}';
44
+ description = 'Scaffold a command, provider, or config file';
45
+ async handle() {
46
+ const type = this.arg('type');
47
+ const name = this.arg('name');
48
+ if (!['command', 'provider', 'config'].includes(type)) {
49
+ throw this.usageError(`Unknown make type "${type}".`, 'Use: make {command|provider|config} {name}');
50
+ }
51
+ if (!/^[a-zA-Z][a-zA-Z0-9-]*$/.test(name)) {
52
+ throw this.usageError(`Invalid name "${name}".`, 'Use letters, numbers, and dashes (e.g. "deploy-site").');
53
+ }
54
+ const k = kebab(name);
55
+ const className = pascal(name);
56
+ let filePath;
57
+ let content;
58
+ if (type === 'command') {
59
+ filePath = join(this.app.basePath, 'src', 'commands', `${k}.command.ts`);
60
+ content = COMMAND_TEMPLATE(k, className);
61
+ }
62
+ else if (type === 'provider') {
63
+ filePath = join(this.app.basePath, 'src', 'providers', `${className}Provider.ts`);
64
+ content = PROVIDER_TEMPLATE(`${className}Provider`);
65
+ }
66
+ else {
67
+ filePath = join(this.app.basePath, 'config', `${k}.ts`);
68
+ content = CONFIG_TEMPLATE;
69
+ }
70
+ if (isAbsolute(filePath) === false || !filePath.startsWith(this.app.basePath)) {
71
+ throw this.usageError('Refusing to write outside the app directory.');
72
+ }
73
+ try {
74
+ await mkdir(join(filePath, '..'), { recursive: true });
75
+ await writeFile(filePath, content, { flag: 'wx' });
76
+ }
77
+ catch (error) {
78
+ if (error.code === 'EEXIST') {
79
+ throw this.usageError(`${relative(this.app.basePath, filePath)} already exists.`);
80
+ }
81
+ throw error;
82
+ }
83
+ this.output.success(`Created ${relative(this.app.basePath, filePath)}`);
84
+ }
85
+ }
86
+ //# sourceMappingURL=make.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make.command.js","sourceRoot":"","sources":["../../src/commands/make.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,SAAS,KAAK,CAAC,IAAY;IACzB,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AACnE,CAAC;AAED,SAAS,MAAM,CAAC,IAAY;IAC1B,OAAO,KAAK,CAAC,IAAI,CAAC;SACf,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAC3D,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAE,SAAiB,EAAU,EAAE,CAAC;;uBAElD,SAAS;iBACf,OAAO;4BACI,OAAO;;;sCAGG,OAAO;;;CAG5C,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAU,EAAE,CAAC;;uBAElC,SAAS;;;;;CAK/B,CAAC;AAEF,MAAM,eAAe,GAAG;;;;;CAKvB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,O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;aAAM,CAAC;YACN,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;YACxD,OAAO,GAAG,eAAe,CAAC;QAC5B,CAAC;QAED,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,KAAK,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9E,MAAM,IAAI,CAAC,UAAU,CAAC,8CAA8C,CAAC,CAAC;QACxE,CAAC;QAED,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACvD,MAAM,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACrD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACvD,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC;YACpF,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ import { Command } from '@mudah-cli/console';
2
+ /** Built-in `version` command. */
3
+ export default class VersionCommand extends Command {
4
+ signature: string;
5
+ description: string;
6
+ handle(): Promise<void>;
7
+ }
@@ -0,0 +1,10 @@
1
+ import { Command } from '@mudah-cli/console';
2
+ /** Built-in `version` command. */
3
+ export default class VersionCommand extends Command {
4
+ signature = 'version';
5
+ description = 'Show the application version';
6
+ async handle() {
7
+ this.output.info(`${this.app.manifest.name} v${this.app.manifest.version}`);
8
+ }
9
+ }
10
+ //# sourceMappingURL=version.command.js.map
@@ -0,0 +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;IAE7C,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,7 @@
1
+ export { run, type RunOptions } from './run.js';
2
+ export { createWatcher, type WatcherOptions } from './watcher.js';
3
+ export { Command } from '@mudah-cli/console';
4
+ export { Application, EventBus, ServiceProvider, UsageError, ExitError, CommandCancelled, loadManifest, type MudahManifest, type LazyProviderOptions, type ProviderClass, type AppEvents, } from '@mudah-cli/core';
5
+ export { ConfigRepository, defineConfig, env, loadEnvFile, loadConfigFiles } from '@mudah-cli/config';
6
+ export { Container } from '@mudah-cli/container';
7
+ export { detectCapabilities, type TerminalCapabilities } from '@mudah-cli/terminal';
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { run } from './run.js';
2
+ export { createWatcher } from './watcher.js';
3
+ // 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, loadManifest, } from '@mudah-cli/core';
6
+ export { ConfigRepository, defineConfig, env, loadEnvFile, loadConfigFiles } from '@mudah-cli/config';
7
+ export { Container } from '@mudah-cli/container';
8
+ export { detectCapabilities } from '@mudah-cli/terminal';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAmB,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,aAAa,EAAuB,MAAM,cAAc,CAAC;AAElE,yFAAyF;AACzF,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EACL,WAAW,EACX,QAAQ,EACR,eAAe,EACf,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,YAAY,GAKb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACtG,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAA6B,MAAM,qBAAqB,CAAC"}
package/dist/run.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { type Application as App } from '@mudah-cli/core';
2
+ export interface RunOptions {
3
+ /** Raw arguments (default: `process.argv.slice(2)`). */
4
+ argv?: string[];
5
+ /** Application root (default: `process.cwd()`). */
6
+ cwd?: string;
7
+ /** Pre-built application, mainly for tests. */
8
+ app?: App;
9
+ /** Environment map for capability detection (default: `process.env`). */
10
+ env?: NodeJS.ProcessEnv;
11
+ /** Where stdout/stderr go (defaults to the real streams). */
12
+ stdout?: {
13
+ write(data: string): unknown;
14
+ };
15
+ stderr?: {
16
+ write(data: string): unknown;
17
+ };
18
+ }
19
+ /**
20
+ * The Mudah entry point. An app's `bin/<name>` stub is:
21
+ *
22
+ * ```js
23
+ * #!/usr/bin/env node
24
+ * import { run } from '@mudah-cli/mudah';
25
+ * process.exitCode = await run();
26
+ * ```
27
+ *
28
+ * `run()` boots the application (providers, discovery), builds the console
29
+ * kernel (built-ins + discovered commands), and dispatches argv. Returns
30
+ * the process exit code — it never throws for user-facing errors.
31
+ */
32
+ export declare function run(options?: RunOptions): Promise<number>;
package/dist/run.js ADDED
@@ -0,0 +1,114 @@
1
+ import { Application, loadManifest, } from '@mudah-cli/core';
2
+ import { detectCapabilities } from '@mudah-cli/terminal';
3
+ import { Output, resolveTheme } from '@mudah-cli/ui';
4
+ import { ConsoleKernel, renderError, renderCommandHelp, renderCommandList } from '@mudah-cli/console';
5
+ import HelpCommand from './commands/help.command.js';
6
+ import VersionCommand from './commands/version.command.js';
7
+ import MakeCommand from './commands/make.command.js';
8
+ import BuildCommand from './commands/build.command.js';
9
+ import DoctorCommand from './commands/doctor.command.js';
10
+ import DevCommand from './commands/dev.command.js';
11
+ /**
12
+ * The Mudah entry point. An app's `bin/<name>` stub is:
13
+ *
14
+ * ```js
15
+ * #!/usr/bin/env node
16
+ * import { run } from '@mudah-cli/mudah';
17
+ * process.exitCode = await run();
18
+ * ```
19
+ *
20
+ * `run()` boots the application (providers, discovery), builds the console
21
+ * kernel (built-ins + discovered commands), and dispatches argv. Returns
22
+ * the process exit code — it never throws for user-facing errors.
23
+ */
24
+ export async function run(options = {}) {
25
+ const cwd = options.cwd ?? process.cwd();
26
+ const argv = options.argv ?? process.argv.slice(2);
27
+ const env = options.env;
28
+ const caps = detectCapabilities({ env });
29
+ let manifest;
30
+ try {
31
+ manifest = loadManifest(cwd);
32
+ }
33
+ catch (error) {
34
+ const message = error instanceof Error ? error.message : String(error);
35
+ (options.stderr ?? process.stderr).write(message + '\n');
36
+ return 1;
37
+ }
38
+ const app = options.app ?? new Application(cwd, manifest);
39
+ const theme = resolveTheme(manifest.ui?.theme);
40
+ const output = new Output({
41
+ stream: options.stdout ?? process.stdout,
42
+ errorStream: options.stderr ?? process.stderr,
43
+ theme,
44
+ colorLevel: caps.colorLevel,
45
+ unicode: caps.unicode,
46
+ osc9: caps.osc9,
47
+ });
48
+ // Providers: discover app providers, boot, then evaluate lazy predicates.
49
+ await app.discoverProviders();
50
+ await app.boot();
51
+ await app.evaluateLazy();
52
+ // Kernel: built-ins first, then discovered app commands, then manifest extras.
53
+ const kernel = new ConsoleKernel(app, output);
54
+ registerBuiltIns(kernel);
55
+ const modules = [...(await app.discoverCommandModules())];
56
+ for (const extra of manifest.commands ?? []) {
57
+ const mod = (await app.importModule(extra));
58
+ if (mod.default)
59
+ modules.push(mod);
60
+ }
61
+ for (const mod of modules) {
62
+ try {
63
+ kernel.register(mod);
64
+ }
65
+ catch (error) {
66
+ (options.stderr ?? process.stderr).write((error instanceof Error ? error.message : String(error)) + '\n');
67
+ }
68
+ }
69
+ // Global flags.
70
+ const [first] = argv;
71
+ if (first === '--help' || first === '-h' || first === undefined) {
72
+ const lines = [];
73
+ renderCommandList(manifest.name, manifest.version, kernel.list(), lines);
74
+ output.raw(lines.join('\n'));
75
+ return 0;
76
+ }
77
+ if (first === '--version') {
78
+ output.info(`${manifest.name} v${manifest.version}`);
79
+ return 0;
80
+ }
81
+ if (first !== undefined && (argv[1] === '--help' || argv[1] === '-h') && kernel.has(first)) {
82
+ const lines = [];
83
+ renderCommandHelp(manifest.name, kernel.get(first), lines);
84
+ output.raw(lines.join('\n'));
85
+ return 0;
86
+ }
87
+ try {
88
+ return await kernel.dispatch(argv);
89
+ }
90
+ catch (error) {
91
+ return renderError(error, output);
92
+ }
93
+ }
94
+ function registerBuiltIns(kernel) {
95
+ kernel.register({
96
+ default: class extends HelpCommand {
97
+ constructor() {
98
+ super(kernel);
99
+ }
100
+ },
101
+ });
102
+ kernel.register({ default: VersionCommand });
103
+ kernel.register({ default: MakeCommand });
104
+ kernel.register({ default: BuildCommand });
105
+ kernel.register({ default: DoctorCommand });
106
+ kernel.register({
107
+ default: class extends DevCommand {
108
+ constructor() {
109
+ super(kernel);
110
+ }
111
+ },
112
+ });
113
+ }
114
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","s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,CAAC,KAAK,CAAE,EAAE,KAAK,CAAC,CAAC;QAC5D,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7B,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAqB;IAC7C,MAAM,CAAC,QAAQ,CAAC;QACd,OAAO,EAAE,KAAM,SAAQ,WAAW;YAChC;gBACE,KAAK,CAAC,MAAM,CAAC,CAAC;YAChB,CAAC;SACF;KACF,CAAC,CAAC;IACH,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;IAC7C,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IAC1C,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;IAC3C,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;IAC5C,MAAM,CAAC,QAAQ,CAAC;QACd,OAAO,EAAE,KAAM,SAAQ,UAAU;YAC/B;gBACE,KAAK,CAAC,MAAM,CAAC,CAAC;YAChB,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1 @@
1
+ export * from '@mudah-cli/terminal';
@@ -0,0 +1,2 @@
1
+ export * from '@mudah-cli/terminal';
2
+ //# sourceMappingURL=terminal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from '@mudah-cli/testing';
@@ -0,0 +1,2 @@
1
+ export * from '@mudah-cli/testing';
2
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
package/dist/ui.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@mudah-cli/ui';
package/dist/ui.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from '@mudah-cli/ui';
2
+ //# sourceMappingURL=ui.js.map
package/dist/ui.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,10 @@
1
+ export interface WatcherOptions {
2
+ /** Debounce window in milliseconds. Default 150. */
3
+ debounceMs?: number;
4
+ }
5
+ /**
6
+ * Watch a set of files or directories (recursively where the platform
7
+ * supports it) and invoke `onChange` after a quiet debounce period.
8
+ * Returns a stop function. Missing paths are skipped silently.
9
+ */
10
+ export declare function createWatcher(paths: string[], onChange: () => void, options?: WatcherOptions): () => void;
@@ -0,0 +1,37 @@
1
+ import { watch, existsSync } from 'node:fs';
2
+ /**
3
+ * Watch a set of files or directories (recursively where the platform
4
+ * supports it) and invoke `onChange` after a quiet debounce period.
5
+ * Returns a stop function. Missing paths are skipped silently.
6
+ */
7
+ export function createWatcher(paths, onChange, options = {}) {
8
+ const debounceMs = options.debounceMs ?? 150;
9
+ let timer = null;
10
+ const emit = () => {
11
+ if (timer)
12
+ clearTimeout(timer);
13
+ timer = setTimeout(() => {
14
+ timer = null;
15
+ onChange();
16
+ }, debounceMs);
17
+ };
18
+ const watchers = [];
19
+ for (const path of paths) {
20
+ if (!existsSync(path))
21
+ continue;
22
+ try {
23
+ watchers.push(watch(path, { recursive: true }, emit));
24
+ }
25
+ catch {
26
+ // Some platforms don't support recursive watch; skip that path.
27
+ }
28
+ }
29
+ return () => {
30
+ if (timer)
31
+ clearTimeout(timer);
32
+ for (const watcher of watchers) {
33
+ watcher.close();
34
+ }
35
+ };
36
+ }
37
+ //# sourceMappingURL=watcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watcher.js","sourceRoot":"","sources":["../src/watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAkB,MAAM,SAAS,CAAC;AAO5D;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAe,EAAE,QAAoB,EAAE,OAAO,GAAmB,EAAE;IAC/F,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,GAAG,CAAC;IAC7C,IAAI,KAAK,GAAyC,IAAI,CAAC;IAEvD,MAAM,IAAI,GAAG,GAAS,EAAE;QACtB,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAC/B,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,KAAK,GAAG,IAAI,CAAC;YACb,QAAQ,EAAE,CAAC;QACb,CAAC,EAAE,UAAU,CAAC,CAAC;IACjB,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAgB,EAAE,CAAC;IACjC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,SAAS;QAChC,IAAI,CAAC;YACH,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;QACxD,CAAC;QAAC,MAAM,CAAC;YACP,gEAAgE;QAClE,CAAC;IACH,CAAC;IAED,OAAO,GAAG,EAAE;QACV,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAC/B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@mudah-cli/mudah",
3
+ "version": "0.1.0",
4
+ "description": "An ergonomic, animation-rich CLI framework — speed, sleek design, and developer ergonomics for Node and Bun.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "engines": {
8
+ "node": ">=26"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./ui": {
16
+ "types": "./dist/ui.d.ts",
17
+ "default": "./dist/ui.js"
18
+ },
19
+ "./terminal": {
20
+ "types": "./dist/terminal.d.ts",
21
+ "default": "./dist/terminal.js"
22
+ },
23
+ "./animation": {
24
+ "types": "./dist/animation.d.ts",
25
+ "default": "./dist/animation.js"
26
+ },
27
+ "./testing": {
28
+ "types": "./dist/testing.d.ts",
29
+ "default": "./dist/testing.js"
30
+ },
31
+ "./package.json": "./package.json"
32
+ },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "sideEffects": false,
37
+ "dependencies": {
38
+ "@mudah-cli/animation": "^0.1.0",
39
+ "@mudah-cli/config": "^0.1.0",
40
+ "@mudah-cli/console": "^0.1.0",
41
+ "@mudah-cli/container": "^0.1.0",
42
+ "@mudah-cli/core": "^0.1.0",
43
+ "@mudah-cli/terminal": "^0.1.0",
44
+ "@mudah-cli/testing": "^0.1.0",
45
+ "@mudah-cli/ui": "^0.1.0"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ }
50
+ }