Skip to content

feat(cli): v0.1.3 codemod migrating layout.components to experimental.xle.components#3290

Open
ejhammond wants to merge 1 commit into
xds-unprefix-integrationfrom
astryx/migrate-layout-components-codemod
Open

feat(cli): v0.1.3 codemod migrating layout.components to experimental.xle.components#3290
ejhammond wants to merge 1 commit into
xds-unprefix-integrationfrom
astryx/migrate-layout-components-codemod

Conversation

@ejhammond

Copy link
Copy Markdown
Contributor

Summary

The published 0.1.2 CLI read XLE app-component registration from astryx.config.* under layout.components. The integration branch relocated this to experimental.xle.components, validated by a strict schema that rejects unknown keys — so any consumer that still has layout.components in their config will hard-error on upgrade.

This PR adds a v0.1.3 config codemod (migrate-layout-components-to-experimental) that performs the relocation automatically.

Semantics are identical (this is a straight move + normalization)

The old and new entry shapes mean the same thing; nothing about import semantics changes:

  • string 'X'{ from: 'X' } — a named import where the key is both the local name and the export name.
  • object { from, description?, default? } → carried over unchanged (preserving from/description/default and key order). default: true = default import; otherwise named.

Behavior

The transform operates on the config's default export and handles both:

  • a bare object literal: export default { ... }
  • a createConfig({ ... }) wrapper: export default createConfig({ ... })

It builds experimental.xle.components from layout.components, places it (creating experimental / experimental.xle as needed), and removes the now-empty layout property.

It bails with a clear migrate-manually error (thrown, surfaced by runConfigCodemod's try/catch as a structured {file, codemod, error}) when:

  • the default export can't be statically analyzed (variable reference, non-literal, etc.)
  • experimental.xle already exists (can't safely merge)
  • layout has keys other than components (the only documented key)
  • an entry value is neither a string nor an object literal (identifier, call, …)

Returns null (no change) when there's no layout.components, including already-migrated configs (idempotence).

Wiring

  • New transform + manifest under packages/cli/src/codemods/transforms/v0.1.3/.
  • Registered 0.1.3 in the codemod registry (after 0.1.2).
  • Uses the unified config-codemod contract: meta.codemodType = 'config' and a (file, api) => string | null | undefined transform, routed through runConfigCodemod.

Testing

  • npx vitest run packages/cli1602 passed (98 files), including 20 new transform tests (string/object entries, multiple entries, both wrapper forms, placement into existing experimental, no-op/idempotence, and all bail cases) plus two end-to-end-ish tests driving the transform through runConfigCodemod.
  • node scripts/sync-exports.js --check → 0
  • ./scripts/add-copyright.sh --check → 0
  • pnpm -F @astryxdesign/cli typecheck:json-api → 0
  • pnpm build + node scripts/verify-exports.mjs → 0
  • npx eslint on changed files → 0
  • node scripts/check-changesets.mjs → 0
  • Smoke: astryx upgrade --list --json includes migrate-layout-components-to-experimental at version 0.1.3.

….xle.components

The published 0.1.2 CLI read XLE app-component registration from
astryx.config.* under layout.components. The next release relocates this
to experimental.xle.components, validated by a strict schema that rejects
unknown keys, so consumers with layout.components would hard-error on
upgrade. This adds a v0.1.3 config codemod that performs the straight
relocation.

Semantics are identical between the old and new shapes; this is purely a
move plus a string to object normalization:
- string 'X' becomes { from: 'X' } (named import, key = export name)
- object { from, description?, default? } is carried over unchanged

The transform recognizes the default export as either a bare object
literal or a createConfig({ ... }) wrapper, and bails with a clear
migrate-manually error when the config cannot be statically analyzed,
when experimental.xle already exists, when layout has keys other than
components, or when an entry is neither a string nor an object literal.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 30, 2026
@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jun 30, 2026 7:38pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant