mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
auto get current package version
This commit is contained in:
5
.changeset/wet-ads-live.md
Normal file
5
.changeset/wet-ads-live.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"create-better-t-stack": patch
|
||||
---
|
||||
|
||||
auto get current package version
|
||||
@@ -1,3 +1,6 @@
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export const TITLE_TEXT = `
|
||||
╔════════════════════════════════════════════════════════════╗
|
||||
║ ║
|
||||
@@ -19,3 +22,7 @@ export const TITLE_TEXT = `
|
||||
║ ║
|
||||
╚════════════════════════════════════════════════════════════╝
|
||||
`;
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const distPath = path.dirname(__filename);
|
||||
export const PKG_ROOT = path.join(distPath, "../");
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Command } from "commander";
|
||||
import { createProject } from "./create-project";
|
||||
import { renderTitle } from "./render-title";
|
||||
import type { ProjectDatabase, ProjectFeature } from "./types";
|
||||
import { getVersion } from "./utils/get-version";
|
||||
import { logger } from "./utils/logger";
|
||||
|
||||
const program = new Command();
|
||||
@@ -116,7 +117,7 @@ process.on("SIGINT", () => {
|
||||
program
|
||||
.name("create-better-t-stack")
|
||||
.description("Create a new Better-T Stack project")
|
||||
.version("1.0.0")
|
||||
.version(getVersion())
|
||||
.option("-y, --yes", "Accept all defaults")
|
||||
.action((options) => main(options));
|
||||
|
||||
|
||||
11
apps/cli/src/utils/get-version.ts
Normal file
11
apps/cli/src/utils/get-version.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import path from "node:path";
|
||||
import fs from "fs-extra";
|
||||
import { PKG_ROOT } from "../consts";
|
||||
|
||||
export const getVersion = () => {
|
||||
const packageJsonPath = path.join(PKG_ROOT, "package.json");
|
||||
|
||||
const packageJsonContent = fs.readJSONSync(packageJsonPath);
|
||||
|
||||
return packageJsonContent.version ?? "1.0.0";
|
||||
};
|
||||
Reference in New Issue
Block a user