zyrk 0.3.7 → 0.3.9
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/bin/zyrk.js +1 -1
- package/dist/cli/main.d.ts +54 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +473 -0
- package/dist/cli/npm-delegate.d.ts +38 -0
- package/dist/cli/npm-delegate.d.ts.map +1 -0
- package/{src/cli/npm-delegate.ts → dist/cli/npm-delegate.js} +26 -55
- package/dist/cli/parse.d.ts +40 -0
- package/dist/cli/parse.d.ts.map +1 -0
- package/dist/cli/parse.js +78 -0
- package/dist/commands/dependencies.d.ts +12 -0
- package/dist/commands/dependencies.d.ts.map +1 -0
- package/dist/commands/dependencies.js +118 -0
- package/dist/commands/deploy.d.ts +15 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +506 -0
- package/dist/commands/maintenance.d.ts +27 -0
- package/dist/commands/maintenance.d.ts.map +1 -0
- package/dist/commands/maintenance.js +198 -0
- package/dist/commands/patch.d.ts +38 -0
- package/dist/commands/patch.d.ts.map +1 -0
- package/dist/commands/patch.js +336 -0
- package/dist/commands/project.d.ts +15 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +396 -0
- package/dist/commands/store.d.ts +10 -0
- package/dist/commands/store.d.ts.map +1 -0
- package/dist/commands/store.js +551 -0
- package/dist/config/paths.d.ts +37 -0
- package/dist/config/paths.d.ts.map +1 -0
- package/dist/config/paths.js +66 -0
- package/dist/dlx/create.d.ts +23 -0
- package/dist/dlx/create.d.ts.map +1 -0
- package/dist/dlx/create.js +59 -0
- package/dist/dlx/run.d.ts +54 -0
- package/dist/dlx/run.d.ts.map +1 -0
- package/dist/dlx/run.js +274 -0
- package/dist/errors.d.ts +68 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +111 -0
- package/dist/extract/tarball.d.ts +82 -0
- package/dist/extract/tarball.d.ts.map +1 -0
- package/dist/extract/tarball.js +645 -0
- package/dist/fetch/all.d.ts +48 -0
- package/dist/fetch/all.d.ts.map +1 -0
- package/dist/fetch/all.js +127 -0
- package/dist/fetch/package.d.ts +45 -0
- package/dist/fetch/package.d.ts.map +1 -0
- package/dist/fetch/package.js +124 -0
- package/dist/fetch/registry.d.ts +109 -0
- package/dist/fetch/registry.d.ts.map +1 -0
- package/dist/fetch/registry.js +418 -0
- package/dist/install/import-npm.d.ts +4 -0
- package/dist/install/import-npm.d.ts.map +1 -0
- package/dist/install/import-npm.js +147 -0
- package/dist/install/lock.d.ts +8 -0
- package/dist/install/lock.d.ts.map +1 -0
- package/dist/install/lock.js +146 -0
- package/dist/install/metadata.d.ts +19 -0
- package/dist/install/metadata.d.ts.map +1 -0
- package/dist/install/metadata.js +79 -0
- package/dist/install/registry.d.ts +8 -0
- package/dist/install/registry.d.ts.map +1 -0
- package/dist/install/registry.js +59 -0
- package/dist/install/run.d.ts +32 -0
- package/dist/install/run.d.ts.map +1 -0
- package/dist/install/run.js +545 -0
- package/dist/lockfile/fingerprints.d.ts +35 -0
- package/dist/lockfile/fingerprints.d.ts.map +1 -0
- package/dist/lockfile/fingerprints.js +56 -0
- package/dist/lockfile/read.d.ts +27 -0
- package/dist/lockfile/read.d.ts.map +1 -0
- package/dist/lockfile/read.js +126 -0
- package/dist/lockfile/types.d.ts +74 -0
- package/dist/lockfile/types.d.ts.map +1 -0
- package/dist/lockfile/types.js +17 -0
- package/dist/lockfile/write.d.ts +39 -0
- package/dist/lockfile/write.d.ts.map +1 -0
- package/dist/lockfile/write.js +180 -0
- package/dist/log.d.ts +21 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +79 -0
- package/dist/project/projection.d.ts +50 -0
- package/dist/project/projection.d.ts.map +1 -0
- package/dist/project/projection.js +276 -0
- package/dist/resolve/resolver.d.ts +75 -0
- package/dist/resolve/resolver.d.ts.map +1 -0
- package/dist/resolve/resolver.js +533 -0
- package/dist/resolve/spec.d.ts +26 -0
- package/dist/resolve/spec.d.ts.map +1 -0
- package/dist/resolve/spec.js +87 -0
- package/dist/store/db.d.ts +49 -0
- package/dist/store/db.d.ts.map +1 -0
- package/{src/store/db.ts → dist/store/db.js} +106 -206
- package/dist/store/graph.d.ts +60 -0
- package/dist/store/graph.d.ts.map +1 -0
- package/dist/store/graph.js +115 -0
- package/dist/store/layout.d.ts +71 -0
- package/dist/store/layout.d.ts.map +1 -0
- package/dist/store/layout.js +282 -0
- package/dist/store/manifests.d.ts +78 -0
- package/dist/store/manifests.d.ts.map +1 -0
- package/dist/store/manifests.js +238 -0
- package/dist/store/objects.d.ts +56 -0
- package/dist/store/objects.d.ts.map +1 -0
- package/dist/store/objects.js +157 -0
- package/dist/store/realize.d.ts +38 -0
- package/dist/store/realize.d.ts.map +1 -0
- package/dist/store/realize.js +227 -0
- package/dist/store/source.d.ts +42 -0
- package/dist/store/source.d.ts.map +1 -0
- package/dist/store/source.js +169 -0
- package/dist/store/txn.d.ts +37 -0
- package/dist/store/txn.d.ts.map +1 -0
- package/dist/store/txn.js +97 -0
- package/dist/store/verify.d.ts +40 -0
- package/dist/store/verify.d.ts.map +1 -0
- package/dist/store/verify.js +396 -0
- package/dist/util/fsx.d.ts +54 -0
- package/dist/util/fsx.d.ts.map +1 -0
- package/dist/util/fsx.js +259 -0
- package/dist/util/hash.d.ts +48 -0
- package/dist/util/hash.d.ts.map +1 -0
- package/dist/util/hash.js +80 -0
- package/dist/util/ids.d.ts +19 -0
- package/dist/util/ids.d.ts.map +1 -0
- package/dist/util/ids.js +38 -0
- package/dist/util/integrity.d.ts +97 -0
- package/dist/util/integrity.d.ts.map +1 -0
- package/dist/util/integrity.js +192 -0
- package/dist/util/json.d.ts +14 -0
- package/dist/util/json.d.ts.map +1 -0
- package/dist/util/json.js +78 -0
- package/dist/util/locks.d.ts +40 -0
- package/dist/util/locks.d.ts.map +1 -0
- package/dist/util/locks.js +186 -0
- package/dist/util/proc.d.ts +32 -0
- package/dist/util/proc.d.ts.map +1 -0
- package/dist/util/proc.js +84 -0
- package/dist/version.d.ts +27 -0
- package/dist/version.d.ts.map +1 -0
- package/{src/version.ts → dist/version.js} +0 -8
- package/package.json +5 -3
- package/src/cli/main.ts +0 -468
- package/src/cli/parse.ts +0 -106
- package/src/commands/dependencies.ts +0 -154
- package/src/commands/deploy.ts +0 -777
- package/src/commands/maintenance.ts +0 -260
- package/src/commands/patch.ts +0 -408
- package/src/commands/project.ts +0 -598
- package/src/commands/store.ts +0 -689
- package/src/config/paths.ts +0 -119
- package/src/dlx/create.ts +0 -69
- package/src/dlx/run.ts +0 -389
- package/src/errors.ts +0 -142
- package/src/extract/tarball.ts +0 -868
- package/src/fetch/all.ts +0 -206
- package/src/fetch/package.ts +0 -181
- package/src/fetch/registry.ts +0 -615
- package/src/install/import-npm.ts +0 -177
- package/src/install/lock.ts +0 -176
- package/src/install/metadata.ts +0 -122
- package/src/install/registry.ts +0 -88
- package/src/install/run.ts +0 -760
- package/src/lockfile/fingerprints.ts +0 -74
- package/src/lockfile/read.ts +0 -198
- package/src/lockfile/types.ts +0 -75
- package/src/lockfile/write.ts +0 -257
- package/src/log.ts +0 -100
- package/src/project/projection.ts +0 -390
- package/src/resolve/resolver.ts +0 -757
- package/src/resolve/spec.ts +0 -131
- package/src/store/graph.ts +0 -175
- package/src/store/layout.ts +0 -431
- package/src/store/manifests.ts +0 -347
- package/src/store/objects.ts +0 -229
- package/src/store/realize.ts +0 -322
- package/src/store/source.ts +0 -249
- package/src/store/txn.ts +0 -118
- package/src/store/verify.ts +0 -433
- package/src/types/vendor.d.ts +0 -120
- package/src/util/fsx.ts +0 -289
- package/src/util/hash.ts +0 -117
- package/src/util/ids.ts +0 -42
- package/src/util/integrity.ts +0 -269
- package/src/util/json.ts +0 -89
- package/src/util/locks.ts +0 -266
- package/src/util/proc.ts +0 -108
|
@@ -16,14 +16,11 @@
|
|
|
16
16
|
* operate outside zyrk's dependency management. Global installs are never
|
|
17
17
|
* delegated (F-018); see parse.ts.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
19
|
import { spawn } from "node:child_process";
|
|
21
|
-
import { ZyrkError } from "../errors.
|
|
22
|
-
import { closeCode } from "../util/proc.
|
|
23
|
-
|
|
20
|
+
import { ZyrkError } from "../errors.js";
|
|
21
|
+
import { closeCode } from "../util/proc.js";
|
|
24
22
|
/** Delegated command, its aliases collapsed, plus help text. */
|
|
25
|
-
const DELEGATED_COMMANDS
|
|
26
|
-
[
|
|
23
|
+
const DELEGATED_COMMANDS = [
|
|
27
24
|
[["publish"], "Publish the current package to the registry (via npm)."],
|
|
28
25
|
[["unpublish"], "Remove a published version from the registry (via npm)."],
|
|
29
26
|
[["access"], "Manage package access and visibility (via npm)."],
|
|
@@ -36,62 +33,36 @@ const DELEGATED_COMMANDS: ReadonlyArray<readonly [readonly string[], string]> =
|
|
|
36
33
|
[["whoami"], "Show the authenticated registry username (via npm)."],
|
|
37
34
|
[["ping"], "Check registry authentication and reachability (via npm)."],
|
|
38
35
|
[["pack"], "Create a tarball from the current package (via npm)."],
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
export function isDelegatedCommand(command: string): boolean {
|
|
46
|
-
return DELEGATED_COMMAND_NAMES.has(command);
|
|
36
|
+
];
|
|
37
|
+
export const DELEGATED_COMMAND_NAMES = new Set(DELEGATED_COMMANDS.flatMap(([names]) => names));
|
|
38
|
+
export function isDelegatedCommand(command) {
|
|
39
|
+
return DELEGATED_COMMAND_NAMES.has(command);
|
|
47
40
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return DELEGATED_COMMANDS.map(
|
|
51
|
-
([names, description]) =>
|
|
52
|
-
` ${names.join(", ").padEnd(22, " ")}${description}`,
|
|
53
|
-
);
|
|
41
|
+
export function delegatedHelpLines() {
|
|
42
|
+
return DELEGATED_COMMANDS.map(([names, description]) => ` ${names.join(", ").padEnd(22, " ")}${description}`);
|
|
54
43
|
}
|
|
55
|
-
|
|
56
|
-
export type DelegateOptions = {
|
|
57
|
-
command: string;
|
|
58
|
-
/** Raw tokens after the command, verbatim (may include --json, --, -g). */
|
|
59
|
-
args: readonly string[];
|
|
60
|
-
env: NodeJS.ProcessEnv;
|
|
61
|
-
stderr: { write(chunk: string): unknown };
|
|
62
|
-
};
|
|
63
|
-
|
|
64
44
|
/**
|
|
65
45
|
* Exec `npm <command> <args...>` with inherited stdio. Resolves with the
|
|
66
46
|
* child exit code, or 128 plus the signal number when signaled (the shell
|
|
67
47
|
* convention), so callers observe the same termination. Rejects with
|
|
68
48
|
* ZYRK_NPM_UNAVAILABLE when npm cannot be launched.
|
|
69
49
|
*/
|
|
70
|
-
export async function delegateToNpm(options
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
50
|
+
export async function delegateToNpm(options) {
|
|
51
|
+
options.stderr.write(`zyrk: delegating \`zyrk ${options.command}\` to npm; zyrk does not implement publishing or registry authentication.\n`);
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
const child = spawn("npm", [options.command, ...options.args], {
|
|
54
|
+
env: options.env,
|
|
55
|
+
stdio: "inherit",
|
|
56
|
+
});
|
|
57
|
+
child.on("error", (error) => {
|
|
58
|
+
reject(new ZyrkError("ZYRK_NPM_UNAVAILABLE", "zyrk could not launch npm for an explicitly delegated command.", {
|
|
59
|
+
detail: { command: options.command },
|
|
60
|
+
remedy: "Install Node.js with npm on PATH, or run the npm command directly.",
|
|
61
|
+
cause: error,
|
|
62
|
+
}));
|
|
63
|
+
});
|
|
64
|
+
child.on("close", (code, signal) => {
|
|
65
|
+
resolve(closeCode(code, signal));
|
|
66
|
+
});
|
|
78
67
|
});
|
|
79
|
-
child.on("error", (error) => {
|
|
80
|
-
reject(
|
|
81
|
-
new ZyrkError(
|
|
82
|
-
"ZYRK_NPM_UNAVAILABLE",
|
|
83
|
-
"zyrk could not launch npm for an explicitly delegated command.",
|
|
84
|
-
{
|
|
85
|
-
detail: { command: options.command },
|
|
86
|
-
remedy:
|
|
87
|
-
"Install Node.js with npm on PATH, or run the npm command directly.",
|
|
88
|
-
cause: error,
|
|
89
|
-
},
|
|
90
|
-
),
|
|
91
|
-
);
|
|
92
|
-
});
|
|
93
|
-
child.on("close", (code, signal) => {
|
|
94
|
-
resolve(closeCode(code, signal));
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
68
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal argv parsing for the zyrk CLI (SPEC 15).
|
|
3
|
+
*
|
|
4
|
+
* zyrk takes no global configuration file of its own here: flags are parsed
|
|
5
|
+
* per invocation. `--json` anywhere before the `--` separator selects the
|
|
6
|
+
* machine-readable envelope. Everything after `--` belongs to the requested
|
|
7
|
+
* user command (SPEC 15.3.1: flags following the separator for `run`/`exec`
|
|
8
|
+
* remain user arguments, never zyrk options).
|
|
9
|
+
*/
|
|
10
|
+
export type ParsedArgs = {
|
|
11
|
+
help: boolean;
|
|
12
|
+
version: boolean;
|
|
13
|
+
/** The requested command, or undefined when none was given. */
|
|
14
|
+
command: string | undefined;
|
|
15
|
+
/** Everything that is not the command, `--json`, or `--help`/`--version`. */
|
|
16
|
+
commandArgs: string[];
|
|
17
|
+
/** Raw tokens after the command token, verbatim, for npm delegation. */
|
|
18
|
+
argsAfterCommand: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Non-zyrk tokens placed before the command token, in order. Delegation
|
|
21
|
+
* forwards these too: a leading protective flag such as `--dry-run`
|
|
22
|
+
* belongs to npm, and dropping it would silently change what runs (S05).
|
|
23
|
+
*/
|
|
24
|
+
argsBeforeCommand: string[];
|
|
25
|
+
json: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare function parseArgs(argv: readonly string[]): ParsedArgs;
|
|
28
|
+
/**
|
|
29
|
+
* Detect global-install mode before any work happens.
|
|
30
|
+
*
|
|
31
|
+
* Exact tokens `-g` and `--global` in any position, plus the `--global=true`
|
|
32
|
+
* spelling, select global mode; `install`/`add` take no `--` payload, so
|
|
33
|
+
* tokens after a separator are still zyrk's. Explicit local selections
|
|
34
|
+
* (`--no-global`, `--global=false`) do not trigger. zyrk defines no
|
|
35
|
+
* configuration that selects global-install mode, so the only remaining
|
|
36
|
+
* channel is the environment npm itself documents: `npm_config_global=true`
|
|
37
|
+
* is honored as a fail-safe, never as a silent conversion.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isGlobalInstallRequest(command: string, commandArgs: readonly string[], env: NodeJS.ProcessEnv): boolean;
|
|
40
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/cli/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,6EAA6E;IAC7E,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,wEAAwE;IACxE,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAkD7D;AAKD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,OAAO,CAOT"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal argv parsing for the zyrk CLI (SPEC 15).
|
|
3
|
+
*
|
|
4
|
+
* zyrk takes no global configuration file of its own here: flags are parsed
|
|
5
|
+
* per invocation. `--json` anywhere before the `--` separator selects the
|
|
6
|
+
* machine-readable envelope. Everything after `--` belongs to the requested
|
|
7
|
+
* user command (SPEC 15.3.1: flags following the separator for `run`/`exec`
|
|
8
|
+
* remain user arguments, never zyrk options).
|
|
9
|
+
*/
|
|
10
|
+
export function parseArgs(argv) {
|
|
11
|
+
const parsed = {
|
|
12
|
+
help: false,
|
|
13
|
+
version: false,
|
|
14
|
+
command: undefined,
|
|
15
|
+
commandArgs: [],
|
|
16
|
+
argsAfterCommand: [],
|
|
17
|
+
argsBeforeCommand: [],
|
|
18
|
+
json: false,
|
|
19
|
+
};
|
|
20
|
+
let separator = false;
|
|
21
|
+
let commandIndex = -1;
|
|
22
|
+
argv.forEach((token, index) => {
|
|
23
|
+
if (separator) {
|
|
24
|
+
parsed.commandArgs.push(token);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (token === "--") {
|
|
28
|
+
separator = true;
|
|
29
|
+
parsed.commandArgs.push(token);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (token === "--json") {
|
|
33
|
+
parsed.json = true;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (parsed.command === undefined &&
|
|
37
|
+
(token === "--help" || token === "-h")) {
|
|
38
|
+
parsed.help = true;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (parsed.command === undefined &&
|
|
42
|
+
(token === "--version" || token === "-v")) {
|
|
43
|
+
parsed.version = true;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (parsed.command === undefined && !token.startsWith("-")) {
|
|
47
|
+
parsed.command = token;
|
|
48
|
+
commandIndex = index;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (parsed.command === undefined)
|
|
52
|
+
parsed.argsBeforeCommand.push(token);
|
|
53
|
+
parsed.commandArgs.push(token);
|
|
54
|
+
});
|
|
55
|
+
if (commandIndex >= 0)
|
|
56
|
+
parsed.argsAfterCommand = argv.slice(commandIndex + 1);
|
|
57
|
+
return parsed;
|
|
58
|
+
}
|
|
59
|
+
/** Commands whose global-install mode zyrk rejects (SPEC 15.3.1, 22.3). */
|
|
60
|
+
const GLOBAL_INSTALL_COMMANDS = new Set(["install", "i", "add"]);
|
|
61
|
+
/**
|
|
62
|
+
* Detect global-install mode before any work happens.
|
|
63
|
+
*
|
|
64
|
+
* Exact tokens `-g` and `--global` in any position, plus the `--global=true`
|
|
65
|
+
* spelling, select global mode; `install`/`add` take no `--` payload, so
|
|
66
|
+
* tokens after a separator are still zyrk's. Explicit local selections
|
|
67
|
+
* (`--no-global`, `--global=false`) do not trigger. zyrk defines no
|
|
68
|
+
* configuration that selects global-install mode, so the only remaining
|
|
69
|
+
* channel is the environment npm itself documents: `npm_config_global=true`
|
|
70
|
+
* is honored as a fail-safe, never as a silent conversion.
|
|
71
|
+
*/
|
|
72
|
+
export function isGlobalInstallRequest(command, commandArgs, env) {
|
|
73
|
+
if (!GLOBAL_INSTALL_COMMANDS.has(command))
|
|
74
|
+
return false;
|
|
75
|
+
if (env.npm_config_global === "true")
|
|
76
|
+
return true;
|
|
77
|
+
return commandArgs.some((token) => token === "-g" || token === "--global" || token === "--global=true");
|
|
78
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RegistryClient } from "../fetch/registry.ts";
|
|
2
|
+
import type { Store } from "../store/layout.ts";
|
|
3
|
+
import { type InstallResult } from "../install/run.ts";
|
|
4
|
+
export type DependencyCommand = "add" | "remove" | "update" | "import";
|
|
5
|
+
export declare function runDependencyCommand(options: {
|
|
6
|
+
command: DependencyCommand;
|
|
7
|
+
args: readonly string[];
|
|
8
|
+
projectDir: string;
|
|
9
|
+
store: Store;
|
|
10
|
+
registry: RegistryClient;
|
|
11
|
+
}): Promise<InstallResult>;
|
|
12
|
+
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/commands/dependencies.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAavE,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,cAAc,CAAC;CAC1B,GAAG,OAAO,CAAC,aAAa,CAAC,CA0HzB"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** Parse dependency edits; the installer owns resolution and atomic publication. */
|
|
2
|
+
import npa from "npm-package-arg";
|
|
3
|
+
import { ZyrkError } from "../errors.js";
|
|
4
|
+
import { packageName } from "../install/lock.js";
|
|
5
|
+
import { installProject, } from "../install/run.js";
|
|
6
|
+
function usage(command, reason) {
|
|
7
|
+
return new ZyrkError("ZYRK_USAGE", `Cannot ${command} dependencies: ${reason}.`, {
|
|
8
|
+
remedy: "Use add <spec...>, remove <name...>, update [--latest] [name...], or import --from npm; review zyrk --help for supported options.",
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export async function runDependencyCommand(options) {
|
|
12
|
+
const { command } = options;
|
|
13
|
+
const install = {
|
|
14
|
+
projectDir: options.projectDir,
|
|
15
|
+
store: options.store,
|
|
16
|
+
registry: options.registry,
|
|
17
|
+
};
|
|
18
|
+
const names = [];
|
|
19
|
+
let from;
|
|
20
|
+
let latest = false;
|
|
21
|
+
let positional = false;
|
|
22
|
+
for (let i = 0; i < options.args.length; i++) {
|
|
23
|
+
const arg = options.args[i];
|
|
24
|
+
if (!positional && arg === "--") {
|
|
25
|
+
positional = true;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (!positional && arg.startsWith("-")) {
|
|
29
|
+
switch (arg) {
|
|
30
|
+
case "-D":
|
|
31
|
+
case "--save-dev":
|
|
32
|
+
if (command !== "add")
|
|
33
|
+
throw usage(command, "--save-dev is only valid for add");
|
|
34
|
+
install.saveDev = true;
|
|
35
|
+
break;
|
|
36
|
+
case "-O":
|
|
37
|
+
case "--save-optional":
|
|
38
|
+
if (command !== "add")
|
|
39
|
+
throw usage(command, "--save-optional is only valid for add");
|
|
40
|
+
install.saveOptional = true;
|
|
41
|
+
break;
|
|
42
|
+
case "-E":
|
|
43
|
+
case "--save-exact":
|
|
44
|
+
if (command !== "add" && command !== "update")
|
|
45
|
+
throw usage(command, "--save-exact is only valid for add or update");
|
|
46
|
+
install.saveExact = true;
|
|
47
|
+
break;
|
|
48
|
+
case "--latest":
|
|
49
|
+
if (command !== "update")
|
|
50
|
+
throw usage(command, "--latest is only valid for update");
|
|
51
|
+
latest = true;
|
|
52
|
+
break;
|
|
53
|
+
case "--ignore-scripts":
|
|
54
|
+
install.ignoreScripts = true;
|
|
55
|
+
break;
|
|
56
|
+
case "--lockfile-only":
|
|
57
|
+
install.lockfileOnly = true;
|
|
58
|
+
break;
|
|
59
|
+
case "--from":
|
|
60
|
+
if (command !== "import" || from !== undefined)
|
|
61
|
+
throw usage(command, "unexpected --from option");
|
|
62
|
+
from = options.args[++i];
|
|
63
|
+
if (from === undefined)
|
|
64
|
+
throw usage(command, "--from requires npm");
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
if (arg.startsWith("--from=") &&
|
|
68
|
+
command === "import" &&
|
|
69
|
+
from === undefined) {
|
|
70
|
+
from = arg.slice(7);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
if (command === "add" &&
|
|
74
|
+
["-g", "--global", "--global=true"].includes(arg))
|
|
75
|
+
throw new ZyrkError("ZYRK_GLOBAL_INSTALL_UNSUPPORTED", "Cannot install global dependencies through zyrk.", { remedy: "Run npm install --global directly instead." });
|
|
76
|
+
throw usage(command, "an unsupported option was supplied");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else
|
|
80
|
+
names.push(arg);
|
|
81
|
+
}
|
|
82
|
+
if (install.saveDev && install.saveOptional)
|
|
83
|
+
throw usage(command, "development and optional dependency groups conflict");
|
|
84
|
+
switch (command) {
|
|
85
|
+
case "add":
|
|
86
|
+
if (!names.length)
|
|
87
|
+
throw usage(command, "at least one package specification is required");
|
|
88
|
+
for (const name of names) {
|
|
89
|
+
try {
|
|
90
|
+
const parsed = npa(name);
|
|
91
|
+
if (!parsed.name ||
|
|
92
|
+
!packageName(parsed.name) ||
|
|
93
|
+
!["version", "range", "tag", "alias"].includes(parsed.type))
|
|
94
|
+
throw new Error("unsupported");
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
throw usage(command, "a registry package specification is invalid");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
install.specs = names;
|
|
101
|
+
break;
|
|
102
|
+
case "remove":
|
|
103
|
+
case "update":
|
|
104
|
+
if (command === "remove" && !names.length)
|
|
105
|
+
throw usage(command, "at least one direct dependency name is required");
|
|
106
|
+
if (names.some((name) => !packageName(name)))
|
|
107
|
+
throw usage(command, "expected direct dependency names without versions");
|
|
108
|
+
install.mutation =
|
|
109
|
+
command === "remove" ? { remove: names } : { update: names, latest };
|
|
110
|
+
break;
|
|
111
|
+
case "import":
|
|
112
|
+
if (from !== "npm" || names.length)
|
|
113
|
+
throw usage(command, "import requires --from npm and no package arguments");
|
|
114
|
+
install.importNpm = true;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
return installProject(install);
|
|
118
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type DeployCommandOptions = {
|
|
2
|
+
command: "deploy" | "docker";
|
|
3
|
+
args: readonly string[];
|
|
4
|
+
cwd: string;
|
|
5
|
+
env: NodeJS.ProcessEnv;
|
|
6
|
+
stdout: {
|
|
7
|
+
write(chunk: string): unknown;
|
|
8
|
+
};
|
|
9
|
+
stderr: {
|
|
10
|
+
write(chunk: string): unknown;
|
|
11
|
+
};
|
|
12
|
+
json?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function runDeployCommand(options: DeployCommandOptions): Promise<number>;
|
|
15
|
+
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AA8CA,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC7B,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,MAAM,EAAE;QAAE,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC1C,MAAM,EAAE;QAAE,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAwEF,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAmUjB"}
|