badmfck-api-server 4.1.33 → 4.1.35
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.
|
@@ -10,6 +10,15 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
10
10
|
const __1 = require("../..");
|
|
11
11
|
const crypto_1 = __importDefault(require("crypto"));
|
|
12
12
|
async function Deploy(opt) {
|
|
13
|
+
if (typeof opt === "string") {
|
|
14
|
+
if (!fs_1.default.existsSync(opt)) {
|
|
15
|
+
throw new Error(`File not found: ${opt}`);
|
|
16
|
+
}
|
|
17
|
+
opt = JSON.parse(fs_1.default.readFileSync(opt).toString("utf-8"));
|
|
18
|
+
if (!opt.name || !opt.token || !opt.host || !opt.username || !opt.password) {
|
|
19
|
+
throw new Error(`Invalid deploy config file: ${opt}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
13
22
|
const archiveName = __1.UID.sha256(opt.name.replaceAll(".", "_")) + ".tar.gz";
|
|
14
23
|
console.log("Changing Config to live");
|
|
15
24
|
const config = path_1.default.resolve("src", "Config.ts");
|
|
@@ -495,18 +495,13 @@ class DeployerService extends BaseService_1.BaseService {
|
|
|
495
495
|
}
|
|
496
496
|
async unpack(destination, uploadedFile, install, ignoreDirectoryClean) {
|
|
497
497
|
return new Promise((resolve) => {
|
|
498
|
-
if (!this._isDestinationSafe(destination)) {
|
|
499
|
-
(0, LogService_1.logError)("Refusing to unpack: destination outside projects_path", destination);
|
|
500
|
-
resolve({ code: 19, message: "Destination outside projects root", httpStatus: 500 });
|
|
501
|
-
return;
|
|
502
|
-
}
|
|
503
498
|
try {
|
|
504
499
|
const tmp = path_1.default.resolve(destination, "__tmp");
|
|
505
500
|
if (fs_1.default.existsSync(tmp))
|
|
506
501
|
fs_1.default.rmSync(tmp, { recursive: true });
|
|
507
502
|
if (!fs_1.default.existsSync(tmp))
|
|
508
503
|
fs_1.default.mkdirSync(tmp, { recursive: true });
|
|
509
|
-
(0, child_process_1.execFileSync)("tar", ["
|
|
504
|
+
(0, child_process_1.execFileSync)("tar", ["-xzf", uploadedFile, "-C", tmp]);
|
|
510
505
|
}
|
|
511
506
|
catch (e) {
|
|
512
507
|
(0, LogService_1.logError)(e);
|