@wocker/ws 1.0.1 → 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 (136) hide show
  1. package/README.md +11 -137
  2. package/bin/ws.js +7 -3
  3. package/lib/App.d.ts +10 -7
  4. package/lib/App.js +99 -44
  5. package/lib/controllers/ImageController.d.ts +4 -2
  6. package/lib/controllers/ImageController.js +27 -25
  7. package/lib/controllers/PluginController.d.ts +14 -0
  8. package/lib/controllers/PluginController.js +84 -0
  9. package/lib/controllers/PresetController.d.ts +21 -0
  10. package/lib/controllers/PresetController.js +169 -0
  11. package/lib/controllers/ProjectController.d.ts +11 -3
  12. package/lib/controllers/ProjectController.js +653 -536
  13. package/lib/{plugins/ProxyPlugin.d.ts → controllers/ProxyController.d.ts} +12 -11
  14. package/lib/controllers/ProxyController.js +273 -0
  15. package/lib/controllers/index.d.ts +3 -0
  16. package/lib/controllers/index.js +19 -25
  17. package/lib/env.js +33 -22
  18. package/lib/index.d.ts +2 -0
  19. package/lib/index.js +29 -28
  20. package/lib/makes/Controller.js +4 -8
  21. package/lib/makes/DI.d.ts +7 -0
  22. package/lib/makes/DI.js +27 -0
  23. package/lib/makes/Docker.js +299 -397
  24. package/lib/makes/FS.d.ts +1 -1
  25. package/lib/makes/FS.js +328 -301
  26. package/lib/makes/LineConvertStream.js +37 -40
  27. package/lib/makes/Logger.d.ts +5 -3
  28. package/lib/makes/Logger.js +18 -34
  29. package/lib/makes/Model.js +8 -12
  30. package/lib/makes/MySQL.js +6 -27
  31. package/lib/makes/Plugin.d.ts +1 -1
  32. package/lib/makes/Plugin.js +55 -37
  33. package/lib/makes/Preset.d.ts +46 -0
  34. package/lib/makes/Preset.js +33 -0
  35. package/lib/{models → makes}/Project.d.ts +23 -16
  36. package/lib/makes/Project.js +127 -0
  37. package/lib/makes/Repository.js +18 -21
  38. package/lib/makes/index.d.ts +3 -0
  39. package/lib/makes/index.js +23 -69
  40. package/lib/plugins/ElasticSearchPlugin.d.ts +18 -0
  41. package/lib/plugins/ElasticSearchPlugin.js +72 -0
  42. package/lib/plugins/LocaltunnelPlugin.d.ts +4 -4
  43. package/lib/plugins/LocaltunnelPlugin.js +256 -255
  44. package/lib/plugins/MaildevPlugin.d.ts +4 -2
  45. package/lib/plugins/MaildevPlugin.js +45 -41
  46. package/lib/plugins/MongodbPlugin.d.ts +6 -4
  47. package/lib/plugins/MongodbPlugin.js +303 -254
  48. package/lib/plugins/NgrokPlugin.d.ts +3 -4
  49. package/lib/plugins/NgrokPlugin.js +221 -230
  50. package/lib/plugins/PageKitePlugin.d.ts +3 -4
  51. package/lib/plugins/PageKitePlugin.js +150 -147
  52. package/lib/plugins/PostgresPlugin.d.ts +1 -1
  53. package/lib/plugins/PostgresPlugin.js +115 -88
  54. package/lib/plugins/ProxmoxPlugin.d.ts +1 -1
  55. package/lib/plugins/ProxmoxPlugin.js +50 -38
  56. package/lib/plugins/RedisPlugin.d.ts +10 -2
  57. package/lib/plugins/RedisPlugin.js +77 -39
  58. package/lib/plugins/index.d.ts +2 -6
  59. package/lib/plugins/index.js +25 -158
  60. package/lib/services/AppConfigService.d.ts +13 -3
  61. package/lib/services/AppConfigService.js +161 -71
  62. package/lib/services/AppEventsService.d.ts +5 -8
  63. package/lib/services/AppEventsService.js +26 -25
  64. package/lib/services/DockerService.d.ts +51 -0
  65. package/lib/services/DockerService.js +200 -0
  66. package/lib/services/LogService.d.ts +12 -0
  67. package/lib/services/LogService.js +38 -0
  68. package/lib/services/PluginService.d.ts +11 -0
  69. package/lib/services/PluginService.js +15 -0
  70. package/lib/services/PresetService.d.ts +14 -0
  71. package/lib/services/PresetService.js +64 -0
  72. package/lib/services/ProjectService.d.ts +12 -4
  73. package/lib/services/ProjectService.js +141 -78
  74. package/lib/services/index.d.ts +4 -0
  75. package/lib/services/index.js +21 -36
  76. package/lib/types/Config.d.ts +4 -3
  77. package/lib/types/Config.js +1 -4
  78. package/lib/types/EnvConfig.js +1 -4
  79. package/lib/types/index.js +16 -25
  80. package/lib/utils/buildOptions.js +5 -8
  81. package/lib/utils/demuxOutput.js +16 -22
  82. package/lib/utils/escapeRegExp.js +4 -7
  83. package/lib/utils/exec.d.ts +1 -1
  84. package/lib/utils/exec.js +38 -40
  85. package/lib/utils/fetch.js +45 -30
  86. package/lib/utils/followProgress.js +66 -77
  87. package/lib/utils/format-size-units.js +16 -16
  88. package/lib/utils/get-config.d.ts +1 -1
  89. package/lib/utils/get-config.js +13 -16
  90. package/lib/utils/get-cursor-position.js +22 -29
  91. package/lib/utils/image-build.js +35 -23
  92. package/lib/utils/index.d.ts +0 -4
  93. package/lib/utils/index.js +32 -235
  94. package/lib/utils/injectVariables.js +10 -13
  95. package/lib/utils/parse-table.js +20 -23
  96. package/lib/utils/set-config.d.ts +1 -1
  97. package/lib/utils/set-config.js +12 -15
  98. package/lib/utils/spawn.js +17 -20
  99. package/lib/utils/tty.js +2 -6
  100. package/lib/utils/volumeFormat.js +5 -12
  101. package/lib/utils/volumeParse.js +10 -13
  102. package/package.json +21 -47
  103. package/presets/bun/Dockerfile +11 -0
  104. package/presets/bun/config.json +3 -0
  105. package/presets/node/Dockerfile +4 -2
  106. package/presets/node/config.json +9 -7
  107. package/presets/php-apache/Dockerfile +40 -38
  108. package/presets/php-apache/config.json +10 -15
  109. package/presets/php-fpm/Dockerfile +21 -0
  110. package/presets/php-fpm/config.json +25 -0
  111. package/lib/models/Preset.d.ts +0 -19
  112. package/lib/models/Preset.js +0 -60
  113. package/lib/models/Project.js +0 -151
  114. package/lib/models/index.d.ts +0 -2
  115. package/lib/models/index.js +0 -27
  116. package/lib/plugins/MariadbPlugin.d.ts +0 -25
  117. package/lib/plugins/MariadbPlugin.js +0 -297
  118. package/lib/plugins/PresetPlugin.d.ts +0 -19
  119. package/lib/plugins/PresetPlugin.js +0 -164
  120. package/lib/plugins/ProjectPlugin.d.ts +0 -12
  121. package/lib/plugins/ProjectPlugin.js +0 -54
  122. package/lib/plugins/ProxyPlugin.js +0 -257
  123. package/lib/plugins/ServeoPlugin.d.ts +0 -36
  124. package/lib/plugins/ServeoPlugin.js +0 -260
  125. package/lib/plugins/TestPlugin.d.ts +0 -10
  126. package/lib/plugins/TestPlugin.js +0 -75
  127. package/lib/utils/promptConfirm.d.ts +0 -6
  128. package/lib/utils/promptConfirm.js +0 -21
  129. package/lib/utils/promptGroup.d.ts +0 -16
  130. package/lib/utils/promptGroup.js +0 -39
  131. package/lib/utils/promptSelect.d.ts +0 -12
  132. package/lib/utils/promptSelect.js +0 -47
  133. package/lib/utils/promptText.d.ts +0 -13
  134. package/lib/utils/promptText.js +0 -53
  135. package/plugins/mariadb/admin/conf/config.user.inc.php +0 -9
  136. package/plugins/serveo/Dockerfile +0 -17
@@ -1,7 +1,6 @@
1
- import { Cli } from "@kearisp/cli";
2
- import { Plugin } from "src/makes";
3
- import { Project } from "src/models";
4
- import { AppConfigService, AppEventsService, ProjectService } from "src/services";
1
+ import { Controller, Cli } from "@wocker/core";
2
+ import { DI, Project } from "../makes";
3
+ import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
5
4
  type InitOptions = {
6
5
  "http-port"?: number;
7
6
  "https-port"?: number;
@@ -9,25 +8,27 @@ type InitOptions = {
9
8
  type DomainsOptions = {
10
9
  name?: string;
11
10
  };
12
- declare class ProxyPlugin extends Plugin {
11
+ declare class ProxyController extends Controller {
12
+ protected containerName: string;
13
13
  protected appConfigService: AppConfigService;
14
14
  protected appEventsService: AppEventsService;
15
15
  protected projectService: ProjectService;
16
- protected containerName: string;
17
- constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService);
16
+ protected dockerService: DockerService;
17
+ constructor(di: DI);
18
18
  install(cli: Cli): void;
19
19
  getProjectNames(): Promise<string[]>;
20
+ getDomains(name: string | undefined, selected: string[]): Promise<string[]>;
20
21
  onProjectStart(project: Project): Promise<void>;
21
- createNetwork(): Promise<void>;
22
+ onProjectStop(project: Project): Promise<void>;
22
23
  init(options: InitOptions): Promise<void>;
23
24
  start(): Promise<void>;
24
25
  stop(): Promise<void>;
25
26
  restart(): Promise<void>;
26
- logs(): Promise<void>;
27
27
  domainList(options: DomainsOptions): Promise<string>;
28
+ setDomains(options: DomainsOptions, domains: string[]): Promise<void>;
28
29
  addDomain(options: DomainsOptions, addDomains: string[]): Promise<void>;
29
30
  removeDomain(options: DomainsOptions, removeDomains: string[]): Promise<void>;
30
- setDomains(options: DomainsOptions, domains: string[]): Promise<void>;
31
31
  clearDomains(options: DomainsOptions): Promise<void>;
32
+ logs(): Promise<void>;
32
33
  }
33
- export { ProxyPlugin };
34
+ export { ProxyController };
@@ -0,0 +1,273 @@
1
+ "use strict";
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
+ exports.ProxyController = void 0;
7
+ const core_1 = require("@wocker/core");
8
+ const utils_1 = require("@wocker/utils");
9
+ const cli_table3_1 = __importDefault(require("cli-table3"));
10
+ const chalk_1 = __importDefault(require("chalk"));
11
+ const makes_1 = require("../makes");
12
+ const utils_2 = require("../utils");
13
+ const services_1 = require("../services");
14
+ class ProxyController extends core_1.Controller {
15
+ constructor(di) {
16
+ super();
17
+ this.containerName = "proxy.workspace";
18
+ this.appConfigService = di.resolveService(services_1.AppConfigService);
19
+ this.appEventsService = di.resolveService(services_1.AppEventsService);
20
+ this.projectService = di.resolveService(services_1.ProjectService);
21
+ this.dockerService = di.resolveService(services_1.DockerService);
22
+ }
23
+ install(cli) {
24
+ super.install(cli);
25
+ this.appEventsService.on("project:beforeStart", (project) => this.onProjectStart(project));
26
+ this.appEventsService.on("project:stop", (project) => this.onProjectStop(project));
27
+ cli.command("proxy:init")
28
+ .option("http-port", {
29
+ type: "number",
30
+ description: "Http port"
31
+ })
32
+ .option("https-port", {
33
+ type: "number",
34
+ description: "Https port"
35
+ })
36
+ .action((options) => this.init(options));
37
+ cli.command("proxy:start")
38
+ .action(() => this.start());
39
+ cli.command("proxy:stop")
40
+ .action(() => this.stop());
41
+ cli.command("proxy:restart")
42
+ .action(() => this.restart());
43
+ cli.command("domains")
44
+ .option("name", {
45
+ type: "string",
46
+ alias: "n",
47
+ description: "Project name"
48
+ })
49
+ .action((options) => this.domainList(options));
50
+ cli.command("domain:set [...domains]")
51
+ .option("name", {
52
+ type: "string",
53
+ alias: "n",
54
+ description: "Project name"
55
+ })
56
+ .completion("name", () => this.getProjectNames())
57
+ .action((options, domains) => this.setDomains(options, domains));
58
+ cli.command("domain:add [...domains]")
59
+ .option("name", {
60
+ type: "string",
61
+ alias: "n",
62
+ description: "Project name"
63
+ })
64
+ .completion("name", () => this.getProjectNames())
65
+ .action((options, domains) => this.addDomain(options, domains));
66
+ cli.command("domain:remove [...domains]")
67
+ .option("name", {
68
+ type: "string",
69
+ alias: "n",
70
+ description: "Project name"
71
+ })
72
+ .completion("name", () => this.getProjectNames())
73
+ .completion("domains", (options, domains) => this.getDomains(options.name, domains))
74
+ .action((options, domains) => this.removeDomain(options, domains));
75
+ cli.command("domain:clear")
76
+ .option("name", {
77
+ type: "string",
78
+ alias: "n",
79
+ description: "Project name"
80
+ })
81
+ .completion("name", () => this.getProjectNames())
82
+ .action((options) => this.clearDomains(options));
83
+ cli.command("proxy:logs")
84
+ .action(() => this.logs());
85
+ }
86
+ async getProjectNames() {
87
+ const projects = await makes_1.Project.search();
88
+ return projects.map((project) => project.name);
89
+ }
90
+ async getDomains(name, selected) {
91
+ if (name) {
92
+ await this.projectService.cdProject(name);
93
+ }
94
+ const project = await this.projectService.get();
95
+ return (project.getEnv("VIRTUAL_HOST") || "").split(",").filter((domain) => {
96
+ return !selected.includes(domain);
97
+ });
98
+ }
99
+ async onProjectStart(project) {
100
+ if (!project.hasEnv("VIRTUAL_HOST")) {
101
+ project.setEnv("VIRTUAL_HOST", `${project.name}.workspace`);
102
+ }
103
+ await this.start();
104
+ }
105
+ async onProjectStop(project) {
106
+ }
107
+ async init(options) {
108
+ let { "http-port": httpPort, "https-port": httpsPort } = options;
109
+ if (typeof httpPort === "undefined" || isNaN(httpPort)) {
110
+ httpPort = await (0, utils_1.promptText)({
111
+ required: true,
112
+ message: "Http port:",
113
+ type: "int",
114
+ default: await this.appConfigService.getEnvVariable("PROXY_HTTP_PORT", "80")
115
+ });
116
+ }
117
+ await this.appConfigService.setEnvVariable("PROXY_HTTP_PORT", httpPort);
118
+ if (typeof httpsPort === "undefined" || isNaN(httpsPort)) {
119
+ httpsPort = await (0, utils_1.promptText)({
120
+ required: true,
121
+ message: "Https port:",
122
+ type: "int",
123
+ default: await this.appConfigService.getEnvVariable("PROXY_HTTPS_PORT", "443")
124
+ });
125
+ }
126
+ await this.appConfigService.setEnvVariable("PROXY_HTTPS_PORT", httpsPort);
127
+ }
128
+ async start() {
129
+ console.info("Proxy starting...");
130
+ await this.dockerService.pullImage("nginxproxy/nginx-proxy");
131
+ const httpPort = await this.appConfigService.getEnvVariable("PROXY_HTTP_PORT", "80");
132
+ const httpsPort = await this.appConfigService.getEnvVariable("PROXY_HTTPS_PORT", "443");
133
+ let container = await this.dockerService.getContainer(this.containerName);
134
+ if (!container) {
135
+ const certsDir = this.appConfigService.dataPath("certs");
136
+ if (!makes_1.FS.existsSync(certsDir)) {
137
+ makes_1.FS.mkdirSync(certsDir, {
138
+ recursive: true
139
+ });
140
+ }
141
+ container = await this.dockerService.createContainer({
142
+ name: this.containerName,
143
+ image: "nginxproxy/nginx-proxy",
144
+ restart: "always",
145
+ env: {
146
+ DEFAULT_HOST: "index.workspace"
147
+ },
148
+ ports: [
149
+ `${httpPort}:80`,
150
+ `${httpsPort}:443`
151
+ ],
152
+ volumes: [
153
+ "/var/run/docker.sock:/tmp/docker.sock:ro",
154
+ `${certsDir}:/etc/nginx/certs`
155
+ ]
156
+ });
157
+ }
158
+ else {
159
+ console.info("Container already exists");
160
+ }
161
+ const { State: { Status } } = await container.inspect();
162
+ if (["created", "exited"].includes(Status)) {
163
+ console.info("Starting...", Status);
164
+ await container.start();
165
+ }
166
+ }
167
+ async stop() {
168
+ console.info("Proxy stopping...");
169
+ await this.dockerService.removeContainer(this.containerName);
170
+ }
171
+ async restart() {
172
+ await this.stop();
173
+ await this.start();
174
+ }
175
+ async domainList(options) {
176
+ const { name } = options;
177
+ if (name) {
178
+ await this.projectService.cdProject(name);
179
+ }
180
+ const project = await this.projectService.get();
181
+ const table = new cli_table3_1.default({
182
+ head: [chalk_1.default.yellow("Domain")]
183
+ });
184
+ const domains = project.getEnv("VIRTUAL_HOST", "").split(",");
185
+ for (const domain of domains) {
186
+ table.push([domain]);
187
+ }
188
+ return table.toString() + "\n";
189
+ }
190
+ async setDomains(options, domains) {
191
+ const { name } = options;
192
+ if (name) {
193
+ await this.projectService.cdProject(name);
194
+ }
195
+ const project = await this.projectService.get();
196
+ project.setEnv("VIRTUAL_HOST", domains.join(","));
197
+ project.save();
198
+ const container = await this.dockerService.getContainer(`${project.name}.workspace`);
199
+ if (container) {
200
+ await this.projectService.stop();
201
+ await this.projectService.start();
202
+ }
203
+ }
204
+ async addDomain(options, addDomains) {
205
+ const { name } = options;
206
+ if (name) {
207
+ await this.projectService.cdProject(name);
208
+ }
209
+ const project = await this.projectService.get();
210
+ let domains = project.getEnv("VIRTUAL_HOST", "").split(",").filter((domain) => {
211
+ return !!domain;
212
+ });
213
+ domains = [
214
+ ...domains,
215
+ ...addDomains.filter((domain) => {
216
+ return !domains.find((existDomain) => {
217
+ return existDomain === domain;
218
+ });
219
+ })
220
+ ];
221
+ project.setEnv("VIRTUAL_HOST", domains.join(","));
222
+ await project.save();
223
+ const container = await this.dockerService.getContainer(`${project.name}.workspace`);
224
+ if (container) {
225
+ await this.projectService.stop();
226
+ await this.projectService.start();
227
+ }
228
+ }
229
+ async removeDomain(options, removeDomains) {
230
+ const { name } = options;
231
+ if (name) {
232
+ await this.projectService.cdProject(name);
233
+ }
234
+ const project = await this.projectService.get();
235
+ let domains = project.getEnv("VIRTUAL_HOST", "").split(",").filter((domain) => {
236
+ return !!domain;
237
+ });
238
+ domains = domains.filter((domain) => {
239
+ return !removeDomains.includes(domain);
240
+ });
241
+ project.setEnv("VIRTUAL_HOST", domains.join(","));
242
+ await project.save();
243
+ }
244
+ async clearDomains(options) {
245
+ const { name } = options;
246
+ if (name) {
247
+ await this.projectService.cdProject(name);
248
+ }
249
+ const project = await this.projectService.get();
250
+ project.unsetEnv("VIRTUAL_HOST");
251
+ await project.save();
252
+ const container = await this.dockerService.getContainer(`${project.name}.workspace`);
253
+ if (container) {
254
+ await this.projectService.stop();
255
+ await this.projectService.start();
256
+ }
257
+ }
258
+ async logs() {
259
+ const container = await this.dockerService.getContainer(this.containerName);
260
+ if (!container) {
261
+ return;
262
+ }
263
+ const stream = await container.logs({
264
+ follow: true,
265
+ stdout: true,
266
+ stderr: true
267
+ });
268
+ stream.on("data", (data) => {
269
+ process.stdout.write((0, utils_2.demuxOutput)(data));
270
+ });
271
+ }
272
+ }
273
+ exports.ProxyController = ProxyController;
@@ -1,2 +1,5 @@
1
1
  export * from "./ImageController";
2
+ export * from "./PluginController";
3
+ export * from "./PresetController";
2
4
  export * from "./ProjectController";
5
+ export * from "./ProxyController";
@@ -1,27 +1,21 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _ImageController = require("./ImageController");
7
- Object.keys(_ImageController).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _ImageController[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _ImageController[key];
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
7
  }
15
- });
16
- });
17
- var _ProjectController = require("./ProjectController");
18
- Object.keys(_ProjectController).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _ProjectController[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _ProjectController[key];
25
- }
26
- });
27
- });
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ImageController"), exports);
18
+ __exportStar(require("./PluginController"), exports);
19
+ __exportStar(require("./PresetController"), exports);
20
+ __exportStar(require("./ProjectController"), exports);
21
+ __exportStar(require("./ProxyController"), exports);
package/lib/env.js CHANGED
@@ -1,24 +1,35 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
5
17
  });
6
- exports.SERVICES_DIR = exports.ROOT_DIR = exports.PRESETS_DIR = exports.PLUGINS_DIR = exports.NODE_ENV = exports.MAP_PATH = exports.DATA_DIR = void 0;
7
- var OS = _interopRequireWildcard(require("os"));
8
- var Path = _interopRequireWildcard(require("path"));
9
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
- const NODE_ENV = process.env.NODE_ENV;
12
- exports.NODE_ENV = NODE_ENV;
13
- const ROOT_DIR = Path.join(__dirname, "..");
14
- exports.ROOT_DIR = ROOT_DIR;
15
- const PRESETS_DIR = Path.join(ROOT_DIR, "presets");
16
- exports.PRESETS_DIR = PRESETS_DIR;
17
- const SERVICES_DIR = Path.join(ROOT_DIR, "services");
18
- exports.SERVICES_DIR = SERVICES_DIR;
19
- const PLUGINS_DIR = Path.join(ROOT_DIR, "plugins");
20
- exports.PLUGINS_DIR = PLUGINS_DIR;
21
- const DATA_DIR = process.env.WS_DIR || Path.join(OS.homedir(), ".workspace");
22
- exports.DATA_DIR = DATA_DIR;
23
- const MAP_PATH = Path.join(DATA_DIR, "data.json");
24
- exports.MAP_PATH = MAP_PATH;
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.MAP_PATH = exports.DATA_DIR = exports.PLUGINS_DIR = exports.SERVICES_DIR = exports.PRESETS_DIR = exports.ROOT_DIR = exports.NODE_ENV = void 0;
27
+ const OS = __importStar(require("os"));
28
+ const Path = __importStar(require("path"));
29
+ exports.NODE_ENV = process.env.NODE_ENV;
30
+ exports.ROOT_DIR = Path.join(__dirname, "..");
31
+ exports.PRESETS_DIR = Path.join(exports.ROOT_DIR, "presets");
32
+ exports.SERVICES_DIR = Path.join(exports.ROOT_DIR, "services");
33
+ exports.PLUGINS_DIR = Path.join(exports.ROOT_DIR, "plugins");
34
+ exports.DATA_DIR = process.env.WS_DIR || Path.join(OS.homedir(), ".workspace");
35
+ exports.MAP_PATH = Path.join(exports.DATA_DIR, "data.json");
package/lib/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  import { App } from "./App";
2
2
  declare const app: App;
3
3
  export { app };
4
+ export * from "./makes";
5
+ export * from "./services";
package/lib/index.js CHANGED
@@ -1,31 +1,32 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
6
17
  exports.app = void 0;
7
- var _controllers = require("./controllers");
8
- var _plugins = require("./plugins");
9
- var _services = require("./services");
10
- var _App = require("./App");
11
- const appConfigService = new _services.AppConfigService();
12
- const appEventsService = new _services.AppEventsService();
13
- const projectService = new _services.ProjectService(appConfigService, appEventsService);
14
- const app = new _App.App(appConfigService);
18
+ const App_1 = require("./App");
19
+ const plugins_1 = require("./plugins");
20
+ const app = new App_1.App();
15
21
  exports.app = app;
16
- app.useController(new _controllers.ImageController());
17
- app.useController(new _controllers.ProjectController(appConfigService, appEventsService, projectService));
18
- app.usePlugin(new _plugins.LocaltunnelPlugin(appConfigService, appEventsService, projectService));
19
- app.usePlugin(new _plugins.MaildevPlugin());
20
- app.usePlugin(new _plugins.MariadbPlugin());
21
- app.usePlugin(new _plugins.MongodbPlugin());
22
- app.usePlugin(new _plugins.NgrokPlugin(appEventsService, projectService));
23
- app.usePlugin(new _plugins.PageKitePlugin(appConfigService, appEventsService, projectService));
24
- app.usePlugin(new _plugins.PostgresPlugin());
25
- app.usePlugin(new _plugins.PresetPlugin(appConfigService, appEventsService));
26
- app.usePlugin(new _plugins.ProxmoxPlugin());
27
- app.usePlugin(new _plugins.ProxyPlugin(appConfigService, appEventsService, projectService));
28
- app.usePlugin(new _plugins.ProjectPlugin());
29
- app.usePlugin(new _plugins.RedisPlugin());
30
- app.usePlugin(new _plugins.ServeoPlugin(appConfigService, appEventsService, projectService));
31
- app.usePlugin(new _plugins.TestPlugin());
22
+ app.use(plugins_1.ElasticSearchPlugin);
23
+ app.use(plugins_1.LocaltunnelPlugin);
24
+ app.use(plugins_1.MaildevPlugin);
25
+ app.use(plugins_1.MongodbPlugin);
26
+ app.use(plugins_1.NgrokPlugin);
27
+ app.use(plugins_1.PageKitePlugin);
28
+ app.use(plugins_1.PostgresPlugin);
29
+ app.use(plugins_1.ProxmoxPlugin);
30
+ app.use(plugins_1.RedisPlugin);
31
+ __exportStar(require("./makes"), exports);
32
+ __exportStar(require("./services"), exports);
@@ -1,12 +1,8 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.Controller = void 0;
7
4
  class Controller {
8
- install() {
9
- // TODO: Do something on install
10
- }
5
+ install() {
6
+ }
11
7
  }
12
- exports.Controller = Controller;
8
+ exports.Controller = Controller;
@@ -0,0 +1,7 @@
1
+ import "reflect-metadata";
2
+ declare class DI {
3
+ private services;
4
+ resolveService<T>(key: any): T;
5
+ registerService(key: any, service: any): void;
6
+ }
7
+ export { DI };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DI = void 0;
4
+ require("reflect-metadata");
5
+ class DI {
6
+ constructor() {
7
+ this.services = new Map();
8
+ }
9
+ resolveService(key) {
10
+ let res = this.services.get(key);
11
+ if (!res) {
12
+ const types = Reflect.getMetadata("design:paramtypes", key);
13
+ if (types && types.length > 0) {
14
+ types.forEach((type) => {
15
+ this.resolveService(type);
16
+ });
17
+ }
18
+ res = new key(this);
19
+ this.services.set(key, res);
20
+ }
21
+ return res;
22
+ }
23
+ registerService(key, service) {
24
+ this.services.set(key, service);
25
+ }
26
+ }
27
+ exports.DI = DI;