@astryxdesign/cli 0.7.2-canary.870a784 → 0.7.2-canary.95e1674
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 +19 -18
- package/api/build/help/help.mjs +1 -1
- 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/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 +12 -0
- package/api/integration/_adapter.mjs +54 -0
- package/api/integration/add-contribution.mjs +1 -1
- package/api/integration/add-contribution.test.mjs +4 -2
- package/api/integration/authoring-checks.mjs +11 -2
- package/api/integration/authoring-checks.test.mjs +39 -0
- package/api/integration/authoring-checks.type.d.mts +9 -0
- package/api/integration/authoring-checks.type.mjs +14 -1
- 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/validate-integration.mjs +8 -0
- package/api/integration/validate-integration.test.mjs +11 -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/docs/README.md +10 -0
- package/assets/docs/author-a-theme.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 +1 -1
- 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 +10 -7
- 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 +51 -5
- package/assets/docs/tree/checks.doc.mjs +23 -15
- 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 +25 -16
- 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/links.doc.mjs +6 -5
- package/assets/docs/tree/migration-setup.doc.mjs +1 -0
- 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 +1 -1
- package/assets/docs/tree/quick-start.doc.mjs +37 -21
- 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 +4 -6
- 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 +4 -15
- 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 +4 -4
- package/assets/docs/tree/type-scale.doc.mjs +3 -3
- package/assets/docs/tree/upgrading.doc.mjs +3 -3
- 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 +28 -25
- 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/doctor-integration-components.doc.mjs +17 -4
- 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 +190 -0
- 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 +284 -0
- package/clients/cli/commands/integration.doc.mjs +6 -2
- package/clients/cli/commands/integration.mjs +106 -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/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 +81 -0
- package/foundation/discovery/docs-discovery.mjs +57 -0
- 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/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 +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/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 +10 -0
- 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/response/response-types.doc.mjs +12 -6
- package/package.json +9 -9
- package/scripts/postinstall.mjs +3 -3
package/README.md
CHANGED
|
@@ -447,8 +447,8 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
447
447
|
| `build.kit` | The template to start from and its kit: query, hasResults, matchCount (never a cap), directMatch, start {name, package, command, basis, reason, alternatives, ...} (the start and each alternative name the package that owns the template), pages (search's closest templates), blocks and domain as SearchResultEntry[] (each naming its package), frame and foundation (Core component names), and hint {reason, commands} when thin. |
|
|
448
448
|
| `swizzle.list` | The names of swizzlable components discoverable from cwd's @astryxdesign/core. The envelope's package is @astryxdesign/core. |
|
|
449
449
|
| `swizzle.copy` | An eject receipt: component name, owning package, output directory, files-copied count, the written file names, whether any file uses StyleX, and, when the owner has an issues URL, feedback ({issuesUrl, ghCommand?}): where to report the gap that led to swizzling. The envelope's package names the same owning package. |
|
|
450
|
-
| `gap-report.categories` | The fixed gap category values and human-readable labels.
|
|
451
|
-
| `gap-report.file` | An aggregate receipt: overall status, the selected package, issuesUrl (or null), deliveries in handler order, each {handlerType: project \| integration \| fallback, handler, audience, status, url, message}, and filedCount/routedOnlyCount totals.
|
|
450
|
+
| `gap-report.categories` | The fixed gap category values and human-readable labels; when a loaded integration names its own issues URL, meta.destinations lists every destination ({to, default, issuesUrl}) and meta.ask tells an agent to ask the person. |
|
|
451
|
+
| `gap-report.file` | An aggregate receipt: overall status, the selected package, issuesUrl (or null), deliveries in handler order, each {handlerType: project \| integration \| fallback, handler, audience, status, url, message}, and filedCount/routedOnlyCount totals; without --to, when a loaded integration names its own issues URL, destinations and ask as on gap-report.categories. |
|
|
452
452
|
| `template.list` | The effective discovered TemplateListEntry[] for pages and blocks. A winning replacement entry includes optional `replaces`, naming the Core id omitted from the default list. |
|
|
453
453
|
| `template.show` | The resolved template's source, exactly as a copy writes it, plus its description, kind, the component names it composes, and demoMediaReplaced (how many Astryx demo media references were replaced with placeholders for you to swap for your own media). |
|
|
454
454
|
| `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes. The envelope's package names the npm package that owns the template. |
|
|
@@ -468,18 +468,19 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
468
468
|
| `theme.palette.generate` | An author-reviewable OKLCH palette candidate, its reproducibility receipt, summary counts, and optional candidate/receipt file-write result. |
|
|
469
469
|
| `upgrade.list` | Every available codemod, oldest→newest, as {name, package, title, version, optional}; returned for --list without running anything. |
|
|
470
470
|
| `upgrade.registry` | The copied-composition receipt for --registry: applied, ok, the counts (found, current, wouldUpdate, updated, wouldMerge, merged, wouldRefreshReceipt, receiptsRefreshed, conflicts, missing, invalid, failed), and items. |
|
|
471
|
-
| `upgrade.status` | A short-circuit outcome with no codemods run (up_to_date, no_codemods, or config_fixable), each carrying the agent-docs summary.
|
|
472
|
-
| `upgrade.run` | The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, sourcePathFound (false when the resolved source directory does not exist, so no source file was read), and (apply mode) filesChanged, transformsApplied, and per-codemod errors.
|
|
471
|
+
| `upgrade.status` | A short-circuit outcome with no codemods run (up_to_date, no_codemods, or config_fixable), each carrying the agent-docs summary. no_codemods and config_fixable carry cliBehindCore ({cliVersion, command}) when the installed Core is newer than the CLI, which then has no codemods for the releases after its own version. |
|
|
472
|
+
| `upgrade.run` | The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, sourcePathFound (false when the resolved source directory does not exist, so no source file was read), and (apply mode) filesChanged, transformsApplied, and per-codemod errors. When the installed Core is newer than the CLI, it also carries cliBehindCore ({cliVersion, command}): codemods for the releases after cliVersion did not run. |
|
|
473
473
|
| `manifest` | The CLI capability manifest: name, version, apiVersion, description, globalOptions, commands (each name, description, arguments, options, json, aliases?, responseTypes?, examples?, exitCodes? as [{code, when}], subcommands?), jsonSupported, and the flat responseTypes index. |
|
|
474
474
|
| `help` | Help, in one of two shapes. A bare `astryx --json` returns the root manifest: name, version, commands (the command names), jsonSupported, and manifest (the full payload `astryx manifest --json` returns). `--help --json` on any command, or `astryx help [command] --json`, returns that command's help: command, description, usage, options (each flags, description, and defaultValue and choices when set), and subcommands (each name and description). data.manifest marks the first shape; data.usage marks the second. |
|
|
475
475
|
| `version` | The CLI version, for `astryx --version --json`: {version}. |
|
|
476
476
|
| `doctor` | The health-check report: `checks` (each with id, label, status: pass \| warn \| fail \| info, a message, and an optional fix, always present on warn and fail) plus a `summary` of counts per status. |
|
|
477
477
|
| `integration.add` | A contribution-writer receipt: kind, name, optional root {path, created}, integration-manifest path, every affected project-relative path, written, and dryRun. |
|
|
478
478
|
| `integration.pack-check` | The packed-package check: name, version, packable, tarball {filename, fileCount, size, unpackedSize} or null, inventory {manifest, roots [{kind, path, expectedFiles, missingFiles, complete}], expectedFiles, packedFiles}, contributions {local, packed}, each null or {themes [{slug, exportName}], components, templates [{id, type, name}], codemods [{version, id}], docs, agentDocsAppend}, and issues [{code, severity, message}]. |
|
|
479
|
-
| `integration.validate` | The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning \| error, message}.
|
|
479
|
+
| `integration.validate` | The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning \| error, message}. When the manifest loads, docTypes checks each doc against its published authoring type: status (checked \| skipped), reason, typescript, docs, findings (all warnings, each naming the field and a fix), unchecked, and fixtures (test fixture docs not checked). |
|
|
480
480
|
| `integration.template-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and non-blocking Core template-id conflicts as {id, severity: warning, integrationPackage, integrationType, integrationName, coreMatches, message, command}. |
|
|
481
|
-
| `integration.component-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and non-blocking conflicts where an integration component name is also owned by Core; each conflict includes the exact package-qualified command.
|
|
481
|
+
| `integration.component-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and non-blocking conflicts where an integration component name is also owned by Core; each conflict includes the exact package-qualified command. When the manifest loads and declares a components root, propDrift compares documented props with the TypeScript props: status (checked \| skipped), reason, typescript, components, typesCompared, typesSkipped, findings (all warnings), unchecked, typesNotCompared, and propsNotChecked. |
|
|
482
482
|
| `integration.doc-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and Core doc overlaps. Each finding includes `severity` (`info` \| `error`) and `relationship` (`replaces` \| `extends` \| `accidental`). |
|
|
483
|
+
| `integration.check` | Every source check of an integration package in one result: validated (false when no integration manifest was found, so nothing was checked), the package name and version, strict, and checks, one entry per check (validate, components, templates, docs), each with check, errors, warnings, skipped, failed, and response, the envelope that check returns on its own. The totals are errors, warnings, and skipped; unchecked counts what the checks could not compare. With --strict, failures lists each warning and each piece of skipped work again as an error, in the issue format the checks use; it is empty without --strict. failed decides the exit code. |
|
|
483
484
|
|
|
484
485
|
<!-- END GENERATED: response-types -->
|
|
485
486
|
<!-- Generated by scripts/generate-cli-readme.mjs from the response-types EnumDoc. Run `pnpm -F @astryxdesign/cli readme`. -->
|
|
@@ -551,12 +552,12 @@ data: { checks, summary } }`) that AI agents and scripts can parse.
|
|
|
551
552
|
Omit `[package]` to inspect the package at the current directory, or pass an
|
|
552
553
|
installed package name:
|
|
553
554
|
|
|
554
|
-
| Command | What it checks
|
|
555
|
-
| ----------------------------------------- |
|
|
556
|
-
| `doctor integration validate [package]` | Manifest shape and every declared contribution
|
|
557
|
-
| `doctor integration templates [package]` | Template IDs shared with Core
|
|
558
|
-
| `doctor integration components [package]` | Component names shared with Core
|
|
559
|
-
| `doctor integration docs [package]` | Core topic replacements, extensions, and same-name conflicts
|
|
555
|
+
| Command | What it checks | Exit `1` when |
|
|
556
|
+
| ----------------------------------------- | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
557
|
+
| `doctor integration validate [package]` | Manifest shape and every declared contribution | A structural issue has error severity |
|
|
558
|
+
| `doctor integration templates [package]` | Template IDs shared with Core | The integration is invalid; ID conflicts are warnings |
|
|
559
|
+
| `doctor integration components [package]` | Component names shared with Core, and each props table against the TypeScript props | The integration is invalid; name conflicts and prop differences are warnings |
|
|
560
|
+
| `doctor integration docs [package]` | Core topic replacements, extensions, and same-name conflicts | A Core overlap is accidental or the docs are invalid |
|
|
560
561
|
|
|
561
562
|
Template and component conflicts include the exact `--package` command needed
|
|
562
563
|
to select the integration contribution. Doc replacements and extensions are
|
|
@@ -580,12 +581,12 @@ There is no factory: write a plain object. For editor autocomplete and
|
|
|
580
581
|
type-checking, annotate it with the `AstryxConfig` type exported from
|
|
581
582
|
`@astryxdesign/cli/authoring`.
|
|
582
583
|
|
|
583
|
-
| Field | Type | Purpose
|
|
584
|
-
| ----------------------------- | ------------------------------ |
|
|
585
|
-
| `integrations` | `string[]` | Integration package names to load (see [Integrations](#integrations)).
|
|
586
|
-
| `issuesUrl` | `string` | Where "report an issue" links point for your project. Defaults to the core issue tracker.
|
|
587
|
-
| `hooks.postCodemod` | `PostCodemodHook[]` | Commands to run after `astryx upgrade` applies codemods (e.g. reinstall, rebuild, reformat).
|
|
588
|
-
| `experimental.xle.components` | `Record<string, XleComponent>` |
|
|
584
|
+
| Field | Type | Purpose |
|
|
585
|
+
| ----------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
586
|
+
| `integrations` | `string[]` | Integration package names to load (see [Integrations](#integrations)). |
|
|
587
|
+
| `issuesUrl` | `string` | Where "report an issue" links point for your project. Defaults to the core issue tracker. |
|
|
588
|
+
| `hooks.postCodemod` | `PostCodemodHook[]` | Commands to run after `astryx upgrade` applies codemods (e.g. reinstall, rebuild, reformat). |
|
|
589
|
+
| `experimental.xle.components` | `Record<string, XleComponent>` | Custom components for the removed layout expander, keyed by component name. The CLI still validates the field, so an entry without a string `from` makes `astryx.config` invalid, but nothing reads it. |
|
|
589
590
|
|
|
590
591
|
The config is validated against a strict schema when the CLI loads it, so an
|
|
591
592
|
unknown field is a hard error rather than a silent no-op. `astryx doctor`
|
package/api/build/help/help.mjs
CHANGED
|
@@ -63,7 +63,7 @@ export function buildHelp() {
|
|
|
63
63
|
"Keep the template's page frame, gap, and padding values. Replace its data, copy, and sections.",
|
|
64
64
|
'No <div>/raw HTML for layout — use VStack/HStack/Grid/Stack/Card etc.',
|
|
65
65
|
'No style={{}} — use component props, and design tokens for values.',
|
|
66
|
-
"Wrap the app in <Theme theme={...}> (import {Theme} from '@astryxdesign/core') and import core reset.css + astryx.css.",
|
|
66
|
+
"Wrap the app in <Theme theme={...}> (import {Theme} from '@astryxdesign/core/theme') and import core reset.css + astryx.css.",
|
|
67
67
|
],
|
|
68
68
|
related: [
|
|
69
69
|
{
|
package/api/docs/_adapter.d.mts
CHANGED
|
@@ -281,6 +281,17 @@ export function resolveTopicDocs(topic: unknown, options?: {
|
|
|
281
281
|
lang: string | null;
|
|
282
282
|
entry: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry;
|
|
283
283
|
}>;
|
|
284
|
+
/**
|
|
285
|
+
* Each doc one integration package ships, checked against the published
|
|
286
|
+
* authoring type for its kind with the project's own TypeScript (spec:AST-039
|
|
287
|
+
* FR13). Without TypeScript the report says nothing was checked.
|
|
288
|
+
* @param {any} integration a loaded integration
|
|
289
|
+
* @param {string} cwd
|
|
290
|
+
* @returns {Promise<import('../../foundation/discovery/doc-types.mjs').DocTypesReport & {fixtures?: number}>}
|
|
291
|
+
*/
|
|
292
|
+
export function integrationDocTypes(integration: any, cwd: string): Promise<import("../../foundation/discovery/doc-types.mjs").DocTypesReport & {
|
|
293
|
+
fixtures?: number;
|
|
294
|
+
}>;
|
|
284
295
|
/**
|
|
285
296
|
* A doc a link found: what a read shows of the link, and the typed doc behind
|
|
286
297
|
* it when a reference block can include it.
|
package/api/docs/_adapter.mjs
CHANGED
|
@@ -17,8 +17,11 @@
|
|
|
17
17
|
* foundation/discovery/docs-discovery, which the catalog comes from.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
import * as path from 'node:path';
|
|
20
21
|
import {Project} from '../../foundation/config/project.mjs';
|
|
21
22
|
import {DocsCatalog} from '../../foundation/discovery/docs-discovery.mjs';
|
|
23
|
+
import {checkDocTypes} from '../../foundation/discovery/doc-types.mjs';
|
|
24
|
+
import {integrationDocFiles} from '../../foundation/discovery/integration-doc-files.mjs';
|
|
22
25
|
import {
|
|
23
26
|
linkReferenceTopic,
|
|
24
27
|
lowerReferenceTopic,
|
|
@@ -53,6 +56,17 @@ import {
|
|
|
53
56
|
selfDocSection,
|
|
54
57
|
} from '../../foundation/discovery/authoring-self-docs.mjs';
|
|
55
58
|
import {CLI_PROVIDER_ID} from '../../foundation/identity/providers.mjs';
|
|
59
|
+
import {
|
|
60
|
+
CORE_PACKAGE,
|
|
61
|
+
discoverOwnedComponents,
|
|
62
|
+
discoverValidIntegrationComponents,
|
|
63
|
+
} from '../../foundation/discovery/component-discovery.mjs';
|
|
64
|
+
import {loadComponentDoc} from '../../foundation/discovery/component-loader.mjs';
|
|
65
|
+
import {
|
|
66
|
+
discoverCoreTemplates,
|
|
67
|
+
discoverIntegrationTemplatesForOne,
|
|
68
|
+
} from '../../foundation/discovery/template-adapter.mjs';
|
|
69
|
+
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
56
70
|
import {AstryxError} from '../error.mjs';
|
|
57
71
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
58
72
|
|
|
@@ -495,12 +509,205 @@ async function docFinder(catalog, fromProvider) {
|
|
|
495
509
|
};
|
|
496
510
|
}
|
|
497
511
|
}
|
|
512
|
+
if (CONTRIBUTED_KINDS.has(parsed.kind)) {
|
|
513
|
+
const link = await contributedDocLink(
|
|
514
|
+
catalog,
|
|
515
|
+
provider,
|
|
516
|
+
parsed.kind,
|
|
517
|
+
parsed.name,
|
|
518
|
+
);
|
|
519
|
+
if (link)
|
|
520
|
+
return {link: {target, ...link}, kind: parsed.kind, typed: null};
|
|
521
|
+
}
|
|
522
|
+
const searchType =
|
|
523
|
+
parsed.kind === 'component'
|
|
524
|
+
? 'component'
|
|
525
|
+
: parsed.kind === 'page' || parsed.kind === 'block'
|
|
526
|
+
? 'template'
|
|
527
|
+
: 'doc';
|
|
498
528
|
return {
|
|
499
|
-
problem: `"${target}" names no doc. Find it with \`astryx search ${parsed.name} --type
|
|
529
|
+
problem: `"${target}" names no doc. Find it with \`astryx search ${parsed.name} --type ${searchType}\`, then name it as \`[<provider>:]<kind>:<name>\`.`,
|
|
500
530
|
};
|
|
501
531
|
};
|
|
502
532
|
}
|
|
503
533
|
|
|
534
|
+
/** The doc kinds no docs tree holds: components and templates. */
|
|
535
|
+
const CONTRIBUTED_KINDS = new Set(['component', 'page', 'block']);
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* The link to a component, page, or block doc (spec:AST-047 FR9). No docs tree
|
|
539
|
+
* holds these, so a link finds them among the component and template records
|
|
540
|
+
* the catalog carries, the ones `astryx component` and `astryx template` open,
|
|
541
|
+
* and reads as that command. A component is named by its export name, a
|
|
542
|
+
* template by its id; anything but Core's names its package.
|
|
543
|
+
* @param {DocsCatalog} catalog
|
|
544
|
+
* @param {string} provider normalized provider id
|
|
545
|
+
* @param {string} kind `component`, `page`, or `block`
|
|
546
|
+
* @param {string} name
|
|
547
|
+
* @returns {Promise<Omit<import('../../foundation/doc-compiler/links.mjs').DocLink, 'target'> | null>}
|
|
548
|
+
*/
|
|
549
|
+
async function contributedDocLink(catalog, provider, kind, name) {
|
|
550
|
+
const contributions = await catalog.contributions();
|
|
551
|
+
if (!contributions) return null;
|
|
552
|
+
const sameProvider = (/** @type {string} */ providerId) => {
|
|
553
|
+
try {
|
|
554
|
+
return normalizeProviderId(providerId) === provider;
|
|
555
|
+
} catch {
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
if (kind === 'component') {
|
|
560
|
+
const record = contributions.components.find(
|
|
561
|
+
component =>
|
|
562
|
+
component.name === name && sameProvider(component.providerId),
|
|
563
|
+
);
|
|
564
|
+
if (!record) return null;
|
|
565
|
+
/** @type {any} */
|
|
566
|
+
let doc = null;
|
|
567
|
+
try {
|
|
568
|
+
doc = record.docPath ? await loadComponentDoc(record.docPath) : null;
|
|
569
|
+
} catch {
|
|
570
|
+
// The component checks report a doc that does not load; the link
|
|
571
|
+
// still opens the component.
|
|
572
|
+
}
|
|
573
|
+
const entry =
|
|
574
|
+
doc?.name === name
|
|
575
|
+
? doc
|
|
576
|
+
: doc?.components?.find(
|
|
577
|
+
(/** @type {any} */ each) => each.name === name,
|
|
578
|
+
);
|
|
579
|
+
// Bare, Core's name opens Core's component unless another package ships
|
|
580
|
+
// the same name or replaces it (spec:AST-035 FR11); then the link selects
|
|
581
|
+
// Core, as it always selects any other package.
|
|
582
|
+
const selectPackage =
|
|
583
|
+
record.package !== CORE_PACKAGE ||
|
|
584
|
+
contributions.components.some(
|
|
585
|
+
other =>
|
|
586
|
+
other.package !== CORE_PACKAGE &&
|
|
587
|
+
(other.name === name || other.replaces === name),
|
|
588
|
+
);
|
|
589
|
+
return {
|
|
590
|
+
id: createDocId(provider, 'component', name),
|
|
591
|
+
route: null,
|
|
592
|
+
title: entry?.displayName ?? name,
|
|
593
|
+
summary: entry?.description ?? doc?.description ?? '',
|
|
594
|
+
command: `astryx component ${name}${selectPackage ? ` --package ${record.package}` : ''}`,
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
const template = contributions.templates.find(
|
|
598
|
+
each =>
|
|
599
|
+
each.type === kind && each.id === name && sameProvider(each.providerId),
|
|
600
|
+
);
|
|
601
|
+
if (!template) return null;
|
|
602
|
+
// The same for a Core template: another package's template of its kind
|
|
603
|
+
// with its id, or one that replaces it, takes the bare id.
|
|
604
|
+
const selectPackage =
|
|
605
|
+
template.package !== CORE_PACKAGE ||
|
|
606
|
+
contributions.templates.some(
|
|
607
|
+
other =>
|
|
608
|
+
other.package !== CORE_PACKAGE &&
|
|
609
|
+
other.type === template.type &&
|
|
610
|
+
(other.id === name || other.replaces === name),
|
|
611
|
+
);
|
|
612
|
+
return {
|
|
613
|
+
id: createDocId(provider, template.type, name),
|
|
614
|
+
route: null,
|
|
615
|
+
title: template.displayName ?? template.name,
|
|
616
|
+
summary: template.description ?? '',
|
|
617
|
+
command: `astryx template ${name} --type ${template.type}${selectPackage ? ` --package ${template.package}` : ''}`,
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* The component and template docs one integration package's links can name:
|
|
623
|
+
* Core's and its own, as `doctor integration docs` checks it before any app
|
|
624
|
+
* configures it.
|
|
625
|
+
* @param {any} integration a loaded integration: its name, provider id, roots,
|
|
626
|
+
* and package directory
|
|
627
|
+
* @returns {Promise<import('../../foundation/discovery/docs-discovery.mjs').LinkableContributions>}
|
|
628
|
+
*/
|
|
629
|
+
async function packageContributions(integration) {
|
|
630
|
+
const own = integration.providerId ?? integration.name;
|
|
631
|
+
/** @type {import('../../foundation/discovery/docs-discovery.mjs').LinkableComponent[]} */
|
|
632
|
+
const components = [];
|
|
633
|
+
const coreDir = findCoreDir(integration.__packageDir ?? process.cwd());
|
|
634
|
+
if (coreDir) {
|
|
635
|
+
try {
|
|
636
|
+
for (const record of discoverOwnedComponents(coreDir, [])) {
|
|
637
|
+
components.push({
|
|
638
|
+
providerId: CORE_PACKAGE,
|
|
639
|
+
package: CORE_PACKAGE,
|
|
640
|
+
name: record.name,
|
|
641
|
+
docPath: record.docPath,
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
} catch {
|
|
645
|
+
// The components check reports a Core it cannot read.
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
if (integration.components) {
|
|
649
|
+
try {
|
|
650
|
+
const {components: records} =
|
|
651
|
+
await discoverValidIntegrationComponents(integration);
|
|
652
|
+
for (const record of records) {
|
|
653
|
+
components.push({
|
|
654
|
+
providerId: own,
|
|
655
|
+
package: integration.name,
|
|
656
|
+
name: record.name,
|
|
657
|
+
docPath: record.docPath,
|
|
658
|
+
// Declared: this package alone cannot tell whether an app applies
|
|
659
|
+
// it, so a link to the Core name it names selects Core.
|
|
660
|
+
...(typeof record.replaces === 'string'
|
|
661
|
+
? {replaces: record.replaces}
|
|
662
|
+
: {}),
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
} catch {
|
|
666
|
+
// `validate` reports components that do not load.
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
/** @type {import('../../foundation/discovery/docs-discovery.mjs').LinkableTemplate[]} */
|
|
670
|
+
const templates = [];
|
|
671
|
+
/** @param {any} template @param {string} providerId @param {string} pkg */
|
|
672
|
+
const addTemplate = (template, providerId, pkg) => {
|
|
673
|
+
if (template.type !== 'page' && template.type !== 'block') return;
|
|
674
|
+
templates.push({
|
|
675
|
+
providerId,
|
|
676
|
+
package: pkg,
|
|
677
|
+
type: template.type,
|
|
678
|
+
id: template.dirName,
|
|
679
|
+
name: template.name,
|
|
680
|
+
...(template.displayName == null
|
|
681
|
+
? {}
|
|
682
|
+
: {displayName: template.displayName}),
|
|
683
|
+
...(template.description == null
|
|
684
|
+
? {}
|
|
685
|
+
: {description: template.description}),
|
|
686
|
+
...(typeof template.replaces === 'string'
|
|
687
|
+
? {replaces: template.replaces}
|
|
688
|
+
: {}),
|
|
689
|
+
});
|
|
690
|
+
};
|
|
691
|
+
try {
|
|
692
|
+
for (const template of await discoverCoreTemplates()) {
|
|
693
|
+
addTemplate(template, CORE_PACKAGE, CORE_PACKAGE);
|
|
694
|
+
}
|
|
695
|
+
} catch {
|
|
696
|
+
// Core templates that do not load leave nothing to link to.
|
|
697
|
+
}
|
|
698
|
+
if (integration.templates) {
|
|
699
|
+
try {
|
|
700
|
+
const {templates: records} =
|
|
701
|
+
await discoverIntegrationTemplatesForOne(integration);
|
|
702
|
+
for (const template of records)
|
|
703
|
+
addTemplate(template, own, integration.name);
|
|
704
|
+
} catch {
|
|
705
|
+
// `validate` reports templates that do not load.
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
return {components, templates};
|
|
709
|
+
}
|
|
710
|
+
|
|
504
711
|
/**
|
|
505
712
|
* How a doc's links find their targets (spec:AST-047 FR9), as
|
|
506
713
|
* {@link docFinder} finds them: each resolves to the link a read shows.
|
|
@@ -701,6 +908,7 @@ export async function docsLinkProblems(
|
|
|
701
908
|
*/
|
|
702
909
|
export async function packageDocsProblems(integration, discovered) {
|
|
703
910
|
const catalog = DocsCatalog.fromBuiltins();
|
|
911
|
+
catalog.setContributions(() => packageContributions(integration));
|
|
704
912
|
for (const record of discovered.records) catalog.add(record);
|
|
705
913
|
catalog.addTreeInputs({
|
|
706
914
|
namespaces: discovered.namespaces.map(input => ({...input, rank: 1})),
|
|
@@ -794,6 +1002,7 @@ async function namespaceReferenceTarget(catalog, route, lang) {
|
|
|
794
1002
|
*/
|
|
795
1003
|
export async function packageReferenceProblems(integration, discovered) {
|
|
796
1004
|
const catalog = DocsCatalog.fromBuiltins();
|
|
1005
|
+
catalog.setContributions(() => packageContributions(integration));
|
|
797
1006
|
for (const record of discovered.records) catalog.add(record);
|
|
798
1007
|
catalog.addTreeInputs({
|
|
799
1008
|
namespaces: discovered.namespaces.map(input => ({...input, rank: 1})),
|
|
@@ -1125,3 +1334,37 @@ export async function resolveTopicDocs(topic, options = {}) {
|
|
|
1125
1334
|
const node = await lowerTopic(catalog, entry, effectiveLang);
|
|
1126
1335
|
return {catalog, node, lang: effectiveLang, entry};
|
|
1127
1336
|
}
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* Each doc one integration package ships, checked against the published
|
|
1340
|
+
* authoring type for its kind with the project's own TypeScript (spec:AST-039
|
|
1341
|
+
* FR13). Without TypeScript the report says nothing was checked.
|
|
1342
|
+
* @param {any} integration a loaded integration
|
|
1343
|
+
* @param {string} cwd
|
|
1344
|
+
* @returns {Promise<import('../../foundation/discovery/doc-types.mjs').DocTypesReport & {fixtures?: number}>}
|
|
1345
|
+
*/
|
|
1346
|
+
export async function integrationDocTypes(integration, cwd) {
|
|
1347
|
+
const packageDir = /** @type {{__packageDir?: string}} */ (integration)
|
|
1348
|
+
.__packageDir;
|
|
1349
|
+
const {files, unread, fixtures} = await integrationDocFiles(integration);
|
|
1350
|
+
const checked = await checkDocTypes(files, {
|
|
1351
|
+
packageDir: packageDir ?? cwd,
|
|
1352
|
+
resolveFrom: [cwd, packageDir],
|
|
1353
|
+
});
|
|
1354
|
+
// Test fixtures no reader serves don't ship as docs: only counted.
|
|
1355
|
+
const report =
|
|
1356
|
+
checked.status === 'checked' && fixtures > 0
|
|
1357
|
+
? {...checked, fixtures}
|
|
1358
|
+
: checked;
|
|
1359
|
+
if (report.status !== 'checked' || unread.length === 0) return report;
|
|
1360
|
+
// A root its reader cannot read serves no doc; say so rather than skip it.
|
|
1361
|
+
const rel = (/** @type {string} */ file) =>
|
|
1362
|
+
path.relative(packageDir ?? cwd, file).split(path.sep).join('/') || '.';
|
|
1363
|
+
return {
|
|
1364
|
+
...report,
|
|
1365
|
+
unchecked: [
|
|
1366
|
+
...report.unchecked,
|
|
1367
|
+
...unread.map(entry => ({doc: rel(entry.path), reason: entry.reason})),
|
|
1368
|
+
].sort((a, b) => a.doc.localeCompare(b.doc)),
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
@@ -22,6 +22,7 @@ import {docs} from './docs.mjs';
|
|
|
22
22
|
import {search} from '../search/search.mjs';
|
|
23
23
|
import {loadDocsCatalog} from './_adapter.mjs';
|
|
24
24
|
import {AstryxError} from '../error.mjs';
|
|
25
|
+
import {discoverCoreTemplates} from '../../foundation/discovery/template-adapter.mjs';
|
|
25
26
|
|
|
26
27
|
const SLOW = 30_000;
|
|
27
28
|
|
|
@@ -110,6 +111,129 @@ describe('integration-contributed topics', () => {
|
|
|
110
111
|
expect(section.data.title).toBe('Overview');
|
|
111
112
|
}, SLOW);
|
|
112
113
|
|
|
114
|
+
it('reads a link to a component or a template as the command that opens it', async () => {
|
|
115
|
+
scaffold({
|
|
116
|
+
'using-widgets.doc.mjs': topic({
|
|
117
|
+
name: 'using-widgets',
|
|
118
|
+
title: 'Using widgets',
|
|
119
|
+
sections: [
|
|
120
|
+
{
|
|
121
|
+
title: 'Overview',
|
|
122
|
+
content: [
|
|
123
|
+
{
|
|
124
|
+
type: 'prose',
|
|
125
|
+
text: 'Start with {@link component:AcmeButton} or {@link block:acme-card}, built on {@link @astryxdesign/core:component:Button}.',
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
}),
|
|
131
|
+
});
|
|
132
|
+
const pkgDir = path.join(tmpDir, 'node_modules', '@acme', 'widgets');
|
|
133
|
+
fs.writeFileSync(
|
|
134
|
+
path.join(pkgDir, 'astryx.integration.mjs'),
|
|
135
|
+
"export default {components: './components', templates: './templates', docs: './docs'};\n",
|
|
136
|
+
);
|
|
137
|
+
fs.mkdirSync(path.join(pkgDir, 'components'));
|
|
138
|
+
fs.writeFileSync(
|
|
139
|
+
path.join(pkgDir, 'components', 'AcmeButton.doc.mjs'),
|
|
140
|
+
"export default {type: 'component', name: 'AcmeButton', displayName: 'Acme Button', description: 'A button.', props: []};\n",
|
|
141
|
+
);
|
|
142
|
+
fs.writeFileSync(
|
|
143
|
+
path.join(pkgDir, 'components', 'AcmeButton.tsx'),
|
|
144
|
+
'export function AcmeButton() { return null; }\n',
|
|
145
|
+
);
|
|
146
|
+
fs.mkdirSync(path.join(pkgDir, 'templates'));
|
|
147
|
+
fs.writeFileSync(
|
|
148
|
+
path.join(pkgDir, 'templates', 'acme-card.doc.mjs'),
|
|
149
|
+
"export default {type: 'block', name: 'Acme card', description: 'A card.'};\n",
|
|
150
|
+
);
|
|
151
|
+
fs.writeFileSync(
|
|
152
|
+
path.join(pkgDir, 'templates', 'acme-card.tsx'),
|
|
153
|
+
'export default function Fixture() { return null; }\n',
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const detail = await docs('using-widgets', undefined, {cwd: tmpDir, full: true});
|
|
157
|
+
|
|
158
|
+
const prose = JSON.stringify(detail.data.sections);
|
|
159
|
+
expect(prose).toContain('`astryx component AcmeButton --package @acme/widgets`');
|
|
160
|
+
expect(prose).toContain(
|
|
161
|
+
'`astryx template acme-card --type block --package @acme/widgets`',
|
|
162
|
+
);
|
|
163
|
+
expect(prose).toContain('`astryx component Button`');
|
|
164
|
+
expect(prose).not.toContain('{@link');
|
|
165
|
+
}, SLOW);
|
|
166
|
+
|
|
167
|
+
it('selects Core in a link only where the bare name would open something else', async () => {
|
|
168
|
+
const core = await discoverCoreTemplates();
|
|
169
|
+
const page = core.find(template => template.type === 'page')?.dirName;
|
|
170
|
+
const block = core.find(template => template.type === 'block')?.dirName;
|
|
171
|
+
scaffold({
|
|
172
|
+
'using-widgets.doc.mjs': topic({
|
|
173
|
+
name: 'using-widgets',
|
|
174
|
+
title: 'Using widgets',
|
|
175
|
+
sections: [
|
|
176
|
+
{
|
|
177
|
+
title: 'Overview',
|
|
178
|
+
content: [
|
|
179
|
+
{
|
|
180
|
+
type: 'prose',
|
|
181
|
+
text:
|
|
182
|
+
'Core: {@link @astryxdesign/core:component:Button}, {@link @astryxdesign/core:component:Badge}, ' +
|
|
183
|
+
`{@link @astryxdesign/core:page:${page}}, {@link @astryxdesign/core:block:${block}}.`,
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
}),
|
|
189
|
+
});
|
|
190
|
+
const pkgDir = path.join(tmpDir, 'node_modules', '@acme', 'widgets');
|
|
191
|
+
// The CLI range that turns component replacement on.
|
|
192
|
+
fs.writeFileSync(
|
|
193
|
+
path.join(pkgDir, 'package.json'),
|
|
194
|
+
JSON.stringify({
|
|
195
|
+
name: '@acme/widgets',
|
|
196
|
+
version: '1.0.0',
|
|
197
|
+
peerDependencies: {'@astryxdesign/cli': '>=0.6.7'},
|
|
198
|
+
peerDependenciesMeta: {'@astryxdesign/cli': {optional: true}},
|
|
199
|
+
}),
|
|
200
|
+
);
|
|
201
|
+
fs.writeFileSync(
|
|
202
|
+
path.join(pkgDir, 'astryx.integration.mjs'),
|
|
203
|
+
"export default {components: './components', templates: './templates', docs: './docs'};\n",
|
|
204
|
+
);
|
|
205
|
+
fs.mkdirSync(path.join(pkgDir, 'components'));
|
|
206
|
+
// AcmeButton replaces Core's Button, so bare `Button` opens AcmeButton.
|
|
207
|
+
fs.writeFileSync(
|
|
208
|
+
path.join(pkgDir, 'components', 'AcmeButton.doc.mjs'),
|
|
209
|
+
"export default {type: 'component', name: 'AcmeButton', displayName: 'Acme Button', description: 'A button.', replaces: 'Button', props: []};\n",
|
|
210
|
+
);
|
|
211
|
+
fs.writeFileSync(
|
|
212
|
+
path.join(pkgDir, 'components', 'AcmeButton.tsx'),
|
|
213
|
+
'export function AcmeButton() { return null; }\n',
|
|
214
|
+
);
|
|
215
|
+
// A page template with a Core page's id makes the bare id ambiguous.
|
|
216
|
+
fs.mkdirSync(path.join(pkgDir, 'templates'));
|
|
217
|
+
fs.writeFileSync(
|
|
218
|
+
path.join(pkgDir, 'templates', `${page}.doc.mjs`),
|
|
219
|
+
"export default {type: 'page', name: 'Acme page', displayName: 'Acme page', description: 'A page.'};\n",
|
|
220
|
+
);
|
|
221
|
+
fs.writeFileSync(
|
|
222
|
+
path.join(pkgDir, 'templates', `${page}.tsx`),
|
|
223
|
+
'export default function Fixture() { return null; }\n',
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
const detail = await docs('using-widgets', undefined, {cwd: tmpDir, full: true});
|
|
227
|
+
|
|
228
|
+
const prose = JSON.stringify(detail.data.sections);
|
|
229
|
+
expect(prose).toContain('`astryx component Button --package @astryxdesign/core`');
|
|
230
|
+
expect(prose).toContain('`astryx component Badge`');
|
|
231
|
+
expect(prose).toContain(
|
|
232
|
+
`\`astryx template ${page} --type page --package @astryxdesign/core\``,
|
|
233
|
+
);
|
|
234
|
+
expect(prose).toContain(`\`astryx template ${block} --type block\``);
|
|
235
|
+
}, SLOW);
|
|
236
|
+
|
|
113
237
|
it('is invisible to a project that does not configure the integration', async () => {
|
|
114
238
|
scaffold({'deploying.doc.mjs': topic()}, {config: 'export default {};\n'});
|
|
115
239
|
const listed = await docs(undefined, undefined, {cwd: tmpDir});
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -351,6 +351,26 @@ export async function checkConfig(ctx) {
|
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
+
/**
|
|
355
|
+
* Why no integration is implicitly linked, from what actually loaded. A
|
|
356
|
+
* configured integration is named in astryx.config; the package's own manifest
|
|
357
|
+
* loads as itself (`__local`). Only the first may be described as named in
|
|
358
|
+
* astryx.config: a package with no config that loads its own manifest has no
|
|
359
|
+
* config file to name it.
|
|
360
|
+
*
|
|
361
|
+
* @param {Array<{name?: string, __local?: boolean}>} integrations loaded, none
|
|
362
|
+
* autolinked and none that failed to load
|
|
363
|
+
* @returns {string}
|
|
364
|
+
*/
|
|
365
|
+
function describeNoImplicit(integrations) {
|
|
366
|
+
const own = integrations.filter(integration => integration.__local);
|
|
367
|
+
const configured = integrations.length - own.length;
|
|
368
|
+
const ownNames = own.map(integration => integration.name ?? 'this package').join(', ');
|
|
369
|
+
if (own.length === 0) return 'None — every loaded integration is named in astryx.config.';
|
|
370
|
+
if (configured === 0) return `None — the only loaded integration is this package's own manifest (${ownNames}).`;
|
|
371
|
+
return `None — every loaded integration is named in astryx.config or is this package's own manifest (${ownNames}).`;
|
|
372
|
+
}
|
|
373
|
+
|
|
354
374
|
/**
|
|
355
375
|
* Check 6 — integrations that are loaded without an astryx.config entry.
|
|
356
376
|
*
|
|
@@ -395,14 +415,18 @@ export function checkImplicitIntegrations(ctx) {
|
|
|
395
415
|
const unreadable = describeUnreadableManifests(ctx.autolinkFailures ?? []);
|
|
396
416
|
|
|
397
417
|
if (implicit.length === 0) {
|
|
418
|
+
// A record that carries `__loadError` (the package's own manifest, or a
|
|
419
|
+
// configured one, that failed to load) loaded nothing, so it is not named
|
|
420
|
+
// as loaded beside the line reporting that it could not be loaded.
|
|
421
|
+
const loaded = ctx.integrations.filter(integration => !integration.__loadError);
|
|
398
422
|
return {
|
|
399
423
|
id,
|
|
400
424
|
label,
|
|
401
425
|
status: 'info',
|
|
402
426
|
message:
|
|
403
|
-
(
|
|
404
|
-
?
|
|
405
|
-
: unreadable
|
|
427
|
+
(loaded.length > 0
|
|
428
|
+
? describeNoImplicit(loaded)
|
|
429
|
+
: ctx.integrations.length > 0 || unreadable
|
|
406
430
|
? 'None loaded.'
|
|
407
431
|
: 'None — no installed dependency ships an astryx.integration.* manifest.') +
|
|
408
432
|
unreadable,
|