@hygraph/cli 0.0.19 → 0.0.21
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/CHANGELOG.md +26 -0
- package/README.md +99 -0
- package/dist/cli.js +2836 -2472
- package/dist/define2.js +5 -1
- package/dist/version.js +1 -1
- package/package.json +3 -1
- package/skills/.gitkeep +0 -0
- package/skills/hygraph-modeling/SKILL.md +148 -0
- package/skills/pull-drift/SKILL.md +90 -0
- package/skills/split-config/SKILL.md +115 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @hygraph/cli
|
|
2
2
|
|
|
3
|
+
## 0.0.21
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 938c66a: Ctrl+C or Ctrl+D at the `hygraph apply` confirmation cancels the apply like a no, and is no longer reported as an error.
|
|
8
|
+
- 292eda4: `hygraph feedback` sends your feedback to the Hygraph team, with an optional email for a reply.
|
|
9
|
+
- 168d344: `plan` moves fields only when their order differs from the config. Before, a plan after an export, or after an apply that deleted a relation or a model, listed position changes for fields already in order.
|
|
10
|
+
- d521c81: The package has a `hygraph-modeling` skill for coding agents. It advises on models and fields, components and references, enumerations and taxonomies, apiId names, locales, variants and stages, and on changes that delete content, with a safe way to make each one.
|
|
11
|
+
- 50ff892: `plan` and `apply` show the `apiIdPlural`, `displayName` and `description` of a model or component they create. Before, they showed only the apiId.
|
|
12
|
+
- 25de0f7: `plan` lists a model's or component's fields in the order of your config. Fields `plan` deletes follow their order in the project. Before, fields were listed alphabetically.
|
|
13
|
+
- 50ff892: `plan --full` and `apply --full` show every setting of what they create. Without `--full`, a create leaves out settings at their default, such as `required: false` on a field, and settings that are not set.
|
|
14
|
+
- 50ff892: `plan` and `apply` name a created field by the builder your config uses, such as `markdown` or `slug`, followed by the type Hygraph stores for a simple field, such as `markdown (STRING)`. When a text field's editor changes, they name the editors the same way. Before, every text field showed as `string`, and an editor change showed Hygraph's ids, such as `GCMS_SINGLE_LINE`.
|
|
15
|
+
- 5d2f5d3: The package includes the agent skill `skills/pull-drift/SKILL.md`. A coding agent that follows it edits your config to match the changes `pull` reports, keeps the layout of your files, and checks the result with `plan`.
|
|
16
|
+
- 0c99006: `pull` and `apply` tell you when Studio can still edit the schema of the target environment, and how to lock it in Studio (Project Settings → Schema lock). A locked schema keeps Studio edits from making live differ from your config. The hint does not change the exit code.
|
|
17
|
+
- 87a2aa9: `plan`, `apply` and `pull` now report a config that is not in the expected form like other config errors, such as an invalid apiId: one block per error. `apply --plan` does the same for a plan file, and so does every command that reads the live schema, for a part of it that is not in the expected form. A config error names a model by its apiId, such as `apply.models.Author.__typename`. A model without a valid apiId, or with the same apiId as another model, keeps its position in the list.
|
|
18
|
+
- d90f206: The package includes an agent skill, `skills/split-config`. It shows a coding agent how to split `hygraph.config.ts` into one file per model, component, enumeration, taxonomy and remote source, and check with `plan` that the schema did not change.
|
|
19
|
+
- fd49bd2: `whoami` takes the config path as its first argument, like `plan`, `apply` and `pull`: `hygraph whoami brands/kaffa.ts`. `--config <file>` still works.
|
|
20
|
+
|
|
21
|
+
## 0.0.20
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- ecd2855: On a terminal, `export` asks before it replaces a config file that is already there, and writes nothing when you answer no. In CI, or when stdin is not a terminal, `export --out` replaces the file without a question, as before.
|
|
26
|
+
- fea7184: `export` now asks for the target's name as "Name for this environment in the config (used with --target)", and the `--name` help says the same. The new Targets section of the README says what a target is and how `--target` selects one.
|
|
27
|
+
- 2587a4e: When live differs from the config, `pull` now ends with the next steps: give the diff to a coding agent, or run `hygraph export --out <config>` to replace the config with the live schema. `pull --help` and the README show how to save the diff with `hygraph pull > drift.diff`.
|
|
28
|
+
|
|
3
29
|
## 0.0.19
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -86,6 +86,30 @@ npx hygraph plan
|
|
|
86
86
|
|
|
87
87
|
Commit `hygraph.config.ts`. From here on it is the source of your schema.
|
|
88
88
|
|
|
89
|
+
## Targets
|
|
90
|
+
|
|
91
|
+
A target is one environment of one project that the config manages. The
|
|
92
|
+
config exports one target, or a list of targets:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const kaffa = define.target({ name: "kaffa" /* … */ });
|
|
96
|
+
const sencha = define.target({ name: "sencha" /* … */ });
|
|
97
|
+
|
|
98
|
+
export default [kaffa, sencha];
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Each target has a `name`. `--name` sets it on `export`. Without the flag,
|
|
102
|
+
`export` asks for it in a terminal, with the environment as the default, and
|
|
103
|
+
uses the environment elsewhere. Two targets cannot have the same name or the
|
|
104
|
+
same environment of the same project.
|
|
105
|
+
|
|
106
|
+
`plan`, `apply`, `pull` and `whoami` use every target in the config. To use
|
|
107
|
+
only one, give its name with `--target`. Repeat the flag to select more:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
npx hygraph plan --target kaffa
|
|
111
|
+
```
|
|
112
|
+
|
|
89
113
|
## Make a change
|
|
90
114
|
|
|
91
115
|
Edit the config. To add a field to a model you already have, add it to the
|
|
@@ -121,6 +145,14 @@ See what would change:
|
|
|
121
145
|
npx hygraph plan
|
|
122
146
|
```
|
|
123
147
|
|
|
148
|
+
A create shows the settings your config sets. To also see the settings it
|
|
149
|
+
leaves at their default, and those it does not set, pass `--full` to `plan` or
|
|
150
|
+
`apply`:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
npx hygraph plan --full
|
|
154
|
+
```
|
|
155
|
+
|
|
124
156
|
Apply it:
|
|
125
157
|
|
|
126
158
|
```bash
|
|
@@ -160,6 +192,35 @@ project, so the plan alone does not let anyone test a guessed value.
|
|
|
160
192
|
`apply` refuses the saved plan when one of these values changed after
|
|
161
193
|
`plan`, or when the project's key changed. Run `plan` again in that case.
|
|
162
194
|
|
|
195
|
+
## Bring live changes into your config
|
|
196
|
+
|
|
197
|
+
When someone changes the schema in Studio, the config no longer matches the
|
|
198
|
+
project. `pull` shows what changed live, as a diff against the config:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
npx hygraph pull
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
To save the diff to a file, redirect it. The file holds the diff only, without
|
|
205
|
+
colours:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
npx hygraph pull > drift.diff
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Then bring the changes into the config in one of two ways:
|
|
212
|
+
|
|
213
|
+
- **Give the diff to a coding agent.** It edits your config in place. For
|
|
214
|
+
example, ask it: "Bring the live changes in drift.diff into
|
|
215
|
+
hygraph.config.ts, then run `npx hygraph plan` until it shows no changes."
|
|
216
|
+
- **Export again.** `npx hygraph export --out hygraph.config.ts` replaces the
|
|
217
|
+
config with the live schema. Your own edits to the file are lost.
|
|
218
|
+
|
|
219
|
+
To stop Studio edits, lock the environment in Studio: Project Settings → Schema
|
|
220
|
+
lock. While it is not locked, `pull` ends with a hint that says so.
|
|
221
|
+
`apply` shows the hint too, but only for a target that it applied or that had no
|
|
222
|
+
changes.
|
|
223
|
+
|
|
163
224
|
## What's supported
|
|
164
225
|
|
|
165
226
|
- **Schema:** models, components, enumerations, taxonomies, locales and
|
|
@@ -183,10 +244,43 @@ hygraph whoami show which project and environment the token reaches
|
|
|
183
244
|
hygraph plan show what would change against the environment
|
|
184
245
|
hygraph apply apply the plan as one migration
|
|
185
246
|
hygraph pull show what changed live, as a diff against the config
|
|
247
|
+
hygraph feedback send feedback to the Hygraph team
|
|
186
248
|
```
|
|
187
249
|
|
|
250
|
+
`plan`, `apply`, `pull` and `whoami` read `hygraph.config.ts`. To read
|
|
251
|
+
another config, give its path as the first argument, such as
|
|
252
|
+
`npx hygraph plan brands/kaffa.ts`.
|
|
253
|
+
|
|
188
254
|
Run `npx hygraph <command> --help` for every option.
|
|
189
255
|
|
|
256
|
+
## Use the CLI with a coding agent
|
|
257
|
+
|
|
258
|
+
The package ships agent skills in its `skills/` folder. A skill is a folder
|
|
259
|
+
with a `SKILL.md` file that tells a coding agent how to do a task with the
|
|
260
|
+
CLI.
|
|
261
|
+
|
|
262
|
+
To link the skills into your project, run the `experimental_sync` command of
|
|
263
|
+
the [`skills`](https://github.com/vercel-labs/skills) CLI. The command is
|
|
264
|
+
experimental.
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
npx skills experimental_sync
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
It finds the skills in `node_modules`, links each one into the skills folder
|
|
271
|
+
of your agents and writes `skills-lock.json`. The links point into
|
|
272
|
+
`node_modules`, so a skill changes when you update the CLI.
|
|
273
|
+
|
|
274
|
+
Or copy a skill into the folder that your agent reads, for example
|
|
275
|
+
`.claude/skills/` for Claude Code:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
cp -r node_modules/@hygraph/cli/skills/<name> .claude/skills/
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
A copy does not change when you update the CLI. Copy it again after an
|
|
282
|
+
update.
|
|
283
|
+
|
|
190
284
|
## Telemetry
|
|
191
285
|
|
|
192
286
|
The CLI reports errors and usage to Hygraph, so that we can fix bugs and
|
|
@@ -210,6 +304,11 @@ see which commands people use. It tells you so the first time it runs.
|
|
|
210
304
|
|
|
211
305
|
To turn it off, set `HYGRAPH_TELEMETRY=0` or `DO_NOT_TRACK=1`.
|
|
212
306
|
|
|
307
|
+
## Feedback
|
|
308
|
+
|
|
309
|
+
`hygraph feedback "..."` sends your feedback to the Hygraph team.
|
|
310
|
+
Without a message, it asks for one. Add `--email` if you want a reply.
|
|
311
|
+
|
|
213
312
|
## License
|
|
214
313
|
|
|
215
314
|
MIT
|