@wocker/ws 1.0.30 → 1.0.31-beta.0

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,15 +1,16 @@
1
- type Options = string | {
2
- ssl?: boolean;
3
- host?: string;
4
- port?: number;
5
- user?: string;
6
- password?: string;
7
- database?: string;
8
- };
9
1
  export declare class MySQL {
10
2
  protected connection: any;
11
- protected options: Options;
12
- constructor(options: Options);
3
+ protected options: MySQL.ConstructorOptions;
4
+ constructor(options: MySQL.ConstructorOptions);
13
5
  query(sql: string): Promise<void>;
14
6
  }
15
- export {};
7
+ export declare namespace MySQL {
8
+ type ConstructorOptions = string | {
9
+ ssl?: boolean;
10
+ host?: string;
11
+ port?: number;
12
+ user?: string;
13
+ password?: string;
14
+ database?: string;
15
+ };
16
+ }
@@ -2,8 +2,8 @@ import { KeystoreProvider } from "@wocker/core";
2
2
  import { Keytar } from "../types/Keytar";
3
3
  export declare class KeytarKeystoreProvider extends KeystoreProvider {
4
4
  protected _keytar?: any;
5
+ protected getKeytar(): Promise<Keytar>;
5
6
  get(key: string, defaultValue?: string): Promise<string | undefined>;
6
7
  set(key: string, value: string): Promise<void>;
7
8
  delete(key: string): Promise<void>;
8
- protected getKeytar(): Promise<Keytar>;
9
9
  }
@@ -43,6 +43,12 @@ exports.KeytarKeystoreProvider = void 0;
43
43
  const core_1 = require("@wocker/core");
44
44
  const env_1 = require("../../../env");
45
45
  let KeytarKeystoreProvider = class KeytarKeystoreProvider extends core_1.KeystoreProvider {
46
+ async getKeytar() {
47
+ if (!this._keytar) {
48
+ this._keytar = await Promise.resolve().then(() => __importStar(require("keytar")));
49
+ }
50
+ return this._keytar;
51
+ }
46
52
  async get(key, defaultValue) {
47
53
  const keytar = await this.getKeytar();
48
54
  const value = await keytar.getPassword(env_1.KEYTAR_SERVICE, key);
@@ -61,12 +67,6 @@ let KeytarKeystoreProvider = class KeytarKeystoreProvider extends core_1.Keystor
61
67
  const keytar = await this.getKeytar();
62
68
  await keytar.deletePassword(env_1.KEYTAR_SERVICE, key);
63
69
  }
64
- async getKeytar() {
65
- if (!this._keytar) {
66
- this._keytar = await Promise.resolve().then(() => __importStar(require("keytar")));
67
- }
68
- return this._keytar;
69
- }
70
70
  };
71
71
  exports.KeytarKeystoreProvider = KeytarKeystoreProvider;
72
72
  exports.KeytarKeystoreProvider = KeytarKeystoreProvider = __decorate([
@@ -1,12 +1,12 @@
1
- import { Project, AppConfigService, EventService } from "@wocker/core";
1
+ import { Project, AppConfigService } from "@wocker/core";
2
2
  import { ProjectService } from "../../project";
3
3
  import { ProxyService } from "../services/ProxyService";
4
4
  export declare class ProxyController {
5
5
  protected readonly appConfigService: AppConfigService;
6
- protected readonly eventService: EventService;
7
6
  protected readonly projectService: ProjectService;
8
7
  protected readonly proxyService: ProxyService;
9
- constructor(appConfigService: AppConfigService, eventService: EventService, projectService: ProjectService, proxyService: ProxyService);
8
+ constructor(appConfigService: AppConfigService, projectService: ProjectService, proxyService: ProxyService);
9
+ onProjectInit(project: Project): Promise<void>;
10
10
  onProjectStart(project: Project): Promise<void>;
11
11
  onProjectStop(_project: Project): Promise<void>;
12
12
  getProjectNames(): string[];
@@ -22,14 +22,13 @@ const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
22
22
  const project_1 = require("../../project");
23
23
  const ProxyService_1 = require("../services/ProxyService");
24
24
  let ProxyController = class ProxyController {
25
- constructor(appConfigService, eventService, projectService, proxyService) {
25
+ constructor(appConfigService, projectService, proxyService) {
26
26
  this.appConfigService = appConfigService;
27
- this.eventService = eventService;
28
27
  this.projectService = projectService;
29
28
  this.proxyService = proxyService;
30
- this.eventService.on("project:init", (project) => this.proxyService.init(project));
31
- this.eventService.on("project:start", (project) => this.onProjectStart(project));
32
- this.eventService.on("project:stop", (project) => this.onProjectStop(project));
29
+ }
30
+ async onProjectInit(project) {
31
+ return this.proxyService.init(project);
33
32
  }
34
33
  async onProjectStart(project) {
35
34
  if (project.domains.length === 0) {
@@ -110,6 +109,24 @@ let ProxyController = class ProxyController {
110
109
  }
111
110
  };
112
111
  exports.ProxyController = ProxyController;
112
+ __decorate([
113
+ (0, core_1.Event)("project:inti"),
114
+ __metadata("design:type", Function),
115
+ __metadata("design:paramtypes", [core_1.Project]),
116
+ __metadata("design:returntype", Promise)
117
+ ], ProxyController.prototype, "onProjectInit", null);
118
+ __decorate([
119
+ (0, core_1.Event)("project:start"),
120
+ __metadata("design:type", Function),
121
+ __metadata("design:paramtypes", [core_1.Project]),
122
+ __metadata("design:returntype", Promise)
123
+ ], ProxyController.prototype, "onProjectStart", null);
124
+ __decorate([
125
+ (0, core_1.Event)("project:stop"),
126
+ __metadata("design:type", Function),
127
+ __metadata("design:paramtypes", [core_1.Project]),
128
+ __metadata("design:returntype", Promise)
129
+ ], ProxyController.prototype, "onProjectStop", null);
113
130
  __decorate([
114
131
  (0, core_1.Completion)("name"),
115
132
  __metadata("design:type", Function),
@@ -174,7 +191,6 @@ exports.ProxyController = ProxyController = __decorate([
174
191
  (0, core_1.Controller)(),
175
192
  (0, core_1.Description)("Proxy commands"),
176
193
  __metadata("design:paramtypes", [core_1.AppConfigService,
177
- core_1.EventService,
178
194
  project_1.ProjectService,
179
195
  ProxyService_1.ProxyService])
180
196
  ], ProxyController);
@@ -91,6 +91,7 @@ let CertService = class CertService {
91
91
  user: "1000",
92
92
  cmd: ["wocker-create-cert", certName]
93
93
  });
94
+ await this.proxyService.start(true);
94
95
  }
95
96
  getCertsMap() {
96
97
  const files = this.fs.readdir("certs/projects");
@@ -149,8 +149,8 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
149
149
  await this.dockerService.imageRm(oldImage);
150
150
  }
151
151
  await this.dockerService.buildImage({
152
- version: this.appConfigService.isExperimentalEnabled("buildKit") ? "2" : "1",
153
152
  tag: this.imageName,
153
+ version: this.appConfigService.isExperimentalEnabled("buildKit") ? "2" : "1",
154
154
  buildArgs: {
155
155
  SSH_PASSWORD: this.appConfigService.getMeta("PROXY_SSH_PASSWORD")
156
156
  },
@@ -1,2 +1 @@
1
- declare const escapeRegExp: (string: string) => string;
2
- export { escapeRegExp };
1
+ export declare const escapeRegExp: (string: string) => string;
@@ -1,4 +1,4 @@
1
1
  import { ExecOptions } from "child_process";
2
2
  type Options = Omit<ExecOptions, "maxBuffer">;
3
- declare const exec: (command: string, options?: Options) => Promise<string>;
4
- export { exec };
3
+ export declare const exec: (command: string, options?: Options) => Promise<string>;
4
+ export {};
@@ -1,5 +1,5 @@
1
1
  type Data = {
2
2
  [key: string]: string;
3
3
  };
4
- export declare const injectVariables: (str: string, data: Data) => string;
4
+ export declare const injectVariables: (pattern: string, data: Data) => string;
5
5
  export {};
@@ -1,14 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.injectVariables = void 0;
4
- const injectVariables = (str, data) => {
5
- let res = str;
6
- Object.keys(data).forEach((key) => {
7
- const variableName = `\\$\\{${key}\\}`;
8
- const variableValue = data[key];
9
- const regex = new RegExp(variableName, "g");
10
- res = res.replace(regex, variableValue);
11
- });
12
- return res;
4
+ const injectVariables = (pattern, data) => {
5
+ return Object.entries(data).reduce((res, [key, value]) => {
6
+ const regex = new RegExp(`\\$\\{${key}\\}`, "g");
7
+ return res.replace(regex, value);
8
+ }, pattern);
13
9
  };
14
10
  exports.injectVariables = injectVariables;
@@ -1,2 +1 @@
1
- declare const parseTable: (string: any, pos: any) => any;
2
- export { parseTable };
1
+ export declare const parseTable: (string: any, pos: any) => any;
@@ -1,2 +1 @@
1
- declare const spawn: (command: string, args: string[]) => Promise<void>;
2
- export { spawn };
1
+ export declare const spawn: (command: string, args: string[]) => Promise<void>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wocker/ws",
3
3
  "type": "commonjs",
4
- "version": "1.0.30",
4
+ "version": "1.0.31-beta.0",
5
5
  "author": "Kris Papercut <krispcut@gmail.com>",
6
6
  "description": "Docker workspace for web projects",
7
7
  "license": "MIT",
@@ -35,8 +35,8 @@
35
35
  "make-coverage-badge": "make-coverage-badge"
36
36
  },
37
37
  "dependencies": {
38
- "@wocker/core": "1.0.30",
39
- "@wocker/docker-module": "^0.0.4",
38
+ "@wocker/core": "1.0.31",
39
+ "@wocker/docker-module": "^0.0.6",
40
40
  "@wocker/utils": "^2.0.6",
41
41
  "async-mutex": "^0.4.0",
42
42
  "axios": "^1.6.7",
@@ -57,7 +57,7 @@
57
57
  "@types/mute-stream": "^0.0.4",
58
58
  "@types/node": "^24.5.2",
59
59
  "@types/unzipper": "^0.10.10",
60
- "@wocker/docker-mock-module": "^0.0.2",
60
+ "@wocker/docker-mock-module": "^0.0.3",
61
61
  "@wocker/testing": "^1.0.4",
62
62
  "jest": "^30.1.3",
63
63
  "make-coverage-badge": "^1.2.0",