@wocker/ws 1.0.2 → 1.0.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 (100) hide show
  1. package/README.md +1 -1
  2. package/lib/App.d.ts +4 -3
  3. package/lib/App.js +98 -77
  4. package/lib/controllers/ImageController.d.ts +2 -2
  5. package/lib/controllers/ImageController.js +27 -27
  6. package/lib/controllers/PluginController.d.ts +2 -2
  7. package/lib/controllers/PluginController.js +78 -56
  8. package/lib/controllers/PresetController.d.ts +3 -1
  9. package/lib/controllers/PresetController.js +155 -136
  10. package/lib/controllers/ProjectController.d.ts +5 -5
  11. package/lib/controllers/ProjectController.js +653 -603
  12. package/lib/controllers/ProxyController.d.ts +4 -1
  13. package/lib/controllers/ProxyController.js +269 -245
  14. package/lib/controllers/index.js +19 -58
  15. package/lib/env.js +33 -15
  16. package/lib/index.d.ts +2 -0
  17. package/lib/index.js +30 -16
  18. package/lib/makes/Controller.js +4 -8
  19. package/lib/makes/DI.d.ts +7 -0
  20. package/lib/makes/DI.js +27 -0
  21. package/lib/makes/Docker.js +298 -382
  22. package/lib/makes/FS.js +328 -304
  23. package/lib/makes/LineConvertStream.js +37 -40
  24. package/lib/makes/Logger.d.ts +9 -1
  25. package/lib/makes/Logger.js +22 -11
  26. package/lib/makes/Model.js +8 -12
  27. package/lib/makes/MySQL.js +6 -27
  28. package/lib/makes/Plugin.d.ts +1 -1
  29. package/lib/makes/Plugin.js +55 -37
  30. package/lib/makes/Preset.d.ts +46 -0
  31. package/lib/makes/Preset.js +33 -0
  32. package/lib/makes/Project.d.ts +45 -0
  33. package/lib/makes/Project.js +127 -0
  34. package/lib/makes/Repository.js +18 -21
  35. package/lib/makes/index.d.ts +3 -0
  36. package/lib/makes/index.js +23 -69
  37. package/lib/plugins/ElasticSearchPlugin.d.ts +3 -1
  38. package/lib/plugins/ElasticSearchPlugin.js +66 -66
  39. package/lib/plugins/LocaltunnelPlugin.d.ts +2 -2
  40. package/lib/plugins/LocaltunnelPlugin.js +256 -257
  41. package/lib/plugins/MaildevPlugin.d.ts +2 -2
  42. package/lib/plugins/MaildevPlugin.js +45 -44
  43. package/lib/plugins/MongodbPlugin.d.ts +2 -2
  44. package/lib/plugins/MongodbPlugin.js +303 -248
  45. package/lib/plugins/NgrokPlugin.d.ts +2 -2
  46. package/lib/plugins/NgrokPlugin.js +221 -231
  47. package/lib/plugins/PageKitePlugin.d.ts +2 -2
  48. package/lib/plugins/PageKitePlugin.js +150 -149
  49. package/lib/plugins/PostgresPlugin.d.ts +1 -1
  50. package/lib/plugins/PostgresPlugin.js +115 -89
  51. package/lib/plugins/ProxmoxPlugin.d.ts +1 -1
  52. package/lib/plugins/ProxmoxPlugin.js +50 -38
  53. package/lib/plugins/RedisPlugin.d.ts +3 -1
  54. package/lib/plugins/RedisPlugin.js +73 -72
  55. package/lib/plugins/index.js +25 -103
  56. package/lib/services/AppConfigService.d.ts +3 -3
  57. package/lib/services/AppConfigService.js +162 -157
  58. package/lib/services/AppEventsService.js +26 -24
  59. package/lib/services/DockerService.d.ts +37 -2
  60. package/lib/services/DockerService.js +185 -205
  61. package/lib/services/LogService.d.ts +3 -2
  62. package/lib/services/LogService.js +33 -34
  63. package/lib/services/PluginService.d.ts +2 -1
  64. package/lib/services/PluginService.js +11 -14
  65. package/lib/services/PresetService.d.ts +8 -3
  66. package/lib/services/PresetService.js +60 -59
  67. package/lib/services/ProjectService.d.ts +11 -4
  68. package/lib/services/ProjectService.js +140 -129
  69. package/lib/services/index.js +21 -80
  70. package/lib/types/Config.d.ts +4 -3
  71. package/lib/types/Config.js +1 -4
  72. package/lib/types/EnvConfig.js +1 -4
  73. package/lib/types/index.js +16 -25
  74. package/lib/utils/buildOptions.js +5 -8
  75. package/lib/utils/demuxOutput.js +16 -20
  76. package/lib/utils/escapeRegExp.js +4 -7
  77. package/lib/utils/exec.js +38 -39
  78. package/lib/utils/fetch.js +46 -30
  79. package/lib/utils/followProgress.js +66 -77
  80. package/lib/utils/format-size-units.js +16 -16
  81. package/lib/utils/get-config.d.ts +1 -1
  82. package/lib/utils/get-config.js +13 -16
  83. package/lib/utils/get-cursor-position.js +22 -29
  84. package/lib/utils/image-build.js +35 -23
  85. package/lib/utils/index.js +32 -191
  86. package/lib/utils/injectVariables.js +10 -13
  87. package/lib/utils/parse-table.js +20 -23
  88. package/lib/utils/set-config.d.ts +1 -1
  89. package/lib/utils/set-config.js +12 -15
  90. package/lib/utils/spawn.js +17 -20
  91. package/lib/utils/tty.js +2 -6
  92. package/lib/utils/volumeFormat.js +5 -12
  93. package/lib/utils/volumeParse.js +10 -13
  94. package/package.json +13 -39
  95. package/presets/bun/Dockerfile +11 -0
  96. package/presets/bun/config.json +3 -0
  97. package/presets/node/Dockerfile +4 -2
  98. package/presets/php-apache/Dockerfile +3 -2
  99. package/.github/workflows/publish.yml +0 -31
  100. package/plugins/mariadb/admin/conf/config.user.inc.php +0 -9
@@ -1,28 +1,30 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.AppEventsService = void 0;
7
- var _core = require("@wocker/core");
8
- class AppEventsService extends _core.AppEventsService {
9
- handles = {};
10
- on(event, handle) {
11
- this.handles[event] = [...(this.handles[event] || []), handle];
12
- return () => {
13
- this.handles[event] = this.handles[event].filter(filterHandle => {
14
- return filterHandle !== handle;
15
- });
16
- };
17
- }
18
- off(event, handle) {
19
- //
20
- }
21
- async emit(event, ...args) {
22
- const handles = this.handles[event] || [];
23
- for (const i in handles) {
24
- await handles[i](...args);
4
+ const core_1 = require("@wocker/core");
5
+ class AppEventsService extends core_1.AppEventsService {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.handles = {};
9
+ }
10
+ on(event, handle) {
11
+ this.handles[event] = [
12
+ ...this.handles[event] || [],
13
+ handle
14
+ ];
15
+ return () => {
16
+ this.handles[event] = this.handles[event].filter((filterHandle) => {
17
+ return filterHandle !== handle;
18
+ });
19
+ };
20
+ }
21
+ off(event, handle) {
22
+ }
23
+ async emit(event, ...args) {
24
+ const handles = this.handles[event] || [];
25
+ for (const i in handles) {
26
+ await handles[i](...args);
27
+ }
25
28
  }
26
- }
27
29
  }
28
- exports.AppEventsService = AppEventsService;
30
+ exports.AppEventsService = AppEventsService;
@@ -1,7 +1,42 @@
1
1
  /// <reference types="node" />
2
- import { DI, DockerService as CoreDockerService, DockerServiceParams as Params } from "@wocker/core";
3
2
  import Docker, { Container } from "dockerode";
4
- declare class DockerService extends CoreDockerService {
3
+ import { DI } from "../makes";
4
+ declare namespace Params {
5
+ type CreateContainer = {
6
+ name: string;
7
+ image: string;
8
+ restart?: "always";
9
+ projectId?: string;
10
+ tty?: boolean;
11
+ ulimits?: {
12
+ [key: string]: {
13
+ hard?: number;
14
+ soft?: number;
15
+ };
16
+ };
17
+ links?: string[];
18
+ env?: {
19
+ [key: string]: string;
20
+ };
21
+ networkMode?: string;
22
+ extraHosts?: any;
23
+ volumes?: string[];
24
+ ports?: string[];
25
+ cmd?: string[];
26
+ };
27
+ type BuildImage = {
28
+ tag: string;
29
+ buildArgs?: {
30
+ [key: string]: string;
31
+ };
32
+ labels?: {
33
+ [key: string]: string;
34
+ };
35
+ context: string;
36
+ src: string;
37
+ };
38
+ }
39
+ declare class DockerService {
5
40
  protected docker: Docker;
6
41
  constructor(di: DI);
7
42
  createContainer(params: Params.CreateContainer): Promise<Container>;
@@ -1,220 +1,200 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.DockerService = void 0;
7
- var _core = require("@wocker/core");
8
- var _dockerode = _interopRequireDefault(require("dockerode"));
9
- var _makes = require("../makes");
10
- var _utils = require("../utils");
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- class DockerService extends _core.DockerService {
13
- constructor(di) {
14
- super();
15
- this.docker = new _dockerode.default({
16
- socketPath: "/var/run/docker.sock"
17
- });
18
- }
19
- async createContainer(params) {
20
- const {
21
- name,
22
- tty,
23
- image,
24
- projectId,
25
- restart,
26
- ulimits,
27
- extraHosts,
28
- networkMode,
29
- links = [],
30
- env = {},
31
- volumes = [],
32
- ports = [],
33
- cmd = []
34
- } = params;
35
- const network = this.docker.getNetwork("workspace");
36
- try {
37
- await network.inspect();
38
- } catch (err) {
39
- if (err.statusCode === 404) {
40
- await this.docker.createNetwork({
41
- Name: "workspace"
7
+ const dockerode_1 = __importDefault(require("dockerode"));
8
+ const utils_1 = require("../utils");
9
+ const makes_1 = require("../makes");
10
+ class DockerService {
11
+ constructor(di) {
12
+ this.docker = new dockerode_1.default({
13
+ socketPath: "/var/run/docker.sock"
42
14
  });
43
- }
44
15
  }
45
- await this.pullImage(image);
46
- return this.docker.createContainer({
47
- name,
48
- Image: image,
49
- Hostname: name,
50
- Labels: {
51
- ...(projectId ? {
52
- projectId
53
- } : {})
54
- },
55
- AttachStdin: true,
56
- AttachStdout: true,
57
- AttachStderr: true,
58
- OpenStdin: true,
59
- StdinOnce: false,
60
- Tty: tty,
61
- Cmd: cmd,
62
- Env: Object.keys(env).map(key => {
63
- const value = env[key];
64
- return `${key}=${value}`;
65
- }),
66
- ExposedPorts: ports.reduce((res, value) => {
67
- const [,, containerPort] = /(\d+):(\d+)/.exec(value) || [];
68
- if (containerPort) {
69
- res[`${containerPort}/tcp`] = {};
16
+ async createContainer(params) {
17
+ const { name, tty, image, projectId, restart, ulimits, extraHosts, networkMode, links = [], env = {}, volumes = [], ports = [], cmd = [] } = params;
18
+ const network = this.docker.getNetwork("workspace");
19
+ try {
20
+ await network.inspect();
70
21
  }
71
- return res;
72
- }, {}),
73
- HostConfig: {
74
- NetworkMode: networkMode,
75
- ExtraHosts: extraHosts,
76
- Ulimits: ulimits ? Object.keys(ulimits).reduce((res, name) => {
77
- return [...res, {
78
- Name: name,
79
- Hard: ulimits[name].hard,
80
- Soft: ulimits[name].soft
81
- }];
82
- }, []) : [],
83
- ...(restart ? {
84
- RestartPolicy: {
85
- Name: restart
86
- }
87
- } : {}),
88
- Binds: volumes,
89
- PortBindings: ports.reduce((res, value) => {
90
- const [, hostPort, containerPort] = /(\d+):(\d+)/.exec(value) || [];
91
- if (hostPort && containerPort) {
92
- res[`${containerPort}/tcp`] = [{
93
- HostPort: hostPort
94
- }];
95
- }
96
- return res;
97
- }, {})
98
- },
99
- NetworkingConfig: {
100
- EndpointsConfig: networkMode === "host" ? {} : {
101
- workspace: {
102
- Links: links
103
- }
22
+ catch (err) {
23
+ if (err.statusCode === 404) {
24
+ await this.docker.createNetwork({
25
+ Name: "workspace"
26
+ });
27
+ }
104
28
  }
105
- }
106
- });
107
- }
108
- async getContainer(name) {
109
- const containers = await this.docker.listContainers({
110
- all: true,
111
- filters: {
112
- name: [name]
113
- }
114
- });
115
- const container = containers.find(container => {
116
- return container.Names.indexOf("/" + name) >= 0;
117
- });
118
- if (container) {
119
- return this.docker.getContainer(container.Id);
29
+ await this.pullImage(image);
30
+ return this.docker.createContainer({
31
+ name,
32
+ Image: image,
33
+ Hostname: name,
34
+ Labels: {
35
+ ...projectId ? { projectId } : {}
36
+ },
37
+ AttachStdin: true,
38
+ AttachStdout: true,
39
+ AttachStderr: true,
40
+ OpenStdin: true,
41
+ StdinOnce: false,
42
+ Tty: tty,
43
+ Cmd: cmd,
44
+ Env: Object.keys(env).map((key) => {
45
+ const value = env[key];
46
+ return `${key}=${value}`;
47
+ }),
48
+ ExposedPorts: ports.reduce((res, value) => {
49
+ const [, , containerPort] = /(\d+):(\d+)/.exec(value) || [];
50
+ if (containerPort) {
51
+ res[`${containerPort}/tcp`] = {};
52
+ }
53
+ return res;
54
+ }, {}),
55
+ HostConfig: {
56
+ NetworkMode: networkMode,
57
+ ExtraHosts: extraHosts,
58
+ Ulimits: ulimits ? Object.keys(ulimits).reduce((res, name) => {
59
+ return [
60
+ ...res,
61
+ {
62
+ Name: name,
63
+ Hard: ulimits[name].hard,
64
+ Soft: ulimits[name].soft
65
+ }
66
+ ];
67
+ }, []) : [],
68
+ ...restart ? {
69
+ RestartPolicy: {
70
+ Name: restart
71
+ }
72
+ } : {},
73
+ Binds: volumes,
74
+ PortBindings: ports.reduce((res, value) => {
75
+ const [, hostPort, containerPort] = /(\d+):(\d+)/.exec(value) || [];
76
+ if (hostPort && containerPort) {
77
+ res[`${containerPort}/tcp`] = [
78
+ { HostPort: hostPort }
79
+ ];
80
+ }
81
+ return res;
82
+ }, {}),
83
+ },
84
+ NetworkingConfig: {
85
+ EndpointsConfig: networkMode === "host" ? {} : {
86
+ workspace: {
87
+ Links: links
88
+ }
89
+ }
90
+ }
91
+ });
120
92
  }
121
- return null;
122
- }
123
- async removeContainer(name) {
124
- const container = await this.getContainer(name);
125
- if (!container) {
126
- return;
93
+ async getContainer(name) {
94
+ const containers = await this.docker.listContainers({
95
+ all: true,
96
+ filters: {
97
+ name: [name]
98
+ }
99
+ });
100
+ const container = containers.find((container) => {
101
+ return container.Names.indexOf("/" + name) >= 0;
102
+ });
103
+ if (container) {
104
+ return this.docker.getContainer(container.Id);
105
+ }
106
+ return null;
127
107
  }
128
- const {
129
- State: {
130
- Status
131
- }
132
- } = await container.inspect();
133
- if (Status === "running" || Status === "restarting") {
134
- try {
135
- await container.stop();
136
- } catch (err) {
137
- _core.Logger.error("DockerService.removeContainer", err.message);
138
- }
108
+ async removeContainer(name) {
109
+ const container = await this.getContainer(name);
110
+ if (!container) {
111
+ return;
112
+ }
113
+ const { State: { Status } } = await container.inspect();
114
+ if (Status === "running" || Status === "restarting") {
115
+ try {
116
+ await container.stop();
117
+ }
118
+ catch (err) {
119
+ makes_1.Logger.error("DockerService.removeContainer", err.message);
120
+ }
121
+ }
122
+ try {
123
+ await container.remove();
124
+ }
125
+ catch (err) {
126
+ makes_1.Logger.error("DockerService.removeContainer: ", err.message);
127
+ }
139
128
  }
140
- try {
141
- await container.remove();
142
- } catch (err) {
143
- _core.Logger.error("DockerService.removeContainer: ", err.message);
129
+ async buildImage(params) {
130
+ const { tag, labels = {}, buildArgs = {}, context, src } = params;
131
+ const files = await makes_1.FS.readdirFiles(context, {
132
+ recursive: true
133
+ });
134
+ const stream = await this.docker.buildImage({
135
+ context,
136
+ src: files
137
+ }, {
138
+ t: tag,
139
+ labels,
140
+ buildargs: Object.keys(buildArgs).reduce((res, key) => {
141
+ res[key] = typeof buildArgs[key] !== "string"
142
+ ? buildArgs[key].toString()
143
+ : buildArgs[key];
144
+ return res;
145
+ }, {}),
146
+ dockerfile: src
147
+ });
148
+ await (0, utils_1.followProgress)(stream);
144
149
  }
145
- }
146
- async buildImage(params) {
147
- const {
148
- tag,
149
- labels = {},
150
- buildArgs = {},
151
- context,
152
- src
153
- } = params;
154
- const files = await _makes.FS.readdirFiles(context, {
155
- recursive: true
156
- });
157
- const stream = await this.docker.buildImage({
158
- context,
159
- src: files
160
- }, {
161
- t: tag,
162
- labels,
163
- buildargs: Object.keys(buildArgs).reduce((res, key) => {
164
- res[key] = typeof buildArgs[key] !== "string" ? buildArgs[key].toString() : buildArgs[key];
165
- return res;
166
- }, {}),
167
- dockerfile: src
168
- });
169
- await (0, _utils.followProgress)(stream);
170
- }
171
- async imageExists(tag) {
172
- const image = this.docker.getImage(tag);
173
- try {
174
- await image.inspect();
175
- return true;
176
- } catch (ignore) {
177
- return false;
150
+ async imageExists(tag) {
151
+ const image = this.docker.getImage(tag);
152
+ try {
153
+ await image.inspect();
154
+ return true;
155
+ }
156
+ catch (ignore) {
157
+ return false;
158
+ }
178
159
  }
179
- }
180
- async imageRm(tag) {
181
- const image = await this.docker.getImage(tag);
182
- if (!image) {
183
- return;
160
+ async imageRm(tag) {
161
+ const image = await this.docker.getImage(tag);
162
+ if (!image) {
163
+ return;
164
+ }
165
+ await image.remove();
184
166
  }
185
- await image.remove();
186
- }
187
- async pullImage(tag) {
188
- const exists = await this.imageExists(tag);
189
- if (exists) {
190
- return;
167
+ async pullImage(tag) {
168
+ const exists = await this.imageExists(tag);
169
+ if (exists) {
170
+ return;
171
+ }
172
+ const stream = await this.docker.pull(tag);
173
+ await (0, utils_1.followProgress)(stream);
191
174
  }
192
- const stream = await this.docker.pull(tag);
193
- await (0, _utils.followProgress)(stream);
194
- }
195
- async attachStream(stream) {
196
- process.stdin.resume();
197
- process.stdin.setEncoding("utf8");
198
- process.stdin.pipe(stream);
199
- if (process.stdin.isTTY) {
200
- process.stdin.setRawMode(true);
175
+ async attachStream(stream) {
176
+ process.stdin.resume();
177
+ process.stdin.setEncoding("utf8");
178
+ process.stdin.pipe(stream);
179
+ if (process.stdin.isTTY) {
180
+ process.stdin.setRawMode(true);
181
+ }
182
+ stream.setEncoding("utf8");
183
+ stream.pipe(process.stdout);
184
+ const end = () => {
185
+ process.stdin.pause();
186
+ process.stdin.unpipe(stream);
187
+ if (process.stdin.isTTY) {
188
+ process.stdin.setRawMode(false);
189
+ }
190
+ stream.unpipe(process.stdout);
191
+ };
192
+ await new Promise((resolve, reject) => {
193
+ stream.on("end", end);
194
+ stream.on("error", end);
195
+ stream.on("end", resolve);
196
+ stream.on("error", reject);
197
+ });
201
198
  }
202
- stream.setEncoding("utf8");
203
- stream.pipe(process.stdout);
204
- const end = () => {
205
- process.stdin.pause();
206
- process.stdin.unpipe(stream);
207
- if (process.stdin.isTTY) {
208
- process.stdin.setRawMode(false);
209
- }
210
- stream.unpipe(process.stdout);
211
- };
212
- await new Promise((resolve, reject) => {
213
- stream.on("end", end);
214
- stream.on("error", end);
215
- stream.on("end", resolve);
216
- stream.on("error", reject);
217
- });
218
- }
219
199
  }
220
- exports.DockerService = DockerService;
200
+ exports.DockerService = DockerService;
@@ -1,10 +1,11 @@
1
- import { DI, AppConfigService } from "@wocker/core";
1
+ import { DI } from "../makes";
2
+ import { AppConfigService } from "./AppConfigService";
2
3
  declare class LogService {
3
4
  protected appConfigService: AppConfigService;
4
5
  constructor(di: DI);
5
6
  log(...data: any[]): void;
6
7
  info(...data: any[]): void;
7
- warning(...data: any[]): void;
8
+ warn(...data: any[]): void;
8
9
  error(...data: any[]): void;
9
10
  protected _log(type: string, ...data: any[]): void;
10
11
  }
@@ -1,39 +1,38 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LogService = void 0;
7
- var _core = require("@wocker/core");
8
- var _format = _interopRequireDefault(require("date-fns/format"));
9
- var _makes = require("../makes");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
+ const format_1 = __importDefault(require("date-fns/format"));
8
+ const makes_1 = require("../makes");
9
+ const AppConfigService_1 = require("./AppConfigService");
11
10
  class LogService {
12
- constructor(di) {
13
- this.appConfigService = di.resolveService(_core.AppConfigService);
14
- }
15
- log(...data) {
16
- this._log("log", ...data);
17
- }
18
- info(...data) {
19
- this._log("info", ...data);
20
- }
21
- warning(...data) {
22
- this._log("warning", ...data);
23
- }
24
- error(...data) {
25
- this._log("error", ...data);
26
- }
27
- _log(type, ...data) {
28
- const time = (0, _format.default)(new Date(), "yyyy-MM-dd hh:mm:ss");
29
- const logPath = this.appConfigService.dataPath("ws.log");
30
- const logData = data.map(item => {
31
- return typeof item !== "string" ? JSON.stringify(item) : item;
32
- }).join(" ");
33
- if (!_makes.FS.existsSync(logPath)) {
34
- _makes.FS.writeFileSync(logPath, "");
11
+ constructor(di) {
12
+ this.appConfigService = di.resolveService(AppConfigService_1.AppConfigService);
13
+ }
14
+ log(...data) {
15
+ this._log("log", ...data);
16
+ }
17
+ info(...data) {
18
+ this._log("info", ...data);
19
+ }
20
+ warn(...data) {
21
+ this._log("warn", ...data);
22
+ }
23
+ error(...data) {
24
+ this._log("error", ...data);
25
+ }
26
+ _log(type, ...data) {
27
+ const time = (0, format_1.default)(new Date(), "yyyy-MM-dd hh:mm:ss");
28
+ const logPath = this.appConfigService.dataPath("ws.log");
29
+ const logData = data.map((item) => {
30
+ return typeof item !== "string" ? JSON.stringify(item) : item;
31
+ }).join(" ");
32
+ if (!makes_1.FS.existsSync(logPath)) {
33
+ makes_1.FS.writeFileSync(logPath, "");
34
+ }
35
+ makes_1.FS.appendFileSync(logPath, `[${time}] ${type}: ${logData}\n`);
35
36
  }
36
- _makes.FS.appendFileSync(logPath, `[${time}] ${type}: ${logData}\n`);
37
- }
38
37
  }
39
- exports.LogService = LogService;
38
+ exports.LogService = LogService;
@@ -1,4 +1,5 @@
1
- import { DI, Cli, Controller } from "@wocker/core";
1
+ import { Cli } from "@wocker/core";
2
+ import { DI, Controller } from "../makes";
2
3
  declare class PluginService {
3
4
  protected di: DI;
4
5
  protected cli: Cli;
@@ -1,18 +1,15 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.PluginService = void 0;
7
- var _core = require("@wocker/core");
4
+ const core_1 = require("@wocker/core");
8
5
  class PluginService {
9
- constructor(di) {
10
- this.di = di;
11
- this.cli = di.resolveService(_core.Cli);
12
- }
13
- use(Constructor) {
14
- const controller = new Constructor(this.di);
15
- controller.install(this.cli);
16
- }
6
+ constructor(di) {
7
+ this.di = di;
8
+ this.cli = di.resolveService(core_1.Cli);
9
+ }
10
+ use(Constructor) {
11
+ const controller = new Constructor(this.di);
12
+ controller.install(this.cli);
13
+ }
17
14
  }
18
- exports.PluginService = PluginService;
15
+ exports.PluginService = PluginService;
@@ -1,9 +1,14 @@
1
- import { DI, PresetService as CorePresetService, PresetServiceSearchOptions as SearchOptions, Preset, EnvConfig } from "@wocker/core";
2
- declare class PresetService extends CorePresetService {
1
+ import { EnvConfig } from "../types";
2
+ import { DI, Preset } from "../makes";
3
+ type SearchOptions = Partial<{
4
+ name: string;
5
+ }>;
6
+ declare class PresetService {
3
7
  constructor(di: DI);
4
8
  getImageName(preset: Preset, buildArgs?: EnvConfig): string;
5
9
  save(preset: Preset): Promise<void>;
6
10
  get(name: string): Promise<Preset>;
7
11
  search(options?: SearchOptions): Promise<Preset[]>;
12
+ searchOne(options?: SearchOptions): Promise<Preset | null>;
8
13
  }
9
- export { PresetService };
14
+ export { PresetService, SearchOptions as PresetServiceSearchOptions };