@diagonal-hq/cli 0.25.1 → 0.25.3

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +26 -4
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -326316,6 +326316,16 @@ function listFiles(root) {
326316
326316
  return files.toSorted((left, right) => left < right ? -1 : left > right ? 1 : 0);
326317
326317
  }
326318
326318
  var MODULE_ENTITY_TYPES = { layouts: "layout", components: "component" };
326319
+ var ENTRY_TYPES = /* @__PURE__ */ new Map([
326320
+ ["layout", { output: "layouts", build: (path, source, ast, root) => buildLayout2(path, path, source, ast, root) }],
326321
+ [
326322
+ "component",
326323
+ {
326324
+ output: "components",
326325
+ build: (path, source, ast, root) => path.endsWith(".tsx") && isComponentModule(path, ast) ? buildComponent(path, path, source, ast, root) : null
326326
+ }
326327
+ ]
326328
+ ]);
326319
326329
  var MODULE_ENTITY_EXTENSIONS = /* @__PURE__ */ new Set([".tsx", ".ts", ".jsx", ".js"]);
326320
326330
  function moduleEntityType(path) {
326321
326331
  const type = MODULE_ENTITY_TYPES[topDirectory(path)] ?? null;
@@ -327072,7 +327082,7 @@ var ENTITY_UID_TYPES = /* @__PURE__ */ new Set(["page", "workflow", "layout", "c
327072
327082
  function hasErrors(diagnostics) {
327073
327083
  return diagnostics.some((diagnostic2) => diagnostic2.severity === "error");
327074
327084
  }
327075
- function buildWorkspace(root, { assetCatalog = null, writeSource = false, fixSource = false } = {}) {
327085
+ function buildWorkspace(root, { assetCatalog = null, writeSource = false, fixSource = false, entryPaths = [] } = {}) {
327076
327086
  const diagnostics = [];
327077
327087
  const output = {
327078
327088
  config: null,
@@ -327467,10 +327477,20 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false, fixSou
327467
327477
  for (const path of otherFiles) {
327468
327478
  buildFile(path);
327469
327479
  }
327470
- const layoutPaths = [...new Set(output.pages.map((page) => page.layout).filter((path) => path !== null))].toSorted();
327471
- for (const path of layoutPaths) {
327480
+ const unitTypes = new Map([
327481
+ ...entryPaths.map((path) => [path, moduleEntityType(path)]),
327482
+ ...output.pages.filter((page) => page.layout !== null).map((page) => [page.layout, "layout"])
327483
+ ]);
327484
+ for (const path of [...unitTypes.keys()].toSorted()) {
327485
+ const type = ENTRY_TYPES.get(unitTypes.get(path));
327486
+ if (type === void 0) {
327487
+ throw new Error(`The entry [${path}] is not a module that builds as an entry`);
327488
+ }
327472
327489
  const entry = buildUnit(path, ({ source, ast }) => {
327473
- output.layouts.push(buildLayout2(path, path, source, ast, root));
327490
+ const unit = type.build(path, source, ast, root);
327491
+ if (unit !== null) {
327492
+ output[type.output].push(unit);
327493
+ }
327474
327494
  });
327475
327495
  if (entry !== null && !uiEntries.some((item) => item.path === path)) {
327476
327496
  uiEntries.push(entry);
@@ -327673,6 +327693,7 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false, fixSou
327673
327693
  recordBindings.entries
327674
327694
  );
327675
327695
  const layouts = output.layouts.map(({ lint: _lint, ...layout }) => layout);
327696
+ const entryComponents = [...output.components, ...output.layouts].filter((unit) => entryPaths.includes(unit.path) && moduleEntityType(unit.path) === "component").map(({ path, compiled_code }) => ({ path, compiled_code }));
327676
327697
  const pages = output.pages.map(
327677
327698
  ({ layoutNode: _layoutNode, resourceNodes: _resourceNodes, seoReads: _seoReads, seoAsset: _seoAsset, warnings: _warnings, lint: _lint, ...page }) => page
327678
327699
  );
@@ -327711,6 +327732,7 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false, fixSou
327711
327732
  })),
327712
327733
  pages,
327713
327734
  layouts,
327735
+ entry_components: entryComponents,
327714
327736
  workflows: workflowBuild.workflows,
327715
327737
  workflow_tests: workflowBuild.workflowTests,
327716
327738
  migrations: migrationBuild.migrations,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagonal-hq/cli",
3
- "version": "0.25.1",
3
+ "version": "0.25.3",
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": {