@astryxdesign/cli 0.7.2-canary.ba6a6e2 → 0.7.2-canary.bd72a5f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -73
- package/api/build/help/help.mjs +1 -1
- package/api/component/_adapter.d.mts +72 -1
- package/api/component/_adapter.mjs +209 -7
- package/api/component/component.mjs +82 -15
- package/api/component/component.test.mjs +80 -0
- package/api/component/doc-links.test.mjs +386 -0
- package/api/component/integration-export-name.test.mjs +644 -0
- package/api/component/list/list.mjs +42 -4
- package/api/discover/_adapter.d.mts +119 -12
- package/api/discover/_adapter.mjs +449 -10
- package/api/discover/_adapter.test.mjs +599 -17
- package/api/discover/_catalog-view.d.mts +16 -5
- package/api/discover/_catalog-view.mjs +32 -8
- package/api/discover/detail/doc/doc.mjs +9 -1
- package/api/discover/discover.d.mts +11 -0
- package/api/discover/discover.doc.mjs +7 -6
- package/api/discover/discover.mjs +107 -19
- package/api/discover/discover.type.d.mts +18 -7
- package/api/discover/discover.type.mjs +15 -7
- package/api/discover/list/list.d.mts +4 -3
- package/api/discover/list/list.mjs +17 -10
- package/api/docs/_adapter.d.mts +74 -0
- package/api/docs/_adapter.mjs +550 -14
- package/api/docs/integration-tree.test.mjs +22 -0
- package/api/docs/integrationDocs.test.mjs +124 -0
- package/api/docs/list/list.mjs +12 -2
- package/api/doctor/doctor.mjs +27 -3
- package/api/doctor/doctor.test.mjs +43 -0
- package/api/doctor/theme-checks.mjs +1 -1
- package/api/doctor/theme-checks.test.mjs +136 -0
- package/api/gap-report/gap-report.d.mts +3 -0
- package/api/gap-report/gap-report.doc.mjs +11 -3
- package/api/gap-report/gap-report.mjs +219 -52
- package/api/gap-report/gap-report.test.mjs +233 -0
- package/api/gap-report/gap-report.type.d.mts +41 -0
- package/api/gap-report/gap-report.type.mjs +18 -0
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/init/run/run.mjs +2 -2
- package/api/integration/_adapter.d.mts +45 -0
- package/api/integration/_adapter.mjs +112 -0
- package/api/integration/add-contribution.component-names.test.mjs +66 -0
- package/api/integration/add-contribution.mjs +8 -4
- package/api/integration/add-contribution.test.mjs +4 -2
- package/api/integration/authoring-checks.mjs +108 -4
- package/api/integration/authoring-checks.test.mjs +808 -0
- package/api/integration/authoring-checks.type.d.mts +143 -0
- package/api/integration/authoring-checks.type.mjs +74 -2
- package/api/integration/check/check.d.mts +96 -0
- package/api/integration/check/check.mjs +357 -0
- package/api/integration/check/check.test.mjs +489 -0
- package/api/integration/integration-check.type.d.mts +118 -0
- package/api/integration/integration-check.type.mjs +84 -0
- package/api/integration/integrationCheck.doc.d.mts +10 -0
- package/api/integration/integrationCheck.doc.mjs +73 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +45 -6
- package/api/integration/integrationDocConflicts.doc.mjs +22 -5
- package/api/integration/pack-check.mjs +357 -114
- package/api/integration/pack-check.test.mjs +726 -0
- package/api/integration/validate-integration-fixes.test.mjs +67 -0
- package/api/integration/validate-integration.mjs +36 -3
- package/api/integration/validate-integration.test.mjs +88 -8
- package/api/integration/validate-integration.type.d.mts +8 -0
- package/api/integration/validate-integration.type.mjs +12 -1
- package/api/integration/validateIntegration.doc.mjs +19 -3
- package/api/search/search.d.mts +81 -12
- package/api/search/search.domain-priority.test.mjs +108 -18
- package/api/search/search.integration-check.test.mjs +24 -0
- package/api/search/search.mjs +611 -54
- package/api/search/search.test.mjs +175 -0
- package/api/swizzle/copy/copy.mjs +28 -14
- package/api/theme/build/build.family.test.mjs +64 -0
- package/api/theme/build/build.mjs +180 -24
- package/api/theme/themeBuild.doc.mjs +4 -4
- package/api/upgrade/_adapter.d.mts +40 -2
- package/api/upgrade/_adapter.mjs +117 -4
- package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
- package/api/upgrade/run/run.mjs +30 -1
- package/api/upgrade/status/status.d.mts +21 -5
- package/api/upgrade/status/status.mjs +45 -8
- package/api/upgrade/upgrade.doc.mjs +5 -3
- package/api/upgrade/upgrade.type.d.mts +23 -0
- package/api/upgrade/upgrade.type.mjs +16 -1
- package/assets/codemods/runner.mjs +7 -1
- package/assets/discover/official-packages.json +367 -0
- package/assets/docs/README.md +10 -0
- package/assets/docs/author-a-theme.doc.mjs +3 -3
- package/assets/docs/browser-support.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +3 -3
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +2 -2
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/add-a-component.doc.mjs +11 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +11 -8
- package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
- package/assets/docs/tree/block-template.doc.mjs +8 -20
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/check-the-props.doc.mjs +201 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +65 -7
- package/assets/docs/tree/checks.doc.mjs +26 -18
- package/assets/docs/tree/codemods.doc.mjs +4 -4
- package/assets/docs/tree/component-family.doc.mjs +8 -6
- package/assets/docs/tree/component-imports.doc.mjs +10 -2
- package/assets/docs/tree/components.doc.mjs +1 -1
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +30 -21
- package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
- package/assets/docs/tree/describe-the-component.doc.mjs +2 -2
- package/assets/docs/tree/docs.doc.mjs +3 -3
- package/assets/docs/tree/document-the-template.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +3 -3
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +6 -6
- package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
- package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
- package/assets/docs/tree/integrations.doc.mjs +8 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
- package/assets/docs/tree/layout.doc.mjs +6 -6
- package/assets/docs/tree/links.doc.mjs +6 -5
- package/assets/docs/tree/migration-setup.doc.mjs +3 -2
- package/assets/docs/tree/migration-verification.doc.mjs +0 -1
- package/assets/docs/tree/migration.doc.mjs +0 -1
- package/assets/docs/tree/package-and-test.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +4 -8
- package/assets/docs/tree/publishing.doc.mjs +4 -4
- package/assets/docs/tree/quick-start.doc.mjs +38 -22
- package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
- package/assets/docs/tree/replace-a-core-template.doc.mjs +6 -8
- package/assets/docs/tree/sections-and-placement.doc.mjs +6 -8
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
- package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
- package/assets/docs/tree/single-component.doc.mjs +15 -6
- package/assets/docs/tree/start-a-template.doc.mjs +3 -3
- package/assets/docs/tree/subcomponent.doc.mjs +6 -6
- package/assets/docs/tree/template-assets.doc.mjs +2 -2
- package/assets/docs/tree/template-doc-overview.doc.mjs +5 -16
- package/assets/docs/tree/template-fonts.doc.mjs +1 -1
- package/assets/docs/tree/template-icons.doc.mjs +1 -1
- package/assets/docs/tree/template-images-media.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +2 -2
- package/assets/docs/tree/templates.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
- package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
- package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
- package/assets/docs/tree/troubleshooting.doc.mjs +16 -8
- package/assets/docs/tree/type-scale.doc.mjs +3 -3
- package/assets/docs/tree/upgrading.doc.mjs +4 -4
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +7 -6
- package/assets/docs/tree/write-the-template-file.doc.mjs +4 -3
- package/assets/docs/use-a-theme.doc.mjs +2 -2
- package/assets/docs/working-with-ai.doc.mjs +43 -4
- package/assets/theme.template.ts +1 -1
- package/authoring/codemod/codemod.doc.mjs +7 -3
- package/authoring/config/config.doc.mjs +9 -6
- package/authoring/config/type.ts +4 -2
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
- package/authoring/doctypes/command/command.doc.mjs +14 -12
- package/authoring/doctypes/component/component.doc.mjs +30 -27
- package/authoring/doctypes/component/type.ts +21 -8
- package/authoring/doctypes/enum/enum.doc.mjs +7 -4
- package/authoring/doctypes/function/function.doc.mjs +9 -8
- package/authoring/doctypes/hook/hook.doc.mjs +5 -4
- package/authoring/doctypes/hook/type.ts +4 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
- package/authoring/doctypes/reference/reference.doc.mjs +11 -10
- package/authoring/doctypes/schema/schema.doc.mjs +9 -9
- package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
- package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
- package/authoring/doctypes/template/parse.d.mts +6 -2
- package/authoring/doctypes/template/parse.mjs +3 -1
- package/authoring/doctypes/template/template.doc.mjs +3 -3
- package/authoring/doctypes/template/type.ts +22 -0
- package/authoring/doctypes/theme/theme.doc.mjs +2 -2
- package/authoring/gap-report/gap-report.doc.mjs +2 -2
- package/authoring/identity/identity.doc.mjs +3 -3
- package/authoring/index.d.ts +1 -0
- package/authoring/integration/integration.doc.mjs +12 -4
- package/authoring/integration/parse.test.mjs +10 -0
- package/authoring/integration/schema.d.mts +2 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +4 -0
- package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
- package/clients/cli/commands/build-theme.mjs +1 -1
- package/clients/cli/commands/build-theme.path-safety.test.mjs +224 -6
- package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
- package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
- package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
- package/clients/cli/commands/discover.doc.mjs +1 -1
- package/clients/cli/commands/discover.mjs +144 -93
- package/clients/cli/commands/discover.no-source.test.mjs +447 -33
- package/clients/cli/commands/discover.sources.test.mjs +20 -1
- package/clients/cli/commands/doctor-integration-components.doc.mjs +18 -4
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +19 -5
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
- package/clients/cli/commands/doctor-integration.test.mjs +884 -0
- package/clients/cli/commands/doctor.mjs +281 -5
- package/clients/cli/commands/gap-report.doc.mjs +14 -2
- package/clients/cli/commands/gap-report.mjs +24 -2
- package/clients/cli/commands/gap-report.test.mjs +79 -0
- package/clients/cli/commands/integration-authoring.test.mjs +46 -0
- package/clients/cli/commands/integration-check.doc.mjs +85 -0
- package/clients/cli/commands/integration-check.test.mjs +411 -0
- package/clients/cli/commands/integration.doc.mjs +6 -2
- package/clients/cli/commands/integration.mjs +116 -5
- package/clients/cli/commands/json-contract.test.mjs +5 -1
- package/clients/cli/commands/setup-nudge.test.mjs +79 -1
- package/clients/cli/commands/swizzle.mjs +5 -3
- package/clients/cli/commands/swizzle.routing.test.mjs +18 -1
- package/clients/cli/commands/text-json-parity.test.mjs +5 -0
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/commands/upgrade.doc.mjs +14 -0
- package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
- package/clients/cli/index.mjs +30 -5
- package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
- package/foundation/agent-docs/agent-doc-state.mjs +38 -0
- package/foundation/agent-docs/agent-docs.d.mts +2 -1
- package/foundation/agent-docs/agent-docs.mjs +8 -6
- package/foundation/config/project.mjs +82 -0
- package/foundation/discovery/authoring-self-docs.mjs +2 -1
- package/foundation/discovery/component-discovery.d.mts +190 -10
- package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
- package/foundation/discovery/component-discovery.mjs +864 -56
- package/foundation/discovery/component-discovery.test.mjs +96 -0
- package/foundation/discovery/component-replacement.mjs +18 -0
- package/foundation/discovery/component-replacement.test.mjs +40 -0
- package/foundation/discovery/copied-passages.d.mts +216 -0
- package/foundation/discovery/copied-passages.mjs +720 -0
- package/foundation/discovery/copied-passages.test.mjs +124 -0
- package/foundation/discovery/doc-consistency.d.mts +34 -0
- package/foundation/discovery/doc-consistency.mjs +513 -0
- package/foundation/discovery/doc-consistency.test.mjs +347 -0
- package/foundation/discovery/doc-fluff.d.mts +112 -0
- package/foundation/discovery/doc-fluff.mjs +328 -0
- package/foundation/discovery/doc-fluff.test.mjs +142 -0
- package/foundation/discovery/doc-types.d.mts +157 -0
- package/foundation/discovery/doc-types.mjs +1231 -0
- package/foundation/discovery/doc-types.test.mjs +744 -0
- package/foundation/discovery/docs-discovery.d.mts +88 -0
- package/foundation/discovery/docs-discovery.mjs +83 -2
- package/foundation/discovery/integration-doc-files.d.mts +22 -0
- package/foundation/discovery/integration-doc-files.mjs +231 -0
- package/foundation/discovery/integration-doc-files.test.mjs +246 -0
- package/foundation/discovery/module-exports.d.mts +27 -0
- package/foundation/discovery/module-exports.mjs +356 -31
- package/foundation/discovery/module-exports.test.mjs +172 -0
- package/foundation/discovery/package-tsconfig.d.mts +14 -0
- package/foundation/discovery/package-tsconfig.mjs +228 -0
- package/foundation/discovery/package-tsconfig.test.mjs +210 -0
- package/foundation/discovery/project-typescript.d.mts +32 -0
- package/foundation/discovery/project-typescript.mjs +89 -0
- package/foundation/discovery/prop-drift.d.mts +297 -0
- package/foundation/discovery/prop-drift.mjs +2428 -0
- package/foundation/discovery/prop-drift.test.mjs +2337 -0
- package/foundation/discovery/stray-pointers.d.mts +52 -0
- package/foundation/discovery/stray-pointers.mjs +293 -0
- package/foundation/discovery/stray-pointers.test.mjs +86 -0
- package/foundation/discovery/type-match.d.mts +53 -0
- package/foundation/discovery/type-match.mjs +660 -0
- package/foundation/discovery/type-match.test.mjs +169 -0
- package/foundation/discovery/type-text.d.mts +68 -0
- package/foundation/discovery/type-text.mjs +658 -0
- package/foundation/discovery/type-text.test.mjs +196 -0
- package/foundation/discovery/unresolved-references.d.mts +62 -0
- package/foundation/discovery/unresolved-references.mjs +790 -0
- package/foundation/discovery/unresolved-references.test.mjs +567 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +30 -0
- package/foundation/doc-compiler/inputs.mjs +23 -0
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/links.d.mts +41 -5
- package/foundation/doc-compiler/links.mjs +167 -28
- package/foundation/doc-compiler/links.test.mjs +97 -4
- package/foundation/doc-compiler/tree.mjs +30 -1
- package/foundation/doc-compiler/tree.test.mjs +7 -0
- package/foundation/env/package-manager.d.mts +32 -0
- package/foundation/env/package-manager.mjs +47 -0
- package/foundation/env/package-manager.test.mjs +194 -7
- package/foundation/fs/module-loader.d.mts +2 -1
- package/foundation/fs/module-loader.mjs +60 -4
- package/foundation/fs/module-loader.test.mjs +194 -0
- package/foundation/integrations/contribution-inventory.d.mts +11 -0
- package/foundation/integrations/contribution-inventory.mjs +56 -3
- package/foundation/integrations/issue.ts +6 -0
- package/foundation/integrations/validate-contributions.mjs +30 -1
- package/foundation/response/response-types.doc.mjs +15 -9
- package/foundation/xle/registry.mjs +4 -0
- package/foundation/xle/registry.test.mjs +28 -0
- package/package.json +11 -11
- 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']});
|
|
@@ -754,6 +1104,285 @@ describe('integrationPackCheck', () => {
|
|
|
754
1104
|
);
|
|
755
1105
|
});
|
|
756
1106
|
|
|
1107
|
+
it('checks the export a component doc names when its file is named otherwise', async () => {
|
|
1108
|
+
fs.writeFileSync(
|
|
1109
|
+
path.join(tmpDir, 'package.json'),
|
|
1110
|
+
`${JSON.stringify({
|
|
1111
|
+
name: '@acme/widgets',
|
|
1112
|
+
version: '1.0.0',
|
|
1113
|
+
files: ['astryx.integration.mjs', 'components'],
|
|
1114
|
+
exports: {'./components/Slides': './components/Slides.tsx'},
|
|
1115
|
+
})}\n`,
|
|
1116
|
+
);
|
|
1117
|
+
fs.writeFileSync(
|
|
1118
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
1119
|
+
"export default {components: './components'};\n",
|
|
1120
|
+
);
|
|
1121
|
+
fs.mkdirSync(path.join(tmpDir, 'components'));
|
|
1122
|
+
// Slides.tsx exports AcmeCarousel and nothing named Slides.
|
|
1123
|
+
fs.writeFileSync(
|
|
1124
|
+
path.join(tmpDir, 'components', 'Slides.tsx'),
|
|
1125
|
+
'export function AcmeCarousel() { return null; }\n',
|
|
1126
|
+
);
|
|
1127
|
+
fs.writeFileSync(
|
|
1128
|
+
path.join(tmpDir, 'components', 'Slides.doc.mjs'),
|
|
1129
|
+
"export default {type: 'component', name: 'AcmeCarousel', import: '@acme/widgets/components/Slides', description: 'x', props: []};\n",
|
|
1130
|
+
);
|
|
1131
|
+
|
|
1132
|
+
const result = await integrationPackCheck({cwd: tmpDir});
|
|
1133
|
+
expect(result.data.packable).toBe(true);
|
|
1134
|
+
expect(result.data.contributions.packed.components).toEqual([
|
|
1135
|
+
'AcmeCarousel',
|
|
1136
|
+
]);
|
|
1137
|
+
});
|
|
1138
|
+
|
|
1139
|
+
it('checks each family member against the module its family doc imports', async () => {
|
|
1140
|
+
fs.writeFileSync(
|
|
1141
|
+
path.join(tmpDir, 'package.json'),
|
|
1142
|
+
`${JSON.stringify({
|
|
1143
|
+
name: '@acme/widgets',
|
|
1144
|
+
version: '1.0.0',
|
|
1145
|
+
files: ['astryx.integration.mjs', 'components'],
|
|
1146
|
+
exports: {'./tabs': './components/tabs/index.ts'},
|
|
1147
|
+
})}\n`,
|
|
1148
|
+
);
|
|
1149
|
+
fs.writeFileSync(
|
|
1150
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
1151
|
+
"export default {components: './components'};\n",
|
|
1152
|
+
);
|
|
1153
|
+
const dir = path.join(tmpDir, 'components', 'tabs');
|
|
1154
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
1155
|
+
fs.writeFileSync(
|
|
1156
|
+
path.join(dir, 'AcmeTabs.tsx'),
|
|
1157
|
+
'export function AcmeTabs() { return null; }\nexport function AcmeTabsLegacy() { return null; }\n',
|
|
1158
|
+
);
|
|
1159
|
+
fs.writeFileSync(
|
|
1160
|
+
path.join(dir, 'tab.tsx'),
|
|
1161
|
+
'export function AcmeTab() { return null; }\n',
|
|
1162
|
+
);
|
|
1163
|
+
// The module apps import exports AcmeTabs and AcmeTab, not AcmeTabsLegacy.
|
|
1164
|
+
fs.writeFileSync(
|
|
1165
|
+
path.join(dir, 'index.ts'),
|
|
1166
|
+
"export {AcmeTabs} from './AcmeTabs';\nexport {AcmeTab} from './tab';\n",
|
|
1167
|
+
);
|
|
1168
|
+
fs.writeFileSync(
|
|
1169
|
+
path.join(dir, 'AcmeTabs.doc.mjs'),
|
|
1170
|
+
"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",
|
|
1171
|
+
);
|
|
1172
|
+
|
|
1173
|
+
const result = await integrationPackCheck({cwd: tmpDir});
|
|
1174
|
+
|
|
1175
|
+
expect(result.data.issues).toEqual([]);
|
|
1176
|
+
expect(result.data.packable).toBe(true);
|
|
1177
|
+
expect(result.data.contributions.packed.components).toEqual([
|
|
1178
|
+
'AcmeTab',
|
|
1179
|
+
'AcmeTabs',
|
|
1180
|
+
]);
|
|
1181
|
+
});
|
|
1182
|
+
|
|
1183
|
+
it.each([
|
|
1184
|
+
'a clean checkout',
|
|
1185
|
+
'a stale build',
|
|
1186
|
+
'a stale build that exports more',
|
|
1187
|
+
])(
|
|
1188
|
+
'reads members a family imports from output its pack lifecycle builds, from %s',
|
|
1189
|
+
async start => {
|
|
1190
|
+
fs.writeFileSync(
|
|
1191
|
+
path.join(tmpDir, 'package.json'),
|
|
1192
|
+
`${JSON.stringify({
|
|
1193
|
+
name: '@acme/widgets',
|
|
1194
|
+
version: '1.0.0',
|
|
1195
|
+
files: ['astryx.integration.mjs', 'components', 'dist'],
|
|
1196
|
+
exports: {'./tabs': './dist/tabs/index.mjs'},
|
|
1197
|
+
scripts: {prepack: 'node build.mjs'},
|
|
1198
|
+
})}\n`,
|
|
1199
|
+
);
|
|
1200
|
+
fs.writeFileSync(
|
|
1201
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
1202
|
+
"export default {components: './components'};\n",
|
|
1203
|
+
);
|
|
1204
|
+
// The build writes the module the family imports; a clean checkout has none.
|
|
1205
|
+
fs.writeFileSync(
|
|
1206
|
+
path.join(tmpDir, 'build.mjs'),
|
|
1207
|
+
"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",
|
|
1208
|
+
);
|
|
1209
|
+
const dir = path.join(tmpDir, 'components', 'tabs');
|
|
1210
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
1211
|
+
fs.writeFileSync(
|
|
1212
|
+
path.join(dir, 'AcmeTabs.tsx'),
|
|
1213
|
+
'export function AcmeTabs() { return null; }\nexport function AcmeTab() { return null; }\nexport function AcmeTabLegacy() { return null; }\n',
|
|
1214
|
+
);
|
|
1215
|
+
fs.writeFileSync(
|
|
1216
|
+
path.join(dir, 'AcmeTabs.doc.mjs'),
|
|
1217
|
+
"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",
|
|
1218
|
+
);
|
|
1219
|
+
|
|
1220
|
+
if (start !== 'a clean checkout') {
|
|
1221
|
+
// An earlier build: before AcmeTab was exported, or while AcmeTabLegacy
|
|
1222
|
+
// still was.
|
|
1223
|
+
const names =
|
|
1224
|
+
start === 'a stale build'
|
|
1225
|
+
? 'AcmeTabs'
|
|
1226
|
+
: 'AcmeTabs, AcmeTab, AcmeTabLegacy';
|
|
1227
|
+
fs.mkdirSync(path.join(tmpDir, 'dist', 'tabs'), {recursive: true});
|
|
1228
|
+
fs.writeFileSync(
|
|
1229
|
+
path.join(tmpDir, 'dist', 'tabs', 'index.mjs'),
|
|
1230
|
+
`export {${names}} from '../../components/tabs/AcmeTabs.tsx';\n`,
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
const result = await integrationPackCheck({cwd: tmpDir});
|
|
1235
|
+
|
|
1236
|
+
expect(result.data.issues).toEqual([]);
|
|
1237
|
+
expect(result.data.packable).toBe(true);
|
|
1238
|
+
expect(result.data.contributions.local.components).toEqual(
|
|
1239
|
+
result.data.contributions.packed.components,
|
|
1240
|
+
);
|
|
1241
|
+
},
|
|
1242
|
+
);
|
|
1243
|
+
|
|
1244
|
+
it.each(['a clean checkout', 'an incremental build'])(
|
|
1245
|
+
'reads members built output re-exports from compiled files, from %s',
|
|
1246
|
+
async start => {
|
|
1247
|
+
fs.writeFileSync(
|
|
1248
|
+
path.join(tmpDir, 'package.json'),
|
|
1249
|
+
`${JSON.stringify({
|
|
1250
|
+
name: '@acme/widgets',
|
|
1251
|
+
version: '1.0.0',
|
|
1252
|
+
files: ['astryx.integration.mjs', 'components', 'dist'],
|
|
1253
|
+
exports: {'./tabs': './dist/tabs/index.mjs'},
|
|
1254
|
+
scripts: {prepack: 'node build.mjs'},
|
|
1255
|
+
})}\n`,
|
|
1256
|
+
);
|
|
1257
|
+
fs.writeFileSync(
|
|
1258
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
1259
|
+
"export default {components: './components'};\n",
|
|
1260
|
+
);
|
|
1261
|
+
// The build compiles each source to its own file and, like an
|
|
1262
|
+
// incremental build, rewrites only the files whose output changed.
|
|
1263
|
+
const output = {
|
|
1264
|
+
'index.mjs':
|
|
1265
|
+
"export {AcmeTabs} from './tabs.mjs';\nexport * from './tab.mjs';\n",
|
|
1266
|
+
'tabs.mjs': 'export function AcmeTabs() { return null; }\n',
|
|
1267
|
+
'tab.mjs': 'export function AcmeTab() { return null; }\n',
|
|
1268
|
+
};
|
|
1269
|
+
fs.writeFileSync(
|
|
1270
|
+
path.join(tmpDir, 'build.mjs'),
|
|
1271
|
+
`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`,
|
|
1272
|
+
);
|
|
1273
|
+
const dir = path.join(tmpDir, 'components', 'tabs');
|
|
1274
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
1275
|
+
fs.writeFileSync(
|
|
1276
|
+
path.join(dir, 'AcmeTabs.tsx'),
|
|
1277
|
+
'export function AcmeTabs() { return null; }\n',
|
|
1278
|
+
);
|
|
1279
|
+
fs.writeFileSync(
|
|
1280
|
+
path.join(dir, 'AcmeTab.tsx'),
|
|
1281
|
+
'export function AcmeTab() { return null; }\n',
|
|
1282
|
+
);
|
|
1283
|
+
fs.writeFileSync(
|
|
1284
|
+
path.join(dir, 'AcmeTabs.doc.mjs'),
|
|
1285
|
+
"export default {type: 'component', name: 'AcmeTabs', import: '@acme/widgets/tabs', description: 'x', components: [{name: 'AcmeTabs', description: 'x', props: []}, {name: 'AcmeTab', description: 'x', props: []}]};\n",
|
|
1286
|
+
);
|
|
1287
|
+
if (start === 'an incremental build') {
|
|
1288
|
+
// An earlier build from before AcmeTab existed: the file the import
|
|
1289
|
+
// names is already current, so the build leaves it untouched.
|
|
1290
|
+
fs.mkdirSync(path.join(tmpDir, 'dist', 'tabs'), {recursive: true});
|
|
1291
|
+
for (const [file, text] of Object.entries({...output, 'tab.mjs': ''})) {
|
|
1292
|
+
fs.writeFileSync(path.join(tmpDir, 'dist', 'tabs', file), text);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
const result = await integrationPackCheck({cwd: tmpDir});
|
|
1297
|
+
|
|
1298
|
+
expect(result.data.issues).toEqual([]);
|
|
1299
|
+
expect(result.data.packable).toBe(true);
|
|
1300
|
+
expect(result.data.contributions.packed.components).toEqual([
|
|
1301
|
+
'AcmeTab',
|
|
1302
|
+
'AcmeTabs',
|
|
1303
|
+
]);
|
|
1304
|
+
expect(result.data.contributions.local.components).toEqual(
|
|
1305
|
+
result.data.contributions.packed.components,
|
|
1306
|
+
);
|
|
1307
|
+
},
|
|
1308
|
+
);
|
|
1309
|
+
|
|
1310
|
+
it('passes a member another folder declares, which has no source', async () => {
|
|
1311
|
+
fs.writeFileSync(
|
|
1312
|
+
path.join(tmpDir, 'package.json'),
|
|
1313
|
+
`${JSON.stringify({
|
|
1314
|
+
name: '@acme/widgets',
|
|
1315
|
+
version: '1.0.0',
|
|
1316
|
+
files: ['astryx.integration.mjs', 'components'],
|
|
1317
|
+
exports: {'./menu': './components/menu/index.ts'},
|
|
1318
|
+
})}\n`,
|
|
1319
|
+
);
|
|
1320
|
+
fs.writeFileSync(
|
|
1321
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
1322
|
+
"export default {components: './components'};\n",
|
|
1323
|
+
);
|
|
1324
|
+
const menu = path.join(tmpDir, 'components', 'menu');
|
|
1325
|
+
const shared = path.join(tmpDir, 'components', 'shared');
|
|
1326
|
+
fs.mkdirSync(menu, {recursive: true});
|
|
1327
|
+
fs.mkdirSync(shared, {recursive: true});
|
|
1328
|
+
fs.writeFileSync(
|
|
1329
|
+
path.join(menu, 'AcmeMenu.doc.mjs'),
|
|
1330
|
+
"export default {type: 'component', name: 'AcmeMenu', import: '@acme/widgets/menu', description: 'x', components: [{name: 'AcmeMenuItem', description: 'x', props: []}]};\n",
|
|
1331
|
+
);
|
|
1332
|
+
fs.writeFileSync(
|
|
1333
|
+
path.join(menu, 'AcmeMenu.tsx'),
|
|
1334
|
+
'export function AcmeMenu() { return null; }\n',
|
|
1335
|
+
);
|
|
1336
|
+
fs.writeFileSync(
|
|
1337
|
+
path.join(menu, 'index.ts'),
|
|
1338
|
+
"export {AcmeMenu} from './AcmeMenu';\nexport {AcmeMenuItem} from '../shared/AcmeMenuItem';\n",
|
|
1339
|
+
);
|
|
1340
|
+
fs.writeFileSync(
|
|
1341
|
+
path.join(shared, 'AcmeMenuItem.tsx'),
|
|
1342
|
+
'export function AcmeMenuItem() { return null; }\n',
|
|
1343
|
+
);
|
|
1344
|
+
|
|
1345
|
+
const result = await integrationPackCheck({cwd: tmpDir});
|
|
1346
|
+
|
|
1347
|
+
expect(result.data.issues).toEqual([]);
|
|
1348
|
+
expect(result.data.packable).toBe(true);
|
|
1349
|
+
expect(result.data.contributions.packed.components).toEqual([
|
|
1350
|
+
'AcmeMenu',
|
|
1351
|
+
'AcmeMenuItem',
|
|
1352
|
+
]);
|
|
1353
|
+
});
|
|
1354
|
+
|
|
1355
|
+
it('reports a family doc the loader rejects once, not once per member', async () => {
|
|
1356
|
+
fs.writeFileSync(
|
|
1357
|
+
path.join(tmpDir, 'package.json'),
|
|
1358
|
+
`${JSON.stringify({
|
|
1359
|
+
name: '@acme/widgets',
|
|
1360
|
+
version: '1.0.0',
|
|
1361
|
+
files: ['astryx.integration.mjs', 'components'],
|
|
1362
|
+
})}\n`,
|
|
1363
|
+
);
|
|
1364
|
+
fs.writeFileSync(
|
|
1365
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
1366
|
+
"export default {components: './components'};\n",
|
|
1367
|
+
);
|
|
1368
|
+
fs.mkdirSync(path.join(tmpDir, 'components'));
|
|
1369
|
+
fs.writeFileSync(
|
|
1370
|
+
path.join(tmpDir, 'components', 'AcmeTabs.tsx'),
|
|
1371
|
+
'export function AcmeTabs() { return null; }\nexport function AcmeTab() { return null; }\nexport function AcmeTabPanel() { return null; }\n',
|
|
1372
|
+
);
|
|
1373
|
+
// A displayName that is not a string makes the loader reject the doc.
|
|
1374
|
+
fs.writeFileSync(
|
|
1375
|
+
path.join(tmpDir, 'components', 'AcmeTabs.doc.mjs'),
|
|
1376
|
+
"export default {type: 'component', name: 'AcmeTabs', displayName: 1, description: 'x', components: [{name: 'AcmeTab', description: 'x', props: []}, {name: 'AcmeTabPanel', description: 'x', props: []}]};\n",
|
|
1377
|
+
);
|
|
1378
|
+
|
|
1379
|
+
const result = await integrationPackCheck({cwd: tmpDir});
|
|
1380
|
+
const codes = result.data.issues.map(issue => issue.code);
|
|
1381
|
+
|
|
1382
|
+
expect(codes).toContain('component_doc_unloadable');
|
|
1383
|
+
expect(codes.length).toBe(new Set(codes).size);
|
|
1384
|
+
});
|
|
1385
|
+
|
|
757
1386
|
it('passes a generated component through its exact packed export', async () => {
|
|
758
1387
|
fs.writeFileSync(
|
|
759
1388
|
path.join(tmpDir, 'package.json'),
|
|
@@ -811,6 +1440,86 @@ describe('integrationPackCheck', () => {
|
|
|
811
1440
|
);
|
|
812
1441
|
});
|
|
813
1442
|
|
|
1443
|
+
it('does not count a type-only re-export as the component', async () => {
|
|
1444
|
+
fs.writeFileSync(
|
|
1445
|
+
path.join(tmpDir, 'package.json'),
|
|
1446
|
+
`${JSON.stringify({
|
|
1447
|
+
name: '@acme/widgets',
|
|
1448
|
+
version: '1.0.0',
|
|
1449
|
+
files: ['astryx.integration.mjs', 'src'],
|
|
1450
|
+
exports: {'.': './src/index.ts'},
|
|
1451
|
+
})}\n`,
|
|
1452
|
+
);
|
|
1453
|
+
fs.writeFileSync(
|
|
1454
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
1455
|
+
"export default {components: './src'};\n",
|
|
1456
|
+
);
|
|
1457
|
+
fs.mkdirSync(path.join(tmpDir, 'src'));
|
|
1458
|
+
fs.writeFileSync(
|
|
1459
|
+
path.join(tmpDir, 'src', 'index.ts'),
|
|
1460
|
+
"export type {AcmeWidget} from './AcmeWidget';\n",
|
|
1461
|
+
);
|
|
1462
|
+
fs.writeFileSync(
|
|
1463
|
+
path.join(tmpDir, 'src', 'AcmeWidget.tsx'),
|
|
1464
|
+
'export function AcmeWidget() { return null; }\n',
|
|
1465
|
+
);
|
|
1466
|
+
fs.writeFileSync(
|
|
1467
|
+
path.join(tmpDir, 'src', 'AcmeWidget.doc.mjs'),
|
|
1468
|
+
"export default {type: 'component', name: 'AcmeWidget', import: '@acme/widgets', description: 'Widget.', props: []};\n",
|
|
1469
|
+
);
|
|
1470
|
+
|
|
1471
|
+
const result = await integrationPackCheck({cwd: tmpDir});
|
|
1472
|
+
|
|
1473
|
+
expect(result.data.issues).toContainEqual(
|
|
1474
|
+
expect.objectContaining({code: 'component_export_missing'}),
|
|
1475
|
+
);
|
|
1476
|
+
});
|
|
1477
|
+
|
|
1478
|
+
it('follows a re-export of a folder to its index file', async () => {
|
|
1479
|
+
// `./primitives` names a folder: TypeScript and bundlers load its index file.
|
|
1480
|
+
fs.writeFileSync(
|
|
1481
|
+
path.join(tmpDir, 'package.json'),
|
|
1482
|
+
`${JSON.stringify({
|
|
1483
|
+
name: '@acme/widgets',
|
|
1484
|
+
version: '1.0.0',
|
|
1485
|
+
files: ['astryx.integration.mjs', 'src'],
|
|
1486
|
+
exports: {'.': './src/index.ts'},
|
|
1487
|
+
})}\n`,
|
|
1488
|
+
);
|
|
1489
|
+
fs.writeFileSync(
|
|
1490
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
1491
|
+
"export default {components: './src'};\n",
|
|
1492
|
+
);
|
|
1493
|
+
const primitives = path.join(tmpDir, 'src', 'primitives');
|
|
1494
|
+
fs.mkdirSync(primitives, {recursive: true});
|
|
1495
|
+
fs.writeFileSync(
|
|
1496
|
+
path.join(tmpDir, 'src', 'index.ts'),
|
|
1497
|
+
"export * from './primitives';\n",
|
|
1498
|
+
);
|
|
1499
|
+
fs.writeFileSync(
|
|
1500
|
+
path.join(primitives, 'index.ts'),
|
|
1501
|
+
"export * from './AcmeWidget';\n",
|
|
1502
|
+
);
|
|
1503
|
+
fs.writeFileSync(
|
|
1504
|
+
path.join(primitives, 'AcmeWidget.tsx'),
|
|
1505
|
+
'export function AcmeWidget() { return null; }\n',
|
|
1506
|
+
);
|
|
1507
|
+
fs.writeFileSync(
|
|
1508
|
+
path.join(primitives, 'AcmeWidget.doc.mjs'),
|
|
1509
|
+
"export default {type: 'component', name: 'AcmeWidget', import: '@acme/widgets', description: 'Widget.', props: []};\n",
|
|
1510
|
+
);
|
|
1511
|
+
|
|
1512
|
+
const result = await integrationPackCheck({cwd: tmpDir});
|
|
1513
|
+
|
|
1514
|
+
expect(result.data.issues).not.toContainEqual(
|
|
1515
|
+
expect.objectContaining({code: 'component_export_missing'}),
|
|
1516
|
+
);
|
|
1517
|
+
expect(
|
|
1518
|
+
result.data.packable,
|
|
1519
|
+
JSON.stringify(result.data.issues, null, 2),
|
|
1520
|
+
).toBe(true);
|
|
1521
|
+
});
|
|
1522
|
+
|
|
814
1523
|
it('fails when packed template source is hidden by package exports', async () => {
|
|
815
1524
|
writePackage({
|
|
816
1525
|
manifest: "export default {templates: './templates'};\n",
|
|
@@ -1199,6 +1908,23 @@ describe('integrationPackCheck', () => {
|
|
|
1199
1908
|
expect(sourceWarnings[0].message).toContain('Card.tsx');
|
|
1200
1909
|
});
|
|
1201
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
|
+
|
|
1202
1928
|
it('cleans up its scratch consumer when npm pack fails', async () => {
|
|
1203
1929
|
writePackage({
|
|
1204
1930
|
files: ['astryx.integration.mjs', 'themes'],
|