@diagonal-hq/cli 0.42.22 → 0.43.0
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
CHANGED
|
@@ -57,11 +57,11 @@ Then the command runs `npm install`. It exits with 1 when a tarball directory ha
|
|
|
57
57
|
|
|
58
58
|
## Workspace API credentials
|
|
59
59
|
|
|
60
|
-
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.
|
|
60
|
+
The API commands read `DIAGONAL_URL` and `DIAGONAL_API_KEY` from the environment. When the environment sets neither, they read both from `.env` in the current folder, so a `.env` never pairs its URL with a key from the environment. The setup command of the Git Keys tab writes that `.env` with a CLI key, an API key that works only for these commands. Workflow commands require `manage_workflows`. Asset commands require `manage_workspace_settings`. A System Administrator has both permissions. Keep API keys out of the repository.
|
|
61
61
|
|
|
62
62
|
## Run a deployed workflow
|
|
63
63
|
|
|
64
|
-
`diagonal workflows`, `diagonal run`, and `diagonal logs` call the runtime API of a deployed workspace. Set two environment variables first:
|
|
64
|
+
`diagonal workflows`, `diagonal run`, and `diagonal logs` call the runtime API of a deployed workspace. Set two environment variables first, or put them in `.env` of the workspace root:
|
|
65
65
|
|
|
66
66
|
- `DIAGONAL_URL` is the workspace URL, for example `https://acme.diagonal.app`.
|
|
67
67
|
- `DIAGONAL_API_KEY` is an API key of an account with `manage_workflows`.
|
|
@@ -1192,7 +1192,7 @@ Use `background: url(asset:hero)` in a CSS file. The hosted build replaces it wi
|
|
|
1192
1192
|
|
|
1193
1193
|
The check follows CSS imports from pages, layouts, and components. An unknown `asset:` key fails with its file, line, and column. `asset:` in `@import` fails. A `url(asset:` value in a TypeScript or TSX module also fails. Move that value to a CSS file.
|
|
1194
1194
|
|
|
1195
|
-
The check refuses binary imports from workspace modules, including images, fonts, SVG, video, audio, and PDF files. Binary files in
|
|
1195
|
+
The check refuses binary imports from workspace modules, including images, fonts, SVG, video, audio, and PDF files. Binary files fail in every folder, also when no module imports them. The check also refuses a file that a workspace cannot hold. Next to the definition files, a workspace holds `.ts`, `.tsx`, `.js`, and `.jsx` modules, CSS and Markdown files, the `.liquid` files of `notifications/` and `email-layouts/`, and `package.json`, `package-lock.json`, `npm-shrinkwrap.json`, `tsconfig.json`, and `LICENSE` at the root. Upload an image as an Application Asset and use `url(asset:<key>)` in CSS. For icons, use `Sdk.Icon` or an SVG written as a TSX component. SVG and font uploads are not supported yet; use an https: URL for those files.
|
|
1196
1196
|
|
|
1197
1197
|
A CSS `url()` can name an Application Asset as `url(asset:<key>)`, a data URL, an HTTP or HTTPS URL, or a fragment. Relative, root-relative, and protocol-relative file URLs fail. CSS `@import` and `composes` cannot name binary files or Application Assets. Import a CSS file instead.
|
|
1198
1198
|
|
|
@@ -21,6 +21,9 @@ import {
|
|
|
21
21
|
} from "./cli-chunk-KP2RSHLJ.mjs";
|
|
22
22
|
|
|
23
23
|
// scripts/lib/runtime-build/api-cli.mjs
|
|
24
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
25
|
+
import { join } from "node:path";
|
|
26
|
+
import { parseEnv } from "node:util";
|
|
24
27
|
var WORKFLOWS_USAGE = "Usage: diagonal workflows [--json]";
|
|
25
28
|
var RUN_USAGE = "Usage: diagonal run <path> [--input '<json object>'] [--json]";
|
|
26
29
|
var LOGS_USAGE = "Usage: diagonal logs [path | execution id] [--status <success|error|exception|started|pending>] [--limit <1-100>] [--json]";
|
|
@@ -28,6 +31,22 @@ var SUCCESS = "execution.success";
|
|
|
28
31
|
var PENDING = "execution.pending";
|
|
29
32
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
30
33
|
var STATUSES = ["success", "error", "exception", "started", "pending"];
|
|
34
|
+
var WORKSPACE_ENV_KEYS = ["DIAGONAL_URL", "DIAGONAL_API_KEY"];
|
|
35
|
+
function withWorkspaceEnv(io) {
|
|
36
|
+
const file = join(io.cwd, ".env");
|
|
37
|
+
const setInEnvironment = WORKSPACE_ENV_KEYS.some((key) => (io.env[key] ?? "").trim() !== "");
|
|
38
|
+
if (setInEnvironment || !existsSync(file)) {
|
|
39
|
+
return io;
|
|
40
|
+
}
|
|
41
|
+
const values = parseEnv(readFileSync(file, "utf8"));
|
|
42
|
+
const env = { ...io.env };
|
|
43
|
+
for (const key of WORKSPACE_ENV_KEYS) {
|
|
44
|
+
if (typeof values[key] === "string") {
|
|
45
|
+
env[key] = values[key];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { ...io, env };
|
|
49
|
+
}
|
|
31
50
|
function credentials(env, stderr) {
|
|
32
51
|
const url = env.DIAGONAL_URL?.trim().replace(/\/+$/, "") ?? "";
|
|
33
52
|
const apiKey = env.DIAGONAL_API_KEY?.trim() ?? "";
|
|
@@ -615,6 +634,7 @@ export {
|
|
|
615
634
|
WORKFLOWS_USAGE,
|
|
616
635
|
RUN_USAGE,
|
|
617
636
|
LOGS_USAGE,
|
|
637
|
+
withWorkspaceEnv,
|
|
618
638
|
credentials,
|
|
619
639
|
errorText,
|
|
620
640
|
request,
|
package/dist/cli.mjs
CHANGED
|
@@ -102,9 +102,10 @@ import {
|
|
|
102
102
|
runWorkflow,
|
|
103
103
|
showLogs,
|
|
104
104
|
takesAssetReference,
|
|
105
|
+
withWorkspaceEnv,
|
|
105
106
|
writeAssetCatalog,
|
|
106
107
|
writeAssetEntry
|
|
107
|
-
} from "./cli-chunk-
|
|
108
|
+
} from "./cli-chunk-FR2ZNG34.mjs";
|
|
108
109
|
import {
|
|
109
110
|
ASSETS_EXPORT,
|
|
110
111
|
GENERATED_ASSETS_MODULE,
|
|
@@ -11751,6 +11752,7 @@ function workspaceBuildRequest(root, plan, { assetCatalog = null, writeSource =
|
|
|
11751
11752
|
planDiagnostics: plan.diagnostics.filter((item) => item.path !== CONFIG_PATH),
|
|
11752
11753
|
planDependencies: [...plan.dependencies],
|
|
11753
11754
|
planFiles: [...plan.files.keys()],
|
|
11755
|
+
planInstalledFiles: [...plan.files].filter(([, file]) => file.source.startsWith("node_modules/")).map(([path]) => path),
|
|
11754
11756
|
planBindings: Object.fromEntries(plan.bindings ?? []),
|
|
11755
11757
|
planOwners: Object.fromEntries([...plan.files].map(([path, file]) => [path, file.name])),
|
|
11756
11758
|
planPackages: plan.packages.map(({ name, version }) => ({ name, version })),
|
|
@@ -11929,20 +11931,20 @@ async function main(argv, io) {
|
|
|
11929
11931
|
case "assets": {
|
|
11930
11932
|
const [subcommand, ...assetArgs] = args;
|
|
11931
11933
|
if (subcommand === "upload")
|
|
11932
|
-
return (await import("./cli-assets-cli-
|
|
11934
|
+
return (await import("./cli-assets-cli-KPJWOWLD.mjs")).uploadAsset(assetArgs, withWorkspaceEnv(io));
|
|
11933
11935
|
if (subcommand === "list")
|
|
11934
|
-
return (await import("./cli-assets-cli-
|
|
11936
|
+
return (await import("./cli-assets-cli-KPJWOWLD.mjs")).listAssets(assetArgs, withWorkspaceEnv(io));
|
|
11935
11937
|
io.stderr.write(`${ASSETS_UPLOAD_USAGE}
|
|
11936
11938
|
${ASSETS_LIST_USAGE}
|
|
11937
11939
|
`);
|
|
11938
11940
|
return 2;
|
|
11939
11941
|
}
|
|
11940
11942
|
case "workflows":
|
|
11941
|
-
return listWorkflows(args, io);
|
|
11943
|
+
return listWorkflows(args, withWorkspaceEnv(io));
|
|
11942
11944
|
case "run":
|
|
11943
|
-
return runWorkflow(args, io);
|
|
11945
|
+
return runWorkflow(args, withWorkspaceEnv(io));
|
|
11944
11946
|
case "logs":
|
|
11945
|
-
return showLogs(args, io);
|
|
11947
|
+
return showLogs(args, withWorkspaceEnv(io));
|
|
11946
11948
|
default:
|
|
11947
11949
|
io.stderr.write(`${USAGE}
|
|
11948
11950
|
`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diagonal-hq/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"description": "The diagonal CLI and the configuration helpers for file-based Diagonal workspaces.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"bun": "1.4.4"
|
|
52
52
|
},
|
|
53
53
|
"optionalDependencies": {
|
|
54
|
-
"@diagonal-hq/workflow-script-compiler-darwin-arm64": "0.1.0-
|
|
55
|
-
"@diagonal-hq/workflow-script-compiler-linux-x64": "0.1.0-
|
|
56
|
-
"@diagonal-hq/workflow-script-compiler-linux-arm64": "0.1.0-
|
|
54
|
+
"@diagonal-hq/workflow-script-compiler-darwin-arm64": "0.1.0-h2f7a0befd91f",
|
|
55
|
+
"@diagonal-hq/workflow-script-compiler-linux-x64": "0.1.0-h2f7a0befd91f",
|
|
56
|
+
"@diagonal-hq/workflow-script-compiler-linux-arm64": "0.1.0-h2f7a0befd91f"
|
|
57
57
|
}
|
|
58
58
|
}
|