@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.
@@ -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, command, descriptor.value);
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;
@@ -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 commandName = Reflect.getMetadata(env_1.COMMAND_METADATA, descriptor.value);
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 (commandName) {
109
- controllerCommands.push({
110
- command: commandName,
111
- controller,
112
- method: name,
113
- argsMeta: Reflect.getMetadata(env_1.ARGS_METADATA, type, name) || []
114
- });
115
- const argsMeta = Reflect.getMetadata(env_1.ARGS_METADATA, type, name) || [];
116
- const command = cli.command(commandName);
117
- command.help({
118
- description: description
119
- });
120
- for (const argMeta of argsMeta) {
121
- if (argMeta.type === "option") {
122
- command.option(argMeta.name, argMeta.params);
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wocker/core",
3
- "version": "1.0.17-dev.5",
3
+ "version": "1.0.17-dev.6",
4
4
  "author": "Kris Papercut <krispcut@gmail.com>",
5
5
  "description": "Core of the Wocker",
6
6
  "license": "MIT",