@astryxdesign/cli 0.7.2-canary.a7d26b7 → 0.7.2-canary.acfd1ff
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/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/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 +11 -0
- package/api/docs/_adapter.mjs +244 -1
- package/api/docs/integrationDocs.test.mjs +124 -0
- 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 +152 -48
- 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 +32 -0
- package/api/integration/_adapter.mjs +80 -0
- package/api/integration/add-contribution.mjs +1 -1
- package/api/integration/add-contribution.test.mjs +4 -2
- package/api/integration/authoring-checks.mjs +44 -4
- package/api/integration/authoring-checks.test.mjs +515 -0
- package/api/integration/authoring-checks.type.d.mts +95 -0
- package/api/integration/authoring-checks.type.mjs +53 -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 +43 -6
- package/api/integration/integrationDocConflicts.doc.mjs +19 -5
- package/api/integration/pack-check.mjs +292 -7
- package/api/integration/pack-check.test.mjs +367 -0
- package/api/integration/validate-integration-fixes.test.mjs +67 -0
- package/api/integration/validate-integration.mjs +8 -0
- package/api/integration/validate-integration.test.mjs +41 -0
- 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 +72 -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 +501 -37
- package/api/search/search.test.mjs +139 -0
- package/api/theme/build/build.family.test.mjs +54 -6
- package/api/theme/build/build.mjs +114 -17
- 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 +1 -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 +196 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +61 -7
- package/assets/docs/tree/checks.doc.mjs +25 -17
- package/assets/docs/tree/codemods.doc.mjs +4 -4
- package/assets/docs/tree/component-family.doc.mjs +3 -5
- package/assets/docs/tree/component-imports.doc.mjs +2 -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 +1 -1
- 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 +14 -5
- 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 +8 -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 +6 -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/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 +29 -26
- package/authoring/doctypes/component/type.ts +7 -5
- 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/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 +155 -21
- 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 +17 -4
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +18 -5
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
- package/clients/cli/commands/doctor-integration.test.mjs +837 -0
- package/clients/cli/commands/doctor.mjs +250 -3
- 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-check.doc.mjs +85 -0
- package/clients/cli/commands/integration-check.test.mjs +370 -0
- package/clients/cli/commands/integration.doc.mjs +6 -2
- package/clients/cli/commands/integration.mjs +106 -1
- 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 +18 -0
- package/foundation/discovery/component-discovery.mjs +2 -2
- 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-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 +1224 -0
- package/foundation/discovery/doc-types.test.mjs +700 -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/project-typescript.d.mts +11 -2
- package/foundation/discovery/project-typescript.mjs +32 -4
- package/foundation/discovery/prop-drift.d.mts +278 -0
- package/foundation/discovery/prop-drift.mjs +2263 -0
- package/foundation/discovery/prop-drift.test.mjs +2272 -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/doc-compiler/doc-loads.test.mjs +16 -2
- package/foundation/doc-compiler/links.d.mts +9 -5
- package/foundation/doc-compiler/links.mjs +4 -2
- 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 +50 -2
- package/foundation/integrations/validate-contributions.mjs +30 -1
- package/foundation/response/response-types.doc.mjs +14 -8
- 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']});
|
|
@@ -1558,6 +1908,23 @@ describe('integrationPackCheck', () => {
|
|
|
1558
1908
|
expect(sourceWarnings[0].message).toContain('Card.tsx');
|
|
1559
1909
|
});
|
|
1560
1910
|
|
|
1911
|
+
it('reports template sources without metadata as warnings', async () => {
|
|
1912
|
+
writePackage({
|
|
1913
|
+
manifest:
|
|
1914
|
+
"export default {themes: './themes', templates: './templates'};\n",
|
|
1915
|
+
files: ['astryx.integration.mjs', 'themes', 'templates'],
|
|
1916
|
+
templates: true,
|
|
1917
|
+
});
|
|
1918
|
+
const result = await integrationPackCheck({cwd: tmpDir});
|
|
1919
|
+
|
|
1920
|
+
const sourceWarnings = result.data.issues.filter(
|
|
1921
|
+
issue => issue.code === 'source_without_template_doc',
|
|
1922
|
+
);
|
|
1923
|
+
expect(sourceWarnings).toHaveLength(1);
|
|
1924
|
+
expect(sourceWarnings[0].severity).toBe('warning');
|
|
1925
|
+
expect(sourceWarnings[0].message).toContain('stray.tsx');
|
|
1926
|
+
});
|
|
1927
|
+
|
|
1561
1928
|
it('cleans up its scratch consumer when npm pack fails', async () => {
|
|
1562
1929
|
writePackage({
|
|
1563
1930
|
files: ['astryx.integration.mjs', 'themes'],
|
|
@@ -37,6 +37,8 @@ const componentDoc = name =>
|
|
|
37
37
|
`export default {type: 'component', name: '${name}', displayName: '${name}', usage: {description: '${name}.'}, props: []};\n`;
|
|
38
38
|
/** @param {string} name */
|
|
39
39
|
const componentSource = name => `export function ${name}() { return null; }\n`;
|
|
40
|
+
const templateSource = name =>
|
|
41
|
+
`export default function ${name}() { return null; }\n`;
|
|
40
42
|
/** @param {string} name */
|
|
41
43
|
const topic = name =>
|
|
42
44
|
`export default ${JSON.stringify({
|
|
@@ -1131,6 +1133,71 @@ describe('source_without_component_doc fixes hold when followed', () => {
|
|
|
1131
1133
|
});
|
|
1132
1134
|
});
|
|
1133
1135
|
|
|
1136
|
+
describe('source_without_template_doc fixes hold when followed', () => {
|
|
1137
|
+
it('adds the named doc, which resolves the warning', async () => {
|
|
1138
|
+
const dir = writePackage({
|
|
1139
|
+
[MANIFEST]: manifest({templates: './templates'}),
|
|
1140
|
+
'templates/hero.tsx': templateSource('Hero'),
|
|
1141
|
+
'templates/hero.test.tsx': templateSource('HeroTest'),
|
|
1142
|
+
});
|
|
1143
|
+
|
|
1144
|
+
const message = only(await issuesOf(dir), 'source_without_template_doc');
|
|
1145
|
+
expect(message).toBe(
|
|
1146
|
+
"Template source \"hero.tsx\" has no same-stem metadata file hero.doc.mjs, so `astryx template` never lists it. Fix: add hero.doc.mjs beside it with type: 'page' or 'block'; `astryx docs authoring integration-template-doc` lists its fields. If it is not a template, move it out of the templates root.",
|
|
1147
|
+
);
|
|
1148
|
+
|
|
1149
|
+
const fixed = follow(dir, {
|
|
1150
|
+
write: {
|
|
1151
|
+
'templates/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
|
|
1152
|
+
},
|
|
1153
|
+
});
|
|
1154
|
+
expect(await issuesOf(fixed)).toEqual([]);
|
|
1155
|
+
});
|
|
1156
|
+
|
|
1157
|
+
it('checks a dotted template id, but no test, spec or story file', async () => {
|
|
1158
|
+
const dir = writePackage({
|
|
1159
|
+
[MANIFEST]: manifest({templates: './templates'}),
|
|
1160
|
+
'templates/landing.page.tsx': templateSource('LandingPage'),
|
|
1161
|
+
'templates/hero.test.tsx': templateSource('HeroTest'),
|
|
1162
|
+
'templates/hero.spec.tsx': templateSource('HeroSpec'),
|
|
1163
|
+
'templates/hero.stories.tsx': templateSource('HeroStories'),
|
|
1164
|
+
});
|
|
1165
|
+
|
|
1166
|
+
const message = only(await issuesOf(dir), 'source_without_template_doc');
|
|
1167
|
+
expect(message).toContain(
|
|
1168
|
+
'Template source "landing.page.tsx" has no same-stem metadata file landing.page.doc.mjs',
|
|
1169
|
+
);
|
|
1170
|
+
|
|
1171
|
+
const fixed = follow(dir, {
|
|
1172
|
+
write: {
|
|
1173
|
+
'templates/landing.page.doc.mjs': `export default {type: 'page', name: 'landing.page', displayName: 'Landing'};\n`,
|
|
1174
|
+
},
|
|
1175
|
+
});
|
|
1176
|
+
expect(await issuesOf(fixed)).toEqual([]);
|
|
1177
|
+
});
|
|
1178
|
+
|
|
1179
|
+
it('never flags a helper in a subfolder of the templates root', async () => {
|
|
1180
|
+
const dir = writePackage({
|
|
1181
|
+
[MANIFEST]: manifest({templates: './templates'}),
|
|
1182
|
+
'templates/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
|
|
1183
|
+
'templates/hero.tsx': templateSource('Hero'),
|
|
1184
|
+
'templates/hero/HeroCard.tsx': templateSource('HeroCard'),
|
|
1185
|
+
});
|
|
1186
|
+
|
|
1187
|
+
expect(await issuesOf(dir)).toEqual([]);
|
|
1188
|
+
});
|
|
1189
|
+
|
|
1190
|
+
it('accepts a released .template.mjs spec as the metadata', async () => {
|
|
1191
|
+
const dir = writePackage({
|
|
1192
|
+
[MANIFEST]: manifest({templates: './templates'}),
|
|
1193
|
+
'templates/hero.tsx': templateSource('Hero'),
|
|
1194
|
+
'templates/hero.template.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
|
|
1195
|
+
});
|
|
1196
|
+
|
|
1197
|
+
expect(await issuesOf(dir)).toEqual([]);
|
|
1198
|
+
});
|
|
1199
|
+
});
|
|
1200
|
+
|
|
1134
1201
|
describe('codemod fixes hold when followed', () => {
|
|
1135
1202
|
it('moves a stray codemod into a version folder, and renames a mis-named one', async () => {
|
|
1136
1203
|
const dir = writePackage({
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
import * as fs from 'node:fs';
|
|
35
35
|
import * as path from 'node:path';
|
|
36
36
|
import {assertWithin} from '../../foundation/fs/path-safety.mjs';
|
|
37
|
+
import {integrationDocTypes} from '../docs/_adapter.mjs';
|
|
37
38
|
import {
|
|
38
39
|
THEME_SLUG_RE,
|
|
39
40
|
unreadThemeFolders,
|
|
@@ -461,6 +462,12 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
461
462
|
const result = pkg
|
|
462
463
|
? await validateInstalledIntegration(pkg, cwd)
|
|
463
464
|
: await validateLocalIntegration(cwd);
|
|
465
|
+
// Each doc the package ships, against the published authoring type for its
|
|
466
|
+
// kind, read with the project's own compiler. Findings are warnings only.
|
|
467
|
+
const integration = result.found ? result.integration : undefined;
|
|
468
|
+
const docTypes = integration
|
|
469
|
+
? await integrationDocTypes(integration, cwd)
|
|
470
|
+
: undefined;
|
|
464
471
|
return {
|
|
465
472
|
type: 'integration.validate',
|
|
466
473
|
data: {
|
|
@@ -472,6 +479,7 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
472
479
|
issues: result.reason === 'no_package_json'
|
|
473
480
|
? [{code: 'no_package', severity: 'error', message: 'No package.json found. Run this command inside a package directory.'}]
|
|
474
481
|
: result.issues,
|
|
482
|
+
...(docTypes ? {docTypes} : {}),
|
|
475
483
|
},
|
|
476
484
|
};
|
|
477
485
|
}
|
|
@@ -176,6 +176,17 @@ describe('validate-integration API', () => {
|
|
|
176
176
|
expect(agentDocsIssues[0].severity).toBe('error');
|
|
177
177
|
});
|
|
178
178
|
|
|
179
|
+
it('reports nothing for a docsiteUrl', async () => {
|
|
180
|
+
const pkgDir = path.join(tmpDir, 'pkg');
|
|
181
|
+
writePackage(pkgDir, {
|
|
182
|
+
manifest: `export default {docsiteUrl: 'https://widgets.example.com'};\n`,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const result = await validateLocalIntegration(pkgDir);
|
|
186
|
+
|
|
187
|
+
expect(result.issues).toEqual([]);
|
|
188
|
+
});
|
|
189
|
+
|
|
179
190
|
it('flags a broken codemod as invalid_codemod error', async () => {
|
|
180
191
|
const pkgDir = path.join(tmpDir, 'pkg');
|
|
181
192
|
writePackage(pkgDir, {
|
|
@@ -310,6 +321,36 @@ export default {type: 'theme', name: 'ocean', displayName: 'Ocean', description:
|
|
|
310
321
|
);
|
|
311
322
|
});
|
|
312
323
|
|
|
324
|
+
it('warns when a template source has no same-stem metadata, skipping test files', async () => {
|
|
325
|
+
const pkgDir = path.join(tmpDir, 'pkg');
|
|
326
|
+
writePackage(pkgDir, {
|
|
327
|
+
manifest: `export default { templates: './templates' };\n`,
|
|
328
|
+
});
|
|
329
|
+
fs.mkdirSync(path.join(pkgDir, 'templates'));
|
|
330
|
+
fs.writeFileSync(
|
|
331
|
+
path.join(pkgDir, 'templates', 'stray.tsx'),
|
|
332
|
+
'export default function Stray() { return null; }\n',
|
|
333
|
+
);
|
|
334
|
+
fs.writeFileSync(
|
|
335
|
+
path.join(pkgDir, 'templates', 'stray.test.tsx'),
|
|
336
|
+
"import {it} from 'vitest';\nit('renders', () => {});\n",
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
const result = await validateLocalIntegration(pkgDir);
|
|
340
|
+
|
|
341
|
+
const warnings = byCode(result.issues, 'source_without_template_doc');
|
|
342
|
+
expect(warnings).toEqual([
|
|
343
|
+
expect.objectContaining({
|
|
344
|
+
severity: 'warning',
|
|
345
|
+
message: expect.stringContaining('"stray.tsx"'),
|
|
346
|
+
}),
|
|
347
|
+
]);
|
|
348
|
+
expect(warnings[0].message).not.toContain('stray.test.tsx');
|
|
349
|
+
expect(warnings[0].message).toContain(
|
|
350
|
+
"Fix: add stray.doc.mjs beside it with type: 'page' or 'block'",
|
|
351
|
+
);
|
|
352
|
+
});
|
|
353
|
+
|
|
313
354
|
it('reports codemods outside semver folders and invalid folder names', async () => {
|
|
314
355
|
const pkgDir = path.join(tmpDir, 'pkg');
|
|
315
356
|
writePackage(pkgDir, {
|
|
@@ -39,5 +39,13 @@ export type ValidateIntegrationResponse = {
|
|
|
39
39
|
name: string | null;
|
|
40
40
|
version: string | null;
|
|
41
41
|
issues: import("../../foundation/integrations/issue").AstryxIntegrationIssue[];
|
|
42
|
+
docTypes?: DocTypesReport;
|
|
42
43
|
};
|
|
43
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* `fixtures`: how many test fixture docs (under `__tests__` in the
|
|
47
|
+
* components or docs root, which those readers skip) were not checked
|
|
48
|
+
*/
|
|
49
|
+
export type DocTypesReport = import("../../foundation/discovery/doc-types.mjs").DocTypesReport & {
|
|
50
|
+
fixtures?: number;
|
|
51
|
+
};
|
|
@@ -38,7 +38,18 @@
|
|
|
38
38
|
* "healthy" — the two are otherwise byte-identical.
|
|
39
39
|
* @typedef {object} ValidateIntegrationResponse
|
|
40
40
|
* @property {'integration.validate'} type
|
|
41
|
-
* @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
|
|
41
|
+
* @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], docTypes?: DocTypesReport}} data
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Each doc the package ships, checked against the published authoring type
|
|
46
|
+
* for its kind. Present when the manifest loads. `status: 'skipped'`
|
|
47
|
+
* means nothing was checked (no TypeScript in the project) and `reason` says
|
|
48
|
+
* why. Every finding is a warning.
|
|
49
|
+
*
|
|
50
|
+
* @typedef {import('../../foundation/discovery/doc-types.mjs').DocTypesReport & {fixtures?: number}} DocTypesReport
|
|
51
|
+
* `fixtures`: how many test fixture docs (under `__tests__` in the
|
|
52
|
+
* components or docs root, which those readers skip) were not checked
|
|
42
53
|
*/
|
|
43
54
|
|
|
44
55
|
export {};
|
|
@@ -23,11 +23,27 @@ export const doc = {
|
|
|
23
23
|
'declared contribution root exists, and runs the codemod/template/component/' +
|
|
24
24
|
'docs/theme validators, returning every finding as an AstryxIntegrationIssue. A missing ' +
|
|
25
25
|
'local manifest is guidance (name null, no issues), not an error, so callers ' +
|
|
26
|
-
'can stay exit-0 in a non-integration directory.'
|
|
26
|
+
'can stay exit-0 in a non-integration directory. It also checks every doc the ' +
|
|
27
|
+
'package ships under its roots (component, template, docs topic, theme, and translation, served or not) against ' +
|
|
28
|
+
"the published authoring type for its kind, as `tsc` would, with the project's " +
|
|
29
|
+
'own `typescript` (or, where `typescript` is missing or has no JavaScript compiler ' +
|
|
30
|
+
'API, as TypeScript 7 does, the `@typescript/typescript6` it installs): an unknown ' +
|
|
31
|
+
'field, a missing required field, or a value outside ' +
|
|
32
|
+
"a field's type is a warning in `docTypes` naming the field and a fix. A test " +
|
|
33
|
+
'fixture under `__tests__` in the components or docs root is counted, not checked. ' +
|
|
34
|
+
'Without TypeScript, `docTypes` is `skipped` with a reason.',
|
|
27
35
|
importPath: '@astryxdesign/cli/api',
|
|
28
36
|
signature:
|
|
29
37
|
'validateIntegration(pkg?: string, options?: ValidateIntegrationOptions): Promise<ValidateIntegrationResponse>',
|
|
30
|
-
keywords: [
|
|
38
|
+
keywords: [
|
|
39
|
+
'integration',
|
|
40
|
+
'validate',
|
|
41
|
+
'manifest',
|
|
42
|
+
'lint',
|
|
43
|
+
'check',
|
|
44
|
+
'types',
|
|
45
|
+
'typecheck',
|
|
46
|
+
],
|
|
31
47
|
params: [
|
|
32
48
|
{
|
|
33
49
|
name: 'pkg',
|
|
@@ -46,7 +62,7 @@ export const doc = {
|
|
|
46
62
|
{
|
|
47
63
|
type: 'integration.validate',
|
|
48
64
|
description:
|
|
49
|
-
'The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means "not looked at", not "healthy"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message}.',
|
|
65
|
+
'The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means "not looked at", not "healthy"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message}. When the manifest loads, `data.docTypes` holds the doc type check: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `docs` (doc values checked), `findings` ({doc, line, export, type, field, problem: `unknown_field` | `missing_field` | `wrong_type`, severity: `warning`, message, fix}), `unchecked` ({doc, reason}: a doc that could not be fully checked, or a root its reader cannot read), and `fixtures` when the components or docs root holds test fixture docs under `__tests__`: how many, none of them checked.',
|
|
50
66
|
},
|
|
51
67
|
],
|
|
52
68
|
examples: [
|