Skip to content

Commit

Permalink
feat: add cli boilerplate
Browse files Browse the repository at this point in the history
chore: wip
  • Loading branch information
chrisbbreuer committed Jan 2, 2025
1 parent 6648ec8 commit fe10983
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
29 changes: 29 additions & 0 deletions bin/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { CAC } from 'cac'
import { version } from '../package.json'
import { config } from '../src/config'

const cli = new CAC('my-cli')

interface ReverseProxyOption {
from: string
verbose: boolean
}

cli
.command('start', 'Start the Reverse Proxy Server')
.option('--from <from>', 'The URL to proxy from')
.option('--verbose', 'Enable verbose logging')
.example('reverse-proxy start --from localhost:5173 --to my-project.localhost')
.action(async (options?: ReverseProxyOption) => {
if (!options?.from || !options.to) {
return startProxies(config)
}
})

cli.command('version', 'Show the version of the CLI').action(() => {
console.log(version)
})

cli.version(version)
cli.help()
cli.parse()
2 changes: 2 additions & 0 deletions cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bun
import('./bin/cli')
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,23 @@
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": ["dist"],
"bin": {
"bin-name": "./dist/bin/cli.js"
},
"scripts": {
"build": "bun --bun build.ts",
"build": "bun --bun build.ts && bun run compile",
"compile": "bun build ./bin/cli.ts --compile --minify --outfile bin/bin-name",
"compile:all": "bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:windows-x64 && bun run compile:darwin-x64 && bun run compile:darwin-arm64",
"compile:linux-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64 --outfile bin/bin-name-linux-x64",
"compile:linux-arm64": "bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64 --outfile bin/bin-name-linux-arm64",
"compile:windows-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-windows-x64 --outfile bin/bin-name-windows-x64.exe",
"compile:darwin-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-darwin-x64 --outfile bin/bin-name-darwin-x64",
"compile:darwin-arm64": "bun build ./bin/cli.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/bin-name-darwin-arm64",
"lint": "bunx --bun eslint --flag unstable_ts_config .",
"lint:fix": "bunx --bun eslint --flag unstable_ts_config . --fix",
"fresh": "bunx rimraf node_modules/ bun.lock && bun i",
"changelog": "bunx changelogen --output CHANGELOG.md",
"prepublishOnly": "bun --bun run build",
"prepublishOnly": "bun --bun run build && bun run compile:all",
"release": "bun run changelog && bunx bumpp package.json --all",
"test": "bun test",
"dev:docs": "bun --bun vitepress dev docs",
Expand Down

0 comments on commit fe10983

Please sign in to comment.