@hygraph/cli 0.0.16 → 0.0.18

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 ADDED
@@ -0,0 +1,124 @@
1
+ # @hygraph/cli
2
+
3
+ ## 0.0.18
4
+
5
+ ### Patch Changes
6
+
7
+ - 8f725b4: The npm package now includes CHANGELOG.md.
8
+ - 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`.
9
+ - 704ada9: The CLI now reports errors and usage to Hygraph, which you can turn off with `HYGRAPH_TELEMETRY=0` or `DO_NOT_TRACK=1`.
10
+ - f9b11dd: When the token is not a permanent auth token, the error now says so without naming Hygraph's internal token type.
11
+
12
+ ## 0.0.17
13
+
14
+ ### Patch Changes
15
+
16
+ - 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.
17
+
18
+ ## 0.0.16
19
+
20
+ ### Patch Changes
21
+
22
+ - 0ed0615: `export` and `pull` refuse to write a config when an apiId or remote source prefix is not a valid name.
23
+ - 4134cfa: A component union field's `visibility` change is now an update. The field and its content stay, and `apply` no longer needs `--prune`.
24
+
25
+ ## 0.0.15
26
+
27
+ ### Patch Changes
28
+
29
+ - 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.
30
+ - 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.
31
+
32
+ ## 0.0.14
33
+
34
+ ### Patch Changes
35
+
36
+ - 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.
37
+ - 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.
38
+ - 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.
39
+ - 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.
40
+
41
+ ## 0.0.13
42
+
43
+ ### Patch Changes
44
+
45
+ - 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`.
46
+
47
+ 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`.
48
+
49
+ - cd28dc4: When a target has no token, `plan`, `apply`, `pull` and `whoami` now say that an exported config reads the token from `HYGRAPH_TOKEN`.
50
+ - 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.
51
+
52
+ ## 0.0.12
53
+
54
+ ### Patch Changes
55
+
56
+ - 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.
57
+ - 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.
58
+
59
+ ## 0.0.11
60
+
61
+ ### Patch Changes
62
+
63
+ - ca70188: `hygraph pull` prints what changed live as a diff against the config.
64
+
65
+ ## 0.0.10
66
+
67
+ ### Patch Changes
68
+
69
+ - 5896fcb: `hygraph validate` no longer shows in `hygraph --help`.
70
+
71
+ ## 0.0.9
72
+
73
+ ### Patch Changes
74
+
75
+ - 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.
76
+
77
+ ## 0.0.8
78
+
79
+ ### Patch Changes
80
+
81
+ - 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.
82
+
83
+ ## 0.0.7
84
+
85
+ ### Patch Changes
86
+
87
+ - ddf7c46: The README covers setup, starting from `export`, the `plan` and `apply` loop, and what the alpha supports so far.
88
+
89
+ ## 0.0.6
90
+
91
+ ### Patch Changes
92
+
93
+ - 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.
94
+
95
+ ## 0.0.5
96
+
97
+ ### Patch Changes
98
+
99
+ - 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.
100
+
101
+ ## 0.0.4
102
+
103
+ ### Patch Changes
104
+
105
+ - 4548043: License the package under MIT.
106
+
107
+ ## 0.0.3
108
+
109
+ ### Patch Changes
110
+
111
+ - 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.
112
+
113
+ ## 0.0.2
114
+
115
+ ### Patch Changes
116
+
117
+ - 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.
118
+
119
+ ## 0.0.1
120
+
121
+ ### Patch Changes
122
+
123
+ - 35ee9bc: Scaffold @hygraph/cli.
124
+ 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
@@ -144,7 +144,7 @@ npx hygraph apply --prune
144
144
  `apply` does not ask for confirmation when `CI` or `TF_BUILD` is set, which
145
145
  most CI providers do. Elsewhere, pass `--yes`.
146
146
 
147
- To apply exactly the plan someone reviewed, save it and pass it to `apply`:
147
+ To apply the plan someone reviewed, save it and pass it to `apply`:
148
148
 
149
149
  ```bash
150
150
  npx hygraph plan --out plan.json
@@ -154,6 +154,12 @@ npx hygraph apply --plan plan.json
154
154
  `apply` refuses the saved plan if the config or the live schema has changed
155
155
  since. Run `plan` again in that case.
156
156
 
157
+ The saved plan holds an HMAC of each remote source header value and OAuth
158
+ secret, never the value. The HMAC uses a key that Hygraph keeps for your
159
+ project, so the plan alone does not let anyone test a guessed value.
160
+ `apply` refuses the saved plan when one of these values changed after
161
+ `plan`, or when the project's key changed. Run `plan` again in that case.
162
+
157
163
  ## What's supported
158
164
 
159
165
  - **Schema:** models, components, enumerations, taxonomies, locales and
@@ -181,6 +187,21 @@ hygraph pull show what changed live, as a diff against the config
181
187
 
182
188
  Run `npx hygraph <command> --help` for every option.
183
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 and the error Hygraph
197
+ gave for it. That error can name models and fields.
198
+ - **Usage:** one event per command: the command, the names of the flags you
199
+ gave, how long it took, whether it worked, the codes of the checks that
200
+ refused a plan, and the project id, environment and endpoint host of
201
+ each target.
202
+
203
+ To turn it off, set `HYGRAPH_TELEMETRY=0` or `DO_NOT_TRACK=1`.
204
+
184
205
  ## License
185
206
 
186
207
  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
- * Parses arguments and captures what would have been written, instead of
9
- * touching the process. Pure, so it is testable. Async because commands
10
- * talk to the management API; parseAsync awaits an action that returns a
11
- * promise, where parse would let it run unobserved.
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