zyrk 0.3.7 → 0.3.8
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/VERSION +1 -1
- package/package.json +1 -1
- package/src/cli/main.ts +137 -3
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v0.3.
|
|
1
|
+
v0.3.8
|
package/package.json
CHANGED
package/src/cli/main.ts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* This is the roadmap skeleton, not the whole implementation: `dlx` and
|
|
5
5
|
* `create` run temporary tool environments; `--help`, `--version`, the
|
|
6
6
|
* global-install rejection, and explicit npm delegation do their jobs.
|
|
7
|
-
* `install` publishes a verified shared project graph. Other dependency
|
|
8
|
-
* rather than pretending to work;
|
|
7
|
+
* `install` publishes a verified shared project graph. Other dependency
|
|
8
|
+
* commands fail with ZYRK_NOT_IMPLEMENTED rather than pretending to work;
|
|
9
|
+
* unknown commands fail with ZYRK_USAGE
|
|
9
10
|
* and the help text.
|
|
10
11
|
* Nothing here launches a subprocess: rejection happens before resolution,
|
|
11
12
|
* downloads, lifecycle execution, project/store mutation, or any child
|
|
@@ -19,7 +20,17 @@ import * as path from "node:path";
|
|
|
19
20
|
import { fileURLToPath } from "node:url";
|
|
20
21
|
import { runCreate } from "../dlx/create.ts";
|
|
21
22
|
import { runDlx } from "../dlx/run.ts";
|
|
23
|
+
import {
|
|
24
|
+
runDependencyCommand,
|
|
25
|
+
type DependencyCommand,
|
|
26
|
+
} from "../commands/dependencies.ts";
|
|
27
|
+
import {
|
|
28
|
+
runProjectCommand,
|
|
29
|
+
type ProjectCommandOptions,
|
|
30
|
+
} from "../commands/project.ts";
|
|
31
|
+
import { runStoreCommand } from "../commands/store.ts";
|
|
22
32
|
import { exitCodeFor, ZyrkError, toZyrkError } from "../errors.ts";
|
|
33
|
+
export { ZyrkError };
|
|
23
34
|
import { DEFAULT_REGISTRY, RegistryClient } from "../fetch/registry.ts";
|
|
24
35
|
import { resolveStoreRoot } from "../config/paths.ts";
|
|
25
36
|
import { Store } from "../store/layout.ts";
|
|
@@ -62,7 +73,24 @@ for (const [names] of NATIVE_COMMANDS) {
|
|
|
62
73
|
}
|
|
63
74
|
|
|
64
75
|
/** Commands with a real implementation behind runCli. */
|
|
65
|
-
const IMPLEMENTED_COMMANDS = new Set([
|
|
76
|
+
const IMPLEMENTED_COMMANDS = new Set([
|
|
77
|
+
"dlx",
|
|
78
|
+
"create",
|
|
79
|
+
"install",
|
|
80
|
+
"i",
|
|
81
|
+
"add",
|
|
82
|
+
"remove",
|
|
83
|
+
"update",
|
|
84
|
+
"import",
|
|
85
|
+
"run",
|
|
86
|
+
"exec",
|
|
87
|
+
"list",
|
|
88
|
+
"why",
|
|
89
|
+
"doctor",
|
|
90
|
+
"repair",
|
|
91
|
+
"store",
|
|
92
|
+
"projects",
|
|
93
|
+
]);
|
|
66
94
|
|
|
67
95
|
export function helpText(version: string): string {
|
|
68
96
|
const lines = [
|
|
@@ -399,6 +427,112 @@ export async function runCli(options: RunCliOptions): Promise<number> {
|
|
|
399
427
|
);
|
|
400
428
|
}
|
|
401
429
|
}
|
|
430
|
+
|
|
431
|
+
// Dependency commands: add, remove, update, import
|
|
432
|
+
if (
|
|
433
|
+
!parsed.help &&
|
|
434
|
+
!parsed.version &&
|
|
435
|
+
(parsed.command === "add" ||
|
|
436
|
+
parsed.command === "remove" ||
|
|
437
|
+
parsed.command === "update" ||
|
|
438
|
+
parsed.command === "import")
|
|
439
|
+
) {
|
|
440
|
+
try {
|
|
441
|
+
const tools =
|
|
442
|
+
options.tools === undefined
|
|
443
|
+
? await defaultTools(options.env, version)
|
|
444
|
+
: await options.tools();
|
|
445
|
+
const result = await runDependencyCommand({
|
|
446
|
+
command: parsed.command as DependencyCommand,
|
|
447
|
+
args: parsed.commandArgs,
|
|
448
|
+
projectDir: options.cwd ?? process.cwd(),
|
|
449
|
+
store: tools.store,
|
|
450
|
+
registry: tools.registry,
|
|
451
|
+
});
|
|
452
|
+
if (parsed.json) {
|
|
453
|
+
return emit({
|
|
454
|
+
exitCode: 0,
|
|
455
|
+
stdout: `${JSON.stringify({ schemaVersion: CLI_JSON_SCHEMA_VERSION, status: "ok", ...result })}\n`,
|
|
456
|
+
stderr: "",
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
return emit({
|
|
460
|
+
exitCode: 0,
|
|
461
|
+
stdout: `Dependency command ${parsed.command} completed.\n`,
|
|
462
|
+
stderr: "",
|
|
463
|
+
});
|
|
464
|
+
} catch (error) {
|
|
465
|
+
return emit(
|
|
466
|
+
fail(toZyrkError(error, `zyrk ${parsed.command} failed.`), parsed),
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Project commands: run, exec, list, why, doctor, repair
|
|
472
|
+
if (
|
|
473
|
+
!parsed.help &&
|
|
474
|
+
!parsed.version &&
|
|
475
|
+
(parsed.command === "run" ||
|
|
476
|
+
parsed.command === "exec" ||
|
|
477
|
+
parsed.command === "list" ||
|
|
478
|
+
parsed.command === "why" ||
|
|
479
|
+
parsed.command === "doctor" ||
|
|
480
|
+
parsed.command === "repair")
|
|
481
|
+
) {
|
|
482
|
+
try {
|
|
483
|
+
return await runProjectCommand({
|
|
484
|
+
command: parsed.command,
|
|
485
|
+
args: parsed.commandArgs,
|
|
486
|
+
cwd: options.cwd ?? process.cwd(),
|
|
487
|
+
env: options.env,
|
|
488
|
+
stdout: options.stdout,
|
|
489
|
+
stderr: options.stderr,
|
|
490
|
+
json: parsed.json,
|
|
491
|
+
});
|
|
492
|
+
} catch (error) {
|
|
493
|
+
return emit(
|
|
494
|
+
fail(toZyrkError(error, `zyrk ${parsed.command} failed.`), parsed),
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// Store and projects commands: store path/status/verify/gc/pin/unpin, projects list/forget
|
|
500
|
+
if (
|
|
501
|
+
!parsed.help &&
|
|
502
|
+
!parsed.version &&
|
|
503
|
+
(parsed.command === "store" || parsed.command === "projects")
|
|
504
|
+
) {
|
|
505
|
+
try {
|
|
506
|
+
const tools =
|
|
507
|
+
options.tools === undefined
|
|
508
|
+
? await defaultTools(options.env, version)
|
|
509
|
+
: await options.tools();
|
|
510
|
+
const result = await runStoreCommand({
|
|
511
|
+
command: parsed.command as "store" | "projects",
|
|
512
|
+
args: parsed.commandArgs,
|
|
513
|
+
store: tools.store,
|
|
514
|
+
cwd: options.cwd ?? process.cwd(),
|
|
515
|
+
json: parsed.json,
|
|
516
|
+
});
|
|
517
|
+
if (parsed.json) {
|
|
518
|
+
return emit({
|
|
519
|
+
exitCode: 0,
|
|
520
|
+
stdout: `${JSON.stringify({ schemaVersion: CLI_JSON_SCHEMA_VERSION, status: "ok", ...(result as Record<string, unknown>) })}\n`,
|
|
521
|
+
stderr: "",
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
return emit({
|
|
525
|
+
exitCode: 0,
|
|
526
|
+
stdout: `${JSON.stringify(result)}\n`,
|
|
527
|
+
stderr: "",
|
|
528
|
+
});
|
|
529
|
+
} catch (error) {
|
|
530
|
+
return emit(
|
|
531
|
+
fail(toZyrkError(error, `zyrk ${parsed.command} failed.`), parsed),
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
402
536
|
return emit(dispatch(parsed, { version, env: options.env }));
|
|
403
537
|
}
|
|
404
538
|
|