Skip to content

Commit

Permalink
fix(cli): Fix CLI version in help message. Fixes hoarder-app#139
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Jun 9, 2024
1 parent 2d0af0b commit f7a7753
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
6 changes: 5 additions & 1 deletion apps/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ const program = new Command()
.makeOptionMandatory(true)
.env("HOARDER_SERVER_ADDR"),
)
.version(process.env.npm_package_version ?? "0.0.0");
.version(
import.meta.env && "CLI_VERSION" in import.meta.env
? import.meta.env.CLI_VERSION
: "0.0.0",
);

program.addCommand(bookmarkCmd);
program.addCommand(listsCmd);
Expand Down
9 changes: 9 additions & 0 deletions apps/cli/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly CLI_VERSION: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}
3 changes: 2 additions & 1 deletion apps/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"strictNullChecks": true,
"paths": {
"@/*": ["./src/*"]
}
},
"types": ["vite/client"]
}
}
5 changes: 5 additions & 0 deletions apps/cli/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ export default defineConfig({
noExternal: /^(?!node:).*$/,
},
plugins: [tsconfigPaths()],
define: {
"import.meta.env.CLI_VERSION": JSON.stringify(
process.env.npm_package_version,
),
},
});

0 comments on commit f7a7753

Please sign in to comment.