@homepages/concrete 4.0.0 → 6.0.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/CHANGELOG.md +359 -0
- package/README.md +28 -17
- package/codemods/fill-is-a-source.mjs +533 -0
- package/codemods/manifest.json +18 -0
- package/codemods/reads-replace-reconcile.mjs +285 -0
- package/dist/artifact/playground/client/assets/{index-D1fwOGVK.js → index-u3T7DiSN.js} +96 -96
- package/dist/artifact/playground/client/index.html +1 -1
- package/dist/artifact/playground/host.mjs +23 -23
- package/dist/base.css +3 -8
- package/dist/browser/site-config.js +1 -16
- package/dist/browser/submit-lead.js +0 -31
- package/dist/cli/build/artifact.js +16 -23
- package/dist/cli/build/captures.js +0 -6
- package/dist/cli/build/esbuild.js +0 -17
- package/dist/cli/build/fixtures.js +15 -30
- package/dist/cli/build/icons.js +0 -3
- package/dist/cli/build/index.js +1 -1
- package/dist/cli/build/playground.js +4 -8
- package/dist/cli/build/sections.js +9 -30
- package/dist/cli/build/source.js +52 -27
- package/dist/cli/build/static.js +4 -25
- package/dist/cli/capture/bundle.js +0 -9
- package/dist/cli/capture/capture-browser.js +0 -14
- package/dist/cli/capture/capture.js +1 -8
- package/dist/cli/check/analyze.js +2 -5
- package/dist/cli/check/index.js +1 -1
- package/dist/cli/check/line-endings.js +52 -0
- package/dist/cli/check/load-workspace.js +3 -8
- package/dist/cli/check/portable-names.js +48 -0
- package/dist/cli/check/render/class-conflicts.js +0 -5
- package/dist/cli/check/render/html.js +0 -1
- package/dist/cli/check/render/invariants.js +0 -5
- package/dist/cli/check/render/island-frames.js +0 -25
- package/dist/cli/check/render/marker-coverage.js +0 -20
- package/dist/cli/check/render/nav.js +0 -33
- package/dist/cli/check/report.js +0 -3
- package/dist/cli/check/stages/bundles.js +1 -9
- package/dist/cli/check/stages/composition.js +3 -2
- package/dist/cli/check/stages/dependencies.js +7 -38
- package/dist/cli/check/stages/fixtures.js +3 -31
- package/dist/cli/check/stages/lint.js +2 -2
- package/dist/cli/check/stages/logic.js +3 -34
- package/dist/cli/check/stages/relations.js +46 -0
- package/dist/cli/check/stages/render.js +0 -1
- package/dist/cli/check/stages/sections.js +3 -3
- package/dist/cli/check/stages/stylesheet.js +1 -1
- package/dist/cli/check/stages/typecheck.js +5 -11
- package/dist/cli/check/stages/workspace.js +36 -14
- package/dist/cli/commands.js +9 -56
- package/dist/cli/currency/cache.js +4 -17
- package/dist/cli/currency/decide.js +0 -14
- package/dist/cli/currency/opt-out.js +0 -7
- package/dist/cli/currency/preamble.js +3 -24
- package/dist/cli/currency/prompt.js +0 -1
- package/dist/cli/currency/refresh.js +5 -12
- package/dist/cli/currency/resolve-latest.js +3 -64
- package/dist/cli/currency/version-order.js +0 -12
- package/dist/cli/dev/crop.js +0 -2
- package/dist/cli/dev/http.js +0 -13
- package/dist/cli/dev/index.js +3 -4
- package/dist/cli/dev/islands.js +25 -70
- package/dist/cli/dev/listen.js +26 -0
- package/dist/cli/dev/load-template.js +0 -1
- package/dist/cli/dev/request-error.js +0 -4
- package/dist/cli/dev/server.js +46 -52
- package/dist/cli/dev/tsconfig-paths.js +0 -13
- package/dist/cli/dev/vite.js +9 -38
- package/dist/cli/dev/workspace-reader.js +4 -34
- package/dist/cli/media/cache.js +4 -51
- package/dist/cli/media/derive.js +2 -94
- package/dist/cli/media/deriver-plugin.js +0 -2
- package/dist/cli/media/frame-rung-floor.js +0 -6
- package/dist/cli/property/index.js +0 -4
- package/dist/cli/property/library.js +6 -24
- package/dist/cli/publish/client.js +0 -1
- package/dist/cli/publish/freshness.js +0 -2
- package/dist/cli/publish/git.js +2 -8
- package/dist/cli/publish/index.js +8 -15
- package/dist/cli/publish/pack.js +5 -6
- package/dist/cli/publish/report.js +0 -6
- package/dist/cli/publish/target.js +16 -13
- package/dist/cli/publish/wire.js +0 -6
- package/dist/cli/tar.js +2 -9
- package/dist/cli/upgrade/codemod.js +0 -8
- package/dist/cli/upgrade/index.js +0 -24
- package/dist/cli/upgrade/manifest.js +0 -12
- package/dist/cli/upgrade/plan.js +0 -17
- package/dist/cli/upgrade/stage.js +12 -15
- package/dist/cli/version.js +0 -8
- package/dist/cli/workspace.js +2 -34
- package/dist/cli.js +4 -21
- package/dist/css/compile.js +25 -28
- package/dist/css/graph.js +3 -10
- package/dist/css/inline.js +3 -13
- package/dist/css/rules.js +6 -43
- package/dist/design-system/format-variants.js +0 -22
- package/dist/eslint/authoring.js +0 -2
- package/dist/eslint/correctness.js +0 -7
- package/dist/eslint/rules/editor-reason.js +0 -11
- package/dist/eslint/rules/island-ids.js +0 -1
- package/dist/eslint/rules/jsx-visitor.js +0 -13
- package/dist/eslint/rules/no-editor-globals.js +0 -2
- package/dist/eslint/rules/no-raw-values.js +0 -1
- package/dist/fixtures/brand.js +0 -1
- package/dist/fixtures/bundle-rule.js +4 -9
- package/dist/fixtures/canonical.d.ts +20 -0
- package/dist/fixtures/image-dimensions.js +0 -1
- package/dist/fixtures/load.js +8 -17
- package/dist/fixtures/media-plugin.js +4 -31
- package/dist/fixtures/media.js +0 -21
- package/dist/fixtures/package-stylesheets.js +0 -6
- package/dist/fixtures/property.js +16 -15
- package/dist/fixtures/resolve.js +102 -29
- package/dist/fixtures/rows.js +12 -11
- package/dist/fixtures/synthesize-empties.js +0 -4
- package/dist/fixtures.d.ts +19 -4
- package/dist/fixtures.js +0 -18
- package/dist/index.d.ts +8 -9
- package/dist/index.js +2 -11
- package/dist/islands/client-module.js +0 -11
- package/dist/islands/marker.js +0 -33
- package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +0 -20
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +22 -36
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +4 -0
- package/dist/packages/internal/fill-bake/dist/derive-source.js +40 -0
- package/dist/packages/internal/fill-bake/dist/display.js +0 -1
- package/dist/packages/internal/fill-bake/dist/index.js +4 -4
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +106 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -49
- package/dist/packages/internal/format-geometry/dist/capture.js +10 -240
- package/dist/packages/internal/format-geometry/dist/geometry.js +0 -6
- package/dist/packages/internal/image-ladder/dist/crop.js +0 -12
- package/dist/packages/internal/image-ladder/dist/policy.js +0 -14
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +0 -13
- package/dist/packages/internal/island-runtime/dist/contract.js +0 -34
- package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +0 -1
- package/dist/packages/internal/island-runtime/dist/index.js +0 -34
- package/dist/packages/internal/island-runtime/dist/island-id-context.js +0 -1
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +0 -15
- package/dist/packages/internal/island-runtime/dist/use-editor.js +0 -10
- package/dist/packages/internal/island-runtime/dist/use-island-id.js +0 -32
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +2 -17
- package/dist/packages/internal/property-facts/dist/index.js +1 -1
- package/dist/packages/internal/property-facts/dist/{property-facts-CSdkSuD7.js → property-facts-5pxZnlkh.js} +13 -2
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +1 -18
- package/dist/packages/internal/section-contracts/dist/catalog.js +16 -8
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +12 -16
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +5 -11
- package/dist/packages/internal/section-contracts/dist/display-contract.js +2 -0
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +2 -8
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +13 -0
- package/dist/packages/internal/section-contracts/dist/index.js +2 -1
- package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +16 -42
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +24 -43
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +11 -18
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +10 -12
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +3 -13
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +6 -18
- package/dist/packages/internal/section-contracts/dist/runners.js +21 -13
- package/dist/packages/internal/section-contracts/dist/source-contract.js +13 -2
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +31 -0
- package/dist/packages/internal/source-resolution/dist/index.js +5 -30
- package/dist/packages/internal/template-artifact/dist/hash.js +0 -8
- package/dist/packages/internal/template-artifact/dist/index.js +1 -1
- package/dist/packages/internal/template-artifact/dist/layout.js +0 -39
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -9
- package/dist/packages/internal/template-artifact/dist/sha256.js +0 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +2 -4
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -16
- package/dist/packages/internal/template-contracts/dist/content-categories.js +0 -4
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +16 -10
- package/dist/packages/internal/template-contracts/dist/facts-view.js +15 -28
- package/dist/packages/internal/template-contracts/dist/layout.js +0 -7
- package/dist/packages/internal/template-contracts/dist/markers.js +0 -29
- package/dist/packages/internal/template-contracts/dist/select-key.js +0 -6
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +56 -34
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +22 -389
- package/dist/platform/file-url.js +8 -0
- package/dist/platform/fs.js +73 -0
- package/dist/platform/names.js +63 -0
- package/dist/platform/order.js +7 -0
- package/dist/platform/paths.js +62 -0
- package/dist/platform/process.js +97 -0
- package/dist/playground/host/page-state.js +0 -2
- package/dist/playground/host/paths.js +0 -1
- package/dist/playground/layout.js +0 -7
- package/dist/playground/wire.js +0 -8
- package/dist/primitives/FrameShell.js +0 -18
- package/dist/primitives/Image.d.ts +5 -1
- package/dist/primitives/Image.js +2 -68
- package/dist/primitives/Section.js +0 -13
- package/dist/primitives/Tour.js +0 -26
- package/dist/primitives/Video.js +0 -32
- package/dist/primitives/embed-playback.js +0 -1
- package/dist/primitives/marker-attrs.js +0 -17
- package/dist/primitives/picture-sources.js +6 -1
- package/dist/primitives/probe-context.js +0 -7
- package/dist/primitives/slot-bindings.d.ts +3 -2
- package/dist/primitives/slot-bindings.js +0 -46
- package/dist/primitives/slot-document.js +0 -11
- package/dist/primitives/slot-group.js +0 -9
- package/dist/primitives/slot-media.js +0 -27
- package/dist/primitives/slot-scalar.js +0 -4
- package/dist/primitives/slot.js +0 -6
- package/dist/rules/registry.js +42 -24
- package/dist/schema/compute.d.ts +46 -8
- package/dist/schema/compute.js +21 -15
- package/dist/schema/define-schema.d.ts +1 -1
- package/dist/schema/define-schema.js +37 -17
- package/dist/schema/extract-fill-spec.js +93 -180
- package/dist/schema/extract-used-facts.js +16 -158
- package/dist/schema/fact.d.ts +33 -18
- package/dist/schema/fact.js +7 -11
- package/dist/schema/fill-builders.d.ts +91 -366
- package/dist/schema/fill-builders.js +21 -259
- package/dist/schema/fill-declaration.d.ts +7 -69
- package/dist/schema/fill-declaration.js +5 -34
- package/dist/schema/fill-spec.js +59 -148
- package/dist/schema/format-presets.js +0 -12
- package/dist/schema/format.js +0 -7
- package/dist/schema/layout.js +0 -10
- package/dist/schema/manifest.js +0 -39
- package/dist/schema/property-facts.d.ts +20 -0
- package/dist/schema/runtime-values.d.ts +6 -18
- package/dist/schema/section-nav.js +0 -15
- package/dist/schema/section-props.d.ts +7 -9
- package/dist/schema/section-schema.d.ts +0 -1
- package/dist/schema/section-schema.js +4 -20
- package/dist/schema/slot-builders.d.ts +128 -117
- package/dist/schema/slot-builders.js +18 -201
- package/dist/schema/slot-ref.d.ts +63 -0
- package/dist/schema/slot-ref.js +33 -0
- package/dist/schema/slot-types.d.ts +3 -2
- package/dist/schema/slot-types.js +11 -20
- package/dist/section/declare.d.ts +14 -10
- package/dist/section/declare.js +13 -2
- package/dist/section/discovery.js +6 -21
- package/dist/section/groups.js +0 -6
- package/dist/section/materialize.js +0 -5
- package/dist/section/placements.js +0 -4
- package/dist/section/section.d.ts +8 -5
- package/dist/section/section.js +7 -29
- package/dist/styles.css +5 -0
- package/dist/template/define-template.d.ts +0 -4
- package/dist/template/define-template.js +1 -15
- package/dist/template/logic-build.js +8 -35
- package/dist/template/logic-shim.d.ts +4 -5
- package/dist/template/logic-shim.js +2 -6
- package/dist/template/logic-transform.js +0 -6
- package/dist/template/materialize.js +52 -43
- package/dist/template/mirror-types.js +43 -0
- package/dist/template/running-copy.js +5 -20
- package/dist/template/section-reads.js +83 -0
- package/guide/reference/cli/INDEX.md +12 -6
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +3 -3
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +1 -1
- package/guide/reference/cli/publish.md +4 -2
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +26 -13
- package/package.json +4 -2
- package/dist/packages/internal/fact-interpolation/dist/index.js +0 -22
- package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +0 -170
- package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +0 -32
- package/dist/packages/internal/fill-vocabulary/dist/facts.js +0 -131
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +0 -11
- package/dist/schema/fill-spec.d.ts +0 -18
- package/dist/template/reconcile.d.ts +0 -67
- package/dist/template/reconcile.js +0 -25
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ASSET_URL_PREFIX, FIXTURE_FILES, fixturePath, isFixtureId } from "../../packages/internal/template-artifact/dist/layout.js";
|
|
2
2
|
import "../../packages/internal/template-artifact/dist/index.js";
|
|
3
|
-
import { deriveAuthorImage } from "../media/derive.js";
|
|
4
3
|
import { assetContentType } from "./esbuild.js";
|
|
5
4
|
import { mediaUrl } from "../../fixtures/property.js";
|
|
6
5
|
import { basename } from "node:path";
|
|
@@ -9,14 +8,12 @@ import { readFile } from "node:fs/promises";
|
|
|
9
8
|
//#region src/cli/build/fixtures.ts
|
|
10
9
|
const encoder = new TextEncoder();
|
|
11
10
|
const json = (value) => encoder.encode(`${JSON.stringify(value, null, 2)}\n`);
|
|
12
|
-
/** Every string in `value` that is a key of `urls`, replaced by its value. */
|
|
13
11
|
function rewriteUrls(value, urls) {
|
|
14
12
|
if (typeof value === "string") return urls.get(value) ?? value;
|
|
15
13
|
if (Array.isArray(value)) return value.map((item) => rewriteUrls(item, urls));
|
|
16
14
|
if (typeof value === "object" && value !== null) return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, rewriteUrls(inner, urls)]));
|
|
17
15
|
return value;
|
|
18
16
|
}
|
|
19
|
-
/** Build every authored fixture's files and the media they name. */
|
|
20
17
|
async function fixtureFiles(input) {
|
|
21
18
|
const files = /* @__PURE__ */ new Map();
|
|
22
19
|
const assets = /* @__PURE__ */ new Map();
|
|
@@ -28,33 +25,21 @@ async function fixtureFiles(input) {
|
|
|
28
25
|
const source = input.assets.get(served);
|
|
29
26
|
if (source === void 0) throw new Error(`build: fixture media ${served} was not recorded by the fixture load.`);
|
|
30
27
|
const bytes = new Uint8Array(await readFile(source.path));
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
file
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
assets.set(filename, {
|
|
47
|
-
filename,
|
|
48
|
-
bytes,
|
|
49
|
-
contentType: assetContentType(filename)
|
|
50
|
-
});
|
|
51
|
-
const url = `${ASSET_URL_PREFIX}${filename}`;
|
|
52
|
-
result = {
|
|
53
|
-
file: url,
|
|
54
|
-
urls: /* @__PURE__ */ new Map([[served, url]]),
|
|
55
|
-
bytes: bytes.byteLength
|
|
56
|
-
};
|
|
57
|
-
}
|
|
28
|
+
const filename = basename(served);
|
|
29
|
+
assets.set(filename, {
|
|
30
|
+
filename,
|
|
31
|
+
bytes,
|
|
32
|
+
contentType: assetContentType(filename)
|
|
33
|
+
});
|
|
34
|
+
const url = `${ASSET_URL_PREFIX}${filename}`;
|
|
35
|
+
const result = {
|
|
36
|
+
file: typeof file === "string" ? url : {
|
|
37
|
+
...file,
|
|
38
|
+
url
|
|
39
|
+
},
|
|
40
|
+
urls: /* @__PURE__ */ new Map([[served, url]]),
|
|
41
|
+
bytes: bytes.byteLength
|
|
42
|
+
};
|
|
58
43
|
artifactFiles.set(served, result);
|
|
59
44
|
return result;
|
|
60
45
|
};
|
package/dist/cli/build/icons.js
CHANGED
|
@@ -7,7 +7,6 @@ import { createHash } from "node:crypto";
|
|
|
7
7
|
const SITE_ICON_PNG_SIZES = [192];
|
|
8
8
|
const APPLE_TOUCH_ICON_SIZE = 180;
|
|
9
9
|
const ICO_SIZE = 32;
|
|
10
|
-
/** Wrap one PNG in an ICO container: ICONDIR, one ICONDIRENTRY, then the PNG verbatim. */
|
|
11
10
|
function pngToIco(png, size) {
|
|
12
11
|
const header = Buffer.alloc(22);
|
|
13
12
|
header.writeUInt16LE(0, 0);
|
|
@@ -23,7 +22,6 @@ function pngToIco(png, size) {
|
|
|
23
22
|
header.writeUInt32LE(22, 18);
|
|
24
23
|
return Buffer.concat([header, png]);
|
|
25
24
|
}
|
|
26
|
-
/** `icon-<16 hex of the master's sha256>`: the stem every derived file of one master shares. */
|
|
27
25
|
function siteIconStem(master) {
|
|
28
26
|
return `icon-${createHash("sha256").update(master).digest("hex").slice(0, 16)}`;
|
|
29
27
|
}
|
|
@@ -34,7 +32,6 @@ async function loadSharp() {
|
|
|
34
32
|
throw new Error("The template's site icons cannot be derived: `sharp` is not installed. It is an optional dependency of @homepages/concrete; reinstall so its native binary lands, then build again.");
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
|
-
/** Derive the icon set from the master at `path`, an `.svg` or `.png`. */
|
|
38
35
|
async function deriveSiteIcons(path) {
|
|
39
36
|
const format = extname(path).toLowerCase();
|
|
40
37
|
if (format !== ".svg" && format !== ".png") throw new Error(`The template's icon must be an .svg or a .png; ${path} is neither.`);
|
package/dist/cli/build/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_BUILD_DIR, parseSpec, stringFlag } from "../commands.js";
|
|
2
|
+
import { findWorkspaceRoot } from "../workspace.js";
|
|
2
3
|
import { formatHuman } from "../check/report.js";
|
|
3
4
|
import { buildArtifact } from "./artifact.js";
|
|
4
|
-
import { findWorkspaceRoot } from "../workspace.js";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
6
|
import { parseArgs } from "node:util";
|
|
7
7
|
|
|
@@ -1,28 +1,24 @@
|
|
|
1
|
+
import { packageRoot, workspacePath } from "../../platform/paths.js";
|
|
1
2
|
import { PLAYGROUND_FILES, playgroundPath } from "../../packages/internal/template-artifact/dist/layout.js";
|
|
2
3
|
import "../../packages/internal/template-artifact/dist/index.js";
|
|
4
|
+
import { byCodeUnit } from "../../platform/order.js";
|
|
3
5
|
import { playgroundDistDir } from "../../playground/layout.js";
|
|
4
6
|
import { existsSync } from "node:fs";
|
|
5
|
-
import {
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { join } from "node:path";
|
|
7
8
|
import { readFile, readdir } from "node:fs/promises";
|
|
8
9
|
|
|
9
10
|
//#region src/cli/build/playground.ts
|
|
10
|
-
/** The package root: this module sits at `src/cli/build/` from source and `dist/cli/build/` built. */
|
|
11
|
-
function packageRoot() {
|
|
12
|
-
return join(dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
|
|
13
|
-
}
|
|
14
11
|
async function listFiles(dir) {
|
|
15
12
|
return (await readdir(dir, {
|
|
16
13
|
withFileTypes: true,
|
|
17
14
|
recursive: true
|
|
18
15
|
})).filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name));
|
|
19
16
|
}
|
|
20
|
-
/** Every playground file, by artifact-relative path, in path order. */
|
|
21
17
|
async function playgroundFiles(root = packageRoot()) {
|
|
22
18
|
const dir = playgroundDistDir(root);
|
|
23
19
|
for (const file of Object.values(PLAYGROUND_FILES)) if (!existsSync(join(dir, file))) throw new Error(`The framework's playground is not built (${join(dir, file)} is missing). Reinstall @homepages/concrete, or build the package from its checkout.`);
|
|
24
20
|
const out = /* @__PURE__ */ new Map();
|
|
25
|
-
const paths = (await listFiles(dir)).map((file) =>
|
|
21
|
+
const paths = (await listFiles(dir)).map((file) => workspacePath(dir, file)).sort(byCodeUnit);
|
|
26
22
|
for (const path of paths) out.set(playgroundPath(path), new Uint8Array(await readFile(join(dir, ...path.split("/")))));
|
|
27
23
|
return out;
|
|
28
24
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isWorkspaceFile, toPosix, workspacePath } from "../../platform/paths.js";
|
|
2
2
|
import { declaresNoServerFrame, stubClientModule, wrapClientModule } from "../dev/islands.js";
|
|
3
|
+
import { mediaCacheDir } from "../media/cache.js";
|
|
3
4
|
import { createMediaDeriver } from "../media/deriver-plugin.js";
|
|
4
5
|
import { bundledFrameworkPlugin, emittedAssets, javascriptOutput, runPass, workspaceLoaders } from "./esbuild.js";
|
|
5
|
-
import { basename, dirname, extname, join
|
|
6
|
+
import nodePath, { basename, dirname, extname, join } from "node:path";
|
|
6
7
|
import { readFile } from "node:fs/promises";
|
|
7
8
|
import { createHash } from "node:crypto";
|
|
8
9
|
import { build } from "esbuild";
|
|
9
10
|
|
|
10
11
|
//#region src/cli/build/sections.ts
|
|
11
|
-
/** The bare specifiers every island chunk and the island runtime leave to the page's import map. */
|
|
12
12
|
const ISLAND_REACT_EXTERNALS = [
|
|
13
13
|
"react",
|
|
14
14
|
"react-dom",
|
|
@@ -23,9 +23,8 @@ function sanitizeKey(key) {
|
|
|
23
23
|
function sha256(bytes) {
|
|
24
24
|
return createHash("sha256").update(bytes).digest("hex");
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
return file.startsWith(prefix) && !file.includes(`${sep}node_modules${sep}`);
|
|
26
|
+
function isIslandSource(root, file, paths = nodePath) {
|
|
27
|
+
return COMPONENT_EXT.test(file) && isWorkspaceFile(root, file, paths);
|
|
29
28
|
}
|
|
30
29
|
function islandKeyOf(sectionKey, file) {
|
|
31
30
|
return `${sectionKey}:${basename(file, extname(file))}`;
|
|
@@ -33,18 +32,12 @@ function islandKeyOf(sectionKey, file) {
|
|
|
33
32
|
function loaderOf(file) {
|
|
34
33
|
return extname(file) === ".jsx" ? "jsx" : "tsx";
|
|
35
34
|
}
|
|
36
|
-
const toPosix = (path) => path.split(sep).join("/");
|
|
37
|
-
/**
|
|
38
|
-
* The server graph's island transform: wrap (or, when `stubFrameless`, stub) every
|
|
39
|
-
* workspace client module, recording each one and refusing two modules that would share
|
|
40
|
-
* one island key.
|
|
41
|
-
*/
|
|
42
35
|
function serverIslandsPlugin(root, sectionKey, found, stubFrameless) {
|
|
43
36
|
return {
|
|
44
37
|
name: "concrete-build:islands-server",
|
|
45
38
|
setup(api) {
|
|
46
39
|
api.onLoad({ filter: COMPONENT_EXT }, async (args) => {
|
|
47
|
-
if (!
|
|
40
|
+
if (!isIslandSource(root, args.path)) return void 0;
|
|
48
41
|
const code = await readFile(args.path, "utf8");
|
|
49
42
|
const islandKey = islandKeyOf(sectionKey, args.path);
|
|
50
43
|
const contents = (stubFrameless ? stubClientModule(code, islandKey, MARKER_SPECIFIER) : null) ?? wrapClientModule(code, islandKey, MARKER_SPECIFIER);
|
|
@@ -61,13 +54,12 @@ function serverIslandsPlugin(root, sectionKey, found, stubFrameless) {
|
|
|
61
54
|
}
|
|
62
55
|
};
|
|
63
56
|
}
|
|
64
|
-
/** The browser graph's transform for one chunk: every client module but the entry is wrapped. */
|
|
65
57
|
function nestedIslandsPlugin(root, sectionKey, entry) {
|
|
66
58
|
return {
|
|
67
59
|
name: "concrete-build:islands-nested",
|
|
68
60
|
setup(api) {
|
|
69
61
|
api.onLoad({ filter: COMPONENT_EXT }, async (args) => {
|
|
70
|
-
if (args.path === entry || !
|
|
62
|
+
if (args.path === entry || !isIslandSource(root, args.path)) return void 0;
|
|
71
63
|
const contents = wrapClientModule(await readFile(args.path, "utf8"), islandKeyOf(sectionKey, args.path), MARKER_SPECIFIER);
|
|
72
64
|
return contents === null ? void 0 : {
|
|
73
65
|
contents,
|
|
@@ -85,11 +77,6 @@ function derivedAssets(deriver) {
|
|
|
85
77
|
contentType: asset.contentType
|
|
86
78
|
}));
|
|
87
79
|
}
|
|
88
|
-
/**
|
|
89
|
-
* The renderer pass. `stubFrameless: false` wraps every island for real, so a
|
|
90
|
-
* `serverFrame = false` island's server render is in the output: the bundle `check`
|
|
91
|
-
* grades that declaration against, never one that ships.
|
|
92
|
-
*/
|
|
93
80
|
async function rendererPass(input, deriver, found, stubFrameless) {
|
|
94
81
|
const { root, key } = input;
|
|
95
82
|
return runPass(`The renderer bundle of section "${key}"`, async () => {
|
|
@@ -129,7 +116,6 @@ async function rendererPass(input, deriver, found, stubFrameless) {
|
|
|
129
116
|
};
|
|
130
117
|
});
|
|
131
118
|
}
|
|
132
|
-
/** Emitted asset filename → the workspace file it was copied from: an asset output has exactly one input. */
|
|
133
119
|
function sourcesOf(metafile) {
|
|
134
120
|
const byEmitted = /* @__PURE__ */ new Map();
|
|
135
121
|
for (const [out, meta] of Object.entries(metafile.outputs)) {
|
|
@@ -138,7 +124,6 @@ function sourcesOf(metafile) {
|
|
|
138
124
|
}
|
|
139
125
|
return byEmitted;
|
|
140
126
|
}
|
|
141
|
-
/** Build a placed section's renderer bundle and its island chunks. */
|
|
142
127
|
async function buildSection(input) {
|
|
143
128
|
const { root, key, minRungWidth } = input;
|
|
144
129
|
const cacheDir = mediaCacheDir(root);
|
|
@@ -159,7 +144,7 @@ async function buildSection(input) {
|
|
|
159
144
|
});
|
|
160
145
|
}
|
|
161
146
|
for (const [master, { masterBytes, derivatives }] of deriver.sources) {
|
|
162
|
-
const file =
|
|
147
|
+
const file = workspacePath(root, master);
|
|
163
148
|
sources.set(file, {
|
|
164
149
|
file,
|
|
165
150
|
bytes: masterBytes,
|
|
@@ -225,21 +210,15 @@ async function buildSection(input) {
|
|
|
225
210
|
passthrough
|
|
226
211
|
};
|
|
227
212
|
}
|
|
228
|
-
/**
|
|
229
|
-
* The section's renderer bundle with every island wrapped for real, `serverFrame = false`
|
|
230
|
-
* or not: what each island's server render would put on the page if the declaration did
|
|
231
|
-
* not delete it. Never written to an artifact.
|
|
232
|
-
*/
|
|
233
213
|
async function buildFramedRenderer(input) {
|
|
234
214
|
return (await rendererPass(input, createMediaDeriver({
|
|
235
215
|
cacheDir: mediaCacheDir(input.root),
|
|
236
216
|
minRungWidth: input.minRungWidth
|
|
237
217
|
}), /* @__PURE__ */ new Map(), false)).bytes;
|
|
238
218
|
}
|
|
239
|
-
/** Where `check` writes a framed renderer to import it: inside the workspace, so its React resolves from there. */
|
|
240
219
|
function framedRendererPath(root, key, bytes) {
|
|
241
220
|
return join(root, ".concrete", "cache", "check", "frames", `${sanitizeKey(key)}-${sha256(bytes).slice(0, 16)}.mjs`);
|
|
242
221
|
}
|
|
243
222
|
|
|
244
223
|
//#endregion
|
|
245
|
-
export { ISLAND_REACT_EXTERNALS, buildFramedRenderer, buildSection, framedRendererPath, sanitizeKey };
|
|
224
|
+
export { ISLAND_REACT_EXTERNALS, buildFramedRenderer, buildSection, framedRendererPath, isIslandSource, sanitizeKey };
|
package/dist/cli/build/source.js
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { toPosix, workspacePath } from "../../platform/paths.js";
|
|
2
|
+
import { execGit } from "../../platform/process.js";
|
|
3
|
+
import { NON_SOURCE_DIRS } from "../workspace.js";
|
|
4
|
+
import { byCodeUnit } from "../../platform/order.js";
|
|
5
|
+
import { listDir } from "../../platform/fs.js";
|
|
6
|
+
import { join, relative } from "node:path";
|
|
7
|
+
import { readFile } from "node:fs/promises";
|
|
5
8
|
|
|
6
9
|
//#region src/cli/build/source.ts
|
|
7
|
-
const run = promisify(execFile);
|
|
8
|
-
const toPosix = (path) => sep === "\\" ? path.replaceAll("\\", "/") : path;
|
|
9
10
|
async function gitListing(root) {
|
|
10
11
|
try {
|
|
11
|
-
|
|
12
|
+
await execGit([
|
|
13
|
+
"check-ignore",
|
|
14
|
+
"-q",
|
|
15
|
+
"."
|
|
16
|
+
], { cwd: root });
|
|
17
|
+
return null;
|
|
18
|
+
} catch (cause) {
|
|
19
|
+
if (cause.code !== 1) return null;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const { stdout } = await execGit([
|
|
12
23
|
"ls-files",
|
|
13
24
|
"-z",
|
|
14
25
|
"--cached",
|
|
@@ -25,38 +36,52 @@ async function gitListing(root) {
|
|
|
25
36
|
return null;
|
|
26
37
|
}
|
|
27
38
|
}
|
|
39
|
+
const WALK_SKIPPED_DIRS = /* @__PURE__ */ new Set([".git", ...NON_SOURCE_DIRS]);
|
|
28
40
|
async function walk(root) {
|
|
29
41
|
const out = [];
|
|
30
42
|
const visit = async (dir) => {
|
|
31
|
-
for (const entry of await
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
await visit(path);
|
|
36
|
-
} else if (entry.isFile()) out.push(toPosix(relative(root, path)));
|
|
37
|
-
}
|
|
43
|
+
for (const entry of await listDir(dir)) if (entry.isDirectory()) {
|
|
44
|
+
if (WALK_SKIPPED_DIRS.has(entry.name)) continue;
|
|
45
|
+
await visit(entry.path);
|
|
46
|
+
} else if (entry.isFile()) out.push(toPosix(relative(root, entry.path)));
|
|
38
47
|
};
|
|
39
48
|
await visit(root);
|
|
40
49
|
return out;
|
|
41
50
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
async function listSourcePaths(root, exclude) {
|
|
52
|
+
const excluded = [...NON_SOURCE_DIRS, ...exclude.map((dir) => workspacePath(root, dir))].filter((dir) => dir !== "" && !dir.startsWith("..")).map((dir) => `${dir.replace(/\/+$/, "")}/`);
|
|
53
|
+
return (await gitListing(root) ?? await walk(root)).filter((onDisk) => !excluded.some((dir) => onDisk.normalize("NFC").startsWith(dir)));
|
|
54
|
+
}
|
|
55
|
+
async function listSourceFiles(root, exclude) {
|
|
56
|
+
const listed = /* @__PURE__ */ new Map();
|
|
57
|
+
for (const onDisk of await listSourcePaths(root, exclude)) {
|
|
58
|
+
const path = onDisk.normalize("NFC");
|
|
59
|
+
if (!listed.has(path)) listed.set(path, onDisk);
|
|
60
|
+
}
|
|
61
|
+
return [...listed].sort(([a], [b]) => byCodeUnit(a, b)).map(([path, onDisk]) => ({
|
|
62
|
+
path,
|
|
63
|
+
file: join(root, onDisk)
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
async function readSourceFile(listed) {
|
|
67
|
+
try {
|
|
68
|
+
return new Uint8Array(await readFile(listed.file));
|
|
69
|
+
} catch (cause) {
|
|
70
|
+
if (cause.code !== "ENOENT") throw cause;
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
46
74
|
async function collectSourceFiles(root, exclude) {
|
|
47
|
-
const excluded = [".concrete", ...exclude.map((dir) => toPosix(relative(root, dir)))].filter((dir) => dir !== "" && !dir.startsWith("..")).map((dir) => `${dir.replace(/\/+$/, "")}/`);
|
|
48
|
-
const paths = (await gitListing(root) ?? await walk(root)).filter((path) => !excluded.some((dir) => path.startsWith(dir)));
|
|
49
75
|
const files = [];
|
|
50
|
-
for (const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
76
|
+
for (const listed of await listSourceFiles(root, exclude)) {
|
|
77
|
+
const bytes = await readSourceFile(listed);
|
|
78
|
+
if (bytes !== null) files.push({
|
|
79
|
+
path: listed.path,
|
|
80
|
+
bytes
|
|
54
81
|
});
|
|
55
|
-
} catch (cause) {
|
|
56
|
-
if (cause.code !== "ENOENT") throw cause;
|
|
57
82
|
}
|
|
58
83
|
return files;
|
|
59
84
|
}
|
|
60
85
|
|
|
61
86
|
//#endregion
|
|
62
|
-
export { collectSourceFiles };
|
|
87
|
+
export { collectSourceFiles, listSourceFiles, listSourcePaths, readSourceFile };
|
package/dist/cli/build/static.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CAPTURE_ISLANDS_READY_GLOBAL } from "../../packages/internal/format-geometry/dist/capture.js";
|
|
2
2
|
import "../../packages/internal/format-geometry/dist/index.js";
|
|
3
|
+
import { externalSpecifier, packageFile } from "../../platform/paths.js";
|
|
3
4
|
import { islandRuntimeFile } from "../dev/islands.js";
|
|
4
5
|
import { javascriptOutput, runPass } from "./esbuild.js";
|
|
5
6
|
import { ISLAND_REACT_EXTERNALS, sanitizeKey } from "./sections.js";
|
|
6
|
-
import { dirname,
|
|
7
|
-
import {
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { pathToFileURL } from "node:url";
|
|
8
9
|
import { readFile } from "node:fs/promises";
|
|
9
10
|
import { createHash } from "node:crypto";
|
|
10
11
|
import { createRequire } from "node:module";
|
|
@@ -22,22 +23,10 @@ function bundleOf(stem, ext, bytes) {
|
|
|
22
23
|
bytes
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
|
-
const FROM_SOURCE = extname(fileURLToPath(import.meta.url)) === ".ts";
|
|
26
|
-
function packageFile(sourcePath, distPath) {
|
|
27
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
28
|
-
return FROM_SOURCE ? join(here, "..", "..", sourcePath) : join(here, "..", "..", distPath);
|
|
29
|
-
}
|
|
30
|
-
/** The page-level stylesheet: layer order, reset gaps, the primitives' own classes. */
|
|
31
26
|
async function baseCssBundle() {
|
|
32
27
|
const bytes = await readFile(packageFile("css/base.css", "base.css"));
|
|
33
28
|
return bundleOf("base", ".css", new Uint8Array(bytes));
|
|
34
29
|
}
|
|
35
|
-
/**
|
|
36
|
-
* The island runtime chunk every page with an island loads once: hydrates each marker
|
|
37
|
-
* from the island map the document carries, and publishes the capture-readiness promise
|
|
38
|
-
* a capturer awaits. React stays external, resolved through the page's import map, so
|
|
39
|
-
* the runtime and every island share one React.
|
|
40
|
-
*/
|
|
41
30
|
async function islandRuntimeBundle() {
|
|
42
31
|
const source = [
|
|
43
32
|
`import { hydrateIslands, islandsCaptureReady } from ${JSON.stringify(islandRuntimeFile())};`,
|
|
@@ -82,10 +71,7 @@ function externalCorePlugin() {
|
|
|
82
71
|
return {
|
|
83
72
|
name: "concrete-build:react-vendor-core",
|
|
84
73
|
setup(api) {
|
|
85
|
-
api.onResolve({ filter: /^\.\/react-vendor-core-[0-9a-f]{64}\.mjs$/ }, (args) => (
|
|
86
|
-
path: args.path,
|
|
87
|
-
external: true
|
|
88
|
-
}));
|
|
74
|
+
api.onResolve({ filter: /^\.\/react-vendor-core-[0-9a-f]{64}\.mjs$/ }, (args) => externalSpecifier(args.path));
|
|
89
75
|
}
|
|
90
76
|
};
|
|
91
77
|
}
|
|
@@ -109,12 +95,6 @@ async function bundleVendorModule(contents, resolveDir, plugins = []) {
|
|
|
109
95
|
})).outputFiles, "a React vendor module");
|
|
110
96
|
});
|
|
111
97
|
}
|
|
112
|
-
/**
|
|
113
|
-
* React for the browser, from the workspace's own React: one CORE bundling every island
|
|
114
|
-
* specifier in a single pass (so React is instantiated once), and one FACADE per
|
|
115
|
-
* specifier re-exporting from the core by its hashed URL. The page's import map points
|
|
116
|
-
* the bare specifiers at the facades; nothing names the core but the facades.
|
|
117
|
-
*/
|
|
118
98
|
async function reactVendorBundles(root) {
|
|
119
99
|
const requireFromRoot = createRequire(join(root, "package.json"));
|
|
120
100
|
const resolved = new Map(ISLAND_REACT_EXTERNALS.map((specifier) => [specifier, requireFromRoot.resolve(specifier)]));
|
|
@@ -135,7 +115,6 @@ async function reactVendorBundles(root) {
|
|
|
135
115
|
facades
|
|
136
116
|
};
|
|
137
117
|
}
|
|
138
|
-
/** The published-site analytics beacon and integrations runtime, as one standalone script. */
|
|
139
118
|
async function analyticsBundle() {
|
|
140
119
|
const entry = packageFile("site-runtime/analytics-entry.ts", "site-analytics.js");
|
|
141
120
|
return bundleOf("analytics", ".js", await runPass("The analytics bundle", async () => {
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { zipSync } from "../../node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/capture/bundle.ts
|
|
4
|
-
/**
|
|
5
|
-
* Disambiguate names that collide.
|
|
6
|
-
*
|
|
7
|
-
* Page filenames come from the author's own labels and are explicitly not
|
|
8
|
-
* unique — a template labelling two pages identically produces two identical
|
|
9
|
-
* names. Inside a zip that is not cosmetic: the second entry would replace the
|
|
10
|
-
* first and the archive would silently be short a page.
|
|
11
|
-
*/
|
|
12
4
|
function uniqueName(taken, name) {
|
|
13
5
|
if (!taken.has(name)) {
|
|
14
6
|
taken.add(name);
|
|
@@ -25,7 +17,6 @@ function uniqueName(taken, name) {
|
|
|
25
17
|
}
|
|
26
18
|
}
|
|
27
19
|
}
|
|
28
|
-
/** Pack the entries, in the order given — which is the canvas's page order. */
|
|
29
20
|
function bundlePages(entries) {
|
|
30
21
|
const taken = /* @__PURE__ */ new Set();
|
|
31
22
|
const members = {};
|
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
//#region src/cli/capture/capture-browser.ts
|
|
2
|
-
/**
|
|
3
|
-
* Close a capture request's page. A capture closes its page in a `finally`,
|
|
4
|
-
* after the artifact has already been written to the response — so a rejection
|
|
5
|
-
* here cannot change what the client received, and letting it out of the handler
|
|
6
|
-
* only produces an unhandled rejection (see request-error.ts). The trigger in
|
|
7
|
-
* practice is the shared browser going away first: the server shutting down
|
|
8
|
-
* mid-capture, or Chromium being reaped under load. Both mean the page is gone
|
|
9
|
-
* already, which is the outcome this call wanted.
|
|
10
|
-
*
|
|
11
|
-
* This is deliberately narrow. It makes CLEANUP non-fatal and nothing else — the
|
|
12
|
-
* capture itself, and every pool failure that precedes the response, still
|
|
13
|
-
* decides the request's status code, so a broken capture can never ship a
|
|
14
|
-
* partial artifact at HTTP 200.
|
|
15
|
-
*/
|
|
16
2
|
async function closeCapturePage(page) {
|
|
17
3
|
try {
|
|
18
4
|
await page.close();
|
|
@@ -7,9 +7,8 @@ import { pathToFileURL } from "node:url";
|
|
|
7
7
|
import { createRequire } from "node:module";
|
|
8
8
|
|
|
9
9
|
//#region src/cli/capture/capture.ts
|
|
10
|
-
/** A capture tool that is not installed — carries the install line. */
|
|
11
10
|
var CaptureUnavailableError = class extends Error {};
|
|
12
|
-
const INSTALL_LINE = "captures need Playwright
|
|
11
|
+
const INSTALL_LINE = "captures need Playwright. Install it in this workspace with these two commands, in order:\n npm install --save-dev @playwright/test\n npx playwright install chromium";
|
|
13
12
|
async function importPlaywright(root, packageRoot) {
|
|
14
13
|
for (const base of [root, packageRoot]) {
|
|
15
14
|
let resolved;
|
|
@@ -99,12 +98,6 @@ function createCapturer(options) {
|
|
|
99
98
|
close: () => pool.close()
|
|
100
99
|
};
|
|
101
100
|
}
|
|
102
|
-
/**
|
|
103
|
-
* The bytes of one capture the host validated: its documents, resolved against the origin
|
|
104
|
-
* serving the host, shot by `capturer`. The host names the documents and has already
|
|
105
|
-
* dropped every page the fixture switches off; this function only shoots what it is given.
|
|
106
|
-
* Throws {@link CaptureUnavailableError} when the capture tool is not installed.
|
|
107
|
-
*/
|
|
108
101
|
async function captureFixture(capturer, origin, request) {
|
|
109
102
|
const entries = request.documents.map((document) => ({
|
|
110
103
|
url: new URL(document.path, origin).href,
|
|
@@ -8,6 +8,7 @@ import { dependencyGates } from "./stages/dependencies.js";
|
|
|
8
8
|
import { fixturesStage } from "./stages/fixtures.js";
|
|
9
9
|
import { lintStage } from "./stages/lint.js";
|
|
10
10
|
import { logicStage } from "./stages/logic.js";
|
|
11
|
+
import { relationsStage } from "./stages/relations.js";
|
|
11
12
|
import { renderStage } from "./stages/render.js";
|
|
12
13
|
import { sectionsStage } from "./stages/sections.js";
|
|
13
14
|
import { stylesheetStage } from "./stages/stylesheet.js";
|
|
@@ -20,6 +21,7 @@ const RUNNERS = {
|
|
|
20
21
|
typecheck: typecheckStage,
|
|
21
22
|
lint: lintStage,
|
|
22
23
|
composition: compositionStage,
|
|
24
|
+
relations: relationsStage,
|
|
23
25
|
stylesheet: stylesheetStage,
|
|
24
26
|
logic: logicStage,
|
|
25
27
|
fixtures: fixturesStage,
|
|
@@ -32,11 +34,6 @@ const RUNNERS = {
|
|
|
32
34
|
async function analyzeCheck(options) {
|
|
33
35
|
return (await analyzeWorkspace(options)).report;
|
|
34
36
|
}
|
|
35
|
-
/**
|
|
36
|
-
* The check run and what its stages produced: the loaded workspace, the composition,
|
|
37
|
-
* the materialized sections. `build` reads the context of a green run rather than
|
|
38
|
-
* loading the workspace a second time, so what it writes is exactly what was graded.
|
|
39
|
-
*/
|
|
40
37
|
async function analyzeWorkspace(options) {
|
|
41
38
|
const ctx = {
|
|
42
39
|
root: options.root,
|
package/dist/cli/check/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { booleanFlag, parseSpec } from "../commands.js";
|
|
2
|
+
import { findWorkspaceRoot } from "../workspace.js";
|
|
2
3
|
import { formatHuman, toJson } from "./report.js";
|
|
3
4
|
import { analyzeCheck } from "./analyze.js";
|
|
4
|
-
import { findWorkspaceRoot } from "../workspace.js";
|
|
5
5
|
import { parseArgs } from "node:util";
|
|
6
6
|
|
|
7
7
|
//#region src/cli/check/index.ts
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { listSourceFiles, readSourceFile } from "../build/source.js";
|
|
2
|
+
|
|
3
|
+
//#region src/cli/check/line-endings.ts
|
|
4
|
+
const NUL = 0;
|
|
5
|
+
const CR = 13;
|
|
6
|
+
const LF = 10;
|
|
7
|
+
const EOF_MARK = 26;
|
|
8
|
+
const PRINTABLE_CONTROLS = /* @__PURE__ */ new Set([
|
|
9
|
+
8,
|
|
10
|
+
9,
|
|
11
|
+
27,
|
|
12
|
+
12
|
|
13
|
+
]);
|
|
14
|
+
function firstCrlfLine(bytes) {
|
|
15
|
+
if (bytes.indexOf(CR) === -1 || bytes.indexOf(NUL) !== -1) return null;
|
|
16
|
+
let printable = 0;
|
|
17
|
+
let nonPrintable = 0;
|
|
18
|
+
let line = 1;
|
|
19
|
+
let firstCrlf = null;
|
|
20
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
21
|
+
const byte = bytes[i];
|
|
22
|
+
if (byte === CR) {
|
|
23
|
+
if (bytes[i + 1] !== LF) return null;
|
|
24
|
+
firstCrlf ??= line;
|
|
25
|
+
line++;
|
|
26
|
+
i++;
|
|
27
|
+
} else if (byte === LF) line++;
|
|
28
|
+
else if (byte === 127 || byte < 32 && !PRINTABLE_CONTROLS.has(byte)) nonPrintable++;
|
|
29
|
+
else printable++;
|
|
30
|
+
}
|
|
31
|
+
if (bytes[bytes.length - 1] === EOF_MARK) nonPrintable--;
|
|
32
|
+
if (printable >> 7 < nonPrintable) return null;
|
|
33
|
+
return firstCrlf;
|
|
34
|
+
}
|
|
35
|
+
async function crlfTextViolations(root) {
|
|
36
|
+
const violations = [];
|
|
37
|
+
for (const listed of await listSourceFiles(root, [])) {
|
|
38
|
+
const bytes = await readSourceFile(listed);
|
|
39
|
+
const line = bytes === null ? null : firstCrlfLine(bytes);
|
|
40
|
+
if (line === null) continue;
|
|
41
|
+
violations.push({
|
|
42
|
+
rule: "workspace/crlf-text",
|
|
43
|
+
file: listed.path,
|
|
44
|
+
line,
|
|
45
|
+
message: `${listed.path} has CRLF line endings. Concrete versions a template by its bytes, so this file builds a different version than the same commit checked out with LF. Add a .gitattributes file at the workspace root containing "* text=auto eol=lf" and convert the file to LF.`
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return violations;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { crlfTextViolations, firstCrlfLine };
|
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
import { isTemplate } from "../../template/define-template.js";
|
|
2
|
+
import { workspacePath } from "../../platform/paths.js";
|
|
2
3
|
import { listModules } from "../../section/discovery.js";
|
|
3
4
|
import { MEDIA_LOADERS, createFixtureMediaPlugin, externalOutsideWorkspace } from "../../fixtures/media-plugin.js";
|
|
4
5
|
import { runningCopyPlugin } from "../../template/running-copy.js";
|
|
5
6
|
import { createPackageStylesheetsPlugin } from "../../fixtures/package-stylesheets.js";
|
|
6
7
|
import { existsSync } from "node:fs";
|
|
7
|
-
import { join
|
|
8
|
+
import { join } from "node:path";
|
|
8
9
|
import { pathToFileURL } from "node:url";
|
|
9
10
|
import { build } from "esbuild";
|
|
10
11
|
|
|
11
12
|
//#region src/cli/check/load-workspace.ts
|
|
12
|
-
/** The one reserved file: the root of the import graph. */
|
|
13
13
|
const TEMPLATE_FILE = "template.ts";
|
|
14
|
-
/** Workspace-relative, `/` separators. */
|
|
15
|
-
function workspacePath(root, file) {
|
|
16
|
-
return relative(root, file).split(sep).join("/");
|
|
17
|
-
}
|
|
18
14
|
function buildMessages(err) {
|
|
19
15
|
const messages = err.errors;
|
|
20
16
|
return Array.isArray(messages) ? messages : null;
|
|
21
17
|
}
|
|
22
18
|
let importSerial = 0;
|
|
23
|
-
/** Build and import the workspace. Every fault is a violation; nothing here throws for an author's mistake. */
|
|
24
19
|
async function loadWorkspace(root) {
|
|
25
20
|
const templateFile = join(root, TEMPLATE_FILE);
|
|
26
21
|
if (!existsSync(templateFile)) return {
|
|
@@ -121,4 +116,4 @@ async function loadWorkspace(root) {
|
|
|
121
116
|
}
|
|
122
117
|
|
|
123
118
|
//#endregion
|
|
124
|
-
export { TEMPLATE_FILE, loadWorkspace
|
|
119
|
+
export { TEMPLATE_FILE, loadWorkspace };
|