@wocker/core 1.0.26-beta.2 → 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 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 index in argsMetadata) {
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.description,
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.description || description })
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
  }
@@ -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", name, params: typeof aliasOrParams === "string" ? { alias: aliasOrParams } : aliasOrParams, index: parameterIndex }) }), target.constructor, propertyKey);
24
- Reflect.defineMetadata(env_1.ARGS_METADATA_OLD, [
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.ARGS_METADATA_OLD, target.constructor, propertyKey) || []
33
+ ...Reflect.getMetadata(env_1.ARGS_OLD_METADATA, target.constructor, propertyKey) || []
32
34
  ], target.constructor, propertyKey);
33
35
  };
34
36
  };
@@ -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.ARGS_METADATA_OLD, [
24
- ...Reflect.getMetadata(env_1.ARGS_METADATA_OLD, target.constructor, propertyKey) || [],
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 ARGS_METADATA_OLD = "__ARGS__";
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.ARGS_METADATA_OLD = 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;
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.ARGS_METADATA_OLD = "__ARGS__";
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";
@@ -2,7 +2,7 @@ import { EnvConfig, PackageManagerType } from "../types";
2
2
  import { PluginRef } from "../types/PluginRef";
3
3
  import { PresetRef } from "../types/PresetRef";
4
4
  import { ProjectRef, ProjectOldRef } from "../types/ProjectRef";
5
- import { PresetSource } from "./Preset";
5
+ import { PresetSource } from "../types/PresetSource";
6
6
  export type AppConfigProperties = {
7
7
  debug?: boolean;
8
8
  pm?: PackageManagerType;
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.AppConfig = void 0;
15
- const Preset_1 = require("./Preset");
15
+ const PresetSource_1 = require("../types/PresetSource");
16
16
  class AppConfig {
17
17
  constructor(data) {
18
18
  this.logLevel = "off";
@@ -83,11 +83,11 @@ class AppConfig {
83
83
  });
84
84
  }
85
85
  registerPreset(name, source, path) {
86
- if (source === Preset_1.PRESET_SOURCE_INTERNAL) {
86
+ if (source === PresetSource_1.PRESET_SOURCE_INTERNAL) {
87
87
  return;
88
88
  }
89
89
  let presetData = this.presets.find((preset) => {
90
- if (source === Preset_1.PRESET_SOURCE_EXTERNAL && preset.path === path) {
90
+ if (source === PresetSource_1.PRESET_SOURCE_EXTERNAL && preset.path === path) {
91
91
  return true;
92
92
  }
93
93
  return preset.name === name;
@@ -100,7 +100,7 @@ class AppConfig {
100
100
  this.presets.push(presetData);
101
101
  }
102
102
  presetData.source = source;
103
- if (presetData.source === Preset_1.PRESET_SOURCE_EXTERNAL) {
103
+ if (presetData.source === PresetSource_1.PRESET_SOURCE_EXTERNAL) {
104
104
  presetData.path = path;
105
105
  }
106
106
  else if (presetData.path) {
@@ -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;
@@ -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
  }
@@ -1,4 +1,5 @@
1
1
  import { PickProperties } from "../types/PickProperties";
2
+ import { PresetSource } from "../types/PresetSource";
2
3
  type TextOption = {
3
4
  type: "text" | "string" | "number" | "int" | "password";
4
5
  message?: string;
@@ -50,8 +51,4 @@ export declare abstract class Preset {
50
51
  toJSON(): PresetProperties;
51
52
  toObject(): PresetProperties;
52
53
  }
53
- export declare const PRESET_SOURCE_INTERNAL: "internal";
54
- export declare const PRESET_SOURCE_EXTERNAL: "external";
55
- export declare const PRESET_SOURCE_GITHUB: "github";
56
- export type PresetSource = typeof PRESET_SOURCE_INTERNAL | typeof PRESET_SOURCE_EXTERNAL | typeof PRESET_SOURCE_GITHUB;
57
54
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PRESET_SOURCE_GITHUB = exports.PRESET_SOURCE_EXTERNAL = exports.PRESET_SOURCE_INTERNAL = exports.Preset = void 0;
3
+ exports.Preset = void 0;
4
4
  class Preset {
5
5
  constructor(data) {
6
6
  this.name = data.name;
@@ -36,6 +36,3 @@ class Preset {
36
36
  }
37
37
  }
38
38
  exports.Preset = Preset;
39
- exports.PRESET_SOURCE_INTERNAL = "internal";
40
- exports.PRESET_SOURCE_EXTERNAL = "external";
41
- exports.PRESET_SOURCE_GITHUB = "github";
@@ -1,7 +1,8 @@
1
1
  import { AppConfig } from "../makes/AppConfig";
2
- import { PresetSource } from "../makes/Preset";
2
+ import { PresetRef } from "../types/PresetRef";
3
3
  import { ProjectRef } from "../types/ProjectRef";
4
4
  import { PluginRef } from "../types/PluginRef";
5
+ import { PresetSource } from "../types/PresetSource";
5
6
  import { AppFileSystemService } from "./AppFileSystemService";
6
7
  import { ProcessService } from "./ProcessService";
7
8
  type TypeMap = {
@@ -19,6 +20,7 @@ export declare class AppConfigService {
19
20
  get debug(): boolean;
20
21
  set debug(debug: boolean);
21
22
  get config(): AppConfig;
23
+ get presets(): PresetRef[];
22
24
  get projects(): ProjectRef[];
23
25
  get plugins(): PluginRef[];
24
26
  /**
@@ -90,6 +90,9 @@ let AppConfigService = class AppConfigService {
90
90
  }
91
91
  return this._config;
92
92
  }
93
+ get presets() {
94
+ return this.config.presets;
95
+ }
93
96
  get projects() {
94
97
  return this.config.projects;
95
98
  }
@@ -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: any;
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 {};
@@ -1,4 +1,4 @@
1
- import { PresetSource } from "../makes/Preset";
1
+ import { PresetSource } from "./PresetSource";
2
2
  export type PresetRef = {
3
3
  name: string;
4
4
  source: PresetSource;
@@ -0,0 +1,4 @@
1
+ export declare const PRESET_SOURCE_INTERNAL: "internal";
2
+ export declare const PRESET_SOURCE_EXTERNAL: "external";
3
+ export declare const PRESET_SOURCE_GITHUB: "github";
4
+ export type PresetSource = typeof PRESET_SOURCE_INTERNAL | typeof PRESET_SOURCE_EXTERNAL | typeof PRESET_SOURCE_GITHUB;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PRESET_SOURCE_GITHUB = exports.PRESET_SOURCE_EXTERNAL = exports.PRESET_SOURCE_INTERNAL = void 0;
4
+ exports.PRESET_SOURCE_INTERNAL = "internal";
5
+ exports.PRESET_SOURCE_EXTERNAL = "external";
6
+ exports.PRESET_SOURCE_GITHUB = "github";
@@ -6,6 +6,8 @@ export * from "./ModuleMetadata";
6
6
  export * from "./PackageManagerType";
7
7
  export * from "./PickProperties";
8
8
  export * from "./PluginMetadata";
9
+ export * from "./PresetRef";
10
+ export * from "./PresetSource";
9
11
  export * from "./Type";
10
12
  export * from "./Volume";
11
13
  export * from "./ProviderType";
@@ -22,6 +22,8 @@ __exportStar(require("./ModuleMetadata"), exports);
22
22
  __exportStar(require("./PackageManagerType"), exports);
23
23
  __exportStar(require("./PickProperties"), exports);
24
24
  __exportStar(require("./PluginMetadata"), exports);
25
+ __exportStar(require("./PresetRef"), exports);
26
+ __exportStar(require("./PresetSource"), exports);
25
27
  __exportStar(require("./Type"), exports);
26
28
  __exportStar(require("./Volume"), exports);
27
29
  __exportStar(require("./ProviderType"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wocker/core",
3
3
  "type": "commonjs",
4
- "version": "1.0.26-beta.2",
4
+ "version": "1.0.26-beta.4",
5
5
  "author": "Kris Papercut <krispcut@gmail.com>",
6
6
  "description": "Core of the Wocker",
7
7
  "license": "MIT",