@diagonal-hq/cli 0.35.0 → 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.
- package/dist/cli.mjs +38 -60
- 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
|
|
289015
|
+
function pagesSdkMember(name, { lint = false } = {}) {
|
|
289016
289016
|
const path = PAGE_SDK_EXPORTS[name];
|
|
289017
|
-
if (
|
|
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
|
|
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
|
|
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;
|
|
@@ -289108,7 +289108,7 @@ function importKind(specifier) {
|
|
|
289108
289108
|
if (specifier.startsWith("@/") || specifier.startsWith("#")) {
|
|
289109
289109
|
return "alias";
|
|
289110
289110
|
}
|
|
289111
|
-
const local = specifier.startsWith(APP_PREFIX) ||
|
|
289111
|
+
const local = specifier.startsWith(APP_PREFIX) || isRelativeSpecifier(specifier);
|
|
289112
289112
|
if (!local) {
|
|
289113
289113
|
return "package";
|
|
289114
289114
|
}
|
|
@@ -289120,6 +289120,9 @@ function importKind(specifier) {
|
|
|
289120
289120
|
}
|
|
289121
289121
|
return BINARY_EXTENSIONS.has(posix.extname(bare).toLowerCase()) ? "binary" : "app";
|
|
289122
289122
|
}
|
|
289123
|
+
function isRelativeSpecifier(specifier) {
|
|
289124
|
+
return specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../");
|
|
289125
|
+
}
|
|
289123
289126
|
function unsupportedImportMessage(specifier, kind, suggestion = null) {
|
|
289124
289127
|
switch (kind) {
|
|
289125
289128
|
case "alias":
|
|
@@ -319021,28 +319024,6 @@ function stageUnstableQueryInputs(ast) {
|
|
|
319021
319024
|
throw failure("Unstable query input", new Error(messages.join("\n")));
|
|
319022
319025
|
}
|
|
319023
319026
|
}
|
|
319024
|
-
function lint(source, resources, customComponents, workspaceFields, pageContext, workflows, { appModules = {}, pagesNamespaces = [], pages = null, typeCheckTimeoutSeconds } = {}) {
|
|
319025
|
-
const [result] = lintMany(
|
|
319026
|
-
[
|
|
319027
|
-
{
|
|
319028
|
-
source,
|
|
319029
|
-
resources,
|
|
319030
|
-
customComponents,
|
|
319031
|
-
workspaceFields,
|
|
319032
|
-
pageContext,
|
|
319033
|
-
workflows,
|
|
319034
|
-
appModules,
|
|
319035
|
-
pagesNamespaces,
|
|
319036
|
-
pages
|
|
319037
|
-
}
|
|
319038
|
-
],
|
|
319039
|
-
{ typeCheckTimeoutSeconds }
|
|
319040
|
-
);
|
|
319041
|
-
if (result.failure !== null) {
|
|
319042
|
-
throw result.failure;
|
|
319043
|
-
}
|
|
319044
|
-
return result.transformed;
|
|
319045
|
-
}
|
|
319046
319027
|
function lintMany(units, { typeCheckTimeoutSeconds } = {}) {
|
|
319047
319028
|
const checked = units.map((unit) => {
|
|
319048
319029
|
const normalized = {
|
|
@@ -319197,20 +319178,23 @@ function failureDiagnostics(unit, failure2) {
|
|
|
319197
319178
|
...fileDiagnostics
|
|
319198
319179
|
];
|
|
319199
319180
|
}
|
|
319200
|
-
function
|
|
319201
|
-
|
|
319202
|
-
|
|
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,
|
|
319203
319190
|
appModules: unit.lint.appModules ?? {},
|
|
319204
319191
|
pagesNamespaces: unit.lint.pagesNamespaces ?? [],
|
|
319205
319192
|
pages: catalogs.pages
|
|
319206
|
-
})
|
|
319207
|
-
|
|
319208
|
-
|
|
319209
|
-
|
|
319210
|
-
|
|
319211
|
-
throw error;
|
|
319212
|
-
}
|
|
319213
|
-
return [];
|
|
319193
|
+
}))
|
|
319194
|
+
);
|
|
319195
|
+
return results.map(
|
|
319196
|
+
({ failure: failure2 }, index3) => failure2 === null ? [] : failureDiagnostics(units[index3], failure2)
|
|
319197
|
+
);
|
|
319214
319198
|
}
|
|
319215
319199
|
|
|
319216
319200
|
// scripts/lib/runtime-build/page-options-migration.mjs
|
|
@@ -321624,7 +321608,7 @@ function keptTypeRange(statement2, helpers) {
|
|
|
321624
321608
|
return null;
|
|
321625
321609
|
}
|
|
321626
321610
|
var LAZY_IMPORT = "__lazy(";
|
|
321627
|
-
function
|
|
321611
|
+
function lintUnit(original, ast, functionNode, helpers, app, functionBinding) {
|
|
321628
321612
|
let source = original;
|
|
321629
321613
|
for (const lazy of app.lazy) {
|
|
321630
321614
|
source = source.slice(0, lazy.start) + LAZY_IMPORT + source.slice(lazy.start + LAZY_IMPORT.length);
|
|
@@ -321702,7 +321686,7 @@ function isTypeOnlySpecifier(statement2, specifier) {
|
|
|
321702
321686
|
function importedName(specifier) {
|
|
321703
321687
|
return specifier.imported.type === "StringLiteral" ? specifier.imported.value : specifier.imported.name;
|
|
321704
321688
|
}
|
|
321705
|
-
function foreignBindingText(statement2, { lint
|
|
321689
|
+
function foreignBindingText(statement2, { lint, resolve: resolve7 }) {
|
|
321706
321690
|
const specifier = statement2.source.value;
|
|
321707
321691
|
const kind = importKind(specifier);
|
|
321708
321692
|
const statements2 = [];
|
|
@@ -321718,9 +321702,9 @@ function foreignBindingText(statement2, { lint: lint2, resolve: resolve7 }) {
|
|
|
321718
321702
|
statements2.push(`const ${local} = Sdk;`);
|
|
321719
321703
|
}
|
|
321720
321704
|
} else if (name !== null && Object.hasOwn(PAGE_SDK_EXPORTS, name)) {
|
|
321721
|
-
statements2.push(`const ${local} = ${pagesSdkMember(name, { lint
|
|
321705
|
+
statements2.push(`const ${local} = ${pagesSdkMember(name, { lint })};`);
|
|
321722
321706
|
} else if (item.type === "ImportNamespaceSpecifier") {
|
|
321723
|
-
statements2.push(`const ${local} = ${pagesSdkObjectText(null, { lint
|
|
321707
|
+
statements2.push(`const ${local} = ${pagesSdkObjectText(null, { lint })};`);
|
|
321724
321708
|
} else if (name !== null && Object.hasOwn(PAGE_SDK_TYPES, name)) {
|
|
321725
321709
|
} else {
|
|
321726
321710
|
statements2.push(`const ${local}: any = undefined;`);
|
|
@@ -321742,7 +321726,7 @@ function foreignBindingText(statement2, { lint: lint2, resolve: resolve7 }) {
|
|
|
321742
321726
|
}
|
|
321743
321727
|
continue;
|
|
321744
321728
|
}
|
|
321745
|
-
if (
|
|
321729
|
+
if (lint) {
|
|
321746
321730
|
statements2.push(
|
|
321747
321731
|
kind === "style_module" ? `const ${local}: Record<string, string> = {};` : `const ${local}: any = undefined;`
|
|
321748
321732
|
);
|
|
@@ -321837,7 +321821,7 @@ return ${functionBinding};`;
|
|
|
321837
321821
|
// What a draft of this unit runs before its own code: the page builder
|
|
321838
321822
|
// previews a page's factory body without its imports.
|
|
321839
321823
|
app_prelude: app.draftPrelude === "" && bindings === "" ? null : `${app.draftPrelude}${bindings}`,
|
|
321840
|
-
lint:
|
|
321824
|
+
lint: lintUnit(source, ast, functionNode, helpers, app, functionBinding)
|
|
321841
321825
|
};
|
|
321842
321826
|
}
|
|
321843
321827
|
function boundName(functionNode) {
|
|
@@ -322772,22 +322756,16 @@ function readWorkflowReferences(root, files, diagnostics) {
|
|
|
322772
322756
|
routesByPath: new Map(workflowFiles.map(({ path, ast }) => [path, ast === null ? null : workflowListing(ast).route]))
|
|
322773
322757
|
};
|
|
322774
322758
|
}
|
|
322775
|
-
function
|
|
322776
|
-
const
|
|
322777
|
-
|
|
322778
|
-
|
|
322779
|
-
|
|
322780
|
-
};
|
|
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 });
|
|
322781
322765
|
const failedPaths = new Set(diagnostics.map((found2) => found2.path));
|
|
322782
322766
|
const reported = /* @__PURE__ */ new Set();
|
|
322783
|
-
|
|
322784
|
-
|
|
322785
|
-
continue;
|
|
322786
|
-
}
|
|
322787
|
-
if (!domainsComplete && Object.hasOwn(unit.lint.appModules ?? {}, GENERATED_DOMAINS_PATH)) {
|
|
322788
|
-
continue;
|
|
322789
|
-
}
|
|
322790
|
-
for (const found2 of lintUnit(unit, catalogs)) {
|
|
322767
|
+
kept.forEach((unit, index3) => {
|
|
322768
|
+
for (const found2 of results[index3]) {
|
|
322791
322769
|
const key = `${found2.path}:${found2.line}:${found2.column}:${found2.message}`;
|
|
322792
322770
|
if (found2.path !== unit.path && (failedPaths.has(found2.path) || reported.has(key))) {
|
|
322793
322771
|
continue;
|
|
@@ -322795,7 +322773,7 @@ function lintUnits(units, resources, pages, diagnostics, assetsComplete, domains
|
|
|
322795
322773
|
reported.add(key);
|
|
322796
322774
|
diagnostics.push(found2);
|
|
322797
322775
|
}
|
|
322798
|
-
}
|
|
322776
|
+
});
|
|
322799
322777
|
}
|
|
322800
322778
|
function buildPageEntries(root, files, write, diagnostics) {
|
|
322801
322779
|
const paths = files.filter((path) => classify(path) === "page");
|
|
@@ -323708,7 +323686,7 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
323708
323686
|
generatedCatalogSource(resourceTypes, pageTypes),
|
|
323709
323687
|
Object.keys(resourceTypes).length > 0 || pageTypes.length > 0
|
|
323710
323688
|
);
|
|
323711
|
-
|
|
323689
|
+
lintPageUnits(
|
|
323712
323690
|
[...output.components, ...output.layouts, ...output.pages].filter((unit) => !sdkCustomPaths.has(unit.path)),
|
|
323713
323691
|
resourceTypes,
|
|
323714
323692
|
pageTypes,
|