@wocker/core 1.0.20-dev.0 → 1.0.20-dev.2
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}/Scanner.d.ts +3 -0
- package/lib/{makes → core}/Scanner.js +97 -76
- package/lib/core/index.d.ts +5 -0
- package/lib/core/index.js +21 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/makes/index.d.ts +0 -2
- package/lib/makes/index.js +0 -2
- package/lib/services/DockerService.d.ts +1 -0
- 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
- /package/lib/{makes → core}/Module.js +0 -0
|
@@ -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,111 @@ 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
|
-
|
|
123
|
-
command.option(argMeta.name, argMeta.params);
|
|
122
|
+
});
|
|
123
|
+
command.action((input) => {
|
|
124
|
+
const args = [];
|
|
125
|
+
const params = Object.values(input.arguments());
|
|
126
|
+
argsMeta.forEach((argMeta) => {
|
|
127
|
+
switch (argMeta.type) {
|
|
128
|
+
case "param":
|
|
129
|
+
args[argMeta.index] = input.argument(argMeta.name);
|
|
130
|
+
break;
|
|
131
|
+
case "option":
|
|
132
|
+
if (designTypes[argMeta.index] === Array) {
|
|
133
|
+
args[argMeta.index] = input.options(argMeta.name);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
args[argMeta.index] = input.option(argMeta.name);
|
|
124
137
|
}
|
|
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
|
-
// });
|
|
138
|
+
break;
|
|
137
139
|
}
|
|
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
140
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
141
|
+
return wrapper.instance[name](...args, ...params);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const controllerCompletions = [];
|
|
146
|
+
for (const method of Object.getOwnPropertyNames(controller.prototype)) {
|
|
147
|
+
const descriptor = Object.getOwnPropertyDescriptor(controller.prototype, method);
|
|
148
|
+
if (!descriptor) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const completions = Reflect.getMetadata(env_1.COMPLETION_METADATA, descriptor.value) || [];
|
|
152
|
+
if (completions.length === 0) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
for (const completion of completions) {
|
|
156
|
+
controllerCompletions.push(Object.assign(Object.assign({}, completion), { method }));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
controllerCompletions.sort((a, b) => {
|
|
160
|
+
return a.command < b.command ? -1 : 1;
|
|
161
|
+
});
|
|
162
|
+
for (const completion of controllerCompletions) {
|
|
163
|
+
const commandNames = completion.command
|
|
164
|
+
? [completion.command]
|
|
165
|
+
: controllerCommandNames.filter((commandName) => {
|
|
166
|
+
return !controllerCompletions.filter((c) => {
|
|
167
|
+
return c.name === completion.name && typeof c.command !== "undefined";
|
|
168
|
+
}).map((c) => {
|
|
169
|
+
return c.method;
|
|
170
|
+
}).includes(commandName);
|
|
171
|
+
});
|
|
172
|
+
const argsMeta = Reflect.getMetadata(env_1.ARGS_METADATA, controller, completion.method) || [];
|
|
173
|
+
const designTypes = Reflect.getMetadata(env_1.PARAMTYPES_METADATA, controller.prototype, completion.method) || [];
|
|
174
|
+
for (const commandName of commandNames) {
|
|
175
|
+
cli.command(commandName).completion(completion.name, (input) => {
|
|
176
|
+
const args = [];
|
|
177
|
+
argsMeta.forEach((argMeta) => {
|
|
178
|
+
switch (argMeta.type) {
|
|
179
|
+
case "param":
|
|
180
|
+
args[argMeta.index] = input.argument(argMeta.name);
|
|
181
|
+
break;
|
|
182
|
+
case "option":
|
|
183
|
+
if (designTypes[argMeta.index] === Array) {
|
|
184
|
+
args[argMeta.index] = input.options(argMeta.name);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
args[argMeta.index] = input.option(argMeta.name);
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
165
190
|
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return controller.instance[method]();
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
}
|
|
191
|
+
});
|
|
192
|
+
return wrapper.instance[completion.method](...args);
|
|
193
|
+
});
|
|
173
194
|
}
|
|
174
195
|
}
|
|
196
|
+
return true;
|
|
175
197
|
}
|
|
176
198
|
scanDynamicModules() {
|
|
177
199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -186,7 +208,6 @@ class Scanner {
|
|
|
186
208
|
module.exports.forEach((type) => {
|
|
187
209
|
const provider = module.getWrapper(type);
|
|
188
210
|
if (!provider) {
|
|
189
|
-
// console.log(type, ">_<", provider);
|
|
190
211
|
return;
|
|
191
212
|
}
|
|
192
213
|
// @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
|
@@ -18,6 +18,7 @@ exports.PLUGIN_DIR_KEY = exports.PLUGIN_NAME_METADATA = exports.MODULE_METADATA
|
|
|
18
18
|
require("reflect-metadata");
|
|
19
19
|
var cli_1 = require("@kearisp/cli");
|
|
20
20
|
Object.defineProperty(exports, "Cli", { enumerable: true, get: function () { return cli_1.Cli; } });
|
|
21
|
+
__exportStar(require("./core"), exports);
|
|
21
22
|
__exportStar(require("./decorators"), exports);
|
|
22
23
|
__exportStar(require("./makes"), exports);
|
|
23
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);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wocker/core",
|
|
3
|
-
"version": "1.0.20-dev.
|
|
3
|
+
"version": "1.0.20-dev.2",
|
|
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
|
|
File without changes
|