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.
@@ -5,5 +5,5 @@ interface IDeployerParams {
5
5
  username: string;
6
6
  password: string;
7
7
  }
8
- export declare function Deploy(opt: IDeployerParams): Promise<string>;
8
+ export declare function Deploy(opt: IDeployerParams | string): Promise<string>;
9
9
  export {};
@@ -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", ["--no-absolute-names", "-xzf", uploadedFile, "-C", tmp]);
504
+ (0, child_process_1.execFileSync)("tar", ["-xzf", uploadedFile, "-C", tmp]);
510
505
  }
511
506
  catch (e) {
512
507
  (0, LogService_1.logError)(e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "4.1.33",
3
+ "version": "4.1.35",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",