@wocker/core 1.1.0-beta.0 → 1.1.0-beta.2

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 (35) hide show
  1. package/lib/core/ApplicationContext.d.ts +4 -2
  2. package/lib/core/ApplicationContext.js +2 -1
  3. package/lib/core/Factory.d.ts +2 -1
  4. package/lib/core/Factory.js +3 -3
  5. package/lib/core/Scanner.js +1 -1
  6. package/lib/makes/AppConfig.d.ts +10 -39
  7. package/lib/makes/AppConfig.js +0 -2
  8. package/lib/modules/project/index.d.ts +1 -0
  9. package/lib/modules/project/index.js +1 -0
  10. package/lib/modules/project/makes/Project.d.ts +37 -28
  11. package/lib/modules/project/makes/Project.js +127 -163
  12. package/lib/modules/project/makes/ProjectConfig.d.ts +61 -0
  13. package/lib/modules/project/makes/ProjectConfig.js +164 -0
  14. package/lib/modules/project/makes/ServiceConfig.d.ts +2 -0
  15. package/lib/modules/project/makes/ServiceConfig.js +6 -0
  16. package/lib/modules/project/repositories/ProjectRepository.d.ts +14 -5
  17. package/lib/modules/project/repositories/ProjectRepository.js +61 -1
  18. package/lib/modules/project/types/ProjectConfigScope.d.ts +9 -0
  19. package/lib/modules/project/types/ProjectConfigScope.js +20 -0
  20. package/lib/modules/project/types/index.d.ts +1 -0
  21. package/lib/modules/project/types/index.js +1 -0
  22. package/lib/services/AppFileSystemService.js +1 -1
  23. package/lib/services/AppService.d.ts +5 -2
  24. package/lib/services/AppService.js +10 -4
  25. package/lib/services/LogService.d.ts +6 -4
  26. package/lib/services/LogService.js +18 -10
  27. package/lib/services/ProcessService.d.ts +3 -0
  28. package/lib/services/ProcessService.js +15 -6
  29. package/lib/types/ApplicationOptions.d.ts +1 -0
  30. package/lib/types/ApplicationOptions.js +2 -0
  31. package/lib/types/LogLevel.d.ts +13 -0
  32. package/lib/types/LogLevel.js +20 -0
  33. package/lib/types/index.d.ts +1 -0
  34. package/lib/types/index.js +1 -0
  35. package/package.json +1 -2
@@ -0,0 +1,61 @@
1
+ import { FileSystem } from "../../../makes";
2
+ import { EnvConfig, ProjectType } from "../../../types";
3
+ import { ServiceProperties } from "../types";
4
+ export declare abstract class ProjectConfig {
5
+ type?: ProjectType;
6
+ image?: string;
7
+ dockerfile?: string;
8
+ composefile?: string;
9
+ preset?: string;
10
+ presetMode?: "global" | "project";
11
+ scripts: {
12
+ [script: string]: string;
13
+ };
14
+ cmd?: string[];
15
+ buildArgs: EnvConfig;
16
+ env: EnvConfig;
17
+ metadata: EnvConfig;
18
+ ports: string[];
19
+ volumes: string[];
20
+ extraHosts: EnvConfig;
21
+ services: Record<string, ServiceProperties>;
22
+ constructor(data: ProjectConfig.Data);
23
+ unsetBuildArg(name: string, service?: string): void;
24
+ getEnv(key: string): string | undefined;
25
+ getEnv(key: string, byDefault: string): string;
26
+ hasEnv(key: string): boolean;
27
+ setEnv(key: string, value: string | boolean, service?: string): void;
28
+ unsetEnv(key: string, service?: string): void;
29
+ abstract save(): void;
30
+ getVolumeBySource(source: string): string | undefined;
31
+ getVolumeByDestination(destination: string): string | undefined;
32
+ volumeMount(...volumes: string[]): void;
33
+ volumeUnmount(...volumes: string[]): void;
34
+ addExtraHost(host: string, domain: string): void;
35
+ removeExtraHost(host: string): void;
36
+ toObject(): ProjectConfig.Data;
37
+ static make(fs: FileSystem, filename: string): ProjectConfig;
38
+ }
39
+ export declare namespace ProjectConfig {
40
+ type Data = {
41
+ type?: ProjectType;
42
+ image?: string;
43
+ /** @deprecated */
44
+ imageName?: string;
45
+ dockerfile?: string;
46
+ composefile?: string;
47
+ preset?: string;
48
+ presetMode?: "global" | "project";
49
+ scripts?: {
50
+ [script: string]: string;
51
+ };
52
+ cmd?: string[];
53
+ buildArgs?: EnvConfig;
54
+ env?: EnvConfig;
55
+ metadata?: EnvConfig;
56
+ volumes?: string[];
57
+ ports?: string[];
58
+ extraHosts?: EnvConfig;
59
+ services?: Record<string, ServiceProperties>;
60
+ };
61
+ }
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectConfig = void 0;
4
+ const volumeParse_1 = require("../../../utils/volumeParse");
5
+ class ProjectConfig {
6
+ constructor(data) {
7
+ const { type, imageName, image = imageName, dockerfile, composefile, preset, presetMode, scripts = {}, cmd, buildArgs = {}, env = {}, metadata = {}, volumes = [], ports = [], extraHosts = {}, services = {} } = data;
8
+ this.type = type;
9
+ this.image = image;
10
+ this.dockerfile = dockerfile;
11
+ this.composefile = composefile;
12
+ this.preset = preset;
13
+ this.presetMode = presetMode;
14
+ this.scripts = scripts;
15
+ this.cmd = cmd;
16
+ this.buildArgs = buildArgs;
17
+ this.env = env;
18
+ this.metadata = metadata;
19
+ this.volumes = volumes;
20
+ this.ports = ports;
21
+ this.extraHosts = extraHosts;
22
+ this.services = services;
23
+ }
24
+ unsetBuildArg(name, service) {
25
+ if (service) {
26
+ if (!this.services[service]) {
27
+ return;
28
+ }
29
+ if (this.services[service].buildArgs && name in this.services[service].buildArgs) {
30
+ delete this.services[service].buildArgs[name];
31
+ }
32
+ return;
33
+ }
34
+ if (name in this.buildArgs) {
35
+ delete this.buildArgs[name];
36
+ }
37
+ }
38
+ getEnv(key, byDefault) {
39
+ if (key in this.env) {
40
+ return this.env[key];
41
+ }
42
+ return byDefault;
43
+ }
44
+ hasEnv(key) {
45
+ return this.env.hasOwnProperty(key);
46
+ }
47
+ setEnv(key, value, service) {
48
+ const sValue = typeof value === "boolean"
49
+ ? (value ? "true" : "false")
50
+ : value;
51
+ if (service) {
52
+ if (!this.services[service]) {
53
+ return;
54
+ }
55
+ if (!this.services[service].env) {
56
+ this.services[service].env = {};
57
+ }
58
+ this.services[service].env[key] = sValue;
59
+ return;
60
+ }
61
+ this.env[key] = sValue;
62
+ }
63
+ unsetEnv(key, service) {
64
+ if (service) {
65
+ if (!this.services[service]) {
66
+ throw new Error(`Service "${service}" not found`);
67
+ }
68
+ if (this.services[service].env && key in this.services[service].env) {
69
+ delete this.services[service].env[key];
70
+ if (Object.keys(this.services[service].env).length === 0) {
71
+ delete this.services[service].env;
72
+ }
73
+ }
74
+ return;
75
+ }
76
+ if (key in this.env) {
77
+ delete this.env[key];
78
+ }
79
+ }
80
+ getVolumeBySource(source) {
81
+ return (this.volumes || []).find((volume) => {
82
+ return (0, volumeParse_1.volumeParse)(volume).source === source;
83
+ });
84
+ }
85
+ getVolumeByDestination(destination) {
86
+ return (this.volumes || []).find((volume) => {
87
+ return (0, volumeParse_1.volumeParse)(volume).destination === destination;
88
+ });
89
+ }
90
+ volumeMount(...volumes) {
91
+ if (volumes.length === 0) {
92
+ return;
93
+ }
94
+ const [volume, ...restVolumes] = volumes;
95
+ const { destination } = (0, volumeParse_1.volumeParse)(volume);
96
+ this.volumes = [
97
+ ...(this.volumes || []).filter((v) => {
98
+ return v !== this.getVolumeByDestination(destination);
99
+ }),
100
+ volume
101
+ ];
102
+ this.volumeMount(...restVolumes);
103
+ }
104
+ volumeUnmount(...volumes) {
105
+ if (!this.volumes || volumes.length === 0) {
106
+ return;
107
+ }
108
+ const [volume, ...restVolumes] = volumes;
109
+ const v = (0, volumeParse_1.volumeParse)(volume);
110
+ this.volumes = this.volumes.filter((mounted) => {
111
+ const m = (0, volumeParse_1.volumeParse)(mounted);
112
+ return v.source !== m.source && v.destination !== m.destination;
113
+ });
114
+ if (this.volumes.length === 0) {
115
+ return;
116
+ }
117
+ this.volumeUnmount(...restVolumes);
118
+ }
119
+ addExtraHost(host, domain) {
120
+ this.extraHosts[host] = domain;
121
+ }
122
+ removeExtraHost(host) {
123
+ if (host in this.extraHosts) {
124
+ delete this.extraHosts[host];
125
+ }
126
+ }
127
+ toObject() {
128
+ return {
129
+ type: this.type,
130
+ image: this.image,
131
+ dockerfile: this.dockerfile,
132
+ composefile: this.composefile,
133
+ preset: this.preset,
134
+ presetMode: this.presetMode,
135
+ scripts: Object.keys(this.scripts).length > 0 ? this.scripts : undefined,
136
+ cmd: this.cmd,
137
+ buildArgs: Object.keys(this.buildArgs).length > 0 ? this.buildArgs : undefined,
138
+ env: Object.keys(this.env).length > 0 ? this.env : undefined,
139
+ metadata: Object.keys(this.metadata).length > 0 ? this.metadata : undefined,
140
+ volumes: this.volumes.length > 0 ? this.volumes : undefined,
141
+ ports: this.ports.length > 0 ? this.ports : undefined,
142
+ };
143
+ }
144
+ static make(fs, filename) {
145
+ let data = {};
146
+ if (fs.exists(filename)) {
147
+ data = fs.readJSON(filename);
148
+ }
149
+ return new class extends ProjectConfig {
150
+ constructor(data) {
151
+ super(data);
152
+ }
153
+ save() {
154
+ if (!fs.exists()) {
155
+ fs.mkdir("", {
156
+ recursive: true
157
+ });
158
+ }
159
+ fs.writeJSON(filename, this.toObject());
160
+ }
161
+ }(data);
162
+ }
163
+ }
164
+ exports.ProjectConfig = ProjectConfig;
@@ -0,0 +1,2 @@
1
+ export declare class ServiceConfig {
2
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServiceConfig = void 0;
4
+ class ServiceConfig {
5
+ }
6
+ exports.ServiceConfig = ServiceConfig;
@@ -1,9 +1,18 @@
1
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;
2
+ import { ProjectConfig } from "../makes/ProjectConfig";
3
+ import { AppFileSystemService, AppService } from "../../../services";
4
+ import { FileSystemDriver } from "../../../types";
5
+ import { ProjectConfigScope } from "../types";
6
+ export declare class ProjectRepository {
7
+ protected readonly appService: AppService;
8
+ protected readonly fs: AppFileSystemService;
9
+ protected readonly driver: FileSystemDriver;
10
+ constructor(appService: AppService, fs: AppFileSystemService, driver: FileSystemDriver);
11
+ getConfig(name: string, scope: ProjectConfigScope): ProjectConfig;
12
+ getByName(name: string): Project;
13
+ save(project: Project): void;
14
+ search(params: ProjectRepository.SearchParams): Project[];
15
+ searchOne(params: ProjectRepository.SearchParams): Project | null;
7
16
  }
8
17
  export declare namespace ProjectRepository {
9
18
  type SearchParams = Partial<{
@@ -5,12 +5,72 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
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
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
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
+ };
8
14
  Object.defineProperty(exports, "__esModule", { value: true });
9
15
  exports.ProjectRepository = void 0;
10
16
  const decorators_1 = require("../../../decorators");
17
+ const Project_1 = require("../makes/Project");
18
+ const ProjectConfig_1 = require("../makes/ProjectConfig");
19
+ const FileSystem_1 = require("../../../makes/FileSystem");
20
+ const services_1 = require("../../../services");
21
+ const env_1 = require("../../../env");
22
+ const types_1 = require("../types");
11
23
  let ProjectRepository = class ProjectRepository {
24
+ constructor(appService, fs, driver) {
25
+ this.appService = appService;
26
+ this.fs = fs;
27
+ this.driver = driver;
28
+ }
29
+ getConfig(name, scope) {
30
+ const ref = this.appService.getProject(name);
31
+ if (!ref) {
32
+ throw new Error("");
33
+ }
34
+ switch (scope) {
35
+ case types_1.ProjectConfigScope.APP:
36
+ return ProjectConfig_1.ProjectConfig.make(this.fs.cd(`projects/${ref.name}`), "config.json");
37
+ case types_1.ProjectConfigScopeEnum.LOCAL:
38
+ return ProjectConfig_1.ProjectConfig.make(new FileSystem_1.FileSystem(ref.path, this.driver), "wocker.config.json");
39
+ }
40
+ }
41
+ getByName(name) {
42
+ const ref = this.appService.getProject(name);
43
+ if (!ref) {
44
+ throw new Error(`Project "${name}" not found`);
45
+ }
46
+ return new Project_1.Project(ref.name, ref.path);
47
+ }
48
+ save(project) {
49
+ project.save();
50
+ }
51
+ search(params) {
52
+ const { name, path } = params, projects = [];
53
+ for (const ref of this.appService.projects) {
54
+ if (name && ref.name !== name) {
55
+ continue;
56
+ }
57
+ if (path && ref.path !== path) {
58
+ continue;
59
+ }
60
+ const project = this.getByName(ref.name);
61
+ projects.push(project);
62
+ }
63
+ return projects;
64
+ }
65
+ searchOne(params) {
66
+ const [project] = this.search(params);
67
+ return project || null;
68
+ }
12
69
  };
13
70
  exports.ProjectRepository = ProjectRepository;
14
71
  exports.ProjectRepository = ProjectRepository = __decorate([
15
- (0, decorators_1.Injectable)("PROJECT_REPOSITORY")
72
+ (0, decorators_1.Injectable)("PROJECT_REPOSITORY"),
73
+ __param(2, (0, decorators_1.Inject)(env_1.FILE_SYSTEM_DRIVER_KEY)),
74
+ __metadata("design:paramtypes", [services_1.AppService,
75
+ services_1.AppFileSystemService, Object])
16
76
  ], ProjectRepository);
@@ -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
+ });
@@ -1,2 +1,3 @@
1
+ export * from "./ProjectConfigScope";
1
2
  export * from "./ProjectV1";
2
3
  export * from "./ServiceProperties";
@@ -14,5 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ProjectConfigScope"), exports);
17
18
  __exportStar(require("./ProjectV1"), exports);
18
19
  __exportStar(require("./ServiceProperties"), exports);
@@ -23,7 +23,7 @@ let AppFileSystemService = class AppFileSystemService extends FileSystem_1.FileS
23
23
  };
24
24
  exports.AppFileSystemService = AppFileSystemService;
25
25
  exports.AppFileSystemService = AppFileSystemService = __decorate([
26
- (0, decorators_1.Injectable)(),
26
+ (0, decorators_1.Injectable)("APP_FILE_SYSTEM_SERVICE"),
27
27
  __param(0, (0, decorators_1.Inject)(env_1.WOCKER_DATA_DIR_KEY)),
28
28
  __param(1, (0, decorators_1.Inject)(env_1.FILE_SYSTEM_DRIVER_KEY)),
29
29
  __metadata("design:paramtypes", [String, Object])
@@ -1,17 +1,19 @@
1
1
  import { AppConfig } from "../makes/AppConfig";
2
2
  import { AppFileSystemService } from "./AppFileSystemService";
3
3
  import { ProcessService } from "./ProcessService";
4
+ import { LogService } from "./LogService";
4
5
  import { ProjectRef, PluginRef, PresetRef, PresetSource } from "../types";
5
6
  type TypeMap = {
6
7
  [type: string]: string;
7
8
  };
8
9
  export declare class AppService {
9
10
  readonly version: string;
10
- protected readonly processService: ProcessService;
11
11
  readonly fs: AppFileSystemService;
12
+ protected readonly processService: ProcessService;
13
+ protected readonly logService: LogService;
12
14
  protected _config?: AppConfig;
13
15
  protected readonly mapTypes: TypeMap;
14
- constructor(version: string, processService: ProcessService, fs: AppFileSystemService);
16
+ constructor(version: string, fs: AppFileSystemService, processService: ProcessService, logService: LogService);
15
17
  get config(): AppConfig;
16
18
  get debug(): boolean;
17
19
  set debug(debug: boolean);
@@ -21,6 +23,7 @@ export declare class AppService {
21
23
  isVersionGT(version: string): boolean;
22
24
  isVersionGTE(version: string): boolean;
23
25
  getProjectTypes(): TypeMap;
26
+ getProject(name: string): ProjectRef | undefined;
24
27
  addProject(name: string, path: string): void;
25
28
  removeProject(name: string): void;
26
29
  addPlugin(name: string, env?: PluginRef["env"]): void;
@@ -18,13 +18,15 @@ const Version_1 = require("../makes/Version");
18
18
  const AppConfig_1 = require("../makes/AppConfig");
19
19
  const AppFileSystemService_1 = require("./AppFileSystemService");
20
20
  const ProcessService_1 = require("./ProcessService");
21
+ const LogService_1 = require("./LogService");
21
22
  const types_1 = require("../types");
22
23
  const env_1 = require("../env");
23
24
  let AppService = class AppService {
24
- constructor(version, processService, fs) {
25
+ constructor(version, fs, processService, logService) {
25
26
  this.version = version;
26
- this.processService = processService;
27
27
  this.fs = fs;
28
+ this.processService = processService;
29
+ this.logService = logService;
28
30
  this.mapTypes = {
29
31
  [types_1.ProjectType.IMAGE]: "Image",
30
32
  [types_1.ProjectType.PRESET]: "Preset",
@@ -64,6 +66,9 @@ let AppService = class AppService {
64
66
  }
65
67
  return this.mapTypes;
66
68
  }
69
+ getProject(name) {
70
+ return this.config.getProject(name);
71
+ }
67
72
  addProject(name, path) {
68
73
  this.config.addProject(name, path);
69
74
  this.config.save();
@@ -128,6 +133,7 @@ exports.AppService = AppService;
128
133
  exports.AppService = AppService = __decorate([
129
134
  (0, decorators_1.Injectable)("APP_SERVICE"),
130
135
  __param(0, (0, decorators_1.Inject)(env_1.WOCKER_VERSION_KEY)),
131
- __metadata("design:paramtypes", [String, ProcessService_1.ProcessService,
132
- AppFileSystemService_1.AppFileSystemService])
136
+ __metadata("design:paramtypes", [String, AppFileSystemService_1.AppFileSystemService,
137
+ ProcessService_1.ProcessService,
138
+ LogService_1.LogService])
133
139
  ], AppService);
@@ -1,11 +1,13 @@
1
- import { AppService } from "./AppService";
1
+ import { ProcessService } from "./ProcessService";
2
2
  import { AppFileSystemService } from "./AppFileSystemService";
3
+ import { LogLevel } from "../types";
3
4
  export declare class LogService {
4
- protected readonly appService: AppService;
5
+ protected readonly processService: ProcessService;
5
6
  protected readonly fs: AppFileSystemService;
6
- constructor(appService: AppService, fs: AppFileSystemService);
7
+ constructor(processService: ProcessService, fs: AppFileSystemService);
8
+ get logLevel(): LogLevel;
7
9
  protected get logName(): string;
8
- protected _log(type: string, ...data: any[]): void;
10
+ protected _log(type: LogLevel, ...data: any[]): void;
9
11
  debug(...data: any[]): void;
10
12
  log(...data: any[]): void;
11
13
  info(...data: any[]): void;
@@ -12,18 +12,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.LogService = void 0;
13
13
  const format_1 = require("date-fns/format");
14
14
  const decorators_1 = require("../decorators");
15
- const AppService_1 = require("./AppService");
15
+ const ProcessService_1 = require("./ProcessService");
16
16
  const AppFileSystemService_1 = require("./AppFileSystemService");
17
+ const types_1 = require("../types");
17
18
  let LogService = class LogService {
18
- constructor(appService, fs) {
19
- this.appService = appService;
19
+ constructor(processService, fs) {
20
+ this.processService = processService;
20
21
  this.fs = fs;
21
22
  }
23
+ get logLevel() {
24
+ const level = this.processService.getEnv("WS_LOG_LEVEL", types_1.LogLevel.WARNING);
25
+ if (types_1.LogLevel.values().includes(level)) {
26
+ return level;
27
+ }
28
+ return types_1.LogLevel.WARNING;
29
+ }
22
30
  get logName() {
23
31
  return "ws.log";
24
32
  }
25
33
  _log(type, ...data) {
26
- if (type === "debug" && !this.appService.debug) {
34
+ if (!types_1.LogLevel.isGTE(this.logLevel, type)) {
27
35
  return;
28
36
  }
29
37
  const time = (0, format_1.format)(new Date(), "yyyy-MM-dd HH:mm:ss");
@@ -36,19 +44,19 @@ let LogService = class LogService {
36
44
  this.fs.appendFile(this.logName, `[${time}] ${type}: ${logData}\n`);
37
45
  }
38
46
  debug(...data) {
39
- this._log("debug", ...data);
47
+ this._log(types_1.LogLevel.DEBUG, ...data);
40
48
  }
41
49
  log(...data) {
42
- this._log("log", ...data);
50
+ this._log(types_1.LogLevel.LOG, ...data);
43
51
  }
44
52
  info(...data) {
45
- this._log("info", ...data);
53
+ this._log(types_1.LogLevel.INFO, ...data);
46
54
  }
47
55
  warn(...data) {
48
- this._log("warn", ...data);
56
+ this._log(types_1.LogLevel.WARNING, ...data);
49
57
  }
50
58
  error(...data) {
51
- this._log("error", ...data);
59
+ this._log(types_1.LogLevel.ERROR, ...data);
52
60
  }
53
61
  clear() {
54
62
  this.fs.writeFile(this.logName, "");
@@ -57,6 +65,6 @@ let LogService = class LogService {
57
65
  exports.LogService = LogService;
58
66
  exports.LogService = LogService = __decorate([
59
67
  (0, decorators_1.Injectable)("LOG_SERVICE"),
60
- __metadata("design:paramtypes", [AppService_1.AppService,
68
+ __metadata("design:paramtypes", [ProcessService_1.ProcessService,
61
69
  AppFileSystemService_1.AppFileSystemService])
62
70
  ], LogService);
@@ -8,4 +8,7 @@ export declare class ProcessService {
8
8
  cd(path: string): void;
9
9
  chdir(path: string): void;
10
10
  write(chunk: string | Buffer): boolean;
11
+ getEnv(key: string): string | undefined;
12
+ getEnv(key: string, byDefault: string): string;
13
+ setEnv(key: string, value: string): void;
11
14
  }
@@ -14,16 +14,16 @@ const path_1 = __importDefault(require("path"));
14
14
  const decorators_1 = require("../decorators");
15
15
  let ProcessService = class ProcessService {
16
16
  get UID() {
17
- if (process.getuid) {
18
- return `${process.getuid()}`;
17
+ if (!process.getuid) {
18
+ return undefined;
19
19
  }
20
- return undefined;
20
+ return `${process.getuid()}`;
21
21
  }
22
22
  get GID() {
23
- if (process.getgid) {
24
- return `${process.getgid()}`;
23
+ if (!process.getgid) {
24
+ return undefined;
25
25
  }
26
- return undefined;
26
+ return `${process.getgid()}`;
27
27
  }
28
28
  get stdin() {
29
29
  return process.stdin;
@@ -46,6 +46,15 @@ let ProcessService = class ProcessService {
46
46
  write(chunk) {
47
47
  return this.stdout.write(chunk);
48
48
  }
49
+ getEnv(key, byDefault) {
50
+ if (key in process.env) {
51
+ return process.env[key];
52
+ }
53
+ return byDefault;
54
+ }
55
+ setEnv(key, value) {
56
+ process.env[key] = value;
57
+ }
49
58
  };
50
59
  exports.ProcessService = ProcessService;
51
60
  exports.ProcessService = ProcessService = __decorate([
@@ -0,0 +1 @@
1
+ export type ApplicationOptions = {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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
+ });
@@ -2,6 +2,7 @@ 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";
@@ -18,6 +18,7 @@ __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);