Skip to content

Commit

Permalink
feat(cli): cli version
Browse files Browse the repository at this point in the history
  • Loading branch information
hngngn committed Feb 9, 2024
1 parent 9059bc6 commit a9f2f72
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 22 deletions.
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@types/lodash.template": "^4.5.1",
"rimraf": "^5.0.1",
"tsup": "^7.2.0",
"type-fest": "^4.10.2",
"typescript": "^5.2.2"
},
"dependencies": {
Expand Down
7 changes: 6 additions & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { add } from "@/src/commands/add"
import { init } from "@/src/commands/init"
import { Command } from "commander"
import { getPackageInfo } from "./utils/get-package-info"

process.on("SIGINT", () => process.exit(0))
process.on("SIGTERM", () => process.exit(0))
Expand All @@ -10,7 +11,11 @@ async function main() {
const program = new Command()
.name("shadcn-solid")
.description("add components and dependencies to your project")
.version("0.4.0", "-v, --version", "display the version number")
.version(
getPackageInfo().version!,
"-v, --version",
"display the version number"
)

program.addCommand(init).addCommand(add)

Expand Down
13 changes: 13 additions & 0 deletions packages/cli/src/utils/get-package-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import fs from "fs-extra"
import { dirname, resolve } from "node:path"
import { type PackageJson } from "type-fest"
import { fileURLToPath } from "url"

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

export function getPackageInfo() {
const packageJsonPath = resolve(__dirname, "../package.json")

return fs.readJSONSync(packageJsonPath) as PackageJson
}
43 changes: 22 additions & 21 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
{
"compilerOptions": {
"composite": false,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true,
"isolatedModules": false,
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
}
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
"compilerOptions": {
"composite": false,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true,
"isolatedModules": false,
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
},
"module": "ES2020"
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
}
8 changes: 8 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 a9f2f72

Please sign in to comment.