I idea came while I was discussing plugins with @wonderwhy.er , when he mentioned bolt can be a npm package which can be used as library.
which sparked the idea of why not first publish the releases of bolt as standalone npm package like jupyter notebook or lab
also I hate the idea of regular end users doing git clone to run the project.
What if we publish the release as bolt package in npm with a bin to start the application
for example:
user goes to terminal and types
npm install bolt -g
this will install bolt as a package in there system
then in the terminal the can type
bolt --port 3000
this will start the local bolt server
here is a simple implementation is did
here is a PR that you can try
stackblitz-labs:main
β thecodacus:bolt-cli
opened 06:30PM - 24 Dec 24 UTC
# Add CLI Support for Global Installation
## Overview
This PR adds CLI suppo⦠rt to the Bolt package, enabling users to install and run Bolt globally via npm. This change significantly improves the user experience by allowing users to run Bolt directly as a command line tool, eliminating the need to clone the repository and manage potentially unstable development versions.
## Key Changes
### 1. CLI Implementation
- Added new `bin/bolt.js` script for CLI functionality
- Configured package.json for global npm installation
- Implemented command-line argument parsing for port, help, and version flags
- Added user-friendly banner and help messages
### 2. Package Configuration
- Updated package.json with bin configuration for CLI support
- Added necessary files array to specify published package contents
- Changed package name to "bolt-diy" for npm registry
- Maintained version numbering and package configuration
## Technical Details
### CLI Implementation
Key technical implementation details:
- Uses Node.js spawn to manage the development server process
- Implements clean process management with proper signal handling
- Provides version detection from package.json
- Supports custom port configuration
Simple usage example:
```javascript
// Command line usage
bolt // Start with default settings
bolt --port 3000 // Start on custom port
bolt --help // Show help message
bolt --version // Display version info
// Core CLI implementation
const options = {
port: 5173,
help: false,
version: false
};
// Parse arguments
for (let i = 0; i < args.length; i++) {
const arg = args[i];
switch (arg) {
case '--port':
case '-p':
options.port = parseInt(args[i + 1]);
i++;
break;
// ... other argument handling
}
}
```
### System Changes
- Added new execution path through CLI entry point
- Modified package distribution configuration
- Updated development server startup process
- Maintained backwards compatibility with existing scripts
## Testing
- Verified CLI installation and execution
- Tested all command line arguments
- Validated process management and cleanup
- Confirmed compatibility with existing npm scripts
- Tested error handling for invalid arguments
## Migration Impact
- No breaking changes for existing users
- New installation method available via npm global install
- Repository-based installation continues to work as before
- All existing npm scripts remain functional
## Future Improvements
- Add support for additional CLI configuration options
- Implement environment-specific configurations
- Add auto-update checking functionality
- Consider adding configuration file support
## Example Usage
### Installation
```bash
# Install globally using npm
npm install -g bolt-diy
# Install globally using pnpm
pnpm add -g bolt-diy
# Install globally using yarn
yarn global add bolt-diy
```
### Basic Usage
```bash
# Start Bolt with default settings (port 5173)
bolt
# Start Bolt on a specific port
bolt --port 3000
bolt -p 3000
# View help and available commands
bolt --help
bolt -h
# Check current version
bolt --version
bolt -v
```
### Example Output
```bash
β
ββββββββββββββββββββββββββββββββββββββββ
B O L T . D I Y
β‘οΈ Welcome β‘οΈ
β
ββββββββββββββββββββββββββββββββββββββββ
π Current Version Tag: v0.0.3
π Starting on port: 5173
Please wait until the URL appears here
β
ββββββββββββββββββββββββββββββββββββββββ
```
3 Likes
Ouh you already did that.
Thus could make it possible to run it as npx bolt.diy or something.
Love it.
Need to take a look.
1 Like
done.
you need to use npm link in the project to use the cli, since its not published yet
1 Like
@wonderwhy.er
try running this command in your terminal, no need to clone the repo just anywhere in the terminal
npm install -g bolt.diy
and then try the command after installation
bolt.diy
@aliasfox this uses build version of the code not the dev version
1 Like
thecodacus:
bolt.diy
tried
npx bolt.diy
got this
Tried
npm install -g bolt.diy
got
did work with sudo npm install -g bolt.diy
but then running with
bolt.diy
Running with sudo did work
But honestly running with sudo could be concerning to some people
But still great progress towards this!
1 Like
Doesnβt work for me, for either bolt.diy
or npx bolt.diy
after install.
Havenβt tried this on Linux yet, but on Windows it just doesnβt know what to do. And most people probably use Windows:
needs to change the bolt.js file permission with chmodβ¦
also needs to see how this can be done on windows since it might needs a exe maybe
@wonderwhy.er
can you try now. i have added steps to fix the permissions
npm i -g bolt.diy@0.0.5-test-2
It tried to launch the shell script again by default, but then I just browsed to the directory and ran the CMD and it worked for me. Iβm running Windows 11 and I will check on Linux later.
so you where not able to directly run bolt.diy?
It defaulted to the bolt.diy
(no extension/shell script) on Windows and not bolt.diy.cmd
, so no.
I think i need to run a vm with windows to get this fixed
Just tried
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: EACCES: permission denied, open β/Users/eduardruzga/Library/Preferences/.wrangler/registry/boltβ
at async open (node:internal/fs/promises:639:25)
at async writeFile (node:internal/fs/promises:1212:14)
at async Object.registerWorker (/usr/local/lib/node_modules/bolt.diy/node_modules/wrangler/wrangler-dist/cli.js:197368:3)
at async LocalRuntimeController. (/usr/local/lib/node_modules/bolt.diy/node_modules/wrangler/wrangler-dist/cli.js:198485:17)
I wonder if this is something specific to me or my setup
This is on Mac
my doubt is, because I am the creator of the file so I have execute permission. when you are installing i have a script whichdoes βchmodβ to the file to make it executable.
thats where the issue is occurring, its not properly getting executed i believe
I actually released my first npm module over last weeks
As part of it also needed to make things executable
Here how it looks for Claude MCPs usually, may be that can help.
The shx chmod +x dist/*.js part
It should work on windows too
"setup": "dist/setup-claude-server.js"
},
"files": [
"dist"
],
"scripts": {
"sync-version": "node scripts/sync-version.js",
"bump": "node scripts/sync-version.js --bump",
"bump:minor": "node scripts/sync-version.js --bump --minor",
"bump:major": "node scripts/sync-version.js --bump --major",
"build": "tsc && shx cp setup-claude-server.js dist/ && shx chmod +x dist/*.js",
"watch": "tsc --watch",
"start": "node dist/index.js",
"setup": "npm install && npm run build && node setup-claude-server.js",
"prepare": "npm run build",
"test": "node test/test.js",
"test:watch": "nodemon test/test.js",
"link:local": "npm run build && npm link",
"unlink:local": "npm unlink",
"inspector": "npx @modelcontextprotocol/inspector dist/index.js"
},
leex279
January 12, 2025, 2:01pm
17
@thecodacus just let me know / ping me in chat, if I should test something out in windows.
1 Like
i initially put chmod but removed it from the package.json.
never tried shx, is this a builtin command in windows ?
leex279
January 12, 2025, 2:06pm
19
wonderwhy.er:
shx chmod +x dist/*.js
itΒ΄s not a build in command: GitHub - shelljs/shx: Portable Shell Commands for Node
so the package has to have this as dependency
1 Like