@wocker/ws 1.0.2 → 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 +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/env.js +33 -15
- package/lib/index.d.ts +2 -0
- package/lib/index.js +30 -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.js +328 -304
- 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,45 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.LineConvertStream = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class LineConvertStream extends
|
|
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
|
-
|
|
4
|
+
const stream_1 = require("stream");
|
|
5
|
+
const async_mutex_1 = require("async-mutex");
|
|
6
|
+
class LineConvertStream extends stream_1.Readable {
|
|
7
|
+
constructor(stream) {
|
|
8
|
+
super();
|
|
9
|
+
this.buf = "";
|
|
10
|
+
this.mutex = new async_mutex_1.Mutex();
|
|
11
|
+
this.stream = stream;
|
|
12
|
+
this.stream.on("data", (chunk) => this.process(chunk));
|
|
13
|
+
this.stream.on("end", () => {
|
|
14
|
+
this.push(null);
|
|
15
|
+
});
|
|
16
|
+
this.stream.on("close", () => {
|
|
17
|
+
this.destroy();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
_read(size) {
|
|
21
|
+
}
|
|
22
|
+
async process(chunk) {
|
|
23
|
+
await this.mutex.acquire();
|
|
24
|
+
this.buf += chunk.toString();
|
|
25
|
+
try {
|
|
26
|
+
let pos;
|
|
27
|
+
while ((pos = this.buf.indexOf("\n")) >= 0) {
|
|
28
|
+
if (pos === 0) {
|
|
29
|
+
this.buf = this.buf.slice(0);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const line = this.buf.slice(0, pos);
|
|
33
|
+
this.buf = this.buf.slice(pos + 1);
|
|
34
|
+
this.push(line);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
this.mutex.release();
|
|
35
39
|
}
|
|
36
|
-
const line = this.buf.slice(0, pos);
|
|
37
|
-
this.buf = this.buf.slice(pos + 1);
|
|
38
|
-
this.push(line);
|
|
39
|
-
}
|
|
40
|
-
} finally {
|
|
41
|
-
this.mutex.release();
|
|
42
40
|
}
|
|
43
|
-
}
|
|
44
41
|
}
|
|
45
|
-
exports.LineConvertStream = LineConvertStream;
|
|
42
|
+
exports.LineConvertStream = LineConvertStream;
|
package/lib/makes/Logger.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { DI } from "./DI";
|
|
2
|
+
declare class Logger {
|
|
3
|
+
static install(di: DI): void;
|
|
4
|
+
static log(...data: any[]): void;
|
|
5
|
+
static info(...data: any[]): void;
|
|
6
|
+
static warn(...data: any[]): void;
|
|
7
|
+
static error(...data: any[]): void;
|
|
8
|
+
}
|
|
9
|
+
export { Logger };
|
package/lib/makes/Logger.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = void 0;
|
|
4
|
+
const LogService_1 = require("../services/LogService");
|
|
5
|
+
let _di;
|
|
6
|
+
class Logger {
|
|
7
|
+
static install(di) {
|
|
8
|
+
_di = di;
|
|
9
|
+
}
|
|
10
|
+
static log(...data) {
|
|
11
|
+
_di.resolveService(LogService_1.LogService).log(...data);
|
|
12
|
+
}
|
|
13
|
+
static info(...data) {
|
|
14
|
+
_di.resolveService(LogService_1.LogService).info(...data);
|
|
15
|
+
}
|
|
16
|
+
static warn(...data) {
|
|
17
|
+
_di.resolveService(LogService_1.LogService).warn(...data);
|
|
18
|
+
}
|
|
19
|
+
static error(...data) {
|
|
20
|
+
_di.resolveService(LogService_1.LogService).error(...data);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.Logger = Logger;
|
package/lib/makes/Model.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.Model = void 0;
|
|
7
4
|
class Model {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
5
|
+
constructor(attributes = {}) {
|
|
6
|
+
this.attributes = {};
|
|
7
|
+
this.attributes = attributes;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
}
|
|
15
11
|
}
|
|
16
|
-
exports.Model = Model;
|
|
12
|
+
exports.Model = Model;
|
package/lib/makes/MySQL.js
CHANGED
|
@@ -1,31 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.MySQL = void 0;
|
|
7
|
-
// import {createConnection} from "mysql";
|
|
8
|
-
|
|
9
4
|
class MySQL {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// this.connection.connect();
|
|
15
|
-
//
|
|
16
|
-
// const res = await new Promise((resolve, reject) => {
|
|
17
|
-
// this.connection.query(sql, (err, res) => {
|
|
18
|
-
// if(err) {
|
|
19
|
-
// return reject(err);
|
|
20
|
-
// }
|
|
21
|
-
//
|
|
22
|
-
// return resolve(res);
|
|
23
|
-
// });
|
|
24
|
-
// });
|
|
25
|
-
//
|
|
26
|
-
// this.connection.end();
|
|
27
|
-
//
|
|
28
|
-
// return res;
|
|
29
|
-
}
|
|
5
|
+
constructor(options) {
|
|
6
|
+
}
|
|
7
|
+
async query(sql) {
|
|
8
|
+
}
|
|
30
9
|
}
|
|
31
|
-
exports.MySQL = MySQL;
|
|
10
|
+
exports.MySQL = MySQL;
|
package/lib/makes/Plugin.d.ts
CHANGED
package/lib/makes/Plugin.js
CHANGED
|
@@ -1,43 +1,61 @@
|
|
|
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.Plugin = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
const Path = __importStar(require("path"));
|
|
28
|
+
const env_1 = require("../env");
|
|
29
|
+
const Controller_1 = require("../makes/Controller");
|
|
30
|
+
const FS_1 = require("../makes/FS");
|
|
31
|
+
class Plugin extends Controller_1.Controller {
|
|
32
|
+
constructor(name) {
|
|
33
|
+
super();
|
|
34
|
+
this.certsDir = Path.join(env_1.DATA_DIR, "certs");
|
|
35
|
+
this.dataDir = Path.join(env_1.DATA_DIR, "plugins", name);
|
|
36
|
+
this.pluginDir = Path.join(env_1.PLUGINS_DIR, name);
|
|
37
|
+
}
|
|
38
|
+
install(cli) {
|
|
39
|
+
super.install(cli);
|
|
40
|
+
if (!FS_1.FS.existsSync(this.certsDir)) {
|
|
41
|
+
FS_1.FS.mkdirSync(this.certsDir, {
|
|
42
|
+
recursive: true
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (!FS_1.FS.existsSync(this.dataDir)) {
|
|
46
|
+
FS_1.FS.mkdirSync(this.dataDir, {
|
|
47
|
+
recursive: true
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
certsPath(...paths) {
|
|
52
|
+
return Path.join(this.certsDir, ...paths);
|
|
53
|
+
}
|
|
54
|
+
dataPath(...paths) {
|
|
55
|
+
return Path.join(this.dataDir, ...paths);
|
|
26
56
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
recursive: true
|
|
30
|
-
});
|
|
57
|
+
pluginPath(...paths) {
|
|
58
|
+
return Path.join(this.pluginDir, ...paths);
|
|
31
59
|
}
|
|
32
|
-
}
|
|
33
|
-
certsPath(...paths) {
|
|
34
|
-
return Path.join(this.certsDir, ...paths);
|
|
35
|
-
}
|
|
36
|
-
dataPath(...paths) {
|
|
37
|
-
return Path.join(this.dataDir, ...paths);
|
|
38
|
-
}
|
|
39
|
-
pluginPath(...paths) {
|
|
40
|
-
return Path.join(this.pluginDir, ...paths);
|
|
41
|
-
}
|
|
42
60
|
}
|
|
43
|
-
exports.Plugin = Plugin;
|
|
61
|
+
exports.Plugin = Plugin;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { EnvConfig } from "../types";
|
|
2
|
+
import { DI } from "../makes";
|
|
3
|
+
import { PresetServiceSearchOptions as SearchOptions } from "../services/PresetService";
|
|
4
|
+
type TextOption = {
|
|
5
|
+
type: "string" | "number" | "int";
|
|
6
|
+
message?: string;
|
|
7
|
+
default?: string | number;
|
|
8
|
+
};
|
|
9
|
+
type ConfirmOption = {
|
|
10
|
+
type: "boolean";
|
|
11
|
+
message?: string;
|
|
12
|
+
default?: boolean;
|
|
13
|
+
};
|
|
14
|
+
type SelectOption = {
|
|
15
|
+
type: "select";
|
|
16
|
+
options: string[] | {
|
|
17
|
+
label?: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}[] | {
|
|
20
|
+
[name: string]: string;
|
|
21
|
+
};
|
|
22
|
+
message?: string;
|
|
23
|
+
default?: string;
|
|
24
|
+
};
|
|
25
|
+
type AnyOption = TextOption | ConfirmOption | SelectOption;
|
|
26
|
+
declare class Preset {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
version: string;
|
|
30
|
+
dockerfile?: string;
|
|
31
|
+
buildArgsOptions?: {
|
|
32
|
+
[name: string]: AnyOption;
|
|
33
|
+
};
|
|
34
|
+
envOptions?: {
|
|
35
|
+
[name: string]: AnyOption;
|
|
36
|
+
};
|
|
37
|
+
volumes?: string[];
|
|
38
|
+
volumeOptions?: string[];
|
|
39
|
+
constructor(data: any);
|
|
40
|
+
save(): Promise<void>;
|
|
41
|
+
getImageName(buildArgs?: EnvConfig): string;
|
|
42
|
+
static install(di: DI): void;
|
|
43
|
+
static search(options: SearchOptions): Promise<Preset[]>;
|
|
44
|
+
static searchOne(options: SearchOptions): Promise<Preset>;
|
|
45
|
+
}
|
|
46
|
+
export { Preset };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Preset = void 0;
|
|
4
|
+
const PresetService_1 = require("../services/PresetService");
|
|
5
|
+
let _di;
|
|
6
|
+
class Preset {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
this.id = data.id;
|
|
9
|
+
this.name = data.name;
|
|
10
|
+
this.version = data.version;
|
|
11
|
+
this.dockerfile = data.dockerfile;
|
|
12
|
+
this.buildArgsOptions = data.buildArgsOptions;
|
|
13
|
+
this.envOptions = data.envOptions;
|
|
14
|
+
this.volumes = data.volumes;
|
|
15
|
+
this.volumeOptions = data.volumeOptions;
|
|
16
|
+
}
|
|
17
|
+
async save() {
|
|
18
|
+
return _di.resolveService(PresetService_1.PresetService).save(this);
|
|
19
|
+
}
|
|
20
|
+
getImageName(buildArgs) {
|
|
21
|
+
return _di.resolveService(PresetService_1.PresetService).getImageName(this, buildArgs);
|
|
22
|
+
}
|
|
23
|
+
static install(di) {
|
|
24
|
+
_di = di;
|
|
25
|
+
}
|
|
26
|
+
static search(options) {
|
|
27
|
+
return _di.resolveService(PresetService_1.PresetService).search(options);
|
|
28
|
+
}
|
|
29
|
+
static searchOne(options) {
|
|
30
|
+
return _di.resolveService(PresetService_1.PresetService).searchOne(options);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.Preset = Preset;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { DI } from "../makes/DI";
|
|
3
|
+
import { EnvConfig } from "../types";
|
|
4
|
+
type SearchOptions = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
path: string;
|
|
8
|
+
};
|
|
9
|
+
declare class Project {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
type: string;
|
|
13
|
+
path: string;
|
|
14
|
+
preset?: string;
|
|
15
|
+
imageName?: string;
|
|
16
|
+
dockerfile?: string;
|
|
17
|
+
scripts?: string[];
|
|
18
|
+
buildArgs?: EnvConfig;
|
|
19
|
+
env: EnvConfig;
|
|
20
|
+
ports?: string[];
|
|
21
|
+
volumes?: string[];
|
|
22
|
+
metadata?: EnvConfig;
|
|
23
|
+
constructor(data: any);
|
|
24
|
+
get containerName(): string;
|
|
25
|
+
hasEnv(name: string): boolean;
|
|
26
|
+
getEnv(name: string, defaultValue?: string): string | undefined;
|
|
27
|
+
setEnv(name: string, value: string | boolean): void;
|
|
28
|
+
unsetEnv(name: string): void;
|
|
29
|
+
hasMeta(name: string): boolean;
|
|
30
|
+
getMeta<D = string | undefined>(name: string, defaultValue?: D): D;
|
|
31
|
+
setMeta(name: string, value: string | boolean): void;
|
|
32
|
+
unsetMeta(name: string): void;
|
|
33
|
+
volumeMount(...volumes: string[]): void;
|
|
34
|
+
getVolumeBySource(source: string): string | undefined;
|
|
35
|
+
getVolumeByDestination(destination: string): string | undefined;
|
|
36
|
+
volumeUnmount(...volumes: string[]): void;
|
|
37
|
+
save(): Promise<void>;
|
|
38
|
+
static install(di: DI): void;
|
|
39
|
+
static fromObject(data: any): Project;
|
|
40
|
+
static search(params?: Partial<SearchOptions>): Promise<Project[]>;
|
|
41
|
+
static searchOne(params: Partial<SearchOptions>): Promise<Project | null>;
|
|
42
|
+
}
|
|
43
|
+
export { Project };
|
|
44
|
+
export declare const PROJECT_TYPE_DOCKERFILE = "dockerfile";
|
|
45
|
+
export declare const PROJECT_TYPE_IMAGE = "image";
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PROJECT_TYPE_IMAGE = exports.PROJECT_TYPE_DOCKERFILE = exports.Project = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const ProjectService_1 = require("../services/ProjectService");
|
|
6
|
+
const volumeParse_1 = require("../utils/volumeParse");
|
|
7
|
+
let projectService;
|
|
8
|
+
class Project {
|
|
9
|
+
constructor(data) {
|
|
10
|
+
this.id = data.id;
|
|
11
|
+
this.name = data.name;
|
|
12
|
+
this.type = data.type;
|
|
13
|
+
this.path = data.path;
|
|
14
|
+
this.preset = data.preset;
|
|
15
|
+
this.dockerfile = data.dockerfile;
|
|
16
|
+
this.imageName = data.imageName;
|
|
17
|
+
this.scripts = data.scripts;
|
|
18
|
+
this.buildArgs = data.buildArgs;
|
|
19
|
+
this.env = data.env || {};
|
|
20
|
+
this.ports = data.ports;
|
|
21
|
+
this.volumes = data.volumes;
|
|
22
|
+
this.metadata = data.metadata;
|
|
23
|
+
}
|
|
24
|
+
get containerName() {
|
|
25
|
+
return `${this.name}.workspace`;
|
|
26
|
+
}
|
|
27
|
+
hasEnv(name) {
|
|
28
|
+
if (!this.env) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return this.env.hasOwnProperty(name);
|
|
32
|
+
}
|
|
33
|
+
getEnv(name, defaultValue) {
|
|
34
|
+
const { [name]: value = defaultValue } = this.env;
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
setEnv(name, value) {
|
|
38
|
+
this.env = {
|
|
39
|
+
...this.env,
|
|
40
|
+
[name]: typeof value === "boolean"
|
|
41
|
+
? (value ? "true" : "false")
|
|
42
|
+
: value
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
unsetEnv(name) {
|
|
46
|
+
if (name in this.env) {
|
|
47
|
+
delete this.env[name];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
hasMeta(name) {
|
|
51
|
+
return !!this.metadata && this.metadata.hasOwnProperty(name);
|
|
52
|
+
}
|
|
53
|
+
getMeta(name, defaultValue) {
|
|
54
|
+
const { [name]: value = defaultValue } = this.metadata || {};
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
setMeta(name, value) {
|
|
58
|
+
if (!this.metadata) {
|
|
59
|
+
this.metadata = {};
|
|
60
|
+
}
|
|
61
|
+
this.metadata[name] = typeof value === "boolean"
|
|
62
|
+
? (value ? "true" : "false")
|
|
63
|
+
: value;
|
|
64
|
+
}
|
|
65
|
+
unsetMeta(name) {
|
|
66
|
+
if (this.metadata && name in this.metadata) {
|
|
67
|
+
delete this.metadata[name];
|
|
68
|
+
}
|
|
69
|
+
if (this.metadata && Object.keys(this.metadata).length === 0) {
|
|
70
|
+
delete this.metadata;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
volumeMount(...volumes) {
|
|
74
|
+
if (volumes.length === 0) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const [volume, ...restVolumes] = volumes;
|
|
78
|
+
const { destination } = (0, volumeParse_1.volumeParse)(volume);
|
|
79
|
+
this.volumes = [
|
|
80
|
+
...(this.volumes || []).filter((v) => {
|
|
81
|
+
return v !== this.getVolumeByDestination(destination);
|
|
82
|
+
}),
|
|
83
|
+
volume
|
|
84
|
+
];
|
|
85
|
+
this.volumeMount(...restVolumes);
|
|
86
|
+
}
|
|
87
|
+
getVolumeBySource(source) {
|
|
88
|
+
return (this.volumes || []).find((volume) => {
|
|
89
|
+
return (0, volumeParse_1.volumeParse)(volume).source === source;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
getVolumeByDestination(destination) {
|
|
93
|
+
return (this.volumes || []).find((volume) => {
|
|
94
|
+
return (0, volumeParse_1.volumeParse)(volume).destination === destination;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
volumeUnmount(...volumes) {
|
|
98
|
+
this.volumes = (this.volumes || []).filter((mounted) => {
|
|
99
|
+
return !volumes.includes(mounted);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
async save() {
|
|
103
|
+
if (!projectService) {
|
|
104
|
+
throw new Error("Dependency is missing");
|
|
105
|
+
}
|
|
106
|
+
await projectService.save(this);
|
|
107
|
+
}
|
|
108
|
+
static install(di) {
|
|
109
|
+
projectService = di.resolveService(ProjectService_1.ProjectService);
|
|
110
|
+
}
|
|
111
|
+
static fromObject(data) {
|
|
112
|
+
return new Project(data);
|
|
113
|
+
}
|
|
114
|
+
static async search(params = {}) {
|
|
115
|
+
if (!projectService) {
|
|
116
|
+
throw new Error("Dependency is missing");
|
|
117
|
+
}
|
|
118
|
+
return projectService.search(params);
|
|
119
|
+
}
|
|
120
|
+
static async searchOne(params) {
|
|
121
|
+
const [project] = await Project.search(params);
|
|
122
|
+
return project || null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.Project = Project;
|
|
126
|
+
exports.PROJECT_TYPE_DOCKERFILE = "dockerfile";
|
|
127
|
+
exports.PROJECT_TYPE_IMAGE = "image";
|
package/lib/makes/Repository.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.Repository = void 0;
|
|
7
4
|
class Repository {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
async create(data) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
async update(id, record) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
async byId(id) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
async search(params) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
async searchOne(params) {
|
|
18
|
+
const [item] = await this.search(params);
|
|
19
|
+
return item;
|
|
20
|
+
}
|
|
24
21
|
}
|
|
25
|
-
exports.Repository = Repository;
|
|
22
|
+
exports.Repository = Repository;
|
package/lib/makes/index.d.ts
CHANGED