@wocker/ws 1.1.1 → 1.1.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/modules/preset/controllers/PresetController.js +1 -1
- package/lib/modules/preset/repositories/PresetRepository.js +4 -4
- package/lib/modules/preset/services/PresetService.js +4 -4
- package/lib/modules/project/controllers/MetadataController.d.ts +5 -3
- package/lib/modules/project/controllers/MetadataController.js +34 -10
- package/lib/modules/project/controllers/ProjectController.d.ts +1 -1
- package/lib/modules/project/controllers/ProjectController.js +5 -3
- package/lib/modules/project/services/ProjectService.d.ts +1 -1
- package/lib/modules/project/services/ProjectService.js +10 -3
- package/package.json +2 -2
|
@@ -45,7 +45,7 @@ let PresetController = class PresetController {
|
|
|
45
45
|
table.push([
|
|
46
46
|
preset.name,
|
|
47
47
|
preset.source,
|
|
48
|
-
preset.source === core_1.
|
|
48
|
+
preset.source === core_1.PresetSource.EXTERNAL ? preset.path : ""
|
|
49
49
|
]);
|
|
50
50
|
}
|
|
51
51
|
return table.toString();
|
|
@@ -35,7 +35,7 @@ let PresetRepository = class PresetRepository {
|
|
|
35
35
|
}
|
|
36
36
|
save() {
|
|
37
37
|
switch (this.source) {
|
|
38
|
-
case core_1.
|
|
38
|
+
case core_1.PresetSource.EXTERNAL:
|
|
39
39
|
fs.writeJSON("config.json", this.toObject());
|
|
40
40
|
break;
|
|
41
41
|
}
|
|
@@ -43,7 +43,7 @@ let PresetRepository = class PresetRepository {
|
|
|
43
43
|
}
|
|
44
44
|
delete() {
|
|
45
45
|
switch (this.source) {
|
|
46
|
-
case core_1.
|
|
46
|
+
case core_1.PresetSource.GITHUB:
|
|
47
47
|
if (fs.exists()) {
|
|
48
48
|
fs.rm("", {
|
|
49
49
|
recursive: true
|
|
@@ -62,12 +62,12 @@ let PresetRepository = class PresetRepository {
|
|
|
62
62
|
...dirs.map((name) => {
|
|
63
63
|
return {
|
|
64
64
|
name,
|
|
65
|
-
source: core_1.
|
|
65
|
+
source: core_1.PresetSource.INTERNAL,
|
|
66
66
|
path: fs.path(name)
|
|
67
67
|
};
|
|
68
68
|
}),
|
|
69
69
|
...presets.map((item) => {
|
|
70
|
-
if (item.source === core_1.
|
|
70
|
+
if (item.source === core_1.PresetSource.GITHUB) {
|
|
71
71
|
return {
|
|
72
72
|
...item,
|
|
73
73
|
path: this.appService.fs.path("presets", item.name)
|
|
@@ -145,7 +145,7 @@ let PresetService = class PresetService {
|
|
|
145
145
|
}
|
|
146
146
|
if (fs.exists("config.json")) {
|
|
147
147
|
const config = fs.readJSON("config.json");
|
|
148
|
-
this.appService.registerPreset(config.name, core_1.
|
|
148
|
+
this.appService.registerPreset(config.name, core_1.PresetSource.EXTERNAL, fs.path());
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
let config = {};
|
|
@@ -214,7 +214,7 @@ let PresetService = class PresetService {
|
|
|
214
214
|
return;
|
|
215
215
|
}
|
|
216
216
|
fs.writeJSON("config.json", config);
|
|
217
|
-
this.appService.registerPreset(config.name, core_1.
|
|
217
|
+
this.appService.registerPreset(config.name, core_1.PresetSource.EXTERNAL, fs.path());
|
|
218
218
|
}
|
|
219
219
|
async deinit() {
|
|
220
220
|
const preset = this.presetRepository.searchOne({
|
|
@@ -272,7 +272,7 @@ let PresetService = class PresetService {
|
|
|
272
272
|
let preset = this.presetRepository.searchOne({
|
|
273
273
|
name: config.name
|
|
274
274
|
});
|
|
275
|
-
if (preset && satisfyingTag && preset.source === core_1.
|
|
275
|
+
if (preset && satisfyingTag && preset.source === core_1.PresetSource.GITHUB && core_1.Version.parse(ref).compare(preset.version) === 0) {
|
|
276
276
|
console.info("Preset already installed");
|
|
277
277
|
return;
|
|
278
278
|
}
|
|
@@ -288,7 +288,7 @@ let PresetService = class PresetService {
|
|
|
288
288
|
});
|
|
289
289
|
}
|
|
290
290
|
this.fs.mv(`presets/.tmp/${config.name}`, `presets/${config.name}`);
|
|
291
|
-
this.appService.registerPreset(config.name, core_1.
|
|
291
|
+
this.appService.registerPreset(config.name, core_1.PresetSource.GITHUB);
|
|
292
292
|
console.info("Preset installed successfully");
|
|
293
293
|
}
|
|
294
294
|
finally {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { AppService } from "@wocker/core";
|
|
1
2
|
import { ProjectService } from "../services/ProjectService";
|
|
2
3
|
export declare class MetadataController {
|
|
4
|
+
protected readonly appService: AppService;
|
|
3
5
|
protected readonly projectService: ProjectService;
|
|
4
|
-
constructor(projectService: ProjectService);
|
|
5
|
-
list(projectName?: string): string;
|
|
6
|
-
set(meta: string[], projectName?: string): void;
|
|
6
|
+
constructor(appService: AppService, projectService: ProjectService);
|
|
7
|
+
list(projectName?: string, global?: boolean): string;
|
|
8
|
+
set(meta: string[], projectName?: string, global?: boolean): void;
|
|
7
9
|
unset(meta: string[], projectName?: string): void;
|
|
8
10
|
}
|
|
@@ -20,10 +20,18 @@ const core_1 = require("@wocker/core");
|
|
|
20
20
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
21
21
|
const ProjectService_1 = require("../services/ProjectService");
|
|
22
22
|
let MetadataController = class MetadataController {
|
|
23
|
-
constructor(projectService) {
|
|
23
|
+
constructor(appService, projectService) {
|
|
24
|
+
this.appService = appService;
|
|
24
25
|
this.projectService = projectService;
|
|
25
26
|
}
|
|
26
|
-
list(projectName) {
|
|
27
|
+
list(projectName, global) {
|
|
28
|
+
if (global) {
|
|
29
|
+
const table = new cli_table3_1.default();
|
|
30
|
+
for (const key in this.appService.config.meta) {
|
|
31
|
+
table.push([key, this.appService.config.meta[key]]);
|
|
32
|
+
}
|
|
33
|
+
return table.toString();
|
|
34
|
+
}
|
|
27
35
|
const project = this.projectService.get(projectName);
|
|
28
36
|
const table = new cli_table3_1.default();
|
|
29
37
|
for (const key in project.metadata) {
|
|
@@ -31,16 +39,29 @@ let MetadataController = class MetadataController {
|
|
|
31
39
|
}
|
|
32
40
|
return table.toString();
|
|
33
41
|
}
|
|
34
|
-
set(meta, projectName) {
|
|
35
|
-
const
|
|
36
|
-
for (const field of meta) {
|
|
42
|
+
set(meta, projectName, global) {
|
|
43
|
+
const fields = meta.reduce((res, field) => {
|
|
37
44
|
let [, key = "", value = ""] = field.split(/^([^=]+)=(.*)$/);
|
|
38
45
|
key = key.trim();
|
|
39
46
|
value = value.trim();
|
|
40
47
|
if (!key) {
|
|
41
|
-
|
|
48
|
+
return res;
|
|
42
49
|
}
|
|
43
|
-
|
|
50
|
+
return {
|
|
51
|
+
...res,
|
|
52
|
+
[key]: value
|
|
53
|
+
};
|
|
54
|
+
}, {});
|
|
55
|
+
if (global) {
|
|
56
|
+
for (const key in fields) {
|
|
57
|
+
this.appService.config.setMeta(key, fields[key]);
|
|
58
|
+
}
|
|
59
|
+
this.appService.save();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const project = this.projectService.get(projectName);
|
|
63
|
+
for (const key in fields) {
|
|
64
|
+
project.setMeta(key, fields[key]);
|
|
44
65
|
}
|
|
45
66
|
project.save();
|
|
46
67
|
}
|
|
@@ -60,8 +81,9 @@ __decorate([
|
|
|
60
81
|
(0, core_1.Description)("List of metafields"),
|
|
61
82
|
__param(0, (0, core_1.Option)("name", "n")),
|
|
62
83
|
__param(0, (0, core_1.Description)("The name of the project")),
|
|
84
|
+
__param(1, (0, core_1.Option)("global", "g")),
|
|
63
85
|
__metadata("design:type", Function),
|
|
64
|
-
__metadata("design:paramtypes", [String]),
|
|
86
|
+
__metadata("design:paramtypes", [String, Boolean]),
|
|
65
87
|
__metadata("design:returntype", void 0)
|
|
66
88
|
], MetadataController.prototype, "list", null);
|
|
67
89
|
__decorate([
|
|
@@ -69,8 +91,9 @@ __decorate([
|
|
|
69
91
|
__param(0, (0, core_1.Param)("meta")),
|
|
70
92
|
__param(1, (0, core_1.Option)("name", "n")),
|
|
71
93
|
__param(1, (0, core_1.Description)("The name of the project")),
|
|
94
|
+
__param(2, (0, core_1.Option)("global", "g")),
|
|
72
95
|
__metadata("design:type", Function),
|
|
73
|
-
__metadata("design:paramtypes", [Array, String]),
|
|
96
|
+
__metadata("design:paramtypes", [Array, String, Boolean]),
|
|
74
97
|
__metadata("design:returntype", void 0)
|
|
75
98
|
], MetadataController.prototype, "set", null);
|
|
76
99
|
__decorate([
|
|
@@ -85,5 +108,6 @@ __decorate([
|
|
|
85
108
|
exports.MetadataController = MetadataController = __decorate([
|
|
86
109
|
(0, core_1.Controller)(),
|
|
87
110
|
(0, core_1.Description)("Metadata commands"),
|
|
88
|
-
__metadata("design:paramtypes", [
|
|
111
|
+
__metadata("design:paramtypes", [core_1.AppService,
|
|
112
|
+
ProjectService_1.ProjectService])
|
|
89
113
|
], MetadataController);
|
|
@@ -16,7 +16,7 @@ export declare class ProjectController {
|
|
|
16
16
|
getScriptNames(): Promise<string[]>;
|
|
17
17
|
init(name: string, type: ProjectType): Promise<void>;
|
|
18
18
|
destroy(name?: string, yes?: boolean): Promise<void>;
|
|
19
|
-
start(name?: string, restart?: boolean, build?: boolean, attach?: boolean): Promise<void>;
|
|
19
|
+
start(name?: string, restart?: boolean, build?: boolean, attach?: boolean, detach?: boolean): Promise<void>;
|
|
20
20
|
stop(name?: string): Promise<void>;
|
|
21
21
|
projectList(all: boolean): Promise<string>;
|
|
22
22
|
buildArgsList(name?: string, service?: string): Promise<string>;
|
|
@@ -168,9 +168,9 @@ let ProjectController = class ProjectController {
|
|
|
168
168
|
recursive: true
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
|
-
async start(name, restart, build, attach) {
|
|
171
|
+
async start(name, restart, build, attach, detach) {
|
|
172
172
|
const project = this.projectService.get(name);
|
|
173
|
-
await this.projectService.start(project, restart, build, attach);
|
|
173
|
+
await this.projectService.start(project, restart, build, attach, detach);
|
|
174
174
|
}
|
|
175
175
|
async stop(name) {
|
|
176
176
|
const project = this.projectService.get(name);
|
|
@@ -657,8 +657,10 @@ __decorate([
|
|
|
657
657
|
__param(2, (0, core_1.Description)("Build")),
|
|
658
658
|
__param(3, (0, core_1.Option)("attach", "a")),
|
|
659
659
|
__param(3, (0, core_1.Description)("Attach")),
|
|
660
|
+
__param(4, (0, core_1.Option)("detach", "d")),
|
|
661
|
+
__param(4, (0, core_1.Description)("Detach")),
|
|
660
662
|
__metadata("design:type", Function),
|
|
661
|
-
__metadata("design:paramtypes", [String, Boolean, Boolean, Boolean]),
|
|
663
|
+
__metadata("design:paramtypes", [String, Boolean, Boolean, Boolean, Boolean]),
|
|
662
664
|
__metadata("design:returntype", Promise)
|
|
663
665
|
], ProjectController.prototype, "start", null);
|
|
664
666
|
__decorate([
|
|
@@ -16,7 +16,7 @@ export declare class ProjectService extends CoreProjectService {
|
|
|
16
16
|
search(params?: ProjectRepository.SearchParams): Project[];
|
|
17
17
|
searchOne(params?: ProjectRepository.SearchParams): Project | null;
|
|
18
18
|
save(project: Project): void;
|
|
19
|
-
start(project: Project, restart?: boolean, rebuild?: boolean, attach?: boolean): Promise<void>;
|
|
19
|
+
start(project: Project, restart?: boolean, rebuild?: boolean, attach?: boolean, detach?: boolean): Promise<void>;
|
|
20
20
|
stop(project: Project): Promise<void>;
|
|
21
21
|
build(project: Project, rebuild?: boolean): Promise<void>;
|
|
22
22
|
attach(project: Project): Promise<void>;
|
|
@@ -55,7 +55,7 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
55
55
|
save(project) {
|
|
56
56
|
this.projectRepository.save(project);
|
|
57
57
|
}
|
|
58
|
-
async start(project, restart, rebuild, attach) {
|
|
58
|
+
async start(project, restart, rebuild, attach, detach) {
|
|
59
59
|
if (restart || rebuild) {
|
|
60
60
|
await this.stop(project);
|
|
61
61
|
}
|
|
@@ -106,7 +106,14 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
106
106
|
}
|
|
107
107
|
await this.eventService.emit("project:start", project);
|
|
108
108
|
await this.eventService.emit("project:afterStart", project);
|
|
109
|
-
|
|
109
|
+
let shouldAttach = (project.getMeta("start.mode") || this.appService.getMeta("start.mode")) === "attach";
|
|
110
|
+
if (typeof attach === "boolean") {
|
|
111
|
+
shouldAttach = attach;
|
|
112
|
+
}
|
|
113
|
+
if (typeof detach === "boolean") {
|
|
114
|
+
shouldAttach = !detach;
|
|
115
|
+
}
|
|
116
|
+
if (shouldAttach) {
|
|
110
117
|
switch (project.type) {
|
|
111
118
|
case core_1.ProjectType.IMAGE:
|
|
112
119
|
case core_1.ProjectType.DOCKERFILE:
|
|
@@ -251,7 +258,7 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
251
258
|
case core_1.ProjectType.IMAGE:
|
|
252
259
|
case core_1.ProjectType.DOCKERFILE:
|
|
253
260
|
case core_1.ProjectType.PRESET:
|
|
254
|
-
await this.dockerService.exec(project.containerName, command,
|
|
261
|
+
await this.dockerService.exec(project.containerName, command, this.processService.stdout.isTTY ?? false);
|
|
255
262
|
break;
|
|
256
263
|
case core_1.ProjectType.COMPOSE: {
|
|
257
264
|
const [service, ...args] = command;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wocker/ws",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"author": "Kris Papercut <krispcut@gmail.com>",
|
|
6
6
|
"description": "Docker workspace for web projects",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"make-coverage-badge": "make-coverage-badge"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@wocker/core": "1.1.
|
|
38
|
+
"@wocker/core": "1.1.2",
|
|
39
39
|
"@wocker/docker-module": "^1.0.1",
|
|
40
40
|
"@wocker/prompts": "^1.0.0",
|
|
41
41
|
"@wocker/utils": "^2.0.6",
|