@hygraph/cli 0.0.17 → 0.0.19
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 +134 -0
- package/README.md +23 -0
- package/dist/cli.d.ts +21 -7
- package/dist/cli.js +5011 -137
- package/dist/define.d.ts +241 -270
- package/dist/define2.js +9 -6
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -1
- package/dist/version.d.ts +7 -0
- package/dist/version.js +5 -2
- package/package.json +5 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# @hygraph/cli
|
|
2
|
+
|
|
3
|
+
## 0.0.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 511852f: Error reports now say more about a failed migration, an apply that left changes behind, and a Hygraph server error. The Telemetry section of the README lists what they hold.
|
|
8
|
+
- 6793077: A remote field can be renamed with `renamedFrom`, as other fields are.
|
|
9
|
+
- b1a7377: The usage event now counts the fields the CLI cannot read yet, by type and reason, and the models with a sidebar panel it cannot read. It sends no apiIds.
|
|
10
|
+
- 8acaeb4: Rich text `embeds` takes `system.model.asset`, so a field that embeds assets is planned, applied and exported like the others.
|
|
11
|
+
- 5cdab20: `apply --prune` now deletes stages, with the entries in them. Before, `plan` refused a stage delete.
|
|
12
|
+
|
|
13
|
+
## 0.0.18
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 8f725b4: The npm package now includes CHANGELOG.md.
|
|
18
|
+
- f9b11dd: Editor hovers on `define.*` and `system.*` describe what you write and no longer show CLI internals. Types such as a field's visibility, a colour or an unsupported field's `type` now show plain names like `FieldVisibility`, `ColorValue` and `FieldType`.
|
|
19
|
+
- 704ada9: The CLI now reports errors and usage to Hygraph, which you can turn off with `HYGRAPH_TELEMETRY=0` or `DO_NOT_TRACK=1`.
|
|
20
|
+
- f9b11dd: When the token is not a permanent auth token, the error now says so without naming Hygraph's internal token type.
|
|
21
|
+
|
|
22
|
+
## 0.0.17
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- ee091d7: `plan.json` now holds an HMAC under a project key in place of each remote source header value and OAuth secret, and `apply --plan` refuses an artifact from an earlier version.
|
|
27
|
+
|
|
28
|
+
## 0.0.16
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- 0ed0615: `export` and `pull` refuse to write a config when an apiId or remote source prefix is not a valid name.
|
|
33
|
+
- 4134cfa: A component union field's `visibility` change is now an update. The field and its content stay, and `apply` no longer needs `--prune`.
|
|
34
|
+
|
|
35
|
+
## 0.0.15
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- 9887d3b: `plan` refuses an asset field on a component whose hidden field back on Asset has a name another field already has. This happens when you rename an asset field and then add a new one under the old apiId: the field back keeps its name. `plan` also refuses a field on Asset, or a field back you name in `reverse`, that takes such a hidden name. Before, `apply` sent the change and Hygraph rolled back the whole migration with an error that did not name the field.
|
|
40
|
+
- d52938c: Model sidebar: `sidebar` on `define.model` lists the panels beside an entry in Studio, in order, and is planned and applied. Leave it out to keep a model's panels as they are; export leaves it out. To start from a model's panels, set `sidebar: []` and run `hygraph pull`: its diff shows the live panels, which you copy into the config. Plan refuses `sidebar` on a model with a panel of a legacy UI extension: leave `sidebar` out for that model.
|
|
41
|
+
|
|
42
|
+
## 0.0.14
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- 99c18a4: Fields whose editor is an installed app's element, with `define.field.custom`, planned, applied and exported like the other field types. Export your config again before you plan or apply: a config exported before this release has no app editors, so its plan sets those fields back to Hygraph's editor.
|
|
47
|
+
- 704b82f: `plan` and `pull` refuse a config where two models, components, enumerations or taxonomies, or two fields of one model or component, are renamed from the same apiId. Before, `plan` renamed one and created the other new and empty.
|
|
48
|
+
- ae780e1: A `renamedFrom` no longer stops the plan on an environment that has neither apiId, such as a new environment, or a field on a model the same plan creates. The plan creates the locale, enumeration, value, taxonomy, node, component, model or field under the new apiId instead, so one config can be promoted from environment to environment with its `renamedFrom`s in place. When the same plan deletes one of the same kind in the same place, the plan warns, as `renamedFrom` may have a typo.
|
|
49
|
+
- 6bf7de9: `plan`, `apply`, `pull`, `export` and `whoami` make up to three attempts per request when the connection fails or Hygraph answers 429, 502, 503 or 504. An outage of a few seconds while `apply` waits for its migration no longer ends the command. When a longer outage does, `apply` says that the migration was submitted.
|
|
50
|
+
|
|
51
|
+
## 0.0.13
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- 48cc60e: `hygraph export` reads the Management API endpoint, the project and the environment from the permanent auth token, and prints what it found to stderr. With `HYGRAPH_TOKEN` set, `hygraph export` needs no flags, also in CI. `--endpoint`, `--project` and `--environment` take precedence over the token. When the token does not name its endpoint, such as an older token, pass `--endpoint`.
|
|
56
|
+
|
|
57
|
+
In a terminal, `export` asks for each value that no flag or the token gives: the token, the endpoint, the environment, the target name and the file to write. Press Enter to take the default in brackets. It does not ask for the token when `HYGRAPH_TOKEN` is set, and it does not ask for the file when you redirect stdout, such as `hygraph export > hygraph.config.ts`. The token input is hidden. The CLI uses the token for this run only: it does not save it, print it or write it into the config. Set `HYGRAPH_TOKEN` before you run `plan`.
|
|
58
|
+
|
|
59
|
+
- cd28dc4: When a target has no token, `plan`, `apply`, `pull` and `whoami` now say that an exported config reads the token from `HYGRAPH_TOKEN`.
|
|
60
|
+
- Studio can create a token for the CLI: in **Project Settings > Permanent Auth Tokens**, click **Generate CLI PAT**. The token has the management permissions the CLI needs and no content access. The button is not on for every project yet. Ask Hygraph support to turn it on for your project.
|
|
61
|
+
|
|
62
|
+
## 0.0.12
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- dd4a6ac: Breaking: `system.asset`, `system.query` and `system.segment` move to `system.model.asset`, `system.model.query` and `system.model.segment`. Rename them in your config, or export it again.
|
|
67
|
+
- dd4a6ac: Variants: `variantEnabled` on fields, and fields on Segment with `system.model.segment`, planned, applied and exported. Export writes Segment as a comment until Hygraph has it.
|
|
68
|
+
|
|
69
|
+
## 0.0.11
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- ca70188: `hygraph pull` prints what changed live as a diff against the config.
|
|
74
|
+
|
|
75
|
+
## 0.0.10
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- 5896fcb: `hygraph validate` no longer shows in `hygraph --help`.
|
|
80
|
+
|
|
81
|
+
## 0.0.9
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- 488cefd: Fields on Asset and Query with `system.asset` and `system.query`, and remote fields with `define.field.remote` on GraphQL and REST remote sources, OAuth included, planned, applied and exported like the other field types.
|
|
86
|
+
|
|
87
|
+
## 0.0.8
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- 2626680: `define.field.referenceUnion` declares a field that connects to entries of several models, such as a video or an image. On a model, each of those models shows the connection back in a field of its own, declared with `define.field.referenceUnionMember`. On a component, the union has no field back. `plan` shows the changes to a union and its fields back, and `apply` creates, changes and deletes them together. `export` writes the union references the environment has.
|
|
92
|
+
|
|
93
|
+
## 0.0.7
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- ddf7c46: The README covers setup, starting from `export`, the `plan` and `apply` loop, and what the alpha supports so far.
|
|
98
|
+
|
|
99
|
+
## 0.0.6
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- aa3b4d9: A config can export a list of targets. `plan` and `apply` run on each of them, one plan and one migration per target, and a target that fails does not stop the others. `--target <name>` picks targets by name, and `{target}` in `--out` and `--plan` writes one plan file per target, such as `plans/{target}.json`. `whoami` checks every target. A config with one target works as before.
|
|
104
|
+
|
|
105
|
+
## 0.0.5
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- ab254cf: `define.field.richText` declares a rich text field. `embeds` lists the models whose entries editors can embed, and `actions` picks the toolbar Studio shows. `plan` creates, changes and deletes rich text fields, and `export` writes the rich text fields the environment has. A field that embeds Asset stays unsupported for now.
|
|
110
|
+
|
|
111
|
+
## 0.0.4
|
|
112
|
+
|
|
113
|
+
### Patch Changes
|
|
114
|
+
|
|
115
|
+
- 4548043: License the package under MIT.
|
|
116
|
+
|
|
117
|
+
## 0.0.3
|
|
118
|
+
|
|
119
|
+
### Patch Changes
|
|
120
|
+
|
|
121
|
+
- 4dfadc6: `define.field.referenceTwoWay` declares one side of a two-way reference: a field on a model that connects to entries of another model, or of the same one, which shows the connection back in a field of its own. Declare both fields, each naming the other in `reverse`. `plan` creates and deletes the two together, and `export` writes the two-way references the environment has.
|
|
122
|
+
|
|
123
|
+
## 0.0.2
|
|
124
|
+
|
|
125
|
+
### Patch Changes
|
|
126
|
+
|
|
127
|
+
- b077d35: `hygraph whoami` is the first command that does something. It reads the target from `hygraph.config.ts` (or `--config <file>`), asks the target's management API who the token is, and prints the token kind, the project it belongs to, the project's region and the target's environment. It exits 1 when the token is rejected, when it belongs to a different project than the target names, or when the project has no environment of that name.
|
|
128
|
+
|
|
129
|
+
## 0.0.1
|
|
130
|
+
|
|
131
|
+
### Patch Changes
|
|
132
|
+
|
|
133
|
+
- 35ee9bc: Scaffold @hygraph/cli.
|
|
134
|
+
This adds the package, the command surface and the authoring API surface. Nothing is implemented — every command and every builder fails on purpose.
|
package/README.md
CHANGED
|
@@ -187,6 +187,29 @@ hygraph pull show what changed live, as a diff against the config
|
|
|
187
187
|
|
|
188
188
|
Run `npx hygraph <command> --help` for every option.
|
|
189
189
|
|
|
190
|
+
## Telemetry
|
|
191
|
+
|
|
192
|
+
The CLI reports errors and usage to Hygraph, so that we can fix bugs and
|
|
193
|
+
see which commands people use. It tells you so the first time it runs.
|
|
194
|
+
|
|
195
|
+
- **Errors:** a crash, with its error type and stack trace but not its
|
|
196
|
+
message, and a migration that failed, with its id, the error Hygraph
|
|
197
|
+
gave for it and the kinds of its changes with their counts, such as
|
|
198
|
+
`createModel: 2`. That error can name models and fields. An apply that
|
|
199
|
+
worked, but left changes in the plan, is reported with the same kinds
|
|
200
|
+
and counts, and with the names of the attributes that still differ,
|
|
201
|
+
such as `field.position`. If a check refuses the plan after it, the code of the check
|
|
202
|
+
is reported. An answer of Hygraph that is a server error is reported
|
|
203
|
+
with its operation name, status, error codes and request ids, not its
|
|
204
|
+
message.
|
|
205
|
+
- **Usage:** one event per command: the command, the names of the flags you
|
|
206
|
+
gave, how long it took, whether it worked, the codes of the checks that
|
|
207
|
+
refused a plan, how many fields of each type the CLI could not read and
|
|
208
|
+
why, how many models have a sidebar panel it could not read, and the
|
|
209
|
+
project id, environment and endpoint host of each target.
|
|
210
|
+
|
|
211
|
+
To turn it off, set `HYGRAPH_TELEMETRY=0` or `DO_NOT_TRACK=1`.
|
|
212
|
+
|
|
190
213
|
## License
|
|
191
214
|
|
|
192
215
|
MIT
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import { t as CliEnvironment } from "./version.js";
|
|
2
|
+
//#region src/telemetry/telemetry.d.ts
|
|
3
|
+
type TelemetryOptions = {
|
|
4
|
+
env: NodeJS.ProcessEnv;
|
|
5
|
+
/** Which build runs; tests set it, the CLI takes its own. */
|
|
6
|
+
cliEnvironment?: CliEnvironment;
|
|
7
|
+
home: string;
|
|
8
|
+
fetch: typeof globalThis.fetch;
|
|
9
|
+
/** How long sending may hold up the end of a command. */
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
1
13
|
//#region src/cli.d.ts
|
|
2
14
|
export interface RunResult {
|
|
3
15
|
stdout: string;
|
|
@@ -5,12 +17,14 @@ export interface RunResult {
|
|
|
5
17
|
exitCode: number;
|
|
6
18
|
}
|
|
7
19
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
20
|
+
* Runs the CLI on `argv` and returns what it printed to stdout and stderr,
|
|
21
|
+
* and its exit code. Reports only when given `telemetry`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function handle(argv: readonly string[], telemetry?: TelemetryOptions): Promise<RunResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Runs the CLI on the process's arguments. Exits only after telemetry is
|
|
26
|
+
* sent, with the CLI's exit code.
|
|
12
27
|
*/
|
|
13
|
-
export declare function handle(argv: readonly string[]): Promise<RunResult>;
|
|
14
|
-
/** Entry point for the bin. Commander reads process.argv and slices it itself. */
|
|
15
28
|
export declare function run(): Promise<void>;
|
|
16
|
-
//#endregion
|
|
29
|
+
//#endregion
|
|
30
|
+
//# sourceMappingURL=cli.d.ts.map
|