@wocker/ws 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/README.md +1 -1
  2. package/lib/App.d.ts +4 -3
  3. package/lib/App.js +98 -77
  4. package/lib/controllers/ImageController.d.ts +2 -2
  5. package/lib/controllers/ImageController.js +27 -27
  6. package/lib/controllers/PluginController.d.ts +2 -2
  7. package/lib/controllers/PluginController.js +78 -56
  8. package/lib/controllers/PresetController.d.ts +3 -1
  9. package/lib/controllers/PresetController.js +155 -136
  10. package/lib/controllers/ProjectController.d.ts +5 -5
  11. package/lib/controllers/ProjectController.js +653 -603
  12. package/lib/controllers/ProxyController.d.ts +4 -1
  13. package/lib/controllers/ProxyController.js +269 -245
  14. package/lib/controllers/index.js +19 -58
  15. package/lib/decorators/Inject.d.ts +1 -0
  16. package/lib/decorators/Inject.js +8 -0
  17. package/lib/decorators/Injectable.d.ts +4 -0
  18. package/lib/decorators/Injectable.js +17 -0
  19. package/lib/decorators/index.d.ts +1 -0
  20. package/lib/decorators/index.js +17 -0
  21. package/lib/env.js +33 -15
  22. package/lib/index.d.ts +3 -0
  23. package/lib/index.js +31 -16
  24. package/lib/makes/Controller.js +4 -8
  25. package/lib/makes/DI.d.ts +7 -0
  26. package/lib/makes/DI.js +27 -0
  27. package/lib/makes/Docker.js +298 -382
  28. package/lib/makes/FS.d.ts +3 -9
  29. package/lib/makes/FS.js +277 -305
  30. package/lib/makes/LineConvertStream.js +37 -40
  31. package/lib/makes/Logger.d.ts +9 -1
  32. package/lib/makes/Logger.js +22 -11
  33. package/lib/makes/Model.js +8 -12
  34. package/lib/makes/MySQL.js +6 -27
  35. package/lib/makes/Plugin.d.ts +1 -1
  36. package/lib/makes/Plugin.js +55 -37
  37. package/lib/makes/Preset.d.ts +46 -0
  38. package/lib/makes/Preset.js +33 -0
  39. package/lib/makes/Project.d.ts +45 -0
  40. package/lib/makes/Project.js +127 -0
  41. package/lib/makes/Repository.js +18 -21
  42. package/lib/makes/index.d.ts +3 -0
  43. package/lib/makes/index.js +23 -69
  44. package/lib/plugins/ElasticSearchPlugin.d.ts +3 -1
  45. package/lib/plugins/ElasticSearchPlugin.js +66 -66
  46. package/lib/plugins/LocaltunnelPlugin.d.ts +2 -2
  47. package/lib/plugins/LocaltunnelPlugin.js +256 -257
  48. package/lib/plugins/MaildevPlugin.d.ts +2 -2
  49. package/lib/plugins/MaildevPlugin.js +45 -44
  50. package/lib/plugins/MongodbPlugin.d.ts +2 -2
  51. package/lib/plugins/MongodbPlugin.js +303 -248
  52. package/lib/plugins/NgrokPlugin.d.ts +2 -2
  53. package/lib/plugins/NgrokPlugin.js +221 -231
  54. package/lib/plugins/PageKitePlugin.d.ts +2 -2
  55. package/lib/plugins/PageKitePlugin.js +150 -149
  56. package/lib/plugins/PostgresPlugin.d.ts +1 -1
  57. package/lib/plugins/PostgresPlugin.js +115 -89
  58. package/lib/plugins/ProxmoxPlugin.d.ts +1 -1
  59. package/lib/plugins/ProxmoxPlugin.js +50 -38
  60. package/lib/plugins/RedisPlugin.d.ts +3 -1
  61. package/lib/plugins/RedisPlugin.js +73 -72
  62. package/lib/plugins/index.js +25 -103
  63. package/lib/services/AppConfigService.d.ts +3 -3
  64. package/lib/services/AppConfigService.js +162 -157
  65. package/lib/services/AppEventsService.js +26 -24
  66. package/lib/services/DockerService.d.ts +37 -2
  67. package/lib/services/DockerService.js +185 -205
  68. package/lib/services/LogService.d.ts +3 -2
  69. package/lib/services/LogService.js +33 -34
  70. package/lib/services/PluginService.d.ts +2 -1
  71. package/lib/services/PluginService.js +11 -14
  72. package/lib/services/PresetService.d.ts +8 -3
  73. package/lib/services/PresetService.js +60 -59
  74. package/lib/services/ProjectService.d.ts +11 -4
  75. package/lib/services/ProjectService.js +140 -129
  76. package/lib/services/index.js +21 -80
  77. package/lib/types/Config.d.ts +4 -3
  78. package/lib/types/Config.js +1 -4
  79. package/lib/types/EnvConfig.js +1 -4
  80. package/lib/types/index.js +16 -25
  81. package/lib/utils/buildOptions.js +5 -8
  82. package/lib/utils/demuxOutput.js +16 -20
  83. package/lib/utils/escapeRegExp.js +4 -7
  84. package/lib/utils/exec.js +38 -39
  85. package/lib/utils/fetch.js +46 -30
  86. package/lib/utils/followProgress.js +66 -77
  87. package/lib/utils/format-size-units.js +16 -16
  88. package/lib/utils/get-config.d.ts +1 -1
  89. package/lib/utils/get-config.js +13 -16
  90. package/lib/utils/get-cursor-position.js +22 -29
  91. package/lib/utils/image-build.js +35 -23
  92. package/lib/utils/index.js +32 -191
  93. package/lib/utils/injectVariables.js +10 -13
  94. package/lib/utils/parse-table.js +20 -23
  95. package/lib/utils/set-config.d.ts +1 -1
  96. package/lib/utils/set-config.js +12 -15
  97. package/lib/utils/spawn.js +17 -20
  98. package/lib/utils/tty.js +2 -6
  99. package/lib/utils/volumeFormat.js +5 -12
  100. package/lib/utils/volumeParse.js +10 -13
  101. package/package.json +13 -39
  102. package/presets/bun/Dockerfile +11 -0
  103. package/presets/bun/config.json +3 -0
  104. package/presets/node/Dockerfile +4 -2
  105. package/presets/php-apache/Dockerfile +3 -2
  106. package/.github/workflows/publish.yml +0 -31
  107. 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
- var _stream = require("stream");
8
- var _asyncMutex = require("async-mutex");
9
- class LineConvertStream extends _stream.Readable {
10
- buf = "";
11
- mutex = new _asyncMutex.Mutex();
12
- constructor(stream) {
13
- super();
14
- this.stream = stream;
15
- this.stream.on("data", chunk => this.process(chunk));
16
- this.stream.on("end", () => {
17
- this.push(null);
18
- });
19
- this.stream.on("close", () => {
20
- this.destroy();
21
- });
22
- }
23
- _read(size) {
24
- //
25
- }
26
- async process(chunk) {
27
- await this.mutex.acquire();
28
- this.buf += chunk.toString();
29
- try {
30
- let pos;
31
- while ((pos = this.buf.indexOf("\n")) >= 0) {
32
- if (pos === 0) {
33
- this.buf = this.buf.slice(0);
34
- continue;
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;
@@ -1 +1,9 @@
1
- export { Logger } from "@wocker/core";
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 };
@@ -1,12 +1,23 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "Logger", {
7
- enumerable: true,
8
- get: function () {
9
- return _core.Logger;
10
- }
11
- });
12
- var _core = require("@wocker/core");
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;
@@ -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
- attributes = {};
9
- constructor(attributes = {}) {
10
- this.attributes = attributes;
11
- }
12
- async save() {
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;
@@ -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
- constructor(options) {
11
- // this.connection = createConnection(options);
12
- }
13
- async query(sql) {
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;
@@ -1,5 +1,5 @@
1
1
  import { Cli } from "@kearisp/cli";
2
- import { Controller } from "src/makes/Controller";
2
+ import { Controller } from "../makes/Controller";
3
3
  declare class Plugin extends Controller {
4
4
  protected certsDir: string;
5
5
  protected dataDir: string;
@@ -1,43 +1,61 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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
- var Path = _interopRequireWildcard(require("path"));
8
- var _env = require("../env");
9
- var _Controller = require("./Controller");
10
- var _FS = require("./FS");
11
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
- class Plugin extends _Controller.Controller {
14
- constructor(name) {
15
- super();
16
- this.certsDir = Path.join(_env.DATA_DIR, "certs");
17
- this.dataDir = Path.join(_env.DATA_DIR, "plugins", name);
18
- this.pluginDir = Path.join(_env.PLUGINS_DIR, name);
19
- }
20
- install(cli) {
21
- super.install(cli);
22
- if (!_FS.FS.existsSync(this.certsDir)) {
23
- _FS.FS.mkdirSync(this.certsDir, {
24
- recursive: true
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
- if (!_FS.FS.existsSync(this.dataDir)) {
28
- _FS.FS.mkdirSync(this.dataDir, {
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";
@@ -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
- async create(data) {
9
- return null;
10
- }
11
- async update(id, record) {
12
- return null;
13
- }
14
- async byId(id) {
15
- return null;
16
- }
17
- async search(params) {
18
- return [];
19
- }
20
- async searchOne(params) {
21
- const [item] = await this.search(params);
22
- return item;
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;
@@ -1,6 +1,9 @@
1
1
  export * from "./Controller";
2
+ export * from "./DI";
2
3
  export * from "./Docker";
3
4
  export * from "./FS";
4
5
  export * from "./Logger";
5
6
  export * from "./Plugin";
7
+ export * from "./Preset";
8
+ export * from "./Project";
6
9
  export * from "./Repository";