@homepages/concrete 5.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.
Files changed (269) hide show
  1. package/CHANGELOG.md +336 -0
  2. package/README.md +28 -17
  3. package/codemods/fill-is-a-source.mjs +533 -0
  4. package/codemods/manifest.json +12 -0
  5. package/codemods/reads-replace-reconcile.mjs +285 -0
  6. package/dist/artifact/playground/client/assets/{index-D1fwOGVK.js → index-u3T7DiSN.js} +96 -96
  7. package/dist/artifact/playground/client/index.html +1 -1
  8. package/dist/artifact/playground/host.mjs +23 -23
  9. package/dist/base.css +3 -8
  10. package/dist/browser/site-config.js +1 -16
  11. package/dist/browser/submit-lead.js +0 -31
  12. package/dist/cli/build/artifact.js +16 -23
  13. package/dist/cli/build/captures.js +0 -6
  14. package/dist/cli/build/esbuild.js +0 -17
  15. package/dist/cli/build/fixtures.js +15 -30
  16. package/dist/cli/build/icons.js +0 -3
  17. package/dist/cli/build/index.js +1 -1
  18. package/dist/cli/build/playground.js +4 -8
  19. package/dist/cli/build/sections.js +9 -30
  20. package/dist/cli/build/source.js +52 -27
  21. package/dist/cli/build/static.js +4 -25
  22. package/dist/cli/capture/bundle.js +0 -9
  23. package/dist/cli/capture/capture-browser.js +0 -14
  24. package/dist/cli/capture/capture.js +1 -8
  25. package/dist/cli/check/analyze.js +2 -5
  26. package/dist/cli/check/index.js +1 -1
  27. package/dist/cli/check/line-endings.js +52 -0
  28. package/dist/cli/check/load-workspace.js +3 -8
  29. package/dist/cli/check/portable-names.js +48 -0
  30. package/dist/cli/check/render/class-conflicts.js +0 -5
  31. package/dist/cli/check/render/html.js +0 -1
  32. package/dist/cli/check/render/invariants.js +0 -5
  33. package/dist/cli/check/render/island-frames.js +0 -25
  34. package/dist/cli/check/render/marker-coverage.js +0 -20
  35. package/dist/cli/check/render/nav.js +0 -33
  36. package/dist/cli/check/report.js +0 -3
  37. package/dist/cli/check/stages/bundles.js +1 -9
  38. package/dist/cli/check/stages/composition.js +3 -2
  39. package/dist/cli/check/stages/dependencies.js +7 -38
  40. package/dist/cli/check/stages/fixtures.js +3 -31
  41. package/dist/cli/check/stages/lint.js +2 -2
  42. package/dist/cli/check/stages/logic.js +3 -34
  43. package/dist/cli/check/stages/relations.js +46 -0
  44. package/dist/cli/check/stages/render.js +0 -1
  45. package/dist/cli/check/stages/sections.js +3 -3
  46. package/dist/cli/check/stages/stylesheet.js +1 -1
  47. package/dist/cli/check/stages/typecheck.js +5 -11
  48. package/dist/cli/check/stages/workspace.js +36 -14
  49. package/dist/cli/commands.js +9 -56
  50. package/dist/cli/currency/cache.js +4 -17
  51. package/dist/cli/currency/decide.js +0 -14
  52. package/dist/cli/currency/opt-out.js +0 -7
  53. package/dist/cli/currency/preamble.js +3 -24
  54. package/dist/cli/currency/prompt.js +0 -1
  55. package/dist/cli/currency/refresh.js +5 -12
  56. package/dist/cli/currency/resolve-latest.js +3 -64
  57. package/dist/cli/currency/version-order.js +0 -12
  58. package/dist/cli/dev/crop.js +0 -2
  59. package/dist/cli/dev/http.js +0 -13
  60. package/dist/cli/dev/index.js +3 -4
  61. package/dist/cli/dev/islands.js +25 -70
  62. package/dist/cli/dev/listen.js +26 -0
  63. package/dist/cli/dev/load-template.js +0 -1
  64. package/dist/cli/dev/request-error.js +0 -4
  65. package/dist/cli/dev/server.js +46 -52
  66. package/dist/cli/dev/tsconfig-paths.js +0 -13
  67. package/dist/cli/dev/vite.js +9 -38
  68. package/dist/cli/dev/workspace-reader.js +4 -34
  69. package/dist/cli/media/cache.js +4 -51
  70. package/dist/cli/media/derive.js +2 -94
  71. package/dist/cli/media/deriver-plugin.js +0 -2
  72. package/dist/cli/media/frame-rung-floor.js +0 -6
  73. package/dist/cli/property/index.js +0 -4
  74. package/dist/cli/property/library.js +6 -24
  75. package/dist/cli/publish/client.js +0 -1
  76. package/dist/cli/publish/freshness.js +0 -2
  77. package/dist/cli/publish/git.js +2 -8
  78. package/dist/cli/publish/index.js +8 -15
  79. package/dist/cli/publish/pack.js +5 -6
  80. package/dist/cli/publish/report.js +0 -6
  81. package/dist/cli/publish/target.js +16 -13
  82. package/dist/cli/publish/wire.js +0 -6
  83. package/dist/cli/tar.js +2 -9
  84. package/dist/cli/upgrade/codemod.js +0 -8
  85. package/dist/cli/upgrade/index.js +0 -24
  86. package/dist/cli/upgrade/manifest.js +0 -12
  87. package/dist/cli/upgrade/plan.js +0 -17
  88. package/dist/cli/upgrade/stage.js +12 -15
  89. package/dist/cli/version.js +0 -8
  90. package/dist/cli/workspace.js +2 -34
  91. package/dist/cli.js +4 -21
  92. package/dist/css/compile.js +25 -28
  93. package/dist/css/graph.js +3 -10
  94. package/dist/css/inline.js +3 -13
  95. package/dist/css/rules.js +6 -43
  96. package/dist/design-system/format-variants.js +0 -22
  97. package/dist/eslint/authoring.js +0 -2
  98. package/dist/eslint/correctness.js +0 -7
  99. package/dist/eslint/rules/editor-reason.js +0 -11
  100. package/dist/eslint/rules/island-ids.js +0 -1
  101. package/dist/eslint/rules/jsx-visitor.js +0 -13
  102. package/dist/eslint/rules/no-editor-globals.js +0 -2
  103. package/dist/eslint/rules/no-raw-values.js +0 -1
  104. package/dist/fixtures/brand.js +0 -1
  105. package/dist/fixtures/bundle-rule.js +4 -9
  106. package/dist/fixtures/canonical.d.ts +20 -0
  107. package/dist/fixtures/image-dimensions.js +0 -1
  108. package/dist/fixtures/load.js +8 -17
  109. package/dist/fixtures/media-plugin.js +4 -31
  110. package/dist/fixtures/media.js +0 -21
  111. package/dist/fixtures/package-stylesheets.js +0 -6
  112. package/dist/fixtures/property.js +16 -15
  113. package/dist/fixtures/resolve.js +102 -29
  114. package/dist/fixtures/rows.js +12 -11
  115. package/dist/fixtures/synthesize-empties.js +0 -4
  116. package/dist/fixtures.d.ts +19 -4
  117. package/dist/fixtures.js +0 -18
  118. package/dist/index.d.ts +8 -9
  119. package/dist/index.js +2 -11
  120. package/dist/islands/client-module.js +0 -11
  121. package/dist/islands/marker.js +0 -33
  122. package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +0 -20
  123. package/dist/packages/external/concrete/package.js +1 -1
  124. package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +21 -35
  125. package/dist/packages/internal/fill-bake/dist/compute-reads.js +4 -0
  126. package/dist/packages/internal/fill-bake/dist/derive-source.js +40 -0
  127. package/dist/packages/internal/fill-bake/dist/display.js +0 -1
  128. package/dist/packages/internal/fill-bake/dist/index.js +4 -4
  129. package/dist/packages/internal/fill-vocabulary/dist/origination.js +106 -0
  130. package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -49
  131. package/dist/packages/internal/format-geometry/dist/capture.js +10 -240
  132. package/dist/packages/internal/format-geometry/dist/geometry.js +0 -6
  133. package/dist/packages/internal/image-ladder/dist/crop.js +0 -12
  134. package/dist/packages/internal/image-ladder/dist/policy.js +0 -14
  135. package/dist/packages/internal/island-runtime/dist/capture-holds.js +0 -13
  136. package/dist/packages/internal/island-runtime/dist/contract.js +0 -34
  137. package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +0 -1
  138. package/dist/packages/internal/island-runtime/dist/index.js +0 -34
  139. package/dist/packages/internal/island-runtime/dist/island-id-context.js +0 -1
  140. package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +0 -15
  141. package/dist/packages/internal/island-runtime/dist/use-editor.js +0 -10
  142. package/dist/packages/internal/island-runtime/dist/use-island-id.js +0 -32
  143. package/dist/packages/internal/property-facts/dist/derive-facts-view.js +2 -17
  144. package/dist/packages/internal/property-facts/dist/index.js +1 -1
  145. package/dist/packages/internal/property-facts/dist/{property-facts-CSdkSuD7.js → property-facts-5pxZnlkh.js} +13 -2
  146. package/dist/packages/internal/section-contracts/dist/cap-contract.js +1 -18
  147. package/dist/packages/internal/section-contracts/dist/catalog.js +16 -8
  148. package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +12 -16
  149. package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +5 -11
  150. package/dist/packages/internal/section-contracts/dist/display-contract.js +2 -0
  151. package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +2 -8
  152. package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +13 -0
  153. package/dist/packages/internal/section-contracts/dist/index.js +2 -1
  154. package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +16 -42
  155. package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +24 -43
  156. package/dist/packages/internal/section-contracts/dist/name-title-contract.js +11 -18
  157. package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +10 -12
  158. package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +3 -13
  159. package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +6 -18
  160. package/dist/packages/internal/section-contracts/dist/runners.js +21 -13
  161. package/dist/packages/internal/section-contracts/dist/source-contract.js +13 -2
  162. package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +31 -0
  163. package/dist/packages/internal/source-resolution/dist/index.js +1 -9
  164. package/dist/packages/internal/template-artifact/dist/hash.js +0 -8
  165. package/dist/packages/internal/template-artifact/dist/index.js +1 -1
  166. package/dist/packages/internal/template-artifact/dist/layout.js +0 -39
  167. package/dist/packages/internal/template-artifact/dist/manifest.js +1 -9
  168. package/dist/packages/internal/template-artifact/dist/sha256.js +0 -1
  169. package/dist/packages/internal/template-artifact/dist/verify.js +2 -4
  170. package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -16
  171. package/dist/packages/internal/template-contracts/dist/content-categories.js +0 -4
  172. package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +16 -10
  173. package/dist/packages/internal/template-contracts/dist/facts-view.js +15 -28
  174. package/dist/packages/internal/template-contracts/dist/layout.js +0 -7
  175. package/dist/packages/internal/template-contracts/dist/markers.js +0 -29
  176. package/dist/packages/internal/template-contracts/dist/select-key.js +0 -6
  177. package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +56 -34
  178. package/dist/packages/internal/template-contracts/dist/slot-catalog.js +22 -389
  179. package/dist/platform/file-url.js +8 -0
  180. package/dist/platform/fs.js +73 -0
  181. package/dist/platform/names.js +63 -0
  182. package/dist/platform/order.js +7 -0
  183. package/dist/platform/paths.js +62 -0
  184. package/dist/platform/process.js +97 -0
  185. package/dist/playground/host/page-state.js +0 -2
  186. package/dist/playground/host/paths.js +0 -1
  187. package/dist/playground/layout.js +0 -7
  188. package/dist/playground/wire.js +0 -8
  189. package/dist/primitives/FrameShell.js +0 -18
  190. package/dist/primitives/Image.d.ts +5 -1
  191. package/dist/primitives/Image.js +2 -68
  192. package/dist/primitives/Section.js +0 -13
  193. package/dist/primitives/Tour.js +0 -26
  194. package/dist/primitives/Video.js +0 -32
  195. package/dist/primitives/embed-playback.js +0 -1
  196. package/dist/primitives/marker-attrs.js +0 -17
  197. package/dist/primitives/picture-sources.js +6 -1
  198. package/dist/primitives/probe-context.js +0 -7
  199. package/dist/primitives/slot-bindings.js +0 -46
  200. package/dist/primitives/slot-document.js +0 -11
  201. package/dist/primitives/slot-group.js +0 -9
  202. package/dist/primitives/slot-media.js +0 -27
  203. package/dist/primitives/slot-scalar.js +0 -4
  204. package/dist/primitives/slot.js +0 -6
  205. package/dist/rules/registry.js +42 -24
  206. package/dist/schema/compute.d.ts +46 -8
  207. package/dist/schema/compute.js +21 -15
  208. package/dist/schema/define-schema.d.ts +1 -1
  209. package/dist/schema/define-schema.js +37 -17
  210. package/dist/schema/extract-fill-spec.js +93 -180
  211. package/dist/schema/extract-used-facts.js +16 -158
  212. package/dist/schema/fact.d.ts +25 -12
  213. package/dist/schema/fact.js +7 -11
  214. package/dist/schema/fill-builders.d.ts +91 -366
  215. package/dist/schema/fill-builders.js +21 -259
  216. package/dist/schema/fill-declaration.d.ts +7 -69
  217. package/dist/schema/fill-declaration.js +5 -34
  218. package/dist/schema/fill-spec.js +59 -148
  219. package/dist/schema/format-presets.js +0 -12
  220. package/dist/schema/format.js +0 -7
  221. package/dist/schema/layout.js +0 -10
  222. package/dist/schema/manifest.js +0 -39
  223. package/dist/schema/property-facts.d.ts +20 -0
  224. package/dist/schema/section-nav.js +0 -15
  225. package/dist/schema/section-schema.d.ts +0 -1
  226. package/dist/schema/section-schema.js +4 -20
  227. package/dist/schema/slot-builders.d.ts +128 -117
  228. package/dist/schema/slot-builders.js +18 -201
  229. package/dist/schema/slot-ref.d.ts +63 -0
  230. package/dist/schema/slot-ref.js +33 -0
  231. package/dist/schema/slot-types.d.ts +3 -2
  232. package/dist/schema/slot-types.js +11 -20
  233. package/dist/section/declare.d.ts +14 -10
  234. package/dist/section/declare.js +13 -2
  235. package/dist/section/discovery.js +6 -21
  236. package/dist/section/groups.js +0 -6
  237. package/dist/section/materialize.js +0 -5
  238. package/dist/section/placements.js +0 -4
  239. package/dist/section/section.d.ts +8 -5
  240. package/dist/section/section.js +7 -29
  241. package/dist/styles.css +5 -0
  242. package/dist/template/define-template.d.ts +0 -4
  243. package/dist/template/define-template.js +1 -15
  244. package/dist/template/logic-build.js +8 -35
  245. package/dist/template/logic-shim.d.ts +4 -5
  246. package/dist/template/logic-shim.js +2 -6
  247. package/dist/template/logic-transform.js +0 -6
  248. package/dist/template/materialize.js +52 -43
  249. package/dist/template/mirror-types.js +43 -0
  250. package/dist/template/running-copy.js +5 -20
  251. package/dist/template/section-reads.js +83 -0
  252. package/guide/reference/cli/INDEX.md +12 -6
  253. package/guide/reference/cli/build.md +1 -1
  254. package/guide/reference/cli/check.md +1 -1
  255. package/guide/reference/cli/dev.md +3 -3
  256. package/guide/reference/cli/property-add.md +1 -1
  257. package/guide/reference/cli/property-list.md +1 -1
  258. package/guide/reference/cli/publish.md +4 -2
  259. package/guide/reference/cli/upgrade.md +1 -1
  260. package/guide/reference/rules/INDEX.md +26 -13
  261. package/package.json +4 -2
  262. package/dist/packages/internal/fact-interpolation/dist/index.js +0 -22
  263. package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +0 -170
  264. package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +0 -32
  265. package/dist/packages/internal/fill-vocabulary/dist/facts.js +0 -131
  266. package/dist/packages/internal/template-contracts/dist/slot-overrides.js +0 -11
  267. package/dist/schema/fill-spec.d.ts +0 -18
  268. package/dist/template/reconcile.d.ts +0 -67
  269. package/dist/template/reconcile.js +0 -25
@@ -5,14 +5,12 @@ const LABEL_WIDTH = 9;
5
5
  function stageLine(stage, text) {
6
6
  return `${stage.padEnd(LABEL_WIDTH)}${text}\n`;
7
7
  }
8
- /** The first 12 characters of a content hash, as `concrete build` prints one. */
9
8
  const shortHash = (hash) => hash.slice(0, 12);
10
9
  function formatBytes(bytes) {
11
10
  if (bytes < 1024) return `${String(bytes)} B`;
12
11
  if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
13
12
  return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
14
13
  }
15
- /** `just now`, `4m ago`, `3h ago`, `2 days ago`. */
16
14
  function formatAge(then, now) {
17
15
  const seconds = Math.max(0, Math.round((now.getTime() - then.getTime()) / 1e3));
18
16
  if (seconds < 60) return "just now";
@@ -25,7 +23,6 @@ const plural = (count, one, many) => `${String(count)} ${count === 1 ? one : man
25
23
  function targetText(target) {
26
24
  return `${target.environmentName} · key ${maskToken(target.token)} · ${target.endpoint}${target.overridden ? " (CONCRETE_API_URL)" : ""}`;
27
25
  }
28
- /** The build line before any build runs: what the tree was compared to, and the decision. */
29
26
  function freshnessText(freshness, now) {
30
27
  if (freshness.kind === "reuse") return `tree matches artifact ${shortHash(freshness.manifest.template.content_hash)} (built ${formatAge(freshness.builtAt, now)}), reusing`;
31
28
  const previous = freshness.previous === null ? "" : ` ${shortHash(freshness.previous.template.content_hash)}`;
@@ -50,7 +47,6 @@ function versionsOf(record) {
50
47
  sections: Object.entries(entries).filter(([key]) => key !== record.template_key).map(([, entry]) => entry)
51
48
  };
52
49
  }
53
- /** Whether the write minted nothing and moved nothing: the environment already held this artifact as current. */
54
50
  function isAlreadyCurrent(record) {
55
51
  const { template, sections } = versionsOf(record);
56
52
  return template !== void 0 && template.status === "unchanged" && !template.latest_moved && sections.every((entry) => entry.status === "unchanged" && !entry.latest_moved);
@@ -81,9 +77,7 @@ function summaryText(record) {
81
77
  if (isAlreadyCurrent(record)) return `${record.template_key} is already current.`;
82
78
  return `Published ${record.template_key}.`;
83
79
  }
84
- /** How many of a refusal's problems are listed before the rest are counted. */
85
80
  const PROBLEMS_SHOWN = 20;
86
- /** The refusal's sentence, then each problem the server named, indented. */
87
81
  function refusalText(record) {
88
82
  const refusal = record.refusal;
89
83
  if (refusal === null) return `concrete publish: the publication ended ${record.state} without saying why; run \`concrete publish\` again.\n`;
@@ -4,7 +4,6 @@ import { readFile } from "node:fs/promises";
4
4
  //#region src/cli/publish/target.ts
5
5
  const TOKEN_VARIABLE = "CONCRETE_TOKEN";
6
6
  const API_URL_VARIABLE = "CONCRETE_API_URL";
7
- /** The endpoint each key prefix publishes to. Changing it is a release of this package. */
8
7
  const ENDPOINTS = {
9
8
  prod: "https://api.homepages.io",
10
9
  staging: "https://api.homepages.christmas",
@@ -15,14 +14,8 @@ const ENVIRONMENT_NAMES = {
15
14
  staging: "staging",
16
15
  dev: "dev"
17
16
  };
18
- /** `cpt_<env>_` then a 43-character base62 secret: the shape a key is minted in. */
19
17
  const TOKEN = /^cpt_(prod|staging|dev)_[0-9A-Za-z]{43}$/;
20
- /** A key or endpoint this command cannot use: exit 2, with the sentence to print. */
21
18
  var TargetError = class extends Error {};
22
- /**
23
- * The `KEY=value` pairs of a dotenv file: blank lines and `#` comments skipped, an
24
- * optional `export ` prefix, one layer of matching quotes removed. No interpolation.
25
- */
26
19
  function parseDotenv(text) {
27
20
  const values = /* @__PURE__ */ new Map();
28
21
  for (const raw of text.split(/\r?\n/)) {
@@ -46,19 +39,29 @@ async function readWorkspaceDotenv(root) {
46
39
  throw cause;
47
40
  }
48
41
  }
49
- /** `cpt_prod_…a41c`: enough to tell two keys apart, never enough to use one. */
50
42
  function maskToken(token) {
51
43
  return `${/^cpt_[a-z]+_/.exec(token)?.[0] ?? ""}…${token.slice(-4)}`;
52
44
  }
53
- /** Resolve the target from the process environment, then the workspace `.env`. */
54
- async function resolveTarget(root, env) {
55
- const dotenv = await readWorkspaceDotenv(root);
45
+ async function readNamedDotenv(file) {
46
+ try {
47
+ return parseDotenv(await readFile(file, "utf8"));
48
+ } catch (cause) {
49
+ if (cause.code === "ENOENT") throw new TargetError(`--env-file names ${file}, which does not exist.`);
50
+ throw cause;
51
+ }
52
+ }
53
+ async function resolveTarget(root, env, envFile) {
54
+ const named = envFile === void 0 ? /* @__PURE__ */ new Map() : await readNamedDotenv(envFile);
55
+ const dotenv = envFile === void 0 ? await readWorkspaceDotenv(root) : /* @__PURE__ */ new Map();
56
56
  const read = (name) => {
57
- const value = env[name] ?? dotenv.get(name);
57
+ const value = named.get(name) ?? env[name] ?? dotenv.get(name);
58
58
  return value === void 0 || value.trim() === "" ? void 0 : value.trim();
59
59
  };
60
60
  const token = read(TOKEN_VARIABLE);
61
- if (token === void 0) throw new TargetError(`${TOKEN_VARIABLE} is not set; set it in the environment or in this workspace's .env to the publisher key a HomePages admin issued you.`);
61
+ if (token === void 0) {
62
+ const where = envFile === void 0 ? "in the environment or in this workspace's .env" : `in ${envFile}`;
63
+ throw new TargetError(`${TOKEN_VARIABLE} is not set; set it ${where} to the publisher key a HomePages admin issued you.`);
64
+ }
62
65
  const match = TOKEN.exec(token);
63
66
  if (match === null) throw new TargetError(`${TOKEN_VARIABLE} is not a publisher key (a key reads cpt_prod_…, cpt_staging_… or cpt_dev_… followed by 43 letters and digits); set it to the key a HomePages admin issued you.`);
64
67
  const environment = match[1];
@@ -1,5 +1,4 @@
1
1
  //#region src/cli/publish/wire.ts
2
- /** The states a poll stops at. */
3
2
  const TERMINAL_STATES = [
4
3
  "published",
5
4
  "refused",
@@ -7,11 +6,6 @@ const TERMINAL_STATES = [
7
6
  "dry_run"
8
7
  ];
9
8
  const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
10
- /**
11
- * Whether a body is a publication record, to the depth this command reads one. The
12
- * endpoint's own schema is the contract; this only keeps a proxy's HTML page or an
13
- * unrelated JSON body from being read as one.
14
- */
15
9
  function isPublicationRecord(value) {
16
10
  return isObject(value) && typeof value.id === "string" && typeof value.state === "string" && typeof value.template_key === "string" && isObject(value.publisher) && typeof value.publisher.name === "string";
17
11
  }
package/dist/cli/tar.js CHANGED
@@ -1,9 +1,8 @@
1
- import { posix } from "node:path";
1
+ import { normalizePosix } from "../platform/paths.js";
2
2
  import { gunzipSync } from "node:zlib";
3
3
 
4
4
  //#region src/cli/tar.ts
5
5
  const BLOCK = 512;
6
- /** A NUL-terminated header field. */
7
6
  function field(bytes, offset, length) {
8
7
  const raw = bytes.subarray(offset, offset + length);
9
8
  const end = raw.indexOf(0);
@@ -15,7 +14,6 @@ function octal(header, offset, length) {
15
14
  if (!Number.isSafeInteger(value) || value < 0) throw new Error("the tarball has an entry whose size cannot be read");
16
15
  return value;
17
16
  }
18
- /** A pax extended header's `path` record, if it carries one. Each record is `<len> <key>=<value>\n`. */
19
17
  function paxPath(body) {
20
18
  let found;
21
19
  let offset = 0;
@@ -31,21 +29,16 @@ function paxPath(body) {
31
29
  }
32
30
  return found;
33
31
  }
34
- /** `package/properties/x` → `properties/x`; `null` for the top directory itself. */
35
32
  function withinPackage(path) {
36
33
  const unsafe = () => /* @__PURE__ */ new Error(`the tarball has an entry outside its package directory: ${path}`);
37
34
  if (path.startsWith("/") || path.includes("\\") || /^[A-Za-z]:/.test(path)) throw unsafe();
38
35
  const slash = path.indexOf("/");
39
36
  if (slash === -1) return null;
40
- const relative = posix.normalize(path.slice(slash + 1));
37
+ const relative = normalizePosix(path.slice(slash + 1));
41
38
  if (relative === "." || relative === "") return null;
42
39
  if (relative === ".." || relative.startsWith("../")) throw unsafe();
43
40
  return relative.endsWith("/") ? relative.slice(0, -1) : relative;
44
41
  }
45
- /**
46
- * Every regular file in a gzipped npm tarball, top-level directory stripped, in archive
47
- * order. Throws on anything that is not one: bad gzip, a truncated entry, an escaping path.
48
- */
49
42
  function readTarball(gzipped) {
50
43
  const archive = gunzipSync(gzipped);
51
44
  const files = [];
@@ -12,20 +12,12 @@ const REPORT_SCHEMA = z.object({
12
12
  reason: z.string()
13
13
  }))
14
14
  });
15
- /** `codemods/<slug>.mjs` under a package directory. */
16
15
  function codemodPath(packageDir, slug) {
17
16
  return join(packageDir, CODEMODS_DIR, `${slug}.mjs`);
18
17
  }
19
18
  function messageOf(cause) {
20
19
  return cause instanceof Error ? cause.message : String(cause);
21
20
  }
22
- /**
23
- * Runs the codemod `slug` shipped in `packageDir` over the workspace at `root`.
24
- *
25
- * Throws, with a sentence naming the codemod, when the file is missing, has no function
26
- * as its default export, throws itself, or returns something that is not a report. The
27
- * caller decides what a throw means; nothing here catches one silently.
28
- */
29
21
  async function runCodemod(packageDir, slug, root) {
30
22
  const file = codemodPath(packageDir, slug);
31
23
  try {
@@ -13,15 +13,7 @@ import { readFile, stat, writeFile } from "node:fs/promises";
13
13
  import { parseArgs } from "node:util";
14
14
 
15
15
  //#region src/cli/upgrade/index.ts
16
- /** Every line this command prints names itself — its output interleaves with npm's. */
17
16
  const PREFIX = "concrete upgrade";
18
- /**
19
- * How long reading npm's config may take before the registry answer is unknown. Its own
20
- * deadline, apart from the request's: this is a command the author asked for, not a read
21
- * in front of every command, and on a loaded box spawning npm alone can outlast the whole
22
- * two-second budget — which would turn a plain "not published" into a real install that
23
- * fails in npm's words instead. The request itself still gives up at the usual budget.
24
- */
25
17
  const CONFIG_READ_TIMEOUT_MS = 15e3;
26
18
  const defaultUpgradeEnvironment = {
27
19
  latest: ({ root, env }) => resolveLatest({
@@ -50,13 +42,6 @@ async function isFile(path) {
50
42
  return false;
51
43
  }
52
44
  }
53
- /**
54
- * The version to move to, or the exit code when there is none to act on.
55
- *
56
- * A `--to` the registry does not carry is a refusal BEFORE anything is written. A registry
57
- * that cannot be read at all is not: an author offline for the afternoon has nothing to
58
- * act on, and failing them would only teach them to reach for the kill switch.
59
- */
60
45
  async function resolveTarget(requested, request, environment, io) {
61
46
  if (requested === null) {
62
47
  const latest = await environment.latest(request);
@@ -76,7 +61,6 @@ async function resolveTarget(requested, request, environment, io) {
76
61
  }
77
62
  return { version: requested };
78
63
  }
79
- /** The codemod manifest a package directory carries, or throws naming what is wrong. */
80
64
  async function readManifestIn(packageDir) {
81
65
  let text;
82
66
  try {
@@ -89,7 +73,6 @@ async function readManifestIn(packageDir) {
89
73
  function renderRewrite(rewrite) {
90
74
  return ` ${CONCRETE_PACKAGE} ${rewrite.from} -> ${rewrite.to}\n`;
91
75
  }
92
- /** The plan, one release at a time: its codemods in order, then what it leaves to the author. */
93
76
  function renderPlan(steps) {
94
77
  const lines = [];
95
78
  for (const step of steps) {
@@ -102,11 +85,6 @@ function renderManual(steps) {
102
85
  const manual = steps.flatMap((step) => step.manual.map((m) => ` ${step.version}: ${m}`));
103
86
  return manual.length === 0 ? "" : `\n${PREFIX}: still to do by hand — no codemod could make these changes:\n${manual.join("\n")}\n`;
104
87
  }
105
- /**
106
- * Runs every codemod of every step, in order, reporting each file on stdout. Returns
107
- * `true` when all ran. A throw stops the chain — every later codemod was written against
108
- * the tree this one was meant to leave — and is reported on stderr with what never ran.
109
- */
110
88
  async function runSteps(steps, packageDir, root, io) {
111
89
  const queue = steps.flatMap((step) => step.codemods.map((slug) => ({
112
90
  version: step.version,
@@ -128,13 +106,11 @@ async function runSteps(steps, packageDir, root, io) {
128
106
  }
129
107
  return true;
130
108
  }
131
- /** Orders two versions both already known to parse. */
132
109
  function isAfter(a, b) {
133
110
  const left = parseVersion(a);
134
111
  const right = parseVersion(b);
135
112
  return left !== null && right !== null && compareVersions(left, right) > 0;
136
113
  }
137
- /** The command, over an injected outside world. `runUpgrade` is it over the real one. */
138
114
  function upgradeWith(environment) {
139
115
  return async (argv, io) => {
140
116
  const command = findCommand("upgrade");
@@ -2,9 +2,7 @@ import { compareVersions, parseVersion } from "../currency/version-order.js";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/cli/upgrade/manifest.ts
5
- /** The manifest format this reader understands. A file naming another number is refused. */
6
5
  const MANIFEST_SCHEMA = 1;
7
- /** Where the manifest and the codemods live, relative to the package root. Shipped. */
8
6
  const CODEMODS_DIR = "codemods";
9
7
  const MANIFEST_FILE = "manifest.json";
10
8
  const ENTRY_SCHEMA = z.object({
@@ -23,11 +21,6 @@ function valueAt(root, path) {
23
21
  }
24
22
  return at;
25
23
  }
26
- /**
27
- * Parses the manifest text, refusing with a sentence that names what is wrong. A
28
- * manifest this reader cannot trust is not a manifest with no codemods — acting on
29
- * either as though it were the other would silently skip a migration.
30
- */
31
24
  function parseCodemodManifest(text) {
32
25
  let raw;
33
26
  try {
@@ -47,11 +40,6 @@ function parseCodemodManifest(text) {
47
40
  }
48
41
  return parsed.data;
49
42
  }
50
- /**
51
- * Every release strictly above `installed` and up to and including `target`, in
52
- * ascending version order. Empty when the move is backward or nowhere: a codemod ports
53
- * a workspace forward across the break it shipped with and has no inverse.
54
- */
55
43
  function stepsBetween(manifest, installed, target) {
56
44
  const low = parseVersion(installed);
57
45
  const high = parseVersion(target);
@@ -1,30 +1,13 @@
1
1
  import { CONCRETE_PACKAGE, DEPENDENCY_SECTIONS, isRegistryRange } from "../workspace.js";
2
2
 
3
3
  //#region src/cli/upgrade/plan.ts
4
- /**
5
- * The dependency RANGE to stamp for the package at `version`.
6
- *
7
- * A release gets a caret so a later patch is picked up by the preamble's refresh
8
- * without another upgrade. A prerelease is pinned EXACTLY: a caret over one would let
9
- * npm resolve onto a later prerelease than the one the author asked for. The scaffolder
10
- * stamps a fresh workspace by this same rule, so an upgraded workspace and a newly
11
- * created one on the same version carry the same manifest.
12
- */
13
4
  function rangeFor(version) {
14
5
  return version.includes("-") ? version : `^${version}`;
15
6
  }
16
- /** The indentation the file already uses, so the rewrite is a diff of the range only. */
17
7
  function detectIndent(text) {
18
8
  return /\n([ \t]+)"/.exec(text)?.[1] ?? 2;
19
9
  }
20
10
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
21
- /**
22
- * What moving this workspace to `targetVersion` would rewrite.
23
- *
24
- * Throws when the text is not a JSON object or declares the package in no dependency
25
- * block — the caller found the workspace root BY that declaration, so either is a
26
- * manifest that changed under it, and rewriting half of it would be worse than stopping.
27
- */
28
11
  function planRewrite(manifestText, targetVersion) {
29
12
  let parsed;
30
13
  try {
@@ -1,9 +1,10 @@
1
+ import { spawnNpm } from "../../platform/process.js";
1
2
  import { CONCRETE_PACKAGE } from "../workspace.js";
3
+ import { removeTree } from "../../platform/fs.js";
2
4
  import { readTarball } from "../tar.js";
3
5
  import { CODEMODS_DIR } from "./manifest.js";
4
6
  import { dirname, join } from "node:path";
5
- import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";
6
- import { spawn } from "node:child_process";
7
+ import { mkdir, mkdtemp, readFile, readdir, writeFile } from "node:fs/promises";
7
8
  import { tmpdir } from "node:os";
8
9
 
9
10
  //#region src/cli/upgrade/stage.ts
@@ -11,39 +12,35 @@ function npmPack(version, destination, request) {
11
12
  return new Promise((resolve) => {
12
13
  let child;
13
14
  try {
14
- child = spawn("npm", [
15
+ child = spawnNpm([
15
16
  "pack",
16
17
  `${CONCRETE_PACKAGE}@${version}`,
17
- "--pack-destination",
18
- destination,
19
18
  "--ignore-scripts"
20
19
  ], {
21
20
  cwd: request.root,
22
- env: { ...request.env },
21
+ env: {
22
+ ...request.env,
23
+ npm_config_pack_destination: destination
24
+ },
23
25
  stdio: [
24
26
  "ignore",
25
27
  "pipe",
26
28
  "pipe"
27
- ],
28
- shell: process.platform === "win32"
29
+ ]
29
30
  });
30
31
  } catch (cause) {
31
32
  resolve(cause instanceof Error ? cause.message : String(cause));
32
33
  return;
33
34
  }
34
- child.stdout.pipe(request.sink, { end: false });
35
- child.stderr.pipe(request.sink, { end: false });
35
+ child.stdout?.pipe(request.sink, { end: false });
36
+ child.stderr?.pipe(request.sink, { end: false });
36
37
  child.once("error", (cause) => resolve(cause.message));
37
38
  child.once("close", (code) => resolve(code === 0 ? null : `npm pack exited ${String(code)}`));
38
39
  });
39
40
  }
40
- /** Fetches `@homepages/concrete@<version>` and lays out its manifest and codemods. */
41
41
  async function stageWithNpmPack(version, request) {
42
42
  const scratch = await mkdtemp(join(tmpdir(), "concrete-upgrade-target-"));
43
- const dispose = () => rm(scratch, {
44
- recursive: true,
45
- force: true
46
- });
43
+ const dispose = () => removeTree(scratch);
47
44
  try {
48
45
  const failure = await npmPack(version, scratch, request);
49
46
  if (failure !== null) throw new Error(failure);
@@ -1,14 +1,6 @@
1
1
  import { version } from "../packages/external/concrete/package.js";
2
2
 
3
3
  //#region src/cli/version.ts
4
- /**
5
- * The published version of this package, as the `concrete` command reports it.
6
- *
7
- * Read from package.json and inlined at build time, so it cannot drift: changesets
8
- * owns package.json's version, and a hardcoded constant here would have to be
9
- * hand-edited on every release. `dist/cli.js --version` is asserted against
10
- * package.json to prove the inlining actually happened.
11
- */
12
4
  const CONCRETE_CLI_VERSION = version;
13
5
 
14
6
  //#endregion
@@ -4,19 +4,14 @@ import { readFile, stat } from "node:fs/promises";
4
4
  import { createRequire } from "node:module";
5
5
 
6
6
  //#region src/cli/workspace.ts
7
- /** The package a workspace depends on — the one thing that makes it a workspace. */
8
7
  const CONCRETE_PACKAGE = "@homepages/concrete";
9
- /**
10
- * The blocks npm resolves a version range from. `peerDependencies` is not one of them
11
- * in a template workspace — nothing there declares a peer.
12
- */
13
8
  const DEPENDENCY_SECTIONS = [
14
9
  "dependencies",
15
10
  "devDependencies",
16
11
  "optionalDependencies"
17
12
  ];
13
+ const NON_SOURCE_DIRS = [".concrete", "node_modules"];
18
14
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
19
- /** The range a manifest declares for the package, or `null` when it declares none. */
20
15
  function declaredRange(manifest) {
21
16
  if (!isRecord(manifest)) return null;
22
17
  for (const section of DEPENDENCY_SECTIONS) {
@@ -27,14 +22,6 @@ function declaredRange(manifest) {
27
22
  }
28
23
  return null;
29
24
  }
30
- /**
31
- * Whether a declared range resolves from the registry at all.
32
- *
33
- * `workspace:*`, `file:`, `link:`, a git or tarball URL — every one of these names an
34
- * install the registry knows nothing about, so no published version can be "ahead" of
35
- * it. The internal templates in the framework's own repository ride `workspace:*`,
36
- * and this is what keeps the currency preamble inert for them.
37
- */
38
25
  function isRegistryRange(range) {
39
26
  return !/^[a-z][a-z0-9+.-]*:/i.test(range.trim());
40
27
  }
@@ -54,10 +41,6 @@ async function readManifest(dir) {
54
41
  return;
55
42
  }
56
43
  }
57
- /**
58
- * The nearest ancestor of `from` (inclusive) whose package.json depends on the
59
- * package. Throws, with the fix, when there is none.
60
- */
61
44
  async function findWorkspaceRoot(from) {
62
45
  let dir = resolve(from);
63
46
  for (;;) {
@@ -67,19 +50,9 @@ async function findWorkspaceRoot(from) {
67
50
  dir = parent;
68
51
  }
69
52
  }
70
- /** The range `<root>/package.json` declares for the package, or `null`. Never throws. */
71
53
  async function readDeclaredRange(root) {
72
54
  return declaredRange(await readManifest(root));
73
55
  }
74
- /**
75
- * The directory of the package this workspace's own `node_modules` resolves — resolved
76
- * from `root` rather than from whatever copy the running process's own module graph
77
- * happens to be. Run through `npx` or a global install, that can be a different install
78
- * entirely: the command's own copy, not this workspace's.
79
- *
80
- * `null` when nothing is installed there — the command that needs it owes the author
81
- * that error in its own words.
82
- */
83
56
  function resolveInstalledPackageDir(root) {
84
57
  const require = createRequire(pathToFileURL(join(root, "package.json")));
85
58
  try {
@@ -88,11 +61,6 @@ function resolveInstalledPackageDir(root) {
88
61
  return null;
89
62
  }
90
63
  }
91
- /**
92
- * The version of the package this workspace's own `node_modules` actually resolves,
93
- * read straight off the installed package's manifest (`resolveInstalledPackageDir`).
94
- * `null` when nothing is installed there, or its manifest names no version.
95
- */
96
64
  async function resolveInstalledVersion(root) {
97
65
  const dir = resolveInstalledPackageDir(root);
98
66
  if (dir === null) return null;
@@ -105,4 +73,4 @@ async function resolveInstalledVersion(root) {
105
73
  }
106
74
 
107
75
  //#endregion
108
- export { CONCRETE_PACKAGE, DEPENDENCY_SECTIONS, declaredRange, findWorkspaceRoot, isRegistryRange, readDeclaredRange, resolveInstalledPackageDir, resolveInstalledVersion };
76
+ export { CONCRETE_PACKAGE, DEPENDENCY_SECTIONS, NON_SOURCE_DIRS, declaredRange, findWorkspaceRoot, isRegistryRange, readDeclaredRange, resolveInstalledPackageDir, resolveInstalledVersion };
package/dist/cli.js CHANGED
@@ -1,18 +1,11 @@
1
1
  #!/usr/bin/env node
2
+ import { resolveRoot } from "./platform/paths.js";
3
+ import { invokedAsBin } from "./platform/process.js";
2
4
  import { COMMANDS, globalFlagSpellings, groupMembers, renderUsage, runsCurrencyPreamble, withoutNoAutoUpdateFlag } from "./cli/commands.js";
3
5
  import { CONCRETE_CLI_VERSION } from "./cli/version.js";
4
- import { realpathSync } from "node:fs";
5
- import { fileURLToPath } from "node:url";
6
6
 
7
7
  //#region src/cli/index.ts
8
8
  const USAGE = renderUsage(`concrete ${CONCRETE_CLI_VERSION}`);
9
- /**
10
- * Refresh the workspace's `@homepages/concrete` when it is behind the published
11
- * release, before the command's own module is imported.
12
- *
13
- * The whole call is guarded because a preamble may never fail the command it precedes —
14
- * an unreadable workspace or an unreachable registry costs the author nothing.
15
- */
16
9
  async function refreshWorkspaceFirst(argv, io) {
17
10
  try {
18
11
  const { enforceCurrency } = await import("./cli/currency/preamble.js");
@@ -26,7 +19,6 @@ async function refreshWorkspaceFirst(argv, io) {
26
19
  });
27
20
  } catch {}
28
21
  }
29
- /** Import one command's module and run it; a throw from either is the command's exit 1. */
30
22
  async function dispatch(name, load, argv, io) {
31
23
  try {
32
24
  return await (await load())(argv, io);
@@ -73,17 +65,8 @@ async function main(argv, io) {
73
65
  io.stderr.write(`concrete: '${cmd}' is declared but has no dispatch branch.\n`);
74
66
  return 1;
75
67
  }
76
- function invokedAsBin() {
77
- const argv1 = process.argv[1];
78
- if (argv1 === void 0) return false;
79
- try {
80
- return realpathSync(argv1) === realpathSync(fileURLToPath(import.meta.url));
81
- } catch {
82
- return false;
83
- }
84
- }
85
- if (invokedAsBin()) process.exitCode = await main(process.argv.slice(2), {
86
- cwd: process.cwd(),
68
+ if (invokedAsBin(import.meta.url)) process.exitCode = await main(process.argv.slice(2), {
69
+ cwd: resolveRoot(process.cwd()),
87
70
  env: process.env,
88
71
  stdout: process.stdout,
89
72
  stderr: process.stderr,
@@ -1,32 +1,22 @@
1
+ import { workspacePath } from "../platform/paths.js";
2
+ import { NON_SOURCE_DIRS } from "../cli/workspace.js";
1
3
  import { compileFormatVariantsToCss } from "../design-system/format-variants.js";
2
4
  import { collectCssGraph } from "./graph.js";
3
5
  import { inlineCssGraph } from "./inline.js";
4
6
  import { externalUrlViolations, retiredLayerViolations, tailwindImportViolations } from "./rules.js";
5
7
  import { readFileSync } from "node:fs";
6
- import { dirname, join } from "node:path";
8
+ import { dirname, isAbsolute, join } from "node:path";
7
9
  import { createHash } from "node:crypto";
8
10
  import { createRequire } from "node:module";
9
11
  import { compile, optimize } from "@tailwindcss/node";
10
12
  import { Scanner } from "@tailwindcss/oxide";
11
13
 
12
14
  //#region src/css/compile.ts
13
- /**
14
- * The Tailwind entry: the inlined graph, then — for a rendered template — one
15
- * `@custom-variant` per declared format id, so `deck-16x9:p-8` compiles. Tailwind drops
16
- * a utility with an unknown variant silently, which is why the block is derived here
17
- * rather than left to the author. A website's entry is the inlined graph unchanged.
18
- */
19
15
  function buildTailwindEntry(inlinedCss, template) {
20
16
  if (template.output === "website") return inlinedCss;
21
17
  return `${inlinedCss.trimEnd()}\n\n${compileFormatVariantsToCss(template.formats)}`;
22
18
  }
23
19
  const TAILWIND_PACKAGE = "tailwindcss";
24
- /**
25
- * The framework's own file for a `tailwindcss` stylesheet import — `tailwindcss` or a
26
- * subpath such as `tailwindcss/theme.css` — read from the package's `style` export.
27
- * Undefined for any other specifier, and for a subpath the package does not export as
28
- * a stylesheet, which Tailwind's own resolver then reports.
29
- */
30
20
  function resolveFrameworkTailwindCss(id) {
31
21
  if (id !== TAILWIND_PACKAGE && !id.startsWith(`${TAILWIND_PACKAGE}/`)) return void 0;
32
22
  const manifest = createRequire(import.meta.url).resolve(`${TAILWIND_PACKAGE}/package.json`);
@@ -35,27 +25,34 @@ function resolveFrameworkTailwindCss(id) {
35
25
  const file = typeof entry === "string" ? entry : entry?.style;
36
26
  return file === void 0 ? void 0 : join(dirname(manifest), file);
37
27
  }
38
- async function compileTailwind(root, entry) {
28
+ function excludedSources(root, exclude) {
29
+ const dirs = [...NON_SOURCE_DIRS, ...exclude.map((dir) => workspacePath(root, dir))];
30
+ return [...new Set(dirs)].filter((dir) => dir !== "" && dir !== ".." && !dir.startsWith("../") && !isAbsolute(dir)).map((dir) => ({
31
+ base: root,
32
+ pattern: `${dir}/**`,
33
+ negated: true
34
+ }));
35
+ }
36
+ async function compileTailwind(root, entry, exclude) {
39
37
  const compiler = await compile(entry, {
40
38
  base: root,
41
39
  onDependency: () => {},
42
40
  customCssResolver: (id) => Promise.resolve(resolveFrameworkTailwindCss(id))
43
41
  });
44
- const scanner = new Scanner({ sources: [...compiler.root === "none" ? [] : compiler.root === null ? [{
45
- base: root,
46
- pattern: "**/*",
47
- negated: false
48
- }] : [{
49
- ...compiler.root,
50
- negated: false
51
- }], ...compiler.sources] });
42
+ const scanner = new Scanner({ sources: [
43
+ ...compiler.root === "none" ? [] : compiler.root === null ? [{
44
+ base: root,
45
+ pattern: "**/*",
46
+ negated: false
47
+ }] : [{
48
+ ...compiler.root,
49
+ negated: false
50
+ }],
51
+ ...excludedSources(root, exclude),
52
+ ...compiler.sources
53
+ ] });
52
54
  return optimize(compiler.build(scanner.scan()), { minify: true }).code;
53
55
  }
54
- /**
55
- * Compile a workspace's `template_css`. Violations are `css/tailwind-import` and, for a
56
- * rendered template, `css/external-url`. Throws when a module or a local `@import` or
57
- * `url()` in the graph fails to resolve, with esbuild's message.
58
- */
59
56
  async function compileTemplateCss(input) {
60
57
  const graph = await collectCssGraph({
61
58
  root: input.root,
@@ -71,7 +68,7 @@ async function compileTemplateCss(input) {
71
68
  bundle: null,
72
69
  violations: importViolations
73
70
  };
74
- const css = await compileTailwind(input.root, buildTailwindEntry(inlined.css, input.template));
71
+ const css = await compileTailwind(input.root, buildTailwindEntry(inlined.css, input.template), input.exclude ?? []);
75
72
  const violations = [...await retiredLayerViolations({
76
73
  root: input.root,
77
74
  sources: graph
package/dist/css/graph.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { externalSpecifier, toPosix } from "../platform/paths.js";
1
2
  import { relative } from "node:path";
2
3
  import { build } from "esbuild";
3
4
 
@@ -36,10 +37,7 @@ function graphPlugin() {
36
37
  setup(api) {
37
38
  api.onResolve({ filter: INTERCEPTED_FILTER }, async (args) => {
38
39
  if (args.kind === "entry-point" || isOwnResolve(args.pluginData)) return void 0;
39
- if (UNFOLLOWED_RE.test(args.path)) return {
40
- path: args.path,
41
- external: true
42
- };
40
+ if (UNFOLLOWED_RE.test(args.path)) return externalSpecifier(args.path);
43
41
  const resolved = await api.resolve(args.path, {
44
42
  kind: args.kind,
45
43
  importer: args.importer,
@@ -82,11 +80,6 @@ function stylesheetsInImportOrder(metafile, entryKey) {
82
80
  visit(entryKey);
83
81
  return order;
84
82
  }
85
- /**
86
- * Every `.css` file reachable by import from `template.ts`, as absolute paths, in import
87
- * order, each once (at its first reach). Throws with esbuild's own message when a module
88
- * in the graph fails to resolve or parse — the renderer bundle would fail on the same.
89
- */
90
83
  async function collectCssGraph(input) {
91
84
  const result = await build({
92
85
  entryPoints: [input.templateFile],
@@ -102,7 +95,7 @@ async function collectCssGraph(input) {
102
95
  plugins: [graphPlugin()],
103
96
  logLevel: "silent"
104
97
  });
105
- const entryKey = relative(input.root, input.templateFile).split("\\").join("/");
98
+ const entryKey = toPosix(relative(input.root, input.templateFile));
106
99
  return stylesheetsInImportOrder(result.metafile, entryKey);
107
100
  }
108
101