@openrewrite/recipes-nodejs 0.59.0 → 0.60.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/migrate/angular-animations/remove-angular-animations-providers.d.ts.map +1 -1
- package/dist/migrate/angular-animations/remove-angular-animations-providers.js +6 -26
- package/dist/migrate/angular-animations/remove-angular-animations-providers.js.map +1 -1
- package/dist/migrate/builtin-binding-visitor.d.ts.map +1 -1
- package/dist/migrate/builtin-binding-visitor.js +6 -22
- package/dist/migrate/builtin-binding-visitor.js.map +1 -1
- package/dist/migrate/crypto-rsa-pss-key-pair-options.js +1 -4
- package/dist/migrate/crypto-rsa-pss-key-pair-options.js.map +1 -1
- package/dist/migrate/exports-folder-mappings.d.ts.map +1 -1
- package/dist/migrate/exports-folder-mappings.js +6 -19
- package/dist/migrate/exports-folder-mappings.js.map +1 -1
- package/dist/migrate/express-request-id/replace-express-request-id.d.ts.map +1 -1
- package/dist/migrate/express-request-id/replace-express-request-id.js +2 -5
- package/dist/migrate/express-request-id/replace-express-request-id.js.map +1 -1
- package/dist/migrate/find-aead-decipheriv-without-auth-tag-length.d.ts.map +1 -1
- package/dist/migrate/find-aead-decipheriv-without-auth-tag-length.js +2 -3
- package/dist/migrate/find-aead-decipheriv-without-auth-tag-length.js.map +1 -1
- package/dist/migrate/find-dns-lookup-options-coercion.js +2 -2
- package/dist/migrate/find-dns-lookup-options-coercion.js.map +1 -1
- package/dist/migrate/find-duplex-to-web-type.d.ts.map +1 -1
- package/dist/migrate/find-duplex-to-web-type.js +2 -3
- package/dist/migrate/find-duplex-to-web-type.js.map +1 -1
- package/dist/migrate/find-stream-thenable-implementations.js +4 -5
- package/dist/migrate/find-stream-thenable-implementations.js.map +1 -1
- package/dist/migrate/fs-extra/find-fs-extra-manual-migrations.d.ts +1 -0
- package/dist/migrate/fs-extra/find-fs-extra-manual-migrations.d.ts.map +1 -1
- package/dist/migrate/fs-extra/find-fs-extra-manual-migrations.js +10 -2
- package/dist/migrate/fs-extra/find-fs-extra-manual-migrations.js.map +1 -1
- package/dist/migrate/fs-extra/fs-extra-support.d.ts +0 -1
- package/dist/migrate/fs-extra/fs-extra-support.d.ts.map +1 -1
- package/dist/migrate/fs-extra/fs-extra-support.js +0 -4
- package/dist/migrate/fs-extra/fs-extra-support.js.map +1 -1
- package/dist/migrate/fs-extra/migrate-fs-extra-to-node-fs.d.ts.map +1 -1
- package/dist/migrate/fs-extra/migrate-fs-extra-to-node-fs.js +3 -2
- package/dist/migrate/fs-extra/migrate-fs-extra-to-node-fs.js.map +1 -1
- package/dist/migrate/fs-extra/replace-fs-extra-move.js +2 -2
- package/dist/migrate/fs-extra/replace-fs-extra-move.js.map +1 -1
- package/dist/migrate/fs-extra/replace-fs-extra-native-methods.d.ts +2 -0
- package/dist/migrate/fs-extra/replace-fs-extra-native-methods.d.ts.map +1 -1
- package/dist/migrate/fs-extra/replace-fs-extra-native-methods.js +58 -6
- package/dist/migrate/fs-extra/replace-fs-extra-native-methods.js.map +1 -1
- package/dist/migrate/fs-extra/replace-fs-extra-read-json.js +1 -1
- package/dist/migrate/fs-extra/replace-fs-extra-read-json.js.map +1 -1
- package/dist/migrate/fs-stats-constructor.d.ts.map +1 -1
- package/dist/migrate/fs-stats-constructor.js +1 -12
- package/dist/migrate/fs-stats-constructor.js.map +1 -1
- package/dist/migrate/hpagent/hpagent-support.d.ts +0 -1
- package/dist/migrate/hpagent/hpagent-support.d.ts.map +1 -1
- package/dist/migrate/hpagent/hpagent-support.js +3 -7
- package/dist/migrate/hpagent/hpagent-support.js.map +1 -1
- package/dist/migrate/hpagent/replace-hpagent.d.ts.map +1 -1
- package/dist/migrate/hpagent/replace-hpagent.js +8 -12
- package/dist/migrate/hpagent/replace-hpagent.js.map +1 -1
- package/dist/migrate/increase-node-engine-version.d.ts.map +1 -1
- package/dist/migrate/increase-node-engine-version.js +7 -26
- package/dist/migrate/increase-node-engine-version.js.map +1 -1
- package/dist/migrate/json-edits.d.ts +4 -9
- package/dist/migrate/json-edits.d.ts.map +1 -1
- package/dist/migrate/json-edits.js +46 -60
- package/dist/migrate/json-edits.js.map +1 -1
- package/dist/migrate/options-literal.d.ts.map +1 -1
- package/dist/migrate/options-literal.js +1 -2
- package/dist/migrate/options-literal.js.map +1 -1
- package/dist/migrate/package-json-support.d.ts +2 -1
- package/dist/migrate/package-json-support.d.ts.map +1 -1
- package/dist/migrate/package-json-support.js +14 -12
- package/dist/migrate/package-json-support.js.map +1 -1
- package/dist/migrate/path/remove-path-dependency.d.ts.map +1 -1
- package/dist/migrate/path/remove-path-dependency.js +4 -25
- package/dist/migrate/path/remove-path-dependency.js.map +1 -1
- package/dist/migrate/promisify-on-promise.js +3 -3
- package/dist/migrate/promisify-on-promise.js.map +1 -1
- package/dist/migrate/prop-types/remove-prop-types.d.ts.map +1 -1
- package/dist/migrate/prop-types/remove-prop-types.js +7 -25
- package/dist/migrate/prop-types/remove-prop-types.js.map +1 -1
- package/dist/migrate/source-map-support/enable-source-maps-at-launch.d.ts.map +1 -1
- package/dist/migrate/source-map-support/enable-source-maps-at-launch.js +14 -64
- package/dist/migrate/source-map-support/enable-source-maps-at-launch.js.map +1 -1
- package/dist/migrate/source-map-support/find-source-map-support-manual-migrations.d.ts.map +1 -1
- package/dist/migrate/source-map-support/find-source-map-support-manual-migrations.js +9 -38
- package/dist/migrate/source-map-support/find-source-map-support-manual-migrations.js.map +1 -1
- package/dist/migrate/source-map-support/replace-source-map-support-api.d.ts.map +1 -1
- package/dist/migrate/source-map-support/replace-source-map-support-api.js +1 -1
- package/dist/migrate/source-map-support/replace-source-map-support-api.js.map +1 -1
- package/dist/migrate/source-map-support/replace-source-map-support-register-in-mocha-config.js +1 -1
- package/dist/migrate/source-map-support/replace-source-map-support-register-in-mocha-config.js.map +1 -1
- package/dist/migrate/source-map-support/replace-source-map-support-register-in-package-json.d.ts.map +1 -1
- package/dist/migrate/source-map-support/replace-source-map-support-register-in-package-json.js +37 -88
- package/dist/migrate/source-map-support/replace-source-map-support-register-in-package-json.js.map +1 -1
- package/dist/migrate/source-map-support/source-map-support-support.d.ts.map +1 -1
- package/dist/migrate/source-map-support/source-map-support-support.js +3 -16
- package/dist/migrate/source-map-support/source-map-support-support.js.map +1 -1
- package/dist/migrate/stream-internal-modules.d.ts.map +1 -1
- package/dist/migrate/stream-internal-modules.js +2 -10
- package/dist/migrate/stream-internal-modules.js.map +1 -1
- package/dist/migrate/tls-internal-modules.d.ts.map +1 -1
- package/dist/migrate/tls-internal-modules.js +2 -10
- package/dist/migrate/tls-internal-modules.js.map +1 -1
- package/package.json +2 -2
- package/src/migrate/angular-animations/remove-angular-animations-providers.ts +7 -23
- package/src/migrate/builtin-binding-visitor.ts +10 -28
- package/src/migrate/crypto-rsa-pss-key-pair-options.ts +2 -11
- package/src/migrate/exports-folder-mappings.ts +18 -19
- package/src/migrate/express-request-id/replace-express-request-id.ts +3 -7
- package/src/migrate/find-aead-decipheriv-without-auth-tag-length.ts +3 -4
- package/src/migrate/find-dns-lookup-options-coercion.ts +3 -3
- package/src/migrate/find-duplex-to-web-type.ts +3 -4
- package/src/migrate/find-stream-thenable-implementations.ts +5 -7
- package/src/migrate/fs-extra/find-fs-extra-manual-migrations.ts +12 -4
- package/src/migrate/fs-extra/fs-extra-support.ts +0 -5
- package/src/migrate/fs-extra/migrate-fs-extra-to-node-fs.ts +3 -2
- package/src/migrate/fs-extra/replace-fs-extra-move.ts +3 -3
- package/src/migrate/fs-extra/replace-fs-extra-native-methods.ts +75 -8
- package/src/migrate/fs-extra/replace-fs-extra-read-json.ts +3 -3
- package/src/migrate/fs-stats-constructor.ts +2 -13
- package/src/migrate/hpagent/hpagent-support.ts +2 -7
- package/src/migrate/hpagent/replace-hpagent.ts +7 -8
- package/src/migrate/increase-node-engine-version.ts +10 -36
- package/src/migrate/json-edits.ts +48 -64
- package/src/migrate/options-literal.ts +2 -3
- package/src/migrate/package-json-support.ts +15 -12
- package/src/migrate/path/remove-path-dependency.ts +6 -23
- package/src/migrate/promisify-on-promise.ts +4 -4
- package/src/migrate/prop-types/remove-prop-types.ts +9 -25
- package/src/migrate/source-map-support/enable-source-maps-at-launch.ts +14 -52
- package/src/migrate/source-map-support/find-source-map-support-manual-migrations.ts +11 -34
- package/src/migrate/source-map-support/replace-source-map-support-api.ts +2 -1
- package/src/migrate/source-map-support/replace-source-map-support-register-in-mocha-config.ts +2 -2
- package/src/migrate/source-map-support/replace-source-map-support-register-in-package-json.ts +53 -98
- package/src/migrate/source-map-support/source-map-support-support.ts +6 -19
- package/src/migrate/stream-internal-modules.ts +4 -13
- package/src/migrate/tls-internal-modules.ts +4 -13
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import {Column, Cursor, DataTable} from "@openrewrite/rewrite";
|
|
8
8
|
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
9
|
-
import {compilationUnitOf, JS, scopeOf, walk} from "@openrewrite/rewrite/javascript";
|
|
9
|
+
import {compilationUnitOf, isAssignmentTarget, isObjectLiteral, JS, scopeOf, walk} from "@openrewrite/rewrite/javascript";
|
|
10
10
|
import {BuiltinBindingVisitor} from "../builtin-binding-visitor";
|
|
11
11
|
import {bindingsOf, isModuleScoped, ModuleBindings, requiredModule, stringLiteral} from "../module-bindings";
|
|
12
12
|
import {REGISTER_MODULES} from "./register-flag";
|
|
@@ -128,10 +128,10 @@ function memberMethodName(e: J): string | undefined {
|
|
|
128
128
|
/** The first `install` option Node has no equivalent for, or undefined where every one is covered. */
|
|
129
129
|
export function nonNativeOption(arg: J | undefined): {option: string; reason: string} | undefined {
|
|
130
130
|
if (!arg || arg.kind === J.Kind.Empty) return undefined;
|
|
131
|
-
if (
|
|
131
|
+
if (!isObjectLiteral(arg)) {
|
|
132
132
|
return {option: 'options', reason: REASONS.nonNativeOption('options that cannot be read statically')};
|
|
133
133
|
}
|
|
134
|
-
for (const s of
|
|
134
|
+
for (const s of arg.body?.statements ?? []) {
|
|
135
135
|
if (s.element.kind === J.Kind.Empty) continue;
|
|
136
136
|
if (s.element.kind !== JS.Kind.PropertyAssignment) {
|
|
137
137
|
// A shorthand method — `retrieveSourceMap(source) {...}` — names the option it sets.
|
|
@@ -161,27 +161,14 @@ export function hasOnlyNativeOptions(arg: J | undefined): boolean {
|
|
|
161
161
|
|
|
162
162
|
/** Whether the tree at `cursor` is written to: assigned, incremented or deleted. */
|
|
163
163
|
export function isWriteTarget(cursor: Cursor): boolean {
|
|
164
|
-
const node = cursor.value as J;
|
|
165
164
|
const parent = cursor.parentTree()?.value as J | undefined;
|
|
166
|
-
|
|
167
|
-
case J.Kind.Assignment:
|
|
168
|
-
case J.Kind.AssignmentOperation:
|
|
169
|
-
case JS.Kind.AssignmentOperation:
|
|
170
|
-
return (parent as J.Assignment).variable === node;
|
|
171
|
-
case JS.Kind.Delete:
|
|
172
|
-
return (parent as JS.Delete).expression === node;
|
|
173
|
-
case J.Kind.Unary:
|
|
174
|
-
return [J.Unary.Type.PreIncrement, J.Unary.Type.PreDecrement, J.Unary.Type.PostIncrement,
|
|
175
|
-
J.Unary.Type.PostDecrement].includes((parent as J.Unary).operator.element);
|
|
176
|
-
default:
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
165
|
+
return isAssignmentTarget(cursor) || parent?.kind === JS.Kind.Delete && (parent as JS.Delete).expression === cursor.value;
|
|
179
166
|
}
|
|
180
167
|
|
|
181
168
|
/** Whether an `install()` options literal sets `environment: 'browser'`. */
|
|
182
169
|
export function isBrowserInstall(arg: J | undefined): boolean {
|
|
183
|
-
if (arg
|
|
184
|
-
return (
|
|
170
|
+
if (!arg || !isObjectLiteral(arg)) return false;
|
|
171
|
+
return (arg.body?.statements ?? []).some(s => s.element.kind === JS.Kind.PropertyAssignment &&
|
|
185
172
|
propertyName(s.element as JS.PropertyAssignment) === 'environment' &&
|
|
186
173
|
stringLiteral((s.element as JS.PropertyAssignment).initializer) === 'browser');
|
|
187
174
|
}
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
|
|
5
5
|
*/
|
|
6
|
-
import {ExecutionContext,
|
|
7
|
-
import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
|
|
6
|
+
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
7
|
+
import {JavaScriptVisitor, JS, withStringValue} from "@openrewrite/rewrite/javascript";
|
|
8
8
|
import {J} from "@openrewrite/rewrite/java";
|
|
9
|
-
import {Draft} from "mutative";
|
|
10
9
|
|
|
11
10
|
export class ReplaceStreamInternalModules extends Recipe {
|
|
12
11
|
readonly name = "org.openrewrite.node.migrate.stream.replace-internal-modules"
|
|
@@ -54,11 +53,7 @@ export class ReplaceStreamInternalModules extends Recipe {
|
|
|
54
53
|
|
|
55
54
|
if (this.deprecatedModules.has(moduleName)) {
|
|
56
55
|
const replacement = this.getReplacement(moduleName);
|
|
57
|
-
return
|
|
58
|
-
const litDraft = (draft as Draft<JS.Import>).moduleSpecifier!.element as Draft<J.Literal>;
|
|
59
|
-
litDraft.value = replacement;
|
|
60
|
-
litDraft.valueSource = `'${replacement}'`;
|
|
61
|
-
});
|
|
56
|
+
return {...imp, moduleSpecifier: {...imp.moduleSpecifier, element: withStringValue(literal, replacement)}} as JS.Import;
|
|
62
57
|
}
|
|
63
58
|
}
|
|
64
59
|
|
|
@@ -84,11 +79,7 @@ export class ReplaceStreamInternalModules extends Recipe {
|
|
|
84
79
|
|
|
85
80
|
if (this.deprecatedModules.has(moduleName)) {
|
|
86
81
|
const replacement = this.getReplacement(moduleName);
|
|
87
|
-
return
|
|
88
|
-
const litDraft = (draft as Draft<J.MethodInvocation>).arguments.elements[0].element as Draft<J.Literal>;
|
|
89
|
-
litDraft.value = replacement;
|
|
90
|
-
litDraft.valueSource = `'${replacement}'`;
|
|
91
|
-
});
|
|
82
|
+
return {...m, arguments: {...m.arguments, elements: [{...args[0], element: withStringValue(literal, replacement)}]}} as J.MethodInvocation;
|
|
92
83
|
}
|
|
93
84
|
}
|
|
94
85
|
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
|
|
5
5
|
*/
|
|
6
|
-
import {ExecutionContext,
|
|
7
|
-
import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
|
|
6
|
+
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
7
|
+
import {JavaScriptVisitor, JS, withStringValue} from "@openrewrite/rewrite/javascript";
|
|
8
8
|
import {J} from "@openrewrite/rewrite/java";
|
|
9
|
-
import {Draft} from "mutative";
|
|
10
9
|
|
|
11
10
|
export class ReplaceTlsInternalModules extends Recipe {
|
|
12
11
|
readonly name = "org.openrewrite.node.migrate.tls.replace-internal-modules"
|
|
@@ -46,11 +45,7 @@ export class ReplaceTlsInternalModules extends Recipe {
|
|
|
46
45
|
|
|
47
46
|
if (this.deprecatedModules.has(moduleName)) {
|
|
48
47
|
const replacement = this.getReplacement(moduleName);
|
|
49
|
-
return
|
|
50
|
-
const litDraft = (draft as Draft<JS.Import>).moduleSpecifier!.element as Draft<J.Literal>;
|
|
51
|
-
litDraft.value = replacement;
|
|
52
|
-
litDraft.valueSource = `'${replacement}'`;
|
|
53
|
-
});
|
|
48
|
+
return {...imp, moduleSpecifier: {...imp.moduleSpecifier, element: withStringValue(literal, replacement)}} as JS.Import;
|
|
54
49
|
}
|
|
55
50
|
}
|
|
56
51
|
|
|
@@ -76,11 +71,7 @@ export class ReplaceTlsInternalModules extends Recipe {
|
|
|
76
71
|
|
|
77
72
|
if (this.deprecatedModules.has(moduleName)) {
|
|
78
73
|
const replacement = this.getReplacement(moduleName);
|
|
79
|
-
return
|
|
80
|
-
const litDraft = (draft as Draft<J.MethodInvocation>).arguments.elements[0].element as Draft<J.Literal>;
|
|
81
|
-
litDraft.value = replacement;
|
|
82
|
-
litDraft.valueSource = `'${replacement}'`;
|
|
83
|
-
});
|
|
74
|
+
return {...m, arguments: {...m.arguments, elements: [{...args[0], element: withStringValue(literal, replacement)}]}} as J.MethodInvocation;
|
|
84
75
|
}
|
|
85
76
|
}
|
|
86
77
|
|