@wocker/ws 1.0.9 → 1.0.11

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.
@@ -1,7 +1,8 @@
1
- import { AppConfigService } from "../services";
1
+ import { AppConfigService, LogService } from "../services";
2
2
  export declare class DebugController {
3
3
  protected readonly appConfigService: AppConfigService;
4
- constructor(appConfigService: AppConfigService);
4
+ protected readonly logService: LogService;
5
+ constructor(appConfigService: AppConfigService, logService: LogService);
5
6
  debug(status: string): Promise<void>;
6
7
  debugCompletion(): Promise<string[]>;
7
8
  }
@@ -13,8 +13,9 @@ exports.DebugController = void 0;
13
13
  const core_1 = require("@wocker/core");
14
14
  const services_1 = require("../services");
15
15
  let DebugController = class DebugController {
16
- constructor(appConfigService) {
16
+ constructor(appConfigService, logService) {
17
17
  this.appConfigService = appConfigService;
18
+ this.logService = logService;
18
19
  }
19
20
  async debug(status) {
20
21
  const config = await this.appConfigService.getConfig();
@@ -40,5 +41,6 @@ __decorate([
40
41
  ], DebugController.prototype, "debugCompletion", null);
41
42
  exports.DebugController = DebugController = __decorate([
42
43
  (0, core_1.Controller)(),
43
- __metadata("design:paramtypes", [services_1.AppConfigService])
44
+ __metadata("design:paramtypes", [services_1.AppConfigService,
45
+ services_1.LogService])
44
46
  ], DebugController);
@@ -29,7 +29,7 @@ let ImageController = class ImageController {
29
29
  for (const image of images) {
30
30
  table.push([image.Id]);
31
31
  }
32
- return table.toString() + "\n";
32
+ return table.toString();
33
33
  }
34
34
  };
35
35
  exports.ImageController = ImageController;
@@ -11,6 +11,7 @@ export declare class PresetController {
11
11
  protected onInit(project: Project): Promise<void>;
12
12
  protected onRebuild(project: Project): Promise<void>;
13
13
  protected onBeforeStart(project: Project): Promise<void>;
14
+ add(preset: string): Promise<void>;
14
15
  eject(name?: string): Promise<void>;
15
16
  build(rebuild: boolean, presetName: string): Promise<void>;
16
17
  }
@@ -42,7 +42,6 @@ const utils_2 = require("@wocker/utils");
42
42
  const Path = __importStar(require("path"));
43
43
  const env_1 = require("../env");
44
44
  const utils_3 = require("../utils");
45
- const makes_1 = require("../makes");
46
45
  const services_1 = require("../services");
47
46
  let PresetController = class PresetController {
48
47
  constructor(appConfigService, appEventsService, projectService, presetService, dockerService) {
@@ -123,7 +122,7 @@ let PresetController = class PresetController {
123
122
  if (!preset) {
124
123
  throw new Error(`Preset ${project.preset} not found`);
125
124
  }
126
- const imageName = preset.getImageName(project.buildArgs || {});
125
+ const imageName = this.presetService.getImageName(preset, project.buildArgs || {});
127
126
  const exists = await this.dockerService.imageExists(imageName);
128
127
  if (exists) {
129
128
  console.info(`Removing image: ${imageName}`);
@@ -136,7 +135,7 @@ let PresetController = class PresetController {
136
135
  }
137
136
  const preset = await this.presetService.get(project.preset);
138
137
  if (preset.dockerfile) {
139
- project.imageName = preset.getImageName(project.buildArgs);
138
+ project.imageName = this.presetService.getImageName(preset, project.buildArgs);
140
139
  if (!await this.dockerService.imageExists(project.imageName)) {
141
140
  await this.dockerService.buildImage({
142
141
  tag: project.imageName,
@@ -150,6 +149,8 @@ let PresetController = class PresetController {
150
149
  }
151
150
  }
152
151
  }
152
+ async add(preset) {
153
+ }
153
154
  async eject(name) {
154
155
  if (name) {
155
156
  await this.projectService.cdProject(name);
@@ -166,37 +167,34 @@ let PresetController = class PresetController {
166
167
  if (!confirm) {
167
168
  return;
168
169
  }
169
- const source = new makes_1.FS(this.appConfigService.presetPath(preset.name));
170
- const destination = new makes_1.FS(this.appConfigService.getPWD());
171
- const fs = new core_1.FSManager(this.appConfigService.presetPath(preset.name), this.appConfigService.getPWD());
170
+ const copier = new core_1.FSManager(this.appConfigService.presetPath(preset.name), this.appConfigService.getPWD());
172
171
  if (preset.dockerfile) {
173
- if (!destination.exists(preset.dockerfile)) {
174
- await fs.copy(preset.dockerfile);
172
+ if (!copier.destination.exists(preset.dockerfile)) {
173
+ await copier.copy(preset.dockerfile);
175
174
  }
176
175
  project.type = "dockerfile";
177
176
  project.dockerfile = preset.dockerfile;
178
177
  }
179
- const files = await source.readdirFiles("", {
178
+ const files = await copier.source.readdirFiles("", {
180
179
  recursive: true
181
180
  });
182
181
  for (const path of files) {
183
- const stat = source.stat(path);
182
+ const stat = copier.source.stat(path), dir = Path.dirname(path);
184
183
  if (stat.isFile() && path === "config.json") {
185
184
  continue;
186
185
  }
187
186
  if (stat.isFile() && path === preset.dockerfile) {
188
187
  continue;
189
188
  }
190
- if (destination.exists(path)) {
189
+ if (copier.destination.exists(path)) {
191
190
  continue;
192
191
  }
193
- const dir = Path.dirname(path);
194
- if (!destination.exists(dir)) {
195
- destination.mkdir(dir, {
192
+ if (!copier.destination.exists(dir)) {
193
+ copier.destination.mkdir(dir, {
196
194
  recursive: true
197
195
  });
198
196
  }
199
- await fs.copy(path);
197
+ await copier.copy(path);
200
198
  }
201
199
  delete project.preset;
202
200
  delete project.imageName;
@@ -208,7 +206,7 @@ let PresetController = class PresetController {
208
206
  if (preset.buildArgsOptions) {
209
207
  buildArgs = await (0, utils_1.promptGroup)(preset.buildArgsOptions);
210
208
  }
211
- const imageName = preset.getImageName(buildArgs);
209
+ const imageName = this.presetService.getImageName(preset, buildArgs);
212
210
  await this.dockerService.buildImage({
213
211
  tag: imageName,
214
212
  labels: {
@@ -221,6 +219,12 @@ let PresetController = class PresetController {
221
219
  }
222
220
  };
223
221
  exports.PresetController = PresetController;
222
+ __decorate([
223
+ (0, core_1.Command)("preset:add <preset>"),
224
+ __metadata("design:type", Function),
225
+ __metadata("design:paramtypes", [String]),
226
+ __metadata("design:returntype", Promise)
227
+ ], PresetController.prototype, "add", null);
224
228
  __decorate([
225
229
  (0, core_1.Command)("preset:eject"),
226
230
  __param(0, (0, core_1.Option)("name", {
@@ -7,6 +7,7 @@ export declare class ProjectController {
7
7
  protected readonly logService: LogService;
8
8
  constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService, logService: LogService);
9
9
  protected getProjectNames(): Promise<string[]>;
10
+ getScriptNames(): Promise<string[]>;
10
11
  init(name: string, type: string, preset: string): Promise<void>;
11
12
  projectList(all: boolean): Promise<string>;
12
13
  start(name?: string, detach?: boolean, rebuild?: boolean, restart?: boolean): Promise<void>;
@@ -62,6 +62,15 @@ let ProjectController = class ProjectController {
62
62
  return project.name;
63
63
  });
64
64
  }
65
+ async getScriptNames() {
66
+ try {
67
+ const project = await this.projectService.get();
68
+ return Object.keys(project.scripts);
69
+ }
70
+ catch (err) {
71
+ return [];
72
+ }
73
+ }
65
74
  async init(name, type, preset) {
66
75
  let project = await this.projectService.searchOne({
67
76
  path: this.appConfigService.getPWD()
@@ -144,7 +153,7 @@ let ProjectController = class ProjectController {
144
153
  const { State: { Status = "stopped" } = {} } = await container.inspect();
145
154
  table.push([project.name, project.type, Status]);
146
155
  }
147
- return table.toString() + "\n";
156
+ return table.toString();
148
157
  }
149
158
  async start(name, detach, rebuild, restart) {
150
159
  if (name) {
@@ -203,8 +212,8 @@ let ProjectController = class ProjectController {
203
212
  if (name) {
204
213
  await this.projectService.cdProject(name);
205
214
  }
206
- const containerName = `${name}.workspace`;
207
- await this.dockerService.attach(containerName);
215
+ const project = await this.projectService.get();
216
+ await this.dockerService.attach(project.containerName);
208
217
  }
209
218
  async configList(name, global) {
210
219
  if (name) {
@@ -225,7 +234,7 @@ let ProjectController = class ProjectController {
225
234
  for (const i in env) {
226
235
  table.push([i, env[i]]);
227
236
  }
228
- return table.toString() + "\n";
237
+ return table.toString();
229
238
  }
230
239
  async configGet(name, global, keys) {
231
240
  if (name) {
@@ -244,7 +253,7 @@ let ProjectController = class ProjectController {
244
253
  }
245
254
  table.push([key, value]);
246
255
  }
247
- return table.toString() + "\n";
256
+ return table.toString();
248
257
  }
249
258
  async configSet(name, global, variables) {
250
259
  if (!global && name) {
@@ -262,6 +271,13 @@ let ProjectController = class ProjectController {
262
271
  config.setEnv(key.trim(), value.trim());
263
272
  }
264
273
  await config.save();
274
+ if (!global) {
275
+ const project = await this.projectService.get();
276
+ const container = await this.dockerService.getContainer(project.containerName);
277
+ if (container) {
278
+ await this.projectService.start(true);
279
+ }
280
+ }
265
281
  }
266
282
  async configUnset(name, global, configs) {
267
283
  const env = configs.reduce((env, config) => {
@@ -280,6 +296,13 @@ let ProjectController = class ProjectController {
280
296
  project.unsetEnv(i);
281
297
  }
282
298
  await project.save();
299
+ if (!global) {
300
+ const project = await this.projectService.get();
301
+ const container = await this.dockerService.getContainer(project.containerName);
302
+ if (container) {
303
+ await this.projectService.start(true);
304
+ }
305
+ }
283
306
  }
284
307
  async buildArgsList(name) {
285
308
  if (name) {
@@ -293,7 +316,7 @@ let ProjectController = class ProjectController {
293
316
  for (const i in buildArgs) {
294
317
  table.push([i, typeof buildArgs[i] === "string" ? buildArgs[i] : JSON.stringify(buildArgs[i])]);
295
318
  }
296
- return table.toString() + "\n";
319
+ return table.toString();
297
320
  }
298
321
  async buildArgsGet(name, args) {
299
322
  if (name) {
@@ -310,7 +333,7 @@ let ProjectController = class ProjectController {
310
333
  table.push([key, value]);
311
334
  }
312
335
  }
313
- return table.toString() + "\n";
336
+ return table.toString();
314
337
  }
315
338
  async buildArgsSet(name, args) {
316
339
  if (name) {
@@ -362,7 +385,7 @@ let ProjectController = class ProjectController {
362
385
  for (const volume of volumes) {
363
386
  table.push([volume]);
364
387
  }
365
- return table.toString() + "\n";
388
+ return table.toString();
366
389
  }
367
390
  async volumeMount(name, volumes) {
368
391
  if (name) {
@@ -390,6 +413,10 @@ let ProjectController = class ProjectController {
390
413
  const prepareLog = (str) => {
391
414
  return str.replace(/^\[.*]\s([^:]+):\s.*$/gm, (substring, type) => {
392
415
  switch (type) {
416
+ case "debug":
417
+ return chalk_1.default.grey(substring);
418
+ case "log":
419
+ return chalk_1.default.white(substring);
393
420
  case "info":
394
421
  return chalk_1.default.green(substring);
395
422
  case "warn":
@@ -471,6 +498,12 @@ __decorate([
471
498
  __metadata("design:paramtypes", []),
472
499
  __metadata("design:returntype", Promise)
473
500
  ], ProjectController.prototype, "getProjectNames", null);
501
+ __decorate([
502
+ (0, core_1.Completion)("script"),
503
+ __metadata("design:type", Function),
504
+ __metadata("design:paramtypes", []),
505
+ __metadata("design:returntype", Promise)
506
+ ], ProjectController.prototype, "getScriptNames", null);
474
507
  __decorate([
475
508
  (0, core_1.Command)("init"),
476
509
  __param(0, (0, core_1.Option)("name", {
@@ -505,22 +538,27 @@ __decorate([
505
538
  ], ProjectController.prototype, "projectList", null);
506
539
  __decorate([
507
540
  (0, core_1.Command)("start"),
541
+ (0, core_1.Description)("Starting project"),
508
542
  __param(0, (0, core_1.Option)("name", {
509
543
  type: "string",
510
544
  alias: "n",
511
- description: "Project name"
545
+ description: "Project name",
546
+ help: true
512
547
  })),
513
548
  __param(1, (0, core_1.Option)("detach", {
514
549
  type: "boolean",
550
+ description: "Detach",
515
551
  alias: "d"
516
552
  })),
517
553
  __param(2, (0, core_1.Option)("build", {
518
554
  type: "boolean",
555
+ description: "Build",
519
556
  alias: "b"
520
557
  })),
521
558
  __param(3, (0, core_1.Option)("restart", {
522
559
  type: "boolean",
523
- alias: "r"
560
+ alias: "r",
561
+ description: "Restart"
524
562
  })),
525
563
  __metadata("design:type", Function),
526
564
  __metadata("design:paramtypes", [String, Boolean, Boolean, Boolean]),
@@ -583,6 +621,7 @@ __decorate([
583
621
  type: "boolean",
584
622
  alias: "g"
585
623
  })),
624
+ __param(2, (0, core_1.Param)("key")),
586
625
  __metadata("design:type", Function),
587
626
  __metadata("design:paramtypes", [String, Boolean, Array]),
588
627
  __metadata("design:returntype", Promise)
package/lib/main.js CHANGED
@@ -17,6 +17,7 @@ exports.app = {
17
17
  const res = await app.run(args);
18
18
  if (res) {
19
19
  process.stdout.write(res);
20
+ process.stdout.write("\n");
20
21
  }
21
22
  }
22
23
  catch (err) {
package/lib/makes/FS.d.ts CHANGED
@@ -2,28 +2,16 @@
2
2
  /// <reference types="node" />
3
3
  import { FS as CoreFS } from "@wocker/core";
4
4
  import * as fs from "fs";
5
- import { Stats, BigIntStats, PathLike, PathOrFileDescriptor, WriteFileOptions, ObjectEncodingOptions, MakeDirectoryOptions } from "fs";
5
+ import { Stats, BigIntStats, PathLike, PathOrFileDescriptor, WriteFileOptions, MakeDirectoryOptions } from "fs";
6
6
  import { PassThrough } from "readable-stream";
7
- type ReaddirOptions = ObjectEncodingOptions & {
8
- recursive?: boolean;
9
- };
10
7
  type ReaddirFilesOptions = {
11
8
  recursive?: boolean;
12
9
  };
13
10
  export declare class FS extends CoreFS {
14
- protected source: string;
15
- constructor(source: string);
16
- path(...parts: string[]): string;
17
- exists(...parts: string[]): boolean;
18
- stat(...parts: string[]): fs.Stats;
19
- mkdir(path: string, options?: MakeDirectoryOptions): void;
20
- readdir(...parts: string[]): Promise<string[]>;
21
- readdirFiles(path?: string, options?: ReaddirOptions): Promise<string[]>;
22
11
  static access(path: PathLike): Promise<any>;
23
12
  static existsSync(path: PathLike): boolean;
24
13
  static mkdir(dirPath: string, options?: MakeDirectoryOptions): Promise<void>;
25
14
  static mkdirSync(path: string, options?: MakeDirectoryOptions): string;
26
- static readdir(path: PathLike): Promise<string[]>;
27
15
  static readdirFiles(path: string, options?: ReaddirFilesOptions): Promise<string[]>;
28
16
  static appendFile(path: PathOrFileDescriptor, data: any, options?: WriteFileOptions): Promise<unknown>;
29
17
  static appendFileSync(path: PathOrFileDescriptor, data: any, options?: WriteFileOptions): void;
package/lib/makes/FS.js CHANGED
@@ -29,45 +29,6 @@ const fs = __importStar(require("fs"));
29
29
  const Path = __importStar(require("path"));
30
30
  const readable_stream_1 = require("readable-stream");
31
31
  class FS extends core_1.FS {
32
- constructor(source) {
33
- super();
34
- this.source = source;
35
- }
36
- path(...parts) {
37
- return Path.join(this.source, ...parts);
38
- }
39
- exists(...parts) {
40
- const fullPath = this.path(...parts);
41
- return FS.existsSync(fullPath);
42
- }
43
- stat(...parts) {
44
- const fullPath = this.path(...parts);
45
- return fs.statSync(fullPath);
46
- }
47
- mkdir(path, options) {
48
- const fullPath = this.path(path);
49
- fs.mkdirSync(fullPath, options);
50
- }
51
- async readdir(...parts) {
52
- const fullPath = this.path(...parts);
53
- return FS.readdir(fullPath);
54
- }
55
- async readdirFiles(path, options) {
56
- const fullPath = this.path(path);
57
- return new Promise((resolve, reject) => {
58
- fs.readdir(fullPath, options, (err, files) => {
59
- if (err) {
60
- reject(err);
61
- return;
62
- }
63
- files = files.filter((path) => {
64
- const stat = this.stat(path);
65
- return stat.isFile();
66
- });
67
- resolve(files);
68
- });
69
- });
70
- }
71
32
  static async access(path) {
72
33
  return new Promise((resolve, reject) => {
73
34
  fs.access(path, (err) => {
@@ -98,18 +59,6 @@ class FS extends core_1.FS {
98
59
  static mkdirSync(path, options) {
99
60
  return fs.mkdirSync(path, options);
100
61
  }
101
- static async readdir(path) {
102
- return new Promise((resolve, reject) => {
103
- fs.readdir(path, (err, files) => {
104
- if (!err) {
105
- resolve(files);
106
- }
107
- else {
108
- reject(err);
109
- }
110
- });
111
- });
112
- }
113
62
  static async readdirFiles(path, options) {
114
63
  const { recursive = false } = options || {};
115
64
  if (recursive) {
@@ -1,5 +1,4 @@
1
1
  import { FSManager } from "@wocker/core";
2
- import { Cli } from "@kearisp/cli";
3
2
  import { AppConfigService, DockerService } from "../services";
4
3
  type StartOptions = {
5
4
  restart?: boolean;
@@ -10,7 +9,6 @@ export declare class ElasticSearchPlugin {
10
9
  protected containerName: string;
11
10
  protected fs: FSManager;
12
11
  constructor(appConfigService: AppConfigService, dockerService: DockerService);
13
- install(cli: Cli): void;
14
12
  start(options: StartOptions): Promise<void>;
15
13
  stop(): Promise<void>;
16
14
  }
@@ -19,17 +19,6 @@ let ElasticSearchPlugin = class ElasticSearchPlugin {
19
19
  this.containerName = "elastic-search.workspace";
20
20
  this.fs = new core_1.FSManager(this.appConfigService.pluginsPath("elastic-search"), this.appConfigService.dataPath("plugins/elastic-search"));
21
21
  }
22
- install(cli) {
23
- cli.command("elastica:start")
24
- .option("restart", {
25
- type: "boolean",
26
- alias: "r",
27
- description: "Restart service"
28
- })
29
- .action((options) => this.start(options));
30
- cli.command("elastica:stop")
31
- .action(() => this.stop());
32
- }
33
22
  async start(options) {
34
23
  const { restart } = options;
35
24
  await this.dockerService.pullImage("docker.elastic.co/elasticsearch/elasticsearch:7.5.2");
@@ -1,5 +1,4 @@
1
1
  import { Project } from "@wocker/core";
2
- import { Cli } from "@kearisp/cli";
3
2
  import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
4
3
  type InitOptions = {
5
4
  name?: string;
@@ -21,7 +20,6 @@ export declare class LocaltunnelPlugin {
21
20
  protected readonly projectService: ProjectService;
22
21
  protected readonly dockerService: DockerService;
23
22
  constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService);
24
- install(cli: Cli): void;
25
23
  getIp(): Promise<string>;
26
24
  onProjectStart(project: Project): Promise<void>;
27
25
  onProjectStop(project: Project): Promise<void>;
@@ -25,64 +25,6 @@ let LocaltunnelPlugin = class LocaltunnelPlugin {
25
25
  this.projectService = projectService;
26
26
  this.dockerService = dockerService;
27
27
  }
28
- install(cli) {
29
- this.appEventsService.on("project:start", (project) => this.onProjectStart(project));
30
- this.appEventsService.on("project:stop", (project) => this.onProjectStop(project));
31
- cli.command("localtunnel:init")
32
- .option("name", {
33
- alias: "n",
34
- type: "string",
35
- description: "Project name"
36
- })
37
- .action((options) => this.init(options));
38
- cli.command("localtunnel:start")
39
- .option("name", {
40
- alias: "n",
41
- type: "string",
42
- description: "Project name"
43
- })
44
- .option("detach", {
45
- type: "boolean",
46
- alias: "d",
47
- description: "Detach"
48
- })
49
- .action((options) => this.start(options));
50
- cli.command("localtunnel:restart")
51
- .option("name", {
52
- alias: "n",
53
- type: "string",
54
- description: "Project name"
55
- })
56
- .option("detach", {
57
- type: "boolean",
58
- alias: "d",
59
- description: "Detach"
60
- })
61
- .action((options) => this.restart(options));
62
- cli.command("localtunnel:stop")
63
- .option("name", {
64
- alias: "n",
65
- type: "string",
66
- description: "Project name"
67
- })
68
- .action((options) => this.stop(options));
69
- cli.command("localtunnel:build")
70
- .action(() => this.build());
71
- cli.command("localtunnel:rebuild")
72
- .action(() => this.rebuild());
73
- cli.command("localtunnel:logs")
74
- .option("name", {
75
- alias: "n",
76
- type: "string",
77
- description: "Project name"
78
- })
79
- .option("detach", {
80
- type: "boolean",
81
- alias: "d",
82
- description: "Detach"
83
- })
84
- .action((options) => this.logs(options));
85
- }
86
28
  async getIp() {
87
29
  const res = await axios_1.default.get("https://ipv4.icanhazip.com");
88
30
  return res.data.replace("\n", "");
@@ -1,11 +1,9 @@
1
- import { Cli } from "@kearisp/cli";
2
1
  import { DockerService, AppConfigService } from "../services";
3
2
  export declare class MaildevPlugin {
4
3
  protected readonly appConfigService: AppConfigService;
5
4
  protected readonly dockerService: DockerService;
6
5
  protected containerName: string;
7
6
  constructor(appConfigService: AppConfigService, dockerService: DockerService);
8
- install(cli: Cli): void;
9
7
  start(): Promise<void>;
10
8
  stop(): Promise<void>;
11
9
  }
@@ -18,12 +18,6 @@ let MaildevPlugin = class MaildevPlugin {
18
18
  this.dockerService = dockerService;
19
19
  this.containerName = "maildev.workspace";
20
20
  }
21
- install(cli) {
22
- cli.command("maildev:start")
23
- .action(() => this.start());
24
- cli.command("maildev:stop")
25
- .action(() => this.stop());
26
- }
27
21
  async start() {
28
22
  console.log("Maildev starting...");
29
23
  const imageName = "ws-maildev";
@@ -1,4 +1,3 @@
1
- import { Cli } from "@kearisp/cli";
2
1
  import { DockerService } from "../services";
3
2
  export declare class MongodbPlugin {
4
3
  protected readonly dockerService: DockerService;
@@ -7,7 +6,6 @@ export declare class MongodbPlugin {
7
6
  protected dataDir: string;
8
7
  constructor(dockerService: DockerService);
9
8
  protected dataPath(...parts: string[]): string;
10
- install(cli: Cli): void;
11
9
  getDatabases(): Promise<string[]>;
12
10
  getDatabasesDumps(): Promise<string[]>;
13
11
  start(): Promise<void>;
@@ -50,63 +50,6 @@ let MongodbPlugin = class MongodbPlugin {
50
50
  dataPath(...parts) {
51
51
  return Path.join(this.dataDir, ...parts);
52
52
  }
53
- install(cli) {
54
- cli.command("mongodb:start").action(() => {
55
- return this.start();
56
- });
57
- cli.command("mongodb:stop").action(() => {
58
- return this.stop();
59
- });
60
- cli.command("mongodb:restart").action(() => {
61
- return this.restart();
62
- });
63
- cli.command("mongodb:backup [database]")
64
- .completion("database", () => {
65
- return this.getDatabases();
66
- })
67
- .action((options, database) => {
68
- return this.backup(database);
69
- });
70
- cli.command("mongodb:restore [database] [filename]")
71
- .completion("database", () => {
72
- const dumpPath = this.dataPath("dump");
73
- return makes_1.FS.readdir(dumpPath);
74
- })
75
- .completion("filename", (options, database) => {
76
- if (!database) {
77
- return [];
78
- }
79
- const dirPath = this.dataPath("dump", database);
80
- if (!makes_1.FS.existsSync(dirPath)) {
81
- return [];
82
- }
83
- return makes_1.FS.readdir(dirPath);
84
- })
85
- .action((options, database, filename) => {
86
- return this.restore(database, filename);
87
- });
88
- cli.command("mongodb:delete-backup [database] [filename]")
89
- .option("yes", {
90
- type: "boolean",
91
- alias: "y"
92
- })
93
- .completion("database", () => {
94
- return this.getDatabasesDumps();
95
- })
96
- .completion("filename", (options, database) => {
97
- if (!database) {
98
- return [];
99
- }
100
- const dumpPath = this.dataPath("dump", database);
101
- if (!makes_1.FS.existsSync(dumpPath)) {
102
- return [];
103
- }
104
- return makes_1.FS.readdirFiles(dumpPath);
105
- })
106
- .action((options, database, filename) => {
107
- return this.deleteBackup(database, filename, options.yes);
108
- });
109
- }
110
53
  async getDatabases() {
111
54
  const stream = await this.dockerService.exec(this.container, [
112
55
  "mongosh",
@@ -1,5 +1,4 @@
1
1
  import { Project } from "@wocker/core";
2
- import { Cli } from "@kearisp/cli";
3
2
  import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
4
3
  type InitOptions = {};
5
4
  type StartOptions = {
@@ -21,7 +20,6 @@ export declare class PageKitePlugin {
21
20
  protected readonly dockerService: DockerService;
22
21
  constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService);
23
22
  pluginPath(...parts: string[]): string;
24
- install(cli: Cli): void;
25
23
  onProjectStart(project: Project): Promise<void>;
26
24
  onProjectStop(project: Project): Promise<void>;
27
25
  init(options: InitOptions): Promise<void>;