@openrewrite/recipes-nodejs 0.34.0-20251119-123234 → 0.34.0-20251119-133952
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.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/migrate/util-extend.d.ts +9 -0
- package/dist/migrate/util-extend.d.ts.map +1 -0
- package/dist/migrate/util-extend.js +54 -0
- package/dist/migrate/util-extend.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/migrate/util-extend.ts +43 -0
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAOpD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,cAAc,QAOhD"}
|
package/dist/index.js
CHANGED
|
@@ -6,11 +6,13 @@ const buffer_slice_1 = require("./migrate/buffer-slice");
|
|
|
6
6
|
const process_features_tls_1 = require("./migrate/process-features-tls");
|
|
7
7
|
const crypto_constructors_1 = require("./migrate/crypto-constructors");
|
|
8
8
|
const util_log_1 = require("./migrate/util-log");
|
|
9
|
+
const util_extend_1 = require("./migrate/util-extend");
|
|
9
10
|
function activate(registry) {
|
|
10
11
|
registry.register(util_type_checking_1.UseNativeTypeCheckingMethods);
|
|
11
12
|
registry.register(buffer_slice_1.ReplaceDeprecatedBufferSlice);
|
|
12
13
|
registry.register(process_features_tls_1.RemoveUsageOfProcessFeaturesTlsConstants);
|
|
13
14
|
registry.register(crypto_constructors_1.ReplaceCryptoConstructors);
|
|
14
15
|
registry.register(util_log_1.ReplaceUtilLog);
|
|
16
|
+
registry.register(util_extend_1.ReplaceUtilExtend);
|
|
15
17
|
}
|
|
16
18
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AASA,4BAOC;AAhBD,qEAA0E;AAC1E,yDAAoE;AAEpE,yEAAwF;AACxF,uEAAwE;AACxE,iDAAkD;AAClD,uDAAwD;AAGxD,SAAgB,QAAQ,CAAC,QAAwB;IAC7C,QAAQ,CAAC,QAAQ,CAAC,iDAA4B,CAAC,CAAC;IAChD,QAAQ,CAAC,QAAQ,CAAC,2CAA4B,CAAC,CAAC;IAChD,QAAQ,CAAC,QAAQ,CAAC,+DAAwC,CAAC,CAAC;IAC5D,QAAQ,CAAC,QAAQ,CAAC,+CAAyB,CAAC,CAAC;IAC7C,QAAQ,CAAC,QAAQ,CAAC,yBAAc,CAAC,CAAC;IAClC,QAAQ,CAAC,QAAQ,CAAC,+BAAiB,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class ReplaceUtilExtend extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.node.migrate.util.replace-util-extend";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly tags: string[];
|
|
7
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=util-extend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util-extend.d.ts","sourceRoot":"","sources":["../../src/migrate/util-extend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAalF,qBAAa,iBAAkB,SAAQ,MAAM;IACzC,QAAQ,CAAC,IAAI,2DAA0D;IACvE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAgE;IAC5F,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAyI;IACrK,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAe;IAEhC,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAuB9D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ReplaceUtilExtend = void 0;
|
|
13
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
14
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
15
|
+
class ReplaceUtilExtend extends rewrite_1.Recipe {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.name = "org.openrewrite.node.migrate.util.replace-util-extend";
|
|
19
|
+
this.displayName = "Replace deprecated `util._extend()` with `Object.assign()`";
|
|
20
|
+
this.description = "Replace deprecated `util._extend(target, source)` calls with `Object.assign(target, source)` which preserves the mutation behavior.";
|
|
21
|
+
this.tags = ["DEP0060"];
|
|
22
|
+
}
|
|
23
|
+
editor() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
return (0, rewrite_1.check)((0, javascript_1.usesMethod)("util _extend(..)"), new class extends javascript_1.JavaScriptVisitor {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.utilExtendMatcher = new javascript_1.MethodMatcher("util _extend(..)");
|
|
29
|
+
}
|
|
30
|
+
visitMethodInvocation(m, p) {
|
|
31
|
+
const _super = Object.create(null, {
|
|
32
|
+
visitMethodInvocation: { get: () => super.visitMethodInvocation }
|
|
33
|
+
});
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const method = yield _super.visitMethodInvocation.call(this, m, p);
|
|
36
|
+
if (this.utilExtendMatcher.matches(method.methodType)) {
|
|
37
|
+
(0, javascript_1.maybeRemoveImport)(this, "util");
|
|
38
|
+
(0, javascript_1.maybeRemoveImport)(this, "util", "_extend");
|
|
39
|
+
const args = method.arguments.elements;
|
|
40
|
+
if (args.length === 2) {
|
|
41
|
+
const target = args[0].element;
|
|
42
|
+
const source = args[1].element;
|
|
43
|
+
return yield (0, javascript_1.template) `Object.assign(${target}, ${source})`.apply(this.cursor, method);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return method;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.ReplaceUtilExtend = ReplaceUtilExtend;
|
|
54
|
+
//# sourceMappingURL=util-extend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util-extend.js","sourceRoot":"","sources":["../../src/migrate/util-extend.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAkF;AAClF,gEAMyC;AAMzC,MAAa,iBAAkB,SAAQ,gBAAM;IAA7C;;QACa,SAAI,GAAG,uDAAuD,CAAA;QAC9D,gBAAW,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
{
|
|
2
2
|
"name": "@openrewrite/recipes-nodejs",
|
|
3
|
-
"version": "0.34.0-20251119-
|
|
3
|
+
"version": "0.34.0-20251119-133952",
|
|
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",
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {RecipeRegistry} from "@openrewrite/rewrite";
|
|
|
4
4
|
import {RemoveUsageOfProcessFeaturesTlsConstants} from "./migrate/process-features-tls";
|
|
5
5
|
import {ReplaceCryptoConstructors} from "./migrate/crypto-constructors";
|
|
6
6
|
import {ReplaceUtilLog} from "./migrate/util-log";
|
|
7
|
+
import {ReplaceUtilExtend} from "./migrate/util-extend";
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
export function activate(registry: RecipeRegistry) {
|
|
@@ -12,4 +13,5 @@ export function activate(registry: RecipeRegistry) {
|
|
|
12
13
|
registry.register(RemoveUsageOfProcessFeaturesTlsConstants);
|
|
13
14
|
registry.register(ReplaceCryptoConstructors);
|
|
14
15
|
registry.register(ReplaceUtilLog);
|
|
16
|
+
registry.register(ReplaceUtilExtend);
|
|
15
17
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {check, ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
+
import {
|
|
3
|
+
JavaScriptVisitor,
|
|
4
|
+
maybeRemoveImport,
|
|
5
|
+
MethodMatcher,
|
|
6
|
+
template,
|
|
7
|
+
usesMethod
|
|
8
|
+
} from "@openrewrite/rewrite/javascript";
|
|
9
|
+
import {J} from "@openrewrite/rewrite/java";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Replace deprecated util._extend() with Object.assign()
|
|
13
|
+
*/
|
|
14
|
+
export class ReplaceUtilExtend extends Recipe {
|
|
15
|
+
readonly name = "org.openrewrite.node.migrate.util.replace-util-extend"
|
|
16
|
+
readonly displayName: string = "Replace deprecated `util._extend()` with `Object.assign()`";
|
|
17
|
+
readonly description: string = "Replace deprecated `util._extend(target, source)` calls with `Object.assign(target, source)` which preserves the mutation behavior.";
|
|
18
|
+
readonly tags: string[] = ["DEP0060"];
|
|
19
|
+
|
|
20
|
+
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
21
|
+
return check(usesMethod("util _extend(..)"), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
22
|
+
utilExtendMatcher = new MethodMatcher("util _extend(..)");
|
|
23
|
+
|
|
24
|
+
protected async visitMethodInvocation(m: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
|
|
25
|
+
const method = await super.visitMethodInvocation(m, p) as J.MethodInvocation;
|
|
26
|
+
if (this.utilExtendMatcher.matches(method.methodType)) {
|
|
27
|
+
maybeRemoveImport(this, "util");
|
|
28
|
+
maybeRemoveImport(this, "util", "_extend");
|
|
29
|
+
|
|
30
|
+
const args = method.arguments.elements;
|
|
31
|
+
|
|
32
|
+
// util._extend requires exactly 2 arguments
|
|
33
|
+
if (args.length === 2) {
|
|
34
|
+
const target = args[0].element;
|
|
35
|
+
const source = args[1].element;
|
|
36
|
+
return await template`Object.assign(${target}, ${source})`.apply(this.cursor, method);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return method;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|