@diagonal-hq/cli 0.35.1 → 0.35.2

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 +34 -59
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -289012,16 +289012,16 @@ var APP_PREFIX = "@app/";
289012
289012
  var AUTHORING_MODULE = "@diagonal-hq/cli";
289013
289013
  var PAGES_SDK_MODULE = PAGES_SDK_PACKAGE;
289014
289014
  var RENAMED_MODULES = /* @__PURE__ */ new Map([["@diagonal/pages", PAGES_SDK_MODULE]]);
289015
- function pagesSdkMember(name, { lint: lint2 = false } = {}) {
289015
+ function pagesSdkMember(name, { lint = false } = {}) {
289016
289016
  const path = PAGE_SDK_EXPORTS[name];
289017
- if (lint2 && PAGE_SDK_FILE_TYPED_EXPORTS.includes(name)) {
289017
+ if (lint && PAGE_SDK_FILE_TYPED_EXPORTS.includes(name)) {
289018
289018
  return `(Sdk as import(${JSON.stringify(SDK_INTERNAL_MODULE)}).FilePageSdk).${path.join(".")}`;
289019
289019
  }
289020
289020
  return ["Sdk", ...path].join(".");
289021
289021
  }
289022
- function pagesSdkObjectText(names2 = null, { lint: lint2 = false } = {}) {
289022
+ function pagesSdkObjectText(names2 = null, { lint = false } = {}) {
289023
289023
  const exported = (names2 ?? Object.keys(PAGE_SDK_EXPORTS)).filter((name) => Object.hasOwn(PAGE_SDK_EXPORTS, name));
289024
- return `{ ${exported.map((name) => `get ${name}() { return ${pagesSdkMember(name, { lint: lint2 })}; }`).join(", ")} }`;
289024
+ return `{ ${exported.map((name) => `get ${name}() { return ${pagesSdkMember(name, { lint })}; }`).join(", ")} }`;
289025
289025
  }
289026
289026
  function isAuthoringModule(specifier) {
289027
289027
  return specifier === AUTHORING_MODULE;
@@ -319024,28 +319024,6 @@ function stageUnstableQueryInputs(ast) {
319024
319024
  throw failure("Unstable query input", new Error(messages.join("\n")));
319025
319025
  }
319026
319026
  }
319027
- function lint(source, resources, customComponents, workspaceFields, pageContext, workflows, { appModules = {}, pagesNamespaces = [], pages = null, typeCheckTimeoutSeconds } = {}) {
319028
- const [result] = lintMany(
319029
- [
319030
- {
319031
- source,
319032
- resources,
319033
- customComponents,
319034
- workspaceFields,
319035
- pageContext,
319036
- workflows,
319037
- appModules,
319038
- pagesNamespaces,
319039
- pages
319040
- }
319041
- ],
319042
- { typeCheckTimeoutSeconds }
319043
- );
319044
- if (result.failure !== null) {
319045
- throw result.failure;
319046
- }
319047
- return result.transformed;
319048
- }
319049
319027
  function lintMany(units, { typeCheckTimeoutSeconds } = {}) {
319050
319028
  const checked = units.map((unit) => {
319051
319029
  const normalized = {
@@ -319200,20 +319178,23 @@ function failureDiagnostics(unit, failure2) {
319200
319178
  ...fileDiagnostics
319201
319179
  ];
319202
319180
  }
319203
- function lintUnit(unit, catalogs) {
319204
- try {
319205
- lint(unit.lint.code, catalogs.resources, catalogs.customComponents, null, null, null, {
319181
+ function lintUnits(units, catalogs) {
319182
+ const results = lintMany(
319183
+ units.map((unit) => ({
319184
+ source: unit.lint.code,
319185
+ resources: catalogs.resources,
319186
+ customComponents: catalogs.customComponents,
319187
+ workspaceFields: null,
319188
+ pageContext: null,
319189
+ workflows: null,
319206
319190
  appModules: unit.lint.appModules ?? {},
319207
319191
  pagesNamespaces: unit.lint.pagesNamespaces ?? [],
319208
319192
  pages: catalogs.pages
319209
- });
319210
- } catch (error) {
319211
- if (error instanceof LintFailure) {
319212
- return failureDiagnostics(unit, error);
319213
- }
319214
- throw error;
319215
- }
319216
- return [];
319193
+ }))
319194
+ );
319195
+ return results.map(
319196
+ ({ failure: failure2 }, index3) => failure2 === null ? [] : failureDiagnostics(units[index3], failure2)
319197
+ );
319217
319198
  }
319218
319199
 
319219
319200
  // scripts/lib/runtime-build/page-options-migration.mjs
@@ -321627,7 +321608,7 @@ function keptTypeRange(statement2, helpers) {
321627
321608
  return null;
321628
321609
  }
321629
321610
  var LAZY_IMPORT = "__lazy(";
321630
- function lintUnit2(original, ast, functionNode, helpers, app, functionBinding) {
321611
+ function lintUnit(original, ast, functionNode, helpers, app, functionBinding) {
321631
321612
  let source = original;
321632
321613
  for (const lazy of app.lazy) {
321633
321614
  source = source.slice(0, lazy.start) + LAZY_IMPORT + source.slice(lazy.start + LAZY_IMPORT.length);
@@ -321705,7 +321686,7 @@ function isTypeOnlySpecifier(statement2, specifier) {
321705
321686
  function importedName(specifier) {
321706
321687
  return specifier.imported.type === "StringLiteral" ? specifier.imported.value : specifier.imported.name;
321707
321688
  }
321708
- function foreignBindingText(statement2, { lint: lint2, resolve: resolve7 }) {
321689
+ function foreignBindingText(statement2, { lint, resolve: resolve7 }) {
321709
321690
  const specifier = statement2.source.value;
321710
321691
  const kind = importKind(specifier);
321711
321692
  const statements2 = [];
@@ -321721,9 +321702,9 @@ function foreignBindingText(statement2, { lint: lint2, resolve: resolve7 }) {
321721
321702
  statements2.push(`const ${local} = Sdk;`);
321722
321703
  }
321723
321704
  } else if (name !== null && Object.hasOwn(PAGE_SDK_EXPORTS, name)) {
321724
- statements2.push(`const ${local} = ${pagesSdkMember(name, { lint: lint2 })};`);
321705
+ statements2.push(`const ${local} = ${pagesSdkMember(name, { lint })};`);
321725
321706
  } else if (item.type === "ImportNamespaceSpecifier") {
321726
- statements2.push(`const ${local} = ${pagesSdkObjectText(null, { lint: lint2 })};`);
321707
+ statements2.push(`const ${local} = ${pagesSdkObjectText(null, { lint })};`);
321727
321708
  } else if (name !== null && Object.hasOwn(PAGE_SDK_TYPES, name)) {
321728
321709
  } else {
321729
321710
  statements2.push(`const ${local}: any = undefined;`);
@@ -321745,7 +321726,7 @@ function foreignBindingText(statement2, { lint: lint2, resolve: resolve7 }) {
321745
321726
  }
321746
321727
  continue;
321747
321728
  }
321748
- if (lint2) {
321729
+ if (lint) {
321749
321730
  statements2.push(
321750
321731
  kind === "style_module" ? `const ${local}: Record<string, string> = {};` : `const ${local}: any = undefined;`
321751
321732
  );
@@ -321840,7 +321821,7 @@ return ${functionBinding};`;
321840
321821
  // What a draft of this unit runs before its own code: the page builder
321841
321822
  // previews a page's factory body without its imports.
321842
321823
  app_prelude: app.draftPrelude === "" && bindings === "" ? null : `${app.draftPrelude}${bindings}`,
321843
- lint: lintUnit2(source, ast, functionNode, helpers, app, functionBinding)
321824
+ lint: lintUnit(source, ast, functionNode, helpers, app, functionBinding)
321844
321825
  };
321845
321826
  }
321846
321827
  function boundName(functionNode) {
@@ -322775,22 +322756,16 @@ function readWorkflowReferences(root, files, diagnostics) {
322775
322756
  routesByPath: new Map(workflowFiles.map(({ path, ast }) => [path, ast === null ? null : workflowListing(ast).route]))
322776
322757
  };
322777
322758
  }
322778
- function lintUnits(units, resources, pages, diagnostics, assetsComplete, domainsComplete) {
322779
- const catalogs = {
322780
- resources,
322781
- customComponents: [],
322782
- pages
322783
- };
322759
+ function lintPageUnits(units, resources, pages, diagnostics, assetsComplete, domainsComplete) {
322760
+ const kept = units.filter((unit) => {
322761
+ const appModules = unit.lint.appModules ?? {};
322762
+ return (assetsComplete || !Object.hasOwn(appModules, GENERATED_ASSETS_PATH)) && (domainsComplete || !Object.hasOwn(appModules, GENERATED_DOMAINS_PATH));
322763
+ });
322764
+ const results = lintUnits(kept, { resources, customComponents: [], pages });
322784
322765
  const failedPaths = new Set(diagnostics.map((found2) => found2.path));
322785
322766
  const reported = /* @__PURE__ */ new Set();
322786
- for (const unit of units) {
322787
- if (!assetsComplete && Object.hasOwn(unit.lint.appModules ?? {}, GENERATED_ASSETS_PATH)) {
322788
- continue;
322789
- }
322790
- if (!domainsComplete && Object.hasOwn(unit.lint.appModules ?? {}, GENERATED_DOMAINS_PATH)) {
322791
- continue;
322792
- }
322793
- for (const found2 of lintUnit(unit, catalogs)) {
322767
+ kept.forEach((unit, index3) => {
322768
+ for (const found2 of results[index3]) {
322794
322769
  const key = `${found2.path}:${found2.line}:${found2.column}:${found2.message}`;
322795
322770
  if (found2.path !== unit.path && (failedPaths.has(found2.path) || reported.has(key))) {
322796
322771
  continue;
@@ -322798,7 +322773,7 @@ function lintUnits(units, resources, pages, diagnostics, assetsComplete, domains
322798
322773
  reported.add(key);
322799
322774
  diagnostics.push(found2);
322800
322775
  }
322801
- }
322776
+ });
322802
322777
  }
322803
322778
  function buildPageEntries(root, files, write, diagnostics) {
322804
322779
  const paths = files.filter((path) => classify(path) === "page");
@@ -323711,7 +323686,7 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
323711
323686
  generatedCatalogSource(resourceTypes, pageTypes),
323712
323687
  Object.keys(resourceTypes).length > 0 || pageTypes.length > 0
323713
323688
  );
323714
- lintUnits(
323689
+ lintPageUnits(
323715
323690
  [...output.components, ...output.layouts, ...output.pages].filter((unit) => !sdkCustomPaths.has(unit.path)),
323716
323691
  resourceTypes,
323717
323692
  pageTypes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagonal-hq/cli",
3
- "version": "0.35.1",
3
+ "version": "0.35.2",
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": {