backlog.md 0.1.9 → 0.1.16

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/cli.js CHANGED
@@ -1,62 +1,151 @@
1
1
  #!/usr/bin/env node
2
- import { spawn } from 'child_process';
3
- import { fileURLToPath } from 'url';
4
- import { dirname, join } from 'path';
5
- import { platform, arch } from 'os';
6
- import { accessSync, constants } from 'fs';
7
-
8
- const __dirname = dirname(fileURLToPath(import.meta.url));
9
-
10
- function getBinaryPath() {
11
- const os = platform();
12
- const architecture = arch();
13
-
14
- const platformMap = {
15
- 'darwin': 'darwin',
16
- 'linux': 'linux',
17
- 'win32': 'win32'
18
- };
19
-
20
- const archMap = {
21
- 'x64': 'x64',
22
- 'arm64': 'arm64'
23
- };
24
-
25
- const mappedOs = platformMap[os];
26
- const mappedArch = archMap[architecture];
27
-
28
- if (!mappedOs || !mappedArch) {
29
- throw new Error(`Unsupported platform: ${os}-${architecture}`);
30
- }
31
-
32
- const binaryName = os === 'win32' ? 'backlog.exe' : 'backlog';
33
- const binaryPath = join(__dirname, 'bin', `backlog-${mappedOs}-${mappedArch}`, binaryName);
34
-
35
- try {
36
- accessSync(binaryPath, constants.X_OK);
37
- return binaryPath;
38
- } catch (error) {
39
- throw new Error(`Binary not found for platform ${mappedOs}-${mappedArch} at ${binaryPath}`);
40
- }
2
+
3
+ const { spawn } = require("node:child_process");
4
+ const { join } = require("node:path");
5
+ const fs = require("node:fs");
6
+ const https = require("node:https");
7
+ const { createWriteStream, chmodSync } = require("node:fs");
8
+
9
+ // Determine the correct binary based on platform and architecture
10
+ function getBinaryName() {
11
+ const platform = process.platform;
12
+ const arch = process.arch;
13
+
14
+ let binaryName = "backlog-";
15
+
16
+ // Map Node.js platform names to Bun target names
17
+ switch (platform) {
18
+ case "linux":
19
+ binaryName += "bun-linux-";
20
+ break;
21
+ case "darwin":
22
+ binaryName += "bun-darwin-";
23
+ break;
24
+ case "win32":
25
+ binaryName += "bun-windows-";
26
+ break;
27
+ default:
28
+ console.error(`Unsupported platform: ${platform}`);
29
+ process.exit(1);
30
+ }
31
+
32
+ // Map Node.js arch names to Bun target names
33
+ switch (arch) {
34
+ case "x64":
35
+ binaryName += "x64";
36
+ break;
37
+ case "arm64":
38
+ binaryName += "arm64";
39
+ break;
40
+ default:
41
+ console.error(`Unsupported architecture: ${arch}`);
42
+ process.exit(1);
43
+ }
44
+
45
+ // Windows executables have .exe extension
46
+ if (platform === "win32") {
47
+ binaryName += ".exe";
48
+ }
49
+
50
+ return binaryName;
51
+ }
52
+
53
+ // Download binary from GitHub releases
54
+ async function downloadBinary(binaryName, binaryPath) {
55
+ const packageJson = require(join(__dirname, "package.json"));
56
+ const version = packageJson.version;
57
+ const url = `https://github.com/MrLesk/Backlog.md/releases/download/v${version}/${binaryName}`;
58
+
59
+ console.log(`Downloading ${binaryName} for your platform...`);
60
+ console.log("This is a one-time download.");
61
+
62
+ return new Promise((resolve, reject) => {
63
+ https
64
+ .get(url, (response) => {
65
+ if (response.statusCode === 302 || response.statusCode === 301) {
66
+ // Follow redirect
67
+ https
68
+ .get(response.headers.location, (redirectResponse) => {
69
+ if (redirectResponse.statusCode !== 200) {
70
+ reject(new Error(`Failed to download: ${redirectResponse.statusCode}`));
71
+ return;
72
+ }
73
+
74
+ const file = createWriteStream(binaryPath);
75
+ redirectResponse.pipe(file);
76
+
77
+ file.on("finish", () => {
78
+ file.close();
79
+ chmodSync(binaryPath, 0o755);
80
+ console.log("Download complete!");
81
+ resolve();
82
+ });
83
+ })
84
+ .on("error", reject);
85
+ } else if (response.statusCode !== 200) {
86
+ reject(new Error(`Failed to download: ${response.statusCode}`));
87
+ } else {
88
+ const file = createWriteStream(binaryPath);
89
+ response.pipe(file);
90
+
91
+ file.on("finish", () => {
92
+ file.close();
93
+ chmodSync(binaryPath, 0o755);
94
+ console.log("Download complete!");
95
+ resolve();
96
+ });
97
+ }
98
+ })
99
+ .on("error", reject);
100
+ });
41
101
  }
42
102
 
43
- try {
44
- const binaryPath = getBinaryPath();
45
- const child = spawn(binaryPath, process.argv.slice(2), {
46
- stdio: 'inherit',
47
- env: process.env
48
- });
49
-
50
- child.on('exit', (code) => {
51
- process.exit(code || 0);
52
- });
53
-
54
- child.on('error', (err) => {
55
- console.error('Failed to run backlog:', err.message);
56
- process.exit(1);
57
- });
58
- } catch (error) {
59
- console.error(error.message);
60
- console.error('\nPlease report this issue at: https://github.com/MrLesk/Backlog.md/issues');
61
- process.exit(1);
103
+ // Main execution
104
+ async function main() {
105
+ const binaryName = getBinaryName();
106
+ const binDir = join(__dirname, ".bin");
107
+ const binaryPath = join(binDir, binaryName);
108
+
109
+ // Create bin directory if it doesn't exist
110
+ if (!fs.existsSync(binDir)) {
111
+ fs.mkdirSync(binDir, { recursive: true });
112
+ }
113
+
114
+ // Check if binary exists
115
+ if (!fs.existsSync(binaryPath)) {
116
+ try {
117
+ await downloadBinary(binaryName, binaryPath);
118
+ } catch (err) {
119
+ console.error("Failed to download binary:", err.message);
120
+ console.error("Please download manually from: https://github.com/MrLesk/Backlog.md/releases");
121
+ process.exit(1);
122
+ }
123
+ }
124
+
125
+ // Spawn the binary with all arguments
126
+ const child = spawn(binaryPath, process.argv.slice(2), {
127
+ stdio: "inherit",
128
+ windowsHide: true,
129
+ });
130
+
131
+ // Handle exit
132
+ child.on("exit", (code) => {
133
+ process.exit(code || 0);
134
+ });
135
+
136
+ // Handle errors
137
+ child.on("error", (err) => {
138
+ if (err.code === "ENOENT") {
139
+ console.error(`Binary not found: ${binaryPath}`);
140
+ console.error(`Please delete ${binDir} and try again.`);
141
+ } else {
142
+ console.error("Failed to start backlog:", err);
143
+ }
144
+ process.exit(1);
145
+ });
62
146
  }
147
+
148
+ main().catch((err) => {
149
+ console.error(err);
150
+ process.exit(1);
151
+ });
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "backlog.md",
3
- "version": "0.1.9",
4
- "module": "src/index.ts",
5
- "type": "module",
3
+ "version": "0.1.16",
6
4
  "bin": {
7
5
  "backlog": "cli.js"
8
6
  },
9
7
  "dependencies": {
8
+ "@types/prompts": "^2.4.9",
10
9
  "blessed": "0.1.81",
11
10
  "commander": "14.0.0",
12
11
  "gray-matter": "4.0.3",
@@ -17,9 +16,7 @@
17
16
  "format": "biome format --write .",
18
17
  "lint": "biome lint --write .",
19
18
  "check": "biome check .",
20
- "build": "bun build --compile --external blessed --outfile=backlog src/cli.ts",
21
- "build:standalone": "node scripts/build-standalone.js",
22
- "build:npm": "node scripts/build.js",
19
+ "build": "bun build --compile --minify --sourcemap --outfile=backlog src/cli.ts",
23
20
  "cli": "bun src/cli.ts"
24
21
  },
25
22
  "lint-staged": {
@@ -53,7 +50,9 @@
53
50
  "@biomejs/biome"
54
51
  ],
55
52
  "files": [
56
- "bin/",
57
- "cli.js"
53
+ "cli.js",
54
+ "package.json",
55
+ "README.md",
56
+ "LICENSE"
58
57
  ]
59
- }
58
+ }
Binary file
Binary file
Binary file
Binary file
Binary file
package/readme.md DELETED
@@ -1,97 +0,0 @@
1
- <h1 align="center">Backlog.md</h1>
2
- <p align="center">✏️ Markdown‑native Task Manager &amp; Kanban visualizer for any Git repository</p>
3
-
4
- <p align="center">
5
- <a href="https://www.npmjs.com/package/backlog.md">
6
- <img src="https://badgen.net/npm/v/backlog.md?icon=npm&label=npm">
7
- </a>
8
- <a href="https://bun.sh">
9
- <img src="https://badgen.net/badge/bun/add%20backlog.md/black?icon=bun">
10
- </a>
11
- <a href="LICENSE"><img src="https://badgen.net/github/license/your-org/backlog.md"></a>
12
- </p>
13
-
14
- ---
15
-
16
- > **Backlog.md** turns any folder with a Git repo into a **self‑contained project board**
17
- > powered by plain Markdown files and a zero‑config CLI.
18
-
19
- * 100 % offline‑friendly – your backlog lives *inside* your repository
20
- * Works on **macOS, Linux and Windows** (Node ≥ 18 / Bun ≥ 1.0)
21
- * Completely free & open‑source (MIT)
22
-
23
- ---
24
-
25
- ### Quick install
26
-
27
- ```bash
28
- # global – Node
29
- npm i -g backlog.md
30
-
31
- # global – Bun
32
- bun add -g backlog.md # Bun 1.0+
33
- ```
34
-
35
- > Prefer per‑project installs? `npm i -D backlog.md` → `npx backlog …`
36
-
37
- ---
38
-
39
- ### Five‑minute tour
40
-
41
- ```bash
42
- # 1. Bootstrap a repo + backlog
43
- backlog init hello-world
44
-
45
- # 2. Capture work
46
- backlog task create "Render markdown as kanban"
47
-
48
- # 3. See where you stand
49
- backlog board view
50
- ```
51
-
52
- All data is saved under `.backlog` folder as human‑readable Markdown (`task‑12 - Fix typo.md`).
53
-
54
- ---
55
-
56
- ## CLI reference (essentials)
57
-
58
- | Action | Example |
59
- |-------------|------------------------------------------------------|
60
- | Create task | `backlog task create "Add OAuth"` |
61
- | Create sub task | `backlog task create --parent 14 "Add Google auth"`|
62
- | List tasks | `backlog task list [-s <status>] [-a <assignee>` |
63
- | View detail | `backlog task 7` |
64
- | Edit | `backlog task edit 7 -a @sara -l auth,backend` |
65
- | Archive | `backlog task archive 7` |
66
- | Draft flow | `backlog draft create "Spike GraphQL"` → `backlog draft promote 3.1` |
67
- | Demote to draft| `backlog task demote <id>` |
68
- | Kanban | `backlog board view` |
69
-
70
- Full help: `backlog --help`
71
-
72
- ---
73
-
74
- ## Configuration
75
-
76
- Backlog.md merges the following layers (highest → lowest):
77
-
78
- 1. CLI flags
79
- 2. `.backlog/config.yml` (per‑project)
80
- 3. `~/.backlog/user` (per‑user)
81
- 4. Built‑ins
82
-
83
- Key options:
84
-
85
- | Key | Purpose | Default |
86
- |-------------------|--------------------|-------------------------------|
87
- | `default_assignee`| Pre‑fill assignee | `[]` |
88
- | `default_status` | First column | `To Do` |
89
- | `statuses` | Board columns | `[To Do, In Progress, Done]` |
90
- | `date_format` | ISO or locale | `yyyy-mm-dd` |
91
-
92
- ---
93
-
94
-
95
- ## License
96
-
97
- Backlog.md is released under the **MIT License** – do anything, just give credit. See [LICENSE](LICENSE).