@nu-art/commando 0.203.122 → 0.204.1
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/cli/cli-params.d.ts +5 -0
- package/cli/cli-params.js +5 -1
- package/package.json +2 -2
package/cli/cli-params.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export type CliParams<T extends BaseCliParam<string, any>[]> = {
|
|
|
7
7
|
keyName: K;
|
|
8
8
|
}>['defaultValue']>;
|
|
9
9
|
};
|
|
10
|
+
export type DependencyParam<T extends Primitive | Primitive[]> = {
|
|
11
|
+
param: BaseCliParam<string, T>;
|
|
12
|
+
value: T;
|
|
13
|
+
};
|
|
10
14
|
export type BaseCliParam<K extends string, V extends Primitive | Primitive[]> = {
|
|
11
15
|
keys: string[];
|
|
12
16
|
keyName: K;
|
|
@@ -18,6 +22,7 @@ export type BaseCliParam<K extends string, V extends Primitive | Primitive[]> =
|
|
|
18
22
|
process?: (value?: string, defaultValue?: V) => V;
|
|
19
23
|
isArray?: true;
|
|
20
24
|
group?: string;
|
|
25
|
+
dependencies?: DependencyParam<any>[];
|
|
21
26
|
};
|
|
22
27
|
export type CliParam<K extends string, V extends Primitive | Primitive[]> = BaseCliParam<K, V> & {
|
|
23
28
|
name: string;
|
package/cli/cli-params.js
CHANGED
|
@@ -45,6 +45,7 @@ class CLIParams_Resolver {
|
|
|
45
45
|
*/
|
|
46
46
|
resolveParamValue(inputParams = process.argv.slice(2, process.argv.length)) {
|
|
47
47
|
return inputParams.reduce((output, inputParam) => {
|
|
48
|
+
var _a;
|
|
48
49
|
const cliParamToResolve = this.findMatchingParamToResolve(inputParam);
|
|
49
50
|
if (!cliParamToResolve)
|
|
50
51
|
return output;
|
|
@@ -53,8 +54,11 @@ class CLIParams_Resolver {
|
|
|
53
54
|
// validate options if exits
|
|
54
55
|
if (cliParamToResolve.options && !cliParamToResolve.options.includes(value))
|
|
55
56
|
throw new Error('value not supported for this param');
|
|
56
|
-
//TODO: OPTIMIZE THIS IS PURE JS
|
|
57
57
|
const key = cliParamToResolve.keyName;
|
|
58
|
+
if ((0, ts_common_1.exists)(cliParamToResolve.dependencies))
|
|
59
|
+
(_a = cliParamToResolve.dependencies) === null || _a === void 0 ? void 0 : _a.forEach(dependency => {
|
|
60
|
+
output[dependency.param.keyName] = dependency.value;
|
|
61
|
+
});
|
|
58
62
|
if (cliParamToResolve.isArray) {
|
|
59
63
|
let currentValues = output[key];
|
|
60
64
|
currentValues = (0, ts_common_1.filterDuplicates)([...currentValues !== null && currentValues !== void 0 ? currentValues : [], finalValue]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/commando",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.204.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"TacB0sS",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"build": "tsc"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@nu-art/ts-common": "0.
|
|
34
|
+
"@nu-art/ts-common": "0.204.1_DEPENDENCY"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^18.0.0"
|