@offckb/cli 0.3.0-canary-e7bf6be.0 → 0.3.0-canary-4e24414.0
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/dist/node/install.js +21 -9
- package/package.json +1 -1
package/dist/node/install.js
CHANGED
|
@@ -68,18 +68,16 @@ function installCKBBinary(version) {
|
|
|
68
68
|
exports.installCKBBinary = installCKBBinary;
|
|
69
69
|
function downloadCKBBinaryAndUnzip(version) {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const
|
|
72
|
-
const osname = getOS();
|
|
73
|
-
const ext = getExtension();
|
|
74
|
-
const ckbVersionOSName = `ckb_v${version}_${arch}-${osname}`;
|
|
71
|
+
const ckbPackageName = buildCKBGithubReleasePackageName(version);
|
|
75
72
|
try {
|
|
76
|
-
const
|
|
73
|
+
const ext = getExtension();
|
|
74
|
+
const tempFilePath = path.join(os_1.default.tmpdir(), `${ckbPackageName}.${ext}`);
|
|
77
75
|
yield downloadAndSaveCKBBinary(version, tempFilePath);
|
|
78
76
|
// Unzip the file
|
|
79
77
|
const extractDir = path.join((0, setting_1.readSettings)().bins.downloadPath, `ckb_v${version}`);
|
|
80
78
|
yield unZipFile(tempFilePath, extractDir, ext === 'tar.gz');
|
|
81
79
|
// Install the extracted files
|
|
82
|
-
const sourcePath = path.join(extractDir,
|
|
80
|
+
const sourcePath = path.join(extractDir, ckbPackageName);
|
|
83
81
|
const targetPath = (0, setting_1.getCKBBinaryInstallPath)(version);
|
|
84
82
|
if (fs.existsSync(targetPath)) {
|
|
85
83
|
fs.rmdirSync(targetPath, { recursive: true });
|
|
@@ -200,15 +198,29 @@ function isPortable() {
|
|
|
200
198
|
}
|
|
201
199
|
return false;
|
|
202
200
|
}
|
|
203
|
-
function
|
|
201
|
+
function buildCKBGithubReleasePackageName(version, opt = {}) {
|
|
202
|
+
const os = opt.os || getOS();
|
|
203
|
+
const arch = opt.arch || getArch();
|
|
204
|
+
if (isPortable()) {
|
|
205
|
+
return `ckb_v${version}_${arch}-${os}-portable`;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
return `ckb_v${version}_${arch}-${os}`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function buildCKBGithubReleasePackageNameWithExtension(version, opt = {}) {
|
|
204
212
|
const os = opt.os || getOS();
|
|
205
213
|
const arch = opt.arch || getArch();
|
|
206
214
|
const extension = opt.ext || getExtension();
|
|
207
215
|
if (isPortable()) {
|
|
208
|
-
return `
|
|
216
|
+
return `ckb_v${version}_${arch}-${os}-portable.${extension}`;
|
|
209
217
|
}
|
|
210
218
|
else {
|
|
211
|
-
return `
|
|
219
|
+
return `ckb_v${version}_${arch}-${os}.${extension}`;
|
|
212
220
|
}
|
|
213
221
|
}
|
|
222
|
+
function buildDownloadUrl(version, opt = {}) {
|
|
223
|
+
const fullPackageName = buildCKBGithubReleasePackageNameWithExtension(version, opt);
|
|
224
|
+
return `https://github.com/nervosnetwork/ckb/releases/download/v${version}/${fullPackageName}`;
|
|
225
|
+
}
|
|
214
226
|
exports.buildDownloadUrl = buildDownloadUrl;
|