@astryxdesign/cli 0.7.2-canary.6d4f178 → 0.7.2-canary.72db6f9

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 (276) hide show
  1. package/README.md +74 -73
  2. package/api/build/help/help.mjs +1 -1
  3. package/api/component/_adapter.d.mts +31 -0
  4. package/api/component/_adapter.mjs +116 -0
  5. package/api/component/component.mjs +60 -10
  6. package/api/component/doc-links.test.mjs +386 -0
  7. package/api/discover/_adapter.d.mts +119 -12
  8. package/api/discover/_adapter.mjs +449 -10
  9. package/api/discover/_adapter.test.mjs +599 -17
  10. package/api/discover/_catalog-view.d.mts +16 -5
  11. package/api/discover/_catalog-view.mjs +32 -8
  12. package/api/discover/detail/doc/doc.mjs +9 -1
  13. package/api/discover/discover.d.mts +11 -0
  14. package/api/discover/discover.doc.mjs +7 -6
  15. package/api/discover/discover.mjs +107 -19
  16. package/api/discover/discover.type.d.mts +18 -7
  17. package/api/discover/discover.type.mjs +15 -7
  18. package/api/discover/list/list.d.mts +4 -3
  19. package/api/discover/list/list.mjs +17 -10
  20. package/api/docs/_adapter.d.mts +74 -0
  21. package/api/docs/_adapter.mjs +550 -14
  22. package/api/docs/integration-tree.test.mjs +22 -0
  23. package/api/docs/integrationDocs.test.mjs +124 -0
  24. package/api/docs/list/list.mjs +12 -2
  25. package/api/doctor/doctor.mjs +27 -3
  26. package/api/doctor/doctor.test.mjs +43 -0
  27. package/api/doctor/theme-checks.mjs +1 -1
  28. package/api/doctor/theme-checks.test.mjs +136 -0
  29. package/api/gap-report/gap-report.d.mts +3 -0
  30. package/api/gap-report/gap-report.doc.mjs +11 -3
  31. package/api/gap-report/gap-report.mjs +152 -48
  32. package/api/gap-report/gap-report.test.mjs +233 -0
  33. package/api/gap-report/gap-report.type.d.mts +41 -0
  34. package/api/gap-report/gap-report.type.mjs +18 -0
  35. package/api/index.d.mts +2 -0
  36. package/api/index.mjs +2 -0
  37. package/api/init/run/run.mjs +2 -2
  38. package/api/integration/_adapter.d.mts +45 -0
  39. package/api/integration/_adapter.mjs +112 -0
  40. package/api/integration/add-contribution.mjs +1 -1
  41. package/api/integration/add-contribution.test.mjs +4 -2
  42. package/api/integration/authoring-checks.mjs +108 -4
  43. package/api/integration/authoring-checks.test.mjs +808 -0
  44. package/api/integration/authoring-checks.type.d.mts +143 -0
  45. package/api/integration/authoring-checks.type.mjs +74 -2
  46. package/api/integration/check/check.d.mts +96 -0
  47. package/api/integration/check/check.mjs +357 -0
  48. package/api/integration/check/check.test.mjs +489 -0
  49. package/api/integration/integration-check.type.d.mts +118 -0
  50. package/api/integration/integration-check.type.mjs +84 -0
  51. package/api/integration/integrationCheck.doc.d.mts +10 -0
  52. package/api/integration/integrationCheck.doc.mjs +73 -0
  53. package/api/integration/integrationComponentConflicts.doc.mjs +45 -6
  54. package/api/integration/integrationDocConflicts.doc.mjs +22 -5
  55. package/api/integration/pack-check.mjs +296 -7
  56. package/api/integration/pack-check.test.mjs +367 -0
  57. package/api/integration/validate-integration-fixes.test.mjs +67 -0
  58. package/api/integration/validate-integration.mjs +36 -3
  59. package/api/integration/validate-integration.test.mjs +88 -8
  60. package/api/integration/validate-integration.type.d.mts +8 -0
  61. package/api/integration/validate-integration.type.mjs +12 -1
  62. package/api/integration/validateIntegration.doc.mjs +19 -3
  63. package/api/search/search.d.mts +72 -12
  64. package/api/search/search.domain-priority.test.mjs +108 -18
  65. package/api/search/search.integration-check.test.mjs +24 -0
  66. package/api/search/search.mjs +503 -38
  67. package/api/search/search.test.mjs +139 -0
  68. package/api/theme/build/build.family.test.mjs +54 -6
  69. package/api/theme/build/build.mjs +114 -17
  70. package/api/theme/themeBuild.doc.mjs +4 -4
  71. package/api/upgrade/_adapter.d.mts +40 -2
  72. package/api/upgrade/_adapter.mjs +117 -4
  73. package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
  74. package/api/upgrade/run/run.mjs +30 -1
  75. package/api/upgrade/status/status.d.mts +21 -5
  76. package/api/upgrade/status/status.mjs +45 -8
  77. package/api/upgrade/upgrade.doc.mjs +5 -3
  78. package/api/upgrade/upgrade.type.d.mts +23 -0
  79. package/api/upgrade/upgrade.type.mjs +16 -1
  80. package/assets/codemods/runner.mjs +7 -1
  81. package/assets/discover/official-packages.json +367 -0
  82. package/assets/docs/README.md +10 -0
  83. package/assets/docs/author-a-theme.doc.mjs +3 -3
  84. package/assets/docs/browser-support.doc.mjs +1 -1
  85. package/assets/docs/getting-started.doc.mjs +3 -3
  86. package/assets/docs/styling-overview.doc.mjs +1 -1
  87. package/assets/docs/theme.doc.dense.mjs +1 -1
  88. package/assets/docs/theme.doc.mjs +2 -2
  89. package/assets/docs/theme.doc.zh.mjs +1 -1
  90. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  91. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  92. package/assets/docs/tree/add-a-topic.doc.mjs +11 -8
  93. package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
  94. package/assets/docs/tree/block-template.doc.mjs +8 -20
  95. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  96. package/assets/docs/tree/check-the-props.doc.mjs +201 -0
  97. package/assets/docs/tree/check-your-docs.doc.mjs +65 -7
  98. package/assets/docs/tree/checks.doc.mjs +25 -17
  99. package/assets/docs/tree/codemods.doc.mjs +4 -4
  100. package/assets/docs/tree/component-family.doc.mjs +3 -5
  101. package/assets/docs/tree/component-imports.doc.mjs +2 -2
  102. package/assets/docs/tree/components.doc.mjs +1 -1
  103. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +30 -21
  104. package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
  105. package/assets/docs/tree/describe-the-component.doc.mjs +2 -2
  106. package/assets/docs/tree/docs.doc.mjs +3 -3
  107. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  108. package/assets/docs/tree/document-the-theme.doc.mjs +3 -3
  109. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  110. package/assets/docs/tree/extend-or-replace.doc.mjs +6 -6
  111. package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
  112. package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
  113. package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
  114. package/assets/docs/tree/integrations.doc.mjs +8 -0
  115. package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
  116. package/assets/docs/tree/layout.doc.mjs +6 -6
  117. package/assets/docs/tree/links.doc.mjs +6 -5
  118. package/assets/docs/tree/migration-setup.doc.mjs +3 -2
  119. package/assets/docs/tree/migration-verification.doc.mjs +0 -1
  120. package/assets/docs/tree/migration.doc.mjs +0 -1
  121. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  122. package/assets/docs/tree/page-template.doc.mjs +4 -8
  123. package/assets/docs/tree/publishing.doc.mjs +4 -4
  124. package/assets/docs/tree/quick-start.doc.mjs +38 -22
  125. package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
  126. package/assets/docs/tree/replace-a-core-template.doc.mjs +6 -8
  127. package/assets/docs/tree/sections-and-placement.doc.mjs +6 -8
  128. package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
  129. package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
  130. package/assets/docs/tree/single-component.doc.mjs +14 -5
  131. package/assets/docs/tree/start-a-template.doc.mjs +3 -3
  132. package/assets/docs/tree/subcomponent.doc.mjs +6 -6
  133. package/assets/docs/tree/template-assets.doc.mjs +2 -2
  134. package/assets/docs/tree/template-doc-overview.doc.mjs +5 -16
  135. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  136. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  137. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  138. package/assets/docs/tree/template-styles.doc.mjs +2 -2
  139. package/assets/docs/tree/templates.doc.mjs +1 -1
  140. package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
  141. package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
  142. package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
  143. package/assets/docs/tree/troubleshooting.doc.mjs +8 -8
  144. package/assets/docs/tree/type-scale.doc.mjs +3 -3
  145. package/assets/docs/tree/upgrading.doc.mjs +4 -4
  146. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
  147. package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
  148. package/assets/docs/tree/versioning.doc.mjs +6 -6
  149. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -3
  150. package/assets/docs/use-a-theme.doc.mjs +2 -2
  151. package/assets/theme.template.ts +1 -1
  152. package/authoring/codemod/codemod.doc.mjs +7 -3
  153. package/authoring/config/config.doc.mjs +9 -6
  154. package/authoring/config/type.ts +4 -2
  155. package/authoring/discover/discover.doc.mjs +1 -1
  156. package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
  157. package/authoring/doctypes/command/command.doc.mjs +14 -12
  158. package/authoring/doctypes/component/component.doc.mjs +29 -26
  159. package/authoring/doctypes/component/type.ts +15 -5
  160. package/authoring/doctypes/enum/enum.doc.mjs +7 -4
  161. package/authoring/doctypes/function/function.doc.mjs +9 -8
  162. package/authoring/doctypes/hook/hook.doc.mjs +5 -4
  163. package/authoring/doctypes/hook/type.ts +4 -0
  164. package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
  165. package/authoring/doctypes/reference/reference.doc.mjs +11 -10
  166. package/authoring/doctypes/schema/schema.doc.mjs +9 -9
  167. package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
  168. package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
  169. package/authoring/doctypes/template/parse.d.mts +6 -2
  170. package/authoring/doctypes/template/parse.mjs +3 -1
  171. package/authoring/doctypes/template/template.doc.mjs +3 -3
  172. package/authoring/doctypes/template/type.ts +22 -0
  173. package/authoring/doctypes/theme/theme.doc.mjs +2 -2
  174. package/authoring/gap-report/gap-report.doc.mjs +2 -2
  175. package/authoring/identity/identity.doc.mjs +3 -3
  176. package/authoring/index.d.ts +1 -0
  177. package/authoring/integration/integration.doc.mjs +12 -4
  178. package/authoring/integration/parse.test.mjs +10 -0
  179. package/authoring/integration/schema.d.mts +2 -0
  180. package/authoring/integration/schema.mjs +1 -0
  181. package/authoring/integration/type.ts +4 -0
  182. package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
  183. package/clients/cli/commands/build-theme.mjs +1 -1
  184. package/clients/cli/commands/build-theme.path-safety.test.mjs +155 -21
  185. package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
  186. package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
  187. package/clients/cli/commands/discover.doc.mjs +1 -1
  188. package/clients/cli/commands/discover.mjs +144 -93
  189. package/clients/cli/commands/discover.no-source.test.mjs +447 -33
  190. package/clients/cli/commands/discover.sources.test.mjs +20 -1
  191. package/clients/cli/commands/doctor-integration-components.doc.mjs +18 -4
  192. package/clients/cli/commands/doctor-integration-docs.doc.mjs +19 -5
  193. package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
  194. package/clients/cli/commands/doctor-integration.test.mjs +884 -0
  195. package/clients/cli/commands/doctor.mjs +281 -5
  196. package/clients/cli/commands/gap-report.doc.mjs +14 -2
  197. package/clients/cli/commands/gap-report.mjs +24 -2
  198. package/clients/cli/commands/gap-report.test.mjs +79 -0
  199. package/clients/cli/commands/integration-authoring.test.mjs +46 -0
  200. package/clients/cli/commands/integration-check.doc.mjs +85 -0
  201. package/clients/cli/commands/integration-check.test.mjs +411 -0
  202. package/clients/cli/commands/integration.doc.mjs +6 -2
  203. package/clients/cli/commands/integration.mjs +116 -5
  204. package/clients/cli/commands/json-contract.test.mjs +5 -1
  205. package/clients/cli/commands/setup-nudge.test.mjs +79 -1
  206. package/clients/cli/commands/swizzle.mjs +5 -3
  207. package/clients/cli/commands/swizzle.routing.test.mjs +18 -1
  208. package/clients/cli/commands/text-json-parity.test.mjs +5 -0
  209. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  210. package/clients/cli/commands/upgrade.doc.mjs +14 -0
  211. package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
  212. package/clients/cli/index.mjs +30 -5
  213. package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
  214. package/foundation/agent-docs/agent-doc-state.mjs +38 -0
  215. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  216. package/foundation/agent-docs/agent-docs.mjs +8 -6
  217. package/foundation/config/project.mjs +82 -0
  218. package/foundation/discovery/authoring-self-docs.mjs +2 -1
  219. package/foundation/discovery/component-discovery.d.mts +18 -0
  220. package/foundation/discovery/component-discovery.mjs +2 -2
  221. package/foundation/discovery/copied-passages.d.mts +216 -0
  222. package/foundation/discovery/copied-passages.mjs +720 -0
  223. package/foundation/discovery/copied-passages.test.mjs +124 -0
  224. package/foundation/discovery/doc-consistency.d.mts +34 -0
  225. package/foundation/discovery/doc-consistency.mjs +513 -0
  226. package/foundation/discovery/doc-consistency.test.mjs +347 -0
  227. package/foundation/discovery/doc-fluff.d.mts +112 -0
  228. package/foundation/discovery/doc-fluff.mjs +328 -0
  229. package/foundation/discovery/doc-fluff.test.mjs +142 -0
  230. package/foundation/discovery/doc-types.d.mts +157 -0
  231. package/foundation/discovery/doc-types.mjs +1231 -0
  232. package/foundation/discovery/doc-types.test.mjs +744 -0
  233. package/foundation/discovery/docs-discovery.d.mts +88 -0
  234. package/foundation/discovery/docs-discovery.mjs +83 -2
  235. package/foundation/discovery/integration-doc-files.d.mts +22 -0
  236. package/foundation/discovery/integration-doc-files.mjs +231 -0
  237. package/foundation/discovery/integration-doc-files.test.mjs +246 -0
  238. package/foundation/discovery/package-tsconfig.d.mts +14 -0
  239. package/foundation/discovery/package-tsconfig.mjs +228 -0
  240. package/foundation/discovery/package-tsconfig.test.mjs +210 -0
  241. package/foundation/discovery/project-typescript.d.mts +32 -0
  242. package/foundation/discovery/project-typescript.mjs +89 -0
  243. package/foundation/discovery/prop-drift.d.mts +297 -0
  244. package/foundation/discovery/prop-drift.mjs +2428 -0
  245. package/foundation/discovery/prop-drift.test.mjs +2337 -0
  246. package/foundation/discovery/stray-pointers.d.mts +52 -0
  247. package/foundation/discovery/stray-pointers.mjs +293 -0
  248. package/foundation/discovery/stray-pointers.test.mjs +86 -0
  249. package/foundation/discovery/type-match.d.mts +53 -0
  250. package/foundation/discovery/type-match.mjs +660 -0
  251. package/foundation/discovery/type-match.test.mjs +169 -0
  252. package/foundation/discovery/type-text.d.mts +68 -0
  253. package/foundation/discovery/type-text.mjs +658 -0
  254. package/foundation/discovery/type-text.test.mjs +196 -0
  255. package/foundation/discovery/unresolved-references.d.mts +62 -0
  256. package/foundation/discovery/unresolved-references.mjs +790 -0
  257. package/foundation/discovery/unresolved-references.test.mjs +567 -0
  258. package/foundation/doc-compiler/doc-loads.test.mjs +26 -0
  259. package/foundation/doc-compiler/links.d.mts +41 -5
  260. package/foundation/doc-compiler/links.mjs +167 -28
  261. package/foundation/doc-compiler/links.test.mjs +97 -4
  262. package/foundation/doc-compiler/tree.mjs +30 -1
  263. package/foundation/doc-compiler/tree.test.mjs +7 -0
  264. package/foundation/env/package-manager.d.mts +32 -0
  265. package/foundation/env/package-manager.mjs +47 -0
  266. package/foundation/env/package-manager.test.mjs +194 -7
  267. package/foundation/fs/module-loader.d.mts +2 -1
  268. package/foundation/fs/module-loader.mjs +60 -4
  269. package/foundation/fs/module-loader.test.mjs +194 -0
  270. package/foundation/integrations/contribution-inventory.d.mts +11 -0
  271. package/foundation/integrations/contribution-inventory.mjs +50 -2
  272. package/foundation/integrations/issue.ts +6 -0
  273. package/foundation/integrations/validate-contributions.mjs +30 -1
  274. package/foundation/response/response-types.doc.mjs +15 -9
  275. package/package.json +11 -11
  276. package/scripts/postinstall.mjs +3 -3
@@ -213,6 +213,7 @@ function writePackage({
213
213
  themeExports = false,
214
214
  npmignore,
215
215
  components = false,
216
+ templates = false,
216
217
  scripts,
217
218
  } = {}) {
218
219
  const pkg = {name, version};
@@ -272,6 +273,14 @@ export default {type: 'theme', name: 'ocean', displayName: 'Ocean', description:
272
273
  'export default function Card() { return null; }\n',
273
274
  );
274
275
  }
276
+ if (templates) {
277
+ const root = path.join(tmpDir, 'templates');
278
+ fs.mkdirSync(root, {recursive: true});
279
+ fs.writeFileSync(
280
+ path.join(root, 'stray.tsx'),
281
+ 'export default function Stray() { return null; }\n',
282
+ );
283
+ }
275
284
  if (npmignore) {
276
285
  fs.writeFileSync(path.join(tmpDir, '.npmignore'), npmignore);
277
286
  }
@@ -303,6 +312,347 @@ function runCliVerify() {
303
312
  };
304
313
  }
305
314
 
315
+ /**
316
+ * Give the built ocean theme a font stylesheet and an entry module that loads
317
+ * the theme's own styles, and export them the way such a package does.
318
+ * @param {string} entry
319
+ * @param {string} [file] the entry's file name in `entries/`
320
+ */
321
+ function writeOwnStylesEntry(entry, file = 'ocean.mjs') {
322
+ fs.writeFileSync(
323
+ path.join(tmpDir, 'themes', 'ocean', 'ocean.fonts.css'),
324
+ "@font-face { font-family: 'Ocean Sans'; src: local('Ocean Sans'); }\n",
325
+ );
326
+ fs.mkdirSync(path.join(tmpDir, 'entries'), {recursive: true});
327
+ fs.writeFileSync(path.join(tmpDir, 'entries', file), entry);
328
+ const packageFile = path.join(tmpDir, 'package.json');
329
+ const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf-8'));
330
+ pkg.files = ['astryx.integration.mjs', 'themes', 'entries'];
331
+ pkg.exports = {
332
+ './themes/ocean': `./entries/${file}`,
333
+ './themes/ocean.css': './themes/ocean/ocean.css',
334
+ './themes/ocean.fonts.css': './themes/ocean/ocean.fonts.css',
335
+ };
336
+ fs.writeFileSync(packageFile, `${JSON.stringify(pkg, null, 2)}\n`);
337
+ }
338
+
339
+ /**
340
+ * Rename the ocean theme to deep-sea, keeping its `ocean` slug, and build it,
341
+ * so its outputs are named after the theme: `deep-sea.css` and `deep-sea.js`,
342
+ * which exports `deepSeaTheme`.
343
+ */
344
+ function writeRenamedOcean() {
345
+ writePackage({files: ['astryx.integration.mjs', 'themes', 'entries']});
346
+ fs.writeFileSync(
347
+ path.join(tmpDir, 'themes', 'ocean', 'oceanTheme.ts'),
348
+ "import {defineTheme} from '@astryxdesign/core/theme';\n\nexport const oceanTheme = defineTheme({name: 'deep-sea'});\n",
349
+ );
350
+ const built = spawnSync(
351
+ process.execPath,
352
+ [
353
+ path.join(process.cwd(), 'packages/cli/clients/cli/bin/astryx.mjs'),
354
+ 'theme',
355
+ 'build',
356
+ 'themes/ocean/oceanTheme.ts',
357
+ ],
358
+ {cwd: tmpDir, encoding: 'utf-8', timeout: 30_000},
359
+ );
360
+ if (built.status !== 0) {
361
+ throw new Error(`Could not build the theme fixture: ${built.stderr}`);
362
+ }
363
+ }
364
+
365
+ /**
366
+ * Give the ocean theme an icon registry and build it, so its built module
367
+ * also exports `oceanIcons`.
368
+ */
369
+ function writeOceanWithIcons() {
370
+ writePackage({files: ['astryx.integration.mjs', 'themes', 'entries']});
371
+ const themeDir = path.join(tmpDir, 'themes', 'ocean');
372
+ fs.writeFileSync(
373
+ path.join(themeDir, 'icons.js'),
374
+ 'export const oceanIcons = {};\n',
375
+ );
376
+ fs.writeFileSync(
377
+ path.join(themeDir, 'oceanTheme.ts'),
378
+ "import {defineTheme} from '@astryxdesign/core/theme';\nimport {oceanIcons} from './icons';\n\nexport const oceanTheme = defineTheme({name: 'ocean', icons: oceanIcons});\n",
379
+ );
380
+ const built = spawnSync(
381
+ process.execPath,
382
+ [
383
+ path.join(process.cwd(), 'packages/cli/clients/cli/bin/astryx.mjs'),
384
+ 'theme',
385
+ 'build',
386
+ 'themes/ocean/oceanTheme.ts',
387
+ ],
388
+ {cwd: tmpDir, encoding: 'utf-8', timeout: 30_000},
389
+ );
390
+ if (built.status !== 0) {
391
+ throw new Error(`Could not build the theme fixture: ${built.stderr}`);
392
+ }
393
+ }
394
+
395
+ // An entry like one whose import is the whole integration: it loads the
396
+ // theme's fonts and stylesheet, by relative path and through the package's
397
+ // own exports, and re-exports the built theme.
398
+ const OWN_STYLES_ENTRY = `// Copyright (c) Acme.
399
+
400
+ import '../themes/ocean/ocean.fonts.css';
401
+ import '@acme/widgets/themes/ocean.css';
402
+
403
+ export {oceanTheme} from '../themes/ocean/ocean.js';
404
+ `;
405
+
406
+ describe('a theme module that loads its own styles', () => {
407
+ it('passes an entry that imports the theme stylesheet and fonts and re-exports the built module', async () => {
408
+ writePackage({themeExports: true});
409
+ writeOwnStylesEntry(OWN_STYLES_ENTRY);
410
+
411
+ const result = await integrationPackCheck({cwd: tmpDir});
412
+
413
+ expect(result.data.issues).toEqual([]);
414
+ expect(result.data.packable).toBe(true);
415
+ const cli = runCliVerify();
416
+ expect(cli.status, cli.stderr).toBe(0);
417
+ expect(cli.receipt?.data.issues).toEqual([]);
418
+ });
419
+
420
+ it('passes an entry that imports its fonts through the package exports and re-exports everything', async () => {
421
+ writePackage({themeExports: true});
422
+ writeOwnStylesEntry(
423
+ "import '@acme/widgets/themes/ocean.fonts.css';\nimport '../themes/ocean/ocean.css';\nexport * from '../themes/ocean/ocean.js';\n",
424
+ );
425
+
426
+ const result = await integrationPackCheck({cwd: tmpDir});
427
+
428
+ expect(result.data.issues).toEqual([]);
429
+ expect(result.data.packable).toBe(true);
430
+ });
431
+
432
+ it.each([
433
+ [
434
+ 'also imports another stylesheet',
435
+ `${OWN_STYLES_ENTRY}import './other.css';\n`,
436
+ "./other.css is not the theme's own stylesheet or font stylesheet",
437
+ ],
438
+ [
439
+ 'also imports a script',
440
+ `import './setup.mjs';\n${OWN_STYLES_ENTRY}`,
441
+ "./setup.mjs is not the theme's own stylesheet or font stylesheet",
442
+ ],
443
+ [
444
+ 'runs code',
445
+ `${OWN_STYLES_ENTRY}console.log('ocean');\n`,
446
+ 'line 7 is neither a stylesheet import nor the re-export',
447
+ ],
448
+ [
449
+ 'exports another value',
450
+ `${OWN_STYLES_ENTRY}export const extra = 1;\n`,
451
+ 'line 7 is neither a stylesheet import nor the re-export',
452
+ ],
453
+ [
454
+ 'renames the theme it re-exports',
455
+ "import '../themes/ocean/ocean.css';\nexport {oceanTheme, oceanTheme as theme} from '../themes/ocean/ocean.js';\n",
456
+ 'it re-exports names other than oceanTheme',
457
+ ],
458
+ [
459
+ 'binds the stylesheet it imports',
460
+ "import styles from '../themes/ocean/ocean.css';\nexport {oceanTheme} from '../themes/ocean/ocean.js';\n",
461
+ 'its import of ../themes/ocean/ocean.css is not a side-effect import',
462
+ ],
463
+ [
464
+ 'imports the stylesheet as a CSS module script',
465
+ "import '../themes/ocean/ocean.css' with {type: 'css'};\nexport {oceanTheme} from '../themes/ocean/ocean.js';\n",
466
+ 'its import of ../themes/ocean/ocean.css is not a side-effect import',
467
+ ],
468
+ [
469
+ 're-exports another name',
470
+ "import '../themes/ocean/ocean.css';\nexport {oceanTheme, missing} from '../themes/ocean/ocean.js';\n",
471
+ 'it re-exports names other than oceanTheme',
472
+ ],
473
+ [
474
+ 're-exports a copy that is not a .js module',
475
+ "import '../themes/ocean/ocean.css';\nexport {oceanTheme} from './copy.cjs';\n",
476
+ 'its re-export from ./copy.cjs does not name a .js module',
477
+ ],
478
+ [
479
+ 'has a directive',
480
+ `'use client';\n${OWN_STYLES_ENTRY}`,
481
+ 'it has a directive',
482
+ ],
483
+ [
484
+ 're-exports twice',
485
+ `${OWN_STYLES_ENTRY}export * from '../themes/ocean/ocean.js';\n`,
486
+ 'it has more than one re-export',
487
+ ],
488
+ ])('fails an entry that %s', async (_label, entry, reason) => {
489
+ writePackage({themeExports: true});
490
+ writeOwnStylesEntry(entry);
491
+ fs.writeFileSync(path.join(tmpDir, 'entries', 'other.css'), '.x {}\n');
492
+ fs.writeFileSync(path.join(tmpDir, 'entries', 'setup.mjs'), 'export {};\n');
493
+ fs.copyFileSync(
494
+ path.join(tmpDir, 'themes', 'ocean', 'ocean.js'),
495
+ path.join(tmpDir, 'entries', 'copy.cjs'),
496
+ );
497
+
498
+ const result = await integrationPackCheck({cwd: tmpDir});
499
+
500
+ expect(result.data.packable).toBe(false);
501
+ expect(result.data.issues).toEqual([
502
+ {
503
+ code: 'theme_module_stale',
504
+ severity: 'error',
505
+ message: `Theme "ocean" module is not the module \`astryx theme build themes/ocean/oceanTheme.ts\` writes and does not only wrap it: ${reason}. A module that wraps the built module may only import the theme's own stylesheet and font stylesheet for their side effects and re-export from the built module either everything or only its theme, as oceanTheme.`,
506
+ },
507
+ ]);
508
+ });
509
+
510
+ it('fails an entry whose re-exported module drifts from source', async () => {
511
+ writePackage({themeExports: true});
512
+ writeOwnStylesEntry(OWN_STYLES_ENTRY);
513
+ fs.appendFileSync(
514
+ path.join(tmpDir, 'themes', 'ocean', 'ocean.js'),
515
+ '// stale module\n',
516
+ );
517
+
518
+ const result = await integrationPackCheck({cwd: tmpDir});
519
+
520
+ expect(result.data.packable).toBe(false);
521
+ expect(result.data.issues).toEqual([
522
+ {
523
+ code: 'theme_module_stale',
524
+ severity: 'error',
525
+ message:
526
+ 'Theme "ocean" module re-exports ../themes/ocean/ocean.js, which does not match themes/ocean/oceanTheme.ts. Run `astryx theme build themes/ocean/oceanTheme.ts` before packing.',
527
+ },
528
+ ]);
529
+ });
530
+
531
+ it('does not accept a TypeScript entry', async () => {
532
+ writePackage({themeExports: true});
533
+ writeOwnStylesEntry(OWN_STYLES_ENTRY, 'ocean.ts');
534
+
535
+ const result = await integrationPackCheck({cwd: tmpDir});
536
+
537
+ expect(result.data.packable).toBe(false);
538
+ expect(result.data.issues).toEqual([
539
+ {
540
+ code: 'theme_module_stale',
541
+ severity: 'error',
542
+ message:
543
+ 'Theme "ocean" module does not match themes/ocean/oceanTheme.ts. Run `astryx theme build themes/ocean/oceanTheme.ts` before packing.',
544
+ },
545
+ ]);
546
+ });
547
+
548
+ it('does not accept an entry that re-exports itself', async () => {
549
+ writePackage({themeExports: true});
550
+ writeOwnStylesEntry(
551
+ "import '../themes/ocean/ocean.css';\nexport * from './ocean.js';\n",
552
+ 'ocean.js',
553
+ );
554
+
555
+ const result = await integrationPackCheck({cwd: tmpDir});
556
+
557
+ expect(result.data.packable).toBe(false);
558
+ expect(result.data.issues).toContainEqual(
559
+ expect.objectContaining({
560
+ code: 'theme_import_unresolvable',
561
+ message: expect.stringContaining('does not export "oceanTheme"'),
562
+ }),
563
+ );
564
+ });
565
+
566
+ it('passes an entry for a theme whose own name differs from its slug', async () => {
567
+ writeRenamedOcean();
568
+ writeOwnStylesEntry(
569
+ "import '../themes/ocean/deep-sea.css';\nexport {deepSeaTheme as oceanTheme} from '../themes/ocean/deep-sea.js';\n",
570
+ );
571
+ setThemeExports({
572
+ './themes/ocean': './entries/ocean.mjs',
573
+ './themes/ocean.css': './themes/ocean/deep-sea.css',
574
+ });
575
+
576
+ const result = await integrationPackCheck({cwd: tmpDir});
577
+
578
+ expect(result.data.issues).toEqual([]);
579
+ expect(result.data.packable).toBe(true);
580
+ const cli = runCliVerify();
581
+ expect(cli.status, cli.stderr).toBe(0);
582
+ });
583
+
584
+ it('compares a partial export set with the module named after the theme', async () => {
585
+ writeRenamedOcean();
586
+ setThemeExports({'./themes/ocean': './themes/ocean/deep-sea.js'});
587
+
588
+ const result = await integrationPackCheck({cwd: tmpDir});
589
+
590
+ expect(result.data.packable).toBe(true);
591
+ expect(result.data.issues.map(issue => issue.code)).toEqual([
592
+ 'theme_exports_incomplete',
593
+ ]);
594
+ });
595
+
596
+ it('passes an entry that re-exports only the theme from a built module that also exports its icons', async () => {
597
+ writeOceanWithIcons();
598
+ writeOwnStylesEntry(OWN_STYLES_ENTRY);
599
+
600
+ const result = await integrationPackCheck({cwd: tmpDir});
601
+
602
+ expect(result.data.issues).toEqual([]);
603
+ expect(result.data.packable).toBe(true);
604
+ });
605
+
606
+ it('fails an entry that gives the built icons the theme export name', async () => {
607
+ writeOceanWithIcons();
608
+ writeOwnStylesEntry(
609
+ "import '../themes/ocean/ocean.css';\nexport {oceanIcons as oceanTheme} from '../themes/ocean/ocean.js';\n",
610
+ );
611
+
612
+ const result = await integrationPackCheck({cwd: tmpDir});
613
+
614
+ expect(result.data.packable).toBe(false);
615
+ expect(result.data.issues).toEqual([
616
+ expect.objectContaining({
617
+ code: 'theme_module_stale',
618
+ message: expect.stringContaining(
619
+ 'it re-exports oceanIcons, which is not the built theme',
620
+ ),
621
+ }),
622
+ ]);
623
+ });
624
+
625
+ it('fails when packing changes the module an entry re-exports', async () => {
626
+ const prepack = [
627
+ "const fs=require('fs')",
628
+ "fs.copyFileSync('themes/ocean/ocean.js','.ocean.js.orig')",
629
+ "fs.appendFileSync('themes/ocean/ocean.js','// packed\\n')",
630
+ ].join(';');
631
+ const postpack =
632
+ "require('fs').renameSync('.ocean.js.orig','themes/ocean/ocean.js')";
633
+ writePackage({
634
+ themeExports: true,
635
+ scripts: {
636
+ prepack: `node -e "${prepack}"`,
637
+ postpack: `node -e "${postpack}"`,
638
+ },
639
+ });
640
+ writeOwnStylesEntry(OWN_STYLES_ENTRY);
641
+
642
+ const result = await integrationPackCheck({cwd: tmpDir});
643
+
644
+ expect(result.data.packable).toBe(false);
645
+ expect(result.data.issues).toEqual([
646
+ {
647
+ code: 'packed_theme_module_changed',
648
+ severity: 'error',
649
+ message:
650
+ 'Theme "ocean" module changed during packing. Keep the built output unchanged in the tarball.',
651
+ },
652
+ ]);
653
+ });
654
+ });
655
+
306
656
  describe('integrationPackCheck', () => {
307
657
  it('returns packable:true for a valid integration with themes', async () => {
308
658
  writePackage({files: ['astryx.integration.mjs', 'themes']});
@@ -1558,6 +1908,23 @@ describe('integrationPackCheck', () => {
1558
1908
  expect(sourceWarnings[0].message).toContain('Card.tsx');
1559
1909
  });
1560
1910
 
1911
+ it('reports template sources without metadata as warnings', async () => {
1912
+ writePackage({
1913
+ manifest:
1914
+ "export default {themes: './themes', templates: './templates'};\n",
1915
+ files: ['astryx.integration.mjs', 'themes', 'templates'],
1916
+ templates: true,
1917
+ });
1918
+ const result = await integrationPackCheck({cwd: tmpDir});
1919
+
1920
+ const sourceWarnings = result.data.issues.filter(
1921
+ issue => issue.code === 'source_without_template_doc',
1922
+ );
1923
+ expect(sourceWarnings).toHaveLength(1);
1924
+ expect(sourceWarnings[0].severity).toBe('warning');
1925
+ expect(sourceWarnings[0].message).toContain('stray.tsx');
1926
+ });
1927
+
1561
1928
  it('cleans up its scratch consumer when npm pack fails', async () => {
1562
1929
  writePackage({
1563
1930
  files: ['astryx.integration.mjs', 'themes'],
@@ -37,6 +37,8 @@ const componentDoc = name =>
37
37
  `export default {type: 'component', name: '${name}', displayName: '${name}', usage: {description: '${name}.'}, props: []};\n`;
38
38
  /** @param {string} name */
39
39
  const componentSource = name => `export function ${name}() { return null; }\n`;
40
+ const templateSource = name =>
41
+ `export default function ${name}() { return null; }\n`;
40
42
  /** @param {string} name */
41
43
  const topic = name =>
42
44
  `export default ${JSON.stringify({
@@ -1131,6 +1133,71 @@ describe('source_without_component_doc fixes hold when followed', () => {
1131
1133
  });
1132
1134
  });
1133
1135
 
1136
+ describe('source_without_template_doc fixes hold when followed', () => {
1137
+ it('adds the named doc, which resolves the warning', async () => {
1138
+ const dir = writePackage({
1139
+ [MANIFEST]: manifest({templates: './templates'}),
1140
+ 'templates/hero.tsx': templateSource('Hero'),
1141
+ 'templates/hero.test.tsx': templateSource('HeroTest'),
1142
+ });
1143
+
1144
+ const message = only(await issuesOf(dir), 'source_without_template_doc');
1145
+ expect(message).toBe(
1146
+ "Template source \"hero.tsx\" has no same-stem metadata file hero.doc.mjs, so `astryx template` never lists it. Fix: add hero.doc.mjs beside it with type: 'page' or 'block'; `astryx docs authoring integration-template-doc` lists its fields. If it is not a template, move it out of the templates root.",
1147
+ );
1148
+
1149
+ const fixed = follow(dir, {
1150
+ write: {
1151
+ 'templates/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
1152
+ },
1153
+ });
1154
+ expect(await issuesOf(fixed)).toEqual([]);
1155
+ });
1156
+
1157
+ it('checks a dotted template id, but no test, spec or story file', async () => {
1158
+ const dir = writePackage({
1159
+ [MANIFEST]: manifest({templates: './templates'}),
1160
+ 'templates/landing.page.tsx': templateSource('LandingPage'),
1161
+ 'templates/hero.test.tsx': templateSource('HeroTest'),
1162
+ 'templates/hero.spec.tsx': templateSource('HeroSpec'),
1163
+ 'templates/hero.stories.tsx': templateSource('HeroStories'),
1164
+ });
1165
+
1166
+ const message = only(await issuesOf(dir), 'source_without_template_doc');
1167
+ expect(message).toContain(
1168
+ 'Template source "landing.page.tsx" has no same-stem metadata file landing.page.doc.mjs',
1169
+ );
1170
+
1171
+ const fixed = follow(dir, {
1172
+ write: {
1173
+ 'templates/landing.page.doc.mjs': `export default {type: 'page', name: 'landing.page', displayName: 'Landing'};\n`,
1174
+ },
1175
+ });
1176
+ expect(await issuesOf(fixed)).toEqual([]);
1177
+ });
1178
+
1179
+ it('never flags a helper in a subfolder of the templates root', async () => {
1180
+ const dir = writePackage({
1181
+ [MANIFEST]: manifest({templates: './templates'}),
1182
+ 'templates/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
1183
+ 'templates/hero.tsx': templateSource('Hero'),
1184
+ 'templates/hero/HeroCard.tsx': templateSource('HeroCard'),
1185
+ });
1186
+
1187
+ expect(await issuesOf(dir)).toEqual([]);
1188
+ });
1189
+
1190
+ it('accepts a released .template.mjs spec as the metadata', async () => {
1191
+ const dir = writePackage({
1192
+ [MANIFEST]: manifest({templates: './templates'}),
1193
+ 'templates/hero.tsx': templateSource('Hero'),
1194
+ 'templates/hero.template.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
1195
+ });
1196
+
1197
+ expect(await issuesOf(dir)).toEqual([]);
1198
+ });
1199
+ });
1200
+
1134
1201
  describe('codemod fixes hold when followed', () => {
1135
1202
  it('moves a stray codemod into a version folder, and renames a mis-named one', async () => {
1136
1203
  const dir = writePackage({
@@ -34,6 +34,8 @@
34
34
  import * as fs from 'node:fs';
35
35
  import * as path from 'node:path';
36
36
  import {assertWithin} from '../../foundation/fs/path-safety.mjs';
37
+ import {integrationDocTypes} from '../docs/_adapter.mjs';
38
+ import {integrationDocConsistency} from '../../foundation/discovery/doc-consistency.mjs';
37
39
  import {
38
40
  THEME_SLUG_RE,
39
41
  unreadThemeFolders,
@@ -331,6 +333,22 @@ async function validateAtPackageDir(
331
333
  issues.push(...(await validateLoadedIntegration(loaded)));
332
334
  if (loaded.themes && !rootProblem(loaded.themes))
333
335
  issues.push(...unreadThemeFolderIssues(packageDir, loaded));
336
+ // What the docs say that no reader serves: a prop listed twice, an
337
+ // overlay's text for a prop the doc lacks, an empty or unreachable section,
338
+ // and an overlay of no topic.
339
+ issues.push(
340
+ ...(await integrationDocConsistency(
341
+ {
342
+ components:
343
+ loaded.components && !rootProblem(loaded.components)
344
+ ? loaded.components
345
+ : undefined,
346
+ docs:
347
+ loaded.docs && !rootProblem(loaded.docs) ? loaded.docs : undefined,
348
+ },
349
+ packageDir,
350
+ )),
351
+ );
334
352
  if (scanUnreachable) {
335
353
  issues.push(
336
354
  ...(await findUnreachableContributionIssues(packageDir, loaded)),
@@ -461,6 +479,12 @@ export async function validateIntegration(pkg, options = {}) {
461
479
  const result = pkg
462
480
  ? await validateInstalledIntegration(pkg, cwd)
463
481
  : await validateLocalIntegration(cwd);
482
+ // Each doc the package ships, against the published authoring type for its
483
+ // kind, read with the project's own compiler. Findings are warnings only.
484
+ const integration = result.found ? result.integration : undefined;
485
+ const docTypes = integration
486
+ ? await integrationDocTypes(integration, cwd)
487
+ : undefined;
464
488
  return {
465
489
  type: 'integration.validate',
466
490
  data: {
@@ -469,9 +493,18 @@ export async function validateIntegration(pkg, options = {}) {
469
493
  validated: result.found,
470
494
  name: result.found ? (result.name ?? null) : null,
471
495
  version: result.found ? (result.version ?? null) : null,
472
- issues: result.reason === 'no_package_json'
473
- ? [{code: 'no_package', severity: 'error', message: 'No package.json found. Run this command inside a package directory.'}]
474
- : result.issues,
496
+ issues:
497
+ result.reason === 'no_package_json'
498
+ ? [
499
+ {
500
+ code: 'no_package',
501
+ severity: 'error',
502
+ message:
503
+ 'No package.json found. Run this command inside a package directory.',
504
+ },
505
+ ]
506
+ : result.issues,
507
+ ...(docTypes ? {docTypes} : {}),
475
508
  },
476
509
  };
477
510
  }