@diagonal-hq/cli 0.22.0 → 0.22.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/README.md +23 -0
- package/dist/cli.mjs +762 -164
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ This package is the authoring SDK for file-based workspaces. A workspace reposit
|
|
|
9
9
|
- The `diagonal make:migration <name>` command. It creates an ordinary workflow in `migrations/` with a timestamped filename. Every migration runs as system.
|
|
10
10
|
- The `diagonal assets upload` and `diagonal assets list` commands. They upload Application Assets, update `assets.ts`, and list immutable references.
|
|
11
11
|
- The `diagonal workflows`, `diagonal run`, and `diagonal logs` commands. They list the deployed workflows, run a manual workflow by its file path, and print recent runs with the error of each failed run.
|
|
12
|
+
- The `diagonal git setup` and `diagonal merge-driver` commands. They merge resource files entry by entry in a git merge.
|
|
12
13
|
|
|
13
14
|
## Check a workspace
|
|
14
15
|
|
|
@@ -39,6 +40,28 @@ diagonal make:migration backfill_post_slug
|
|
|
39
40
|
|
|
40
41
|
The command creates `migrations/YYYYMMDDHHmmss_backfill_post_slug.ts` with the current timestamp. In a workspace template, run `npm run migration -- backfill_post_slug` for the same result. Edit the generated workflow, then run `diagonal check` before committing. Keep deployed files unchanged. Use a new migration filename for a correction.
|
|
41
42
|
|
|
43
|
+
## Merge resource files
|
|
44
|
+
|
|
45
|
+
Git merges a file line by line. When two branches each add a field, a record, or a policy to one resource, git can report a conflict that does not exist. The `diagonal-resource` merge driver merges each `resources/<name>.ts` file entry by entry. Run this command once in each clone:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx diagonal git setup
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The command registers the driver in the local git config. It also adds `resources/*.ts merge=diagonal-resource` to `.gitattributes` when the line is missing. A new workspace repository has this line already. Commit `.gitattributes`.
|
|
52
|
+
|
|
53
|
+
The driver compares each entry of the three versions: the base, your branch, and the other branch.
|
|
54
|
+
|
|
55
|
+
- `fields` and `records` merge by key.
|
|
56
|
+
- An array of objects with a string `uid`, such as `policies`, merges by uid.
|
|
57
|
+
- An array of string literals, such as `fieldOrder`, keeps the additions and removals of both branches.
|
|
58
|
+
- Each other option, and the code around `defineResource()`, merges as one value.
|
|
59
|
+
- A difference in whitespace or trailing commas is not a change.
|
|
60
|
+
|
|
61
|
+
When both branches change one entry differently, or one branch deletes an entry that the other changes, the entry is a conflict. The driver writes diff3 markers around that entry only, with the labels `branch`, `base`, and `main`. Resolve the markers, then run `diagonal check`. When the driver cannot read a file, git's line merge with diff3 markers runs instead.
|
|
62
|
+
|
|
63
|
+
Git starts the driver as `diagonal merge-driver %O %A %B %P`. The command exits with 0 when the merge has no conflict and with 1 when it has a conflict.
|
|
64
|
+
|
|
42
65
|
## Workspace API credentials
|
|
43
66
|
|
|
44
67
|
The API commands read `DIAGONAL_URL` and `DIAGONAL_API_KEY`. Workflow commands require `manage_workflows`. Asset commands require `manage_workspace_settings`. A System Administrator has both permissions. Keep API keys out of the repository.
|