@wocker/core 1.0.17-dev.4 → 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/Project.d.ts +3 -0
- package/lib/makes/Project.js +17 -0
- 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/Project.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare abstract class Project {
|
|
|
15
15
|
env?: EnvConfig;
|
|
16
16
|
ports?: string[];
|
|
17
17
|
volumes?: string[];
|
|
18
|
+
extraHosts?: EnvConfig;
|
|
18
19
|
metadata?: EnvConfig;
|
|
19
20
|
protected constructor(data: ProjectProperties);
|
|
20
21
|
get containerName(): string;
|
|
@@ -37,6 +38,8 @@ export declare abstract class Project {
|
|
|
37
38
|
getVolumeByDestination(destination: string): string | undefined;
|
|
38
39
|
volumeMount(...volumes: string[]): void;
|
|
39
40
|
volumeUnmount(...volumes: string[]): void;
|
|
41
|
+
addExtraHost(host: string, domain: string): void;
|
|
42
|
+
removeExtraHost(host: string): void;
|
|
40
43
|
abstract save(): Promise<void>;
|
|
41
44
|
toJSON(): ProjectProperties;
|
|
42
45
|
}
|
package/lib/makes/Project.js
CHANGED
|
@@ -17,6 +17,7 @@ class Project {
|
|
|
17
17
|
this.env = data.env;
|
|
18
18
|
this.ports = data.ports;
|
|
19
19
|
this.volumes = data.volumes;
|
|
20
|
+
this.extraHosts = data.extraHosts;
|
|
20
21
|
this.metadata = data.metadata;
|
|
21
22
|
Object.assign(this, data);
|
|
22
23
|
}
|
|
@@ -171,6 +172,21 @@ class Project {
|
|
|
171
172
|
}
|
|
172
173
|
this.volumeUnmount(...restVolumes);
|
|
173
174
|
}
|
|
175
|
+
addExtraHost(host, domain) {
|
|
176
|
+
if (!this.extraHosts) {
|
|
177
|
+
this.extraHosts = {};
|
|
178
|
+
}
|
|
179
|
+
this.extraHosts[host] = domain;
|
|
180
|
+
}
|
|
181
|
+
removeExtraHost(host) {
|
|
182
|
+
if (!this.extraHosts || !this.extraHosts[host]) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
delete this.extraHosts[host];
|
|
186
|
+
if (Object.keys(this.extraHosts).length === 0) {
|
|
187
|
+
delete this.extraHosts;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
174
190
|
toJSON() {
|
|
175
191
|
return {
|
|
176
192
|
id: this.id,
|
|
@@ -186,6 +202,7 @@ class Project {
|
|
|
186
202
|
env: this.env,
|
|
187
203
|
ports: this.ports,
|
|
188
204
|
volumes: this.volumes,
|
|
205
|
+
extraHosts: this.extraHosts,
|
|
189
206
|
metadata: this.metadata
|
|
190
207
|
};
|
|
191
208
|
}
|
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) {
|