Skip to content

Commit 9189ef4

Browse files
committed
feat(node): add CLI and library templates
1 parent efe82b9 commit 9189ef4

27 files changed

Lines changed: 10491 additions & 7 deletions

.github/workflows/template-smoke.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,46 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
template:
20-
- bun/cli
21-
- bun/lib
19+
include:
20+
- template: bun/cli
21+
runtime: bun
22+
install: bun install
23+
verify: bun run verify
24+
- template: bun/lib
25+
runtime: bun
26+
install: bun install
27+
verify: bun run verify
28+
- template: node/cli
29+
runtime: node
30+
install: npm ci
31+
verify: npm run verify
32+
- template: node/lib
33+
runtime: node
34+
install: npm ci
35+
verify: npm run verify
2236

2337
steps:
2438
- name: Checkout
2539
uses: actions/checkout@v6
2640

41+
- name: Setup Node.js
42+
if: matrix.runtime == 'node'
43+
uses: actions/setup-node@v6
44+
with:
45+
node-version: 24
46+
cache: npm
47+
cache-dependency-path: ${{ matrix.template }}/package-lock.json
48+
2749
- name: Setup Bun
50+
if: matrix.runtime == 'bun'
2851
uses: oven-sh/setup-bun@v2
2952
with:
3053
bun-version: "1.3.11"
3154

3255
- name: Install dependencies
3356
working-directory: ${{ matrix.template }}
34-
run: bun install
57+
run: ${{ matrix.install }}
3558

3659
- name: Verify template
3760
working-directory: ${{ matrix.template }}
38-
run: bun run verify
61+
run: ${{ matrix.verify }}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ Use [giget](https://github.com/unjs/giget) to scaffold a new project:
1010
npx giget gh:bentruyman/templates/<template> <project-name>
1111
```
1212

13+
The Node templates require Node.js 24 or newer.
14+
1315
## Available Templates
1416

1517
| Template | Description | Command |
1618
| -------------------- | ---------------------------------------------- | -------------------------------------------------- |
1719
| [bun/cli](./bun/cli) | Bun CLI with TypeScript, Husky, and release-it | `npx giget gh:bentruyman/templates/bun/cli my-cli` |
1820
| [bun/lib](./bun/lib) | Bun library with TypeScript, Husky, and release-it | `npx giget gh:bentruyman/templates/bun/lib my-lib` |
21+
| [node/cli](./node/cli) | Node.js CLI with TypeScript, Vitest, Husky, and release-it | `npx giget gh:bentruyman/templates/node/cli my-cli` |
22+
| [node/lib](./node/lib) | Node.js library with TypeScript, Vitest, Husky, and release-it | `npx giget gh:bentruyman/templates/node/lib my-lib` |
1923

2024
See each template's README for detailed usage instructions.

node/cli/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
node_modules/

node/cli/.husky/pre-commit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
npm exec lint-staged
2+
npm run typecheck
3+
npm test

node/cli/.oxfmtrc.jsonc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"ignorePatterns": [".agents"],
4+
"printWidth": 80,
5+
"proseWrap": "always",
6+
"sortImports": true,
7+
"sortPackageJson": {
8+
"sortScripts": true,
9+
},
10+
}

node/cli/.release-it.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://unpkg.com/release-it/schema/release-it.json",
3+
"git": {
4+
"commitMessage": "chore: release v${version}"
5+
},
6+
"github": {
7+
"release": true
8+
},
9+
"npm": {
10+
"publish": true
11+
},
12+
"hooks": {
13+
"before:init": ["npm run typecheck", "npm test"],
14+
"after:bump": "npm run build"
15+
}
16+
}

node/cli/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# node/cli
2+
3+
A TypeScript CLI template using Node.js.
4+
5+
## Requirements
6+
7+
- Node.js 24 or newer
8+
9+
## Getting Started
10+
11+
```bash
12+
npx giget gh:bentruyman/templates/node/cli my-cli
13+
cd my-cli
14+
npm install
15+
```
16+
17+
## Customize
18+
19+
Update `package.json` with your project details:
20+
21+
- `name` - Your CLI package name
22+
- `description` - What your CLI does
23+
- `bin` - Rename the command users will type
24+
25+
## Scripts
26+
27+
| Script | Description |
28+
| ------------------- | --------------------------------------------- |
29+
| `npm run build` | Compile the CLI to `dist/` |
30+
| `npm run format` | Format code with oxfmt and apply oxlint fixes |
31+
| `npm run lint` | Check formatting and lint the template |
32+
| `npm test` | Run tests with Vitest |
33+
| `npm run typecheck` | Type-check with TypeScript |
34+
| `npm run verify` | Run lint, typecheck, test, and build |
35+
| `npm run release` | Publish a new version with release-it |
36+
37+
## Development
38+
39+
Run your CLI locally with Node's native TypeScript support:
40+
41+
```bash
42+
node src/index.ts --help
43+
```
44+
45+
## Publishing
46+
47+
1. Update `package.json` name and bin fields
48+
2. Run `npm run release` to build, tag, and publish to npm

0 commit comments

Comments
 (0)