@diagonal-hq/cli 0.4.2 → 0.5.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/dist/cli.mjs +103 -50
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -263670,7 +263670,7 @@ function getParserClass(pluginsMap) {
|
|
|
263670
263670
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
263671
263671
|
import { existsSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
263672
263672
|
import { builtinModules } from "node:module";
|
|
263673
|
-
import { basename, dirname, join, posix } from "node:path";
|
|
263673
|
+
import { basename, dirname, join, posix, relative } from "node:path";
|
|
263674
263674
|
var APP_PREFIX = "@app/";
|
|
263675
263675
|
var AUTHORING_MODULE = "@diagonal-hq/cli";
|
|
263676
263676
|
var PAGES_SDK_MODULE = "@diagonal/pages";
|
|
@@ -263687,22 +263687,55 @@ var HOST_MODULES = /* @__PURE__ */ new Set([
|
|
|
263687
263687
|
AUTHORING_MODULE
|
|
263688
263688
|
]);
|
|
263689
263689
|
var SOURCE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx"];
|
|
263690
|
-
var
|
|
263691
|
-
".
|
|
263692
|
-
".
|
|
263693
|
-
".
|
|
263694
|
-
".
|
|
263695
|
-
".
|
|
263696
|
-
".
|
|
263697
|
-
".
|
|
263698
|
-
".
|
|
263699
|
-
".
|
|
263700
|
-
".
|
|
263701
|
-
".
|
|
263702
|
-
".
|
|
263703
|
-
".
|
|
263704
|
-
".
|
|
263705
|
-
|
|
263690
|
+
var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
263691
|
+
".apng",
|
|
263692
|
+
".avif",
|
|
263693
|
+
".bmp",
|
|
263694
|
+
".gif",
|
|
263695
|
+
".heic",
|
|
263696
|
+
".heif",
|
|
263697
|
+
".ico",
|
|
263698
|
+
".jpeg",
|
|
263699
|
+
".jpg",
|
|
263700
|
+
".jxl",
|
|
263701
|
+
".png",
|
|
263702
|
+
".svg",
|
|
263703
|
+
".svgz",
|
|
263704
|
+
".tif",
|
|
263705
|
+
".tiff",
|
|
263706
|
+
".webp",
|
|
263707
|
+
".cur",
|
|
263708
|
+
".m4v",
|
|
263709
|
+
".mov",
|
|
263710
|
+
".mp4",
|
|
263711
|
+
".mpeg",
|
|
263712
|
+
".mpg",
|
|
263713
|
+
".ogv",
|
|
263714
|
+
".webm",
|
|
263715
|
+
".aac",
|
|
263716
|
+
".flac",
|
|
263717
|
+
".m4a",
|
|
263718
|
+
".mp3",
|
|
263719
|
+
".oga",
|
|
263720
|
+
".ogg",
|
|
263721
|
+
".opus",
|
|
263722
|
+
".wav",
|
|
263723
|
+
".weba",
|
|
263724
|
+
".pdf",
|
|
263725
|
+
".eot",
|
|
263726
|
+
".otf",
|
|
263727
|
+
".ttf",
|
|
263728
|
+
".woff",
|
|
263729
|
+
".woff2"
|
|
263730
|
+
]);
|
|
263731
|
+
var BINARY_FILE_MESSAGE = "Binary files cannot be in the repository. Add it as an Application Asset and use Assets.<key>. For an icon, use Sdk.Icon or an SVG written as a TSX component";
|
|
263732
|
+
function binaryCssUrlMessage(value) {
|
|
263733
|
+
return `url("${value}") names a file in the repository. Binary files cannot be in the repository. Add it as an Application Asset and use url(asset:<key>)`;
|
|
263734
|
+
}
|
|
263735
|
+
function binaryCssImportMessage(value) {
|
|
263736
|
+
const request2 = value.split(/[?#]/)[0];
|
|
263737
|
+
return BINARY_EXTENSIONS.has(posix.extname(request2).toLowerCase()) ? `"${value}" is a binary file. Binary files cannot be in the repository. Add it as an Application Asset and use url(asset:<key>)` : null;
|
|
263738
|
+
}
|
|
263706
263739
|
var NODE_MODULES = new Set(builtinModules.flatMap((name) => [name, `node:${name}`]));
|
|
263707
263740
|
var SERVER_PACKAGES = /* @__PURE__ */ new Set(["@diagonal/workflow", "@diagonal/workflow/workspace"]);
|
|
263708
263741
|
function importKind(specifier) {
|
|
@@ -263729,10 +263762,12 @@ function importKind(specifier) {
|
|
|
263729
263762
|
if (bare.endsWith(".css")) {
|
|
263730
263763
|
return "style";
|
|
263731
263764
|
}
|
|
263732
|
-
return
|
|
263765
|
+
return BINARY_EXTENSIONS.has(posix.extname(bare).toLowerCase()) ? "binary" : "app";
|
|
263733
263766
|
}
|
|
263734
263767
|
function unsupportedImportMessage(specifier, kind) {
|
|
263735
263768
|
switch (kind) {
|
|
263769
|
+
case "binary":
|
|
263770
|
+
return `"${specifier}" is a binary file. ${BINARY_FILE_MESSAGE}`;
|
|
263736
263771
|
case "node":
|
|
263737
263772
|
return `"${specifier}" is a Node.js module. Pages run in the browser, so they cannot import it`;
|
|
263738
263773
|
case "server":
|
|
@@ -263811,6 +263846,18 @@ function checkoutFile(root, path) {
|
|
|
263811
263846
|
const realFile = realpathSync(file2);
|
|
263812
263847
|
return realFile.startsWith(`${realRoot}/`) ? file2 : null;
|
|
263813
263848
|
}
|
|
263849
|
+
function isExternalCssUrl(value) {
|
|
263850
|
+
return /^(asset:|data:|https?:|#)/i.test(value);
|
|
263851
|
+
}
|
|
263852
|
+
function resolveCssReference(root, importerPath, value) {
|
|
263853
|
+
const request2 = value.split(/[?#]/)[0];
|
|
263854
|
+
if (posix.isAbsolute(request2)) {
|
|
263855
|
+
return null;
|
|
263856
|
+
}
|
|
263857
|
+
const path = posix.normalize(posix.join(posix.dirname(importerPath), request2));
|
|
263858
|
+
const file2 = checkoutFile(root, path);
|
|
263859
|
+
return file2 !== null && isExactFile(file2) ? relative(realpathSync(root), realpathSync(file2)).split("\\").join("/") : null;
|
|
263860
|
+
}
|
|
263814
263861
|
function assetUrlKey(value) {
|
|
263815
263862
|
return /^asset:/i.test(value) ? value.slice(6) : null;
|
|
263816
263863
|
}
|
|
@@ -263820,6 +263867,7 @@ function cssReferences(source) {
|
|
|
263820
263867
|
const functions = [];
|
|
263821
263868
|
let offset = 0;
|
|
263822
263869
|
let importing = false;
|
|
263870
|
+
let composing = false;
|
|
263823
263871
|
let nextNewline = source.indexOf("\n");
|
|
263824
263872
|
let line = 1;
|
|
263825
263873
|
let lineStart = 0;
|
|
@@ -263875,6 +263923,15 @@ function cssReferences(source) {
|
|
|
263875
263923
|
if (identifier4 !== null) {
|
|
263876
263924
|
offset += identifier4[0].length;
|
|
263877
263925
|
const name = identifier4[0].toLowerCase();
|
|
263926
|
+
if (name === "composes" || name === "composes-with") {
|
|
263927
|
+
skipSpace();
|
|
263928
|
+
composing = source[offset] === ":";
|
|
263929
|
+
} else if (composing && name === "from") {
|
|
263930
|
+
importing = true;
|
|
263931
|
+
composing = false;
|
|
263932
|
+
} else if (importing && name !== "url") {
|
|
263933
|
+
importing = false;
|
|
263934
|
+
}
|
|
263878
263935
|
if (source[offset] === "(") {
|
|
263879
263936
|
offset++;
|
|
263880
263937
|
if (name === "url") {
|
|
@@ -263896,6 +263953,7 @@ function cssReferences(source) {
|
|
|
263896
263953
|
functions.pop();
|
|
263897
263954
|
} else if (char === ";" || char === "{" || char === "}") {
|
|
263898
263955
|
importing = false;
|
|
263956
|
+
composing = false;
|
|
263899
263957
|
}
|
|
263900
263958
|
offset++;
|
|
263901
263959
|
}
|
|
@@ -263958,7 +264016,7 @@ function defaultExportOf(ast, { helpers: helperPlacement = "none", allowAppImpor
|
|
|
263958
264016
|
const specifier = statement2.source.value;
|
|
263959
264017
|
const kind = importKind(specifier);
|
|
263960
264018
|
const refused = unsupportedImportMessage(specifier, kind);
|
|
263961
|
-
if (allowAppImports && refused !== null) {
|
|
264019
|
+
if (allowAppImports && statement2.importKind !== "type" && refused !== null) {
|
|
263962
264020
|
throw new SourceError(refused, statement2.source);
|
|
263963
264021
|
}
|
|
263964
264022
|
if (!isAuthoringModule(specifier) && !allowAppImports && !extraImports.includes(specifier)) {
|
|
@@ -267449,7 +267507,7 @@ function checkCapabilities(resources, platformSlugs, diagnostics) {
|
|
|
267449
267507
|
// scripts/lib/runtime-build/module-graph.mjs
|
|
267450
267508
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
267451
267509
|
import { readFileSync } from "node:fs";
|
|
267452
|
-
import { posix as posix2, join as join2
|
|
267510
|
+
import { posix as posix2, join as join2 } from "node:path";
|
|
267453
267511
|
|
|
267454
267512
|
// scripts/lib/runtime-build/page-build-protocol.mjs
|
|
267455
267513
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
@@ -267461,14 +267519,15 @@ function sha256(value) {
|
|
|
267461
267519
|
}
|
|
267462
267520
|
|
|
267463
267521
|
// scripts/lib/runtime-build/module-graph.mjs
|
|
267464
|
-
var STYLE_KINDS = /* @__PURE__ */ new Set(["style", "style_module"
|
|
267522
|
+
var STYLE_KINDS = /* @__PURE__ */ new Set(["style", "style_module"]);
|
|
267465
267523
|
function resolveFileSpecifier(root, from, specifier) {
|
|
267466
267524
|
const request2 = specifier.startsWith(APP_PREFIX) ? specifier.slice(APP_PREFIX.length) : posix2.join(posix2.dirname(from), specifier);
|
|
267467
267525
|
const path = posix2.normalize(request2);
|
|
267468
267526
|
if (path.startsWith("../") || path === ".." || path.startsWith("/")) {
|
|
267469
267527
|
return null;
|
|
267470
267528
|
}
|
|
267471
|
-
|
|
267529
|
+
const file2 = checkoutFile(root, path);
|
|
267530
|
+
return file2 !== null && isExactFile(file2) ? path : null;
|
|
267472
267531
|
}
|
|
267473
267532
|
function declaredPackages(manifest) {
|
|
267474
267533
|
return /* @__PURE__ */ new Set([...Object.keys(manifest?.dependencies ?? {}), ...Object.keys(manifest?.peerDependencies ?? {})]);
|
|
@@ -267566,9 +267625,7 @@ function buildModuleGraph(root, entries, manifest, diagnostics, assetKeys = /* @
|
|
|
267566
267625
|
}
|
|
267567
267626
|
const kind = importKind(`./${posix2.basename(path)}`);
|
|
267568
267627
|
if (STYLE_KINDS.has(kind)) {
|
|
267569
|
-
|
|
267570
|
-
checkStylesheet(root, path, assetKeys, diagnostics, scannedStyles);
|
|
267571
|
-
}
|
|
267628
|
+
checkStylesheet(root, path, assetKeys, diagnostics, scannedStyles);
|
|
267572
267629
|
modules[path] = { kind, source_sha256: sha256(readFileSync(join2(root, path))), imports: [] };
|
|
267573
267630
|
continue;
|
|
267574
267631
|
}
|
|
@@ -267726,14 +267783,12 @@ function checkStylesheet(root, path, assetKeys, diagnostics, scanned) {
|
|
|
267726
267783
|
}
|
|
267727
267784
|
scanned.add(path);
|
|
267728
267785
|
const { urls, imports } = cssReferences(readFileSync(join2(root, path), "utf8"));
|
|
267729
|
-
|
|
267730
|
-
|
|
267731
|
-
|
|
267732
|
-
|
|
267733
|
-
|
|
267734
|
-
|
|
267735
|
-
);
|
|
267736
|
-
}
|
|
267786
|
+
for (const url of urls) {
|
|
267787
|
+
const key = assetUrlKey(url.value);
|
|
267788
|
+
if (key !== null && assetKeys !== null && !assetKeys.has(key)) {
|
|
267789
|
+
diagnostics.push(diagnostic(path, url.line, url.column, `Unknown asset "${key}". Add it to assets.ts`));
|
|
267790
|
+
} else if (!isExternalCssUrl(url.value)) {
|
|
267791
|
+
diagnostics.push(diagnostic(path, url.line, url.column, binaryCssUrlMessage(url.value)));
|
|
267737
267792
|
}
|
|
267738
267793
|
}
|
|
267739
267794
|
for (const target of imports) {
|
|
@@ -267743,22 +267798,20 @@ function checkStylesheet(root, path, assetKeys, diagnostics, scanned) {
|
|
|
267743
267798
|
);
|
|
267744
267799
|
continue;
|
|
267745
267800
|
}
|
|
267746
|
-
if (
|
|
267801
|
+
if (isExternalCssUrl(target.value)) {
|
|
267747
267802
|
continue;
|
|
267748
267803
|
}
|
|
267749
|
-
const
|
|
267750
|
-
|
|
267751
|
-
|
|
267752
|
-
|
|
267753
|
-
|
|
267754
|
-
|
|
267755
|
-
|
|
267756
|
-
|
|
267757
|
-
|
|
267758
|
-
diagnostics,
|
|
267759
|
-
scanned
|
|
267760
|
-
);
|
|
267804
|
+
const binary = binaryCssImportMessage(target.value);
|
|
267805
|
+
if (binary !== null) {
|
|
267806
|
+
diagnostics.push(diagnostic(path, target.line, target.column, binary));
|
|
267807
|
+
continue;
|
|
267808
|
+
}
|
|
267809
|
+
const resolved = resolveCssReference(root, path, target.value);
|
|
267810
|
+
if (resolved === null) {
|
|
267811
|
+
diagnostics.push(diagnostic(path, target.line, target.column, `Cannot find "${target.value}" from ${path}`));
|
|
267812
|
+
continue;
|
|
267761
267813
|
}
|
|
267814
|
+
checkStylesheet(root, resolved, assetKeys, diagnostics, scanned);
|
|
267762
267815
|
}
|
|
267763
267816
|
}
|
|
267764
267817
|
|
|
@@ -298359,7 +298412,7 @@ var defineEmailLayout = (layout) => layout;
|
|
|
298359
298412
|
|
|
298360
298413
|
// scripts/lib/runtime-build/app-modules.mjs
|
|
298361
298414
|
var APP_IMPORT = "__appImport";
|
|
298362
|
-
var PRELUDE_SKIPPED_KINDS = /* @__PURE__ */ new Set(["host", "package", "style", "style_module", "
|
|
298415
|
+
var PRELUDE_SKIPPED_KINDS = /* @__PURE__ */ new Set(["host", "package", "style", "style_module", "binary"]);
|
|
298363
298416
|
var AUTHORING_HELPERS_SOURCE = objectLiteral(cli_exports);
|
|
298364
298417
|
var AUTHORING_HELPERS_MODULE = Object.entries(cli_exports).map(([name, value]) => `export const ${name} = ${helperSource(value)};
|
|
298365
298418
|
`).join("");
|
|
@@ -298732,7 +298785,7 @@ function foreignBindingText(statement2) {
|
|
|
298732
298785
|
}
|
|
298733
298786
|
continue;
|
|
298734
298787
|
}
|
|
298735
|
-
const placeholder2 = kind === "
|
|
298788
|
+
const placeholder2 = kind === "style_module" ? `const ${local}: Record<string, string> = {};` : `const ${local}: any = undefined;`;
|
|
298736
298789
|
statements2.push(placeholder2);
|
|
298737
298790
|
}
|
|
298738
298791
|
return statements2.join(" ");
|
|
@@ -300977,7 +301030,7 @@ function defineResourceArgument(ast) {
|
|
|
300977
301030
|
}
|
|
300978
301031
|
function isUnitSupportFile(path) {
|
|
300979
301032
|
const extension = extname2(path).toLowerCase();
|
|
300980
|
-
return extension === ".ts" || extension === ".css"
|
|
301033
|
+
return extension === ".ts" || extension === ".css";
|
|
300981
301034
|
}
|
|
300982
301035
|
function classify(path) {
|
|
300983
301036
|
if (path === "assets.ts") {
|
|
@@ -301175,7 +301228,7 @@ function buildWorkspace(root, { assetCatalog = null, writeGeneratedResources = f
|
|
|
301175
301228
|
}
|
|
301176
301229
|
if (kind === "unknown") {
|
|
301177
301230
|
diagnostics.push(
|
|
301178
|
-
diagnosticAt(path, null, "The build does not know this file. Move or rename it")
|
|
301231
|
+
diagnosticAt(path, null, BINARY_EXTENSIONS.has(extname2(path).toLowerCase()) ? BINARY_FILE_MESSAGE : "The build does not know this file. Move or rename it")
|
|
301179
301232
|
);
|
|
301180
301233
|
continue;
|
|
301181
301234
|
}
|