everkm-publish 0.10.3 → 0.10.5
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/install.js +57 -44
- package/package.json +2 -1
package/install.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const Downloader = require("nodejs-file-downloader");
|
|
3
|
+
// const decompress = require("decompress");
|
|
3
4
|
|
|
4
5
|
var __create = Object.create;
|
|
5
6
|
var __defProp = Object.defineProperty;
|
|
@@ -27,13 +28,13 @@ var path = require("path");
|
|
|
27
28
|
var knownWindowsPackages = {
|
|
28
29
|
// "win32 arm64": "@esbuild/win32-arm64",
|
|
29
30
|
// "win32 ia32": "@esbuild/win32-ia32",
|
|
30
|
-
"win32 x64": "windows-amd64.
|
|
31
|
+
"win32 x64": "windows-amd64.zip",
|
|
31
32
|
};
|
|
32
33
|
var knownUnixlikePackages = {
|
|
33
34
|
// "android arm64": "@esbuild/android-arm64",
|
|
34
35
|
// "darwin arm64": "@esbuild/darwin-arm64",
|
|
35
|
-
"darwin arm64": "darwin-universal.
|
|
36
|
-
"darwin x64": "darwin-universal.
|
|
36
|
+
"darwin arm64": "darwin-universal.zip",
|
|
37
|
+
"darwin x64": "darwin-universal.zip",
|
|
37
38
|
// "freebsd arm64": "@esbuild/freebsd-arm64",
|
|
38
39
|
// "freebsd x64": "@esbuild/freebsd-x64",
|
|
39
40
|
// "linux arm": "@esbuild/linux-arm",
|
|
@@ -43,7 +44,7 @@ var knownUnixlikePackages = {
|
|
|
43
44
|
// "linux ppc64": "@esbuild/linux-ppc64",
|
|
44
45
|
// "linux riscv64": "@esbuild/linux-riscv64",
|
|
45
46
|
// "linux s390x BE": "@esbuild/linux-s390x",
|
|
46
|
-
"linux x64": "linux-amd64.
|
|
47
|
+
"linux x64": "linux-amd64.zip",
|
|
47
48
|
// "linux loong64": "@esbuild/linux-loong64",
|
|
48
49
|
// "netbsd x64": "@esbuild/netbsd-x64",
|
|
49
50
|
// "openbsd x64": "@esbuild/openbsd-x64",
|
|
@@ -186,13 +187,16 @@ function traverseDirectory(directory) {
|
|
|
186
187
|
}
|
|
187
188
|
|
|
188
189
|
async function downloadBinary(pkg, binName) {
|
|
189
|
-
const binaryDist = (process.env.EVERKM_PUBLISH_BINARY ||
|
|
190
|
+
const binaryDist = (process.env.EVERKM_PUBLISH_BINARY || "").replace(
|
|
191
|
+
/\/$/,
|
|
192
|
+
""
|
|
193
|
+
);
|
|
190
194
|
let fileUrl = `https://github.com/everkm/publish/releases/download/everkm-publish%40v${versionFromPackageJSON}/EverkmPublish_${versionFromPackageJSON}_${pkg}`;
|
|
191
|
-
if (binaryDist){
|
|
195
|
+
if (binaryDist) {
|
|
192
196
|
// fileUrl = `https://assets.daobox.cc/everkm-publish/stable/${versionFromPackageJSON}/EverkmPublish_${versionFromPackageJSON}_${pkg}`;
|
|
193
197
|
fileUrl = `${binaryDist}/${versionFromPackageJSON}/EverkmPublish_${versionFromPackageJSON}_${pkg}`;
|
|
194
198
|
}
|
|
195
|
-
// const fileUrl = "http://localhost:8000/daobox/everkm-publish.
|
|
199
|
+
// const fileUrl = "http://localhost:8000/daobox/everkm-publish.zip";
|
|
196
200
|
const filename = path.join(__dirname, "bin", pkg);
|
|
197
201
|
const dest = path.dirname(filename);
|
|
198
202
|
console.log("download everkm publish binary:", fileUrl);
|
|
@@ -207,7 +211,7 @@ async function downloadBinary(pkg, binName) {
|
|
|
207
211
|
const params = {
|
|
208
212
|
url: fileUrl,
|
|
209
213
|
directory: dest,
|
|
210
|
-
cloneFiles: false
|
|
214
|
+
cloneFiles: false,
|
|
211
215
|
};
|
|
212
216
|
if (proxy) {
|
|
213
217
|
params.proxy = proxy;
|
|
@@ -242,7 +246,7 @@ async function downloadBinary(pkg, binName) {
|
|
|
242
246
|
const files = traverseDirectory(extractDir);
|
|
243
247
|
|
|
244
248
|
// 打印所有文件
|
|
245
|
-
|
|
249
|
+
console.log("files", files);
|
|
246
250
|
|
|
247
251
|
files.some(function (file) {
|
|
248
252
|
const arr = file.split("/");
|
|
@@ -267,42 +271,51 @@ async function downloadBinary(pkg, binName) {
|
|
|
267
271
|
};
|
|
268
272
|
|
|
269
273
|
// 解压缩
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
} else {
|
|
304
|
-
|
|
274
|
+
// decompress(filename, extractDir)
|
|
275
|
+
// .then((files) => {
|
|
276
|
+
// console.log("extract done,", files);
|
|
277
|
+
// extractFinish();
|
|
278
|
+
// })
|
|
279
|
+
// .catch((err) => {
|
|
280
|
+
// reject(err);
|
|
281
|
+
// });
|
|
282
|
+
|
|
283
|
+
// if (/\.tar\.gz$/.test(filename)) {
|
|
284
|
+
// const readStream = fs.createReadStream(filename);
|
|
285
|
+
// const unzip = zlib.createGunzip(); // 创建 gunzip 解压缩流
|
|
286
|
+
// const untar = tar.x({
|
|
287
|
+
// sync: true,
|
|
288
|
+
// C: extractDir, // alias for cwd:'some-dir', also ok
|
|
289
|
+
// }); // 创建 tar 解压缩流
|
|
290
|
+
|
|
291
|
+
// readStream
|
|
292
|
+
// .pipe(unzip) // 使用 gunzip 解压缩流
|
|
293
|
+
// .pipe(untar) // 使用 tar 解压缩流
|
|
294
|
+
// .on("error", (err) => {
|
|
295
|
+
// console.error(err);
|
|
296
|
+
// })
|
|
297
|
+
// .on("finish", () => {
|
|
298
|
+
// // console.log("解压缩完成", filename, extractDir);
|
|
299
|
+
|
|
300
|
+
// try {
|
|
301
|
+
// extractFinish();
|
|
302
|
+
// resolve();
|
|
303
|
+
// } catch (err) {
|
|
304
|
+
// reject(err);
|
|
305
|
+
// }
|
|
306
|
+
// });
|
|
307
|
+
// } else if (/\.zip$/.test(filename)) {
|
|
308
|
+
const zip = new AdmZip(filename); // 指定 ZIP 文件路径
|
|
309
|
+
zip.extractAllTo(extractDir, true); // 解压 ZIP 文件到指定目录
|
|
310
|
+
try {
|
|
311
|
+
extractFinish();
|
|
312
|
+
resolve();
|
|
313
|
+
} catch (err) {
|
|
314
|
+
reject(err);
|
|
305
315
|
}
|
|
316
|
+
// } else {
|
|
317
|
+
// reject(`not support archive package: ${pkg}`);
|
|
318
|
+
// }
|
|
306
319
|
});
|
|
307
320
|
} catch (error) {
|
|
308
321
|
//IMPORTANT: Handle a possible error. An error is thrown in case of network errors, or status codes of 400 and above.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "everkm-publish",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"postinstall": "node install.js",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"adm-zip": "^0.5.10",
|
|
20
|
+
"decompress": "^4.2.1",
|
|
20
21
|
"nodejs-file-downloader": "^4.12.1",
|
|
21
22
|
"tar": "^6.1.13"
|
|
22
23
|
}
|