@cagov/ca-ds 0.0.0-stage → 1.1.0
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/LICENSE +21 -0
- package/README.md +602 -2
- package/THIRD-PARTY-LICENSES.txt +690 -0
- package/ca-ds.js +48337 -0
- package/package.json +36 -4
- package/preview.css +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 State of California
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,603 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cagov/ca-ds
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This package is the California Design System's toolbelt. Its `ca-ds` command previews, validates, builds, packs, and publishes a collection of items, and adds, updates, diffs, and ejects the items it installs from the registry. The registry runs the same code, so the validator you run is the one the registry runs.
|
|
4
|
+
|
|
5
|
+
This README owns the commands, their flags, their `--json` shapes, and their exit codes. The item model, the manifest, and the validator's rules belong to the system's own docs, which the registry serves:
|
|
6
|
+
|
|
7
|
+
- `standard/contracts`, the item model and the validator's rules
|
|
8
|
+
- `standard/packaging`, how to package an item and publish it
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
The package needs Node 24 or later. Run any command through `npx`, from inside a collection:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npx @cagov/ca-ds validate
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Or add it to a project, and run `ca-ds` from its scripts:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install --save-dev @cagov/ca-ds
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The package installs the command as one file, `ca-ds.js`, which holds its JavaScript dependencies at the versions the registry runs. It installs two packages beside it, `esbuild` and `lightningcss`, each at one exact version, since each ships a binary per platform. `THIRD-PARTY-LICENSES.txt` lists the packages inside `ca-ds.js` with their licenses.
|
|
25
|
+
|
|
26
|
+
`playwright-core` is an optional peer dependency. Only `ca-ds preview --screenshots` needs it.
|
|
27
|
+
|
|
28
|
+
The package's version covers the `ca-ds` command: its commands, flags, `--json` shapes, and exit codes. The package exports no module.
|
|
29
|
+
|
|
30
|
+
## Collections
|
|
31
|
+
|
|
32
|
+
A collection is a folder of items with two root files. `ca-ds` finds it by walking up from the working folder to the nearest `collection.json`. A command that needs one exits with the usage code when there's none.
|
|
33
|
+
|
|
34
|
+
### collection.json
|
|
35
|
+
|
|
36
|
+
`collection.json` says what the collection asks for. `./src/schema/collection.schema.json` owns its shape. Its fields, each optional:
|
|
37
|
+
|
|
38
|
+
- **`registry`**: the registry's base URL
|
|
39
|
+
- **`namespaces`**: the namespaces the collection authors
|
|
40
|
+
- **`release`**: a system release, such as `v0.1.0`, that `add` and `update` take their pins from
|
|
41
|
+
- **`items`**: the items asked for, each with a semver range, such as `{ "standard/button": "^0.3.1" }`
|
|
42
|
+
- **`presets`**: named subsets, each `{ "items": [...] }`, for `build --preset`
|
|
43
|
+
- **`pages`**: globs of your own HTML pages, which `preview` serves
|
|
44
|
+
- **`install`**: the folder `add` writes to, `items` by default. A skill installs to `skills` instead
|
|
45
|
+
- **`skills`**: the folders an installed skill goes in, each relative to the collection, `[".agents/skills", ".claude/skills"]` by default. The first holds the skill's files, and each later one a link to them (§ *Skills*, under *add*)
|
|
46
|
+
- **`dist`**: the folder `build` writes to, `dist` by default
|
|
47
|
+
|
|
48
|
+
`ca-ds init` writes one. A command that changes it rewrites it as two-space JSON.
|
|
49
|
+
|
|
50
|
+
### collection.lock.json
|
|
51
|
+
|
|
52
|
+
`collection.lock.json` records what resolved. `./src/schema/collection.lock.schema.json` owns its shape:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"release": "v0.1.0",
|
|
57
|
+
"foundation": ["standard/tokens", "standard/reset"],
|
|
58
|
+
"items": {
|
|
59
|
+
"standard/button": {
|
|
60
|
+
"version": "0.3.1",
|
|
61
|
+
"path": "items/standard/button",
|
|
62
|
+
"requested": true,
|
|
63
|
+
"files": { "button.css": "<sha256>", "item.json": "<sha256>" }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- **`release`**: the release the items resolved against, or `null`
|
|
70
|
+
- **`foundation`**: the items every build and validation loads first, in order. Absent, the collection has none
|
|
71
|
+
- **`items`**: each installed item by scoped name, sorted by name. `requested` is true for an item `collection.json` asks for, and false for a dependency. `files` holds the SHA-256 of each file as installed, the baseline `diff` and `update` compare against. `path` is the item's folder, which for a skill sits in the first skills folder. `links`, on a skill alone, lists the links and copies the install made in the later skills folders
|
|
72
|
+
|
|
73
|
+
A collection that installs nothing holds `{ "release": null, "items": {} }`.
|
|
74
|
+
|
|
75
|
+
### Authored and installed
|
|
76
|
+
|
|
77
|
+
Any folder holding an `item.json` is an item. The walk skips `node_modules`, `build`, and `.git`. Each item is one of two kinds:
|
|
78
|
+
|
|
79
|
+
- **authored**: its scope is one of `namespaces`. You own it, and `pack`, `publish`, and `pull` take it. Its `version` is the registry version the folder was last pulled from, its base, which the registry and `pull` write and you never raise by hand. A new item carries the version its first publish takes, `0.1.0` from `new`
|
|
80
|
+
- **installed**: the lock records it. It came from the registry at a pinned version, and its files are yours to edit. `update` merges a new version into your edits
|
|
81
|
+
|
|
82
|
+
An authored skill stays where you keep it. No command places it in the skills folders.
|
|
83
|
+
|
|
84
|
+
`validate` rejects an item that is neither, and one that is both.
|
|
85
|
+
|
|
86
|
+
### A bundle
|
|
87
|
+
|
|
88
|
+
A bundle ZIP from the registry's `/bundles` page or `POST /api/bundles` is a collection. It unzips to `collection.json`, `collection.lock.json`, `items/<scope>/<name>/`, `dist/`, and a `README.md`, so every command runs in its folder.
|
|
89
|
+
|
|
90
|
+
## The registry and your token
|
|
91
|
+
|
|
92
|
+
The commands that read the registry find it in this order:
|
|
93
|
+
|
|
94
|
+
1. `CA_DS_URL`
|
|
95
|
+
2. `collection.json`'s `registry`
|
|
96
|
+
3. `https://v0.ds.innovation.ca.gov`
|
|
97
|
+
|
|
98
|
+
They take a token in this order:
|
|
99
|
+
|
|
100
|
+
1. `--token <token>`
|
|
101
|
+
2. `CA_DS_TOKEN`
|
|
102
|
+
3. the credential `ca-ds login` stored for the registry's URL
|
|
103
|
+
|
|
104
|
+
On your own machine, sign in with `ca-ds login`, which goes through your browser. In CI and scripts, use an API key from `<registry>/settings/api-keys` in `CA_DS_TOKEN`. A flag stays in your shell history, so prefer the variable or `login`.
|
|
105
|
+
|
|
106
|
+
`login` stores credentials in `$XDG_CONFIG_HOME/ca-ds/credentials.json`, or `%APPDATA%\ca-ds\credentials.json` on Windows, or else `~/.config/ca-ds/credentials.json`. The folder is made with mode 0700, and the file is written whole with mode 0600 through a temporary file, so a reader never sees half of it. It holds one entry per registry URL, in one of two shapes:
|
|
107
|
+
|
|
108
|
+
- **a pasted key**: `{ "token" }`, which stays live until you revoke it at `<registry>/settings/api-keys`
|
|
109
|
+
- **a browser sign-in**: `{ "token", "refresh", "expiresAt", "clientId", "tokenEndpoint", "revocationEndpoint", "kind": "oauth" }`, `token` the access token, `refresh` the refresh token, `expiresAt` the access token's expiry as an ISO date, `clientId` always `ca-ds`, and the two endpoints the ones the registry's authorization server metadata names
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"registries": {
|
|
114
|
+
"https://v0.ds.innovation.ca.gov": { "token": "cads_..." },
|
|
115
|
+
"http://localhost:3000": {
|
|
116
|
+
"token": "cads_...",
|
|
117
|
+
"refresh": "cadsr_...",
|
|
118
|
+
"expiresAt": "2026-11-09T18:00:00.000Z",
|
|
119
|
+
"clientId": "ca-ds",
|
|
120
|
+
"tokenEndpoint": "http://localhost:3000/oauth/token",
|
|
121
|
+
"revocationEndpoint": "http://localhost:3000/oauth/revoke",
|
|
122
|
+
"kind": "oauth"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
A command that reads a browser sign-in from the file refreshes its access token when it expires within 60 seconds, and refreshes once and retries when the registry answers 401. Each refresh writes the new pair back to the file the same way. When the registry refuses the refresh, as it does for a revoked or expired connection, the command fails with exit 4 and tells you to run `ca-ds login` again. A token from `--token` or `CA_DS_TOKEN` never refreshes.
|
|
129
|
+
|
|
130
|
+
These commands run offline:
|
|
131
|
+
|
|
132
|
+
- `init` and `new`
|
|
133
|
+
- `remove` and `eject`
|
|
134
|
+
- `build` and `preview`
|
|
135
|
+
- `pack`
|
|
136
|
+
- `logout`, which goes online only to revoke a browser sign-in
|
|
137
|
+
|
|
138
|
+
`validate` goes online only as § *validate* describes: it reads the purges when the collection names a registry, and the items it lacks when a check skips.
|
|
139
|
+
|
|
140
|
+
## Commands
|
|
141
|
+
|
|
142
|
+
| Command | Does |
|
|
143
|
+
|---|---|
|
|
144
|
+
| `init` | writes an empty `collection.json`, and with `--ci github` a workflow |
|
|
145
|
+
| `new <kind> <scope>/<name>` | scaffolds an item folder that passes `validate` |
|
|
146
|
+
| `add <name>[@range]...` | installs items and their dependencies |
|
|
147
|
+
| `remove <name>...` | removes installed items, with `--prune` |
|
|
148
|
+
| `update [name...]` | merges newer versions into your edits |
|
|
149
|
+
| `diff <name>` | shows your edits to an installed item |
|
|
150
|
+
| `outdated` | lists installed items with newer versions |
|
|
151
|
+
| `eject <name> --to <namespace>` | turns an installed item into an authored one |
|
|
152
|
+
| `build` | writes tokens, CSS, and JS to `dist/` |
|
|
153
|
+
| `preview` | serves items and pages with live reload |
|
|
154
|
+
| `validate` | runs the validator over the collection |
|
|
155
|
+
| `format [name...]` | rewrites authored items' markdown in the serializer's form |
|
|
156
|
+
| `pack [name...]` | writes item ZIPs, or a release folder |
|
|
157
|
+
| `publish [name...]` | sends changed authored items, which the registry mints versions for, or records a release |
|
|
158
|
+
| `pull` | writes the registry's newer versions of authored items, merging your edits |
|
|
159
|
+
| `login` | signs in to a registry through your browser, or stores a token for it |
|
|
160
|
+
| `logout` | signs out of a registry, or removes a stored token |
|
|
161
|
+
|
|
162
|
+
`ca-ds --help` lists them, and `ca-ds <command> --help` prints a command's usage. `ca-ds --version` prints the version, and with `--json` prints `{ "version" }`.
|
|
163
|
+
|
|
164
|
+
Every command takes `--json` and `--help`. An item argument names an item by its scoped name, such as `standard/button`, or by its folder.
|
|
165
|
+
|
|
166
|
+
### init
|
|
167
|
+
|
|
168
|
+
```sh
|
|
169
|
+
ca-ds init [--registry <url>] [--namespace <namespace> ...] [--ci github] [--branch <branch>]
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Writes `collection.json` in the working folder. Its `registry` is `--registry`, then `CA_DS_URL`, then the production host. Each `--namespace` adds one namespace the collection authors.
|
|
173
|
+
|
|
174
|
+
`--ci github` also writes `.github/workflows/ca-ds.yml`:
|
|
175
|
+
|
|
176
|
+
- on a pull request, `ca-ds validate`, then `ca-ds publish --dry-run` when the `CA_DS_TOKEN` repository secret is set
|
|
177
|
+
- on a push to `<branch>`, `ca-ds publish --summary` with the commit's subject, with the token from `CA_DS_TOKEN`
|
|
178
|
+
- hourly on weekdays and by hand, `ca-ds pull`, committing what it writes straight to `<branch>`, which a protected branch refuses
|
|
179
|
+
|
|
180
|
+
`--branch` names the branch, `main` by default. In a folder that already holds a `collection.json`, `--ci github` alone writes the workflow and keeps the file.
|
|
181
|
+
|
|
182
|
+
- **`--json`**: `{ collection, workflow }`, each a path, or `null` when it wasn't written
|
|
183
|
+
- **Exit 3**: `collection.json` exists and `--ci` wasn't given alone, or the workflow file exists
|
|
184
|
+
|
|
185
|
+
### new
|
|
186
|
+
|
|
187
|
+
```sh
|
|
188
|
+
ca-ds new component|guidance|template|media|page|skill <scope>/<name> [--dir <folder>] [--title <title>] [--skill-name <name>]
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Scaffolds an item folder that `validate` passes with zero rejections, its `item.json` included. The scope must be one of `namespaces`. The folder is `--dir`, or `<name>` in the working folder, and must not hold files yet. `--title` sets the title, which defaults to one made from the name. Each kind writes:
|
|
192
|
+
|
|
193
|
+
- **`component`**: `item.json`, a short overview, a contract with one starter rule, a stylesheet, and one example in `examples/`
|
|
194
|
+
- **`guidance`**: `item.json` and the doc
|
|
195
|
+
- **`template`**: `item.json`, the overview, a composition of one region, and the page, `examples/<name>.html`. It depends on `standard/layout` when the collection holds it
|
|
196
|
+
- **`media`**: `item.json` and a placeholder SVG rendition, with its alt text
|
|
197
|
+
- **`page`**: `item.json` and the page's doc, `<name>.html`, a section holding a heading and a paragraph in the canonical format. Its `slug` is its name, and it carries no `tasks`
|
|
198
|
+
- **`skill`**: `item.json` and `SKILL.md`, whose frontmatter holds `name` and a placeholder `description`. The frontmatter `name` is `--skill-name`, or else the item's name with any `-skill` suffix dropped, so `new skill myteam/forms-skill` writes the skill `forms`. It writes no empty `scripts/`, `references/`, or `assets/` folder
|
|
199
|
+
|
|
200
|
+
Its answer and its refusals:
|
|
201
|
+
|
|
202
|
+
- **`--json`**: `{ name, kind, dir, files }`, `files` the paths written inside `dir`
|
|
203
|
+
- **Exit 2**: a scope `collection.json` doesn't author, a name the collection holds, a doc named `notes.md`, a folder that holds files, a skill name the frontmatter's rules refuse, or `--skill-name` with a kind other than `skill`
|
|
204
|
+
|
|
205
|
+
### add
|
|
206
|
+
|
|
207
|
+
```sh
|
|
208
|
+
ca-ds add <scope>/<name>[@<range>]... [--token <token>]
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Installs items and their dependencies, resolved through the registry's `POST /api/resolve`. Each item lands in `<install>/<scope>/<name>/` and in the lock. Each version comes from these rules:
|
|
212
|
+
|
|
213
|
+
- with `collection.json`'s `release`, a `standard` item takes the release's pin
|
|
214
|
+
- any other item takes the highest version in its range, or its latest
|
|
215
|
+
- an item already installed stays at its version. `update` moves it
|
|
216
|
+
|
|
217
|
+
An item asked for joins `collection.json`'s `items`, with the range given, or with a caret range of its version, such as `^0.3.1`. A dependency is recorded as not asked for. The foundation installs with the first item. A skill installs as § *Skills* describes.
|
|
218
|
+
|
|
219
|
+
- **`--json`**: `{ release, added, requested, warnings }`, `added` as `[{ name, version, path, requested, links? }]`, `links` on a skill alone, `requested` as `[{ name, range, version }]`, and `warnings` as `[{ rule, name, message }]`
|
|
220
|
+
- **Exit 1**: no live version satisfies a range, or a range misses the release's pin or the installed version
|
|
221
|
+
- **Exit 2**: a name in a namespace the collection authors
|
|
222
|
+
- **Exit 3**: an item's folder already holds files, an authored fork names the item, or a skill's install conflicts, as § *Skills* lists
|
|
223
|
+
|
|
224
|
+
#### Skills
|
|
225
|
+
|
|
226
|
+
`add` writes a skill to `<skills[0]>/<skill name>/`, the skill name being its `SKILL.md` frontmatter `name`, since an agent finds a skill by its folder. A skill whose frontmatter names none takes its item's short name. The folder holds the skill's files and its `item.json`, and the lock's `path` names it.
|
|
227
|
+
|
|
228
|
+
Each later skills folder gets a relative symlink at `<folder>/<skill name>`, pointing at the first. With the defaults, `.claude/skills/forms` links to `.agents/skills/forms`. The text output ends the skill's line with `, linked from` and the links, and `--json` lists them in its entry's `links`. Where the system refuses a symlink with `EPERM`, as Windows does without Developer Mode, the folder gets a copy of the skill's files without its `item.json` instead, marked by a `.ca-ds-copy` file inside it. The lock's entry records each link and copy in its `links`. `update` makes each recorded copy again from the skill's own folder, so an edit to a copy is lost. Edit the skill in its own folder.
|
|
229
|
+
|
|
230
|
+
`remove`, `update`, and `eject` act on the recorded links alone, never on what `skills` names now. Each goes only while it is still a link to the skill's folder or a folder holding the `.ca-ds-copy` marker. Anything else at a recorded path, such as a folder of your own, stays, with a warning under the rule `skill-link`.
|
|
231
|
+
|
|
232
|
+
`add` refuses a skill with exit 3, and writes nothing, when:
|
|
233
|
+
|
|
234
|
+
- another installed skill, or another skill in the same `add`, takes the same frontmatter `name`
|
|
235
|
+
- the skill's folder in the first skills folder already holds files
|
|
236
|
+
- a later skills folder already holds a folder at that name, other than this skill's link, a `.ca-ds-copy` folder among them, since a copy the lock never recorded may hold your files
|
|
237
|
+
|
|
238
|
+
A skill that ships a file with the role `script` prints a warning that an agent may run its scripts, naming its `scripts` folder to review. `--json` carries it in `warnings`, with the rule `skill-scripts`.
|
|
239
|
+
|
|
240
|
+
### remove
|
|
241
|
+
|
|
242
|
+
```sh
|
|
243
|
+
ca-ds remove <scope>/<name>... [--prune]
|
|
244
|
+
ca-ds remove --prune
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Deletes installed items, their folders, and their lock entries, and drops them from `collection.json`'s `items`. A skill's recorded links and copies go too, even when its own folder was already deleted, and so does each folder they leave empty. `--prune` also deletes every dependency nothing asked for or authored still reaches. The foundation stays while anything else remains.
|
|
248
|
+
|
|
249
|
+
- **`--json`**: `{ removed, warnings }`, `removed` as `[{ name, version, path, requested }]`, and `warnings` as `add`'s
|
|
250
|
+
- **Exit 2**: a name that isn't installed, or a range
|
|
251
|
+
- **Exit 3**: another item still depends on an item named, and nothing is deleted
|
|
252
|
+
|
|
253
|
+
### update
|
|
254
|
+
|
|
255
|
+
```sh
|
|
256
|
+
ca-ds update [<scope>/<name>...] [--dry-run] [--latest] [--token <token>]
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Moves installed items to newer versions. It merges each file three ways: the installed version is the base, your file is ours, and the new version is theirs. Where the items move:
|
|
260
|
+
|
|
261
|
+
- **with `collection.json`'s `release`**: to the latest release, which `collection.json` then names. A `standard` item takes its pin. Names are refused, since a release moves the set together
|
|
262
|
+
- **with no release**: each item asked for to the highest version in its range, and each dependency to its latest
|
|
263
|
+
- **with `--latest`**: every item to its latest version, and `collection.json` drops its `release`
|
|
264
|
+
|
|
265
|
+
With names, only the named items and their dependencies move. Under a release or `--latest`, a range the new version leaves becomes a caret range of the new version.
|
|
266
|
+
|
|
267
|
+
Each file merges one of these ways:
|
|
268
|
+
|
|
269
|
+
- **an unchanged file**: fast-forwards
|
|
270
|
+
- **a text file both sides changed**: merges, or takes git-style conflict markers, `<<<<<<< local` and `>>>>>>> <name>@<version>`. `validate` rejects a file that holds them
|
|
271
|
+
- **a JSON file**: merges by key. A key both sides changed is a hard stop
|
|
272
|
+
- **a binary file both sides changed, or a file one side deleted and the other changed**: a hard stop
|
|
273
|
+
|
|
274
|
+
A hard stop leaves that item's files and lock entry untouched, and the other items still move. Each item ends one of these ways:
|
|
275
|
+
|
|
276
|
+
- **`current`**: it was already at its version
|
|
277
|
+
- **`updated`**: every file fast-forwarded, kept, or merged cleanly
|
|
278
|
+
- **`conflict`**: a text file holds conflict markers. The item still moves, and its baseline is the new version
|
|
279
|
+
- **`stopped`**: a hard stop, so its files and its lock entry stay as they were
|
|
280
|
+
- **`added`**: a new dependency, installed fresh
|
|
281
|
+
- **`orphaned`**: no item needs it any more. It stays until `remove --prune`
|
|
282
|
+
|
|
283
|
+
A skill whose new version renames it in its frontmatter moves to the new name's folder, and its links follow. The text output prints a `moved` line for it. When another installed skill takes the new name, or its folder or a later folder's link already holds files, the skill stops instead, with the reason on its doc. A skill whose new version ships a `script` file the old one didn't, or one whose bytes differ from the baseline's, prints `add`'s scripts warning, in a dry run too. A later skills folder that holds a folder the lock never recorded at the skill's name, a `.ca-ds-copy` folder among them, stays, and the skill isn't linked there, with a warning under the rule `skill-link`. A new dependency that is a skill installs as `add` installs one, with its scripts warning.
|
|
284
|
+
|
|
285
|
+
`--dry-run` reports the same outcomes and moves, and writes nothing. Under each item that would move to a newer version, it prints the changelog entry of every version above the installed one, up to the new one, newest first, as `outdated` does.
|
|
286
|
+
|
|
287
|
+
- **`--json`**: `{ dryRun, release, items, ranges, warnings }`. `release` is `{ from, to }` or `null`. `items` is `[{ name, from, to, status, files, moved?, changelog? }]`, `files` each file not kept as `{ path, outcome, conflicts?, reason?, keys? }`, `moved` a skill's `{ from, to }` folders, and `changelog`, in a dry run, the entries as `outdated` answers them. `ranges` is `[{ name, from, to }]`, the ranges rewritten. `warnings` is `add`'s
|
|
288
|
+
- **Exit 2**: a name that isn't installed, a range, or names under a release
|
|
289
|
+
- **Exit 3**: a conflict or a hard stop, in a real run or a dry run
|
|
290
|
+
|
|
291
|
+
### diff
|
|
292
|
+
|
|
293
|
+
```sh
|
|
294
|
+
ca-ds diff <scope>/<name> [--token <token>]
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Prints your edits to an installed item as a unified diff against its baseline, the version the lock records. It reads the item's folder from the lock's `path`, a skill's included. The lock's hashes say which files changed. The baseline's copy of each changed file comes from the registry, so an item with edits needs the network, and one without needs none. It exits 0 either way.
|
|
298
|
+
|
|
299
|
+
- **`--json`**: `{ name, version, path, edited, files }`, `files` as `[{ path, status, binary, patch }]`. `status` is `modified`, `added`, or `deleted`, and `patch` is `null` for a binary file
|
|
300
|
+
|
|
301
|
+
### outdated
|
|
302
|
+
|
|
303
|
+
```sh
|
|
304
|
+
ca-ds outdated [--token <token>]
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Lists the installed items with newer versions, skills included, each with three versions:
|
|
308
|
+
|
|
309
|
+
- **current**: the version the lock records
|
|
310
|
+
- **wanted**: the version `update` moves it to
|
|
311
|
+
- **latest**: the registry's latest version, which `update --latest` moves it to
|
|
312
|
+
|
|
313
|
+
After the table it prints the changelog entry of every version above each item's current one, up to the newer of wanted and latest, newest first: the version, the author's summary, and the entry, marked when a model generated it. A registry from before changelogs answers none, and the table stands alone. It exits 0 either way.
|
|
314
|
+
|
|
315
|
+
- **`--json`**: `{ release, latestRelease, items }`, `items` as `[{ name, current, wanted, latest, requested, changelog }]`, `changelog` as `[{ version, yanked, summary, entry, source }]`, `source` being `mechanical`, `generated`, or `author`, or `null` with no entry
|
|
316
|
+
|
|
317
|
+
### eject
|
|
318
|
+
|
|
319
|
+
```sh
|
|
320
|
+
ca-ds eject <scope>/<name> --to <namespace>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Turns an installed item into an authored one. `standard/card` becomes `<namespace>/card`:
|
|
324
|
+
|
|
325
|
+
- its manifest takes the new name, the version `0.1.0`, `forkedFrom: "standard/card@<version>"`, and a `source` naming its new folder
|
|
326
|
+
- its folder moves to `<install>/<namespace>/card/`. A skill moves there too, out of the skills folders, and its links and copies go, since an authored skill is never placed in them
|
|
327
|
+
- every dependency and related load of `standard/card` in the collection names the fork
|
|
328
|
+
- it leaves the lock and `collection.json`'s `items`, so `update` never touches it again
|
|
329
|
+
- `collection.json`'s `namespaces` gains the namespace
|
|
330
|
+
|
|
331
|
+
A collection that holds both the original and its fork fails `validate`.
|
|
332
|
+
|
|
333
|
+
- **`--json`**: `{ from, name, version, path, rewritten, namespaceAdded, warnings }`, `rewritten` the items whose manifests now name the fork, and `warnings` as `add`'s
|
|
334
|
+
- **Exit 3**: the collection already holds the new name or its folder
|
|
335
|
+
|
|
336
|
+
### build
|
|
337
|
+
|
|
338
|
+
```sh
|
|
339
|
+
ca-ds build [--preset <name>]
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Builds the collection into its `dist` folder:
|
|
343
|
+
|
|
344
|
+
- `ca-ds.css`: the tokens, then every item's CSS in load order
|
|
345
|
+
- `ca-ds.js`: every item's scripts in load order, as one ES module
|
|
346
|
+
- `ca-ds.min.css` and `ca-ds.min.js`: the same, minified
|
|
347
|
+
- a source map beside each of those four
|
|
348
|
+
- `tokens.css`: the tokens alone
|
|
349
|
+
- each file the CSS links, such as the fonts, at its path inside its item
|
|
350
|
+
|
|
351
|
+
With no preset, it builds the `everything` preset when the collection defines one, and otherwise every item, the ones `collection.json` asks for first. `--preset` names a preset of `collection.json`, or else of `system.json`. A set with no tokens item builds with a warning. `build` doesn't clear the folder first.
|
|
352
|
+
|
|
353
|
+
- **`--json`**: `{ dist, from, order, files, warnings }`. `dist` is the folder, `from` names the set, `order` is the load order, `files` lists every path written, and `warnings` is `[{ rule, message }]`
|
|
354
|
+
|
|
355
|
+
### preview
|
|
356
|
+
|
|
357
|
+
```sh
|
|
358
|
+
ca-ds preview [--port <n>] [--open | --no-open]
|
|
359
|
+
ca-ds preview --screenshots [<scope>/<name> ...]
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Serves every item's examples and check pages, and your own pages, with live reload. It builds in memory and writes nothing to `dist/`. It listens on `--port`, or `PORT`, or the first free port from 3000. When a previewer of the same collection already runs, it prints that one's URL and exits 0.
|
|
363
|
+
|
|
364
|
+
`--screenshots` writes the WebP behind each example whose manifest entry sets `site` to `image`, through your installed Chrome, for the named items or every item. It needs `playwright-core`.
|
|
365
|
+
|
|
366
|
+
- **`--json`**: `{ url, running }` once it listens, `running` true when another previewer answered. With `--screenshots`, `{ written }`, as `[{ name, theme, file }]`
|
|
367
|
+
- **Exit 1**: `playwright-core` is missing
|
|
368
|
+
|
|
369
|
+
§ *Previewing* lists the routes and how to drive the previewer from a script.
|
|
370
|
+
|
|
371
|
+
### validate
|
|
372
|
+
|
|
373
|
+
```sh
|
|
374
|
+
ca-ds validate [<name, folder, ZIP, or release folder> ...] [--offline] [--token <token>]
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Runs the validator over every item in the collection, or over the items named, and prints the punch list, rejections first. An argument may name an item ZIP, which validates against the collection, or a release folder, which validates as its own published state. It rejects nothing about an authored item's version, since the registry mints each one. `ca-ds publish --dry-run` checks a change against the registry.
|
|
378
|
+
|
|
379
|
+
The run is offline first. Two checks need a `standard` item, and skip with a warning when the collection lacks it:
|
|
380
|
+
|
|
381
|
+
- the emblem check needs `standard/ca-logo`
|
|
382
|
+
- the page checklist needs `standard/page-checklist`
|
|
383
|
+
|
|
384
|
+
The links check skips a link the same way when its target's item sits in a namespace the collection doesn't author and the collection lacks it, and its warning names the item in `needs`.
|
|
385
|
+
|
|
386
|
+
When one skips and the collection names a registry, in `collection.json`'s `registry` or `CA_DS_URL`, the run goes online. It reads the registry's version for the handshake, fetches the latest copy of each missing item, and validates again. A link whose target's item the registry lacks too resolves to nothing then. A registry that refuses or doesn't answer within 20 seconds leaves the offline result, with a warning. `--offline` never reads the registry.
|
|
387
|
+
|
|
388
|
+
When the collection names a registry, the run also reads the items the registry purged, through `GET /api/purges`, with the same timeout, before it validates. A page or a template that still links a purged media leaf, or still names it in `dependencies`, then warns `purged-media`, naming the leaf, as a publish's checks do. Without the read, once `pull` removes the leaf's folder, the link and the dependency each reject as ones to an item the registry never held. Remove the image and the dependency, then publish the page. A registry that refuses the read, or doesn't answer, skips it with a warning.
|
|
389
|
+
|
|
390
|
+
- **`--json`**: `{ summary, items, releases?, registry?, purges? }`:
|
|
391
|
+
- `summary`: `{ items, rejections, warnings, byRule }`
|
|
392
|
+
- `items`: `[{ name, dir, rejections, warnings }]`, each finding `{ severity, check, rule, file, line, message, needs? }`, `needs` the item a skipped check waits on
|
|
393
|
+
- `releases`: only when an argument names a release folder
|
|
394
|
+
- `registry`: only when the run read items the collection lacks, `{ url, items, handshake, error }`
|
|
395
|
+
- `purges`: only when the run asked for the purges, `{ url, names, error }`, `names` the purged items' scoped names and `error` null or the reason it skipped
|
|
396
|
+
- **Exit 1**: any rejection
|
|
397
|
+
|
|
398
|
+
### format
|
|
399
|
+
|
|
400
|
+
```sh
|
|
401
|
+
ca-ds format [<name or folder> ...] [--check]
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Rewrites each markdown file an authored item ships, its docs, into the form the markdown serializer writes, `src/lib/markdown.js`. The validator rejects a `standard` or `site` doc in any other form, and warns on another namespace's, so the docs site's editor changes only the lines a person edits. With no argument it formats every authored item, and an argument names one. It leaves each version alone, since the registry mints the next one when you publish. `--check` writes nothing.
|
|
405
|
+
|
|
406
|
+
The form follows the system's docs style:
|
|
407
|
+
|
|
408
|
+
- ATX headings, one blank line between blocks, and each paragraph one line
|
|
409
|
+
- `-` for a bullet and `1.` for a numbered item, each continuation indented to the item's text
|
|
410
|
+
- `*` for emphasis and `**` for strong
|
|
411
|
+
- a fenced block in backticks, with its info string
|
|
412
|
+
- a table as `| a | b |` rows under a `|---|---|` separator, with no padding
|
|
413
|
+
- a character that would start markup escaped with a backslash, and no other
|
|
414
|
+
|
|
415
|
+
- **`--json`**: `{ files, written }`, `files` as `[{ item, path, line }]`, `line` the first line formatting changes
|
|
416
|
+
- **Exit 1**: with `--check`, a file that would change, or a file that doesn't parse
|
|
417
|
+
- **Exit 2**: an item that isn't authored in the collection
|
|
418
|
+
|
|
419
|
+
### pack
|
|
420
|
+
|
|
421
|
+
```sh
|
|
422
|
+
ca-ds pack [<name or folder> ...] [--out <folder>]
|
|
423
|
+
ca-ds pack --release [--tag v<semver>] [--out <folder>]
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
Validates items against the collection, then writes each one's ZIP, `<scope>-<name>-<version>.zip`, to `--out`, `build/pack/` in the collection by default. With no name, every authored item packs. An item the validator rejects gets no ZIP.
|
|
427
|
+
|
|
428
|
+
`--release` packs every `standard` item into one release folder, `build/release/<tag>/` by default, beside a `release.json`. Only the `standard` namespace records releases, so an item of another namespace the collection authors, such as a `site` page, packs and publishes alone.
|
|
429
|
+
|
|
430
|
+
- **`--json`**: `{ packed, rejected }`, `packed` as `[{ name, version, file, files, warnings }]` and `rejected` as the validator's results. With `--release`, `{ tag, dir, items, warnings, rejected }`
|
|
431
|
+
- **Exit 1**: the validator rejected an item
|
|
432
|
+
|
|
433
|
+
### publish
|
|
434
|
+
|
|
435
|
+
```sh
|
|
436
|
+
ca-ds publish [<name or folder> ...] [--bump patch|minor|major] [--summary <text>] [--dry-run] [--token <token>]
|
|
437
|
+
ca-ds publish --release <tag> [--from <release folder> | --out <folder>] [--no-warm] [--token <token>]
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
Sends the collection's authored items, every one or the named ones, in dependency order, and the registry mints each new version. It first reads the registry's version for the handshake (§ *The version handshake*). Then it compares each item's files with the registry's at the item's `version`, its base:
|
|
441
|
+
|
|
442
|
+
- **new**: the registry holds no such item, so `publish` sends it, and its first version is the item's `version`
|
|
443
|
+
- **current**: the files equal the registry's at that version, and that version is the latest, so nothing is sent
|
|
444
|
+
- **behind**: the files equal the registry's at that version, and the registry holds a later one, so nothing is sent. Run `pull`. It fails nothing
|
|
445
|
+
- **changed**: the files differ, so `publish` sends the item's ZIP, `POST /api/items`. The registry merges the change onto its latest version when the base is older, mints the version, and answers it, which `publish` prints as `published <name> <version> (from <base>, merged onto <latest>)`
|
|
446
|
+
- **purged**: an admin purged the item from the registry, as `GET /api/purges` lists it, and the registry takes its name no more. Nothing is sent, it fails nothing, and the next `pull` removes the collection's copy
|
|
447
|
+
|
|
448
|
+
The registry answers a changed item in one of these ways:
|
|
449
|
+
|
|
450
|
+
- **published**: it minted the version, at least the bump `--bump` asks for, patch by default, raised to the floor the change allows. Below 1.0.0 a major floor mints a minor, and a major you ask for with `--bump major` mints 1.0.0
|
|
451
|
+
- **current**: the latest version already holds the change, so it minted nothing, and `publish` reports the item behind
|
|
452
|
+
- **conflict**: the change and a later version change the same lines, or the same JSON key, so nothing is stored. The answer names each file. Run `pull`, settle each conflict, then publish again
|
|
453
|
+
- **unknown base**: the registry never published the item's `version`. Run `pull`
|
|
454
|
+
- **rejected**: the validator rejected the merged item, which stops the run
|
|
455
|
+
|
|
456
|
+
A conflict or an unknown base publishes nothing for that item, and the run goes on to the rest, then exits 3. `publish` never writes the working copy. When it minted a version, it says to run `pull`, which brings the versions back. `--summary` records its text on each version it mints.
|
|
457
|
+
|
|
458
|
+
`--dry-run` sends each changed item to the dry run, `POST /api/validate`, which answers what the publish would do, the version it would mint included, and stores nothing. The run reports every rejection, then exits 1. A dry run publishes nothing, so an item whose dependency, member, or foundation item the same run sends ahead of it reports pending, not rejected, since its findings may wait on that change alone. A registry of another major version skips the dry run with a warning.
|
|
459
|
+
|
|
460
|
+
`--release <tag>` records a release over the registry's versions, so every `standard` item must be current first: its files equal the registry's latest version's. An item that isn't is listed, and the run refuses with exit 1. Publish, then pull, then release again. The run packs every `standard` item into a release folder, into `--out` or `build/release/<tag>/`, whose hashes match the registry's, records the release, and builds each preset once, so its first download is cached. `--no-warm` skips the builds. `--from <folder>` publishes a folder already packed instead: an item the registry doesn't hold is a first publish at the folder's version, one it holds at that version with the same files already exists, and any other refuses the run.
|
|
461
|
+
|
|
462
|
+
- **`--json`**: `{ registry, handshake, dryRun, published, current, behind, conflicts, pending, purged, rejected }`. `published` is `[{ name, version, base, merged, bump, floor, warnings }]`, `version` the minted one, `current` lists names, `behind` is `[{ name, version, latest }]`, `conflicts` is `[{ name, version, error, latest, conflicts }]`, `error` being `conflict` or `unknown-base` and `conflicts` each file as `{ path, reason, keys? }`, `pending` and `purged` are `[{ name, version }]`, and `rejected` is `null` or the first `{ name, version, rejections, warnings }`. A dry run against a registry of another major version answers `{ registry, handshake, dryRun, skipped }`. With `--release`, `{ registry, handshake, tag, dir, published, existing, behind, release, warmed, rejected }`, `release` being `created` or `existing` and `behind` the items that weren't current
|
|
463
|
+
- **Exit 1**: a rejection, a `standard` item that isn't current before a release, a release that holds other content, or a different major version
|
|
464
|
+
- **Exit 2**: `--from`, `--out`, or `--no-warm` without `--release`, `--bump`, `--summary`, or `--dry-run` with it, a bump outside the three, a tag that doesn't match `--from`'s folder, or a release from a collection that doesn't author `standard`
|
|
465
|
+
- **Exit 3**: a conflict or an unknown base
|
|
466
|
+
|
|
467
|
+
### pull
|
|
468
|
+
|
|
469
|
+
```sh
|
|
470
|
+
ca-ds pull [--dry-run] [--token <token>]
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
Writes the registry's newer versions of the collection's authored items into the collection, so a version minted outside it, such as by a page published from the browser or by your own `publish`, comes back. It lists every item the registry holds in one of `namespaces`, and takes each one's latest version:
|
|
474
|
+
|
|
475
|
+
- **current**: the collection's `version` is the latest, so nothing is written
|
|
476
|
+
- **updated**: the collection's files equal the registry's at its `version`, so the latest version's files replace them in the item's folder
|
|
477
|
+
- **merged**: the collection's files differ from the registry's at its `version`, so each file merges three ways, the base the registry's file at the collection's `version`, theirs the latest's, and ours the local file. A file you left alone fast-forwards, a text file takes both sides' lines, and a JSON file merges by key path. `item.json`'s `version` becomes the latest on every side first, so it never conflicts. A collection `version` the registry never published merges two ways, with no base
|
|
478
|
+
- **conflict**: a text file changed the same lines on both sides, so it takes git-style conflict markers, and the item moves to the latest version. `validate` rejects the file until you resolve it
|
|
479
|
+
- **added**: the collection holds no such item, so the latest version's files land at its `source`
|
|
480
|
+
- **removed**: an admin purged the item, as `GET /api/purges` lists it, so the files the collection's version ships are deleted, and git history keeps them. A file the item never shipped, such as its `notes.md`, stays, and `pull` says so on stderr
|
|
481
|
+
- **stopped**: the item can't be written safely, and the reason says why. The item's files stay as they were
|
|
482
|
+
|
|
483
|
+
The files are the registry's bytes where you made no edit, so a `publish` after a `pull` finds each item current and sends nothing. A write touches only the files the registry's versions ship:
|
|
484
|
+
|
|
485
|
+
- a file the item never ships, such as `notes.md` or a check page, stays
|
|
486
|
+
- a file the collection's version shipped and the latest doesn't is deleted, unless you edited it
|
|
487
|
+
|
|
488
|
+
An added item arrives without a `notes.md`, since no version ships one, and `pull` says so on stderr. Write one by hand for each added item whose decisions need their reasons.
|
|
489
|
+
|
|
490
|
+
An item stops on any of these:
|
|
491
|
+
|
|
492
|
+
- a JSON key, or a binary file, changed on both sides, or a file deleted on one side and changed on the other. The item stays at its version, untouched. Settle the file by hand, such as by taking one side, then pull again
|
|
493
|
+
- it was purged, and the collection holds a version the registry never published, which `pull` won't delete
|
|
494
|
+
- its latest version's `source` names another folder than the collection's. The reason names the move: move the folder there whole, with `git mv`, so its `notes.md` and check pages go with it, then `pull` again
|
|
495
|
+
- its `source` names no folder inside the collection, sits outside `standard/` for a `standard` item or outside `site/` for a `site` item, or sits in the install folder or a folder the walk skips
|
|
496
|
+
- another item already sits at its `source`, or a new item's files would land on files already there
|
|
497
|
+
- its `source` sits inside another item's folder over a file of that item, which the written `item.json` would cut off from it, or holds another item's folder over a file it ships. An index item's folder holds its leaves' folders, so nesting alone stops nothing
|
|
498
|
+
|
|
499
|
+
A stopped item stops itself alone, and the run writes every other item. `--dry-run` reports the same and writes nothing.
|
|
500
|
+
|
|
501
|
+
- **`--json`**: `{ registry, dryRun, current, items }`. `current` counts the current items, and `items` is `[{ name, from, to, versions, path, status, written, removed, files, reason? }]`, one for each item not current, sorted by name. `from` is `null` for an added item, `to` is `null` for a removed one, `versions` the registry's live versions past `from` up to `to`, or a removed item's purged versions, `path` the folder written, `written` the files whose bytes changed, `removed` the files deleted, and `files` each file a merge changed, as `{ path, outcome, conflicts?, reason?, keys? }`
|
|
502
|
+
- **Exit 2**: a name, or a `collection.json` with no `namespaces`
|
|
503
|
+
- **Exit 3**: a conflict or a stopped item
|
|
504
|
+
|
|
505
|
+
### login
|
|
506
|
+
|
|
507
|
+
```sh
|
|
508
|
+
ca-ds login [--no-open]
|
|
509
|
+
ca-ds login --paste [--no-open]
|
|
510
|
+
ca-ds login --token <token>
|
|
511
|
+
printf '%s' "$TOKEN" | ca-ds login
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
Signs in to the registry, or stores a token for it. It runs with or without a collection.
|
|
515
|
+
|
|
516
|
+
On a terminal, with no `--token` or `--paste`, it signs in through your browser:
|
|
517
|
+
|
|
518
|
+
1. **Discovery.** It reads `<registry>/.well-known/oauth-authorization-server`. Any answer but a JSON object naming an authorization and a token endpoint, such as a 404, a 401, or a page, falls back to the pasted token, and one line on stderr says why.
|
|
519
|
+
2. **The authorize address.** It listens on `127.0.0.1` at a free port, at `/callback`, and builds the authorize address with a PKCE S256 challenge, a random `state`, the client ID `ca-ds`, the scope `registry`, and the resource `<registry>/mcp`.
|
|
520
|
+
3. **The browser.** It prints the address on stderr, and opens it in your browser unless `--no-open` or `--json` is given. Sign in and allow the request. The browser returns to the loopback address, and the tab says the sign-in finished.
|
|
521
|
+
4. **The pasted address.** When the browser runs on another machine, such as over SSH, it can't reach the loopback address. Copy the address the browser lands on, and paste it at the prompt.
|
|
522
|
+
5. **The checks.** The answer's `state` matches the one sent, and its `iss` names the metadata's issuer. The code goes to the token endpoint with the PKCE verifier, and the access token must pass `GET /api/releases` before the file stores the pair.
|
|
523
|
+
|
|
524
|
+
The sign-in waits 5 minutes for the answer. A denied sign-in, a `state` or an `iss` that doesn't match, a refused code, and the timeout each end with exit 4, and store nothing.
|
|
525
|
+
|
|
526
|
+
`--paste` takes the pasted token on a terminal: it prints `<registry>/settings/api-keys`, opens it in your browser unless `--no-open` or `--json` is given, and reads the pasted token without echoing it. `--token` takes the token from the command line. Piped, `login` reads the first line of stdin. Each checks the token against the registry and stores it only when the registry takes it.
|
|
527
|
+
|
|
528
|
+
- **`--json`**: `{ registry, file }` for a token, and `{ registry, file, kind: "oauth", expiresAt }` for a browser sign-in, `expiresAt` the access token's expiry
|
|
529
|
+
- **Exit 2**: an empty token
|
|
530
|
+
- **Exit 4**: the registry refused the token or the code, or the sign-in was denied, failed its checks, or timed out, and the file is left as it was
|
|
531
|
+
- **Exit 5**: the registry or its token endpoint can't be reached
|
|
532
|
+
|
|
533
|
+
### logout
|
|
534
|
+
|
|
535
|
+
```sh
|
|
536
|
+
ca-ds logout
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
Removes the stored credential for the registry, and keeps every other registry's.
|
|
540
|
+
|
|
541
|
+
For a browser sign-in, it posts the refresh token to the registry's revocation endpoint first, which ends the connection. A failed revocation warns and still removes the entry, so revoke the connection yourself under Connected apps at `<registry>/settings/api-keys`.
|
|
542
|
+
|
|
543
|
+
For a pasted key, it only removes the entry. The key stays live until you revoke it at `<registry>/settings/api-keys`.
|
|
544
|
+
|
|
545
|
+
- **`--json`**: `{ registry, file, removed }`, `removed` false when the file held no entry, and for a browser sign-in also `kind: "oauth"` and `revoked`, whether the registry took the revocation
|
|
546
|
+
|
|
547
|
+
## Output
|
|
548
|
+
|
|
549
|
+
Text output is for people, and `--json` is the contract. With `--json`:
|
|
550
|
+
|
|
551
|
+
- stdout holds exactly one JSON document, the command's answer, as § *Commands* gives each
|
|
552
|
+
- a failure prints `{ "error": { "code": "<name>", "message": "..." } }`, `code` being the exit code's name
|
|
553
|
+
- the text a person reads is silent, apart from `login`'s prompts and its authorize address on stderr
|
|
554
|
+
|
|
555
|
+
### Exit codes
|
|
556
|
+
|
|
557
|
+
| Code | Name | Means |
|
|
558
|
+
|---|---|---|
|
|
559
|
+
| 0 | `ok` | the command did its work |
|
|
560
|
+
| 1 | `rejected` | the collection fails a check, such as a validator rejection or a build its content breaks, and any failure no other code names |
|
|
561
|
+
| 2 | `usage` | the command line is wrong, such as an unknown command or flag, a missing argument, or no `collection.json` at or above the folder |
|
|
562
|
+
| 3 | `conflict` | a merge conflict, which leaves markers, or a hard stop, which leaves the files untouched |
|
|
563
|
+
| 4 | `auth` | the registry refused the token, or there is none, or a browser sign-in was denied, failed its checks, or timed out |
|
|
564
|
+
| 5 | `registry` | the registry can't be reached, answers with an error, or lacks an item asked for. A file whose hash doesn't match ends here too |
|
|
565
|
+
|
|
566
|
+
## The version handshake
|
|
567
|
+
|
|
568
|
+
The registry's `GET /api/health` reports the `@cagov/ca-ds` version the registry runs. `publish` and an online `validate` compare it with their own:
|
|
569
|
+
|
|
570
|
+
- **`match`**: the two are equal
|
|
571
|
+
- **`registry-older` or `local-older`**: they differ by a minor or a patch version, which warns
|
|
572
|
+
- **`major`**: they differ in the major version, which `publish` refuses, `publish --dry-run` skips, and `validate` warns about
|
|
573
|
+
- **`unknown`**: the registry reports no version, which warns
|
|
574
|
+
|
|
575
|
+
Version 1.0.0 gave an upload's `version` its meaning as the base, so a 0.x `ca-ds` meets `major` against a 1.x registry and refuses to publish. The registry's dry run catches the real failures either way, and the handshake explains them.
|
|
576
|
+
|
|
577
|
+
## Previewing
|
|
578
|
+
|
|
579
|
+
The previewer's routes:
|
|
580
|
+
|
|
581
|
+
| Route | Answers |
|
|
582
|
+
|---|---|
|
|
583
|
+
| `/` | the index: your pages first, then the templates, then every other item |
|
|
584
|
+
| `/preview/item/<scope>/<name>/<file>` | an example or a check page in the preview shell |
|
|
585
|
+
| `/frame/item/<scope>/<name>/<file>` | the same page's bare frame |
|
|
586
|
+
| `/preview/page/<path>` and `/frame/page/<path>` | a page `collection.json`'s `pages` globs match |
|
|
587
|
+
| `/assets/tokens.css`, `/assets/bundle.css`, and `/assets/bundle.js` | the in-memory build, with source maps beside each |
|
|
588
|
+
| `/media/<slug>/<file>` | a file of the media item in folder `<slug>` |
|
|
589
|
+
| `/__preview__` | the previewer's identity: its name, collection, PID, port, and version |
|
|
590
|
+
|
|
591
|
+
A page that holds `<html` is a whole document, and keeps its own head, with the built CSS linked first and the script last. Any other page is a fragment, which takes the stock frame. A check page and a fragment take three comment markers, which `./src/preview/pages.js` describes:
|
|
592
|
+
|
|
593
|
+
- `preview-title`, the page's label
|
|
594
|
+
- `preview-styles`, the stylesheets that load in place of the full build
|
|
595
|
+
- `preview-inset`, the demo gutter forced on or off
|
|
596
|
+
|
|
597
|
+
To drive the previewer from a script or an agent:
|
|
598
|
+
|
|
599
|
+
- **The start.** `ca-ds preview` is idempotent. Start it in the background and read its URL from the `running at` or `already running at` line, or from `--json`'s `url`.
|
|
600
|
+
- **The frame for measuring.** Load `/frame/...` for measuring and screenshots, so media queries see the real viewport and not the shell's iframe. A bare `/<item>/<page>.html` is no route.
|
|
601
|
+
- **A rendered page first.** A wrong path answers a plain-text 404, which screenshots like a valid image. Assert a title or a known element before you trust a screenshot.
|
|
602
|
+
- **Print emulation.** Playwright's `emulateMedia({ media: 'print' })` doesn't survive a navigation. Emulate after `goto`, then check that `matchMedia('print').matches`.
|
|
603
|
+
- **The stop.** `/__preview__` answers the PID. Never stop node processes by pattern. A previewer left running is harmless, since the next start reuses it.
|