diff --git a/.changeset/cli-drop-theme-default-neutral-rename.md b/.changeset/cli-drop-theme-default-neutral-rename.md new file mode 100644 index 000000000000..3cc3b77380dd --- /dev/null +++ b/.changeset/cli-drop-theme-default-neutral-rename.md @@ -0,0 +1,6 @@ +--- +'@astryxdesign/cli': patch +--- + +[fix] Remove the `@xds/theme-default` → `@astryxdesign/theme-neutral` collapse from the v0.1.0 upgrade codemods (module-specifiers, css-surfaces, and declare-module). `theme-default` was dropped at the v0.1.0 scope move, so no v0.1.x consumer imported it — the collapse was dead and could rewrite unrelated source (including `@xds/theme-default/theme.css` CSS imports) to a `@astryxdesign/theme-neutral` package the app never declared. The `@xds/theme-daily` → `theme-neutral` collapse (and its `defaultTheme` → `neutralTheme` export remap) is unchanged. +@ejhammond diff --git a/packages/cli/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs b/packages/cli/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs index b2b72b6fc2c4..e35df94a146a 100644 --- a/packages/cli/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +++ b/packages/cli/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs @@ -69,13 +69,13 @@ describe('migrate-xds-css-surfaces', () => { const input = [ `@import '@xds/core/reset.css';`, `@import '@xds/core/xds.css';`, - `@import '@xds/theme-default/theme.css';`, + `@import '@xds/theme-daily/theme.css';`, ].join('\n'); const output = await applyTransform(input); expect(output).toContain(`@import '@astryxdesign/core/reset.css';`); // xds.css is renamed to astryx.css (file rename, not just scope swap). expect(output).toContain(`@import '@astryxdesign/core/astryx.css';`); - // theme-default collapses to theme-neutral. + // theme-daily collapses to theme-neutral. expect(output).toContain( `@import '@astryxdesign/theme-neutral/theme.css';`, ); diff --git a/packages/cli/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs b/packages/cli/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs index 93e026f446de..b637eea19cb1 100644 --- a/packages/cli/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +++ b/packages/cli/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs @@ -17,7 +17,7 @@ describe('migrate-xds-module-specifiers', () => { it('renames import and export source paths including subpaths', async () => { const input = [ "import {Button} from '@xds/core/Button';", - "import '@xds/theme-default/theme.css';", + "import '@xds/theme-daily/theme.css';", "export {LabThing} from '@xds/lab/Thing';", "export * from '@xds/core/theme';", ].join('\n'); @@ -49,18 +49,6 @@ describe('migrate-xds-module-specifiers', () => { expect(output).toBe(input); }); - it('remaps defaultTheme -> neutralTheme when collapsing theme-default', async () => { - const output = await applyTransform( - `import {defaultTheme} from '@xds/theme-default';`, - 'test.ts', - ); - // Package collapses to theme-neutral; binding aliased so local usage works. - expect(output).toContain('neutralTheme as defaultTheme'); - expect(output).toContain('@astryxdesign/theme-neutral'); - expect(output).not.toContain('@xds/'); - expect(output).not.toContain('theme-default'); - }); - it('remaps defaultTheme -> neutralTheme for theme-daily and /built subpath', async () => { const output = await applyTransform( `import {defaultTheme} from '@xds/theme-daily/built';`, @@ -72,7 +60,7 @@ describe('migrate-xds-module-specifiers', () => { it('preserves an existing alias when remapping defaultTheme', async () => { const output = await applyTransform( - `import {defaultTheme as dt} from '@xds/theme-default';`, + `import {defaultTheme as dt} from '@xds/theme-daily';`, 'test.ts', ); expect(output).toContain('neutralTheme as dt'); diff --git a/packages/cli/assets/codemods/transforms/v0.1.0/migrate-xds-css-surfaces.mjs b/packages/cli/assets/codemods/transforms/v0.1.0/migrate-xds-css-surfaces.mjs index 762ccdeb3b73..3536fb346675 100644 --- a/packages/cli/assets/codemods/transforms/v0.1.0/migrate-xds-css-surfaces.mjs +++ b/packages/cli/assets/codemods/transforms/v0.1.0/migrate-xds-css-surfaces.mjs @@ -20,7 +20,7 @@ * comma-separated `\@layer a, b;` statement lists and nested blocks. * - `\@import '\@xds/...'` package stylesheet imports: scope rewrite, plus the * `\@xds/core/xds.css` -> `\@astryxdesign/core/astryx.css` file rename and the - * `theme-default` / `theme-daily` -> `theme-neutral` collapse. + * `theme-daily` -> `theme-neutral` collapse. * * It deliberately does NOT blindly replace every `xds` substring: a bare * `xds` in a comment, a custom-property value, or an unrelated identifier is @@ -36,7 +36,7 @@ export const meta = { '`[data-xds-theme-prose]` / `[data-xds-media]` attribute selectors, ' + '`@layer xds-theme` / `@layer xds-base` cascade-layer names, and ' + '`@import` of @xds/* package stylesheets (scope rewrite, xds.css->astryx.css, ' + - 'theme-default/theme-daily->theme-neutral) all become their Astryx forms.', + 'theme-daily->theme-neutral) all become their Astryx forms.', pr: '#3092', fileExtensions: ['.css', '.scss'], }; @@ -60,15 +60,15 @@ function rewriteLayerPrelude(/** @type {any} */ prelude) { // from an @xds/* path to its @astryxdesign/* equivalent. Handles the two // non-mechanical cases beyond the scope swap: // @xds/core/xds.css -> @astryxdesign/core/astryx.css (file rename) -// @xds/theme-default/* -> @astryxdesign/theme-neutral/* (collapse) // @xds/theme-daily/* -> @astryxdesign/theme-neutral/* (collapse) // Returns the original value unchanged if it is not an @xds/* specifier. function rewriteImportSpecifier(/** @type {any} */ spec) { if (!spec.startsWith('@xds/')) return spec; - // Theme package collapse (default/daily -> neutral). - let next = spec - .replace(/^@xds\/theme-default(\/|$)/, '@astryxdesign/theme-neutral$1') - .replace(/^@xds\/theme-daily(\/|$)/, '@astryxdesign/theme-neutral$1'); + // Theme package collapse (daily -> neutral). + let next = spec.replace( + /^@xds\/theme-daily(\/|$)/, + '@astryxdesign/theme-neutral$1', + ); if (next === spec) { // Not a collapsed theme — plain scope swap. next = spec.replace(/^@xds\//, '@astryxdesign/'); diff --git a/packages/cli/assets/codemods/transforms/v0.1.0/migrate-xds-declare-module.mjs b/packages/cli/assets/codemods/transforms/v0.1.0/migrate-xds-declare-module.mjs index af7cd5152a93..102446bedfb5 100644 --- a/packages/cli/assets/codemods/transforms/v0.1.0/migrate-xds-declare-module.mjs +++ b/packages/cli/assets/codemods/transforms/v0.1.0/migrate-xds-declare-module.mjs @@ -40,7 +40,6 @@ const PACKAGE_RENAMES = new Map([ ['@xds/theme-butter', '@astryxdesign/theme-butter'], ['@xds/theme-chocolate', '@astryxdesign/theme-chocolate'], ['@xds/theme-daily', '@astryxdesign/theme-neutral'], - ['@xds/theme-default', '@astryxdesign/theme-neutral'], ['@xds/theme-gothic', '@astryxdesign/theme-gothic'], ['@xds/theme-matcha', '@astryxdesign/theme-matcha'], ['@xds/theme-neutral', '@astryxdesign/theme-neutral'], diff --git a/packages/cli/assets/codemods/transforms/v0.1.0/migrate-xds-module-specifiers.mjs b/packages/cli/assets/codemods/transforms/v0.1.0/migrate-xds-module-specifiers.mjs index b33b45d2ac30..3c7dc6652d2b 100644 --- a/packages/cli/assets/codemods/transforms/v0.1.0/migrate-xds-module-specifiers.mjs +++ b/packages/cli/assets/codemods/transforms/v0.1.0/migrate-xds-module-specifiers.mjs @@ -27,7 +27,6 @@ const PACKAGE_RENAMES = new Map([ ['@xds/theme-butter', '@astryxdesign/theme-butter'], ['@xds/theme-chocolate', '@astryxdesign/theme-chocolate'], ['@xds/theme-daily', '@astryxdesign/theme-neutral'], - ['@xds/theme-default', '@astryxdesign/theme-neutral'], ['@xds/theme-gothic', '@astryxdesign/theme-gothic'], ['@xds/theme-matcha', '@astryxdesign/theme-matcha'], ['@xds/theme-neutral', '@astryxdesign/theme-neutral'], @@ -52,19 +51,16 @@ function rewriteLiteral(/** @type {any} */ node) { return true; } -// @xds/theme-default and @xds/theme-daily both collapse to -// @astryxdesign/theme-neutral, whose exported theme binding is `neutralTheme` -// (not `defaultTheme`). When we rewrite an import from one of those packages, -// remap a `defaultTheme` named import to `neutralTheme`, aliasing back to the -// original local name so downstream usages keep working unchanged: -// import {defaultTheme} from '@xds/theme-default' +// @xds/theme-daily collapses to @astryxdesign/theme-neutral, whose exported +// theme binding is `neutralTheme` (not `defaultTheme`). When we rewrite an +// import from that package, remap a `defaultTheme` named import to +// `neutralTheme`, aliasing back to the original local name so downstream usages +// keep working unchanged: +// import {defaultTheme} from '@xds/theme-daily' // -> import {neutralTheme as defaultTheme} from '@astryxdesign/theme-neutral' // An already-aliased `{defaultTheme as x}` just has its imported name remapped. const THEME_EXPORT_RENAMES = new Map([['defaultTheme', 'neutralTheme']]); -const COLLAPSED_THEME_SOURCES = new Set([ - '@xds/theme-default', - '@xds/theme-daily', -]); +const COLLAPSED_THEME_SOURCES = new Set(['@xds/theme-daily']); function isCollapsedThemeSource(/** @type {any} */ value) { if (typeof value !== 'string') return false; @@ -128,7 +124,7 @@ export default function transformer(file, api) { root.find(j.ImportDeclaration).forEach((/** @type {any} */ path) => { // Remap collapsed-theme export names BEFORE rewriting the source specifier - // (the check keys off the original @xds/theme-default|daily path). + // (the check keys off the original @xds/theme-daily path). if (isCollapsedThemeSource(path.node.source.value)) { hasChanges = remapThemeExportNames(path, j) || hasChanges; }