deduplicate name/version

This commit is contained in:
EatThePooh 2026-02-25 16:20:26 +07:00
parent 8cf96c4282
commit d2aae92692
4 changed files with 9 additions and 11 deletions

View file

@ -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 .
```

View file

@ -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";

View file

@ -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:

View file

@ -9,6 +9,7 @@
"verbatimModuleSyntax": true,
"isolatedModules": true,
"moduleDetection": "force",
"skipLibCheck": true
"skipLibCheck": true,
"resolveJsonModule": true
}
}