@astryxdesign/cli 0.7.2-canary.ab79547 → 0.7.2-canary.b40ba52

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 (255) hide show
  1. package/README.md +20 -19
  2. package/api/build/help/help.mjs +1 -1
  3. package/api/component/_adapter.d.mts +41 -1
  4. package/api/component/_adapter.mjs +93 -7
  5. package/api/component/component.mjs +22 -5
  6. package/api/component/integration-export-name.test.mjs +644 -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/discover.d.mts +11 -0
  13. package/api/discover/discover.doc.mjs +7 -6
  14. package/api/discover/discover.mjs +107 -19
  15. package/api/discover/discover.type.d.mts +18 -7
  16. package/api/discover/discover.type.mjs +15 -7
  17. package/api/discover/list/list.d.mts +4 -3
  18. package/api/discover/list/list.mjs +17 -10
  19. package/api/docs/_adapter.d.mts +11 -0
  20. package/api/docs/_adapter.mjs +244 -1
  21. package/api/docs/integrationDocs.test.mjs +124 -0
  22. package/api/doctor/doctor.mjs +27 -3
  23. package/api/doctor/doctor.test.mjs +43 -0
  24. package/api/doctor/theme-checks.mjs +1 -1
  25. package/api/doctor/theme-checks.test.mjs +136 -0
  26. package/api/gap-report/gap-report.d.mts +3 -0
  27. package/api/gap-report/gap-report.doc.mjs +11 -3
  28. package/api/gap-report/gap-report.mjs +219 -52
  29. package/api/gap-report/gap-report.test.mjs +233 -0
  30. package/api/gap-report/gap-report.type.d.mts +41 -0
  31. package/api/gap-report/gap-report.type.mjs +18 -0
  32. package/api/index.d.mts +2 -0
  33. package/api/index.mjs +2 -0
  34. package/api/init/run/run.mjs +2 -2
  35. package/api/integration/_adapter.d.mts +12 -0
  36. package/api/integration/_adapter.mjs +54 -0
  37. package/api/integration/add-contribution.component-names.test.mjs +66 -0
  38. package/api/integration/add-contribution.mjs +8 -4
  39. package/api/integration/add-contribution.test.mjs +4 -2
  40. package/api/integration/authoring-checks.mjs +11 -2
  41. package/api/integration/authoring-checks.test.mjs +39 -0
  42. package/api/integration/authoring-checks.type.d.mts +9 -0
  43. package/api/integration/authoring-checks.type.mjs +14 -1
  44. package/api/integration/check/check.d.mts +96 -0
  45. package/api/integration/check/check.mjs +357 -0
  46. package/api/integration/check/check.test.mjs +489 -0
  47. package/api/integration/integration-check.type.d.mts +118 -0
  48. package/api/integration/integration-check.type.mjs +84 -0
  49. package/api/integration/integrationCheck.doc.d.mts +10 -0
  50. package/api/integration/integrationCheck.doc.mjs +73 -0
  51. package/api/integration/integrationComponentConflicts.doc.mjs +43 -6
  52. package/api/integration/pack-check.mjs +343 -104
  53. package/api/integration/pack-check.test.mjs +700 -0
  54. package/api/integration/validate-integration.mjs +8 -0
  55. package/api/integration/validate-integration.test.mjs +11 -0
  56. package/api/integration/validate-integration.type.d.mts +8 -0
  57. package/api/integration/validate-integration.type.mjs +12 -1
  58. package/api/integration/validateIntegration.doc.mjs +19 -3
  59. package/api/search/search.d.mts +81 -12
  60. package/api/search/search.domain-priority.test.mjs +108 -18
  61. package/api/search/search.integration-check.test.mjs +24 -0
  62. package/api/search/search.mjs +601 -50
  63. package/api/search/search.test.mjs +139 -0
  64. package/api/swizzle/copy/copy.mjs +28 -14
  65. package/api/theme/build/build.family.test.mjs +54 -6
  66. package/api/theme/build/build.mjs +114 -17
  67. package/api/theme/themeBuild.doc.mjs +4 -4
  68. package/api/upgrade/_adapter.d.mts +40 -2
  69. package/api/upgrade/_adapter.mjs +117 -4
  70. package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
  71. package/api/upgrade/run/run.mjs +30 -1
  72. package/api/upgrade/status/status.d.mts +21 -5
  73. package/api/upgrade/status/status.mjs +45 -8
  74. package/api/upgrade/upgrade.doc.mjs +5 -3
  75. package/api/upgrade/upgrade.type.d.mts +23 -0
  76. package/api/upgrade/upgrade.type.mjs +16 -1
  77. package/assets/codemods/runner.mjs +7 -1
  78. package/assets/discover/official-packages.json +367 -0
  79. package/assets/docs/README.md +10 -0
  80. package/assets/docs/author-a-theme.doc.mjs +1 -1
  81. package/assets/docs/getting-started.doc.mjs +3 -3
  82. package/assets/docs/styling-overview.doc.mjs +1 -1
  83. package/assets/docs/theme.doc.dense.mjs +1 -1
  84. package/assets/docs/theme.doc.mjs +1 -1
  85. package/assets/docs/theme.doc.zh.mjs +1 -1
  86. package/assets/docs/tree/add-a-component.doc.mjs +11 -1
  87. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  88. package/assets/docs/tree/add-a-topic.doc.mjs +10 -7
  89. package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
  90. package/assets/docs/tree/block-template.doc.mjs +8 -20
  91. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  92. package/assets/docs/tree/check-the-props.doc.mjs +196 -0
  93. package/assets/docs/tree/check-your-docs.doc.mjs +51 -5
  94. package/assets/docs/tree/checks.doc.mjs +24 -16
  95. package/assets/docs/tree/codemods.doc.mjs +4 -4
  96. package/assets/docs/tree/component-family.doc.mjs +8 -6
  97. package/assets/docs/tree/component-imports.doc.mjs +10 -2
  98. package/assets/docs/tree/components.doc.mjs +1 -1
  99. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +25 -16
  100. package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
  101. package/assets/docs/tree/describe-the-component.doc.mjs +2 -2
  102. package/assets/docs/tree/docs.doc.mjs +3 -3
  103. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  104. package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
  105. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  106. package/assets/docs/tree/extend-or-replace.doc.mjs +6 -6
  107. package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
  108. package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
  109. package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
  110. package/assets/docs/tree/integrations.doc.mjs +8 -0
  111. package/assets/docs/tree/links.doc.mjs +6 -5
  112. package/assets/docs/tree/migration-setup.doc.mjs +1 -0
  113. package/assets/docs/tree/migration-verification.doc.mjs +0 -1
  114. package/assets/docs/tree/migration.doc.mjs +0 -1
  115. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  116. package/assets/docs/tree/page-template.doc.mjs +4 -8
  117. package/assets/docs/tree/publishing.doc.mjs +1 -1
  118. package/assets/docs/tree/quick-start.doc.mjs +37 -21
  119. package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
  120. package/assets/docs/tree/replace-a-core-template.doc.mjs +6 -8
  121. package/assets/docs/tree/sections-and-placement.doc.mjs +4 -6
  122. package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
  123. package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
  124. package/assets/docs/tree/single-component.doc.mjs +15 -6
  125. package/assets/docs/tree/start-a-template.doc.mjs +3 -3
  126. package/assets/docs/tree/subcomponent.doc.mjs +6 -6
  127. package/assets/docs/tree/template-assets.doc.mjs +2 -2
  128. package/assets/docs/tree/template-doc-overview.doc.mjs +4 -15
  129. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  130. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  131. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  132. package/assets/docs/tree/template-styles.doc.mjs +2 -2
  133. package/assets/docs/tree/templates.doc.mjs +1 -1
  134. package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
  135. package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
  136. package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
  137. package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
  138. package/assets/docs/tree/type-scale.doc.mjs +3 -3
  139. package/assets/docs/tree/upgrading.doc.mjs +3 -3
  140. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
  141. package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
  142. package/assets/docs/tree/versioning.doc.mjs +7 -6
  143. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -3
  144. package/assets/docs/use-a-theme.doc.mjs +2 -2
  145. package/assets/theme.template.ts +1 -1
  146. package/authoring/codemod/codemod.doc.mjs +7 -3
  147. package/authoring/config/config.doc.mjs +9 -6
  148. package/authoring/config/type.ts +4 -2
  149. package/authoring/discover/discover.doc.mjs +1 -1
  150. package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
  151. package/authoring/doctypes/command/command.doc.mjs +14 -12
  152. package/authoring/doctypes/component/component.doc.mjs +29 -26
  153. package/authoring/doctypes/component/type.ts +13 -8
  154. package/authoring/doctypes/enum/enum.doc.mjs +7 -4
  155. package/authoring/doctypes/function/function.doc.mjs +9 -8
  156. package/authoring/doctypes/hook/hook.doc.mjs +5 -4
  157. package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
  158. package/authoring/doctypes/reference/reference.doc.mjs +11 -10
  159. package/authoring/doctypes/schema/schema.doc.mjs +9 -9
  160. package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
  161. package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
  162. package/authoring/doctypes/template/parse.d.mts +6 -2
  163. package/authoring/doctypes/template/parse.mjs +3 -1
  164. package/authoring/doctypes/template/template.doc.mjs +3 -3
  165. package/authoring/doctypes/template/type.ts +22 -0
  166. package/authoring/doctypes/theme/theme.doc.mjs +2 -2
  167. package/authoring/gap-report/gap-report.doc.mjs +2 -2
  168. package/authoring/identity/identity.doc.mjs +3 -3
  169. package/authoring/index.d.ts +1 -0
  170. package/authoring/integration/integration.doc.mjs +12 -4
  171. package/authoring/integration/parse.test.mjs +10 -0
  172. package/authoring/integration/schema.d.mts +2 -0
  173. package/authoring/integration/schema.mjs +1 -0
  174. package/authoring/integration/type.ts +4 -0
  175. package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
  176. package/clients/cli/commands/build-theme.mjs +1 -1
  177. package/clients/cli/commands/build-theme.path-safety.test.mjs +155 -21
  178. package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
  179. package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
  180. package/clients/cli/commands/discover.doc.mjs +1 -1
  181. package/clients/cli/commands/discover.mjs +144 -93
  182. package/clients/cli/commands/discover.no-source.test.mjs +447 -33
  183. package/clients/cli/commands/discover.sources.test.mjs +20 -1
  184. package/clients/cli/commands/doctor-integration-components.doc.mjs +17 -4
  185. package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
  186. package/clients/cli/commands/doctor-integration.test.mjs +837 -0
  187. package/clients/cli/commands/doctor.mjs +190 -0
  188. package/clients/cli/commands/gap-report.doc.mjs +14 -2
  189. package/clients/cli/commands/gap-report.mjs +24 -2
  190. package/clients/cli/commands/gap-report.test.mjs +79 -0
  191. package/clients/cli/commands/integration-check.doc.mjs +85 -0
  192. package/clients/cli/commands/integration-check.test.mjs +284 -0
  193. package/clients/cli/commands/integration.doc.mjs +6 -2
  194. package/clients/cli/commands/integration.mjs +106 -1
  195. package/clients/cli/commands/json-contract.test.mjs +5 -1
  196. package/clients/cli/commands/setup-nudge.test.mjs +79 -1
  197. package/clients/cli/commands/swizzle.mjs +5 -3
  198. package/clients/cli/commands/swizzle.routing.test.mjs +18 -1
  199. package/clients/cli/commands/text-json-parity.test.mjs +5 -0
  200. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  201. package/clients/cli/commands/upgrade.doc.mjs +14 -0
  202. package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
  203. package/clients/cli/index.mjs +30 -5
  204. package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
  205. package/foundation/agent-docs/agent-doc-state.mjs +38 -0
  206. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  207. package/foundation/agent-docs/agent-docs.mjs +8 -6
  208. package/foundation/config/project.mjs +82 -0
  209. package/foundation/discovery/authoring-self-docs.mjs +2 -1
  210. package/foundation/discovery/component-discovery.d.mts +178 -10
  211. package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
  212. package/foundation/discovery/component-discovery.mjs +659 -62
  213. package/foundation/discovery/component-replacement.mjs +18 -0
  214. package/foundation/discovery/component-replacement.test.mjs +40 -0
  215. package/foundation/discovery/doc-types.d.mts +157 -0
  216. package/foundation/discovery/doc-types.mjs +1224 -0
  217. package/foundation/discovery/doc-types.test.mjs +700 -0
  218. package/foundation/discovery/docs-discovery.d.mts +81 -0
  219. package/foundation/discovery/docs-discovery.mjs +57 -0
  220. package/foundation/discovery/integration-doc-files.d.mts +22 -0
  221. package/foundation/discovery/integration-doc-files.mjs +231 -0
  222. package/foundation/discovery/integration-doc-files.test.mjs +246 -0
  223. package/foundation/discovery/module-exports.d.mts +27 -0
  224. package/foundation/discovery/module-exports.mjs +356 -31
  225. package/foundation/discovery/module-exports.test.mjs +172 -0
  226. package/foundation/discovery/package-tsconfig.d.mts +14 -0
  227. package/foundation/discovery/package-tsconfig.mjs +228 -0
  228. package/foundation/discovery/package-tsconfig.test.mjs +210 -0
  229. package/foundation/discovery/project-typescript.d.mts +32 -0
  230. package/foundation/discovery/project-typescript.mjs +89 -0
  231. package/foundation/discovery/prop-drift.d.mts +278 -0
  232. package/foundation/discovery/prop-drift.mjs +2263 -0
  233. package/foundation/discovery/prop-drift.test.mjs +2272 -0
  234. package/foundation/discovery/type-match.d.mts +53 -0
  235. package/foundation/discovery/type-match.mjs +660 -0
  236. package/foundation/discovery/type-match.test.mjs +169 -0
  237. package/foundation/discovery/type-text.d.mts +68 -0
  238. package/foundation/discovery/type-text.mjs +658 -0
  239. package/foundation/discovery/type-text.test.mjs +196 -0
  240. package/foundation/discovery/unresolved-references.d.mts +62 -0
  241. package/foundation/discovery/unresolved-references.mjs +790 -0
  242. package/foundation/discovery/unresolved-references.test.mjs +567 -0
  243. package/foundation/doc-compiler/doc-loads.test.mjs +10 -0
  244. package/foundation/doc-compiler/links.d.mts +9 -5
  245. package/foundation/doc-compiler/links.mjs +4 -2
  246. package/foundation/env/package-manager.d.mts +32 -0
  247. package/foundation/env/package-manager.mjs +47 -0
  248. package/foundation/env/package-manager.test.mjs +194 -7
  249. package/foundation/fs/module-loader.d.mts +2 -1
  250. package/foundation/fs/module-loader.mjs +60 -4
  251. package/foundation/fs/module-loader.test.mjs +194 -0
  252. package/foundation/integrations/contribution-inventory.mjs +6 -1
  253. package/foundation/response/response-types.doc.mjs +13 -7
  254. package/package.json +9 -9
  255. package/scripts/postinstall.mjs +3 -3
@@ -303,6 +303,347 @@ function runCliVerify() {
303
303
  };
304
304
  }
305
305
 
306
+ /**
307
+ * Give the built ocean theme a font stylesheet and an entry module that loads
308
+ * the theme's own styles, and export them the way such a package does.
309
+ * @param {string} entry
310
+ * @param {string} [file] the entry's file name in `entries/`
311
+ */
312
+ function writeOwnStylesEntry(entry, file = 'ocean.mjs') {
313
+ fs.writeFileSync(
314
+ path.join(tmpDir, 'themes', 'ocean', 'ocean.fonts.css'),
315
+ "@font-face { font-family: 'Ocean Sans'; src: local('Ocean Sans'); }\n",
316
+ );
317
+ fs.mkdirSync(path.join(tmpDir, 'entries'), {recursive: true});
318
+ fs.writeFileSync(path.join(tmpDir, 'entries', file), entry);
319
+ const packageFile = path.join(tmpDir, 'package.json');
320
+ const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf-8'));
321
+ pkg.files = ['astryx.integration.mjs', 'themes', 'entries'];
322
+ pkg.exports = {
323
+ './themes/ocean': `./entries/${file}`,
324
+ './themes/ocean.css': './themes/ocean/ocean.css',
325
+ './themes/ocean.fonts.css': './themes/ocean/ocean.fonts.css',
326
+ };
327
+ fs.writeFileSync(packageFile, `${JSON.stringify(pkg, null, 2)}\n`);
328
+ }
329
+
330
+ /**
331
+ * Rename the ocean theme to deep-sea, keeping its `ocean` slug, and build it,
332
+ * so its outputs are named after the theme: `deep-sea.css` and `deep-sea.js`,
333
+ * which exports `deepSeaTheme`.
334
+ */
335
+ function writeRenamedOcean() {
336
+ writePackage({files: ['astryx.integration.mjs', 'themes', 'entries']});
337
+ fs.writeFileSync(
338
+ path.join(tmpDir, 'themes', 'ocean', 'oceanTheme.ts'),
339
+ "import {defineTheme} from '@astryxdesign/core/theme';\n\nexport const oceanTheme = defineTheme({name: 'deep-sea'});\n",
340
+ );
341
+ const built = spawnSync(
342
+ process.execPath,
343
+ [
344
+ path.join(process.cwd(), 'packages/cli/clients/cli/bin/astryx.mjs'),
345
+ 'theme',
346
+ 'build',
347
+ 'themes/ocean/oceanTheme.ts',
348
+ ],
349
+ {cwd: tmpDir, encoding: 'utf-8', timeout: 30_000},
350
+ );
351
+ if (built.status !== 0) {
352
+ throw new Error(`Could not build the theme fixture: ${built.stderr}`);
353
+ }
354
+ }
355
+
356
+ /**
357
+ * Give the ocean theme an icon registry and build it, so its built module
358
+ * also exports `oceanIcons`.
359
+ */
360
+ function writeOceanWithIcons() {
361
+ writePackage({files: ['astryx.integration.mjs', 'themes', 'entries']});
362
+ const themeDir = path.join(tmpDir, 'themes', 'ocean');
363
+ fs.writeFileSync(
364
+ path.join(themeDir, 'icons.js'),
365
+ 'export const oceanIcons = {};\n',
366
+ );
367
+ fs.writeFileSync(
368
+ path.join(themeDir, 'oceanTheme.ts'),
369
+ "import {defineTheme} from '@astryxdesign/core/theme';\nimport {oceanIcons} from './icons';\n\nexport const oceanTheme = defineTheme({name: 'ocean', icons: oceanIcons});\n",
370
+ );
371
+ const built = spawnSync(
372
+ process.execPath,
373
+ [
374
+ path.join(process.cwd(), 'packages/cli/clients/cli/bin/astryx.mjs'),
375
+ 'theme',
376
+ 'build',
377
+ 'themes/ocean/oceanTheme.ts',
378
+ ],
379
+ {cwd: tmpDir, encoding: 'utf-8', timeout: 30_000},
380
+ );
381
+ if (built.status !== 0) {
382
+ throw new Error(`Could not build the theme fixture: ${built.stderr}`);
383
+ }
384
+ }
385
+
386
+ // An entry like one whose import is the whole integration: it loads the
387
+ // theme's fonts and stylesheet, by relative path and through the package's
388
+ // own exports, and re-exports the built theme.
389
+ const OWN_STYLES_ENTRY = `// Copyright (c) Acme.
390
+
391
+ import '../themes/ocean/ocean.fonts.css';
392
+ import '@acme/widgets/themes/ocean.css';
393
+
394
+ export {oceanTheme} from '../themes/ocean/ocean.js';
395
+ `;
396
+
397
+ describe('a theme module that loads its own styles', () => {
398
+ it('passes an entry that imports the theme stylesheet and fonts and re-exports the built module', async () => {
399
+ writePackage({themeExports: true});
400
+ writeOwnStylesEntry(OWN_STYLES_ENTRY);
401
+
402
+ const result = await integrationPackCheck({cwd: tmpDir});
403
+
404
+ expect(result.data.issues).toEqual([]);
405
+ expect(result.data.packable).toBe(true);
406
+ const cli = runCliVerify();
407
+ expect(cli.status, cli.stderr).toBe(0);
408
+ expect(cli.receipt?.data.issues).toEqual([]);
409
+ });
410
+
411
+ it('passes an entry that imports its fonts through the package exports and re-exports everything', async () => {
412
+ writePackage({themeExports: true});
413
+ writeOwnStylesEntry(
414
+ "import '@acme/widgets/themes/ocean.fonts.css';\nimport '../themes/ocean/ocean.css';\nexport * from '../themes/ocean/ocean.js';\n",
415
+ );
416
+
417
+ const result = await integrationPackCheck({cwd: tmpDir});
418
+
419
+ expect(result.data.issues).toEqual([]);
420
+ expect(result.data.packable).toBe(true);
421
+ });
422
+
423
+ it.each([
424
+ [
425
+ 'also imports another stylesheet',
426
+ `${OWN_STYLES_ENTRY}import './other.css';\n`,
427
+ "./other.css is not the theme's own stylesheet or font stylesheet",
428
+ ],
429
+ [
430
+ 'also imports a script',
431
+ `import './setup.mjs';\n${OWN_STYLES_ENTRY}`,
432
+ "./setup.mjs is not the theme's own stylesheet or font stylesheet",
433
+ ],
434
+ [
435
+ 'runs code',
436
+ `${OWN_STYLES_ENTRY}console.log('ocean');\n`,
437
+ 'line 7 is neither a stylesheet import nor the re-export',
438
+ ],
439
+ [
440
+ 'exports another value',
441
+ `${OWN_STYLES_ENTRY}export const extra = 1;\n`,
442
+ 'line 7 is neither a stylesheet import nor the re-export',
443
+ ],
444
+ [
445
+ 'renames the theme it re-exports',
446
+ "import '../themes/ocean/ocean.css';\nexport {oceanTheme, oceanTheme as theme} from '../themes/ocean/ocean.js';\n",
447
+ 'it re-exports names other than oceanTheme',
448
+ ],
449
+ [
450
+ 'binds the stylesheet it imports',
451
+ "import styles from '../themes/ocean/ocean.css';\nexport {oceanTheme} from '../themes/ocean/ocean.js';\n",
452
+ 'its import of ../themes/ocean/ocean.css is not a side-effect import',
453
+ ],
454
+ [
455
+ 'imports the stylesheet as a CSS module script',
456
+ "import '../themes/ocean/ocean.css' with {type: 'css'};\nexport {oceanTheme} from '../themes/ocean/ocean.js';\n",
457
+ 'its import of ../themes/ocean/ocean.css is not a side-effect import',
458
+ ],
459
+ [
460
+ 're-exports another name',
461
+ "import '../themes/ocean/ocean.css';\nexport {oceanTheme, missing} from '../themes/ocean/ocean.js';\n",
462
+ 'it re-exports names other than oceanTheme',
463
+ ],
464
+ [
465
+ 're-exports a copy that is not a .js module',
466
+ "import '../themes/ocean/ocean.css';\nexport {oceanTheme} from './copy.cjs';\n",
467
+ 'its re-export from ./copy.cjs does not name a .js module',
468
+ ],
469
+ [
470
+ 'has a directive',
471
+ `'use client';\n${OWN_STYLES_ENTRY}`,
472
+ 'it has a directive',
473
+ ],
474
+ [
475
+ 're-exports twice',
476
+ `${OWN_STYLES_ENTRY}export * from '../themes/ocean/ocean.js';\n`,
477
+ 'it has more than one re-export',
478
+ ],
479
+ ])('fails an entry that %s', async (_label, entry, reason) => {
480
+ writePackage({themeExports: true});
481
+ writeOwnStylesEntry(entry);
482
+ fs.writeFileSync(path.join(tmpDir, 'entries', 'other.css'), '.x {}\n');
483
+ fs.writeFileSync(path.join(tmpDir, 'entries', 'setup.mjs'), 'export {};\n');
484
+ fs.copyFileSync(
485
+ path.join(tmpDir, 'themes', 'ocean', 'ocean.js'),
486
+ path.join(tmpDir, 'entries', 'copy.cjs'),
487
+ );
488
+
489
+ const result = await integrationPackCheck({cwd: tmpDir});
490
+
491
+ expect(result.data.packable).toBe(false);
492
+ expect(result.data.issues).toEqual([
493
+ {
494
+ code: 'theme_module_stale',
495
+ severity: 'error',
496
+ 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.`,
497
+ },
498
+ ]);
499
+ });
500
+
501
+ it('fails an entry whose re-exported module drifts from source', async () => {
502
+ writePackage({themeExports: true});
503
+ writeOwnStylesEntry(OWN_STYLES_ENTRY);
504
+ fs.appendFileSync(
505
+ path.join(tmpDir, 'themes', 'ocean', 'ocean.js'),
506
+ '// stale module\n',
507
+ );
508
+
509
+ const result = await integrationPackCheck({cwd: tmpDir});
510
+
511
+ expect(result.data.packable).toBe(false);
512
+ expect(result.data.issues).toEqual([
513
+ {
514
+ code: 'theme_module_stale',
515
+ severity: 'error',
516
+ message:
517
+ '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.',
518
+ },
519
+ ]);
520
+ });
521
+
522
+ it('does not accept a TypeScript entry', async () => {
523
+ writePackage({themeExports: true});
524
+ writeOwnStylesEntry(OWN_STYLES_ENTRY, 'ocean.ts');
525
+
526
+ const result = await integrationPackCheck({cwd: tmpDir});
527
+
528
+ expect(result.data.packable).toBe(false);
529
+ expect(result.data.issues).toEqual([
530
+ {
531
+ code: 'theme_module_stale',
532
+ severity: 'error',
533
+ message:
534
+ 'Theme "ocean" module does not match themes/ocean/oceanTheme.ts. Run `astryx theme build themes/ocean/oceanTheme.ts` before packing.',
535
+ },
536
+ ]);
537
+ });
538
+
539
+ it('does not accept an entry that re-exports itself', async () => {
540
+ writePackage({themeExports: true});
541
+ writeOwnStylesEntry(
542
+ "import '../themes/ocean/ocean.css';\nexport * from './ocean.js';\n",
543
+ 'ocean.js',
544
+ );
545
+
546
+ const result = await integrationPackCheck({cwd: tmpDir});
547
+
548
+ expect(result.data.packable).toBe(false);
549
+ expect(result.data.issues).toContainEqual(
550
+ expect.objectContaining({
551
+ code: 'theme_import_unresolvable',
552
+ message: expect.stringContaining('does not export "oceanTheme"'),
553
+ }),
554
+ );
555
+ });
556
+
557
+ it('passes an entry for a theme whose own name differs from its slug', async () => {
558
+ writeRenamedOcean();
559
+ writeOwnStylesEntry(
560
+ "import '../themes/ocean/deep-sea.css';\nexport {deepSeaTheme as oceanTheme} from '../themes/ocean/deep-sea.js';\n",
561
+ );
562
+ setThemeExports({
563
+ './themes/ocean': './entries/ocean.mjs',
564
+ './themes/ocean.css': './themes/ocean/deep-sea.css',
565
+ });
566
+
567
+ const result = await integrationPackCheck({cwd: tmpDir});
568
+
569
+ expect(result.data.issues).toEqual([]);
570
+ expect(result.data.packable).toBe(true);
571
+ const cli = runCliVerify();
572
+ expect(cli.status, cli.stderr).toBe(0);
573
+ });
574
+
575
+ it('compares a partial export set with the module named after the theme', async () => {
576
+ writeRenamedOcean();
577
+ setThemeExports({'./themes/ocean': './themes/ocean/deep-sea.js'});
578
+
579
+ const result = await integrationPackCheck({cwd: tmpDir});
580
+
581
+ expect(result.data.packable).toBe(true);
582
+ expect(result.data.issues.map(issue => issue.code)).toEqual([
583
+ 'theme_exports_incomplete',
584
+ ]);
585
+ });
586
+
587
+ it('passes an entry that re-exports only the theme from a built module that also exports its icons', async () => {
588
+ writeOceanWithIcons();
589
+ writeOwnStylesEntry(OWN_STYLES_ENTRY);
590
+
591
+ const result = await integrationPackCheck({cwd: tmpDir});
592
+
593
+ expect(result.data.issues).toEqual([]);
594
+ expect(result.data.packable).toBe(true);
595
+ });
596
+
597
+ it('fails an entry that gives the built icons the theme export name', async () => {
598
+ writeOceanWithIcons();
599
+ writeOwnStylesEntry(
600
+ "import '../themes/ocean/ocean.css';\nexport {oceanIcons as oceanTheme} from '../themes/ocean/ocean.js';\n",
601
+ );
602
+
603
+ const result = await integrationPackCheck({cwd: tmpDir});
604
+
605
+ expect(result.data.packable).toBe(false);
606
+ expect(result.data.issues).toEqual([
607
+ expect.objectContaining({
608
+ code: 'theme_module_stale',
609
+ message: expect.stringContaining(
610
+ 'it re-exports oceanIcons, which is not the built theme',
611
+ ),
612
+ }),
613
+ ]);
614
+ });
615
+
616
+ it('fails when packing changes the module an entry re-exports', async () => {
617
+ const prepack = [
618
+ "const fs=require('fs')",
619
+ "fs.copyFileSync('themes/ocean/ocean.js','.ocean.js.orig')",
620
+ "fs.appendFileSync('themes/ocean/ocean.js','// packed\\n')",
621
+ ].join(';');
622
+ const postpack =
623
+ "require('fs').renameSync('.ocean.js.orig','themes/ocean/ocean.js')";
624
+ writePackage({
625
+ themeExports: true,
626
+ scripts: {
627
+ prepack: `node -e "${prepack}"`,
628
+ postpack: `node -e "${postpack}"`,
629
+ },
630
+ });
631
+ writeOwnStylesEntry(OWN_STYLES_ENTRY);
632
+
633
+ const result = await integrationPackCheck({cwd: tmpDir});
634
+
635
+ expect(result.data.packable).toBe(false);
636
+ expect(result.data.issues).toEqual([
637
+ {
638
+ code: 'packed_theme_module_changed',
639
+ severity: 'error',
640
+ message:
641
+ 'Theme "ocean" module changed during packing. Keep the built output unchanged in the tarball.',
642
+ },
643
+ ]);
644
+ });
645
+ });
646
+
306
647
  describe('integrationPackCheck', () => {
307
648
  it('returns packable:true for a valid integration with themes', async () => {
308
649
  writePackage({files: ['astryx.integration.mjs', 'themes']});
@@ -754,6 +1095,285 @@ describe('integrationPackCheck', () => {
754
1095
  );
755
1096
  });
756
1097
 
1098
+ it('checks the export a component doc names when its file is named otherwise', async () => {
1099
+ fs.writeFileSync(
1100
+ path.join(tmpDir, 'package.json'),
1101
+ `${JSON.stringify({
1102
+ name: '@acme/widgets',
1103
+ version: '1.0.0',
1104
+ files: ['astryx.integration.mjs', 'components'],
1105
+ exports: {'./components/Slides': './components/Slides.tsx'},
1106
+ })}\n`,
1107
+ );
1108
+ fs.writeFileSync(
1109
+ path.join(tmpDir, 'astryx.integration.mjs'),
1110
+ "export default {components: './components'};\n",
1111
+ );
1112
+ fs.mkdirSync(path.join(tmpDir, 'components'));
1113
+ // Slides.tsx exports AcmeCarousel and nothing named Slides.
1114
+ fs.writeFileSync(
1115
+ path.join(tmpDir, 'components', 'Slides.tsx'),
1116
+ 'export function AcmeCarousel() { return null; }\n',
1117
+ );
1118
+ fs.writeFileSync(
1119
+ path.join(tmpDir, 'components', 'Slides.doc.mjs'),
1120
+ "export default {type: 'component', name: 'AcmeCarousel', import: '@acme/widgets/components/Slides', description: 'x', props: []};\n",
1121
+ );
1122
+
1123
+ const result = await integrationPackCheck({cwd: tmpDir});
1124
+ expect(result.data.packable).toBe(true);
1125
+ expect(result.data.contributions.packed.components).toEqual([
1126
+ 'AcmeCarousel',
1127
+ ]);
1128
+ });
1129
+
1130
+ it('checks each family member against the module its family doc imports', async () => {
1131
+ fs.writeFileSync(
1132
+ path.join(tmpDir, 'package.json'),
1133
+ `${JSON.stringify({
1134
+ name: '@acme/widgets',
1135
+ version: '1.0.0',
1136
+ files: ['astryx.integration.mjs', 'components'],
1137
+ exports: {'./tabs': './components/tabs/index.ts'},
1138
+ })}\n`,
1139
+ );
1140
+ fs.writeFileSync(
1141
+ path.join(tmpDir, 'astryx.integration.mjs'),
1142
+ "export default {components: './components'};\n",
1143
+ );
1144
+ const dir = path.join(tmpDir, 'components', 'tabs');
1145
+ fs.mkdirSync(dir, {recursive: true});
1146
+ fs.writeFileSync(
1147
+ path.join(dir, 'AcmeTabs.tsx'),
1148
+ 'export function AcmeTabs() { return null; }\nexport function AcmeTabsLegacy() { return null; }\n',
1149
+ );
1150
+ fs.writeFileSync(
1151
+ path.join(dir, 'tab.tsx'),
1152
+ 'export function AcmeTab() { return null; }\n',
1153
+ );
1154
+ // The module apps import exports AcmeTabs and AcmeTab, not AcmeTabsLegacy.
1155
+ fs.writeFileSync(
1156
+ path.join(dir, 'index.ts'),
1157
+ "export {AcmeTabs} from './AcmeTabs';\nexport {AcmeTab} from './tab';\n",
1158
+ );
1159
+ fs.writeFileSync(
1160
+ path.join(dir, 'AcmeTabs.doc.mjs'),
1161
+ "export default {type: 'component', name: 'AcmeTabs', import: '@acme/widgets/tabs', description: 'x', components: [{name: 'AcmeTabs', description: 'x', props: []}, {name: 'AcmeTab', description: 'x', props: []}, {name: 'AcmeTabsLegacy', description: 'x', props: []}]};\n",
1162
+ );
1163
+
1164
+ const result = await integrationPackCheck({cwd: tmpDir});
1165
+
1166
+ expect(result.data.issues).toEqual([]);
1167
+ expect(result.data.packable).toBe(true);
1168
+ expect(result.data.contributions.packed.components).toEqual([
1169
+ 'AcmeTab',
1170
+ 'AcmeTabs',
1171
+ ]);
1172
+ });
1173
+
1174
+ it.each([
1175
+ 'a clean checkout',
1176
+ 'a stale build',
1177
+ 'a stale build that exports more',
1178
+ ])(
1179
+ 'reads members a family imports from output its pack lifecycle builds, from %s',
1180
+ async start => {
1181
+ fs.writeFileSync(
1182
+ path.join(tmpDir, 'package.json'),
1183
+ `${JSON.stringify({
1184
+ name: '@acme/widgets',
1185
+ version: '1.0.0',
1186
+ files: ['astryx.integration.mjs', 'components', 'dist'],
1187
+ exports: {'./tabs': './dist/tabs/index.mjs'},
1188
+ scripts: {prepack: 'node build.mjs'},
1189
+ })}\n`,
1190
+ );
1191
+ fs.writeFileSync(
1192
+ path.join(tmpDir, 'astryx.integration.mjs'),
1193
+ "export default {components: './components'};\n",
1194
+ );
1195
+ // The build writes the module the family imports; a clean checkout has none.
1196
+ fs.writeFileSync(
1197
+ path.join(tmpDir, 'build.mjs'),
1198
+ "import fs from 'node:fs';\nfs.mkdirSync('dist/tabs', {recursive: true});\nfs.writeFileSync('dist/tabs/index.mjs', \"export {AcmeTabs, AcmeTab} from '../../components/tabs/AcmeTabs.tsx';\\n\");\n",
1199
+ );
1200
+ const dir = path.join(tmpDir, 'components', 'tabs');
1201
+ fs.mkdirSync(dir, {recursive: true});
1202
+ fs.writeFileSync(
1203
+ path.join(dir, 'AcmeTabs.tsx'),
1204
+ 'export function AcmeTabs() { return null; }\nexport function AcmeTab() { return null; }\nexport function AcmeTabLegacy() { return null; }\n',
1205
+ );
1206
+ fs.writeFileSync(
1207
+ path.join(dir, 'AcmeTabs.doc.mjs'),
1208
+ "export default {type: 'component', name: 'AcmeTabs', import: '@acme/widgets/tabs', description: 'x', components: [{name: 'AcmeTabs', description: 'x', props: []}, {name: 'AcmeTab', description: 'x', props: []}, {name: 'AcmeTabLegacy', description: 'x', props: []}]};\n",
1209
+ );
1210
+
1211
+ if (start !== 'a clean checkout') {
1212
+ // An earlier build: before AcmeTab was exported, or while AcmeTabLegacy
1213
+ // still was.
1214
+ const names =
1215
+ start === 'a stale build'
1216
+ ? 'AcmeTabs'
1217
+ : 'AcmeTabs, AcmeTab, AcmeTabLegacy';
1218
+ fs.mkdirSync(path.join(tmpDir, 'dist', 'tabs'), {recursive: true});
1219
+ fs.writeFileSync(
1220
+ path.join(tmpDir, 'dist', 'tabs', 'index.mjs'),
1221
+ `export {${names}} from '../../components/tabs/AcmeTabs.tsx';\n`,
1222
+ );
1223
+ }
1224
+
1225
+ const result = await integrationPackCheck({cwd: tmpDir});
1226
+
1227
+ expect(result.data.issues).toEqual([]);
1228
+ expect(result.data.packable).toBe(true);
1229
+ expect(result.data.contributions.local.components).toEqual(
1230
+ result.data.contributions.packed.components,
1231
+ );
1232
+ },
1233
+ );
1234
+
1235
+ it.each(['a clean checkout', 'an incremental build'])(
1236
+ 'reads members built output re-exports from compiled files, from %s',
1237
+ async start => {
1238
+ fs.writeFileSync(
1239
+ path.join(tmpDir, 'package.json'),
1240
+ `${JSON.stringify({
1241
+ name: '@acme/widgets',
1242
+ version: '1.0.0',
1243
+ files: ['astryx.integration.mjs', 'components', 'dist'],
1244
+ exports: {'./tabs': './dist/tabs/index.mjs'},
1245
+ scripts: {prepack: 'node build.mjs'},
1246
+ })}\n`,
1247
+ );
1248
+ fs.writeFileSync(
1249
+ path.join(tmpDir, 'astryx.integration.mjs'),
1250
+ "export default {components: './components'};\n",
1251
+ );
1252
+ // The build compiles each source to its own file and, like an
1253
+ // incremental build, rewrites only the files whose output changed.
1254
+ const output = {
1255
+ 'index.mjs':
1256
+ "export {AcmeTabs} from './tabs.mjs';\nexport * from './tab.mjs';\n",
1257
+ 'tabs.mjs': 'export function AcmeTabs() { return null; }\n',
1258
+ 'tab.mjs': 'export function AcmeTab() { return null; }\n',
1259
+ };
1260
+ fs.writeFileSync(
1261
+ path.join(tmpDir, 'build.mjs'),
1262
+ `import fs from 'node:fs';\nconst output = ${JSON.stringify(output)};\nfs.mkdirSync('dist/tabs', {recursive: true});\nfor (const [file, text] of Object.entries(output)) {\n const target = 'dist/tabs/' + file;\n if (!fs.existsSync(target) || fs.readFileSync(target, 'utf-8') !== text) fs.writeFileSync(target, text);\n}\n`,
1263
+ );
1264
+ const dir = path.join(tmpDir, 'components', 'tabs');
1265
+ fs.mkdirSync(dir, {recursive: true});
1266
+ fs.writeFileSync(
1267
+ path.join(dir, 'AcmeTabs.tsx'),
1268
+ 'export function AcmeTabs() { return null; }\n',
1269
+ );
1270
+ fs.writeFileSync(
1271
+ path.join(dir, 'AcmeTab.tsx'),
1272
+ 'export function AcmeTab() { return null; }\n',
1273
+ );
1274
+ fs.writeFileSync(
1275
+ path.join(dir, 'AcmeTabs.doc.mjs'),
1276
+ "export default {type: 'component', name: 'AcmeTabs', import: '@acme/widgets/tabs', description: 'x', components: [{name: 'AcmeTabs', description: 'x', props: []}, {name: 'AcmeTab', description: 'x', props: []}]};\n",
1277
+ );
1278
+ if (start === 'an incremental build') {
1279
+ // An earlier build from before AcmeTab existed: the file the import
1280
+ // names is already current, so the build leaves it untouched.
1281
+ fs.mkdirSync(path.join(tmpDir, 'dist', 'tabs'), {recursive: true});
1282
+ for (const [file, text] of Object.entries({...output, 'tab.mjs': ''})) {
1283
+ fs.writeFileSync(path.join(tmpDir, 'dist', 'tabs', file), text);
1284
+ }
1285
+ }
1286
+
1287
+ const result = await integrationPackCheck({cwd: tmpDir});
1288
+
1289
+ expect(result.data.issues).toEqual([]);
1290
+ expect(result.data.packable).toBe(true);
1291
+ expect(result.data.contributions.packed.components).toEqual([
1292
+ 'AcmeTab',
1293
+ 'AcmeTabs',
1294
+ ]);
1295
+ expect(result.data.contributions.local.components).toEqual(
1296
+ result.data.contributions.packed.components,
1297
+ );
1298
+ },
1299
+ );
1300
+
1301
+ it('passes a member another folder declares, which has no source', async () => {
1302
+ fs.writeFileSync(
1303
+ path.join(tmpDir, 'package.json'),
1304
+ `${JSON.stringify({
1305
+ name: '@acme/widgets',
1306
+ version: '1.0.0',
1307
+ files: ['astryx.integration.mjs', 'components'],
1308
+ exports: {'./menu': './components/menu/index.ts'},
1309
+ })}\n`,
1310
+ );
1311
+ fs.writeFileSync(
1312
+ path.join(tmpDir, 'astryx.integration.mjs'),
1313
+ "export default {components: './components'};\n",
1314
+ );
1315
+ const menu = path.join(tmpDir, 'components', 'menu');
1316
+ const shared = path.join(tmpDir, 'components', 'shared');
1317
+ fs.mkdirSync(menu, {recursive: true});
1318
+ fs.mkdirSync(shared, {recursive: true});
1319
+ fs.writeFileSync(
1320
+ path.join(menu, 'AcmeMenu.doc.mjs'),
1321
+ "export default {type: 'component', name: 'AcmeMenu', import: '@acme/widgets/menu', description: 'x', components: [{name: 'AcmeMenuItem', description: 'x', props: []}]};\n",
1322
+ );
1323
+ fs.writeFileSync(
1324
+ path.join(menu, 'AcmeMenu.tsx'),
1325
+ 'export function AcmeMenu() { return null; }\n',
1326
+ );
1327
+ fs.writeFileSync(
1328
+ path.join(menu, 'index.ts'),
1329
+ "export {AcmeMenu} from './AcmeMenu';\nexport {AcmeMenuItem} from '../shared/AcmeMenuItem';\n",
1330
+ );
1331
+ fs.writeFileSync(
1332
+ path.join(shared, 'AcmeMenuItem.tsx'),
1333
+ 'export function AcmeMenuItem() { return null; }\n',
1334
+ );
1335
+
1336
+ const result = await integrationPackCheck({cwd: tmpDir});
1337
+
1338
+ expect(result.data.issues).toEqual([]);
1339
+ expect(result.data.packable).toBe(true);
1340
+ expect(result.data.contributions.packed.components).toEqual([
1341
+ 'AcmeMenu',
1342
+ 'AcmeMenuItem',
1343
+ ]);
1344
+ });
1345
+
1346
+ it('reports a family doc the loader rejects once, not once per member', async () => {
1347
+ fs.writeFileSync(
1348
+ path.join(tmpDir, 'package.json'),
1349
+ `${JSON.stringify({
1350
+ name: '@acme/widgets',
1351
+ version: '1.0.0',
1352
+ files: ['astryx.integration.mjs', 'components'],
1353
+ })}\n`,
1354
+ );
1355
+ fs.writeFileSync(
1356
+ path.join(tmpDir, 'astryx.integration.mjs'),
1357
+ "export default {components: './components'};\n",
1358
+ );
1359
+ fs.mkdirSync(path.join(tmpDir, 'components'));
1360
+ fs.writeFileSync(
1361
+ path.join(tmpDir, 'components', 'AcmeTabs.tsx'),
1362
+ 'export function AcmeTabs() { return null; }\nexport function AcmeTab() { return null; }\nexport function AcmeTabPanel() { return null; }\n',
1363
+ );
1364
+ // A displayName that is not a string makes the loader reject the doc.
1365
+ fs.writeFileSync(
1366
+ path.join(tmpDir, 'components', 'AcmeTabs.doc.mjs'),
1367
+ "export default {type: 'component', name: 'AcmeTabs', displayName: 1, description: 'x', components: [{name: 'AcmeTab', description: 'x', props: []}, {name: 'AcmeTabPanel', description: 'x', props: []}]};\n",
1368
+ );
1369
+
1370
+ const result = await integrationPackCheck({cwd: tmpDir});
1371
+ const codes = result.data.issues.map(issue => issue.code);
1372
+
1373
+ expect(codes).toContain('component_doc_unloadable');
1374
+ expect(codes.length).toBe(new Set(codes).size);
1375
+ });
1376
+
757
1377
  it('passes a generated component through its exact packed export', async () => {
758
1378
  fs.writeFileSync(
759
1379
  path.join(tmpDir, 'package.json'),
@@ -811,6 +1431,86 @@ describe('integrationPackCheck', () => {
811
1431
  );
812
1432
  });
813
1433
 
1434
+ it('does not count a type-only re-export as the component', async () => {
1435
+ fs.writeFileSync(
1436
+ path.join(tmpDir, 'package.json'),
1437
+ `${JSON.stringify({
1438
+ name: '@acme/widgets',
1439
+ version: '1.0.0',
1440
+ files: ['astryx.integration.mjs', 'src'],
1441
+ exports: {'.': './src/index.ts'},
1442
+ })}\n`,
1443
+ );
1444
+ fs.writeFileSync(
1445
+ path.join(tmpDir, 'astryx.integration.mjs'),
1446
+ "export default {components: './src'};\n",
1447
+ );
1448
+ fs.mkdirSync(path.join(tmpDir, 'src'));
1449
+ fs.writeFileSync(
1450
+ path.join(tmpDir, 'src', 'index.ts'),
1451
+ "export type {AcmeWidget} from './AcmeWidget';\n",
1452
+ );
1453
+ fs.writeFileSync(
1454
+ path.join(tmpDir, 'src', 'AcmeWidget.tsx'),
1455
+ 'export function AcmeWidget() { return null; }\n',
1456
+ );
1457
+ fs.writeFileSync(
1458
+ path.join(tmpDir, 'src', 'AcmeWidget.doc.mjs'),
1459
+ "export default {type: 'component', name: 'AcmeWidget', import: '@acme/widgets', description: 'Widget.', props: []};\n",
1460
+ );
1461
+
1462
+ const result = await integrationPackCheck({cwd: tmpDir});
1463
+
1464
+ expect(result.data.issues).toContainEqual(
1465
+ expect.objectContaining({code: 'component_export_missing'}),
1466
+ );
1467
+ });
1468
+
1469
+ it('follows a re-export of a folder to its index file', async () => {
1470
+ // `./primitives` names a folder: TypeScript and bundlers load its index file.
1471
+ fs.writeFileSync(
1472
+ path.join(tmpDir, 'package.json'),
1473
+ `${JSON.stringify({
1474
+ name: '@acme/widgets',
1475
+ version: '1.0.0',
1476
+ files: ['astryx.integration.mjs', 'src'],
1477
+ exports: {'.': './src/index.ts'},
1478
+ })}\n`,
1479
+ );
1480
+ fs.writeFileSync(
1481
+ path.join(tmpDir, 'astryx.integration.mjs'),
1482
+ "export default {components: './src'};\n",
1483
+ );
1484
+ const primitives = path.join(tmpDir, 'src', 'primitives');
1485
+ fs.mkdirSync(primitives, {recursive: true});
1486
+ fs.writeFileSync(
1487
+ path.join(tmpDir, 'src', 'index.ts'),
1488
+ "export * from './primitives';\n",
1489
+ );
1490
+ fs.writeFileSync(
1491
+ path.join(primitives, 'index.ts'),
1492
+ "export * from './AcmeWidget';\n",
1493
+ );
1494
+ fs.writeFileSync(
1495
+ path.join(primitives, 'AcmeWidget.tsx'),
1496
+ 'export function AcmeWidget() { return null; }\n',
1497
+ );
1498
+ fs.writeFileSync(
1499
+ path.join(primitives, 'AcmeWidget.doc.mjs'),
1500
+ "export default {type: 'component', name: 'AcmeWidget', import: '@acme/widgets', description: 'Widget.', props: []};\n",
1501
+ );
1502
+
1503
+ const result = await integrationPackCheck({cwd: tmpDir});
1504
+
1505
+ expect(result.data.issues).not.toContainEqual(
1506
+ expect.objectContaining({code: 'component_export_missing'}),
1507
+ );
1508
+ expect(
1509
+ result.data.packable,
1510
+ JSON.stringify(result.data.issues, null, 2),
1511
+ ).toBe(true);
1512
+ });
1513
+
814
1514
  it('fails when packed template source is hidden by package exports', async () => {
815
1515
  writePackage({
816
1516
  manifest: "export default {templates: './templates'};\n",