@openrewrite/recipes-react 0.17.0 → 0.18.0
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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-config-blockers.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-config-blockers.js +3 -5
- package/dist/migration/cra-to-vite/find-cra-config-blockers.js.map +1 -1
- package/dist/migration/cra-to-vite/update-react-app-env-types.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/update-react-app-env-types.js +5 -2
- package/dist/migration/cra-to-vite/update-react-app-env-types.js.map +1 -1
- package/dist/react18/replace-unmount-component-at-node.d.ts.map +1 -1
- package/dist/react18/replace-unmount-component-at-node.js +8 -1
- package/dist/react18/replace-unmount-component-at-node.js.map +1 -1
- package/dist/react19/find-legacy-context-api.d.ts.map +1 -1
- package/dist/react19/find-legacy-context-api.js +21 -38
- package/dist/react19/find-legacy-context-api.js.map +1 -1
- package/dist/{react18 → react19}/remove-unstable-batched-updates.d.ts +2 -2
- package/dist/react19/remove-unstable-batched-updates.d.ts.map +1 -0
- package/dist/react19/remove-unstable-batched-updates.js +295 -0
- package/dist/react19/remove-unstable-batched-updates.js.map +1 -0
- package/dist/react19/replace-default-props.d.ts +1 -0
- package/dist/react19/replace-default-props.d.ts.map +1 -1
- package/dist/react19/replace-default-props.js +198 -151
- package/dist/react19/replace-default-props.js.map +1 -1
- package/dist/react19/replace-react-shallow-renderer.d.ts.map +1 -1
- package/dist/react19/replace-react-shallow-renderer.js +10 -25
- package/dist/react19/replace-react-shallow-renderer.js.map +1 -1
- package/dist/refactoring/class-to-functional.d.ts.map +1 -1
- package/dist/refactoring/class-to-functional.js +2 -0
- package/dist/refactoring/class-to-functional.js.map +1 -1
- package/dist/refactoring/create-class-to-es6.d.ts.map +1 -1
- package/dist/refactoring/create-class-to-es6.js +14 -49
- package/dist/refactoring/create-class-to-es6.js.map +1 -1
- package/dist/search/find-function-component-default-props.d.ts.map +1 -1
- package/dist/search/find-function-component-default-props.js +6 -15
- package/dist/search/find-function-component-default-props.js.map +1 -1
- package/dist/search/find-redux-stores.d.ts +12 -0
- package/dist/search/find-redux-stores.d.ts.map +1 -0
- package/dist/search/find-redux-stores.js +87 -0
- package/dist/search/find-redux-stores.js.map +1 -0
- package/dist/simplify-object-pattern-property.d.ts.map +1 -1
- package/dist/simplify-object-pattern-property.js +14 -21
- package/dist/simplify-object-pattern-property.js.map +1 -1
- package/dist/simplify-react-imports.d.ts.map +1 -1
- package/dist/simplify-react-imports.js +10 -59
- package/dist/simplify-react-imports.js.map +1 -1
- package/dist/testing/enzyme-to-react-testing-library.d.ts +10 -1
- package/dist/testing/enzyme-to-react-testing-library.d.ts.map +1 -1
- package/dist/testing/enzyme-to-react-testing-library.js +79 -22
- package/dist/testing/enzyme-to-react-testing-library.js.map +1 -1
- package/dist/testing/enzyme-wrapper-scope.d.ts +3 -1
- package/dist/testing/enzyme-wrapper-scope.d.ts.map +1 -1
- package/dist/testing/enzyme-wrapper-scope.js +10 -7
- package/dist/testing/enzyme-wrapper-scope.js.map +1 -1
- package/dist/util/java-recipe-proxy.d.ts +2 -0
- package/dist/util/java-recipe-proxy.d.ts.map +1 -1
- package/dist/util/java-recipe-proxy.js +14 -2
- package/dist/util/java-recipe-proxy.js.map +1 -1
- package/dist/util/reindent.d.ts +5 -0
- package/dist/util/reindent.d.ts.map +1 -0
- package/dist/util/reindent.js +44 -0
- package/dist/util/reindent.js.map +1 -0
- package/dist/zustand/redux-stores.d.ts +74 -0
- package/dist/zustand/redux-stores.d.ts.map +1 -0
- package/dist/zustand/redux-stores.js +402 -0
- package/dist/zustand/redux-stores.js.map +1 -0
- package/dist/zustand/redux-to-zustand.d.ts +76 -0
- package/dist/zustand/redux-to-zustand.d.ts.map +1 -0
- package/dist/zustand/redux-to-zustand.js +653 -0
- package/dist/zustand/redux-to-zustand.js.map +1 -0
- package/dist/zustand/zustand-plan.d.ts +96 -0
- package/dist/zustand/zustand-plan.d.ts.map +1 -0
- package/dist/zustand/zustand-plan.js +822 -0
- package/dist/zustand/zustand-plan.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +7 -3
- package/src/migration/cra-to-vite/find-cra-config-blockers.ts +3 -5
- package/src/migration/cra-to-vite/update-react-app-env-types.ts +3 -3
- package/src/react18/replace-unmount-component-at-node.ts +13 -2
- package/src/react19/find-legacy-context-api.ts +21 -42
- package/src/react19/remove-unstable-batched-updates.ts +301 -0
- package/src/react19/replace-default-props.ts +212 -159
- package/src/react19/replace-react-shallow-renderer.ts +13 -36
- package/src/refactoring/class-to-functional.ts +3 -1
- package/src/refactoring/create-class-to-es6.ts +12 -63
- package/src/search/find-function-component-default-props.ts +8 -10
- package/src/search/find-redux-stores.ts +76 -0
- package/src/simplify-object-pattern-property.ts +22 -49
- package/src/simplify-react-imports.ts +12 -66
- package/src/testing/enzyme-to-react-testing-library.ts +112 -27
- package/src/testing/enzyme-wrapper-scope.ts +15 -10
- package/src/util/java-recipe-proxy.ts +15 -2
- package/src/util/reindent.ts +35 -0
- package/src/zustand/redux-stores.ts +409 -0
- package/src/zustand/redux-to-zustand.ts +657 -0
- package/src/zustand/zustand-plan.ts +843 -0
- package/dist/react18/remove-unstable-batched-updates.d.ts.map +0 -1
- package/dist/react18/remove-unstable-batched-updates.js +0 -170
- package/dist/react18/remove-unstable-batched-updates.js.map +0 -1
- package/src/react18/remove-unstable-batched-updates.ts +0 -192
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TEST_SOURCE = exports.SUGGESTED_ACTIONS = exports.ReduxStoreRow = exports.REDUX_STORES_TABLE = exports.ZUSTAND_GUIDE = exports.RTK = exports.REDUX = void 0;
|
|
10
|
+
exports.importedAs = importedAs;
|
|
11
|
+
exports.objectProperties = objectProperties;
|
|
12
|
+
exports.caseReducers = caseReducers;
|
|
13
|
+
exports.localSlices = localSlices;
|
|
14
|
+
exports.resolveSliceReducer = resolveSliceReducer;
|
|
15
|
+
exports.storeFunctions = storeFunctions;
|
|
16
|
+
exports.storeFindings = storeFindings;
|
|
17
|
+
exports.storeName = storeName;
|
|
18
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
19
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
20
|
+
const java_1 = require("@openrewrite/rewrite/java");
|
|
21
|
+
const module_imports_1 = require("../util/module-imports");
|
|
22
|
+
exports.REDUX = "redux";
|
|
23
|
+
exports.RTK = "@reduxjs/toolkit";
|
|
24
|
+
exports.ZUSTAND_GUIDE = "https://zustand.docs.pmnd.rs/guides/migrating-to-zustand";
|
|
25
|
+
exports.REDUX_STORES_TABLE = "org.openrewrite.react.table.ReduxStores";
|
|
26
|
+
class ReduxStoreRow {
|
|
27
|
+
}
|
|
28
|
+
exports.ReduxStoreRow = ReduxStoreRow;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, rewrite_1.Column)({ displayName: "Source path", description: "The file that creates the Redux store." })
|
|
31
|
+
], ReduxStoreRow.prototype, "sourcePath", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, rewrite_1.Column)({ displayName: "Store", description: "The variable or function the store is created in, or <module> when it has no name." })
|
|
34
|
+
], ReduxStoreRow.prototype, "store", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, rewrite_1.Column)({ displayName: "API", description: "The Redux function that creates the store: `createStore`, `legacy_createStore` or `configureStore`." })
|
|
37
|
+
], ReduxStoreRow.prototype, "api", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, rewrite_1.Column)({ displayName: "Status", description: "CANDIDATE for a store whose setup a conversion to zustand can keep, or REVIEW for one it can't, with one row per reason." })
|
|
40
|
+
], ReduxStoreRow.prototype, "status", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, rewrite_1.Column)({ displayName: "Reason", description: "A stable reason code: SLICE_STORE for a candidate, or the part of the setup that keeps the store from converting." })
|
|
43
|
+
], ReduxStoreRow.prototype, "reason", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, rewrite_1.Column)({ displayName: "Detail", description: "The option, reducer key or slice the reason is about, when there is one." })
|
|
46
|
+
], ReduxStoreRow.prototype, "detail", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, rewrite_1.Column)({ displayName: "Test source", description: "Whether the file looks like a test, mock or story." })
|
|
49
|
+
], ReduxStoreRow.prototype, "testSource", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, rewrite_1.Column)({ displayName: "Suggested action", description: "What to do before the store can move to zustand." })
|
|
52
|
+
], ReduxStoreRow.prototype, "suggestedAction", void 0);
|
|
53
|
+
function importedAs(cu, module, ...names) {
|
|
54
|
+
return new Set((0, module_imports_1.importBindings)(cu).filter(binding => binding.module === module && names.includes(binding.name)).map(binding => binding.local));
|
|
55
|
+
}
|
|
56
|
+
function objectProperties(node) {
|
|
57
|
+
var _a;
|
|
58
|
+
if ((node === null || node === void 0 ? void 0 : node.kind) !== java_1.J.Kind.NewClass)
|
|
59
|
+
return undefined;
|
|
60
|
+
const literal = node;
|
|
61
|
+
if (literal.class || !literal.body)
|
|
62
|
+
return undefined;
|
|
63
|
+
const properties = new Map();
|
|
64
|
+
for (const { element } of literal.body.statements) {
|
|
65
|
+
if (element.kind !== javascript_1.JS.Kind.PropertyAssignment)
|
|
66
|
+
return undefined;
|
|
67
|
+
const property = element;
|
|
68
|
+
const name = property.name.element;
|
|
69
|
+
const key = (0, java_1.isIdentifier)(name) ? name.simpleName :
|
|
70
|
+
name.kind === java_1.J.Kind.Literal && typeof name.value === "string" ? name.value : undefined;
|
|
71
|
+
if (key === undefined)
|
|
72
|
+
return undefined;
|
|
73
|
+
properties.set(key, (_a = property.initializer) !== null && _a !== void 0 ? _a : name);
|
|
74
|
+
}
|
|
75
|
+
return properties;
|
|
76
|
+
}
|
|
77
|
+
function sliceFacts(node, createSlice, cu, variable) {
|
|
78
|
+
var _a;
|
|
79
|
+
const path = cu.sourcePath;
|
|
80
|
+
if ((node === null || node === void 0 ? void 0 : node.kind) !== java_1.J.Kind.MethodInvocation)
|
|
81
|
+
return undefined;
|
|
82
|
+
const call = node;
|
|
83
|
+
if (call.select || !createSlice.has(call.name.simpleName))
|
|
84
|
+
return undefined;
|
|
85
|
+
const options = objectProperties((_a = call.arguments.elements[0]) === null || _a === void 0 ? void 0 : _a.element);
|
|
86
|
+
const nameValue = options === null || options === void 0 ? void 0 : options.get("name");
|
|
87
|
+
const name = (nameValue === null || nameValue === void 0 ? void 0 : nameValue.kind) === java_1.J.Kind.Literal ? String(nameValue.value) : "<unnamed>";
|
|
88
|
+
if (!options)
|
|
89
|
+
return { name, path, variable, blocker: { reason: "SLICE_OPTIONS_NOT_LITERAL", detail: name } };
|
|
90
|
+
const extra = options.has("extraReducers") ? thunkCases(options.get("extraReducers"), cu) : undefined;
|
|
91
|
+
if (typeof extra === "string")
|
|
92
|
+
return { name, path, variable, blocker: { reason: "EXTRA_REDUCERS", detail: `${name}: ${extra}` } };
|
|
93
|
+
const reducers = options.get("reducers");
|
|
94
|
+
const literal = (reducers === null || reducers === void 0 ? void 0 : reducers.kind) === java_1.J.Kind.NewClass && !reducers.class ? reducers.body : undefined;
|
|
95
|
+
if (reducers && !(literal === null || literal === void 0 ? void 0 : literal.statements.every(({ element }) => element.kind === javascript_1.JS.Kind.PropertyAssignment || element.kind === java_1.J.Kind.MethodDeclaration))) {
|
|
96
|
+
return { name, path, variable, blocker: { reason: "SLICE_REDUCERS_NOT_LITERAL", detail: name } };
|
|
97
|
+
}
|
|
98
|
+
return Object.assign({ name, path, variable }, extra && { thunks: extra.thunks, cases: extra.cases.map(({ thunk, stage }) => ({ thunk, stage })) });
|
|
99
|
+
}
|
|
100
|
+
function caseReducers(cu, variable) {
|
|
101
|
+
var _a, _b, _c, _d;
|
|
102
|
+
for (const { element } of cu.statements) {
|
|
103
|
+
if (element.kind !== java_1.J.Kind.VariableDeclarations)
|
|
104
|
+
continue;
|
|
105
|
+
const found = (_a = element.variables.find(v => (0, java_1.isIdentifier)(v.element.name) && v.element.name.simpleName === variable)) === null || _a === void 0 ? void 0 : _a.element;
|
|
106
|
+
const call = (_b = found === null || found === void 0 ? void 0 : found.initializer) === null || _b === void 0 ? void 0 : _b.element;
|
|
107
|
+
if ((call === null || call === void 0 ? void 0 : call.kind) !== java_1.J.Kind.MethodInvocation)
|
|
108
|
+
continue;
|
|
109
|
+
const extra = (_d = objectProperties((_c = call.arguments.elements[0]) === null || _c === void 0 ? void 0 : _c.element)) === null || _d === void 0 ? void 0 : _d.get("extraReducers");
|
|
110
|
+
const cases = extra ? thunkCases(extra, cu) : undefined;
|
|
111
|
+
return cases && typeof cases !== "string" ? cases.cases : [];
|
|
112
|
+
}
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
const THUNK_STAGES = new Set(["pending", "fulfilled", "rejected"]);
|
|
116
|
+
const THUNK_API = new Set(["rejectWithValue", "fulfillWithValue", "signal", "requestId"]);
|
|
117
|
+
function lambdaOf(node) {
|
|
118
|
+
if ((node === null || node === void 0 ? void 0 : node.kind) === javascript_1.JS.Kind.ArrowFunction)
|
|
119
|
+
return node.lambda;
|
|
120
|
+
return (node === null || node === void 0 ? void 0 : node.kind) === java_1.J.Kind.Lambda ? node : undefined;
|
|
121
|
+
}
|
|
122
|
+
function parametersOf(lambda) {
|
|
123
|
+
return lambda.parameters.parameters.map(p => p.element).filter(p => p.kind !== java_1.J.Kind.Empty);
|
|
124
|
+
}
|
|
125
|
+
function plainParameter(node) {
|
|
126
|
+
if ((0, java_1.isIdentifier)(node))
|
|
127
|
+
return node.simpleName;
|
|
128
|
+
if (node.kind !== java_1.J.Kind.VariableDeclarations)
|
|
129
|
+
return undefined;
|
|
130
|
+
const declarations = node;
|
|
131
|
+
const variable = declarations.variables.length === 1 ? declarations.variables[0].element : undefined;
|
|
132
|
+
return variable && !declarations.typeExpression && !declarations.varargs && !variable.initializer && (0, java_1.isIdentifier)(variable.name) ? variable.name.simpleName : undefined;
|
|
133
|
+
}
|
|
134
|
+
function thunkCases(value, cu) {
|
|
135
|
+
const lambda = lambdaOf(value);
|
|
136
|
+
const parameters = lambda ? parametersOf(lambda) : [];
|
|
137
|
+
const builder = parameters.length === 1 ? plainParameter(parameters[0]) : undefined;
|
|
138
|
+
if (!lambda || !builder)
|
|
139
|
+
return "`extraReducers` isn't a function of the builder";
|
|
140
|
+
const body = lambda.body;
|
|
141
|
+
const expressions = body.kind === java_1.J.Kind.Block ? body.statements.map(s => s.element) : [body];
|
|
142
|
+
const thunks = new Map();
|
|
143
|
+
const cases = [];
|
|
144
|
+
for (let expression of expressions) {
|
|
145
|
+
if (expression.kind === javascript_1.JS.Kind.ExpressionStatement)
|
|
146
|
+
expression = expression.expression;
|
|
147
|
+
const chain = [];
|
|
148
|
+
let node = expression;
|
|
149
|
+
while (node.kind === java_1.J.Kind.MethodInvocation) {
|
|
150
|
+
const call = node;
|
|
151
|
+
if (!call.select)
|
|
152
|
+
break;
|
|
153
|
+
if (call.name.simpleName !== "addCase")
|
|
154
|
+
return `\`builder.${call.name.simpleName}\``;
|
|
155
|
+
const args = call.arguments.elements.map(a => a.element).filter(a => a.kind !== java_1.J.Kind.Empty);
|
|
156
|
+
const matcher = args[0];
|
|
157
|
+
if (args.length !== 2 || (matcher === null || matcher === void 0 ? void 0 : matcher.kind) !== java_1.J.Kind.FieldAccess || !(0, java_1.isIdentifier)(matcher.target) ||
|
|
158
|
+
!THUNK_STAGES.has(matcher.name.element.simpleName))
|
|
159
|
+
return "a case for what isn't a stage of a thunk";
|
|
160
|
+
if (!lambdaOf(args[1]))
|
|
161
|
+
return "a case reducer that isn't a function written in place";
|
|
162
|
+
const thunk = matcher.target.simpleName;
|
|
163
|
+
chain.unshift({ thunk, stage: matcher.name.element.simpleName, reducer: args[1] });
|
|
164
|
+
node = call.select.element;
|
|
165
|
+
}
|
|
166
|
+
if (!(0, java_1.isIdentifier)(node) || node.simpleName !== builder || chain.length === 0)
|
|
167
|
+
return "`extraReducers` does more than `builder.addCase`";
|
|
168
|
+
cases.push(...chain);
|
|
169
|
+
}
|
|
170
|
+
const seen = new Set();
|
|
171
|
+
for (const { thunk, stage } of cases) {
|
|
172
|
+
if (seen.has(`${thunk}.${stage}`))
|
|
173
|
+
return `two cases for \`${thunk}.${stage}\``;
|
|
174
|
+
seen.add(`${thunk}.${stage}`);
|
|
175
|
+
if (thunks.has(thunk))
|
|
176
|
+
continue;
|
|
177
|
+
const found = asyncThunk(thunk, cu);
|
|
178
|
+
if (typeof found === "string")
|
|
179
|
+
return found;
|
|
180
|
+
thunks.set(thunk, found);
|
|
181
|
+
}
|
|
182
|
+
return { thunks, cases };
|
|
183
|
+
}
|
|
184
|
+
function asyncThunk(name, cu) {
|
|
185
|
+
var _a, _b;
|
|
186
|
+
const createAsyncThunk = importedAs(cu, exports.RTK, "createAsyncThunk");
|
|
187
|
+
for (const { element } of cu.statements) {
|
|
188
|
+
if (element.kind !== java_1.J.Kind.VariableDeclarations)
|
|
189
|
+
continue;
|
|
190
|
+
const declarations = element;
|
|
191
|
+
const variable = (_a = declarations.variables.find(v => (0, java_1.isIdentifier)(v.element.name) && v.element.name.simpleName === name)) === null || _a === void 0 ? void 0 : _a.element;
|
|
192
|
+
if (!variable)
|
|
193
|
+
continue;
|
|
194
|
+
const init = (_b = variable.initializer) === null || _b === void 0 ? void 0 : _b.element;
|
|
195
|
+
const call = (init === null || init === void 0 ? void 0 : init.kind) === java_1.J.Kind.MethodInvocation ? init : undefined;
|
|
196
|
+
if (declarations.variables.length !== 1 || !declarations.modifiers.some(m => m.keyword === "const") || !call || call.select ||
|
|
197
|
+
!createAsyncThunk.has(call.name.simpleName))
|
|
198
|
+
return `\`${name}\` isn't a \`createAsyncThunk\` of the slice's source`;
|
|
199
|
+
const args = call.arguments.elements.map(a => a.element).filter(a => a.kind !== java_1.J.Kind.Empty);
|
|
200
|
+
if (args.length !== 2)
|
|
201
|
+
return `\`${name}\` has options`;
|
|
202
|
+
if (args[0].kind !== java_1.J.Kind.Literal || typeof args[0].value !== "string")
|
|
203
|
+
return `\`${name}\`'s type isn't a string literal`;
|
|
204
|
+
const creator = lambdaOf(args[1]);
|
|
205
|
+
if (!creator)
|
|
206
|
+
return `\`${name}\`'s payload creator isn't an arrow function`;
|
|
207
|
+
const parameters = parametersOf(creator);
|
|
208
|
+
if (parameters.length > 2)
|
|
209
|
+
return `\`${name}\`'s payload creator takes more than \`arg\` and \`thunkAPI\``;
|
|
210
|
+
if (parameters.length === 2) {
|
|
211
|
+
const api = plainParameter(parameters[1]);
|
|
212
|
+
if (!api)
|
|
213
|
+
return `\`${name}\`'s \`thunkAPI\` isn't a plain parameter`;
|
|
214
|
+
let mentions = 0;
|
|
215
|
+
let kept = 0;
|
|
216
|
+
(0, javascript_1.walk)(creator.body, tree => {
|
|
217
|
+
var _a;
|
|
218
|
+
const node = tree;
|
|
219
|
+
if ((0, java_1.isIdentifier)(node) && node.simpleName === api)
|
|
220
|
+
mentions++;
|
|
221
|
+
const target = node.kind === java_1.J.Kind.FieldAccess ? node.target :
|
|
222
|
+
node.kind === java_1.J.Kind.MethodInvocation ? (_a = node.select) === null || _a === void 0 ? void 0 : _a.element : undefined;
|
|
223
|
+
const member = node.kind === java_1.J.Kind.FieldAccess ? node.name.element.simpleName :
|
|
224
|
+
node.kind === java_1.J.Kind.MethodInvocation ? node.name.simpleName : undefined;
|
|
225
|
+
if (target && (0, java_1.isIdentifier)(target) && target.simpleName === api && member && THUNK_API.has(member))
|
|
226
|
+
kept++;
|
|
227
|
+
return true;
|
|
228
|
+
});
|
|
229
|
+
if (mentions !== kept)
|
|
230
|
+
return `\`${name}\` uses \`${api}\` for more than ${[...THUNK_API].map(m => `\`${m}\``).join(", ")}`;
|
|
231
|
+
}
|
|
232
|
+
return { variable: name, typePrefix: args[0].value };
|
|
233
|
+
}
|
|
234
|
+
return `\`${name}\` isn't a \`createAsyncThunk\` of the slice's source`;
|
|
235
|
+
}
|
|
236
|
+
function reducerOf(node, slices) {
|
|
237
|
+
if ((node === null || node === void 0 ? void 0 : node.kind) !== java_1.J.Kind.FieldAccess)
|
|
238
|
+
return undefined;
|
|
239
|
+
const access = node;
|
|
240
|
+
return access.name.element.simpleName === "reducer" && (0, java_1.isIdentifier)(access.target) ? slices.get(access.target.simpleName) : undefined;
|
|
241
|
+
}
|
|
242
|
+
function exportKeywords(modifiers) {
|
|
243
|
+
const keywords = new Set(modifiers.map(modifier => modifier.keyword));
|
|
244
|
+
return { exported: keywords.has("export"), isDefault: keywords.has("default") };
|
|
245
|
+
}
|
|
246
|
+
function localSlices(cu) {
|
|
247
|
+
var _a, _b, _c, _d;
|
|
248
|
+
const createSlice = importedAs(cu, exports.RTK, "createSlice");
|
|
249
|
+
const result = { localSlices: new Map(), localReducers: new Map(), reducers: new Map(), slices: new Map() };
|
|
250
|
+
if (createSlice.size === 0)
|
|
251
|
+
return result;
|
|
252
|
+
const exportedNames = [];
|
|
253
|
+
for (const { element } of cu.statements) {
|
|
254
|
+
if (element.kind === java_1.J.Kind.VariableDeclarations) {
|
|
255
|
+
const declarations = element;
|
|
256
|
+
const { exported } = exportKeywords(declarations.modifiers);
|
|
257
|
+
for (const { element: variable } of declarations.variables) {
|
|
258
|
+
if (!(0, java_1.isIdentifier)(variable.name))
|
|
259
|
+
continue;
|
|
260
|
+
const name = variable.name.simpleName;
|
|
261
|
+
const init = (_a = variable.initializer) === null || _a === void 0 ? void 0 : _a.element;
|
|
262
|
+
const slice = sliceFacts(init, createSlice, cu, name);
|
|
263
|
+
if (slice)
|
|
264
|
+
result.localSlices.set(name, slice);
|
|
265
|
+
const reducer = reducerOf(init, result.localSlices);
|
|
266
|
+
if (reducer)
|
|
267
|
+
result.localReducers.set(name, reducer);
|
|
268
|
+
if (exported)
|
|
269
|
+
exportedNames.push([name, name]);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
else if (element.kind === javascript_1.JS.Kind.ExportAssignment) {
|
|
273
|
+
const expression = element.expression.element;
|
|
274
|
+
const reducer = (_b = reducerOf(expression, result.localSlices)) !== null && _b !== void 0 ? _b : ((0, java_1.isIdentifier)(expression) ? result.localReducers.get(expression.simpleName) : undefined);
|
|
275
|
+
if (reducer)
|
|
276
|
+
result.reducers.set("default", reducer);
|
|
277
|
+
const slice = (_c = sliceFacts(expression, createSlice, cu, "")) !== null && _c !== void 0 ? _c : ((0, java_1.isIdentifier)(expression) ? result.localSlices.get(expression.simpleName) : undefined);
|
|
278
|
+
if (slice)
|
|
279
|
+
result.slices.set("default", slice);
|
|
280
|
+
}
|
|
281
|
+
else if (element.kind === javascript_1.JS.Kind.ExportDeclaration) {
|
|
282
|
+
const declaration = element;
|
|
283
|
+
if (declaration.moduleSpecifier || ((_d = declaration.exportClause) === null || _d === void 0 ? void 0 : _d.kind) !== javascript_1.JS.Kind.NamedExports)
|
|
284
|
+
continue;
|
|
285
|
+
for (const { element: specifier } of declaration.exportClause.elements.elements) {
|
|
286
|
+
if (specifier.kind !== javascript_1.JS.Kind.ExportSpecifier)
|
|
287
|
+
continue;
|
|
288
|
+
const named = specifier.specifier;
|
|
289
|
+
if ((0, java_1.isIdentifier)(named))
|
|
290
|
+
exportedNames.push([named.simpleName, named.simpleName]);
|
|
291
|
+
else if (named.kind === javascript_1.JS.Kind.Alias) {
|
|
292
|
+
const alias = named;
|
|
293
|
+
const local = alias.propertyName.element;
|
|
294
|
+
if ((0, java_1.isIdentifier)(local) && (0, java_1.isIdentifier)(alias.alias))
|
|
295
|
+
exportedNames.push([local.simpleName, alias.alias.simpleName]);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
for (const [local, exported] of exportedNames) {
|
|
301
|
+
const slice = result.localSlices.get(local);
|
|
302
|
+
if (slice)
|
|
303
|
+
result.slices.set(exported, slice);
|
|
304
|
+
const reducer = result.localReducers.get(local);
|
|
305
|
+
if (reducer)
|
|
306
|
+
result.reducers.set(exported, reducer);
|
|
307
|
+
}
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
310
|
+
function resolveSliceReducer(node, cu, local, modules) {
|
|
311
|
+
var _a;
|
|
312
|
+
const inFile = (_a = reducerOf(node, local.localSlices)) !== null && _a !== void 0 ? _a : ((0, java_1.isIdentifier)(node) ? local.localReducers.get(node.simpleName) : undefined);
|
|
313
|
+
if (inFile)
|
|
314
|
+
return inFile;
|
|
315
|
+
const imported = (name) => {
|
|
316
|
+
const binding = (0, module_imports_1.importBindings)(cu).find(b => b.local === name);
|
|
317
|
+
const path = binding && (0, module_imports_1.resolveRelative)(cu.sourcePath, binding.module, modules);
|
|
318
|
+
return path ? { binding, module: modules.get(path) } : undefined;
|
|
319
|
+
};
|
|
320
|
+
if ((0, java_1.isIdentifier)(node)) {
|
|
321
|
+
const found = imported(node.simpleName);
|
|
322
|
+
return found === null || found === void 0 ? void 0 : found.module.reducers.get(found.binding.name);
|
|
323
|
+
}
|
|
324
|
+
if (node.kind === java_1.J.Kind.FieldAccess) {
|
|
325
|
+
const access = node;
|
|
326
|
+
if (access.name.element.simpleName !== "reducer" || !(0, java_1.isIdentifier)(access.target))
|
|
327
|
+
return undefined;
|
|
328
|
+
const found = imported(access.target.simpleName);
|
|
329
|
+
return found === null || found === void 0 ? void 0 : found.module.slices.get(found.binding.name);
|
|
330
|
+
}
|
|
331
|
+
return undefined;
|
|
332
|
+
}
|
|
333
|
+
exports.SUGGESTED_ACTIONS = {
|
|
334
|
+
SLICE_STORE: "A store of `createSlice` reducers with the default middleware: each slice can become a zustand store. Check its consumers next.",
|
|
335
|
+
LEGACY_STORE: "Move the store to Redux Toolkit's `configureStore` and its reducers to `createSlice` first, or write the zustand store by hand.",
|
|
336
|
+
OPTIONS_NOT_LITERAL: "Write the `configureStore` options as an object literal, so that the setup can be read.",
|
|
337
|
+
ROOT_REDUCER: "Pass `reducer` as an object of slice reducers; a single root reducer, such as `combineReducers(...)`, can't be split into zustand stores.",
|
|
338
|
+
NON_SLICE_REDUCER: "Rewrite this reducer with `createSlice`, or keep it in Redux; zustand has no place for a hand-written reducer.",
|
|
339
|
+
EXTRA_REDUCERS: "Write `extraReducers` as `builder.addCase(thunk.pending, reducer)` cases of `createAsyncThunk`s declared in the slice's source, whose payload creators use only `rejectWithValue`, `fulfillWithValue`, `signal` and `requestId` of `thunkAPI`, or move what it handles into actions of the zustand store by hand.",
|
|
340
|
+
SLICE_OPTIONS_NOT_LITERAL: "Write the `createSlice` options as an object literal, so that the slice can be read.",
|
|
341
|
+
SLICE_REDUCERS_NOT_LITERAL: "Write `reducers` as an object of reducer functions; the builder callback form can't be read.",
|
|
342
|
+
MIDDLEWARE: "Custom middleware has no zustand equivalent: move it into the store's actions or zustand middleware by hand.",
|
|
343
|
+
ENHANCERS: "Store enhancers have no zustand equivalent: replace them by hand, for example with zustand middleware.",
|
|
344
|
+
PRELOADED_STATE: "Merge the preloaded state into the slices' initial state, or set it on the zustand store after it is created.",
|
|
345
|
+
DEVTOOLS: "Configure zustand's `devtools` middleware to match the `devTools` option by hand.",
|
|
346
|
+
UNKNOWN_OPTION: "Review this `configureStore` option by hand."
|
|
347
|
+
};
|
|
348
|
+
exports.TEST_SOURCE = /(^|\/)(__tests__|__mocks__|tests?|stories)\/|\.(test|spec|stories)\.[jt]sx?$/i;
|
|
349
|
+
const BLOCKING_OPTIONS = {
|
|
350
|
+
middleware: "MIDDLEWARE", enhancers: "ENHANCERS", preloadedState: "PRELOADED_STATE", devTools: "DEVTOOLS"
|
|
351
|
+
};
|
|
352
|
+
function storeFunctions(cu) {
|
|
353
|
+
return {
|
|
354
|
+
legacy: new Set([...importedAs(cu, exports.REDUX, "createStore", "legacy_createStore"), ...importedAs(cu, exports.RTK, "createStore", "legacy_createStore")]),
|
|
355
|
+
configure: importedAs(cu, exports.RTK, "configureStore")
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function storeFindings(call, cu, modules, functions = storeFunctions(cu)) {
|
|
359
|
+
var _a, _b;
|
|
360
|
+
if (call.select)
|
|
361
|
+
return undefined;
|
|
362
|
+
const api = call.name.simpleName;
|
|
363
|
+
if (functions.legacy.has(api))
|
|
364
|
+
return { api, findings: [{ reason: "LEGACY_STORE", detail: api }], slices: new Map() };
|
|
365
|
+
if (!functions.configure.has(api))
|
|
366
|
+
return undefined;
|
|
367
|
+
const slices = new Map();
|
|
368
|
+
const options = objectProperties((_a = call.arguments.elements[0]) === null || _a === void 0 ? void 0 : _a.element);
|
|
369
|
+
if (!options)
|
|
370
|
+
return { api, findings: [{ reason: "OPTIONS_NOT_LITERAL", detail: "" }], slices };
|
|
371
|
+
const findings = [];
|
|
372
|
+
for (const key of options.keys()) {
|
|
373
|
+
if (key !== "reducer")
|
|
374
|
+
findings.push({ reason: (_b = BLOCKING_OPTIONS[key]) !== null && _b !== void 0 ? _b : "UNKNOWN_OPTION", detail: key });
|
|
375
|
+
}
|
|
376
|
+
const reducers = objectProperties(options.get("reducer"));
|
|
377
|
+
if (!reducers)
|
|
378
|
+
return { api, findings: [...findings, { reason: "ROOT_REDUCER", detail: "" }], slices };
|
|
379
|
+
const local = localSlices(cu);
|
|
380
|
+
for (const [key, value] of reducers) {
|
|
381
|
+
const slice = resolveSliceReducer(value, cu, local, modules);
|
|
382
|
+
if (!slice)
|
|
383
|
+
findings.push({ reason: "NON_SLICE_REDUCER", detail: key });
|
|
384
|
+
else if (slice.blocker)
|
|
385
|
+
findings.push(slice.blocker);
|
|
386
|
+
else
|
|
387
|
+
slices.set(key, slice);
|
|
388
|
+
}
|
|
389
|
+
return { api, findings, slices };
|
|
390
|
+
}
|
|
391
|
+
function storeName(cursor) {
|
|
392
|
+
for (let c = cursor.parent; c; c = c.parent) {
|
|
393
|
+
const node = c.value;
|
|
394
|
+
if ((node === null || node === void 0 ? void 0 : node.kind) === java_1.J.Kind.NamedVariable && (0, java_1.isIdentifier)(node.name)) {
|
|
395
|
+
return node.name.simpleName;
|
|
396
|
+
}
|
|
397
|
+
if ((node === null || node === void 0 ? void 0 : node.kind) === java_1.J.Kind.MethodDeclaration)
|
|
398
|
+
return node.name.simpleName;
|
|
399
|
+
}
|
|
400
|
+
return "<module>";
|
|
401
|
+
}
|
|
402
|
+
//# sourceMappingURL=redux-stores.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redux-stores.js","sourceRoot":"","sources":["../../src/zustand/redux-stores.ts"],"names":[],"mappings":";;;;;;;;;AAgFA,gCAEC;AAGD,4CAgBC;AAwBD,oCAWC;AA6HD,kCAgDC;AAGD,kDAmBC;AA+BD,wCAKC;AAMD,sCAuBC;AAGD,8BASC;AAxZD,kDAAoD;AACpD,gEAAyD;AACzD,oDAA0D;AAC1D,2DAAuE;AAE1D,QAAA,KAAK,GAAG,OAAO,CAAC;AAChB,QAAA,GAAG,GAAG,kBAAkB,CAAC;AACzB,QAAA,aAAa,GAAG,0DAA0D,CAAC;AAC3E,QAAA,kBAAkB,GAAG,yCAAyC,CAAC;AAE5E,MAAa,aAAa;CAwBzB;AAxBD,sCAwBC;AAtBG;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,wCAAwC,EAAC,CAAC;iDACxE;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,OA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
|
1
|
+
import { ExecutionContext, ScanningRecipe, SourceFile, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
import { AddDependencyOptions } from "@openrewrite/rewrite/javascript";
|
|
3
|
+
import { JavaDependencyRecipe } from "../util/java-recipe-proxy";
|
|
4
|
+
import { SliceModule } from "./redux-stores";
|
|
5
|
+
import { SliceSource, SourceFacts } from "./zustand-plan";
|
|
6
|
+
export interface ZustandForecast {
|
|
7
|
+
converting?: () => Promise<ReadonlySet<string>>;
|
|
8
|
+
refused?: Map<string, {
|
|
9
|
+
message: string;
|
|
10
|
+
lock: string;
|
|
11
|
+
}>;
|
|
12
|
+
react?: (root: string) => string | undefined;
|
|
13
|
+
}
|
|
14
|
+
interface PackageFacts {
|
|
15
|
+
react?: string;
|
|
16
|
+
zustand?: string;
|
|
17
|
+
immer?: string;
|
|
18
|
+
}
|
|
19
|
+
interface Scanned {
|
|
20
|
+
sources: Map<string, SourceFacts>;
|
|
21
|
+
modules: Map<string, SliceModule>;
|
|
22
|
+
sliceSources: Map<string, SliceSource>;
|
|
23
|
+
packages: Map<string, PackageFacts>;
|
|
24
|
+
}
|
|
25
|
+
declare abstract class ZustandDependency extends JavaDependencyRecipe {
|
|
26
|
+
private readonly addition;
|
|
27
|
+
private readonly forecast;
|
|
28
|
+
readonly landed: Set<string>;
|
|
29
|
+
private readonly held;
|
|
30
|
+
private readonly locks;
|
|
31
|
+
private readonly unfit;
|
|
32
|
+
protected constructor(addition: AddDependencyOptions, forecast: ZustandForecast);
|
|
33
|
+
initialValue(): number;
|
|
34
|
+
protected scanned(manifest: SourceFile): boolean;
|
|
35
|
+
protected edits(manifest: SourceFile): boolean;
|
|
36
|
+
private fits;
|
|
37
|
+
private lockOf;
|
|
38
|
+
generate(acc: number, ctx: ExecutionContext): Promise<SourceFile[]>;
|
|
39
|
+
}
|
|
40
|
+
export declare class AddZustand extends ZustandDependency {
|
|
41
|
+
readonly name = "org.openrewrite.react.migrate.add-zustand";
|
|
42
|
+
readonly displayName = "Add `zustand` where a Redux store is migrated";
|
|
43
|
+
readonly description = "Adds `zustand` 5 to packages that declare `@reduxjs/toolkit` and resolve React 18 or later, where a Redux store moves to zustand.";
|
|
44
|
+
constructor(forecast?: ZustandForecast);
|
|
45
|
+
}
|
|
46
|
+
export declare class AddZustand4 extends ZustandDependency {
|
|
47
|
+
readonly name = "org.openrewrite.react.migrate.add-zustand-4";
|
|
48
|
+
readonly displayName = "Add `zustand` 4 where a Redux store is migrated on React 16.8 to 17";
|
|
49
|
+
readonly description = "Adds `zustand` 4 to packages that declare `@reduxjs/toolkit` and resolve React 16.8 to 17, where a Redux store moves to zustand.";
|
|
50
|
+
constructor(forecast?: ZustandForecast);
|
|
51
|
+
}
|
|
52
|
+
export declare class AddImmer extends ZustandDependency {
|
|
53
|
+
readonly name = "org.openrewrite.react.migrate.add-immer";
|
|
54
|
+
readonly displayName = "Add `immer` where a Redux store is migrated";
|
|
55
|
+
readonly description = "Adds `immer` 10 to packages that declare `@reduxjs/toolkit` and resolve React 16.8 or later, where a Redux store moves to zustand and its slices' reducers run through `produce`.";
|
|
56
|
+
constructor(forecast?: ZustandForecast);
|
|
57
|
+
}
|
|
58
|
+
export declare class ReduxToZustand extends ScanningRecipe<Scanned> {
|
|
59
|
+
readonly name = "org.openrewrite.react.migrate.redux-to-zustand";
|
|
60
|
+
readonly displayName = "Migrate Redux Toolkit slices to zustand";
|
|
61
|
+
readonly description = "Moves a repository's one Redux Toolkit store to zustand when it is a `configureStore` of `createSlice` reducers with no other option, its sources are JavaScript, and every use of it converts: each slice becomes a zustand store whose action creators keep their names and run the slice's reducers through immer's `produce`, `useSelector` reads of one slice become the slice's zustand hook, `dispatch` and `store.dispatch` of the slices' action creators become calls of them, `store.getState()` reads become the slice store's `getState()`, and the react-redux `Provider` and the store's source are removed. Adds `zustand` and `immer` where they are missing. Stores with any other use, such as `connect`, thunks, selectors that build values or several stores, stay in Redux and are recorded for review.";
|
|
62
|
+
private readonly forecast;
|
|
63
|
+
private readonly storeSources;
|
|
64
|
+
private asked?;
|
|
65
|
+
private readonly steps;
|
|
66
|
+
private readonly stores;
|
|
67
|
+
initialValue(): Scanned;
|
|
68
|
+
scanner(scanned: Scanned): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
69
|
+
private plans;
|
|
70
|
+
private planned;
|
|
71
|
+
private dependencies;
|
|
72
|
+
editorWithData(scanned: Scanned): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
73
|
+
recipeList(): Promise<(AddZustand | AddZustand4 | AddImmer)[]>;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=redux-to-zustand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redux-to-zustand.d.ts","sourceRoot":"","sources":["../../src/zustand/redux-to-zustand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,gBAAgB,EAAqC,cAAc,EAAE,UAAU,EAAsB,WAAW,EAAC,MAAM,sBAAsB,CAAC;AACvL,OAAO,EACH,oBAAoB,EACvB,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EAAC,oBAAoB,EAAc,MAAM,2BAA2B,CAAC;AAG5E,OAAO,EAA6E,WAAW,EAAiC,MAAM,gBAAgB,CAAC;AACvJ,OAAO,EAEwD,WAAW,EAAE,WAAW,EACtF,MAAM,gBAAgB,CAAC;AAcxB,MAAM,WAAW,eAAe;IAC5B,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAKhD,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IAEvD,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CAChD;AAKD,UAAU,YAAY;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC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