@diagonal-hq/cli 0.7.0 → 0.8.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 +14 -1
- package/dist/cli.mjs +155 -33
- package/dist/index.d.ts +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ This package is the authoring SDK for file-based workspaces. A workspace reposit
|
|
|
5
5
|
- The configuration helpers: `defineConfig`, `defineResource`, `definePage`, `defineNavigation`, `defineAssets`, `asset.version`, `defineNotificationType`, `defineNotificationTemplate`, `defineEmailLayout`, `defineNotificationSchedule`, and the `field` builders. Each `define*` function returns its first argument. Each `field.<type>(options)` call returns `{ $field, ...options }`, where `$field` is the stored field type. The package root exports them as ESM JavaScript with declarations, so a Vite build or a Node script can import a configuration file.
|
|
6
6
|
- Types for the helpers, `WorkflowConfig`, and the `Sdk` and `React` globals.
|
|
7
7
|
- Editor types for the workflow script SDK: `@diagonal/workflow`, `@diagonal/workflow/testing`, and `@diagonal/workflow/workspace`.
|
|
8
|
-
- The `diagonal check` command. It runs the same build and checks that a platform deploy runs, including the workflow tests.
|
|
8
|
+
- The `diagonal check` command. It runs the same build and checks that a platform deploy runs, including the workflow tests. It also writes `generated/resources.ts` and the missing definition uids.
|
|
9
9
|
- The `diagonal workflows` and `diagonal run` commands. They list the deployed workflows and run a manual workflow by its file path.
|
|
10
10
|
|
|
11
11
|
## Check a workspace
|
|
@@ -61,6 +61,19 @@ The build reads each file with a parser. It runs only the workflow tests.
|
|
|
61
61
|
|
|
62
62
|
- The build does not read `notifications/` or `email-layouts/` yet. The editor type-checks the shape of their definitions. See [Notifications](#notifications).
|
|
63
63
|
|
|
64
|
+
## Definition uids and slugs
|
|
65
|
+
|
|
66
|
+
A definition can have two identity options. No definition uses them yet.
|
|
67
|
+
|
|
68
|
+
- `uid` is the stable identity of the definition. Its value is a lowercase UUID string literal, such as `uid: '3f2b8c1e-7d4a-4e9b-a6c5-1d0e9f8a7b6c'`. A file move, a file rename, or a name change keeps the uid. Do not change a uid.
|
|
69
|
+
- `slug` is the editable, user-facing name of the definition. It is kebab-case: lowercase letters and digits in groups that one `-` joins, such as `job-postings`. A slug change keeps the uid.
|
|
70
|
+
|
|
71
|
+
`diagonal check` writes a new uid into each definition that has none. It adds `uid: '<uuid>'` as the first option of the `defineX()` object and leaves the rest of the file unchanged. Commit the change.
|
|
72
|
+
|
|
73
|
+
A platform deploy does not write source. A definition without a uid fails the deploy, and the error tells you to run `diagonal check`.
|
|
74
|
+
|
|
75
|
+
A uid is unique among the definitions of one type. Two definitions of one type with one uid are an error at the second file, and the error names the first file. The check does not replace a duplicate uid. When you copy a definition file, delete its `uid` and run `diagonal check`. A uid that is not a lowercase UUID string literal is an error.
|
|
76
|
+
|
|
64
77
|
## Resource references
|
|
65
78
|
|
|
66
79
|
The file name is the resource slug: `resources/job-postings.ts` declares the resource `job-postings`. A file name must start with a lowercase letter and contain only a-z, 0-9, `_`, and `-`. A resource has no `id` in source. The platform derives the stored id from the workspace and the slug, so each branch and environment has its own ids.
|
package/dist/cli.mjs
CHANGED
|
@@ -249426,8 +249426,8 @@ ${RUN_USAGE}
|
|
|
249426
249426
|
|
|
249427
249427
|
// scripts/lib/runtime-build/build-workspace.mjs
|
|
249428
249428
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
249429
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync7, readdirSync as readdirSync3, writeFileSync as
|
|
249430
|
-
import { basename as basename3, dirname as dirname6, extname as extname2, join as
|
|
249429
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync7, readdirSync as readdirSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
249430
|
+
import { basename as basename3, dirname as dirname6, extname as extname2, join as join10, relative as relative4, sep } from "node:path";
|
|
249431
249431
|
|
|
249432
249432
|
// scripts/lib/runtime-build/assets.mjs
|
|
249433
249433
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
@@ -267542,10 +267542,129 @@ function checkCapabilities(resources, platformSlugs, diagnostics) {
|
|
|
267542
267542
|
}
|
|
267543
267543
|
}
|
|
267544
267544
|
|
|
267545
|
+
// scripts/lib/runtime-build/definition-uid.mjs
|
|
267546
|
+
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
267547
|
+
import { randomUUID } from "node:crypto";
|
|
267548
|
+
import { writeFileSync } from "node:fs";
|
|
267549
|
+
import { join as join2 } from "node:path";
|
|
267550
|
+
var UID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
267551
|
+
var UID_EXAMPLE = "3f2b8c1e-7d4a-4e9b-a6c5-1d0e9f8a7b6c";
|
|
267552
|
+
function isUid(value) {
|
|
267553
|
+
return typeof value === "string" && UID_PATTERN.test(value);
|
|
267554
|
+
}
|
|
267555
|
+
function newUid() {
|
|
267556
|
+
return randomUUID();
|
|
267557
|
+
}
|
|
267558
|
+
function uidProperty(object) {
|
|
267559
|
+
return object.properties.find(
|
|
267560
|
+
(property) => property.type === "ObjectProperty" && propertyKey(property) === "uid"
|
|
267561
|
+
) ?? null;
|
|
267562
|
+
}
|
|
267563
|
+
function readUid(object) {
|
|
267564
|
+
if (object.type !== "ObjectExpression") {
|
|
267565
|
+
throw new SourceError("The definition must be an object literal", object);
|
|
267566
|
+
}
|
|
267567
|
+
const property = uidProperty(object);
|
|
267568
|
+
if (property === null) {
|
|
267569
|
+
return null;
|
|
267570
|
+
}
|
|
267571
|
+
const { value } = property;
|
|
267572
|
+
if (value.type !== "StringLiteral" || value.extra.raw.slice(1, -1) !== value.value || !isUid(value.value)) {
|
|
267573
|
+
throw new SourceError(
|
|
267574
|
+
`"uid" must be a lowercase UUID string literal, such as '${UID_EXAMPLE}'`,
|
|
267575
|
+
value
|
|
267576
|
+
);
|
|
267577
|
+
}
|
|
267578
|
+
return value.value;
|
|
267579
|
+
}
|
|
267580
|
+
function uidInsertion(source, object, uid2) {
|
|
267581
|
+
const property = `uid: '${uid2}'`;
|
|
267582
|
+
const [first] = object.properties;
|
|
267583
|
+
const anchor = first === void 0 ? object.innerComments?.[0] : first.leadingComments?.[0] ?? first;
|
|
267584
|
+
if (anchor === void 0) {
|
|
267585
|
+
const inside = object.start + 1;
|
|
267586
|
+
const separator = inside === object.end - 1 ? " " : "";
|
|
267587
|
+
return { start: inside, end: inside, text: ` ${property}${separator}` };
|
|
267588
|
+
}
|
|
267589
|
+
if (anchor.loc.start.line === object.loc.start.line) {
|
|
267590
|
+
return { start: anchor.start, end: anchor.start, text: `${property}, ` };
|
|
267591
|
+
}
|
|
267592
|
+
const lineStart = source.lastIndexOf("\n", anchor.start - 1) + 1;
|
|
267593
|
+
const indent = source.slice(lineStart, anchor.start);
|
|
267594
|
+
const newline = source[lineStart - 2] === "\r" ? "\r\n" : "\n";
|
|
267595
|
+
return { start: anchor.start, end: anchor.start, text: `${property},${newline}${indent}` };
|
|
267596
|
+
}
|
|
267597
|
+
function withInsertions(source, insertions) {
|
|
267598
|
+
let result = source;
|
|
267599
|
+
for (const insertion of insertions.toSorted((left, right) => right.start - left.start)) {
|
|
267600
|
+
result = `${result.slice(0, insertion.start)}${insertion.text}${result.slice(insertion.end)}`;
|
|
267601
|
+
}
|
|
267602
|
+
return result;
|
|
267603
|
+
}
|
|
267604
|
+
function checkDefinitionUids(root, definitions, { write }) {
|
|
267605
|
+
const diagnostics = [];
|
|
267606
|
+
const uids = [];
|
|
267607
|
+
const firstByUid = /* @__PURE__ */ new Map();
|
|
267608
|
+
const sourceByPath = /* @__PURE__ */ new Map();
|
|
267609
|
+
const insertionsByPath = /* @__PURE__ */ new Map();
|
|
267610
|
+
for (const definition of definitions) {
|
|
267611
|
+
const known = sourceByPath.get(definition.path);
|
|
267612
|
+
if (known !== void 0 && known !== definition.source) {
|
|
267613
|
+
throw new Error(`Two definitions of ${definition.path} give different sources`);
|
|
267614
|
+
}
|
|
267615
|
+
sourceByPath.set(definition.path, definition.source);
|
|
267616
|
+
let uid2;
|
|
267617
|
+
try {
|
|
267618
|
+
uid2 = readUid(definition.node);
|
|
267619
|
+
} catch (error) {
|
|
267620
|
+
diagnostics.push(diagnosticFromError(definition.path, error));
|
|
267621
|
+
uids.push(null);
|
|
267622
|
+
continue;
|
|
267623
|
+
}
|
|
267624
|
+
if (uid2 !== null) {
|
|
267625
|
+
const key = `${definition.type}\0${uid2}`;
|
|
267626
|
+
const first = firstByUid.get(key);
|
|
267627
|
+
if (first === void 0) {
|
|
267628
|
+
firstByUid.set(key, definition);
|
|
267629
|
+
} else {
|
|
267630
|
+
diagnostics.push(
|
|
267631
|
+
diagnosticAt(
|
|
267632
|
+
definition.path,
|
|
267633
|
+
uidProperty(definition.node).value,
|
|
267634
|
+
`Duplicate ${definition.type} uid "${uid2}". ${first.path} already uses it. Give one of them a new uid`
|
|
267635
|
+
)
|
|
267636
|
+
);
|
|
267637
|
+
}
|
|
267638
|
+
uids.push(uid2);
|
|
267639
|
+
continue;
|
|
267640
|
+
}
|
|
267641
|
+
if (!write) {
|
|
267642
|
+
diagnostics.push(
|
|
267643
|
+
diagnosticAt(
|
|
267644
|
+
definition.path,
|
|
267645
|
+
definition.node,
|
|
267646
|
+
`The ${definition.type} has no uid. Run \`diagonal check\` to write one`
|
|
267647
|
+
)
|
|
267648
|
+
);
|
|
267649
|
+
uids.push(null);
|
|
267650
|
+
continue;
|
|
267651
|
+
}
|
|
267652
|
+
const generated = newUid();
|
|
267653
|
+
const insertions = insertionsByPath.get(definition.path) ?? [];
|
|
267654
|
+
insertions.push(uidInsertion(definition.source, definition.node, generated));
|
|
267655
|
+
insertionsByPath.set(definition.path, insertions);
|
|
267656
|
+
uids.push(generated);
|
|
267657
|
+
}
|
|
267658
|
+
for (const [path, insertions] of insertionsByPath) {
|
|
267659
|
+
writeFileSync(join2(root, path), withInsertions(sourceByPath.get(path), insertions));
|
|
267660
|
+
}
|
|
267661
|
+
return { uids, diagnostics };
|
|
267662
|
+
}
|
|
267663
|
+
|
|
267545
267664
|
// scripts/lib/runtime-build/module-graph.mjs
|
|
267546
267665
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
267547
267666
|
import { readFileSync } from "node:fs";
|
|
267548
|
-
import { posix as posix2, join as
|
|
267667
|
+
import { posix as posix2, join as join3 } from "node:path";
|
|
267549
267668
|
|
|
267550
267669
|
// scripts/lib/runtime-build/page-build-protocol.mjs
|
|
267551
267670
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
@@ -267664,12 +267783,12 @@ function buildModuleGraph(root, entries, manifest, diagnostics, assetKeys = /* @
|
|
|
267664
267783
|
const kind = importKind(`./${posix2.basename(path)}`);
|
|
267665
267784
|
if (STYLE_KINDS.has(kind)) {
|
|
267666
267785
|
checkStylesheet(root, path, assetKeys, diagnostics, scannedStyles);
|
|
267667
|
-
modules[path] = { kind, source_sha256: sha256(readFileSync(
|
|
267786
|
+
modules[path] = { kind, source_sha256: sha256(readFileSync(join3(root, path))), imports: [] };
|
|
267668
267787
|
continue;
|
|
267669
267788
|
}
|
|
267670
267789
|
let entry = parsed.get(path);
|
|
267671
267790
|
if (entry === void 0) {
|
|
267672
|
-
const source = readFileSync(
|
|
267791
|
+
const source = readFileSync(join3(root, path), "utf8");
|
|
267673
267792
|
try {
|
|
267674
267793
|
entry = { path, source, ast: parseSource(source, { jsx: path.endsWith("x") }) };
|
|
267675
267794
|
} catch (error) {
|
|
@@ -267820,7 +267939,7 @@ function checkStylesheet(root, path, assetKeys, diagnostics, scanned) {
|
|
|
267820
267939
|
return;
|
|
267821
267940
|
}
|
|
267822
267941
|
scanned.add(path);
|
|
267823
|
-
const { urls, imports } = cssReferences(readFileSync(
|
|
267942
|
+
const { urls, imports } = cssReferences(readFileSync(join3(root, path), "utf8"));
|
|
267824
267943
|
for (const url of urls) {
|
|
267825
267944
|
const key = assetUrlKey(url.value);
|
|
267826
267945
|
if (key !== null && assetKeys !== null && !assetKeys.has(key)) {
|
|
@@ -293294,7 +293413,7 @@ and limitations under the License.
|
|
|
293294
293413
|
// scripts/pageTypeCheck.mjs
|
|
293295
293414
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
293296
293415
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
293297
|
-
import { dirname as dirname2, join as
|
|
293416
|
+
import { dirname as dirname2, join as join4 } from "node:path";
|
|
293298
293417
|
|
|
293299
293418
|
// app/pages/resources/js/pageRuntime/sdk/buildCustomComponentTypes.ts
|
|
293300
293419
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
@@ -294346,7 +294465,7 @@ function typeCheckPage(userSource, {
|
|
|
294346
294465
|
if (libFiles3) {
|
|
294347
294466
|
return libFiles3.get(name);
|
|
294348
294467
|
}
|
|
294349
|
-
const path =
|
|
294468
|
+
const path = join4(libDir, name);
|
|
294350
294469
|
return existsSync2(path) ? readFileSync2(path, "utf8") : void 0;
|
|
294351
294470
|
};
|
|
294352
294471
|
const getText = (name) => virtual.get(name) ?? readLib(name);
|
|
@@ -298231,17 +298350,17 @@ function withoutBuildNodes(resource) {
|
|
|
298231
298350
|
// scripts/lib/runtime-build/sdk-packages.mjs
|
|
298232
298351
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
298233
298352
|
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "node:fs";
|
|
298234
|
-
import { join as
|
|
298353
|
+
import { join as join5 } from "node:path";
|
|
298235
298354
|
var DIAGONAL_PACKAGE = /^@diagonal(-hq)?\//;
|
|
298236
298355
|
var TARBALL_VERSION = /-(\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)\.tgz$/;
|
|
298237
298356
|
var EXACT_VERSION = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;
|
|
298238
298357
|
function readPackageFiles(root, diagnostics) {
|
|
298239
298358
|
const read = (path) => {
|
|
298240
|
-
if (!existsSync3(
|
|
298359
|
+
if (!existsSync3(join5(root, path))) {
|
|
298241
298360
|
return null;
|
|
298242
298361
|
}
|
|
298243
298362
|
try {
|
|
298244
|
-
return JSON.parse(readFileSync3(
|
|
298363
|
+
return JSON.parse(readFileSync3(join5(root, path), "utf8"));
|
|
298245
298364
|
} catch (error) {
|
|
298246
298365
|
if (!(error instanceof SyntaxError)) {
|
|
298247
298366
|
throw error;
|
|
@@ -298434,7 +298553,7 @@ init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
|
298434
298553
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
298435
298554
|
var import_sucrase2 = __toESM(require_dist2(), 1);
|
|
298436
298555
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
298437
|
-
import { join as
|
|
298556
|
+
import { join as join6 } from "node:path";
|
|
298438
298557
|
|
|
298439
298558
|
// packages/cli/index.js
|
|
298440
298559
|
var cli_exports = {};
|
|
@@ -298586,7 +298705,7 @@ function appModuleClosure(root, imports, external = /* @__PURE__ */ new Set(), {
|
|
|
298586
298705
|
if (modules.has(path)) {
|
|
298587
298706
|
continue;
|
|
298588
298707
|
}
|
|
298589
|
-
const source = readFileSync4(
|
|
298708
|
+
const source = readFileSync4(join6(root, path), "utf8");
|
|
298590
298709
|
const ast = parseModule(path, source);
|
|
298591
298710
|
const requires = {};
|
|
298592
298711
|
const references = ui ? moduleSpecifiers2(ast).filter((item) => item.specifier !== null && !item.typeOnly).map((item) => ({ specifier: item.specifier, source: item.node })) : ast.program.body.filter(
|
|
@@ -299236,27 +299355,27 @@ function pageKeyOf(path, ast) {
|
|
|
299236
299355
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
299237
299356
|
var import_typescript2 = __toESM(require_typescript(), 1);
|
|
299238
299357
|
import { spawnSync } from "node:child_process";
|
|
299239
|
-
import { mkdirSync, mkdtempSync, realpathSync as realpathSync2, rmSync, writeFileSync } from "node:fs";
|
|
299358
|
+
import { mkdirSync, mkdtempSync, realpathSync as realpathSync2, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
299240
299359
|
import { tmpdir } from "node:os";
|
|
299241
|
-
import { dirname as dirname4, join as
|
|
299360
|
+
import { dirname as dirname4, join as join8, relative as relative3 } from "node:path";
|
|
299242
299361
|
|
|
299243
299362
|
// scripts/lib/runtime-build/script-sdk.mjs
|
|
299244
299363
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
299245
299364
|
import { readFileSync as readFileSync5, readdirSync as readdirSync2, statSync as statSync2 } from "node:fs";
|
|
299246
299365
|
import { createRequire } from "node:module";
|
|
299247
|
-
import { dirname as dirname3, join as
|
|
299366
|
+
import { dirname as dirname3, join as join7, relative as relative2, resolve as resolve3 } from "node:path";
|
|
299248
299367
|
import { fileURLToPath } from "node:url";
|
|
299249
299368
|
var SCRIPT_SDK_ROOT = resolve3(
|
|
299250
299369
|
dirname3(fileURLToPath(import.meta.url)),
|
|
299251
299370
|
"../../../packages/workflows/src"
|
|
299252
299371
|
);
|
|
299253
299372
|
var SDK_RUNTIME_ENTRY_POINTS = {
|
|
299254
|
-
workflow:
|
|
299255
|
-
testing:
|
|
299373
|
+
workflow: join7(SCRIPT_SDK_ROOT, "index.ts"),
|
|
299374
|
+
testing: join7(SCRIPT_SDK_ROOT, "testing/index.ts")
|
|
299256
299375
|
};
|
|
299257
299376
|
function walk(directory) {
|
|
299258
299377
|
return readdirSync2(directory).flatMap(
|
|
299259
|
-
(name) => statSync2(
|
|
299378
|
+
(name) => statSync2(join7(directory, name)).isDirectory() ? walk(join7(directory, name)) : [join7(directory, name)]
|
|
299260
299379
|
);
|
|
299261
299380
|
}
|
|
299262
299381
|
function readSandboxSdkFiles() {
|
|
@@ -299411,8 +299530,8 @@ function relativeSandboxPath(from, target) {
|
|
|
299411
299530
|
return path.startsWith(".") ? path : `./${path}`;
|
|
299412
299531
|
}
|
|
299413
299532
|
function writeFile(root, path, content) {
|
|
299414
|
-
mkdirSync(dirname4(
|
|
299415
|
-
|
|
299533
|
+
mkdirSync(dirname4(join8(root, path)), { recursive: true });
|
|
299534
|
+
writeFileSync2(join8(root, path), content);
|
|
299416
299535
|
}
|
|
299417
299536
|
function parseResults(stdout) {
|
|
299418
299537
|
return stdout.split("\n").filter((line) => line.startsWith(RESULT_PREFIX)).map((line) => JSON.parse(line.slice(RESULT_PREFIX.length)));
|
|
@@ -299460,7 +299579,7 @@ function runWorkflowTests({
|
|
|
299460
299579
|
modules.set(path, module);
|
|
299461
299580
|
}
|
|
299462
299581
|
}
|
|
299463
|
-
const root = realpathSync2(mkdtempSync(
|
|
299582
|
+
const root = realpathSync2(mkdtempSync(join8(tmpdir(), "diagonal-workflow-tests-")));
|
|
299464
299583
|
try {
|
|
299465
299584
|
writeFile(root, "package.json", '{"type":"module"}\n');
|
|
299466
299585
|
writeFile(root, "reporter.mjs", REPORTER_SOURCE);
|
|
@@ -299532,7 +299651,7 @@ function runWorkflowTests({
|
|
|
299532
299651
|
const results = parseResults(run.stdout ?? "");
|
|
299533
299652
|
const timedOut = run.error?.code === "ETIMEDOUT" || run.signal !== null;
|
|
299534
299653
|
const workflowTests = runnable.map((test) => {
|
|
299535
|
-
const file2 =
|
|
299654
|
+
const file2 = join8(root, test.path.replace(/\.ts$/, ".js"));
|
|
299536
299655
|
const own = results.filter((result) => result.file === file2);
|
|
299537
299656
|
for (const result of own) {
|
|
299538
299657
|
if (!result.ok) {
|
|
@@ -299882,7 +300001,7 @@ function literal(node) {
|
|
|
299882
300001
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
299883
300002
|
import { readFileSync as readFileSync6 } from "node:fs";
|
|
299884
300003
|
import { createRequire as createRequire2 } from "node:module";
|
|
299885
|
-
import { dirname as dirname5, join as
|
|
300004
|
+
import { dirname as dirname5, join as join9 } from "node:path";
|
|
299886
300005
|
var ROOT_LIB = "lib.es2023.d.ts";
|
|
299887
300006
|
function libClosure(read, root = ROOT_LIB) {
|
|
299888
300007
|
const files = {};
|
|
@@ -299901,7 +300020,7 @@ function libClosure(read, root = ROOT_LIB) {
|
|
|
299901
300020
|
}
|
|
299902
300021
|
function readLibClosure(root = ROOT_LIB) {
|
|
299903
300022
|
const libDir = dirname5(createRequire2(import.meta.url).resolve("typescript/lib/lib.d.ts"));
|
|
299904
|
-
return libClosure((name) => readFileSync6(
|
|
300023
|
+
return libClosure((name) => readFileSync6(join9(libDir, name), "utf8"), root);
|
|
299905
300024
|
}
|
|
299906
300025
|
|
|
299907
300026
|
// scripts/lib/workflow-script/lint-rules.mjs
|
|
@@ -301132,10 +301251,10 @@ function listFiles(root) {
|
|
|
301132
301251
|
}
|
|
301133
301252
|
if (entry.isDirectory()) {
|
|
301134
301253
|
if (!IGNORED_DIRECTORIES.has(entry.name)) {
|
|
301135
|
-
pending.push(
|
|
301254
|
+
pending.push(join10(directory, entry.name));
|
|
301136
301255
|
}
|
|
301137
301256
|
} else if (entry.isFile()) {
|
|
301138
|
-
files.push(relative4(root,
|
|
301257
|
+
files.push(relative4(root, join10(directory, entry.name)).split(sep).join("/"));
|
|
301139
301258
|
}
|
|
301140
301259
|
}
|
|
301141
301260
|
}
|
|
@@ -301333,14 +301452,14 @@ function checkPageResources(pages, resources, platformSlugs, names2, diagnostics
|
|
|
301333
301452
|
}
|
|
301334
301453
|
function syncGeneratedResources(root, names2, write, diagnostics) {
|
|
301335
301454
|
const expected = generatedResourcesSource(names2);
|
|
301336
|
-
const path =
|
|
301455
|
+
const path = join10(root, GENERATED_RESOURCES_PATH);
|
|
301337
301456
|
const current = existsSync4(path) ? readFileSync7(path, "utf8") : null;
|
|
301338
301457
|
if (current === expected || current === null && names2.slugsByName.size === 0) {
|
|
301339
301458
|
return;
|
|
301340
301459
|
}
|
|
301341
301460
|
if (write) {
|
|
301342
301461
|
mkdirSync2(dirname6(path), { recursive: true });
|
|
301343
|
-
|
|
301462
|
+
writeFileSync3(path, expected);
|
|
301344
301463
|
return;
|
|
301345
301464
|
}
|
|
301346
301465
|
diagnostics.push(
|
|
@@ -301376,7 +301495,7 @@ function pageKeyOfSource(path, source) {
|
|
|
301376
301495
|
function hasErrors(diagnostics) {
|
|
301377
301496
|
return diagnostics.some((diagnostic2) => diagnostic2.severity === "error");
|
|
301378
301497
|
}
|
|
301379
|
-
function buildWorkspace(root, { assetCatalog = null,
|
|
301498
|
+
function buildWorkspace(root, { assetCatalog = null, writeSource = false } = {}) {
|
|
301380
301499
|
const diagnostics = [];
|
|
301381
301500
|
const output = {
|
|
301382
301501
|
config: null,
|
|
@@ -301392,6 +301511,7 @@ function buildWorkspace(root, { assetCatalog = null, writeGeneratedResources = f
|
|
|
301392
301511
|
skills: []
|
|
301393
301512
|
};
|
|
301394
301513
|
const workflowFiles = [];
|
|
301514
|
+
const uidDefinitions = [];
|
|
301395
301515
|
const skillFiles = [];
|
|
301396
301516
|
const workflowTestFiles = [];
|
|
301397
301517
|
const files = listFiles(root);
|
|
@@ -301399,7 +301519,7 @@ function buildWorkspace(root, { assetCatalog = null, writeGeneratedResources = f
|
|
|
301399
301519
|
files.filter((path) => classify(path) === "resource"),
|
|
301400
301520
|
diagnostics
|
|
301401
301521
|
);
|
|
301402
|
-
syncGeneratedResources(root, names2,
|
|
301522
|
+
syncGeneratedResources(root, names2, writeSource, diagnostics);
|
|
301403
301523
|
const uiEntries = [];
|
|
301404
301524
|
const failedLayouts = /* @__PURE__ */ new Set();
|
|
301405
301525
|
const failedComponents = /* @__PURE__ */ new Set();
|
|
@@ -301415,7 +301535,7 @@ function buildWorkspace(root, { assetCatalog = null, writeGeneratedResources = f
|
|
|
301415
301535
|
);
|
|
301416
301536
|
continue;
|
|
301417
301537
|
}
|
|
301418
|
-
const source = readFileSync7(
|
|
301538
|
+
const source = readFileSync7(join10(root, path), "utf8");
|
|
301419
301539
|
if (kind === "skill") {
|
|
301420
301540
|
skillFiles.push({ path, content: source });
|
|
301421
301541
|
continue;
|
|
@@ -301479,6 +301599,8 @@ function buildWorkspace(root, { assetCatalog = null, writeGeneratedResources = f
|
|
|
301479
301599
|
}
|
|
301480
301600
|
}
|
|
301481
301601
|
}
|
|
301602
|
+
const uidCheck = checkDefinitionUids(root, uidDefinitions, { write: writeSource });
|
|
301603
|
+
diagnostics.push(...uidCheck.diagnostics);
|
|
301482
301604
|
if (output.config === null && !diagnostics.some((diagnostic2) => diagnostic2.path === CONFIG_PATH)) {
|
|
301483
301605
|
diagnostics.push(diagnosticAt(CONFIG_PATH, null, "The workspace has no diagonal.config.ts"));
|
|
301484
301606
|
}
|
|
@@ -301647,7 +301769,7 @@ ${CHECK_USAGE}
|
|
|
301647
301769
|
`);
|
|
301648
301770
|
return 2;
|
|
301649
301771
|
}
|
|
301650
|
-
const result = buildWorkspace(root, {
|
|
301772
|
+
const result = buildWorkspace(root, { writeSource: true });
|
|
301651
301773
|
if (parsed.json) {
|
|
301652
301774
|
stdout.write(
|
|
301653
301775
|
`${JSON.stringify({ ok: result.ok, diagnostics: result.diagnostics }, null, 2)}
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,26 @@ export type StaticValue =
|
|
|
30
30
|
| readonly StaticValue[]
|
|
31
31
|
| { readonly [key: string]: StaticValue };
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* The stable identity of a definition: a lowercase UUID string literal, such as
|
|
35
|
+
* `'3f2b8c1e-7d4a-4e9b-a6c5-1d0e9f8a7b6c'`. `diagonal check` writes one into a
|
|
36
|
+
* definition that has none. A file move or a rename keeps it. Do not change it.
|
|
37
|
+
*/
|
|
38
|
+
export type DefinitionUid = string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The editable, user-facing name of a definition in kebab-case, such as
|
|
42
|
+
* `'job-postings'`. It matches `^[a-z0-9]+(?:-[a-z0-9]+)*$`. A slug change
|
|
43
|
+
* keeps the identity of the definition.
|
|
44
|
+
*/
|
|
45
|
+
export type DefinitionSlug = string;
|
|
46
|
+
|
|
47
|
+
/** The `uid` option of a definition. */
|
|
48
|
+
export type UidOption = { uid?: DefinitionUid };
|
|
49
|
+
|
|
50
|
+
/** The `slug` option of a definition. */
|
|
51
|
+
export type SlugOption = { slug?: DefinitionSlug };
|
|
52
|
+
|
|
33
53
|
export type ConfigDefinition = {
|
|
34
54
|
name: string;
|
|
35
55
|
brand?: { readonly [key: string]: StaticValue };
|