@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
@@ -55,8 +55,8 @@ let Container = class Container {
55
55
  if (wrapper) {
56
56
  wrapper.replace(provider);
57
57
  }
58
- this.modules.forEach((moduleRef) => {
59
- moduleRef.replace(token, provider);
58
+ this.modules.forEach((moduleWrapper) => {
59
+ moduleWrapper.replace(token, provider);
60
60
  });
61
61
  }
62
62
  };
@@ -19,6 +19,7 @@ const AppFileSystemService_1 = require("../services/AppFileSystemService");
19
19
  const ProcessService_1 = require("../services/ProcessService");
20
20
  const EventService_1 = require("../services/EventService");
21
21
  const LogService_1 = require("../services/LogService");
22
+ const ProjectRepository_1 = require("../services/ProjectRepository");
22
23
  const env_1 = require("../env");
23
24
  let CoreModule = class CoreModule {
24
25
  };
@@ -43,6 +44,7 @@ exports.CoreModule = CoreModule = __decorate([
43
44
  AppService_1.AppService,
44
45
  AppConfigService_1.AppConfigService,
45
46
  AppFileSystemService_1.AppFileSystemService,
47
+ ProjectRepository_1.ProjectRepository,
46
48
  ProcessService_1.ProcessService,
47
49
  EventService_1.EventService,
48
50
  LogService_1.LogService
@@ -55,6 +57,7 @@ exports.CoreModule = CoreModule = __decorate([
55
57
  AppService_1.AppService,
56
58
  AppConfigService_1.AppConfigService,
57
59
  AppFileSystemService_1.AppFileSystemService,
60
+ ProjectRepository_1.ProjectRepository,
58
61
  ProcessService_1.ProcessService,
59
62
  EventService_1.EventService,
60
63
  LogService_1.LogService
@@ -1,27 +1,15 @@
1
- import { EnvConfig, PackageManagerType, PluginRef, PresetRef, ProjectRef, ProjectOldRef, PresetSource } from "../types";
2
1
  import { FileSystem } from "./FileSystem";
3
- export type AppConfigProperties = {
4
- debug?: boolean;
5
- pm?: PackageManagerType;
6
- keystore?: string;
7
- logLevel?: "off" | "info" | "warn" | "error";
8
- plugins?: PluginRef[];
9
- presets?: PresetRef[];
10
- projects?: ProjectOldRef[];
11
- meta?: EnvConfig;
12
- env?: EnvConfig;
13
- };
2
+ import { EnvConfig, PackageManagerType, PluginRef, PresetRef, ProjectRef, ProjectOldRef, PresetSource } from "../types";
14
3
  export declare abstract class AppConfig {
15
4
  debug?: boolean;
16
5
  pm?: PackageManagerType;
17
6
  keystore?: string;
18
- logLevel: "off" | "info" | "warn" | "error";
19
7
  plugins: PluginRef[];
20
8
  presets: PresetRef[];
21
9
  projects: ProjectRef[];
22
10
  meta?: EnvConfig;
23
11
  env?: EnvConfig;
24
- constructor(data: AppConfigProperties);
12
+ constructor(data: AppConfig.Data);
25
13
  addPlugin(name: string, env?: PluginRef["env"]): void;
26
14
  removePlugin(name: string): void;
27
15
  getProject(name: string): ProjectRef | undefined;
@@ -39,7 +27,19 @@ export declare abstract class AppConfig {
39
27
  setEnv(name: string, value: string): void;
40
28
  unsetEnv(name: string): void;
41
29
  abstract save(): void;
42
- toObject(): AppConfigProperties;
30
+ toObject(): AppConfig.Data;
43
31
  toJsString(): string;
44
32
  static make(fs: FileSystem): AppConfig;
45
33
  }
34
+ export declare namespace AppConfig {
35
+ type Data = {
36
+ debug?: boolean;
37
+ pm?: PackageManagerType;
38
+ keystore?: string;
39
+ plugins?: PluginRef[];
40
+ presets?: PresetRef[];
41
+ projects?: ProjectOldRef[];
42
+ meta?: EnvConfig;
43
+ env?: EnvConfig;
44
+ };
45
+ }
@@ -15,7 +15,6 @@ exports.AppConfig = void 0;
15
15
  const types_1 = require("../types");
16
16
  class AppConfig {
17
17
  constructor(data) {
18
- this.logLevel = "off";
19
18
  const { plugins = [], presets = [], projects = [] } = data, rest = __rest(data, ["plugins", "presets", "projects"]);
20
19
  Object.assign(this, rest);
21
20
  this.plugins = plugins.map((plugin) => {
@@ -167,7 +166,6 @@ class AppConfig {
167
166
  return {
168
167
  debug: this.debug,
169
168
  pm: this.pm,
170
- logLevel: this.logLevel,
171
169
  keystore: this.keystore,
172
170
  plugins: this.plugins.length > 0 ? this.plugins : undefined,
173
171
  presets: this.presets.length > 0 ? this.presets : undefined,
@@ -0,0 +1,19 @@
1
+ import { JSONPath, Node, ModificationOptions } from "jsonc-parser";
2
+ export declare class JsonEditor<T extends object> {
3
+ protected readonly original: string;
4
+ protected content: string;
5
+ protected root: Node;
6
+ state: T;
7
+ constructor(original: string);
8
+ protected createProxy(keys: JSONPath, options?: JsonEditor.CreateProxyOptions): any;
9
+ get(key: string | JSONPath): any;
10
+ set(key: string | JSONPath, value: any, options?: ModificationOptions): void;
11
+ isDirty(): boolean;
12
+ toString(): string;
13
+ }
14
+ export declare namespace JsonEditor {
15
+ type CreateProxyOptions = {
16
+ isArray?: boolean;
17
+ removeOnEmpty?: boolean;
18
+ };
19
+ }
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonEditor = void 0;
4
+ const jsonc_parser_1 = require("jsonc-parser");
5
+ class JsonEditor {
6
+ constructor(original) {
7
+ this.original = original;
8
+ this.content = this.original;
9
+ this.root = (0, jsonc_parser_1.parseTree)(this.content);
10
+ this.state = this.createProxy([]);
11
+ }
12
+ createProxy(keys, options = {}) {
13
+ const { isArray, removeOnEmpty } = options;
14
+ let target = this.get(keys);
15
+ if (!target) {
16
+ target = isArray ? [] : {};
17
+ }
18
+ return new Proxy(target, {
19
+ get: (target, property) => {
20
+ if (target && target.__proto__ && property in target.__proto__) {
21
+ if (typeof target[property] === "function") {
22
+ return (...args) => {
23
+ const res = target[property](...args);
24
+ this.set(keys, target, {
25
+ formattingOptions: {
26
+ keepLines: false,
27
+ insertSpaces: true
28
+ }
29
+ });
30
+ return res;
31
+ };
32
+ }
33
+ return target[property];
34
+ }
35
+ if (Array.isArray(target)) {
36
+ property = parseInt(property);
37
+ }
38
+ const value = this.get([...keys, property]);
39
+ if (value !== null && typeof value === "object") {
40
+ return this.createProxy([...keys, property]);
41
+ }
42
+ return value;
43
+ },
44
+ set: (_, property, value) => {
45
+ if (Array.isArray(_)) {
46
+ property = parseInt(property);
47
+ }
48
+ this.set([...keys, property], value, {
49
+ formattingOptions: {
50
+ keepLines: false,
51
+ insertSpaces: true
52
+ }
53
+ });
54
+ if (removeOnEmpty) {
55
+ const value = this.get(keys);
56
+ if (typeof value === "object" && Object.keys(value).length === 0) {
57
+ this.set(keys, undefined);
58
+ }
59
+ }
60
+ return true;
61
+ },
62
+ has: (target, property) => {
63
+ return property in target;
64
+ },
65
+ deleteProperty: (_, property) => {
66
+ if (Array.isArray(_)) {
67
+ property = parseInt(property);
68
+ }
69
+ this.set([...keys, property], undefined);
70
+ if (removeOnEmpty) {
71
+ const value = this.get(keys);
72
+ if (typeof value === "object" && Object.keys(value).length === 0) {
73
+ this.set(keys, undefined);
74
+ }
75
+ }
76
+ return true;
77
+ }
78
+ });
79
+ }
80
+ ;
81
+ get(key) {
82
+ const path = typeof key === "string" ? key.split(".") : key;
83
+ const node = (0, jsonc_parser_1.findNodeAtLocation)(this.root, path);
84
+ if (!node) {
85
+ return undefined;
86
+ }
87
+ return (0, jsonc_parser_1.getNodeValue)(node);
88
+ }
89
+ set(key, value, options = {}) {
90
+ const path = typeof key === "string" ? key.split(".") : key;
91
+ this.content = (0, jsonc_parser_1.applyEdits)(this.content, (0, jsonc_parser_1.modify)(this.content, path, value, options));
92
+ this.root = (0, jsonc_parser_1.parseTree)(this.content);
93
+ }
94
+ isDirty() {
95
+ return this.content !== this.original;
96
+ }
97
+ toString() {
98
+ return this.content;
99
+ }
100
+ }
101
+ exports.JsonEditor = JsonEditor;
@@ -0,0 +1,63 @@
1
+ import { ProjectConfig } from "./ProjectConfig";
2
+ import { EnvConfig, ProjectConfigScope, ProjectRef, ProjectType } from "../types";
3
+ export declare class Project {
4
+ name: string;
5
+ path: string;
6
+ readonly ref?: ProjectRef;
7
+ readonly configs: Record<ProjectConfigScope, ProjectConfig>;
8
+ constructor(name: string, path: string);
9
+ get type(): ProjectType;
10
+ set type(type: ProjectType);
11
+ get containerName(): string;
12
+ get scripts(): any;
13
+ get preset(): string | undefined;
14
+ set preset(preset: string | undefined);
15
+ get presetMode(): "project" | "global";
16
+ set presetMode(mode: "project" | "global");
17
+ get imageName(): string | undefined;
18
+ set imageName(image: string | undefined);
19
+ get dockerfile(): string | undefined;
20
+ set dockerfile(dockerfile: string | undefined);
21
+ get composefile(): string | undefined;
22
+ set composefile(composefile: string | undefined);
23
+ get cmd(): string[] | undefined;
24
+ get domains(): string[];
25
+ hasDomain(domain: string): boolean;
26
+ addDomain(addDomain: string): void;
27
+ removeDomain(removeDomain: string): void;
28
+ clearDomains(): void;
29
+ get volumes(): string[];
30
+ get ports(): string[];
31
+ set ports(ports: string[]);
32
+ linkPort(hostPort: number, containerPort: number): void;
33
+ unlinkPort(hostPort: number, containerPort: number): void;
34
+ get buildArgs(): EnvConfig;
35
+ set buildArgs(buildArgs: EnvConfig);
36
+ setBuildArg(key: string, value: string, service?: string): void;
37
+ unsetBuildArg(name: string, service?: string): void;
38
+ get env(): EnvConfig;
39
+ set env(env: EnvConfig);
40
+ hasEnv(name: string): boolean;
41
+ getEnv(key: string): string | undefined;
42
+ getEnv(key: string, byDefault: string): string;
43
+ setEnv(key: string, value: string | boolean, service?: string): void;
44
+ unsetEnv(key: string, service?: string): void;
45
+ hasMeta(key: string): boolean;
46
+ getMeta(key: string): string | undefined;
47
+ getMeta(key: string, byDefault: string): string;
48
+ setMeta(name: string, value: string | boolean): void;
49
+ unsetMeta(name: string): void;
50
+ getVolumeBySource(source: string): string | undefined;
51
+ getVolumeByDestination(destination: string): string | undefined;
52
+ volumeMount(...volumes: string[]): void;
53
+ volumeUnmount(...volumes: string[]): void;
54
+ get extraHosts(): any;
55
+ addExtraHost(host: string, domain: string): void;
56
+ removeExtraHost(host: string): void;
57
+ get services(): any;
58
+ getSecret(key: string): Promise<string | undefined>;
59
+ getSecret(key: string, byDefault: string): Promise<string>;
60
+ setSecret(key: string, value: string): Promise<void>;
61
+ unsetSecret(key: string): Promise<void>;
62
+ save(): void;
63
+ }
@@ -0,0 +1,229 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Project = void 0;
13
+ const AsyncStorage_1 = require("../core/AsyncStorage");
14
+ const AppService_1 = require("../services/AppService");
15
+ const ProjectRepository_1 = require("../services/ProjectRepository");
16
+ const volumeParse_1 = require("../utils/volumeParse");
17
+ const types_1 = require("../types");
18
+ class Project {
19
+ constructor(name, path) {
20
+ this.name = name;
21
+ this.path = path;
22
+ const container = AsyncStorage_1.AsyncStorage.getContainer(), appService = container.get(AppService_1.AppService), projectRepository = container.get(ProjectRepository_1.ProjectRepository);
23
+ this.ref = appService.getProject(this.name);
24
+ this.configs = {
25
+ [types_1.ProjectConfigScope.APP]: projectRepository.getConfig(this.name, types_1.ProjectConfigScope.APP),
26
+ [types_1.ProjectConfigScope.LOCAL]: projectRepository.getConfig(this.name, types_1.ProjectConfigScope.LOCAL)
27
+ };
28
+ }
29
+ get type() {
30
+ return this.configs.app.type || this.configs.project.type;
31
+ }
32
+ set type(type) {
33
+ this.configs.app.type = type;
34
+ }
35
+ get containerName() {
36
+ return `${this.name}.workspace`;
37
+ }
38
+ get scripts() {
39
+ return Object.assign(Object.assign({}, this.configs.project.scripts), this.configs.app.scripts);
40
+ }
41
+ get preset() {
42
+ return this.configs.project.preset || this.configs.app.preset;
43
+ }
44
+ set preset(preset) {
45
+ this.configs.app.preset = preset;
46
+ }
47
+ get presetMode() {
48
+ return this.configs.app.presetMode;
49
+ }
50
+ set presetMode(mode) {
51
+ this.configs.app.presetMode = mode;
52
+ }
53
+ get imageName() {
54
+ return this.configs.app.image;
55
+ }
56
+ set imageName(image) {
57
+ this.configs.app.image = image;
58
+ }
59
+ get dockerfile() {
60
+ return this.configs.project.dockerfile || this.configs.app.dockerfile;
61
+ }
62
+ set dockerfile(dockerfile) {
63
+ this.configs.app.dockerfile = dockerfile;
64
+ }
65
+ get composefile() {
66
+ return this.configs.project.composefile || this.configs.app.composefile;
67
+ }
68
+ set composefile(composefile) {
69
+ this.configs.app.composefile = composefile;
70
+ }
71
+ get cmd() {
72
+ return this.configs.app.cmd;
73
+ }
74
+ get domains() {
75
+ const host = this.getEnv("VIRTUAL_HOST");
76
+ if (!host) {
77
+ return [];
78
+ }
79
+ return host.split(",");
80
+ }
81
+ hasDomain(domain) {
82
+ return this.domains.includes(domain);
83
+ }
84
+ addDomain(addDomain) {
85
+ let domains = [
86
+ ...this.domains.filter((domain) => {
87
+ return domain !== addDomain;
88
+ }),
89
+ addDomain
90
+ ];
91
+ this.setEnv("VIRTUAL_HOST", domains.join(","));
92
+ }
93
+ removeDomain(removeDomain) {
94
+ if (!this.hasDomain(removeDomain)) {
95
+ return;
96
+ }
97
+ let domains = this.domains.filter((domain) => {
98
+ return domain !== removeDomain;
99
+ });
100
+ this.setEnv("VIRTUAL_HOST", domains.join(","));
101
+ }
102
+ clearDomains() {
103
+ this.unsetEnv("VIRTUAL_HOST");
104
+ }
105
+ get volumes() {
106
+ return [
107
+ ...this.configs.project.volumes.filter((volume) => {
108
+ return !this.configs.app.getVolumeByDestination((0, volumeParse_1.volumeParse)(volume).destination);
109
+ }),
110
+ ...this.configs.app.volumes
111
+ ];
112
+ }
113
+ get ports() {
114
+ return [
115
+ ...this.configs.project.ports,
116
+ ...this.configs.app.ports
117
+ ];
118
+ }
119
+ set ports(ports) {
120
+ this.configs.app.ports = ports;
121
+ }
122
+ linkPort(hostPort, containerPort) {
123
+ this.configs.app.ports = [
124
+ ...this.configs.app.ports.filter((link) => {
125
+ return link !== `${hostPort}:${containerPort}`;
126
+ }),
127
+ `${hostPort}:${containerPort}`
128
+ ];
129
+ }
130
+ unlinkPort(hostPort, containerPort) {
131
+ this.configs.app.ports = this.configs.app.ports.filter((link) => {
132
+ return link !== `${hostPort}:${containerPort}`;
133
+ });
134
+ }
135
+ get buildArgs() {
136
+ return Object.assign(Object.assign({}, this.configs.project.buildArgs), this.configs.app.buildArgs);
137
+ }
138
+ set buildArgs(buildArgs) {
139
+ this.configs.app.buildArgs = buildArgs;
140
+ }
141
+ setBuildArg(key, value, service) {
142
+ this.configs.app.setBuildArg(key, value, service);
143
+ }
144
+ unsetBuildArg(name, service) {
145
+ this.configs.app.unsetBuildArg(name, service);
146
+ }
147
+ get env() {
148
+ return Object.assign(Object.assign({}, this.configs.project.env), this.configs.app.env);
149
+ }
150
+ set env(env) {
151
+ this.configs.app.env = env;
152
+ }
153
+ hasEnv(name) {
154
+ return this.configs.app.hasEnv(name) || this.configs.project.hasEnv(name);
155
+ }
156
+ getEnv(key, byDefault) {
157
+ return this.configs.app.env[key] || this.configs.project.env[key] || byDefault;
158
+ }
159
+ setEnv(key, value, service) {
160
+ this.configs.app.setEnv(key, value, service);
161
+ }
162
+ unsetEnv(key, service) {
163
+ this.configs.app.unsetEnv(key, service);
164
+ }
165
+ hasMeta(key) {
166
+ return this.configs.app.metadata.hasOwnProperty(key) || this.configs.project.metadata.hasOwnProperty(key);
167
+ }
168
+ getMeta(key, byDefault) {
169
+ return this.configs.app.metadata[key] || this.configs.project.metadata[key] || byDefault;
170
+ }
171
+ setMeta(name, value) {
172
+ this.configs.app.metadata[name] = typeof value === "boolean"
173
+ ? (value ? "true" : "false")
174
+ : value;
175
+ }
176
+ unsetMeta(name) {
177
+ if (name in this.configs.app.metadata) {
178
+ delete this.configs.app.metadata[name];
179
+ }
180
+ }
181
+ getVolumeBySource(source) {
182
+ return this.configs.project.getVolumeBySource(source) || this.configs.app.getVolumeBySource(source);
183
+ }
184
+ getVolumeByDestination(destination) {
185
+ return this.configs.project.getVolumeByDestination(destination) || this.configs.app.getVolumeByDestination(destination);
186
+ }
187
+ volumeMount(...volumes) {
188
+ this.configs.app.volumeMount(...volumes);
189
+ }
190
+ volumeUnmount(...volumes) {
191
+ this.configs.app.volumeUnmount(...volumes);
192
+ }
193
+ get extraHosts() {
194
+ return Object.assign(Object.assign({}, this.configs.project.extraHosts), this.configs.app.extraHosts);
195
+ }
196
+ ;
197
+ addExtraHost(host, domain) {
198
+ this.configs.app.addExtraHost(host, domain);
199
+ }
200
+ removeExtraHost(host) {
201
+ this.configs.app.removeExtraHost(host);
202
+ }
203
+ get services() {
204
+ return this.configs.app.services;
205
+ }
206
+ getSecret(key, byDefault) {
207
+ return __awaiter(this, void 0, void 0, function* () {
208
+ const container = AsyncStorage_1.AsyncStorage.getContainer(), keystoreService = container.get("KEYSTORE_SERVICE");
209
+ return keystoreService.get(`p:${this.name}:${key}`, byDefault);
210
+ });
211
+ }
212
+ setSecret(key, value) {
213
+ return __awaiter(this, void 0, void 0, function* () {
214
+ const container = AsyncStorage_1.AsyncStorage.getContainer(), keystoreService = container.get("KEYSTORE_SERVICE");
215
+ return keystoreService.set(`p:${this.name}:${key}`, value);
216
+ });
217
+ }
218
+ unsetSecret(key) {
219
+ return __awaiter(this, void 0, void 0, function* () {
220
+ const container = AsyncStorage_1.AsyncStorage.getContainer(), keystoreService = container.get("KEYSTORE_SERVICE");
221
+ return keystoreService.delete(`p:${this.name}:${key}`);
222
+ });
223
+ }
224
+ save() {
225
+ const container = AsyncStorage_1.AsyncStorage.getContainer(), projectRepository = container.get(ProjectRepository_1.ProjectRepository);
226
+ projectRepository.save(this);
227
+ }
228
+ }
229
+ exports.Project = Project;
@@ -0,0 +1,85 @@
1
+ import { FileSystem } from "./FileSystem";
2
+ import { EnvConfig, ProjectType } from "../types";
3
+ import { JsonEditor } from "./JsonEditor";
4
+ import { ServiceConfig } from "./ServiceConfig";
5
+ export declare class ProjectConfig extends JsonEditor<ProjectConfig.Data> {
6
+ constructor(content: string);
7
+ get type(): ProjectType | undefined;
8
+ set type(type: ProjectType | undefined);
9
+ get buildArgs(): EnvConfig;
10
+ set buildArgs(buildArgs: EnvConfig);
11
+ get env(): EnvConfig;
12
+ set env(env: EnvConfig | undefined);
13
+ get metadata(): EnvConfig;
14
+ set metadata(metadata: EnvConfig);
15
+ get preset(): string | undefined;
16
+ set preset(preset: string | undefined);
17
+ get presetMode(): "project" | "global" | undefined;
18
+ set presetMode(presetMode: "project" | "global" | undefined);
19
+ get image(): string | undefined;
20
+ set image(image: string | undefined);
21
+ get imageName(): string | undefined;
22
+ set imageName(image: string | undefined);
23
+ get composefile(): string | undefined;
24
+ set composefile(composefile: string | undefined);
25
+ get dockerfile(): string | undefined;
26
+ set dockerfile(dockerfile: string | undefined);
27
+ get cmd(): string[] | undefined;
28
+ set cmd(cmd: string[] | undefined);
29
+ get scripts(): any;
30
+ get services(): any;
31
+ get extraHosts(): any;
32
+ set extraHosts(extraHosts: any);
33
+ get volumes(): string[];
34
+ set volumes(volumes: string[]);
35
+ get ports(): string[];
36
+ set ports(ports: string[]);
37
+ setBuildArg(key: string, value: string, service?: string): void;
38
+ unsetBuildArg(name: string, service?: string): void;
39
+ getEnv(key: string): string | undefined;
40
+ getEnv(key: string, byDefault: string): string;
41
+ hasEnv(key: string): boolean;
42
+ setEnv(key: string, value: string | boolean, service?: string): void;
43
+ unsetEnv(key: string, service?: string): void;
44
+ getVolumeBySource(source: string): string | undefined;
45
+ getVolumeByDestination(destination: string): string | undefined;
46
+ volumeMount(...volumes: string[]): void;
47
+ volumeUnmount(...volumes: string[]): void;
48
+ addExtraHost(host: string, domain: string): void;
49
+ removeExtraHost(host: string): void;
50
+ addService(name: string, data: ServiceConfig.Data): void;
51
+ service(name: string): any;
52
+ toObject(): ProjectConfig.Data;
53
+ static make(fs: FileSystem, filename: string): ProjectConfig;
54
+ }
55
+ export declare namespace ProjectConfig {
56
+ type Data = {
57
+ type?: ProjectType;
58
+ image?: string;
59
+ /** @deprecated */
60
+ imageName?: string;
61
+ dockerfile?: string;
62
+ composefile?: string;
63
+ preset?: string;
64
+ presetMode?: "global" | "project";
65
+ scripts?: {
66
+ [script: string]: string;
67
+ };
68
+ cmd?: string[];
69
+ buildArgs?: EnvConfig;
70
+ env?: EnvConfig;
71
+ metadata?: EnvConfig;
72
+ volumes?: string[];
73
+ ports?: string[];
74
+ extraHosts?: EnvConfig;
75
+ services?: Record<string, ProjectConfig.Service>;
76
+ };
77
+ type Service = {
78
+ type?: "compose" | "plugin";
79
+ containerName?: string;
80
+ buildArgs?: EnvConfig;
81
+ env?: EnvConfig;
82
+ ports?: string[];
83
+ volumes?: string[];
84
+ };
85
+ }