@openrewrite/recipes-nodejs 0.33.0-20251024-110448 → 0.33.0-20251024-203626
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util-type-checking.d.ts","sourceRoot":"","sources":["../../src/migrate/util-type-checking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAA0B,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"util-type-checking.d.ts","sourceRoot":"","sources":["../../src/migrate/util-type-checking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAA0B,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAWxH,qBAAa,4BAA6B,SAAQ,MAAM;IACpD,QAAQ,CAAC,IAAI,wEAAuE;IACpF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAoE;IAChG,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA6E;IAEnG,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CA6H9D"}
|
|
@@ -52,20 +52,16 @@ class UseNativeTypeCheckingMethods extends rewrite_1.Recipe {
|
|
|
52
52
|
if (unaryAfter.expression.kind === javascript_1.JS.Kind.Binary) {
|
|
53
53
|
const binary = unaryAfter.expression;
|
|
54
54
|
if (binary.operator.element === "IdentityEquals") {
|
|
55
|
-
return (
|
|
56
|
-
draft.operator.element = "IdentityNotEquals";
|
|
57
|
-
});
|
|
55
|
+
return Object.assign(Object.assign({}, binary), { operator: Object.assign(Object.assign({}, binary.operator), { element: "IdentityNotEquals" }) });
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
else if (unaryAfter.expression.kind === java_1.J.Kind.Binary) {
|
|
61
59
|
const binary = unaryAfter.expression;
|
|
62
60
|
if (binary.operator.element === "Equal") {
|
|
63
|
-
return (
|
|
64
|
-
draft.operator.element = "NotEqual";
|
|
65
|
-
});
|
|
61
|
+
return Object.assign(Object.assign({}, binary), { operator: Object.assign(Object.assign({}, binary.operator), { element: "NotEqual" }) });
|
|
66
62
|
}
|
|
67
63
|
}
|
|
68
|
-
return (0, rewrite_1.produceAsync)(unaryAfter, draft => {
|
|
64
|
+
return yield (0, rewrite_1.produceAsync)(unaryAfter, draft => {
|
|
69
65
|
draft.expression =
|
|
70
66
|
{
|
|
71
67
|
kind: java_1.J.Kind.Parentheses,
|
|
@@ -89,63 +85,63 @@ class UseNativeTypeCheckingMethods extends rewrite_1.Recipe {
|
|
|
89
85
|
(0, javascript_1.maybeRemoveImport)(this, "util");
|
|
90
86
|
if (this.isArray.matches(method.methodType)) {
|
|
91
87
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isArray");
|
|
92
|
-
return (0, javascript_1.template) `Array.isArray(${arg})`.apply(this.cursor, method);
|
|
88
|
+
return yield (0, javascript_1.template) `Array.isArray(${arg})`.apply(this.cursor, method);
|
|
93
89
|
}
|
|
94
90
|
else if (this.isBoolean.matches(method.methodType)) {
|
|
95
91
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isBoolean");
|
|
96
|
-
return (0, javascript_1.template) `typeof ${arg} === 'boolean'`.apply(this.cursor, method);
|
|
92
|
+
return yield (0, javascript_1.template) `typeof ${arg} === 'boolean'`.apply(this.cursor, method);
|
|
97
93
|
}
|
|
98
94
|
else if (this.isBuffer.matches(method.methodType)) {
|
|
99
95
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isBuffer");
|
|
100
|
-
return (0, javascript_1.template) `Buffer.isBuffer(${arg})`.apply(this.cursor, method);
|
|
96
|
+
return yield (0, javascript_1.template) `Buffer.isBuffer(${arg})`.apply(this.cursor, method);
|
|
101
97
|
}
|
|
102
98
|
else if (this.isDate.matches(method.methodType)) {
|
|
103
99
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isDate");
|
|
104
|
-
return (0, javascript_1.template) `${arg} instanceof Date`.apply(this.cursor, method);
|
|
100
|
+
return yield (0, javascript_1.template) `${arg} instanceof Date`.apply(this.cursor, method);
|
|
105
101
|
}
|
|
106
102
|
else if (this.isError.matches(method.methodType)) {
|
|
107
103
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isError");
|
|
108
|
-
return (0, javascript_1.template) `${arg} instanceof Error`.apply(this.cursor, method);
|
|
104
|
+
return yield (0, javascript_1.template) `${arg} instanceof Error`.apply(this.cursor, method);
|
|
109
105
|
}
|
|
110
106
|
else if (this.isFunction.matches(method.methodType)) {
|
|
111
107
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isFunction");
|
|
112
|
-
return (0, javascript_1.template) `typeof (${arg}) === 'function'`.apply(this.cursor, method);
|
|
108
|
+
return yield (0, javascript_1.template) `typeof (${arg}) === 'function'`.apply(this.cursor, method);
|
|
113
109
|
}
|
|
114
110
|
else if (this.isNull.matches(method.methodType)) {
|
|
115
111
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isNull");
|
|
116
|
-
return (0, javascript_1.template) `${arg} === null`.apply(this.cursor, method);
|
|
112
|
+
return yield (0, javascript_1.template) `${arg} === null`.apply(this.cursor, method);
|
|
117
113
|
}
|
|
118
114
|
else if (this.isNullOrUndefined.matches(method.methodType)) {
|
|
119
115
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isNullOrUndefined");
|
|
120
|
-
return (0, javascript_1.template) `${arg} == null`.apply(this.cursor, method);
|
|
116
|
+
return yield (0, javascript_1.template) `${arg} == null`.apply(this.cursor, method);
|
|
121
117
|
}
|
|
122
118
|
else if (this.isNumber.matches(method.methodType)) {
|
|
123
119
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isNumber");
|
|
124
|
-
return (0, javascript_1.template) `typeof ${arg} === 'number'`.apply(this.cursor, method);
|
|
120
|
+
return yield (0, javascript_1.template) `typeof ${arg} === 'number'`.apply(this.cursor, method);
|
|
125
121
|
}
|
|
126
122
|
else if (this.isObject.matches(method.methodType)) {
|
|
127
123
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isObject");
|
|
128
|
-
return (0, javascript_1.template) `typeof ${arg} === 'object' && ${arg} !== null`.apply(this.cursor, method);
|
|
124
|
+
return yield (0, javascript_1.template) `typeof ${arg} === 'object' && ${arg} !== null`.apply(this.cursor, method);
|
|
129
125
|
}
|
|
130
126
|
else if (this.isPrimitive.matches(method.methodType)) {
|
|
131
127
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isPrimitive");
|
|
132
|
-
return (0, javascript_1.template) `${arg} !== Object(${arg})`.apply(this.cursor, method);
|
|
128
|
+
return yield (0, javascript_1.template) `${arg} !== Object(${arg})`.apply(this.cursor, method);
|
|
133
129
|
}
|
|
134
130
|
else if (this.isRegExp.matches(method.methodType)) {
|
|
135
131
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isRegExp");
|
|
136
|
-
return (0, javascript_1.template) `${arg} instanceof RegExp`.apply(this.cursor, method);
|
|
132
|
+
return yield (0, javascript_1.template) `${arg} instanceof RegExp`.apply(this.cursor, method);
|
|
137
133
|
}
|
|
138
134
|
else if (this.isString.matches(method.methodType)) {
|
|
139
135
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isString");
|
|
140
|
-
return (0, javascript_1.template) `typeof ${arg} === 'string'`.apply(this.cursor, method);
|
|
136
|
+
return yield (0, javascript_1.template) `typeof ${arg} === 'string'`.apply(this.cursor, method);
|
|
141
137
|
}
|
|
142
138
|
else if (this.isSymbol.matches(method.methodType)) {
|
|
143
139
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isSymbol");
|
|
144
|
-
return (0, javascript_1.template) `typeof ${arg} === 'symbol'`.apply(this.cursor, method);
|
|
140
|
+
return yield (0, javascript_1.template) `typeof ${arg} === 'symbol'`.apply(this.cursor, method);
|
|
145
141
|
}
|
|
146
142
|
else if (this.isUndefined.matches(method.methodType)) {
|
|
147
143
|
(0, javascript_1.maybeRemoveImport)(this, "util", "isUndefined");
|
|
148
|
-
return (0, javascript_1.template) `${arg} === undefined`.apply(this.cursor, method);
|
|
144
|
+
return yield (0, javascript_1.template) `${arg} === undefined`.apply(this.cursor, method);
|
|
149
145
|
}
|
|
150
146
|
}
|
|
151
147
|
return _super.visitMethodInvocation.call(this, method, p);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util-type-checking.js","sourceRoot":"","sources":["../../src/migrate/util-type-checking.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAwH;AACxH,
|
|
1
|
+
{"version":3,"file":"util-type-checking.js","sourceRoot":"","sources":["../../src/migrate/util-type-checking.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAwH;AACxH,gEAOyC;AACzC,oDAAiF;AAEjF,MAAa,4BAA6B,SAAQ,gBAAM;IAAxD;;QACa,SAAI,GAAG,oEAAoE,CAAA;QAC3E,gBAAW,GAAW,gEAAgE,CAAC;QACvF,gBAAW,GAAW,yEAAyE,CAAC;IA+H7G,CAAC;IA7HS,MAAM;;YACR,OAAO,IAAA,eAAK,EAAC,IAAA,uBAAU,EAAC,cAAc,CAAC,EAAE,IAAI,KAAM,SAAQ,8BAAmC;gBAAjD;;oBACzC,WAAM,GAAG,IAAI,0BAAa,CAAC,cAAc,CAAC,CAAC;oBAC3C,YAAO,GAAG,IAAI,0BAAa,CAAC,kBAAkB,CAAC,CAAC;oBAChD,cAAS,GAAG,IAAI,0BAAa,CAAC,oBAAoB,CAAC,CAAC;oBACpD,aAAQ,GAAG,IAAI,0BAAa,CAAC,mBAAmB,CAAC,CAAC;oBAClD,WAAM,GAAG,IAAI,0BAAa,CAAC,iBAAiB,CAAC,CAAC;oBAC9C,YAAO,GAAG,IAAI,0BAAa,CAAC,kBAAkB,CAAC,CAAC;oBAChD,eAAU,GAAG,IAAI,0BAAa,CAAC,qBAAqB,CAAC,CAAC;oBACtD,WAAM,GAAG,IAAI,0BAAa,CAAC,iBAAiB,CAAC,CAAC;oBAC9C,sBAAiB,GAAG,IAAI,0BAA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,MAAM,EAAE,MAAM,CAAC,CAAC;4BACjF,CAAC;iCAAM,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;gCACrD,IAAA,8BAAiB,EAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;gCAC/C,OAAO,MAAM,IAAA,qBAAQ,EAAA,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;4BAC3E,CAAC;wBACL,CAAC;wBACD,OAAO,OAAM,qBAAqB,YAAC,MAAM,EAAE,CAAC,EAAE;oBAClD,CAAC;iBAAA;aACJ,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AAlID,oEAkIC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrewrite/recipes-nodejs",
|
|
3
|
-
"version": "0.33.0-20251024-
|
|
3
|
+
"version": "0.33.0-20251024-203626",
|
|
4
4
|
"license": "Moderne Source Available License",
|
|
5
5
|
"description": "OpenRewrite recipes for Node.js library migrations.",
|
|
6
6
|
"homepage": "https://github.com/moderneinc/rewrite-node",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {check, emptyMarkers, ExecutionContext, produceAsync, randomId, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
2
|
import {
|
|
3
|
-
JavaScriptVisitor,
|
|
3
|
+
JavaScriptVisitor,
|
|
4
|
+
JS,
|
|
4
5
|
maybeRemoveImport,
|
|
5
6
|
MethodMatcher,
|
|
6
7
|
template,
|
|
@@ -38,21 +39,37 @@ export class UseNativeTypeCheckingMethods extends Recipe {
|
|
|
38
39
|
if (unaryAfter.expression.kind === JS.Kind.Binary) {
|
|
39
40
|
const binary = unaryAfter.expression as JS.Binary;
|
|
40
41
|
if (binary.operator.element === JS.Binary.Type.IdentityEquals) {
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
return {
|
|
43
|
+
...binary,
|
|
44
|
+
operator: {
|
|
45
|
+
...binary.operator,
|
|
46
|
+
element: JS.Binary.Type.IdentityNotEquals
|
|
47
|
+
}
|
|
48
|
+
} as JS.Binary;
|
|
49
|
+
// TODO analyze why immer `produce()` gives us the "RangeError: Maximum call stack size exceeded" error
|
|
50
|
+
// return produce(binary, draft => {
|
|
51
|
+
// draft.operator.element = JS.Binary.Type.IdentityNotEquals;
|
|
52
|
+
// });
|
|
44
53
|
}
|
|
45
54
|
} else if (unaryAfter.expression.kind === J.Kind.Binary) {
|
|
46
55
|
// used for `!util.isNullOrUndefined(x)`
|
|
47
56
|
const binary = unaryAfter.expression as J.Binary;
|
|
48
57
|
if (binary.operator.element === J.Binary.Type.Equal) {
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
return {
|
|
59
|
+
...binary,
|
|
60
|
+
operator: {
|
|
61
|
+
...binary.operator,
|
|
62
|
+
element: J.Binary.Type.NotEqual
|
|
63
|
+
}
|
|
64
|
+
} as J.Binary;
|
|
65
|
+
// TODO analyze why immer `produce()` gives us the "RangeError: Maximum call stack size exceeded" error
|
|
66
|
+
// return produce(binary, draft => {
|
|
67
|
+
// draft.operator.element = J.Binary.Type.NotEqual;
|
|
68
|
+
// });
|
|
52
69
|
}
|
|
53
70
|
}
|
|
54
71
|
|
|
55
|
-
return produceAsync(unaryAfter, draft => {
|
|
72
|
+
return await produceAsync(unaryAfter, draft => {
|
|
56
73
|
draft.expression =
|
|
57
74
|
{
|
|
58
75
|
kind: J.Kind.Parentheses,
|
|
@@ -73,49 +90,49 @@ export class UseNativeTypeCheckingMethods extends Recipe {
|
|
|
73
90
|
maybeRemoveImport(this, "util");
|
|
74
91
|
if (this.isArray.matches(method.methodType)) {
|
|
75
92
|
maybeRemoveImport(this, "util", "isArray");
|
|
76
|
-
return template`Array.isArray(${arg})`.apply(this.cursor, method);
|
|
93
|
+
return await template`Array.isArray(${arg})`.apply(this.cursor, method);
|
|
77
94
|
} else if (this.isBoolean.matches(method.methodType)) {
|
|
78
95
|
maybeRemoveImport(this, "util", "isBoolean");
|
|
79
|
-
return template`typeof ${arg} === 'boolean'`.apply(this.cursor, method);
|
|
96
|
+
return await template`typeof ${arg} === 'boolean'`.apply(this.cursor, method);
|
|
80
97
|
} else if (this.isBuffer.matches(method.methodType)) {
|
|
81
98
|
maybeRemoveImport(this, "util", "isBuffer");
|
|
82
|
-
return template`Buffer.isBuffer(${arg})`.apply(this.cursor, method);
|
|
99
|
+
return await template`Buffer.isBuffer(${arg})`.apply(this.cursor, method);
|
|
83
100
|
} else if (this.isDate.matches(method.methodType)) {
|
|
84
101
|
maybeRemoveImport(this, "util", "isDate");
|
|
85
|
-
return template`${arg} instanceof Date`.apply(this.cursor, method);
|
|
102
|
+
return await template`${arg} instanceof Date`.apply(this.cursor, method);
|
|
86
103
|
} else if (this.isError.matches(method.methodType)) {
|
|
87
104
|
maybeRemoveImport(this, "util", "isError");
|
|
88
|
-
return template`${arg} instanceof Error`.apply(this.cursor, method);
|
|
105
|
+
return await template`${arg} instanceof Error`.apply(this.cursor, method);
|
|
89
106
|
} else if (this.isFunction.matches(method.methodType)) {
|
|
90
107
|
maybeRemoveImport(this, "util", "isFunction");
|
|
91
|
-
return template`typeof (${arg}) === 'function'`.apply(this.cursor, method);
|
|
108
|
+
return await template`typeof (${arg}) === 'function'`.apply(this.cursor, method);
|
|
92
109
|
} else if (this.isNull.matches(method.methodType)) {
|
|
93
110
|
maybeRemoveImport(this, "util", "isNull");
|
|
94
|
-
return template`${arg} === null`.apply(this.cursor, method);
|
|
111
|
+
return await template`${arg} === null`.apply(this.cursor, method);
|
|
95
112
|
} else if (this.isNullOrUndefined.matches(method.methodType)) {
|
|
96
113
|
maybeRemoveImport(this, "util", "isNullOrUndefined");
|
|
97
|
-
return template`${arg} == null`.apply(this.cursor, method);
|
|
114
|
+
return await template`${arg} == null`.apply(this.cursor, method);
|
|
98
115
|
} else if (this.isNumber.matches(method.methodType)) {
|
|
99
116
|
maybeRemoveImport(this, "util", "isNumber");
|
|
100
|
-
return template`typeof ${arg} === 'number'`.apply(this.cursor, method);
|
|
117
|
+
return await template`typeof ${arg} === 'number'`.apply(this.cursor, method);
|
|
101
118
|
} else if (this.isObject.matches(method.methodType)) {
|
|
102
119
|
maybeRemoveImport(this, "util", "isObject");
|
|
103
|
-
return template`typeof ${arg} === 'object' && ${arg} !== null`.apply(this.cursor, method);
|
|
120
|
+
return await template`typeof ${arg} === 'object' && ${arg} !== null`.apply(this.cursor, method);
|
|
104
121
|
} else if (this.isPrimitive.matches(method.methodType)) {
|
|
105
122
|
maybeRemoveImport(this, "util", "isPrimitive");
|
|
106
|
-
return template`${arg} !== Object(${arg})`.apply(this.cursor, method);
|
|
123
|
+
return await template`${arg} !== Object(${arg})`.apply(this.cursor, method);
|
|
107
124
|
} else if (this.isRegExp.matches(method.methodType)) {
|
|
108
125
|
maybeRemoveImport(this, "util", "isRegExp");
|
|
109
|
-
return template`${arg} instanceof RegExp`.apply(this.cursor, method);
|
|
126
|
+
return await template`${arg} instanceof RegExp`.apply(this.cursor, method);
|
|
110
127
|
} else if (this.isString.matches(method.methodType)) {
|
|
111
128
|
maybeRemoveImport(this, "util", "isString");
|
|
112
|
-
return template`typeof ${arg} === 'string'`.apply(this.cursor, method);
|
|
129
|
+
return await template`typeof ${arg} === 'string'`.apply(this.cursor, method);
|
|
113
130
|
} else if (this.isSymbol.matches(method.methodType)) {
|
|
114
131
|
maybeRemoveImport(this, "util", "isSymbol");
|
|
115
|
-
return template`typeof ${arg} === 'symbol'`.apply(this.cursor, method);
|
|
132
|
+
return await template`typeof ${arg} === 'symbol'`.apply(this.cursor, method);
|
|
116
133
|
} else if (this.isUndefined.matches(method.methodType)) {
|
|
117
134
|
maybeRemoveImport(this, "util", "isUndefined");
|
|
118
|
-
return template`${arg} === undefined`.apply(this.cursor, method);
|
|
135
|
+
return await template`${arg} === undefined`.apply(this.cursor, method);
|
|
119
136
|
}
|
|
120
137
|
}
|
|
121
138
|
return super.visitMethodInvocation(method, p);
|