@wocker/core 1.1.9-beta.1 → 1.1.9-beta.2
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/makes/LayerResolver.d.ts +3 -1
- package/lib/makes/LayerResolver.js +23 -3
- package/lib/makes/Project.d.ts +4 -2
- package/lib/makes/Project.js +39 -30
- package/lib/makes/ProjectConfig.d.ts +10 -19
- package/lib/makes/ProjectConfig.js +15 -12
- package/lib/services/ProjectRepository.d.ts +2 -2
- package/lib/services/ProjectRepository.js +4 -4
- package/lib/types/ProjectLayerType.d.ts +11 -0
- package/lib/types/ProjectLayerType.js +33 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +1 -1
- package/package.json +1 -1
- package/lib/makes/ServiceConfig.d.ts +0 -23
- package/lib/makes/ServiceConfig.js +0 -57
- package/lib/types/ProjectConfigScope.d.ts +0 -10
- package/lib/types/ProjectConfigScope.js +0 -21
|
@@ -20,9 +20,11 @@ export declare const record: <T extends object>(rules: Rules<T>) => ResolveRule<
|
|
|
20
20
|
export declare const resolveObject: <D>(rules: Rules<D>, sources: D[]) => D;
|
|
21
21
|
export declare class LayerResolver<D, L extends D = D> {
|
|
22
22
|
protected readonly rules: Rules<D>;
|
|
23
|
-
protected readonly
|
|
23
|
+
protected readonly _layers: Layer<L>[];
|
|
24
24
|
constructor(rules: Rules<D>, layers: Layer<L>[]);
|
|
25
|
+
get layers(): Layer<L>[];
|
|
25
26
|
layer(name: string): Layer<L> | undefined;
|
|
27
|
+
origin(path: keyof D | string[]): string | undefined;
|
|
26
28
|
resolve<K extends keyof D>(path: K | [K]): D[K];
|
|
27
29
|
resolve<K extends keyof D, K2 extends keyof NonNullable<D[K]>>(path: [K, K2]): NonNullable<D[K]>[K2];
|
|
28
30
|
resolve<K extends keyof D, K2 extends keyof NonNullable<D[K]>, K3 extends keyof NonNullable<NonNullable<D[K]>[K2]>>(path: [K, K2, K3]): NonNullable<NonNullable<D[K]>[K2]>[K3];
|
|
@@ -69,16 +69,36 @@ exports.resolveObject = resolveObject;
|
|
|
69
69
|
class LayerResolver {
|
|
70
70
|
constructor(rules, layers) {
|
|
71
71
|
this.rules = rules;
|
|
72
|
-
this.
|
|
72
|
+
this._layers = [...layers].sort((a, b) => a.priority - b.priority);
|
|
73
|
+
}
|
|
74
|
+
get layers() {
|
|
75
|
+
return this._layers;
|
|
73
76
|
}
|
|
74
77
|
layer(name) {
|
|
75
|
-
return this.
|
|
78
|
+
return this._layers.find((l) => l.name === name);
|
|
79
|
+
}
|
|
80
|
+
origin(path) {
|
|
81
|
+
const segments = Array.isArray(path) ? path : [path];
|
|
82
|
+
for (const layer of this._layers) {
|
|
83
|
+
let value = layer.data;
|
|
84
|
+
for (const segment of segments) {
|
|
85
|
+
if (value === null || typeof value !== "object") {
|
|
86
|
+
value = undefined;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
value = value[segment];
|
|
90
|
+
}
|
|
91
|
+
if (isDefined(value)) {
|
|
92
|
+
return layer.name;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
76
96
|
}
|
|
77
97
|
resolve(path) {
|
|
78
98
|
var _a, _b;
|
|
79
99
|
const [field, ...rest] = Array.isArray(path) ? path : [path];
|
|
80
100
|
const rule = this.rules[field];
|
|
81
|
-
const values = this.
|
|
101
|
+
const values = this._layers.map((layer) => layer.data[field]).filter(isDefined);
|
|
82
102
|
let value = (_a = rule.apply(values)) !== null && _a !== void 0 ? _a : (_b = rule.empty) === null || _b === void 0 ? void 0 : _b.call(rule);
|
|
83
103
|
for (const segment of rest) {
|
|
84
104
|
if (value === null || typeof value !== "object") {
|
package/lib/makes/Project.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProjectConfig } from "./ProjectConfig";
|
|
2
2
|
import { LayerResolver } from "./LayerResolver";
|
|
3
|
-
import { EnvConfig,
|
|
3
|
+
import { EnvConfig, ProjectLayerType, ProjectRef, ProjectType, PresetMode } from "../types";
|
|
4
4
|
export declare class Project {
|
|
5
5
|
name: string;
|
|
6
6
|
path: string;
|
|
@@ -69,6 +69,8 @@ export declare class Project {
|
|
|
69
69
|
setSecret(key: string, value: string): Promise<void>;
|
|
70
70
|
getSecrets(): Promise<string[]>;
|
|
71
71
|
unsetSecret(key: string): Promise<void>;
|
|
72
|
-
layer(key:
|
|
72
|
+
layer(key: ProjectLayerType): ProjectConfig;
|
|
73
|
+
layers(): Map<ProjectLayerType, ProjectConfig>;
|
|
74
|
+
origin(path: keyof ProjectConfig.Resolvable | string[]): ProjectLayerType | undefined;
|
|
73
75
|
save(): void;
|
|
74
76
|
}
|
package/lib/makes/Project.js
CHANGED
|
@@ -16,19 +16,19 @@ class Project {
|
|
|
16
16
|
this._ref = appService.getProject(this.name);
|
|
17
17
|
this.resolver = new LayerResolver_1.LayerResolver(ProjectConfig_1.ProjectConfig.rules, [
|
|
18
18
|
{
|
|
19
|
-
name: types_1.
|
|
19
|
+
name: types_1.ProjectLayerType.DATA,
|
|
20
20
|
priority: 10,
|
|
21
|
-
data: projectRepository.getConfig(types_1.
|
|
21
|
+
data: projectRepository.getConfig(types_1.ProjectLayerType.DATA, this.name, this.path)
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
|
-
name: types_1.
|
|
24
|
+
name: types_1.ProjectLayerType.REPOSITORY,
|
|
25
25
|
priority: 50,
|
|
26
|
-
data: projectRepository.getConfig(types_1.
|
|
26
|
+
data: projectRepository.getConfig(types_1.ProjectLayerType.REPOSITORY, this.name, this.path)
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
|
-
name: types_1.
|
|
29
|
+
name: types_1.ProjectLayerType.GLOBAL,
|
|
30
30
|
priority: 100,
|
|
31
|
-
data: projectRepository.getConfig(types_1.
|
|
31
|
+
data: projectRepository.getConfig(types_1.ProjectLayerType.GLOBAL, this.name, this.path)
|
|
32
32
|
}
|
|
33
33
|
]);
|
|
34
34
|
}
|
|
@@ -39,7 +39,7 @@ class Project {
|
|
|
39
39
|
return this.resolver.resolve("type");
|
|
40
40
|
}
|
|
41
41
|
set type(type) {
|
|
42
|
-
this.layer(types_1.
|
|
42
|
+
this.layer(types_1.ProjectLayerType.DATA).type = type;
|
|
43
43
|
}
|
|
44
44
|
get containerName() {
|
|
45
45
|
return `${this.name}.workspace`;
|
|
@@ -51,23 +51,23 @@ class Project {
|
|
|
51
51
|
return this.resolver.resolve("preset");
|
|
52
52
|
}
|
|
53
53
|
set preset(preset) {
|
|
54
|
-
this.layer(types_1.
|
|
54
|
+
this.layer(types_1.ProjectLayerType.DATA).preset = preset;
|
|
55
55
|
}
|
|
56
56
|
get presetMode() {
|
|
57
57
|
return this.resolver.resolve("presetMode");
|
|
58
58
|
}
|
|
59
59
|
set presetMode(mode) {
|
|
60
|
-
this.layer(types_1.
|
|
60
|
+
this.layer(types_1.ProjectLayerType.DATA).presetMode = mode;
|
|
61
61
|
}
|
|
62
62
|
get image() {
|
|
63
63
|
return this.resolver.resolve("image");
|
|
64
64
|
}
|
|
65
65
|
set image(image) {
|
|
66
66
|
if (!image) {
|
|
67
|
-
delete this.layer(types_1.
|
|
67
|
+
delete this.layer(types_1.ProjectLayerType.DATA).image;
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
this.layer(types_1.
|
|
70
|
+
this.layer(types_1.ProjectLayerType.DATA).image = image;
|
|
71
71
|
}
|
|
72
72
|
/** @deprecated */
|
|
73
73
|
get imageName() {
|
|
@@ -81,13 +81,13 @@ class Project {
|
|
|
81
81
|
return this.resolver.resolve("dockerfile");
|
|
82
82
|
}
|
|
83
83
|
set dockerfile(dockerfile) {
|
|
84
|
-
this.layer(types_1.
|
|
84
|
+
this.layer(types_1.ProjectLayerType.DATA).dockerfile = dockerfile;
|
|
85
85
|
}
|
|
86
86
|
get composefile() {
|
|
87
87
|
return this.resolver.resolve("composefile");
|
|
88
88
|
}
|
|
89
89
|
set composefile(composefile) {
|
|
90
|
-
this.layer(types_1.
|
|
90
|
+
this.layer(types_1.ProjectLayerType.DATA).composefile = composefile;
|
|
91
91
|
}
|
|
92
92
|
get cmd() {
|
|
93
93
|
return this.resolver.resolve("cmd");
|
|
@@ -130,18 +130,18 @@ class Project {
|
|
|
130
130
|
return this.resolver.resolve("ports");
|
|
131
131
|
}
|
|
132
132
|
set ports(ports) {
|
|
133
|
-
this.layer(types_1.
|
|
133
|
+
this.layer(types_1.ProjectLayerType.DATA).ports = ports;
|
|
134
134
|
}
|
|
135
135
|
linkPort(hostPort, containerPort) {
|
|
136
|
-
this.layer(types_1.
|
|
137
|
-
...(this.layer(types_1.
|
|
136
|
+
this.layer(types_1.ProjectLayerType.DATA).ports = [
|
|
137
|
+
...(this.layer(types_1.ProjectLayerType.DATA).ports || []).filter((link) => {
|
|
138
138
|
return link !== `${hostPort}:${containerPort}`;
|
|
139
139
|
}),
|
|
140
140
|
`${hostPort}:${containerPort}`
|
|
141
141
|
];
|
|
142
142
|
}
|
|
143
143
|
unlinkPort(hostPort, containerPort) {
|
|
144
|
-
this.layer(types_1.
|
|
144
|
+
this.layer(types_1.ProjectLayerType.DATA).ports = (this.layer(types_1.ProjectLayerType.DATA).ports || []).filter((link) => {
|
|
145
145
|
return link !== `${hostPort}:${containerPort}`;
|
|
146
146
|
});
|
|
147
147
|
}
|
|
@@ -149,19 +149,19 @@ class Project {
|
|
|
149
149
|
return this.resolver.resolve("buildArgs");
|
|
150
150
|
}
|
|
151
151
|
set buildArgs(buildArgs) {
|
|
152
|
-
this.layer(types_1.
|
|
152
|
+
this.layer(types_1.ProjectLayerType.DATA).buildArgs = buildArgs;
|
|
153
153
|
}
|
|
154
154
|
setBuildArg(key, value, service) {
|
|
155
|
-
this.layer(types_1.
|
|
155
|
+
this.layer(types_1.ProjectLayerType.DATA).setBuildArg(key, value, service);
|
|
156
156
|
}
|
|
157
157
|
unsetBuildArg(name, service) {
|
|
158
|
-
this.layer(types_1.
|
|
158
|
+
this.layer(types_1.ProjectLayerType.DATA).unsetBuildArg(name, service);
|
|
159
159
|
}
|
|
160
160
|
get env() {
|
|
161
161
|
return this.resolver.resolve("env");
|
|
162
162
|
}
|
|
163
163
|
set env(env) {
|
|
164
|
-
this.layer(types_1.
|
|
164
|
+
this.layer(types_1.ProjectLayerType.DATA).env = env;
|
|
165
165
|
}
|
|
166
166
|
hasEnv(name) {
|
|
167
167
|
return name in this.env;
|
|
@@ -171,10 +171,10 @@ class Project {
|
|
|
171
171
|
return (_a = this.resolver.resolve(["env", key])) !== null && _a !== void 0 ? _a : byDefault;
|
|
172
172
|
}
|
|
173
173
|
setEnv(key, value, service) {
|
|
174
|
-
this.layer(types_1.
|
|
174
|
+
this.layer(types_1.ProjectLayerType.DATA).setEnv(key, value, service);
|
|
175
175
|
}
|
|
176
176
|
unsetEnv(key, service) {
|
|
177
|
-
this.layer(types_1.
|
|
177
|
+
this.layer(types_1.ProjectLayerType.DATA).unsetEnv(key, service);
|
|
178
178
|
}
|
|
179
179
|
hasMeta(key) {
|
|
180
180
|
return key in this.metadata;
|
|
@@ -184,13 +184,13 @@ class Project {
|
|
|
184
184
|
return (_a = this.resolver.resolve(["metadata", key])) !== null && _a !== void 0 ? _a : byDefault;
|
|
185
185
|
}
|
|
186
186
|
setMeta(name, value) {
|
|
187
|
-
this.layer(types_1.
|
|
187
|
+
this.layer(types_1.ProjectLayerType.DATA).metadata[name] = typeof value === "boolean"
|
|
188
188
|
? (value ? "true" : "false")
|
|
189
189
|
: value;
|
|
190
190
|
}
|
|
191
191
|
unsetMeta(name) {
|
|
192
|
-
if (name in this.layer(types_1.
|
|
193
|
-
delete this.layer(types_1.
|
|
192
|
+
if (name in this.layer(types_1.ProjectLayerType.DATA).metadata) {
|
|
193
|
+
delete this.layer(types_1.ProjectLayerType.DATA).metadata[name];
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
getVolumeBySource(source) {
|
|
@@ -204,20 +204,20 @@ class Project {
|
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
volumeMount(...volumes) {
|
|
207
|
-
this.layer(types_1.
|
|
207
|
+
this.layer(types_1.ProjectLayerType.DATA).volumeMount(...volumes);
|
|
208
208
|
}
|
|
209
209
|
volumeUnmount(...volumes) {
|
|
210
|
-
this.layer(types_1.
|
|
210
|
+
this.layer(types_1.ProjectLayerType.DATA).volumeUnmount(...volumes);
|
|
211
211
|
}
|
|
212
212
|
get extraHosts() {
|
|
213
213
|
return this.resolver.resolve("extraHosts");
|
|
214
214
|
}
|
|
215
215
|
;
|
|
216
216
|
addExtraHost(host, domain) {
|
|
217
|
-
this.layer(types_1.
|
|
217
|
+
this.layer(types_1.ProjectLayerType.DATA).addExtraHost(host, domain);
|
|
218
218
|
}
|
|
219
219
|
removeExtraHost(host) {
|
|
220
|
-
this.layer(types_1.
|
|
220
|
+
this.layer(types_1.ProjectLayerType.DATA).removeExtraHost(host);
|
|
221
221
|
}
|
|
222
222
|
get metadata() {
|
|
223
223
|
return this.resolver.resolve("metadata");
|
|
@@ -250,6 +250,15 @@ class Project {
|
|
|
250
250
|
}
|
|
251
251
|
return layer.data;
|
|
252
252
|
}
|
|
253
|
+
layers() {
|
|
254
|
+
return this.resolver.layers.reduce((res, layer) => {
|
|
255
|
+
res.set(layer.name, layer.data);
|
|
256
|
+
return res;
|
|
257
|
+
}, new Map());
|
|
258
|
+
}
|
|
259
|
+
origin(path) {
|
|
260
|
+
return this.resolver.origin(path);
|
|
261
|
+
}
|
|
253
262
|
save() {
|
|
254
263
|
const container = AsyncStorage_1.AsyncStorage.getContainer(), projectRepository = container.get(ProjectRepository_1.ProjectRepository);
|
|
255
264
|
projectRepository.save(this);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { JsonEditor } from "./JsonEditor";
|
|
2
|
-
import { ServiceConfig } from "./ServiceConfig";
|
|
3
2
|
import { Rules } from "./LayerResolver";
|
|
4
3
|
import { EnvConfig, ProjectType, PresetMode } from "../types";
|
|
5
4
|
export declare class ProjectConfig extends JsonEditor<ProjectConfig.Data> {
|
|
6
5
|
constructor(content: string);
|
|
6
|
+
protected migrateImageName(): void;
|
|
7
7
|
get type(): ProjectType | undefined;
|
|
8
8
|
set type(type: ProjectType | undefined);
|
|
9
9
|
get image(): string | undefined;
|
|
@@ -24,9 +24,9 @@ export declare class ProjectConfig extends JsonEditor<ProjectConfig.Data> {
|
|
|
24
24
|
set metadata(metadata: EnvConfig);
|
|
25
25
|
get cmd(): string[] | undefined;
|
|
26
26
|
set cmd(cmd: string[] | undefined);
|
|
27
|
-
get scripts():
|
|
28
|
-
set scripts(scripts:
|
|
29
|
-
get services():
|
|
27
|
+
get scripts(): Record<string, string> | undefined;
|
|
28
|
+
set scripts(scripts: Record<string, string> | undefined);
|
|
29
|
+
get services(): Record<string, ProjectConfig.Service>;
|
|
30
30
|
get extraHosts(): any;
|
|
31
31
|
set extraHosts(extraHosts: any);
|
|
32
32
|
get volumes(): string[];
|
|
@@ -46,11 +46,9 @@ export declare class ProjectConfig extends JsonEditor<ProjectConfig.Data> {
|
|
|
46
46
|
volumeUnmount(...volumes: string[]): void;
|
|
47
47
|
addExtraHost(host: string, domain: string): void;
|
|
48
48
|
removeExtraHost(host: string): void;
|
|
49
|
-
addService(name: string, data: ServiceConfig.Data): void;
|
|
50
|
-
service(name: string): any;
|
|
51
49
|
}
|
|
52
50
|
export declare namespace ProjectConfig {
|
|
53
|
-
|
|
51
|
+
type Data = {
|
|
54
52
|
type?: ProjectType;
|
|
55
53
|
image?: string;
|
|
56
54
|
/** @deprecated */
|
|
@@ -71,22 +69,15 @@ export declare namespace ProjectConfig {
|
|
|
71
69
|
extraHosts?: EnvConfig;
|
|
72
70
|
services?: Record<string, ProjectConfig.Service>;
|
|
73
71
|
};
|
|
74
|
-
type
|
|
75
|
-
type
|
|
76
|
-
name: string;
|
|
77
|
-
config?: Record<string, string>;
|
|
78
|
-
};
|
|
79
|
-
type ComposeService = {
|
|
80
|
-
type: "compose";
|
|
72
|
+
type Service = {
|
|
73
|
+
type?: "compose" | "plugin";
|
|
81
74
|
containerName?: string;
|
|
82
75
|
buildArgs?: EnvConfig;
|
|
83
76
|
env?: EnvConfig;
|
|
84
77
|
ports?: string[];
|
|
85
78
|
volumes?: string[];
|
|
86
79
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
export const rules: Rules<Resolvable>;
|
|
91
|
-
export {};
|
|
80
|
+
type Resolvable = Omit<Data, "imageName">;
|
|
81
|
+
const serviceRules: Rules<Service>;
|
|
82
|
+
const rules: Rules<Resolvable>;
|
|
92
83
|
}
|
|
@@ -31,6 +31,17 @@ class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
|
31
31
|
"VIRTUAL_PORT"
|
|
32
32
|
]
|
|
33
33
|
});
|
|
34
|
+
this.migrateImageName();
|
|
35
|
+
}
|
|
36
|
+
migrateImageName() {
|
|
37
|
+
const imageName = this.get(["imageName"]);
|
|
38
|
+
if (imageName === undefined) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (this.get(["image"]) === undefined) {
|
|
42
|
+
this.set(["image"], imageName);
|
|
43
|
+
}
|
|
44
|
+
this.unset(["imageName"]);
|
|
34
45
|
}
|
|
35
46
|
get type() {
|
|
36
47
|
return this.state.type;
|
|
@@ -104,10 +115,12 @@ class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
|
104
115
|
});
|
|
105
116
|
}
|
|
106
117
|
set scripts(scripts) {
|
|
107
|
-
this.
|
|
118
|
+
this.set(["scripts"], scripts);
|
|
108
119
|
}
|
|
109
120
|
get services() {
|
|
110
|
-
return {
|
|
121
|
+
return this.createProxy(["services"], {
|
|
122
|
+
removeOnEmpty: true
|
|
123
|
+
});
|
|
111
124
|
}
|
|
112
125
|
get extraHosts() {
|
|
113
126
|
return this.createProxy(["extraHosts"], {
|
|
@@ -233,21 +246,11 @@ class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
|
233
246
|
delete this.state.extraHosts[host];
|
|
234
247
|
}
|
|
235
248
|
}
|
|
236
|
-
addService(name, data) {
|
|
237
|
-
//
|
|
238
|
-
}
|
|
239
|
-
service(name) {
|
|
240
|
-
return this.createProxy(["services", name], {
|
|
241
|
-
removeOnEmpty: true
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
249
|
}
|
|
245
250
|
exports.ProjectConfig = ProjectConfig;
|
|
246
251
|
(function (ProjectConfig) {
|
|
247
252
|
ProjectConfig.serviceRules = {
|
|
248
253
|
type: (0, LayerResolver_1.first)(),
|
|
249
|
-
name: (0, LayerResolver_1.first)(),
|
|
250
|
-
config: (0, LayerResolver_1.merge)(),
|
|
251
254
|
containerName: (0, LayerResolver_1.first)(),
|
|
252
255
|
buildArgs: (0, LayerResolver_1.merge)(),
|
|
253
256
|
env: (0, LayerResolver_1.merge)(),
|
|
@@ -2,13 +2,13 @@ import { Project } from "../makes/Project";
|
|
|
2
2
|
import { ProjectConfig } from "../makes/ProjectConfig";
|
|
3
3
|
import { AppService } from "./AppService";
|
|
4
4
|
import { AppFileSystemService } from "./AppFileSystemService";
|
|
5
|
-
import { FileSystemDriver,
|
|
5
|
+
import { FileSystemDriver, ProjectLayerType } from "../types";
|
|
6
6
|
export declare class ProjectRepository {
|
|
7
7
|
protected readonly appService: AppService;
|
|
8
8
|
protected readonly fs: AppFileSystemService;
|
|
9
9
|
protected readonly driver: FileSystemDriver;
|
|
10
10
|
constructor(appService: AppService, fs: AppFileSystemService, driver: FileSystemDriver);
|
|
11
|
-
getConfig(scope:
|
|
11
|
+
getConfig(scope: ProjectLayerType, name: string, path?: string): ProjectConfig;
|
|
12
12
|
getByName(name: string): Project;
|
|
13
13
|
save(project: Project): void;
|
|
14
14
|
search(params: ProjectRepository.SearchParams): Project[];
|
|
@@ -31,7 +31,7 @@ let ProjectRepository = class ProjectRepository {
|
|
|
31
31
|
getConfig(scope, name, path) {
|
|
32
32
|
const ref = this.appService.getProject(name);
|
|
33
33
|
switch (scope) {
|
|
34
|
-
case types_1.
|
|
34
|
+
case types_1.ProjectLayerType.DATA: {
|
|
35
35
|
if (!ref) {
|
|
36
36
|
return new ProjectConfig_1.ProjectConfig("{}");
|
|
37
37
|
}
|
|
@@ -41,7 +41,7 @@ let ProjectRepository = class ProjectRepository {
|
|
|
41
41
|
}
|
|
42
42
|
return new ProjectConfig_1.ProjectConfig(fs.readFile("config.json").toString());
|
|
43
43
|
}
|
|
44
|
-
case types_1.
|
|
44
|
+
case types_1.ProjectLayerType.REPOSITORY:
|
|
45
45
|
path = path || (ref === null || ref === void 0 ? void 0 : ref.path);
|
|
46
46
|
if (!path) {
|
|
47
47
|
return new ProjectConfig_1.ProjectConfig("{}");
|
|
@@ -51,7 +51,7 @@ let ProjectRepository = class ProjectRepository {
|
|
|
51
51
|
return new ProjectConfig_1.ProjectConfig("{}");
|
|
52
52
|
}
|
|
53
53
|
return new ProjectConfig_1.ProjectConfig(fs.readFile("wocker.config.json").toString());
|
|
54
|
-
case types_1.
|
|
54
|
+
case types_1.ProjectLayerType.GLOBAL:
|
|
55
55
|
return new ProjectConfig_1.ProjectConfig(JSON.stringify({
|
|
56
56
|
env: this.appService.config.env
|
|
57
57
|
}));
|
|
@@ -71,7 +71,7 @@ let ProjectRepository = class ProjectRepository {
|
|
|
71
71
|
if (!this.fs.exists(`projects/${project.name}`)) {
|
|
72
72
|
this.fs.mkdir(`projects/${project.name}`);
|
|
73
73
|
}
|
|
74
|
-
const appLayer = project.layer(types_1.
|
|
74
|
+
const appLayer = project.layer(types_1.ProjectLayerType.DATA), projectLayer = project.layer(types_1.ProjectLayerType.REPOSITORY);
|
|
75
75
|
if (appLayer.isDirty()) {
|
|
76
76
|
this.fs.writeFile(`projects/${project.name}/config.json`, appLayer.toString());
|
|
77
77
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ProjectRef } from "../types";
|
|
2
|
+
export declare enum ProjectLayerTypeEnum {
|
|
3
|
+
DATA = "app",
|
|
4
|
+
REPOSITORY = "project",
|
|
5
|
+
GLOBAL = "global"
|
|
6
|
+
}
|
|
7
|
+
export type ProjectLayerType = ProjectLayerTypeEnum;
|
|
8
|
+
export declare const ProjectLayerType: typeof ProjectLayerTypeEnum & {
|
|
9
|
+
label(type: ProjectLayerTypeEnum): string;
|
|
10
|
+
fileName(type: ProjectLayerTypeEnum, projectRef: ProjectRef): string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProjectLayerType = exports.ProjectLayerTypeEnum = void 0;
|
|
4
|
+
var ProjectLayerTypeEnum;
|
|
5
|
+
(function (ProjectLayerTypeEnum) {
|
|
6
|
+
ProjectLayerTypeEnum["DATA"] = "app";
|
|
7
|
+
ProjectLayerTypeEnum["REPOSITORY"] = "project";
|
|
8
|
+
ProjectLayerTypeEnum["GLOBAL"] = "global";
|
|
9
|
+
})(ProjectLayerTypeEnum || (exports.ProjectLayerTypeEnum = ProjectLayerTypeEnum = {}));
|
|
10
|
+
exports.ProjectLayerType = Object.assign({}, ProjectLayerTypeEnum, {
|
|
11
|
+
label(type) {
|
|
12
|
+
switch (type) {
|
|
13
|
+
case ProjectLayerTypeEnum.DATA:
|
|
14
|
+
return "Data";
|
|
15
|
+
case ProjectLayerTypeEnum.GLOBAL:
|
|
16
|
+
return "Global";
|
|
17
|
+
case ProjectLayerTypeEnum.REPOSITORY:
|
|
18
|
+
return "Repository";
|
|
19
|
+
default:
|
|
20
|
+
return type;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
fileName(type, projectRef) {
|
|
24
|
+
switch (type) {
|
|
25
|
+
case ProjectLayerTypeEnum.DATA:
|
|
26
|
+
return `projects/${projectRef.name}/config.json`;
|
|
27
|
+
case ProjectLayerTypeEnum.REPOSITORY:
|
|
28
|
+
return `wocker.config.json`;
|
|
29
|
+
default:
|
|
30
|
+
throw new Error(`Unknown config layer: ${type}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
package/lib/types/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from "./PackageManagerType";
|
|
|
9
9
|
export * from "./PickProperties";
|
|
10
10
|
export * from "./Permissions";
|
|
11
11
|
export * from "./PluginMetadata";
|
|
12
|
-
export * from "./
|
|
12
|
+
export * from "./ProjectLayerType";
|
|
13
13
|
export * from "./PluginRef";
|
|
14
14
|
export * from "./PresetRef";
|
|
15
15
|
export * from "./PresetMode";
|
package/lib/types/index.js
CHANGED
|
@@ -25,7 +25,7 @@ __exportStar(require("./PackageManagerType"), exports);
|
|
|
25
25
|
__exportStar(require("./PickProperties"), exports);
|
|
26
26
|
__exportStar(require("./Permissions"), exports);
|
|
27
27
|
__exportStar(require("./PluginMetadata"), exports);
|
|
28
|
-
__exportStar(require("./
|
|
28
|
+
__exportStar(require("./ProjectLayerType"), exports);
|
|
29
29
|
__exportStar(require("./PluginRef"), exports);
|
|
30
30
|
__exportStar(require("./PresetRef"), exports);
|
|
31
31
|
__exportStar(require("./PresetMode"), exports);
|
package/package.json
CHANGED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ProjectRef } from "../types";
|
|
2
|
-
export declare enum ProjectConfigScopeEnum {
|
|
3
|
-
APP = "app",
|
|
4
|
-
LOCAL = "project",
|
|
5
|
-
GLOBAL = "global"
|
|
6
|
-
}
|
|
7
|
-
export type ProjectConfigScope = ProjectConfigScopeEnum;
|
|
8
|
-
export declare const ProjectConfigScope: typeof ProjectConfigScopeEnum & {
|
|
9
|
-
fileName(scope: ProjectConfigScopeEnum, projectRef: ProjectRef): string;
|
|
10
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProjectConfigScope = exports.ProjectConfigScopeEnum = void 0;
|
|
4
|
-
var ProjectConfigScopeEnum;
|
|
5
|
-
(function (ProjectConfigScopeEnum) {
|
|
6
|
-
ProjectConfigScopeEnum["APP"] = "app";
|
|
7
|
-
ProjectConfigScopeEnum["LOCAL"] = "project";
|
|
8
|
-
ProjectConfigScopeEnum["GLOBAL"] = "global";
|
|
9
|
-
})(ProjectConfigScopeEnum || (exports.ProjectConfigScopeEnum = ProjectConfigScopeEnum = {}));
|
|
10
|
-
exports.ProjectConfigScope = Object.assign({}, ProjectConfigScopeEnum, {
|
|
11
|
-
fileName(scope, projectRef) {
|
|
12
|
-
switch (scope) {
|
|
13
|
-
case ProjectConfigScopeEnum.APP:
|
|
14
|
-
return `projects/${projectRef.name}/config.json`;
|
|
15
|
-
case ProjectConfigScopeEnum.LOCAL:
|
|
16
|
-
return `wocker.config.json`;
|
|
17
|
-
default:
|
|
18
|
-
throw new Error(`Unknown config scope: ${scope}`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
});
|