@wocker/core 1.1.4-beta.0 → 1.1.4-beta.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.
@@ -1,5 +1,5 @@
1
1
  import { FileSystem } from "./FileSystem";
2
- import { EnvConfig, PackageManagerType, PluginRef, PresetRef, ProjectRef, ProjectOldRef, PresetSource } from "../types";
2
+ import { EnvConfig, PackageManagerType, PluginRef, PresetRef, ProjectRef, ProjectOldRef } from "../types";
3
3
  export declare abstract class AppConfig {
4
4
  debug?: boolean;
5
5
  pm?: PackageManagerType;
@@ -16,8 +16,8 @@ export declare abstract class AppConfig {
16
16
  getProjectByPath(path: string): ProjectRef | undefined;
17
17
  addProject(name: string, path: string): void;
18
18
  removeProject(name: string): void;
19
- registerPreset(name: string, source: PresetSource, path?: string): void;
20
- unregisterPreset(name: string): void;
19
+ registerPreset(presetRef: PresetRef): void;
20
+ unregisterPreset(path: string): void;
21
21
  hasMeta(name: string): boolean;
22
22
  getMeta(name: string, defaultValue?: string): string | undefined;
23
23
  getMeta(name: string, defaultValue: string): string;
@@ -12,7 +12,6 @@ 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 types_1 = require("../types");
16
15
  class AppConfig {
17
16
  constructor(data) {
18
17
  const { plugins = [], presets = [], projects = [] } = data, rest = __rest(data, ["plugins", "presets", "projects"]);
@@ -86,37 +85,30 @@ class AppConfig {
86
85
  return projectData.name !== name;
87
86
  });
88
87
  }
89
- registerPreset(name, source, path) {
90
- if (source === types_1.PresetSource.INTERNAL) {
88
+ registerPreset(presetRef) {
89
+ const { name, path } = presetRef;
90
+ if (!path) {
91
91
  return;
92
92
  }
93
93
  let presetData = this.presets.find((preset) => {
94
- if (source === types_1.PresetSource.EXTERNAL && preset.path === path) {
95
- return true;
96
- }
97
- return preset.name === name;
94
+ return preset.path === path;
98
95
  });
99
96
  if (!presetData) {
100
97
  presetData = {
101
98
  name,
102
- source
99
+ path
103
100
  };
104
101
  this.presets.push(presetData);
105
102
  }
106
- presetData.source = source;
107
- if (presetData.source === types_1.PresetSource.EXTERNAL) {
108
- presetData.path = path;
109
- }
110
- else if (presetData.path) {
111
- delete presetData.path;
112
- }
103
+ presetData.name = name;
104
+ presetData.path = path;
113
105
  }
114
- unregisterPreset(name) {
106
+ unregisterPreset(path) {
115
107
  if (this.presets.length === 0) {
116
108
  return;
117
109
  }
118
110
  this.presets = this.presets.filter((preset) => {
119
- return preset.name !== name;
111
+ return preset.path !== path;
120
112
  });
121
113
  }
122
114
  hasMeta(name) {
@@ -1,19 +1,34 @@
1
1
  import { PickProperties, PresetSource } from "../../../types";
2
- type TextOption = {
2
+ export type PresetVariableCondition = {
3
+ variable: string;
4
+ equals?: string;
5
+ notEquals?: string;
6
+ in?: string[];
7
+ notIn?: string[];
8
+ contains?: string;
9
+ includes?: string | string[];
10
+ };
11
+ type BaseVariableConfig = {
12
+ when?: PresetVariableCondition;
13
+ };
14
+ type TextOption = BaseVariableConfig & {
3
15
  type: "text" | "string" | "number" | "int" | "password";
4
16
  message?: string;
5
17
  default?: string | number;
6
18
  };
7
- type ConfirmOption = {
19
+ type ConfirmOption = BaseVariableConfig & {
8
20
  type: "boolean";
9
21
  message?: string;
10
22
  required?: boolean;
11
23
  default?: boolean;
12
24
  };
13
- type SelectOption = {
25
+ export type PresetSelectMode = "flags" | "variable";
26
+ type SelectOption = BaseVariableConfig & {
14
27
  type: "select";
15
28
  required?: boolean;
16
29
  multiple?: boolean;
30
+ mode?: PresetSelectMode;
31
+ delimiter?: string;
17
32
  options: string[] | {
18
33
  label?: string;
19
34
  value: string;
@@ -3,6 +3,7 @@ import { Preset } from "../makes/Preset";
3
3
  type SearchOptions = Partial<{
4
4
  name: string;
5
5
  source: string;
6
+ version: string;
6
7
  path: string;
7
8
  }>;
8
9
  declare abstract class PresetService {
@@ -67,10 +67,21 @@ let AppConfigService = class AppConfigService {
67
67
  this.appService.removePlugin(name);
68
68
  }
69
69
  registerPreset(name, source, path) {
70
- this.appService.registerPreset(name, source, path);
70
+ if (!path) {
71
+ return;
72
+ }
73
+ this.appService.registerPreset({
74
+ name,
75
+ source,
76
+ path
77
+ });
71
78
  }
72
79
  unregisterPreset(name) {
73
- this.appService.unregisterPreset(name);
80
+ const preset = this.appService.config.presets.find(p => p.name === name);
81
+ if (!preset || !preset.path) {
82
+ return;
83
+ }
84
+ this.appService.unregisterPreset(preset.path);
74
85
  }
75
86
  getEnv(key, byDefault) {
76
87
  return this.appService.getEnv(key, byDefault);
@@ -2,7 +2,7 @@ import { AppConfig } from "../makes/AppConfig";
2
2
  import { AppFileSystemService } from "./AppFileSystemService";
3
3
  import { ProcessService } from "./ProcessService";
4
4
  import { LogService } from "./LogService";
5
- import { ProjectRef, PluginRef, PresetRef, PresetSource } from "../types";
5
+ import { ProjectRef, PluginRef, PresetRef } from "../types";
6
6
  type TypeMap = {
7
7
  [type: string]: string;
8
8
  };
@@ -28,8 +28,8 @@ export declare class AppService {
28
28
  removeProject(name: string): void;
29
29
  addPlugin(name: string, env?: PluginRef["env"]): void;
30
30
  removePlugin(name: string): void;
31
- registerPreset(name: string, source: PresetSource, path?: string): void;
32
- unregisterPreset(name: string): void;
31
+ registerPreset(presetRef: PresetRef): void;
32
+ unregisterPreset(path: string): void;
33
33
  getEnv(key: string, byDefault?: string): string | undefined;
34
34
  getEnv(key: string, byDefault: string): string;
35
35
  setEnv(key: string, value: string): void;
@@ -85,12 +85,12 @@ let AppService = class AppService {
85
85
  this.config.removePlugin(name);
86
86
  this.config.save();
87
87
  }
88
- registerPreset(name, source, path) {
89
- this.config.registerPreset(name, source, path);
88
+ registerPreset(presetRef) {
89
+ this.config.registerPreset(presetRef);
90
90
  this.config.save();
91
91
  }
92
- unregisterPreset(name) {
93
- this.config.unregisterPreset(name);
92
+ unregisterPreset(path) {
93
+ this.config.unregisterPreset(path);
94
94
  this.config.save();
95
95
  }
96
96
  getEnv(key, byDefault) {
@@ -1,6 +1,7 @@
1
1
  import { PresetSource } from "./PresetSource";
2
2
  export type PresetRef = {
3
3
  name: string;
4
- source: PresetSource;
4
+ /** @deprecated */
5
+ source?: PresetSource;
5
6
  path?: string;
6
7
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wocker/core",
3
3
  "type": "commonjs",
4
- "version": "1.1.4-beta.0",
4
+ "version": "1.1.4-beta.1",
5
5
  "author": "Kris Papercut <krispcut@gmail.com>",
6
6
  "description": "Core of the Wocker",
7
7
  "license": "MIT",