@wocker/ws 1.0.2 → 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 (100) 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/env.js +33 -15
  16. package/lib/index.d.ts +2 -0
  17. package/lib/index.js +30 -16
  18. package/lib/makes/Controller.js +4 -8
  19. package/lib/makes/DI.d.ts +7 -0
  20. package/lib/makes/DI.js +27 -0
  21. package/lib/makes/Docker.js +298 -382
  22. package/lib/makes/FS.js +328 -304
  23. package/lib/makes/LineConvertStream.js +37 -40
  24. package/lib/makes/Logger.d.ts +9 -1
  25. package/lib/makes/Logger.js +22 -11
  26. package/lib/makes/Model.js +8 -12
  27. package/lib/makes/MySQL.js +6 -27
  28. package/lib/makes/Plugin.d.ts +1 -1
  29. package/lib/makes/Plugin.js +55 -37
  30. package/lib/makes/Preset.d.ts +46 -0
  31. package/lib/makes/Preset.js +33 -0
  32. package/lib/makes/Project.d.ts +45 -0
  33. package/lib/makes/Project.js +127 -0
  34. package/lib/makes/Repository.js +18 -21
  35. package/lib/makes/index.d.ts +3 -0
  36. package/lib/makes/index.js +23 -69
  37. package/lib/plugins/ElasticSearchPlugin.d.ts +3 -1
  38. package/lib/plugins/ElasticSearchPlugin.js +66 -66
  39. package/lib/plugins/LocaltunnelPlugin.d.ts +2 -2
  40. package/lib/plugins/LocaltunnelPlugin.js +256 -257
  41. package/lib/plugins/MaildevPlugin.d.ts +2 -2
  42. package/lib/plugins/MaildevPlugin.js +45 -44
  43. package/lib/plugins/MongodbPlugin.d.ts +2 -2
  44. package/lib/plugins/MongodbPlugin.js +303 -248
  45. package/lib/plugins/NgrokPlugin.d.ts +2 -2
  46. package/lib/plugins/NgrokPlugin.js +221 -231
  47. package/lib/plugins/PageKitePlugin.d.ts +2 -2
  48. package/lib/plugins/PageKitePlugin.js +150 -149
  49. package/lib/plugins/PostgresPlugin.d.ts +1 -1
  50. package/lib/plugins/PostgresPlugin.js +115 -89
  51. package/lib/plugins/ProxmoxPlugin.d.ts +1 -1
  52. package/lib/plugins/ProxmoxPlugin.js +50 -38
  53. package/lib/plugins/RedisPlugin.d.ts +3 -1
  54. package/lib/plugins/RedisPlugin.js +73 -72
  55. package/lib/plugins/index.js +25 -103
  56. package/lib/services/AppConfigService.d.ts +3 -3
  57. package/lib/services/AppConfigService.js +162 -157
  58. package/lib/services/AppEventsService.js +26 -24
  59. package/lib/services/DockerService.d.ts +37 -2
  60. package/lib/services/DockerService.js +185 -205
  61. package/lib/services/LogService.d.ts +3 -2
  62. package/lib/services/LogService.js +33 -34
  63. package/lib/services/PluginService.d.ts +2 -1
  64. package/lib/services/PluginService.js +11 -14
  65. package/lib/services/PresetService.d.ts +8 -3
  66. package/lib/services/PresetService.js +60 -59
  67. package/lib/services/ProjectService.d.ts +11 -4
  68. package/lib/services/ProjectService.js +140 -129
  69. package/lib/services/index.js +21 -80
  70. package/lib/types/Config.d.ts +4 -3
  71. package/lib/types/Config.js +1 -4
  72. package/lib/types/EnvConfig.js +1 -4
  73. package/lib/types/index.js +16 -25
  74. package/lib/utils/buildOptions.js +5 -8
  75. package/lib/utils/demuxOutput.js +16 -20
  76. package/lib/utils/escapeRegExp.js +4 -7
  77. package/lib/utils/exec.js +38 -39
  78. package/lib/utils/fetch.js +46 -30
  79. package/lib/utils/followProgress.js +66 -77
  80. package/lib/utils/format-size-units.js +16 -16
  81. package/lib/utils/get-config.d.ts +1 -1
  82. package/lib/utils/get-config.js +13 -16
  83. package/lib/utils/get-cursor-position.js +22 -29
  84. package/lib/utils/image-build.js +35 -23
  85. package/lib/utils/index.js +32 -191
  86. package/lib/utils/injectVariables.js +10 -13
  87. package/lib/utils/parse-table.js +20 -23
  88. package/lib/utils/set-config.d.ts +1 -1
  89. package/lib/utils/set-config.js +12 -15
  90. package/lib/utils/spawn.js +17 -20
  91. package/lib/utils/tty.js +2 -6
  92. package/lib/utils/volumeFormat.js +5 -12
  93. package/lib/utils/volumeParse.js +10 -13
  94. package/package.json +13 -39
  95. package/presets/bun/Dockerfile +11 -0
  96. package/presets/bun/config.json +3 -0
  97. package/presets/node/Dockerfile +4 -2
  98. package/presets/php-apache/Dockerfile +3 -2
  99. package/.github/workflows/publish.yml +0 -31
  100. package/plugins/mariadb/admin/conf/config.user.inc.php +0 -9
@@ -1,150 +1,169 @@
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
  });
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 });
6
26
  exports.PresetController = void 0;
7
- var _core = require("@wocker/core");
8
- var _utils = require("@wocker/utils");
9
- var Path = _interopRequireWildcard(require("path"));
10
- var _env = require("../env");
11
- var _utils2 = require("../utils");
12
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
- class PresetController extends _core.Controller {
15
- constructor(di) {
16
- super();
17
- this.appConfigService = di.resolveService(_core.AppConfigService);
18
- this.appEventsService = di.resolveService(_core.AppEventsService);
19
- this.projectService = di.resolveService(_core.ProjectService);
20
- this.presetService = di.resolveService(_core.PresetService);
21
- this.dockerService = di.resolveService(_core.DockerService);
22
- }
23
- install(cli) {
24
- super.install(cli);
25
- this.appConfigService.registerProjectType("preset", "Preset");
26
- this.appEventsService.on("project:init", project => this.onInit(project));
27
- this.appEventsService.on("project:beforeStart", project => this.onBeforeStart(project));
28
- this.appEventsService.on("project:rebuild", project => this.onRebuild(project));
29
- cli.command("preset:build <preset>").completion("preset", () => this.presets()).option("rebuild", {
30
- type: "boolean",
31
- alias: "r",
32
- description: "Rebuild image"
33
- }).action((options, preset) => this.build(options, preset));
34
- }
35
- async presets() {
36
- const presets = await this.presetService.search();
37
- return presets.map(preset => {
38
- return preset.name;
39
- });
40
- }
41
- async onInit(project) {
42
- if (project.type !== "preset") {
43
- return;
44
- }
45
- const presets = await this.presetService.search();
46
- if (presets.length === 0) {
47
- throw new Error("No presets");
48
- }
49
- project.preset = await (0, _utils.promptSelect)({
50
- message: "Choose preset:",
51
- options: presets.map(preset => {
52
- return {
53
- label: preset.name,
54
- value: preset.name
55
- };
56
- }),
57
- default: project.preset
58
- });
59
- const preset = await this.presetService.get(project.preset);
60
- if (!preset) {
61
- throw new Error("Preset not found");
27
+ const utils_1 = require("@wocker/utils");
28
+ const Path = __importStar(require("path"));
29
+ const env_1 = require("../env");
30
+ const utils_2 = require("../utils");
31
+ const makes_1 = require("../makes");
32
+ const services_1 = require("../services");
33
+ class PresetController extends makes_1.Controller {
34
+ constructor(di) {
35
+ super();
36
+ this.appConfigService = di.resolveService(services_1.AppConfigService);
37
+ this.appEventsService = di.resolveService(services_1.AppEventsService);
38
+ this.projectService = di.resolveService(services_1.ProjectService);
39
+ this.presetService = di.resolveService(services_1.PresetService);
40
+ this.dockerService = di.resolveService(services_1.DockerService);
62
41
  }
63
- if (preset.buildArgsOptions) {
64
- project.buildArgs = await (0, _utils.promptConfig)(preset.buildArgsOptions, project.buildArgs);
42
+ install(cli) {
43
+ super.install(cli);
44
+ this.appConfigService.registerProjectType("preset", "Preset");
45
+ this.appEventsService.on("project:init", (project) => this.onInit(project));
46
+ this.appEventsService.on("project:beforeStart", (project) => this.onBeforeStart(project));
47
+ this.appEventsService.on("project:rebuild", (project) => this.onRebuild(project));
48
+ cli.command("preset:build <preset>")
49
+ .completion("preset", () => this.presets())
50
+ .option("rebuild", {
51
+ type: "boolean",
52
+ alias: "r",
53
+ description: "Rebuild image"
54
+ })
55
+ .action((options, preset) => this.build(options, preset));
65
56
  }
66
- if (preset.envOptions) {
67
- project.env = await (0, _utils.promptConfig)(preset.envOptions, project.env);
68
- }
69
- if (preset.volumeOptions) {
70
- for (let volume of preset.volumeOptions) {
71
- volume = (0, _utils2.injectVariables)(volume, {
72
- ...(project.buildArgs || {}),
73
- ...(project.env || {})
74
- });
75
- const {
76
- destination,
77
- options
78
- } = (0, _utils2.volumeParse)(volume);
79
- let projectVolume = project.getVolumeByDestination(destination);
80
- const source = await (0, _utils.promptText)({
81
- message: "Volume",
82
- suffix: `:${destination}`,
83
- default: projectVolume ? (0, _utils2.volumeParse)(projectVolume).source : "./"
57
+ async presets() {
58
+ const presets = await this.presetService.search();
59
+ return presets.map((preset) => {
60
+ return preset.name;
84
61
  });
85
- projectVolume = (0, _utils2.volumeFormat)({
86
- source,
87
- destination,
88
- options
89
- });
90
- project.volumeMount(projectVolume);
91
- }
92
- }
93
- if (preset.dockerfile) {
94
- project.imageName = preset.getImageName(project.buildArgs);
95
- }
96
- }
97
- async onRebuild(project) {
98
- if (project.type !== "preset") {
99
- return;
100
62
  }
101
- const preset = await this.presetService.get(project.preset);
102
- if (!preset) {
103
- throw new Error(`Preset ${project.preset} not found`);
63
+ async onInit(project) {
64
+ if (project.type !== "preset") {
65
+ return;
66
+ }
67
+ const presets = await this.presetService.search();
68
+ if (presets.length === 0) {
69
+ throw new Error("No presets");
70
+ }
71
+ project.preset = await (0, utils_1.promptSelect)({
72
+ message: "Choose preset:",
73
+ options: presets.map((preset) => {
74
+ return {
75
+ label: preset.name,
76
+ value: preset.name
77
+ };
78
+ }),
79
+ default: project.preset
80
+ });
81
+ const preset = await this.presetService.get(project.preset);
82
+ if (!preset) {
83
+ throw new Error("Preset not found");
84
+ }
85
+ if (preset.buildArgsOptions) {
86
+ project.buildArgs = await (0, utils_1.promptConfig)(preset.buildArgsOptions, project.buildArgs);
87
+ }
88
+ if (preset.envOptions) {
89
+ project.env = await (0, utils_1.promptConfig)(preset.envOptions, project.env);
90
+ }
91
+ if (preset.volumeOptions) {
92
+ for (let volume of preset.volumeOptions) {
93
+ volume = (0, utils_2.injectVariables)(volume, {
94
+ ...project.buildArgs || {},
95
+ ...project.env || {}
96
+ });
97
+ const { destination, options } = (0, utils_2.volumeParse)(volume);
98
+ let projectVolume = project.getVolumeByDestination(destination);
99
+ const source = await (0, utils_1.promptText)({
100
+ message: "Volume",
101
+ suffix: `:${destination}`,
102
+ default: projectVolume ? (0, utils_2.volumeParse)(projectVolume).source : "./"
103
+ });
104
+ projectVolume = (0, utils_2.volumeFormat)({
105
+ source,
106
+ destination,
107
+ options
108
+ });
109
+ project.volumeMount(projectVolume);
110
+ }
111
+ }
112
+ if (preset.dockerfile) {
113
+ project.imageName = preset.getImageName(project.buildArgs);
114
+ }
104
115
  }
105
- const imageName = preset.getImageName(project.buildArgs || {});
106
- const exists = await this.dockerService.imageExists(imageName);
107
- if (exists) {
108
- console.info(`Removing image: ${imageName}`);
109
- await this.dockerService.imageRm(imageName);
116
+ async onRebuild(project) {
117
+ if (project.type !== "preset") {
118
+ return;
119
+ }
120
+ const preset = await this.presetService.get(project.preset);
121
+ if (!preset) {
122
+ throw new Error(`Preset ${project.preset} not found`);
123
+ }
124
+ const imageName = preset.getImageName(project.buildArgs || {});
125
+ const exists = await this.dockerService.imageExists(imageName);
126
+ if (exists) {
127
+ console.info(`Removing image: ${imageName}`);
128
+ await this.dockerService.imageRm(imageName);
129
+ }
110
130
  }
111
- }
112
- async onBeforeStart(project) {
113
- if (project.type !== "preset") {
114
- return;
131
+ async onBeforeStart(project) {
132
+ if (project.type !== "preset") {
133
+ return;
134
+ }
135
+ const preset = await this.presetService.get(project.preset);
136
+ if (preset.dockerfile) {
137
+ project.imageName = preset.getImageName(project.buildArgs);
138
+ if (!await this.dockerService.imageExists(project.imageName)) {
139
+ await this.dockerService.buildImage({
140
+ tag: project.imageName,
141
+ labels: {
142
+ presetName: preset.name
143
+ },
144
+ buildArgs: project.buildArgs,
145
+ context: Path.join(env_1.PRESETS_DIR, preset.name),
146
+ src: preset.dockerfile
147
+ });
148
+ }
149
+ }
115
150
  }
116
- const preset = await this.presetService.get(project.preset);
117
- if (preset.dockerfile) {
118
- project.imageName = preset.getImageName(project.buildArgs);
119
- if (!(await this.dockerService.imageExists(project.imageName))) {
151
+ async build(options, presetName) {
152
+ const preset = await this.presetService.get(presetName);
153
+ let buildArgs = {};
154
+ if (preset.buildArgsOptions) {
155
+ buildArgs = await (0, utils_1.promptGroup)(preset.buildArgsOptions);
156
+ }
157
+ const imageName = preset.getImageName(buildArgs);
120
158
  await this.dockerService.buildImage({
121
- tag: project.imageName,
122
- labels: {
123
- presetName: preset.name
124
- },
125
- buildArgs: project.buildArgs,
126
- context: Path.join(_env.PRESETS_DIR, preset.name),
127
- src: preset.dockerfile
159
+ tag: imageName,
160
+ labels: {
161
+ presetName: preset.name
162
+ },
163
+ buildArgs: buildArgs,
164
+ context: Path.join(env_1.PRESETS_DIR, preset.name),
165
+ src: preset.dockerfile
128
166
  });
129
- }
130
- }
131
- }
132
- async build(options, presetName) {
133
- const preset = await this.presetService.get(presetName);
134
- let buildArgs = {};
135
- if (preset.buildArgsOptions) {
136
- buildArgs = await (0, _utils.promptGroup)(preset.buildArgsOptions);
137
167
  }
138
- const imageName = preset.getImageName(buildArgs);
139
- await this.dockerService.buildImage({
140
- tag: imageName,
141
- labels: {
142
- presetName: preset.name
143
- },
144
- buildArgs: buildArgs,
145
- context: Path.join(_env.PRESETS_DIR, preset.name),
146
- src: preset.dockerfile
147
- });
148
- }
149
168
  }
150
- exports.PresetController = PresetController;
169
+ exports.PresetController = PresetController;
@@ -1,6 +1,6 @@
1
- import { DI, AppConfigService as CoreAppConfigService, AppEventsService as CoreAppEventsService, ProjectService as CoreProjectService, DockerService } from "@wocker/core";
2
1
  import { Cli } from "@kearisp/cli";
3
- import { Controller } from "src/makes";
2
+ import { DI, Controller } from "../makes";
3
+ import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
4
4
  type InitOptions = {
5
5
  name?: string;
6
6
  type?: string;
@@ -41,9 +41,9 @@ type ExecOptions = {
41
41
  };
42
42
  declare class ProjectController extends Controller {
43
43
  protected di: DI;
44
- protected appConfigService: CoreAppConfigService;
45
- protected appEventsService: CoreAppEventsService;
46
- protected projectService: CoreProjectService;
44
+ protected appConfigService: AppConfigService;
45
+ protected appEventsService: AppEventsService;
46
+ protected projectService: ProjectService;
47
47
  protected dockerService: DockerService;
48
48
  constructor(di: DI);
49
49
  install(cli: Cli): void;