@wocker/ws 1.0.2 → 1.0.4
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/README.md +1 -1
- package/lib/App.d.ts +4 -3
- package/lib/App.js +98 -77
- package/lib/controllers/ImageController.d.ts +2 -2
- package/lib/controllers/ImageController.js +27 -27
- package/lib/controllers/PluginController.d.ts +2 -2
- package/lib/controllers/PluginController.js +78 -56
- package/lib/controllers/PresetController.d.ts +3 -1
- package/lib/controllers/PresetController.js +155 -136
- package/lib/controllers/ProjectController.d.ts +5 -5
- package/lib/controllers/ProjectController.js +653 -603
- package/lib/controllers/ProxyController.d.ts +4 -1
- package/lib/controllers/ProxyController.js +269 -245
- package/lib/controllers/index.js +19 -58
- package/lib/decorators/Inject.d.ts +1 -0
- package/lib/decorators/Inject.js +8 -0
- package/lib/decorators/Injectable.d.ts +4 -0
- package/lib/decorators/Injectable.js +17 -0
- package/lib/decorators/index.d.ts +1 -0
- package/lib/decorators/index.js +17 -0
- package/lib/env.js +33 -15
- package/lib/index.d.ts +3 -0
- package/lib/index.js +31 -16
- package/lib/makes/Controller.js +4 -8
- package/lib/makes/DI.d.ts +7 -0
- package/lib/makes/DI.js +27 -0
- package/lib/makes/Docker.js +298 -382
- package/lib/makes/FS.d.ts +3 -9
- package/lib/makes/FS.js +277 -305
- package/lib/makes/LineConvertStream.js +37 -40
- package/lib/makes/Logger.d.ts +9 -1
- package/lib/makes/Logger.js +22 -11
- package/lib/makes/Model.js +8 -12
- package/lib/makes/MySQL.js +6 -27
- package/lib/makes/Plugin.d.ts +1 -1
- package/lib/makes/Plugin.js +55 -37
- package/lib/makes/Preset.d.ts +46 -0
- package/lib/makes/Preset.js +33 -0
- package/lib/makes/Project.d.ts +45 -0
- package/lib/makes/Project.js +127 -0
- package/lib/makes/Repository.js +18 -21
- package/lib/makes/index.d.ts +3 -0
- package/lib/makes/index.js +23 -69
- package/lib/plugins/ElasticSearchPlugin.d.ts +3 -1
- package/lib/plugins/ElasticSearchPlugin.js +66 -66
- package/lib/plugins/LocaltunnelPlugin.d.ts +2 -2
- package/lib/plugins/LocaltunnelPlugin.js +256 -257
- package/lib/plugins/MaildevPlugin.d.ts +2 -2
- package/lib/plugins/MaildevPlugin.js +45 -44
- package/lib/plugins/MongodbPlugin.d.ts +2 -2
- package/lib/plugins/MongodbPlugin.js +303 -248
- package/lib/plugins/NgrokPlugin.d.ts +2 -2
- package/lib/plugins/NgrokPlugin.js +221 -231
- package/lib/plugins/PageKitePlugin.d.ts +2 -2
- package/lib/plugins/PageKitePlugin.js +150 -149
- package/lib/plugins/PostgresPlugin.d.ts +1 -1
- package/lib/plugins/PostgresPlugin.js +115 -89
- package/lib/plugins/ProxmoxPlugin.d.ts +1 -1
- package/lib/plugins/ProxmoxPlugin.js +50 -38
- package/lib/plugins/RedisPlugin.d.ts +3 -1
- package/lib/plugins/RedisPlugin.js +73 -72
- package/lib/plugins/index.js +25 -103
- package/lib/services/AppConfigService.d.ts +3 -3
- package/lib/services/AppConfigService.js +162 -157
- package/lib/services/AppEventsService.js +26 -24
- package/lib/services/DockerService.d.ts +37 -2
- package/lib/services/DockerService.js +185 -205
- package/lib/services/LogService.d.ts +3 -2
- package/lib/services/LogService.js +33 -34
- package/lib/services/PluginService.d.ts +2 -1
- package/lib/services/PluginService.js +11 -14
- package/lib/services/PresetService.d.ts +8 -3
- package/lib/services/PresetService.js +60 -59
- package/lib/services/ProjectService.d.ts +11 -4
- package/lib/services/ProjectService.js +140 -129
- package/lib/services/index.js +21 -80
- package/lib/types/Config.d.ts +4 -3
- package/lib/types/Config.js +1 -4
- package/lib/types/EnvConfig.js +1 -4
- package/lib/types/index.js +16 -25
- package/lib/utils/buildOptions.js +5 -8
- package/lib/utils/demuxOutput.js +16 -20
- package/lib/utils/escapeRegExp.js +4 -7
- package/lib/utils/exec.js +38 -39
- package/lib/utils/fetch.js +46 -30
- package/lib/utils/followProgress.js +66 -77
- package/lib/utils/format-size-units.js +16 -16
- package/lib/utils/get-config.d.ts +1 -1
- package/lib/utils/get-config.js +13 -16
- package/lib/utils/get-cursor-position.js +22 -29
- package/lib/utils/image-build.js +35 -23
- package/lib/utils/index.js +32 -191
- package/lib/utils/injectVariables.js +10 -13
- package/lib/utils/parse-table.js +20 -23
- package/lib/utils/set-config.d.ts +1 -1
- package/lib/utils/set-config.js +12 -15
- package/lib/utils/spawn.js +17 -20
- package/lib/utils/tty.js +2 -6
- package/lib/utils/volumeFormat.js +5 -12
- package/lib/utils/volumeParse.js +10 -13
- package/package.json +13 -39
- package/presets/bun/Dockerfile +11 -0
- package/presets/bun/config.json +3 -0
- package/presets/node/Dockerfile +4 -2
- package/presets/php-apache/Dockerfile +3 -2
- package/.github/workflows/publish.yml +0 -31
- package/plugins/mariadb/admin/conf/config.user.inc.php +0 -9
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.AppEventsService = void 0;
|
|
7
|
-
|
|
8
|
-
class AppEventsService extends
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
const core_1 = require("@wocker/core");
|
|
5
|
+
class AppEventsService extends core_1.AppEventsService {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.handles = {};
|
|
9
|
+
}
|
|
10
|
+
on(event, handle) {
|
|
11
|
+
this.handles[event] = [
|
|
12
|
+
...this.handles[event] || [],
|
|
13
|
+
handle
|
|
14
|
+
];
|
|
15
|
+
return () => {
|
|
16
|
+
this.handles[event] = this.handles[event].filter((filterHandle) => {
|
|
17
|
+
return filterHandle !== handle;
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
off(event, handle) {
|
|
22
|
+
}
|
|
23
|
+
async emit(event, ...args) {
|
|
24
|
+
const handles = this.handles[event] || [];
|
|
25
|
+
for (const i in handles) {
|
|
26
|
+
await handles[i](...args);
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
|
-
}
|
|
27
29
|
}
|
|
28
|
-
exports.AppEventsService = AppEventsService;
|
|
30
|
+
exports.AppEventsService = AppEventsService;
|
|
@@ -1,7 +1,42 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { DI, DockerService as CoreDockerService, DockerServiceParams as Params } from "@wocker/core";
|
|
3
2
|
import Docker, { Container } from "dockerode";
|
|
4
|
-
|
|
3
|
+
import { DI } from "../makes";
|
|
4
|
+
declare namespace Params {
|
|
5
|
+
type CreateContainer = {
|
|
6
|
+
name: string;
|
|
7
|
+
image: string;
|
|
8
|
+
restart?: "always";
|
|
9
|
+
projectId?: string;
|
|
10
|
+
tty?: boolean;
|
|
11
|
+
ulimits?: {
|
|
12
|
+
[key: string]: {
|
|
13
|
+
hard?: number;
|
|
14
|
+
soft?: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
links?: string[];
|
|
18
|
+
env?: {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
};
|
|
21
|
+
networkMode?: string;
|
|
22
|
+
extraHosts?: any;
|
|
23
|
+
volumes?: string[];
|
|
24
|
+
ports?: string[];
|
|
25
|
+
cmd?: string[];
|
|
26
|
+
};
|
|
27
|
+
type BuildImage = {
|
|
28
|
+
tag: string;
|
|
29
|
+
buildArgs?: {
|
|
30
|
+
[key: string]: string;
|
|
31
|
+
};
|
|
32
|
+
labels?: {
|
|
33
|
+
[key: string]: string;
|
|
34
|
+
};
|
|
35
|
+
context: string;
|
|
36
|
+
src: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
declare class DockerService {
|
|
5
40
|
protected docker: Docker;
|
|
6
41
|
constructor(di: DI);
|
|
7
42
|
createContainer(params: Params.CreateContainer): Promise<Container>;
|
|
@@ -1,220 +1,200 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
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
6
|
exports.DockerService = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
super();
|
|
15
|
-
this.docker = new _dockerode.default({
|
|
16
|
-
socketPath: "/var/run/docker.sock"
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
async createContainer(params) {
|
|
20
|
-
const {
|
|
21
|
-
name,
|
|
22
|
-
tty,
|
|
23
|
-
image,
|
|
24
|
-
projectId,
|
|
25
|
-
restart,
|
|
26
|
-
ulimits,
|
|
27
|
-
extraHosts,
|
|
28
|
-
networkMode,
|
|
29
|
-
links = [],
|
|
30
|
-
env = {},
|
|
31
|
-
volumes = [],
|
|
32
|
-
ports = [],
|
|
33
|
-
cmd = []
|
|
34
|
-
} = params;
|
|
35
|
-
const network = this.docker.getNetwork("workspace");
|
|
36
|
-
try {
|
|
37
|
-
await network.inspect();
|
|
38
|
-
} catch (err) {
|
|
39
|
-
if (err.statusCode === 404) {
|
|
40
|
-
await this.docker.createNetwork({
|
|
41
|
-
Name: "workspace"
|
|
7
|
+
const dockerode_1 = __importDefault(require("dockerode"));
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
const makes_1 = require("../makes");
|
|
10
|
+
class DockerService {
|
|
11
|
+
constructor(di) {
|
|
12
|
+
this.docker = new dockerode_1.default({
|
|
13
|
+
socketPath: "/var/run/docker.sock"
|
|
42
14
|
});
|
|
43
|
-
}
|
|
44
15
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Labels: {
|
|
51
|
-
...(projectId ? {
|
|
52
|
-
projectId
|
|
53
|
-
} : {})
|
|
54
|
-
},
|
|
55
|
-
AttachStdin: true,
|
|
56
|
-
AttachStdout: true,
|
|
57
|
-
AttachStderr: true,
|
|
58
|
-
OpenStdin: true,
|
|
59
|
-
StdinOnce: false,
|
|
60
|
-
Tty: tty,
|
|
61
|
-
Cmd: cmd,
|
|
62
|
-
Env: Object.keys(env).map(key => {
|
|
63
|
-
const value = env[key];
|
|
64
|
-
return `${key}=${value}`;
|
|
65
|
-
}),
|
|
66
|
-
ExposedPorts: ports.reduce((res, value) => {
|
|
67
|
-
const [,, containerPort] = /(\d+):(\d+)/.exec(value) || [];
|
|
68
|
-
if (containerPort) {
|
|
69
|
-
res[`${containerPort}/tcp`] = {};
|
|
16
|
+
async createContainer(params) {
|
|
17
|
+
const { name, tty, image, projectId, restart, ulimits, extraHosts, networkMode, links = [], env = {}, volumes = [], ports = [], cmd = [] } = params;
|
|
18
|
+
const network = this.docker.getNetwork("workspace");
|
|
19
|
+
try {
|
|
20
|
+
await network.inspect();
|
|
70
21
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return [...res, {
|
|
78
|
-
Name: name,
|
|
79
|
-
Hard: ulimits[name].hard,
|
|
80
|
-
Soft: ulimits[name].soft
|
|
81
|
-
}];
|
|
82
|
-
}, []) : [],
|
|
83
|
-
...(restart ? {
|
|
84
|
-
RestartPolicy: {
|
|
85
|
-
Name: restart
|
|
86
|
-
}
|
|
87
|
-
} : {}),
|
|
88
|
-
Binds: volumes,
|
|
89
|
-
PortBindings: ports.reduce((res, value) => {
|
|
90
|
-
const [, hostPort, containerPort] = /(\d+):(\d+)/.exec(value) || [];
|
|
91
|
-
if (hostPort && containerPort) {
|
|
92
|
-
res[`${containerPort}/tcp`] = [{
|
|
93
|
-
HostPort: hostPort
|
|
94
|
-
}];
|
|
95
|
-
}
|
|
96
|
-
return res;
|
|
97
|
-
}, {})
|
|
98
|
-
},
|
|
99
|
-
NetworkingConfig: {
|
|
100
|
-
EndpointsConfig: networkMode === "host" ? {} : {
|
|
101
|
-
workspace: {
|
|
102
|
-
Links: links
|
|
103
|
-
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
if (err.statusCode === 404) {
|
|
24
|
+
await this.docker.createNetwork({
|
|
25
|
+
Name: "workspace"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
104
28
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
29
|
+
await this.pullImage(image);
|
|
30
|
+
return this.docker.createContainer({
|
|
31
|
+
name,
|
|
32
|
+
Image: image,
|
|
33
|
+
Hostname: name,
|
|
34
|
+
Labels: {
|
|
35
|
+
...projectId ? { projectId } : {}
|
|
36
|
+
},
|
|
37
|
+
AttachStdin: true,
|
|
38
|
+
AttachStdout: true,
|
|
39
|
+
AttachStderr: true,
|
|
40
|
+
OpenStdin: true,
|
|
41
|
+
StdinOnce: false,
|
|
42
|
+
Tty: tty,
|
|
43
|
+
Cmd: cmd,
|
|
44
|
+
Env: Object.keys(env).map((key) => {
|
|
45
|
+
const value = env[key];
|
|
46
|
+
return `${key}=${value}`;
|
|
47
|
+
}),
|
|
48
|
+
ExposedPorts: ports.reduce((res, value) => {
|
|
49
|
+
const [, , containerPort] = /(\d+):(\d+)/.exec(value) || [];
|
|
50
|
+
if (containerPort) {
|
|
51
|
+
res[`${containerPort}/tcp`] = {};
|
|
52
|
+
}
|
|
53
|
+
return res;
|
|
54
|
+
}, {}),
|
|
55
|
+
HostConfig: {
|
|
56
|
+
NetworkMode: networkMode,
|
|
57
|
+
ExtraHosts: extraHosts,
|
|
58
|
+
Ulimits: ulimits ? Object.keys(ulimits).reduce((res, name) => {
|
|
59
|
+
return [
|
|
60
|
+
...res,
|
|
61
|
+
{
|
|
62
|
+
Name: name,
|
|
63
|
+
Hard: ulimits[name].hard,
|
|
64
|
+
Soft: ulimits[name].soft
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
}, []) : [],
|
|
68
|
+
...restart ? {
|
|
69
|
+
RestartPolicy: {
|
|
70
|
+
Name: restart
|
|
71
|
+
}
|
|
72
|
+
} : {},
|
|
73
|
+
Binds: volumes,
|
|
74
|
+
PortBindings: ports.reduce((res, value) => {
|
|
75
|
+
const [, hostPort, containerPort] = /(\d+):(\d+)/.exec(value) || [];
|
|
76
|
+
if (hostPort && containerPort) {
|
|
77
|
+
res[`${containerPort}/tcp`] = [
|
|
78
|
+
{ HostPort: hostPort }
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
return res;
|
|
82
|
+
}, {}),
|
|
83
|
+
},
|
|
84
|
+
NetworkingConfig: {
|
|
85
|
+
EndpointsConfig: networkMode === "host" ? {} : {
|
|
86
|
+
workspace: {
|
|
87
|
+
Links: links
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
120
92
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
93
|
+
async getContainer(name) {
|
|
94
|
+
const containers = await this.docker.listContainers({
|
|
95
|
+
all: true,
|
|
96
|
+
filters: {
|
|
97
|
+
name: [name]
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const container = containers.find((container) => {
|
|
101
|
+
return container.Names.indexOf("/" + name) >= 0;
|
|
102
|
+
});
|
|
103
|
+
if (container) {
|
|
104
|
+
return this.docker.getContainer(container.Id);
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
127
107
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
108
|
+
async removeContainer(name) {
|
|
109
|
+
const container = await this.getContainer(name);
|
|
110
|
+
if (!container) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const { State: { Status } } = await container.inspect();
|
|
114
|
+
if (Status === "running" || Status === "restarting") {
|
|
115
|
+
try {
|
|
116
|
+
await container.stop();
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
makes_1.Logger.error("DockerService.removeContainer", err.message);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
await container.remove();
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
makes_1.Logger.error("DockerService.removeContainer: ", err.message);
|
|
127
|
+
}
|
|
139
128
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
129
|
+
async buildImage(params) {
|
|
130
|
+
const { tag, labels = {}, buildArgs = {}, context, src } = params;
|
|
131
|
+
const files = await makes_1.FS.readdirFiles(context, {
|
|
132
|
+
recursive: true
|
|
133
|
+
});
|
|
134
|
+
const stream = await this.docker.buildImage({
|
|
135
|
+
context,
|
|
136
|
+
src: files
|
|
137
|
+
}, {
|
|
138
|
+
t: tag,
|
|
139
|
+
labels,
|
|
140
|
+
buildargs: Object.keys(buildArgs).reduce((res, key) => {
|
|
141
|
+
res[key] = typeof buildArgs[key] !== "string"
|
|
142
|
+
? buildArgs[key].toString()
|
|
143
|
+
: buildArgs[key];
|
|
144
|
+
return res;
|
|
145
|
+
}, {}),
|
|
146
|
+
dockerfile: src
|
|
147
|
+
});
|
|
148
|
+
await (0, utils_1.followProgress)(stream);
|
|
144
149
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const files = await _makes.FS.readdirFiles(context, {
|
|
155
|
-
recursive: true
|
|
156
|
-
});
|
|
157
|
-
const stream = await this.docker.buildImage({
|
|
158
|
-
context,
|
|
159
|
-
src: files
|
|
160
|
-
}, {
|
|
161
|
-
t: tag,
|
|
162
|
-
labels,
|
|
163
|
-
buildargs: Object.keys(buildArgs).reduce((res, key) => {
|
|
164
|
-
res[key] = typeof buildArgs[key] !== "string" ? buildArgs[key].toString() : buildArgs[key];
|
|
165
|
-
return res;
|
|
166
|
-
}, {}),
|
|
167
|
-
dockerfile: src
|
|
168
|
-
});
|
|
169
|
-
await (0, _utils.followProgress)(stream);
|
|
170
|
-
}
|
|
171
|
-
async imageExists(tag) {
|
|
172
|
-
const image = this.docker.getImage(tag);
|
|
173
|
-
try {
|
|
174
|
-
await image.inspect();
|
|
175
|
-
return true;
|
|
176
|
-
} catch (ignore) {
|
|
177
|
-
return false;
|
|
150
|
+
async imageExists(tag) {
|
|
151
|
+
const image = this.docker.getImage(tag);
|
|
152
|
+
try {
|
|
153
|
+
await image.inspect();
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
catch (ignore) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
178
159
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
160
|
+
async imageRm(tag) {
|
|
161
|
+
const image = await this.docker.getImage(tag);
|
|
162
|
+
if (!image) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
await image.remove();
|
|
184
166
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
167
|
+
async pullImage(tag) {
|
|
168
|
+
const exists = await this.imageExists(tag);
|
|
169
|
+
if (exists) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const stream = await this.docker.pull(tag);
|
|
173
|
+
await (0, utils_1.followProgress)(stream);
|
|
191
174
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
175
|
+
async attachStream(stream) {
|
|
176
|
+
process.stdin.resume();
|
|
177
|
+
process.stdin.setEncoding("utf8");
|
|
178
|
+
process.stdin.pipe(stream);
|
|
179
|
+
if (process.stdin.isTTY) {
|
|
180
|
+
process.stdin.setRawMode(true);
|
|
181
|
+
}
|
|
182
|
+
stream.setEncoding("utf8");
|
|
183
|
+
stream.pipe(process.stdout);
|
|
184
|
+
const end = () => {
|
|
185
|
+
process.stdin.pause();
|
|
186
|
+
process.stdin.unpipe(stream);
|
|
187
|
+
if (process.stdin.isTTY) {
|
|
188
|
+
process.stdin.setRawMode(false);
|
|
189
|
+
}
|
|
190
|
+
stream.unpipe(process.stdout);
|
|
191
|
+
};
|
|
192
|
+
await new Promise((resolve, reject) => {
|
|
193
|
+
stream.on("end", end);
|
|
194
|
+
stream.on("error", end);
|
|
195
|
+
stream.on("end", resolve);
|
|
196
|
+
stream.on("error", reject);
|
|
197
|
+
});
|
|
201
198
|
}
|
|
202
|
-
stream.setEncoding("utf8");
|
|
203
|
-
stream.pipe(process.stdout);
|
|
204
|
-
const end = () => {
|
|
205
|
-
process.stdin.pause();
|
|
206
|
-
process.stdin.unpipe(stream);
|
|
207
|
-
if (process.stdin.isTTY) {
|
|
208
|
-
process.stdin.setRawMode(false);
|
|
209
|
-
}
|
|
210
|
-
stream.unpipe(process.stdout);
|
|
211
|
-
};
|
|
212
|
-
await new Promise((resolve, reject) => {
|
|
213
|
-
stream.on("end", end);
|
|
214
|
-
stream.on("error", end);
|
|
215
|
-
stream.on("end", resolve);
|
|
216
|
-
stream.on("error", reject);
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
199
|
}
|
|
220
|
-
exports.DockerService = DockerService;
|
|
200
|
+
exports.DockerService = DockerService;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { DI
|
|
1
|
+
import { DI } from "../makes";
|
|
2
|
+
import { AppConfigService } from "./AppConfigService";
|
|
2
3
|
declare class LogService {
|
|
3
4
|
protected appConfigService: AppConfigService;
|
|
4
5
|
constructor(di: DI);
|
|
5
6
|
log(...data: any[]): void;
|
|
6
7
|
info(...data: any[]): void;
|
|
7
|
-
|
|
8
|
+
warn(...data: any[]): void;
|
|
8
9
|
error(...data: any[]): void;
|
|
9
10
|
protected _log(type: string, ...data: any[]): void;
|
|
10
11
|
}
|
|
@@ -1,39 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
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
6
|
exports.LogService = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
+
const format_1 = __importDefault(require("date-fns/format"));
|
|
8
|
+
const makes_1 = require("../makes");
|
|
9
|
+
const AppConfigService_1 = require("./AppConfigService");
|
|
11
10
|
class LogService {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
11
|
+
constructor(di) {
|
|
12
|
+
this.appConfigService = di.resolveService(AppConfigService_1.AppConfigService);
|
|
13
|
+
}
|
|
14
|
+
log(...data) {
|
|
15
|
+
this._log("log", ...data);
|
|
16
|
+
}
|
|
17
|
+
info(...data) {
|
|
18
|
+
this._log("info", ...data);
|
|
19
|
+
}
|
|
20
|
+
warn(...data) {
|
|
21
|
+
this._log("warn", ...data);
|
|
22
|
+
}
|
|
23
|
+
error(...data) {
|
|
24
|
+
this._log("error", ...data);
|
|
25
|
+
}
|
|
26
|
+
_log(type, ...data) {
|
|
27
|
+
const time = (0, format_1.default)(new Date(), "yyyy-MM-dd hh:mm:ss");
|
|
28
|
+
const logPath = this.appConfigService.dataPath("ws.log");
|
|
29
|
+
const logData = data.map((item) => {
|
|
30
|
+
return typeof item !== "string" ? JSON.stringify(item) : item;
|
|
31
|
+
}).join(" ");
|
|
32
|
+
if (!makes_1.FS.existsSync(logPath)) {
|
|
33
|
+
makes_1.FS.writeFileSync(logPath, "");
|
|
34
|
+
}
|
|
35
|
+
makes_1.FS.appendFileSync(logPath, `[${time}] ${type}: ${logData}\n`);
|
|
35
36
|
}
|
|
36
|
-
_makes.FS.appendFileSync(logPath, `[${time}] ${type}: ${logData}\n`);
|
|
37
|
-
}
|
|
38
37
|
}
|
|
39
|
-
exports.LogService = LogService;
|
|
38
|
+
exports.LogService = LogService;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.PluginService = void 0;
|
|
7
|
-
|
|
4
|
+
const core_1 = require("@wocker/core");
|
|
8
5
|
class PluginService {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
constructor(di) {
|
|
7
|
+
this.di = di;
|
|
8
|
+
this.cli = di.resolveService(core_1.Cli);
|
|
9
|
+
}
|
|
10
|
+
use(Constructor) {
|
|
11
|
+
const controller = new Constructor(this.di);
|
|
12
|
+
controller.install(this.cli);
|
|
13
|
+
}
|
|
17
14
|
}
|
|
18
|
-
exports.PluginService = PluginService;
|
|
15
|
+
exports.PluginService = PluginService;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { EnvConfig } from "../types";
|
|
2
|
+
import { DI, Preset } from "../makes";
|
|
3
|
+
type SearchOptions = Partial<{
|
|
4
|
+
name: string;
|
|
5
|
+
}>;
|
|
6
|
+
declare class PresetService {
|
|
3
7
|
constructor(di: DI);
|
|
4
8
|
getImageName(preset: Preset, buildArgs?: EnvConfig): string;
|
|
5
9
|
save(preset: Preset): Promise<void>;
|
|
6
10
|
get(name: string): Promise<Preset>;
|
|
7
11
|
search(options?: SearchOptions): Promise<Preset[]>;
|
|
12
|
+
searchOne(options?: SearchOptions): Promise<Preset | null>;
|
|
8
13
|
}
|
|
9
|
-
export { PresetService };
|
|
14
|
+
export { PresetService, SearchOptions as PresetServiceSearchOptions };
|