mirror of
https://github.com/sajenim/javascript-template.git
synced 2025-12-17 03:50:40 +08:00
Add interactive REPL with helpers and improve package management
- Add Node.js to devshell for mature, stable REPL - Create .replrc.js with println() and dir() helpers - Add 'just repl' command with auto-loaded helpers - Add 'just add-dev' and 'just remove' for package management - Update README with complete command reference and feature list
This commit is contained in:
parent
6f67a0dc1a
commit
506821f638
4 changed files with 32 additions and 2 deletions
5
.replrc.js
Normal file
5
.replrc.js
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
// REPL helper functions
|
||||||
|
// Loaded automatically by `just repl`
|
||||||
|
|
||||||
|
globalThis.println = (...args) => console.log(...args);
|
||||||
|
globalThis.dir = (obj) => console.dir(obj, { depth: null, colors: true });
|
||||||
8
Justfile
8
Justfile
|
|
@ -6,6 +6,10 @@ default:
|
||||||
dev:
|
dev:
|
||||||
bun run dev
|
bun run dev
|
||||||
|
|
||||||
|
# Start interactive REPL with auto-loaded helpers
|
||||||
|
repl:
|
||||||
|
node --eval "await import('./.replrc.js')" -i
|
||||||
|
|
||||||
# Add a package dependency
|
# Add a package dependency
|
||||||
add package:
|
add package:
|
||||||
bun add {{package}}
|
bun add {{package}}
|
||||||
|
|
@ -34,6 +38,10 @@ install:
|
||||||
update:
|
update:
|
||||||
nix flake update
|
nix flake update
|
||||||
|
|
||||||
|
# Upgrade package dependencies
|
||||||
|
upgrade:
|
||||||
|
bun update
|
||||||
|
|
||||||
# Clean build artifacts and dependencies
|
# Clean build artifacts and dependencies
|
||||||
clean:
|
clean:
|
||||||
rm -rf dist node_modules bun.lockb
|
rm -rf dist node_modules bun.lockb
|
||||||
|
|
|
||||||
20
README.md
20
README.md
|
|
@ -3,8 +3,9 @@
|
||||||
A minimal JavaScript development template using Nix. Key features:
|
A minimal JavaScript development template using Nix. Key features:
|
||||||
|
|
||||||
- Nix + Flakes for reproducible environments
|
- Nix + Flakes for reproducible environments
|
||||||
- Bun (fast JavaScript runtime)
|
- Bun (fast JavaScript runtime & package manager)
|
||||||
- Vite (development server & build tool)
|
- Vite (development server & build tool)
|
||||||
|
- Node.js (mature REPL with custom helpers)
|
||||||
- ESLint + Prettier (linting & formatting)
|
- ESLint + Prettier (linting & formatting)
|
||||||
- Devshell commands via just
|
- Devshell commands via just
|
||||||
|
|
||||||
|
|
@ -37,14 +38,29 @@ just dev
|
||||||
fhs = true;
|
fhs = true;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Available Commands
|
||||||
|
|
||||||
|
Run `just` to see all available commands:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
just dev # Start dev server
|
||||||
|
just repl # Node.js REPL with helpers
|
||||||
|
just lint # Lint with ESLint
|
||||||
|
just format # Format with Prettier
|
||||||
|
just build # Production build
|
||||||
|
just clean # Clean build artifacts
|
||||||
|
just update # Update flake inputs
|
||||||
|
just upgrade # Upgrade bun packages
|
||||||
|
```
|
||||||
|
|
||||||
## Customization
|
## Customization
|
||||||
|
|
||||||
This template provides minimal, sensible defaults. Customize as needed:
|
This template provides minimal, sensible defaults. Customize as needed:
|
||||||
|
|
||||||
- Add dependencies: `just add <package>`
|
|
||||||
- Modify linting rules in `eslint.config.js`
|
- Modify linting rules in `eslint.config.js`
|
||||||
- Add Prettier config via `.prettierrc` if needed
|
- Add Prettier config via `.prettierrc` if needed
|
||||||
- Extend `Justfile` with project-specific commands
|
- Extend `Justfile` with project-specific commands
|
||||||
|
- Add custom REPL helpers in `.replrc.js`
|
||||||
|
|
||||||
## Acknowledgments
|
## Acknowledgments
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ in {
|
||||||
nativeBuildInputs = with pkgs;
|
nativeBuildInputs = with pkgs;
|
||||||
[
|
[
|
||||||
bun
|
bun
|
||||||
|
nodejs
|
||||||
eslint
|
eslint
|
||||||
just
|
just
|
||||||
prettierd
|
prettierd
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue