@xstate/codemod 0.1.0-alpha.1 → 0.1.0-alpha.3

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
@@ -6,4 +6,4 @@ Run `xstate-codemod migrate [globs...] --dry` to review a v5-to-v6 migration. Om
6
6
  The transforms rename imports, wrap string targets, convert inline `types` declarations to schemas, and report APIs requiring manual migration. `--transform name,name` selects transforms.
7
7
 
8
8
  <!-- helper binding and output validation from src/util.ts, src/transforms/types-to-schemas.ts and src/runner.ts -->
9
- Schema helpers use value imports, preserve usable aliases, and avoid conflicting local names. Namespace and type-only imports are supported. Event payload separators and escaped event names retain their meaning. The runner checks transformed syntax before saving; generated code still needs your application's typecheck and tests, and reported manual migrations still need review.
9
+ The codemod supports named, namespace and type-only imports. It checks transformed syntax before saving. Run your application's typecheck and tests after migration, and review any reported manual migration steps.
@@ -7,7 +7,12 @@ const RENAMES = {
7
7
  Interpreter: 'Actor',
8
8
  fromCallback: 'createCallbackLogic',
9
9
  fromObservable: 'createObservableLogic',
10
- fromEventObservable: 'createEventObservableLogic'
10
+ fromEventObservable: 'createEventObservableLogic',
11
+ ExecutableActionObject: 'ExecutableEffect',
12
+ ExecutableActionsFrom: 'ExecutableEffectFrom',
13
+ ExecutableSpawnAction: 'SpawnExecutableEffect',
14
+ SpecialExecutableAction: 'SpecialExecutableEffect',
15
+ ToExecutableAction: 'ToExecutableEffect'
11
16
  };
12
17
 
13
18
  /**
@@ -17,7 +22,7 @@ const RENAMES = {
17
22
  */
18
23
  const renameImports = {
19
24
  name: 'rename-imports',
20
- description: "Rename renamed 'xstate' imports (interpret→createActor, Interpreter→Actor, fromCallback/fromObservable/fromEventObservable→create*Logic) and their usages.",
25
+ description: "Rename renamed 'xstate' imports (interpret→createActor, Interpreter→Actor, fromCallback/fromObservable/fromEventObservable→create*Logic, executable action types→executable effect types) and their usages.",
21
26
  apply(sourceFile) {
22
27
  const notes = [];
23
28
  let changed = false;
@@ -446,9 +451,12 @@ const REMOVED_APIS = {
446
451
  and: 'inline the guard as `(...) => a(...) && b(...)`',
447
452
  or: 'inline the guard as `(...) => a(...) || b(...)`',
448
453
  not: 'inline the guard as `(...) => !a(...)`',
449
- stateIn: 'use `self.getSnapshot().matches(...)` or `checkStateIn(snapshot, "#id")`',
454
+ stateIn: 'use `self.getSnapshot().matches(...)`',
450
455
  fromPromise: 'use `createAsyncLogic(...)`',
451
- fromTransition: 'use `createLogic({ context, run })`'
456
+ fromTransition: 'use `createStepLogic({ context, run })`',
457
+ toObserver: 'pass an observer object or callback directly',
458
+ pathToStateValue: 'build the state value object directly',
459
+ SpecialTargets: 'use `enq.sendTo(self, event)` for internal sends; parent sends use `enq.sendTo(...)` with the parent ref'
452
460
  };
453
461
 
454
462
  /**
@@ -458,7 +466,7 @@ const REMOVED_APIS = {
458
466
  */
459
467
  const reportRemovedApis = {
460
468
  name: 'report-removed-apis',
461
- description: 'Detect (report only) usages of removed/restructured v5 xstate APIs (assign, raise, sendTo, emit, fromPromise, and/or/not, etc.) that need manual migration.',
469
+ description: 'Detect (report only) usages of removed/restructured v5 xstate APIs (assign, raise, sendTo, emit, fromPromise, and/or/not, toObserver, SpecialTargets, etc.) that need manual migration.',
462
470
  apply(sourceFile) {
463
471
  const notes = [];
464
472
  const xstateImports = sourceFile.getImportDeclarations().filter(imp => imp.getModuleSpecifierValue() === 'xstate');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xstate/codemod",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.3",
4
4
  "description": "Codemods for migrating XState source between versions (v5 → v6)",
5
5
  "keywords": [
6
6
  "xstate",