@wocker/ws 1.0.2 → 1.0.4

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 (107) hide show
  1. package/README.md +1 -1
  2. package/lib/App.d.ts +4 -3
  3. package/lib/App.js +98 -77
  4. package/lib/controllers/ImageController.d.ts +2 -2
  5. package/lib/controllers/ImageController.js +27 -27
  6. package/lib/controllers/PluginController.d.ts +2 -2
  7. package/lib/controllers/PluginController.js +78 -56
  8. package/lib/controllers/PresetController.d.ts +3 -1
  9. package/lib/controllers/PresetController.js +155 -136
  10. package/lib/controllers/ProjectController.d.ts +5 -5
  11. package/lib/controllers/ProjectController.js +653 -603
  12. package/lib/controllers/ProxyController.d.ts +4 -1
  13. package/lib/controllers/ProxyController.js +269 -245
  14. package/lib/controllers/index.js +19 -58
  15. package/lib/decorators/Inject.d.ts +1 -0
  16. package/lib/decorators/Inject.js +8 -0
  17. package/lib/decorators/Injectable.d.ts +4 -0
  18. package/lib/decorators/Injectable.js +17 -0
  19. package/lib/decorators/index.d.ts +1 -0
  20. package/lib/decorators/index.js +17 -0
  21. package/lib/env.js +33 -15
  22. package/lib/index.d.ts +3 -0
  23. package/lib/index.js +31 -16
  24. package/lib/makes/Controller.js +4 -8
  25. package/lib/makes/DI.d.ts +7 -0
  26. package/lib/makes/DI.js +27 -0
  27. package/lib/makes/Docker.js +298 -382
  28. package/lib/makes/FS.d.ts +3 -9
  29. package/lib/makes/FS.js +277 -305
  30. package/lib/makes/LineConvertStream.js +37 -40
  31. package/lib/makes/Logger.d.ts +9 -1
  32. package/lib/makes/Logger.js +22 -11
  33. package/lib/makes/Model.js +8 -12
  34. package/lib/makes/MySQL.js +6 -27
  35. package/lib/makes/Plugin.d.ts +1 -1
  36. package/lib/makes/Plugin.js +55 -37
  37. package/lib/makes/Preset.d.ts +46 -0
  38. package/lib/makes/Preset.js +33 -0
  39. package/lib/makes/Project.d.ts +45 -0
  40. package/lib/makes/Project.js +127 -0
  41. package/lib/makes/Repository.js +18 -21
  42. package/lib/makes/index.d.ts +3 -0
  43. package/lib/makes/index.js +23 -69
  44. package/lib/plugins/ElasticSearchPlugin.d.ts +3 -1
  45. package/lib/plugins/ElasticSearchPlugin.js +66 -66
  46. package/lib/plugins/LocaltunnelPlugin.d.ts +2 -2
  47. package/lib/plugins/LocaltunnelPlugin.js +256 -257
  48. package/lib/plugins/MaildevPlugin.d.ts +2 -2
  49. package/lib/plugins/MaildevPlugin.js +45 -44
  50. package/lib/plugins/MongodbPlugin.d.ts +2 -2
  51. package/lib/plugins/MongodbPlugin.js +303 -248
  52. package/lib/plugins/NgrokPlugin.d.ts +2 -2
  53. package/lib/plugins/NgrokPlugin.js +221 -231
  54. package/lib/plugins/PageKitePlugin.d.ts +2 -2
  55. package/lib/plugins/PageKitePlugin.js +150 -149
  56. package/lib/plugins/PostgresPlugin.d.ts +1 -1
  57. package/lib/plugins/PostgresPlugin.js +115 -89
  58. package/lib/plugins/ProxmoxPlugin.d.ts +1 -1
  59. package/lib/plugins/ProxmoxPlugin.js +50 -38
  60. package/lib/plugins/RedisPlugin.d.ts +3 -1
  61. package/lib/plugins/RedisPlugin.js +73 -72
  62. package/lib/plugins/index.js +25 -103
  63. package/lib/services/AppConfigService.d.ts +3 -3
  64. package/lib/services/AppConfigService.js +162 -157
  65. package/lib/services/AppEventsService.js +26 -24
  66. package/lib/services/DockerService.d.ts +37 -2
  67. package/lib/services/DockerService.js +185 -205
  68. package/lib/services/LogService.d.ts +3 -2
  69. package/lib/services/LogService.js +33 -34
  70. package/lib/services/PluginService.d.ts +2 -1
  71. package/lib/services/PluginService.js +11 -14
  72. package/lib/services/PresetService.d.ts +8 -3
  73. package/lib/services/PresetService.js +60 -59
  74. package/lib/services/ProjectService.d.ts +11 -4
  75. package/lib/services/ProjectService.js +140 -129
  76. package/lib/services/index.js +21 -80
  77. package/lib/types/Config.d.ts +4 -3
  78. package/lib/types/Config.js +1 -4
  79. package/lib/types/EnvConfig.js +1 -4
  80. package/lib/types/index.js +16 -25
  81. package/lib/utils/buildOptions.js +5 -8
  82. package/lib/utils/demuxOutput.js +16 -20
  83. package/lib/utils/escapeRegExp.js +4 -7
  84. package/lib/utils/exec.js +38 -39
  85. package/lib/utils/fetch.js +46 -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.js +32 -191
  93. package/lib/utils/injectVariables.js +10 -13
  94. package/lib/utils/parse-table.js +20 -23
  95. package/lib/utils/set-config.d.ts +1 -1
  96. package/lib/utils/set-config.js +12 -15
  97. package/lib/utils/spawn.js +17 -20
  98. package/lib/utils/tty.js +2 -6
  99. package/lib/utils/volumeFormat.js +5 -12
  100. package/lib/utils/volumeParse.js +10 -13
  101. package/package.json +13 -39
  102. package/presets/bun/Dockerfile +11 -0
  103. package/presets/bun/config.json +3 -0
  104. package/presets/node/Dockerfile +4 -2
  105. package/presets/php-apache/Dockerfile +3 -2
  106. package/.github/workflows/publish.yml +0 -31
  107. package/plugins/mariadb/admin/conf/config.user.inc.php +0 -9
@@ -1,4 +1,6 @@
1
- import { DI, AppConfigService, AppEventsService, ProjectService, DockerService, Controller, Cli, Project } from "@wocker/core";
1
+ import { Controller, Cli } from "@wocker/core";
2
+ import { DI, Project } from "../makes";
3
+ import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
2
4
  type InitOptions = {
3
5
  "http-port"?: number;
4
6
  "https-port"?: number;
@@ -15,6 +17,7 @@ declare class ProxyController extends Controller {
15
17
  constructor(di: DI);
16
18
  install(cli: Cli): void;
17
19
  getProjectNames(): Promise<string[]>;
20
+ getDomains(name: string | undefined, selected: string[]): Promise<string[]>;
18
21
  onProjectStart(project: Project): Promise<void>;
19
22
  onProjectStop(project: Project): Promise<void>;
20
23
  init(options: InitOptions): Promise<void>;
@@ -1,249 +1,273 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ProxyController = void 0;
7
- var _core = require("@wocker/core");
8
- var _utils = require("@wocker/utils");
9
- var _cliTable = _interopRequireDefault(require("cli-table3"));
10
- var _chalk = _interopRequireDefault(require("chalk"));
11
- var _makes = require("../makes");
12
- var _utils2 = require("../utils");
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- class ProxyController extends _core.Controller {
15
- containerName = "proxy.workspace";
16
- constructor(di) {
17
- super();
18
- this.appConfigService = di.resolveService(_core.AppConfigService);
19
- this.appEventsService = di.resolveService(_core.AppEventsService);
20
- this.projectService = di.resolveService(_core.ProjectService);
21
- this.dockerService = di.resolveService(_core.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").option("http-port", {
28
- type: "number",
29
- description: "Http port"
30
- }).option("https-port", {
31
- type: "number",
32
- description: "Https port"
33
- }).action(options => this.init(options));
34
- cli.command("proxy:start").action(() => this.start());
35
- cli.command("proxy:stop").action(() => this.stop());
36
- cli.command("proxy:restart").action(() => this.restart());
37
- cli.command("domains").option("name", {
38
- type: "string",
39
- alias: "n",
40
- description: "Project name"
41
- }).action(options => this.domainList(options));
42
- cli.command("domain:set [...domains]").option("name", {
43
- type: "string",
44
- alias: "n",
45
- description: "Project name"
46
- }).completion("name", () => this.getProjectNames()).action((options, domains) => this.setDomains(options, domains));
47
- cli.command("domain:add [...domains]").option("name", {
48
- type: "string",
49
- alias: "n",
50
- description: "Project name"
51
- }).completion("name", () => this.getProjectNames()).action((options, domains) => this.addDomain(options, domains));
52
- cli.command("domain:remove [...domains]").option("name", {
53
- type: "string",
54
- alias: "n",
55
- description: "Project name"
56
- }).completion("name", () => this.getProjectNames()).action((options, domains) => this.removeDomain(options, domains));
57
- cli.command("domain:clear").option("name", {
58
- type: "string",
59
- alias: "n",
60
- description: "Project name"
61
- }).completion("name", () => this.getProjectNames()).action(options => this.clearDomains(options));
62
- cli.command("proxy:logs").action(() => this.logs());
63
- }
64
- async getProjectNames() {
65
- const projects = await _core.Project.search();
66
- return projects.map(project => project.name);
67
- }
68
- async onProjectStart(project) {
69
- if (!project.hasEnv("VIRTUAL_HOST")) {
70
- project.setEnv("VIRTUAL_HOST", `${project.name}.workspace`);
71
- }
72
- await this.start();
73
- }
74
- async onProjectStop(project) {
75
- //
76
- }
77
- async init(options) {
78
- let {
79
- "http-port": httpPort,
80
- "https-port": httpsPort
81
- } = options;
82
- if (typeof httpPort === "undefined" || isNaN(httpPort)) {
83
- httpPort = await (0, _utils.promptText)({
84
- required: true,
85
- message: "Http port:",
86
- type: "int",
87
- default: await this.appConfigService.getEnvVariable("PROXY_HTTP_PORT", "80")
88
- });
89
- }
90
- await this.appConfigService.setEnvVariable("PROXY_HTTP_PORT", httpPort);
91
- if (typeof httpsPort === "undefined" || isNaN(httpsPort)) {
92
- httpsPort = await (0, _utils.promptText)({
93
- required: true,
94
- message: "Https port:",
95
- type: "int",
96
- default: await this.appConfigService.getEnvVariable("PROXY_HTTPS_PORT", "443")
97
- });
98
- }
99
- await this.appConfigService.setEnvVariable("PROXY_HTTPS_PORT", httpsPort);
100
- }
101
- async start() {
102
- console.info("Proxy starting...");
103
- await this.dockerService.pullImage("nginxproxy/nginx-proxy");
104
- const httpPort = await this.appConfigService.getEnvVariable("PROXY_HTTP_PORT", "80");
105
- const httpsPort = await this.appConfigService.getEnvVariable("PROXY_HTTPS_PORT", "443");
106
- let container = await this.dockerService.getContainer(this.containerName);
107
- if (!container) {
108
- const certsDir = this.appConfigService.dataPath("certs");
109
- if (!_makes.FS.existsSync(certsDir)) {
110
- _makes.FS.mkdirSync(certsDir, {
111
- recursive: true
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")]
112
183
  });
113
- }
114
- container = await this.dockerService.createContainer({
115
- name: this.containerName,
116
- image: "nginxproxy/nginx-proxy",
117
- volumes: ["/var/run/docker.sock:/tmp/docker.sock:ro", `${certsDir}:/etc/nginx/certs`],
118
- ports: [`${httpPort}:80`, `${httpsPort}:443`],
119
- env: {
120
- DEFAULT_HOST: "index.workspace"
121
- }
122
- });
123
- } else {
124
- console.info("Container already exists");
125
- }
126
- const {
127
- State: {
128
- Status
129
- }
130
- } = await container.inspect();
131
- if (["created", "exited"].includes(Status)) {
132
- console.info("Starting...", Status);
133
- await container.start();
134
- }
135
- }
136
- async stop() {
137
- console.info("Proxy stopping...");
138
- await this.dockerService.removeContainer(this.containerName);
139
- }
140
- async restart() {
141
- await this.stop();
142
- await this.start();
143
- }
144
- async domainList(options) {
145
- const {
146
- name
147
- } = options;
148
- if (name) {
149
- await this.projectService.cdProject(name);
150
- }
151
- const project = await this.projectService.get();
152
- const table = new _cliTable.default({
153
- head: [_chalk.default.yellow("Domain")]
154
- });
155
- const domains = project.getEnv("VIRTUAL_HOST", "").split(",");
156
- for (const domain of domains) {
157
- table.push([domain]);
158
- }
159
- return table.toString() + "\n";
160
- }
161
- async setDomains(options, domains) {
162
- const {
163
- name
164
- } = options;
165
- if (name) {
166
- await this.projectService.cdProject(name);
167
- }
168
- const project = await this.projectService.get();
169
- project.setEnv("VIRTUAL_HOST", domains.join(","));
170
- project.save();
171
- const container = await this.dockerService.getContainer(`${project.name}.workspace`);
172
- if (container) {
173
- await this.projectService.stop(project);
174
- await this.projectService.start(project);
175
- }
176
- }
177
- async addDomain(options, addDomains) {
178
- const {
179
- name
180
- } = options;
181
- if (name) {
182
- await this.projectService.cdProject(name);
183
- }
184
- const project = await this.projectService.get();
185
- let domains = project.getEnv("VIRTUAL_HOST", "").split(",").filter(domain => {
186
- return !!domain;
187
- });
188
- domains = [...domains, ...addDomains.filter(domain => {
189
- return !domains.find(existDomain => {
190
- return existDomain === domain;
191
- });
192
- })];
193
- project.setEnv("VIRTUAL_HOST", domains.join(","));
194
- await project.save();
195
- const container = await this.dockerService.getContainer(`${project.name}.workspace`);
196
- if (container) {
197
- await this.projectService.stop(project);
198
- await this.projectService.start(project);
199
- }
200
- }
201
- async removeDomain(options, removeDomains) {
202
- const {
203
- name
204
- } = options;
205
- if (name) {
206
- await this.projectService.cdProject(name);
207
- }
208
- const project = await this.projectService.get();
209
- let domains = project.getEnv("VIRTUAL_HOST", "").split(",").filter(domain => {
210
- return !!domain;
211
- });
212
- domains = domains.filter(domain => {
213
- return !removeDomains.includes(domain);
214
- });
215
- project.setEnv("VIRTUAL_HOST", domains.join(","));
216
- await project.save();
217
- }
218
- async clearDomains(options) {
219
- const {
220
- name
221
- } = options;
222
- if (name) {
223
- await this.projectService.cdProject(name);
224
- }
225
- const project = await this.projectService.get();
226
- project.unsetEnv("VIRTUAL_HOST");
227
- await project.save();
228
- const container = await this.dockerService.getContainer(`${project.name}.workspace`);
229
- if (container) {
230
- await this.projectService.stop(project);
231
- await this.projectService.start(project);
232
- }
233
- }
234
- async logs() {
235
- const container = await this.dockerService.getContainer(this.containerName);
236
- if (!container) {
237
- return;
238
- }
239
- const stream = await container.logs({
240
- follow: true,
241
- stdout: true,
242
- stderr: true
243
- });
244
- stream.on("data", data => {
245
- process.stdout.write((0, _utils2.demuxOutput)(data));
246
- });
247
- }
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
+ }
248
272
  }
249
- exports.ProxyController = ProxyController;
273
+ exports.ProxyController = ProxyController;
@@ -1,60 +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 _PluginController = require("./PluginController");
18
- Object.keys(_PluginController).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _PluginController[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _PluginController[key];
25
- }
26
- });
27
- });
28
- var _PresetController = require("./PresetController");
29
- Object.keys(_PresetController).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _PresetController[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _PresetController[key];
36
- }
37
- });
38
- });
39
- var _ProjectController = require("./ProjectController");
40
- Object.keys(_ProjectController).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _ProjectController[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _ProjectController[key];
47
- }
48
- });
49
- });
50
- var _ProxyController = require("./ProxyController");
51
- Object.keys(_ProxyController).forEach(function (key) {
52
- if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _ProxyController[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function () {
57
- return _ProxyController[key];
58
- }
59
- });
60
- });
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);
@@ -0,0 +1 @@
1
+ export declare const Inject: () => (target: any) => void;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Inject = void 0;
4
+ const Inject = () => {
5
+ return (target) => {
6
+ };
7
+ };
8
+ exports.Inject = Inject;
@@ -0,0 +1,4 @@
1
+ import { DI } from "../makes";
2
+ export declare const Injectable: () => <T extends new (...rest: any[]) => {}>(Target: T) => {
3
+ new (di: DI): {};
4
+ } & T;