@moostjs/event-cli 0.2.9 → 0.2.11
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/dist/index.cjs +34 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +34 -2
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ class MoostCli {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
onInit() {
|
|
45
|
-
this.cliApp.run();
|
|
45
|
+
void this.cliApp.run();
|
|
46
46
|
}
|
|
47
47
|
bindHandler(opts) {
|
|
48
48
|
let fn;
|
|
@@ -86,6 +86,7 @@ class MoostCli {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
+
restoreCtx();
|
|
89
90
|
// fire after interceptors
|
|
90
91
|
response = yield interceptorHandler.fireAfter(response);
|
|
91
92
|
unscope();
|
|
@@ -98,6 +99,18 @@ class MoostCli {
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
const banner = () => `[${"@moostjs/event-cli"}][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
103
|
+
|
|
104
|
+
/* istanbul ignore file */
|
|
105
|
+
function logError(error) {
|
|
106
|
+
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function panic(error) {
|
|
110
|
+
logError(error);
|
|
111
|
+
return new Error(error);
|
|
112
|
+
}
|
|
113
|
+
|
|
101
114
|
/**
|
|
102
115
|
* Get Cli Flag
|
|
103
116
|
* @decorator
|
|
@@ -114,6 +127,25 @@ function Flag(name) {
|
|
|
114
127
|
*/
|
|
115
128
|
function Flags() {
|
|
116
129
|
return moost.Resolve(() => eventCli.useFlags(), 'flags');
|
|
130
|
+
}
|
|
131
|
+
function CliParam(keys, descr) {
|
|
132
|
+
return moost.Resolve(() => {
|
|
133
|
+
const flags = eventCli.useFlags();
|
|
134
|
+
const names = [keys].flat();
|
|
135
|
+
const vals = [];
|
|
136
|
+
for (const name of names) {
|
|
137
|
+
if (flags[name]) {
|
|
138
|
+
vals.push(flags[name]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (vals.length > 1) {
|
|
142
|
+
throw panic(`Options ${names.map(n => n.length === 1 ? '-' + n : '--' + n).join(' and ')} are synonyms. Please use only one of them.`);
|
|
143
|
+
}
|
|
144
|
+
if (vals.length === 0) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
return vals[0];
|
|
148
|
+
});
|
|
117
149
|
}
|
|
118
150
|
|
|
119
151
|
function Cli(path) {
|
|
@@ -121,6 +153,7 @@ function Cli(path) {
|
|
|
121
153
|
}
|
|
122
154
|
|
|
123
155
|
exports.Cli = Cli;
|
|
156
|
+
exports.CliParam = CliParam;
|
|
124
157
|
exports.Flag = Flag;
|
|
125
158
|
exports.Flags = Flags;
|
|
126
159
|
exports.MoostCli = MoostCli;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,20 +5,22 @@ import { WooksCli } from '@wooksjs/event-cli';
|
|
|
5
5
|
|
|
6
6
|
export declare function Cli(path?: string): MethodDecorator;
|
|
7
7
|
|
|
8
|
+
export declare function CliParam(keys: string | [string, string], descr?: string): ParameterDecorator & PropertyDecorator;
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* Get Cli Flag
|
|
10
12
|
* @decorator
|
|
11
13
|
* @param name - flag name
|
|
12
14
|
* @paramType string
|
|
13
15
|
*/
|
|
14
|
-
export declare function Flag(name: string): ParameterDecorator;
|
|
16
|
+
export declare function Flag(name: string): ParameterDecorator & PropertyDecorator;
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Get Cli Flags
|
|
18
20
|
* @decorator
|
|
19
21
|
* @paramType object
|
|
20
22
|
*/
|
|
21
|
-
export declare function Flags(): ParameterDecorator;
|
|
23
|
+
export declare function Flags(): ParameterDecorator & PropertyDecorator;
|
|
22
24
|
|
|
23
25
|
export declare class MoostCli implements TMoostAdapter<TCliHandlerMeta> {
|
|
24
26
|
protected cliApp: WooksCli;
|
package/dist/index.mjs
CHANGED
|
@@ -40,7 +40,7 @@ class MoostCli {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
onInit() {
|
|
43
|
-
this.cliApp.run();
|
|
43
|
+
void this.cliApp.run();
|
|
44
44
|
}
|
|
45
45
|
bindHandler(opts) {
|
|
46
46
|
let fn;
|
|
@@ -84,6 +84,7 @@ class MoostCli {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
restoreCtx();
|
|
87
88
|
// fire after interceptors
|
|
88
89
|
response = yield interceptorHandler.fireAfter(response);
|
|
89
90
|
unscope();
|
|
@@ -96,6 +97,18 @@ class MoostCli {
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
|
|
100
|
+
const banner = () => `[${"@moostjs/event-cli"}][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
101
|
+
|
|
102
|
+
/* istanbul ignore file */
|
|
103
|
+
function logError(error) {
|
|
104
|
+
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function panic(error) {
|
|
108
|
+
logError(error);
|
|
109
|
+
return new Error(error);
|
|
110
|
+
}
|
|
111
|
+
|
|
99
112
|
/**
|
|
100
113
|
* Get Cli Flag
|
|
101
114
|
* @decorator
|
|
@@ -112,10 +125,29 @@ function Flag(name) {
|
|
|
112
125
|
*/
|
|
113
126
|
function Flags() {
|
|
114
127
|
return Resolve(() => useFlags(), 'flags');
|
|
128
|
+
}
|
|
129
|
+
function CliParam(keys, descr) {
|
|
130
|
+
return Resolve(() => {
|
|
131
|
+
const flags = useFlags();
|
|
132
|
+
const names = [keys].flat();
|
|
133
|
+
const vals = [];
|
|
134
|
+
for (const name of names) {
|
|
135
|
+
if (flags[name]) {
|
|
136
|
+
vals.push(flags[name]);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (vals.length > 1) {
|
|
140
|
+
throw panic(`Options ${names.map(n => n.length === 1 ? '-' + n : '--' + n).join(' and ')} are synonyms. Please use only one of them.`);
|
|
141
|
+
}
|
|
142
|
+
if (vals.length === 0) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
return vals[0];
|
|
146
|
+
});
|
|
115
147
|
}
|
|
116
148
|
|
|
117
149
|
function Cli(path) {
|
|
118
150
|
return getMoostMate().decorate('handlers', { path, type: 'CLI' }, true);
|
|
119
151
|
}
|
|
120
152
|
|
|
121
|
-
export { Cli, Flag, Flags, MoostCli };
|
|
153
|
+
export { Cli, CliParam, Flag, Flags, MoostCli };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/event-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "@moostjs/event-cli",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-cli#readme",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"moost": "0.2.
|
|
32
|
-
"wooks": "^0.2.
|
|
33
|
-
"@wooksjs/event-core": "^0.2.
|
|
31
|
+
"moost": "0.2.11",
|
|
32
|
+
"wooks": "^0.2.6",
|
|
33
|
+
"@wooksjs/event-core": "^0.2.6"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@wooksjs/event-cli": "^0.2.
|
|
36
|
+
"@wooksjs/event-cli": "^0.2.6"
|
|
37
37
|
}
|
|
38
38
|
}
|