@wocker/ws 1.0.31 → 1.1.0
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 -3
- package/lib/modules/preset/controllers/PresetListener.js +21 -30
- 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 +63 -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 +5 -6
- package/lib/modules/project/services/ProjectService.js +38 -39
- package/lib/modules/proxy/controllers/CertController.js +6 -0
- package/lib/modules/proxy/controllers/HttpAuthController.d.ts +15 -0
- package/lib/modules/proxy/controllers/HttpAuthController.js +137 -0
- package/lib/modules/proxy/controllers/ProxyController.d.ts +3 -3
- package/lib/modules/proxy/controllers/ProxyController.js +11 -11
- package/lib/modules/proxy/index.js +4 -0
- package/lib/modules/proxy/services/CertService.d.ts +6 -5
- package/lib/modules/proxy/services/CertService.js +1 -2
- package/lib/modules/proxy/services/HttpAuthService.d.ts +23 -0
- package/lib/modules/proxy/services/HttpAuthService.js +137 -0
- package/lib/modules/proxy/services/ProxyService.d.ts +4 -3
- package/lib/modules/proxy/services/ProxyService.js +31 -19
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -1
- package/package.json +5 -13
- package/plugins/proxy/Dockerfile +14 -4
- package/plugins/proxy/wocker-entrypoint.sh +11 -0
- 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 -10
- 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,9 +62,9 @@ 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) {
|
|
@@ -74,7 +73,7 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
74
73
|
image: project.imageName,
|
|
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,10 +138,10 @@ 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.
|
|
141
|
+
case core_1.ProjectType.IMAGE:
|
|
143
142
|
await this.dockerService.pullImage(project.imageName);
|
|
144
143
|
break;
|
|
145
|
-
case core_1.
|
|
144
|
+
case core_1.ProjectType.DOCKERFILE: {
|
|
146
145
|
project.imageName = `project-${project.name}:develop`;
|
|
147
146
|
project.save();
|
|
148
147
|
if (rebuild) {
|
|
@@ -150,7 +149,7 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
150
149
|
}
|
|
151
150
|
if (!await this.dockerService.imageExists(project.imageName)) {
|
|
152
151
|
await this.dockerService.buildImage({
|
|
153
|
-
version: this.
|
|
152
|
+
version: this.appService.isExperimentalEnabled("buildKit") ? "2" : "1",
|
|
154
153
|
tag: project.imageName,
|
|
155
154
|
buildArgs: project.buildArgs,
|
|
156
155
|
context: project.path,
|
|
@@ -159,7 +158,7 @@ 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
|
});
|
|
@@ -176,7 +175,7 @@ let ProjectService = class ProjectService extends core_1.ProjectService {
|
|
|
176
175
|
}
|
|
177
176
|
if (!await this.dockerService.imageExists(project.imageName)) {
|
|
178
177
|
await this.dockerService.buildImage({
|
|
179
|
-
version: this.
|
|
178
|
+
version: this.appService.isExperimentalEnabled("buildKit") ? "2" : "1",
|
|
180
179
|
tag: project.imageName,
|
|
181
180
|
labels: {
|
|
182
181
|
"org.wocker.preset": preset.name
|
|
@@ -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])
|
|
@@ -48,12 +48,14 @@ let CertController = class CertController {
|
|
|
48
48
|
exports.CertController = CertController;
|
|
49
49
|
__decorate([
|
|
50
50
|
(0, core_1.Command)("certs"),
|
|
51
|
+
(0, core_1.Description)("Show certs"),
|
|
51
52
|
__metadata("design:type", Function),
|
|
52
53
|
__metadata("design:paramtypes", []),
|
|
53
54
|
__metadata("design:returntype", Promise)
|
|
54
55
|
], CertController.prototype, "list", null);
|
|
55
56
|
__decorate([
|
|
56
57
|
(0, core_1.Command)("cert:generate [cert]"),
|
|
58
|
+
(0, core_1.Description)("Generate cert"),
|
|
57
59
|
__param(0, (0, core_1.Param)("cert")),
|
|
58
60
|
__param(1, (0, core_1.Option)("dns", {
|
|
59
61
|
type: "string",
|
|
@@ -66,6 +68,7 @@ __decorate([
|
|
|
66
68
|
], CertController.prototype, "createCert", null);
|
|
67
69
|
__decorate([
|
|
68
70
|
(0, core_1.Command)("cert:use [cert]"),
|
|
71
|
+
(0, core_1.Description)("Use cert"),
|
|
69
72
|
__param(0, (0, core_1.Param)("cert")),
|
|
70
73
|
__param(1, (0, core_1.Option)("name", {
|
|
71
74
|
type: "string",
|
|
@@ -78,6 +81,7 @@ __decorate([
|
|
|
78
81
|
], CertController.prototype, "use", null);
|
|
79
82
|
__decorate([
|
|
80
83
|
(0, core_1.Command)("cert:remove"),
|
|
84
|
+
(0, core_1.Description)("Remove cert"),
|
|
81
85
|
__param(0, (0, core_1.Option)("name", {
|
|
82
86
|
type: "string",
|
|
83
87
|
alias: "n",
|
|
@@ -89,6 +93,7 @@ __decorate([
|
|
|
89
93
|
], CertController.prototype, "remove", null);
|
|
90
94
|
__decorate([
|
|
91
95
|
(0, core_1.Command)("cert:delete <cert>"),
|
|
96
|
+
(0, core_1.Description)("Delete cert"),
|
|
92
97
|
__param(0, (0, core_1.Param)("cert")),
|
|
93
98
|
__metadata("design:type", Function),
|
|
94
99
|
__metadata("design:paramtypes", [String]),
|
|
@@ -109,6 +114,7 @@ __decorate([
|
|
|
109
114
|
], CertController.prototype, "existsOtherNames", null);
|
|
110
115
|
exports.CertController = CertController = __decorate([
|
|
111
116
|
(0, core_1.Controller)(),
|
|
117
|
+
(0, core_1.Description)("Cert commands"),
|
|
112
118
|
__metadata("design:paramtypes", [project_1.ProjectService,
|
|
113
119
|
CertService_1.CertService])
|
|
114
120
|
], CertController);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ProjectService } from "../../project";
|
|
2
|
+
import { HttpAuthService } from "../services/HttpAuthService";
|
|
3
|
+
import { ProxyService } from "../services/ProxyService";
|
|
4
|
+
export declare class HttpAuthController {
|
|
5
|
+
protected readonly projectService: ProjectService;
|
|
6
|
+
protected readonly httpAuthService: HttpAuthService;
|
|
7
|
+
protected readonly proxyService: ProxyService;
|
|
8
|
+
constructor(projectService: ProjectService, httpAuthService: HttpAuthService, proxyService: ProxyService);
|
|
9
|
+
users(): Promise<void>;
|
|
10
|
+
enable(domain?: string, noRestart?: boolean): Promise<void>;
|
|
11
|
+
disable(domain?: string, noRestart?: boolean): Promise<void>;
|
|
12
|
+
add(user?: string, password?: string, global?: boolean, algorithm?: HttpAuthService.Algorithm): Promise<void>;
|
|
13
|
+
remove(user?: string): Promise<void>;
|
|
14
|
+
clear(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.HttpAuthController = void 0;
|
|
16
|
+
const core_1 = require("@wocker/core");
|
|
17
|
+
const prompts_1 = require("@wocker/prompts");
|
|
18
|
+
const project_1 = require("../../project");
|
|
19
|
+
const HttpAuthService_1 = require("../services/HttpAuthService");
|
|
20
|
+
const ProxyService_1 = require("../services/ProxyService");
|
|
21
|
+
let HttpAuthController = class HttpAuthController {
|
|
22
|
+
constructor(projectService, httpAuthService, proxyService) {
|
|
23
|
+
this.projectService = projectService;
|
|
24
|
+
this.httpAuthService = httpAuthService;
|
|
25
|
+
this.proxyService = proxyService;
|
|
26
|
+
}
|
|
27
|
+
async users() {
|
|
28
|
+
await this.httpAuthService.usersForProject(this.projectService.get());
|
|
29
|
+
}
|
|
30
|
+
async enable(domain, noRestart) {
|
|
31
|
+
await this.httpAuthService.enableForProject(this.projectService.get(), domain);
|
|
32
|
+
if (!noRestart) {
|
|
33
|
+
await this.proxyService.start(true);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async disable(domain, noRestart) {
|
|
37
|
+
await this.httpAuthService.disableForProject(this.projectService.get(), domain);
|
|
38
|
+
if (!noRestart) {
|
|
39
|
+
await this.proxyService.start(true);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async add(user, password, global, algorithm) {
|
|
43
|
+
if (!user) {
|
|
44
|
+
user = await (0, prompts_1.promptInput)({
|
|
45
|
+
required: true,
|
|
46
|
+
message: "User",
|
|
47
|
+
type: "text"
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (!password) {
|
|
51
|
+
password = await (0, prompts_1.promptInput)({
|
|
52
|
+
required: true,
|
|
53
|
+
message: "Password",
|
|
54
|
+
type: "password"
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (global) {
|
|
58
|
+
await this.httpAuthService.addForGlobal(user, password, algorithm);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
await this.httpAuthService.addForProject(this.projectService.get(), user, password, algorithm);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async remove(user) {
|
|
65
|
+
await this.httpAuthService.removeForProject(this.projectService.get(), user);
|
|
66
|
+
}
|
|
67
|
+
async clear() {
|
|
68
|
+
await this.httpAuthService.clearForProject(this.projectService.get());
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.HttpAuthController = HttpAuthController;
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, core_1.Command)("http-auth"),
|
|
74
|
+
(0, core_1.Description)(""),
|
|
75
|
+
__metadata("design:type", Function),
|
|
76
|
+
__metadata("design:paramtypes", []),
|
|
77
|
+
__metadata("design:returntype", Promise)
|
|
78
|
+
], HttpAuthController.prototype, "users", null);
|
|
79
|
+
__decorate([
|
|
80
|
+
(0, core_1.Command)("http-auth:enable"),
|
|
81
|
+
__param(0, (0, core_1.Option)("domain", "d")),
|
|
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)("")),
|
|
85
|
+
__metadata("design:type", Function),
|
|
86
|
+
__metadata("design:paramtypes", [String, Boolean]),
|
|
87
|
+
__metadata("design:returntype", Promise)
|
|
88
|
+
], HttpAuthController.prototype, "enable", null);
|
|
89
|
+
__decorate([
|
|
90
|
+
(0, core_1.Command)("http-auth:disable"),
|
|
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)("")),
|
|
95
|
+
__metadata("design:type", Function),
|
|
96
|
+
__metadata("design:paramtypes", [String, Boolean]),
|
|
97
|
+
__metadata("design:returntype", Promise)
|
|
98
|
+
], HttpAuthController.prototype, "disable", null);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, core_1.Command)("http-auth:add-user"),
|
|
101
|
+
(0, core_1.Command)("http-auth:add-user [user]"),
|
|
102
|
+
(0, core_1.Command)("http-auth:add-user [user]:[password]"),
|
|
103
|
+
(0, core_1.Description)("Add a user for HTTP Basic Auth"),
|
|
104
|
+
__param(0, (0, core_1.Param)("user")),
|
|
105
|
+
__param(0, (0, core_1.Description)("Username for Basic Auth. If omitted, you will be prompted.")),
|
|
106
|
+
__param(1, (0, core_1.Param)("password")),
|
|
107
|
+
__param(1, (0, core_1.Description)("Password for Basic Auth. If omitted, you will be prompted.")),
|
|
108
|
+
__param(2, (0, core_1.Option)("global", "g")),
|
|
109
|
+
__param(2, (0, core_1.Description)("")),
|
|
110
|
+
__param(3, (0, core_1.Option)("algorithm", "a")),
|
|
111
|
+
__param(3, (0, core_1.Description)("Password hashing algorithm (e.g. md5, bcrypt, sha1, sha256, sha512).")),
|
|
112
|
+
__metadata("design:type", Function),
|
|
113
|
+
__metadata("design:paramtypes", [String, String, Boolean, String]),
|
|
114
|
+
__metadata("design:returntype", Promise)
|
|
115
|
+
], HttpAuthController.prototype, "add", null);
|
|
116
|
+
__decorate([
|
|
117
|
+
(0, core_1.Command)("http-auth:remove-user [user]"),
|
|
118
|
+
(0, core_1.Description)(""),
|
|
119
|
+
__param(0, (0, core_1.Param)("user")),
|
|
120
|
+
__metadata("design:type", Function),
|
|
121
|
+
__metadata("design:paramtypes", [String]),
|
|
122
|
+
__metadata("design:returntype", Promise)
|
|
123
|
+
], HttpAuthController.prototype, "remove", null);
|
|
124
|
+
__decorate([
|
|
125
|
+
(0, core_1.Command)("http-auth:clear"),
|
|
126
|
+
(0, core_1.Description)("Remove all users for the project."),
|
|
127
|
+
__metadata("design:type", Function),
|
|
128
|
+
__metadata("design:paramtypes", []),
|
|
129
|
+
__metadata("design:returntype", Promise)
|
|
130
|
+
], HttpAuthController.prototype, "clear", null);
|
|
131
|
+
exports.HttpAuthController = HttpAuthController = __decorate([
|
|
132
|
+
(0, core_1.Controller)(),
|
|
133
|
+
(0, core_1.Description)("BasicAuth commands"),
|
|
134
|
+
__metadata("design:paramtypes", [project_1.ProjectService,
|
|
135
|
+
HttpAuthService_1.HttpAuthService,
|
|
136
|
+
ProxyService_1.ProxyService])
|
|
137
|
+
], HttpAuthController);
|
|
@@ -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);
|
|
@@ -13,8 +13,10 @@ exports.CertService = exports.ProxyService = exports.ProxyModule = void 0;
|
|
|
13
13
|
const core_1 = require("@wocker/core");
|
|
14
14
|
const docker_module_1 = __importDefault(require("@wocker/docker-module"));
|
|
15
15
|
const project_1 = require("../project");
|
|
16
|
+
const HttpAuthController_1 = require("./controllers/HttpAuthController");
|
|
16
17
|
const CertController_1 = require("./controllers/CertController");
|
|
17
18
|
const ProxyController_1 = require("./controllers/ProxyController");
|
|
19
|
+
const HttpAuthService_1 = require("./services/HttpAuthService");
|
|
18
20
|
const CertService_1 = require("./services/CertService");
|
|
19
21
|
Object.defineProperty(exports, "CertService", { enumerable: true, get: function () { return CertService_1.CertService; } });
|
|
20
22
|
const ProxyService_1 = require("./services/ProxyService");
|
|
@@ -29,10 +31,12 @@ exports.ProxyModule = ProxyModule = __decorate([
|
|
|
29
31
|
project_1.ProjectModule
|
|
30
32
|
],
|
|
31
33
|
controllers: [
|
|
34
|
+
HttpAuthController_1.HttpAuthController,
|
|
32
35
|
CertController_1.CertController,
|
|
33
36
|
ProxyController_1.ProxyController
|
|
34
37
|
],
|
|
35
38
|
providers: [
|
|
39
|
+
HttpAuthService_1.HttpAuthService,
|
|
36
40
|
ProxyService_1.ProxyService,
|
|
37
41
|
CertService_1.CertService
|
|
38
42
|
],
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Project, AppFileSystemService } from "@wocker/core";
|
|
2
2
|
import { DockerService } from "@wocker/docker-module";
|
|
3
3
|
import { ProxyService } from "./ProxyService";
|
|
4
|
-
type CertMap = {
|
|
5
|
-
[name: string]: string[];
|
|
6
|
-
};
|
|
7
4
|
export declare class CertService {
|
|
8
5
|
protected readonly fs: AppFileSystemService;
|
|
9
6
|
protected readonly proxyService: ProxyService;
|
|
@@ -11,9 +8,13 @@ export declare class CertService {
|
|
|
11
8
|
constructor(fs: AppFileSystemService, proxyService: ProxyService, dockerService: DockerService);
|
|
12
9
|
list(): Promise<string>;
|
|
13
10
|
generate(certName: string, dns: string[]): Promise<void>;
|
|
14
|
-
getCertsMap(): CertMap;
|
|
11
|
+
getCertsMap(): CertService.CertMap;
|
|
15
12
|
use(project: Project, name: string): Promise<void>;
|
|
16
13
|
remove(project: Project): Promise<void>;
|
|
17
14
|
delete(name: string): Promise<void>;
|
|
18
15
|
}
|
|
19
|
-
export {
|
|
16
|
+
export declare namespace CertService {
|
|
17
|
+
type CertMap = {
|
|
18
|
+
[name: string]: string[];
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -96,8 +96,7 @@ let CertService = class CertService {
|
|
|
96
96
|
getCertsMap() {
|
|
97
97
|
const files = this.fs.readdir("certs/projects");
|
|
98
98
|
return files.reduce((res, file) => {
|
|
99
|
-
const ext = Path.extname(file);
|
|
100
|
-
const name = Path.basename(file, ext);
|
|
99
|
+
const ext = Path.extname(file), name = Path.basename(file, ext);
|
|
101
100
|
if (!res[name]) {
|
|
102
101
|
res[name] = [];
|
|
103
102
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AppFileSystemService, Project, ProcessService } from "@wocker/core";
|
|
2
|
+
import { DockerService } from "@wocker/docker-module";
|
|
3
|
+
import { ProxyService } from "./ProxyService";
|
|
4
|
+
export declare class HttpAuthService {
|
|
5
|
+
protected readonly processService: ProcessService;
|
|
6
|
+
protected readonly fs: AppFileSystemService;
|
|
7
|
+
protected readonly dockerService: DockerService;
|
|
8
|
+
protected readonly proxyService: ProxyService;
|
|
9
|
+
constructor(processService: ProcessService, fs: AppFileSystemService, dockerService: DockerService, proxyService: ProxyService);
|
|
10
|
+
users(path: string): Promise<void>;
|
|
11
|
+
add(path: string, user: string, password: string, algorithm?: HttpAuthService.Algorithm): Promise<void>;
|
|
12
|
+
addForProject(project: Project, user: string, password: string, algorithm?: HttpAuthService.Algorithm): Promise<void>;
|
|
13
|
+
addForGlobal(user: string, password: string, algorithm?: HttpAuthService.Algorithm): Promise<void>;
|
|
14
|
+
removeUser(path: string, user: string): Promise<void>;
|
|
15
|
+
usersForProject(project: Project): Promise<void>;
|
|
16
|
+
removeForProject(project: Project, user: string): Promise<void>;
|
|
17
|
+
clearForProject(project: Project): Promise<void>;
|
|
18
|
+
enableForProject(project: Project, domain?: string): Promise<void>;
|
|
19
|
+
disableForProject(project: Project, domain?: string): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export declare namespace HttpAuthService {
|
|
22
|
+
type Algorithm = "md5" | "sha1" | "sha256" | "sha512" | "bcrypt";
|
|
23
|
+
}
|