bunosh 0.1.5 → 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/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,15 +1,12 @@
1
- import program from "./src/program";
2
- import exec from "./src/tasks/exec";
3
- import fetch from "./src/tasks/fetch";
4
- import writeToFile from "./src/tasks/writeToFile";
5
- import io from "./src/io";
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
- import { task, stopOnFail, ignoreFail } from "./src/task";
8
+ export { exec, fetch, writeToFile, copyFile, ask, yell, say, task, stopOnFail, ignoreFail };
8
9
 
9
- export { program as bunosh };
10
-
11
- export { io, exec, fetch, task, stopOnFail, ignoreFail, writeToFile };
12
- export { exec as $ }
13
10
 
14
11
  export function buildCmd(cmd) {
15
12
  return function(args) {
@@ -18,7 +15,7 @@ export function buildCmd(cmd) {
18
15
  }
19
16
 
20
17
  global.bunosh = {
21
- ...io,
18
+ ask, yell, say,
22
19
  fetch,
23
20
  exec,
24
21
  writeToFile,
@@ -30,3 +27,4 @@ global.bunosh = {
30
27
  $: exec,
31
28
  }
32
29
 
30
+ export default global.bunosh;
package/package.json CHANGED
@@ -1,47 +1,53 @@
1
1
  {
2
2
  "name": "bunosh",
3
- "version": "0.1.5",
3
+ "version": "0.2.2",
4
+ "type": "module",
4
5
  "module": "index.js",
5
6
  "bin": {
6
- "bunosh": "./run.js"
7
+ "bunosh": "./bunosh.js"
7
8
  },
8
9
  "devDependencies": {
9
10
  "@types/bun": "latest",
10
- "prettier": "^3.2.4",
11
- "lint-staged": "^15.2.0"
11
+ "lint-staged": "^16.1.2",
12
+ "prettier": "^3.4.3",
13
+ "vitest": "^3.2.4"
12
14
  },
13
- "types": "index.d.ts",
15
+ "types": "types.d.ts",
14
16
  "dependencies": {
15
- "@babel/parser": "^7.23.6",
16
- "@babel/traverse": "^7.23.7",
17
- "@types/node-fetch": "^2.6.11",
18
- "cfonts": "^3.2.0",
19
- "chalk": "^5.3.0",
20
- "commander": "^11.1.0",
21
- "debug": "^4.3.4",
22
- "fs-extra": "^11.2.0",
23
- "ink": "^4.4.1",
24
- "ink-big-text": "^2.0.0",
25
- "ink-gradient": "^3.0.0",
26
- "ink-spinner": "^5.0.0",
27
- "inquirer": "^9.2.13",
28
- "open-editor": "^4.1.1",
29
- "react": "^18.2.0",
30
- "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"
31
26
  },
32
27
  "license": "ISC",
33
28
  "files": [
34
29
  "index.js",
35
- "run.js",
36
- "io.js",
37
- "files.js",
30
+ "bunosh.js",
31
+ "types.d.ts",
38
32
  "src",
39
- "templates"
33
+ "templates",
34
+ "COMPLETION.md",
35
+ "UPGRADE.md"
40
36
  ],
41
37
  "lint-staged": {
42
38
  "*.{js,css,md}": "prettier --write"
43
39
  },
44
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",
45
51
  "hello:other": "bunosh hello:other",
46
52
  "hello:world": "bunosh hello:world",
47
53
  "update:to-production": "bunosh update:to-production",