Strata · API

planSourceUpgrade

planSourceUpgrade, from @niscorp/strata/upgrade, computes the upgraded form of each artifact written in an app’s source. For each artifact that a migration changes it returns the expected JSON, the migrations applied and a positional diff; the others are listed in untouched. It does not rewrite any source file.

Lock (source stamp)
{ nisc.nova: 2, nisc.prism: 3, theatre.kit: 0 }
Source artifacts
[
  {
    id: 'ticket',
    file: 'src/app/ticket.layout.ts',
    document: {
      component: 'Card',
      children: [
        { component: 'Text', children: 'The Tempest' },
        {
          component: 'Button',
          props: { label: 'Show my ticket', tone: 'primary' },
        },
      ],
    },
  },
  {
    id: 'programme',
    file: 'src/app/programme.layout.ts',
    document: { component: 'Text', children: 'This week' },
  },
]
Plan
{
  documents: [
    {
      id: 'ticket',
      file: 'src/app/ticket.layout.ts',
      applied: ['theatre.kit/1', 'theatre.kit/2', 'theatre.kit/3'],
      changes: [
        '- children[1].props.label',
        '+ children[1].props.text',
        '- children[1].props.tone',
        '+ children[1].props.variant',
        '~ component: "Card" → "Tile"',
      ],
      expected: {
        component: 'Tile',
        children: [
          { component: 'Text', children: 'The Tempest' },
          {
            component: 'Button',
            props: { text: 'Show my ticket', variant: 'filled' },
          },
        ],
      },
    },
  ],
  untouched: ['nisc.nova/layout:programme'],
  problems: [],
}
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.