@wocker/core 1.0.17-dev.5 → 1.0.17-dev.6
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/lib/decorators/Command.js +4 -1
- package/lib/makes/Scanner.js +29 -27
- package/package.json +1 -1
|
@@ -5,7 +5,10 @@ require("reflect-metadata");
|
|
|
5
5
|
const env_1 = require("../env");
|
|
6
6
|
const Command = (command) => {
|
|
7
7
|
return (_target, _key, descriptor) => {
|
|
8
|
-
Reflect.defineMetadata(env_1.COMMAND_METADATA,
|
|
8
|
+
Reflect.defineMetadata(env_1.COMMAND_METADATA, [
|
|
9
|
+
...Reflect.getMetadata(env_1.COMMAND_METADATA, descriptor.value) || [],
|
|
10
|
+
command
|
|
11
|
+
], descriptor.value);
|
|
9
12
|
};
|
|
10
13
|
};
|
|
11
14
|
exports.Command = Command;
|
package/lib/makes/Scanner.js
CHANGED
|
@@ -97,7 +97,7 @@ class Scanner {
|
|
|
97
97
|
continue;
|
|
98
98
|
}
|
|
99
99
|
const description = Reflect.getMetadata(env_1.COMMAND_DESCRIPTION_METADATA, descriptor.value);
|
|
100
|
-
const
|
|
100
|
+
const commandNames = Reflect.getMetadata(env_1.COMMAND_METADATA, descriptor.value) || [];
|
|
101
101
|
const completions = (Reflect.getMetadata(env_1.COMPLETION_METADATA, descriptor.value) || [])
|
|
102
102
|
.map((completion) => {
|
|
103
103
|
return Object.assign(Object.assign({}, completion), { method: name });
|
|
@@ -105,34 +105,36 @@ class Scanner {
|
|
|
105
105
|
if (completions.length > 0) {
|
|
106
106
|
controllerCompletions.push(...completions);
|
|
107
107
|
}
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
108
|
+
if (commandNames.length > 0) {
|
|
109
|
+
for (const commandName of commandNames) {
|
|
110
|
+
controllerCommands.push({
|
|
111
|
+
command: commandName,
|
|
112
|
+
controller,
|
|
113
|
+
method: name,
|
|
114
|
+
argsMeta: Reflect.getMetadata(env_1.ARGS_METADATA, type, name) || []
|
|
115
|
+
});
|
|
116
|
+
const argsMeta = Reflect.getMetadata(env_1.ARGS_METADATA, type, name) || [];
|
|
117
|
+
const command = cli.command(commandName);
|
|
118
|
+
command.help({
|
|
119
|
+
description: description
|
|
120
|
+
});
|
|
121
|
+
for (const argMeta of argsMeta) {
|
|
122
|
+
if (argMeta.type === "option") {
|
|
123
|
+
command.option(argMeta.name, argMeta.params);
|
|
124
|
+
}
|
|
123
125
|
}
|
|
126
|
+
// command.action((options, ...params) => {
|
|
127
|
+
// const args: any[] = [];
|
|
128
|
+
//
|
|
129
|
+
// argsMeta.forEach((argMeta: any) => {
|
|
130
|
+
// if(argMeta.type === "option") {
|
|
131
|
+
// args[argMeta.index] = options[argMeta.name];
|
|
132
|
+
// }
|
|
133
|
+
// });
|
|
134
|
+
//
|
|
135
|
+
// return controller.instance[name](...args, ...params);
|
|
136
|
+
// });
|
|
124
137
|
}
|
|
125
|
-
// command.action((options, ...params) => {
|
|
126
|
-
// const args: any[] = [];
|
|
127
|
-
//
|
|
128
|
-
// argsMeta.forEach((argMeta: any) => {
|
|
129
|
-
// if(argMeta.type === "option") {
|
|
130
|
-
// args[argMeta.index] = options[argMeta.name];
|
|
131
|
-
// }
|
|
132
|
-
// });
|
|
133
|
-
//
|
|
134
|
-
// return controller.instance[name](...args, ...params);
|
|
135
|
-
// });
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
140
|
for (const controllerCommand of controllerCommands) {
|