@beads/bd 0.21.5

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/bd.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const os = require('os');
6
+ const fs = require('fs');
7
+
8
+ // Determine the platform-specific binary name
9
+ function getBinaryPath() {
10
+ const platform = os.platform();
11
+ const arch = os.arch();
12
+
13
+ let binaryName = 'bd';
14
+ if (platform === 'win32') {
15
+ binaryName = 'bd.exe';
16
+ }
17
+
18
+ // Binary is stored in the package's bin directory
19
+ const binaryPath = path.join(__dirname, binaryName);
20
+
21
+ if (!fs.existsSync(binaryPath)) {
22
+ console.error(`Error: bd binary not found at ${binaryPath}`);
23
+ console.error('This may indicate that the postinstall script failed to download the binary.');
24
+ console.error(`Platform: ${platform}, Architecture: ${arch}`);
25
+ process.exit(1);
26
+ }
27
+
28
+ return binaryPath;
29
+ }
30
+
31
+ // Execute the native binary with all arguments passed through
32
+ function main() {
33
+ const binaryPath = getBinaryPath();
34
+
35
+ // Spawn the native bd binary with all command-line arguments
36
+ const child = spawn(binaryPath, process.argv.slice(2), {
37
+ stdio: 'inherit',
38
+ env: process.env
39
+ });
40
+
41
+ child.on('error', (err) => {
42
+ console.error(`Error executing bd binary: ${err.message}`);
43
+ process.exit(1);
44
+ });
45
+
46
+ child.on('exit', (code, signal) => {
47
+ if (signal) {
48
+ process.exit(1);
49
+ }
50
+ process.exit(code || 0);
51
+ });
52
+ }
53
+
54
+ main();
File without changes
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@beads/bd",
3
+ "version": "0.21.5",
4
+ "description": "Beads issue tracker - lightweight memory system for coding agents with native binary support",
5
+ "main": "bin/bd.js",
6
+ "bin": {
7
+ "bd": "bin/bd.js"
8
+ },
9
+ "scripts": {
10
+ "postinstall": "node scripts/postinstall.js",
11
+ "test": "node scripts/test.js"
12
+ },
13
+ "keywords": [
14
+ "issue-tracker",
15
+ "dependency-tracking",
16
+ "ai-agent",
17
+ "coding-agent",
18
+ "claude",
19
+ "sqlite",
20
+ "git",
21
+ "project-management"
22
+ ],
23
+ "author": "Steve Yegge",
24
+ "license": "MIT",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/steveyegge/beads.git",
28
+ "directory": "npm-package"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/steveyegge/beads/issues"
32
+ },
33
+ "homepage": "https://github.com/steveyegge/beads#readme",
34
+ "engines": {
35
+ "node": ">=14.0.0"
36
+ },
37
+ "os": [
38
+ "darwin",
39
+ "linux",
40
+ "win32"
41
+ ],
42
+ "cpu": [
43
+ "x64",
44
+ "arm64"
45
+ ],
46
+ "files": [
47
+ "bin/",
48
+ "scripts/",
49
+ "README.md",
50
+ "LICENSE"
51
+ ]
52
+ }
@@ -0,0 +1,206 @@
1
+ #!/usr/bin/env node
2
+
3
+ const https = require('https');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const os = require('os');
7
+ const { execSync } = require('child_process');
8
+
9
+ // Get package version to determine which release to download
10
+ const packageJson = require('../package.json');
11
+ const VERSION = packageJson.version;
12
+
13
+ // Determine platform and architecture
14
+ function getPlatformInfo() {
15
+ const platform = os.platform();
16
+ const arch = os.arch();
17
+
18
+ let platformName;
19
+ let archName;
20
+ let binaryName = 'bd';
21
+
22
+ // Map Node.js platform names to GitHub release names
23
+ switch (platform) {
24
+ case 'darwin':
25
+ platformName = 'darwin';
26
+ break;
27
+ case 'linux':
28
+ platformName = 'linux';
29
+ break;
30
+ case 'win32':
31
+ platformName = 'windows';
32
+ binaryName = 'bd.exe';
33
+ break;
34
+ default:
35
+ throw new Error(`Unsupported platform: ${platform}`);
36
+ }
37
+
38
+ // Map Node.js arch names to GitHub release names
39
+ switch (arch) {
40
+ case 'x64':
41
+ archName = 'amd64';
42
+ break;
43
+ case 'arm64':
44
+ archName = 'arm64';
45
+ break;
46
+ default:
47
+ throw new Error(`Unsupported architecture: ${arch}`);
48
+ }
49
+
50
+ return { platformName, archName, binaryName };
51
+ }
52
+
53
+ // Download file from URL
54
+ function downloadFile(url, dest) {
55
+ return new Promise((resolve, reject) => {
56
+ console.log(`Downloading from: ${url}`);
57
+ const file = fs.createWriteStream(dest);
58
+
59
+ const request = https.get(url, (response) => {
60
+ // Handle redirects
61
+ if (response.statusCode === 301 || response.statusCode === 302) {
62
+ const redirectUrl = response.headers.location;
63
+ console.log(`Following redirect to: ${redirectUrl}`);
64
+ downloadFile(redirectUrl, dest).then(resolve).catch(reject);
65
+ return;
66
+ }
67
+
68
+ if (response.statusCode !== 200) {
69
+ reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
70
+ return;
71
+ }
72
+
73
+ response.pipe(file);
74
+
75
+ file.on('finish', () => {
76
+ file.close();
77
+ resolve();
78
+ });
79
+ });
80
+
81
+ request.on('error', (err) => {
82
+ fs.unlink(dest, () => {});
83
+ reject(err);
84
+ });
85
+
86
+ file.on('error', (err) => {
87
+ fs.unlink(dest, () => {});
88
+ reject(err);
89
+ });
90
+ });
91
+ }
92
+
93
+ // Extract tar.gz file
94
+ function extractTarGz(tarGzPath, destDir, binaryName) {
95
+ console.log(`Extracting ${tarGzPath}...`);
96
+
97
+ try {
98
+ // Use tar command to extract
99
+ execSync(`tar -xzf "${tarGzPath}" -C "${destDir}"`, { stdio: 'inherit' });
100
+
101
+ // The binary should now be in destDir
102
+ const extractedBinary = path.join(destDir, binaryName);
103
+
104
+ if (!fs.existsSync(extractedBinary)) {
105
+ throw new Error(`Binary not found after extraction: ${extractedBinary}`);
106
+ }
107
+
108
+ // Make executable on Unix-like systems
109
+ if (os.platform() !== 'win32') {
110
+ fs.chmodSync(extractedBinary, 0o755);
111
+ }
112
+
113
+ console.log(`Binary extracted to: ${extractedBinary}`);
114
+ } catch (err) {
115
+ throw new Error(`Failed to extract archive: ${err.message}`);
116
+ }
117
+ }
118
+
119
+ // Extract zip file (for Windows)
120
+ function extractZip(zipPath, destDir, binaryName) {
121
+ console.log(`Extracting ${zipPath}...`);
122
+
123
+ try {
124
+ // Use unzip command or powershell on Windows
125
+ if (os.platform() === 'win32') {
126
+ execSync(`powershell -command "Expand-Archive -Path '${zipPath}' -DestinationPath '${destDir}' -Force"`, { stdio: 'inherit' });
127
+ } else {
128
+ execSync(`unzip -o "${zipPath}" -d "${destDir}"`, { stdio: 'inherit' });
129
+ }
130
+
131
+ // The binary should now be in destDir
132
+ const extractedBinary = path.join(destDir, binaryName);
133
+
134
+ if (!fs.existsSync(extractedBinary)) {
135
+ throw new Error(`Binary not found after extraction: ${extractedBinary}`);
136
+ }
137
+
138
+ console.log(`Binary extracted to: ${extractedBinary}`);
139
+ } catch (err) {
140
+ throw new Error(`Failed to extract archive: ${err.message}`);
141
+ }
142
+ }
143
+
144
+ // Main installation function
145
+ async function install() {
146
+ try {
147
+ const { platformName, archName, binaryName } = getPlatformInfo();
148
+
149
+ console.log(`Installing bd v${VERSION} for ${platformName}-${archName}...`);
150
+
151
+ // Construct download URL
152
+ // Format: https://github.com/steveyegge/beads/releases/download/v0.21.5/beads_0.21.5_darwin_amd64.tar.gz
153
+ const releaseVersion = VERSION;
154
+ const archiveExt = platformName === 'windows' ? 'zip' : 'tar.gz';
155
+ const archiveName = `beads_${releaseVersion}_${platformName}_${archName}.${archiveExt}`;
156
+ const downloadUrl = `https://github.com/steveyegge/beads/releases/download/v${releaseVersion}/${archiveName}`;
157
+
158
+ // Determine destination paths
159
+ const binDir = path.join(__dirname, '..', 'bin');
160
+ const archivePath = path.join(binDir, archiveName);
161
+ const binaryPath = path.join(binDir, binaryName);
162
+
163
+ // Ensure bin directory exists
164
+ if (!fs.existsSync(binDir)) {
165
+ fs.mkdirSync(binDir, { recursive: true });
166
+ }
167
+
168
+ // Download the archive
169
+ console.log(`Downloading bd binary...`);
170
+ await downloadFile(downloadUrl, archivePath);
171
+
172
+ // Extract the archive based on platform
173
+ if (platformName === 'windows') {
174
+ extractZip(archivePath, binDir, binaryName);
175
+ } else {
176
+ extractTarGz(archivePath, binDir, binaryName);
177
+ }
178
+
179
+ // Clean up archive
180
+ fs.unlinkSync(archivePath);
181
+
182
+ // Verify the binary works
183
+ try {
184
+ const output = execSync(`"${binaryPath}" version`, { encoding: 'utf8' });
185
+ console.log(`✓ bd installed successfully: ${output.trim()}`);
186
+ } catch (err) {
187
+ console.warn('Warning: Could not verify binary version');
188
+ }
189
+
190
+ } catch (err) {
191
+ console.error(`Error installing bd: ${err.message}`);
192
+ console.error('');
193
+ console.error('Installation failed. You can try:');
194
+ console.error('1. Installing manually from: https://github.com/steveyegge/beads/releases');
195
+ console.error('2. Using the install script: curl -fsSL https://raw.githubusercontent.com/steveyegge/beads/main/scripts/install.sh | bash');
196
+ console.error('3. Opening an issue: https://github.com/steveyegge/beads/issues');
197
+ process.exit(1);
198
+ }
199
+ }
200
+
201
+ // Run installation if not in CI environment
202
+ if (!process.env.CI) {
203
+ install();
204
+ } else {
205
+ console.log('Skipping binary download in CI environment');
206
+ }
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execSync } = require('child_process');
4
+ const path = require('path');
5
+
6
+ function runTests() {
7
+ console.log('Testing bd installation...\n');
8
+
9
+ const bdPath = path.join(__dirname, '..', 'bin', 'bd.js');
10
+
11
+ try {
12
+ // Test 1: Version check
13
+ console.log('Test 1: Checking bd version...');
14
+ const version = execSync(`node "${bdPath}" version`, { encoding: 'utf8' });
15
+ console.log(`✓ Version check passed: ${version.trim()}\n`);
16
+
17
+ // Test 2: Help command
18
+ console.log('Test 2: Checking bd help...');
19
+ execSync(`node "${bdPath}" --help`, { stdio: 'pipe' });
20
+ console.log('✓ Help command passed\n');
21
+
22
+ console.log('✓ All tests passed!');
23
+ } catch (err) {
24
+ console.error('✗ Tests failed:', err.message);
25
+ process.exit(1);
26
+ }
27
+ }
28
+
29
+ runTests();