backlog.md 0.1.9 → 0.1.15

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,147 @@
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
2
 
8
- const __dirname = dirname(fileURLToPath(import.meta.url));
3
+ const { spawn } = require('child_process');
4
+ const { join } = require('path');
5
+ const fs = require('fs');
6
+ const https = require('https');
7
+ const { createWriteStream, chmodSync } = require('fs');
9
8
 
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}`);
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
30
  }
31
31
 
32
- const binaryName = os === 'win32' ? 'backlog.exe' : 'backlog';
33
- const binaryPath = join(__dirname, 'bin', `backlog-${mappedOs}-${mappedArch}`, binaryName);
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
+ }
34
44
 
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}`);
45
+ // Windows executables have .exe extension
46
+ if (platform === 'win32') {
47
+ binaryName += '.exe';
40
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.get(url, (response) => {
64
+ if (response.statusCode === 302 || response.statusCode === 301) {
65
+ // Follow redirect
66
+ https.get(response.headers.location, (redirectResponse) => {
67
+ if (redirectResponse.statusCode !== 200) {
68
+ reject(new Error(`Failed to download: ${redirectResponse.statusCode}`));
69
+ return;
70
+ }
71
+
72
+ const file = createWriteStream(binaryPath);
73
+ redirectResponse.pipe(file);
74
+
75
+ file.on('finish', () => {
76
+ file.close();
77
+ chmodSync(binaryPath, 0o755);
78
+ console.log('Download complete!');
79
+ resolve();
80
+ });
81
+ }).on('error', reject);
82
+ } else if (response.statusCode !== 200) {
83
+ reject(new Error(`Failed to download: ${response.statusCode}`));
84
+ } else {
85
+ const file = createWriteStream(binaryPath);
86
+ response.pipe(file);
87
+
88
+ file.on('finish', () => {
89
+ file.close();
90
+ chmodSync(binaryPath, 0o755);
91
+ console.log('Download complete!');
92
+ resolve();
93
+ });
94
+ }
95
+ }).on('error', reject);
96
+ });
41
97
  }
42
98
 
43
- try {
44
- const binaryPath = getBinaryPath();
99
+ // Main execution
100
+ async function main() {
101
+ const binaryName = getBinaryName();
102
+ const binDir = join(__dirname, '.bin');
103
+ const binaryPath = join(binDir, binaryName);
104
+
105
+ // Create bin directory if it doesn't exist
106
+ if (!fs.existsSync(binDir)) {
107
+ fs.mkdirSync(binDir, { recursive: true });
108
+ }
109
+
110
+ // Check if binary exists
111
+ if (!fs.existsSync(binaryPath)) {
112
+ try {
113
+ await downloadBinary(binaryName, binaryPath);
114
+ } catch (err) {
115
+ console.error('Failed to download binary:', err.message);
116
+ console.error(`Please download manually from: https://github.com/MrLesk/Backlog.md/releases`);
117
+ process.exit(1);
118
+ }
119
+ }
120
+
121
+ // Spawn the binary with all arguments
45
122
  const child = spawn(binaryPath, process.argv.slice(2), {
46
123
  stdio: 'inherit',
47
- env: process.env
124
+ windowsHide: true
48
125
  });
49
126
 
127
+ // Handle exit
50
128
  child.on('exit', (code) => {
51
129
  process.exit(code || 0);
52
130
  });
53
131
 
132
+ // Handle errors
54
133
  child.on('error', (err) => {
55
- console.error('Failed to run backlog:', err.message);
134
+ if (err.code === 'ENOENT') {
135
+ console.error(`Binary not found: ${binaryPath}`);
136
+ console.error(`Please delete ${binDir} and try again.`);
137
+ } else {
138
+ console.error('Failed to start backlog:', err);
139
+ }
56
140
  process.exit(1);
57
141
  });
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);
62
142
  }
143
+
144
+ main().catch(err => {
145
+ console.error(err);
146
+ process.exit(1);
147
+ });
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "backlog.md",
3
- "version": "0.1.9",
4
- "module": "src/index.ts",
3
+ "version": "0.1.15",
5
4
  "type": "module",
6
5
  "bin": {
7
6
  "backlog": "cli.js"
8
7
  },
9
8
  "dependencies": {
9
+ "@types/prompts": "^2.4.9",
10
10
  "blessed": "0.1.81",
11
11
  "commander": "14.0.0",
12
12
  "gray-matter": "4.0.3",
@@ -17,9 +17,7 @@
17
17
  "format": "biome format --write .",
18
18
  "lint": "biome lint --write .",
19
19
  "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",
20
+ "build": "bun build --compile --minify --sourcemap --outfile=backlog src/cli.ts",
23
21
  "cli": "bun src/cli.ts"
24
22
  },
25
23
  "lint-staged": {
@@ -53,7 +51,9 @@
53
51
  "@biomejs/biome"
54
52
  ],
55
53
  "files": [
56
- "bin/",
57
- "cli.js"
54
+ "cli.js",
55
+ "package.json",
56
+ "README.md",
57
+ "LICENSE"
58
58
  ]
59
- }
59
+ }
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).