@wocker/ws 1.0.1 → 1.0.3
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 +11 -137
- package/bin/ws.js +7 -3
- package/lib/App.d.ts +10 -7
- package/lib/App.js +99 -44
- package/lib/controllers/ImageController.d.ts +4 -2
- package/lib/controllers/ImageController.js +27 -25
- package/lib/controllers/PluginController.d.ts +14 -0
- package/lib/controllers/PluginController.js +84 -0
- package/lib/controllers/PresetController.d.ts +21 -0
- package/lib/controllers/PresetController.js +169 -0
- package/lib/controllers/ProjectController.d.ts +11 -3
- package/lib/controllers/ProjectController.js +653 -536
- package/lib/{plugins/ProxyPlugin.d.ts → controllers/ProxyController.d.ts} +12 -11
- package/lib/controllers/ProxyController.js +273 -0
- package/lib/controllers/index.d.ts +3 -0
- package/lib/controllers/index.js +19 -25
- package/lib/env.js +33 -22
- package/lib/index.d.ts +2 -0
- package/lib/index.js +29 -28
- 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 +299 -397
- package/lib/makes/FS.d.ts +1 -1
- package/lib/makes/FS.js +328 -301
- package/lib/makes/LineConvertStream.js +37 -40
- package/lib/makes/Logger.d.ts +5 -3
- package/lib/makes/Logger.js +18 -34
- 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/{models → makes}/Project.d.ts +23 -16
- 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 +18 -0
- package/lib/plugins/ElasticSearchPlugin.js +72 -0
- package/lib/plugins/LocaltunnelPlugin.d.ts +4 -4
- package/lib/plugins/LocaltunnelPlugin.js +256 -255
- package/lib/plugins/MaildevPlugin.d.ts +4 -2
- package/lib/plugins/MaildevPlugin.js +45 -41
- package/lib/plugins/MongodbPlugin.d.ts +6 -4
- package/lib/plugins/MongodbPlugin.js +303 -254
- package/lib/plugins/NgrokPlugin.d.ts +3 -4
- package/lib/plugins/NgrokPlugin.js +221 -230
- package/lib/plugins/PageKitePlugin.d.ts +3 -4
- package/lib/plugins/PageKitePlugin.js +150 -147
- package/lib/plugins/PostgresPlugin.d.ts +1 -1
- package/lib/plugins/PostgresPlugin.js +115 -88
- package/lib/plugins/ProxmoxPlugin.d.ts +1 -1
- package/lib/plugins/ProxmoxPlugin.js +50 -38
- package/lib/plugins/RedisPlugin.d.ts +10 -2
- package/lib/plugins/RedisPlugin.js +77 -39
- package/lib/plugins/index.d.ts +2 -6
- package/lib/plugins/index.js +25 -158
- package/lib/services/AppConfigService.d.ts +13 -3
- package/lib/services/AppConfigService.js +161 -71
- package/lib/services/AppEventsService.d.ts +5 -8
- package/lib/services/AppEventsService.js +26 -25
- package/lib/services/DockerService.d.ts +51 -0
- package/lib/services/DockerService.js +200 -0
- package/lib/services/LogService.d.ts +12 -0
- package/lib/services/LogService.js +38 -0
- package/lib/services/PluginService.d.ts +11 -0
- package/lib/services/PluginService.js +15 -0
- package/lib/services/PresetService.d.ts +14 -0
- package/lib/services/PresetService.js +64 -0
- package/lib/services/ProjectService.d.ts +12 -4
- package/lib/services/ProjectService.js +141 -78
- package/lib/services/index.d.ts +4 -0
- package/lib/services/index.js +21 -36
- 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 -22
- package/lib/utils/escapeRegExp.js +4 -7
- package/lib/utils/exec.d.ts +1 -1
- package/lib/utils/exec.js +38 -40
- package/lib/utils/fetch.js +45 -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.d.ts +0 -4
- package/lib/utils/index.js +32 -235
- 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 +21 -47
- package/presets/bun/Dockerfile +11 -0
- package/presets/bun/config.json +3 -0
- package/presets/node/Dockerfile +4 -2
- package/presets/node/config.json +9 -7
- package/presets/php-apache/Dockerfile +40 -38
- package/presets/php-apache/config.json +10 -15
- package/presets/php-fpm/Dockerfile +21 -0
- package/presets/php-fpm/config.json +25 -0
- package/lib/models/Preset.d.ts +0 -19
- package/lib/models/Preset.js +0 -60
- package/lib/models/Project.js +0 -151
- package/lib/models/index.d.ts +0 -2
- package/lib/models/index.js +0 -27
- package/lib/plugins/MariadbPlugin.d.ts +0 -25
- package/lib/plugins/MariadbPlugin.js +0 -297
- package/lib/plugins/PresetPlugin.d.ts +0 -19
- package/lib/plugins/PresetPlugin.js +0 -164
- package/lib/plugins/ProjectPlugin.d.ts +0 -12
- package/lib/plugins/ProjectPlugin.js +0 -54
- package/lib/plugins/ProxyPlugin.js +0 -257
- package/lib/plugins/ServeoPlugin.d.ts +0 -36
- package/lib/plugins/ServeoPlugin.js +0 -260
- package/lib/plugins/TestPlugin.d.ts +0 -10
- package/lib/plugins/TestPlugin.js +0 -75
- package/lib/utils/promptConfirm.d.ts +0 -6
- package/lib/utils/promptConfirm.js +0 -21
- package/lib/utils/promptGroup.d.ts +0 -16
- package/lib/utils/promptGroup.js +0 -39
- package/lib/utils/promptSelect.d.ts +0 -12
- package/lib/utils/promptSelect.js +0 -47
- package/lib/utils/promptText.d.ts +0 -13
- package/lib/utils/promptText.js +0 -53
- package/plugins/mariadb/admin/conf/config.user.inc.php +0 -9
- package/plugins/serveo/Dockerfile +0 -17
|
@@ -1,91 +1,154 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
5
17
|
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.ProjectService = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
+
const Path = __importStar(require("path"));
|
|
28
|
+
const makes_1 = require("../makes");
|
|
29
|
+
const services_1 = require("../services");
|
|
12
30
|
class ProjectService {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
async cdProject(name) {
|
|
18
|
-
const project = await _models.Project.searchOne({
|
|
19
|
-
name
|
|
20
|
-
});
|
|
21
|
-
if (!project) {
|
|
22
|
-
throw new Error("Project not found");
|
|
31
|
+
constructor(di) {
|
|
32
|
+
this.appConfigService = di.resolveService(services_1.AppConfigService);
|
|
33
|
+
this.appEventsService = di.resolveService(services_1.AppEventsService);
|
|
34
|
+
this.dockerService = di.resolveService(services_1.DockerService);
|
|
23
35
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
async cdProject(name) {
|
|
37
|
+
const project = await makes_1.Project.searchOne({
|
|
38
|
+
name
|
|
39
|
+
});
|
|
40
|
+
if (!project) {
|
|
41
|
+
throw new Error("Project not found");
|
|
42
|
+
}
|
|
43
|
+
this.appConfigService.setPWD(project.path);
|
|
32
44
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const project = await this.get();
|
|
37
|
-
if (project.type === "dockerfile") {
|
|
38
|
-
project.imageName = `project-${project.name}:develop`;
|
|
39
|
-
const images = await _makes.Docker.imageLs({
|
|
40
|
-
tag: project.imageName
|
|
41
|
-
});
|
|
42
|
-
if (images.length === 0) {
|
|
43
|
-
await _makes.Docker.imageBuild2({
|
|
44
|
-
tag: project.imageName,
|
|
45
|
-
context: this.appConfigService.getPWD(),
|
|
46
|
-
src: project.dockerfile
|
|
45
|
+
async get() {
|
|
46
|
+
const project = await makes_1.Project.searchOne({
|
|
47
|
+
path: this.appConfigService.getPWD()
|
|
47
48
|
});
|
|
48
|
-
|
|
49
|
+
if (!project) {
|
|
50
|
+
throw new Error("Project not found");
|
|
51
|
+
}
|
|
52
|
+
return project;
|
|
49
53
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!container) {
|
|
54
|
-
container = await _makes.Docker.createContainer({
|
|
55
|
-
name: containerName,
|
|
56
|
-
image: project.imageName,
|
|
57
|
-
env: {
|
|
58
|
-
...(await this.appConfigService.getAllEnvVariables()),
|
|
59
|
-
...(project.env || {})
|
|
60
|
-
},
|
|
61
|
-
volumes: (project.volumes || []).map(volume => {
|
|
62
|
-
const regVolume = /^([^:]+):([^:]+)(?::([^:]+))?$/;
|
|
63
|
-
const [, source, destination, options] = regVolume.exec(volume);
|
|
64
|
-
return `${Path.join(this.appConfigService.getPWD(), source)}:${destination}` + (options ? `:${options}` : "");
|
|
65
|
-
})
|
|
66
|
-
});
|
|
67
|
-
} else {
|
|
68
|
-
process.stdout.write("Container already exists\n");
|
|
54
|
+
async getContainer() {
|
|
55
|
+
const project = await this.get();
|
|
56
|
+
return this.dockerService.getContainer(project.containerName);
|
|
69
57
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
async start() {
|
|
59
|
+
const project = await this.get();
|
|
60
|
+
if (project.type === "dockerfile") {
|
|
61
|
+
project.imageName = `project-${project.name}:develop`;
|
|
62
|
+
const images = await makes_1.Docker.imageLs({
|
|
63
|
+
tag: project.imageName
|
|
64
|
+
});
|
|
65
|
+
if (images.length === 0) {
|
|
66
|
+
await makes_1.Docker.imageBuild2({
|
|
67
|
+
tag: project.imageName,
|
|
68
|
+
context: this.appConfigService.getPWD(),
|
|
69
|
+
src: project.dockerfile
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
await this.appEventsService.emit("project:beforeStart", project);
|
|
74
|
+
let container = await this.dockerService.getContainer(project.containerName);
|
|
75
|
+
if (!container) {
|
|
76
|
+
container = await makes_1.Docker.createContainer({
|
|
77
|
+
name: project.containerName,
|
|
78
|
+
image: project.imageName,
|
|
79
|
+
env: {
|
|
80
|
+
...await this.appConfigService.getAllEnvVariables(),
|
|
81
|
+
...project.env || {}
|
|
82
|
+
},
|
|
83
|
+
volumes: (project.volumes || []).map((volume) => {
|
|
84
|
+
const regVolume = /^([^:]+):([^:]+)(?::([^:]+))?$/;
|
|
85
|
+
const [, source, destination, options] = regVolume.exec(volume);
|
|
86
|
+
return `${Path.join(this.appConfigService.getPWD(), source)}:${destination}` + (options ? `:${options}` : "");
|
|
87
|
+
}),
|
|
88
|
+
ports: project.ports || []
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
process.stdout.write("Container already exists\n");
|
|
93
|
+
}
|
|
94
|
+
if (container) {
|
|
95
|
+
const { State: { Status } } = await container.inspect();
|
|
96
|
+
if (Status === "created" || Status === "exited") {
|
|
97
|
+
await container.start();
|
|
98
|
+
await this.appEventsService.emit("project:start", project);
|
|
99
|
+
}
|
|
74
100
|
}
|
|
75
|
-
} = await container.inspect();
|
|
76
|
-
if (Status === "created" || Status === "exited") {
|
|
77
|
-
await container.start();
|
|
78
|
-
await this.appEventsService.emit("project:start", project);
|
|
79
|
-
}
|
|
80
101
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
102
|
+
async stop() {
|
|
103
|
+
const project = await this.get();
|
|
104
|
+
const container = await makes_1.Docker.getContainer(project.containerName);
|
|
105
|
+
if (container) {
|
|
106
|
+
await this.appEventsService.emit("project:stop", project);
|
|
107
|
+
await makes_1.Docker.removeContainer(`${project.name}.workspace`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async save(project) {
|
|
111
|
+
if (!project.name) {
|
|
112
|
+
throw new Error("Project should has a name");
|
|
113
|
+
}
|
|
114
|
+
if (!project.path) {
|
|
115
|
+
throw new Error("Project should has a path");
|
|
116
|
+
}
|
|
117
|
+
if (!project.id) {
|
|
118
|
+
project.id = project.name;
|
|
119
|
+
}
|
|
120
|
+
const projectDirPath = this.appConfigService.dataPath("projects", project.id);
|
|
121
|
+
const configPath = this.appConfigService.dataPath("projects", project.id, "config.json");
|
|
122
|
+
if (!makes_1.FS.existsSync(projectDirPath)) {
|
|
123
|
+
await makes_1.FS.mkdir(projectDirPath, {
|
|
124
|
+
recursive: true
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
await this.appConfigService.setProjectConfig(project.id, project.path);
|
|
128
|
+
await makes_1.FS.writeJSON(configPath, project);
|
|
129
|
+
}
|
|
130
|
+
async search(params = {}) {
|
|
131
|
+
const { id, name, path } = params;
|
|
132
|
+
const { projects: configs } = await this.appConfigService.getAppConfig();
|
|
133
|
+
const projects = [];
|
|
134
|
+
for (const config of configs) {
|
|
135
|
+
if (id && config.id !== id) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (path && config.src !== path) {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const projectData = await makes_1.FS.readJSON(this.appConfigService.dataPath("projects", config.id, "config.json"));
|
|
142
|
+
if (name && projectData.name !== name) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const project = makes_1.Project.fromObject({
|
|
146
|
+
id: config.id,
|
|
147
|
+
...projectData
|
|
148
|
+
});
|
|
149
|
+
projects.push(project);
|
|
150
|
+
}
|
|
151
|
+
return projects;
|
|
88
152
|
}
|
|
89
|
-
}
|
|
90
153
|
}
|
|
91
|
-
exports.ProjectService = ProjectService;
|
|
154
|
+
exports.ProjectService = ProjectService;
|
package/lib/services/index.d.ts
CHANGED
package/lib/services/index.js
CHANGED
|
@@ -1,38 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.keys(_AppConfigService).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _AppConfigService[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _AppConfigService[key];
|
|
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]; } };
|
|
14
7
|
}
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (key in exports && exports[key] === _ProjectService[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _ProjectService[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AppConfigService"), exports);
|
|
18
|
+
__exportStar(require("./AppEventsService"), exports);
|
|
19
|
+
__exportStar(require("./DockerService"), exports);
|
|
20
|
+
__exportStar(require("./LogService"), exports);
|
|
21
|
+
__exportStar(require("./PluginService"), exports);
|
|
22
|
+
__exportStar(require("./PresetService"), exports);
|
|
23
|
+
__exportStar(require("./ProjectService"), exports);
|
package/lib/types/Config.d.ts
CHANGED
package/lib/types/Config.js
CHANGED
package/lib/types/EnvConfig.js
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.keys(_Config).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _Config[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _Config[key];
|
|
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]; } };
|
|
14
7
|
}
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
});
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Config"), exports);
|
|
18
|
+
__exportStar(require("./EnvConfig"), exports);
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.buildOptions = void 0;
|
|
7
4
|
const buildOptions = (name, options) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
return Object.keys(options).map((key) => {
|
|
6
|
+
return `--${name} ${key}=${options[key]}`;
|
|
7
|
+
}).join(" ");
|
|
11
8
|
};
|
|
12
|
-
exports.buildOptions = buildOptions;
|
|
9
|
+
exports.buildOptions = buildOptions;
|
package/lib/utils/demuxOutput.js
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.demuxOutput = void 0;
|
|
7
|
-
const demuxOutput = buffer => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return out;
|
|
22
|
-
}
|
|
23
|
-
return output;
|
|
4
|
+
const demuxOutput = (buffer) => {
|
|
5
|
+
let nextDataLength = null, output = Buffer.from([]);
|
|
6
|
+
while (buffer.length > 0) {
|
|
7
|
+
const header = bufferSlice(8);
|
|
8
|
+
nextDataLength = header.readUInt32BE(4);
|
|
9
|
+
const content = bufferSlice(nextDataLength);
|
|
10
|
+
output = Buffer.concat([output, content]);
|
|
11
|
+
}
|
|
12
|
+
function bufferSlice(end) {
|
|
13
|
+
const out = buffer.slice(0, end);
|
|
14
|
+
buffer = Buffer.from(buffer.slice(end, buffer.length));
|
|
15
|
+
return out;
|
|
16
|
+
}
|
|
17
|
+
return output;
|
|
24
18
|
};
|
|
25
|
-
exports.demuxOutput = demuxOutput;
|
|
19
|
+
exports.demuxOutput = demuxOutput;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.escapeRegExp = void 0;
|
|
7
|
-
const escapeRegExp = string => {
|
|
8
|
-
|
|
4
|
+
const escapeRegExp = (string) => {
|
|
5
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9
6
|
};
|
|
10
|
-
exports.escapeRegExp = escapeRegExp;
|
|
7
|
+
exports.escapeRegExp = escapeRegExp;
|
package/lib/utils/exec.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const exec: (command:
|
|
1
|
+
declare const exec: (command: string) => Promise<unknown>;
|
|
2
2
|
export { exec };
|
package/lib/utils/exec.js
CHANGED
|
@@ -1,44 +1,42 @@
|
|
|
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.exec = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
_Logger.Logger.info("exit", _chalk.default.red(code));
|
|
7
|
+
const core_1 = require("@wocker/core");
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const exec = async (command) => {
|
|
11
|
+
core_1.Logger.info(` > ${command.trim().replace(/\s+/g, " ")}`);
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const worker = (0, child_process_1.exec)(command, {
|
|
14
|
+
maxBuffer: Infinity
|
|
15
|
+
}, (err, stdout, stderr) => {
|
|
16
|
+
if (err) {
|
|
17
|
+
return reject(err);
|
|
18
|
+
}
|
|
19
|
+
return resolve({
|
|
20
|
+
stdout,
|
|
21
|
+
stderr
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
if (worker.stdout) {
|
|
25
|
+
worker.stdout.on("data", (data) => {
|
|
26
|
+
process.stdout.write(data);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (worker.stderr) {
|
|
30
|
+
worker.stderr.on("data", (data) => {
|
|
31
|
+
process.stderr.write(data);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
worker.on("close", (code) => {
|
|
35
|
+
core_1.Logger.info("close", chalk_1.default.red(code));
|
|
36
|
+
});
|
|
37
|
+
worker.on("exit", (code) => {
|
|
38
|
+
core_1.Logger.info("exit", chalk_1.default.red(code));
|
|
39
|
+
});
|
|
41
40
|
});
|
|
42
|
-
});
|
|
43
41
|
};
|
|
44
|
-
exports.exec = exec;
|
|
42
|
+
exports.exec = exec;
|
package/lib/utils/fetch.js
CHANGED
|
@@ -1,37 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
5
17
|
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.fetch = void 0;
|
|
7
|
-
|
|
8
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
+
const https = __importStar(require("https"));
|
|
10
28
|
const fetch = async (url, options) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const { method = "GET" } = options || {};
|
|
30
|
+
const target = new URL(url);
|
|
31
|
+
const params = {
|
|
32
|
+
method,
|
|
33
|
+
protocol: target.protocol,
|
|
34
|
+
hostname: target.hostname,
|
|
35
|
+
port: target.port,
|
|
36
|
+
path: target.pathname
|
|
37
|
+
};
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
const req = https.request(params, (res) => {
|
|
40
|
+
let body = "";
|
|
41
|
+
res.on("data", (data) => {
|
|
42
|
+
body += data;
|
|
43
|
+
});
|
|
44
|
+
res.on("end", () => {
|
|
45
|
+
resolve(body);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
req.on("error", reject);
|
|
49
|
+
req.end();
|
|
31
50
|
});
|
|
32
|
-
req.on("error", reject);
|
|
33
|
-
req.end();
|
|
34
|
-
});
|
|
35
51
|
};
|
|
36
52
|
exports.fetch = fetch;
|
|
37
|
-
class Response {}
|