@cratis/components.migrator 4.14.0 → 4.14.2

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 CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  The Components 4 Migrator updates a Components 3 codebase to the Components 4 public contracts. It moves root namespaces to explicit subpath imports, replaces deprecated Button appearance props, and changes legacy event-wrapper callbacks to semantic value callbacks. The CLI uses syntax-aware codemods internally, but each command is named for the migration it performs, can be run independently, and is idempotent. Components 4 keeps only package-wide provider setup at the root; every component is imported from its explicit subpath (`@cratis/components/Canvas`, for example). The companion `@cratis/eslint-plugin-components` package's `no-root-barrel-import` rule enforces this once a consumer has migrated.
4
4
 
5
- > **Publication status:** The install examples target the owner-authorized 4.0.0 npm release. When
6
- > reading this README from repository source before that release, verify availability with
7
- > `npm view @cratis/components.migrator@4.0.0 version`; source contributors run the workspace
8
- > commands from this checkout instead. The Migrator is never an application runtime dependency.
5
+ The package is published on npm and released at the same version as `@cratis/components`
6
+ (4.0.0 onward). Run it with `npx`, `pnpm dlx`, or `yarn dlx` as shown below; it is never an
7
+ application runtime dependency. Contributors to this repository can run the workspace scripts
8
+ directly instead.
9
9
 
10
10
  The published package is a **CLI-only** tool. Its public surface is the documented `cratis-components-*` executable names (plus `./package.json` for tooling metadata); `lib/`, `scripts/`, and individual transforms are implementation details and are blocked by the package export map. Do not import them from application code or build custom migration APIs on them.
11
11
 
@@ -181,21 +181,16 @@ The transform never guesses through JSX spreads, dynamic legacy values, duplicat
181
181
 
182
182
  ## `change-handler`
183
183
 
184
- `cratis-components-change-handler` resolves affected Components-owned JSX identifiers imported with aliases or namespaces from `@cratis/components/Dropdown`, `@cratis/components/CommandForm`, and `@cratis/components/CommandForm/fields`. It rewrites only a structurally-proven single forwarding callback:
184
+ `cratis-components-change-handler` resolves Components-owned JSX identifiers imported with aliases or namespaces from `@cratis/components/Dropdown`, `@cratis/components/CommandForm`, and `@cratis/components/CommandForm/fields`. It rewrites structurally-proven single forwarding callbacks on standalone `Dropdown` and CommandForm field `onValueChange` props:
185
185
 
186
186
  ```tsx
187
- // Safe rewrites
187
+ // Before
188
188
  <Dropdown onChange={(event) => setRole(event.value)} />
189
- <InputTextField onChange={(event) => setName(event.target.value)} />
190
- <CheckboxField onChange={({ target: { checked } }) => setEnabled(checked)} />
191
-
192
- // become
189
+ // After
193
190
  <Dropdown onChange={(value) => setRole(value)} />
194
- <InputTextField onChange={(value) => setName(value)} />
195
- <CheckboxField onChange={(value) => setEnabled(value)} />
196
191
  ```
197
192
 
198
- The affected CommandForm fields cover legacy `target`/`currentTarget` `value`, `checked`, and `valueAsNumber` payloads, plus `DropdownField`/`MultiSelectField` `event.value`. Already-semantic callbacks and callback references such as `onChange={setValue}` are unchanged.
193
+ For Components 4 CommandForm fields, the codemod leaves `onChange` unchanged and reports an actionable diagnostic instead of changing its callback. Arc's `asCommandFormField` wrappers do not expose `onChange` as a field prop in Components 4, so keeping the attribute would produce TS2322 even if the callback were rewritten. Move its side effects to the enclosing `CommandForm`'s `onFieldChange(command, fieldName, oldValue, newValue, validationInfo?)` callback. Legacy `onValueChange` field callbacks with a proven event payload are rewritten to semantic values; already-semantic `onValueChange` callbacks are untouched. The [Components 3 to 4 migration guide](https://cratis.io/components/migration/3-to-4/) covers this case.
199
194
 
200
195
  Multi-statement, multi-use, wrong-payload, destructuring-with-default/rest, and native-event-dependent callbacks are refused, reported, and annotated once:
201
196
 
@@ -254,7 +249,9 @@ node Migrator/scripts/change-handler.js --check Source
254
249
  cd Migrator && yarn test
255
250
  ```
256
251
 
257
- Repository fixtures for every supported and unsupported case live under
252
+ Repository fixtures for every supported and unsupported root-import case live under
258
253
  `Migrator/test/fixtures`,
259
254
  each as an `input.ts`/`expected.ts` pair (`input.ts` and `expected.ts` are identical for an
260
- unsupported case, since nothing should change).
255
+ unsupported case, since nothing should change). The Button and change-handler transforms use
256
+ `input.tsx`/`expected.tsx` pairs under `Migrator/test/button-fixtures` and
257
+ `Migrator/test/change-handler-fixtures`.
@@ -96,6 +96,14 @@ export function transformChangeHandlers(fileName, text, options = {}) {
96
96
  if (!ts.isJsxAttribute(attribute)) continue;
97
97
  const propName = attribute.name.getText(sourceFile);
98
98
  if (propName !== 'onChange' && propName !== 'onValueChange') continue;
99
+ if (target.group === 'CommandForm' && propName === 'onChange') {
100
+ report(
101
+ attribute,
102
+ target.component,
103
+ "Components 4 field props do not accept onChange; move the handler to the enclosing CommandForm's onFieldChange(command, fieldName, oldValue, newValue, validationInfo?)",
104
+ );
105
+ continue;
106
+ }
99
107
  if (
100
108
  !attribute.initializer ||
101
109
  !ts.isJsxExpression(attribute.initializer) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/components.migrator",
3
- "version": "4.14.0",
3
+ "version": "4.14.2",
4
4
  "description": "Migration tooling for updating @cratis/components consumers from Components 3 to Components 4.",
5
5
  "author": "Cratis",
6
6
  "license": "MIT",