Seed default config on install; share defaults JSON with runtime
The defaults now live in a single file, scripts/config.default.json:
- src/config.ts imports it via 'with { type: "json" }' and derives
DEFAULT_CONFIG (with seconds->ms conversion at the boundary), so the
CLI help text always matches what the seeded user config contains.
- scripts/install.sh copies the same file to
$XDG_CONFIG_HOME/move/config.json only if no file is already there.
Existing configs (yours or from a previous install) are never
overwritten.
- scripts/uninstall.sh does not touch the user config file at all,
following the strict Unix convention. It does print a one-line
notice pointing at the path so the user can rm -rf the dir
themselves if they want a fully-clean removal.
- tsconfig.json gains resolveJsonModule:true so tsc accepts the JSON
import.
- A small runtime assertion in src/config.ts (assertSeedShape) fails
loudly if the seed file is missing keys or has wrong types.
- README Configuration section documents the seed behavior; Uninstall
section documents the leave-config-behind policy with the rm-it-
yourself command; Files table gains scripts/config.default.json.
This commit is contained in:
@@ -67,6 +67,15 @@ curl -fsSL https://gitea.cahlen.com/nokeo08/Move/raw/branch/master/scripts/unins
|
||||
Removes the wrapper at `$XDG_BIN_HOME/move` and the install tree at
|
||||
`$XDG_DATA_HOME/move`. Bun stays — it's your runtime, not ours.
|
||||
|
||||
Your config file at `$XDG_CONFIG_HOME/move/config.json` is **intentionally
|
||||
left behind**, whether you customized it or never touched the seeded
|
||||
defaults. The uninstaller prints a one-line notice pointing at the path
|
||||
so you can remove it manually if you want:
|
||||
|
||||
```sh
|
||||
rm -rf "${XDG_CONFIG_HOME:-$HOME/.config}/move"
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
@@ -109,7 +118,13 @@ error to `stderr` and exits with code `2`.
|
||||
${XDG_CONFIG_HOME:-$HOME/.config}/move/config.json
|
||||
```
|
||||
|
||||
If the file is missing, defaults are used (no config file is required).
|
||||
The installer seeds this file with the default values on a fresh install,
|
||||
**only if no file already exists at that path**. Existing configs — yours
|
||||
or from a previous install — are never overwritten. If you remove the
|
||||
file later, `move` still works: missing defaults fall back to the values
|
||||
baked into the binary (which match what was seeded, since both come from
|
||||
`scripts/config.default.json`).
|
||||
|
||||
Pass `-C` / `--config <path>` to point at a different file; in that mode
|
||||
the file must exist.
|
||||
|
||||
@@ -252,12 +267,13 @@ move --help
|
||||
|
||||
| File | Purpose |
|
||||
| ------------------- | ----------------------------------------------------------------------------- |
|
||||
| `scripts/install.sh` | End-user installer; curl-pipeable from Gitea. |
|
||||
| `scripts/uninstall.sh` | End-user uninstaller; curl-pipeable from Gitea. |
|
||||
| `scripts/dev-setup.sh` | Contributor bootstrap (verify Bun + `bun install`). |
|
||||
| `scripts/install.sh` | End-user installer; curl-pipeable from Gitea. |
|
||||
| `scripts/uninstall.sh` | End-user uninstaller; curl-pipeable from Gitea. |
|
||||
| `scripts/dev-setup.sh` | Contributor bootstrap (verify Bun + `bun install`). |
|
||||
| `scripts/config.default.json`| Single source of truth for default values: imported by `src/config.ts` and copied to `$XDG_CONFIG_HOME/move/config.json` on a fresh install. |
|
||||
| `src/move.ts` | CLI entry point: parses args, dispatches help/version, starts the loop. |
|
||||
| `src/cli.ts` | Argument parsing, validation, and help/version output. |
|
||||
| `src/config.ts` | `Config` type (carries every tunable, including `verbose`), `DEFAULT_CONFIG`, `defaultConfigPath`, and the layered `resolveConfig` overlay. |
|
||||
| `src/config.ts` | `Config` type (carries every tunable, including `verbose`), `DEFAULT_CONFIG` (derived from `scripts/config.default.json`), `defaultConfigPath`, and the layered `resolveConfig` overlay. |
|
||||
| `src/configFile.ts` | Optional JSON config-file loader with strict schema validation. |
|
||||
| `src/keeper.ts` | Synthetic-activity sweep and idle-watch loop. |
|
||||
| `package.json` | Bun project manifest. Single runtime dep: `@nut-tree-fork/nut-js`. |
|
||||
|
||||
Reference in New Issue
Block a user