badmfck-api-server 4.1.30 → 4.1.33
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.
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Deploy = void 0;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const __1 = require("../..");
|
|
11
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
12
|
+
async function Deploy(opt) {
|
|
13
|
+
const archiveName = __1.UID.sha256(opt.name.replaceAll(".", "_")) + ".tar.gz";
|
|
14
|
+
console.log("Changing Config to live");
|
|
15
|
+
const config = path_1.default.resolve("src", "Config.ts");
|
|
16
|
+
let configSrc = fs_1.default.readFileSync(config).toString("utf-8");
|
|
17
|
+
if (configSrc.indexOf("static scheme:Scheme = local;") !== -1) {
|
|
18
|
+
configSrc = configSrc.replace("static scheme:Scheme = local;", "static scheme:Scheme = live;");
|
|
19
|
+
fs_1.default.writeFileSync(config, configSrc);
|
|
20
|
+
}
|
|
21
|
+
const pkgPath = path_1.default.resolve("package.json");
|
|
22
|
+
const pkg = JSON.parse(fs_1.default.readFileSync(pkgPath).toString("utf-8"));
|
|
23
|
+
const parts = String(pkg.version || "0.0.0").split(".").map(p => parseInt(p, 10) || 0);
|
|
24
|
+
while (parts.length < 3)
|
|
25
|
+
parts.push(0);
|
|
26
|
+
parts[parts.length - 1] += 1;
|
|
27
|
+
const newVersion = parts.join(".");
|
|
28
|
+
console.log(`Bumping version: ${pkg.version} -> ${newVersion}`);
|
|
29
|
+
pkg.version = newVersion;
|
|
30
|
+
fs_1.default.writeFileSync(pkgPath, JSON.stringify(pkg, null, "\t") + "\n");
|
|
31
|
+
if (fs_1.default.existsSync(path_1.default.resolve(archiveName))) {
|
|
32
|
+
fs_1.default.rmSync(path_1.default.resolve(archiveName));
|
|
33
|
+
console.log("Removing old archive");
|
|
34
|
+
}
|
|
35
|
+
console.log("Build");
|
|
36
|
+
var execResult = run("npm run build");
|
|
37
|
+
console.log(execResult);
|
|
38
|
+
console.log("Archiving");
|
|
39
|
+
execResult = run("tar -czvf " + archiveName + " ./bin package.json");
|
|
40
|
+
console.log(execResult);
|
|
41
|
+
if (!fs_1.default.existsSync(path_1.default.resolve(archiveName))) {
|
|
42
|
+
console.error("ARCHIVE NOT CREATED!");
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
const cmd = `curl \
|
|
46
|
+
-H "Authorization: Bearer ${crypto_1.default.createHash("sha256").update(opt.username + ":" + opt.password).digest("hex")}" \
|
|
47
|
+
-F "token=${opt.token}" \
|
|
48
|
+
-F "name=${opt.name}" \
|
|
49
|
+
-F "file=@${archiveName}" \
|
|
50
|
+
"${opt.host}"`;
|
|
51
|
+
console.log("Deploying: \n" + cmd);
|
|
52
|
+
execResult = run(cmd);
|
|
53
|
+
console.log(execResult);
|
|
54
|
+
const deployedAt = new Date();
|
|
55
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
56
|
+
const stamp = `${deployedAt.getFullYear()}-${pad(deployedAt.getMonth() + 1)}-${pad(deployedAt.getDate())} ${pad(deployedAt.getHours())}:${pad(deployedAt.getMinutes())}:${pad(deployedAt.getSeconds())}`;
|
|
57
|
+
console.log(`\nDeployed v${newVersion} at ${stamp}\n`);
|
|
58
|
+
return archiveName;
|
|
59
|
+
}
|
|
60
|
+
exports.Deploy = Deploy;
|
|
61
|
+
function run(cmd) {
|
|
62
|
+
try {
|
|
63
|
+
return (0, child_process_1.execSync)(cmd, { encoding: "utf-8" });
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
console.error(`\nCommand failed: ${cmd}\n`);
|
|
67
|
+
const out = (err.stdout || "").toString().trim();
|
|
68
|
+
const errOut = (err.stderr || "").toString().trim();
|
|
69
|
+
if (out)
|
|
70
|
+
console.error(out);
|
|
71
|
+
if (errOut)
|
|
72
|
+
console.error(errOut);
|
|
73
|
+
process.exit(typeof err.status === "number" ? err.status : 1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -10,7 +10,7 @@ const DeployerService_1 = require("./DeployerService");
|
|
|
10
10
|
class Deployer extends BaseEndpoint_1.BaseEndpoint {
|
|
11
11
|
ignoreInDocumentation = true;
|
|
12
12
|
constructor() {
|
|
13
|
-
super("
|
|
13
|
+
super("pckg");
|
|
14
14
|
this.registerEndpoints([
|
|
15
15
|
{
|
|
16
16
|
ignoreInterceptor: true,
|
package/dist/index.d.ts
CHANGED
|
@@ -16,4 +16,5 @@ import { ZipUtils } from "./apiServer/helper/ZipUtils";
|
|
|
16
16
|
import { Http } from "./apiServer/http/Http";
|
|
17
17
|
import { MicroserviceHost } from "./apiServer/external/MicroserviceHost";
|
|
18
18
|
import { MicroserviceClient } from "./apiServer/external/MicroserviceClient";
|
|
19
|
-
|
|
19
|
+
import { Deploy } from "./apiServer/deployment/Deploy";
|
|
20
|
+
export { MicroserviceHost, MicroserviceClient, Http, ZipUtils, UID, YYYYMMDDHH, JSONStableStringify, APIService, Initializer, LocalRequest, ValidationModel, MysqlService, TimeframeService, Validator, LogService, DataProvider, ErrorUtils, ExternalService, DBService, Deploy, S_MONITOR_REGISTRATE_ACTION };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.S_MONITOR_REGISTRATE_ACTION = exports.DBService = exports.ExternalService = exports.ErrorUtils = exports.DataProvider = exports.LogService = exports.Validator = exports.TimeframeService = exports.MysqlService = exports.LocalRequest = exports.Initializer = exports.APIService = exports.JSONStableStringify = exports.YYYYMMDDHH = exports.UID = exports.ZipUtils = exports.Http = exports.MicroserviceClient = exports.MicroserviceHost = void 0;
|
|
3
|
+
exports.S_MONITOR_REGISTRATE_ACTION = exports.Deploy = exports.DBService = exports.ExternalService = exports.ErrorUtils = exports.DataProvider = exports.LogService = exports.Validator = exports.TimeframeService = exports.MysqlService = exports.LocalRequest = exports.Initializer = exports.APIService = exports.JSONStableStringify = exports.YYYYMMDDHH = exports.UID = exports.ZipUtils = exports.Http = exports.MicroserviceClient = exports.MicroserviceHost = void 0;
|
|
4
4
|
const APIService_1 = require("./apiServer/APIService");
|
|
5
5
|
Object.defineProperty(exports, "APIService", { enumerable: true, get: function () { return APIService_1.APIService; } });
|
|
6
6
|
Object.defineProperty(exports, "Initializer", { enumerable: true, get: function () { return APIService_1.Initializer; } });
|
|
@@ -38,3 +38,5 @@ const MicroserviceHost_1 = require("./apiServer/external/MicroserviceHost");
|
|
|
38
38
|
Object.defineProperty(exports, "MicroserviceHost", { enumerable: true, get: function () { return MicroserviceHost_1.MicroserviceHost; } });
|
|
39
39
|
const MicroserviceClient_1 = require("./apiServer/external/MicroserviceClient");
|
|
40
40
|
Object.defineProperty(exports, "MicroserviceClient", { enumerable: true, get: function () { return MicroserviceClient_1.MicroserviceClient; } });
|
|
41
|
+
const Deploy_1 = require("./apiServer/deployment/Deploy");
|
|
42
|
+
Object.defineProperty(exports, "Deploy", { enumerable: true, get: function () { return Deploy_1.Deploy; } });
|