From d2aae92692d4a49e2b5ea737f01d729c91f4adb2 Mon Sep 17 00:00:00 2001 From: EatThePooh Date: Wed, 25 Feb 2026 16:20:26 +0700 Subject: [PATCH] deduplicate name/version --- README.md | 9 ++------- flake.nix | 5 +++-- src/index.ts | 3 ++- tsconfig.json | 3 ++- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 23a46a6..5bdd801 100644 --- a/README.md +++ b/README.md @@ -28,15 +28,10 @@ npm run check ## Renaming -To rename the CLI from `name-placeholder` to your desired name: - -```bash -sed -i 's/name-placeholder/your-new-name/g' package.json src/index.ts flake.nix -``` - -Then rebuild: +To rename the CLI, edit the `name` field in `package.json`. Both the Nix package and the CLI will update automatically. ```bash +# Edit package.json, then rebuild: nix build . ``` diff --git a/flake.nix b/flake.nix index a8a0e0d..63adb5b 100644 --- a/flake.nix +++ b/flake.nix @@ -13,12 +13,13 @@ perSystem = { config, system, pkgs, lib, ... }: let + packageJson = builtins.fromJSON (builtins.readFile ./package.json); runtimeDeps = [ ]; # e. g. pkgs.jq runtimePath = lib.makeSearchPath "bin" runtimeDeps; basePackage = { - pname = "name-placeholder"; - version = "0.1.0"; + pname = packageJson.name; + version = packageJson.version; src = ./.; npmDepsHash = "sha256-EvM5ZyNQEW8RYFCfI7Bkju1qL+1y8nleXPAX3IKce78="; npmBuildScript = "build"; diff --git a/src/index.ts b/src/index.ts index 0eda35c..94d805a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ #!/usr/bin/env node +import packageJson from "../package.json" with { type: "json" }; import { buildApplication, buildCommand, @@ -107,7 +108,7 @@ const root = buildRouteMap({ }, }); -const app = buildApplication(root, { name: "name-placeholder" }); +const app = buildApplication(root, { name: packageJson.name }); await run(app, process.argv.slice(2), { process: diff --git a/tsconfig.json b/tsconfig.json index 7762198..d823a16 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "verbatimModuleSyntax": true, "isolatedModules": true, "moduleDetection": "force", - "skipLibCheck": true + "skipLibCheck": true, + "resolveJsonModule": true } }