@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.
- package/LICENSE +21 -0
- package/README.md +155 -0
- package/bin/ws.js +13 -0
- package/lib/App.d.ts +13 -0
- package/lib/App.js +52 -0
- package/lib/controllers/ImageController.d.ts +8 -0
- package/lib/controllers/ImageController.js +29 -0
- package/lib/controllers/ProjectController.d.ts +64 -0
- package/lib/controllers/ProjectController.js +561 -0
- package/lib/controllers/index.d.ts +2 -0
- package/lib/controllers/index.js +27 -0
- package/lib/env.d.ts +7 -0
- package/lib/env.js +24 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +31 -0
- package/lib/makes/Controller.d.ts +5 -0
- package/lib/makes/Controller.js +12 -0
- package/lib/makes/Docker.d.ts +58 -0
- package/lib/makes/Docker.js +418 -0
- package/lib/makes/FS.d.ts +37 -0
- package/lib/makes/FS.js +317 -0
- package/lib/makes/LineConvertStream.d.ts +13 -0
- package/lib/makes/LineConvertStream.js +45 -0
- package/lib/makes/Logger.d.ts +7 -0
- package/lib/makes/Logger.js +39 -0
- package/lib/makes/Model.d.ts +5 -0
- package/lib/makes/Model.js +16 -0
- package/lib/makes/MySQL.d.ts +15 -0
- package/lib/makes/MySQL.js +31 -0
- package/lib/makes/Plugin.d.ts +13 -0
- package/lib/makes/Plugin.js +43 -0
- package/lib/makes/Repository.d.ts +11 -0
- package/lib/makes/Repository.js +25 -0
- package/lib/makes/index.d.ts +6 -0
- package/lib/makes/index.js +71 -0
- package/lib/models/Preset.d.ts +19 -0
- package/lib/models/Preset.js +60 -0
- package/lib/models/Project.d.ts +38 -0
- package/lib/models/Project.js +151 -0
- package/lib/models/index.d.ts +2 -0
- package/lib/models/index.js +27 -0
- package/lib/plugins/LocaltunnelPlugin.d.ts +36 -0
- package/lib/plugins/LocaltunnelPlugin.js +273 -0
- package/lib/plugins/MaildevPlugin.d.ts +10 -0
- package/lib/plugins/MaildevPlugin.js +45 -0
- package/lib/plugins/MariadbPlugin.d.ts +25 -0
- package/lib/plugins/MariadbPlugin.js +297 -0
- package/lib/plugins/MongodbPlugin.d.ts +20 -0
- package/lib/plugins/MongodbPlugin.js +271 -0
- package/lib/plugins/NgrokPlugin.d.ts +37 -0
- package/lib/plugins/NgrokPlugin.js +248 -0
- package/lib/plugins/PageKitePlugin.d.ts +31 -0
- package/lib/plugins/PageKitePlugin.js +158 -0
- package/lib/plugins/PostgresPlugin.d.ts +16 -0
- package/lib/plugins/PostgresPlugin.js +94 -0
- package/lib/plugins/PresetPlugin.d.ts +19 -0
- package/lib/plugins/PresetPlugin.js +164 -0
- package/lib/plugins/ProjectPlugin.d.ts +12 -0
- package/lib/plugins/ProjectPlugin.js +54 -0
- package/lib/plugins/ProxmoxPlugin.d.ts +9 -0
- package/lib/plugins/ProxmoxPlugin.js +55 -0
- package/lib/plugins/ProxyPlugin.d.ts +33 -0
- package/lib/plugins/ProxyPlugin.js +257 -0
- package/lib/plugins/RedisPlugin.d.ts +10 -0
- package/lib/plugins/RedisPlugin.js +42 -0
- package/lib/plugins/ServeoPlugin.d.ts +36 -0
- package/lib/plugins/ServeoPlugin.js +260 -0
- package/lib/plugins/TestPlugin.d.ts +10 -0
- package/lib/plugins/TestPlugin.js +75 -0
- package/lib/plugins/index.d.ts +14 -0
- package/lib/plugins/index.js +159 -0
- package/lib/services/AppConfigService.d.ts +18 -0
- package/lib/services/AppConfigService.js +77 -0
- package/lib/services/AppEventsService.d.ts +13 -0
- package/lib/services/AppEventsService.js +29 -0
- package/lib/services/ProjectService.d.ts +13 -0
- package/lib/services/ProjectService.js +91 -0
- package/lib/services/index.d.ts +3 -0
- package/lib/services/index.js +38 -0
- package/lib/types/Config.d.ts +11 -0
- package/lib/types/Config.js +5 -0
- package/lib/types/EnvConfig.d.ts +3 -0
- package/lib/types/EnvConfig.js +5 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +27 -0
- package/lib/utils/buildOptions.d.ts +1 -0
- package/lib/utils/buildOptions.js +12 -0
- package/lib/utils/demuxOutput.d.ts +2 -0
- package/lib/utils/demuxOutput.js +25 -0
- package/lib/utils/escapeRegExp.d.ts +2 -0
- package/lib/utils/escapeRegExp.js +10 -0
- package/lib/utils/exec.d.ts +2 -0
- package/lib/utils/exec.js +44 -0
- package/lib/utils/fetch.d.ts +5 -0
- package/lib/utils/fetch.js +37 -0
- package/lib/utils/followProgress.d.ts +6 -0
- package/lib/utils/followProgress.js +80 -0
- package/lib/utils/format-size-units.d.ts +1 -0
- package/lib/utils/format-size-units.js +19 -0
- package/lib/utils/get-config.d.ts +2 -0
- package/lib/utils/get-config.js +20 -0
- package/lib/utils/get-cursor-position.d.ts +4 -0
- package/lib/utils/get-cursor-position.js +34 -0
- package/lib/utils/image-build.d.ts +13 -0
- package/lib/utils/image-build.js +34 -0
- package/lib/utils/index.d.ts +21 -0
- package/lib/utils/index.js +236 -0
- package/lib/utils/injectVariables.d.ts +5 -0
- package/lib/utils/injectVariables.js +17 -0
- package/lib/utils/parse-table.d.ts +2 -0
- package/lib/utils/parse-table.js +27 -0
- package/lib/utils/promptConfirm.d.ts +6 -0
- package/lib/utils/promptConfirm.js +21 -0
- package/lib/utils/promptGroup.d.ts +16 -0
- package/lib/utils/promptGroup.js +39 -0
- package/lib/utils/promptSelect.d.ts +12 -0
- package/lib/utils/promptSelect.js +47 -0
- package/lib/utils/promptText.d.ts +13 -0
- package/lib/utils/promptText.js +53 -0
- package/lib/utils/set-config.d.ts +2 -0
- package/lib/utils/set-config.js +18 -0
- package/lib/utils/spawn.d.ts +2 -0
- package/lib/utils/spawn.js +24 -0
- package/lib/utils/tty.d.ts +2 -0
- package/lib/utils/tty.js +10 -0
- package/lib/utils/volumeFormat.d.ts +6 -0
- package/lib/utils/volumeFormat.js +15 -0
- package/lib/utils/volumeParse.d.ts +2 -0
- package/lib/utils/volumeParse.js +16 -0
- package/package.json +90 -0
- package/plugins/localtunnel/Dockerfile +37 -0
- package/plugins/localtunnel/Ubuntu.dockerfile +34 -0
- package/plugins/localtunnel/config.json +3 -0
- package/plugins/maildev/Dockerfile +5 -0
- package/plugins/maildev/config.json +3 -0
- package/plugins/mariadb/admin/conf/config.user.inc.php +9 -0
- package/plugins/ngrok/Dockerfile +2 -0
- package/plugins/pagekite/Dockerfile +3 -0
- package/plugins/proxmox/Dockerfile +35 -0
- package/plugins/proxy/Dockerfile +7 -0
- package/plugins/proxy/config.json +3 -0
- package/plugins/serveo/Dockerfile +17 -0
- package/presets/apache/.docker/apache2/apache2.conf +230 -0
- package/presets/apache/.docker/apache2/mods-available/mpm_prefork.conf +16 -0
- package/presets/apache/.docker/apache2/sites-available/000-default.conf.conf +21 -0
- package/presets/apache/Dockerfile +110 -0
- package/presets/apache/bin/compare-version +3 -0
- package/presets/apache/config.json +47 -0
- package/presets/go/Dockerfile +19 -0
- package/presets/go/config.json +13 -0
- package/presets/node/Dockerfile +37 -0
- package/presets/node/config.json +36 -0
- package/presets/php-apache/Dockerfile +133 -0
- package/presets/php-apache/bin/compare-version +3 -0
- package/presets/php-apache/config.json +56 -0
- package/presets/php-apache/etc/apache2/apache2.conf +230 -0
- package/presets/php-apache/etc/apache2/mods-available/mpm_prefork.conf +16 -0
- package/presets/php-apache/etc/apache2/sites-available/000-default.conf +21 -0
- package/presets/shopify/Dockerfile +160 -0
- package/presets/shopify/bin/compare-version +3 -0
- package/presets/shopify/config.json +24 -0
- package/presets/shopify/etc/apache2/apache2.conf +230 -0
- package/presets/shopify/etc/apache2/mods-available/mpm_prefork.conf +16 -0
- package/presets/shopify/etc/apache2/sites-available/000-default.conf +21 -0
package/lib/makes/FS.js
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FS = void 0;
|
|
7
|
+
var fs = _interopRequireWildcard(require("fs"));
|
|
8
|
+
var Path = _interopRequireWildcard(require("path"));
|
|
9
|
+
var _readableStream = require("readable-stream");
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
class FS {
|
|
13
|
+
static async access(path) {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
fs.access(path, err => {
|
|
16
|
+
if (!err) {
|
|
17
|
+
resolve(null);
|
|
18
|
+
} else {
|
|
19
|
+
reject(err);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Asynchronously tests whether or not the given path exists by checking with the file system.
|
|
27
|
+
* @param path path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
|
28
|
+
*/
|
|
29
|
+
static async exists(path) {
|
|
30
|
+
return new Promise(resolve => {
|
|
31
|
+
fs.exists(path, exists => {
|
|
32
|
+
resolve(exists);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
static existsSync(path) {
|
|
37
|
+
return fs.existsSync(path);
|
|
38
|
+
}
|
|
39
|
+
static async mkdir(dirPath, options = {}) {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
fs.mkdir(dirPath, options, err => {
|
|
42
|
+
if (!err) {
|
|
43
|
+
resolve();
|
|
44
|
+
} else {
|
|
45
|
+
reject(err);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
static mkdirSync(path, options) {
|
|
51
|
+
return fs.mkdirSync(path, options);
|
|
52
|
+
}
|
|
53
|
+
static async readdir(path) {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
fs.readdir(path, (err, files) => {
|
|
56
|
+
if (!err) {
|
|
57
|
+
resolve(files);
|
|
58
|
+
} else {
|
|
59
|
+
reject(err);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
static async readdirFiles(path, options) {
|
|
65
|
+
const {
|
|
66
|
+
recursive = false
|
|
67
|
+
} = options || {};
|
|
68
|
+
if (recursive) {
|
|
69
|
+
const names = await FS.readdir(path);
|
|
70
|
+
let res = [];
|
|
71
|
+
for (const name of names) {
|
|
72
|
+
const filePath = Path.join(path, name);
|
|
73
|
+
let sub = [name];
|
|
74
|
+
const stats = await FS.stat(filePath);
|
|
75
|
+
if (stats.isDirectory()) {
|
|
76
|
+
sub = (await FS.readdirFiles(filePath, {
|
|
77
|
+
recursive: true
|
|
78
|
+
})).map(subName => {
|
|
79
|
+
return Path.join(name, subName);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
res = [...res, ...sub];
|
|
83
|
+
}
|
|
84
|
+
return res;
|
|
85
|
+
}
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
fs.readdir(path, {
|
|
88
|
+
withFileTypes: true
|
|
89
|
+
}, (err, files) => {
|
|
90
|
+
if (err) {
|
|
91
|
+
return reject(err);
|
|
92
|
+
}
|
|
93
|
+
const names = files.filter(dirent => {
|
|
94
|
+
return dirent.isFile();
|
|
95
|
+
}).map(dirent => {
|
|
96
|
+
return dirent.name;
|
|
97
|
+
});
|
|
98
|
+
resolve(names);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
static async appendFile(path, data, options) {
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
fs.appendFile(path, data, options, (error, data) => {
|
|
105
|
+
if (error) {
|
|
106
|
+
reject(error);
|
|
107
|
+
} else {
|
|
108
|
+
resolve(data);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
static appendFileSync(path, data, options) {
|
|
114
|
+
return fs.appendFileSync(path, data, options);
|
|
115
|
+
}
|
|
116
|
+
static read() {
|
|
117
|
+
//
|
|
118
|
+
}
|
|
119
|
+
static async readBytes(filePath, position = 0, size) {
|
|
120
|
+
if (position < 0 && typeof size === "undefined") {
|
|
121
|
+
const stats = await FS.stat(filePath);
|
|
122
|
+
size = BigInt(position) * -1n;
|
|
123
|
+
position = BigInt(stats.size) - size;
|
|
124
|
+
if (position < 0n) {
|
|
125
|
+
position = 0;
|
|
126
|
+
}
|
|
127
|
+
} else if (typeof size === "undefined") {
|
|
128
|
+
const stats = await FS.stat(filePath);
|
|
129
|
+
if (typeof stats.size !== "bigint" && typeof position !== "bigint") {
|
|
130
|
+
size = stats.size - position;
|
|
131
|
+
} else {
|
|
132
|
+
size = BigInt(stats.size) - BigInt(position);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (size < 0n) {
|
|
136
|
+
// throw Error(`Buffer size ${size}`);
|
|
137
|
+
|
|
138
|
+
return Buffer.alloc(0);
|
|
139
|
+
}
|
|
140
|
+
const buffer = Buffer.alloc(Number(size));
|
|
141
|
+
return new Promise((resolve, reject) => {
|
|
142
|
+
fs.open(filePath, (err, file) => {
|
|
143
|
+
if (err) {
|
|
144
|
+
reject(err);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
fs.read(file, buffer, 0, buffer.length, position, (err, bytesRead, buffer) => {
|
|
148
|
+
if (err) {
|
|
149
|
+
reject(err);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
resolve(buffer);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
static async readFile(filePath) {
|
|
158
|
+
return new Promise((resolve, reject) => {
|
|
159
|
+
fs.readFile(filePath, (err, data) => {
|
|
160
|
+
if (!err) {
|
|
161
|
+
resolve(data);
|
|
162
|
+
} else {
|
|
163
|
+
reject(err);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
static readFileSync(filePath) {
|
|
169
|
+
return fs.readFileSync(filePath);
|
|
170
|
+
}
|
|
171
|
+
static async writeFile(filePath, data, options) {
|
|
172
|
+
return new Promise((resolve, reject) => {
|
|
173
|
+
fs.writeFile(filePath, data, options, err => {
|
|
174
|
+
if (!err) {
|
|
175
|
+
resolve();
|
|
176
|
+
} else {
|
|
177
|
+
reject(err);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
static writeFileSync(path, data, options) {
|
|
183
|
+
return fs.writeFileSync(path, data, options);
|
|
184
|
+
}
|
|
185
|
+
static createWriteStream(path) {
|
|
186
|
+
return fs.createWriteStream(path);
|
|
187
|
+
}
|
|
188
|
+
static async readJSON(filePath) {
|
|
189
|
+
return FS.readFile(filePath).then(res => {
|
|
190
|
+
try {
|
|
191
|
+
const str = res.toString();
|
|
192
|
+
return JSON.parse(str);
|
|
193
|
+
} catch (ignore) {
|
|
194
|
+
return {};
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
static async writeJSON(filePath, data) {
|
|
199
|
+
const json = JSON.stringify(data, null, 4);
|
|
200
|
+
return FS.writeFile(filePath, json);
|
|
201
|
+
}
|
|
202
|
+
static async unlink(filePath) {
|
|
203
|
+
return new Promise((resolve, reject) => {
|
|
204
|
+
fs.unlink(filePath, err => {
|
|
205
|
+
if (!err) {
|
|
206
|
+
resolve();
|
|
207
|
+
} else {
|
|
208
|
+
reject(err);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
static watch(filename, options) {
|
|
214
|
+
return fs.watch(filename, options);
|
|
215
|
+
}
|
|
216
|
+
static stat(filename, options) {
|
|
217
|
+
return new Promise((resolve, reject) => {
|
|
218
|
+
fs.stat(filename, options, (err, stats) => {
|
|
219
|
+
if (err) {
|
|
220
|
+
reject(err);
|
|
221
|
+
} else {
|
|
222
|
+
resolve(stats);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
static createReadStream(path, options) {
|
|
228
|
+
return fs.createReadStream(path, options);
|
|
229
|
+
}
|
|
230
|
+
static createReadLinesStream(path, count) {
|
|
231
|
+
const write = new _readableStream.PassThrough();
|
|
232
|
+
(async () => {
|
|
233
|
+
if (typeof count === "undefined" || count > 0) {
|
|
234
|
+
const stats = await FS.stat(path);
|
|
235
|
+
const resLines = [""];
|
|
236
|
+
let position = 0n;
|
|
237
|
+
while (position < stats.size) {
|
|
238
|
+
let size = BigInt(count ? 64 * count : 255);
|
|
239
|
+
if (position + size > stats.size) {
|
|
240
|
+
size = BigInt(stats.size) - position;
|
|
241
|
+
}
|
|
242
|
+
const buffer = await FS.readBytes(path, position, size);
|
|
243
|
+
const lines = buffer.toString("utf-8").split("\n");
|
|
244
|
+
position += size;
|
|
245
|
+
for (let i = 0; i < lines.length; i++) {
|
|
246
|
+
const line = lines[i];
|
|
247
|
+
if (i === 0) {
|
|
248
|
+
resLines[resLines.length - 1] = (resLines[resLines.length - 1] || "") + line;
|
|
249
|
+
} else {
|
|
250
|
+
resLines.push(line);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (resLines.length > count + 1) {
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
for (let i = 0; i < (count || resLines.length); i++) {
|
|
258
|
+
write.write(resLines[i]);
|
|
259
|
+
}
|
|
260
|
+
} else if (count < 0) {
|
|
261
|
+
const stats = await FS.stat(path);
|
|
262
|
+
const resLines = [""];
|
|
263
|
+
let position = BigInt(stats.size);
|
|
264
|
+
while (position > 0n) {
|
|
265
|
+
// let size = BigInt(64 * count * -1);
|
|
266
|
+
let size = BigInt(2 * count * -1);
|
|
267
|
+
position -= size;
|
|
268
|
+
if (position < 0) {
|
|
269
|
+
size = position + size;
|
|
270
|
+
position = 0n;
|
|
271
|
+
}
|
|
272
|
+
const buffer = await FS.readBytes(path, position, size);
|
|
273
|
+
const lines = buffer.toString("utf-8").split("\n").reverse();
|
|
274
|
+
for (let i = 0; i < lines.length; i++) {
|
|
275
|
+
const line = lines[i];
|
|
276
|
+
if (i === 0) {
|
|
277
|
+
resLines[0] = line + (resLines[0] || "");
|
|
278
|
+
} else {
|
|
279
|
+
resLines.unshift(line);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (resLines.length > count * -1 + 1) {
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const lines = resLines.slice(count - 1);
|
|
287
|
+
for (let i = 0; i < lines.length; i++) {
|
|
288
|
+
write.write(lines[i]);
|
|
289
|
+
}
|
|
290
|
+
write.end();
|
|
291
|
+
}
|
|
292
|
+
})();
|
|
293
|
+
return write;
|
|
294
|
+
}
|
|
295
|
+
static async copyFile(src, dest) {
|
|
296
|
+
new Promise((resolve, reject) => {
|
|
297
|
+
fs.copyFile(src, dest, err => {
|
|
298
|
+
if (!err) {
|
|
299
|
+
resolve(undefined);
|
|
300
|
+
} else {
|
|
301
|
+
reject(err);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
static async rm(path, options) {
|
|
307
|
+
return new Promise((resolve, reject) => {
|
|
308
|
+
fs.rm(path, options, err => {
|
|
309
|
+
if (err) {
|
|
310
|
+
return reject(err);
|
|
311
|
+
}
|
|
312
|
+
return resolve(undefined);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
exports.FS = FS;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Readable } from "stream";
|
|
4
|
+
import { Mutex } from "async-mutex";
|
|
5
|
+
declare class LineConvertStream extends Readable {
|
|
6
|
+
protected stream: NodeJS.ReadableStream;
|
|
7
|
+
protected buf: string;
|
|
8
|
+
protected mutex: Mutex;
|
|
9
|
+
constructor(stream: NodeJS.ReadableStream);
|
|
10
|
+
_read(size: number): void;
|
|
11
|
+
process(chunk: any): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export { LineConvertStream };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LineConvertStream = void 0;
|
|
7
|
+
var _stream = require("stream");
|
|
8
|
+
var _asyncMutex = require("async-mutex");
|
|
9
|
+
class LineConvertStream extends _stream.Readable {
|
|
10
|
+
buf = "";
|
|
11
|
+
mutex = new _asyncMutex.Mutex();
|
|
12
|
+
constructor(stream) {
|
|
13
|
+
super();
|
|
14
|
+
this.stream = stream;
|
|
15
|
+
this.stream.on("data", chunk => this.process(chunk));
|
|
16
|
+
this.stream.on("end", () => {
|
|
17
|
+
this.push(null);
|
|
18
|
+
});
|
|
19
|
+
this.stream.on("close", () => {
|
|
20
|
+
this.destroy();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_read(size) {
|
|
24
|
+
//
|
|
25
|
+
}
|
|
26
|
+
async process(chunk) {
|
|
27
|
+
await this.mutex.acquire();
|
|
28
|
+
this.buf += chunk.toString();
|
|
29
|
+
try {
|
|
30
|
+
let pos;
|
|
31
|
+
while ((pos = this.buf.indexOf("\n")) >= 0) {
|
|
32
|
+
if (pos === 0) {
|
|
33
|
+
this.buf = this.buf.slice(0);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const line = this.buf.slice(0, pos);
|
|
37
|
+
this.buf = this.buf.slice(pos + 1);
|
|
38
|
+
this.push(line);
|
|
39
|
+
}
|
|
40
|
+
} finally {
|
|
41
|
+
this.mutex.release();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.LineConvertStream = LineConvertStream;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Logger = void 0;
|
|
7
|
+
var Path = _interopRequireWildcard(require("path"));
|
|
8
|
+
var _format = _interopRequireDefault(require("date-fns/format"));
|
|
9
|
+
var _env = require("../env");
|
|
10
|
+
var _FS = require("./FS");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
class Logger {
|
|
15
|
+
static log(...data) {
|
|
16
|
+
Logger._log("log", ...data);
|
|
17
|
+
}
|
|
18
|
+
static info(...data) {
|
|
19
|
+
Logger._log("info", ...data);
|
|
20
|
+
}
|
|
21
|
+
static warning(...data) {
|
|
22
|
+
Logger._log("warning", ...data);
|
|
23
|
+
}
|
|
24
|
+
static error(...data) {
|
|
25
|
+
Logger._log("error", ...data);
|
|
26
|
+
}
|
|
27
|
+
static _log(type, ...data) {
|
|
28
|
+
const time = (0, _format.default)(new Date(), "yyyy-MM-dd hh:mm:ss");
|
|
29
|
+
const logPath = Path.join(_env.DATA_DIR, "ws.log");
|
|
30
|
+
const logData = data.map(item => {
|
|
31
|
+
return typeof item !== "string" ? JSON.stringify(item) : item;
|
|
32
|
+
}).join(" ");
|
|
33
|
+
if (!_FS.FS.existsSync(logPath)) {
|
|
34
|
+
_FS.FS.writeFileSync(logPath, "");
|
|
35
|
+
}
|
|
36
|
+
_FS.FS.appendFileSync(logPath, `[${time}] ${type}: ${logData}\n`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.Logger = Logger;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Model = void 0;
|
|
7
|
+
class Model {
|
|
8
|
+
attributes = {};
|
|
9
|
+
constructor(attributes = {}) {
|
|
10
|
+
this.attributes = attributes;
|
|
11
|
+
}
|
|
12
|
+
async save() {
|
|
13
|
+
//
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.Model = Model;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type Options = string | {
|
|
2
|
+
ssl?: boolean;
|
|
3
|
+
host?: string;
|
|
4
|
+
port?: number;
|
|
5
|
+
user?: string;
|
|
6
|
+
password?: string;
|
|
7
|
+
database?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class MySQL {
|
|
10
|
+
protected connection: any;
|
|
11
|
+
protected options: Options;
|
|
12
|
+
constructor(options: Options);
|
|
13
|
+
query(sql: string): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MySQL = void 0;
|
|
7
|
+
// import {createConnection} from "mysql";
|
|
8
|
+
|
|
9
|
+
class MySQL {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
// this.connection = createConnection(options);
|
|
12
|
+
}
|
|
13
|
+
async query(sql) {
|
|
14
|
+
// this.connection.connect();
|
|
15
|
+
//
|
|
16
|
+
// const res = await new Promise((resolve, reject) => {
|
|
17
|
+
// this.connection.query(sql, (err, res) => {
|
|
18
|
+
// if(err) {
|
|
19
|
+
// return reject(err);
|
|
20
|
+
// }
|
|
21
|
+
//
|
|
22
|
+
// return resolve(res);
|
|
23
|
+
// });
|
|
24
|
+
// });
|
|
25
|
+
//
|
|
26
|
+
// this.connection.end();
|
|
27
|
+
//
|
|
28
|
+
// return res;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.MySQL = MySQL;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Cli } from "@kearisp/cli";
|
|
2
|
+
import { Controller } from "src/makes/Controller";
|
|
3
|
+
declare class Plugin extends Controller {
|
|
4
|
+
protected certsDir: string;
|
|
5
|
+
protected dataDir: string;
|
|
6
|
+
protected pluginDir: string;
|
|
7
|
+
constructor(name: string);
|
|
8
|
+
install(cli: Cli): void;
|
|
9
|
+
certsPath(...paths: string[]): string;
|
|
10
|
+
dataPath(...paths: string[]): string;
|
|
11
|
+
pluginPath(...paths: string[]): string;
|
|
12
|
+
}
|
|
13
|
+
export { Plugin };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Plugin = void 0;
|
|
7
|
+
var Path = _interopRequireWildcard(require("path"));
|
|
8
|
+
var _env = require("../env");
|
|
9
|
+
var _Controller = require("./Controller");
|
|
10
|
+
var _FS = require("./FS");
|
|
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 Plugin extends _Controller.Controller {
|
|
14
|
+
constructor(name) {
|
|
15
|
+
super();
|
|
16
|
+
this.certsDir = Path.join(_env.DATA_DIR, "certs");
|
|
17
|
+
this.dataDir = Path.join(_env.DATA_DIR, "plugins", name);
|
|
18
|
+
this.pluginDir = Path.join(_env.PLUGINS_DIR, name);
|
|
19
|
+
}
|
|
20
|
+
install(cli) {
|
|
21
|
+
super.install(cli);
|
|
22
|
+
if (!_FS.FS.existsSync(this.certsDir)) {
|
|
23
|
+
_FS.FS.mkdirSync(this.certsDir, {
|
|
24
|
+
recursive: true
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (!_FS.FS.existsSync(this.dataDir)) {
|
|
28
|
+
_FS.FS.mkdirSync(this.dataDir, {
|
|
29
|
+
recursive: true
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
certsPath(...paths) {
|
|
34
|
+
return Path.join(this.certsDir, ...paths);
|
|
35
|
+
}
|
|
36
|
+
dataPath(...paths) {
|
|
37
|
+
return Path.join(this.dataDir, ...paths);
|
|
38
|
+
}
|
|
39
|
+
pluginPath(...paths) {
|
|
40
|
+
return Path.join(this.pluginDir, ...paths);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.Plugin = Plugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Entity = {
|
|
2
|
+
id: number | string;
|
|
3
|
+
};
|
|
4
|
+
export declare class Repository<E extends Entity> {
|
|
5
|
+
create(data: Partial<E>): Promise<E>;
|
|
6
|
+
update(id: E["id"], record: Partial<E>): Promise<E>;
|
|
7
|
+
byId(id: E["id"]): Promise<E>;
|
|
8
|
+
search(params?: any): Promise<E[]>;
|
|
9
|
+
searchOne(params?: any): Promise<E>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Repository = void 0;
|
|
7
|
+
class Repository {
|
|
8
|
+
async create(data) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
async update(id, record) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
async byId(id) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
async search(params) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
async searchOne(params) {
|
|
21
|
+
const [item] = await this.search(params);
|
|
22
|
+
return item;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.Repository = Repository;
|
|
@@ -0,0 +1,71 @@
|
|
|
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];
|
|
14
|
+
}
|
|
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
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PromptGroupOptions } from "src/utils";
|
|
2
|
+
import { Project } from "./Project";
|
|
3
|
+
export declare class Preset {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
dockerfile?: string;
|
|
7
|
+
buildArgsOptions?: PromptGroupOptions<{
|
|
8
|
+
hash?: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
envOptions?: PromptGroupOptions;
|
|
11
|
+
volumeOptions?: string[];
|
|
12
|
+
volumes?: string[];
|
|
13
|
+
constructor(data?: Preset);
|
|
14
|
+
getImageArgs(project: Project): import("../types").EnvConfig;
|
|
15
|
+
getImageName(buildArgs: {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
}): string;
|
|
18
|
+
static get(name: string): Promise<Preset>;
|
|
19
|
+
}
|