@wocker/ws 1.0.1

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 (164) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +155 -0
  3. package/bin/ws.js +13 -0
  4. package/lib/App.d.ts +13 -0
  5. package/lib/App.js +52 -0
  6. package/lib/controllers/ImageController.d.ts +8 -0
  7. package/lib/controllers/ImageController.js +29 -0
  8. package/lib/controllers/ProjectController.d.ts +64 -0
  9. package/lib/controllers/ProjectController.js +561 -0
  10. package/lib/controllers/index.d.ts +2 -0
  11. package/lib/controllers/index.js +27 -0
  12. package/lib/env.d.ts +7 -0
  13. package/lib/env.js +24 -0
  14. package/lib/index.d.ts +3 -0
  15. package/lib/index.js +31 -0
  16. package/lib/makes/Controller.d.ts +5 -0
  17. package/lib/makes/Controller.js +12 -0
  18. package/lib/makes/Docker.d.ts +58 -0
  19. package/lib/makes/Docker.js +418 -0
  20. package/lib/makes/FS.d.ts +37 -0
  21. package/lib/makes/FS.js +317 -0
  22. package/lib/makes/LineConvertStream.d.ts +13 -0
  23. package/lib/makes/LineConvertStream.js +45 -0
  24. package/lib/makes/Logger.d.ts +7 -0
  25. package/lib/makes/Logger.js +39 -0
  26. package/lib/makes/Model.d.ts +5 -0
  27. package/lib/makes/Model.js +16 -0
  28. package/lib/makes/MySQL.d.ts +15 -0
  29. package/lib/makes/MySQL.js +31 -0
  30. package/lib/makes/Plugin.d.ts +13 -0
  31. package/lib/makes/Plugin.js +43 -0
  32. package/lib/makes/Repository.d.ts +11 -0
  33. package/lib/makes/Repository.js +25 -0
  34. package/lib/makes/index.d.ts +6 -0
  35. package/lib/makes/index.js +71 -0
  36. package/lib/models/Preset.d.ts +19 -0
  37. package/lib/models/Preset.js +60 -0
  38. package/lib/models/Project.d.ts +38 -0
  39. package/lib/models/Project.js +151 -0
  40. package/lib/models/index.d.ts +2 -0
  41. package/lib/models/index.js +27 -0
  42. package/lib/plugins/LocaltunnelPlugin.d.ts +36 -0
  43. package/lib/plugins/LocaltunnelPlugin.js +273 -0
  44. package/lib/plugins/MaildevPlugin.d.ts +10 -0
  45. package/lib/plugins/MaildevPlugin.js +45 -0
  46. package/lib/plugins/MariadbPlugin.d.ts +25 -0
  47. package/lib/plugins/MariadbPlugin.js +297 -0
  48. package/lib/plugins/MongodbPlugin.d.ts +20 -0
  49. package/lib/plugins/MongodbPlugin.js +271 -0
  50. package/lib/plugins/NgrokPlugin.d.ts +37 -0
  51. package/lib/plugins/NgrokPlugin.js +248 -0
  52. package/lib/plugins/PageKitePlugin.d.ts +31 -0
  53. package/lib/plugins/PageKitePlugin.js +158 -0
  54. package/lib/plugins/PostgresPlugin.d.ts +16 -0
  55. package/lib/plugins/PostgresPlugin.js +94 -0
  56. package/lib/plugins/PresetPlugin.d.ts +19 -0
  57. package/lib/plugins/PresetPlugin.js +164 -0
  58. package/lib/plugins/ProjectPlugin.d.ts +12 -0
  59. package/lib/plugins/ProjectPlugin.js +54 -0
  60. package/lib/plugins/ProxmoxPlugin.d.ts +9 -0
  61. package/lib/plugins/ProxmoxPlugin.js +55 -0
  62. package/lib/plugins/ProxyPlugin.d.ts +33 -0
  63. package/lib/plugins/ProxyPlugin.js +257 -0
  64. package/lib/plugins/RedisPlugin.d.ts +10 -0
  65. package/lib/plugins/RedisPlugin.js +42 -0
  66. package/lib/plugins/ServeoPlugin.d.ts +36 -0
  67. package/lib/plugins/ServeoPlugin.js +260 -0
  68. package/lib/plugins/TestPlugin.d.ts +10 -0
  69. package/lib/plugins/TestPlugin.js +75 -0
  70. package/lib/plugins/index.d.ts +14 -0
  71. package/lib/plugins/index.js +159 -0
  72. package/lib/services/AppConfigService.d.ts +18 -0
  73. package/lib/services/AppConfigService.js +77 -0
  74. package/lib/services/AppEventsService.d.ts +13 -0
  75. package/lib/services/AppEventsService.js +29 -0
  76. package/lib/services/ProjectService.d.ts +13 -0
  77. package/lib/services/ProjectService.js +91 -0
  78. package/lib/services/index.d.ts +3 -0
  79. package/lib/services/index.js +38 -0
  80. package/lib/types/Config.d.ts +11 -0
  81. package/lib/types/Config.js +5 -0
  82. package/lib/types/EnvConfig.d.ts +3 -0
  83. package/lib/types/EnvConfig.js +5 -0
  84. package/lib/types/index.d.ts +2 -0
  85. package/lib/types/index.js +27 -0
  86. package/lib/utils/buildOptions.d.ts +1 -0
  87. package/lib/utils/buildOptions.js +12 -0
  88. package/lib/utils/demuxOutput.d.ts +2 -0
  89. package/lib/utils/demuxOutput.js +25 -0
  90. package/lib/utils/escapeRegExp.d.ts +2 -0
  91. package/lib/utils/escapeRegExp.js +10 -0
  92. package/lib/utils/exec.d.ts +2 -0
  93. package/lib/utils/exec.js +44 -0
  94. package/lib/utils/fetch.d.ts +5 -0
  95. package/lib/utils/fetch.js +37 -0
  96. package/lib/utils/followProgress.d.ts +6 -0
  97. package/lib/utils/followProgress.js +80 -0
  98. package/lib/utils/format-size-units.d.ts +1 -0
  99. package/lib/utils/format-size-units.js +19 -0
  100. package/lib/utils/get-config.d.ts +2 -0
  101. package/lib/utils/get-config.js +20 -0
  102. package/lib/utils/get-cursor-position.d.ts +4 -0
  103. package/lib/utils/get-cursor-position.js +34 -0
  104. package/lib/utils/image-build.d.ts +13 -0
  105. package/lib/utils/image-build.js +34 -0
  106. package/lib/utils/index.d.ts +21 -0
  107. package/lib/utils/index.js +236 -0
  108. package/lib/utils/injectVariables.d.ts +5 -0
  109. package/lib/utils/injectVariables.js +17 -0
  110. package/lib/utils/parse-table.d.ts +2 -0
  111. package/lib/utils/parse-table.js +27 -0
  112. package/lib/utils/promptConfirm.d.ts +6 -0
  113. package/lib/utils/promptConfirm.js +21 -0
  114. package/lib/utils/promptGroup.d.ts +16 -0
  115. package/lib/utils/promptGroup.js +39 -0
  116. package/lib/utils/promptSelect.d.ts +12 -0
  117. package/lib/utils/promptSelect.js +47 -0
  118. package/lib/utils/promptText.d.ts +13 -0
  119. package/lib/utils/promptText.js +53 -0
  120. package/lib/utils/set-config.d.ts +2 -0
  121. package/lib/utils/set-config.js +18 -0
  122. package/lib/utils/spawn.d.ts +2 -0
  123. package/lib/utils/spawn.js +24 -0
  124. package/lib/utils/tty.d.ts +2 -0
  125. package/lib/utils/tty.js +10 -0
  126. package/lib/utils/volumeFormat.d.ts +6 -0
  127. package/lib/utils/volumeFormat.js +15 -0
  128. package/lib/utils/volumeParse.d.ts +2 -0
  129. package/lib/utils/volumeParse.js +16 -0
  130. package/package.json +90 -0
  131. package/plugins/localtunnel/Dockerfile +37 -0
  132. package/plugins/localtunnel/Ubuntu.dockerfile +34 -0
  133. package/plugins/localtunnel/config.json +3 -0
  134. package/plugins/maildev/Dockerfile +5 -0
  135. package/plugins/maildev/config.json +3 -0
  136. package/plugins/mariadb/admin/conf/config.user.inc.php +9 -0
  137. package/plugins/ngrok/Dockerfile +2 -0
  138. package/plugins/pagekite/Dockerfile +3 -0
  139. package/plugins/proxmox/Dockerfile +35 -0
  140. package/plugins/proxy/Dockerfile +7 -0
  141. package/plugins/proxy/config.json +3 -0
  142. package/plugins/serveo/Dockerfile +17 -0
  143. package/presets/apache/.docker/apache2/apache2.conf +230 -0
  144. package/presets/apache/.docker/apache2/mods-available/mpm_prefork.conf +16 -0
  145. package/presets/apache/.docker/apache2/sites-available/000-default.conf.conf +21 -0
  146. package/presets/apache/Dockerfile +110 -0
  147. package/presets/apache/bin/compare-version +3 -0
  148. package/presets/apache/config.json +47 -0
  149. package/presets/go/Dockerfile +19 -0
  150. package/presets/go/config.json +13 -0
  151. package/presets/node/Dockerfile +37 -0
  152. package/presets/node/config.json +36 -0
  153. package/presets/php-apache/Dockerfile +133 -0
  154. package/presets/php-apache/bin/compare-version +3 -0
  155. package/presets/php-apache/config.json +56 -0
  156. package/presets/php-apache/etc/apache2/apache2.conf +230 -0
  157. package/presets/php-apache/etc/apache2/mods-available/mpm_prefork.conf +16 -0
  158. package/presets/php-apache/etc/apache2/sites-available/000-default.conf +21 -0
  159. package/presets/shopify/Dockerfile +160 -0
  160. package/presets/shopify/bin/compare-version +3 -0
  161. package/presets/shopify/config.json +24 -0
  162. package/presets/shopify/etc/apache2/apache2.conf +230 -0
  163. package/presets/shopify/etc/apache2/mods-available/mpm_prefork.conf +16 -0
  164. package/presets/shopify/etc/apache2/sites-available/000-default.conf +21 -0
@@ -0,0 +1,260 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ServeoPlugin = void 0;
7
+ var _makes = require("../makes");
8
+ var _models = require("../models");
9
+ var _utils = require("../utils");
10
+ class ServeoPlugin extends _makes.Plugin {
11
+ constructor(appConfigService, appEventsService, projectService) {
12
+ super("serveo");
13
+ this.appConfigService = appConfigService;
14
+ this.appEventsService = appEventsService;
15
+ this.projectService = projectService;
16
+ }
17
+ install(cli) {
18
+ super.install(cli);
19
+ this.appEventsService.on("project:start", project => this.onProjectStart(project));
20
+ this.appEventsService.on("project:stop", project => this.onProjectStop(project));
21
+ cli.command("serveo:init").option("name", {
22
+ alias: "n",
23
+ type: "string",
24
+ description: "Project name"
25
+ }).action(options => this.init(options));
26
+ cli.command("serveo:start").option("name", {
27
+ alias: "n",
28
+ type: "string",
29
+ description: "Project name"
30
+ }).option("detach", {
31
+ alias: "d",
32
+ type: "boolean",
33
+ description: "Detach"
34
+ }).option("rebuild", {
35
+ alias: "r",
36
+ type: "boolean",
37
+ description: "Rebuild"
38
+ }).action(options => this.start(options));
39
+ cli.command("serveo:restart").option("name", {
40
+ alias: "n",
41
+ type: "string",
42
+ description: "Project name"
43
+ }).option("detach", {
44
+ alias: "d",
45
+ type: "boolean",
46
+ description: "Detach"
47
+ }).option("rebuild", {
48
+ alias: "r",
49
+ type: "boolean",
50
+ description: "Rebuild"
51
+ }).action(options => this.restart(options));
52
+ cli.command("serveo:stop").option("name", {
53
+ alias: "n",
54
+ type: "string",
55
+ description: "Project name"
56
+ }).action(options => this.stop(options));
57
+ cli.command("serveo:build").action(() => this.build());
58
+ cli.command("serveo:rebuild").action(() => this.rebuild());
59
+ cli.command("serveo:logs").option("name", {
60
+ alias: "n",
61
+ type: "string",
62
+ description: "Project name"
63
+ }).option("detach", {
64
+ type: "boolean",
65
+ alias: "d",
66
+ description: "Detach"
67
+ }).action(options => this.logs(options));
68
+ }
69
+ async onProjectStart(project) {
70
+ if (!project || project.getEnv("SERVEO_ENABLE", "false") !== "true") {
71
+ return;
72
+ }
73
+ console.info("Serveo starting...");
74
+ await this.build();
75
+ const subdomain = project.getEnv(`SERVEO_SUBDOMAIN`);
76
+ await _makes.FS.mkdir(this.dataPath(".ssh"), {
77
+ recursive: true
78
+ });
79
+ let container = await _makes.Docker.getContainer(`serveo-${project.name}`);
80
+ if (container) {
81
+ const {
82
+ State: {
83
+ Running
84
+ }
85
+ } = await container.inspect();
86
+ if (Running) {
87
+ console.info("Serveo is already running");
88
+ return;
89
+ } else {
90
+ await _makes.Docker.removeContainer(`serveo-${project.name}`);
91
+ }
92
+ }
93
+ container = await _makes.Docker.createContainer({
94
+ name: `serveo-${project.name}`,
95
+ image: "ws-serveo",
96
+ tty: true,
97
+ restart: "always",
98
+ volumes: [`${this.dataPath(".ssh")}:/home/user/.ssh`]
99
+ });
100
+ await container.start();
101
+ const stream = await container.attach({
102
+ stream: true,
103
+ stdin: true,
104
+ stdout: true,
105
+ stderr: true,
106
+ hijack: true,
107
+ logs: true
108
+ });
109
+ await container.resize({
110
+ w: process.stdout.columns,
111
+ h: process.stdout.rows
112
+ });
113
+ const lsExec = await container.exec({
114
+ AttachStdin: true,
115
+ AttachStdout: true,
116
+ AttachStderr: true,
117
+ Cmd: ["ls", "/home/user/.ssh/"]
118
+ });
119
+ const lsStream = await lsExec.start({});
120
+ const ls = await new Promise((resolve, reject) => {
121
+ let ls = "";
122
+ lsStream.on("data", data => {
123
+ ls += (0, _utils.demuxOutput)(data);
124
+ });
125
+ lsStream.on("end", () => {
126
+ resolve(ls);
127
+ });
128
+ lsStream.on("error", reject);
129
+ });
130
+ if (ls === "") {
131
+ stream.write("ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa\n");
132
+ } else {
133
+ _makes.Logger.log(JSON.stringify(ls));
134
+ }
135
+ stream.write(`autossh -R ${subdomain ? `${subdomain}.serveo.net:` : ""}80:${project.name}.workspace:80 serveo.net\n`);
136
+ stream.on("data", data => {
137
+ _makes.Logger.log(data);
138
+ if (/Forwarding HTTP traffic/.test(data.toString())) {
139
+ stream.end();
140
+ }
141
+ });
142
+ await _makes.Docker.attachStream(stream);
143
+ }
144
+ async onProjectStop(project) {
145
+ if (!project || project.getEnv("SERVEO_ENABLE", "false") !== "true") {
146
+ return;
147
+ }
148
+ console.info("Serveo stopping...");
149
+ await _makes.Docker.removeContainer(`serveo-${project.name}`);
150
+ }
151
+ async init(options) {
152
+ const {
153
+ name
154
+ } = options;
155
+ const project = await _models.Project.searchOne(name ? {
156
+ name
157
+ } : {
158
+ src: this.appConfigService.getPWD()
159
+ });
160
+ if (!project) {
161
+ throw new Error(`Project not found`);
162
+ }
163
+ const enabled = await (0, _utils.promptConfirm)({
164
+ message: "Enable serveo?",
165
+ default: project.getEnv("SERVEO_ENABLE", "true") === "true"
166
+ });
167
+ if (enabled) {
168
+ project.setEnv("SERVEO_ENABLE", "true");
169
+ const subdomain = await (0, _utils.promptText)({
170
+ message: "Subdomain",
171
+ prefix: "https://",
172
+ suffix: ".serveo.net",
173
+ default: project.getEnv("SERVEO_SUBDOMAIN", project.name)
174
+ });
175
+ project.setEnv("SERVEO_SUBDOMAIN", subdomain);
176
+ } else {
177
+ project.setEnv("SERVEO_ENABLE", "false");
178
+ }
179
+ await project.save();
180
+ }
181
+ async start(options) {
182
+ const {
183
+ name,
184
+ detach,
185
+ rebuild
186
+ } = options;
187
+ if (name) {
188
+ await this.projectService.cdProject(name);
189
+ }
190
+ const project = await this.projectService.get();
191
+ if (rebuild) {
192
+ await this.rebuild();
193
+ }
194
+ await this.onProjectStart(project);
195
+
196
+ // const project = await Project.
197
+ }
198
+
199
+ async stop(options) {
200
+ const {
201
+ name
202
+ } = options;
203
+ if (name) {
204
+ await this.projectService.cdProject(name);
205
+ }
206
+ const project = await this.projectService.get();
207
+ await this.onProjectStop(project);
208
+ }
209
+ async restart(options) {
210
+ const {
211
+ name
212
+ } = options;
213
+ await this.stop({
214
+ name
215
+ });
216
+ await this.start(options);
217
+ }
218
+ async build() {
219
+ const exists = await _makes.Docker.imageExists("ws-serveo");
220
+ if (!exists) {
221
+ const stream = await _makes.Docker.imageBuild2({
222
+ tag: "ws-serveo",
223
+ context: this.pluginPath(),
224
+ src: "./Dockerfile"
225
+ });
226
+ await (0, _utils.followProgress)(stream);
227
+ }
228
+ }
229
+ async rebuild() {
230
+ const exists = await _makes.Docker.imageExists("ws-serveo");
231
+ if (exists) {
232
+ await _makes.Docker.imageRm("ws-serveo");
233
+ }
234
+ await this.build();
235
+ }
236
+ async logs(options) {
237
+ const {
238
+ name,
239
+ detach
240
+ } = options;
241
+ if (name) {
242
+ await this.projectService.cdProject(name);
243
+ }
244
+ const project = await this.projectService.get();
245
+ const container = await _makes.Docker.getContainer(`serveo-${project.name}`);
246
+ const stream = await container.logs({
247
+ follow: true,
248
+ stderr: true,
249
+ stdout: true,
250
+ tail: 5
251
+ });
252
+ stream.on("data", data => {
253
+ process.stdout.write(data);
254
+ });
255
+ stream.on("error", data => {
256
+ process.stderr.write(data);
257
+ });
258
+ }
259
+ }
260
+ exports.ServeoPlugin = ServeoPlugin;
@@ -0,0 +1,10 @@
1
+ import { Cli } from "@kearisp/cli";
2
+ import { Plugin } from "src/makes";
3
+ declare class TestPlugin extends Plugin {
4
+ constructor();
5
+ install(cli: Cli): void;
6
+ test(): Promise<void>;
7
+ testData(): Promise<void>;
8
+ test2(): Promise<void>;
9
+ }
10
+ export { TestPlugin };
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TestPlugin = void 0;
7
+ var os = _interopRequireWildcard(require("os"));
8
+ var _stream = require("stream");
9
+ var _makes = require("../makes");
10
+ var _utils = require("../utils");
11
+ 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); }
12
+ 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; }
13
+ class TestPlugin extends _makes.Plugin {
14
+ constructor() {
15
+ super("test");
16
+ }
17
+ install(cli) {
18
+ super.install(cli);
19
+ cli.command("test").action(() => this.test());
20
+ cli.command("test2").action(() => this.test2());
21
+ cli.command("test:data").action(() => this.testData());
22
+ cli.command("test:info").action(async () => {
23
+ _makes.Logger.info(Math.random());
24
+ });
25
+ cli.command("test:warning").action(async () => {
26
+ _makes.Logger.warning(Math.random());
27
+ });
28
+ cli.command("test:error").action(async () => {
29
+ _makes.Logger.error(Math.random());
30
+ });
31
+ cli.command("test:action").action(async () => {
32
+ const a = process.stdout.getWindowSize();
33
+ _makes.Logger.info(a);
34
+
35
+ // await Docker.attach("timer.workspace");
36
+ // await Docker.attach("ngrok-timer");
37
+
38
+ // let image = await Docker.getImage("node:lts");
39
+
40
+ // console.log(image);
41
+ });
42
+ }
43
+
44
+ async test() {
45
+ const readable = new _stream.Readable();
46
+ const pause = async (time = 0) => {
47
+ await new Promise(resolve => setTimeout(resolve, time * 1000));
48
+ };
49
+ readable._read = () => undefined;
50
+ (0, _utils.followProgress)(readable);
51
+ const chunks = ["{\"stream\":\"Step 1/13 : ARG PHP_VERSION\"}\n", "{\"stream\":\"\\n\"}\n", "{\"stream\":\"Step 2/13 : FROM php:${PHP_VERSION}-apache\"}\n", "{\"stream\":\"\\n\"}\n", "{\"status\":\"Pulling from library/php\",\"id\":\"5.6-apache\"}\n", "{\"status\":\"Pulling fs layer\",\"progressDetail\":{},\"id\":\"5e6ec7f28fb7\"}\n", "{\"status\":\"Pulling fs layer\",\"progressDetail\":{},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Waiting\",\"progressDetail\":{},\"id\":\"5e6ec7f28fb7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":10,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":25,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":50,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":100,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":120,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":200,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":229,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Download complete\",\"progressDetail\":{},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Digest: sha256:0a40fd273961b99d8afe69a61a68c73c04bc0caa9de384d3b2dd9e7986eec86d\"}\n", "{\"aux\":{\"ID\":\"sha256:87ebbade0d24f347f4067955aad05690956e610dfc0e20c5b278b415c1c36dfc\"}}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":15,\"total\":100},\"id\":\"5e6ec7f28fb7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":30,\"total\":100},\"id\":\"5e6ec7f28fb7\"}\n", "{\"status\":\"Download complete\",\"progressDetail\":{},\"id\":\"5e6ec7f28fb7\"}\n", "{\"stream\":\"\\u001b[91m\\r# 1.0%\\u001b[0m\"}\n", "{\"stream\":\"\\u001b[91m\\r## 2.0%\\u001b[0m\"}\n", "{\"stream\":\"Long line ..................................................................................\\rReplace long line.............\\n\"}\n", "{\"stream\":\"\\u001b[91m\\r### 3.0%\\u001b[0m\"}\n", "{\"stream\":\"\\u001b[91m\\r##### 5.0%\\u001b[0m\"}\n", "{\"stream\":\"\\u001b[91m\\r###### 5.0%\\u001b[0m\"}\n", "{\"stream\":\"\\u001b[91m\\r####### 5.0%\\u001b[0m\"}\n", "{\"stream\":\"\\n\"}\n", "{\"stream\":\"\\n\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":100,\"total\":100},\"id\":\"5e6ec7f28fb7\"}\n"];
52
+ for (const chunk of chunks) {
53
+ readable.push(chunk);
54
+ await pause(0.5);
55
+ }
56
+ }
57
+ async testData() {
58
+ const homedir = os.homedir();
59
+ _makes.Logger.info(homedir);
60
+ }
61
+ async test2() {
62
+ process.stdout.write("1 Line\n");
63
+ process.stdout.write("2 Line\n\n");
64
+ process.stdout.write(`\x1b[1A`);
65
+ process.stdout.write("3 Line\n");
66
+ process.stdout.write("4 Line\n");
67
+ process.stdout.write(`\x1b[s`);
68
+ process.stdout.write("5 Line\n");
69
+ process.stdout.write(`\x1b[1A`);
70
+ process.stdout.write("Not 5 Line\n");
71
+ process.stdout.write(`\x1b[u`);
72
+ process.stdout.write("6 Line\n");
73
+ }
74
+ }
75
+ exports.TestPlugin = TestPlugin;
@@ -0,0 +1,14 @@
1
+ export * from "./LocaltunnelPlugin";
2
+ export * from "./MaildevPlugin";
3
+ export * from "./MariadbPlugin";
4
+ export * from "./MongodbPlugin";
5
+ export * from "./NgrokPlugin";
6
+ export * from "./PageKitePlugin";
7
+ export * from "./PostgresPlugin";
8
+ export * from "./PresetPlugin";
9
+ export * from "./ProjectPlugin";
10
+ export * from "./ProxmoxPlugin";
11
+ export * from "./ProxyPlugin";
12
+ export * from "./RedisPlugin";
13
+ export * from "./ServeoPlugin";
14
+ export * from "./TestPlugin";
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _LocaltunnelPlugin = require("./LocaltunnelPlugin");
7
+ Object.keys(_LocaltunnelPlugin).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _LocaltunnelPlugin[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _LocaltunnelPlugin[key];
14
+ }
15
+ });
16
+ });
17
+ var _MaildevPlugin = require("./MaildevPlugin");
18
+ Object.keys(_MaildevPlugin).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _MaildevPlugin[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _MaildevPlugin[key];
25
+ }
26
+ });
27
+ });
28
+ var _MariadbPlugin = require("./MariadbPlugin");
29
+ Object.keys(_MariadbPlugin).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _MariadbPlugin[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _MariadbPlugin[key];
36
+ }
37
+ });
38
+ });
39
+ var _MongodbPlugin = require("./MongodbPlugin");
40
+ Object.keys(_MongodbPlugin).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _MongodbPlugin[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _MongodbPlugin[key];
47
+ }
48
+ });
49
+ });
50
+ var _NgrokPlugin = require("./NgrokPlugin");
51
+ Object.keys(_NgrokPlugin).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _NgrokPlugin[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _NgrokPlugin[key];
58
+ }
59
+ });
60
+ });
61
+ var _PageKitePlugin = require("./PageKitePlugin");
62
+ Object.keys(_PageKitePlugin).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _PageKitePlugin[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _PageKitePlugin[key];
69
+ }
70
+ });
71
+ });
72
+ var _PostgresPlugin = require("./PostgresPlugin");
73
+ Object.keys(_PostgresPlugin).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (key in exports && exports[key] === _PostgresPlugin[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function () {
79
+ return _PostgresPlugin[key];
80
+ }
81
+ });
82
+ });
83
+ var _PresetPlugin = require("./PresetPlugin");
84
+ Object.keys(_PresetPlugin).forEach(function (key) {
85
+ if (key === "default" || key === "__esModule") return;
86
+ if (key in exports && exports[key] === _PresetPlugin[key]) return;
87
+ Object.defineProperty(exports, key, {
88
+ enumerable: true,
89
+ get: function () {
90
+ return _PresetPlugin[key];
91
+ }
92
+ });
93
+ });
94
+ var _ProjectPlugin = require("./ProjectPlugin");
95
+ Object.keys(_ProjectPlugin).forEach(function (key) {
96
+ if (key === "default" || key === "__esModule") return;
97
+ if (key in exports && exports[key] === _ProjectPlugin[key]) return;
98
+ Object.defineProperty(exports, key, {
99
+ enumerable: true,
100
+ get: function () {
101
+ return _ProjectPlugin[key];
102
+ }
103
+ });
104
+ });
105
+ var _ProxmoxPlugin = require("./ProxmoxPlugin");
106
+ Object.keys(_ProxmoxPlugin).forEach(function (key) {
107
+ if (key === "default" || key === "__esModule") return;
108
+ if (key in exports && exports[key] === _ProxmoxPlugin[key]) return;
109
+ Object.defineProperty(exports, key, {
110
+ enumerable: true,
111
+ get: function () {
112
+ return _ProxmoxPlugin[key];
113
+ }
114
+ });
115
+ });
116
+ var _ProxyPlugin = require("./ProxyPlugin");
117
+ Object.keys(_ProxyPlugin).forEach(function (key) {
118
+ if (key === "default" || key === "__esModule") return;
119
+ if (key in exports && exports[key] === _ProxyPlugin[key]) return;
120
+ Object.defineProperty(exports, key, {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _ProxyPlugin[key];
124
+ }
125
+ });
126
+ });
127
+ var _RedisPlugin = require("./RedisPlugin");
128
+ Object.keys(_RedisPlugin).forEach(function (key) {
129
+ if (key === "default" || key === "__esModule") return;
130
+ if (key in exports && exports[key] === _RedisPlugin[key]) return;
131
+ Object.defineProperty(exports, key, {
132
+ enumerable: true,
133
+ get: function () {
134
+ return _RedisPlugin[key];
135
+ }
136
+ });
137
+ });
138
+ var _ServeoPlugin = require("./ServeoPlugin");
139
+ Object.keys(_ServeoPlugin).forEach(function (key) {
140
+ if (key === "default" || key === "__esModule") return;
141
+ if (key in exports && exports[key] === _ServeoPlugin[key]) return;
142
+ Object.defineProperty(exports, key, {
143
+ enumerable: true,
144
+ get: function () {
145
+ return _ServeoPlugin[key];
146
+ }
147
+ });
148
+ });
149
+ var _TestPlugin = require("./TestPlugin");
150
+ Object.keys(_TestPlugin).forEach(function (key) {
151
+ if (key === "default" || key === "__esModule") return;
152
+ if (key in exports && exports[key] === _TestPlugin[key]) return;
153
+ Object.defineProperty(exports, key, {
154
+ enumerable: true,
155
+ get: function () {
156
+ return _TestPlugin[key];
157
+ }
158
+ });
159
+ });
@@ -0,0 +1,18 @@
1
+ type TypeMap = {
2
+ [type: string]: string;
3
+ };
4
+ declare class AppConfigService {
5
+ protected pwd: string;
6
+ protected mapTypes: TypeMap;
7
+ constructor();
8
+ getPWD(): string;
9
+ setPWD(pwd: string): void;
10
+ getAllEnvVariables(): Promise<any>;
11
+ getEnvVariable(name: string, defaultValue?: string): Promise<any>;
12
+ setEnv(env: any): Promise<void>;
13
+ setEnvVariable(name: string, value: string | number): Promise<void>;
14
+ unsetEnv(...keys: string[]): Promise<void>;
15
+ registerProjectType(name: string, title?: string): void;
16
+ getProjectTypes(): TypeMap;
17
+ }
18
+ export { AppConfigService };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AppConfigService = void 0;
7
+ var _env = require("../env");
8
+ var _makes = require("../makes");
9
+ class AppConfigService {
10
+ mapTypes = {
11
+ image: "Image",
12
+ dockerfile: "Dockerfile"
13
+ };
14
+ constructor() {
15
+ this.pwd = process.cwd() || process.env.PWD;
16
+ }
17
+ getPWD() {
18
+ return this.pwd;
19
+ }
20
+ setPWD(pwd) {
21
+ this.pwd = pwd;
22
+ }
23
+ async getAllEnvVariables() {
24
+ const {
25
+ env = {}
26
+ } = await _makes.FS.readJSON(_env.MAP_PATH);
27
+ return env;
28
+ }
29
+ async getEnvVariable(name, defaultValue) {
30
+ const {
31
+ [name]: value = defaultValue
32
+ } = await this.getAllEnvVariables();
33
+ if (value === null) {
34
+ return defaultValue;
35
+ }
36
+ return value;
37
+ }
38
+ async setEnv(env) {
39
+ const config = await _makes.FS.readJSON(_env.MAP_PATH);
40
+ await _makes.FS.writeJSON(_env.MAP_PATH, {
41
+ ...config,
42
+ env: {
43
+ ...(config.env || {}),
44
+ ...env
45
+ }
46
+ });
47
+ }
48
+ async setEnvVariable(name, value) {
49
+ const config = await _makes.FS.readJSON(_env.MAP_PATH);
50
+ await _makes.FS.writeJSON(_env.MAP_PATH, {
51
+ ...config,
52
+ env: {
53
+ ...(config.env || {}),
54
+ [name]: value
55
+ }
56
+ });
57
+ }
58
+ async unsetEnv(...keys) {
59
+ const config = await _makes.FS.readJSON(_env.MAP_PATH);
60
+ await _makes.FS.writeJSON(_env.MAP_PATH, {
61
+ ...config,
62
+ env: Object.keys(config.env || {}).reduce((res, key) => {
63
+ if (!keys.includes(key)) {
64
+ res[key] = config.env[key];
65
+ }
66
+ return res;
67
+ }, {})
68
+ });
69
+ }
70
+ registerProjectType(name, title) {
71
+ this.mapTypes[name] = title || name;
72
+ }
73
+ getProjectTypes() {
74
+ return this.mapTypes;
75
+ }
76
+ }
77
+ exports.AppConfigService = AppConfigService;
@@ -0,0 +1,13 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from "events";
3
+ type EventHandle = (...args: any[]) => Promise<void> | void;
4
+ declare class AppEventsService {
5
+ protected emitter: EventEmitter;
6
+ protected handles: ({
7
+ [event: string]: EventHandle[];
8
+ });
9
+ on(event: string, handle: EventHandle): () => void;
10
+ off(event: string, handle: EventHandle): void;
11
+ emit(event: string, ...args: any[]): Promise<void>;
12
+ }
13
+ export { AppEventsService };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AppEventsService = void 0;
7
+ var _events = require("events");
8
+ class AppEventsService {
9
+ emitter = new _events.EventEmitter();
10
+ handles = {};
11
+ on(event, handle) {
12
+ this.handles[event] = [...(this.handles[event] || []), handle];
13
+ return () => {
14
+ this.handles[event] = this.handles[event].filter(filterHandle => {
15
+ return filterHandle !== handle;
16
+ });
17
+ };
18
+ }
19
+ off(event, handle) {
20
+ //
21
+ }
22
+ async emit(event, ...args) {
23
+ const handles = this.handles[event] || [];
24
+ for (const i in handles) {
25
+ await handles[i](...args);
26
+ }
27
+ }
28
+ }
29
+ exports.AppEventsService = AppEventsService;
@@ -0,0 +1,13 @@
1
+ import { Project } from "src/models";
2
+ import { AppConfigService } from "./AppConfigService";
3
+ import { AppEventsService } from "./AppEventsService";
4
+ declare class ProjectService {
5
+ protected appConfigService: AppConfigService;
6
+ protected appEventsService: AppEventsService;
7
+ constructor(appConfigService: AppConfigService, appEventsService: AppEventsService);
8
+ cdProject(name: string): Promise<void>;
9
+ get(): Promise<Project>;
10
+ start(): Promise<void>;
11
+ stop(): Promise<void>;
12
+ }
13
+ export { ProjectService };