gitmorph 0.2.0 → 0.2.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/postinstall.js +5 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitmorph",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "GitMorph CLI — work with gitmorph.com from the command line",
5
5
  "bin": {
6
6
  "gm": "bin/gm"
package/postinstall.js CHANGED
@@ -3,10 +3,9 @@ const path = require("path");
3
3
  const https = require("https");
4
4
 
5
5
  const VERSION = require("./package.json").version;
6
- const HOST = "gitmorph.com";
7
- const REPO = "tejas/cli";
8
6
  const BIN_DIR = path.join(__dirname, "bin");
9
7
  const BINARY_PATH = path.join(BIN_DIR, "gm-binary");
8
+ const BASE_URL = "https://github.com/morphllm/gitmorph/releases/download";
10
9
 
11
10
  const PLATFORM_MAP = {
12
11
  "darwin-arm64": "gm-darwin-arm64",
@@ -15,11 +14,11 @@ const PLATFORM_MAP = {
15
14
  "linux-arm64": "gm-linux-arm64",
16
15
  };
17
16
 
18
- function fetch(url) {
17
+ function download(url) {
19
18
  return new Promise((resolve, reject) => {
20
19
  https.get(url, (res) => {
21
20
  if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
22
- return fetch(res.headers.location).then(resolve, reject);
21
+ return download(res.headers.location).then(resolve, reject);
23
22
  }
24
23
  if (res.statusCode !== 200) {
25
24
  return reject(new Error(`HTTP ${res.statusCode} from ${url}`));
@@ -42,22 +41,11 @@ async function main() {
42
41
  process.exit(0);
43
42
  }
44
43
 
44
+ const url = `${BASE_URL}/v${VERSION}/${filename}`;
45
45
  console.log(`Downloading gm v${VERSION} for ${key}...`);
46
46
 
47
47
  try {
48
- // Fetch release metadata from Gitea API
49
- const releaseUrl = `https://${HOST}/api/v1/repos/${REPO}/releases/tags/v${VERSION}`;
50
- const releaseData = JSON.parse((await fetch(releaseUrl)).toString());
51
- const asset = (releaseData.assets || []).find((a) => a.name === filename);
52
-
53
- if (!asset) {
54
- throw new Error(`No binary found for ${filename} in release v${VERSION}`);
55
- }
56
-
57
- // Download binary via browser_download_url
58
- const downloadUrl = asset.browser_download_url || `https://${HOST}/attachments/${asset.uuid}`;
59
- const data = await fetch(downloadUrl);
60
-
48
+ const data = await download(url);
61
49
  fs.mkdirSync(BIN_DIR, { recursive: true });
62
50
  fs.writeFileSync(BINARY_PATH, data);
63
51
  fs.chmodSync(BINARY_PATH, 0o755);