@wocker/core 1.1.0-beta.3 → 1.1.0-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.
|
@@ -8,6 +8,7 @@ export declare class JsonEditor<T extends object> {
|
|
|
8
8
|
protected createProxy(keys: JSONPath, options?: JsonEditor.CreateProxyOptions): any;
|
|
9
9
|
get(key: string | JSONPath): any;
|
|
10
10
|
set(key: string | JSONPath, value: any, options?: ModificationOptions): void;
|
|
11
|
+
unset(key: string | JSONPath): void;
|
|
11
12
|
isDirty(): boolean;
|
|
12
13
|
toString(): string;
|
|
13
14
|
}
|
package/lib/makes/JsonEditor.js
CHANGED
|
@@ -86,11 +86,19 @@ class JsonEditor {
|
|
|
86
86
|
}
|
|
87
87
|
return (0, jsonc_parser_1.getNodeValue)(node);
|
|
88
88
|
}
|
|
89
|
-
set(key, value, options
|
|
89
|
+
set(key, value, options) {
|
|
90
90
|
const path = typeof key === "string" ? key.split(".") : key;
|
|
91
|
-
this.content = (0, jsonc_parser_1.applyEdits)(this.content, (0, jsonc_parser_1.modify)(this.content, path, value, options
|
|
91
|
+
this.content = (0, jsonc_parser_1.applyEdits)(this.content, (0, jsonc_parser_1.modify)(this.content, path, value, options || {
|
|
92
|
+
formattingOptions: {
|
|
93
|
+
insertSpaces: true,
|
|
94
|
+
keepLines: false
|
|
95
|
+
}
|
|
96
|
+
}));
|
|
92
97
|
this.root = (0, jsonc_parser_1.parseTree)(this.content);
|
|
93
98
|
}
|
|
99
|
+
unset(key) {
|
|
100
|
+
this.set(key, undefined);
|
|
101
|
+
}
|
|
94
102
|
isDirty() {
|
|
95
103
|
return this.content !== this.original;
|
|
96
104
|
}
|
package/lib/makes/Project.js
CHANGED
|
@@ -3,30 +3,32 @@ import { EnvConfig, ProjectType } from "../types";
|
|
|
3
3
|
import { JsonEditor } from "./JsonEditor";
|
|
4
4
|
import { ServiceConfig } from "./ServiceConfig";
|
|
5
5
|
export declare class ProjectConfig extends JsonEditor<ProjectConfig.Data> {
|
|
6
|
-
|
|
6
|
+
readonly filename: string;
|
|
7
|
+
constructor(filename: string, content: string);
|
|
7
8
|
get type(): ProjectType | undefined;
|
|
8
9
|
set type(type: ProjectType | undefined);
|
|
9
|
-
get buildArgs(): EnvConfig;
|
|
10
|
-
set buildArgs(buildArgs: EnvConfig);
|
|
11
|
-
get env(): EnvConfig;
|
|
12
|
-
set env(env: EnvConfig | undefined);
|
|
13
|
-
get metadata(): EnvConfig;
|
|
14
|
-
set metadata(metadata: EnvConfig);
|
|
15
|
-
get preset(): string | undefined;
|
|
16
|
-
set preset(preset: string | undefined);
|
|
17
|
-
get presetMode(): "project" | "global" | undefined;
|
|
18
|
-
set presetMode(presetMode: "project" | "global" | undefined);
|
|
19
10
|
get image(): string | undefined;
|
|
20
11
|
set image(image: string | undefined);
|
|
21
12
|
get imageName(): string | undefined;
|
|
22
13
|
set imageName(image: string | undefined);
|
|
23
|
-
get composefile(): string | undefined;
|
|
24
|
-
set composefile(composefile: string | undefined);
|
|
25
14
|
get dockerfile(): string | undefined;
|
|
26
15
|
set dockerfile(dockerfile: string | undefined);
|
|
16
|
+
get composefile(): string | undefined;
|
|
17
|
+
set composefile(composefile: string | undefined);
|
|
18
|
+
get preset(): string | undefined;
|
|
19
|
+
set preset(preset: string | undefined);
|
|
20
|
+
get presetMode(): ProjectConfig.Data["presetMode"];
|
|
21
|
+
set presetMode(presetMode: ProjectConfig.Data["presetMode"]);
|
|
22
|
+
get buildArgs(): EnvConfig;
|
|
23
|
+
set buildArgs(buildArgs: EnvConfig);
|
|
24
|
+
get env(): EnvConfig;
|
|
25
|
+
set env(env: EnvConfig | undefined);
|
|
26
|
+
get metadata(): EnvConfig;
|
|
27
|
+
set metadata(metadata: EnvConfig);
|
|
27
28
|
get cmd(): string[] | undefined;
|
|
28
29
|
set cmd(cmd: string[] | undefined);
|
|
29
30
|
get scripts(): any;
|
|
31
|
+
set scripts(scripts: any);
|
|
30
32
|
get services(): any;
|
|
31
33
|
get extraHosts(): any;
|
|
32
34
|
set extraHosts(extraHosts: any);
|
|
@@ -49,7 +51,6 @@ export declare class ProjectConfig extends JsonEditor<ProjectConfig.Data> {
|
|
|
49
51
|
removeExtraHost(host: string): void;
|
|
50
52
|
addService(name: string, data: ServiceConfig.Data): void;
|
|
51
53
|
service(name: string): any;
|
|
52
|
-
toObject(): ProjectConfig.Data;
|
|
53
54
|
static make(fs: FileSystem, filename: string): ProjectConfig;
|
|
54
55
|
}
|
|
55
56
|
export declare namespace ProjectConfig {
|
|
@@ -4,55 +4,9 @@ exports.ProjectConfig = void 0;
|
|
|
4
4
|
const volumeParse_1 = require("../utils/volumeParse");
|
|
5
5
|
const JsonEditor_1 = require("./JsonEditor");
|
|
6
6
|
class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
7
|
-
|
|
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) {
|
|
7
|
+
constructor(filename, content) {
|
|
25
8
|
super(content);
|
|
26
|
-
|
|
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;
|
|
9
|
+
this.filename = filename;
|
|
56
10
|
}
|
|
57
11
|
get type() {
|
|
58
12
|
return this.state.type;
|
|
@@ -60,29 +14,30 @@ class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
|
60
14
|
set type(type) {
|
|
61
15
|
this.state.type = type;
|
|
62
16
|
}
|
|
63
|
-
get
|
|
64
|
-
return this.
|
|
65
|
-
removeOnEmpty: true
|
|
66
|
-
});
|
|
17
|
+
get image() {
|
|
18
|
+
return this.state.image || this.state.imageName;
|
|
67
19
|
}
|
|
68
|
-
set
|
|
69
|
-
this.state.
|
|
20
|
+
set image(image) {
|
|
21
|
+
this.state.image = image;
|
|
22
|
+
this.state.imageName = undefined;
|
|
70
23
|
}
|
|
71
|
-
get
|
|
72
|
-
return this.
|
|
73
|
-
removeOnEmpty: true
|
|
74
|
-
});
|
|
24
|
+
get imageName() {
|
|
25
|
+
return this.image;
|
|
75
26
|
}
|
|
76
|
-
set
|
|
77
|
-
this.
|
|
27
|
+
set imageName(image) {
|
|
28
|
+
this.image = image;
|
|
78
29
|
}
|
|
79
|
-
get
|
|
80
|
-
return this.
|
|
81
|
-
removeOnEmpty: true
|
|
82
|
-
});
|
|
30
|
+
get dockerfile() {
|
|
31
|
+
return this.state.dockerfile;
|
|
83
32
|
}
|
|
84
|
-
set
|
|
85
|
-
this.state.
|
|
33
|
+
set dockerfile(dockerfile) {
|
|
34
|
+
this.state.dockerfile = dockerfile;
|
|
35
|
+
}
|
|
36
|
+
get composefile() {
|
|
37
|
+
return this.state.composefile;
|
|
38
|
+
}
|
|
39
|
+
set composefile(composefile) {
|
|
40
|
+
this.state.composefile = composefile;
|
|
86
41
|
}
|
|
87
42
|
get preset() {
|
|
88
43
|
return this.state.preset;
|
|
@@ -96,29 +51,29 @@ class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
|
96
51
|
set presetMode(presetMode) {
|
|
97
52
|
this.state.presetMode = presetMode;
|
|
98
53
|
}
|
|
99
|
-
get
|
|
100
|
-
return this.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.state.image = image;
|
|
104
|
-
}
|
|
105
|
-
get imageName() {
|
|
106
|
-
return this.state.imageName;
|
|
54
|
+
get buildArgs() {
|
|
55
|
+
return this.createProxy(["buildArgs"], {
|
|
56
|
+
removeOnEmpty: true
|
|
57
|
+
});
|
|
107
58
|
}
|
|
108
|
-
set
|
|
109
|
-
this.state.
|
|
59
|
+
set buildArgs(buildArgs) {
|
|
60
|
+
this.state.buildArgs = Object.assign({}, buildArgs);
|
|
110
61
|
}
|
|
111
|
-
get
|
|
112
|
-
return this.
|
|
62
|
+
get env() {
|
|
63
|
+
return this.createProxy(["env"], {
|
|
64
|
+
removeOnEmpty: true
|
|
65
|
+
});
|
|
113
66
|
}
|
|
114
|
-
set
|
|
115
|
-
this.state.
|
|
67
|
+
set env(env) {
|
|
68
|
+
this.state.env = env ? Object.assign({}, env) : env;
|
|
116
69
|
}
|
|
117
|
-
get
|
|
118
|
-
return this.
|
|
70
|
+
get metadata() {
|
|
71
|
+
return this.createProxy(["metadata"], {
|
|
72
|
+
removeOnEmpty: true
|
|
73
|
+
});
|
|
119
74
|
}
|
|
120
|
-
set
|
|
121
|
-
this.state.
|
|
75
|
+
set metadata(metadata) {
|
|
76
|
+
this.state.metadata = Object.assign({}, metadata);
|
|
122
77
|
}
|
|
123
78
|
get cmd() {
|
|
124
79
|
return this.state.cmd;
|
|
@@ -127,13 +82,20 @@ class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
|
127
82
|
this.state.cmd = cmd;
|
|
128
83
|
}
|
|
129
84
|
get scripts() {
|
|
130
|
-
return {
|
|
85
|
+
return this.createProxy(["scripts"], {
|
|
86
|
+
removeOnEmpty: true
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
set scripts(scripts) {
|
|
90
|
+
this.state.scripts = scripts;
|
|
131
91
|
}
|
|
132
92
|
get services() {
|
|
133
93
|
return {};
|
|
134
94
|
}
|
|
135
95
|
get extraHosts() {
|
|
136
|
-
return this.createProxy(["extraHosts"]
|
|
96
|
+
return this.createProxy(["extraHosts"], {
|
|
97
|
+
removeOnEmpty: true
|
|
98
|
+
});
|
|
137
99
|
}
|
|
138
100
|
set extraHosts(extraHosts) {
|
|
139
101
|
this.state.extraHosts = Object.assign({}, extraHosts);
|
|
@@ -201,37 +163,17 @@ class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
|
201
163
|
? (value ? "true" : "false")
|
|
202
164
|
: value;
|
|
203
165
|
if (service) {
|
|
204
|
-
|
|
205
|
-
// return;
|
|
206
|
-
// }
|
|
207
|
-
//
|
|
208
|
-
// if(!this.services[service].env) {
|
|
209
|
-
// this.services[service].env = {};
|
|
210
|
-
// }
|
|
211
|
-
//
|
|
212
|
-
// this.services[service].env[key] = sValue;
|
|
166
|
+
this.set(["services", service, "env", key], sValue);
|
|
213
167
|
return;
|
|
214
168
|
}
|
|
215
|
-
this.env
|
|
169
|
+
this.set(["env", key], sValue);
|
|
216
170
|
}
|
|
217
171
|
unsetEnv(key, service) {
|
|
218
172
|
if (service) {
|
|
219
|
-
|
|
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
|
-
// }
|
|
173
|
+
this.unset(["services", service, "env", key]);
|
|
230
174
|
return;
|
|
231
175
|
}
|
|
232
|
-
|
|
233
|
-
delete this.env[key];
|
|
234
|
-
}
|
|
176
|
+
this.unset(["env", key]);
|
|
235
177
|
}
|
|
236
178
|
getVolumeBySource(source) {
|
|
237
179
|
return (this.state.volumes || []).find((volume) => {
|
|
@@ -290,40 +232,12 @@ class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
|
290
232
|
removeOnEmpty: true
|
|
291
233
|
});
|
|
292
234
|
}
|
|
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
235
|
static make(fs, filename) {
|
|
312
236
|
let content = "{}";
|
|
313
237
|
if (fs.exists(filename)) {
|
|
314
238
|
content = fs.readFile(filename).toString();
|
|
315
239
|
}
|
|
316
|
-
return new
|
|
317
|
-
save() {
|
|
318
|
-
// if(!fs.exists()) {
|
|
319
|
-
// fs.mkdir("", {
|
|
320
|
-
// recursive: true
|
|
321
|
-
// });
|
|
322
|
-
// }
|
|
323
|
-
//
|
|
324
|
-
// fs.writeJSON(filename, this.toObject());
|
|
325
|
-
}
|
|
326
|
-
}(content);
|
|
240
|
+
return new ProjectConfig(filename, content);
|
|
327
241
|
}
|
|
328
242
|
}
|
|
329
243
|
exports.ProjectConfig = ProjectConfig;
|
|
@@ -14,9 +14,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ProjectRepository = void 0;
|
|
16
16
|
const decorators_1 = require("../decorators");
|
|
17
|
+
const makes_1 = require("../makes");
|
|
17
18
|
const Project_1 = require("../makes/Project");
|
|
18
19
|
const ProjectConfig_1 = require("../makes/ProjectConfig");
|
|
19
|
-
const makes_1 = require("../makes");
|
|
20
20
|
const AppService_1 = require("./AppService");
|
|
21
21
|
const AppFileSystemService_1 = require("./AppFileSystemService");
|
|
22
22
|
const types_1 = require("../types");
|
|
@@ -35,7 +35,7 @@ let ProjectRepository = class ProjectRepository {
|
|
|
35
35
|
switch (scope) {
|
|
36
36
|
case types_1.ProjectConfigScope.APP:
|
|
37
37
|
return ProjectConfig_1.ProjectConfig.make(this.fs.cd(`projects/${ref.name}`), "config.json");
|
|
38
|
-
case types_1.
|
|
38
|
+
case types_1.ProjectConfigScope.LOCAL:
|
|
39
39
|
return ProjectConfig_1.ProjectConfig.make(new makes_1.FileSystem(ref.path, this.driver), "wocker.config.json");
|
|
40
40
|
}
|
|
41
41
|
}
|