@wocker/core 1.1.0-beta.1 → 1.1.0-beta.3
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/Container.js +2 -2
- package/lib/core/CoreModule.js +3 -0
- package/lib/makes/AppConfig.d.ts +15 -15
- package/lib/makes/AppConfig.js +0 -2
- package/lib/makes/JsonEditor.d.ts +19 -0
- package/lib/makes/JsonEditor.js +101 -0
- package/lib/makes/Project.d.ts +63 -0
- package/lib/makes/Project.js +229 -0
- package/lib/makes/ProjectConfig.d.ts +85 -0
- package/lib/makes/ProjectConfig.js +329 -0
- package/lib/makes/ServiceConfig.d.ts +23 -0
- package/lib/makes/ServiceConfig.js +57 -0
- package/lib/makes/index.d.ts +1 -0
- package/lib/makes/index.js +1 -0
- package/lib/modules/project/index.d.ts +0 -3
- package/lib/modules/project/index.js +0 -2
- package/lib/modules/project/services/ProjectService.d.ts +2 -2
- package/lib/services/AppFileSystemService.js +1 -1
- package/lib/services/AppService.d.ts +5 -2
- package/lib/services/AppService.js +10 -4
- package/lib/services/LogService.d.ts +6 -4
- package/lib/services/LogService.js +18 -10
- package/lib/services/ProcessService.d.ts +1 -1
- package/lib/services/ProjectRepository.d.ts +22 -0
- package/lib/services/ProjectRepository.js +89 -0
- package/lib/services/index.d.ts +1 -0
- package/lib/services/index.js +1 -0
- package/lib/types/LogLevel.d.ts +13 -0
- package/lib/types/LogLevel.js +20 -0
- package/lib/types/ProjectConfigScope.d.ts +9 -0
- package/lib/types/ProjectConfigScope.js +20 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +2 -0
- package/package.json +2 -1
- package/lib/modules/project/makes/Project.d.ts +0 -59
- package/lib/modules/project/makes/Project.js +0 -282
- package/lib/modules/project/repositories/ProjectRepository.d.ts +0 -13
- package/lib/modules/project/repositories/ProjectRepository.js +0 -16
- package/lib/modules/project/types/ProjectV1.d.ts +0 -25
- package/lib/modules/project/types/ProjectV1.js +0 -2
- package/lib/modules/project/types/ServiceProperties.d.ts +0 -9
- package/lib/modules/project/types/ServiceProperties.js +0 -2
- package/lib/modules/project/types/index.d.ts +0 -2
- package/lib/modules/project/types/index.js +0 -18
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProjectConfig = void 0;
|
|
4
|
+
const volumeParse_1 = require("../utils/volumeParse");
|
|
5
|
+
const JsonEditor_1 = require("./JsonEditor");
|
|
6
|
+
class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
7
|
+
// public editor: JsonEditor<ProjectConfig.Data>;
|
|
8
|
+
// protected state: ProjectConfig.Data;
|
|
9
|
+
// public type?: ProjectType;
|
|
10
|
+
// public image?: string;
|
|
11
|
+
// public dockerfile?: string;
|
|
12
|
+
// public composefile?: string;
|
|
13
|
+
// public preset?: string;
|
|
14
|
+
// public presetMode?: "global" | "project";
|
|
15
|
+
// public scripts: {
|
|
16
|
+
// [script: string]: string;
|
|
17
|
+
// };
|
|
18
|
+
// public cmd?: string[];
|
|
19
|
+
// public metadata: EnvConfig;
|
|
20
|
+
// public ports: string[];
|
|
21
|
+
// public volumes: string[];
|
|
22
|
+
// public extraHosts: EnvConfig;
|
|
23
|
+
// public services: Record<string, ProjectConfig.Service>;
|
|
24
|
+
constructor(content) {
|
|
25
|
+
super(content);
|
|
26
|
+
// this.editor = new JsonEditor<ProjectConfig.Data>(content);
|
|
27
|
+
// const {
|
|
28
|
+
// type,
|
|
29
|
+
// imageName,
|
|
30
|
+
// image = imageName,
|
|
31
|
+
// dockerfile,
|
|
32
|
+
// composefile,
|
|
33
|
+
// preset,
|
|
34
|
+
// presetMode,
|
|
35
|
+
// scripts = {},
|
|
36
|
+
// cmd,
|
|
37
|
+
// metadata = {},
|
|
38
|
+
// volumes = [],
|
|
39
|
+
// ports = [],
|
|
40
|
+
// extraHosts = {},
|
|
41
|
+
// services = {}
|
|
42
|
+
// } = data;
|
|
43
|
+
// this.type = type;
|
|
44
|
+
// this.image = image;
|
|
45
|
+
// this.dockerfile = dockerfile;
|
|
46
|
+
// this.composefile = composefile;
|
|
47
|
+
// this.preset = preset;
|
|
48
|
+
// this.presetMode = presetMode;
|
|
49
|
+
// this.scripts = scripts;
|
|
50
|
+
// this.cmd = cmd;
|
|
51
|
+
// this.metadata = metadata;
|
|
52
|
+
// this.volumes = volumes;
|
|
53
|
+
// this.ports = ports;
|
|
54
|
+
// this.extraHosts = extraHosts;
|
|
55
|
+
// this.services = services;
|
|
56
|
+
}
|
|
57
|
+
get type() {
|
|
58
|
+
return this.state.type;
|
|
59
|
+
}
|
|
60
|
+
set type(type) {
|
|
61
|
+
this.state.type = type;
|
|
62
|
+
}
|
|
63
|
+
get buildArgs() {
|
|
64
|
+
return this.createProxy(["buildArgs"], {
|
|
65
|
+
removeOnEmpty: true
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
set buildArgs(buildArgs) {
|
|
69
|
+
this.state.buildArgs = Object.assign({}, buildArgs);
|
|
70
|
+
}
|
|
71
|
+
get env() {
|
|
72
|
+
return this.createProxy(["env"], {
|
|
73
|
+
removeOnEmpty: true
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
set env(env) {
|
|
77
|
+
this.state.env = env ? Object.assign({}, env) : env;
|
|
78
|
+
}
|
|
79
|
+
get metadata() {
|
|
80
|
+
return this.createProxy(["metadata"], {
|
|
81
|
+
removeOnEmpty: true
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
set metadata(metadata) {
|
|
85
|
+
this.state.metadata = Object.assign({}, metadata);
|
|
86
|
+
}
|
|
87
|
+
get preset() {
|
|
88
|
+
return this.state.preset;
|
|
89
|
+
}
|
|
90
|
+
set preset(preset) {
|
|
91
|
+
this.state.preset = preset;
|
|
92
|
+
}
|
|
93
|
+
get presetMode() {
|
|
94
|
+
return this.state.presetMode;
|
|
95
|
+
}
|
|
96
|
+
set presetMode(presetMode) {
|
|
97
|
+
this.state.presetMode = presetMode;
|
|
98
|
+
}
|
|
99
|
+
get image() {
|
|
100
|
+
return this.state.image;
|
|
101
|
+
}
|
|
102
|
+
set image(image) {
|
|
103
|
+
this.state.image = image;
|
|
104
|
+
}
|
|
105
|
+
get imageName() {
|
|
106
|
+
return this.state.imageName;
|
|
107
|
+
}
|
|
108
|
+
set imageName(image) {
|
|
109
|
+
this.state.imageName = image;
|
|
110
|
+
}
|
|
111
|
+
get composefile() {
|
|
112
|
+
return this.state.composefile;
|
|
113
|
+
}
|
|
114
|
+
set composefile(composefile) {
|
|
115
|
+
this.state.composefile = composefile;
|
|
116
|
+
}
|
|
117
|
+
get dockerfile() {
|
|
118
|
+
return this.state.dockerfile;
|
|
119
|
+
}
|
|
120
|
+
set dockerfile(dockerfile) {
|
|
121
|
+
this.state.dockerfile = dockerfile;
|
|
122
|
+
}
|
|
123
|
+
get cmd() {
|
|
124
|
+
return this.state.cmd;
|
|
125
|
+
}
|
|
126
|
+
set cmd(cmd) {
|
|
127
|
+
this.state.cmd = cmd;
|
|
128
|
+
}
|
|
129
|
+
get scripts() {
|
|
130
|
+
return {};
|
|
131
|
+
}
|
|
132
|
+
get services() {
|
|
133
|
+
return {};
|
|
134
|
+
}
|
|
135
|
+
get extraHosts() {
|
|
136
|
+
return this.createProxy(["extraHosts"]);
|
|
137
|
+
}
|
|
138
|
+
set extraHosts(extraHosts) {
|
|
139
|
+
this.state.extraHosts = Object.assign({}, extraHosts);
|
|
140
|
+
}
|
|
141
|
+
get volumes() {
|
|
142
|
+
return this.createProxy(["volumes"], {
|
|
143
|
+
removeOnEmpty: true,
|
|
144
|
+
isArray: true
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
set volumes(volumes) {
|
|
148
|
+
this.state.volumes = volumes;
|
|
149
|
+
}
|
|
150
|
+
get ports() {
|
|
151
|
+
return this.createProxy(["ports"], {
|
|
152
|
+
isArray: true,
|
|
153
|
+
removeOnEmpty: true
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
set ports(ports) {
|
|
157
|
+
this.state.ports = [...ports];
|
|
158
|
+
}
|
|
159
|
+
setBuildArg(key, value, service) {
|
|
160
|
+
if (service) {
|
|
161
|
+
// if(!this.services[service]) {
|
|
162
|
+
// this.services[service] = {};
|
|
163
|
+
// }
|
|
164
|
+
//
|
|
165
|
+
// if(!this.services[service].buildArgs) {
|
|
166
|
+
// this.services[service].buildArgs = {};
|
|
167
|
+
// }
|
|
168
|
+
//
|
|
169
|
+
// this.services[service].buildArgs[key] = value;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
this.buildArgs[key] = value;
|
|
173
|
+
}
|
|
174
|
+
unsetBuildArg(name, service) {
|
|
175
|
+
if (service) {
|
|
176
|
+
// if(!this.services[service]) {
|
|
177
|
+
// return;
|
|
178
|
+
// }
|
|
179
|
+
//
|
|
180
|
+
// if(this.services[service].buildArgs && name in this.services[service].buildArgs) {
|
|
181
|
+
// delete this.services[service].buildArgs[name];
|
|
182
|
+
// }
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (name in this.buildArgs) {
|
|
186
|
+
delete this.buildArgs[name];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
getEnv(key, byDefault) {
|
|
190
|
+
if (key in this.env) {
|
|
191
|
+
return this.env[key];
|
|
192
|
+
}
|
|
193
|
+
return byDefault;
|
|
194
|
+
}
|
|
195
|
+
hasEnv(key) {
|
|
196
|
+
// return this.env.hasOwnProperty(key);
|
|
197
|
+
return key in this.env;
|
|
198
|
+
}
|
|
199
|
+
setEnv(key, value, service) {
|
|
200
|
+
const sValue = typeof value === "boolean"
|
|
201
|
+
? (value ? "true" : "false")
|
|
202
|
+
: value;
|
|
203
|
+
if (service) {
|
|
204
|
+
// if(!this.services[service]) {
|
|
205
|
+
// return;
|
|
206
|
+
// }
|
|
207
|
+
//
|
|
208
|
+
// if(!this.services[service].env) {
|
|
209
|
+
// this.services[service].env = {};
|
|
210
|
+
// }
|
|
211
|
+
//
|
|
212
|
+
// this.services[service].env[key] = sValue;
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
this.env[key] = sValue;
|
|
216
|
+
}
|
|
217
|
+
unsetEnv(key, service) {
|
|
218
|
+
if (service) {
|
|
219
|
+
// if(!this.services[service]) {
|
|
220
|
+
// throw new Error(`Service "${service}" not found`);
|
|
221
|
+
// }
|
|
222
|
+
//
|
|
223
|
+
// if(this.services[service].env && key in this.services[service].env) {
|
|
224
|
+
// delete this.services[service].env[key];
|
|
225
|
+
//
|
|
226
|
+
// if(Object.keys(this.services[service].env).length === 0) {
|
|
227
|
+
// delete this.services[service].env;
|
|
228
|
+
// }
|
|
229
|
+
// }
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (key in this.env) {
|
|
233
|
+
delete this.env[key];
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
getVolumeBySource(source) {
|
|
237
|
+
return (this.state.volumes || []).find((volume) => {
|
|
238
|
+
return (0, volumeParse_1.volumeParse)(volume).source === source;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
getVolumeByDestination(destination) {
|
|
242
|
+
return (this.state.volumes || []).find((volume) => {
|
|
243
|
+
return (0, volumeParse_1.volumeParse)(volume).destination === destination;
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
volumeMount(...volumes) {
|
|
247
|
+
if (volumes.length === 0) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const [volume, ...restVolumes] = volumes;
|
|
251
|
+
const { destination } = (0, volumeParse_1.volumeParse)(volume);
|
|
252
|
+
this.state.volumes = [
|
|
253
|
+
...(this.state.volumes || []).filter((v) => {
|
|
254
|
+
return v !== this.getVolumeByDestination(destination);
|
|
255
|
+
}),
|
|
256
|
+
volume
|
|
257
|
+
];
|
|
258
|
+
this.volumeMount(...restVolumes);
|
|
259
|
+
}
|
|
260
|
+
volumeUnmount(...volumes) {
|
|
261
|
+
if (!this.state.volumes || volumes.length === 0) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const [volume, ...restVolumes] = volumes;
|
|
265
|
+
const v = (0, volumeParse_1.volumeParse)(volume);
|
|
266
|
+
this.state.volumes = this.state.volumes.filter((mounted) => {
|
|
267
|
+
const m = (0, volumeParse_1.volumeParse)(mounted);
|
|
268
|
+
return v.source !== m.source && v.destination !== m.destination;
|
|
269
|
+
});
|
|
270
|
+
if (this.state.volumes.length === 0) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
this.volumeUnmount(...restVolumes);
|
|
274
|
+
}
|
|
275
|
+
addExtraHost(host, domain) {
|
|
276
|
+
if (!this.state.extraHosts) {
|
|
277
|
+
this.state.extraHosts = {};
|
|
278
|
+
}
|
|
279
|
+
this.state.extraHosts[host] = domain;
|
|
280
|
+
}
|
|
281
|
+
removeExtraHost(host) {
|
|
282
|
+
if (this.state.extraHosts && host in this.state.extraHosts) {
|
|
283
|
+
delete this.state.extraHosts[host];
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
addService(name, data) {
|
|
287
|
+
}
|
|
288
|
+
service(name) {
|
|
289
|
+
return this.createProxy(["services", name], {
|
|
290
|
+
removeOnEmpty: true
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
toObject() {
|
|
294
|
+
// return {
|
|
295
|
+
// type: this.type,
|
|
296
|
+
// image: this.image,
|
|
297
|
+
// dockerfile: this.dockerfile,
|
|
298
|
+
// composefile: this.composefile,
|
|
299
|
+
// preset: this.preset,
|
|
300
|
+
// presetMode: this.presetMode,
|
|
301
|
+
// scripts: Object.keys(this.scripts).length > 0 ? this.scripts : undefined,
|
|
302
|
+
// cmd: this.cmd,
|
|
303
|
+
// buildArgs: Object.keys(this.buildArgs).length > 0 ? this.buildArgs : undefined,
|
|
304
|
+
// env: Object.keys(this.env).length > 0 ? this.env : undefined,
|
|
305
|
+
// metadata: Object.keys(this.metadata).length > 0 ? this.metadata : undefined,
|
|
306
|
+
// volumes: this.volumes.length > 0 ? this.volumes : undefined,
|
|
307
|
+
// ports: this.ports.length > 0 ? this.ports : undefined,
|
|
308
|
+
// };
|
|
309
|
+
return this.state;
|
|
310
|
+
}
|
|
311
|
+
static make(fs, filename) {
|
|
312
|
+
let content = "{}";
|
|
313
|
+
if (fs.exists(filename)) {
|
|
314
|
+
content = fs.readFile(filename).toString();
|
|
315
|
+
}
|
|
316
|
+
return new class extends ProjectConfig {
|
|
317
|
+
save() {
|
|
318
|
+
// if(!fs.exists()) {
|
|
319
|
+
// fs.mkdir("", {
|
|
320
|
+
// recursive: true
|
|
321
|
+
// });
|
|
322
|
+
// }
|
|
323
|
+
//
|
|
324
|
+
// fs.writeJSON(filename, this.toObject());
|
|
325
|
+
}
|
|
326
|
+
}(content);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
exports.ProjectConfig = ProjectConfig;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EnvConfig } from "../types";
|
|
2
|
+
export declare class ServiceConfig {
|
|
3
|
+
protected readonly original: ServiceConfig.Data;
|
|
4
|
+
protected readonly state: ServiceConfig.Data;
|
|
5
|
+
constructor(original: ServiceConfig.Data);
|
|
6
|
+
get buildArgs(): EnvConfig;
|
|
7
|
+
set buildArgs(buildArgs: EnvConfig);
|
|
8
|
+
get env(): EnvConfig;
|
|
9
|
+
set env(env: EnvConfig);
|
|
10
|
+
isDirty(): boolean;
|
|
11
|
+
toObject(): ServiceConfig.Data;
|
|
12
|
+
}
|
|
13
|
+
export declare namespace ServiceConfig {
|
|
14
|
+
type Data = {
|
|
15
|
+
type?: "compose" | "plugin";
|
|
16
|
+
image?: string;
|
|
17
|
+
containerName?: string;
|
|
18
|
+
buildArgs?: EnvConfig;
|
|
19
|
+
env?: EnvConfig;
|
|
20
|
+
ports?: string[];
|
|
21
|
+
volumes?: string[];
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceConfig = void 0;
|
|
4
|
+
class ServiceConfig {
|
|
5
|
+
constructor(original) {
|
|
6
|
+
this.original = original;
|
|
7
|
+
this.state = JSON.parse(JSON.stringify(this.original));
|
|
8
|
+
}
|
|
9
|
+
get buildArgs() {
|
|
10
|
+
if (!this.state.buildArgs) {
|
|
11
|
+
this.state.buildArgs = {};
|
|
12
|
+
}
|
|
13
|
+
return this.state.buildArgs;
|
|
14
|
+
}
|
|
15
|
+
set buildArgs(buildArgs) {
|
|
16
|
+
this.state.buildArgs = Object.assign({}, buildArgs);
|
|
17
|
+
}
|
|
18
|
+
get env() {
|
|
19
|
+
if (!this.state.env) {
|
|
20
|
+
this.state.env = {};
|
|
21
|
+
}
|
|
22
|
+
return this.state.env;
|
|
23
|
+
}
|
|
24
|
+
set env(env) {
|
|
25
|
+
this.state.env = Object.assign({}, env);
|
|
26
|
+
}
|
|
27
|
+
isDirty() {
|
|
28
|
+
return JSON.stringify(this.toObject()) !== JSON.stringify(this.original);
|
|
29
|
+
}
|
|
30
|
+
toObject() {
|
|
31
|
+
const { type, image, containerName, buildArgs, env, volumes, ports } = this.state;
|
|
32
|
+
const object = {};
|
|
33
|
+
if (type) {
|
|
34
|
+
object.type = type;
|
|
35
|
+
}
|
|
36
|
+
if (image) {
|
|
37
|
+
object.image = image;
|
|
38
|
+
}
|
|
39
|
+
if (containerName) {
|
|
40
|
+
object.containerName = containerName;
|
|
41
|
+
}
|
|
42
|
+
if (buildArgs && Object.keys(buildArgs).length > 0) {
|
|
43
|
+
object.buildArgs = Object.assign({}, buildArgs);
|
|
44
|
+
}
|
|
45
|
+
if (env && Object.keys(env).length > 0) {
|
|
46
|
+
object.env = Object.assign({}, env);
|
|
47
|
+
}
|
|
48
|
+
if (volumes && volumes.length > 0) {
|
|
49
|
+
object.volumes = [...volumes];
|
|
50
|
+
}
|
|
51
|
+
if (ports && ports.length > 0) {
|
|
52
|
+
object.ports = [...ports];
|
|
53
|
+
}
|
|
54
|
+
return object;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.ServiceConfig = ServiceConfig;
|
package/lib/makes/index.d.ts
CHANGED
package/lib/makes/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./ConfigCollection"), exports);
|
|
|
20
20
|
__exportStar(require("./FileSystem"), exports);
|
|
21
21
|
__exportStar(require("./FileSystemManager"), exports);
|
|
22
22
|
__exportStar(require("./Logger"), exports);
|
|
23
|
+
__exportStar(require("./Project"), exports);
|
|
23
24
|
__exportStar(require("./Version"), exports);
|
|
24
25
|
__exportStar(require("./VersionRange"), exports);
|
|
25
26
|
__exportStar(require("./VersionRule"), exports);
|
|
@@ -14,6 +14,4 @@ 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("./makes/Project"), exports);
|
|
18
|
-
__exportStar(require("./repositories/ProjectRepository"), exports);
|
|
19
17
|
__exportStar(require("./services/ProjectService"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Project } from "
|
|
2
|
-
import { ProjectRepository } from "
|
|
1
|
+
import { Project } from "../../../makes/Project";
|
|
2
|
+
import { ProjectRepository } from "../../../services/ProjectRepository";
|
|
3
3
|
export declare abstract class ProjectService {
|
|
4
4
|
abstract get(name?: string): Project;
|
|
5
5
|
abstract save(project: Project): void;
|
|
@@ -23,7 +23,7 @@ let AppFileSystemService = class AppFileSystemService extends FileSystem_1.FileS
|
|
|
23
23
|
};
|
|
24
24
|
exports.AppFileSystemService = AppFileSystemService;
|
|
25
25
|
exports.AppFileSystemService = AppFileSystemService = __decorate([
|
|
26
|
-
(0, decorators_1.Injectable)(),
|
|
26
|
+
(0, decorators_1.Injectable)("APP_FILE_SYSTEM_SERVICE"),
|
|
27
27
|
__param(0, (0, decorators_1.Inject)(env_1.WOCKER_DATA_DIR_KEY)),
|
|
28
28
|
__param(1, (0, decorators_1.Inject)(env_1.FILE_SYSTEM_DRIVER_KEY)),
|
|
29
29
|
__metadata("design:paramtypes", [String, Object])
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { AppConfig } from "../makes/AppConfig";
|
|
2
2
|
import { AppFileSystemService } from "./AppFileSystemService";
|
|
3
3
|
import { ProcessService } from "./ProcessService";
|
|
4
|
+
import { LogService } from "./LogService";
|
|
4
5
|
import { ProjectRef, PluginRef, PresetRef, PresetSource } from "../types";
|
|
5
6
|
type TypeMap = {
|
|
6
7
|
[type: string]: string;
|
|
7
8
|
};
|
|
8
9
|
export declare class AppService {
|
|
9
10
|
readonly version: string;
|
|
10
|
-
protected readonly processService: ProcessService;
|
|
11
11
|
readonly fs: AppFileSystemService;
|
|
12
|
+
protected readonly processService: ProcessService;
|
|
13
|
+
protected readonly logService: LogService;
|
|
12
14
|
protected _config?: AppConfig;
|
|
13
15
|
protected readonly mapTypes: TypeMap;
|
|
14
|
-
constructor(version: string, processService: ProcessService,
|
|
16
|
+
constructor(version: string, fs: AppFileSystemService, processService: ProcessService, logService: LogService);
|
|
15
17
|
get config(): AppConfig;
|
|
16
18
|
get debug(): boolean;
|
|
17
19
|
set debug(debug: boolean);
|
|
@@ -21,6 +23,7 @@ export declare class AppService {
|
|
|
21
23
|
isVersionGT(version: string): boolean;
|
|
22
24
|
isVersionGTE(version: string): boolean;
|
|
23
25
|
getProjectTypes(): TypeMap;
|
|
26
|
+
getProject(name: string): ProjectRef | undefined;
|
|
24
27
|
addProject(name: string, path: string): void;
|
|
25
28
|
removeProject(name: string): void;
|
|
26
29
|
addPlugin(name: string, env?: PluginRef["env"]): void;
|
|
@@ -18,13 +18,15 @@ const Version_1 = require("../makes/Version");
|
|
|
18
18
|
const AppConfig_1 = require("../makes/AppConfig");
|
|
19
19
|
const AppFileSystemService_1 = require("./AppFileSystemService");
|
|
20
20
|
const ProcessService_1 = require("./ProcessService");
|
|
21
|
+
const LogService_1 = require("./LogService");
|
|
21
22
|
const types_1 = require("../types");
|
|
22
23
|
const env_1 = require("../env");
|
|
23
24
|
let AppService = class AppService {
|
|
24
|
-
constructor(version, processService,
|
|
25
|
+
constructor(version, fs, processService, logService) {
|
|
25
26
|
this.version = version;
|
|
26
|
-
this.processService = processService;
|
|
27
27
|
this.fs = fs;
|
|
28
|
+
this.processService = processService;
|
|
29
|
+
this.logService = logService;
|
|
28
30
|
this.mapTypes = {
|
|
29
31
|
[types_1.ProjectType.IMAGE]: "Image",
|
|
30
32
|
[types_1.ProjectType.PRESET]: "Preset",
|
|
@@ -64,6 +66,9 @@ let AppService = class AppService {
|
|
|
64
66
|
}
|
|
65
67
|
return this.mapTypes;
|
|
66
68
|
}
|
|
69
|
+
getProject(name) {
|
|
70
|
+
return this.config.getProject(name);
|
|
71
|
+
}
|
|
67
72
|
addProject(name, path) {
|
|
68
73
|
this.config.addProject(name, path);
|
|
69
74
|
this.config.save();
|
|
@@ -128,6 +133,7 @@ exports.AppService = AppService;
|
|
|
128
133
|
exports.AppService = AppService = __decorate([
|
|
129
134
|
(0, decorators_1.Injectable)("APP_SERVICE"),
|
|
130
135
|
__param(0, (0, decorators_1.Inject)(env_1.WOCKER_VERSION_KEY)),
|
|
131
|
-
__metadata("design:paramtypes", [String,
|
|
132
|
-
|
|
136
|
+
__metadata("design:paramtypes", [String, AppFileSystemService_1.AppFileSystemService,
|
|
137
|
+
ProcessService_1.ProcessService,
|
|
138
|
+
LogService_1.LogService])
|
|
133
139
|
], AppService);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProcessService } from "./ProcessService";
|
|
2
2
|
import { AppFileSystemService } from "./AppFileSystemService";
|
|
3
|
+
import { LogLevel } from "../types";
|
|
3
4
|
export declare class LogService {
|
|
4
|
-
protected readonly
|
|
5
|
+
protected readonly processService: ProcessService;
|
|
5
6
|
protected readonly fs: AppFileSystemService;
|
|
6
|
-
constructor(
|
|
7
|
+
constructor(processService: ProcessService, fs: AppFileSystemService);
|
|
8
|
+
get logLevel(): LogLevel;
|
|
7
9
|
protected get logName(): string;
|
|
8
|
-
protected _log(type:
|
|
10
|
+
protected _log(type: LogLevel, ...data: any[]): void;
|
|
9
11
|
debug(...data: any[]): void;
|
|
10
12
|
log(...data: any[]): void;
|
|
11
13
|
info(...data: any[]): void;
|
|
@@ -12,18 +12,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.LogService = void 0;
|
|
13
13
|
const format_1 = require("date-fns/format");
|
|
14
14
|
const decorators_1 = require("../decorators");
|
|
15
|
-
const
|
|
15
|
+
const ProcessService_1 = require("./ProcessService");
|
|
16
16
|
const AppFileSystemService_1 = require("./AppFileSystemService");
|
|
17
|
+
const types_1 = require("../types");
|
|
17
18
|
let LogService = class LogService {
|
|
18
|
-
constructor(
|
|
19
|
-
this.
|
|
19
|
+
constructor(processService, fs) {
|
|
20
|
+
this.processService = processService;
|
|
20
21
|
this.fs = fs;
|
|
21
22
|
}
|
|
23
|
+
get logLevel() {
|
|
24
|
+
const level = this.processService.getEnv("WS_LOG_LEVEL", types_1.LogLevel.WARNING);
|
|
25
|
+
if (types_1.LogLevel.values().includes(level)) {
|
|
26
|
+
return level;
|
|
27
|
+
}
|
|
28
|
+
return types_1.LogLevel.WARNING;
|
|
29
|
+
}
|
|
22
30
|
get logName() {
|
|
23
31
|
return "ws.log";
|
|
24
32
|
}
|
|
25
33
|
_log(type, ...data) {
|
|
26
|
-
if (
|
|
34
|
+
if (!types_1.LogLevel.isGTE(this.logLevel, type)) {
|
|
27
35
|
return;
|
|
28
36
|
}
|
|
29
37
|
const time = (0, format_1.format)(new Date(), "yyyy-MM-dd HH:mm:ss");
|
|
@@ -36,19 +44,19 @@ let LogService = class LogService {
|
|
|
36
44
|
this.fs.appendFile(this.logName, `[${time}] ${type}: ${logData}\n`);
|
|
37
45
|
}
|
|
38
46
|
debug(...data) {
|
|
39
|
-
this._log(
|
|
47
|
+
this._log(types_1.LogLevel.DEBUG, ...data);
|
|
40
48
|
}
|
|
41
49
|
log(...data) {
|
|
42
|
-
this._log(
|
|
50
|
+
this._log(types_1.LogLevel.LOG, ...data);
|
|
43
51
|
}
|
|
44
52
|
info(...data) {
|
|
45
|
-
this._log(
|
|
53
|
+
this._log(types_1.LogLevel.INFO, ...data);
|
|
46
54
|
}
|
|
47
55
|
warn(...data) {
|
|
48
|
-
this._log(
|
|
56
|
+
this._log(types_1.LogLevel.WARNING, ...data);
|
|
49
57
|
}
|
|
50
58
|
error(...data) {
|
|
51
|
-
this._log(
|
|
59
|
+
this._log(types_1.LogLevel.ERROR, ...data);
|
|
52
60
|
}
|
|
53
61
|
clear() {
|
|
54
62
|
this.fs.writeFile(this.logName, "");
|
|
@@ -57,6 +65,6 @@ let LogService = class LogService {
|
|
|
57
65
|
exports.LogService = LogService;
|
|
58
66
|
exports.LogService = LogService = __decorate([
|
|
59
67
|
(0, decorators_1.Injectable)("LOG_SERVICE"),
|
|
60
|
-
__metadata("design:paramtypes", [
|
|
68
|
+
__metadata("design:paramtypes", [ProcessService_1.ProcessService,
|
|
61
69
|
AppFileSystemService_1.AppFileSystemService])
|
|
62
70
|
], LogService);
|
|
@@ -8,7 +8,7 @@ export declare class ProcessService {
|
|
|
8
8
|
cd(path: string): void;
|
|
9
9
|
chdir(path: string): void;
|
|
10
10
|
write(chunk: string | Buffer): boolean;
|
|
11
|
-
getEnv(key: string
|
|
11
|
+
getEnv(key: string): string | undefined;
|
|
12
12
|
getEnv(key: string, byDefault: string): string;
|
|
13
13
|
setEnv(key: string, value: string): void;
|
|
14
14
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Project } from "../makes/Project";
|
|
2
|
+
import { ProjectConfig } from "../makes/ProjectConfig";
|
|
3
|
+
import { AppService } from "./AppService";
|
|
4
|
+
import { AppFileSystemService } from "./AppFileSystemService";
|
|
5
|
+
import { FileSystemDriver, ProjectConfigScope } from "../types";
|
|
6
|
+
export declare class ProjectRepository {
|
|
7
|
+
protected readonly appService: AppService;
|
|
8
|
+
protected readonly fs: AppFileSystemService;
|
|
9
|
+
protected readonly driver: FileSystemDriver;
|
|
10
|
+
constructor(appService: AppService, fs: AppFileSystemService, driver: FileSystemDriver);
|
|
11
|
+
getConfig(name: string, scope: ProjectConfigScope): ProjectConfig;
|
|
12
|
+
getByName(name: string): Project;
|
|
13
|
+
save(project: Project): void;
|
|
14
|
+
search(params: ProjectRepository.SearchParams): Project[];
|
|
15
|
+
searchOne(params: ProjectRepository.SearchParams): Project | null;
|
|
16
|
+
}
|
|
17
|
+
export declare namespace ProjectRepository {
|
|
18
|
+
type SearchParams = Partial<{
|
|
19
|
+
name: string;
|
|
20
|
+
path: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|