@wocker/ws 1.0.8 → 1.0.10
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/bin/ws.js +1 -12
- package/lib/AppModule.js +6 -3
- package/lib/controllers/DebugController.d.ts +8 -0
- package/lib/controllers/DebugController.js +46 -0
- package/lib/controllers/ImageController.js +1 -1
- package/lib/controllers/PluginController.d.ts +2 -0
- package/lib/controllers/PluginController.js +42 -41
- package/lib/controllers/PresetController.d.ts +1 -0
- package/lib/controllers/PresetController.js +67 -6
- package/lib/controllers/ProjectController.d.ts +2 -3
- package/lib/controllers/ProjectController.js +58 -68
- package/lib/controllers/ProxyController.js +15 -6
- package/lib/controllers/index.d.ts +1 -0
- package/lib/controllers/index.js +1 -0
- package/lib/main.d.ts +1 -1
- package/lib/main.js +22 -2
- package/lib/makes/FS.d.ts +3 -5
- package/lib/makes/FS.js +3 -21
- package/lib/makes/Http.d.ts +18 -0
- package/lib/makes/Http.js +72 -0
- package/lib/makes/Preset.d.ts +2 -2
- package/lib/makes/index.d.ts +1 -0
- package/lib/makes/index.js +1 -0
- package/lib/plugins/index.d.ts +0 -2
- package/lib/plugins/index.js +0 -2
- package/lib/services/AppConfigService.d.ts +6 -16
- package/lib/services/AppConfigService.js +29 -113
- package/lib/services/DockerService.d.ts +2 -1
- package/lib/services/DockerService.js +31 -11
- package/lib/services/PluginService.d.ts +9 -2
- package/lib/services/PluginService.js +85 -3
- package/lib/services/PresetService.d.ts +1 -2
- package/lib/services/PresetService.js +19 -7
- package/lib/services/ProjectService.js +18 -13
- package/lib/utils/exec.d.ts +4 -1
- package/lib/utils/exec.js +16 -31
- package/lib/utils/followProgress.js +49 -45
- package/lib/utils/index.d.ts +0 -6
- package/lib/utils/index.js +0 -6
- package/lib/utils/spawn.d.ts +1 -1
- package/lib/utils/spawn.js +20 -12
- package/package.json +4 -6
- package/presets/php-apache/Dockerfile +1 -1
- package/presets/php-apache/config.json +2 -1
- package/lib/App.d.ts +0 -11
- package/lib/App.js +0 -81
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -22
- package/lib/plugins/NgrokPlugin.d.ts +0 -37
- package/lib/plugins/NgrokPlugin.js +0 -254
- package/lib/plugins/RedisPlugin.d.ts +0 -16
- package/lib/plugins/RedisPlugin.js +0 -91
- package/lib/utils/buildOptions.d.ts +0 -1
- package/lib/utils/buildOptions.js +0 -9
- package/lib/utils/fetch.d.ts +0 -5
- package/lib/utils/fetch.js +0 -52
- package/lib/utils/get-config.d.ts +0 -2
- package/lib/utils/get-config.js +0 -17
- package/lib/utils/image-build.d.ts +0 -13
- package/lib/utils/image-build.js +0 -46
- package/lib/utils/set-config.d.ts +0 -2
- package/lib/utils/set-config.js +0 -15
- package/lib/utils/tty.d.ts +0 -2
- package/lib/utils/tty.js +0 -6
- package/plugins/ngrok/Dockerfile +0 -2
|
@@ -54,30 +54,33 @@ let ProxyController = class ProxyController {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
async init(httpPort, httpsPort) {
|
|
57
|
+
const config = await this.appConfigService.getConfig();
|
|
57
58
|
if (typeof httpPort === "undefined" || isNaN(httpPort)) {
|
|
58
59
|
httpPort = await (0, utils_1.promptText)({
|
|
59
60
|
required: true,
|
|
60
61
|
message: "Http port:",
|
|
61
62
|
type: "int",
|
|
62
|
-
default:
|
|
63
|
+
default: config.getMeta("PROXY_HTTP_PORT", "80")
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
+
config.setMeta("PROXY_HTTP_PORT", httpPort.toString());
|
|
66
67
|
if (typeof httpsPort === "undefined" || isNaN(httpsPort)) {
|
|
67
68
|
httpsPort = await (0, utils_1.promptText)({
|
|
68
69
|
required: true,
|
|
69
70
|
message: "Https port:",
|
|
70
71
|
type: "int",
|
|
71
|
-
default:
|
|
72
|
+
default: config.getMeta("PROXY_HTTPS_PORT", "443")
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
+
config.setMeta("PROXY_HTTPS_PORT", httpsPort.toString());
|
|
76
|
+
await config.save();
|
|
75
77
|
}
|
|
76
78
|
async start() {
|
|
77
79
|
console.info("Proxy starting...");
|
|
80
|
+
const config = await this.appConfigService.getConfig();
|
|
78
81
|
await this.dockerService.pullImage("nginxproxy/nginx-proxy");
|
|
79
|
-
const httpPort =
|
|
80
|
-
const httpsPort =
|
|
82
|
+
const httpPort = config.getMeta("PROXY_HTTP_PORT", "80");
|
|
83
|
+
const httpsPort = config.getMeta("PROXY_HTTPS_PORT", "443");
|
|
81
84
|
let container = await this.dockerService.getContainer(this.containerName);
|
|
82
85
|
if (!container) {
|
|
83
86
|
const certsDir = this.appConfigService.dataPath("certs");
|
|
@@ -217,6 +220,12 @@ __decorate([
|
|
|
217
220
|
__metadata("design:paramtypes", []),
|
|
218
221
|
__metadata("design:returntype", Promise)
|
|
219
222
|
], ProxyController.prototype, "getProjectNames", null);
|
|
223
|
+
__decorate([
|
|
224
|
+
(0, core_1.Command)("domains"),
|
|
225
|
+
__metadata("design:type", Function),
|
|
226
|
+
__metadata("design:paramtypes", [String, Array]),
|
|
227
|
+
__metadata("design:returntype", Promise)
|
|
228
|
+
], ProxyController.prototype, "getDomains", null);
|
|
220
229
|
__decorate([
|
|
221
230
|
(0, core_1.Command)("proxy:init"),
|
|
222
231
|
__param(0, (0, core_1.Option)("http-port", {
|
package/lib/controllers/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./CompletionController"), exports);
|
|
18
|
+
__exportStar(require("./DebugController"), exports);
|
|
18
19
|
__exportStar(require("./ImageController"), exports);
|
|
19
20
|
__exportStar(require("./PluginController"), exports);
|
|
20
21
|
__exportStar(require("./PresetController"), exports);
|
package/lib/main.d.ts
CHANGED
package/lib/main.js
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.app = void 0;
|
|
4
7
|
const core_1 = require("@wocker/core");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
5
9
|
const AppModule_1 = require("./AppModule");
|
|
10
|
+
const services_1 = require("./services");
|
|
6
11
|
exports.app = {
|
|
7
12
|
async run(args) {
|
|
8
|
-
const
|
|
9
|
-
|
|
13
|
+
const app = await core_1.Factory.create(AppModule_1.AppModule);
|
|
14
|
+
const config = app.get(services_1.AppConfigService);
|
|
15
|
+
const logger = app.get(services_1.LogService);
|
|
16
|
+
try {
|
|
17
|
+
const res = await app.run(args);
|
|
18
|
+
if (res) {
|
|
19
|
+
process.stdout.write(res);
|
|
20
|
+
process.stdout.write("\n");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
console.error(chalk_1.default.red(err.message));
|
|
25
|
+
const { debug } = await config.getConfig();
|
|
26
|
+
if (debug) {
|
|
27
|
+
logger.error(err.stack || err.message);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
10
30
|
}
|
|
11
31
|
};
|
package/lib/makes/FS.d.ts
CHANGED
|
@@ -7,13 +7,11 @@ import { PassThrough } from "readable-stream";
|
|
|
7
7
|
type ReaddirFilesOptions = {
|
|
8
8
|
recursive?: boolean;
|
|
9
9
|
};
|
|
10
|
-
declare class FS extends CoreFS {
|
|
10
|
+
export declare class FS extends CoreFS {
|
|
11
11
|
static access(path: PathLike): Promise<any>;
|
|
12
|
-
static exists(path: PathLike): Promise<boolean>;
|
|
13
12
|
static existsSync(path: PathLike): boolean;
|
|
14
13
|
static mkdir(dirPath: string, options?: MakeDirectoryOptions): Promise<void>;
|
|
15
|
-
static mkdirSync(path:
|
|
16
|
-
static readdir(path: PathLike): Promise<string[]>;
|
|
14
|
+
static mkdirSync(path: string, options?: MakeDirectoryOptions): string;
|
|
17
15
|
static readdirFiles(path: string, options?: ReaddirFilesOptions): Promise<string[]>;
|
|
18
16
|
static appendFile(path: PathOrFileDescriptor, data: any, options?: WriteFileOptions): Promise<unknown>;
|
|
19
17
|
static appendFileSync(path: PathOrFileDescriptor, data: any, options?: WriteFileOptions): void;
|
|
@@ -28,4 +26,4 @@ declare class FS extends CoreFS {
|
|
|
28
26
|
static createReadLinesStream(path: PathLike, count?: number): PassThrough;
|
|
29
27
|
static copyFile(src: PathLike, dest: PathLike): Promise<void>;
|
|
30
28
|
}
|
|
31
|
-
export {
|
|
29
|
+
export {};
|
package/lib/makes/FS.js
CHANGED
|
@@ -41,13 +41,6 @@ class FS extends core_1.FS {
|
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
static async exists(path) {
|
|
45
|
-
return new Promise((resolve) => {
|
|
46
|
-
fs.exists(path, (exists) => {
|
|
47
|
-
resolve(exists);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
44
|
static existsSync(path) {
|
|
52
45
|
return fs.existsSync(path);
|
|
53
46
|
}
|
|
@@ -66,18 +59,6 @@ class FS extends core_1.FS {
|
|
|
66
59
|
static mkdirSync(path, options) {
|
|
67
60
|
return fs.mkdirSync(path, options);
|
|
68
61
|
}
|
|
69
|
-
static async readdir(path) {
|
|
70
|
-
return new Promise((resolve, reject) => {
|
|
71
|
-
fs.readdir(path, (err, files) => {
|
|
72
|
-
if (!err) {
|
|
73
|
-
resolve(files);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
reject(err);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
62
|
static async readdirFiles(path, options) {
|
|
82
63
|
const { recursive = false } = options || {};
|
|
83
64
|
if (recursive) {
|
|
@@ -106,7 +87,8 @@ class FS extends core_1.FS {
|
|
|
106
87
|
withFileTypes: true
|
|
107
88
|
}, (err, files) => {
|
|
108
89
|
if (err) {
|
|
109
|
-
|
|
90
|
+
reject(err);
|
|
91
|
+
return;
|
|
110
92
|
}
|
|
111
93
|
const names = files.filter((dirent) => {
|
|
112
94
|
return dirent.isFile();
|
|
@@ -160,7 +142,7 @@ class FS extends core_1.FS {
|
|
|
160
142
|
reject(err);
|
|
161
143
|
return;
|
|
162
144
|
}
|
|
163
|
-
fs.read(file, buffer, 0, buffer.length, position, (err,
|
|
145
|
+
fs.read(file, buffer, 0, buffer.length, position, (err, _, buffer) => {
|
|
164
146
|
if (err) {
|
|
165
147
|
reject(err);
|
|
166
148
|
return;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AxiosHeaders, AxiosResponse } from "axios";
|
|
2
|
+
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
3
|
+
export declare class Http {
|
|
4
|
+
readonly method: HttpMethod;
|
|
5
|
+
readonly url: string;
|
|
6
|
+
body?: any;
|
|
7
|
+
protected headers: AxiosHeaders;
|
|
8
|
+
private constructor();
|
|
9
|
+
withHeader(name: string, value: string): Http;
|
|
10
|
+
withBody(body: any): Http;
|
|
11
|
+
send(path: string): Promise<AxiosResponse>;
|
|
12
|
+
static get(url: string): Http;
|
|
13
|
+
static post(url: string): Http;
|
|
14
|
+
static put(url: string): Http;
|
|
15
|
+
static patch(url: string): Http;
|
|
16
|
+
static delete(url: string): Http;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
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 __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 });
|
|
26
|
+
exports.Http = void 0;
|
|
27
|
+
const axios_1 = __importStar(require("axios"));
|
|
28
|
+
class Http {
|
|
29
|
+
constructor(method = "GET", url, body) {
|
|
30
|
+
this.method = method;
|
|
31
|
+
this.url = url;
|
|
32
|
+
this.body = body;
|
|
33
|
+
this.headers = new axios_1.AxiosHeaders();
|
|
34
|
+
}
|
|
35
|
+
withHeader(name, value) {
|
|
36
|
+
this.headers.set(name, value);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
withBody(body) {
|
|
40
|
+
this.body = body;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
async send(path) {
|
|
44
|
+
return axios_1.default.create({
|
|
45
|
+
method: this.method,
|
|
46
|
+
baseURL: this.url,
|
|
47
|
+
headers: this.headers.toJSON(),
|
|
48
|
+
validateStatus() {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}).request({
|
|
52
|
+
url: path,
|
|
53
|
+
data: this.body
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
static get(url) {
|
|
57
|
+
return new Http("GET", url);
|
|
58
|
+
}
|
|
59
|
+
static post(url) {
|
|
60
|
+
return new Http("POST", url);
|
|
61
|
+
}
|
|
62
|
+
static put(url) {
|
|
63
|
+
return new Http("PUT", url);
|
|
64
|
+
}
|
|
65
|
+
static patch(url) {
|
|
66
|
+
return new Http("PATCH", url);
|
|
67
|
+
}
|
|
68
|
+
static delete(url) {
|
|
69
|
+
return new Http("DELETE", url);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.Http = Http;
|
package/lib/makes/Preset.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ declare class Preset {
|
|
|
39
39
|
save(): Promise<void>;
|
|
40
40
|
getImageName(buildArgs?: EnvConfig): string;
|
|
41
41
|
static install(ps: PresetService): void;
|
|
42
|
-
static search(options: SearchOptions): Promise<Preset[]>;
|
|
43
|
-
static searchOne(options: SearchOptions): Promise<Preset>;
|
|
42
|
+
static search(options: SearchOptions): Promise<import("@wocker/core").Preset[]>;
|
|
43
|
+
static searchOne(options: SearchOptions): Promise<import("@wocker/core").Preset>;
|
|
44
44
|
}
|
|
45
45
|
export { Preset };
|
package/lib/makes/index.d.ts
CHANGED
package/lib/makes/index.js
CHANGED
|
@@ -15,5 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./FS"), exports);
|
|
18
|
+
__exportStar(require("./Http"), exports);
|
|
18
19
|
__exportStar(require("./Logger"), exports);
|
|
19
20
|
__exportStar(require("./Preset"), exports);
|
package/lib/plugins/index.d.ts
CHANGED
|
@@ -2,7 +2,5 @@ export * from "./ElasticSearchPlugin";
|
|
|
2
2
|
export * from "./LocaltunnelPlugin";
|
|
3
3
|
export * from "./MaildevPlugin";
|
|
4
4
|
export * from "./MongodbPlugin";
|
|
5
|
-
export * from "./NgrokPlugin";
|
|
6
5
|
export * from "./PageKitePlugin";
|
|
7
6
|
export * from "./ProxmoxPlugin";
|
|
8
|
-
export * from "./RedisPlugin";
|
package/lib/plugins/index.js
CHANGED
|
@@ -18,7 +18,5 @@ __exportStar(require("./ElasticSearchPlugin"), exports);
|
|
|
18
18
|
__exportStar(require("./LocaltunnelPlugin"), exports);
|
|
19
19
|
__exportStar(require("./MaildevPlugin"), exports);
|
|
20
20
|
__exportStar(require("./MongodbPlugin"), exports);
|
|
21
|
-
__exportStar(require("./NgrokPlugin"), exports);
|
|
22
21
|
__exportStar(require("./PageKitePlugin"), exports);
|
|
23
22
|
__exportStar(require("./ProxmoxPlugin"), exports);
|
|
24
|
-
__exportStar(require("./RedisPlugin"), exports);
|
|
@@ -1,28 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Config, AppConfigService as CoreAppConfigService } from "@wocker/core";
|
|
2
2
|
type TypeMap = {
|
|
3
3
|
[type: string]: string;
|
|
4
4
|
};
|
|
5
|
-
export declare class AppConfigService {
|
|
5
|
+
export declare class AppConfigService extends CoreAppConfigService {
|
|
6
6
|
protected pwd: string;
|
|
7
7
|
protected mapTypes: TypeMap;
|
|
8
8
|
constructor();
|
|
9
|
-
dataPath(...
|
|
10
|
-
pluginsPath(...
|
|
9
|
+
dataPath(...parts: string[]): string;
|
|
10
|
+
pluginsPath(...parts: string[]): string;
|
|
11
|
+
presetPath(...parts: string[]): string;
|
|
11
12
|
getPWD(): string;
|
|
12
13
|
setPWD(pwd: string): void;
|
|
13
|
-
getAppConfig(): Promise<Config>;
|
|
14
|
-
private saveAppConfig;
|
|
15
|
-
getMeta(name: string, defaultValue?: string): Promise<string>;
|
|
16
|
-
setMeta(name: string, value?: string | number): Promise<void>;
|
|
17
|
-
getAllEnvVariables(): Promise<EnvConfig>;
|
|
18
|
-
getEnvVariable(name: string, defaultValue?: string): Promise<string>;
|
|
19
|
-
setEnv(env: any): Promise<void>;
|
|
20
|
-
setEnvVariable(name: string, value: string | number): Promise<void>;
|
|
21
|
-
unsetEnv(...keys: string[]): Promise<void>;
|
|
22
14
|
getProjectTypes(): TypeMap;
|
|
23
15
|
registerProjectType(name: string, title?: string): void;
|
|
24
|
-
|
|
25
|
-
activatePlugin(name: string): Promise<void>;
|
|
26
|
-
deactivatePlugin(name: string): Promise<void>;
|
|
16
|
+
protected loadConfig(): Promise<Config>;
|
|
27
17
|
}
|
|
28
18
|
export {};
|
|
@@ -37,19 +37,23 @@ const core_1 = require("@wocker/core");
|
|
|
37
37
|
const Path = __importStar(require("path"));
|
|
38
38
|
const env_1 = require("../env");
|
|
39
39
|
const makes_1 = require("../makes");
|
|
40
|
-
let AppConfigService = class AppConfigService {
|
|
40
|
+
let AppConfigService = class AppConfigService extends core_1.AppConfigService {
|
|
41
41
|
constructor() {
|
|
42
|
+
super();
|
|
42
43
|
this.mapTypes = {
|
|
43
44
|
image: "Image",
|
|
44
45
|
dockerfile: "Dockerfile"
|
|
45
46
|
};
|
|
46
47
|
this.pwd = (process.cwd() || process.env.PWD);
|
|
47
48
|
}
|
|
48
|
-
dataPath(...
|
|
49
|
-
return Path.join(env_1.DATA_DIR, ...
|
|
49
|
+
dataPath(...parts) {
|
|
50
|
+
return Path.join(env_1.DATA_DIR, ...parts);
|
|
50
51
|
}
|
|
51
|
-
pluginsPath(...
|
|
52
|
-
return Path.join(env_1.PLUGINS_DIR, ...
|
|
52
|
+
pluginsPath(...parts) {
|
|
53
|
+
return Path.join(env_1.PLUGINS_DIR, ...parts);
|
|
54
|
+
}
|
|
55
|
+
presetPath(...parts) {
|
|
56
|
+
return Path.join(env_1.PRESETS_DIR, ...parts);
|
|
53
57
|
}
|
|
54
58
|
getPWD() {
|
|
55
59
|
return this.pwd;
|
|
@@ -57,121 +61,33 @@ let AppConfigService = class AppConfigService {
|
|
|
57
61
|
setPWD(pwd) {
|
|
58
62
|
this.pwd = pwd;
|
|
59
63
|
}
|
|
60
|
-
async getAppConfig() {
|
|
61
|
-
return makes_1.FS.readJSON(env_1.MAP_PATH);
|
|
62
|
-
}
|
|
63
|
-
async saveAppConfig(config) {
|
|
64
|
-
await makes_1.FS.writeJSON(env_1.MAP_PATH, config);
|
|
65
|
-
}
|
|
66
|
-
async getMeta(name, defaultValue) {
|
|
67
|
-
const config = await this.getAppConfig();
|
|
68
|
-
const value = (config.meta || {})[name];
|
|
69
|
-
if (!value) {
|
|
70
|
-
return defaultValue;
|
|
71
|
-
}
|
|
72
|
-
return value;
|
|
73
|
-
}
|
|
74
|
-
async setMeta(name, value) {
|
|
75
|
-
const config = await this.getAppConfig();
|
|
76
|
-
if (!config.meta) {
|
|
77
|
-
config.meta = {};
|
|
78
|
-
}
|
|
79
|
-
config.meta[name] = value ? value.toString() : undefined;
|
|
80
|
-
await this.saveAppConfig(config);
|
|
81
|
-
}
|
|
82
|
-
async getAllEnvVariables() {
|
|
83
|
-
const { env = {} } = await makes_1.FS.readJSON(env_1.MAP_PATH);
|
|
84
|
-
return env;
|
|
85
|
-
}
|
|
86
|
-
async getEnvVariable(name, defaultValue) {
|
|
87
|
-
const { [name]: value = defaultValue } = await this.getAllEnvVariables();
|
|
88
|
-
if (value === null) {
|
|
89
|
-
return defaultValue;
|
|
90
|
-
}
|
|
91
|
-
return value;
|
|
92
|
-
}
|
|
93
|
-
async setEnv(env) {
|
|
94
|
-
const config = await makes_1.FS.readJSON(env_1.MAP_PATH);
|
|
95
|
-
await makes_1.FS.writeJSON(env_1.MAP_PATH, {
|
|
96
|
-
...config,
|
|
97
|
-
env: {
|
|
98
|
-
...config.env || {},
|
|
99
|
-
...env
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
async setEnvVariable(name, value) {
|
|
104
|
-
const config = await makes_1.FS.readJSON(env_1.MAP_PATH);
|
|
105
|
-
await makes_1.FS.writeJSON(env_1.MAP_PATH, {
|
|
106
|
-
...config,
|
|
107
|
-
env: {
|
|
108
|
-
...config.env || {},
|
|
109
|
-
[name]: value
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
async unsetEnv(...keys) {
|
|
114
|
-
const config = await makes_1.FS.readJSON(env_1.MAP_PATH);
|
|
115
|
-
await makes_1.FS.writeJSON(env_1.MAP_PATH, {
|
|
116
|
-
...config,
|
|
117
|
-
env: Object.keys(config.env || {}).reduce((res, key) => {
|
|
118
|
-
if (!keys.includes(key)) {
|
|
119
|
-
res[key] = config.env[key];
|
|
120
|
-
}
|
|
121
|
-
return res;
|
|
122
|
-
}, {})
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
64
|
getProjectTypes() {
|
|
126
65
|
return this.mapTypes;
|
|
127
66
|
}
|
|
128
67
|
registerProjectType(name, title) {
|
|
129
68
|
this.mapTypes[name] = title || name;
|
|
130
69
|
}
|
|
131
|
-
async
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
id: id,
|
|
143
|
-
src: path
|
|
70
|
+
async loadConfig() {
|
|
71
|
+
const data = makes_1.FS.existsSync(env_1.MAP_PATH)
|
|
72
|
+
? await makes_1.FS.readJSON(env_1.MAP_PATH)
|
|
73
|
+
: {};
|
|
74
|
+
return new class extends core_1.Config {
|
|
75
|
+
constructor(data) {
|
|
76
|
+
super(data);
|
|
77
|
+
}
|
|
78
|
+
addPlugin(plugin) {
|
|
79
|
+
if (!this.plugins) {
|
|
80
|
+
this.plugins = [];
|
|
144
81
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
await makes_1.FS.writeJSON(env_1.MAP_PATH, {
|
|
155
|
-
plugins: [
|
|
156
|
-
...plugins.filter((plugin) => {
|
|
157
|
-
return plugin !== name;
|
|
158
|
-
}),
|
|
159
|
-
name
|
|
160
|
-
],
|
|
161
|
-
...rest
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
async deactivatePlugin(name) {
|
|
165
|
-
const { plugins = [], ...rest } = await this.getAppConfig();
|
|
166
|
-
if (!plugins.includes(name)) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
await makes_1.FS.writeJSON(env_1.MAP_PATH, {
|
|
170
|
-
plugins: plugins.filter((plugin) => {
|
|
171
|
-
return plugin !== name;
|
|
172
|
-
}),
|
|
173
|
-
...rest
|
|
174
|
-
});
|
|
82
|
+
if (this.plugins.includes(plugin)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.plugins.push(plugin);
|
|
86
|
+
}
|
|
87
|
+
async save() {
|
|
88
|
+
await makes_1.FS.writeJSON(env_1.MAP_PATH, this.toJson());
|
|
89
|
+
}
|
|
90
|
+
}(data);
|
|
175
91
|
}
|
|
176
92
|
};
|
|
177
93
|
exports.AppConfigService = AppConfigService;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import Docker, { Container } from "dockerode";
|
|
4
3
|
import { DockerServiceParams as Params } from "@wocker/core";
|
|
4
|
+
import Docker, { Container } from "dockerode";
|
|
5
5
|
import { LogService } from "./LogService";
|
|
6
6
|
export declare class DockerService {
|
|
7
7
|
protected readonly logService: LogService;
|
|
@@ -16,6 +16,7 @@ export declare class DockerService {
|
|
|
16
16
|
imageLs(options?: Params.ImageList): Promise<Docker.ImageInfo[]>;
|
|
17
17
|
pullImage(tag: string): Promise<void>;
|
|
18
18
|
attach(name: string): Promise<void>;
|
|
19
|
+
logs(name: string): Promise<void>;
|
|
19
20
|
attachStream(stream: NodeJS.ReadWriteStream): Promise<void>;
|
|
20
21
|
exec(name: string, args?: string[], tty?: boolean): Promise<import("stream").Duplex>;
|
|
21
22
|
}
|
|
@@ -13,9 +13,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.DockerService = void 0;
|
|
16
|
-
const dockerode_1 = __importDefault(require("dockerode"));
|
|
17
16
|
const core_1 = require("@wocker/core");
|
|
18
|
-
const utils_1 = require("
|
|
17
|
+
const utils_1 = require("@wocker/utils");
|
|
18
|
+
const dockerode_1 = __importDefault(require("dockerode"));
|
|
19
|
+
const utils_2 = require("../utils");
|
|
19
20
|
const makes_1 = require("../makes");
|
|
20
21
|
const LogService_1 = require("./LogService");
|
|
21
22
|
let DockerService = class DockerService {
|
|
@@ -159,7 +160,7 @@ let DockerService = class DockerService {
|
|
|
159
160
|
}, {}),
|
|
160
161
|
dockerfile: src
|
|
161
162
|
});
|
|
162
|
-
await (0,
|
|
163
|
+
await (0, utils_2.followProgress)(stream);
|
|
163
164
|
}
|
|
164
165
|
async imageExists(tag) {
|
|
165
166
|
const image = this.docker.getImage(tag);
|
|
@@ -209,17 +210,21 @@ let DockerService = class DockerService {
|
|
|
209
210
|
return;
|
|
210
211
|
}
|
|
211
212
|
const stream = await this.docker.pull(tag);
|
|
212
|
-
await (0,
|
|
213
|
+
await (0, utils_2.followProgress)(stream);
|
|
213
214
|
}
|
|
214
215
|
async attach(name) {
|
|
215
216
|
const container = await this.getContainer(name);
|
|
217
|
+
if (!container) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
216
220
|
const stream = await container.attach({
|
|
217
221
|
logs: true,
|
|
218
222
|
stream: true,
|
|
219
223
|
hijack: true,
|
|
220
224
|
stdin: true,
|
|
221
225
|
stdout: true,
|
|
222
|
-
stderr: true
|
|
226
|
+
stderr: true,
|
|
227
|
+
detachKeys: "ctrl-c"
|
|
223
228
|
});
|
|
224
229
|
process.stdin.resume();
|
|
225
230
|
process.stdin.setEncoding("utf8");
|
|
@@ -230,12 +235,8 @@ let DockerService = class DockerService {
|
|
|
230
235
|
process.stdin.setRawMode(false);
|
|
231
236
|
}
|
|
232
237
|
});
|
|
233
|
-
stream.
|
|
234
|
-
|
|
235
|
-
const [width, height] = process.stdout.getWindowSize();
|
|
236
|
-
await container.resize({
|
|
237
|
-
w: width,
|
|
238
|
-
h: height
|
|
238
|
+
stream.on("data", (data) => {
|
|
239
|
+
process.stdout.write((0, utils_1.demuxOutput)(data));
|
|
239
240
|
});
|
|
240
241
|
stream.on("end", async () => {
|
|
241
242
|
process.exit();
|
|
@@ -247,6 +248,25 @@ let DockerService = class DockerService {
|
|
|
247
248
|
h: height
|
|
248
249
|
});
|
|
249
250
|
});
|
|
251
|
+
const [width, height] = process.stdout.getWindowSize();
|
|
252
|
+
await container.resize({
|
|
253
|
+
w: width,
|
|
254
|
+
h: height
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
async logs(name) {
|
|
258
|
+
const container = await this.getContainer(name);
|
|
259
|
+
if (!container) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const stream = await container.logs({
|
|
263
|
+
stdout: true,
|
|
264
|
+
stderr: true,
|
|
265
|
+
follow: true
|
|
266
|
+
});
|
|
267
|
+
stream.on("data", (data) => {
|
|
268
|
+
process.stdout.write((0, utils_1.demuxOutput)(data));
|
|
269
|
+
});
|
|
250
270
|
}
|
|
251
271
|
async attachStream(stream) {
|
|
252
272
|
process.stdin.resume();
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { Cli } from "@wocker/core";
|
|
2
|
+
import { AppConfigService } from "./AppConfigService";
|
|
3
|
+
import { LogService } from "./LogService";
|
|
2
4
|
export declare class PluginService {
|
|
5
|
+
protected readonly appConfigService: AppConfigService;
|
|
6
|
+
protected readonly logService: LogService;
|
|
3
7
|
protected readonly cli: Cli;
|
|
4
|
-
constructor(cli: Cli);
|
|
5
|
-
|
|
8
|
+
constructor(appConfigService: AppConfigService, logService: LogService, cli: Cli);
|
|
9
|
+
checkPlugin(pluginName: string): Promise<boolean>;
|
|
10
|
+
import(): Promise<void>;
|
|
11
|
+
update(): Promise<void>;
|
|
12
|
+
protected getCurrentVersion(name: string): Promise<string | null>;
|
|
6
13
|
}
|