dev-report 0.1.0
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/dev-report.js +29 -0
- package/install.js +110 -0
- package/package.json +34 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* dev-report.js — thin Node.js shim that locates and executes the
|
|
4
|
+
* platform-specific Go binary.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { spawnSync } = require("child_process");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const fs = require("fs");
|
|
10
|
+
const os = require("os");
|
|
11
|
+
|
|
12
|
+
const isWindows = os.platform() === "win32";
|
|
13
|
+
const binName = isWindows ? "dev-report.exe" : "dev-report";
|
|
14
|
+
const binPath = path.join(__dirname, binName);
|
|
15
|
+
|
|
16
|
+
if (!fs.existsSync(binPath)) {
|
|
17
|
+
console.error(
|
|
18
|
+
`\n dev-report: binary not found at ${binPath}\n` +
|
|
19
|
+
` Try re-installing: npm install -g dev-report\n`
|
|
20
|
+
);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const result = spawnSync(binPath, process.argv.slice(2), {
|
|
25
|
+
stdio: "inherit",
|
|
26
|
+
windowsHide: false,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
process.exit(result.status ?? 1);
|
package/install.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* install.js — downloads the correct pre-built Go binary for the current
|
|
4
|
+
* OS and architecture from GitHub Releases.
|
|
5
|
+
*
|
|
6
|
+
* Supports: Windows (amd64), macOS (amd64, arm64), Linux (amd64, arm64)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const https = require("https");
|
|
10
|
+
const fs = require("fs");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
const { execSync } = require("child_process");
|
|
13
|
+
const os = require("os");
|
|
14
|
+
const zlib = require("zlib");
|
|
15
|
+
|
|
16
|
+
const VERSION = require("./package.json").version;
|
|
17
|
+
const REPO = "TonmoyTalukder/dev-report";
|
|
18
|
+
const BIN_DIR = path.join(__dirname, "bin");
|
|
19
|
+
|
|
20
|
+
function getPlatformInfo() {
|
|
21
|
+
const platform = os.platform();
|
|
22
|
+
const arch = os.arch();
|
|
23
|
+
|
|
24
|
+
const osMap = { win32: "windows", darwin: "darwin", linux: "linux" };
|
|
25
|
+
const archMap = { x64: "amd64", arm64: "arm64", ia32: "386" };
|
|
26
|
+
|
|
27
|
+
const goos = osMap[platform];
|
|
28
|
+
const goarch = archMap[arch];
|
|
29
|
+
|
|
30
|
+
if (!goos) throw new Error(`Unsupported OS: ${platform}`);
|
|
31
|
+
if (!goarch) throw new Error(`Unsupported arch: ${arch}`);
|
|
32
|
+
|
|
33
|
+
const ext = goos === "windows" ? ".zip" : ".tar.gz";
|
|
34
|
+
const binName = goos === "windows" ? "dev-report.exe" : "dev-report";
|
|
35
|
+
const archiveName = `dev-report_${VERSION}_${goos}_${goarch}${ext}`;
|
|
36
|
+
|
|
37
|
+
return { goos, goarch, ext, binName, archiveName };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function downloadFile(url, dest) {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const file = fs.createWriteStream(dest);
|
|
43
|
+
const get = (url) => {
|
|
44
|
+
https
|
|
45
|
+
.get(url, { headers: { "User-Agent": "dev-report-installer" } }, (res) => {
|
|
46
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
47
|
+
return get(res.headers.location);
|
|
48
|
+
}
|
|
49
|
+
if (res.statusCode !== 200) {
|
|
50
|
+
return reject(new Error(`Download failed: HTTP ${res.statusCode} — ${url}`));
|
|
51
|
+
}
|
|
52
|
+
res.pipe(file);
|
|
53
|
+
file.on("finish", () => file.close(resolve));
|
|
54
|
+
})
|
|
55
|
+
.on("error", reject);
|
|
56
|
+
};
|
|
57
|
+
get(url);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function main() {
|
|
62
|
+
const { goos, binName, archiveName } = getPlatformInfo();
|
|
63
|
+
const downloadURL = `https://github.com/${REPO}/releases/download/v${VERSION}/${archiveName}`;
|
|
64
|
+
const tmpFile = path.join(os.tmpdir(), archiveName);
|
|
65
|
+
|
|
66
|
+
if (!fs.existsSync(BIN_DIR)) {
|
|
67
|
+
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const binDest = path.join(BIN_DIR, binName);
|
|
71
|
+
|
|
72
|
+
// Skip if already installed
|
|
73
|
+
if (fs.existsSync(binDest)) {
|
|
74
|
+
console.log(` dev-report: binary already present, skipping download.`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log(` dev-report: downloading ${archiveName}…`);
|
|
79
|
+
try {
|
|
80
|
+
await downloadFile(downloadURL, tmpFile);
|
|
81
|
+
} catch (err) {
|
|
82
|
+
console.error(`\n ⚠ Binary download failed: ${err.message}`);
|
|
83
|
+
console.error(` You can download it manually from:`);
|
|
84
|
+
console.error(` https://github.com/${REPO}/releases/tag/v${VERSION}\n`);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Extract binary
|
|
89
|
+
console.log(` dev-report: extracting…`);
|
|
90
|
+
if (goos === "windows") {
|
|
91
|
+
// Use PowerShell to extract zip on Windows
|
|
92
|
+
execSync(
|
|
93
|
+
`powershell -Command "Expand-Archive -Force '${tmpFile}' '${path.join(os.tmpdir(), "dev-report-extract")}'"`,
|
|
94
|
+
{ stdio: "pipe" }
|
|
95
|
+
);
|
|
96
|
+
const extracted = path.join(os.tmpdir(), "dev-report-extract", binName);
|
|
97
|
+
fs.copyFileSync(extracted, binDest);
|
|
98
|
+
} else {
|
|
99
|
+
execSync(`tar -xzf "${tmpFile}" -C "${BIN_DIR}" "${binName}"`, { stdio: "pipe" });
|
|
100
|
+
fs.chmodSync(binDest, 0o755);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
fs.unlinkSync(tmpFile);
|
|
104
|
+
console.log(` ✅ dev-report installed to ${binDest}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
main().catch((err) => {
|
|
108
|
+
console.error(` ❌ Install error: ${err.message}`);
|
|
109
|
+
process.exit(1);
|
|
110
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dev-report",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AI-powered developer work report generator from Git commits",
|
|
5
|
+
"bin": {
|
|
6
|
+
"dev-report": "bin/dev-report.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node install.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin/",
|
|
13
|
+
"install.js",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"developer",
|
|
18
|
+
"report",
|
|
19
|
+
"git",
|
|
20
|
+
"ai",
|
|
21
|
+
"work-log",
|
|
22
|
+
"cli"
|
|
23
|
+
],
|
|
24
|
+
"author": "Tonmoy Talukder",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=16"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/TonmoyTalukder/dev-report.git"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/TonmoyTalukder/dev-report#readme"
|
|
34
|
+
}
|