@astryxdesign/cli 0.7.4 → 0.7.5-canary.031a639
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 +20 -20
- package/api/component/_adapter.mjs +16 -1
- package/api/component/component.test.mjs +31 -0
- package/api/discover/_adapter.d.mts +1 -1
- package/api/docs/_adapter.d.mts +5 -2
- package/api/docs/_adapter.mjs +24 -16
- package/api/docs/docs.test.mjs +18 -0
- package/api/docs/integrationDocs.test.mjs +2 -2
- package/api/experimental.d.mts +5 -0
- package/api/experimental.mjs +15 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/icon/_adapter.d.mts +3 -2
- package/api/icon/_adapter.mjs +16 -3
- package/api/icon/_authoring.d.mts +5 -1
- package/api/icon/_authoring.mjs +478 -63
- package/api/icon/_options.d.mts +11 -0
- package/api/icon/_options.mjs +39 -4
- package/api/icon/_records.d.mts +19 -0
- package/api/icon/_records.mjs +25 -0
- package/api/icon/add/add.d.mts +3 -3
- package/api/icon/add/add.mjs +227 -14
- package/api/icon/all-or-nothing.test.mjs +283 -0
- package/api/icon/detail/detail.mjs +2 -13
- package/api/icon/error-codes.test.mjs +14 -7
- package/api/icon/icon.d.mts +2 -2
- package/api/icon/icon.doc.mjs +30 -2
- package/api/icon/icon.mjs +57 -8
- package/api/icon/icon.test.mjs +133 -1
- package/api/icon/icon.type.d.mts +126 -1
- package/api/icon/icon.type.mjs +67 -3
- package/api/icon/iconAdd.doc.mjs +22 -6
- package/api/icon/iconMap.doc.mjs +24 -8
- package/api/icon/iconNewDefinition.doc.mjs +2 -2
- package/api/icon/iconNewSet.doc.mjs +30 -2
- package/api/icon/iconUse.doc.mjs +4 -1
- package/api/icon/map/map.d.mts +4 -4
- package/api/icon/map/map.mjs +134 -9
- package/api/icon/new-definition/new-definition.mjs +6 -2
- package/api/icon/new-set/new-set.mjs +2 -2
- package/api/icon/new-set/new-set.test.mjs +60 -10
- package/api/icon/option-pairs.test.mjs +368 -0
- package/api/icon/search/search.d.mts +10 -0
- package/api/icon/search/search.mjs +55 -14
- package/api/icon/use/use.mjs +2 -13
- package/api/integration/add-helpers.d.mts +15 -1
- package/api/integration/add-helpers.mjs +1 -1
- package/api/integration/pack-check.lifecycle-output.test.mjs +24 -1
- package/api/integration/pack-check.mjs +10 -4
- package/api/integration/pack-check.test.mjs +5 -1
- package/api/integration/validate-integration.type.d.mts +3 -2
- package/api/integration/validate-integration.type.mjs +3 -2
- package/api/render/_adapter.d.mts +28 -0
- package/api/render/_adapter.mjs +540 -0
- package/api/render/render.d.mts +15 -0
- package/api/render/render.doc.d.mts +9 -0
- package/api/render/render.doc.mjs +112 -0
- package/api/render/render.mjs +113 -0
- package/api/render/render.test.mjs +1155 -0
- package/api/render/render.type.d.mts +74 -0
- package/api/render/render.type.mjs +64 -0
- package/api/search/_adapter.test.mjs +21 -2
- package/api/search/_result.d.mts +5 -5
- package/api/search/search.d.mts +1 -1
- package/api/template/template.mjs +3 -1
- package/api/template/template.type.d.mts +2 -1
- package/api/template/template.type.mjs +1 -1
- package/api/template/tokenizer-showcase.test.mjs +47 -0
- package/api/template/unknown-name.test.mjs +63 -0
- package/api/theme/build/build.adaptation-enrollment.test.mjs +4 -0
- package/api/theme/build/build.icon-entry-variants.test.mjs +134 -0
- package/api/theme/build/build.icon-variants.test.mjs +105 -0
- package/api/theme/build/build.mjs +134 -75
- package/api/theme/build/build.test.mjs +77 -0
- package/api/upgrade/_adapter.d.mts +47 -2
- package/api/upgrade/_adapter.mjs +58 -2
- package/api/upgrade/run/failure-receipt.test.mjs +212 -0
- package/api/upgrade/run/outcomes.test.mjs +646 -0
- package/api/upgrade/run/run.d.mts +36 -0
- package/api/upgrade/run/run.mjs +670 -44
- package/api/upgrade/upgrade.doc.mjs +4 -4
- package/api/upgrade/upgrade.mjs +19 -4
- package/api/upgrade/upgrade.type.d.mts +36 -1
- package/api/upgrade/upgrade.type.mjs +29 -4
- package/assets/codemods/__tests__/runner.symlinks.test.mjs +205 -0
- package/assets/codemods/__tests__/runner.unparseable.test.mjs +457 -0
- package/assets/codemods/integration-runner.mjs +8 -2
- package/assets/codemods/integration-runner.protection.test.mjs +53 -0
- package/assets/codemods/outcome.mjs +79 -0
- package/assets/codemods/outcome.test.mjs +40 -0
- package/assets/codemods/parse.mjs +94 -0
- package/assets/codemods/run-codemod.mjs +109 -5
- package/assets/codemods/runner.mjs +119 -13
- package/assets/codemods/transform-prop.mjs +99 -49
- package/assets/codemods/transform-prop.test.mjs +36 -1
- package/assets/codemods/transforms/next/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +130 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-codeblock-tokenizer-to-language.mjs +315 -0
- package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +216 -2
- package/assets/codemods/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +88 -6
- package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +4 -3
- package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +207 -6
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +143 -70
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface-v0.6-data.mjs +6 -1
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +244 -42
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +23 -78
- package/assets/discover/official-packages.json +4 -0
- package/assets/docs/author-a-theme.doc.mjs +3 -1
- package/assets/docs/icons.doc.mjs +82 -1
- package/assets/docs/theme.doc.dense.mjs +8 -0
- package/assets/docs/theme.doc.mjs +16 -0
- package/assets/docs/theme.doc.zh.mjs +11 -0
- package/assets/docs/tree/icon-definitions.doc.mjs +2 -2
- package/assets/docs/tree/icon-set-files.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +50 -20
- package/assets/docs/tree/render-pages.doc.mjs +94 -0
- package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +1 -1
- package/assets/docs/tree/tokens-color.doc.mjs +145 -1
- package/assets/docs/tree/tokens.doc.mjs +1 -1
- package/assets/icons/definitions/activity.doc.mjs +1 -1
- package/assets/icons/definitions/alignCenter.doc.mjs +9 -0
- package/assets/icons/definitions/alignEnd.doc.mjs +10 -0
- package/assets/icons/definitions/alignStart.doc.mjs +10 -0
- package/assets/icons/definitions/archive.doc.mjs +1 -1
- package/assets/icons/definitions/arrowsUpDown.doc.mjs +1 -1
- package/assets/icons/definitions/attach.doc.mjs +1 -1
- package/assets/icons/definitions/audio.doc.mjs +1 -1
- package/assets/icons/definitions/cart.doc.mjs +1 -1
- package/assets/icons/definitions/checkDouble.doc.mjs +1 -1
- package/assets/icons/definitions/chevronsLeft.doc.mjs +1 -1
- package/assets/icons/definitions/chevronsRight.doc.mjs +1 -1
- package/assets/icons/definitions/close.doc.mjs +1 -1
- package/assets/icons/definitions/collapse.doc.mjs +1 -1
- package/assets/icons/definitions/compose.doc.mjs +1 -1
- package/assets/icons/definitions/conversation.doc.mjs +1 -1
- package/assets/icons/definitions/copy.doc.mjs +1 -1
- package/assets/icons/definitions/cpu.doc.mjs +9 -0
- package/assets/icons/definitions/database.doc.mjs +1 -1
- package/assets/icons/definitions/desktop.doc.mjs +1 -1
- package/assets/icons/definitions/discount.doc.mjs +1 -1
- package/assets/icons/definitions/download.doc.mjs +1 -1
- package/assets/icons/definitions/emoji.doc.mjs +1 -1
- package/assets/icons/definitions/error.doc.mjs +1 -1
- package/assets/icons/definitions/expand.doc.mjs +1 -1
- package/assets/icons/definitions/experiment.doc.mjs +1 -1
- package/assets/icons/definitions/externalLink.doc.mjs +7 -1
- package/assets/icons/definitions/eyeSlash.doc.mjs +1 -1
- package/assets/icons/definitions/flipHorizontal.doc.mjs +9 -0
- package/assets/icons/definitions/flipVertical.doc.mjs +9 -0
- package/assets/icons/definitions/folderAdd.doc.mjs +1 -1
- package/assets/icons/definitions/gitBranch.doc.mjs +9 -0
- package/assets/icons/definitions/gitFork.doc.mjs +9 -0
- package/assets/icons/definitions/info.doc.mjs +1 -1
- package/assets/icons/definitions/location.doc.mjs +1 -1
- package/assets/icons/definitions/mention.doc.mjs +1 -1
- package/assets/icons/definitions/menu.doc.mjs +1 -1
- package/assets/icons/definitions/microphone.doc.mjs +1 -1
- package/assets/icons/definitions/mobile.doc.mjs +1 -1
- package/assets/icons/definitions/money.doc.mjs +1 -1
- package/assets/icons/definitions/moreHorizontal.doc.mjs +1 -1
- package/assets/icons/definitions/notificationActive.doc.mjs +1 -1
- package/assets/icons/definitions/notificationOff.doc.mjs +1 -1
- package/assets/icons/definitions/panelLeft.doc.mjs +10 -0
- package/assets/icons/definitions/panelRight.doc.mjs +10 -0
- package/assets/icons/definitions/raiseHand.doc.mjs +1 -1
- package/assets/icons/definitions/redo.doc.mjs +1 -1
- package/assets/icons/definitions/refresh.doc.mjs +1 -1
- package/assets/icons/definitions/rotate.doc.mjs +9 -0
- package/assets/icons/definitions/scale.doc.mjs +10 -0
- package/assets/icons/definitions/search.doc.mjs +1 -1
- package/assets/icons/definitions/send.doc.mjs +1 -1
- package/assets/icons/definitions/settings.doc.mjs +1 -1
- package/assets/icons/definitions/star.doc.mjs +1 -1
- package/assets/icons/definitions/stop.doc.mjs +1 -1
- package/assets/icons/definitions/success.doc.mjs +1 -1
- package/assets/icons/definitions/textCase.doc.mjs +9 -0
- package/assets/icons/definitions/thumbsDown.doc.mjs +1 -1
- package/assets/icons/definitions/thumbsUp.doc.mjs +1 -1
- package/assets/icons/definitions/trendDown.doc.mjs +7 -1
- package/assets/icons/definitions/trendUp.doc.mjs +1 -1
- package/assets/icons/definitions/undo.doc.mjs +1 -1
- package/assets/icons/definitions/upload.doc.mjs +1 -1
- package/assets/icons/definitions/userAdd.doc.mjs +1 -1
- package/assets/icons/definitions/warning.doc.mjs +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +61 -55
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.tsx +68 -37
- package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.doc.mjs +1 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.tsx +10 -2
- package/assets/templates/blocks/components/Thumbnail/ThumbnailDisabled.doc.mjs +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +30 -30
- package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +17 -16
- package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +29 -29
- package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +22 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +39 -41
- package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -0
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +3 -3
- package/assets/templates/pages/form-wizard-inline/template.doc.mjs +6 -1
- package/assets/templates/pages/library/page.tsx +1 -2
- package/assets/templates/pages/table-comparison/page.tsx +12 -3
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +3 -0
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +3 -2
- package/assets/templates/themes/butter/butterTheme.ts +47 -44
- package/assets/templates/themes/chocolate/chocolateTheme.ts +15 -2
- package/assets/templates/themes/gothic/gothicTheme.ts +21 -16
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/matcha/matchaTheme.ts +15 -2
- package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +4 -4
- package/assets/templates/themes/neutral/neutralTheme.ts +24 -119
- package/assets/templates/themes/stone/stoneTheme.ts +46 -21
- package/assets/templates/themes/y2k/y2kTheme.ts +20 -16
- package/assets/theme.template.ts +18 -5
- package/authoring/codemod/type.ts +10 -0
- package/authoring/debug/parse.d.mts +2 -2
- package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +4 -4
- package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +6 -0
- package/authoring/doctypes/icon-set/parse.d.mts +1 -0
- package/authoring/doctypes/icon-set/parse.mjs +1 -0
- package/authoring/doctypes/icon-set/type.ts +5 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +2 -1
- package/clients/cli/commands/build-theme.adaptations.test.mjs +110 -0
- package/clients/cli/commands/build-theme.outside-project.test.mjs +140 -0
- package/clients/cli/commands/doctor.mjs +16 -17
- package/clients/cli/commands/experimental/icon.mjs +167 -35
- package/clients/cli/commands/experimental/index.mjs +2 -0
- package/clients/cli/commands/experimental/render.mjs +113 -0
- package/clients/cli/commands/experimental-icon-add.doc.mjs +14 -4
- package/clients/cli/commands/experimental-icon-map.doc.mjs +12 -2
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +28 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +18 -2
- package/clients/cli/commands/experimental-render.doc.mjs +60 -0
- package/clients/cli/commands/experimental.doc.mjs +4 -2
- package/clients/cli/commands/icon-authoring.test.mjs +1823 -13
- package/clients/cli/commands/icon-options-wiring.test.mjs +158 -0
- package/clients/cli/commands/icon.test.mjs +1 -1
- package/clients/cli/commands/template.mjs +4 -1
- package/clients/cli/commands/text-json-parity.test.mjs +46 -0
- package/clients/cli/commands/upgrade.doc.mjs +47 -2
- package/clients/cli/commands/upgrade.file-protection.test.mjs +175 -0
- package/clients/cli/commands/upgrade.flag-help.test.mjs +37 -0
- package/clients/cli/commands/upgrade.integration-policy.test.mjs +103 -0
- package/clients/cli/commands/upgrade.mjs +9 -2
- package/clients/cli/commands/upgrade.outcomes.test.mjs +350 -0
- package/clients/cli/index.mjs +1 -0
- package/foundation/agent-docs/agent-docs.mjs +1 -0
- package/foundation/agent-docs/agent-docs.test.mjs +5 -0
- package/foundation/discovery/component-discovery.d.mts +2 -1
- package/foundation/discovery/component-discovery.export-names.test.mjs +41 -0
- package/foundation/discovery/component-discovery.mjs +13 -7
- package/foundation/discovery/icon-set-checks.d.mts +43 -9
- package/foundation/discovery/icon-set-checks.mjs +296 -21
- package/foundation/discovery/icon-set-checks.test.mjs +125 -12
- package/foundation/discovery/icon-set-writer.d.mts +192 -3
- package/foundation/discovery/icon-set-writer.mjs +608 -34
- package/foundation/discovery/icon-set-writer.test.mjs +26 -0
- package/foundation/discovery/module-exports.mjs +82 -25
- package/foundation/discovery/module-exports.test.mjs +38 -1
- package/foundation/discovery/package-exports.d.mts +13 -0
- package/foundation/discovery/package-exports.mjs +40 -1
- package/foundation/discovery/template-icons.d.mts +6 -0
- package/foundation/discovery/template-icons.mjs +98 -10
- package/foundation/discovery/template-icons.test.mjs +103 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +22 -11
- package/foundation/doc-compiler/import.mjs +81 -8
- package/foundation/doc-compiler/read.d.mts +4 -3
- package/foundation/doc-compiler/read.mjs +15 -10
- package/foundation/doc-compiler/read.test.mjs +59 -1
- package/foundation/doc-compiler/tree.mjs +3 -1
- package/foundation/fs/module-loader.d.mts +3 -2
- package/foundation/fs/module-loader.mjs +3 -2
- package/foundation/fs/publish-file-eperm-mutation.test.mjs +2 -0
- package/foundation/fs/read-record.d.mts +27 -0
- package/foundation/fs/read-record.mjs +83 -15
- package/foundation/fs/read-record.test.mjs +88 -1
- package/foundation/render/assets.d.mts +31 -0
- package/foundation/render/assets.mjs +102 -0
- package/foundation/render/component-map.d.mts +52 -0
- package/foundation/render/component-map.mjs +141 -0
- package/foundation/render/css-cut.d.mts +29 -0
- package/foundation/render/css-cut.mjs +144 -0
- package/foundation/render/embedded-files.d.mts +28 -0
- package/foundation/render/embedded-files.mjs +108 -0
- package/foundation/render/embedded-imports.d.mts +61 -0
- package/foundation/render/embedded-imports.mjs +315 -0
- package/foundation/render/html-reader.d.mts +37 -0
- package/foundation/render/html-reader.mjs +121 -0
- package/foundation/render/page-worker.d.mts +7 -0
- package/foundation/render/page-worker.mjs +519 -0
- package/foundation/render/rebuild.d.mts +19 -0
- package/foundation/render/rebuild.mjs +269 -0
- package/foundation/render/render-page.d.mts +85 -0
- package/foundation/render/render-page.mjs +612 -0
- package/foundation/render/render.test.mjs +117 -0
- package/foundation/render/source-block.d.mts +52 -0
- package/foundation/render/source-block.mjs +106 -0
- package/foundation/response/base.d.ts +7 -0
- package/foundation/response/error-codes.d.mts +10 -1
- package/foundation/response/error-codes.doc.mjs +59 -2
- package/foundation/response/error-codes.mjs +62 -1
- package/foundation/response/json.d.mts +10 -3
- package/foundation/response/json.mjs +16 -4
- package/foundation/response/response-types.doc.mjs +39 -2
- package/foundation/text/string-utils.mjs +33 -0
- package/foundation/text/string-utils.test.mjs +17 -0
- package/foundation/text/suggest-order.d.mts +17 -3
- package/foundation/text/suggest-order.mjs +58 -13
- package/foundation/text/suggest-order.test.mjs +53 -0
- package/package.json +15 -9
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
|
|
59
59
|
import * as fs from 'node:fs';
|
|
60
60
|
import * as path from 'node:path';
|
|
61
|
-
import {isBuiltin} from 'node:module';
|
|
61
|
+
import {createRequire, isBuiltin} from 'node:module';
|
|
62
62
|
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
63
63
|
import {parse} from '@babel/parser';
|
|
64
64
|
import {createJiti} from 'jiti';
|
|
@@ -1103,6 +1103,28 @@ function componentHasAugmentableInterface(pascalName, interfaceName) {
|
|
|
1103
1103
|
return re.test(decl);
|
|
1104
1104
|
}
|
|
1105
1105
|
|
|
1106
|
+
/**
|
|
1107
|
+
* Public augmentable maps whose axis requests artwork instead of styling.
|
|
1108
|
+
* `Icon.variant` selects a theme's icon artwork, so it has no component styling
|
|
1109
|
+
* map (architecture:component-theming-surface INV14): a `components` key on it
|
|
1110
|
+
* never enrolls a value or generates an augmentation of its map.
|
|
1111
|
+
*/
|
|
1112
|
+
const ARTWORK_REQUEST_MAPS = new Set(['IconVariantMap']);
|
|
1113
|
+
|
|
1114
|
+
/**
|
|
1115
|
+
* Whether a theme's component styling keys may enroll values in `interfaceName`
|
|
1116
|
+
* on `@astryxdesign/core/<Component>`.
|
|
1117
|
+
* @param {string} pascalName
|
|
1118
|
+
* @param {string} interfaceName
|
|
1119
|
+
* @returns {boolean}
|
|
1120
|
+
*/
|
|
1121
|
+
function isComponentValueAugmentationPoint(pascalName, interfaceName) {
|
|
1122
|
+
return (
|
|
1123
|
+
!ARTWORK_REQUEST_MAPS.has(interfaceName) &&
|
|
1124
|
+
componentHasAugmentableInterface(pascalName, interfaceName)
|
|
1125
|
+
);
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1106
1128
|
/**
|
|
1107
1129
|
* Adaptation values from resolved runtime rules, raw input, or normalized built
|
|
1108
1130
|
* metadata. Built modules intentionally omit `__adaptationRules`, so every CLI
|
|
@@ -1410,7 +1432,7 @@ async function classifyComponentValue(component, prop, value) {
|
|
|
1410
1432
|
const propPascal = prop.charAt(0).toUpperCase() + prop.slice(1);
|
|
1411
1433
|
const target = (await resolveAugmentationTargetCandidates(component)).find(
|
|
1412
1434
|
candidate =>
|
|
1413
|
-
|
|
1435
|
+
isComponentValueAugmentationPoint(
|
|
1414
1436
|
candidate.moduleName,
|
|
1415
1437
|
`${candidate.interfacePrefix}${propPascal}Map`,
|
|
1416
1438
|
),
|
|
@@ -1567,7 +1589,7 @@ async function generateVariantDeclarationsAsync(themeDef) {
|
|
|
1567
1589
|
const target = (
|
|
1568
1590
|
await resolveAugmentationTargetCandidates(component)
|
|
1569
1591
|
).find(candidate =>
|
|
1570
|
-
|
|
1592
|
+
isComponentValueAugmentationPoint(
|
|
1571
1593
|
candidate.moduleName,
|
|
1572
1594
|
`${candidate.interfacePrefix}${propPascal}Map`,
|
|
1573
1595
|
),
|
|
@@ -1833,19 +1855,43 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
1833
1855
|
commonJsPatch.undo();
|
|
1834
1856
|
}
|
|
1835
1857
|
} else {
|
|
1836
|
-
mod = await jiti.import(filePath
|
|
1858
|
+
mod = await jiti.import(filePath);
|
|
1837
1859
|
}
|
|
1838
1860
|
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1861
|
+
// Both loads hand back the module. The theme is read from the module's own
|
|
1862
|
+
// exports, never from the module object itself: jiti's interop answers a
|
|
1863
|
+
// property the module lacks from its default export (and a missing
|
|
1864
|
+
// `default` with the module), so the module can pass for the theme while
|
|
1865
|
+
// its own keys hide the theme's fields.
|
|
1866
|
+
const isModule = mod != null && typeof mod === 'object';
|
|
1867
|
+
const hasDefault = isModule && Object.hasOwn(mod, 'default');
|
|
1868
|
+
const defaultExport = hasDefault ? mod.default : undefined;
|
|
1869
|
+
if (isThemeObject(defaultExport)) {
|
|
1870
|
+
return {theme: defaultExport, exportName: 'default', degraded};
|
|
1871
|
+
}
|
|
1872
|
+
if (isModule) {
|
|
1845
1873
|
for (const [exportName, value] of Object.entries(mod)) {
|
|
1874
|
+
if (exportName === 'default' || exportName === 'module.exports') continue;
|
|
1846
1875
|
if (isThemeObject(value)) return {theme: value, exportName, degraded};
|
|
1847
1876
|
}
|
|
1848
1877
|
}
|
|
1878
|
+
// A plain-object default export is the module's theme even when it has
|
|
1879
|
+
// no tokens of its own (local tokens, typography or component styles may
|
|
1880
|
+
// be all it defines), or no name: the build's validation says what it
|
|
1881
|
+
// lacks.
|
|
1882
|
+
if (isPlainObject(defaultExport)) {
|
|
1883
|
+
return {theme: defaultExport, exportName: 'default', degraded};
|
|
1884
|
+
}
|
|
1885
|
+
// A CommonJS module whose exports are the theme (`module.exports =
|
|
1886
|
+
// theme`) has no default of its own: interop answers `default` with
|
|
1887
|
+
// those exports, and without interop (a family build's loader) the module
|
|
1888
|
+
// is them.
|
|
1889
|
+
if (isModule && !hasDefault) {
|
|
1890
|
+
const exportsObject = mod.default ?? mod;
|
|
1891
|
+
if (isThemeObject(exportsObject)) {
|
|
1892
|
+
return {theme: exportsObject, exportName: 'default', degraded};
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1849
1895
|
|
|
1850
1896
|
throw new Error(
|
|
1851
1897
|
`Could not find a defineTheme() result in ${filePath}.\n` +
|
|
@@ -1853,6 +1899,45 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
1853
1899
|
);
|
|
1854
1900
|
}
|
|
1855
1901
|
|
|
1902
|
+
/**
|
|
1903
|
+
* Whether the theme file's own folder resolves Core's theme entry, as the
|
|
1904
|
+
* theme's own `import ... from '@astryxdesign/core/theme'` would. A theme
|
|
1905
|
+
* outside any project (an empty folder, a fresh clone) does not, and is
|
|
1906
|
+
* handed the Core the CLI answers with instead, as a new project with that
|
|
1907
|
+
* Core would build it (`theme build` runs the same outside a project, spec
|
|
1908
|
+
* AST-081 FR3). Only a Core not installed there (MODULE_NOT_FOUND) reads as
|
|
1909
|
+
* no: an installed Core whose entry does not resolve is the theme's own, and
|
|
1910
|
+
* its load reports that.
|
|
1911
|
+
* @param {string} filePath
|
|
1912
|
+
* @returns {boolean}
|
|
1913
|
+
*/
|
|
1914
|
+
function themeFolderResolvesCore(filePath) {
|
|
1915
|
+
try {
|
|
1916
|
+
createRequire(filePath).resolve('@astryxdesign/core/theme');
|
|
1917
|
+
return true;
|
|
1918
|
+
} catch (error) {
|
|
1919
|
+
const {code} = /** @type {NodeJS.ErrnoException} */ (error);
|
|
1920
|
+
if (code === 'MODULE_NOT_FOUND') return false;
|
|
1921
|
+
if (code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') return true;
|
|
1922
|
+
throw error;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
/**
|
|
1927
|
+
* A plain object, not an array or a module namespace: a theme module's
|
|
1928
|
+
* default export, read as its theme.
|
|
1929
|
+
* @param {any} value
|
|
1930
|
+
* @returns {boolean}
|
|
1931
|
+
*/
|
|
1932
|
+
function isPlainObject(value) {
|
|
1933
|
+
return (
|
|
1934
|
+
value != null &&
|
|
1935
|
+
typeof value === 'object' &&
|
|
1936
|
+
!Array.isArray(value) &&
|
|
1937
|
+
value[Symbol.toStringTag] !== 'Module'
|
|
1938
|
+
);
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1856
1941
|
/**
|
|
1857
1942
|
* @param {any} value
|
|
1858
1943
|
* @returns {boolean}
|
|
@@ -1868,12 +1953,9 @@ function isThemeObject(value) {
|
|
|
1868
1953
|
}
|
|
1869
1954
|
|
|
1870
1955
|
/**
|
|
1871
|
-
* Extract the theme definition from a JS/TS file
|
|
1872
|
-
*
|
|
1873
|
-
*
|
|
1874
|
-
* The legacy fallback needs no interception: it evaluates the `defineTheme()`
|
|
1875
|
-
* ARGUMENT, so what it returns is raw authored input with `adaptations` still
|
|
1876
|
-
* on it — nothing has erased anything yet. It is therefore never degraded.
|
|
1956
|
+
* Extract the theme definition from a JS/TS file, through jiti (full TS
|
|
1957
|
+
* support). A module that does not load fails with its own error: the theme
|
|
1958
|
+
* is never read from the file's text instead.
|
|
1877
1959
|
*
|
|
1878
1960
|
* @param {string} filePath
|
|
1879
1961
|
* @param {import('./core-interception.mjs').CoreInterception} [interception]
|
|
@@ -1884,18 +1966,12 @@ async function extractThemeDefinition(filePath, interception, /** @type {any} */
|
|
|
1884
1966
|
try {
|
|
1885
1967
|
return await importThemeModule(filePath, interception, loader);
|
|
1886
1968
|
} catch (jitiError) {
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
const je = /** @type {Error} */ (jitiError);
|
|
1894
|
-
throw new Error(
|
|
1895
|
-
`Failed to load theme from ${filePath}: ${je.message}\n` +
|
|
1896
|
-
`Make sure all imports in the theme file are resolvable.`,
|
|
1897
|
-
);
|
|
1898
|
-
}
|
|
1969
|
+
const je = /** @type {Error} */ (jitiError);
|
|
1970
|
+
throw new Error(
|
|
1971
|
+
`Failed to load theme from ${filePath}: ${je.message}\n` +
|
|
1972
|
+
`Make sure all imports in the theme file are resolvable.`,
|
|
1973
|
+
{cause: jitiError},
|
|
1974
|
+
);
|
|
1899
1975
|
}
|
|
1900
1976
|
}
|
|
1901
1977
|
|
|
@@ -1941,45 +2017,6 @@ export async function validateThemePrivateInputs(
|
|
|
1941
2017
|
}
|
|
1942
2018
|
}
|
|
1943
2019
|
|
|
1944
|
-
/**
|
|
1945
|
-
* Fallback extraction via regex + eval.
|
|
1946
|
-
* Only works for plain object literals — can't follow imports or variables.
|
|
1947
|
-
* Never erase icon references: an unresolved registry must preserve the loader
|
|
1948
|
-
* error instead of turning an incomplete theme into a successful build.
|
|
1949
|
-
* @param {string} filePath
|
|
1950
|
-
* @returns {any}
|
|
1951
|
-
*/
|
|
1952
|
-
function extractThemeDefinitionLegacy(filePath) {
|
|
1953
|
-
const content = fs.readFileSync(filePath, 'utf8');
|
|
1954
|
-
|
|
1955
|
-
const defineMatch = content.match(/defineTheme\s*\(\s*({[\s\S]*?})\s*\)/);
|
|
1956
|
-
if (!defineMatch) {
|
|
1957
|
-
const defaultMatch = content.match(/export\s+default\s+({[\s\S]*?});/);
|
|
1958
|
-
if (!defaultMatch) {
|
|
1959
|
-
throw new Error(
|
|
1960
|
-
`Could not find defineTheme() call or default export in ${filePath}.\n` +
|
|
1961
|
-
`Expected: defineTheme({ name: '...', tokens: {...} })`,
|
|
1962
|
-
);
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
return eval(`(${defaultMatch[1]})`);
|
|
1966
|
-
}
|
|
1967
|
-
|
|
1968
|
-
let objStr = defineMatch[1];
|
|
1969
|
-
objStr = objStr.replace(/\s+as\s+const/g, '');
|
|
1970
|
-
|
|
1971
|
-
try {
|
|
1972
|
-
return eval(`(${objStr})`);
|
|
1973
|
-
} catch (e) {
|
|
1974
|
-
const err = /** @type {Error} */ (e);
|
|
1975
|
-
throw new Error(
|
|
1976
|
-
`Failed to parse theme definition in ${filePath}: ${err.message}\n` +
|
|
1977
|
-
`Make sure the defineTheme() argument is a plain object literal.`,
|
|
1978
|
-
{cause: e},
|
|
1979
|
-
);
|
|
1980
|
-
}
|
|
1981
|
-
}
|
|
1982
|
-
|
|
1983
2020
|
/**
|
|
1984
2021
|
* Extract a family member's named registry import from its source file.
|
|
1985
2022
|
* Returns { importPath, exportName } or null when the theme names none.
|
|
@@ -2151,7 +2188,22 @@ function generateBuiltModule(
|
|
|
2151
2188
|
serializeField('__onDark', themeDef.__onDark) +
|
|
2152
2189
|
serializeField('__onLight', themeDef.__onLight) +
|
|
2153
2190
|
serializeField('__adaptations', themeDef.__adaptations) +
|
|
2154
|
-
serializeField('__axes', themeDef.__axes ?? {}, true)
|
|
2191
|
+
serializeField('__axes', themeDef.__axes ?? {}, true) +
|
|
2192
|
+
// An explicit empty list replaces an inherited one, so keep `[]`.
|
|
2193
|
+
serializeField('iconVariants', themeDef.iconVariants, true) +
|
|
2194
|
+
// Each inherited function entry keeps its defining theme's list. JSON
|
|
2195
|
+
// drops `undefined`, so a defining theme with no list is written as `[]`,
|
|
2196
|
+
// which no variant matches either.
|
|
2197
|
+
serializeField(
|
|
2198
|
+
'__iconEntryVariants',
|
|
2199
|
+
themeDef.__iconEntryVariants &&
|
|
2200
|
+
Object.fromEntries(
|
|
2201
|
+
Object.entries(themeDef.__iconEntryVariants).map(([name, list]) => [
|
|
2202
|
+
name,
|
|
2203
|
+
list ?? [],
|
|
2204
|
+
]),
|
|
2205
|
+
),
|
|
2206
|
+
);
|
|
2155
2207
|
|
|
2156
2208
|
return `${iconImport}${iconDeclaration}/**
|
|
2157
2209
|
* ${themeDef.name} theme — built by \`${getCliInvocation()} theme build\`
|
|
@@ -2580,13 +2632,15 @@ async function themeBuildInternal(
|
|
|
2580
2632
|
}
|
|
2581
2633
|
await selectCore(cwd, {projectOnly: projectCore});
|
|
2582
2634
|
|
|
2583
|
-
// Standalone builds
|
|
2584
|
-
// adaptations
|
|
2635
|
+
// Standalone builds need interception when an older Core could erase
|
|
2636
|
+
// adaptations, and when the theme's folder has no Core of its own: its
|
|
2637
|
+
// imports of Core are then handed the Core this build selected, as family
|
|
2638
|
+
// builds' are. Family preparation always supplies the same recorder as its
|
|
2585
2639
|
// shared loader so exact authored parent identity stays CLI-private instead
|
|
2586
2640
|
// of becoming a public DefinedTheme field.
|
|
2587
2641
|
const interception =
|
|
2588
2642
|
options.__familyInterception ??
|
|
2589
|
-
(_generateAdaptationCSS
|
|
2643
|
+
(_generateAdaptationCSS && themeFolderResolvesCore(filePath)
|
|
2590
2644
|
? undefined
|
|
2591
2645
|
: interceptCore(_coreThemeModule, _coreRootModule));
|
|
2592
2646
|
|
|
@@ -2870,10 +2924,15 @@ async function themeBuildInternal(
|
|
|
2870
2924
|
/** @type {string[]} */
|
|
2871
2925
|
const droppedDeclarations = [];
|
|
2872
2926
|
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
droppedDeclarations
|
|
2876
|
-
)
|
|
2927
|
+
let themeRules;
|
|
2928
|
+
try {
|
|
2929
|
+
themeRules = _generateThemeRulesSplit(resolvedTheme, droppedDeclarations);
|
|
2930
|
+
} catch (error) {
|
|
2931
|
+
const message =
|
|
2932
|
+
error instanceof Error ? error.message : 'Theme normalization failed.';
|
|
2933
|
+
throw new AstryxError(message, undefined, ERROR_CODES.ERR_THEME_INVALID);
|
|
2934
|
+
}
|
|
2935
|
+
const {component, prose} = themeRules;
|
|
2877
2936
|
const cssParts = [];
|
|
2878
2937
|
// Prose element defaults always ship — the `<Theme>` runtime
|
|
2879
2938
|
// (generateThemeCSS) always emits them, so the build must too, or the
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
import {
|
|
28
28
|
themeBuild,
|
|
29
29
|
validateComponentOverridesAgainstRegistry,
|
|
30
|
+
validateThemePrivateInputs,
|
|
30
31
|
} from './build.mjs';
|
|
31
32
|
|
|
32
33
|
// `themeBuild` captures core's generator once at module load. Wrap the two
|
|
@@ -212,6 +213,55 @@ describe('themeBuild() — receipt', () => {
|
|
|
212
213
|
});
|
|
213
214
|
});
|
|
214
215
|
|
|
216
|
+
describe.each(['mjs', 'ts'])('a .%s theme module with no theme export', ext => {
|
|
217
|
+
beforeEach(() => {
|
|
218
|
+
fs.writeFileSync(
|
|
219
|
+
path.join(tmpDir, `none.${ext}`),
|
|
220
|
+
'export const notATheme = 42;\n',
|
|
221
|
+
);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('fails the build as a module that does not load a theme', async () => {
|
|
225
|
+
const build = themeBuild(`none.${ext}`, {}, {cwd: tmpDir});
|
|
226
|
+
await expect(build).rejects.toThrow(
|
|
227
|
+
/Could not find a defineTheme\(\) result/,
|
|
228
|
+
);
|
|
229
|
+
await expect(build).rejects.toMatchObject({code: 'ERR_THEME_LOAD'});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("fails doctor's private-input check the same way, rather than read its exports as a theme", async () => {
|
|
233
|
+
await expect(
|
|
234
|
+
validateThemePrivateInputs(`none.${ext}`, {cwd: tmpDir}),
|
|
235
|
+
).rejects.toThrow(/Could not find a defineTheme\(\) result/);
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
describe('themeBuild() — a theme module that does not load', () => {
|
|
240
|
+
it('fails with the import error, rather than build the theme from the file text', async () => {
|
|
241
|
+
fs.writeFileSync(
|
|
242
|
+
path.join(tmpDir, 'unresolved.mjs'),
|
|
243
|
+
"import './missing-helper.mjs';\nexport default {name: 'unresolved', tokens: {'--color-bg': '#000'}};\n",
|
|
244
|
+
);
|
|
245
|
+
await expect(
|
|
246
|
+
themeBuild('unresolved.mjs', {}, {cwd: tmpDir}),
|
|
247
|
+
).rejects.toThrow(
|
|
248
|
+
/Failed to load theme from .*unresolved\.mjs: .*missing-helper\.mjs/s,
|
|
249
|
+
);
|
|
250
|
+
expect(fs.existsSync(path.join(tmpDir, 'unresolved.css'))).toBe(false);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('fails with the error the module throws, rather than build the theme from the file text', async () => {
|
|
254
|
+
fs.writeFileSync(
|
|
255
|
+
path.join(tmpDir, 'throws.mjs'),
|
|
256
|
+
"throw new Error('the theme module failed');\nexport default {name: 'throws', tokens: {'--color-bg': '#000'}};\n",
|
|
257
|
+
);
|
|
258
|
+
await expect(themeBuild('throws.mjs', {}, {cwd: tmpDir})).rejects.toThrow(
|
|
259
|
+
/the theme module failed/,
|
|
260
|
+
);
|
|
261
|
+
expect(fs.existsSync(path.join(tmpDir, 'throws.css'))).toBe(false);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
215
265
|
describe('themeBuild() — dropped declarations reach the receipt', () => {
|
|
216
266
|
// Core's generator refuses a declaration whose value would end it early
|
|
217
267
|
// (an unquoted `;` or brace, an unclosed string/comment/url). The runtime
|
|
@@ -599,6 +649,33 @@ describe('themeBuild() — component override validation', () => {
|
|
|
599
649
|
});
|
|
600
650
|
});
|
|
601
651
|
|
|
652
|
+
describe('themeBuild() — Icon size dimensions', () => {
|
|
653
|
+
it('writes width and height on an icon size into the vars the glyph reads, with no warnings', async () => {
|
|
654
|
+
// spec:AST-087 FR10: a built theme sets an Icon size's glyph dimension the
|
|
655
|
+
// way the runtime provider does, through the shared compiler's derived
|
|
656
|
+
// vars. Raw width/height would lose to a consumer's unlayered StyleX.
|
|
657
|
+
const themeFile = path.join(tmpDir, 'iconsizes.mjs');
|
|
658
|
+
fs.writeFileSync(
|
|
659
|
+
themeFile,
|
|
660
|
+
`export default {
|
|
661
|
+
name: 'iconsizes',
|
|
662
|
+
tokens: {'--color-bg': '#0a0a0a'},
|
|
663
|
+
components: {icon: {'size:sm': {width: '18px', height: '22px'}}},
|
|
664
|
+
};\n`,
|
|
665
|
+
);
|
|
666
|
+
|
|
667
|
+
const result = await themeBuild('iconsizes.mjs', {}, {cwd: tmpDir});
|
|
668
|
+
|
|
669
|
+
expect(result?.data.warnings).toEqual([]);
|
|
670
|
+
const css = fs.readFileSync(path.join(tmpDir, 'iconsizes.css'), 'utf8');
|
|
671
|
+
const rule =
|
|
672
|
+
css.match(/\.astryx-icon\[data-size="sm"\]\s*\{([^}]*)\}/)?.[1] ?? '';
|
|
673
|
+
expect(rule).toMatch(/--_icon-width:\s*18px/);
|
|
674
|
+
expect(rule).toMatch(/--_icon-height:\s*22px/);
|
|
675
|
+
expect(rule).not.toMatch(/(^|[\s;])(width|height)\s*:/);
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
|
|
602
679
|
describe('themeBuild() — the shipped theme template', () => {
|
|
603
680
|
// `assets/theme.template.ts` is what `astryx theme template` puts in a
|
|
604
681
|
// consumer's project. It is the one theme file we hand out, so it has to
|
|
@@ -180,13 +180,42 @@ export function getCoreVersionManifests(from: string, to: string): Promise<CoreV
|
|
|
180
180
|
export function ensureCodemodDeps({ installDeps }?: {
|
|
181
181
|
installDeps?: boolean;
|
|
182
182
|
}): Promise<boolean>;
|
|
183
|
+
/**
|
|
184
|
+
* @typedef {{kind: 'manual', file: string, codemod: string, message: string, line?: number} | {kind: 'regenerate', file: string, codemod: string, message: string, commands: string[]}} CodemodOutcomeRecord
|
|
185
|
+
*/
|
|
186
|
+
/**
|
|
187
|
+
* Wrap each core code and config transform so the non-failure outcomes it
|
|
188
|
+
* throws (`assets/codemods/outcome.mjs`) are recorded instead of reaching the
|
|
189
|
+
* runner as errors. The wrapped transform leaves that file unchanged, exactly
|
|
190
|
+
* as the throw did. Project codemods keep their own contract. One wrapper per
|
|
191
|
+
* pass: the regeneration re-check takes a fresh one, so an outcome a hook
|
|
192
|
+
* resolved does not linger.
|
|
193
|
+
*
|
|
194
|
+
* @template {{version: string, transforms: Array<{name: string, transform: any, meta?: {codemodType?: string}}>}} M
|
|
195
|
+
* @param {M[]} versionManifests
|
|
196
|
+
* @param {string} root project root; recorded files are relative to it
|
|
197
|
+
* @returns {{versionManifests: M[], outcomes: CodemodOutcomeRecord[]}}
|
|
198
|
+
*/
|
|
199
|
+
export function withCodemodOutcomes<M extends {
|
|
200
|
+
version: string;
|
|
201
|
+
transforms: Array<{
|
|
202
|
+
name: string;
|
|
203
|
+
transform: any;
|
|
204
|
+
meta?: {
|
|
205
|
+
codemodType?: string;
|
|
206
|
+
};
|
|
207
|
+
}>;
|
|
208
|
+
}>(versionManifests: M[], root: string): {
|
|
209
|
+
versionManifests: M[];
|
|
210
|
+
outcomes: CodemodOutcomeRecord[];
|
|
211
|
+
};
|
|
183
212
|
/**
|
|
184
213
|
* Run the CORE registry codemods. Runs BEFORE the config is loaded so a core
|
|
185
214
|
* CONFIG codemod can repair a config the strict loader would otherwise reject.
|
|
186
215
|
* @param {CoreVersionManifest[]} versionManifests
|
|
187
|
-
* @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean}} options
|
|
216
|
+
* @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean, outcomes?: CodemodOutcomeRecord[]}} options
|
|
188
217
|
*/
|
|
189
|
-
export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply, path: srcPath, codemod, skipCodemods, root, protection, silent, coversTarget, }: {
|
|
218
|
+
export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply, path: srcPath, codemod, skipCodemods, root, protection, silent, coversTarget, outcomes, }: {
|
|
190
219
|
apply: boolean;
|
|
191
220
|
path: string;
|
|
192
221
|
codemod?: string;
|
|
@@ -198,6 +227,7 @@ export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply
|
|
|
198
227
|
};
|
|
199
228
|
silent?: boolean;
|
|
200
229
|
coversTarget?: boolean;
|
|
230
|
+
outcomes?: CodemodOutcomeRecord[];
|
|
201
231
|
}): Promise<{
|
|
202
232
|
totalFilesChanged: number;
|
|
203
233
|
totalTransformsApplied: number;
|
|
@@ -206,6 +236,7 @@ export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply
|
|
|
206
236
|
writtenFiles: string[];
|
|
207
237
|
stagedContents: Map<string, string>;
|
|
208
238
|
protectedFiles: import("../../authoring/codemod/type").CodemodRunResult["protectedFiles"];
|
|
239
|
+
declinedCandidates: NonNullable<import("../../authoring/codemod/type").CodemodRunResult["declinedCandidates"]>;
|
|
209
240
|
errors: Array<{
|
|
210
241
|
file: string;
|
|
211
242
|
codemod: string;
|
|
@@ -301,6 +332,7 @@ export function runIntegrationCodemodsStep(versionGroups: Array<{
|
|
|
301
332
|
writtenFiles: string[];
|
|
302
333
|
stagedContents: Map<string, string>;
|
|
303
334
|
protectedFiles: import("../../authoring/codemod/type").CodemodRunResult["protectedFiles"];
|
|
335
|
+
declinedCandidates: NonNullable<import("../../authoring/codemod/type").CodemodRunResult["declinedCandidates"]>;
|
|
304
336
|
errors: Array<{
|
|
305
337
|
file: string;
|
|
306
338
|
codemod: string;
|
|
@@ -347,4 +379,17 @@ export type AgentDocsRefreshPlan = {
|
|
|
347
379
|
renderedBlock: string | null;
|
|
348
380
|
summary: import("./upgrade.type.mjs").AgentDocsSummary;
|
|
349
381
|
};
|
|
382
|
+
export type CodemodOutcomeRecord = {
|
|
383
|
+
kind: "manual";
|
|
384
|
+
file: string;
|
|
385
|
+
codemod: string;
|
|
386
|
+
message: string;
|
|
387
|
+
line?: number;
|
|
388
|
+
} | {
|
|
389
|
+
kind: "regenerate";
|
|
390
|
+
file: string;
|
|
391
|
+
codemod: string;
|
|
392
|
+
message: string;
|
|
393
|
+
commands: string[];
|
|
394
|
+
};
|
|
350
395
|
import { inspectAgentDocs } from '../../foundation/agent-docs/agent-docs.mjs';
|
package/api/upgrade/_adapter.mjs
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
latestVersion,
|
|
25
25
|
} from '../../assets/codemods/registry.mjs';
|
|
26
26
|
import {runCodemods} from '../../assets/codemods/runner.mjs';
|
|
27
|
+
import {codemodOutcome} from '../../assets/codemods/outcome.mjs';
|
|
27
28
|
import {
|
|
28
29
|
discoverIntegrationCodemods,
|
|
29
30
|
selectIntegrationCodemods,
|
|
@@ -141,7 +142,12 @@ export function relativeToOrigin(result, {cwd: root, origin}) {
|
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
144
|
if (data.modifiedFiles) data.modifiedFiles = data.modifiedFiles.map(rebase);
|
|
144
|
-
for (const key of [
|
|
145
|
+
for (const key of [
|
|
146
|
+
'protectedFiles',
|
|
147
|
+
'declinedCandidates',
|
|
148
|
+
'errors',
|
|
149
|
+
'regenerate',
|
|
150
|
+
]) {
|
|
145
151
|
if (data[key]) {
|
|
146
152
|
data[key] = data[key].map(
|
|
147
153
|
(/** @type {{file: string, declarations?: string[]}} */ entry) => ({
|
|
@@ -599,11 +605,59 @@ export async function ensureCodemodDeps({installDeps} = {}) {
|
|
|
599
605
|
return ensureJscodeshift({installDeps, silent: logger.silent});
|
|
600
606
|
}
|
|
601
607
|
|
|
608
|
+
/**
|
|
609
|
+
* @typedef {{kind: 'manual', file: string, codemod: string, message: string, line?: number} | {kind: 'regenerate', file: string, codemod: string, message: string, commands: string[]}} CodemodOutcomeRecord
|
|
610
|
+
*/
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Wrap each core code and config transform so the non-failure outcomes it
|
|
614
|
+
* throws (`assets/codemods/outcome.mjs`) are recorded instead of reaching the
|
|
615
|
+
* runner as errors. The wrapped transform leaves that file unchanged, exactly
|
|
616
|
+
* as the throw did. Project codemods keep their own contract. One wrapper per
|
|
617
|
+
* pass: the regeneration re-check takes a fresh one, so an outcome a hook
|
|
618
|
+
* resolved does not linger.
|
|
619
|
+
*
|
|
620
|
+
* @template {{version: string, transforms: Array<{name: string, transform: any, meta?: {codemodType?: string}}>}} M
|
|
621
|
+
* @param {M[]} versionManifests
|
|
622
|
+
* @param {string} root project root; recorded files are relative to it
|
|
623
|
+
* @returns {{versionManifests: M[], outcomes: CodemodOutcomeRecord[]}}
|
|
624
|
+
*/
|
|
625
|
+
export function withCodemodOutcomes(versionManifests, root) {
|
|
626
|
+
/** @type {CodemodOutcomeRecord[]} */
|
|
627
|
+
const outcomes = [];
|
|
628
|
+
const wrapped = versionManifests.map(manifest => ({
|
|
629
|
+
...manifest,
|
|
630
|
+
transforms: manifest.transforms.map(entry => {
|
|
631
|
+
if (entry.meta?.codemodType === 'project') return entry;
|
|
632
|
+
const {transform, name} = entry;
|
|
633
|
+
return {
|
|
634
|
+
...entry,
|
|
635
|
+
/** @param {{path: string, source: string}} file @param {unknown} api */
|
|
636
|
+
transform(file, api) {
|
|
637
|
+
try {
|
|
638
|
+
return transform(file, api);
|
|
639
|
+
} catch (err) {
|
|
640
|
+
const outcome = codemodOutcome(err);
|
|
641
|
+
if (!outcome) throw err;
|
|
642
|
+
outcomes.push({
|
|
643
|
+
...outcome,
|
|
644
|
+
file: path.relative(root, file.path).split(path.sep).join('/'),
|
|
645
|
+
codemod: `core:${name}`,
|
|
646
|
+
});
|
|
647
|
+
return undefined;
|
|
648
|
+
}
|
|
649
|
+
},
|
|
650
|
+
};
|
|
651
|
+
}),
|
|
652
|
+
}));
|
|
653
|
+
return {versionManifests: /** @type {M[]} */ (wrapped), outcomes};
|
|
654
|
+
}
|
|
655
|
+
|
|
602
656
|
/**
|
|
603
657
|
* Run the CORE registry codemods. Runs BEFORE the config is loaded so a core
|
|
604
658
|
* CONFIG codemod can repair a config the strict loader would otherwise reject.
|
|
605
659
|
* @param {CoreVersionManifest[]} versionManifests
|
|
606
|
-
* @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean}} options
|
|
660
|
+
* @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean, outcomes?: CodemodOutcomeRecord[]}} options
|
|
607
661
|
*/
|
|
608
662
|
export async function runCoreCodemods(
|
|
609
663
|
versionManifests,
|
|
@@ -616,6 +670,7 @@ export async function runCoreCodemods(
|
|
|
616
670
|
protection,
|
|
617
671
|
silent,
|
|
618
672
|
coversTarget,
|
|
673
|
+
outcomes,
|
|
619
674
|
},
|
|
620
675
|
) {
|
|
621
676
|
return runCodemods(versionManifests, {
|
|
@@ -627,6 +682,7 @@ export async function runCoreCodemods(
|
|
|
627
682
|
root,
|
|
628
683
|
protection,
|
|
629
684
|
coversTarget,
|
|
685
|
+
outcomes,
|
|
630
686
|
});
|
|
631
687
|
}
|
|
632
688
|
|