@wocker/ws 1.0.32 → 1.1.1
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/AppModule.js +1 -2
- package/lib/main.js +2 -2
- package/lib/makes/GithubClient.d.ts +3 -2
- package/lib/makes/GithubClient.js +27 -27
- package/lib/makes/index.d.ts +0 -3
- package/lib/makes/index.js +0 -3
- package/lib/modules/core/controllers/DebugController.d.ts +3 -4
- package/lib/modules/core/controllers/DebugController.js +5 -22
- package/lib/modules/core/controllers/ExperimentalController.d.ts +3 -3
- package/lib/modules/core/controllers/ExperimentalController.js +1 -1
- package/lib/modules/dns/index.js +3 -3
- package/lib/modules/keystore/controllers/KeystoreController.d.ts +3 -3
- package/lib/modules/keystore/controllers/KeystoreController.js +8 -8
- package/lib/modules/keystore/providers/FileKeystoreProvider.js +8 -8
- package/lib/modules/keystore/services/KeystoreService.d.ts +3 -3
- package/lib/modules/keystore/services/KeystoreService.js +4 -4
- package/lib/modules/package-manager/service/PackageManager.d.ts +3 -3
- package/lib/modules/package-manager/service/PackageManager.js +8 -8
- package/lib/modules/package-manager/service/RegistryService.js +5 -4
- package/lib/modules/plugin/controllers/PluginController.d.ts +3 -3
- package/lib/modules/plugin/controllers/PluginController.js +4 -4
- package/lib/modules/plugin/index.js +4 -5
- package/lib/modules/plugin/services/PluginService.d.ts +3 -3
- package/lib/modules/plugin/services/PluginService.js +11 -13
- package/lib/modules/preset/controllers/PresetController.d.ts +3 -3
- package/lib/modules/preset/controllers/PresetController.js +6 -6
- package/lib/modules/preset/controllers/PresetListener.d.ts +5 -4
- package/lib/modules/preset/controllers/PresetListener.js +19 -55
- package/lib/modules/preset/repositories/PresetRepository.d.ts +3 -3
- package/lib/modules/preset/repositories/PresetRepository.js +7 -7
- package/lib/modules/preset/services/PresetService.d.ts +4 -3
- package/lib/modules/preset/services/PresetService.js +33 -33
- package/lib/modules/project/controllers/MetadataController.d.ts +8 -0
- package/lib/modules/project/controllers/MetadataController.js +89 -0
- package/lib/modules/project/controllers/ProjectController.d.ts +6 -6
- package/lib/modules/project/controllers/ProjectController.js +62 -49
- package/lib/modules/project/controllers/SecretsController.js +2 -2
- package/lib/modules/project/index.d.ts +1 -2
- package/lib/modules/project/index.js +4 -6
- package/lib/modules/project/services/ProjectService.d.ts +3 -4
- package/lib/modules/project/services/ProjectService.js +49 -50
- package/lib/modules/proxy/controllers/HttpAuthController.d.ts +3 -4
- package/lib/modules/proxy/controllers/HttpAuthController.js +28 -16
- package/lib/modules/proxy/controllers/ProxyController.d.ts +3 -3
- package/lib/modules/proxy/controllers/ProxyController.js +11 -11
- package/lib/modules/proxy/services/HttpAuthService.d.ts +3 -0
- package/lib/modules/proxy/services/HttpAuthService.js +29 -10
- package/lib/modules/proxy/services/ProxyService.d.ts +3 -3
- package/lib/modules/proxy/services/ProxyService.js +9 -9
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -1
- package/package.json +6 -14
- package/lib/makes/Http.d.ts +0 -18
- package/lib/makes/Http.js +0 -82
- package/lib/makes/Version.d.ts +0 -22
- package/lib/makes/Version.js +0 -59
- package/lib/makes/VersionRange.d.ts +0 -6
- package/lib/makes/VersionRange.js +0 -18
- package/lib/makes/VersionRule.d.ts +0 -24
- package/lib/makes/VersionRule.js +0 -68
- package/lib/modules/project/repositories/ProjectRepository.d.ts +0 -13
- package/lib/modules/project/repositories/ProjectRepository.js +0 -71
- package/lib/utils/injectVariables.d.ts +0 -5
- package/lib/utils/injectVariables.js +0 -10
|
@@ -14,16 +14,15 @@ const core_1 = require("@wocker/core");
|
|
|
14
14
|
const docker_module_1 = require("@wocker/docker-module");
|
|
15
15
|
const cli_1 = require("@kearisp/cli");
|
|
16
16
|
const preset_1 = require("../../preset");
|
|
17
|
-
const ProjectRepository_1 = require("../repositories/ProjectRepository");
|
|
18
17
|
class PublicCli extends cli_1.Cli {
|
|
19
18
|
parseCommand(command, index) {
|
|
20
19
|
return super.parseCommand(command, index);
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
24
|
-
constructor(
|
|
23
|
+
constructor(appService, processService, eventService, dockerService, composeService, projectRepository, presetService, presetRepository, logService) {
|
|
25
24
|
super();
|
|
26
|
-
this.
|
|
25
|
+
this.appService = appService;
|
|
27
26
|
this.processService = processService;
|
|
28
27
|
this.eventService = eventService;
|
|
29
28
|
this.dockerService = dockerService;
|
|
@@ -63,18 +62,18 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
63
62
|
await this.build(project, rebuild);
|
|
64
63
|
await this.eventService.emit("project:beforeStart", project);
|
|
65
64
|
switch (project.type) {
|
|
66
|
-
case core_1.
|
|
67
|
-
case core_1.
|
|
68
|
-
case core_1.
|
|
65
|
+
case core_1.ProjectType.IMAGE:
|
|
66
|
+
case core_1.ProjectType.DOCKERFILE:
|
|
67
|
+
case core_1.ProjectType.PRESET: {
|
|
69
68
|
let container = await this.dockerService.getContainer(project.containerName);
|
|
70
69
|
const fs = new core_1.FileSystem(project.path);
|
|
71
70
|
if (!container) {
|
|
72
71
|
container = await this.dockerService.createContainer({
|
|
73
72
|
name: project.containerName,
|
|
74
|
-
image: project.
|
|
73
|
+
image: project.image,
|
|
75
74
|
cmd: project.cmd,
|
|
76
75
|
env: {
|
|
77
|
-
...this.
|
|
76
|
+
...this.appService.config.env || {},
|
|
78
77
|
...project.env || {}
|
|
79
78
|
},
|
|
80
79
|
ports: project.ports || [],
|
|
@@ -97,7 +96,7 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
97
96
|
}
|
|
98
97
|
break;
|
|
99
98
|
}
|
|
100
|
-
case core_1.
|
|
99
|
+
case core_1.ProjectType.COMPOSE: {
|
|
101
100
|
await this.composeService.up({
|
|
102
101
|
context: project.path,
|
|
103
102
|
composefile: project.composefile
|
|
@@ -109,12 +108,12 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
109
108
|
await this.eventService.emit("project:afterStart", project);
|
|
110
109
|
if (attach) {
|
|
111
110
|
switch (project.type) {
|
|
112
|
-
case core_1.
|
|
113
|
-
case core_1.
|
|
114
|
-
case core_1.
|
|
111
|
+
case core_1.ProjectType.IMAGE:
|
|
112
|
+
case core_1.ProjectType.DOCKERFILE:
|
|
113
|
+
case core_1.ProjectType.PRESET:
|
|
115
114
|
await this.dockerService.attach(project.containerName);
|
|
116
115
|
break;
|
|
117
|
-
case core_1.
|
|
116
|
+
case core_1.ProjectType.COMPOSE:
|
|
118
117
|
break;
|
|
119
118
|
}
|
|
120
119
|
}
|
|
@@ -122,12 +121,12 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
122
121
|
async stop(project) {
|
|
123
122
|
await this.eventService.emit("project:beforeStop", project);
|
|
124
123
|
switch (project.type) {
|
|
125
|
-
case core_1.
|
|
126
|
-
case core_1.
|
|
127
|
-
case core_1.
|
|
124
|
+
case core_1.ProjectType.IMAGE:
|
|
125
|
+
case core_1.ProjectType.DOCKERFILE:
|
|
126
|
+
case core_1.ProjectType.PRESET:
|
|
128
127
|
await this.dockerService.removeContainer(project.containerName);
|
|
129
128
|
break;
|
|
130
|
-
case core_1.
|
|
129
|
+
case core_1.ProjectType.COMPOSE: {
|
|
131
130
|
await this.composeService.down({
|
|
132
131
|
context: project.path,
|
|
133
132
|
composefile: project.composefile
|
|
@@ -139,19 +138,19 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
139
138
|
}
|
|
140
139
|
async build(project, rebuild) {
|
|
141
140
|
switch (project.type) {
|
|
142
|
-
case core_1.
|
|
143
|
-
await this.dockerService.pullImage(project.
|
|
141
|
+
case core_1.ProjectType.IMAGE:
|
|
142
|
+
await this.dockerService.pullImage(project.image);
|
|
144
143
|
break;
|
|
145
|
-
case core_1.
|
|
146
|
-
project.
|
|
144
|
+
case core_1.ProjectType.DOCKERFILE: {
|
|
145
|
+
project.image = `project-${project.name}:develop`;
|
|
147
146
|
project.save();
|
|
148
147
|
if (rebuild) {
|
|
149
|
-
await this.dockerService.imageRm(project.
|
|
148
|
+
await this.dockerService.imageRm(project.image);
|
|
150
149
|
}
|
|
151
|
-
if (!await this.dockerService.imageExists(project.
|
|
150
|
+
if (!await this.dockerService.imageExists(project.image)) {
|
|
152
151
|
await this.dockerService.buildImage({
|
|
153
|
-
version: this.
|
|
154
|
-
tag: project.
|
|
152
|
+
version: this.appService.isExperimentalEnabled("buildKit") ? "2" : "1",
|
|
153
|
+
tag: project.image,
|
|
155
154
|
buildArgs: project.buildArgs,
|
|
156
155
|
context: project.path,
|
|
157
156
|
dockerfile: project.dockerfile
|
|
@@ -159,25 +158,25 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
159
158
|
}
|
|
160
159
|
break;
|
|
161
160
|
}
|
|
162
|
-
case core_1.
|
|
161
|
+
case core_1.ProjectType.PRESET: {
|
|
163
162
|
const preset = this.presetRepository.searchOne({
|
|
164
163
|
name: project.preset
|
|
165
164
|
});
|
|
166
165
|
if (preset.image) {
|
|
167
166
|
await this.dockerService.pullImage(preset.image);
|
|
168
|
-
project.
|
|
167
|
+
project.image = preset.image;
|
|
169
168
|
project.save();
|
|
170
169
|
}
|
|
171
170
|
if (preset.dockerfile) {
|
|
172
|
-
project.
|
|
171
|
+
project.image = this.presetService.getImageNameForProject(project, preset);
|
|
173
172
|
project.save();
|
|
174
173
|
if (rebuild) {
|
|
175
|
-
await this.dockerService.imageRm(project.
|
|
174
|
+
await this.dockerService.imageRm(project.image);
|
|
176
175
|
}
|
|
177
|
-
if (!await this.dockerService.imageExists(project.
|
|
176
|
+
if (!await this.dockerService.imageExists(project.image)) {
|
|
178
177
|
await this.dockerService.buildImage({
|
|
179
|
-
version: this.
|
|
180
|
-
tag: project.
|
|
178
|
+
version: this.appService.isExperimentalEnabled("buildKit") ? "2" : "1",
|
|
179
|
+
tag: project.image,
|
|
181
180
|
labels: {
|
|
182
181
|
"org.wocker.preset": preset.name
|
|
183
182
|
},
|
|
@@ -191,7 +190,7 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
191
190
|
}
|
|
192
191
|
break;
|
|
193
192
|
}
|
|
194
|
-
case core_1.
|
|
193
|
+
case core_1.ProjectType.COMPOSE: {
|
|
195
194
|
await this.composeService.build({
|
|
196
195
|
context: project.path,
|
|
197
196
|
composefile: project.composefile
|
|
@@ -203,9 +202,9 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
203
202
|
}
|
|
204
203
|
async attach(project) {
|
|
205
204
|
switch (project.type) {
|
|
206
|
-
case core_1.
|
|
207
|
-
case core_1.
|
|
208
|
-
case core_1.
|
|
205
|
+
case core_1.ProjectType.IMAGE:
|
|
206
|
+
case core_1.ProjectType.DOCKERFILE:
|
|
207
|
+
case core_1.ProjectType.PRESET: {
|
|
209
208
|
await this.dockerService.attach(project.containerName);
|
|
210
209
|
break;
|
|
211
210
|
}
|
|
@@ -216,9 +215,9 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
216
215
|
throw new Error(`Script ${script} not found`);
|
|
217
216
|
}
|
|
218
217
|
switch (project.type) {
|
|
219
|
-
case core_1.
|
|
220
|
-
case core_1.
|
|
221
|
-
case core_1.
|
|
218
|
+
case core_1.ProjectType.IMAGE:
|
|
219
|
+
case core_1.ProjectType.DOCKERFILE:
|
|
220
|
+
case core_1.ProjectType.PRESET: {
|
|
222
221
|
const container = await this.dockerService.getContainer(project.containerName);
|
|
223
222
|
if (!container) {
|
|
224
223
|
throw new Error("The project is not started");
|
|
@@ -241,7 +240,7 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
241
240
|
await this.dockerService.attachStream(stream);
|
|
242
241
|
break;
|
|
243
242
|
}
|
|
244
|
-
case core_1.
|
|
243
|
+
case core_1.ProjectType.COMPOSE: {
|
|
245
244
|
console.log(service, script, args);
|
|
246
245
|
break;
|
|
247
246
|
}
|
|
@@ -249,12 +248,12 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
249
248
|
}
|
|
250
249
|
async exec(project, command) {
|
|
251
250
|
switch (project.type) {
|
|
252
|
-
case core_1.
|
|
253
|
-
case core_1.
|
|
254
|
-
case core_1.
|
|
251
|
+
case core_1.ProjectType.IMAGE:
|
|
252
|
+
case core_1.ProjectType.DOCKERFILE:
|
|
253
|
+
case core_1.ProjectType.PRESET:
|
|
255
254
|
await this.dockerService.exec(project.containerName, command, true);
|
|
256
255
|
break;
|
|
257
|
-
case core_1.
|
|
256
|
+
case core_1.ProjectType.COMPOSE: {
|
|
258
257
|
const [service, ...args] = command;
|
|
259
258
|
await this.composeService.exec({
|
|
260
259
|
service,
|
|
@@ -268,9 +267,9 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
268
267
|
}
|
|
269
268
|
async logs(project, detach) {
|
|
270
269
|
switch (project.type) {
|
|
271
|
-
case core_1.
|
|
272
|
-
case core_1.
|
|
273
|
-
case core_1.
|
|
270
|
+
case core_1.ProjectType.IMAGE:
|
|
271
|
+
case core_1.ProjectType.DOCKERFILE:
|
|
272
|
+
case core_1.ProjectType.PRESET: {
|
|
274
273
|
const container = await this.dockerService.getContainer(project.containerName);
|
|
275
274
|
if (!container) {
|
|
276
275
|
throw new Error("Project not started");
|
|
@@ -288,7 +287,7 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
288
287
|
}
|
|
289
288
|
break;
|
|
290
289
|
}
|
|
291
|
-
case core_1.
|
|
290
|
+
case core_1.ProjectType.COMPOSE:
|
|
292
291
|
break;
|
|
293
292
|
}
|
|
294
293
|
}
|
|
@@ -296,12 +295,12 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
296
295
|
exports.ProjectService = ProjectService;
|
|
297
296
|
exports.ProjectService = ProjectService = __decorate([
|
|
298
297
|
(0, core_1.Injectable)("PROJECT_SERVICE"),
|
|
299
|
-
__metadata("design:paramtypes", [core_1.
|
|
298
|
+
__metadata("design:paramtypes", [core_1.AppService,
|
|
300
299
|
core_1.ProcessService,
|
|
301
300
|
core_1.EventService,
|
|
302
301
|
docker_module_1.DockerService,
|
|
303
302
|
docker_module_1.ComposeService,
|
|
304
|
-
|
|
303
|
+
core_1.ProjectRepository,
|
|
305
304
|
preset_1.PresetService,
|
|
306
305
|
preset_1.PresetRepository,
|
|
307
306
|
core_1.LogService])
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Project } from "@wocker/core";
|
|
2
1
|
import { ProjectService } from "../../project";
|
|
3
2
|
import { HttpAuthService } from "../services/HttpAuthService";
|
|
4
3
|
import { ProxyService } from "../services/ProxyService";
|
|
@@ -7,9 +6,9 @@ export declare class HttpAuthController {
|
|
|
7
6
|
protected readonly httpAuthService: HttpAuthService;
|
|
8
7
|
protected readonly proxyService: ProxyService;
|
|
9
8
|
constructor(projectService: ProjectService, httpAuthService: HttpAuthService, proxyService: ProxyService);
|
|
10
|
-
|
|
11
|
-
enable(domain?: string): Promise<void>;
|
|
12
|
-
disable(domain?: string): Promise<void>;
|
|
9
|
+
users(): Promise<void>;
|
|
10
|
+
enable(domain?: string, noRestart?: boolean): Promise<void>;
|
|
11
|
+
disable(domain?: string, noRestart?: boolean): Promise<void>;
|
|
13
12
|
add(user?: string, password?: string, global?: boolean, algorithm?: HttpAuthService.Algorithm): Promise<void>;
|
|
14
13
|
remove(user?: string): Promise<void>;
|
|
15
14
|
clear(): Promise<void>;
|
|
@@ -14,7 +14,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.HttpAuthController = void 0;
|
|
16
16
|
const core_1 = require("@wocker/core");
|
|
17
|
-
const
|
|
17
|
+
const prompts_1 = require("@wocker/prompts");
|
|
18
18
|
const project_1 = require("../../project");
|
|
19
19
|
const HttpAuthService_1 = require("../services/HttpAuthService");
|
|
20
20
|
const ProxyService_1 = require("../services/ProxyService");
|
|
@@ -24,27 +24,31 @@ let HttpAuthController = class HttpAuthController {
|
|
|
24
24
|
this.httpAuthService = httpAuthService;
|
|
25
25
|
this.proxyService = proxyService;
|
|
26
26
|
}
|
|
27
|
-
async
|
|
28
|
-
|
|
27
|
+
async users() {
|
|
28
|
+
await this.httpAuthService.usersForProject(this.projectService.get());
|
|
29
29
|
}
|
|
30
|
-
async enable(domain) {
|
|
30
|
+
async enable(domain, noRestart) {
|
|
31
31
|
await this.httpAuthService.enableForProject(this.projectService.get(), domain);
|
|
32
|
-
|
|
32
|
+
if (!noRestart) {
|
|
33
|
+
await this.proxyService.start(true);
|
|
34
|
+
}
|
|
33
35
|
}
|
|
34
|
-
async disable(domain) {
|
|
36
|
+
async disable(domain, noRestart) {
|
|
35
37
|
await this.httpAuthService.disableForProject(this.projectService.get(), domain);
|
|
36
|
-
|
|
38
|
+
if (!noRestart) {
|
|
39
|
+
await this.proxyService.start(true);
|
|
40
|
+
}
|
|
37
41
|
}
|
|
38
42
|
async add(user, password, global, algorithm) {
|
|
39
43
|
if (!user) {
|
|
40
|
-
user = await (0,
|
|
44
|
+
user = await (0, prompts_1.promptInput)({
|
|
41
45
|
required: true,
|
|
42
46
|
message: "User",
|
|
43
47
|
type: "text"
|
|
44
48
|
});
|
|
45
49
|
}
|
|
46
50
|
if (!password) {
|
|
47
|
-
password = await (0,
|
|
51
|
+
password = await (0, prompts_1.promptInput)({
|
|
48
52
|
required: true,
|
|
49
53
|
message: "Password",
|
|
50
54
|
type: "password"
|
|
@@ -56,34 +60,40 @@ let HttpAuthController = class HttpAuthController {
|
|
|
56
60
|
else {
|
|
57
61
|
await this.httpAuthService.addForProject(this.projectService.get(), user, password, algorithm);
|
|
58
62
|
}
|
|
59
|
-
await this.proxyService.start(true);
|
|
60
63
|
}
|
|
61
64
|
async remove(user) {
|
|
62
65
|
await this.httpAuthService.removeForProject(this.projectService.get(), user);
|
|
63
66
|
}
|
|
64
67
|
async clear() {
|
|
68
|
+
await this.httpAuthService.clearForProject(this.projectService.get());
|
|
65
69
|
}
|
|
66
70
|
};
|
|
67
71
|
exports.HttpAuthController = HttpAuthController;
|
|
68
72
|
__decorate([
|
|
69
|
-
(0, core_1.
|
|
73
|
+
(0, core_1.Command)("http-auth"),
|
|
74
|
+
(0, core_1.Description)(""),
|
|
70
75
|
__metadata("design:type", Function),
|
|
71
|
-
__metadata("design:paramtypes", [
|
|
76
|
+
__metadata("design:paramtypes", []),
|
|
72
77
|
__metadata("design:returntype", Promise)
|
|
73
|
-
], HttpAuthController.prototype, "
|
|
78
|
+
], HttpAuthController.prototype, "users", null);
|
|
74
79
|
__decorate([
|
|
75
80
|
(0, core_1.Command)("http-auth:enable"),
|
|
76
81
|
__param(0, (0, core_1.Option)("domain", "d")),
|
|
77
82
|
__param(0, (0, core_1.Description)("Domain to apply authentication to.")),
|
|
83
|
+
__param(1, (0, core_1.Option)("no-restart")),
|
|
84
|
+
__param(1, (0, core_1.Description)("")),
|
|
78
85
|
__metadata("design:type", Function),
|
|
79
|
-
__metadata("design:paramtypes", [String]),
|
|
86
|
+
__metadata("design:paramtypes", [String, Boolean]),
|
|
80
87
|
__metadata("design:returntype", Promise)
|
|
81
88
|
], HttpAuthController.prototype, "enable", null);
|
|
82
89
|
__decorate([
|
|
83
90
|
(0, core_1.Command)("http-auth:disable"),
|
|
84
91
|
__param(0, (0, core_1.Option)("domain", "d")),
|
|
92
|
+
__param(0, (0, core_1.Description)("")),
|
|
93
|
+
__param(1, (0, core_1.Option)("no-restart")),
|
|
94
|
+
__param(1, (0, core_1.Description)("")),
|
|
85
95
|
__metadata("design:type", Function),
|
|
86
|
-
__metadata("design:paramtypes", [String]),
|
|
96
|
+
__metadata("design:paramtypes", [String, Boolean]),
|
|
87
97
|
__metadata("design:returntype", Promise)
|
|
88
98
|
], HttpAuthController.prototype, "disable", null);
|
|
89
99
|
__decorate([
|
|
@@ -104,7 +114,8 @@ __decorate([
|
|
|
104
114
|
__metadata("design:returntype", Promise)
|
|
105
115
|
], HttpAuthController.prototype, "add", null);
|
|
106
116
|
__decorate([
|
|
107
|
-
(0, core_1.Command)("http-auth:remove [user]"),
|
|
117
|
+
(0, core_1.Command)("http-auth:remove-user [user]"),
|
|
118
|
+
(0, core_1.Description)(""),
|
|
108
119
|
__param(0, (0, core_1.Param)("user")),
|
|
109
120
|
__metadata("design:type", Function),
|
|
110
121
|
__metadata("design:paramtypes", [String]),
|
|
@@ -112,6 +123,7 @@ __decorate([
|
|
|
112
123
|
], HttpAuthController.prototype, "remove", null);
|
|
113
124
|
__decorate([
|
|
114
125
|
(0, core_1.Command)("http-auth:clear"),
|
|
126
|
+
(0, core_1.Description)("Remove all users for the project."),
|
|
115
127
|
__metadata("design:type", Function),
|
|
116
128
|
__metadata("design:paramtypes", []),
|
|
117
129
|
__metadata("design:returntype", Promise)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Project,
|
|
1
|
+
import { Project, AppService } from "@wocker/core";
|
|
2
2
|
import { ProjectService } from "../../project";
|
|
3
3
|
import { ProxyService } from "../services/ProxyService";
|
|
4
4
|
export declare class ProxyController {
|
|
5
|
-
protected readonly
|
|
5
|
+
protected readonly appService: AppService;
|
|
6
6
|
protected readonly projectService: ProjectService;
|
|
7
7
|
protected readonly proxyService: ProxyService;
|
|
8
|
-
constructor(
|
|
8
|
+
constructor(appService: AppService, projectService: ProjectService, proxyService: ProxyService);
|
|
9
9
|
onProjectInit(project: Project): Promise<void>;
|
|
10
10
|
onProjectStart(project: Project): Promise<void>;
|
|
11
11
|
onProjectStop(_project: Project): Promise<void>;
|
|
@@ -17,13 +17,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.ProxyController = void 0;
|
|
19
19
|
const core_1 = require("@wocker/core");
|
|
20
|
-
const
|
|
20
|
+
const prompts_1 = require("@wocker/prompts");
|
|
21
21
|
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
22
22
|
const project_1 = require("../../project");
|
|
23
23
|
const ProxyService_1 = require("../services/ProxyService");
|
|
24
24
|
let ProxyController = class ProxyController {
|
|
25
|
-
constructor(
|
|
26
|
-
this.
|
|
25
|
+
constructor(appService, projectService, proxyService) {
|
|
26
|
+
this.appService = appService;
|
|
27
27
|
this.projectService = projectService;
|
|
28
28
|
this.proxyService = proxyService;
|
|
29
29
|
}
|
|
@@ -47,9 +47,9 @@ let ProxyController = class ProxyController {
|
|
|
47
47
|
return projects.map((project) => project.name);
|
|
48
48
|
}
|
|
49
49
|
async init(httpPort, httpsPort, sshPort, sshPassword) {
|
|
50
|
-
const config = this.
|
|
50
|
+
const config = this.appService.config;
|
|
51
51
|
if (httpPort === null || typeof httpPort === "undefined" || isNaN(httpPort)) {
|
|
52
|
-
httpPort = await (0,
|
|
52
|
+
httpPort = await (0, prompts_1.promptInput)({
|
|
53
53
|
required: true,
|
|
54
54
|
message: "Http port",
|
|
55
55
|
type: "number",
|
|
@@ -58,7 +58,7 @@ let ProxyController = class ProxyController {
|
|
|
58
58
|
}
|
|
59
59
|
config.setMeta("PROXY_HTTP_PORT", httpPort.toString());
|
|
60
60
|
if (httpsPort === null || typeof httpsPort === "undefined" || isNaN(httpsPort)) {
|
|
61
|
-
httpsPort = await (0,
|
|
61
|
+
httpsPort = await (0, prompts_1.promptInput)({
|
|
62
62
|
required: true,
|
|
63
63
|
message: "Https port",
|
|
64
64
|
type: "number",
|
|
@@ -67,14 +67,14 @@ let ProxyController = class ProxyController {
|
|
|
67
67
|
}
|
|
68
68
|
config.setMeta("PROXY_HTTPS_PORT", httpsPort.toString());
|
|
69
69
|
let enableSsh = !sshPassword && !sshPort
|
|
70
|
-
? await (0,
|
|
70
|
+
? await (0, prompts_1.promptConfirm)({
|
|
71
71
|
message: "Enable ssh proxy?",
|
|
72
72
|
default: false
|
|
73
73
|
})
|
|
74
74
|
: true;
|
|
75
75
|
if (enableSsh) {
|
|
76
76
|
if (!sshPassword) {
|
|
77
|
-
sshPassword = await (0,
|
|
77
|
+
sshPassword = await (0, prompts_1.promptInput)({
|
|
78
78
|
message: "SSH Password",
|
|
79
79
|
type: "password",
|
|
80
80
|
required: true,
|
|
@@ -82,7 +82,7 @@ let ProxyController = class ProxyController {
|
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
if (!sshPort) {
|
|
85
|
-
sshPort = await (0,
|
|
85
|
+
sshPort = await (0, prompts_1.promptInput)({
|
|
86
86
|
message: "SSH port",
|
|
87
87
|
type: "number",
|
|
88
88
|
default: parseInt(config.getMeta("PROXY_SSH_PORT", "22"))
|
|
@@ -95,7 +95,7 @@ let ProxyController = class ProxyController {
|
|
|
95
95
|
config.unsetMeta("PROXY_SSH_PASSWORD");
|
|
96
96
|
config.unsetMeta("PROXY_SSH_PORT");
|
|
97
97
|
}
|
|
98
|
-
this.
|
|
98
|
+
this.appService.save();
|
|
99
99
|
}
|
|
100
100
|
async start(restart, rebuild) {
|
|
101
101
|
await this.proxyService.start(restart, rebuild);
|
|
@@ -190,7 +190,7 @@ __decorate([
|
|
|
190
190
|
exports.ProxyController = ProxyController = __decorate([
|
|
191
191
|
(0, core_1.Controller)(),
|
|
192
192
|
(0, core_1.Description)("Proxy commands"),
|
|
193
|
-
__metadata("design:paramtypes", [core_1.
|
|
193
|
+
__metadata("design:paramtypes", [core_1.AppService,
|
|
194
194
|
project_1.ProjectService,
|
|
195
195
|
ProxyService_1.ProxyService])
|
|
196
196
|
], ProxyController);
|
|
@@ -7,11 +7,14 @@ export declare class HttpAuthService {
|
|
|
7
7
|
protected readonly dockerService: DockerService;
|
|
8
8
|
protected readonly proxyService: ProxyService;
|
|
9
9
|
constructor(processService: ProcessService, fs: AppFileSystemService, dockerService: DockerService, proxyService: ProxyService);
|
|
10
|
+
users(path: string): Promise<void>;
|
|
10
11
|
add(path: string, user: string, password: string, algorithm?: HttpAuthService.Algorithm): Promise<void>;
|
|
11
12
|
addForProject(project: Project, user: string, password: string, algorithm?: HttpAuthService.Algorithm): Promise<void>;
|
|
12
13
|
addForGlobal(user: string, password: string, algorithm?: HttpAuthService.Algorithm): Promise<void>;
|
|
13
14
|
removeUser(path: string, user: string): Promise<void>;
|
|
15
|
+
usersForProject(project: Project): Promise<void>;
|
|
14
16
|
removeForProject(project: Project, user: string): Promise<void>;
|
|
17
|
+
clearForProject(project: Project): Promise<void>;
|
|
15
18
|
enableForProject(project: Project, domain?: string): Promise<void>;
|
|
16
19
|
disableForProject(project: Project, domain?: string): Promise<void>;
|
|
17
20
|
}
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.HttpAuthService = void 0;
|
|
13
13
|
const core_1 = require("@wocker/core");
|
|
14
14
|
const docker_module_1 = require("@wocker/docker-module");
|
|
15
|
-
const utils_1 = require("@wocker/utils");
|
|
16
15
|
const ProxyService_1 = require("./ProxyService");
|
|
17
16
|
let HttpAuthService = class HttpAuthService {
|
|
18
17
|
constructor(processService, fs, dockerService, proxyService) {
|
|
@@ -21,6 +20,13 @@ let HttpAuthService = class HttpAuthService {
|
|
|
21
20
|
this.dockerService = dockerService;
|
|
22
21
|
this.proxyService = proxyService;
|
|
23
22
|
}
|
|
23
|
+
async users(path) {
|
|
24
|
+
await this.dockerService.exec("wocker-proxy", {
|
|
25
|
+
tty: true,
|
|
26
|
+
user: "nginx",
|
|
27
|
+
cmd: ["cut", "-d:", "-f1", `/etc/${path}`]
|
|
28
|
+
});
|
|
29
|
+
}
|
|
24
30
|
async add(path, user, password, algorithm = "md5") {
|
|
25
31
|
const alMap = {
|
|
26
32
|
md5: "-m",
|
|
@@ -37,16 +43,10 @@ let HttpAuthService = class HttpAuthService {
|
|
|
37
43
|
mode: 0o640
|
|
38
44
|
});
|
|
39
45
|
}
|
|
40
|
-
|
|
46
|
+
await this.dockerService.exec("wocker-proxy", {
|
|
41
47
|
user: "nginx",
|
|
42
|
-
cmd: ["htpasswd", "-b", alMap[algorithm], `/etc/${path}`, user, password]
|
|
43
|
-
|
|
44
|
-
await new Promise((resolve, reject) => {
|
|
45
|
-
stream.on("data", (chunk) => {
|
|
46
|
-
this.processService.stdout.write((0, utils_1.demuxOutput)(chunk));
|
|
47
|
-
});
|
|
48
|
-
stream.on("end", resolve);
|
|
49
|
-
stream.on("error", reject);
|
|
48
|
+
cmd: ["htpasswd", "-b", alMap[algorithm], `/etc/${path}`, user, password],
|
|
49
|
+
tty: true
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
async addForProject(project, user, password, algorithm = "md5") {
|
|
@@ -61,6 +61,17 @@ let HttpAuthService = class HttpAuthService {
|
|
|
61
61
|
return this.add(`nginx/htpasswd/_global`, user, password, algorithm);
|
|
62
62
|
}
|
|
63
63
|
async removeUser(path, user) {
|
|
64
|
+
await this.dockerService.exec("wocker-proxy", {
|
|
65
|
+
cmd: ["htpasswd", "-D", `/etc/${path}`, user],
|
|
66
|
+
user: "nginx",
|
|
67
|
+
tty: true
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async usersForProject(project) {
|
|
71
|
+
if (!this.fs.exists("nginx/htpasswd/projects")) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
await this.users(`nginx/htpasswd/projects/${project.name}`);
|
|
64
75
|
}
|
|
65
76
|
async removeForProject(project, user) {
|
|
66
77
|
if (!this.fs.exists("nginx/htpasswd/projects")) {
|
|
@@ -68,6 +79,14 @@ let HttpAuthService = class HttpAuthService {
|
|
|
68
79
|
}
|
|
69
80
|
await this.removeUser(`nginx/htpasswd/projects/${project.name}`, user);
|
|
70
81
|
}
|
|
82
|
+
async clearForProject(project) {
|
|
83
|
+
const filePath = `nginx/htpasswd/projects/${project.name}`;
|
|
84
|
+
if (this.fs.exists(filePath)) {
|
|
85
|
+
this.fs.writeFile(filePath, "", {
|
|
86
|
+
mode: 0o640
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
71
90
|
async enableForProject(project, domain) {
|
|
72
91
|
if (!this.fs.exists(`nginx/htpasswd/projects/${project.name}`)) {
|
|
73
92
|
throw new Error(`No htpasswd for ${project.name}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Project,
|
|
1
|
+
import { Project, AppService, AppFileSystemService, ProcessService, ProxyService as CoreProxyService } from "@wocker/core";
|
|
2
2
|
import { DockerService } from "@wocker/docker-module";
|
|
3
3
|
export declare class ProxyService extends CoreProxyService {
|
|
4
|
-
protected readonly
|
|
4
|
+
protected readonly appService: AppService;
|
|
5
5
|
protected readonly processService: ProcessService;
|
|
6
6
|
protected readonly fs: AppFileSystemService;
|
|
7
7
|
protected readonly dockerService: DockerService;
|
|
@@ -9,7 +9,7 @@ export declare class ProxyService extends CoreProxyService {
|
|
|
9
9
|
protected oldContainerNames: string[];
|
|
10
10
|
protected imageName: string;
|
|
11
11
|
protected oldImages: string[];
|
|
12
|
-
constructor(
|
|
12
|
+
constructor(appService: AppService, processService: ProcessService, fs: AppFileSystemService, dockerService: DockerService);
|
|
13
13
|
init(project: Project): Promise<void>;
|
|
14
14
|
start(restart?: boolean, rebuild?: boolean): Promise<void>;
|
|
15
15
|
stop(): Promise<void>;
|
|
@@ -45,13 +45,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
45
45
|
exports.ProxyService = void 0;
|
|
46
46
|
const core_1 = require("@wocker/core");
|
|
47
47
|
const docker_module_1 = require("@wocker/docker-module");
|
|
48
|
-
const
|
|
48
|
+
const prompts_1 = require("@wocker/prompts");
|
|
49
49
|
const Path = __importStar(require("path"));
|
|
50
50
|
const env_1 = require("../../../env");
|
|
51
51
|
let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
52
|
-
constructor(
|
|
52
|
+
constructor(appService, processService, fs, dockerService) {
|
|
53
53
|
super();
|
|
54
|
-
this.
|
|
54
|
+
this.appService = appService;
|
|
55
55
|
this.processService = processService;
|
|
56
56
|
this.fs = fs;
|
|
57
57
|
this.dockerService = dockerService;
|
|
@@ -64,7 +64,7 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
64
64
|
];
|
|
65
65
|
}
|
|
66
66
|
async init(project) {
|
|
67
|
-
const appPort = await (0,
|
|
67
|
+
const appPort = await (0, prompts_1.promptInput)({
|
|
68
68
|
message: "App port",
|
|
69
69
|
type: "number",
|
|
70
70
|
default: parseInt(project.getEnv("VIRTUAL_PORT", "80"))
|
|
@@ -110,7 +110,7 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
110
110
|
else {
|
|
111
111
|
this.fs.chmod("nginx/htpasswd", 0o764);
|
|
112
112
|
}
|
|
113
|
-
const httpPort = this.
|
|
113
|
+
const httpPort = this.appService.getMeta("PROXY_HTTP_PORT", "80"), httpsPort = this.appService.getMeta("PROXY_HTTPS_PORT", "443"), sshPort = this.appService.getMeta("PROXY_SSH_PORT", "22");
|
|
114
114
|
container = await this.dockerService.createContainer({
|
|
115
115
|
name: this.containerName,
|
|
116
116
|
image: this.imageName,
|
|
@@ -124,7 +124,7 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
124
124
|
ports: [
|
|
125
125
|
`${httpPort}:80`,
|
|
126
126
|
`${httpsPort}:443`,
|
|
127
|
-
...this.
|
|
127
|
+
...this.appService.getMeta("PROXY_SSH_PASSWORD") ? [
|
|
128
128
|
`${sshPort}:22`
|
|
129
129
|
] : []
|
|
130
130
|
],
|
|
@@ -161,9 +161,9 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
161
161
|
}
|
|
162
162
|
await this.dockerService.buildImage({
|
|
163
163
|
tag: this.imageName,
|
|
164
|
-
version: this.
|
|
164
|
+
version: this.appService.isExperimentalEnabled("buildKit") ? "2" : "1",
|
|
165
165
|
buildArgs: {
|
|
166
|
-
SSH_PASSWORD: this.
|
|
166
|
+
SSH_PASSWORD: this.appService.getMeta("PROXY_SSH_PASSWORD")
|
|
167
167
|
},
|
|
168
168
|
context: Path.join(env_1.PLUGINS_DIR, "proxy"),
|
|
169
169
|
dockerfile: "./Dockerfile"
|
|
@@ -176,7 +176,7 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
176
176
|
exports.ProxyService = ProxyService;
|
|
177
177
|
exports.ProxyService = ProxyService = __decorate([
|
|
178
178
|
(0, core_1.Injectable)("PROXY_SERVICE"),
|
|
179
|
-
__metadata("design:paramtypes", [core_1.
|
|
179
|
+
__metadata("design:paramtypes", [core_1.AppService,
|
|
180
180
|
core_1.ProcessService,
|
|
181
181
|
core_1.AppFileSystemService,
|
|
182
182
|
docker_module_1.DockerService])
|