@wocker/core 1.0.19 → 1.0.20-dev.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/lib/{makes → core}/Module.js +1 -1
- package/lib/{makes → core}/Scanner.d.ts +3 -0
- package/lib/{makes → core}/Scanner.js +96 -76
- package/lib/core/index.d.ts +5 -0
- package/lib/core/index.js +21 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/makes/index.d.ts +0 -2
- package/lib/makes/index.js +0 -2
- package/lib/services/DockerService.d.ts +6 -1
- package/package.json +2 -2
- /package/lib/{makes → core}/ApplicationContext.d.ts +0 -0
- /package/lib/{makes → core}/ApplicationContext.js +0 -0
- /package/lib/{makes → core}/Container.d.ts +0 -0
- /package/lib/{makes → core}/Container.js +0 -0
- /package/lib/{makes → core}/Factory.d.ts +0 -0
- /package/lib/{makes → core}/Factory.js +0 -0
- /package/lib/{makes → core}/InstanceWrapper.d.ts +0 -0
- /package/lib/{makes → core}/InstanceWrapper.js +0 -0
- /package/lib/{makes → core}/Module.d.ts +0 -0
|
@@ -26,7 +26,7 @@ class Module {
|
|
|
26
26
|
return wrapper.instance;
|
|
27
27
|
}
|
|
28
28
|
getWrapper(type) {
|
|
29
|
-
const token = typeof type
|
|
29
|
+
const token = typeof type === "function"
|
|
30
30
|
? Reflect.getMetadata(env_1.INJECT_TOKEN_METADATA, type) || type
|
|
31
31
|
: type;
|
|
32
32
|
const wrapper = this.providers.get(token);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
+
import { Cli } from "@kearisp/cli";
|
|
2
3
|
import { Container } from "./Container";
|
|
4
|
+
import { InstanceWrapper } from "./InstanceWrapper";
|
|
3
5
|
import { Module } from "./Module";
|
|
4
6
|
export declare class Scanner {
|
|
5
7
|
readonly container: Container;
|
|
@@ -11,5 +13,6 @@ export declare class Scanner {
|
|
|
11
13
|
protected scanImports(module: Module): void;
|
|
12
14
|
protected scanExports(module: Module): void;
|
|
13
15
|
protected scanRoutes(): void;
|
|
16
|
+
protected scanControllerRoutes(cli: Cli, controller: any, wrapper: InstanceWrapper): boolean;
|
|
14
17
|
protected scanDynamicModules(): Promise<void>;
|
|
15
18
|
}
|
|
@@ -89,89 +89,110 @@ class Scanner {
|
|
|
89
89
|
if (!controller.instance) {
|
|
90
90
|
continue;
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
92
|
+
this.scanControllerRoutes(cli, type, controller);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
scanControllerRoutes(cli, controller, wrapper) {
|
|
97
|
+
const controllerCommandNames = [];
|
|
98
|
+
for (const name of Object.getOwnPropertyNames(controller.prototype)) {
|
|
99
|
+
const descriptor = Object.getOwnPropertyDescriptor(controller.prototype, name);
|
|
100
|
+
if (!descriptor) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const commandNames = Reflect.getMetadata(env_1.COMMAND_METADATA, descriptor.value) || [];
|
|
104
|
+
if (commandNames.length === 0) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const argsMeta = Reflect.getMetadata(env_1.ARGS_METADATA, controller, name) || [];
|
|
108
|
+
const designTypes = Reflect.getMetadata(env_1.PARAMTYPES_METADATA, controller.prototype, name) || [];
|
|
109
|
+
const description = Reflect.getMetadata(env_1.COMMAND_DESCRIPTION_METADATA, descriptor.value);
|
|
110
|
+
for (const commandName of commandNames) {
|
|
111
|
+
controllerCommandNames.push(commandName);
|
|
112
|
+
const command = cli.command(commandName);
|
|
113
|
+
if (description) {
|
|
114
|
+
command.help({
|
|
115
|
+
description
|
|
104
116
|
});
|
|
105
|
-
|
|
106
|
-
|
|
117
|
+
}
|
|
118
|
+
argsMeta.forEach((argMeta) => {
|
|
119
|
+
if (argMeta.type === "option") {
|
|
120
|
+
command.option(argMeta.name, argMeta.params);
|
|
107
121
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (argMeta.type === "option") {
|
|
123
|
-
command.option(argMeta.name, argMeta.params);
|
|
122
|
+
});
|
|
123
|
+
command.action((input) => {
|
|
124
|
+
const args = [];
|
|
125
|
+
argsMeta.forEach((argMeta) => {
|
|
126
|
+
switch (argMeta.type) {
|
|
127
|
+
case "param":
|
|
128
|
+
args[argMeta.index] = input.argument(argMeta.name);
|
|
129
|
+
break;
|
|
130
|
+
case "option":
|
|
131
|
+
if (designTypes[argMeta.index] === Array) {
|
|
132
|
+
args[argMeta.index] = input.options(argMeta.name);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
args[argMeta.index] = input.option(argMeta.name);
|
|
124
136
|
}
|
|
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
|
-
// });
|
|
137
|
+
break;
|
|
137
138
|
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
for (const controllerCommand of controllerCommands) {
|
|
141
|
-
const { command: commandName, method, argsMeta } = controllerCommand;
|
|
142
|
-
cli.command(commandName)
|
|
143
|
-
.action((input) => {
|
|
144
|
-
const args = [];
|
|
145
|
-
const params = Object.values(input.arguments());
|
|
146
|
-
argsMeta.forEach((argMeta) => {
|
|
147
|
-
if (argMeta.type === "param") {
|
|
148
|
-
args[argMeta.index] = input.argument(argMeta.name);
|
|
149
|
-
}
|
|
150
|
-
else if (argMeta.type === "option") {
|
|
151
|
-
args[argMeta.index] = input.option(argMeta.name);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
return controller.instance[method](...args, ...params);
|
|
155
139
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
140
|
+
return wrapper.instance[name](...args);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const controllerCompletions = [];
|
|
145
|
+
for (const method of Object.getOwnPropertyNames(controller.prototype)) {
|
|
146
|
+
const descriptor = Object.getOwnPropertyDescriptor(controller.prototype, method);
|
|
147
|
+
if (!descriptor) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const completions = Reflect.getMetadata(env_1.COMPLETION_METADATA, descriptor.value) || [];
|
|
151
|
+
if (completions.length === 0) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
for (const completion of completions) {
|
|
155
|
+
controllerCompletions.push(Object.assign(Object.assign({}, completion), { method }));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
controllerCompletions.sort((a, b) => {
|
|
159
|
+
return a.command < b.command ? -1 : 1;
|
|
160
|
+
});
|
|
161
|
+
for (const completion of controllerCompletions) {
|
|
162
|
+
const commandNames = completion.command
|
|
163
|
+
? [completion.command]
|
|
164
|
+
: controllerCommandNames.filter((commandName) => {
|
|
165
|
+
return !controllerCompletions.filter((c) => {
|
|
166
|
+
return c.name === completion.name && typeof c.command !== "undefined";
|
|
167
|
+
}).map((c) => {
|
|
168
|
+
return c.method;
|
|
169
|
+
}).includes(commandName);
|
|
170
|
+
});
|
|
171
|
+
const argsMeta = Reflect.getMetadata(env_1.ARGS_METADATA, controller, completion.method) || [];
|
|
172
|
+
const designTypes = Reflect.getMetadata(env_1.PARAMTYPES_METADATA, controller.prototype, completion.method) || [];
|
|
173
|
+
for (const commandName of commandNames) {
|
|
174
|
+
cli.command(commandName).completion(completion.name, (input) => {
|
|
175
|
+
const args = [];
|
|
176
|
+
argsMeta.forEach((argMeta) => {
|
|
177
|
+
switch (argMeta.type) {
|
|
178
|
+
case "param":
|
|
179
|
+
args[argMeta.index] = input.argument(argMeta.name);
|
|
180
|
+
break;
|
|
181
|
+
case "option":
|
|
182
|
+
if (designTypes[argMeta.index] === Array) {
|
|
183
|
+
args[argMeta.index] = input.options(argMeta.name);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
args[argMeta.index] = input.option(argMeta.name);
|
|
187
|
+
}
|
|
188
|
+
break;
|
|
165
189
|
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return controller.instance[method]();
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
}
|
|
190
|
+
});
|
|
191
|
+
return wrapper.instance[completion.method](...args);
|
|
192
|
+
});
|
|
173
193
|
}
|
|
174
194
|
}
|
|
195
|
+
return true;
|
|
175
196
|
}
|
|
176
197
|
scanDynamicModules() {
|
|
177
198
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -186,7 +207,6 @@ class Scanner {
|
|
|
186
207
|
module.exports.forEach((type) => {
|
|
187
208
|
const provider = module.getWrapper(type);
|
|
188
209
|
if (!provider) {
|
|
189
|
-
// console.log(type, ">_<", provider);
|
|
190
210
|
return;
|
|
191
211
|
}
|
|
192
212
|
// @ts-ignore
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ApplicationContext"), exports);
|
|
18
|
+
__exportStar(require("./Container"), exports);
|
|
19
|
+
__exportStar(require("./Factory"), exports);
|
|
20
|
+
__exportStar(require("./InstanceWrapper"), exports);
|
|
21
|
+
__exportStar(require("./Scanner"), exports);
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -15,8 +15,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.PLUGIN_DIR_KEY = exports.PLUGIN_NAME_METADATA = exports.MODULE_METADATA = exports.IS_MODULE_METADATA = exports.Cli = void 0;
|
|
18
|
+
require("reflect-metadata");
|
|
18
19
|
var cli_1 = require("@kearisp/cli");
|
|
19
20
|
Object.defineProperty(exports, "Cli", { enumerable: true, get: function () { return cli_1.Cli; } });
|
|
21
|
+
__exportStar(require("./core"), exports);
|
|
20
22
|
__exportStar(require("./decorators"), exports);
|
|
21
23
|
__exportStar(require("./makes"), exports);
|
|
22
24
|
__exportStar(require("./services"), exports);
|
package/lib/makes/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
export * from "./AppConfig";
|
|
2
2
|
export * from "./Config";
|
|
3
3
|
export * from "./ConfigCollection";
|
|
4
|
-
export * from "./Container";
|
|
5
4
|
export * from "./FileSystem";
|
|
6
5
|
export * from "./FS";
|
|
7
6
|
export * from "./FSManager";
|
|
8
7
|
export * from "./Logger";
|
|
9
8
|
export * from "./Preset";
|
|
10
9
|
export * from "./Project";
|
|
11
|
-
export * from "./Factory";
|
package/lib/makes/index.js
CHANGED
|
@@ -17,11 +17,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./AppConfig"), exports);
|
|
18
18
|
__exportStar(require("./Config"), exports);
|
|
19
19
|
__exportStar(require("./ConfigCollection"), exports);
|
|
20
|
-
__exportStar(require("./Container"), exports);
|
|
21
20
|
__exportStar(require("./FileSystem"), exports);
|
|
22
21
|
__exportStar(require("./FS"), exports);
|
|
23
22
|
__exportStar(require("./FSManager"), exports);
|
|
24
23
|
__exportStar(require("./Logger"), exports);
|
|
25
24
|
__exportStar(require("./Preset"), exports);
|
|
26
25
|
__exportStar(require("./Project"), exports);
|
|
27
|
-
__exportStar(require("./Factory"), exports);
|
|
@@ -43,6 +43,11 @@ export declare namespace DockerServiceParams {
|
|
|
43
43
|
context: string;
|
|
44
44
|
src: string;
|
|
45
45
|
};
|
|
46
|
+
type Exec = {
|
|
47
|
+
cmd: string[];
|
|
48
|
+
tty?: boolean;
|
|
49
|
+
user?: string;
|
|
50
|
+
};
|
|
46
51
|
}
|
|
47
52
|
export declare abstract class DockerService {
|
|
48
53
|
abstract createContainer(params: DockerServiceParams.CreateContainer): Promise<Container>;
|
|
@@ -58,6 +63,6 @@ export declare abstract class DockerService {
|
|
|
58
63
|
abstract pullImage(tag: string): Promise<void>;
|
|
59
64
|
abstract attach(name: string | Container): Promise<NodeJS.ReadWriteStream>;
|
|
60
65
|
abstract attachStream(stream: NodeJS.ReadWriteStream): Promise<void>;
|
|
61
|
-
abstract exec(name: string, command?: string[], tty?: boolean): Promise<Duplex>;
|
|
66
|
+
abstract exec(name: string, command?: DockerServiceParams.Exec | string[], tty?: boolean): Promise<Duplex>;
|
|
62
67
|
abstract logs(containerOrName: string | Container): Promise<NodeJS.ReadableStream>;
|
|
63
68
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wocker/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20-dev.1",
|
|
4
4
|
"author": "Kris Papercut <krispcut@gmail.com>",
|
|
5
5
|
"description": "Core of the Wocker",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"test-watch": "jest --colors --watchAll --coverage"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@kearisp/cli": "^2.0.
|
|
28
|
+
"@kearisp/cli": "^2.0.7-dev.0",
|
|
29
29
|
"fs": "^0.0.1-security",
|
|
30
30
|
"path": "^0.12.7",
|
|
31
31
|
"reflect-metadata": "^0.2.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|