@wocker/core 1.0.25 → 1.0.26-beta.0
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/core/ApplicationContext.d.ts +1 -1
- package/lib/core/AsyncStorage.d.ts +10 -2
- package/lib/core/AsyncStorage.js +9 -1
- package/lib/core/Container.d.ts +3 -2
- package/lib/core/Container.js +8 -0
- package/lib/core/InstanceWrapper.d.ts +1 -2
- package/lib/core/InstanceWrapper.js +4 -4
- package/lib/core/ModuleWrapper.d.ts +10 -6
- package/lib/core/ModuleWrapper.js +21 -2
- package/lib/core/Route.d.ts +1 -3
- package/lib/core/Route.js +6 -8
- package/lib/core/Scanner.d.ts +10 -7
- package/lib/core/Scanner.js +71 -39
- package/lib/decorators/Description.js +13 -0
- package/lib/decorators/Module.d.ts +1 -8
- package/lib/decorators/Option.js +19 -6
- package/lib/decorators/Optional.d.ts +1 -0
- package/lib/decorators/Optional.js +22 -0
- package/lib/decorators/Param.js +15 -2
- package/lib/decorators/Plugin.d.ts +2 -7
- package/lib/decorators/Plugin.js +3 -1
- package/lib/decorators/index.d.ts +1 -5
- package/lib/decorators/index.js +1 -0
- package/lib/env.d.ts +2 -1
- package/lib/env.js +3 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/makes/AppConfig.d.ts +1 -6
- package/lib/makes/AppConfig.js +1 -10
- package/lib/makes/index.d.ts +0 -1
- package/lib/makes/index.js +0 -1
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +17 -0
- package/lib/modules/project/index.d.ts +4 -0
- package/lib/modules/project/index.js +25 -0
- package/lib/{makes → modules/project/makes}/Project.d.ts +27 -25
- package/lib/modules/project/makes/Project.js +281 -0
- package/lib/modules/project/repositories/ProjectRepository.d.ts +11 -0
- package/lib/modules/project/repositories/ProjectRepository.js +16 -0
- package/lib/{services → modules/project/services}/ProjectService.d.ts +3 -7
- package/lib/{services → modules/project/services}/ProjectService.js +1 -1
- package/lib/modules/project/types/ProjectType.d.ts +5 -0
- package/lib/modules/project/types/ProjectType.js +7 -0
- package/lib/modules/project/types/ProjectV1.d.ts +23 -0
- package/lib/modules/project/types/ProjectV1.js +2 -0
- package/lib/modules/project/types/ServiceProperties.d.ts +9 -0
- package/lib/modules/project/types/ServiceProperties.js +2 -0
- package/lib/modules/project/types/index.d.ts +3 -0
- package/lib/modules/project/types/index.js +19 -0
- package/lib/services/AppConfigService.d.ts +4 -2
- package/lib/services/AppConfigService.js +18 -11
- package/lib/services/AppService.d.ts +1 -1
- package/lib/services/AppService.js +2 -2
- package/lib/services/index.d.ts +0 -1
- package/lib/services/index.js +0 -1
- package/lib/types/ArgMeta.d.ts +1 -0
- package/lib/types/DynamicModule.d.ts +9 -0
- package/lib/types/DynamicModule.js +2 -0
- package/lib/types/ModuleMetadata.d.ts +11 -0
- package/lib/types/ModuleMetadata.js +3 -0
- package/lib/types/PluginMetadata.d.ts +5 -0
- package/lib/types/PluginMetadata.js +3 -0
- package/lib/types/index.d.ts +14 -0
- package/lib/types/index.js +4 -0
- package/package.json +7 -9
- package/lib/makes/Project.js +0 -200
package/lib/env.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export declare const INJECTABLE_WATERMARK = "__injectable__";
|
|
|
4
4
|
export declare const DESCRIPTION_METADATA = "__DESCRIPTION__";
|
|
5
5
|
export declare const COMMAND_METADATA = "command";
|
|
6
6
|
export declare const COMPLETION_METADATA = "completion";
|
|
7
|
-
export declare const ARGS_METADATA = "
|
|
7
|
+
export declare const ARGS_METADATA = "__ARGS_METADATA__";
|
|
8
|
+
export declare const ARGS_METADATA_OLD = "__ARGS__";
|
|
8
9
|
export declare const ALIAS_METADATA = "__ALIAS_METADATA__";
|
|
9
10
|
export declare const OPTION_META = "__OPTION_META__";
|
|
10
11
|
export declare const PARAMTYPES_METADATA = "design:paramtypes";
|
package/lib/env.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.WOCKER_DATA_DIR_KEY = exports.WOCKER_VERSION_KEY = exports.DATA_DIR = exports.MODULE_METADATA = exports.PLUGIN_NAME_METADATA = exports.PLUGIN_DIR_KEY = exports.INJECT_TOKEN_METADATA = exports.SELF_DECLARED_DEPS_METADATA = exports.PARAMTYPES_METADATA = exports.OPTION_META = exports.ALIAS_METADATA = exports.ARGS_METADATA = exports.COMPLETION_METADATA = exports.COMMAND_METADATA = exports.DESCRIPTION_METADATA = exports.INJECTABLE_WATERMARK = exports.IS_MODULE_METADATA = exports.IS_GLOBAL_METADATA = void 0;
|
|
6
|
+
exports.WOCKER_DATA_DIR_KEY = exports.WOCKER_VERSION_KEY = exports.DATA_DIR = exports.MODULE_METADATA = exports.PLUGIN_NAME_METADATA = exports.PLUGIN_DIR_KEY = exports.INJECT_TOKEN_METADATA = exports.SELF_DECLARED_DEPS_METADATA = exports.PARAMTYPES_METADATA = exports.OPTION_META = exports.ALIAS_METADATA = exports.ARGS_METADATA_OLD = exports.ARGS_METADATA = exports.COMPLETION_METADATA = exports.COMMAND_METADATA = exports.DESCRIPTION_METADATA = exports.INJECTABLE_WATERMARK = exports.IS_MODULE_METADATA = exports.IS_GLOBAL_METADATA = void 0;
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
exports.IS_GLOBAL_METADATA = "IS_GLOBAL";
|
|
@@ -12,7 +12,8 @@ exports.INJECTABLE_WATERMARK = "__injectable__";
|
|
|
12
12
|
exports.DESCRIPTION_METADATA = "__DESCRIPTION__";
|
|
13
13
|
exports.COMMAND_METADATA = "command";
|
|
14
14
|
exports.COMPLETION_METADATA = "completion";
|
|
15
|
-
exports.ARGS_METADATA = "
|
|
15
|
+
exports.ARGS_METADATA = "__ARGS_METADATA__";
|
|
16
|
+
exports.ARGS_METADATA_OLD = "__ARGS__";
|
|
16
17
|
exports.ALIAS_METADATA = "__ALIAS_METADATA__";
|
|
17
18
|
exports.OPTION_META = "__OPTION_META__";
|
|
18
19
|
exports.PARAMTYPES_METADATA = "design:paramtypes";
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -23,6 +23,7 @@ __exportStar(require("./core"), exports);
|
|
|
23
23
|
__exportStar(require("./decorators"), exports);
|
|
24
24
|
__exportStar(require("./exceptions"), exports);
|
|
25
25
|
__exportStar(require("./makes"), exports);
|
|
26
|
+
__exportStar(require("./modules"), exports);
|
|
26
27
|
__exportStar(require("./services"), exports);
|
|
27
28
|
var services_1 = require("./services");
|
|
28
29
|
/**
|
package/lib/makes/AppConfig.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare class AppConfig {
|
|
|
26
26
|
addPlugin(name: string, env?: PluginRef["env"]): void;
|
|
27
27
|
removePlugin(name: string): void;
|
|
28
28
|
getProject(name: string): ProjectRef | undefined;
|
|
29
|
-
addProject(
|
|
29
|
+
addProject(name: string, path: string): void;
|
|
30
30
|
removeProject(name: string): void;
|
|
31
31
|
registerPreset(name: string, source: PresetSource, path?: string): void;
|
|
32
32
|
unregisterPreset(name: string): void;
|
|
@@ -39,11 +39,6 @@ export declare class AppConfig {
|
|
|
39
39
|
getEnv(name: string, defaultValue: string): string;
|
|
40
40
|
setEnv(name: string, value: string): void;
|
|
41
41
|
unsetEnv(name: string): void;
|
|
42
|
-
/**
|
|
43
|
-
* @deprecated
|
|
44
|
-
*/
|
|
45
|
-
toJson(): AppConfigProperties;
|
|
46
42
|
toObject(): AppConfigProperties;
|
|
47
43
|
toJsString(): string;
|
|
48
|
-
toString(): string;
|
|
49
44
|
}
|
package/lib/makes/AppConfig.js
CHANGED
|
@@ -62,7 +62,7 @@ class AppConfig {
|
|
|
62
62
|
return projectData.name === name;
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
addProject(
|
|
65
|
+
addProject(name, path) {
|
|
66
66
|
let projectRef = this.getProject(name);
|
|
67
67
|
if (!projectRef) {
|
|
68
68
|
this.projects.push({
|
|
@@ -163,12 +163,6 @@ class AppConfig {
|
|
|
163
163
|
delete this.env;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
/**
|
|
167
|
-
* @deprecated
|
|
168
|
-
*/
|
|
169
|
-
toJson() {
|
|
170
|
-
return this.toObject();
|
|
171
|
-
}
|
|
172
166
|
toObject() {
|
|
173
167
|
return {
|
|
174
168
|
debug: this.debug,
|
|
@@ -185,8 +179,5 @@ class AppConfig {
|
|
|
185
179
|
const json = JSON.stringify(this.toObject(), null, 4);
|
|
186
180
|
return `// Wocker config\nexports.config = ${json};`;
|
|
187
181
|
}
|
|
188
|
-
toString() {
|
|
189
|
-
return JSON.stringify(this.toObject(), null, 4);
|
|
190
|
-
}
|
|
191
182
|
}
|
|
192
183
|
exports.AppConfig = AppConfig;
|
package/lib/makes/index.d.ts
CHANGED
package/lib/makes/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./project";
|
|
@@ -0,0 +1,17 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./project"), exports);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from "./makes/Project";
|
|
2
|
+
export * from "./repositories/ProjectRepository";
|
|
3
|
+
export * from "./services/ProjectService";
|
|
4
|
+
export { PROJECT_TYPE_IMAGE, PROJECT_TYPE_DOCKERFILE, PROJECT_TYPE_COMPOSE, PROJECT_TYPE_PRESET, ProjectType, ServiceProperties } from "./types";
|
|
@@ -0,0 +1,25 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.PROJECT_TYPE_PRESET = exports.PROJECT_TYPE_COMPOSE = exports.PROJECT_TYPE_DOCKERFILE = exports.PROJECT_TYPE_IMAGE = void 0;
|
|
18
|
+
__exportStar(require("./makes/Project"), exports);
|
|
19
|
+
__exportStar(require("./repositories/ProjectRepository"), exports);
|
|
20
|
+
__exportStar(require("./services/ProjectService"), exports);
|
|
21
|
+
var types_1 = require("./types");
|
|
22
|
+
Object.defineProperty(exports, "PROJECT_TYPE_IMAGE", { enumerable: true, get: function () { return types_1.PROJECT_TYPE_IMAGE; } });
|
|
23
|
+
Object.defineProperty(exports, "PROJECT_TYPE_DOCKERFILE", { enumerable: true, get: function () { return types_1.PROJECT_TYPE_DOCKERFILE; } });
|
|
24
|
+
Object.defineProperty(exports, "PROJECT_TYPE_COMPOSE", { enumerable: true, get: function () { return types_1.PROJECT_TYPE_COMPOSE; } });
|
|
25
|
+
Object.defineProperty(exports, "PROJECT_TYPE_PRESET", { enumerable: true, get: function () { return types_1.PROJECT_TYPE_PRESET; } });
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
id
|
|
1
|
+
import { EnvConfig } from "../../../types";
|
|
2
|
+
import { ServiceProperties, ProjectType, ProjectV1 } from "../types";
|
|
3
|
+
export declare class Project {
|
|
4
|
+
/** @deprecated */
|
|
5
|
+
id?: string;
|
|
6
6
|
name: string;
|
|
7
7
|
type: ProjectType;
|
|
8
8
|
path: string;
|
|
9
|
-
preset?: string;
|
|
10
|
-
presetMode?: "global" | "project";
|
|
11
9
|
imageName?: string;
|
|
12
10
|
dockerfile?: string;
|
|
13
11
|
composefile?: string;
|
|
12
|
+
preset?: string;
|
|
13
|
+
presetMode?: "global" | "project";
|
|
14
14
|
scripts?: string[];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
services: {
|
|
16
|
+
[name: string]: ServiceProperties;
|
|
17
|
+
};
|
|
18
|
+
buildArgs: EnvConfig;
|
|
19
|
+
env: EnvConfig;
|
|
20
|
+
metadata: EnvConfig;
|
|
21
|
+
ports: string[];
|
|
22
|
+
extraHosts: EnvConfig;
|
|
23
|
+
volumes: string[];
|
|
24
|
+
constructor(data: ProjectV1);
|
|
22
25
|
get containerName(): string;
|
|
23
26
|
get domains(): string[];
|
|
24
27
|
hasDomain(domain: string): boolean;
|
|
@@ -27,10 +30,12 @@ export declare abstract class Project {
|
|
|
27
30
|
clearDomains(): void;
|
|
28
31
|
linkPort(hostPort: number, containerPort: number): void;
|
|
29
32
|
unlinkPort(hostPort: number, containerPort: number): void;
|
|
33
|
+
setBuildArg(name: string, value: string, service?: string): void;
|
|
34
|
+
unsetBuildArg(name: string, service?: string): void;
|
|
30
35
|
hasEnv(name: string): boolean;
|
|
31
36
|
getEnv(name: string, defaultValue?: string): string | undefined;
|
|
32
|
-
setEnv(name: string, value: string | boolean): void;
|
|
33
|
-
unsetEnv(name: string): void;
|
|
37
|
+
setEnv(name: string, value: string | boolean, service?: string): void;
|
|
38
|
+
unsetEnv(name: string, service?: string): void;
|
|
34
39
|
hasMeta(name: string): boolean;
|
|
35
40
|
getMeta<D = string | undefined>(name: string, defaultValue?: D): D;
|
|
36
41
|
setMeta(name: string, value: string | boolean): void;
|
|
@@ -41,13 +46,10 @@ export declare abstract class Project {
|
|
|
41
46
|
volumeUnmount(...volumes: string[]): void;
|
|
42
47
|
addExtraHost(host: string, domain: string): void;
|
|
43
48
|
removeExtraHost(host: string): void;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
getSecret(key: string): Promise<string | undefined>;
|
|
50
|
+
getSecret(key: string, byDefault: string): Promise<string>;
|
|
51
|
+
setSecret(key: string, value: string): Promise<void>;
|
|
52
|
+
unsetSecret(key: string): Promise<void>;
|
|
53
|
+
save(): void;
|
|
54
|
+
toObject(): ProjectV1;
|
|
49
55
|
}
|
|
50
|
-
export declare const PROJECT_TYPE_DOCKERFILE = "dockerfile";
|
|
51
|
-
export declare const PROJECT_TYPE_IMAGE = "image";
|
|
52
|
-
export declare const PROJECT_TYPE_PRESET = "preset";
|
|
53
|
-
export declare const PROJECT_TYPE_COMPOSE = "compose";
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.Project = void 0;
|
|
24
|
+
const AsyncStorage_1 = require("../../../core/AsyncStorage");
|
|
25
|
+
const volumeParse_1 = require("../../../utils/volumeParse");
|
|
26
|
+
const ProjectRepository_1 = require("../repositories/ProjectRepository");
|
|
27
|
+
class Project {
|
|
28
|
+
constructor(data) {
|
|
29
|
+
const { name, services = {}, buildArgs = {}, env = {}, metadata = {}, ports = [], extraHosts = {}, volumes = [] } = data, rest = __rest(data, ["name", "services", "buildArgs", "env", "metadata", "ports", "extraHosts", "volumes"]);
|
|
30
|
+
this.id = this.name = name;
|
|
31
|
+
this.services = services;
|
|
32
|
+
this.buildArgs = buildArgs;
|
|
33
|
+
this.env = env;
|
|
34
|
+
this.metadata = metadata;
|
|
35
|
+
this.ports = ports;
|
|
36
|
+
this.extraHosts = extraHosts;
|
|
37
|
+
this.volumes = volumes;
|
|
38
|
+
Object.assign(this, rest);
|
|
39
|
+
}
|
|
40
|
+
get containerName() {
|
|
41
|
+
return `${this.name}.workspace`;
|
|
42
|
+
}
|
|
43
|
+
get domains() {
|
|
44
|
+
const host = this.getEnv("VIRTUAL_HOST");
|
|
45
|
+
if (!host) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
return host.split(",");
|
|
49
|
+
}
|
|
50
|
+
hasDomain(domain) {
|
|
51
|
+
return this.domains.includes(domain);
|
|
52
|
+
}
|
|
53
|
+
addDomain(addDomain) {
|
|
54
|
+
let domains = [
|
|
55
|
+
...this.domains.filter((domain) => {
|
|
56
|
+
return domain !== addDomain;
|
|
57
|
+
}),
|
|
58
|
+
addDomain
|
|
59
|
+
];
|
|
60
|
+
this.setEnv("VIRTUAL_HOST", domains.join(","));
|
|
61
|
+
}
|
|
62
|
+
removeDomain(removeDomain) {
|
|
63
|
+
if (!this.hasDomain(removeDomain)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
let domains = this.domains.filter((domain) => {
|
|
67
|
+
return domain !== removeDomain;
|
|
68
|
+
});
|
|
69
|
+
this.setEnv("VIRTUAL_HOST", domains.join(","));
|
|
70
|
+
}
|
|
71
|
+
clearDomains() {
|
|
72
|
+
this.unsetEnv("VIRTUAL_HOST");
|
|
73
|
+
}
|
|
74
|
+
linkPort(hostPort, containerPort) {
|
|
75
|
+
this.ports = [
|
|
76
|
+
...this.ports.filter((link) => {
|
|
77
|
+
return link !== `${hostPort}:${containerPort}`;
|
|
78
|
+
}),
|
|
79
|
+
`${hostPort}:${containerPort}`
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
unlinkPort(hostPort, containerPort) {
|
|
83
|
+
if (!this.ports) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.ports = this.ports.filter((link) => {
|
|
87
|
+
return link !== `${hostPort}:${containerPort}`;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
setBuildArg(name, value, service) {
|
|
91
|
+
if (service) {
|
|
92
|
+
if (!this.services[service]) {
|
|
93
|
+
throw new Error(`Service "${service}" not found`);
|
|
94
|
+
}
|
|
95
|
+
if (!this.services[service].buildArgs) {
|
|
96
|
+
this.services[service].buildArgs = {};
|
|
97
|
+
}
|
|
98
|
+
this.services[service].buildArgs[name] = value;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.buildArgs[name] = value;
|
|
102
|
+
}
|
|
103
|
+
unsetBuildArg(name, service) {
|
|
104
|
+
if (service) {
|
|
105
|
+
if (!this.services[service]) {
|
|
106
|
+
throw new Error(`Service "${service}" not found`);
|
|
107
|
+
}
|
|
108
|
+
if (this.services[service].buildArgs && name in this.services[service].buildArgs) {
|
|
109
|
+
delete this.services[service].buildArgs[name];
|
|
110
|
+
if (Object.keys(this.services[service].buildArgs).length === 0) {
|
|
111
|
+
delete this.services[service].buildArgs;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (name in this.buildArgs) {
|
|
117
|
+
delete this.buildArgs[name];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
hasEnv(name) {
|
|
121
|
+
if (!this.env) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
return this.env.hasOwnProperty(name);
|
|
125
|
+
}
|
|
126
|
+
getEnv(name, defaultValue) {
|
|
127
|
+
const { [name]: value = defaultValue } = this.env || {};
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
setEnv(name, value, service) {
|
|
131
|
+
if (!this.env) {
|
|
132
|
+
this.env = {};
|
|
133
|
+
}
|
|
134
|
+
if (service) {
|
|
135
|
+
if (!this.services[service]) {
|
|
136
|
+
throw new Error(`Service "${service}" not found`);
|
|
137
|
+
}
|
|
138
|
+
if (!this.services[service].env) {
|
|
139
|
+
this.services[service].env = {};
|
|
140
|
+
}
|
|
141
|
+
this.services[service].env[name] = typeof value === "boolean"
|
|
142
|
+
? (value ? "true" : "false")
|
|
143
|
+
: value;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.env[name] = typeof value === "boolean"
|
|
147
|
+
? (value ? "true" : "false")
|
|
148
|
+
: value;
|
|
149
|
+
}
|
|
150
|
+
unsetEnv(name, service) {
|
|
151
|
+
if (service) {
|
|
152
|
+
if (!this.services[service]) {
|
|
153
|
+
throw new Error(`Service "${service}" not found`);
|
|
154
|
+
}
|
|
155
|
+
if (this.services[service].env && name in this.services[service].env) {
|
|
156
|
+
delete this.services[service].env[name];
|
|
157
|
+
if (Object.keys(this.services[service].env).length === 0) {
|
|
158
|
+
delete this.services[service].env;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (name in this.env) {
|
|
164
|
+
delete this.env[name];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
hasMeta(name) {
|
|
168
|
+
return !!this.metadata && this.metadata.hasOwnProperty(name);
|
|
169
|
+
}
|
|
170
|
+
getMeta(name, defaultValue) {
|
|
171
|
+
const { [name]: value = defaultValue } = this.metadata || {};
|
|
172
|
+
return value;
|
|
173
|
+
}
|
|
174
|
+
setMeta(name, value) {
|
|
175
|
+
if (!this.metadata) {
|
|
176
|
+
this.metadata = {};
|
|
177
|
+
}
|
|
178
|
+
this.metadata[name] = typeof value === "boolean"
|
|
179
|
+
? (value ? "true" : "false")
|
|
180
|
+
: value;
|
|
181
|
+
}
|
|
182
|
+
unsetMeta(name) {
|
|
183
|
+
if (name in this.metadata) {
|
|
184
|
+
delete this.metadata[name];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
getVolumeBySource(source) {
|
|
188
|
+
return (this.volumes || []).find((volume) => {
|
|
189
|
+
return (0, volumeParse_1.volumeParse)(volume).source === source;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
getVolumeByDestination(destination) {
|
|
193
|
+
return (this.volumes || []).find((volume) => {
|
|
194
|
+
return (0, volumeParse_1.volumeParse)(volume).destination === destination;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
volumeMount(...volumes) {
|
|
198
|
+
if (volumes.length === 0) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const [volume, ...restVolumes] = volumes;
|
|
202
|
+
const { destination } = (0, volumeParse_1.volumeParse)(volume);
|
|
203
|
+
this.volumes = [
|
|
204
|
+
...(this.volumes || []).filter((v) => {
|
|
205
|
+
return v !== this.getVolumeByDestination(destination);
|
|
206
|
+
}),
|
|
207
|
+
volume
|
|
208
|
+
];
|
|
209
|
+
this.volumeMount(...restVolumes);
|
|
210
|
+
}
|
|
211
|
+
volumeUnmount(...volumes) {
|
|
212
|
+
if (!this.volumes || volumes.length === 0) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const [volume, ...restVolumes] = volumes;
|
|
216
|
+
const v = (0, volumeParse_1.volumeParse)(volume);
|
|
217
|
+
this.volumes = this.volumes.filter((mounted) => {
|
|
218
|
+
const m = (0, volumeParse_1.volumeParse)(mounted);
|
|
219
|
+
return v.source !== m.source && v.destination !== m.destination;
|
|
220
|
+
});
|
|
221
|
+
if (this.volumes.length === 0) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
this.volumeUnmount(...restVolumes);
|
|
225
|
+
}
|
|
226
|
+
addExtraHost(host, domain) {
|
|
227
|
+
if (!this.extraHosts) {
|
|
228
|
+
this.extraHosts = {};
|
|
229
|
+
}
|
|
230
|
+
this.extraHosts[host] = domain;
|
|
231
|
+
}
|
|
232
|
+
removeExtraHost(host) {
|
|
233
|
+
if (!this.extraHosts || !this.extraHosts[host]) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
delete this.extraHosts[host];
|
|
237
|
+
}
|
|
238
|
+
getSecret(key, byDefault) {
|
|
239
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
240
|
+
const container = AsyncStorage_1.AsyncStorage.getContainer(), keystoreService = container.get("KEYSTORE_SERVICE");
|
|
241
|
+
return keystoreService.get(`p:${this.name}:${key}`, byDefault);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
setSecret(key, value) {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
+
const container = AsyncStorage_1.AsyncStorage.getContainer(), keystoreService = container.get("KEYSTORE_SERVICE");
|
|
247
|
+
return keystoreService.set(`p:${this.name}:${key}`, value);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
unsetSecret(key) {
|
|
251
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
252
|
+
const container = AsyncStorage_1.AsyncStorage.getContainer(), keystoreService = container.get("KEYSTORE_SERVICE");
|
|
253
|
+
return keystoreService.delete(`p:${this.name}:${key}`);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
save() {
|
|
257
|
+
const container = AsyncStorage_1.AsyncStorage.getContainer(), projectRepository = container.get(ProjectRepository_1.ProjectRepository);
|
|
258
|
+
projectRepository.save(this);
|
|
259
|
+
}
|
|
260
|
+
toObject() {
|
|
261
|
+
return {
|
|
262
|
+
name: this.name,
|
|
263
|
+
type: this.type,
|
|
264
|
+
path: this.path,
|
|
265
|
+
imageName: this.imageName,
|
|
266
|
+
dockerfile: this.dockerfile,
|
|
267
|
+
composefile: this.composefile,
|
|
268
|
+
preset: this.preset,
|
|
269
|
+
presetMode: this.presetMode,
|
|
270
|
+
scripts: this.scripts,
|
|
271
|
+
services: Object.keys(this.services).length > 0 ? this.services : undefined,
|
|
272
|
+
buildArgs: Object.keys(this.buildArgs).length > 0 ? this.buildArgs : undefined,
|
|
273
|
+
env: Object.keys(this.env).length > 0 ? this.env : undefined,
|
|
274
|
+
metadata: Object.keys(this.metadata).length > 0 ? this.metadata : undefined,
|
|
275
|
+
ports: this.ports.length > 0 ? this.ports : undefined,
|
|
276
|
+
extraHosts: Object.keys(this.extraHosts).length ? this.extraHosts : undefined,
|
|
277
|
+
volumes: this.volumes.length > 0 ? this.volumes : undefined,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
exports.Project = Project;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Project } from "../makes/Project";
|
|
2
|
+
export type ProjectRepositorySearchParams = Partial<{
|
|
3
|
+
name: string;
|
|
4
|
+
path: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare abstract class ProjectRepository {
|
|
7
|
+
abstract getByName(name: string): Project;
|
|
8
|
+
abstract save(project: Project): void;
|
|
9
|
+
abstract search(params: ProjectRepositorySearchParams): Project[];
|
|
10
|
+
abstract searchOne(params: ProjectRepositorySearchParams): Project;
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ProjectRepository = void 0;
|
|
10
|
+
const decorators_1 = require("../../../decorators");
|
|
11
|
+
let ProjectRepository = class ProjectRepository {
|
|
12
|
+
};
|
|
13
|
+
exports.ProjectRepository = ProjectRepository;
|
|
14
|
+
exports.ProjectRepository = ProjectRepository = __decorate([
|
|
15
|
+
(0, decorators_1.Injectable)("PROJECT_REPOSITORY")
|
|
16
|
+
], ProjectRepository);
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { Project } from "../makes/Project";
|
|
2
|
-
|
|
3
|
-
name: string;
|
|
4
|
-
path: string;
|
|
5
|
-
}>;
|
|
2
|
+
import { ProjectRepositorySearchParams } from "../repositories/ProjectRepository";
|
|
6
3
|
export declare abstract class ProjectService {
|
|
7
4
|
abstract get(name?: string): Project;
|
|
8
5
|
abstract save(project: Project): void;
|
|
9
|
-
abstract search(params: SearchParams): Project[];
|
|
10
6
|
abstract start(project: Project): Promise<void>;
|
|
11
7
|
abstract stop(project: Project): Promise<void>;
|
|
12
|
-
|
|
8
|
+
abstract search(params: ProjectRepositorySearchParams): Project[];
|
|
9
|
+
searchOne(params?: ProjectRepositorySearchParams): Project | null;
|
|
13
10
|
/**
|
|
14
11
|
* @deprecated
|
|
15
12
|
*/
|
|
16
13
|
cdProject(name?: string): void;
|
|
17
14
|
}
|
|
18
|
-
export { SearchParams as ProjectServiceSearchParams };
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.ProjectService = void 0;
|
|
10
|
-
const decorators_1 = require("
|
|
10
|
+
const decorators_1 = require("../../../decorators");
|
|
11
11
|
let ProjectService = class ProjectService {
|
|
12
12
|
searchOne(params = {}) {
|
|
13
13
|
const [project] = this.search(params);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const PROJECT_TYPE_DOCKERFILE = "dockerfile";
|
|
2
|
+
export declare const PROJECT_TYPE_IMAGE = "image";
|
|
3
|
+
export declare const PROJECT_TYPE_PRESET = "preset";
|
|
4
|
+
export declare const PROJECT_TYPE_COMPOSE = "compose";
|
|
5
|
+
export type ProjectType = typeof PROJECT_TYPE_DOCKERFILE | typeof PROJECT_TYPE_IMAGE | typeof PROJECT_TYPE_PRESET | typeof PROJECT_TYPE_COMPOSE;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PROJECT_TYPE_COMPOSE = exports.PROJECT_TYPE_PRESET = exports.PROJECT_TYPE_IMAGE = exports.PROJECT_TYPE_DOCKERFILE = void 0;
|
|
4
|
+
exports.PROJECT_TYPE_DOCKERFILE = "dockerfile";
|
|
5
|
+
exports.PROJECT_TYPE_IMAGE = "image";
|
|
6
|
+
exports.PROJECT_TYPE_PRESET = "preset";
|
|
7
|
+
exports.PROJECT_TYPE_COMPOSE = "compose";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EnvConfig } from "../../../types";
|
|
2
|
+
import { ProjectType } from "./ProjectType";
|
|
3
|
+
import { ServiceProperties } from "./ServiceProperties";
|
|
4
|
+
export type ProjectV1 = {
|
|
5
|
+
name: string;
|
|
6
|
+
type: ProjectType;
|
|
7
|
+
path: string;
|
|
8
|
+
imageName?: string;
|
|
9
|
+
dockerfile?: string;
|
|
10
|
+
composefile?: string;
|
|
11
|
+
preset?: string;
|
|
12
|
+
presetMode?: "global" | "project";
|
|
13
|
+
scripts?: string[];
|
|
14
|
+
services?: {
|
|
15
|
+
[service: string]: ServiceProperties;
|
|
16
|
+
};
|
|
17
|
+
buildArgs?: EnvConfig;
|
|
18
|
+
env?: EnvConfig;
|
|
19
|
+
metadata?: EnvConfig;
|
|
20
|
+
ports?: string[];
|
|
21
|
+
extraHosts?: EnvConfig;
|
|
22
|
+
volumes?: string[];
|
|
23
|
+
};
|