@hygraph/cli 0.0.21 → 0.1.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/CHANGELOG.md +12 -0
- package/README.md +14 -7
- package/dist/cli.js +20 -11
- package/dist/define.d.ts +23 -0
- package/dist/define2.js +12 -8
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/hygraph-modeling/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @hygraph/cli
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e8e61bd: `ignoreTitleWarning: true` on `define.model` or `define.component` turns off the warning that it has no title field. Set it on a model or component that needs no title, such as a model with one entry that holds settings. On `define.environment`, it turns the warning off for every model and component.
|
|
8
|
+
|
|
9
|
+
## 0.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 5c0f7b1: The CLI is now in beta. **Generate CLI PAT** in Studio is on for every project, and the Setup section of the README names it as the first way to create the token.
|
|
14
|
+
|
|
3
15
|
## 0.0.21
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Manage your Hygraph schema as code. Describe the schema in TypeScript, review
|
|
|
6
6
|
what would change, and apply it as one migration.
|
|
7
7
|
|
|
8
8
|
> [!WARNING]
|
|
9
|
-
> The CLI is in **
|
|
9
|
+
> The CLI is in **beta** and under active development. Not every field type
|
|
10
10
|
> and platform capability is supported yet, and commands and the config
|
|
11
11
|
> format can still change between releases.
|
|
12
12
|
>
|
|
@@ -28,12 +28,11 @@ npm i -D @hygraph/cli
|
|
|
28
28
|
The CLI needs a permanent auth token from your project's settings in Studio:
|
|
29
29
|
|
|
30
30
|
- a **permanent auth token** **(PAT)**
|
|
31
|
-
- Create one in **Project Settings > Permanent Auth Tokens
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
your project.
|
|
31
|
+
- Create one in **Project Settings > Permanent Auth Tokens** with
|
|
32
|
+
**Generate CLI PAT**. It creates a token with the management permissions
|
|
33
|
+
the CLI needs and no content access.
|
|
34
|
+
- Or use **Add token** on the same page, and then enable all management
|
|
35
|
+
permissions for it.
|
|
37
36
|
- Put the token in the `HYGRAPH_TOKEN` environment variable. The config
|
|
38
37
|
reads it from there, so the token never ends up in a file you commit.
|
|
39
38
|
|
|
@@ -145,6 +144,14 @@ See what would change:
|
|
|
145
144
|
npx hygraph plan
|
|
146
145
|
```
|
|
147
146
|
|
|
147
|
+
The plan can end with warnings, such as a model or component that has no title
|
|
148
|
+
field. Studio shows a model's entries, and labels a component, by its title
|
|
149
|
+
field, so set `title: true` on one of its fields, such as a name or a heading. A
|
|
150
|
+
model or component that needs no title, such as a model with one entry that
|
|
151
|
+
holds settings, takes `ignoreTitleWarning: true`: `plan` and `apply` then leave
|
|
152
|
+
out that warning for it. To leave it out for every model and component, set
|
|
153
|
+
`ignoreTitleWarning: true` on `define.environment`.
|
|
154
|
+
|
|
148
155
|
A create shows the settings your config sets. To also see the settings it
|
|
149
156
|
leaves at their default, and those it does not set, pass `--full` to `plan` or
|
|
150
157
|
`apply`:
|
package/dist/cli.js
CHANGED
|
@@ -14566,7 +14566,7 @@ const fixes = {
|
|
|
14566
14566
|
["model.invalidRenamedFrom"]: "Use the apiId the model has in Hygraph right now: an uppercase letter, then letters, digits and underscores only, up to 64 characters.",
|
|
14567
14567
|
["model.renamedFromMatchesApiId"]: "Set renamedFrom to the apiId the model has in Hygraph right now, or remove it.",
|
|
14568
14568
|
["model.duplicateRenamedFrom"]: "Keep renamedFrom on the model that continues it. The other models are created new.",
|
|
14569
|
-
["model.noTitleField"]: "Set title: true on the field Studio should show entries by, such as a name or a heading.",
|
|
14569
|
+
["model.noTitleField"]: "Set title: true on the field Studio should show entries by, such as a name or a heading. If the model needs none, set ignoreTitleWarning: true on it, or on define.environment to turn the warning off for every model and component.",
|
|
14570
14570
|
["model.apiIdReserved"]: "Use another apiId. To add fields to Asset, Query or Segment, put system.model.asset({ fields }), system.model.query({ fields }) or system.model.segment({ fields }) in models.",
|
|
14571
14571
|
["model.sidebarDuplicate"]: "List each panel once. A model has each of Hygraph's panels, and each app element's, at most once.",
|
|
14572
14572
|
["model.sidebarDuplicateDisplayName"]: "Give the app panel another displayName. Hygraph's panels are titled Entry information, Schedule, Stages, Localizations, Versions, Preview, Content workflows, Variants, Agents and Tags.",
|
|
@@ -14593,7 +14593,7 @@ const fixes = {
|
|
|
14593
14593
|
["component.invalidRenamedFrom"]: "Use the apiId the component has in Hygraph right now: an uppercase letter, then letters, digits and underscores only, up to 64 characters.",
|
|
14594
14594
|
["component.renamedFromMatchesApiId"]: "Set renamedFrom to the apiId the component has in Hygraph right now, or remove it.",
|
|
14595
14595
|
["component.duplicateRenamedFrom"]: "Keep renamedFrom on the component that continues it. The other components are created new.",
|
|
14596
|
-
["component.noTitleField"]: "Set title: true on the field Studio should label the component by, such as a name or a heading.",
|
|
14596
|
+
["component.noTitleField"]: "Set title: true on the field Studio should label the component by, such as a name or a heading. If the component needs none, set ignoreTitleWarning: true on it, or on define.environment to turn the warning off for every model and component.",
|
|
14597
14597
|
["component.duplicateApiId"]: "Rename one of them. Models, components, enumerations and taxonomies share their apiIds, unique per environment.",
|
|
14598
14598
|
["component.duplicateDisplayName"]: "Rename one of them. A component displayName is unique per environment.",
|
|
14599
14599
|
["enumeration.invalidApiId"]: "Start with an uppercase letter, then use letters, digits and underscores only, up to 64 characters.",
|
|
@@ -19239,8 +19239,11 @@ function validateSystemSegment(segment) {
|
|
|
19239
19239
|
* What a component can tell about itself, its fields included. Whether its
|
|
19240
19240
|
* names collide with another resource belongs to the environment. Every
|
|
19241
19241
|
* check runs, whatever the ones before it found.
|
|
19242
|
+
*
|
|
19243
|
+
* `ignoreTitleWarning` is the environment's: it turns the no-title warning
|
|
19244
|
+
* off for every component, as the component's own setting does for it.
|
|
19242
19245
|
*/
|
|
19243
|
-
function validateComponent(component) {
|
|
19246
|
+
function validateComponent(component, { ignoreTitleWarning = false } = {}) {
|
|
19244
19247
|
const validations = [];
|
|
19245
19248
|
if (!isValidApiId(component.apiId)) validations.push({
|
|
19246
19249
|
code: "component.invalidApiId",
|
|
@@ -19281,7 +19284,7 @@ function validateComponent(component) {
|
|
|
19281
19284
|
kind: "component",
|
|
19282
19285
|
apiId: component.apiId
|
|
19283
19286
|
}, component.fields));
|
|
19284
|
-
if (component.fields.length > 0 && !component.fields.some((field) => field.__typename === "UnsupportedField" || "title" in field && field.title)) validations.push({
|
|
19287
|
+
if (!ignoreTitleWarning && !component.ignoreTitleWarning && component.fields.length > 0 && !component.fields.some((field) => field.__typename === "UnsupportedField" || "title" in field && field.title)) validations.push({
|
|
19285
19288
|
code: "component.noTitleField",
|
|
19286
19289
|
severity: "warning",
|
|
19287
19290
|
path: componentPath(component.apiId, "fields"),
|
|
@@ -19567,8 +19570,11 @@ function describePanel(element) {
|
|
|
19567
19570
|
*
|
|
19568
19571
|
* Every check runs, whatever the ones before it found. Two faults in one
|
|
19569
19572
|
* model are two entries, not one report and a second run to find the rest.
|
|
19573
|
+
*
|
|
19574
|
+
* `ignoreTitleWarning` is the environment's: it turns the no-title warning
|
|
19575
|
+
* off for every model, as the model's own setting does for it.
|
|
19570
19576
|
*/
|
|
19571
|
-
function validateModel(model) {
|
|
19577
|
+
function validateModel(model, { ignoreTitleWarning = false } = {}) {
|
|
19572
19578
|
const validations = [];
|
|
19573
19579
|
if (!isValidApiId(model.apiId)) validations.push({
|
|
19574
19580
|
code: "model.invalidApiId",
|
|
@@ -19617,7 +19623,7 @@ function validateModel(model) {
|
|
|
19617
19623
|
message: messages["model.sidebarVariantsMissing"](model.apiId),
|
|
19618
19624
|
fix: fixes["model.sidebarVariantsMissing"]
|
|
19619
19625
|
});
|
|
19620
|
-
if (model.fields.length > 0 && !model.fields.some((field) => field.__typename === "UnsupportedField" || "title" in field && field.title)) validations.push({
|
|
19626
|
+
if (!ignoreTitleWarning && !model.ignoreTitleWarning && model.fields.length > 0 && !model.fields.some((field) => field.__typename === "UnsupportedField" || "title" in field && field.title)) validations.push({
|
|
19621
19627
|
code: "model.noTitleField",
|
|
19622
19628
|
severity: "warning",
|
|
19623
19629
|
path: modelPath(model.apiId, "fields"),
|
|
@@ -19900,7 +19906,7 @@ function validateEnvironment(environment) {
|
|
|
19900
19906
|
}
|
|
19901
19907
|
const needsSegment = environment.systemModels.some((model) => model.__typename === "SystemSegment") || environment.models.some((model) => model.fields.some((field) => field.__typename !== "UnsupportedField" && field.variantEnabled));
|
|
19902
19908
|
for (const model of environment.models) {
|
|
19903
|
-
validations.push(...validateModel(model));
|
|
19909
|
+
validations.push(...validateModel(model, { ignoreTitleWarning: environment.ignoreTitleWarning }));
|
|
19904
19910
|
if ([
|
|
19905
19911
|
"Asset",
|
|
19906
19912
|
"QueryModel",
|
|
@@ -19981,7 +19987,7 @@ function validateEnvironment(environment) {
|
|
|
19981
19987
|
const componentDisplayNames = /* @__PURE__ */ new Set();
|
|
19982
19988
|
const componentRenamedFroms = /* @__PURE__ */ new Set();
|
|
19983
19989
|
for (const component of environment.components) {
|
|
19984
|
-
validations.push(...validateComponent(component));
|
|
19990
|
+
validations.push(...validateComponent(component, { ignoreTitleWarning: environment.ignoreTitleWarning }));
|
|
19985
19991
|
if (apiIds.has(component.apiId)) validations.push({
|
|
19986
19992
|
code: "component.duplicateApiId",
|
|
19987
19993
|
severity: "error",
|
|
@@ -24003,7 +24009,8 @@ const componentSchema = strictObject({
|
|
|
24003
24009
|
displayName: string$1(),
|
|
24004
24010
|
description: string$1().nullable(),
|
|
24005
24011
|
fields: array(fieldSchema),
|
|
24006
|
-
renamedFrom: string$1().nullable()
|
|
24012
|
+
renamedFrom: string$1().nullable(),
|
|
24013
|
+
ignoreTitleWarning: boolean()
|
|
24007
24014
|
});
|
|
24008
24015
|
//#endregion
|
|
24009
24016
|
//#region src/define/resources/locale.zod.ts
|
|
@@ -24025,7 +24032,8 @@ const modelSchema = strictObject({
|
|
|
24025
24032
|
description: string$1().nullable(),
|
|
24026
24033
|
fields: array(fieldSchema),
|
|
24027
24034
|
sidebar: array(sidebarElementSchema$1).nullable(),
|
|
24028
|
-
renamedFrom: string$1().nullable()
|
|
24035
|
+
renamedFrom: string$1().nullable(),
|
|
24036
|
+
ignoreTitleWarning: boolean()
|
|
24029
24037
|
});
|
|
24030
24038
|
//#endregion
|
|
24031
24039
|
//#region src/define/resources/environment.zod.ts
|
|
@@ -24042,7 +24050,8 @@ const environmentSchema = strictObject({
|
|
|
24042
24050
|
systemAssetSchema,
|
|
24043
24051
|
systemQuerySchema,
|
|
24044
24052
|
systemSegmentSchema
|
|
24045
|
-
]))
|
|
24053
|
+
])),
|
|
24054
|
+
ignoreTitleWarning: boolean()
|
|
24046
24055
|
});
|
|
24047
24056
|
//#endregion
|
|
24048
24057
|
//#region src/define/resources/target.zod.ts
|
package/dist/define.d.ts
CHANGED
|
@@ -220,6 +220,13 @@ type ModelInput = {
|
|
|
220
220
|
* that has neither apiId gets a new model under the new apiId.
|
|
221
221
|
*/
|
|
222
222
|
renamedFrom?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Turns off the warning that the model has no title field. Set it on a
|
|
225
|
+
* model whose entries need no title, such as a model with one entry
|
|
226
|
+
* that holds settings.
|
|
227
|
+
* @default false
|
|
228
|
+
*/
|
|
229
|
+
ignoreTitleWarning?: boolean;
|
|
223
230
|
};
|
|
224
231
|
/** What `define.model` hands back: the input with every default filled in. */
|
|
225
232
|
type Model = {
|
|
@@ -232,6 +239,7 @@ type Model = {
|
|
|
232
239
|
/** `null` when the config leaves the sidebar as it is. */
|
|
233
240
|
sidebar: SidebarElement[] | null;
|
|
234
241
|
renamedFrom: string | null;
|
|
242
|
+
ignoreTitleWarning: boolean;
|
|
235
243
|
};
|
|
236
244
|
/**
|
|
237
245
|
* One model.
|
|
@@ -504,6 +512,12 @@ type ComponentInput = {
|
|
|
504
512
|
* component under the new apiId.
|
|
505
513
|
*/
|
|
506
514
|
renamedFrom?: string;
|
|
515
|
+
/**
|
|
516
|
+
* Turns off the warning that the component has no title field. Set it on
|
|
517
|
+
* a component that needs no label in Studio.
|
|
518
|
+
* @default false
|
|
519
|
+
*/
|
|
520
|
+
ignoreTitleWarning?: boolean;
|
|
507
521
|
};
|
|
508
522
|
/**
|
|
509
523
|
* What `define.component` hands back: the input with every default filled
|
|
@@ -517,6 +531,7 @@ type Component = {
|
|
|
517
531
|
description: string | null;
|
|
518
532
|
fields: Field[];
|
|
519
533
|
renamedFrom: string | null;
|
|
534
|
+
ignoreTitleWarning: boolean;
|
|
520
535
|
};
|
|
521
536
|
/**
|
|
522
537
|
* A group of fields that editors fill in inside an entry. A component has
|
|
@@ -2580,6 +2595,13 @@ type EnvironmentInput = {
|
|
|
2580
2595
|
/** @default [] */
|
|
2581
2596
|
components?: Component[];
|
|
2582
2597
|
models: (Model | SystemModel)[];
|
|
2598
|
+
/**
|
|
2599
|
+
* Turns off the warning that a model or component has no title field,
|
|
2600
|
+
* for every model and component in the environment. To turn it off for
|
|
2601
|
+
* one of them only, set `ignoreTitleWarning` on that model or component.
|
|
2602
|
+
* @default false
|
|
2603
|
+
*/
|
|
2604
|
+
ignoreTitleWarning?: boolean;
|
|
2583
2605
|
};
|
|
2584
2606
|
type Environment = {
|
|
2585
2607
|
__typename: "Environment";
|
|
@@ -2593,6 +2615,7 @@ type Environment = {
|
|
|
2593
2615
|
models: Model[];
|
|
2594
2616
|
/** The models Hygraph provides that `models` lists, in its order. */
|
|
2595
2617
|
systemModels: SystemModel[];
|
|
2618
|
+
ignoreTitleWarning: boolean;
|
|
2596
2619
|
};
|
|
2597
2620
|
/** A model Hygraph provides, as `system.*` hands it back. */
|
|
2598
2621
|
type SystemModel = SystemAsset | SystemQuery | SystemSegment;
|
package/dist/define2.js
CHANGED
|
@@ -5517,13 +5517,15 @@ function component(input) {
|
|
|
5517
5517
|
displayName: input.displayName,
|
|
5518
5518
|
description: isEmpty(input.description) ? null : input.description,
|
|
5519
5519
|
fields: [...input.fields],
|
|
5520
|
-
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
5520
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom,
|
|
5521
|
+
ignoreTitleWarning: input.ignoreTitleWarning ?? false
|
|
5521
5522
|
};
|
|
5522
5523
|
}
|
|
5523
5524
|
/**
|
|
5524
5525
|
* The canonical form, as `convertModelToIR` makes a model's. `renamedFrom`
|
|
5525
|
-
* is intent, not schema, and stays out
|
|
5526
|
-
* becomes its
|
|
5526
|
+
* is intent, not schema, and stays out, as does `ignoreTitleWarning`, which
|
|
5527
|
+
* only plan-time checks read. A field's index in `fields` becomes its
|
|
5528
|
+
* position.
|
|
5527
5529
|
*/
|
|
5528
5530
|
function convertComponentToIR(component) {
|
|
5529
5531
|
return {
|
|
@@ -5618,14 +5620,15 @@ function model$1(input) {
|
|
|
5618
5620
|
description: isEmpty(input.description) ? null : input.description,
|
|
5619
5621
|
fields: [...input.fields],
|
|
5620
5622
|
sidebar: input.sidebar?.map(sidebarElement) ?? null,
|
|
5621
|
-
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
5623
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom,
|
|
5624
|
+
ignoreTitleWarning: input.ignoreTitleWarning ?? false
|
|
5622
5625
|
};
|
|
5623
5626
|
}
|
|
5624
5627
|
/**
|
|
5625
5628
|
* Everything the canonical form adds to a model happens here. `renamedFrom`
|
|
5626
|
-
* is intent, not schema, and stays out
|
|
5627
|
-
*
|
|
5628
|
-
* `sidebar` does.
|
|
5629
|
+
* is intent, not schema, and stays out, as does `ignoreTitleWarning`, which
|
|
5630
|
+
* only plan-time checks read. Fields are keyed by apiId, and a field's index
|
|
5631
|
+
* in `fields` becomes its position, as a panel's in `sidebar` does.
|
|
5629
5632
|
*/
|
|
5630
5633
|
function convertModelToIR(model) {
|
|
5631
5634
|
return {
|
|
@@ -5743,7 +5746,8 @@ function environment(input) {
|
|
|
5743
5746
|
remoteSources: [...input.remoteSources ?? []],
|
|
5744
5747
|
components: [...input.components ?? []],
|
|
5745
5748
|
models: input.models.filter((model) => !SYSTEM_MODELS.includes(model.__typename)),
|
|
5746
|
-
systemModels: input.models.filter((model) => SYSTEM_MODELS.includes(model.__typename))
|
|
5749
|
+
systemModels: input.models.filter((model) => SYSTEM_MODELS.includes(model.__typename)),
|
|
5750
|
+
ignoreTitleWarning: input.ignoreTitleWarning ?? false
|
|
5747
5751
|
};
|
|
5748
5752
|
}
|
|
5749
5753
|
/** Converts every resource it holds on the way. */
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -120,7 +120,7 @@ Docs: [models](https://hygraph.com/docs/developer-guides/schema/models), [reserv
|
|
|
120
120
|
- `plan` checks the characters and length of each apiId. It does not check reserved names, so `apply` fails on them. Check each new name against the reserved terms page: it reserves names such as `Status`, `User` and `Locale` for a type, and `id`, `status` and `locale` for a field. Also reserved, but not on that page: `Type` for a model, component or enumeration.
|
|
121
121
|
- `Asset`, `Query` and `Segment` are Hygraph's models. To add fields to them, use `system.model.asset`, `system.model.query` or `system.model.segment`.
|
|
122
122
|
- Models are singular PascalCase (`Article`), with an `apiIdPlural` that differs (`Articles`). Fields are camelCase. A boolean starts with `is` or `has` (`isFeatured`). A reference is named after its model: `author` for one, `authors` for many. Enumeration values are UPPER_SNAKE_CASE (`IN_STOCK`).
|
|
123
|
-
- Set `title: true` on the field Studio shows entries by, such as a name or a heading. `plan` warns about a model without one.
|
|
123
|
+
- Set `title: true` on the field Studio shows a model's entries by, or labels a component by, such as a name or a heading. `plan` warns about a model or component without one. When it needs none, such as a model with one entry that holds settings, set `ignoreTitleWarning: true` on it. To turn the warning off for every model and component, set `ignoreTitleWarning: true` on `define.environment`.
|
|
124
124
|
|
|
125
125
|
## Locales and variants
|
|
126
126
|
|