badmfck-api-server 4.1.40 → 4.1.42
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.
|
@@ -9,6 +9,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const __1 = require("../..");
|
|
11
11
|
const crypto_1 = __importDefault(require("crypto"));
|
|
12
|
+
const undici_1 = require("undici");
|
|
12
13
|
async function Deploy(opt) {
|
|
13
14
|
if (typeof opt === "string") {
|
|
14
15
|
if (!fs_1.default.existsSync(opt)) {
|
|
@@ -68,7 +69,17 @@ async function Deploy(opt) {
|
|
|
68
69
|
const items = [];
|
|
69
70
|
const binExists = fs_1.default.existsSync("./bin");
|
|
70
71
|
if (binExists) {
|
|
71
|
-
items.push("./bin"
|
|
72
|
+
items.push("./bin");
|
|
73
|
+
if (fs_1.default.existsSync("package.json")) {
|
|
74
|
+
items.push("package.json");
|
|
75
|
+
}
|
|
76
|
+
if (fs_1.default.existsSync("package-lock.json")) {
|
|
77
|
+
items.push("package-lock.json");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else if (fs_1.default.existsSync("./dist") && fs_1.default.existsSync(path_1.default.resolve("dist", "index.html"))) {
|
|
81
|
+
console.log("No ./bin found — detected ./dist with index.html, using it as distribution");
|
|
82
|
+
items.push("./dist");
|
|
72
83
|
}
|
|
73
84
|
if (Array.isArray(opt.includes)) {
|
|
74
85
|
for (const inc of opt.includes) {
|
|
@@ -140,8 +151,13 @@ async function Deploy(opt) {
|
|
|
140
151
|
formData.set("file", fileBlob, archiveName);
|
|
141
152
|
console.log(`Deploying to ${opt.host} (archive: ${archiveName})`);
|
|
142
153
|
const startedAt = Date.now();
|
|
154
|
+
const uploadAgent = new undici_1.Agent({
|
|
155
|
+
headersTimeout: 5 * 60 * 1000,
|
|
156
|
+
bodyTimeout: 5 * 60 * 1000,
|
|
157
|
+
});
|
|
143
158
|
const uploadResponse = await __1.Http.post(opt.host, formData, {
|
|
144
159
|
headers: { authorization: `Bearer ${authToken}` },
|
|
160
|
+
dispatcher: uploadAgent,
|
|
145
161
|
timeoutMs: 5 * 60 * 1000,
|
|
146
162
|
retry: { enabled: false },
|
|
147
163
|
});
|
|
@@ -611,7 +611,15 @@ class DeployerService extends BaseService_1.BaseService {
|
|
|
611
611
|
}
|
|
612
612
|
if (install) {
|
|
613
613
|
try {
|
|
614
|
-
|
|
614
|
+
const tmpDir = path_1.default.resolve(destination, "__tmp");
|
|
615
|
+
const useCi = fs_1.default.existsSync(path_1.default.resolve(tmpDir, "package-lock.json"));
|
|
616
|
+
if (!useCi) {
|
|
617
|
+
(0, LogService_1.logWarn)("No package-lock.json in uploaded tarball — falling back to `npm i`. " +
|
|
618
|
+
"This is non-deterministic and vulnerable to supply-chain attacks. " +
|
|
619
|
+
"Commit and include package-lock.json for `npm ci` (deterministic + faster).");
|
|
620
|
+
}
|
|
621
|
+
const npmCmd = useCi ? "ci" : "i";
|
|
622
|
+
(0, child_process_1.execFileSync)("npm", ["--prefix", tmpDir, npmCmd, "--ignore-scripts"]);
|
|
615
623
|
}
|
|
616
624
|
catch (e) {
|
|
617
625
|
console.error(e);
|