@pixeljuggle/project-context 0.0.12 → 0.1.1
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 +29 -7
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -7,12 +7,38 @@ const zlib = require("node:zlib");
|
|
|
7
7
|
const tar = require("tar");
|
|
8
8
|
const { pipeline } = require("node:stream/promises");
|
|
9
9
|
|
|
10
|
-
const pkg = require("./package.json");
|
|
11
|
-
const version = pkg.version;
|
|
12
10
|
const binaryName = "project-context";
|
|
13
11
|
const repo = "pixeljuggle/project-context";
|
|
14
12
|
|
|
13
|
+
async function getLatestVersion() {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
const options = {
|
|
16
|
+
headers: { "User-Agent": "project-context-npm-install" },
|
|
17
|
+
};
|
|
18
|
+
https
|
|
19
|
+
.get(
|
|
20
|
+
"https://api.github.com/repos/pixeljuggle/project-context/releases/latest",
|
|
21
|
+
options,
|
|
22
|
+
(res) => {
|
|
23
|
+
let data = "";
|
|
24
|
+
res.on("data", (chunk) => (data += chunk));
|
|
25
|
+
res.on("end", () => {
|
|
26
|
+
try {
|
|
27
|
+
const release = JSON.parse(data);
|
|
28
|
+
const version = release.tag_name.replace(/^v/, "");
|
|
29
|
+
resolve(version);
|
|
30
|
+
} catch (_e) {
|
|
31
|
+
reject(new Error("Failed to parse latest release from GitHub"));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
)
|
|
36
|
+
.on("error", reject);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
15
40
|
async function main() {
|
|
41
|
+
const version = await getLatestVersion();
|
|
16
42
|
const platform = process.platform;
|
|
17
43
|
const arch = process.arch;
|
|
18
44
|
|
|
@@ -29,9 +55,8 @@ async function main() {
|
|
|
29
55
|
const targetBinary = platform === "win32" ? `${binaryName}.exe` : binaryName;
|
|
30
56
|
const targetPath = path.join(binDir, targetBinary);
|
|
31
57
|
|
|
32
|
-
console.log(`Downloading ${binaryName} ${version} for ${goOs}
|
|
58
|
+
console.log(`Downloading ${binaryName} ${version} for ${goOs}_${goArch}...`);
|
|
33
59
|
|
|
34
|
-
// Download with redirect support
|
|
35
60
|
const response = await new Promise((resolve, reject) => {
|
|
36
61
|
https
|
|
37
62
|
.get(url, (res) => {
|
|
@@ -68,8 +93,5 @@ main()
|
|
|
68
93
|
.then(() => process.exit(0))
|
|
69
94
|
.catch((err) => {
|
|
70
95
|
console.error("❌ Failed to install project-context:", err.message);
|
|
71
|
-
console.error(
|
|
72
|
-
` → Make sure you have released v${version} on GitHub with the .tar.gz files`,
|
|
73
|
-
);
|
|
74
96
|
process.exit(1);
|
|
75
97
|
});
|
package/package.json
CHANGED