@reliverse/rempts 1.7.17 → 1.7.19
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.
|
@@ -295,7 +295,8 @@ export async function showUsage(command, parserOptions = {}) {
|
|
|
295
295
|
def.description ?? "",
|
|
296
296
|
`type=${def.type}`,
|
|
297
297
|
def.default !== void 0 ? `default=${JSON.stringify(def.default)}` : null,
|
|
298
|
-
def.required ? "required" : null
|
|
298
|
+
def.required ? "required" : null,
|
|
299
|
+
def.dependencies ? `depends on: ${def.dependencies.map((r) => `--${r}`).join(", ")}` : null
|
|
299
300
|
].filter(Boolean);
|
|
300
301
|
optionItems.push({ text, desc: parts.join(" | ") });
|
|
301
302
|
}
|
|
@@ -674,6 +675,23 @@ async function runCommandWithArgs(command, argv, parserOptions, returnCtx) {
|
|
|
674
675
|
if (autoExit) process.exit(1);
|
|
675
676
|
else throw new Error(`Missing required argument: --${key}`);
|
|
676
677
|
}
|
|
678
|
+
if (def.dependencies && Array.isArray(def.dependencies)) {
|
|
679
|
+
for (const dependency of def.dependencies) {
|
|
680
|
+
const dependencyValue = parsed[dependency] ?? defaultMap[dependency];
|
|
681
|
+
if (!dependencyValue) {
|
|
682
|
+
await showUsage(command, parserOptions);
|
|
683
|
+
relinka(
|
|
684
|
+
"error",
|
|
685
|
+
`Argument --${key} requires --${dependency} to be set`
|
|
686
|
+
);
|
|
687
|
+
if (autoExit) process.exit(1);
|
|
688
|
+
else
|
|
689
|
+
throw new Error(
|
|
690
|
+
`Argument --${key} requires --${dependency} to be set`
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
677
695
|
try {
|
|
678
696
|
if (def.type === "boolean") {
|
|
679
697
|
finalArgs[key] = rawVal !== void 0 ? castArgValue(def, rawVal, key) : false;
|
|
@@ -878,6 +896,16 @@ export async function runCmd(command, argv = [], parserOptions = {}) {
|
|
|
878
896
|
if (valueOrDefault == null && def.required) {
|
|
879
897
|
throw new Error(`Missing required argument: --${key}`);
|
|
880
898
|
}
|
|
899
|
+
if (def.dependencies && Array.isArray(def.dependencies)) {
|
|
900
|
+
for (const dependency of def.dependencies) {
|
|
901
|
+
const dependencyValue = parsed[dependency] ?? defaultMap[dependency];
|
|
902
|
+
if (!dependencyValue) {
|
|
903
|
+
throw new Error(
|
|
904
|
+
`Argument --${key} requires --${dependency} to be set`
|
|
905
|
+
);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
881
909
|
try {
|
|
882
910
|
if (def.type === "boolean") {
|
|
883
911
|
finalArgs[key] = rawVal !== void 0 ? castArgValue(def, rawVal, key) : false;
|
|
@@ -4,28 +4,40 @@ export type BaseArgProps = {
|
|
|
4
4
|
required?: boolean;
|
|
5
5
|
allowed?: string[];
|
|
6
6
|
};
|
|
7
|
-
export type
|
|
7
|
+
export type BaseArgDefinition = {
|
|
8
|
+
type: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
default?: any;
|
|
12
|
+
allowed?: any[];
|
|
13
|
+
dependencies?: string[];
|
|
14
|
+
};
|
|
15
|
+
export type PositionalArgDefinition = BaseArgDefinition & {
|
|
8
16
|
type: "positional";
|
|
9
17
|
default?: string;
|
|
10
|
-
}
|
|
11
|
-
export type BooleanArgDefinition = {
|
|
18
|
+
};
|
|
19
|
+
export type BooleanArgDefinition = BaseArgDefinition & {
|
|
12
20
|
type: "boolean";
|
|
13
21
|
default?: boolean;
|
|
14
22
|
allowed?: boolean[];
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
alias?: string;
|
|
24
|
+
};
|
|
25
|
+
export type StringArgDefinition = BaseArgDefinition & {
|
|
17
26
|
type: "string";
|
|
18
27
|
default?: string;
|
|
19
|
-
|
|
20
|
-
|
|
28
|
+
alias?: string;
|
|
29
|
+
};
|
|
30
|
+
export type NumberArgDefinition = BaseArgDefinition & {
|
|
21
31
|
type: "number";
|
|
22
32
|
default?: number;
|
|
23
33
|
allowed?: number[];
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
alias?: string;
|
|
35
|
+
};
|
|
36
|
+
export type ArrayArgDefinition = BaseArgDefinition & {
|
|
26
37
|
type: "array";
|
|
27
38
|
default?: string | readonly string[];
|
|
28
|
-
|
|
39
|
+
alias?: string;
|
|
40
|
+
};
|
|
29
41
|
export type ArgDefinition = PositionalArgDefinition | BooleanArgDefinition | StringArgDefinition | NumberArgDefinition | ArrayArgDefinition;
|
|
30
42
|
export type ArgDefinitions = Record<string, ArgDefinition>;
|
|
31
43
|
export type CommandMeta = {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"@reliverse/pathkit": "^1.2.1",
|
|
5
5
|
"@reliverse/reliarg": "^1.0.3",
|
|
6
6
|
"@reliverse/relico": "^1.1.2",
|
|
7
|
-
"@reliverse/relifso": "^1.
|
|
7
|
+
"@reliverse/relifso": "^1.4.5",
|
|
8
8
|
"@reliverse/relinka": "^1.4.7",
|
|
9
9
|
"@reliverse/runtime": "^1.0.3",
|
|
10
10
|
"ansi-escapes": "^7.0.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"name": "@reliverse/rempts",
|
|
31
31
|
"type": "module",
|
|
32
|
-
"version": "1.7.
|
|
32
|
+
"version": "1.7.19",
|
|
33
33
|
"author": "reliverse",
|
|
34
34
|
"bugs": {
|
|
35
35
|
"email": "blefnk@gmail.com",
|