@wocker/core 1.1.0-beta.1 → 1.1.0-beta.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.
Files changed (44) hide show
  1. package/lib/core/Container.js +2 -2
  2. package/lib/core/CoreModule.js +3 -0
  3. package/lib/makes/AppConfig.d.ts +15 -15
  4. package/lib/makes/AppConfig.js +0 -2
  5. package/lib/makes/JsonEditor.d.ts +19 -0
  6. package/lib/makes/JsonEditor.js +101 -0
  7. package/lib/makes/Project.d.ts +63 -0
  8. package/lib/makes/Project.js +229 -0
  9. package/lib/makes/ProjectConfig.d.ts +85 -0
  10. package/lib/makes/ProjectConfig.js +329 -0
  11. package/lib/makes/ServiceConfig.d.ts +23 -0
  12. package/lib/makes/ServiceConfig.js +57 -0
  13. package/lib/makes/index.d.ts +1 -0
  14. package/lib/makes/index.js +1 -0
  15. package/lib/modules/project/index.d.ts +0 -3
  16. package/lib/modules/project/index.js +0 -2
  17. package/lib/modules/project/services/ProjectService.d.ts +2 -2
  18. package/lib/services/AppFileSystemService.js +1 -1
  19. package/lib/services/AppService.d.ts +5 -2
  20. package/lib/services/AppService.js +10 -4
  21. package/lib/services/LogService.d.ts +6 -4
  22. package/lib/services/LogService.js +18 -10
  23. package/lib/services/ProcessService.d.ts +1 -1
  24. package/lib/services/ProjectRepository.d.ts +22 -0
  25. package/lib/services/ProjectRepository.js +89 -0
  26. package/lib/services/index.d.ts +1 -0
  27. package/lib/services/index.js +1 -0
  28. package/lib/types/LogLevel.d.ts +13 -0
  29. package/lib/types/LogLevel.js +20 -0
  30. package/lib/types/ProjectConfigScope.d.ts +9 -0
  31. package/lib/types/ProjectConfigScope.js +20 -0
  32. package/lib/types/index.d.ts +2 -0
  33. package/lib/types/index.js +2 -0
  34. package/package.json +2 -1
  35. package/lib/modules/project/makes/Project.d.ts +0 -59
  36. package/lib/modules/project/makes/Project.js +0 -282
  37. package/lib/modules/project/repositories/ProjectRepository.d.ts +0 -13
  38. package/lib/modules/project/repositories/ProjectRepository.js +0 -16
  39. package/lib/modules/project/types/ProjectV1.d.ts +0 -25
  40. package/lib/modules/project/types/ProjectV1.js +0 -2
  41. package/lib/modules/project/types/ServiceProperties.d.ts +0 -9
  42. package/lib/modules/project/types/ServiceProperties.js +0 -2
  43. package/lib/modules/project/types/index.d.ts +0 -2
  44. package/lib/modules/project/types/index.js +0 -18
@@ -0,0 +1,89 @@
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
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ProjectRepository = void 0;
16
+ const decorators_1 = require("../decorators");
17
+ const Project_1 = require("../makes/Project");
18
+ const ProjectConfig_1 = require("../makes/ProjectConfig");
19
+ const makes_1 = require("../makes");
20
+ const AppService_1 = require("./AppService");
21
+ const AppFileSystemService_1 = require("./AppFileSystemService");
22
+ const types_1 = require("../types");
23
+ const env_1 = require("../env");
24
+ let ProjectRepository = class ProjectRepository {
25
+ constructor(appService, fs, driver) {
26
+ this.appService = appService;
27
+ this.fs = fs;
28
+ this.driver = driver;
29
+ }
30
+ getConfig(name, scope) {
31
+ const ref = this.appService.getProject(name);
32
+ if (!ref) {
33
+ throw new Error("");
34
+ }
35
+ switch (scope) {
36
+ case types_1.ProjectConfigScope.APP:
37
+ return ProjectConfig_1.ProjectConfig.make(this.fs.cd(`projects/${ref.name}`), "config.json");
38
+ case types_1.ProjectConfigScopeEnum.LOCAL:
39
+ return ProjectConfig_1.ProjectConfig.make(new makes_1.FileSystem(ref.path, this.driver), "wocker.config.json");
40
+ }
41
+ }
42
+ getByName(name) {
43
+ const ref = this.appService.getProject(name);
44
+ if (!ref) {
45
+ throw new Error(`Project "${name}" not found`);
46
+ }
47
+ return new Project_1.Project(ref.name, ref.path);
48
+ }
49
+ save(project) {
50
+ if (!project.ref) {
51
+ this.appService.addProject(project.name, project.path);
52
+ }
53
+ if (!this.fs.exists(`projects/${project.name}`)) {
54
+ this.fs.mkdir(`projects/${project.name}`);
55
+ }
56
+ if (project.configs.app.isDirty()) {
57
+ this.fs.writeFile(`projects/${project.name}/config.json`, project.configs.app.toString());
58
+ }
59
+ if (project.configs.project.isDirty()) {
60
+ const projectFS = new makes_1.FileSystem(project.path, this.driver);
61
+ projectFS.writeFile("wocker.config.json", project.configs.project.toString());
62
+ }
63
+ }
64
+ search(params) {
65
+ const { name, path } = params, projects = [];
66
+ for (const ref of this.appService.projects) {
67
+ if (name && ref.name !== name) {
68
+ continue;
69
+ }
70
+ if (path && ref.path !== path) {
71
+ continue;
72
+ }
73
+ const project = this.getByName(ref.name);
74
+ projects.push(project);
75
+ }
76
+ return projects;
77
+ }
78
+ searchOne(params) {
79
+ const [project] = this.search(params);
80
+ return project || null;
81
+ }
82
+ };
83
+ exports.ProjectRepository = ProjectRepository;
84
+ exports.ProjectRepository = ProjectRepository = __decorate([
85
+ (0, decorators_1.Injectable)("PROJECT_REPOSITORY"),
86
+ __param(2, (0, decorators_1.Inject)(env_1.FILE_SYSTEM_DRIVER_KEY)),
87
+ __metadata("design:paramtypes", [AppService_1.AppService,
88
+ AppFileSystemService_1.AppFileSystemService, Object])
89
+ ], ProjectRepository);
@@ -4,3 +4,4 @@ export * from "./AppService";
4
4
  export * from "./EventService";
5
5
  export * from "./LogService";
6
6
  export * from "./ProcessService";
7
+ export * from "./ProjectRepository";
@@ -20,3 +20,4 @@ __exportStar(require("./AppService"), exports);
20
20
  __exportStar(require("./EventService"), exports);
21
21
  __exportStar(require("./LogService"), exports);
22
22
  __exportStar(require("./ProcessService"), exports);
23
+ __exportStar(require("./ProjectRepository"), exports);
@@ -0,0 +1,13 @@
1
+ declare enum LogLevelEnum {
2
+ DEBUG = "debug",
3
+ LOG = "log",
4
+ INFO = "info",
5
+ WARNING = "warn",
6
+ ERROR = "error"
7
+ }
8
+ export type LogLevel = LogLevelEnum;
9
+ export declare const LogLevel: typeof LogLevelEnum & {
10
+ values(): LogLevelEnum[];
11
+ isGTE(a: LogLevelEnum, b: LogLevelEnum): boolean;
12
+ };
13
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogLevel = void 0;
4
+ var LogLevelEnum;
5
+ (function (LogLevelEnum) {
6
+ LogLevelEnum["DEBUG"] = "debug";
7
+ LogLevelEnum["LOG"] = "log";
8
+ LogLevelEnum["INFO"] = "info";
9
+ LogLevelEnum["WARNING"] = "warn";
10
+ LogLevelEnum["ERROR"] = "error";
11
+ })(LogLevelEnum || (LogLevelEnum = {}));
12
+ exports.LogLevel = Object.assign({}, LogLevelEnum, {
13
+ values() {
14
+ return Object.values(LogLevelEnum);
15
+ },
16
+ isGTE(a, b) {
17
+ const values = exports.LogLevel.values();
18
+ return values.indexOf(a) <= values.indexOf(b);
19
+ }
20
+ });
@@ -0,0 +1,9 @@
1
+ import { ProjectRef } from "../types";
2
+ export declare enum ProjectConfigScopeEnum {
3
+ APP = "app",
4
+ LOCAL = "project"
5
+ }
6
+ export type ProjectConfigScope = ProjectConfigScopeEnum;
7
+ export declare const ProjectConfigScope: typeof ProjectConfigScopeEnum & {
8
+ fileName(scope: ProjectConfigScopeEnum, projectRef: ProjectRef): string;
9
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectConfigScope = exports.ProjectConfigScopeEnum = void 0;
4
+ var ProjectConfigScopeEnum;
5
+ (function (ProjectConfigScopeEnum) {
6
+ ProjectConfigScopeEnum["APP"] = "app";
7
+ ProjectConfigScopeEnum["LOCAL"] = "project";
8
+ })(ProjectConfigScopeEnum || (exports.ProjectConfigScopeEnum = ProjectConfigScopeEnum = {}));
9
+ exports.ProjectConfigScope = Object.assign({}, ProjectConfigScopeEnum, {
10
+ fileName(scope, projectRef) {
11
+ switch (scope) {
12
+ case ProjectConfigScopeEnum.APP:
13
+ return `projects/${projectRef.name}/config.json`;
14
+ case ProjectConfigScopeEnum.LOCAL:
15
+ return `wocker.config.json`;
16
+ default:
17
+ throw new Error(`Unknown config scope: ${scope}`);
18
+ }
19
+ }
20
+ });
@@ -2,10 +2,12 @@ export * from "./DynamicModule";
2
2
  export * from "./EnvConfig";
3
3
  export * from "./FileSystemDriver";
4
4
  export * from "./InjectionToken";
5
+ export * from "./LogLevel";
5
6
  export * from "./ModuleMetadata";
6
7
  export * from "./PackageManagerType";
7
8
  export * from "./PickProperties";
8
9
  export * from "./PluginMetadata";
10
+ export * from "./ProjectConfigScope";
9
11
  export * from "./PluginRef";
10
12
  export * from "./PresetRef";
11
13
  export * from "./PresetSource";
@@ -18,10 +18,12 @@ __exportStar(require("./DynamicModule"), exports);
18
18
  __exportStar(require("./EnvConfig"), exports);
19
19
  __exportStar(require("./FileSystemDriver"), exports);
20
20
  __exportStar(require("./InjectionToken"), exports);
21
+ __exportStar(require("./LogLevel"), exports);
21
22
  __exportStar(require("./ModuleMetadata"), exports);
22
23
  __exportStar(require("./PackageManagerType"), exports);
23
24
  __exportStar(require("./PickProperties"), exports);
24
25
  __exportStar(require("./PluginMetadata"), exports);
26
+ __exportStar(require("./ProjectConfigScope"), exports);
25
27
  __exportStar(require("./PluginRef"), exports);
26
28
  __exportStar(require("./PresetRef"), exports);
27
29
  __exportStar(require("./PresetSource"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wocker/core",
3
3
  "type": "commonjs",
4
- "version": "1.1.0-beta.1",
4
+ "version": "1.1.0-beta.3",
5
5
  "author": "Kris Papercut <krispcut@gmail.com>",
6
6
  "description": "Core of the Wocker",
7
7
  "license": "MIT",
@@ -29,6 +29,7 @@
29
29
  "dependencies": {
30
30
  "@kearisp/cli": "^2.0.9",
31
31
  "date-fns": "^4.1.0",
32
+ "jsonc-parser": "^3.3.1",
32
33
  "readline": "^1.3.0",
33
34
  "reflect-metadata": "^0.2.2",
34
35
  "stream": "^0.0.3",
@@ -1,59 +0,0 @@
1
- import { EnvConfig, ProjectType } from "../../../types";
2
- import { ServiceProperties, ProjectV1 } from "../types";
3
- export declare class Project {
4
- /** @deprecated */
5
- id?: string;
6
- name: string;
7
- type: ProjectType;
8
- path: string;
9
- cmd?: string[];
10
- imageName?: string;
11
- dockerfile?: string;
12
- composefile?: string;
13
- preset?: string;
14
- presetMode?: "global" | "project";
15
- scripts?: {
16
- [script: string]: string;
17
- };
18
- services: {
19
- [name: string]: ServiceProperties;
20
- };
21
- buildArgs: EnvConfig;
22
- env: EnvConfig;
23
- metadata: EnvConfig;
24
- ports: string[];
25
- extraHosts: EnvConfig;
26
- volumes: string[];
27
- constructor(data: ProjectV1);
28
- get containerName(): string;
29
- get domains(): string[];
30
- hasDomain(domain: string): boolean;
31
- addDomain(addDomain: string): void;
32
- removeDomain(removeDomain: string): void;
33
- clearDomains(): void;
34
- linkPort(hostPort: number, containerPort: number): void;
35
- unlinkPort(hostPort: number, containerPort: number): void;
36
- setBuildArg(name: string, value: string, service?: string): void;
37
- unsetBuildArg(name: string, service?: string): void;
38
- hasEnv(name: string): boolean;
39
- getEnv(key: string): string | undefined;
40
- getEnv(key: string, byDefault: string): string;
41
- setEnv(name: string, value: string | boolean, service?: string): void;
42
- unsetEnv(name: string, service?: string): void;
43
- hasMeta(name: string): boolean;
44
- getMeta<D = string | undefined>(name: string, defaultValue?: D): D;
45
- setMeta(name: string, value: string | boolean): void;
46
- unsetMeta(name: string): void;
47
- getVolumeBySource(source: string): string | undefined;
48
- getVolumeByDestination(destination: string): string | undefined;
49
- volumeMount(...volumes: string[]): void;
50
- volumeUnmount(...volumes: string[]): void;
51
- addExtraHost(host: string, domain: string): void;
52
- removeExtraHost(host: string): void;
53
- getSecret(key: string): Promise<string | undefined>;
54
- getSecret(key: string, byDefault: string): Promise<string>;
55
- setSecret(key: string, value: string): Promise<void>;
56
- unsetSecret(key: string): Promise<void>;
57
- save(): void;
58
- toObject(): ProjectV1;
59
- }
@@ -1,282 +0,0 @@
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
- cmd: this.cmd,
271
- scripts: this.scripts,
272
- services: Object.keys(this.services).length > 0 ? this.services : undefined,
273
- buildArgs: Object.keys(this.buildArgs).length > 0 ? this.buildArgs : undefined,
274
- env: Object.keys(this.env).length > 0 ? this.env : undefined,
275
- metadata: Object.keys(this.metadata).length > 0 ? this.metadata : undefined,
276
- ports: this.ports.length > 0 ? this.ports : undefined,
277
- extraHosts: Object.keys(this.extraHosts).length ? this.extraHosts : undefined,
278
- volumes: this.volumes.length > 0 ? this.volumes : undefined,
279
- };
280
- }
281
- }
282
- exports.Project = Project;
@@ -1,13 +0,0 @@
1
- import { Project } from "../makes/Project";
2
- export declare abstract class ProjectRepository {
3
- abstract getByName(name: string): Project;
4
- abstract save(project: Project): void;
5
- abstract search(params: ProjectRepository.SearchParams): Project[];
6
- abstract searchOne(params: ProjectRepository.SearchParams): Project;
7
- }
8
- export declare namespace ProjectRepository {
9
- type SearchParams = Partial<{
10
- name: string;
11
- path: string;
12
- }>;
13
- }
@@ -1,16 +0,0 @@
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,25 +0,0 @@
1
- import { EnvConfig, ProjectType } from "../../../types";
2
- import { ServiceProperties } from "./ServiceProperties";
3
- export type ProjectV1 = {
4
- name: string;
5
- type: ProjectType;
6
- path: string;
7
- imageName?: string;
8
- dockerfile?: string;
9
- composefile?: string;
10
- preset?: string;
11
- presetMode?: "global" | "project";
12
- cmd?: string[];
13
- scripts?: {
14
- [script: string]: string;
15
- };
16
- services?: {
17
- [service: string]: ServiceProperties;
18
- };
19
- buildArgs?: EnvConfig;
20
- env?: EnvConfig;
21
- metadata?: EnvConfig;
22
- ports?: string[];
23
- extraHosts?: EnvConfig;
24
- volumes?: string[];
25
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +0,0 @@
1
- import { EnvConfig } from "../../../types";
2
- export type ServiceProperties = {
3
- type?: "compose" | "plugin";
4
- containerName?: string;
5
- buildArgs?: EnvConfig;
6
- env?: EnvConfig;
7
- ports?: string[];
8
- volumes?: string[];
9
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- export * from "./ProjectV1";
2
- export * from "./ServiceProperties";
@@ -1,18 +0,0 @@
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("./ProjectV1"), exports);
18
- __exportStar(require("./ServiceProperties"), exports);