@tobisk/codesafari 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -0
- package/dist/cli.js +22 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/export.d.ts +2 -0
- package/dist/commands/export.js +6 -0
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/gitignore.d.ts +8 -0
- package/dist/commands/gitignore.js +31 -0
- package/dist/commands/gitignore.js.map +1 -0
- package/dist/commands/insert.d.ts +49 -0
- package/dist/commands/insert.js +279 -0
- package/dist/commands/insert.js.map +1 -0
- package/dist/commands/validate.js +1 -1
- package/dist/commands/validate.js.map +1 -1
- package/dist/content/loadContent.d.ts +9 -1
- package/dist/content/loadContent.js +87 -1
- package/dist/content/loadContent.js.map +1 -1
- package/dist/ignore/ignore.d.ts +1 -0
- package/dist/ignore/ignore.js +54 -2
- package/dist/ignore/ignore.js.map +1 -1
- package/dist/manifest/build.js +21 -12
- package/dist/manifest/build.js.map +1 -1
- package/dist/model/types.d.ts +26 -0
- package/package.json +2 -2
- package/skills/README.md +53 -0
- package/skills/authoring-code-safaris/SKILL.md +411 -0
- package/viewer-dist/assets/{abnfDiagram-VRR7QNED-D3fx4JHm.js → abnfDiagram-VRR7QNED-CUtCPUcK.js} +1 -1
- package/viewer-dist/assets/{arc-CDTQlIOl.js → arc-DT1qPdzO.js} +1 -1
- package/viewer-dist/assets/{architectureDiagram-ZJ3FMSHR-Bc-C9AOz.js → architectureDiagram-ZJ3FMSHR-Clz4_k6c.js} +1 -1
- package/viewer-dist/assets/{blockDiagram-677ZJIJ3-ZChUq7oC.js → blockDiagram-677ZJIJ3-BprAT8ww.js} +1 -1
- package/viewer-dist/assets/{c4Diagram-LMCZKHZV-Bh84Wvzw.js → c4Diagram-LMCZKHZV-K4EFS-bi.js} +1 -1
- package/viewer-dist/assets/channel-B6VWJVDA.js +1 -0
- package/viewer-dist/assets/{chunk-2Q5K7J3B-BL2GPise.js → chunk-2Q5K7J3B-wt4j9iAJ.js} +1 -1
- package/viewer-dist/assets/{chunk-32BRIVSS-C8J4_0PY.js → chunk-32BRIVSS-DZndHhpA.js} +1 -1
- package/viewer-dist/assets/{chunk-5VM5RSS4-BEPuob2j.js → chunk-5VM5RSS4-Zc4pbF2-.js} +1 -1
- package/viewer-dist/assets/{chunk-EX3LRPZG-C8dshNGY.js → chunk-EX3LRPZG-D150rsiB.js} +1 -1
- package/viewer-dist/assets/{chunk-JWPE2WC7-DB3UPcb9.js → chunk-JWPE2WC7-CnWGcCgD.js} +1 -1
- package/viewer-dist/assets/{chunk-MOJQB5TN-CoW82BtI.js → chunk-MOJQB5TN-CNNkBqHI.js} +1 -1
- package/viewer-dist/assets/{chunk-RYQCIY6F-BSkOviuC.js → chunk-RYQCIY6F-BohP8cpF.js} +1 -1
- package/viewer-dist/assets/{chunk-V7JOEXUC-C3uhoOMH.js → chunk-V7JOEXUC-O8PMb1tP.js} +1 -1
- package/viewer-dist/assets/{chunk-VR4S4FIN-IAlLBWOE.js → chunk-VR4S4FIN-AjltP-MY.js} +1 -1
- package/viewer-dist/assets/{chunk-XXDRQBXY-BZ2dkDjb.js → chunk-XXDRQBXY-BOvzmjQv.js} +1 -1
- package/viewer-dist/assets/classDiagram-OUVF2IWQ-7lFY7hbW.js +1 -0
- package/viewer-dist/assets/classDiagram-v2-EOCWNBFH-7lFY7hbW.js +1 -0
- package/viewer-dist/assets/{cose-bilkent-JH36ORCC-qThT2S0A.js → cose-bilkent-JH36ORCC-BI5sbJIe.js} +1 -1
- package/viewer-dist/assets/{cynefin-VYW2F7L2-DMuuSzID.js → cynefin-VYW2F7L2-DsqQ6c-8.js} +1 -1
- package/viewer-dist/assets/{cynefinDiagram-TSTJHNR4-58B-tzsV.js → cynefinDiagram-TSTJHNR4-aSrdlJhs.js} +1 -1
- package/viewer-dist/assets/{dagre-VKFMJZFB-DD2dvjEA.js → dagre-VKFMJZFB-C1JJb4il.js} +1 -1
- package/viewer-dist/assets/{diagram-FQU43EPY-BwhXWJOe.js → diagram-FQU43EPY-bqnjeq9L.js} +1 -1
- package/viewer-dist/assets/{diagram-G47NLZAW-Bvw3coaF.js → diagram-G47NLZAW-CI_3tBI7.js} +1 -1
- package/viewer-dist/assets/{diagram-NH7WQ7WH-Cug3_TDj.js → diagram-NH7WQ7WH--Cuuj_l0.js} +1 -1
- package/viewer-dist/assets/{diagram-OA4YK3LP-COuB13FS.js → diagram-OA4YK3LP-Ber9CxgW.js} +1 -1
- package/viewer-dist/assets/{diagram-WEI45ONY-Cs9bIVJ-.js → diagram-WEI45ONY-DA4LRa2G.js} +1 -1
- package/viewer-dist/assets/{ebnfDiagram-CCIWWBDH-DNxW5fFn.js → ebnfDiagram-CCIWWBDH-BWw30PPO.js} +1 -1
- package/viewer-dist/assets/{erDiagram-Q63AITRT-CoxCZQYq.js → erDiagram-Q63AITRT-CvTYXHZZ.js} +1 -1
- package/viewer-dist/assets/{flowDiagram-23GEKE2U-DDOkOM11.js → flowDiagram-23GEKE2U-Jzg6zox9.js} +1 -1
- package/viewer-dist/assets/{ganttDiagram-NO4QXBWP-BMIv-Vup.js → ganttDiagram-NO4QXBWP-DXxub_Mn.js} +1 -1
- package/viewer-dist/assets/{gitGraphDiagram-IHSO6WYX-CaYRI7Ti.js → gitGraphDiagram-IHSO6WYX-DplAVHS7.js} +1 -1
- package/viewer-dist/assets/index-DVLkX2-Z.css +1 -0
- package/viewer-dist/assets/{index-DPa56qLF.js → index-MwqpmjOm.js} +96 -96
- package/viewer-dist/assets/{infoDiagram-FWYZ7A6U-CG1-XeBO.js → infoDiagram-FWYZ7A6U-Df_ey2Yt.js} +1 -1
- package/viewer-dist/assets/{ishikawaDiagram-FXEZZL3T-BAaIgDfG.js → ishikawaDiagram-FXEZZL3T-C68vhFVb.js} +1 -1
- package/viewer-dist/assets/{journeyDiagram-5HDEW3XC-oPpLTcMj.js → journeyDiagram-5HDEW3XC-CoDmHoV3.js} +1 -1
- package/viewer-dist/assets/{kanban-definition-HUTT4EX6-wplcQi9I.js → kanban-definition-HUTT4EX6-B6r0jwQw.js} +1 -1
- package/viewer-dist/assets/{linear-3o0ZqjSV.js → linear-DIoMe8rR.js} +1 -1
- package/viewer-dist/assets/{mindmap-definition-LN4V7U3C-FkdX9xoS.js → mindmap-definition-LN4V7U3C-Bnswylok.js} +1 -1
- package/viewer-dist/assets/{pegDiagram-2B236MQR-UcxUgXaX.js → pegDiagram-2B236MQR-DIN1FTnX.js} +1 -1
- package/viewer-dist/assets/{pieDiagram-ENE6RG2P-BEujiO1u.js → pieDiagram-ENE6RG2P-CprqMtkw.js} +1 -1
- package/viewer-dist/assets/{quadrantDiagram-ABIIQ3AL-BsWx4RNa.js → quadrantDiagram-ABIIQ3AL-BDDULhdJ.js} +1 -1
- package/viewer-dist/assets/{railroadDiagram-RFXS5EU6-CaiR8155.js → railroadDiagram-RFXS5EU6-DYchCzqc.js} +1 -1
- package/viewer-dist/assets/{requirementDiagram-TGXJPOKE-B7WepZjB.js → requirementDiagram-TGXJPOKE-C5wnr9uO.js} +1 -1
- package/viewer-dist/assets/{sankeyDiagram-HTMAVEWB-D2ys-GcR.js → sankeyDiagram-HTMAVEWB-DkwntNXb.js} +1 -1
- package/viewer-dist/assets/{sequenceDiagram-DBY2YBRQ-BCx5Lqm4.js → sequenceDiagram-DBY2YBRQ-CjDmNFC_.js} +1 -1
- package/viewer-dist/assets/{sizeCapture-X5ZJPWSS-CdyWDUKU.js → sizeCapture-X5ZJPWSS-DPuxDmrs.js} +1 -1
- package/viewer-dist/assets/{stateDiagram-2N3HPSRC-CKjHd02p.js → stateDiagram-2N3HPSRC-BYVZZo-M.js} +1 -1
- package/viewer-dist/assets/stateDiagram-v2-6OUMAXLB-BRXNY8_F.js +1 -0
- package/viewer-dist/assets/{swimlanes-5IMT3BWC-wE7K0Eo8.js → swimlanes-5IMT3BWC-GXmz8FzP.js} +2 -2
- package/viewer-dist/assets/swimlanesDiagram-G3AALYLV-Gfb32vBV.js +8 -0
- package/viewer-dist/assets/{timeline-definition-FHXFAJF6-B9iZKy9Y.js → timeline-definition-FHXFAJF6-CQLwZsEX.js} +1 -1
- package/viewer-dist/assets/{vennDiagram-L72KCM5P-CIMukQYN.js → vennDiagram-L72KCM5P-DZt4sGqU.js} +1 -1
- package/viewer-dist/assets/{wardleyDiagram-EHGQE667-JZnnBRHP.js → wardleyDiagram-EHGQE667-7OXN_C-l.js} +1 -1
- package/viewer-dist/assets/{xychartDiagram-FW5EYKEG-BphHZiLL.js → xychartDiagram-FW5EYKEG-rI5CAM0A.js} +1 -1
- package/viewer-dist/index.html +2 -2
- package/viewer-dist/assets/channel-c5yLhzg_.js +0 -1
- package/viewer-dist/assets/classDiagram-OUVF2IWQ-t57CRPeZ.js +0 -1
- package/viewer-dist/assets/classDiagram-v2-EOCWNBFH-t57CRPeZ.js +0 -1
- package/viewer-dist/assets/index-sJB3TFqL.css +0 -1
- package/viewer-dist/assets/stateDiagram-v2-6OUMAXLB-oQDdTlVJ.js +0 -1
- package/viewer-dist/assets/swimlanesDiagram-G3AALYLV-Axc7yQiy.js +0 -8
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ npm install --save-dev @tobisk/codesafari
|
|
|
42
42
|
| `codesafari dev [root] --port 4317` | Build the manifest, serve the viewer, watch files, and live-reload. |
|
|
43
43
|
| `codesafari export [root] --out codesafari-site` | Write a frozen manifest, bundled source content, and static assets. |
|
|
44
44
|
| `codesafari validate [root]` | Parse all content and report errors (bad frontmatter, dangling links, unresolved steps, broken Mermaid). |
|
|
45
|
+
| `codesafari insert <spec> [root] --dry-run` | Write `@tour` comments into source files from a JSON spec. |
|
|
45
46
|
|
|
46
47
|
`root` defaults to the current directory. It must contain a `.tour/` folder.
|
|
47
48
|
|
|
@@ -55,6 +56,7 @@ All authored content lives under `.tour/`. Markdown files use YAML frontmatter.
|
|
|
55
56
|
components/*.md # software components
|
|
56
57
|
tours/**/*.md # tour entry pages
|
|
57
58
|
glossary/**/*.md # glossary concepts (one or many per file)
|
|
59
|
+
docs/**/*.md # standalone documentation pages (folders = structure)
|
|
58
60
|
examples/**/*.md # (v1.5) small self-contained code walkthroughs
|
|
59
61
|
```
|
|
60
62
|
|
|
@@ -106,6 +108,45 @@ One file may define many concepts using headings. Link to a concept from anywher
|
|
|
106
108
|
See the [Queue worker](glossary:queue-worker) for details.
|
|
107
109
|
```
|
|
108
110
|
|
|
111
|
+
### Docs — `.tour/docs/**/*.md`
|
|
112
|
+
|
|
113
|
+
Standalone documentation pages for concepts that need more room than a glossary
|
|
114
|
+
entry and don't belong to any one tour. Drop in a Markdown file and it becomes a
|
|
115
|
+
page — no frontmatter or registration required.
|
|
116
|
+
|
|
117
|
+
**Folders are the navigation structure**, recursively. A folder's `index.md`
|
|
118
|
+
becomes that folder's own page, so a section can have prose as well as children;
|
|
119
|
+
a folder without one is a pure grouping node labelled from its name.
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
.tour/docs/
|
|
123
|
+
index.md # the Docs landing page
|
|
124
|
+
architecture/
|
|
125
|
+
index.md # the "Architecture" section's own page
|
|
126
|
+
event-loop.md # nested beneath it
|
|
127
|
+
deployment.md # a top-level page
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Frontmatter is optional:
|
|
131
|
+
|
|
132
|
+
| Field | Effect |
|
|
133
|
+
| --- | --- |
|
|
134
|
+
| `title` | Page heading. Defaults to the leading `# Heading`, then the humanized file name. |
|
|
135
|
+
| `navTitle` | Shorter label for the navigation tree only. Defaults to `title`. |
|
|
136
|
+
| `order` | Sort key among siblings. Unordered pages sort last, alphabetically. |
|
|
137
|
+
|
|
138
|
+
A page's slug is its path under `.tour/docs/` without the extension. Link to one
|
|
139
|
+
from any Markdown in the project — a tour step, a component page, a glossary
|
|
140
|
+
concept, or another doc — with the `doc:` scheme:
|
|
141
|
+
|
|
142
|
+
```markdown
|
|
143
|
+
See [the event loop](doc:architecture/event-loop) for the full story.
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Broken `doc:` links are reported by `codesafari validate`, just like broken
|
|
147
|
+
`glossary:` links. In the viewer, docs get their own navigation tree in the left
|
|
148
|
+
sidebar, under a book icon beneath the file-explorer icon.
|
|
149
|
+
|
|
109
150
|
## Inline tour comments
|
|
110
151
|
|
|
111
152
|
Anchor a tour step to code with a comment whose first line is:
|
|
@@ -145,10 +186,60 @@ Given a step comment, the target range is chosen by what directly follows it:
|
|
|
145
186
|
- Directly before another **block** → that block.
|
|
146
187
|
- Otherwise → the comment plus the next `defaultSnippetLines` lines (tour-level value overrides the project default).
|
|
147
188
|
|
|
189
|
+
## Bulk-inserting steps
|
|
190
|
+
|
|
191
|
+
Placing `@tour` comments by hand is fiddly: consecutive `//`/`#` lines merge
|
|
192
|
+
into one comment block and only the first line is read as the header, so a
|
|
193
|
+
comment written under a doc comment — or under a Rust `#[derive(...)]`, which
|
|
194
|
+
the scanner also sees as a comment — silently stops being a step.
|
|
195
|
+
|
|
196
|
+
`insert` applies a JSON spec instead:
|
|
197
|
+
|
|
198
|
+
```json
|
|
199
|
+
[{
|
|
200
|
+
"file": "src/auth/middleware.ts",
|
|
201
|
+
"line": 42,
|
|
202
|
+
"match": "export function requireSession",
|
|
203
|
+
"tour": "authentication",
|
|
204
|
+
"order": "10",
|
|
205
|
+
"title": "The edge guard",
|
|
206
|
+
"body": ["Every request passes through here first."]
|
|
207
|
+
}]
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
npx @tobisk/codesafari insert steps.json --dry-run
|
|
212
|
+
npx @tobisk/codesafari insert steps.json
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
`match` is the anchor and `line` only a hint — if the hint has drifted, the
|
|
216
|
+
match must still resolve uniquely nearby or the entry is reported rather than
|
|
217
|
+
guessed. The comment marker comes from the file type, the block is hoisted
|
|
218
|
+
above doc comments and attributes (but stays below decorators), insertions are
|
|
219
|
+
applied bottom-up, nothing is written unless every entry resolves, and entries
|
|
220
|
+
already present are skipped — so a corrected spec can be re-run safely. Use
|
|
221
|
+
`"tour": "comment"` for a callout.
|
|
222
|
+
|
|
148
223
|
## Diagrams
|
|
149
224
|
|
|
150
225
|
Fenced ```` ```mermaid ```` blocks in any `.tour/` Markdown or source-comment body are rendered locally to SVG — on demand during `dev`, and pre-rendered into static assets during `export`. Rendering never touches the network. `validate` reports the file and block for any diagram that fails to render.
|
|
151
226
|
|
|
227
|
+
## Authoring with a coding agent
|
|
228
|
+
|
|
229
|
+
The package ships an agent skill, [`skills/authoring-code-safaris`](skills/authoring-code-safaris/SKILL.md),
|
|
230
|
+
for generating a CodeSafari in *your* repository. It covers the content model
|
|
231
|
+
(glossary vs. components vs. tours), how to write `.tour/index.md`, which
|
|
232
|
+
components are worth a page, and which tours to generate — with a baseline of
|
|
233
|
+
authentication, the data layer, and the API for any server codebase. It asks
|
|
234
|
+
its clarifying questions up front, in one round, before writing anything.
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
mkdir -p .claude/skills
|
|
238
|
+
cp -R node_modules/@tobisk/codesafari/skills/authoring-code-safaris .claude/skills/
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
See [`skills/README.md`](skills/README.md) for Claude Code and Codex setup.
|
|
242
|
+
|
|
152
243
|
## Ignore rules
|
|
153
244
|
|
|
154
245
|
Files are excluded from parsing, serving, and export using `.gitignore` plus an optional `.codesafariignore` (same syntax). `.tour/` content is always included, even if a broad pattern would otherwise match it. Images referenced from source comments must be project-relative paths that are not ignored.
|
|
@@ -210,6 +301,88 @@ wraps it in dark-mode Safari chrome with the vendored
|
|
|
210
301
|
`docs/viewer-explorer.safari.png` — the image shown at the top of this README.
|
|
211
302
|
The framing step needs macOS; on other platforms the raw capture is still written.
|
|
212
303
|
|
|
304
|
+
## Releasing
|
|
305
|
+
|
|
306
|
+
Releases use **split ownership**: **Forgejo** (`origin`, the source of truth) owns
|
|
307
|
+
versioning, and **GitHub** (a push mirror) publishes to npm.
|
|
308
|
+
|
|
309
|
+
### Conventional Commits → version
|
|
310
|
+
|
|
311
|
+
Versions are computed automatically from
|
|
312
|
+
[Conventional Commit](https://www.conventionalcommits.org/) messages since the last
|
|
313
|
+
`vX.Y.Z` tag:
|
|
314
|
+
|
|
315
|
+
| Commit | Bump |
|
|
316
|
+
| --------------------------------------------- | ----- |
|
|
317
|
+
| `fix:` / `perf:` | patch |
|
|
318
|
+
| `feat:` | minor |
|
|
319
|
+
| `!` after type/scope, or `BREAKING CHANGE:` | major |
|
|
320
|
+
| `docs:`, `chore:`, `refactor:`, `test:`, … | none |
|
|
321
|
+
|
|
322
|
+
Tags are formatted `vX.Y.Z`. The first automated release starts at **1.0.0** (create
|
|
323
|
+
a `v0.1.0` tag manually first if you want to keep releasing in the `0.x` range).
|
|
324
|
+
|
|
325
|
+
### The split, step by step
|
|
326
|
+
|
|
327
|
+
1. You push Conventional Commits to `main` on Forgejo.
|
|
328
|
+
2. Forgejo CI (`.forgejo/workflows/ci.yml`) runs the build/test job, then a `release`
|
|
329
|
+
job (default-branch only, serialized) runs `semantic-release`. It bumps the
|
|
330
|
+
version files + `CHANGELOG.md`, commits `chore(release): vX.Y.Z`, and pushes a
|
|
331
|
+
`vX.Y.Z` tag. **Forgejo creates the tag only** — it does not publish to npm and
|
|
332
|
+
does not create a hosted Forgejo release.
|
|
333
|
+
3. The commit and tag mirror to GitHub. The `v*` tag triggers
|
|
334
|
+
`.github/workflows/release.yml`, which checks out the tag, builds, publishes to
|
|
335
|
+
npm, and creates a GitHub Release.
|
|
336
|
+
|
|
337
|
+
The version published to npm is whatever `package.json` holds at the tag — already
|
|
338
|
+
bumped by Forgejo — so GitHub runs no version logic.
|
|
339
|
+
|
|
340
|
+
### Why the release commit has no `[skip ci]`
|
|
341
|
+
|
|
342
|
+
`semantic-release` is intentionally configured to write a **marker-free** release
|
|
343
|
+
commit message. The `v*` tag points at that commit and mirrors to GitHub; a
|
|
344
|
+
`[skip ci]` / `[ci skip]` marker would travel with it and silently skip the mirrored
|
|
345
|
+
npm publish. Loop prevention instead comes from **git tags**: `semantic-release`
|
|
346
|
+
derives the next version from the last `vX.Y.Z` tag, so when the release commit
|
|
347
|
+
re-triggers Forgejo CI, the run finds zero commits since the fresh tag and exits as a
|
|
348
|
+
harmless no-op. One no-op Forgejo run per release is expected.
|
|
349
|
+
|
|
350
|
+
### Authoritative version surfaces
|
|
351
|
+
|
|
352
|
+
`package.json` and `package-lock.json` (both the top-level `version` and
|
|
353
|
+
`packages[""].version`). `semantic-release` keeps them in sync; `CHANGELOG.md` is
|
|
354
|
+
regenerated. There are no workspaces.
|
|
355
|
+
|
|
356
|
+
### npm publish uses OIDC — no token
|
|
357
|
+
|
|
358
|
+
GitHub publishes with **npm trusted publishing (OIDC)**: no `NPM_TOKEN` /
|
|
359
|
+
`NODE_AUTH_TOKEN` exists anywhere. The `release.yml` job has `id-token: write`; npm
|
|
360
|
+
exchanges the GitHub OIDC identity for a short-lived credential and attaches build
|
|
361
|
+
provenance automatically.
|
|
362
|
+
|
|
363
|
+
**One-time manual setup (cannot be done from code):**
|
|
364
|
+
|
|
365
|
+
- **npm:** on npmjs.com, configure the package's **Trusted Publisher → GitHub
|
|
366
|
+
Actions**, pointing at the GitHub mirror `owner/repo` (e.g. `kellertobias/codesafari`)
|
|
367
|
+
and the exact workflow filename **`release.yml`**. Trusted publishing needs the
|
|
368
|
+
package to already exist, so a brand-new package may need one manual initial
|
|
369
|
+
`npm publish` before OIDC can take over. A public package is required for automatic
|
|
370
|
+
provenance.
|
|
371
|
+
- **Forgejo:** create the **`SEMANTIC_RELEASE_TOKEN`** secret — a token that can push
|
|
372
|
+
the release commit to the protected `main` branch and push tags. The `release` job
|
|
373
|
+
fails fast with a clear error if it is empty.
|
|
374
|
+
|
|
375
|
+
### Dry-run preview (safe, no tag)
|
|
376
|
+
|
|
377
|
+
Preview the next version and notes without creating a tag or publishing:
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
npx semantic-release --dry-run --no-ci
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
Run it against full history (`fetch-depth: 0`). It reports the proposed version and
|
|
384
|
+
release notes and makes no changes.
|
|
385
|
+
|
|
213
386
|
## License
|
|
214
387
|
|
|
215
388
|
MIT © CodeSafari contributors
|
package/dist/cli.js
CHANGED
|
@@ -4,6 +4,7 @@ import { readFile } from 'node:fs/promises';
|
|
|
4
4
|
import { Command } from 'commander';
|
|
5
5
|
import { runValidate } from './commands/validate.js';
|
|
6
6
|
import { runExport } from './commands/export.js';
|
|
7
|
+
import { runInsert } from './commands/insert.js';
|
|
7
8
|
import { runDev } from './server/devServer.js';
|
|
8
9
|
import { packageRoot } from './commands/paths.js';
|
|
9
10
|
async function readVersion() {
|
|
@@ -48,8 +49,9 @@ async function main() {
|
|
|
48
49
|
.argument('[root]', 'project directory', process.cwd())
|
|
49
50
|
.description('Write a self-contained static site')
|
|
50
51
|
.option('-o, --out <dir>', 'output directory', 'codesafari-site')
|
|
52
|
+
.option('--no-ignore', 'do not add the output directory to .gitignore')
|
|
51
53
|
.action(async (root, opts) => {
|
|
52
|
-
const result = await runExport(root, { out: opts.out });
|
|
54
|
+
const result = await runExport(root, { out: opts.out, ignore: opts.ignore });
|
|
53
55
|
if (!result.ok)
|
|
54
56
|
process.exitCode = 1;
|
|
55
57
|
});
|
|
@@ -65,6 +67,25 @@ async function main() {
|
|
|
65
67
|
if (!result.ok)
|
|
66
68
|
process.exitCode = 1;
|
|
67
69
|
});
|
|
70
|
+
program
|
|
71
|
+
.command('insert')
|
|
72
|
+
.argument('<spec>', 'JSON file describing the comments to insert')
|
|
73
|
+
.argument('[root]', 'project directory', process.cwd())
|
|
74
|
+
.description('Insert @tour comments into source files from a spec')
|
|
75
|
+
.option('--dry-run', 'resolve and report, but write nothing')
|
|
76
|
+
.option('--radius <lines>', 'how far from the line hint to search', '40')
|
|
77
|
+
.action(async (spec, root, opts) => {
|
|
78
|
+
const radius = Number.parseInt(opts.radius, 10);
|
|
79
|
+
if (!Number.isInteger(radius) || radius < 0) {
|
|
80
|
+
program.error(`Invalid --radius value: ${opts.radius}`);
|
|
81
|
+
}
|
|
82
|
+
const result = await runInsert(root, spec, {
|
|
83
|
+
dryRun: opts.dryRun,
|
|
84
|
+
radius,
|
|
85
|
+
});
|
|
86
|
+
if (!result.ok)
|
|
87
|
+
process.exitCode = 1;
|
|
88
|
+
});
|
|
68
89
|
// With no command, print help rather than doing nothing.
|
|
69
90
|
if (process.argv.length <= 2) {
|
|
70
91
|
program.help();
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,sDAAsD;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,KAAK,UAAU,WAAW;IACxB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CACpB,MAAM,QAAQ,CAAC,GAAG,WAAW,EAAE,eAAe,EAAE,MAAM,CAAC,CACxD,CAAC;QACF,OAAO,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC;AAED,uCAAuC;AACvC,4EAA4E;AAC5E,+EAA+E;AAC/E,6EAA6E;AAC7E,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B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,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC;IAED,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** `codesafari export` — write a self-contained static site. */
|
|
2
2
|
export interface ExportOptions {
|
|
3
3
|
out: string;
|
|
4
|
+
/** Add the output directory to the project's `.gitignore`. Defaults to true. */
|
|
5
|
+
ignore?: boolean;
|
|
4
6
|
}
|
|
5
7
|
export interface ExportResult {
|
|
6
8
|
ok: boolean;
|
package/dist/commands/export.js
CHANGED
|
@@ -3,6 +3,7 @@ import { promises as fs } from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { buildManifest } from '../manifest/build.js';
|
|
5
5
|
import { viewerBuilt, viewerDistDir } from './paths.js';
|
|
6
|
+
import { ignoreOutput } from './gitignore.js';
|
|
6
7
|
// @tour pipeline:5 Freezing a static site
|
|
7
8
|
// The same manifest, made portable. `export` builds it with source content
|
|
8
9
|
// bundled in, copies the prebuilt viewer, and writes the manifest as both JSON
|
|
@@ -41,6 +42,11 @@ export async function runExport(root, options) {
|
|
|
41
42
|
const json = JSON.stringify(manifest);
|
|
42
43
|
await fs.writeFile(path.join(outDir, 'data', 'manifest.json'), json, 'utf8');
|
|
43
44
|
await fs.writeFile(path.join(outDir, 'data', 'manifest.js'), `window.__CODESAFARI_MANIFEST__ = ${json};`, 'utf8');
|
|
45
|
+
if (options.ignore !== false) {
|
|
46
|
+
const entry = await ignoreOutput(resolved, outDir);
|
|
47
|
+
if (entry)
|
|
48
|
+
console.log(`Added ${entry} to .gitignore (pass --no-ignore to keep it tracked).`);
|
|
49
|
+
}
|
|
44
50
|
console.log(`Exported static site to ${outDir}`);
|
|
45
51
|
console.log(` ${manifest.files.length} source file(s) bundled.`);
|
|
46
52
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAEhE,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAEhE,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAe9C,0CAA0C;AAC1C,2EAA2E;AAC3E,+EAA+E;AAC/E,+EAA+E;AAC/E,qDAAqD;AACrD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,IAAY,EACZ,OAAsB;IAEtB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAEzC,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,KAAK,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAChE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,MAAM,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Keep generated output out of version control. */
|
|
2
|
+
/**
|
|
3
|
+
* Add `outDir` to the project's `.gitignore`, creating the file if needed.
|
|
4
|
+
* Paths outside the project root are left alone — we only manage entries we can
|
|
5
|
+
* express relative to the repository. Returns the entry written, or null if
|
|
6
|
+
* nothing was needed.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ignoreOutput(root: string, outDir: string): Promise<string | null>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Keep generated output out of version control. */
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
const MARKER = '# codesafari generated output';
|
|
5
|
+
/**
|
|
6
|
+
* Add `outDir` to the project's `.gitignore`, creating the file if needed.
|
|
7
|
+
* Paths outside the project root are left alone — we only manage entries we can
|
|
8
|
+
* express relative to the repository. Returns the entry written, or null if
|
|
9
|
+
* nothing was needed.
|
|
10
|
+
*/
|
|
11
|
+
export async function ignoreOutput(root, outDir) {
|
|
12
|
+
const rel = path.relative(root, outDir);
|
|
13
|
+
if (rel === '' || rel.startsWith('..') || path.isAbsolute(rel))
|
|
14
|
+
return null;
|
|
15
|
+
const entry = `/${rel.split(path.sep).join('/')}/`;
|
|
16
|
+
const file = path.join(root, '.gitignore');
|
|
17
|
+
let existing = '';
|
|
18
|
+
try {
|
|
19
|
+
existing = await fs.readFile(file, 'utf8');
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
// No .gitignore yet — we write a fresh one below.
|
|
23
|
+
}
|
|
24
|
+
const lines = existing.split('\n').map((l) => l.trim());
|
|
25
|
+
if (lines.includes(entry) || lines.includes(entry.slice(1, -1)))
|
|
26
|
+
return null;
|
|
27
|
+
const prefix = existing === '' || existing.endsWith('\n') ? '' : '\n';
|
|
28
|
+
await fs.appendFile(file, `${prefix}\n${MARKER}\n${entry}\n`, 'utf8');
|
|
29
|
+
return entry;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=gitignore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitignore.js","sourceRoot":"","sources":["../../src/commands/gitignore.ts"],"names":[],"mappings":"AAAA,oDAAoD;AAEpD,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,MAAM,GAAG,+BAA+B,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAY,EACZ,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxC,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAE5E,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACnD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAE3C,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,kDAAkD;IACpD,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACxD,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAE7E,MAAM,MAAM,GAAG,QAAQ,KAAK,EAAE,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACtE,MAAM,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,MAAM,KAAK,MAAM,KAAK,KAAK,IAAI,EAAE,MAAM,CAAC,CAAC;IACtE,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `codesafari insert` — write `@tour` comments into source files from a spec.
|
|
3
|
+
*
|
|
4
|
+
* Authoring a tour means placing many comments in many files, and placement is
|
|
5
|
+
* load-bearing: {@link ../parser/comments.ts} merges consecutive comment lines
|
|
6
|
+
* into one block and only reads `@tour` on a block's *first* line, so a comment
|
|
7
|
+
* dropped underneath a doc comment or a Rust `#[attr]` silently stops being a
|
|
8
|
+
* step. This command encodes those rules once instead of leaving every author
|
|
9
|
+
* (human or agent) to rediscover them.
|
|
10
|
+
*
|
|
11
|
+
* Two properties matter for unattended use:
|
|
12
|
+
* - **All-or-nothing.** Every entry is resolved before any file is written,
|
|
13
|
+
* so a spec with one bad anchor leaves the tree untouched.
|
|
14
|
+
* - **Idempotent.** An entry whose header already exists in the file is
|
|
15
|
+
* skipped, so re-running a corrected spec cannot duplicate comments.
|
|
16
|
+
*/
|
|
17
|
+
/** One comment to insert. `line` is a hint; `match` is the real anchor. */
|
|
18
|
+
export interface InsertEntry {
|
|
19
|
+
/** Project-relative path of the source file. */
|
|
20
|
+
file: string;
|
|
21
|
+
/** Expected 1-based line of the anchor. Optional; `match` decides. */
|
|
22
|
+
line?: number;
|
|
23
|
+
/** Text that must appear in the anchor line. Must resolve unambiguously. */
|
|
24
|
+
match: string;
|
|
25
|
+
/** Tour slug, or the literal `comment` for a non-navigable callout. */
|
|
26
|
+
tour: string;
|
|
27
|
+
/** Dot-aware order key. Required unless `tour` is `comment`. */
|
|
28
|
+
order?: string | number;
|
|
29
|
+
/** Step title (the rest of the header line). */
|
|
30
|
+
title: string;
|
|
31
|
+
/** Body paragraphs. A single string is treated as one paragraph. */
|
|
32
|
+
body?: string | string[];
|
|
33
|
+
}
|
|
34
|
+
export interface InsertResult {
|
|
35
|
+
ok: boolean;
|
|
36
|
+
applied: number;
|
|
37
|
+
skipped: number;
|
|
38
|
+
problems: string[];
|
|
39
|
+
}
|
|
40
|
+
export interface InsertOptions {
|
|
41
|
+
/** Resolve and report, but write nothing. */
|
|
42
|
+
dryRun?: boolean;
|
|
43
|
+
/** How far from `line` to search for `match`. */
|
|
44
|
+
radius?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Apply a spec file. Nothing is written unless every entry resolves.
|
|
48
|
+
*/
|
|
49
|
+
export declare function runInsert(root: string, specPath: string, options?: InsertOptions): Promise<InsertResult>;
|