@wocker/ws 1.0.22 → 1.0.23
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 +36 -29
- package/lib/controllers/DebugController.d.ts +2 -1
- package/lib/controllers/DebugController.js +7 -7
- package/lib/controllers/ExperimentalController.d.ts +8 -0
- package/lib/controllers/ExperimentalController.js +77 -0
- package/lib/controllers/PluginController.d.ts +2 -1
- package/lib/controllers/PluginController.js +4 -3
- package/lib/controllers/PresetController.d.ts +5 -1
- package/lib/controllers/PresetController.js +11 -8
- package/lib/controllers/ProjectController.d.ts +6 -2
- package/lib/controllers/ProjectController.js +80 -59
- package/lib/controllers/index.d.ts +1 -3
- package/lib/controllers/index.js +1 -3
- package/lib/env.d.ts +1 -2
- package/lib/env.js +2 -3
- package/lib/main.js +7 -3
- package/lib/makes/Logger.d.ts +1 -1
- package/lib/makes/Plugin.d.ts +0 -1
- package/lib/makes/Plugin.js +0 -1
- package/lib/makes/index.d.ts +0 -1
- package/lib/makes/index.js +0 -1
- package/lib/modules/app/index.d.ts +2 -0
- package/lib/modules/app/index.js +16 -0
- package/lib/modules/docker/index.d.ts +8 -0
- package/lib/modules/docker/index.js +41 -0
- package/lib/modules/docker/services/ContainerService.d.ts +14 -0
- package/lib/modules/docker/services/ContainerService.js +115 -0
- package/lib/{services → modules/docker/services}/DockerService.d.ts +12 -5
- package/lib/{services → modules/docker/services}/DockerService.js +27 -114
- package/lib/modules/docker/services/ImageService.d.ts +18 -0
- package/lib/modules/docker/services/ImageService.js +68 -0
- package/lib/modules/docker/services/ModemService.d.ts +14 -0
- package/lib/modules/docker/services/ModemService.js +137 -0
- package/lib/modules/docker/services/ProtoService.d.ts +6 -0
- package/lib/modules/docker/services/ProtoService.js +20 -0
- package/lib/modules/index.d.ts +3 -0
- package/lib/{keystore → modules}/index.js +3 -1
- package/lib/{controllers → modules/keystore/controllers}/KeystoreController.d.ts +2 -2
- package/lib/{controllers → modules/keystore/controllers}/KeystoreController.js +5 -5
- package/lib/modules/keystore/index.d.ts +4 -0
- package/lib/modules/keystore/index.js +29 -0
- package/lib/{keystore → modules/keystore}/providers/FileKeystoreProvider.d.ts +1 -1
- package/lib/{keystore → modules/keystore}/providers/FileKeystoreProvider.js +1 -1
- package/lib/{keystore → modules/keystore}/providers/KeytarKeystoreProvider.js +1 -1
- package/lib/{keystore → modules/keystore/services}/KeystoreService.d.ts +1 -1
- package/lib/{keystore → modules/keystore/services}/KeystoreService.js +3 -3
- package/lib/{controllers → modules/proxy/controllers}/CertController.d.ts +2 -1
- package/lib/{controllers → modules/proxy/controllers}/CertController.js +4 -3
- package/lib/{controllers → modules/proxy/controllers}/ProxyController.d.ts +4 -1
- package/lib/{controllers → modules/proxy/controllers}/ProxyController.js +9 -6
- package/lib/modules/proxy/index.d.ts +5 -0
- package/lib/modules/proxy/index.js +39 -0
- package/lib/{services → modules/proxy/services}/CertService.d.ts +3 -3
- package/lib/{services → modules/proxy/services}/CertService.js +9 -9
- package/lib/{services → modules/proxy/services}/ProxyService.d.ts +2 -2
- package/lib/{services → modules/proxy/services}/ProxyService.js +15 -7
- package/lib/services/AppConfigService.d.ts +2 -13
- package/lib/services/AppConfigService.js +17 -26
- package/lib/services/PluginService.js +6 -8
- package/lib/services/PresetService.js +2 -3
- package/lib/services/ProjectService.d.ts +4 -4
- package/lib/services/ProjectService.js +9 -10
- package/lib/utils/followProgress2.d.ts +1 -0
- package/lib/utils/followProgress2.js +63 -0
- package/lib/utils/index.d.ts +1 -2
- package/lib/utils/index.js +1 -2
- package/package.json +5 -6
- package/proto/buildkit.proto +55 -0
- package/proto/solver/pb/ops.proto +443 -0
- package/lib/keystore/index.d.ts +0 -1
- package/lib/keystore/types/Encryption.d.ts +0 -9
- package/lib/keystore/types/Encryption.js +0 -81
- package/lib/keystore/types/Encryptor.d.ts +0 -10
- package/lib/keystore/types/Encryptor.js +0 -59
- package/lib/makes/FS.d.ts +0 -27
- package/lib/makes/FS.js +0 -284
- package/lib/makes/LineConvertStream.d.ts +0 -11
- package/lib/makes/LineConvertStream.js +0 -42
- package/lib/plugins/MongodbPlugin.d.ts +0 -20
- package/lib/plugins/MongodbPlugin.js +0 -288
- package/lib/plugins/index.d.ts +0 -1
- package/lib/plugins/index.js +0 -17
- package/lib/services/index.d.ts +0 -10
- package/lib/services/index.js +0 -26
- package/lib/utils/followProgress.d.ts +0 -1
- package/lib/utils/followProgress.js +0 -73
- /package/lib/{utils/format-size-units.d.ts → modules/docker/utils/formatSizeUnits.d.ts} +0 -0
- /package/lib/{utils/format-size-units.js → modules/docker/utils/formatSizeUnits.js} +0 -0
- /package/lib/{keystore → modules/keystore}/providers/KeytarKeystoreProvider.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/types/FileKeystore.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/types/FileKeystore.js +0 -0
- /package/lib/{keystore → modules/keystore}/types/Keytar.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/types/Keytar.js +0 -0
- /package/lib/{keystore → modules/keystore}/utils/createEncryptionKey.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/utils/createEncryptionKey.js +0 -0
- /package/lib/{keystore → modules/keystore}/utils/createPasswordHash.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/utils/createPasswordHash.js +0 -0
- /package/lib/{keystore → modules/keystore}/utils/decrypt.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/utils/decrypt.js +0 -0
- /package/lib/{keystore → modules/keystore}/utils/encrypt.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/utils/encrypt.js +0 -0
- /package/lib/{keystore → modules/keystore}/utils/index.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/utils/index.js +0 -0
- /package/lib/{keystore → modules/keystore}/utils/verifyPasswordHash.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/utils/verifyPasswordHash.js +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.KeystoreService = exports.KeystoreModule = void 0;
|
|
10
|
+
const core_1 = require("@wocker/core");
|
|
11
|
+
const KeystoreController_1 = require("./controllers/KeystoreController");
|
|
12
|
+
const KeystoreService_1 = require("./services/KeystoreService");
|
|
13
|
+
Object.defineProperty(exports, "KeystoreService", { enumerable: true, get: function () { return KeystoreService_1.KeystoreService; } });
|
|
14
|
+
let KeystoreModule = class KeystoreModule {
|
|
15
|
+
};
|
|
16
|
+
exports.KeystoreModule = KeystoreModule;
|
|
17
|
+
exports.KeystoreModule = KeystoreModule = __decorate([
|
|
18
|
+
(0, core_1.Module)({
|
|
19
|
+
controllers: [
|
|
20
|
+
KeystoreController_1.KeystoreController
|
|
21
|
+
],
|
|
22
|
+
providers: [
|
|
23
|
+
KeystoreService_1.KeystoreService
|
|
24
|
+
],
|
|
25
|
+
exports: [
|
|
26
|
+
KeystoreService_1.KeystoreService
|
|
27
|
+
]
|
|
28
|
+
})
|
|
29
|
+
], KeystoreModule);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KeystoreProvider } from "@wocker/core";
|
|
2
|
-
import { AppConfigService } from "
|
|
2
|
+
import { AppConfigService } from "../../../services/AppConfigService";
|
|
3
3
|
import { FileKeystore } from "../types/FileKeystore";
|
|
4
4
|
export declare class FileKeystoreProvider extends KeystoreProvider {
|
|
5
5
|
protected readonly appConfigService: AppConfigService;
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.FileKeystoreProvider = void 0;
|
|
13
13
|
const core_1 = require("@wocker/core");
|
|
14
14
|
const utils_1 = require("@wocker/utils");
|
|
15
|
-
const AppConfigService_1 = require("
|
|
15
|
+
const AppConfigService_1 = require("../../../services/AppConfigService");
|
|
16
16
|
const FileKeystore_1 = require("../types/FileKeystore");
|
|
17
17
|
const utils_2 = require("../utils");
|
|
18
18
|
let FileKeystoreProvider = class FileKeystoreProvider extends core_1.KeystoreProvider {
|
|
@@ -41,7 +41,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.KeytarKeystoreProvider = void 0;
|
|
43
43
|
const core_1 = require("@wocker/core");
|
|
44
|
-
const env_1 = require("
|
|
44
|
+
const env_1 = require("../../../env");
|
|
45
45
|
let KeytarKeystoreProvider = class KeytarKeystoreProvider extends core_1.KeystoreProvider {
|
|
46
46
|
async get(key, defaultValue) {
|
|
47
47
|
const keytar = await this.getKeytar();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KeystoreService as CoreKeystoreService, KeystoreProvider } from "@wocker/core";
|
|
2
|
-
import { AppConfigService } from "
|
|
2
|
+
import { AppConfigService } from "../../../services/AppConfigService";
|
|
3
3
|
export declare class KeystoreService extends CoreKeystoreService {
|
|
4
4
|
protected readonly appConfigService: AppConfigService;
|
|
5
5
|
protected providers: Map<string, KeystoreProvider>;
|
|
@@ -11,9 +11,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.KeystoreService = void 0;
|
|
13
13
|
const core_1 = require("@wocker/core");
|
|
14
|
-
const AppConfigService_1 = require("
|
|
15
|
-
const KeytarKeystoreProvider_1 = require("
|
|
16
|
-
const FileKeystoreProvider_1 = require("
|
|
14
|
+
const AppConfigService_1 = require("../../../services/AppConfigService");
|
|
15
|
+
const KeytarKeystoreProvider_1 = require("./../providers/KeytarKeystoreProvider");
|
|
16
|
+
const FileKeystoreProvider_1 = require("./../providers/FileKeystoreProvider");
|
|
17
17
|
let KeystoreService = class KeystoreService extends core_1.KeystoreService {
|
|
18
18
|
constructor(appConfigService) {
|
|
19
19
|
super();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CertService } from "../services/CertService";
|
|
2
|
+
import { ProjectService } from "../../../services/ProjectService";
|
|
2
3
|
export declare class CertController {
|
|
3
4
|
protected readonly projectService: ProjectService;
|
|
4
5
|
protected readonly certService: CertService;
|
|
@@ -14,7 +14,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.CertController = void 0;
|
|
16
16
|
const core_1 = require("@wocker/core");
|
|
17
|
-
const
|
|
17
|
+
const CertService_1 = require("../services/CertService");
|
|
18
|
+
const ProjectService_1 = require("../../../services/ProjectService");
|
|
18
19
|
let CertController = class CertController {
|
|
19
20
|
constructor(projectService, certService) {
|
|
20
21
|
this.projectService = projectService;
|
|
@@ -108,6 +109,6 @@ __decorate([
|
|
|
108
109
|
], CertController.prototype, "existsOtherNames", null);
|
|
109
110
|
exports.CertController = CertController = __decorate([
|
|
110
111
|
(0, core_1.Controller)(),
|
|
111
|
-
__metadata("design:paramtypes", [
|
|
112
|
-
|
|
112
|
+
__metadata("design:paramtypes", [ProjectService_1.ProjectService,
|
|
113
|
+
CertService_1.CertService])
|
|
113
114
|
], CertController);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Project } from "@wocker/core";
|
|
2
|
-
import { AppConfigService
|
|
2
|
+
import { AppConfigService } from "../../../services/AppConfigService";
|
|
3
|
+
import { AppEventsService } from "../../../services/AppEventsService";
|
|
4
|
+
import { ProjectService } from "../../../services/ProjectService";
|
|
5
|
+
import { ProxyService } from "../services/ProxyService";
|
|
3
6
|
export declare class ProxyController {
|
|
4
7
|
protected readonly appConfigService: AppConfigService;
|
|
5
8
|
protected readonly appEventsService: AppEventsService;
|
|
@@ -19,7 +19,10 @@ exports.ProxyController = void 0;
|
|
|
19
19
|
const core_1 = require("@wocker/core");
|
|
20
20
|
const utils_1 = require("@wocker/utils");
|
|
21
21
|
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
22
|
-
const
|
|
22
|
+
const AppConfigService_1 = require("../../../services/AppConfigService");
|
|
23
|
+
const AppEventsService_1 = require("../../../services/AppEventsService");
|
|
24
|
+
const ProjectService_1 = require("../../../services/ProjectService");
|
|
25
|
+
const ProxyService_1 = require("../services/ProxyService");
|
|
23
26
|
let ProxyController = class ProxyController {
|
|
24
27
|
constructor(appConfigService, appEventsService, projectService, proxyService) {
|
|
25
28
|
this.appConfigService = appConfigService;
|
|
@@ -96,7 +99,7 @@ let ProxyController = class ProxyController {
|
|
|
96
99
|
config.unsetMeta("PROXY_SSH_PASSWORD");
|
|
97
100
|
config.unsetMeta("PROXY_SSH_PORT");
|
|
98
101
|
}
|
|
99
|
-
|
|
102
|
+
this.appConfigService.save();
|
|
100
103
|
}
|
|
101
104
|
async start(restart, rebuild) {
|
|
102
105
|
await this.proxyService.start(restart, rebuild);
|
|
@@ -173,8 +176,8 @@ __decorate([
|
|
|
173
176
|
exports.ProxyController = ProxyController = __decorate([
|
|
174
177
|
(0, core_1.Controller)(),
|
|
175
178
|
(0, core_1.Description)("Proxy commands"),
|
|
176
|
-
__metadata("design:paramtypes", [
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
__metadata("design:paramtypes", [AppConfigService_1.AppConfigService,
|
|
180
|
+
AppEventsService_1.AppEventsService,
|
|
181
|
+
ProjectService_1.ProjectService,
|
|
182
|
+
ProxyService_1.ProxyService])
|
|
180
183
|
], ProxyController);
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CertService = exports.ProxyService = exports.ProxyModule = void 0;
|
|
10
|
+
const core_1 = require("@wocker/core");
|
|
11
|
+
const docker_1 = require("../docker");
|
|
12
|
+
const CertController_1 = require("./controllers/CertController");
|
|
13
|
+
const ProxyController_1 = require("./controllers/ProxyController");
|
|
14
|
+
const CertService_1 = require("./services/CertService");
|
|
15
|
+
Object.defineProperty(exports, "CertService", { enumerable: true, get: function () { return CertService_1.CertService; } });
|
|
16
|
+
const ProxyService_1 = require("./services/ProxyService");
|
|
17
|
+
Object.defineProperty(exports, "ProxyService", { enumerable: true, get: function () { return ProxyService_1.ProxyService; } });
|
|
18
|
+
let ProxyModule = class ProxyModule {
|
|
19
|
+
};
|
|
20
|
+
exports.ProxyModule = ProxyModule;
|
|
21
|
+
exports.ProxyModule = ProxyModule = __decorate([
|
|
22
|
+
(0, core_1.Module)({
|
|
23
|
+
imports: [
|
|
24
|
+
docker_1.DockerModule
|
|
25
|
+
],
|
|
26
|
+
controllers: [
|
|
27
|
+
CertController_1.CertController,
|
|
28
|
+
ProxyController_1.ProxyController
|
|
29
|
+
],
|
|
30
|
+
providers: [
|
|
31
|
+
ProxyService_1.ProxyService,
|
|
32
|
+
CertService_1.CertService
|
|
33
|
+
],
|
|
34
|
+
exports: [
|
|
35
|
+
ProxyService_1.ProxyService,
|
|
36
|
+
CertService_1.CertService
|
|
37
|
+
]
|
|
38
|
+
})
|
|
39
|
+
], ProxyModule);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Project } from "@wocker/core";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { DockerService } from "../../docker";
|
|
3
|
+
import { AppConfigService } from "../../../services/AppConfigService";
|
|
4
4
|
import { ProxyService } from "./ProxyService";
|
|
5
5
|
type CertMap = {
|
|
6
6
|
[name: string]: string[];
|
|
@@ -12,7 +12,7 @@ export declare class CertService {
|
|
|
12
12
|
constructor(appConfigService: AppConfigService, proxyService: ProxyService, dockerService: DockerService);
|
|
13
13
|
list(): Promise<string>;
|
|
14
14
|
generate(certName: string, dns: string[]): Promise<void>;
|
|
15
|
-
getCertsMap():
|
|
15
|
+
getCertsMap(): CertMap;
|
|
16
16
|
use(project: Project, name: string): Promise<void>;
|
|
17
17
|
remove(project: Project): Promise<void>;
|
|
18
18
|
delete(name: string): Promise<void>;
|
|
@@ -49,8 +49,8 @@ exports.CertService = void 0;
|
|
|
49
49
|
const core_1 = require("@wocker/core");
|
|
50
50
|
const Path = __importStar(require("path"));
|
|
51
51
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
52
|
-
const
|
|
53
|
-
const
|
|
52
|
+
const docker_1 = require("../../docker");
|
|
53
|
+
const AppConfigService_1 = require("../../../services/AppConfigService");
|
|
54
54
|
const ProxyService_1 = require("./ProxyService");
|
|
55
55
|
let CertService = class CertService {
|
|
56
56
|
constructor(appConfigService, proxyService, dockerService) {
|
|
@@ -62,7 +62,7 @@ let CertService = class CertService {
|
|
|
62
62
|
const table = new cli_table3_1.default({
|
|
63
63
|
head: ["Name"]
|
|
64
64
|
});
|
|
65
|
-
const certMap =
|
|
65
|
+
const certMap = this.getCertsMap();
|
|
66
66
|
for (const name in certMap) {
|
|
67
67
|
table.push([name]);
|
|
68
68
|
}
|
|
@@ -93,7 +93,7 @@ let CertService = class CertService {
|
|
|
93
93
|
cmd: ["wocker-create-cert", certName]
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
getCertsMap() {
|
|
97
97
|
const files = this.appConfigService.fs.readdir("certs/projects");
|
|
98
98
|
return files.reduce((res, file) => {
|
|
99
99
|
const ext = Path.extname(file);
|
|
@@ -106,7 +106,7 @@ let CertService = class CertService {
|
|
|
106
106
|
}, {});
|
|
107
107
|
}
|
|
108
108
|
async use(project, name) {
|
|
109
|
-
const certs =
|
|
109
|
+
const certs = this.getCertsMap();
|
|
110
110
|
if (!name) {
|
|
111
111
|
name = project.domains.find((domain) => domain in certs);
|
|
112
112
|
}
|
|
@@ -121,17 +121,17 @@ let CertService = class CertService {
|
|
|
121
121
|
throw new Error(`${name}.key file missing`);
|
|
122
122
|
}
|
|
123
123
|
project.setEnv("CERT_NAME", name);
|
|
124
|
-
|
|
124
|
+
project.save();
|
|
125
125
|
}
|
|
126
126
|
async remove(project) {
|
|
127
127
|
if (!project.hasEnv("CERT_NAME")) {
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
project.unsetEnv("CERT_NAME");
|
|
131
|
-
|
|
131
|
+
project.save();
|
|
132
132
|
}
|
|
133
133
|
async delete(name) {
|
|
134
|
-
const certs =
|
|
134
|
+
const certs = this.getCertsMap();
|
|
135
135
|
if (!(name in certs)) {
|
|
136
136
|
console.warn(`Cert ${name} not found`);
|
|
137
137
|
return;
|
|
@@ -147,5 +147,5 @@ exports.CertService = CertService = __decorate([
|
|
|
147
147
|
(0, core_1.Injectable)(),
|
|
148
148
|
__metadata("design:paramtypes", [AppConfigService_1.AppConfigService,
|
|
149
149
|
ProxyService_1.ProxyService,
|
|
150
|
-
|
|
150
|
+
docker_1.DockerService])
|
|
151
151
|
], CertService);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Project, ProxyService as CoreProxyService } from "@wocker/core";
|
|
2
|
-
import { AppConfigService } from "
|
|
3
|
-
import { DockerService } from "
|
|
2
|
+
import { AppConfigService } from "../../../services/AppConfigService";
|
|
3
|
+
import { DockerService } from "../../docker";
|
|
4
4
|
export declare class ProxyService extends CoreProxyService {
|
|
5
5
|
protected readonly appConfigService: AppConfigService;
|
|
6
6
|
protected readonly dockerService: DockerService;
|
|
@@ -46,9 +46,9 @@ exports.ProxyService = void 0;
|
|
|
46
46
|
const core_1 = require("@wocker/core");
|
|
47
47
|
const utils_1 = require("@wocker/utils");
|
|
48
48
|
const Path = __importStar(require("path"));
|
|
49
|
-
const env_1 = require("
|
|
50
|
-
const AppConfigService_1 = require("
|
|
51
|
-
const
|
|
49
|
+
const env_1 = require("../../../env");
|
|
50
|
+
const AppConfigService_1 = require("../../../services/AppConfigService");
|
|
51
|
+
const docker_1 = require("../../docker");
|
|
52
52
|
let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
53
53
|
constructor(appConfigService, dockerService) {
|
|
54
54
|
super();
|
|
@@ -67,7 +67,7 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
67
67
|
default: parseInt(project.getEnv("VIRTUAL_PORT", "80"))
|
|
68
68
|
});
|
|
69
69
|
project.setEnv("VIRTUAL_PORT", appPort.toString());
|
|
70
|
-
|
|
70
|
+
project.save();
|
|
71
71
|
}
|
|
72
72
|
async start(restart, rebuild) {
|
|
73
73
|
if (restart || rebuild) {
|
|
@@ -77,6 +77,7 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
77
77
|
if (!container) {
|
|
78
78
|
console.info("Proxy starting...");
|
|
79
79
|
await this.build(rebuild);
|
|
80
|
+
const fs = this.appConfigService.fs;
|
|
80
81
|
if (!this.appConfigService.fs.exists("certs/ca")) {
|
|
81
82
|
this.appConfigService.fs.mkdir("certs/ca", {
|
|
82
83
|
recursive: true,
|
|
@@ -89,6 +90,12 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
89
90
|
mode: 0o700
|
|
90
91
|
});
|
|
91
92
|
}
|
|
93
|
+
if (!fs.exists("nginx/vhost.d")) {
|
|
94
|
+
fs.mkdir("nginx/vhost.d", {
|
|
95
|
+
recursive: true,
|
|
96
|
+
mode: 0o700
|
|
97
|
+
});
|
|
98
|
+
}
|
|
92
99
|
const config = this.appConfigService.config;
|
|
93
100
|
const httpPort = config.getMeta("PROXY_HTTP_PORT", "80");
|
|
94
101
|
const httpsPort = config.getMeta("PROXY_HTTPS_PORT", "443");
|
|
@@ -110,8 +117,9 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
110
117
|
],
|
|
111
118
|
volumes: [
|
|
112
119
|
"/var/run/docker.sock:/tmp/docker.sock:ro",
|
|
113
|
-
`${
|
|
114
|
-
`${
|
|
120
|
+
`${fs.path("certs/projects")}:/etc/nginx/certs`,
|
|
121
|
+
`${fs.path("certs/ca")}:/etc/nginx/ca-certs`,
|
|
122
|
+
`${fs.path("nginx/vhost.d")}:/etc/nginx/vhost.d`
|
|
115
123
|
],
|
|
116
124
|
network: "workspace"
|
|
117
125
|
});
|
|
@@ -155,5 +163,5 @@ exports.ProxyService = ProxyService;
|
|
|
155
163
|
exports.ProxyService = ProxyService = __decorate([
|
|
156
164
|
(0, core_1.Injectable)("PROXY_SERVICE"),
|
|
157
165
|
__metadata("design:paramtypes", [AppConfigService_1.AppConfigService,
|
|
158
|
-
|
|
166
|
+
docker_1.DockerService])
|
|
159
167
|
], ProxyService);
|
|
@@ -10,26 +10,15 @@ export declare class AppConfigService extends CoreAppConfigService {
|
|
|
10
10
|
constructor();
|
|
11
11
|
get version(): string;
|
|
12
12
|
get config(): AppConfig;
|
|
13
|
-
get projects():
|
|
14
|
-
id: string;
|
|
15
|
-
name?: string;
|
|
16
|
-
path?: string;
|
|
17
|
-
src?: string;
|
|
18
|
-
}[];
|
|
13
|
+
get projects(): import("@wocker/core/lib/types/ProjectRef").ProjectRef[];
|
|
19
14
|
get fs(): FileSystem;
|
|
20
15
|
pwd(...parts: string[]): string;
|
|
21
16
|
setPWD(pwd: string): void;
|
|
22
17
|
dataPath(...parts: string[]): string;
|
|
23
|
-
pluginsPath(...parts: string[]): string;
|
|
24
18
|
presetPath(...parts: string[]): string;
|
|
25
19
|
getProjectTypes(): TypeMap;
|
|
26
20
|
addProject(id: string, name: string, path: string): void;
|
|
27
|
-
removeProject(
|
|
28
|
-
id: string;
|
|
29
|
-
name?: string;
|
|
30
|
-
path?: string;
|
|
31
|
-
src?: string;
|
|
32
|
-
};
|
|
21
|
+
removeProject(name: string): void;
|
|
33
22
|
save(): void;
|
|
34
23
|
}
|
|
35
24
|
export {};
|
|
@@ -96,26 +96,7 @@ let AppConfigService = class AppConfigService extends core_1.AppConfigService {
|
|
|
96
96
|
recursive: true
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
-
this._config = new
|
|
100
|
-
constructor(data) {
|
|
101
|
-
super(data);
|
|
102
|
-
}
|
|
103
|
-
async save() {
|
|
104
|
-
if (!fs.exists()) {
|
|
105
|
-
fs.mkdir("", {
|
|
106
|
-
recursive: true
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
fs.writeFile("wocker.config.js", this.toJsString());
|
|
110
|
-
fs.writeFile("wocker.config.json", this.toString());
|
|
111
|
-
if (fs.exists("data.json")) {
|
|
112
|
-
fs.rm("data.json");
|
|
113
|
-
}
|
|
114
|
-
if (fs.exists("wocker.json")) {
|
|
115
|
-
fs.rm("wocker.json");
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}(data);
|
|
99
|
+
this._config = new core_1.AppConfig(data);
|
|
119
100
|
}
|
|
120
101
|
return this._config;
|
|
121
102
|
}
|
|
@@ -137,9 +118,6 @@ let AppConfigService = class AppConfigService extends core_1.AppConfigService {
|
|
|
137
118
|
dataPath(...parts) {
|
|
138
119
|
return Path.join(env_1.DATA_DIR, ...parts);
|
|
139
120
|
}
|
|
140
|
-
pluginsPath(...parts) {
|
|
141
|
-
return Path.join(env_1.PLUGINS_DIR, ...parts);
|
|
142
|
-
}
|
|
143
121
|
presetPath(...parts) {
|
|
144
122
|
return Path.join(env_1.PRESETS_DIR, ...parts);
|
|
145
123
|
}
|
|
@@ -149,11 +127,24 @@ let AppConfigService = class AppConfigService extends core_1.AppConfigService {
|
|
|
149
127
|
addProject(id, name, path) {
|
|
150
128
|
this.config.addProject(id, name, path);
|
|
151
129
|
}
|
|
152
|
-
removeProject(
|
|
153
|
-
return this.config.
|
|
130
|
+
removeProject(name) {
|
|
131
|
+
return this.config.removeProject(name);
|
|
154
132
|
}
|
|
155
133
|
save() {
|
|
156
|
-
this.
|
|
134
|
+
const fs = this.fs;
|
|
135
|
+
if (!fs.exists()) {
|
|
136
|
+
fs.mkdir("", {
|
|
137
|
+
recursive: true
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
fs.writeFile("wocker.config.js", this.config.toJsString());
|
|
141
|
+
fs.writeFile("wocker.config.json", this.config.toString());
|
|
142
|
+
if (fs.exists("data.json")) {
|
|
143
|
+
fs.rm("data.json");
|
|
144
|
+
}
|
|
145
|
+
if (fs.exists("wocker.json")) {
|
|
146
|
+
fs.rm("wocker.json");
|
|
147
|
+
}
|
|
157
148
|
}
|
|
158
149
|
};
|
|
159
150
|
exports.AppConfigService = AppConfigService;
|
|
@@ -90,11 +90,10 @@ let PluginService = class PluginService {
|
|
|
90
90
|
async install(pluginName, beta) {
|
|
91
91
|
const [, prefix = "@wocker/", name, suffix = "-plugin"] = /^(@wocker\/)?(\w+)(-plugin)?$/.exec(pluginName) || [];
|
|
92
92
|
const fullName = `${prefix}${name}${suffix}`;
|
|
93
|
-
const config = this.appConfigService.config;
|
|
94
93
|
try {
|
|
95
94
|
if (await this.checkPlugin(fullName)) {
|
|
96
|
-
config.addPlugin(fullName);
|
|
97
|
-
|
|
95
|
+
this.appConfigService.config.addPlugin(fullName);
|
|
96
|
+
this.appConfigService.save();
|
|
98
97
|
console.info(`Plugin ${fullName} activated`);
|
|
99
98
|
return;
|
|
100
99
|
}
|
|
@@ -102,8 +101,8 @@ let PluginService = class PluginService {
|
|
|
102
101
|
const env = packageInfo["dist-tags"].beta && beta ? "beta" : "latest";
|
|
103
102
|
await this.npmService.install(fullName, env);
|
|
104
103
|
if (await this.checkPlugin(fullName)) {
|
|
105
|
-
config.addPlugin(fullName, env);
|
|
106
|
-
|
|
104
|
+
this.appConfigService.config.addPlugin(fullName, env);
|
|
105
|
+
this.appConfigService.save();
|
|
107
106
|
console.info(`Plugin ${fullName}@${env} activated`);
|
|
108
107
|
return;
|
|
109
108
|
}
|
|
@@ -115,9 +114,8 @@ let PluginService = class PluginService {
|
|
|
115
114
|
async uninstall(pluginName) {
|
|
116
115
|
const [, prefix = "@wocker/", name, suffix = "-plugin"] = /^(@wocker\/)?(\w+)(-plugin)?$/.exec(pluginName) || [];
|
|
117
116
|
const fullName = `${prefix}${name}${suffix}`;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
await config.save();
|
|
117
|
+
this.appConfigService.config.removePlugin(fullName);
|
|
118
|
+
this.appConfigService.save();
|
|
121
119
|
console.info(`Plugin ${fullName} deactivated`);
|
|
122
120
|
}
|
|
123
121
|
async import(name) {
|
|
@@ -205,9 +205,8 @@ let PresetService = class PresetService {
|
|
|
205
205
|
if (!preset) {
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
config.save();
|
|
208
|
+
this.appConfigService.config.unregisterPreset(preset.name);
|
|
209
|
+
this.appConfigService.save();
|
|
211
210
|
}
|
|
212
211
|
get(name) {
|
|
213
212
|
const preset = name
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Project, ProjectProperties } from "@wocker/core";
|
|
2
|
-
import {
|
|
2
|
+
import { DockerService } from "../modules/docker";
|
|
3
|
+
import { KeystoreService } from "../modules/keystore";
|
|
3
4
|
import { AppConfigService } from "./AppConfigService";
|
|
4
5
|
import { AppEventsService } from "./AppEventsService";
|
|
5
|
-
import { DockerService } from "./DockerService";
|
|
6
6
|
type SearchParams = Partial<{
|
|
7
7
|
name: string;
|
|
8
8
|
path: string;
|
|
9
9
|
}>;
|
|
10
|
-
declare class ProjectService {
|
|
10
|
+
export declare class ProjectService {
|
|
11
11
|
protected readonly appConfigService: AppConfigService;
|
|
12
12
|
protected readonly appEventsService: AppEventsService;
|
|
13
13
|
protected readonly keystoreService: KeystoreService;
|
|
@@ -24,4 +24,4 @@ declare class ProjectService {
|
|
|
24
24
|
searchOne(params?: Partial<SearchParams>): Project | null;
|
|
25
25
|
logs(detach?: boolean): Promise<void>;
|
|
26
26
|
}
|
|
27
|
-
export {
|
|
27
|
+
export {};
|
|
@@ -11,10 +11,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ProjectService = void 0;
|
|
13
13
|
const core_1 = require("@wocker/core");
|
|
14
|
-
const
|
|
14
|
+
const docker_1 = require("../modules/docker");
|
|
15
|
+
const keystore_1 = require("../modules/keystore");
|
|
15
16
|
const AppConfigService_1 = require("./AppConfigService");
|
|
16
17
|
const AppEventsService_1 = require("./AppEventsService");
|
|
17
|
-
const DockerService_1 = require("./DockerService");
|
|
18
18
|
let ProjectService = class ProjectService {
|
|
19
19
|
constructor(appConfigService, appEventsService, keystoreService, dockerService) {
|
|
20
20
|
this.appConfigService = appConfigService;
|
|
@@ -54,12 +54,11 @@ let ProjectService = class ProjectService {
|
|
|
54
54
|
return project;
|
|
55
55
|
}
|
|
56
56
|
getById(id) {
|
|
57
|
-
const
|
|
58
|
-
const projectData = config.getProject(id);
|
|
57
|
+
const projectData = this.appConfigService.config.getProject(id);
|
|
59
58
|
const data = this.appConfigService.fs.readJSON("projects", id, "config.json");
|
|
60
59
|
return this.fromObject({
|
|
61
60
|
...data,
|
|
62
|
-
path: projectData.path
|
|
61
|
+
path: projectData.path
|
|
63
62
|
});
|
|
64
63
|
}
|
|
65
64
|
cdProject(name) {
|
|
@@ -159,14 +158,14 @@ let ProjectService = class ProjectService {
|
|
|
159
158
|
search(params = {}) {
|
|
160
159
|
const { name, path } = params;
|
|
161
160
|
const projects = [];
|
|
162
|
-
for (const
|
|
163
|
-
if (name &&
|
|
161
|
+
for (const projectRef of this.appConfigService.projects || []) {
|
|
162
|
+
if (name && projectRef.name !== name) {
|
|
164
163
|
continue;
|
|
165
164
|
}
|
|
166
|
-
if (path &&
|
|
165
|
+
if (path && projectRef.path !== path) {
|
|
167
166
|
continue;
|
|
168
167
|
}
|
|
169
|
-
const project = this.getById(
|
|
168
|
+
const project = this.getById(projectRef.name);
|
|
170
169
|
if (name && project.name !== name) {
|
|
171
170
|
continue;
|
|
172
171
|
}
|
|
@@ -203,5 +202,5 @@ exports.ProjectService = ProjectService = __decorate([
|
|
|
203
202
|
__metadata("design:paramtypes", [AppConfigService_1.AppConfigService,
|
|
204
203
|
AppEventsService_1.AppEventsService,
|
|
205
204
|
keystore_1.KeystoreService,
|
|
206
|
-
|
|
205
|
+
docker_1.DockerService])
|
|
207
206
|
], ProjectService);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const followProgress2: (stream: NodeJS.ReadableStream) => Promise<void>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.followProgress2 = void 0;
|
|
7
|
+
const protobufjs_1 = __importDefault(require("protobufjs"));
|
|
8
|
+
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
9
|
+
const env_1 = require("../env");
|
|
10
|
+
const followProgress2 = async (stream) => {
|
|
11
|
+
const root = await protobufjs_1.default.load([
|
|
12
|
+
`${env_1.ROOT_DIR}/proto/solver/pb/ops.proto`,
|
|
13
|
+
`${env_1.ROOT_DIR}/proto/buildkit.proto`
|
|
14
|
+
]);
|
|
15
|
+
const StatusResponse = root.lookupType("moby.buildkit.v1.StatusResponse");
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
let isEnded = false;
|
|
18
|
+
let success = 0, error = 0;
|
|
19
|
+
const handleEnd = () => {
|
|
20
|
+
if (!isEnded) {
|
|
21
|
+
isEnded = true;
|
|
22
|
+
console.log(`success: ${success} errors: ${error}`);
|
|
23
|
+
resolve();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
stream.on("data", (data) => {
|
|
28
|
+
const content = data.toString().replace(/}\s*\{/g, '},{'), items = JSON.parse(`[${content}]`);
|
|
29
|
+
for (const item of items) {
|
|
30
|
+
switch (item.id) {
|
|
31
|
+
case "moby.buildkit.trace": {
|
|
32
|
+
if (!item.aux) {
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
let buffer = Buffer.from(item.aux, "base64");
|
|
36
|
+
try {
|
|
37
|
+
const decoded = StatusResponse.decode(buffer);
|
|
38
|
+
const obj = StatusResponse.toObject(decoded, {
|
|
39
|
+
enums: String,
|
|
40
|
+
longs: String,
|
|
41
|
+
bytes: String,
|
|
42
|
+
defaults: true,
|
|
43
|
+
});
|
|
44
|
+
console.dir(obj, { depth: null });
|
|
45
|
+
success++;
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
error++;
|
|
49
|
+
console.error(yoctocolors_cjs_1.default.red(`Error: ${err.message}`));
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
default:
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
stream.on("end", handleEnd);
|
|
59
|
+
stream.on("close", handleEnd);
|
|
60
|
+
stream.on("error", reject);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
exports.followProgress2 = followProgress2;
|