Skip to content

forcedotcom/sf-skills / plugins/builder/experience-lwc/skills/experience-lwc-legacy-migrate

experience-lwc-legacy-migrate

Verified

Migrate legacy Salesforce UI stacks onto modern LWC — Aura → LWC conversion completeness verification and Lightning Out Beta → Lightning Out 2.0 host-page migration. TRIGGER on "verify Aura to LWC migration completeness", "migrate Lightning Out Beta to LO 2.0", "upgrade $Lightning.use() to <lightning-out-application>", "replace hardcoded LO tokens with OAuth PKCE", "write an LO 2.0 host page", or an external Lightning Out page that stopped rendering; also `.cmp`/`.js-meta.xml` files alongside LWC. DO NOT TRIGGER for the initial Aura-to-LWC conversion (use experience-aura-lwc-migrate), a React-to-LWC migration, or building a new LWC (use experience-lwc-design-generate).

scripts/convert-lo-names.py

View on GitHub
#!/usr/bin/env python3
"""Deterministic Lightning Out Beta -> LO 2.0 name/URL transforms.

The Beta -> LO 2.0 migration includes a few *purely mechanical* string
conversions that must be applied identically every time (Workflow B, Step B3):

  * Aura component id ``c:myComponent`` -> LWC custom-element tag ``c-my-component``
  * camelCase attribute names -> kebab-case HTML attribute names
  * the org My Domain -> the versioned LO 2.0 library ``<script>`` URL

This script performs those conversions so the workflow never has to hand-derive
them. It does NOT make any judgement calls (target DOM location, whether an LO
2.0 App id is needed, placeholder values) -- those stay in the skill body.

Usage:
  python3 scripts/convert-lo-names.py \
      --component c:myComponent \
      --attributes recordId,ownerId,showRevenue \
      --my-domain https://acme.my.salesforce.com

Any of the flags may be omitted; only the requested conversions are printed.
Exit code is 0 on success, 2 on a malformed argument.
"""
import argparse
import re
import sys

LO2_LIBRARY_PATH = "/lightning/lightning.out.latest/index.iife.prod.js"


def camel_to_kebab(name: str) -> str:
    """myComponent / MyComponent / my_component -> my-component."""
    name = name.strip().replace("_", "-")
    # split camelCase / PascalCase boundaries
    name = re.sub(r"([a-z0-9])([A-Z])", r"\1-\2", name)
    name = re.sub(r"([A-Z]+)([A-Z][a-z])", r"\1-\2", name)
    return name.lower()


def component_tag(aura_id: str) -> str:
    """c:myComponent -> c-my-component (namespace preserved)."""
    aura_id = aura_id.strip()
    if ":" in aura_id:
        ns, name = aura_id.split(":", 1)
    else:
        ns, name = "c", aura_id
    return f"{ns.strip().lower()}-{camel_to_kebab(name)}"


def library_url(my_domain: str) -> str:
    """Normalize a My Domain to the versioned LO 2.0 library URL."""
    d = my_domain.strip().rstrip("/")
    if not d.startswith("http"):
        d = "https://" + d
    # Beta hosts on *.lightning.force.com; LO 2.0 must load from *.my.salesforce.com
    d = d.replace(".lightning.force.com", ".my.salesforce.com")
    # strip any path the caller pasted, keep scheme://host
    m = re.match(r"(https?://[^/]+)", d)
    host = m.group(1) if m else d
    return f"{host}{LO2_LIBRARY_PATH}"


def main(argv=None) -> int:
    p = argparse.ArgumentParser(description=__doc__,
                                formatter_class=argparse.RawDescriptionHelpFormatter)
    p.add_argument("--component", help="Beta component id, e.g. c:myComponent")
    p.add_argument("--attributes",
                   help="comma/space separated camelCase attribute names")
    p.add_argument("--my-domain",
                   help="org My Domain or Beta host URL")
    args = p.parse_args(argv)

    if not (args.component or args.attributes or args.my_domain):
        p.print_help()
        return 2

    if args.component:
        print(f"component-tag: <{component_tag(args.component)}>")

    if args.attributes:
        raw = [a for a in re.split(r"[,\s]+", args.attributes) if a]
        pairs = [(a, camel_to_kebab(a)) for a in raw]
        print("attributes:")
        for src, dst in pairs:
            print(f"  {src} -> {dst}")

    if args.my_domain:
        print(f"library-url: {library_url(args.my_domain)}  (add the `async` attribute)")

    return 0


if __name__ == "__main__":
    sys.exit(main())
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall