@delta-infra/cli 1.0.33 → 1.0.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.
- package/checksums.txt +5 -4
- package/package.json +1 -1
- package/scripts/install.js +128 -47
package/checksums.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
3280a243a3ad74deff648243103fa6835de7b16624a96bff4388e001ba6d3d83 delta-cli-darwin-amd64.tar.gz
|
|
2
|
+
f42ca72eb07e3c8edc08c64cb38db980e83c025a10dbb63817cd8074d05018de delta-cli-darwin-arm64.tar.gz
|
|
3
|
+
4f3aa674d93f227f3182c5052db7f6bb1fdbc9684e654973474b147f00021ee7 delta-cli-linux-amd64.tar.gz
|
|
4
|
+
6eebd852f36fda70edc83c2950a29808a4beddb01fe777af56db930f0ecb9b65 delta-cli-linux-arm64.tar.gz
|
|
5
|
+
23b0d6614d594977cefc96fa357b31f27324e7c5db291efa33432b86d48360bd delta-cli-windows-amd64.zip
|
package/package.json
CHANGED
package/scripts/install.js
CHANGED
|
@@ -31,6 +31,13 @@ const REPO = "yzailab/delta-infra-cli";
|
|
|
31
31
|
const DEFAULT_ALLOWED_HOSTS = new Set([
|
|
32
32
|
"github.com",
|
|
33
33
|
"gh-proxy.com",
|
|
34
|
+
"ghproxy.net",
|
|
35
|
+
"gh.ddlc.top",
|
|
36
|
+
"gh.llkk.cc",
|
|
37
|
+
"gh.dpik.top",
|
|
38
|
+
"gh.con.sh",
|
|
39
|
+
"slink.ltd",
|
|
40
|
+
"xget.xi-xu.me",
|
|
34
41
|
"objects.githubusercontent.com",
|
|
35
42
|
"release-assets.githubusercontent.com",
|
|
36
43
|
"github-releases.githubusercontent.com",
|
|
@@ -75,17 +82,89 @@ function _getCurlTimeout() {
|
|
|
75
82
|
return _curlTimeoutMs;
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
|
|
85
|
+
// List of well-known GitHub release download mirrors.
|
|
86
|
+
// Format: [hostname, urlPrefix] — urlPrefix is prepended to the GitHub URL.
|
|
87
|
+
var _MIRROR_LIST = [
|
|
88
|
+
["gh-proxy.com", "https://gh-proxy.com"],
|
|
89
|
+
["ghproxy.net", "https://ghproxy.net"],
|
|
90
|
+
["gh.ddlc.top", "https://gh.ddlc.top"],
|
|
91
|
+
["gh.llkk.cc", "https://gh.llkk.cc"],
|
|
92
|
+
["gh.dpik.top", "https://gh.dpik.top"],
|
|
93
|
+
["gh.con.sh", "https://gh.con.sh"],
|
|
94
|
+
["slink.ltd", "https://slink.ltd"],
|
|
95
|
+
["xget.xi-xu.me", "https://xget.xi-xu.me"],
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
// Quick connectivity check: fetch a small file (checksums.txt) from each
|
|
99
|
+
// mirror and return only the ones that respond within the probe timeout.
|
|
100
|
+
function probeMirrors(version, cb) {
|
|
101
|
+
var probeUrl = "/https://github.com/" + REPO + "/releases/download/v" + version + "/checksums.txt";
|
|
102
|
+
var results = [];
|
|
103
|
+
var pending = _MIRROR_LIST.length;
|
|
104
|
+
var done = false;
|
|
105
|
+
|
|
106
|
+
function finish() {
|
|
107
|
+
if (done) return;
|
|
108
|
+
done = true;
|
|
109
|
+
cb(results);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (pending === 0) return finish();
|
|
113
|
+
|
|
114
|
+
for (var i = 0; i < _MIRROR_LIST.length; i++) {
|
|
115
|
+
(function(idx) {
|
|
116
|
+
var entry = _MIRROR_LIST[idx];
|
|
117
|
+
var host = entry[0];
|
|
118
|
+
var prefix = entry[1];
|
|
119
|
+
var testUrl = prefix + probeUrl;
|
|
120
|
+
var args = [
|
|
121
|
+
"--fail", "--location", "--silent", "--show-error",
|
|
122
|
+
"--connect-timeout", "3", "--max-time", "5",
|
|
123
|
+
"--output", "/dev/null", testUrl,
|
|
124
|
+
];
|
|
125
|
+
var child;
|
|
126
|
+
try {
|
|
127
|
+
child = require("child_process").spawn("curl", args, { stdio: ["ignore", "pipe", "pipe"], timeout: 8000 });
|
|
128
|
+
var stdout = "";
|
|
129
|
+
var stderr = "";
|
|
130
|
+
child.stdout.on("data", function(d) { stdout += d; });
|
|
131
|
+
child.stderr.on("data", function(d) { stderr += d; });
|
|
132
|
+
child.on("close", function(code) {
|
|
133
|
+
if (code === 0) {
|
|
134
|
+
results.push(prefix + "/https://github.com/" + REPO + "/releases/download/v" + version + "/" + archiveName);
|
|
135
|
+
}
|
|
136
|
+
pending--;
|
|
137
|
+
if (pending === 0) finish();
|
|
138
|
+
});
|
|
139
|
+
child.on("error", function() {
|
|
140
|
+
pending--;
|
|
141
|
+
if (pending === 0) finish();
|
|
142
|
+
});
|
|
143
|
+
} catch (e) {
|
|
144
|
+
pending--;
|
|
145
|
+
if (pending === 0) finish();
|
|
146
|
+
}
|
|
147
|
+
})(i);
|
|
148
|
+
}
|
|
149
|
+
// Safety timeout: if probes hang, continue without mirrors after 10s
|
|
150
|
+
setTimeout(finish, 10000);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function releaseAssetUrls(version, assetName, cb) {
|
|
79
154
|
var urls = [];
|
|
80
155
|
var mirror = process.env.DELTA_CLI_MIRROR || "";
|
|
81
156
|
if (mirror) {
|
|
82
157
|
urls.push("" + mirror.replace(/\/$/, "") + "/yzailab/delta-infra-cli/releases/download/v" + version + "/" + assetName);
|
|
83
158
|
}
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
159
|
+
// Probe mirrors in parallel first, then fallback
|
|
160
|
+
probeMirrors(version, function(mirrorUrls) {
|
|
161
|
+
for (var i = 0; i < mirrorUrls.length; i++) {
|
|
162
|
+
urls.push(mirrorUrls[i]);
|
|
163
|
+
}
|
|
164
|
+
// GitHub source (last resort)
|
|
165
|
+
urls.push(GITHUB_URL);
|
|
166
|
+
cb(urls);
|
|
167
|
+
});
|
|
89
168
|
}
|
|
90
169
|
|
|
91
170
|
function assertAllowedHost(url) {
|
|
@@ -232,58 +311,60 @@ function verifyChecksum(archivePath, expectedHash) {
|
|
|
232
311
|
// ── Main install ───────────────────────────────────────────────────────────
|
|
233
312
|
|
|
234
313
|
function install() {
|
|
235
|
-
const downloadUrls = releaseAssetUrls(VERSION, archiveName);
|
|
236
|
-
|
|
237
314
|
fs.mkdirSync(binDir, { recursive: true });
|
|
238
|
-
|
|
239
|
-
|
|
315
|
+
var tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "delta-cli-"));
|
|
316
|
+
var archivePath = path.join(tmpDir, archiveName);
|
|
240
317
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
318
|
+
releaseAssetUrls(VERSION, archiveName, function(downloadUrls) {
|
|
319
|
+
try {
|
|
320
|
+
var lastErr;
|
|
321
|
+
var downloaded = false;
|
|
322
|
+
for (var i = 0; i < downloadUrls.length; i++) {
|
|
323
|
+
try {
|
|
324
|
+
console.error("Downloading from " + downloadUrls[i]);
|
|
325
|
+
download(downloadUrls[i], archivePath);
|
|
326
|
+
downloaded = true;
|
|
327
|
+
break;
|
|
328
|
+
} catch (e) {
|
|
329
|
+
console.error("Failed: " + e.message);
|
|
330
|
+
lastErr = e;
|
|
331
|
+
}
|
|
251
332
|
}
|
|
252
|
-
|
|
253
|
-
if (!downloaded) throw lastErr;
|
|
333
|
+
if (!downloaded) throw lastErr;
|
|
254
334
|
|
|
255
|
-
|
|
256
|
-
|
|
335
|
+
const expectedHash = getExpectedChecksum(archiveName);
|
|
336
|
+
verifyChecksum(archivePath, expectedHash);
|
|
257
337
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
338
|
+
if (isWindows) {
|
|
339
|
+
extractZipWindows(archivePath, tmpDir);
|
|
340
|
+
} else {
|
|
341
|
+
execFileSync("tar", ["-xzf", archivePath, "-C", tmpDir], { stdio: "ignore" });
|
|
342
|
+
}
|
|
263
343
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
} else {
|
|
269
|
-
// Fallback: try the plain name (older release format)
|
|
270
|
-
const plainBinary = path.join(tmpDir, binaryName);
|
|
271
|
-
if (fs.existsSync(plainBinary)) {
|
|
272
|
-
fs.copyFileSync(plainBinary, dest);
|
|
344
|
+
const binaryName = NAME + (isWindows ? ".exe" : "");
|
|
345
|
+
const extractedBinary = path.join(tmpDir, NAME + "-" + platform + "-" + arch);
|
|
346
|
+
if (fs.existsSync(extractedBinary)) {
|
|
347
|
+
fs.copyFileSync(extractedBinary, dest);
|
|
273
348
|
} else {
|
|
274
|
-
//
|
|
275
|
-
const
|
|
276
|
-
if (
|
|
277
|
-
fs.copyFileSync(
|
|
349
|
+
// Fallback: try the plain name (older release format)
|
|
350
|
+
const plainBinary = path.join(tmpDir, binaryName);
|
|
351
|
+
if (fs.existsSync(plainBinary)) {
|
|
352
|
+
fs.copyFileSync(plainBinary, dest);
|
|
278
353
|
} else {
|
|
279
|
-
|
|
354
|
+
// Search in tmpDir
|
|
355
|
+
const files = fs.readdirSync(tmpDir).filter(function(f) { return f.indexOf(NAME) !== -1 || f.indexOf(binaryName) !== -1; });
|
|
356
|
+
if (files.length > 0) {
|
|
357
|
+
fs.copyFileSync(path.join(tmpDir, files[0]), dest);
|
|
358
|
+
} else {
|
|
359
|
+
throw new Error("Binary not found in extracted archive. Files: " + fs.readdirSync(tmpDir).join(", "));
|
|
360
|
+
}
|
|
280
361
|
}
|
|
281
362
|
}
|
|
363
|
+
fs.chmodSync(dest, 0o755);
|
|
364
|
+
} finally {
|
|
365
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
282
366
|
}
|
|
283
|
-
|
|
284
|
-
} finally {
|
|
285
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
286
|
-
}
|
|
367
|
+
});
|
|
287
368
|
}
|
|
288
369
|
|
|
289
370
|
// ── Entry ──────────────────────────────────────────────────────────────────
|