@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,260 +0,0 @@
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;
@@ -1,10 +0,0 @@
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 };
@@ -1,75 +0,0 @@
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;
@@ -1,6 +0,0 @@
1
- type Options = {
2
- message?: string;
3
- default?: boolean;
4
- };
5
- export declare const promptConfirm: (options: Options) => Promise<any>;
6
- export { Options as PromptConfirmOptions };
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.promptConfirm = void 0;
7
- var _inquirer = require("inquirer");
8
- const promptConfirm = async options => {
9
- const {
10
- message,
11
- default: defaultValue = true
12
- } = options;
13
- const res = await (0, _inquirer.prompt)({
14
- type: "confirm",
15
- name: "confirm",
16
- message,
17
- default: defaultValue
18
- });
19
- return res.confirm;
20
- };
21
- exports.promptConfirm = promptConfirm;
@@ -1,16 +0,0 @@
1
- import { PromptConfirmOptions } from "./promptConfirm";
2
- import { PromptSelectOptions } from "./promptSelect";
3
- import { PromptTextOptions } from "./promptText";
4
- type Values = {
5
- [key: string]: string;
6
- };
7
- type Option = ({
8
- type: "boolean";
9
- } & PromptConfirmOptions) | PromptTextOptions | ({
10
- type: "select";
11
- } & PromptSelectOptions);
12
- type Options<T = unknown> = {
13
- [key: string]: Option & T;
14
- };
15
- export declare const promptGroup: (values: Values, options: Options) => Promise<Values>;
16
- export { Options as PromptGroupOptions };
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.promptGroup = void 0;
7
- var _promptConfirm = require("./promptConfirm");
8
- var _promptSelect = require("./promptSelect");
9
- var _promptText = require("./promptText");
10
- const promptGroup = async (values, options) => {
11
- for (const key in options) {
12
- const value = values[key];
13
- const option = options[key];
14
- switch (option.type) {
15
- case "boolean":
16
- values[key] = await (0, _promptConfirm.promptConfirm)({
17
- ...option,
18
- default: typeof value !== "undefined" ? value === "true" : true
19
- });
20
- values[key] = values[key].toString();
21
- break;
22
- case "string":
23
- case "integer":
24
- values[key] = await (0, _promptText.promptText)({
25
- ...option,
26
- default: typeof value !== "undefined" ? value : option.default || ""
27
- });
28
- break;
29
- case "select":
30
- values[key] = await (0, _promptSelect.promptSelect)({
31
- ...option,
32
- default: typeof value !== "undefined" ? value : option.default || ""
33
- });
34
- break;
35
- }
36
- }
37
- return values;
38
- };
39
- exports.promptGroup = promptGroup;
@@ -1,12 +0,0 @@
1
- type Options = {
2
- message?: string;
3
- options: string[] | {
4
- [value: string]: string;
5
- } | {
6
- label?: string;
7
- value: string;
8
- }[];
9
- default?: string;
10
- };
11
- declare const promptSelect: (props: Options) => Promise<any>;
12
- export { promptSelect, Options as PromptSelectOptions };
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.promptSelect = void 0;
7
- var inquirer = _interopRequireWildcard(require("inquirer"));
8
- 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); }
9
- 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; }
10
- const promptSelect = async props => {
11
- const {
12
- message = "Select: ",
13
- options: rawOptions,
14
- default: value
15
- } = props;
16
- const options = Array.isArray(rawOptions) ? rawOptions.map(option => {
17
- return {
18
- label: typeof option === "string" ? option : option.label || option.value,
19
- value: typeof option === "string" ? option : option.value
20
- };
21
- }) : Object.keys(rawOptions).map(value => {
22
- return {
23
- label: rawOptions[value],
24
- value
25
- };
26
- });
27
- const defaultOption = options.find(option => {
28
- return option.value === value;
29
- });
30
- const res = await inquirer.prompt({
31
- type: "list",
32
- name: "value",
33
- message: `${message}: `,
34
- choices: options.map(option => {
35
- return option.label || option.value;
36
- }),
37
- default: defaultOption ? defaultOption.label || defaultOption.value : ""
38
- });
39
- const option = options.find(option => {
40
- return (option.label || option.value) === res.value;
41
- });
42
- if (option) {
43
- return option.value;
44
- }
45
- return "";
46
- };
47
- exports.promptSelect = promptSelect;
@@ -1,13 +0,0 @@
1
- import { Transformer } from "inquirer";
2
- type Options = {
3
- required?: boolean;
4
- message?: string;
5
- label?: string;
6
- prefix?: string;
7
- suffix?: string;
8
- type?: "string" | "integer";
9
- default?: string;
10
- transformer?: Transformer;
11
- };
12
- export declare const promptText: (props: Options) => Promise<any>;
13
- export { Options as PromptTextOptions };
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.promptText = void 0;
7
- var _inquirer = require("inquirer");
8
- var _chalk = _interopRequireDefault(require("chalk"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- const promptText = async props => {
11
- const {
12
- required,
13
- message = "Prompt",
14
- label = message || "Prompt",
15
- prefix = "",
16
- suffix = "",
17
- type = "string",
18
- default: defaultValue,
19
- transformer
20
- } = props;
21
- const res = await (0, _inquirer.prompt)({
22
- message: `${label}: `,
23
- name: "value",
24
- type: "input",
25
- default: defaultValue,
26
- validate(value) {
27
- if (required) {
28
- if (typeof value === "undefined" || value === "") {
29
- return "Mandatory value";
30
- }
31
- }
32
- if (type === "integer") {
33
- if (isNaN(parseInt(value)) || parseInt(value).toString() !== value) {
34
- return "Should be integer";
35
- }
36
- }
37
- return true;
38
- },
39
- transformer: transformer || (value => {
40
- if (!prefix && !suffix) {
41
- return value;
42
- }
43
- if (suffix) {
44
- setTimeout(() => {
45
- process.stdout.write(`\x1b[${suffix.length}D`);
46
- }, 0);
47
- }
48
- return `${_chalk.default.gray(prefix)}${value}${_chalk.default.gray(suffix)}`;
49
- })
50
- });
51
- return res.value;
52
- };
53
- exports.promptText = promptText;
@@ -1,9 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- */
5
-
6
- $cfg['DefaultLang'] = 'uk';
7
- $cfg['UploadDir'] = '/etc/phpmyadmin/upload';
8
- $cfg['SaveDir'] = '/etc/phpmyadmin/save';
9
- $cfg['DefaultConnectionCollation'] = 'utf8_general_ci';
@@ -1,17 +0,0 @@
1
- FROM ubuntu:latest
2
-
3
- ARG USER=user
4
-
5
- RUN apt-get update && apt-get install -y autossh
6
- RUN useradd -m -d /home/$USER -s /bin/bash $USER
7
- RUN mkdir -p /home/$USER/.ssh
8
- RUN chown -R $USER:$USER /home/$USER
9
-
10
- USER $USER
11
-
12
- RUN ssh-keygen -q -t rsa -N '' -f /home/$USER/.ssh/id_rsa
13
-
14
- RUN chmod 700 /home/$USER/.ssh
15
- RUN chmod 600 /home/$USER/.ssh/*
16
-
17
- CMD ["/bin/bash"]