@wocker/ws 1.0.10 → 1.0.12

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.
@@ -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
  }
@@ -122,7 +122,7 @@ let PresetController = class PresetController {
122
122
  if (!preset) {
123
123
  throw new Error(`Preset ${project.preset} not found`);
124
124
  }
125
- const imageName = preset.getImageName(project.buildArgs || {});
125
+ const imageName = this.presetService.getImageName(preset, project.buildArgs || {});
126
126
  const exists = await this.dockerService.imageExists(imageName);
127
127
  if (exists) {
128
128
  console.info(`Removing image: ${imageName}`);
@@ -135,7 +135,7 @@ let PresetController = class PresetController {
135
135
  }
136
136
  const preset = await this.presetService.get(project.preset);
137
137
  if (preset.dockerfile) {
138
- project.imageName = preset.getImageName(project.buildArgs);
138
+ project.imageName = this.presetService.getImageName(preset, project.buildArgs);
139
139
  if (!await this.dockerService.imageExists(project.imageName)) {
140
140
  await this.dockerService.buildImage({
141
141
  tag: project.imageName,
@@ -149,6 +149,8 @@ let PresetController = class PresetController {
149
149
  }
150
150
  }
151
151
  }
152
+ async add(preset) {
153
+ }
152
154
  async eject(name) {
153
155
  if (name) {
154
156
  await this.projectService.cdProject(name);
@@ -204,7 +206,7 @@ let PresetController = class PresetController {
204
206
  if (preset.buildArgsOptions) {
205
207
  buildArgs = await (0, utils_1.promptGroup)(preset.buildArgsOptions);
206
208
  }
207
- const imageName = preset.getImageName(buildArgs);
209
+ const imageName = this.presetService.getImageName(preset, buildArgs);
208
210
  await this.dockerService.buildImage({
209
211
  tag: imageName,
210
212
  labels: {
@@ -217,6 +219,12 @@ let PresetController = class PresetController {
217
219
  }
218
220
  };
219
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);
220
228
  __decorate([
221
229
  (0, core_1.Command)("preset:eject"),
222
230
  __param(0, (0, core_1.Option)("name", {
@@ -7,9 +7,10 @@ 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
- start(name?: string, detach?: boolean, rebuild?: boolean, restart?: boolean): Promise<void>;
13
+ start(name?: string, detach?: boolean, attach?: boolean, rebuild?: boolean, restart?: boolean): Promise<void>;
13
14
  stop(name: string): Promise<void>;
14
15
  run(name: string, script: string): Promise<void>;
15
16
  attach(name?: string): 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()
@@ -146,17 +155,19 @@ let ProjectController = class ProjectController {
146
155
  }
147
156
  return table.toString();
148
157
  }
149
- async start(name, detach, rebuild, restart) {
158
+ async start(name, detach, attach, rebuild, restart) {
150
159
  if (name) {
151
160
  await this.projectService.cdProject(name);
152
161
  }
153
162
  const project = await this.projectService.get();
154
163
  if (rebuild) {
155
- await this.projectService.stop();
156
- await this.appEventsService.emit("project:rebuild", project);
164
+ await this.projectService.rebuild(project);
157
165
  }
158
- await this.projectService.start(restart);
159
- if (!detach) {
166
+ await this.projectService.start(project, restart);
167
+ if (detach) {
168
+ console.info(chalk_1.default.yellow("Warning: Detach option is deprecated"));
169
+ }
170
+ if (attach) {
160
171
  const project = await this.projectService.get();
161
172
  const containerName = project.containerName;
162
173
  const container = await this.dockerService.getContainer(containerName);
@@ -171,7 +182,8 @@ let ProjectController = class ProjectController {
171
182
  if (name) {
172
183
  await this.projectService.cdProject(name);
173
184
  }
174
- await this.projectService.stop();
185
+ const project = await this.projectService.get();
186
+ await this.projectService.stop(project);
175
187
  }
176
188
  async run(name, script) {
177
189
  if (name) {
@@ -266,7 +278,7 @@ let ProjectController = class ProjectController {
266
278
  const project = await this.projectService.get();
267
279
  const container = await this.dockerService.getContainer(project.containerName);
268
280
  if (container) {
269
- await this.projectService.start(true);
281
+ await this.projectService.start(project, true);
270
282
  }
271
283
  }
272
284
  }
@@ -291,7 +303,7 @@ let ProjectController = class ProjectController {
291
303
  const project = await this.projectService.get();
292
304
  const container = await this.dockerService.getContainer(project.containerName);
293
305
  if (container) {
294
- await this.projectService.start(true);
306
+ await this.projectService.start(project, true);
295
307
  }
296
308
  }
297
309
  }
@@ -404,6 +416,10 @@ let ProjectController = class ProjectController {
404
416
  const prepareLog = (str) => {
405
417
  return str.replace(/^\[.*]\s([^:]+):\s.*$/gm, (substring, type) => {
406
418
  switch (type) {
419
+ case "debug":
420
+ return chalk_1.default.grey(substring);
421
+ case "log":
422
+ return chalk_1.default.white(substring);
407
423
  case "info":
408
424
  return chalk_1.default.green(substring);
409
425
  case "warn":
@@ -485,6 +501,12 @@ __decorate([
485
501
  __metadata("design:paramtypes", []),
486
502
  __metadata("design:returntype", Promise)
487
503
  ], ProjectController.prototype, "getProjectNames", null);
504
+ __decorate([
505
+ (0, core_1.Completion)("script"),
506
+ __metadata("design:type", Function),
507
+ __metadata("design:paramtypes", []),
508
+ __metadata("design:returntype", Promise)
509
+ ], ProjectController.prototype, "getScriptNames", null);
488
510
  __decorate([
489
511
  (0, core_1.Command)("init"),
490
512
  __param(0, (0, core_1.Option)("name", {
@@ -519,25 +541,35 @@ __decorate([
519
541
  ], ProjectController.prototype, "projectList", null);
520
542
  __decorate([
521
543
  (0, core_1.Command)("start"),
544
+ (0, core_1.Description)("Starting project"),
522
545
  __param(0, (0, core_1.Option)("name", {
523
546
  type: "string",
524
547
  alias: "n",
525
- description: "Project name"
548
+ description: "Project name",
549
+ help: true
526
550
  })),
527
551
  __param(1, (0, core_1.Option)("detach", {
528
552
  type: "boolean",
553
+ description: "Detach",
529
554
  alias: "d"
530
555
  })),
531
- __param(2, (0, core_1.Option)("build", {
556
+ __param(2, (0, core_1.Option)("attach", {
532
557
  type: "boolean",
558
+ description: "Attach",
559
+ alias: "a"
560
+ })),
561
+ __param(3, (0, core_1.Option)("build", {
562
+ type: "boolean",
563
+ description: "Build",
533
564
  alias: "b"
534
565
  })),
535
- __param(3, (0, core_1.Option)("restart", {
566
+ __param(4, (0, core_1.Option)("restart", {
536
567
  type: "boolean",
537
- alias: "r"
568
+ alias: "r",
569
+ description: "Restart"
538
570
  })),
539
571
  __metadata("design:type", Function),
540
- __metadata("design:paramtypes", [String, Boolean, Boolean, Boolean]),
572
+ __metadata("design:paramtypes", [String, Boolean, Boolean, Boolean, Boolean]),
541
573
  __metadata("design:returntype", Promise)
542
574
  ], ProjectController.prototype, "start", null);
543
575
  __decorate([
@@ -597,6 +629,7 @@ __decorate([
597
629
  type: "boolean",
598
630
  alias: "g"
599
631
  })),
632
+ __param(2, (0, core_1.Param)("key")),
600
633
  __metadata("design:type", Function),
601
634
  __metadata("design:paramtypes", [String, Boolean, Array]),
602
635
  __metadata("design:returntype", Promise)
@@ -143,8 +143,8 @@ let ProxyController = class ProxyController {
143
143
  await project.save();
144
144
  const container = await this.dockerService.getContainer(`${project.name}.workspace`);
145
145
  if (container) {
146
- await this.projectService.stop();
147
- await this.projectService.start();
146
+ await this.projectService.stop(project);
147
+ await this.projectService.start(project);
148
148
  }
149
149
  }
150
150
  async addDomain(name, addDomains) {
@@ -167,8 +167,8 @@ let ProxyController = class ProxyController {
167
167
  await project.save();
168
168
  const container = await this.dockerService.getContainer(`${project.name}.workspace`);
169
169
  if (container) {
170
- await this.projectService.stop();
171
- await this.projectService.start();
170
+ await this.projectService.stop(project);
171
+ await this.projectService.start(project);
172
172
  }
173
173
  }
174
174
  async removeDomain(name, removeDomains) {
@@ -194,8 +194,8 @@ let ProxyController = class ProxyController {
194
194
  await project.save();
195
195
  const container = await this.dockerService.getContainer(`${project.name}.workspace`);
196
196
  if (container) {
197
- await this.projectService.stop();
198
- await this.projectService.start();
197
+ await this.projectService.stop(project);
198
+ await this.projectService.start(project);
199
199
  }
200
200
  }
201
201
  async logs() {
package/lib/makes/FS.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { FS as CoreFS } from "@wocker/core";
4
2
  import * as fs from "fs";
5
3
  import { Stats, BigIntStats, PathLike, PathOrFileDescriptor, WriteFileOptions, MakeDirectoryOptions } from "fs";
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { Readable } from "stream";
4
2
  import { Mutex } from "async-mutex";
5
3
  declare class LineConvertStream extends Readable {
@@ -1,4 +1,3 @@
1
1
  export * from "./FS";
2
2
  export * from "./Http";
3
3
  export * from "./Logger";
4
- export * from "./Preset";
@@ -17,4 +17,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./FS"), exports);
18
18
  __exportStar(require("./Http"), exports);
19
19
  __exportStar(require("./Logger"), exports);
20
- __exportStar(require("./Preset"), exports);
@@ -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>;
@@ -23,38 +23,6 @@ let PageKitePlugin = class PageKitePlugin {
23
23
  pluginPath(...parts) {
24
24
  return this.appConfigService.pluginsPath("pagekite", ...parts);
25
25
  }
26
- install(cli) {
27
- this.appEventsService.on("project:start", (project) => this.onProjectStart(project));
28
- this.appEventsService.on("project:stop", (project) => this.onProjectStop(project));
29
- cli.command("pagekite:init")
30
- .action((options) => this.init(options));
31
- cli.command("pagekite:start")
32
- .option("name", {
33
- type: "string",
34
- alias: "n",
35
- description: "Project name"
36
- })
37
- .option("restart", {
38
- type: "boolean",
39
- alias: "r",
40
- description: "Restart"
41
- })
42
- .action((options) => this.start(options));
43
- cli.command("pagekite:stop")
44
- .option("name", {
45
- type: "string",
46
- alias: "n",
47
- description: "Project name"
48
- })
49
- .action((options) => this.stop(options));
50
- cli.command("pagekite:build")
51
- .option("rebuild", {
52
- type: "boolean",
53
- alias: "r",
54
- description: "Rebuild"
55
- })
56
- .action((options) => this.build(options));
57
- }
58
26
  async onProjectStart(project) {
59
27
  if (!project || project.getEnv("PAGEKITE_ENABLE", "false") !== "true") {
60
28
  return;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { DockerServiceParams as Params } from "@wocker/core";
4
2
  import Docker, { Container } from "dockerode";
5
3
  import { LogService } from "./LogService";
@@ -44,14 +44,14 @@ let PresetService = class PresetService {
44
44
  }
45
45
  async get(name) {
46
46
  const config = await makes_1.FS.readJSON(env_1.PRESETS_DIR, name, "config.json");
47
+ const _this = this;
47
48
  return new class extends core_1.Preset {
48
- constructor(presetService, data) {
49
+ constructor(data) {
49
50
  super(data);
50
- this.presetService = presetService;
51
51
  }
52
52
  async save() {
53
53
  }
54
- }(this, {
54
+ }({
55
55
  name,
56
56
  ...config
57
57
  });
@@ -64,11 +64,7 @@ let PresetService = class PresetService {
64
64
  if (name && name !== dir) {
65
65
  continue;
66
66
  }
67
- const config = await makes_1.FS.readJSON(env_1.PRESETS_DIR, dir, "config.json");
68
- const preset = new core_1.Preset({
69
- name: dir,
70
- ...config
71
- });
67
+ const preset = await this.get(dir);
72
68
  presets.push(preset);
73
69
  }
74
70
  return presets;
@@ -15,8 +15,9 @@ declare class ProjectService {
15
15
  cdProject(name: string): Promise<void>;
16
16
  get(): Promise<Project>;
17
17
  getContainer(): Promise<import("dockerode").Container>;
18
- start(restart?: boolean): Promise<void>;
19
- stop(): Promise<void>;
18
+ rebuild(project: Project): Promise<void>;
19
+ start(project: Project, restart?: boolean): Promise<void>;
20
+ stop(project: Project): Promise<void>;
20
21
  save(project: Project): Promise<void>;
21
22
  search(params?: Partial<SearchParams>): Promise<Project[]>;
22
23
  searchOne(params?: Partial<SearchParams>): Promise<Project | null>;
@@ -80,8 +80,20 @@ let ProjectService = class ProjectService {
80
80
  const project = await this.get();
81
81
  return this.dockerService.getContainer(project.containerName);
82
82
  }
83
- async start(restart) {
84
- const project = await this.get();
83
+ async rebuild(project) {
84
+ await this.stop(project);
85
+ if (project.type === "dockerfile") {
86
+ project.imageName = `project-${project.name}:develop`;
87
+ const images = await this.dockerService.imageLs({
88
+ tag: project.imageName
89
+ });
90
+ if (images.length > 0) {
91
+ await this.dockerService.imageRm(project.imageName);
92
+ }
93
+ }
94
+ await this.appEventsService.emit("project:rebuild", project);
95
+ }
96
+ async start(project, restart) {
85
97
  if (project.type === "dockerfile") {
86
98
  project.imageName = `project-${project.name}:develop`;
87
99
  const images = await this.dockerService.imageLs({
@@ -96,6 +108,7 @@ let ProjectService = class ProjectService {
96
108
  });
97
109
  }
98
110
  }
111
+ await this.appEventsService.emit("project:beforeStart", project);
99
112
  let container = await this.dockerService.getContainer(project.containerName);
100
113
  if (container && restart) {
101
114
  container = null;
@@ -120,14 +133,12 @@ let ProjectService = class ProjectService {
120
133
  });
121
134
  }
122
135
  const { State: { Status } } = await container.inspect();
123
- await this.appEventsService.emit("project:beforeStart", project);
124
136
  if (Status === "created" || Status === "exited") {
125
137
  await container.start();
126
138
  }
127
139
  await this.appEventsService.emit("project:start", project);
128
140
  }
129
- async stop() {
130
- const project = await this.get();
141
+ async stop(project) {
131
142
  const container = await this.dockerService.getContainer(project.containerName);
132
143
  if (!container) {
133
144
  return;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { ExecOptions } from "child_process";
3
2
  type Options = Omit<ExecOptions, "maxBuffer">;
4
3
  declare const exec: (command: string, options?: Options) => Promise<string>;
@@ -1,6 +1 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
- /// <reference types="node" />
6
1
  export declare const followProgress: (stream: NodeJS.ReadableStream) => Promise<unknown>;
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@wocker/ws",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "author": "Kris Papercut <krispcut@gmail.com>",
5
5
  "description": "Docker workspace for web projects",
6
6
  "license": "MIT",
7
+ "main": "lib/index.js",
8
+ "types": "lib/index.d.ts",
9
+ "bin": {
10
+ "ws": "./bin/ws.js"
11
+ },
7
12
  "homepage": "https://kearisp.github.io/wocker",
8
13
  "repository": {
9
14
  "type": "git",
@@ -12,11 +17,6 @@
12
17
  "bugs": {
13
18
  "url": "https://github.com/kearisp/wocker-ws/issues"
14
19
  },
15
- "main": "lib/index.js",
16
- "types": "lib/index.d.ts",
17
- "bin": {
18
- "ws": "./bin/ws.js"
19
- },
20
20
  "scripts": {
21
21
  "prepare": "npm run build",
22
22
  "start": "npm run watch",
@@ -25,8 +25,7 @@
25
25
  "lint": "eslint \"**/*.{js,jsx,ts,tsx}\""
26
26
  },
27
27
  "dependencies": {
28
- "@kearisp/cli": "^1.0.7",
29
- "@wocker/core": "^1.0.10",
28
+ "@wocker/core": "^1.0.11",
30
29
  "@wocker/utils": "^1.0.4",
31
30
  "async-mutex": "^0.4.0",
32
31
  "axios": "^1.6.7",
@@ -39,8 +38,7 @@
39
38
  "md5": "^2.3.0",
40
39
  "os": "^0.1.2",
41
40
  "path": "^0.12.7",
42
- "readable-stream": "^4.1.0",
43
- "reflect-metadata": "^0.2.1"
41
+ "readable-stream": "^4.1.0"
44
42
  },
45
43
  "devDependencies": {
46
44
  "@types/dockerode": "3.3.23",
@@ -56,6 +54,6 @@
56
54
  "eslint-plugin-import": "^2.28.1",
57
55
  "eslint-plugin-node": "^11.1.0",
58
56
  "eslint-webpack-plugin": "^3.1.0",
59
- "typescript": "^5.4.4"
57
+ "typescript": "^5.5.2"
60
58
  }
61
59
  }
@@ -1,45 +0,0 @@
1
- import { EnvConfig } from "@wocker/core";
2
- import { PresetService, PresetServiceSearchOptions as SearchOptions } from "../services/PresetService";
3
- type TextOption = {
4
- type: "string" | "number" | "int";
5
- message?: string;
6
- default?: string | number;
7
- };
8
- type ConfirmOption = {
9
- type: "boolean";
10
- message?: string;
11
- default?: boolean;
12
- };
13
- type SelectOption = {
14
- type: "select";
15
- options: string[] | {
16
- label?: string;
17
- value: string;
18
- }[] | {
19
- [name: string]: string;
20
- };
21
- message?: string;
22
- default?: string;
23
- };
24
- type AnyOption = TextOption | ConfirmOption | SelectOption;
25
- declare class Preset {
26
- id: string;
27
- name: string;
28
- version: string;
29
- dockerfile?: string;
30
- buildArgsOptions?: {
31
- [name: string]: AnyOption;
32
- };
33
- envOptions?: {
34
- [name: string]: AnyOption;
35
- };
36
- volumes?: string[];
37
- volumeOptions?: string[];
38
- constructor(data: any);
39
- save(): Promise<void>;
40
- getImageName(buildArgs?: EnvConfig): string;
41
- static install(ps: PresetService): void;
42
- static search(options: SearchOptions): Promise<import("@wocker/core").Preset[]>;
43
- static searchOne(options: SearchOptions): Promise<import("@wocker/core").Preset>;
44
- }
45
- export { Preset };
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Preset = void 0;
4
- let presetService;
5
- class Preset {
6
- constructor(data) {
7
- this.id = data.id;
8
- this.name = data.name;
9
- this.version = data.version;
10
- this.dockerfile = data.dockerfile;
11
- this.buildArgsOptions = data.buildArgsOptions;
12
- this.envOptions = data.envOptions;
13
- this.volumes = data.volumes;
14
- this.volumeOptions = data.volumeOptions;
15
- }
16
- async save() {
17
- if (!presetService) {
18
- throw new Error("Dependency is missing");
19
- }
20
- return presetService.save(this);
21
- }
22
- getImageName(buildArgs) {
23
- if (!presetService) {
24
- throw new Error("Dependency is missing");
25
- }
26
- return presetService.getImageName(this, buildArgs);
27
- }
28
- static install(ps) {
29
- presetService = ps;
30
- }
31
- static search(options) {
32
- if (!presetService) {
33
- throw new Error("Dependency is missing");
34
- }
35
- return presetService.search(options);
36
- }
37
- static searchOne(options) {
38
- if (!presetService) {
39
- throw new Error("Dependency is missing");
40
- }
41
- return presetService.searchOne(options);
42
- }
43
- }
44
- exports.Preset = Preset;