Skip to content

Commit 3b6c2ae

Browse files
committed
Initial CLI example template v1.0.0
0 parents  commit 3b6c2ae

58 files changed

Lines changed: 5290 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
contents: read
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
node-version: [20, 22]
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
cache: npm
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Run lint
35+
run: npm run lint
36+
37+
- name: Run typecheck
38+
run: npm run typecheck
39+
40+
- name: Run unit tests
41+
run: npm run test:unit
42+
43+
- name: Run build
44+
run: npm run build
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish Preview Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish-preview:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node for GitHub Packages
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
registry-url: https://npm.pkg.github.com
25+
scope: "@danielarndt0" # Replace with your GitHub username or organization
26+
cache: npm
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Run lint
32+
run: npm run lint
33+
34+
- name: Run typecheck
35+
run: npm run typecheck
36+
37+
- name: Run unit tests
38+
run: npm run test:unit
39+
40+
- name: Run build
41+
run: npm run build
42+
43+
- name: Set preview version
44+
shell: bash
45+
run: |
46+
BASE_VERSION=$(node -e "const fs=require('fs'); const pkg=JSON.parse(fs.readFileSync('package.json','utf8')); process.stdout.write(pkg.version.split('-')[0]);")
47+
PREVIEW_VERSION="${BASE_VERSION}-dev.${GITHUB_RUN_NUMBER}"
48+
npm version "$PREVIEW_VERSION" --no-git-tag-version --allow-same-version
49+
50+
- name: Publish preview package
51+
run: npm publish --tag dev
52+
env:
53+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Release and Publish Stable Package
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write
14+
packages: write
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node for GitHub Packages
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
registry-url: https://npm.pkg.github.com
25+
scope: "@danielarndt0" # Replace with your GitHub username or organization
26+
cache: npm
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Run lint
32+
run: npm run lint
33+
34+
- name: Run typecheck
35+
run: npm run typecheck
36+
37+
- name: Run unit tests
38+
run: npm run test:unit
39+
40+
- name: Run build
41+
run: npm run build
42+
43+
- name: Sync package version with tag
44+
shell: bash
45+
run: |
46+
VERSION="${GITHUB_REF_NAME#v}"
47+
npm version "$VERSION" --no-git-tag-version --allow-same-version
48+
49+
- name: Pack npm tarball
50+
run: npm pack
51+
52+
- name: Publish stable package
53+
run: npm publish
54+
env:
55+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Create source zip
58+
run: git archive --format=zip --output=cli-example-${GITHUB_REF_NAME}.zip HEAD
59+
60+
- name: Create GitHub Release
61+
uses: softprops/action-gh-release@v2
62+
with:
63+
generate_release_notes: true
64+
files: |
65+
*.tgz
66+
cli-example-${{ github.ref_name }}.zip

.gitignore

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# Snowpack dependency directory (https://snowpack.dev/)
45+
web_modules/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Optional stylelint cache
57+
.stylelintcache
58+
59+
# Optional REPL history
60+
.node_repl_history
61+
62+
# Output of 'npm pack'
63+
*.tgz
64+
65+
# Yarn Integrity file
66+
.yarn-integrity
67+
68+
# dotenv environment variable files
69+
.env
70+
.env.*
71+
!.env.example
72+
73+
# parcel-bundler cache (https://parceljs.org/)
74+
.cache
75+
.parcel-cache
76+
77+
# Next.js build output
78+
.next
79+
out
80+
81+
# Nuxt.js build / generate output
82+
.nuxt
83+
dist
84+
85+
# Gatsby files
86+
.cache/
87+
# Comment in the public line in if your project uses Gatsby and not Next.js
88+
# https://nextjs.org/blog/next-9-1#public-directory-support
89+
# public
90+
91+
# vuepress build output
92+
.vuepress/dist
93+
94+
# vuepress v2.x temp and cache directory
95+
.temp
96+
.cache
97+
98+
# Sveltekit cache directory
99+
.svelte-kit/
100+
101+
# vitepress build output
102+
**/.vitepress/dist
103+
104+
# vitepress cache directory
105+
**/.vitepress/cache
106+
107+
# Docusaurus cache and generated files
108+
.docusaurus
109+
110+
# Serverless directories
111+
.serverless/
112+
113+
# FuseBox cache
114+
.fusebox/
115+
116+
# DynamoDB Local files
117+
.dynamodb/
118+
119+
# Firebase cache directory
120+
.firebase/
121+
122+
# TernJS port file
123+
.tern-port
124+
125+
# Stores VSCode versions used for testing VSCode extensions
126+
.vscode-test
127+
128+
# yarn v3
129+
.pnp.*
130+
.yarn/*
131+
!.yarn/patches
132+
!.yarn/plugins
133+
!.yarn/releases
134+
!.yarn/sdks
135+
!.yarn/versions
136+
137+
# Vite logs files
138+
vite.config.js.timestamp-*
139+
vite.config.ts.timestamp-*
140+
141+
# MacOS
142+
.DS_Store
143+
src/.DS_Store
144+
tests/.DS_Store

.npmrc.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@your-scope:registry=https://npm.pkg.github.com
2+
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"semi": true,
3+
"singleQuote": false
4+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Daniel Arndt
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# CLI Example
2+
3+
**CLI Example** is a reusable template for building command-line tools with **TypeScript**, **Commander**, **Tsup**, **Vitest**, and **GitHub Actions**.
4+
5+
The README stays intentionally short. The detailed maintenance docs live in the `docs/` folder.
6+
7+
## What this repository includes
8+
9+
- CLI entrypoint with separated command registrars
10+
- `core` layer for errors, common types, and utilities
11+
- `services` layer for reusable logic
12+
- example commands with arguments, options, and help text
13+
- build, lint, typecheck, and test scripts
14+
- GitHub Actions for CI and publishing
15+
16+
## Example commands
17+
18+
```bash
19+
cli-example --help
20+
cli-example --version
21+
cli-example hello --name world
22+
cli-example math sum 10 20 30
23+
cli-example math multiply 2 3 4
24+
cli-example system info
25+
cli-example text digits "Order #AB-123"
26+
cli-example array unique red blue red green
27+
cli-example random pick apple banana orange
28+
```
29+
30+
## Local development
31+
32+
```bash
33+
npm install
34+
npm run build
35+
npm run cli -- --help
36+
npm run cli -- system info
37+
npm run cli -- math average 5 10 15
38+
```
39+
40+
## Documentation map
41+
42+
- [Project structure overview](docs/PROJECT_STRUCTURE.md)
43+
- [Adding a command and service](docs/ADDING_A_COMMAND.md)
44+
- [Core layer overview](docs/CORE.md)
45+
- [DevOps overview](docs/DEVOPS_OVERVIEW.md)
46+
- [DevOps customization](docs/DEVOPS_CUSTOMIZATION.md)
47+
- [.npmrc overview](docs/NPMRC.md)
48+
- [GitHub token overview](docs/GITHUB_TOKEN.md)
49+
- [Publishing](docs/PUBLISHING.md)
50+
51+
## Credits
52+
53+
Repository template maintained by **Daniel Arndt**.

0 commit comments

Comments
 (0)