Skip to content

Commit

Permalink
feat: add chibivite CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
nozomuikuta committed May 3, 2024
1 parent ac4188a commit 4babe07
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 6 deletions.
7 changes: 7 additions & 0 deletions packages/chibivite/bin/chibivite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env node

function start() {
return import('../dist/node/cli.js')
}

start()
3 changes: 3 additions & 0 deletions packages/chibivite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
"node": ">=20.12.0"
},
"packageManager": "[email protected]",
"bin": "bin/chibivite.js",
"scripts": {
"build": "rimraf dist && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript"
},
"dependencies": {
"rollup": "^4.17.2"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-typescript": "^11.1.6",
"cac": "^6.7.14",
"rimraf": "^5.0.5",
"tslib": "^2.6.2"
}
Expand Down
10 changes: 7 additions & 3 deletions packages/chibivite/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'rollup'
import nodeResolve from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'

const __dirname = fileURLToPath(new URL('.', import.meta.url))

export default defineConfig({
input: path.resolve(__dirname, 'src/index.ts'),
input: {
cli: path.resolve(__dirname, 'src/node/cli.ts'),
},
output: {
dir: './dist',
entryFileNames: `[name].js`,
entryFileNames: `node/[name].js`,
exports: 'named',
format: 'esm',
externalLiveBindings: false,
freeze: false,
sourcemap: true,
},
plugins: [
nodeResolve(),
typescript({
tsconfig: path.resolve(__dirname, 'tsconfig.base.json'),
tsconfig: path.resolve(__dirname, 'src/node/tsconfig.json'),
sourceMap: true,
}),
],
Expand Down
1 change: 0 additions & 1 deletion packages/chibivite/src/index.ts

This file was deleted.

9 changes: 9 additions & 0 deletions packages/chibivite/src/node/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { cac } from 'cac'

const cli = cac('chibivite')

cli.command('[root]', 'start dev server').action(async (root: string) => {
console.log(`Hello, chibivite at ${root}!`)
})

cli.parse()
7 changes: 7 additions & 0 deletions packages/chibivite/src/node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"inlclude": ["./**/*.ts"],
"compilerOptions": {
"lib": ["ESNext", "DOM"]
}
}
2 changes: 0 additions & 2 deletions packages/chibivite/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"inlclude": ["src/**/*.ts"],
"compilerOptions": {
"baseUrl": ".",
"outDir": "dist",
"lib": ["ESNext"],
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
Expand Down
1 change: 1 addition & 0 deletions packages/chibivite/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "./tsconfig.base.json",
"include": ["./rollup.config.ts"],
"compilerOptions": {
"lib": ["ESNext"],
"declaration": false,
"declarationMap": false
}
Expand Down
62 changes: 62 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4babe07

Please sign in to comment.