@wocker/core 1.0.14 → 1.0.16
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/decorators/Description.js +2 -2
- package/lib/decorators/Option.d.ts +1 -0
- package/lib/decorators/Option.js +1 -0
- package/lib/makes/AppConfig.d.ts +50 -0
- package/lib/makes/AppConfig.js +186 -0
- package/lib/makes/Config.d.ts +7 -34
- package/lib/makes/Config.js +8 -109
- package/lib/makes/FileSystem.d.ts +9 -4
- package/lib/makes/FileSystem.js +71 -6
- package/lib/makes/Preset.d.ts +2 -0
- package/lib/makes/Preset.js +6 -2
- package/lib/makes/Project.d.ts +1 -0
- package/lib/makes/Project.js +13 -2
- package/lib/makes/index.d.ts +1 -0
- package/lib/makes/index.js +1 -0
- package/lib/services/AppConfigService.d.ts +6 -11
- package/lib/services/AppConfigService.js +4 -15
- package/lib/services/LogService.d.ts +1 -0
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.js +0 -1
- package/package.json +1 -1
- package/lib/types/AppConfig.d.ts +0 -12
- package/lib/types/AppConfig.js +0 -2
|
@@ -4,8 +4,8 @@ exports.Description = void 0;
|
|
|
4
4
|
require("reflect-metadata");
|
|
5
5
|
const env_1 = require("../env");
|
|
6
6
|
const Description = (description) => {
|
|
7
|
-
return (
|
|
8
|
-
Reflect.defineMetadata(env_1.COMMAND_DESCRIPTION_METADATA, description, descriptor);
|
|
7
|
+
return (_target, _propertyKey, descriptor) => {
|
|
8
|
+
Reflect.defineMetadata(env_1.COMMAND_DESCRIPTION_METADATA, description, descriptor.value);
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
exports.Description = Description;
|
package/lib/decorators/Option.js
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { EnvConfig, PickProperties } from "../types";
|
|
2
|
+
import { PresetType } from "./Preset";
|
|
3
|
+
type ProjectData = {
|
|
4
|
+
id: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
/** @deprecated */
|
|
8
|
+
src?: string;
|
|
9
|
+
};
|
|
10
|
+
type PresetData = {
|
|
11
|
+
name: string;
|
|
12
|
+
source: PresetType;
|
|
13
|
+
path?: string;
|
|
14
|
+
};
|
|
15
|
+
export type AppConfigProperties = Omit<PickProperties<AppConfig>, "logLevel"> & {
|
|
16
|
+
logLevel?: AppConfig["logLevel"];
|
|
17
|
+
};
|
|
18
|
+
export declare abstract class AppConfig {
|
|
19
|
+
debug?: boolean;
|
|
20
|
+
logLevel: "off" | "info" | "warn" | "error";
|
|
21
|
+
plugins?: string[];
|
|
22
|
+
presets?: PresetData[];
|
|
23
|
+
projects?: ProjectData[];
|
|
24
|
+
meta?: EnvConfig;
|
|
25
|
+
env?: EnvConfig;
|
|
26
|
+
protected constructor(data: AppConfigProperties);
|
|
27
|
+
addPlugin(plugin: string): void;
|
|
28
|
+
removePlugin(removePlugin: string): void;
|
|
29
|
+
getProject(id: string): ProjectData | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated
|
|
32
|
+
* @see Project.addProject
|
|
33
|
+
*/
|
|
34
|
+
setProject(id: string, path: string): void;
|
|
35
|
+
addProject(id: string, name: string, path: string): void;
|
|
36
|
+
removeProject(id: string): void;
|
|
37
|
+
registerPreset(name: string, source: PresetType, path?: string): void;
|
|
38
|
+
unregisterPreset(name: string): void;
|
|
39
|
+
getMeta(name: string): string | undefined;
|
|
40
|
+
getMeta(name: string, defaultValue: string): string;
|
|
41
|
+
setMeta(name: string, value: string): void;
|
|
42
|
+
unsetMeta(name: string): void;
|
|
43
|
+
getEnv(name: string): string | undefined;
|
|
44
|
+
getEnv(name: string, defaultValue: string): string;
|
|
45
|
+
setEnv(name: string, value: string): void;
|
|
46
|
+
unsetEnv(name: string): void;
|
|
47
|
+
abstract save(): Promise<void>;
|
|
48
|
+
toJson(): AppConfigProperties;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppConfig = void 0;
|
|
4
|
+
const Preset_1 = require("./Preset");
|
|
5
|
+
class AppConfig {
|
|
6
|
+
constructor(data) {
|
|
7
|
+
this.logLevel = "off";
|
|
8
|
+
Object.assign(this, data);
|
|
9
|
+
}
|
|
10
|
+
addPlugin(plugin) {
|
|
11
|
+
if (!this.plugins) {
|
|
12
|
+
this.plugins = [];
|
|
13
|
+
}
|
|
14
|
+
if (this.plugins.includes(plugin)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
this.plugins.push(plugin);
|
|
18
|
+
}
|
|
19
|
+
removePlugin(removePlugin) {
|
|
20
|
+
if (!this.plugins) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
this.plugins = this.plugins.filter((plugin) => plugin !== removePlugin);
|
|
24
|
+
if (this.plugins.length === 0) {
|
|
25
|
+
delete this.plugins;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
getProject(id) {
|
|
29
|
+
if (!this.projects) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
return this.projects.find((projectData) => {
|
|
33
|
+
return projectData.id === id;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/* istanbul ignore next */
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated
|
|
39
|
+
* @see Project.addProject
|
|
40
|
+
*/
|
|
41
|
+
setProject(id, path) {
|
|
42
|
+
if (!this.projects) {
|
|
43
|
+
this.projects = [];
|
|
44
|
+
}
|
|
45
|
+
let projectData = this.projects.find((projectData) => {
|
|
46
|
+
return projectData.id === id;
|
|
47
|
+
});
|
|
48
|
+
if (!projectData) {
|
|
49
|
+
this.projects.push({
|
|
50
|
+
id,
|
|
51
|
+
path,
|
|
52
|
+
src: path
|
|
53
|
+
});
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
projectData.name = id;
|
|
57
|
+
projectData.path = path;
|
|
58
|
+
projectData.src = path;
|
|
59
|
+
}
|
|
60
|
+
addProject(id, name, path) {
|
|
61
|
+
if (!this.projects) {
|
|
62
|
+
this.projects = [];
|
|
63
|
+
}
|
|
64
|
+
let projectData = this.projects.find((projectData) => {
|
|
65
|
+
return projectData.id === id;
|
|
66
|
+
});
|
|
67
|
+
if (!projectData) {
|
|
68
|
+
this.projects.push({
|
|
69
|
+
id,
|
|
70
|
+
name,
|
|
71
|
+
path,
|
|
72
|
+
});
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
/* istanbul ignore next */
|
|
76
|
+
if (projectData.src) {
|
|
77
|
+
delete projectData.src;
|
|
78
|
+
}
|
|
79
|
+
projectData.name = name;
|
|
80
|
+
projectData.path = path;
|
|
81
|
+
}
|
|
82
|
+
removeProject(id) {
|
|
83
|
+
if (!this.projects) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.projects = this.projects.filter((projectData) => {
|
|
87
|
+
return projectData.id !== id;
|
|
88
|
+
});
|
|
89
|
+
if (this.projects.length === 0) {
|
|
90
|
+
delete this.projects;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
registerPreset(name, source, path) {
|
|
94
|
+
if (!this.presets) {
|
|
95
|
+
this.presets = [];
|
|
96
|
+
}
|
|
97
|
+
let presetData = this.presets.find((preset) => {
|
|
98
|
+
return preset.name === name;
|
|
99
|
+
});
|
|
100
|
+
if (!presetData) {
|
|
101
|
+
presetData = {
|
|
102
|
+
name,
|
|
103
|
+
source
|
|
104
|
+
};
|
|
105
|
+
this.presets.push(presetData);
|
|
106
|
+
}
|
|
107
|
+
presetData.source = source;
|
|
108
|
+
if (presetData.source === Preset_1.PRESET_SOURCE_EXTERNAL) {
|
|
109
|
+
presetData.path = path;
|
|
110
|
+
}
|
|
111
|
+
else if (presetData.path) {
|
|
112
|
+
delete presetData.path;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
unregisterPreset(name) {
|
|
116
|
+
if (!this.presets) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this.presets = this.presets.filter((preset) => {
|
|
120
|
+
return preset.name !== name;
|
|
121
|
+
});
|
|
122
|
+
if (this.presets.length === 0) {
|
|
123
|
+
delete this.presets;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
getMeta(name, defaultValue) {
|
|
127
|
+
if (!this.meta || !(name in this.meta)) {
|
|
128
|
+
return defaultValue;
|
|
129
|
+
}
|
|
130
|
+
return this.meta[name];
|
|
131
|
+
}
|
|
132
|
+
setMeta(name, value) {
|
|
133
|
+
if (!this.meta) {
|
|
134
|
+
this.meta = {};
|
|
135
|
+
}
|
|
136
|
+
this.meta[name] = value;
|
|
137
|
+
}
|
|
138
|
+
unsetMeta(name) {
|
|
139
|
+
if (!this.meta || !(name in this.meta)) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
delete this.meta[name];
|
|
143
|
+
if (Object.keys(this.meta).length === 0) {
|
|
144
|
+
delete this.meta;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
getEnv(name, defaultValue) {
|
|
148
|
+
if (!this.env || !(name in this.env)) {
|
|
149
|
+
return defaultValue;
|
|
150
|
+
}
|
|
151
|
+
return this.env[name];
|
|
152
|
+
}
|
|
153
|
+
setEnv(name, value) {
|
|
154
|
+
if (!this.env) {
|
|
155
|
+
this.env = {};
|
|
156
|
+
}
|
|
157
|
+
this.env[name] = value;
|
|
158
|
+
}
|
|
159
|
+
unsetEnv(name) {
|
|
160
|
+
if (!this.env || !(name in this.env)) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
delete this.env[name];
|
|
164
|
+
if (Object.keys(this.env).length === 0) {
|
|
165
|
+
delete this.env;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
toJson() {
|
|
169
|
+
const json = {
|
|
170
|
+
debug: this.debug,
|
|
171
|
+
logLevel: this.logLevel,
|
|
172
|
+
plugins: this.plugins,
|
|
173
|
+
projects: this.projects,
|
|
174
|
+
presets: this.presets,
|
|
175
|
+
env: this.env,
|
|
176
|
+
meta: this.meta
|
|
177
|
+
};
|
|
178
|
+
return Object.keys(json).reduce((res, key) => {
|
|
179
|
+
if (typeof json[key] !== "undefined") {
|
|
180
|
+
res[key] = json[key];
|
|
181
|
+
}
|
|
182
|
+
return res;
|
|
183
|
+
}, {});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.AppConfig = AppConfig;
|
package/lib/makes/Config.d.ts
CHANGED
|
@@ -1,36 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
logLevel: "off" | "info" | "warn" | "error";
|
|
9
|
-
plugins: string[];
|
|
10
|
-
presets?: {
|
|
11
|
-
name: string;
|
|
12
|
-
source: PresetType;
|
|
13
|
-
path?: string;
|
|
14
|
-
}[];
|
|
15
|
-
projects: {
|
|
16
|
-
id: string;
|
|
17
|
-
name?: string;
|
|
18
|
-
src: string;
|
|
19
|
-
}[];
|
|
20
|
-
meta?: EnvConfig;
|
|
21
|
-
env?: EnvConfig;
|
|
1
|
+
import { AppConfig, AppConfigProperties } from "./AppConfig";
|
|
2
|
+
export type ConfigProperties = AppConfigProperties;
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated
|
|
5
|
+
* @see AppConfig
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class Config extends AppConfig {
|
|
22
8
|
protected constructor(data: ConfigProperties);
|
|
23
|
-
addPlugin(plugin: string): void;
|
|
24
|
-
removePlugin(removePlugin: string): void;
|
|
25
|
-
setProject(id: string, path: string): void;
|
|
26
|
-
registerPreset(name: string, source: PresetType, path?: string): void;
|
|
27
|
-
unregisterPreset(name: string): void;
|
|
28
|
-
getMeta(name: string, defaultValue: string): string;
|
|
29
|
-
setMeta(name: string, value: string): void;
|
|
30
|
-
unsetMeta(name: string): void;
|
|
31
|
-
getEnv(name: string, defaultValue: string): string;
|
|
32
|
-
setEnv(name: string, value: string): void;
|
|
33
|
-
unsetEnv(name: string): void;
|
|
34
|
-
abstract save(): Promise<void>;
|
|
35
|
-
toJson(): ConfigProperties;
|
|
36
9
|
}
|
package/lib/makes/Config.js
CHANGED
|
@@ -1,116 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Config = void 0;
|
|
4
|
-
|
|
4
|
+
const AppConfig_1 = require("./AppConfig");
|
|
5
|
+
/* istanbul ignore next */
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated
|
|
8
|
+
* @see AppConfig
|
|
9
|
+
*/
|
|
10
|
+
class Config extends AppConfig_1.AppConfig {
|
|
5
11
|
constructor(data) {
|
|
6
|
-
|
|
7
|
-
this.plugins = [];
|
|
8
|
-
this.presets = [];
|
|
9
|
-
this.projects = [];
|
|
10
|
-
Object.assign(this, data);
|
|
11
|
-
}
|
|
12
|
-
addPlugin(plugin) {
|
|
13
|
-
if (!this.plugins) {
|
|
14
|
-
this.plugins = [];
|
|
15
|
-
}
|
|
16
|
-
if (this.plugins.includes(plugin)) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
this.plugins.push(plugin);
|
|
20
|
-
}
|
|
21
|
-
removePlugin(removePlugin) {
|
|
22
|
-
this.plugins = this.plugins.filter((plugin) => plugin !== removePlugin);
|
|
23
|
-
}
|
|
24
|
-
setProject(id, path) {
|
|
25
|
-
this.projects = [
|
|
26
|
-
...this.projects.filter((project) => {
|
|
27
|
-
return project.id !== id && project.src !== path;
|
|
28
|
-
}),
|
|
29
|
-
{
|
|
30
|
-
id,
|
|
31
|
-
src: path
|
|
32
|
-
}
|
|
33
|
-
];
|
|
34
|
-
}
|
|
35
|
-
registerPreset(name, source, path) {
|
|
36
|
-
if (!this.presets) {
|
|
37
|
-
this.presets = [];
|
|
38
|
-
}
|
|
39
|
-
const preset = this.presets.find((preset) => {
|
|
40
|
-
return preset.name === name;
|
|
41
|
-
});
|
|
42
|
-
if (!preset) {
|
|
43
|
-
this.presets.push({
|
|
44
|
-
name,
|
|
45
|
-
source,
|
|
46
|
-
path
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
unregisterPreset(name) {
|
|
51
|
-
if (!this.presets) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
this.presets = this.presets.filter((preset) => {
|
|
55
|
-
return preset.name !== name;
|
|
56
|
-
});
|
|
57
|
-
if (this.presets.length === 0) {
|
|
58
|
-
delete this.presets;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
getMeta(name, defaultValue) {
|
|
62
|
-
if (!this.meta || !(name in this.meta)) {
|
|
63
|
-
return defaultValue;
|
|
64
|
-
}
|
|
65
|
-
return this.meta[name];
|
|
66
|
-
}
|
|
67
|
-
setMeta(name, value) {
|
|
68
|
-
if (!this.meta) {
|
|
69
|
-
this.meta = {};
|
|
70
|
-
}
|
|
71
|
-
this.meta[name] = value;
|
|
72
|
-
}
|
|
73
|
-
unsetMeta(name) {
|
|
74
|
-
if (!this.meta || !(name in this.meta)) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
delete this.meta[name];
|
|
78
|
-
if (Object.keys(this.meta).length === 0) {
|
|
79
|
-
delete this.meta;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
getEnv(name, defaultValue) {
|
|
83
|
-
if (!this.env || !(name in this.env)) {
|
|
84
|
-
return defaultValue;
|
|
85
|
-
}
|
|
86
|
-
return this.env[name];
|
|
87
|
-
}
|
|
88
|
-
setEnv(name, value) {
|
|
89
|
-
if (!this.env) {
|
|
90
|
-
this.env = {};
|
|
91
|
-
}
|
|
92
|
-
this.env[name] = value;
|
|
93
|
-
}
|
|
94
|
-
unsetEnv(name) {
|
|
95
|
-
if (!this.env || !(name in this.env)) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
delete this.env[name];
|
|
99
|
-
if (Object.keys(this.env).length === 0) {
|
|
100
|
-
delete this.env;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// noinspection JSUnusedGlobalSymbols
|
|
104
|
-
toJson() {
|
|
105
|
-
return {
|
|
106
|
-
debug: this.debug,
|
|
107
|
-
logLevel: this.logLevel,
|
|
108
|
-
plugins: this.plugins,
|
|
109
|
-
projects: this.projects,
|
|
110
|
-
presets: (this.presets || []).length > 0 ? this.presets : undefined,
|
|
111
|
-
env: this.env,
|
|
112
|
-
meta: this.meta
|
|
113
|
-
};
|
|
12
|
+
super(data);
|
|
114
13
|
}
|
|
115
14
|
}
|
|
116
15
|
exports.Config = Config;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
type ReaddirOptions =
|
|
1
|
+
import FS, { RmOptions, Stats, WriteFileOptions } from "fs";
|
|
2
|
+
type ReaddirOptions = FS.ObjectEncodingOptions & {
|
|
3
3
|
recursive?: boolean | undefined;
|
|
4
4
|
};
|
|
5
5
|
export declare class FileSystem {
|
|
6
6
|
protected readonly source: string;
|
|
7
7
|
constructor(source: string);
|
|
8
8
|
path(...parts: string[]): string;
|
|
9
|
+
basename(...parts: string[]): string;
|
|
9
10
|
exists(...parts: string[]): boolean;
|
|
10
|
-
stat(...parts: string[]):
|
|
11
|
-
mkdir(path: string, options?:
|
|
11
|
+
stat(...parts: string[]): Stats;
|
|
12
|
+
mkdir(path: string, options?: FS.MakeDirectoryOptions): void;
|
|
12
13
|
readdir(...parts: string[]): Promise<unknown>;
|
|
13
14
|
readdirFiles(path?: string, options?: ReaddirOptions): Promise<string[]>;
|
|
15
|
+
readJSON(...paths: string[]): any;
|
|
16
|
+
writeFile(path: string, data: string | Buffer): Promise<void>;
|
|
17
|
+
writeJSON(path: string, data: any, options?: WriteFileOptions): Promise<void>;
|
|
18
|
+
rm(path: string, options?: RmOptions): Promise<void>;
|
|
14
19
|
}
|
|
15
20
|
export {};
|
package/lib/makes/FileSystem.js
CHANGED
|
@@ -31,9 +31,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
34
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
38
|
exports.FileSystem = void 0;
|
|
36
|
-
const
|
|
39
|
+
const fs_1 = __importDefault(require("fs"));
|
|
40
|
+
const fs_2 = __importDefault(require("fs"));
|
|
37
41
|
const Path = __importStar(require("path"));
|
|
38
42
|
class FileSystem {
|
|
39
43
|
constructor(source) {
|
|
@@ -42,23 +46,26 @@ class FileSystem {
|
|
|
42
46
|
path(...parts) {
|
|
43
47
|
return Path.join(this.source, ...parts);
|
|
44
48
|
}
|
|
49
|
+
basename(...parts) {
|
|
50
|
+
return Path.basename(this.path(...parts));
|
|
51
|
+
}
|
|
45
52
|
exists(...parts) {
|
|
46
53
|
const fullPath = this.path(...parts);
|
|
47
|
-
return
|
|
54
|
+
return fs_2.default.existsSync(fullPath);
|
|
48
55
|
}
|
|
49
56
|
stat(...parts) {
|
|
50
57
|
const fullPath = this.path(...parts);
|
|
51
|
-
return
|
|
58
|
+
return fs_2.default.statSync(fullPath);
|
|
52
59
|
}
|
|
53
60
|
mkdir(path, options) {
|
|
54
61
|
const fullPath = this.path(path);
|
|
55
|
-
|
|
62
|
+
fs_2.default.mkdirSync(fullPath, options);
|
|
56
63
|
}
|
|
57
64
|
readdir(...parts) {
|
|
58
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
66
|
const fullPath = this.path(...parts);
|
|
60
67
|
return new Promise((resolve, reject) => {
|
|
61
|
-
|
|
68
|
+
fs_2.default.readdir(fullPath, (err, files) => {
|
|
62
69
|
if (err) {
|
|
63
70
|
reject(err);
|
|
64
71
|
return;
|
|
@@ -72,7 +79,7 @@ class FileSystem {
|
|
|
72
79
|
return __awaiter(this, arguments, void 0, function* (path = "", options) {
|
|
73
80
|
const fullPath = this.path(path);
|
|
74
81
|
return new Promise((resolve, reject) => {
|
|
75
|
-
|
|
82
|
+
fs_2.default.readdir(fullPath, options, (err, files) => {
|
|
76
83
|
if (err) {
|
|
77
84
|
reject(err);
|
|
78
85
|
return;
|
|
@@ -86,5 +93,63 @@ class FileSystem {
|
|
|
86
93
|
});
|
|
87
94
|
});
|
|
88
95
|
}
|
|
96
|
+
readJSON(...paths) {
|
|
97
|
+
const filePath = this.path(...paths);
|
|
98
|
+
const res = fs_2.default.readFileSync(filePath);
|
|
99
|
+
return JSON.parse(res.toString());
|
|
100
|
+
}
|
|
101
|
+
writeFile(path, data) {
|
|
102
|
+
const fullPath = this.path(path);
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
fs_2.default.writeFile(fullPath, data, (err) => {
|
|
105
|
+
if (err) {
|
|
106
|
+
reject(err);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
resolve(undefined);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
writeJSON(path, data, options) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const fullPath = this.path(path);
|
|
116
|
+
const json = JSON.stringify(data, null, 4);
|
|
117
|
+
return new Promise((resolve, reject) => {
|
|
118
|
+
const callback = (err) => {
|
|
119
|
+
if (err) {
|
|
120
|
+
reject(err);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
resolve(undefined);
|
|
124
|
+
};
|
|
125
|
+
if (options) {
|
|
126
|
+
fs_2.default.writeFile(fullPath, json, options, callback);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
fs_2.default.writeFile(fullPath, json, callback);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
rm(path, options) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
const fullPath = this.path(path);
|
|
137
|
+
return new Promise((resolve, reject) => {
|
|
138
|
+
const callback = (err) => {
|
|
139
|
+
if (err) {
|
|
140
|
+
reject(err);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
resolve(undefined);
|
|
144
|
+
};
|
|
145
|
+
if (options) {
|
|
146
|
+
fs_1.default.rm(fullPath, options, callback);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
fs_1.default.rm(fullPath, callback);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
89
154
|
}
|
|
90
155
|
exports.FileSystem = FileSystem;
|
package/lib/makes/Preset.d.ts
CHANGED
package/lib/makes/Preset.js
CHANGED
|
@@ -4,9 +4,11 @@ exports.PRESET_SOURCE_GITHUB = exports.PRESET_SOURCE_EXTERNAL = exports.PRESET_S
|
|
|
4
4
|
class Preset {
|
|
5
5
|
constructor(data) {
|
|
6
6
|
this.name = data.name;
|
|
7
|
+
this.version = data.version;
|
|
8
|
+
this.type = data.type;
|
|
7
9
|
this.source = data.source;
|
|
8
10
|
this.path = data.path;
|
|
9
|
-
this.
|
|
11
|
+
this.image = data.image;
|
|
10
12
|
this.dockerfile = data.dockerfile;
|
|
11
13
|
this.buildArgsOptions = data.buildArgsOptions;
|
|
12
14
|
this.envOptions = data.envOptions;
|
|
@@ -17,8 +19,10 @@ class Preset {
|
|
|
17
19
|
toJSON() {
|
|
18
20
|
return {
|
|
19
21
|
name: this.name,
|
|
20
|
-
source: this.source,
|
|
21
22
|
version: this.version,
|
|
23
|
+
type: this.type,
|
|
24
|
+
source: this.source,
|
|
25
|
+
image: this.image,
|
|
22
26
|
dockerfile: this.dockerfile,
|
|
23
27
|
buildArgsOptions: this.buildArgsOptions,
|
|
24
28
|
envOptions: this.envOptions,
|
package/lib/makes/Project.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PickProperties, EnvConfig } from "../types";
|
|
2
|
+
export type ProjectType = typeof PROJECT_TYPE_DOCKERFILE | typeof PROJECT_TYPE_IMAGE | typeof PROJECT_TYPE_PRESET;
|
|
2
3
|
export type ProjectProperties = Omit<PickProperties<Project>, "containerName" | "domains">;
|
|
3
4
|
export declare abstract class Project {
|
|
4
5
|
id: string;
|
package/lib/makes/Project.js
CHANGED
|
@@ -155,9 +155,20 @@ class Project {
|
|
|
155
155
|
this.volumeMount(...restVolumes);
|
|
156
156
|
}
|
|
157
157
|
volumeUnmount(...volumes) {
|
|
158
|
-
|
|
159
|
-
return
|
|
158
|
+
if (!this.volumes || volumes.length === 0) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const [volume, ...restVolumes] = volumes;
|
|
162
|
+
const v = (0, volumeParse_1.volumeParse)(volume);
|
|
163
|
+
this.volumes = this.volumes.filter((mounted) => {
|
|
164
|
+
const m = (0, volumeParse_1.volumeParse)(mounted);
|
|
165
|
+
return v.source !== m.source && v.destination !== m.destination;
|
|
160
166
|
});
|
|
167
|
+
if (this.volumes.length === 0) {
|
|
168
|
+
delete this.volumes;
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
this.volumeUnmount(...restVolumes);
|
|
161
172
|
}
|
|
162
173
|
toJSON() {
|
|
163
174
|
return {
|
package/lib/makes/index.d.ts
CHANGED
package/lib/makes/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AppConfig"), exports);
|
|
17
18
|
__exportStar(require("./Config"), exports);
|
|
18
19
|
__exportStar(require("./Container"), exports);
|
|
19
20
|
__exportStar(require("./FileSystem"), exports);
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type TypeMap = {
|
|
3
|
-
[type: string]: string;
|
|
4
|
-
};
|
|
1
|
+
import { AppConfig } from "../makes";
|
|
5
2
|
declare abstract class AppConfigService {
|
|
6
|
-
protected config?:
|
|
7
|
-
abstract dataPath(...args: string[]): string;
|
|
8
|
-
abstract pluginsPath(...args: string[]): string;
|
|
3
|
+
protected config?: AppConfig;
|
|
9
4
|
abstract getPWD(): string;
|
|
10
5
|
abstract setPWD(pwd: string): void;
|
|
11
|
-
abstract
|
|
12
|
-
abstract
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
abstract dataPath(...args: string[]): string;
|
|
7
|
+
abstract pluginsPath(...args: string[]): string;
|
|
8
|
+
getConfig(): AppConfig;
|
|
9
|
+
protected abstract loadConfig(): AppConfig;
|
|
15
10
|
}
|
|
16
11
|
export { AppConfigService };
|
|
@@ -5,26 +5,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
9
|
exports.AppConfigService = void 0;
|
|
19
10
|
const decorators_1 = require("../decorators");
|
|
20
11
|
let AppConfigService = class AppConfigService {
|
|
21
12
|
getConfig() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return this.config;
|
|
27
|
-
});
|
|
13
|
+
if (!this.config) {
|
|
14
|
+
this.config = this.loadConfig();
|
|
15
|
+
}
|
|
16
|
+
return this.config;
|
|
28
17
|
}
|
|
29
18
|
};
|
|
30
19
|
exports.AppConfigService = AppConfigService;
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./AppConfig"), exports);
|
|
18
17
|
__exportStar(require("./EnvConfig"), exports);
|
|
19
18
|
__exportStar(require("./PickProperties"), exports);
|
|
20
19
|
__exportStar(require("./Volume"), exports);
|
package/package.json
CHANGED
package/lib/types/AppConfig.d.ts
DELETED
package/lib/types/AppConfig.js
DELETED