@wocker/core 1.0.26-beta.3 → 1.0.26-beta.4
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/core/Route.js +26 -6
- package/lib/decorators/Option.js +5 -3
- package/lib/decorators/Param.js +2 -2
- package/lib/env.d.ts +1 -1
- package/lib/env.js +2 -2
- package/lib/makes/FileSystem.d.ts +1 -0
- package/lib/makes/FileSystem.js +26 -0
- package/lib/types/ArgMeta.d.ts +9 -3
- package/lib/types/FileSystemDriver.d.ts +2 -0
- package/package.json +1 -1
package/lib/core/Route.js
CHANGED
|
@@ -18,24 +18,44 @@ class Route {
|
|
|
18
18
|
this.commandNames = Reflect.getMetadata(env_1.COMMAND_METADATA, descriptor.value) || [];
|
|
19
19
|
this.completions = Reflect.getMetadata(env_1.COMPLETION_METADATA, descriptor.value) || [];
|
|
20
20
|
this.designTypes = Reflect.getMetadata(env_1.PARAMTYPES_METADATA, this.type.prototype, this.method) || [];
|
|
21
|
-
const argsMetadata = Reflect.getMetadata(env_1.ARGS_METADATA, this.type, this.method) || [], argsAliases = Reflect.getMetadata(env_1.ALIAS_METADATA, this.type, this.method) || {};
|
|
22
|
-
for (const
|
|
23
|
-
const argMeta = argsMetadata[index];
|
|
21
|
+
const argsMetadata = Reflect.getMetadata(env_1.ARGS_METADATA, this.type, this.method) || [], argsOldMetadata = Reflect.getMetadata(env_1.ARGS_OLD_METADATA, this.type, this.method) || [], argsDescription = Reflect.getMetadata(env_1.DESCRIPTION_METADATA, this.type, method) || {}, argsAliases = Reflect.getMetadata(env_1.ALIAS_METADATA, this.type, this.method) || {};
|
|
22
|
+
for (const key in argsMetadata) {
|
|
23
|
+
const index = key, argMeta = argsMetadata[index];
|
|
24
|
+
if (argMeta.type === "param") {
|
|
25
|
+
this.args[index] = {
|
|
26
|
+
type: argMeta.type,
|
|
27
|
+
name: argMeta.name,
|
|
28
|
+
params: {
|
|
29
|
+
description: argMeta.description
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
else if (argMeta.type === "option") {
|
|
34
|
+
const { type, alias, description } = argMeta.params || {};
|
|
35
|
+
this.args[index] = {
|
|
36
|
+
type: argMeta.type,
|
|
37
|
+
name: argMeta.name,
|
|
38
|
+
params: Object.assign(Object.assign({}, argMeta.params), { type: this.getArgType(index) || type, alias: argsAliases[index] || alias, description: argMeta.description || description })
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
for (let i = 0; i < argsOldMetadata.length; i++) {
|
|
43
|
+
const argMeta = argsOldMetadata[i];
|
|
24
44
|
if (argMeta.type === "param") {
|
|
25
45
|
this.args[argMeta.index] = {
|
|
26
46
|
type: argMeta.type,
|
|
27
47
|
name: argMeta.name,
|
|
28
48
|
params: {
|
|
29
|
-
description: argMeta.
|
|
49
|
+
description: argsDescription[argMeta.index] || ""
|
|
30
50
|
}
|
|
31
51
|
};
|
|
32
52
|
}
|
|
33
|
-
if (argMeta.type === "option") {
|
|
53
|
+
else if (argMeta.type === "option") {
|
|
34
54
|
const { type, alias, description } = argMeta.params || {};
|
|
35
55
|
this.args[argMeta.index] = {
|
|
36
56
|
type: argMeta.type,
|
|
37
57
|
name: argMeta.name,
|
|
38
|
-
params: Object.assign(Object.assign({}, argMeta.params), { type: this.getArgType(argMeta.index) || type, alias: argsAliases[argMeta.index] || alias, description: argMeta.
|
|
58
|
+
params: Object.assign(Object.assign({}, argMeta.params), { type: this.getArgType(argMeta.index) || type, alias: argsAliases[argMeta.index] || alias, description: argsDescription[argMeta.index] || description })
|
|
39
59
|
};
|
|
40
60
|
}
|
|
41
61
|
}
|
package/lib/decorators/Option.js
CHANGED
|
@@ -20,15 +20,17 @@ const Option = (name, aliasOrParams) => {
|
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
const _a = Reflect.getMetadata(env_1.ARGS_METADATA, target.constructor, propertyKey) || {}, _b = parameterIndex, options = _a[_b], rest = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
23
|
-
Reflect.defineMetadata(env_1.ARGS_METADATA, Object.assign(Object.assign({}, rest), { [parameterIndex]: Object.assign(Object.assign({}, options || {}), { type: "option",
|
|
24
|
-
|
|
23
|
+
Reflect.defineMetadata(env_1.ARGS_METADATA, Object.assign(Object.assign({}, rest), { [parameterIndex]: Object.assign(Object.assign({}, options || {}), { name, type: "option", params: typeof aliasOrParams === "string"
|
|
24
|
+
? { alias: aliasOrParams }
|
|
25
|
+
: aliasOrParams }) }), target.constructor, propertyKey);
|
|
26
|
+
Reflect.defineMetadata(env_1.ARGS_OLD_METADATA, [
|
|
25
27
|
{
|
|
26
28
|
type: "option",
|
|
27
29
|
name,
|
|
28
30
|
params: typeof aliasOrParams === "string" ? { alias: aliasOrParams } : aliasOrParams,
|
|
29
31
|
index: parameterIndex
|
|
30
32
|
},
|
|
31
|
-
...Reflect.getMetadata(env_1.
|
|
33
|
+
...Reflect.getMetadata(env_1.ARGS_OLD_METADATA, target.constructor, propertyKey) || []
|
|
32
34
|
], target.constructor, propertyKey);
|
|
33
35
|
};
|
|
34
36
|
};
|
package/lib/decorators/Param.js
CHANGED
|
@@ -20,8 +20,8 @@ const Param = (name) => {
|
|
|
20
20
|
}
|
|
21
21
|
const _a = Reflect.getMetadata(env_1.ARGS_METADATA, target.constructor, propertyKey) || {}, _b = parameterIndex, options = _a[_b], rest = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
22
22
|
Reflect.defineMetadata(env_1.ARGS_METADATA, Object.assign(Object.assign({}, rest), { [parameterIndex]: Object.assign(Object.assign({}, options || {}), { type: "param", name, index: parameterIndex }) }), target.constructor, propertyKey);
|
|
23
|
-
Reflect.defineMetadata(env_1.
|
|
24
|
-
...Reflect.getMetadata(env_1.
|
|
23
|
+
Reflect.defineMetadata(env_1.ARGS_OLD_METADATA, [
|
|
24
|
+
...Reflect.getMetadata(env_1.ARGS_OLD_METADATA, target.constructor, propertyKey) || [],
|
|
25
25
|
{
|
|
26
26
|
type: "param",
|
|
27
27
|
name,
|
package/lib/env.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const DESCRIPTION_METADATA = "__DESCRIPTION__";
|
|
|
5
5
|
export declare const COMMAND_METADATA = "command";
|
|
6
6
|
export declare const COMPLETION_METADATA = "completion";
|
|
7
7
|
export declare const ARGS_METADATA = "__ARGS_METADATA__";
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const ARGS_OLD_METADATA = "__ARGS__";
|
|
9
9
|
export declare const ALIAS_METADATA = "__ALIAS_METADATA__";
|
|
10
10
|
export declare const OPTION_META = "__OPTION_META__";
|
|
11
11
|
export declare const PARAMTYPES_METADATA = "design:paramtypes";
|
package/lib/env.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.WOCKER_DATA_DIR_KEY = exports.WOCKER_VERSION_KEY = exports.DATA_DIR = exports.MODULE_METADATA = exports.PLUGIN_NAME_METADATA = exports.PLUGIN_DIR_KEY = exports.INJECT_TOKEN_METADATA = exports.SELF_DECLARED_DEPS_METADATA = exports.PARAMTYPES_METADATA = exports.OPTION_META = exports.ALIAS_METADATA = exports.
|
|
6
|
+
exports.WOCKER_DATA_DIR_KEY = exports.WOCKER_VERSION_KEY = exports.DATA_DIR = exports.MODULE_METADATA = exports.PLUGIN_NAME_METADATA = exports.PLUGIN_DIR_KEY = exports.INJECT_TOKEN_METADATA = exports.SELF_DECLARED_DEPS_METADATA = exports.PARAMTYPES_METADATA = exports.OPTION_META = exports.ALIAS_METADATA = exports.ARGS_OLD_METADATA = exports.ARGS_METADATA = exports.COMPLETION_METADATA = exports.COMMAND_METADATA = exports.DESCRIPTION_METADATA = exports.INJECTABLE_WATERMARK = exports.IS_MODULE_METADATA = exports.IS_GLOBAL_METADATA = void 0;
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
exports.IS_GLOBAL_METADATA = "IS_GLOBAL";
|
|
@@ -13,7 +13,7 @@ exports.DESCRIPTION_METADATA = "__DESCRIPTION__";
|
|
|
13
13
|
exports.COMMAND_METADATA = "command";
|
|
14
14
|
exports.COMPLETION_METADATA = "completion";
|
|
15
15
|
exports.ARGS_METADATA = "__ARGS_METADATA__";
|
|
16
|
-
exports.
|
|
16
|
+
exports.ARGS_OLD_METADATA = "__ARGS__";
|
|
17
17
|
exports.ALIAS_METADATA = "__ALIAS_METADATA__";
|
|
18
18
|
exports.OPTION_META = "__OPTION_META__";
|
|
19
19
|
exports.PARAMTYPES_METADATA = "design:paramtypes";
|
|
@@ -36,6 +36,7 @@ export declare class FileSystem {
|
|
|
36
36
|
writeJSON(path: string, data: any, options?: FS.WriteFileOptions): void;
|
|
37
37
|
appendFile(path: string, data: string | Uint8Array, options?: FS.WriteFileOptions): void;
|
|
38
38
|
rm(path: string, options?: FS.RmOptions): void;
|
|
39
|
+
mv(src: string, dest: string): void;
|
|
39
40
|
createWriteStream(path: string, options?: WriteStreamOptions): FS.WriteStream;
|
|
40
41
|
createReadStream(path: string, options?: ReadStreamOptions): FS.ReadStream;
|
|
41
42
|
createReadlineStream(path: string, options?: ReadlineOptions): Readable;
|
package/lib/makes/FileSystem.js
CHANGED
|
@@ -110,6 +110,32 @@ class FileSystem {
|
|
|
110
110
|
const fullPath = this.path(path);
|
|
111
111
|
this.driver.rmSync(fullPath, options);
|
|
112
112
|
}
|
|
113
|
+
mv(src, dest) {
|
|
114
|
+
const srcPath = this.path(src), destPath = this.path(dest), destDir = this.path(dest, ".."), srcStat = this.stat(src);
|
|
115
|
+
if (!this.driver.existsSync(destDir)) {
|
|
116
|
+
this.driver.mkdirSync(destDir, {
|
|
117
|
+
recursive: true
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
let sameFs = false;
|
|
121
|
+
try {
|
|
122
|
+
const destStat = this.driver.statSync(destDir);
|
|
123
|
+
sameFs = srcStat.dev === destStat.dev;
|
|
124
|
+
}
|
|
125
|
+
catch (_a) { }
|
|
126
|
+
if (sameFs) {
|
|
127
|
+
this.driver.renameSync(srcPath, destPath);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.driver.cpSync(srcPath, destPath, {
|
|
131
|
+
recursive: true
|
|
132
|
+
});
|
|
133
|
+
this.driver.rmSync(srcPath, {
|
|
134
|
+
recursive: true,
|
|
135
|
+
force: true
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
113
139
|
createWriteStream(path, options) {
|
|
114
140
|
return this.driver.createWriteStream(this.path(path), options);
|
|
115
141
|
}
|
package/lib/types/ArgMeta.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { Option } from "@kearisp/cli";
|
|
1
2
|
export type ArgMeta = {
|
|
2
|
-
index: number;
|
|
3
|
-
type: "param" | "option";
|
|
4
3
|
name: string;
|
|
4
|
+
type: "param" | "option";
|
|
5
5
|
description?: string;
|
|
6
|
-
params:
|
|
6
|
+
params: Omit<Option, "name">;
|
|
7
|
+
};
|
|
8
|
+
export type ArgOldMeta = {
|
|
9
|
+
name: string;
|
|
10
|
+
type: "param" | "option";
|
|
11
|
+
index: number;
|
|
12
|
+
params: Omit<Option, "name">;
|
|
7
13
|
};
|
|
@@ -34,5 +34,7 @@ export interface FileSystemDriver {
|
|
|
34
34
|
createReadStream(path: string, options?: ReadStreamOptions): FS.ReadStream;
|
|
35
35
|
watch(file: string, options: FS.WatchOptions, listener?: FS.WatchListener<string | Buffer>): FS.FSWatcher;
|
|
36
36
|
watchFile(path: string, listener: FS.StatsListener): FS.StatWatcher;
|
|
37
|
+
cpSync(source: string, destination: string, opts?: FS.CopySyncOptions): void;
|
|
38
|
+
renameSync(oldPath: string, newPath: string): void;
|
|
37
39
|
}
|
|
38
40
|
export {};
|