@vino.tian/myte 0.1.9 → 0.1.19
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/bin/myte.js +5 -5
- package/dist/VERSION +1 -0
- package/package.json +2 -2
- package/scripts/install.js +17 -9
- package/vendor/VERSION +0 -1
- package/vendor/manifest.json +0 -4
package/bin/myte.js
CHANGED
|
@@ -6,16 +6,16 @@ const { join } = require("node:path");
|
|
|
6
6
|
|
|
7
7
|
function detectTarget() {
|
|
8
8
|
if (process.platform === "linux" && process.arch === "x64") {
|
|
9
|
-
return {
|
|
9
|
+
return { dir: "linux-x64", binary: "myte" };
|
|
10
10
|
}
|
|
11
11
|
if (process.platform === "linux" && process.arch === "arm64") {
|
|
12
|
-
return {
|
|
12
|
+
return { dir: "linux-arm64", binary: "myte" };
|
|
13
13
|
}
|
|
14
14
|
if (process.platform === "win32" && process.arch === "x64") {
|
|
15
|
-
return {
|
|
15
|
+
return { dir: "windows-x64", binary: "myte.exe" };
|
|
16
16
|
}
|
|
17
17
|
if (process.platform === "darwin" && process.arch === "arm64") {
|
|
18
|
-
return {
|
|
18
|
+
return { dir: "macos-arm64", binary: "myte" };
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
console.error(`暂不支持的平台:${process.platform}-${process.arch}`);
|
|
@@ -23,7 +23,7 @@ function detectTarget() {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const target = detectTarget();
|
|
26
|
-
const binaryPath = join(__dirname, "..", "
|
|
26
|
+
const binaryPath = join(__dirname, "..", "dist", target.dir, target.binary);
|
|
27
27
|
|
|
28
28
|
if (!existsSync(binaryPath)) {
|
|
29
29
|
console.error(`缺少当前平台的 myte 二进制:${binaryPath}`);
|
package/dist/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.19
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vino.tian/myte",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "myte CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"bin",
|
|
15
15
|
"scripts",
|
|
16
|
-
"
|
|
16
|
+
"dist",
|
|
17
17
|
"README.md"
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
package/scripts/install.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { createHash } = require("node:crypto");
|
|
4
|
-
const { createWriteStream, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync } = require("node:fs");
|
|
4
|
+
const { chmodSync, copyFileSync, createWriteStream, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync } = require("node:fs");
|
|
5
5
|
const { tmpdir } = require("node:os");
|
|
6
6
|
const { dirname, join } = require("node:path");
|
|
7
7
|
const { pipeline } = require("node:stream/promises");
|
|
@@ -11,16 +11,16 @@ const SEMVER_VERSION = /^\d+\.\d+\.\d+$/;
|
|
|
11
11
|
|
|
12
12
|
function detectTarget() {
|
|
13
13
|
if (process.platform === "linux" && process.arch === "x64") {
|
|
14
|
-
return {
|
|
14
|
+
return { dir: "linux-x64", release: "linux-x64", assetExt: "tar.gz", binary: "myte" };
|
|
15
15
|
}
|
|
16
16
|
if (process.platform === "linux" && process.arch === "arm64") {
|
|
17
|
-
return {
|
|
17
|
+
return { dir: "linux-arm64", release: "linux-arm64", assetExt: "tar.gz", binary: "myte" };
|
|
18
18
|
}
|
|
19
19
|
if (process.platform === "win32" && process.arch === "x64") {
|
|
20
|
-
return {
|
|
20
|
+
return { dir: "windows-x64", release: "win32-x64", assetExt: "zip", binary: "myte.exe" };
|
|
21
21
|
}
|
|
22
22
|
if (process.platform === "darwin" && process.arch === "arm64") {
|
|
23
|
-
return {
|
|
23
|
+
return { dir: "macos-arm64", release: "darwin-arm64", assetExt: "tar.gz", binary: "myte" };
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
throw new Error(`暂不支持的平台:${process.platform}-${process.arch}`);
|
|
@@ -40,7 +40,14 @@ function validatePackageVersion(version) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function vendorBinaryPath(target) {
|
|
43
|
-
return join(__dirname, "..", "
|
|
43
|
+
return join(__dirname, "..", "dist", target.dir, target.binary);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function ensureExecutable(filePath) {
|
|
47
|
+
if (process.platform === "win32") {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
chmodSync(filePath, 0o755);
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
function fetchBuffer(url) {
|
|
@@ -159,7 +166,7 @@ async function install() {
|
|
|
159
166
|
const packageKey = pkg.myte.packageKey;
|
|
160
167
|
const releaseRepository = pkg.myte.releaseRepository;
|
|
161
168
|
const releaseTag = `${packageKey}-v${pkg.version}`;
|
|
162
|
-
const assetName = `${releaseTag}-${target.
|
|
169
|
+
const assetName = `${releaseTag}-${target.release}.${target.assetExt}`;
|
|
163
170
|
const checksumName = `${releaseTag}-checksums.txt`;
|
|
164
171
|
const baseUrl = `https://github.com/${releaseRepository}/releases/download/${releaseTag}`;
|
|
165
172
|
const tempDir = mkdtempSync(join(tmpdir(), "myte-install-"));
|
|
@@ -173,13 +180,14 @@ async function install() {
|
|
|
173
180
|
const extractDir = join(tempDir, "extract");
|
|
174
181
|
extractArchive(assetPath, extractDir);
|
|
175
182
|
|
|
176
|
-
const extractedBinary = join(extractDir,
|
|
183
|
+
const extractedBinary = join(extractDir, target.binary);
|
|
177
184
|
if (!existsSync(extractedBinary)) {
|
|
178
185
|
throw new Error(`资产中缺少平台二进制:${assetName}`);
|
|
179
186
|
}
|
|
180
187
|
|
|
181
188
|
mkdirSync(dirname(binaryPath), { recursive: true });
|
|
182
|
-
|
|
189
|
+
copyFileSync(extractedBinary, binaryPath);
|
|
190
|
+
ensureExecutable(binaryPath);
|
|
183
191
|
} finally {
|
|
184
192
|
rmSync(tempDir, { recursive: true, force: true });
|
|
185
193
|
}
|
package/vendor/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.1.9
|
package/vendor/manifest.json
DELETED