jira-jr 0.5.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/install.js +105 -0
  2. package/package.json +28 -0
package/install.js ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { execSync } = require("child_process");
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ const https = require("https");
8
+ const { createWriteStream, mkdirSync } = require("fs");
9
+ const { pipeline } = require("stream/promises");
10
+ const zlib = require("zlib");
11
+ const tar = require("tar");
12
+
13
+ const REPO = "sofq/jira-cli";
14
+ const BIN_DIR = path.join(__dirname, "bin");
15
+
16
+ const PLATFORM_MAP = {
17
+ darwin: "darwin",
18
+ linux: "linux",
19
+ win32: "windows",
20
+ };
21
+
22
+ const ARCH_MAP = {
23
+ x64: "amd64",
24
+ arm64: "arm64",
25
+ };
26
+
27
+ async function getVersion() {
28
+ const pkg = require("./package.json");
29
+ return pkg.version;
30
+ }
31
+
32
+ function getPlatformArch() {
33
+ const platform = PLATFORM_MAP[process.platform];
34
+ const arch = ARCH_MAP[process.arch];
35
+ if (!platform || !arch) {
36
+ console.error(
37
+ `Unsupported platform/arch: ${process.platform}/${process.arch}`
38
+ );
39
+ process.exit(1);
40
+ }
41
+ return { platform, arch };
42
+ }
43
+
44
+ function getDownloadUrl(version, platform, arch) {
45
+ const ext = platform === "windows" ? "zip" : "tar.gz";
46
+ const name = `jira-cli_${version}_${platform}_${arch}.${ext}`;
47
+ return `https://github.com/${REPO}/releases/download/v${version}/${name}`;
48
+ }
49
+
50
+ function follow(url) {
51
+ return new Promise((resolve, reject) => {
52
+ https
53
+ .get(url, { headers: { "User-Agent": "jr-npm-installer" } }, (res) => {
54
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
55
+ return follow(res.headers.location).then(resolve, reject);
56
+ }
57
+ if (res.statusCode !== 200) {
58
+ return reject(new Error(`HTTP ${res.statusCode} for ${url}`));
59
+ }
60
+ resolve(res);
61
+ })
62
+ .on("error", reject);
63
+ });
64
+ }
65
+
66
+ async function install() {
67
+ const version = await getVersion();
68
+ const { platform, arch } = getPlatformArch();
69
+ const url = getDownloadUrl(version, platform, arch);
70
+ const binName = platform === "windows" ? "jr.exe" : "jr";
71
+ const binPath = path.join(BIN_DIR, binName);
72
+
73
+ if (fs.existsSync(binPath)) {
74
+ return;
75
+ }
76
+
77
+ mkdirSync(BIN_DIR, { recursive: true });
78
+
79
+ console.log(`Downloading jr v${version} for ${platform}/${arch}...`);
80
+ const res = await follow(url);
81
+
82
+ if (platform === "windows") {
83
+ // Download zip, extract with unzip
84
+ const tmpZip = path.join(BIN_DIR, "jr.zip");
85
+ const ws = createWriteStream(tmpZip);
86
+ await pipeline(res, ws);
87
+ execSync(`unzip -o "${tmpZip}" jr.exe -d "${BIN_DIR}"`, { stdio: "pipe" });
88
+ fs.unlinkSync(tmpZip);
89
+ } else {
90
+ // Stream tar.gz and extract
91
+ const tmpTar = path.join(BIN_DIR, "jr.tar.gz");
92
+ const ws = createWriteStream(tmpTar);
93
+ await pipeline(res, ws);
94
+ execSync(`tar xzf "${tmpTar}" -C "${BIN_DIR}" jr`, { stdio: "pipe" });
95
+ fs.unlinkSync(tmpTar);
96
+ }
97
+
98
+ fs.chmodSync(binPath, 0o755);
99
+ console.log(`Installed jr to ${binPath}`);
100
+ }
101
+
102
+ install().catch((err) => {
103
+ console.error("Failed to install jr:", err.message);
104
+ process.exit(1);
105
+ });
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "jira-jr",
3
+ "version": "0.5.2",
4
+ "description": "Agent-friendly Jira CLI with structured JSON output and jq filtering",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/sofq/jira-cli"
9
+ },
10
+ "homepage": "https://github.com/sofq/jira-cli",
11
+ "keywords": [
12
+ "jira",
13
+ "cli",
14
+ "ai",
15
+ "agent",
16
+ "json"
17
+ ],
18
+ "bin": {
19
+ "jr": "bin/jr"
20
+ },
21
+ "scripts": {
22
+ "postinstall": "node install.js"
23
+ },
24
+ "files": [
25
+ "bin/",
26
+ "install.js"
27
+ ]
28
+ }