@wocker/ws 1.0.24 → 1.0.25
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/{RootModule.d.ts → AppModule.d.ts} +1 -1
- package/lib/{RootModule.js → AppModule.js} +9 -22
- package/lib/controllers/ProjectController.d.ts +0 -1
- package/lib/controllers/ProjectController.js +0 -16
- package/lib/env.d.ts +1 -1
- package/lib/env.js +3 -3
- package/lib/main.js +2 -2
- package/lib/modules/core/index.d.ts +2 -0
- package/lib/modules/{app → core}/index.js +19 -6
- package/lib/modules/docker/index.d.ts +2 -1
- package/lib/modules/docker/index.js +5 -1
- package/lib/modules/docker/services/ComposeService.d.ts +32 -0
- package/lib/modules/docker/services/ComposeService.js +129 -0
- package/lib/modules/docker/services/DockerService.js +2 -24
- package/lib/modules/docker/services/ImageService.d.ts +2 -8
- package/lib/modules/docker/services/ImageService.js +15 -3
- package/lib/modules/docker/services/ModemService.d.ts +3 -2
- package/lib/modules/docker/services/ModemService.js +24 -5
- package/lib/modules/docker/services/ProtoService.js +2 -2
- package/lib/modules/docker/type/ComposeConfig.d.ts +12 -0
- package/lib/modules/docker/type/ComposeConfig.js +2 -0
- package/lib/modules/index.d.ts +1 -1
- package/lib/modules/index.js +1 -1
- package/lib/modules/keystore/services/KeystoreService.d.ts +2 -3
- package/lib/modules/keystore/services/KeystoreService.js +2 -4
- package/lib/modules/preset/controllers/PresetController.js +2 -1
- package/lib/modules/preset/controllers/PresetListener.d.ts +3 -2
- package/lib/modules/preset/controllers/PresetListener.js +6 -3
- package/lib/modules/preset/services/PresetService.js +11 -2
- package/lib/modules/project/controllers/ProjectController.d.ts +1 -0
- package/lib/modules/project/controllers/ProjectController.js +16 -0
- package/lib/modules/project/services/ProjectService.d.ts +8 -4
- package/lib/modules/project/services/ProjectService.js +50 -8
- package/lib/modules/proxy/services/ProxyService.js +4 -3
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -1
- package/package.json +4 -3
- package/lib/modules/app/index.d.ts +0 -2
- package/lib/utils/followProgress2.d.ts +0 -1
- package/lib/utils/followProgress2.js +0 -63
- package/plugins/proxmox/Dockerfile +0 -35
- package/plugins/proxy/Dockerfile +0 -25
- package/plugins/proxy/Procfile +0 -2
- package/plugins/proxy/bin/wocker-create-ca +0 -19
- package/plugins/proxy/bin/wocker-create-cert +0 -38
- package/plugins/proxy/bin/wocker-create-domains +0 -21
- package/presets/shopify/Dockerfile +0 -160
- package/presets/shopify/bin/compare-version +0 -3
- package/presets/shopify/config.json +0 -26
- package/presets/shopify/etc/apache2/apache2.conf +0 -230
- package/presets/shopify/etc/apache2/mods-available/mpm_prefork.conf +0 -16
- package/presets/shopify/etc/apache2/sites-available/000-default.conf +0 -21
- package/proto/buildkit.proto +0 -55
- package/proto/solver/pb/ops.proto +0 -443
|
@@ -5,17 +5,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
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
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
-
var
|
|
8
|
+
var AppModule_1;
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.AppModule = void 0;
|
|
11
11
|
const core_1 = require("@wocker/core");
|
|
12
12
|
const controllers_1 = require("./controllers");
|
|
13
13
|
const PluginService_1 = require("./services/PluginService");
|
|
14
14
|
const NpmService_1 = require("./services/NpmService");
|
|
15
15
|
const modules_1 = require("./modules");
|
|
16
|
-
let
|
|
16
|
+
let AppModule = AppModule_1 = class AppModule {
|
|
17
17
|
async load(container) {
|
|
18
|
-
const appModule = container.getModule(
|
|
18
|
+
const appModule = container.getModule(AppModule_1), fs = appModule.get(core_1.AppFileSystemService), appConfigService = appModule.get(core_1.AppConfigService), logService = appModule.get(core_1.LogService), pluginService = appModule.get(PluginService_1.PluginService);
|
|
19
19
|
const imports = [];
|
|
20
20
|
for (const pluginData of appConfigService.plugins || []) {
|
|
21
21
|
try {
|
|
@@ -41,12 +41,12 @@ let RootModule = RootModule_1 = class RootModule {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
exports.
|
|
45
|
-
exports.
|
|
44
|
+
exports.AppModule = AppModule;
|
|
45
|
+
exports.AppModule = AppModule = AppModule_1 = __decorate([
|
|
46
46
|
(0, core_1.Global)(),
|
|
47
47
|
(0, core_1.Module)({
|
|
48
48
|
imports: [
|
|
49
|
-
modules_1.
|
|
49
|
+
modules_1.CoreModule,
|
|
50
50
|
modules_1.ProjectModule,
|
|
51
51
|
modules_1.PresetModule,
|
|
52
52
|
modules_1.DockerModule,
|
|
@@ -61,23 +61,10 @@ exports.RootModule = RootModule = RootModule_1 = __decorate([
|
|
|
61
61
|
controllers_1.DebugController
|
|
62
62
|
],
|
|
63
63
|
providers: [
|
|
64
|
-
core_1.AppService,
|
|
65
|
-
core_1.AppFileSystemService,
|
|
66
|
-
core_1.AppConfigService,
|
|
67
|
-
core_1.EventService,
|
|
68
|
-
core_1.LogService,
|
|
69
64
|
NpmService_1.NpmService,
|
|
70
|
-
PluginService_1.PluginService
|
|
71
|
-
core_1.ProcessService
|
|
65
|
+
PluginService_1.PluginService
|
|
72
66
|
],
|
|
73
67
|
exports: [
|
|
74
|
-
core_1.WOCKER_VERSION_KEY,
|
|
75
|
-
core_1.WOCKER_DATA_DIR_KEY,
|
|
76
|
-
core_1.AppService,
|
|
77
|
-
core_1.AppFileSystemService,
|
|
78
|
-
core_1.AppConfigService,
|
|
79
|
-
core_1.EventService,
|
|
80
|
-
core_1.LogService,
|
|
81
68
|
modules_1.DockerService,
|
|
82
69
|
modules_1.CertService,
|
|
83
70
|
modules_1.ContainerService,
|
|
@@ -90,4 +77,4 @@ exports.RootModule = RootModule = RootModule_1 = __decorate([
|
|
|
90
77
|
core_1.ProcessService
|
|
91
78
|
]
|
|
92
79
|
})
|
|
93
|
-
],
|
|
80
|
+
], AppModule);
|
|
@@ -39,7 +39,6 @@ export declare class ProjectController {
|
|
|
39
39
|
addExtraHost(extraHost: string, extraDomain: string, name?: string): Promise<void>;
|
|
40
40
|
removeExtraHost(extraHost: string, name?: string): Promise<void>;
|
|
41
41
|
attach(name?: string): Promise<void>;
|
|
42
|
-
exec(command?: string[], name?: string): Promise<void>;
|
|
43
42
|
run(script: string, args?: string[], name?: string): Promise<void>;
|
|
44
43
|
logs(name?: string, global?: boolean, detach?: boolean, follow?: boolean, clear?: boolean): Promise<void>;
|
|
45
44
|
}
|
|
@@ -464,10 +464,6 @@ let ProjectController = class ProjectController {
|
|
|
464
464
|
const project = this.projectService.get(name);
|
|
465
465
|
await this.dockerService.attach(project.containerName);
|
|
466
466
|
}
|
|
467
|
-
async exec(command, name) {
|
|
468
|
-
const project = this.projectService.get(name);
|
|
469
|
-
await this.dockerService.exec(project.containerName, command, true);
|
|
470
|
-
}
|
|
471
467
|
async run(script, args, name) {
|
|
472
468
|
const project = this.projectService.get(name);
|
|
473
469
|
if (!project.scripts || !project.scripts[script]) {
|
|
@@ -909,18 +905,6 @@ __decorate([
|
|
|
909
905
|
__metadata("design:paramtypes", [String]),
|
|
910
906
|
__metadata("design:returntype", Promise)
|
|
911
907
|
], ProjectController.prototype, "attach", null);
|
|
912
|
-
__decorate([
|
|
913
|
-
(0, core_1.Command)("exec [...command]"),
|
|
914
|
-
__param(0, (0, core_1.Param)("command")),
|
|
915
|
-
__param(1, (0, core_1.Option)("name", {
|
|
916
|
-
type: "string",
|
|
917
|
-
alias: "n",
|
|
918
|
-
description: "The name of the project"
|
|
919
|
-
})),
|
|
920
|
-
__metadata("design:type", Function),
|
|
921
|
-
__metadata("design:paramtypes", [Array, String]),
|
|
922
|
-
__metadata("design:returntype", Promise)
|
|
923
|
-
], ProjectController.prototype, "exec", null);
|
|
924
908
|
__decorate([
|
|
925
909
|
(0, core_1.Command)("run <script> [...args]"),
|
|
926
910
|
__param(0, (0, core_1.Param)("script")),
|
package/lib/env.d.ts
CHANGED
package/lib/env.js
CHANGED
|
@@ -36,11 +36,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.KEYTAR_SERVICE = exports.VIRTUAL_HOST_KEY = exports.WOCKER_DATA_DIR = exports.PLUGINS_DIR = exports.PRESETS_DIR = exports.ROOT_DIR = exports.NODE_ENV = exports.WOCKER_VERSION = void 0;
|
|
37
37
|
const OS = __importStar(require("os"));
|
|
38
38
|
const Path = __importStar(require("path"));
|
|
39
|
-
exports.WOCKER_VERSION = "1.0.
|
|
39
|
+
exports.WOCKER_VERSION = "1.0.25";
|
|
40
40
|
exports.NODE_ENV = process.env.NODE_ENV;
|
|
41
41
|
exports.ROOT_DIR = Path.join(__dirname, "..");
|
|
42
|
-
exports.PRESETS_DIR = Path.join(exports.ROOT_DIR, "presets");
|
|
43
|
-
exports.PLUGINS_DIR = Path.join(exports.ROOT_DIR, "plugins");
|
|
42
|
+
exports.PRESETS_DIR = Path.join(exports.ROOT_DIR, "fixtures/presets");
|
|
43
|
+
exports.PLUGINS_DIR = Path.join(exports.ROOT_DIR, "fixtures/plugins");
|
|
44
44
|
exports.WOCKER_DATA_DIR = process.env.WS_DIR || Path.join(OS.homedir(), ".workspace");
|
|
45
45
|
exports.VIRTUAL_HOST_KEY = "VIRTUAL_HOST";
|
|
46
46
|
exports.KEYTAR_SERVICE = process.env.WOCKER_KEYTAR_SERVICE || "wocker";
|
package/lib/main.js
CHANGED
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.app = void 0;
|
|
7
7
|
const core_1 = require("@wocker/core");
|
|
8
8
|
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
9
|
-
const
|
|
9
|
+
const AppModule_1 = require("./AppModule");
|
|
10
10
|
exports.app = {
|
|
11
11
|
async run(args) {
|
|
12
|
-
const context = await core_1.Factory.create(
|
|
12
|
+
const context = await core_1.Factory.create(AppModule_1.AppModule), appConfigService = context.get(core_1.AppConfigService), logService = context.get(core_1.LogService);
|
|
13
13
|
try {
|
|
14
14
|
const res = await context.run(args);
|
|
15
15
|
if (res) {
|
|
@@ -6,13 +6,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.CoreModule = void 0;
|
|
10
10
|
const core_1 = require("@wocker/core");
|
|
11
11
|
const env_1 = require("../../env");
|
|
12
|
-
let
|
|
12
|
+
let CoreModule = class CoreModule {
|
|
13
13
|
};
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
14
|
+
exports.CoreModule = CoreModule;
|
|
15
|
+
exports.CoreModule = CoreModule = __decorate([
|
|
16
|
+
(0, core_1.Global)(),
|
|
16
17
|
(0, core_1.Module)({
|
|
17
18
|
providers: [
|
|
18
19
|
{
|
|
@@ -22,11 +23,23 @@ exports.AppModule = AppModule = __decorate([
|
|
|
22
23
|
{
|
|
23
24
|
provide: core_1.WOCKER_DATA_DIR_KEY,
|
|
24
25
|
useValue: env_1.WOCKER_DATA_DIR
|
|
25
|
-
}
|
|
26
|
+
},
|
|
27
|
+
core_1.AppService,
|
|
28
|
+
core_1.AppConfigService,
|
|
29
|
+
core_1.AppFileSystemService,
|
|
30
|
+
core_1.EventService,
|
|
31
|
+
core_1.LogService,
|
|
32
|
+
core_1.ProcessService
|
|
26
33
|
],
|
|
27
34
|
exports: [
|
|
35
|
+
core_1.AppService,
|
|
36
|
+
core_1.AppConfigService,
|
|
37
|
+
core_1.AppFileSystemService,
|
|
38
|
+
core_1.EventService,
|
|
39
|
+
core_1.LogService,
|
|
40
|
+
core_1.ProcessService,
|
|
28
41
|
core_1.WOCKER_VERSION_KEY,
|
|
29
42
|
core_1.WOCKER_DATA_DIR_KEY
|
|
30
43
|
]
|
|
31
44
|
})
|
|
32
|
-
],
|
|
45
|
+
], CoreModule);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ComposeService } from "./services/ComposeService";
|
|
1
2
|
import { ContainerService } from "./services/ContainerService";
|
|
2
3
|
import { DockerService } from "./services/DockerService";
|
|
3
4
|
import { ImageService } from "./services/ImageService";
|
|
@@ -5,4 +6,4 @@ import { ModemService } from "./services/ModemService";
|
|
|
5
6
|
import { ProtoService } from "./services/ProtoService";
|
|
6
7
|
export declare class DockerModule {
|
|
7
8
|
}
|
|
8
|
-
export { ContainerService, DockerService, ImageService, ModemService, ProtoService };
|
|
9
|
+
export { ComposeService, ContainerService, DockerService, ImageService, ModemService, ProtoService };
|
|
@@ -6,8 +6,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ProtoService = exports.ModemService = exports.ImageService = exports.DockerService = exports.ContainerService = exports.DockerModule = void 0;
|
|
9
|
+
exports.ProtoService = exports.ModemService = exports.ImageService = exports.DockerService = exports.ContainerService = exports.ComposeService = exports.DockerModule = void 0;
|
|
10
10
|
const core_1 = require("@wocker/core");
|
|
11
|
+
const ComposeService_1 = require("./services/ComposeService");
|
|
12
|
+
Object.defineProperty(exports, "ComposeService", { enumerable: true, get: function () { return ComposeService_1.ComposeService; } });
|
|
11
13
|
const ContainerService_1 = require("./services/ContainerService");
|
|
12
14
|
Object.defineProperty(exports, "ContainerService", { enumerable: true, get: function () { return ContainerService_1.ContainerService; } });
|
|
13
15
|
const DockerService_1 = require("./services/DockerService");
|
|
@@ -24,6 +26,7 @@ exports.DockerModule = DockerModule;
|
|
|
24
26
|
exports.DockerModule = DockerModule = __decorate([
|
|
25
27
|
(0, core_1.Module)({
|
|
26
28
|
providers: [
|
|
29
|
+
ComposeService_1.ComposeService,
|
|
27
30
|
ContainerService_1.ContainerService,
|
|
28
31
|
DockerService_1.DockerService,
|
|
29
32
|
ImageService_1.ImageService,
|
|
@@ -31,6 +34,7 @@ exports.DockerModule = DockerModule = __decorate([
|
|
|
31
34
|
ProtoService_1.ProtoService
|
|
32
35
|
],
|
|
33
36
|
exports: [
|
|
37
|
+
ComposeService_1.ComposeService,
|
|
34
38
|
ContainerService_1.ContainerService,
|
|
35
39
|
DockerService_1.DockerService,
|
|
36
40
|
ImageService_1.ImageService,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LogService } from "@wocker/core";
|
|
2
|
+
import { ComposeConfig } from "../type/ComposeConfig";
|
|
3
|
+
type UpOptions = {
|
|
4
|
+
composefile: string;
|
|
5
|
+
context: string;
|
|
6
|
+
};
|
|
7
|
+
type DownOptions = {
|
|
8
|
+
composefile: string;
|
|
9
|
+
context: string;
|
|
10
|
+
};
|
|
11
|
+
type BuildOptions = {
|
|
12
|
+
composefile: string;
|
|
13
|
+
context: string;
|
|
14
|
+
};
|
|
15
|
+
type ExecOptions = {
|
|
16
|
+
service: string;
|
|
17
|
+
args: string[];
|
|
18
|
+
composefile: string;
|
|
19
|
+
context: string;
|
|
20
|
+
};
|
|
21
|
+
export declare class ComposeService {
|
|
22
|
+
protected readonly logService: LogService;
|
|
23
|
+
constructor(logService: LogService);
|
|
24
|
+
up(options: UpOptions): Promise<void>;
|
|
25
|
+
down(options: DownOptions): Promise<void>;
|
|
26
|
+
build(options: BuildOptions): Promise<void>;
|
|
27
|
+
exec(options: ExecOptions): Promise<void>;
|
|
28
|
+
protected getConfig(context: string, composefile: string): ComposeConfig;
|
|
29
|
+
protected getConfigAsString(context: string, composefile: string): string;
|
|
30
|
+
protected processChunk(chunk: Buffer<ArrayBuffer>, streamSource?: "stdout" | "stderr"): void;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.ComposeService = void 0;
|
|
49
|
+
const core_1 = require("@wocker/core");
|
|
50
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
51
|
+
const compose = __importStar(require("docker-compose"));
|
|
52
|
+
let ComposeService = class ComposeService {
|
|
53
|
+
constructor(logService) {
|
|
54
|
+
this.logService = logService;
|
|
55
|
+
}
|
|
56
|
+
async up(options) {
|
|
57
|
+
const { context, composefile } = options;
|
|
58
|
+
const res = await compose.upAll({
|
|
59
|
+
cwd: context,
|
|
60
|
+
configAsString: this.getConfigAsString(context, composefile),
|
|
61
|
+
callback: (chunk, streamSource) => this.processChunk(chunk, streamSource)
|
|
62
|
+
});
|
|
63
|
+
this.logService.debug("compose up", res);
|
|
64
|
+
}
|
|
65
|
+
async down(options) {
|
|
66
|
+
const { context, composefile } = options;
|
|
67
|
+
const res = await compose.downAll({
|
|
68
|
+
cwd: context,
|
|
69
|
+
configAsString: this.getConfigAsString(context, composefile),
|
|
70
|
+
callback: (chunk, streamSource) => this.processChunk(chunk, streamSource)
|
|
71
|
+
});
|
|
72
|
+
this.logService.debug("compose down", res);
|
|
73
|
+
}
|
|
74
|
+
async build(options) {
|
|
75
|
+
const { context, composefile } = options;
|
|
76
|
+
const res = await compose.buildAll({
|
|
77
|
+
cwd: context,
|
|
78
|
+
config: composefile,
|
|
79
|
+
callback: (chunk, streamSource) => this.processChunk(chunk, streamSource)
|
|
80
|
+
});
|
|
81
|
+
this.logService.debug("build", res);
|
|
82
|
+
}
|
|
83
|
+
async exec(options) {
|
|
84
|
+
const { service, args, context, composefile } = options;
|
|
85
|
+
const config = this.getConfig(context, composefile);
|
|
86
|
+
console.log(config);
|
|
87
|
+
await compose.exec(service, args, {
|
|
88
|
+
configAsString: this.getConfigAsString(context, composefile),
|
|
89
|
+
callback: (chunk, streamSource) => this.processChunk(chunk, streamSource)
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
getConfig(context, composefile) {
|
|
93
|
+
const fs = new core_1.FileSystem(context), config = fs.readYAML(composefile);
|
|
94
|
+
if (!config.networks) {
|
|
95
|
+
config.networks = {};
|
|
96
|
+
}
|
|
97
|
+
config.networks.workspace = {
|
|
98
|
+
external: true
|
|
99
|
+
};
|
|
100
|
+
for (const name in config.services) {
|
|
101
|
+
if (!config.services[name].networks) {
|
|
102
|
+
config.services[name].networks = [];
|
|
103
|
+
}
|
|
104
|
+
if (!config.services[name].networks.includes("workspace")) {
|
|
105
|
+
config.services[name].networks.push("workspace");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return config;
|
|
109
|
+
}
|
|
110
|
+
getConfigAsString(context, composefile) {
|
|
111
|
+
const config = this.getConfig(context, composefile);
|
|
112
|
+
return yaml_1.default.stringify(config);
|
|
113
|
+
}
|
|
114
|
+
processChunk(chunk, streamSource) {
|
|
115
|
+
switch (streamSource) {
|
|
116
|
+
case "stdout":
|
|
117
|
+
process.stdout.write(chunk);
|
|
118
|
+
break;
|
|
119
|
+
case "stderr":
|
|
120
|
+
process.stderr.write(chunk);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
exports.ComposeService = ComposeService;
|
|
126
|
+
exports.ComposeService = ComposeService = __decorate([
|
|
127
|
+
(0, core_1.Injectable)("DOCKER_COMPOSE_SERVICE"),
|
|
128
|
+
__metadata("design:paramtypes", [core_1.LogService])
|
|
129
|
+
], ComposeService);
|
|
@@ -126,7 +126,7 @@ let DockerService = class DockerService extends core_1.DockerService {
|
|
|
126
126
|
},
|
|
127
127
|
NetworkingConfig: {
|
|
128
128
|
EndpointsConfig: networkMode === "host" ? {} : {
|
|
129
|
-
|
|
129
|
+
[networkName]: {
|
|
130
130
|
Links: links,
|
|
131
131
|
Aliases: aliases || (env.VIRTUAL_HOST ? env.VIRTUAL_HOST.split(",") : undefined)
|
|
132
132
|
}
|
|
@@ -141,29 +141,7 @@ let DockerService = class DockerService extends core_1.DockerService {
|
|
|
141
141
|
await this.containerService.rm(name);
|
|
142
142
|
}
|
|
143
143
|
async buildImage(params) {
|
|
144
|
-
|
|
145
|
-
const fs = new core_1.FileSystem(context);
|
|
146
|
-
const files = await fs.readdirFiles("", {
|
|
147
|
-
recursive: true
|
|
148
|
-
});
|
|
149
|
-
const stream = await this.docker.buildImage({
|
|
150
|
-
context,
|
|
151
|
-
src: files
|
|
152
|
-
}, {
|
|
153
|
-
t: tag,
|
|
154
|
-
labels,
|
|
155
|
-
buildargs: Object.keys(buildArgs).reduce((res, key) => {
|
|
156
|
-
const value = buildArgs[key];
|
|
157
|
-
if (typeof value !== "undefined") {
|
|
158
|
-
res[key] = typeof buildArgs[key] !== "string"
|
|
159
|
-
? buildArgs[key].toString()
|
|
160
|
-
: buildArgs[key];
|
|
161
|
-
}
|
|
162
|
-
return res;
|
|
163
|
-
}, {}),
|
|
164
|
-
dockerfile: src
|
|
165
|
-
});
|
|
166
|
-
await this.modemService.followProgress(stream);
|
|
144
|
+
await this.imageService.build(params);
|
|
167
145
|
}
|
|
168
146
|
async imageExists(tag) {
|
|
169
147
|
return this.imageService.exists(tag);
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import type Docker from "dockerode";
|
|
2
|
+
import { DockerServiceParams as Params } from "@wocker/core";
|
|
2
3
|
import { ModemService } from "./ModemService";
|
|
3
|
-
type BuildParams = {
|
|
4
|
-
tag: string;
|
|
5
|
-
context: string;
|
|
6
|
-
dockerfile: string;
|
|
7
|
-
version: "1" | "2";
|
|
8
|
-
};
|
|
9
4
|
export declare class ImageService {
|
|
10
5
|
protected readonly modemService: ModemService;
|
|
11
6
|
constructor(modemService: ModemService);
|
|
12
7
|
get docker(): Docker;
|
|
13
|
-
build(params:
|
|
8
|
+
build(params: Params.BuildImage): Promise<void>;
|
|
14
9
|
exists(tag: string): Promise<boolean>;
|
|
15
10
|
pull(tag: string): Promise<void>;
|
|
16
11
|
rm(tag: string, force?: boolean): Promise<void>;
|
|
17
12
|
}
|
|
18
|
-
export {};
|
|
@@ -20,7 +20,10 @@ let ImageService = class ImageService {
|
|
|
20
20
|
return this.modemService.docker;
|
|
21
21
|
}
|
|
22
22
|
async build(params) {
|
|
23
|
-
const { tag, context,
|
|
23
|
+
const { version, tag, context, labels, buildArgs } = params;
|
|
24
|
+
const dockerfile = "dockerfile" in params
|
|
25
|
+
? params.dockerfile
|
|
26
|
+
: params.src;
|
|
24
27
|
const files = (new core_1.FileSystem(context)).readdir("", {
|
|
25
28
|
recursive: true
|
|
26
29
|
});
|
|
@@ -28,9 +31,18 @@ let ImageService = class ImageService {
|
|
|
28
31
|
context,
|
|
29
32
|
src: files
|
|
30
33
|
}, {
|
|
34
|
+
version,
|
|
31
35
|
t: tag,
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
labels,
|
|
37
|
+
buildargs: Object.keys(buildArgs || {}).reduce((res, key) => {
|
|
38
|
+
const value = buildArgs[key];
|
|
39
|
+
if (typeof value !== "undefined") {
|
|
40
|
+
res[key] = typeof value !== "string" ? value.toString() : value;
|
|
41
|
+
}
|
|
42
|
+
return res;
|
|
43
|
+
}, {}),
|
|
44
|
+
rm: true,
|
|
45
|
+
dockerfile
|
|
34
46
|
});
|
|
35
47
|
await this.modemService.followProgress(stream);
|
|
36
48
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ModemService as CoreModemService } from "@wocker/core";
|
|
1
|
+
import { ModemService as CoreModemService, LogService } from "@wocker/core";
|
|
2
2
|
import type Modem from "docker-modem";
|
|
3
3
|
import type Docker from "dockerode";
|
|
4
4
|
import { ProtoService } from "./ProtoService";
|
|
5
5
|
export declare class ModemService extends CoreModemService {
|
|
6
6
|
protected readonly protoService: ProtoService;
|
|
7
|
+
protected readonly logService: LogService;
|
|
7
8
|
protected _modem?: Modem;
|
|
8
9
|
protected _docker?: Docker;
|
|
9
10
|
protected record?: boolean;
|
|
10
|
-
constructor(protoService: ProtoService);
|
|
11
|
+
constructor(protoService: ProtoService, logService: LogService);
|
|
11
12
|
get modem(): Modem;
|
|
12
13
|
get docker(): Docker;
|
|
13
14
|
attachStream(stream: NodeJS.ReadWriteStream): Promise<NodeJS.ReadWriteStream>;
|
|
@@ -14,9 +14,10 @@ const core_1 = require("@wocker/core");
|
|
|
14
14
|
const formatSizeUnits_1 = require("../utils/formatSizeUnits");
|
|
15
15
|
const ProtoService_1 = require("./ProtoService");
|
|
16
16
|
let ModemService = class ModemService extends core_1.ModemService {
|
|
17
|
-
constructor(protoService) {
|
|
17
|
+
constructor(protoService, logService) {
|
|
18
18
|
super();
|
|
19
19
|
this.protoService = protoService;
|
|
20
|
+
this.logService = logService;
|
|
20
21
|
this.record = true;
|
|
21
22
|
}
|
|
22
23
|
get modem() {
|
|
@@ -76,13 +77,30 @@ let ModemService = class ModemService extends core_1.ModemService {
|
|
|
76
77
|
const text = chunk.toString().replace(/}\s*\{/g, "},{"), items = JSON.parse(`[${text}]`);
|
|
77
78
|
for (const item of items) {
|
|
78
79
|
if (item.id === "moby.buildkit.trace") {
|
|
80
|
+
const StatusResponse = this.protoService.lookupType("moby.buildkit.v1.StatusResponse");
|
|
81
|
+
const buffer = Buffer.from(item.aux, "base64");
|
|
82
|
+
const decoded = StatusResponse.decode(buffer);
|
|
83
|
+
const obj = StatusResponse.toObject(decoded, {
|
|
84
|
+
enums: String,
|
|
85
|
+
longs: String,
|
|
86
|
+
bytes: String,
|
|
87
|
+
defaults: true
|
|
88
|
+
});
|
|
89
|
+
console.dir(obj, {
|
|
90
|
+
depth: null
|
|
91
|
+
});
|
|
79
92
|
}
|
|
80
|
-
if (item.
|
|
93
|
+
else if (item.id === "moby.image.id") {
|
|
94
|
+
console.dir(item, {
|
|
95
|
+
depth: null
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else if (item.stream) {
|
|
81
99
|
process.stdout.write(`${item.stream}`);
|
|
82
100
|
line += item.stream.split("\n").length - 1;
|
|
83
101
|
}
|
|
84
102
|
else if (item.id) {
|
|
85
|
-
const { id, status, processDetail: { current, total
|
|
103
|
+
const { id, status, processDetail: { current, total } = {} } = item;
|
|
86
104
|
if (typeof mapLines[id] === "undefined") {
|
|
87
105
|
mapLines[id] = line;
|
|
88
106
|
}
|
|
@@ -133,6 +151,7 @@ let ModemService = class ModemService extends core_1.ModemService {
|
|
|
133
151
|
};
|
|
134
152
|
exports.ModemService = ModemService;
|
|
135
153
|
exports.ModemService = ModemService = __decorate([
|
|
136
|
-
(0, core_1.Injectable)("
|
|
137
|
-
__metadata("design:paramtypes", [ProtoService_1.ProtoService
|
|
154
|
+
(0, core_1.Injectable)("DOCKER_MODEM_SERVICE"),
|
|
155
|
+
__metadata("design:paramtypes", [ProtoService_1.ProtoService,
|
|
156
|
+
core_1.LogService])
|
|
138
157
|
], ModemService);
|
|
@@ -7,8 +7,8 @@ class ProtoService {
|
|
|
7
7
|
get root() {
|
|
8
8
|
if (!this._root) {
|
|
9
9
|
this._root = (0, protobufjs_1.loadSync)([
|
|
10
|
-
`${env_1.ROOT_DIR}/proto/solver/pb/ops.proto`,
|
|
11
|
-
`${env_1.ROOT_DIR}/proto/buildkit.proto`
|
|
10
|
+
`${env_1.ROOT_DIR}/fixtures/proto/solver/pb/ops.proto`,
|
|
11
|
+
`${env_1.ROOT_DIR}/fixtures/proto/buildkit.proto`
|
|
12
12
|
]);
|
|
13
13
|
}
|
|
14
14
|
return this._root;
|
package/lib/modules/index.d.ts
CHANGED
package/lib/modules/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./core"), exports);
|
|
18
18
|
__exportStar(require("./docker"), exports);
|
|
19
19
|
__exportStar(require("./keystore"), exports);
|
|
20
20
|
__exportStar(require("./preset"), exports);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppConfigService, AppFileSystemService, KeystoreService as CoreKeystoreService, KeystoreProvider } from "@wocker/core";
|
|
2
2
|
export declare class KeystoreService extends CoreKeystoreService {
|
|
3
|
-
protected readonly appService: AppService;
|
|
4
3
|
protected readonly appConfigService: AppConfigService;
|
|
5
4
|
protected readonly fs: AppFileSystemService;
|
|
6
5
|
protected providers: Map<string, KeystoreProvider>;
|
|
7
|
-
constructor(
|
|
6
|
+
constructor(appConfigService: AppConfigService, fs: AppFileSystemService);
|
|
8
7
|
hasProvider(name: string): boolean;
|
|
9
8
|
provider(name?: string): KeystoreProvider;
|
|
10
9
|
get(keys: string | string[], byDefault?: string): Promise<string | undefined>;
|
|
@@ -14,9 +14,8 @@ const core_1 = require("@wocker/core");
|
|
|
14
14
|
const KeytarKeystoreProvider_1 = require("../providers/KeytarKeystoreProvider");
|
|
15
15
|
const FileKeystoreProvider_1 = require("../providers/FileKeystoreProvider");
|
|
16
16
|
let KeystoreService = class KeystoreService extends core_1.KeystoreService {
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(appConfigService, fs) {
|
|
18
18
|
super();
|
|
19
|
-
this.appService = appService;
|
|
20
19
|
this.appConfigService = appConfigService;
|
|
21
20
|
this.fs = fs;
|
|
22
21
|
this.providers = new Map();
|
|
@@ -67,7 +66,6 @@ let KeystoreService = class KeystoreService extends core_1.KeystoreService {
|
|
|
67
66
|
exports.KeystoreService = KeystoreService;
|
|
68
67
|
exports.KeystoreService = KeystoreService = __decorate([
|
|
69
68
|
(0, core_1.Injectable)("KEYSTORE_SERVICE"),
|
|
70
|
-
__metadata("design:paramtypes", [core_1.
|
|
71
|
-
core_1.AppConfigService,
|
|
69
|
+
__metadata("design:paramtypes", [core_1.AppConfigService,
|
|
72
70
|
core_1.AppFileSystemService])
|
|
73
71
|
], KeystoreService);
|