You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On `startPushDaemon` the daemon also runs a one-shot startup-backlog check (fetch + `rev-list --count <remote>/<branch>..<branch>`) and queues any commits ahead of the remote; this is how a restarted daemon catches up.
Everything documented in [`specs/`](https://github.com/JarvusInnovations/gitsheets/tree/develop/specs) (and re-exported from `gitsheets`) is stable from v1.0 forward. Internal modules under `dist/` that aren't re-exported are implementation details and may change in minor releases.
250
+
Everything documented in [`specs/`](https://github.com/JarvusInnovations/gitsheets/tree/develop/specs) (and re-exported from `gitsheets`) is stable from v1.0 onward. Additions in minor versions are additive (new methods, new options). Internal modules under `dist/` that aren't re-exported are implementation details and may change in minor releases.
-`--encoding <enc>` — encoding for file/stdin input. Default `utf8`. Accepts any Node `BufferEncoding`.
50
+
-`--delete-missing` — **DESTRUCTIVE**: full-replace mode. After upserting every input record, deletes any record in the sheet whose path isn't in the input set, in the same transaction. If validation fails on any input record, the whole transaction rolls back and the tree is unchanged.
51
+
-`--attachment <name>=<source>` (repeatable) — attach a file alongside the (single) upserted record in the same transaction. `<source>` is a file path (relative to the input file's directory, or cwd when input is stdin) or `-` for stdin (only one `-` per command). Requires a single-record input set.
52
+
53
+
```bash
54
+
gitsheets upsert users '{"slug":"jane"}' \
55
+
--attachment avatar.jpg=./assets/jane.jpg \
56
+
--attachment bio.md=-
57
+
```
58
+
59
+
-`--patch` — treat each input record as an [RFC 7396 JSON Merge Patch](https://datatracker.ietf.org/doc/html/rfc7396). Fields present in the sheet's path template are split out as the query (which existing record to find); the remaining fields are merged into that record. `null` deletes a field. Cannot be combined with `--delete-missing` or `--attachment`.
60
+
61
+
```bash
62
+
# Update jane's email; delete her bio; add a team field.
For sheets whose template uses expressions (e.g., `${{ slug.toLowerCase() }}`), the CLI does a best-effort identifier scan to find the query fields. If that doesn't yield the right split, use the library API `Sheet.patch(query, partial)` directly.
67
+
68
+
TOML input supports three layouts: a `[[records]]` array of tables (recommended for multi-record files), a top-level table where every value is itself a table (each value becomes one record), or a single-record document.
69
+
70
+
CSV input uses the first row as a header. Cell values stay as strings — type coercion belongs in the consumer schema, not in CSV parsing.
39
71
40
72
Output (per record):
41
73
@@ -45,30 +77,55 @@ Output (per record):
45
77
46
78
### `gitsheets query <sheet>`
47
79
48
-
Read records. Output is newline-delimited JSON.
80
+
Read records. Output is newline-delimited JSON by default.
Open a record in `$EDITOR` for interactive editing. On save:
117
+
118
+
1. The CLI re-reads the tmpfile, parses it as TOML.
119
+
2. If the file is byte-identical to what was written out, no commit is made (idempotent — no empty commits).
120
+
3. Otherwise the parsed record is upserted in a transaction; validation, normalization, and path rendering all run.
121
+
122
+
Editor resolution: `$VISUAL` → `$EDITOR` → `vi`. The editor is spawned through a shell, so `EDITOR="code --wait"` and similar wrapped commands work. Exit-code 0 from the editor means "save"; anything else aborts without commit.
123
+
124
+
```bash
125
+
gitsheets edit users jane
126
+
```
127
+
128
+
Validation failures abort with a clear message rather than re-opening the editor — re-edit the input via `gitsheets read users <path> --format=toml` plus `upsert` if you need a second pass.
72
129
73
130
### `gitsheets normalize <sheet>`
74
131
@@ -80,6 +137,55 @@ or after a manual edit that didn't preserve canonical key order.
80
137
gitsheets normalize users
81
138
```
82
139
140
+
### `gitsheets init <sheet>`
141
+
142
+
Scaffold `.gitsheets/<sheet>.toml` with sensible defaults. Useful as a first-step before bulk-importing records.
-`--schema <file>` — embed a JSON Schema file under `[gitsheet.schema]`. The schema is validated through the same loader the runtime uses; an invalid schema aborts before the transaction commits.
159
+
-`--force` — overwrite an existing `.gitsheets/<sheet>.toml`. Without `--force`, init refuses to clobber.
160
+
161
+
### `gitsheets infer <sheet>`
162
+
163
+
Scan every record in the sheet and write a conservative starter `[gitsheet.schema]` block into `.gitsheets/<sheet>.toml`. The committed schema captures observed types per field, plus `minimum`/`maximum` hints for numeric fields and `items.type` for arrays. Fields present in every record are listed under `required`.
164
+
165
+
```bash
166
+
gitsheets infer users
167
+
```
168
+
169
+
Existing `root`, `path`, and any non-schema `fields.<name>.sort` rules are preserved. The result is a starting point — review and tighten (add `pattern`, `format`, etc.) before relying on it.
170
+
171
+
### `gitsheets migrate-config <sheet>`
172
+
173
+
Convert a pre-v1.0 `[gitsheet.fields]` config to a v1.0 `[gitsheet.schema]` config in one transaction.
| HTTP `POST /sheets/:name`| Your own HTTP layer + `sheet.upsert(...)`|
32
32
33
33
## Permissive vs strict mode
@@ -147,11 +147,16 @@ Every gitsheets error extends `GitsheetsError` and carries a stable `code`. See
147
147
148
148
## CLI changes
149
149
150
-
-`git sheet upsert` / `query` / `read` / `normalize` — same command shape, rebuilt against the new core (`edit` deferred to [#150](https://github.com/JarvusInnovations/gitsheets/issues/150))
151
-
-`--patch-existing` → `--patch` (RFC 7396 semantics, deferred — use library `Sheet.patch` for now)
150
+
-`git sheet upsert` / `query` / `read` / `normalize` — same command shape, rebuilt against the new core
151
+
-`git sheet edit <sheet> <path>` — new in v1.1: `$EDITOR`-based round-trip on a record
152
+
-`git sheet init <sheet>` — new in v1.1: scaffold a starter `.gitsheets/<sheet>.toml`
153
+
-`git sheet infer <sheet>` / `migrate-config <sheet>` — new in v1.1: schema inference and pre-v1.0 fields-config migration
Copy file name to clipboardExpand all lines: docs/recipes/migrating-config.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,13 @@
2
2
3
3
Pre-v1.0 gitsheets used a `[gitsheet.fields]` block for typed field configuration. v1.0 replaces it with a proper `[gitsheet.schema]` JSON Schema block. The mapping is lossless for `type` / `enum` / `default`; `sort` stays where it is (it's a different concept); `trueValues` / `falseValues` move to a CSV-ingest helper.
4
4
5
-
> The `gitsheets migrate-config <sheet>` CLI command that automates this is tracked at [#151](https://github.com/JarvusInnovations/gitsheets/issues/151) — until that lands, follow this guide manually.
5
+
The `gitsheets migrate-config <sheet>` CLI command (shipped in v1.1) automates this:
6
+
7
+
```bash
8
+
gitsheets migrate-config users --message='migrate users config to v1.0 schema'
9
+
```
10
+
11
+
This guide walks through what the command does step-by-step, useful when you want to understand the resulting config or apply migrations by hand.
|`sort: ...`|`[gitsheet.fields.<name>.sort]` (unchanged — different concept) |
152
-
|`trueValues` / `falseValues`|Moves to a CSV-ingest helper (deferred)|
152
+
|`trueValues` / `falseValues`|Out of scope for the validation layer — `gitsheets migrate-config` emits a warning; CSV-input boolean coercion stays a consumer concern|
153
153
154
154
See the [migrating-config recipe](recipes/migrating-config.md) for a worked example.
0 commit comments