bunosh 0.1.4 → 0.2.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.
- package/COMPLETION.md +214 -0
- package/README.md +489 -73
- package/UPGRADE.md +200 -0
- package/bunosh.js +56 -0
- package/index.js +22 -11
- package/package.json +32 -24
- package/src/completion.js +341 -0
- package/src/font.js +258 -0
- package/src/formatters/base.js +17 -0
- package/src/formatters/console.js +81 -0
- package/src/formatters/factory.js +17 -0
- package/src/formatters/github-actions.js +43 -0
- package/src/init.js +13 -6
- package/src/io.js +20 -0
- package/src/printer.js +91 -0
- package/src/program.js +374 -154
- package/src/task.js +148 -0
- package/src/tasks/copyFile.js +21 -0
- package/src/tasks/exec.js +204 -0
- package/src/tasks/fetch.js +47 -0
- package/src/tasks/{writeToFile.jsx → writeToFile.js} +18 -16
- package/src/upgrade.js +255 -0
- package/types.d.ts +44 -0
- package/run.js +0 -31
- package/src/io.jsx +0 -47
- package/src/output.js +0 -37
- package/src/task.jsx +0 -209
- package/src/tasks/copyFile.jsx +0 -14
- package/src/tasks/exec.jsx +0 -104
- package/src/tasks/fetch.jsx +0 -74
- package/templates/banner.js +0 -8
package/UPGRADE.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# Bunosh Upgrade Guide
|
|
2
|
+
|
|
3
|
+
Bunosh provides different upgrade paths depending on how it was installed.
|
|
4
|
+
|
|
5
|
+
## Single Executable (Recommended)
|
|
6
|
+
|
|
7
|
+
If you installed Bunosh as a single executable, you can upgrade directly using the built-in upgrade command.
|
|
8
|
+
|
|
9
|
+
### Check for Updates
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bunosh upgrade --check
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Example output:**
|
|
16
|
+
```bash
|
|
17
|
+
📍 Current version: 0.1.5
|
|
18
|
+
🔍 Checking for updates...
|
|
19
|
+
📦 Latest version: 0.1.6
|
|
20
|
+
✨ Update available! 0.1.5 → 0.1.6
|
|
21
|
+
Run bunosh upgrade to update.
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Upgrade to Latest Version
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
bunosh upgrade
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Example output:**
|
|
31
|
+
```bash
|
|
32
|
+
📍 Current version: 0.1.5
|
|
33
|
+
⬆️ Starting upgrade process...
|
|
34
|
+
|
|
35
|
+
Checking for updates...
|
|
36
|
+
Downloading latest release...
|
|
37
|
+
Download complete
|
|
38
|
+
Extracting and installing...
|
|
39
|
+
Installation complete
|
|
40
|
+
|
|
41
|
+
🎉 Upgrade successful!
|
|
42
|
+
0.1.5 → 0.1.6
|
|
43
|
+
|
|
44
|
+
💡 Run bunosh --version to verify the new version.
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Force Reinstall
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
bunosh upgrade --force
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
This will reinstall the current version even if you're already on the latest.
|
|
54
|
+
|
|
55
|
+
## NPM Installation
|
|
56
|
+
|
|
57
|
+
If you installed Bunosh via npm:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Check current version
|
|
61
|
+
npm list -g bunosh
|
|
62
|
+
|
|
63
|
+
# Update to latest
|
|
64
|
+
npm update -g bunosh
|
|
65
|
+
|
|
66
|
+
# Or reinstall
|
|
67
|
+
npm install -g bunosh@latest
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## How the Upgrade Works
|
|
71
|
+
|
|
72
|
+
### For Single Executables
|
|
73
|
+
|
|
74
|
+
1. **Detection**: Automatically detects you're running a single executable
|
|
75
|
+
2. **Version Check**: Compares current version with latest GitHub release
|
|
76
|
+
3. **Platform Detection**: Identifies your OS and architecture
|
|
77
|
+
4. **Download**: Downloads the appropriate binary from GitHub releases
|
|
78
|
+
5. **Backup**: Creates a backup of your current executable
|
|
79
|
+
6. **Replace**: Replaces the current executable with the new version
|
|
80
|
+
7. **Cleanup**: Removes temporary files and backup
|
|
81
|
+
|
|
82
|
+
### Safety Features
|
|
83
|
+
|
|
84
|
+
- **Automatic Backup**: Creates `.backup` file before upgrade
|
|
85
|
+
- **Rollback on Failure**: Restores backup if upgrade fails
|
|
86
|
+
- **Platform Validation**: Only upgrades if your platform is supported
|
|
87
|
+
- **Executable Detection**: Prevents NPM users from using executable upgrade
|
|
88
|
+
|
|
89
|
+
## Supported Platforms
|
|
90
|
+
|
|
91
|
+
The upgrade command works on:
|
|
92
|
+
- **Linux x64**: `bunosh-linux-x64`
|
|
93
|
+
- **macOS ARM64**: `bunosh-darwin-arm64` (Apple Silicon)
|
|
94
|
+
- **macOS Intel**: `bunosh-darwin-x64`
|
|
95
|
+
- **Windows x64**: `bunosh-windows-x64.exe`
|
|
96
|
+
|
|
97
|
+
## Error Scenarios
|
|
98
|
+
|
|
99
|
+
### Not Running as Executable
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
📦 Bunosh is installed via npm.
|
|
103
|
+
To upgrade, run: npm update -g bunosh
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Unsupported Platform
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
❌ Upgrade failed: Unsupported platform: linux arm64
|
|
110
|
+
|
|
111
|
+
💡 Supported platforms:
|
|
112
|
+
• Linux x64
|
|
113
|
+
• macOS ARM64 (Apple Silicon)
|
|
114
|
+
• Windows x64
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Network Issues
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
❌ Upgrade failed: Failed to fetch release info: fetch failed
|
|
121
|
+
|
|
122
|
+
💡 Try again later or check your internet connection.
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Already Latest Version
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
📍 Current version: 0.1.6
|
|
129
|
+
⬆️ Starting upgrade process...
|
|
130
|
+
|
|
131
|
+
✅ Already on latest version: 0.1.6
|
|
132
|
+
Use --force to reinstall the current version.
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Troubleshooting
|
|
136
|
+
|
|
137
|
+
### Permission Issues (Unix)
|
|
138
|
+
|
|
139
|
+
If you get permission errors:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
sudo bunosh upgrade
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Or move bunosh to a user-writable location:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Move to user bin directory
|
|
149
|
+
mv /usr/local/bin/bunosh ~/bin/bunosh
|
|
150
|
+
export PATH="$HOME/bin:$PATH"
|
|
151
|
+
bunosh upgrade
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Windows Antivirus
|
|
155
|
+
|
|
156
|
+
Some antivirus software may flag the download. This is a false positive. The binaries are:
|
|
157
|
+
- Downloaded from official GitHub releases
|
|
158
|
+
- Signed and verified
|
|
159
|
+
- Scanned by GitHub's security systems
|
|
160
|
+
|
|
161
|
+
### Verification
|
|
162
|
+
|
|
163
|
+
After upgrade, verify the installation:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Check version
|
|
167
|
+
bunosh --version
|
|
168
|
+
|
|
169
|
+
# Check it works
|
|
170
|
+
bunosh --help
|
|
171
|
+
|
|
172
|
+
# Test with a simple command
|
|
173
|
+
bunosh init --help
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Automatic Updates (Future)
|
|
177
|
+
|
|
178
|
+
Future versions may include:
|
|
179
|
+
- **Update notifications** when new versions are available
|
|
180
|
+
- **Automatic background checks** for updates
|
|
181
|
+
- **Scheduled upgrade** options
|
|
182
|
+
|
|
183
|
+
## Rollback
|
|
184
|
+
|
|
185
|
+
If you need to rollback to a previous version:
|
|
186
|
+
|
|
187
|
+
1. Download the older release manually from [GitHub Releases](https://github.com/davertmik/bunosh/releases)
|
|
188
|
+
2. Replace your current executable
|
|
189
|
+
3. Or use `--force` with a manual downgrade
|
|
190
|
+
|
|
191
|
+
## Development Builds
|
|
192
|
+
|
|
193
|
+
For development or beta versions:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Install specific version (manual download required)
|
|
197
|
+
curl -L https://github.com/davertmik/bunosh/releases/download/v0.1.5/bunosh-linux-x64.tar.gz | tar -xz
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The upgrade command only works with official releases, not development builds.
|
package/bunosh.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import program, { BUNOSHFILE, banner } from "./src/program.js";
|
|
3
|
+
import { existsSync, readFileSync, statSync } from "fs";
|
|
4
|
+
import init from "./src/init.js";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import './index.js';
|
|
7
|
+
|
|
8
|
+
// Parse --bunoshfile flag before importing tasks
|
|
9
|
+
const bunoshfileIndex = process.argv.indexOf('--bunoshfile');
|
|
10
|
+
let customBunoshfile = null;
|
|
11
|
+
if (bunoshfileIndex !== -1 && bunoshfileIndex + 1 < process.argv.length) {
|
|
12
|
+
customBunoshfile = process.argv[bunoshfileIndex + 1];
|
|
13
|
+
// Remove the flag and its value from process.argv so it doesn't interfere with command parsing
|
|
14
|
+
process.argv.splice(bunoshfileIndex, 2);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let tasksFile;
|
|
18
|
+
if (customBunoshfile) {
|
|
19
|
+
const resolvedPath = path.isAbsolute(customBunoshfile) ? customBunoshfile : path.resolve(customBunoshfile);
|
|
20
|
+
// If it's a directory, append the default BUNOSHFILE
|
|
21
|
+
if (existsSync(resolvedPath) && statSync(resolvedPath).isDirectory()) {
|
|
22
|
+
tasksFile = path.join(resolvedPath, BUNOSHFILE);
|
|
23
|
+
// Change working directory to the bunoshfile directory
|
|
24
|
+
process.chdir(resolvedPath);
|
|
25
|
+
} else {
|
|
26
|
+
tasksFile = resolvedPath;
|
|
27
|
+
// Change working directory to the bunoshfile's directory
|
|
28
|
+
process.chdir(path.dirname(resolvedPath));
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
tasksFile = path.join(process.cwd(), BUNOSHFILE);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!existsSync(tasksFile)) {
|
|
35
|
+
banner();
|
|
36
|
+
|
|
37
|
+
if (process.argv.includes('init')) {
|
|
38
|
+
init();
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.log();
|
|
43
|
+
console.error(`Bunoshfile not found: ${tasksFile}`);
|
|
44
|
+
console.log(customBunoshfile ?
|
|
45
|
+
`Run \`bunosh init\` in the directory or specify a valid --bunoshfile path` :
|
|
46
|
+
"Run `bunosh init` to create a new Bunoshfile here")
|
|
47
|
+
console.log();
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
import(tasksFile).then((tasks) => {
|
|
52
|
+
program(tasks, readFileSync(tasksFile, "utf-8"));
|
|
53
|
+
}).catch((e) => {
|
|
54
|
+
console.error(`Error loading: ${tasksFile}`);
|
|
55
|
+
console.error(e);
|
|
56
|
+
});
|
package/index.js
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import exec from "./src/tasks/exec.js";
|
|
2
|
+
import fetch from "./src/tasks/fetch.js";
|
|
3
|
+
import writeToFile from "./src/tasks/writeToFile.js";
|
|
4
|
+
import copyFile from "./src/tasks/copyFile.js";
|
|
5
|
+
import { ask, yell, say } from "./src/io.js";
|
|
6
|
+
import { task, stopOnFail, ignoreFail } from "./src/task.js";
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
export { exec, fetch, writeToFile, copyFile, ask, yell, say, task, stopOnFail, ignoreFail };
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
export { program as bunosh };
|
|
11
|
-
|
|
12
|
-
export { io, exec, fetch, task, stopOnFail, ignoreFail, writeToFile };
|
|
13
|
-
export { exec as $ }
|
|
14
|
-
|
|
15
11
|
export function buildCmd(cmd) {
|
|
16
12
|
return function(args) {
|
|
17
13
|
return exec`${cmd} ${args}`
|
|
18
14
|
}
|
|
19
15
|
}
|
|
16
|
+
|
|
17
|
+
global.bunosh = {
|
|
18
|
+
ask, yell, say,
|
|
19
|
+
fetch,
|
|
20
|
+
exec,
|
|
21
|
+
writeToFile,
|
|
22
|
+
copyFile,
|
|
23
|
+
stopOnFail,
|
|
24
|
+
ignoreFail,
|
|
25
|
+
task,
|
|
26
|
+
buildCmd,
|
|
27
|
+
$: exec,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default global.bunosh;
|
package/package.json
CHANGED
|
@@ -1,45 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunosh",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"module": "index.js",
|
|
5
6
|
"bin": {
|
|
6
|
-
"bunosh": "./
|
|
7
|
+
"bunosh": "./bunosh.js"
|
|
7
8
|
},
|
|
8
9
|
"devDependencies": {
|
|
9
10
|
"@types/bun": "latest",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
11
|
+
"lint-staged": "^16.1.2",
|
|
12
|
+
"prettier": "^3.4.3",
|
|
13
|
+
"vitest": "^3.2.4"
|
|
12
14
|
},
|
|
15
|
+
"types": "types.d.ts",
|
|
13
16
|
"dependencies": {
|
|
14
|
-
"@babel/parser": "^7.
|
|
15
|
-
"@babel/traverse": "^7.
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"ink-gradient": "^3.0.0",
|
|
24
|
-
"ink-spinner": "^5.0.0",
|
|
25
|
-
"inquirer": "^9.2.13",
|
|
26
|
-
"open-editor": "^4.1.1",
|
|
27
|
-
"react": "^18.2.0",
|
|
28
|
-
"timer-node": "^5.0.7"
|
|
17
|
+
"@babel/parser": "^7.27.5",
|
|
18
|
+
"@babel/traverse": "^7.27.4",
|
|
19
|
+
"chalk": "^5.4.1",
|
|
20
|
+
"commander": "^14.0.0",
|
|
21
|
+
"debug": "^4.4.1",
|
|
22
|
+
"fs-extra": "^11.3.0",
|
|
23
|
+
"inquirer": "^12.6.3",
|
|
24
|
+
"open-editor": "^5.1.0",
|
|
25
|
+
"timer-node": "^5.0.9"
|
|
29
26
|
},
|
|
30
27
|
"license": "ISC",
|
|
31
28
|
"files": [
|
|
32
29
|
"index.js",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"files.js",
|
|
30
|
+
"bunosh.js",
|
|
31
|
+
"types.d.ts",
|
|
36
32
|
"src",
|
|
37
|
-
"templates"
|
|
38
|
-
|
|
33
|
+
"templates",
|
|
34
|
+
"COMPLETION.md",
|
|
35
|
+
"UPGRADE.md"
|
|
36
|
+
],
|
|
39
37
|
"lint-staged": {
|
|
40
38
|
"*.{js,css,md}": "prettier --write"
|
|
41
39
|
},
|
|
42
40
|
"scripts": {
|
|
41
|
+
"test": "bun test test/",
|
|
42
|
+
"test:watch": "bun test test/ --watch",
|
|
43
|
+
"test:e2e": "vitest run",
|
|
44
|
+
"test:e2e:watch": "vitest",
|
|
45
|
+
"build": "bun build ./bunosh.js --compile --outfile bunosh",
|
|
46
|
+
"build:all": "npm run build:linux && npm run build:macos && npm run build:windows",
|
|
47
|
+
"build:linux": "bun build ./bunosh.js --compile --target=bun-linux-x64 --outfile dist/bunosh-linux-x64",
|
|
48
|
+
"build:macos": "bun build ./bunosh.js --compile --target=bun-darwin-arm64 --outfile dist/bunosh-darwin-arm64",
|
|
49
|
+
"build:windows": "bun build ./bunosh.js --compile --target=bun-windows-x64 --outfile dist/bunosh-windows-x64.exe",
|
|
50
|
+
"test:build": "npm run build && ./bunosh --help && rm bunosh",
|
|
43
51
|
"hello:other": "bunosh hello:other",
|
|
44
52
|
"hello:world": "bunosh hello:world",
|
|
45
53
|
"update:to-production": "bunosh update:to-production",
|