@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,71 +1,25 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _Controller = require("./Controller");
7
- Object.keys(_Controller).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _Controller[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _Controller[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 _Docker = require("./Docker");
18
- Object.keys(_Docker).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _Docker[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _Docker[key];
25
- }
26
- });
27
- });
28
- var _FS = require("./FS");
29
- Object.keys(_FS).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _FS[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _FS[key];
36
- }
37
- });
38
- });
39
- var _Logger = require("./Logger");
40
- Object.keys(_Logger).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _Logger[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _Logger[key];
47
- }
48
- });
49
- });
50
- var _Plugin = require("./Plugin");
51
- Object.keys(_Plugin).forEach(function (key) {
52
- if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _Plugin[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function () {
57
- return _Plugin[key];
58
- }
59
- });
60
- });
61
- var _Repository = require("./Repository");
62
- Object.keys(_Repository).forEach(function (key) {
63
- if (key === "default" || key === "__esModule") return;
64
- if (key in exports && exports[key] === _Repository[key]) return;
65
- Object.defineProperty(exports, key, {
66
- enumerable: true,
67
- get: function () {
68
- return _Repository[key];
69
- }
70
- });
71
- });
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("./Controller"), exports);
18
+ __exportStar(require("./DI"), exports);
19
+ __exportStar(require("./Docker"), exports);
20
+ __exportStar(require("./FS"), exports);
21
+ __exportStar(require("./Logger"), exports);
22
+ __exportStar(require("./Plugin"), exports);
23
+ __exportStar(require("./Preset"), exports);
24
+ __exportStar(require("./Project"), exports);
25
+ __exportStar(require("./Repository"), exports);
@@ -0,0 +1,18 @@
1
+ import { FSManager } from "@wocker/core";
2
+ import { Cli } from "@kearisp/cli";
3
+ import { Plugin, DI } from "../makes";
4
+ import { AppConfigService, DockerService } from "../services";
5
+ type StartOptions = {
6
+ restart?: boolean;
7
+ };
8
+ declare class ElasticSearchPlugin extends Plugin {
9
+ protected containerName: string;
10
+ protected appConfigService: AppConfigService;
11
+ protected dockerService: DockerService;
12
+ protected fs: FSManager;
13
+ constructor(di: DI);
14
+ install(cli: Cli): void;
15
+ start(options: StartOptions): Promise<void>;
16
+ stop(): Promise<void>;
17
+ }
18
+ export { ElasticSearchPlugin };
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ElasticSearchPlugin = void 0;
4
+ const core_1 = require("@wocker/core");
5
+ const makes_1 = require("../makes");
6
+ const services_1 = require("../services");
7
+ class ElasticSearchPlugin extends makes_1.Plugin {
8
+ constructor(di) {
9
+ super("elastic-search");
10
+ this.containerName = "elastic-search.workspace";
11
+ this.appConfigService = di.resolveService(services_1.AppConfigService);
12
+ this.dockerService = di.resolveService(services_1.DockerService);
13
+ this.fs = new core_1.FSManager(this.appConfigService.pluginsPath("elastic-search"), this.appConfigService.dataPath("plugins/elastic-search"));
14
+ }
15
+ install(cli) {
16
+ super.install(cli);
17
+ cli.command("elastica:start")
18
+ .option("restart", {
19
+ type: "boolean",
20
+ alias: "r",
21
+ description: "Restart service"
22
+ })
23
+ .action((options) => this.start(options));
24
+ cli.command("elastica:stop")
25
+ .action(() => this.stop());
26
+ }
27
+ async start(options) {
28
+ const { restart } = options;
29
+ await this.dockerService.pullImage("docker.elastic.co/elasticsearch/elasticsearch:7.5.2");
30
+ let container = await this.dockerService.getContainer(this.containerName);
31
+ if (restart && container) {
32
+ await this.dockerService.removeContainer(this.containerName);
33
+ container = null;
34
+ }
35
+ if (!container) {
36
+ await this.fs.mkdir("data", {
37
+ recursive: true
38
+ });
39
+ container = await this.dockerService.createContainer({
40
+ name: this.containerName,
41
+ image: "docker.elastic.co/elasticsearch/elasticsearch:7.5.2",
42
+ ulimits: {
43
+ memlock: {
44
+ hard: -1,
45
+ soft: -1
46
+ }
47
+ },
48
+ env: {
49
+ "node.name": "elasticsearch",
50
+ "cluster.name": "elasticsearch",
51
+ "cluster.initial_master_nodes": "elasticsearch",
52
+ "bootstrap.memory_lock": "false",
53
+ ES_JAVA_OPTS: "-Xms512m -Xmx512m"
54
+ },
55
+ volumes: [
56
+ `${this.fs.path("data")}:/usr/share/elasticsearch/data`
57
+ ],
58
+ ports: [
59
+ "9200:9200"
60
+ ]
61
+ });
62
+ }
63
+ const { State: { Status } } = await container.inspect();
64
+ if (Status === "created" || Status === "exited") {
65
+ await container.start();
66
+ }
67
+ }
68
+ async stop() {
69
+ await this.dockerService.removeContainer(this.containerName);
70
+ }
71
+ }
72
+ exports.ElasticSearchPlugin = ElasticSearchPlugin;
@@ -1,7 +1,6 @@
1
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";
2
+ import { DI, Plugin, Project } from "../makes";
3
+ import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
5
4
  type InitOptions = {
6
5
  name?: string;
7
6
  };
@@ -20,7 +19,8 @@ declare class LocaltunnelPlugin extends Plugin {
20
19
  protected appConfigService: AppConfigService;
21
20
  protected appEventsService: AppEventsService;
22
21
  protected projectService: ProjectService;
23
- constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService);
22
+ protected dockerService: DockerService;
23
+ constructor(di: DI);
24
24
  install(cli: Cli): void;
25
25
  getIp(): Promise<string>;
26
26
  onProjectStart(project: Project): Promise<void>;