@wocker/ws 1.0.1
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/LICENSE +21 -0
- package/README.md +155 -0
- package/bin/ws.js +13 -0
- package/lib/App.d.ts +13 -0
- package/lib/App.js +52 -0
- package/lib/controllers/ImageController.d.ts +8 -0
- package/lib/controllers/ImageController.js +29 -0
- package/lib/controllers/ProjectController.d.ts +64 -0
- package/lib/controllers/ProjectController.js +561 -0
- package/lib/controllers/index.d.ts +2 -0
- package/lib/controllers/index.js +27 -0
- package/lib/env.d.ts +7 -0
- package/lib/env.js +24 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +31 -0
- package/lib/makes/Controller.d.ts +5 -0
- package/lib/makes/Controller.js +12 -0
- package/lib/makes/Docker.d.ts +58 -0
- package/lib/makes/Docker.js +418 -0
- package/lib/makes/FS.d.ts +37 -0
- package/lib/makes/FS.js +317 -0
- package/lib/makes/LineConvertStream.d.ts +13 -0
- package/lib/makes/LineConvertStream.js +45 -0
- package/lib/makes/Logger.d.ts +7 -0
- package/lib/makes/Logger.js +39 -0
- package/lib/makes/Model.d.ts +5 -0
- package/lib/makes/Model.js +16 -0
- package/lib/makes/MySQL.d.ts +15 -0
- package/lib/makes/MySQL.js +31 -0
- package/lib/makes/Plugin.d.ts +13 -0
- package/lib/makes/Plugin.js +43 -0
- package/lib/makes/Repository.d.ts +11 -0
- package/lib/makes/Repository.js +25 -0
- package/lib/makes/index.d.ts +6 -0
- package/lib/makes/index.js +71 -0
- package/lib/models/Preset.d.ts +19 -0
- package/lib/models/Preset.js +60 -0
- package/lib/models/Project.d.ts +38 -0
- package/lib/models/Project.js +151 -0
- package/lib/models/index.d.ts +2 -0
- package/lib/models/index.js +27 -0
- package/lib/plugins/LocaltunnelPlugin.d.ts +36 -0
- package/lib/plugins/LocaltunnelPlugin.js +273 -0
- package/lib/plugins/MaildevPlugin.d.ts +10 -0
- package/lib/plugins/MaildevPlugin.js +45 -0
- package/lib/plugins/MariadbPlugin.d.ts +25 -0
- package/lib/plugins/MariadbPlugin.js +297 -0
- package/lib/plugins/MongodbPlugin.d.ts +20 -0
- package/lib/plugins/MongodbPlugin.js +271 -0
- package/lib/plugins/NgrokPlugin.d.ts +37 -0
- package/lib/plugins/NgrokPlugin.js +248 -0
- package/lib/plugins/PageKitePlugin.d.ts +31 -0
- package/lib/plugins/PageKitePlugin.js +158 -0
- package/lib/plugins/PostgresPlugin.d.ts +16 -0
- package/lib/plugins/PostgresPlugin.js +94 -0
- package/lib/plugins/PresetPlugin.d.ts +19 -0
- package/lib/plugins/PresetPlugin.js +164 -0
- package/lib/plugins/ProjectPlugin.d.ts +12 -0
- package/lib/plugins/ProjectPlugin.js +54 -0
- package/lib/plugins/ProxmoxPlugin.d.ts +9 -0
- package/lib/plugins/ProxmoxPlugin.js +55 -0
- package/lib/plugins/ProxyPlugin.d.ts +33 -0
- package/lib/plugins/ProxyPlugin.js +257 -0
- package/lib/plugins/RedisPlugin.d.ts +10 -0
- package/lib/plugins/RedisPlugin.js +42 -0
- package/lib/plugins/ServeoPlugin.d.ts +36 -0
- package/lib/plugins/ServeoPlugin.js +260 -0
- package/lib/plugins/TestPlugin.d.ts +10 -0
- package/lib/plugins/TestPlugin.js +75 -0
- package/lib/plugins/index.d.ts +14 -0
- package/lib/plugins/index.js +159 -0
- package/lib/services/AppConfigService.d.ts +18 -0
- package/lib/services/AppConfigService.js +77 -0
- package/lib/services/AppEventsService.d.ts +13 -0
- package/lib/services/AppEventsService.js +29 -0
- package/lib/services/ProjectService.d.ts +13 -0
- package/lib/services/ProjectService.js +91 -0
- package/lib/services/index.d.ts +3 -0
- package/lib/services/index.js +38 -0
- package/lib/types/Config.d.ts +11 -0
- package/lib/types/Config.js +5 -0
- package/lib/types/EnvConfig.d.ts +3 -0
- package/lib/types/EnvConfig.js +5 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +27 -0
- package/lib/utils/buildOptions.d.ts +1 -0
- package/lib/utils/buildOptions.js +12 -0
- package/lib/utils/demuxOutput.d.ts +2 -0
- package/lib/utils/demuxOutput.js +25 -0
- package/lib/utils/escapeRegExp.d.ts +2 -0
- package/lib/utils/escapeRegExp.js +10 -0
- package/lib/utils/exec.d.ts +2 -0
- package/lib/utils/exec.js +44 -0
- package/lib/utils/fetch.d.ts +5 -0
- package/lib/utils/fetch.js +37 -0
- package/lib/utils/followProgress.d.ts +6 -0
- package/lib/utils/followProgress.js +80 -0
- package/lib/utils/format-size-units.d.ts +1 -0
- package/lib/utils/format-size-units.js +19 -0
- package/lib/utils/get-config.d.ts +2 -0
- package/lib/utils/get-config.js +20 -0
- package/lib/utils/get-cursor-position.d.ts +4 -0
- package/lib/utils/get-cursor-position.js +34 -0
- package/lib/utils/image-build.d.ts +13 -0
- package/lib/utils/image-build.js +34 -0
- package/lib/utils/index.d.ts +21 -0
- package/lib/utils/index.js +236 -0
- package/lib/utils/injectVariables.d.ts +5 -0
- package/lib/utils/injectVariables.js +17 -0
- package/lib/utils/parse-table.d.ts +2 -0
- package/lib/utils/parse-table.js +27 -0
- package/lib/utils/promptConfirm.d.ts +6 -0
- package/lib/utils/promptConfirm.js +21 -0
- package/lib/utils/promptGroup.d.ts +16 -0
- package/lib/utils/promptGroup.js +39 -0
- package/lib/utils/promptSelect.d.ts +12 -0
- package/lib/utils/promptSelect.js +47 -0
- package/lib/utils/promptText.d.ts +13 -0
- package/lib/utils/promptText.js +53 -0
- package/lib/utils/set-config.d.ts +2 -0
- package/lib/utils/set-config.js +18 -0
- package/lib/utils/spawn.d.ts +2 -0
- package/lib/utils/spawn.js +24 -0
- package/lib/utils/tty.d.ts +2 -0
- package/lib/utils/tty.js +10 -0
- package/lib/utils/volumeFormat.d.ts +6 -0
- package/lib/utils/volumeFormat.js +15 -0
- package/lib/utils/volumeParse.d.ts +2 -0
- package/lib/utils/volumeParse.js +16 -0
- package/package.json +90 -0
- package/plugins/localtunnel/Dockerfile +37 -0
- package/plugins/localtunnel/Ubuntu.dockerfile +34 -0
- package/plugins/localtunnel/config.json +3 -0
- package/plugins/maildev/Dockerfile +5 -0
- package/plugins/maildev/config.json +3 -0
- package/plugins/mariadb/admin/conf/config.user.inc.php +9 -0
- package/plugins/ngrok/Dockerfile +2 -0
- package/plugins/pagekite/Dockerfile +3 -0
- package/plugins/proxmox/Dockerfile +35 -0
- package/plugins/proxy/Dockerfile +7 -0
- package/plugins/proxy/config.json +3 -0
- package/plugins/serveo/Dockerfile +17 -0
- package/presets/apache/.docker/apache2/apache2.conf +230 -0
- package/presets/apache/.docker/apache2/mods-available/mpm_prefork.conf +16 -0
- package/presets/apache/.docker/apache2/sites-available/000-default.conf.conf +21 -0
- package/presets/apache/Dockerfile +110 -0
- package/presets/apache/bin/compare-version +3 -0
- package/presets/apache/config.json +47 -0
- package/presets/go/Dockerfile +19 -0
- package/presets/go/config.json +13 -0
- package/presets/node/Dockerfile +37 -0
- package/presets/node/config.json +36 -0
- package/presets/php-apache/Dockerfile +133 -0
- package/presets/php-apache/bin/compare-version +3 -0
- package/presets/php-apache/config.json +56 -0
- package/presets/php-apache/etc/apache2/apache2.conf +230 -0
- package/presets/php-apache/etc/apache2/mods-available/mpm_prefork.conf +16 -0
- package/presets/php-apache/etc/apache2/sites-available/000-default.conf +21 -0
- package/presets/shopify/Dockerfile +160 -0
- package/presets/shopify/bin/compare-version +3 -0
- package/presets/shopify/config.json +24 -0
- package/presets/shopify/etc/apache2/apache2.conf +230 -0
- package/presets/shopify/etc/apache2/mods-available/mpm_prefork.conf +16 -0
- package/presets/shopify/etc/apache2/sites-available/000-default.conf +21 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ProjectService = void 0;
|
|
7
|
+
var Path = _interopRequireWildcard(require("path"));
|
|
8
|
+
var _makes = require("../makes");
|
|
9
|
+
var _models = require("../models");
|
|
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; }
|
|
12
|
+
class ProjectService {
|
|
13
|
+
constructor(appConfigService, appEventsService) {
|
|
14
|
+
this.appConfigService = appConfigService;
|
|
15
|
+
this.appEventsService = appEventsService;
|
|
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");
|
|
23
|
+
}
|
|
24
|
+
this.appConfigService.setPWD(project.path);
|
|
25
|
+
}
|
|
26
|
+
async get() {
|
|
27
|
+
const project = await _models.Project.searchOne({
|
|
28
|
+
src: this.appConfigService.getPWD()
|
|
29
|
+
});
|
|
30
|
+
if (!project) {
|
|
31
|
+
throw new Error("Project not found");
|
|
32
|
+
}
|
|
33
|
+
return project;
|
|
34
|
+
}
|
|
35
|
+
async start() {
|
|
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
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
await this.appEventsService.emit("project:beforeStart", project);
|
|
51
|
+
const containerName = `${project.name}.workspace`;
|
|
52
|
+
let container = await _makes.Docker.getContainer(containerName);
|
|
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");
|
|
69
|
+
}
|
|
70
|
+
if (container) {
|
|
71
|
+
const {
|
|
72
|
+
State: {
|
|
73
|
+
Status
|
|
74
|
+
}
|
|
75
|
+
} = await container.inspect();
|
|
76
|
+
if (Status === "created" || Status === "exited") {
|
|
77
|
+
await container.start();
|
|
78
|
+
await this.appEventsService.emit("project:start", project);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async stop() {
|
|
83
|
+
const project = await this.get();
|
|
84
|
+
const container = await _makes.Docker.getContainer(`${project.name}.workspace`);
|
|
85
|
+
if (container) {
|
|
86
|
+
await this.appEventsService.emit("project:stop", project);
|
|
87
|
+
await _makes.Docker.removeContainer(`${project.name}.workspace`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.ProjectService = ProjectService;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _AppConfigService = require("./AppConfigService");
|
|
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];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _AppEventsService = require("./AppEventsService");
|
|
18
|
+
Object.keys(_AppEventsService).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _AppEventsService[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _AppEventsService[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _ProjectService = require("./ProjectService");
|
|
29
|
+
Object.keys(_ProjectService).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
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
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _Config = require("./Config");
|
|
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];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _EnvConfig = require("./EnvConfig");
|
|
18
|
+
Object.keys(_EnvConfig).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _EnvConfig[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _EnvConfig[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const buildOptions: (name: string, options: any) => string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildOptions = void 0;
|
|
7
|
+
const buildOptions = (name, options) => {
|
|
8
|
+
return Object.keys(options).map(key => {
|
|
9
|
+
return `--${name} ${key}=${options[key]}`;
|
|
10
|
+
}).join(" ");
|
|
11
|
+
};
|
|
12
|
+
exports.buildOptions = buildOptions;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.demuxOutput = void 0;
|
|
7
|
+
const demuxOutput = buffer => {
|
|
8
|
+
let nextDataLength = null,
|
|
9
|
+
output = Buffer.from([]);
|
|
10
|
+
while (buffer.length > 0) {
|
|
11
|
+
// Logger.info(buffer.length, buffer.toString("utf8"));
|
|
12
|
+
|
|
13
|
+
const header = bufferSlice(8);
|
|
14
|
+
nextDataLength = header.readUInt32BE(4);
|
|
15
|
+
const content = bufferSlice(nextDataLength);
|
|
16
|
+
output = Buffer.concat([output, content]);
|
|
17
|
+
}
|
|
18
|
+
function bufferSlice(end) {
|
|
19
|
+
const out = buffer.slice(0, end);
|
|
20
|
+
buffer = Buffer.from(buffer.slice(end, buffer.length));
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
return output;
|
|
24
|
+
};
|
|
25
|
+
exports.demuxOutput = demuxOutput;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.exec = void 0;
|
|
7
|
+
var _child_process = require("child_process");
|
|
8
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
+
var _Logger = require("../makes/Logger");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const exec = async command => {
|
|
12
|
+
_Logger.Logger.info(` > ${command.trim().replace(/\s+/g, " ")}`);
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const worker = (0, _child_process.exec)(command, {
|
|
15
|
+
maxBuffer: Infinity
|
|
16
|
+
}, (err, stdout, stderr) => {
|
|
17
|
+
if (err) {
|
|
18
|
+
return reject(err);
|
|
19
|
+
}
|
|
20
|
+
return resolve({
|
|
21
|
+
stdout,
|
|
22
|
+
stderr
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
if (worker.stdout) {
|
|
26
|
+
worker.stdout.on("data", data => {
|
|
27
|
+
process.stdout.write(data);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (worker.stderr) {
|
|
31
|
+
worker.stderr.on("data", data => {
|
|
32
|
+
// process.stdout.write(chalk.red(data));
|
|
33
|
+
process.stderr.write(data);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
worker.on("close", code => {
|
|
37
|
+
_Logger.Logger.info("close", _chalk.default.red(code));
|
|
38
|
+
});
|
|
39
|
+
worker.on("exit", code => {
|
|
40
|
+
_Logger.Logger.info("exit", _chalk.default.red(code));
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
exports.exec = exec;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fetch = void 0;
|
|
7
|
+
var https = _interopRequireWildcard(require("https"));
|
|
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; }
|
|
10
|
+
const fetch = async (url, options) => {
|
|
11
|
+
const {
|
|
12
|
+
method = "GET"
|
|
13
|
+
} = options || {};
|
|
14
|
+
const target = new URL(url);
|
|
15
|
+
const params = {
|
|
16
|
+
method,
|
|
17
|
+
protocol: target.protocol,
|
|
18
|
+
hostname: target.hostname,
|
|
19
|
+
port: target.port,
|
|
20
|
+
path: target.pathname
|
|
21
|
+
};
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
const req = https.request(params, res => {
|
|
24
|
+
let body = "";
|
|
25
|
+
res.on("data", data => {
|
|
26
|
+
body += data;
|
|
27
|
+
});
|
|
28
|
+
res.on("end", () => {
|
|
29
|
+
resolve(body);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
req.on("error", reject);
|
|
33
|
+
req.end();
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
exports.fetch = fetch;
|
|
37
|
+
class Response {}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.followProgress = void 0;
|
|
7
|
+
var _Logger = require("../makes/Logger");
|
|
8
|
+
var _LineConvertStream = require("../makes/LineConvertStream");
|
|
9
|
+
var _formatSizeUnits = require("./format-size-units");
|
|
10
|
+
const followProgress = async stream => {
|
|
11
|
+
const lineStream = new _LineConvertStream.LineConvertStream(stream);
|
|
12
|
+
let line = 0;
|
|
13
|
+
const mapLines = {};
|
|
14
|
+
lineStream.on("data", chunk => {
|
|
15
|
+
const data = JSON.parse(chunk.toString());
|
|
16
|
+
const {
|
|
17
|
+
stream,
|
|
18
|
+
id,
|
|
19
|
+
status,
|
|
20
|
+
progressDetail: {
|
|
21
|
+
current,
|
|
22
|
+
total
|
|
23
|
+
} = {},
|
|
24
|
+
aux
|
|
25
|
+
} = data;
|
|
26
|
+
if (stream) {
|
|
27
|
+
process.stdout.write(`${stream}`);
|
|
28
|
+
line += stream.split("\n").length - 1;
|
|
29
|
+
// line += Math.ceil(stream.length / process.stdout.columns);
|
|
30
|
+
} else if (id) {
|
|
31
|
+
if (typeof mapLines[id] === "undefined") {
|
|
32
|
+
mapLines[id] = line;
|
|
33
|
+
}
|
|
34
|
+
const targetLine = typeof mapLines[id] !== "undefined" ? mapLines[id] : line;
|
|
35
|
+
const dy = line - targetLine;
|
|
36
|
+
if (dy > 0) {
|
|
37
|
+
process.stdout.write("\x1b[s");
|
|
38
|
+
process.stdout.write(`\x1b[${dy}A`);
|
|
39
|
+
}
|
|
40
|
+
process.stdout.write("\x1b[2K");
|
|
41
|
+
let str = `${id}: ${status}\n`;
|
|
42
|
+
if (status === "Downloading") {
|
|
43
|
+
const width = process.stdout.columns;
|
|
44
|
+
const sizeWidth = 19,
|
|
45
|
+
totalWidth = width - id.length - status.length - sizeWidth - 7,
|
|
46
|
+
currentWidth = Math.floor(totalWidth * (current / total)),
|
|
47
|
+
formatSize = `${(0, _formatSizeUnits.formatSizeUnits)(current)}/${(0, _formatSizeUnits.formatSizeUnits)(total)}`;
|
|
48
|
+
str = `${id}: ${status} [${"█".repeat(currentWidth)}${"░".repeat(totalWidth - currentWidth)}] ${formatSize}\n`;
|
|
49
|
+
}
|
|
50
|
+
process.stdout.write(str);
|
|
51
|
+
if (dy > 0) {
|
|
52
|
+
process.stdout.write("\x1b[u");
|
|
53
|
+
} else {
|
|
54
|
+
line++;
|
|
55
|
+
}
|
|
56
|
+
} else if (status) {
|
|
57
|
+
process.stdout.write(`${status}\n`);
|
|
58
|
+
line += Math.ceil(status.length / process.stdout.columns);
|
|
59
|
+
} else if (aux) {
|
|
60
|
+
const str = `auxID: ${aux.ID}`;
|
|
61
|
+
process.stdout.write(`${str}\n`);
|
|
62
|
+
line += Math.ceil(str.length / process.stdout.columns);
|
|
63
|
+
} else {
|
|
64
|
+
_Logger.Logger.warning("followProgress: unexpected data", data);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
let isEnded = false;
|
|
69
|
+
const handleEnd = () => {
|
|
70
|
+
if (!isEnded) {
|
|
71
|
+
resolve(null);
|
|
72
|
+
}
|
|
73
|
+
isEnded = true;
|
|
74
|
+
};
|
|
75
|
+
lineStream.on("end", handleEnd);
|
|
76
|
+
lineStream.on("close", handleEnd);
|
|
77
|
+
lineStream.on("error", reject);
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
exports.followProgress = followProgress;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatSizeUnits: (bytes: number) => string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatSizeUnits = void 0;
|
|
7
|
+
const formatSizeUnits = bytes => {
|
|
8
|
+
if (bytes >= 1073741824) {
|
|
9
|
+
return (bytes / 1073741824).toFixed(2) + "GB";
|
|
10
|
+
} else if (bytes >= 1048576) {
|
|
11
|
+
return (bytes / 1048576).toFixed(2) + "MB";
|
|
12
|
+
} else if (bytes >= 1024) {
|
|
13
|
+
return (bytes / 1024).toFixed(2) + "kB";
|
|
14
|
+
} else if (bytes >= 1) {
|
|
15
|
+
return bytes + "b";
|
|
16
|
+
}
|
|
17
|
+
return "0b";
|
|
18
|
+
};
|
|
19
|
+
exports.formatSizeUnits = formatSizeUnits;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getConfig = void 0;
|
|
7
|
+
var _env = require("../env");
|
|
8
|
+
var _FS = require("../makes/FS");
|
|
9
|
+
const getConfig = async () => {
|
|
10
|
+
return _FS.FS.readJSON(_env.MAP_PATH).catch(err => {
|
|
11
|
+
if (err.code === "ENOENT") {
|
|
12
|
+
return Promise.resolve({
|
|
13
|
+
env: {},
|
|
14
|
+
projects: []
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
throw err;
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
exports.getConfig = getConfig;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCursorPosition = void 0;
|
|
7
|
+
// import {} from "tty";
|
|
8
|
+
|
|
9
|
+
const code = '\x1b[6n';
|
|
10
|
+
const getCursorPosition = async () => {
|
|
11
|
+
process.stdin.resume();
|
|
12
|
+
process.stdin.setRawMode(true);
|
|
13
|
+
const position = {};
|
|
14
|
+
await new Promise((resolve, reject) => {
|
|
15
|
+
const handleData = data => {
|
|
16
|
+
const match = /\[(\d+);(\d+)R$/.exec(data.toString());
|
|
17
|
+
if (match) {
|
|
18
|
+
const [, col, row] = match.slice(1, 3).reverse().map(Number);
|
|
19
|
+
position.row = row;
|
|
20
|
+
position.col = col;
|
|
21
|
+
resolve(undefined);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// process.stdin.setRawMode(false);
|
|
25
|
+
process.stdin.off("data", handleData);
|
|
26
|
+
process.stdin.pause();
|
|
27
|
+
};
|
|
28
|
+
process.stdin.once("data", handleData);
|
|
29
|
+
process.stdout.write(code);
|
|
30
|
+
process.stdout.emit("data", code);
|
|
31
|
+
});
|
|
32
|
+
return position;
|
|
33
|
+
};
|
|
34
|
+
exports.getCursorPosition = getCursorPosition;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.imageBuild = void 0;
|
|
7
|
+
var _exec = require("./exec");
|
|
8
|
+
var Path = _interopRequireWildcard(require("path"));
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
const imageBuild = async options => {
|
|
12
|
+
const {
|
|
13
|
+
tag,
|
|
14
|
+
buildArgs = {},
|
|
15
|
+
labels = {},
|
|
16
|
+
context,
|
|
17
|
+
src
|
|
18
|
+
} = options;
|
|
19
|
+
const buildArgsString = Object.keys(buildArgs).map(key => {
|
|
20
|
+
return `--build-arg ${key}=${buildArgs[key]}`;
|
|
21
|
+
}).join(" ");
|
|
22
|
+
const labelsString = Object.keys(labels).map(key => {
|
|
23
|
+
return `--label ${key}=${labels[key]}`;
|
|
24
|
+
}).join(" ");
|
|
25
|
+
await (0, _exec.exec)(`
|
|
26
|
+
docker build \
|
|
27
|
+
--tag "${tag}" \
|
|
28
|
+
${buildArgsString} \
|
|
29
|
+
${labelsString} \
|
|
30
|
+
--file ${Path.join(context, src)} \
|
|
31
|
+
${context}
|
|
32
|
+
`);
|
|
33
|
+
};
|
|
34
|
+
exports.imageBuild = imageBuild;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from "./buildOptions";
|
|
2
|
+
export * from "./demuxOutput";
|
|
3
|
+
export * from "./escapeRegExp";
|
|
4
|
+
export * from "./exec";
|
|
5
|
+
export * from "./fetch";
|
|
6
|
+
export * from "./followProgress";
|
|
7
|
+
export * from "./format-size-units";
|
|
8
|
+
export * from "./get-config";
|
|
9
|
+
export * from "./get-cursor-position";
|
|
10
|
+
export * from "./image-build";
|
|
11
|
+
export * from "./injectVariables";
|
|
12
|
+
export * from "./parse-table";
|
|
13
|
+
export * from "./promptConfirm";
|
|
14
|
+
export * from "./promptGroup";
|
|
15
|
+
export * from "./promptSelect";
|
|
16
|
+
export * from "./promptText";
|
|
17
|
+
export * from "./set-config";
|
|
18
|
+
export * from "./spawn";
|
|
19
|
+
export * from "./tty";
|
|
20
|
+
export * from "./volumeFormat";
|
|
21
|
+
export * from "./volumeParse";
|