@openrewrite/recipes-nodejs 0.34.0-20251119-114110 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAKpD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,cAAc,QAKhD"}
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
@@ -5,10 +5,14 @@ const util_type_checking_1 = require("./migrate/util-type-checking");
5
5
  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
+ const util_log_1 = require("./migrate/util-log");
9
+ const util_extend_1 = require("./migrate/util-extend");
8
10
  function activate(registry) {
9
11
  registry.register(util_type_checking_1.UseNativeTypeCheckingMethods);
10
12
  registry.register(buffer_slice_1.ReplaceDeprecatedBufferSlice);
11
13
  registry.register(process_features_tls_1.RemoveUsageOfProcessFeaturesTlsConstants);
12
14
  registry.register(crypto_constructors_1.ReplaceCryptoConstructors);
15
+ registry.register(util_log_1.ReplaceUtilLog);
16
+ registry.register(util_extend_1.ReplaceUtilExtend);
13
17
  }
14
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":";;AAOA,4BAKC;AAZD,qEAA0E;AAC1E,yDAAoE;AAEpE,yEAAwF;AACxF,uEAAwE;AAGxE,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;AACjD,CAAC"}
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,GAAW,4DAA4D,CAAC;QACnF,gBAAW,GAAW,qIAAqI,CAAC;QAC5J,SAAI,GAAa,CAAC,SAAS,CAAC,CAAC;IAyB1C,CAAC;IAvBS,MAAM;;YACR,OAAO,IAAA,eAAK,EAAC,IAAA,uBAAU,EAAC,kBAAkB,CAAC,EAAE,IAAI,KAAM,SAAQ,8BAAmC;gBAAjD;;oBAC7C,sBAAiB,GAAG,IAAI,0BAAa,CAAC,kBAAkB,CAAC,CAAC;gBAmB9D,CAAC;gBAjBmB,qBAAqB,CAAC,CAAqB,EAAE,CAAmB;;;;;wBAC5E,MAAM,MAAM,GAAG,MAAM,OAAM,qBAAqB,YAAC,CAAC,EAAE,CAAC,CAAuB,CAAC;wBAC7E,IAAI,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;4BACpD,IAAA,8BAAiB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;4BAChC,IAAA,8BAAiB,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;4BAE3C,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;4BAGvC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gCACpB,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;gCAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;gCAC/B,OAAO,MAAM,IAAA,qBAAQ,EAAA,iBAAiB,MAAM,KAAK,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;4BAC1F,CAAC;wBACL,CAAC;wBACD,OAAO,MAAM,CAAC;oBAClB,CAAC;iBAAA;aACJ,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AA7BD,8CA6BC"}
@@ -0,0 +1,9 @@
1
+ import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
2
+ export declare class ReplaceUtilLog extends Recipe {
3
+ readonly name = "org.openrewrite.node.migrate.util.replace-util-log";
4
+ readonly displayName: string;
5
+ readonly description: string;
6
+ readonly tags: string[];
7
+ editor(): Promise<TreeVisitor<any, ExecutionContext>>;
8
+ }
9
+ //# sourceMappingURL=util-log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util-log.d.ts","sourceRoot":"","sources":["../../src/migrate/util-log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAclF,qBAAa,cAAe,SAAQ,MAAM;IACtC,QAAQ,CAAC,IAAI,wDAAuD;IACpE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA0D;IACtF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAuI;IACnK,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAe;IAIhC,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAgB9D"}
@@ -0,0 +1,50 @@
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.ReplaceUtilLog = void 0;
13
+ const rewrite_1 = require("@openrewrite/rewrite");
14
+ const javascript_1 = require("@openrewrite/rewrite/javascript");
15
+ class ReplaceUtilLog extends rewrite_1.Recipe {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.name = "org.openrewrite.node.migrate.util.replace-util-log";
19
+ this.displayName = "Replace deprecated `util.log()` with `console.log()`";
20
+ this.description = "Replace deprecated `util.log()` calls with `console.log()`. Note: `util.log()` included timestamps, but `console.log()` does not.";
21
+ this.tags = ["DEP0059"];
22
+ }
23
+ editor() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ return (0, rewrite_1.check)((0, javascript_1.usesMethod)("util log(..)"), new class extends javascript_1.JavaScriptVisitor {
26
+ constructor() {
27
+ super(...arguments);
28
+ this.utilLogMatcher = new javascript_1.MethodMatcher("util log(..)");
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.utilLogMatcher.matches(method.methodType)) {
37
+ (0, javascript_1.maybeRemoveImport)(this, "util");
38
+ (0, javascript_1.maybeRemoveImport)(this, "util", "log");
39
+ const args = method.arguments.elements;
40
+ return yield (0, javascript_1.template) `console.log(${args})`.apply(this.cursor, method);
41
+ }
42
+ return method;
43
+ });
44
+ }
45
+ });
46
+ });
47
+ }
48
+ }
49
+ exports.ReplaceUtilLog = ReplaceUtilLog;
50
+ //# sourceMappingURL=util-log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util-log.js","sourceRoot":"","sources":["../../src/migrate/util-log.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAkF;AAClF,gEAOyC;AAMzC,MAAa,cAAe,SAAQ,gBAAM;IAA1C;;QACa,SAAI,GAAG,oDAAoD,CAAA;QAC3D,gBAAW,GAAW,sDAAsD,CAAC;QAC7E,gBAAW,GAAW,mIAAmI,CAAC;QAC1J,SAAI,GAAa,CAAC,SAAS,CAAC,CAAC;IAoB1C,CAAC;IAhBS,MAAM;;YACR,OAAO,IAAA,eAAK,EAAC,IAAA,uBAAU,EAAC,cAAc,CAAC,EAAE,IAAI,KAAM,SAAQ,8BAAmC;gBAAjD;;oBACzC,mBAAc,GAAG,IAAI,0BAAa,CAAC,cAAc,CAAC,CAAC;gBAYvD,CAAC;gBAVmB,qBAAqB,CAAC,CAAqB,EAAE,CAAmB;;;;;wBAC5E,MAAM,MAAM,GAAG,MAAM,OAAM,qBAAqB,YAAC,CAAC,EAAE,CAAC,CAAuB,CAAC;wBAC7E,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;4BACjD,IAAA,8BAAiB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;4BAChC,IAAA,8BAAiB,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;4BACvC,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;4BACvC,OAAO,MAAM,IAAA,qBAAQ,EAAA,eAAe,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;wBAC3E,CAAC;wBACD,OAAO,MAAM,CAAC;oBAClB,CAAC;iBAAA;aACJ,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AAxBD,wCAwBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openrewrite/recipes-nodejs",
3
- "version": "0.34.0-20251119-114110",
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
@@ -3,6 +3,8 @@ import {ReplaceDeprecatedBufferSlice} from "./migrate/buffer-slice";
3
3
  import {RecipeRegistry} from "@openrewrite/rewrite";
4
4
  import {RemoveUsageOfProcessFeaturesTlsConstants} from "./migrate/process-features-tls";
5
5
  import {ReplaceCryptoConstructors} from "./migrate/crypto-constructors";
6
+ import {ReplaceUtilLog} from "./migrate/util-log";
7
+ import {ReplaceUtilExtend} from "./migrate/util-extend";
6
8
 
7
9
 
8
10
  export function activate(registry: RecipeRegistry) {
@@ -10,4 +12,6 @@ export function activate(registry: RecipeRegistry) {
10
12
  registry.register(ReplaceDeprecatedBufferSlice);
11
13
  registry.register(RemoveUsageOfProcessFeaturesTlsConstants);
12
14
  registry.register(ReplaceCryptoConstructors);
15
+ registry.register(ReplaceUtilLog);
16
+ registry.register(ReplaceUtilExtend);
13
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
+ }
@@ -0,0 +1,39 @@
1
+ import {check, ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
2
+ import {
3
+ JavaScriptVisitor,
4
+ maybeAddImport,
5
+ maybeRemoveImport,
6
+ MethodMatcher,
7
+ template,
8
+ usesMethod
9
+ } from "@openrewrite/rewrite/javascript";
10
+ import {J} from "@openrewrite/rewrite/java";
11
+
12
+ /**
13
+ * Replace deprecated util.log() with console.log()
14
+ */
15
+ export class ReplaceUtilLog extends Recipe {
16
+ readonly name = "org.openrewrite.node.migrate.util.replace-util-log"
17
+ readonly displayName: string = "Replace deprecated `util.log()` with `console.log()`";
18
+ readonly description: string = "Replace deprecated `util.log()` calls with `console.log()`. Note: `util.log()` included timestamps, but `console.log()` does not.";
19
+ readonly tags: string[] = ["DEP0059"];
20
+
21
+ // TODO possibly take some arguments on what should the replacement be, console.log is a reasonable default,
22
+ // but likely not the only viable option.
23
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
24
+ return check(usesMethod("util log(..)"), new class extends JavaScriptVisitor<ExecutionContext> {
25
+ utilLogMatcher = new MethodMatcher("util log(..)");
26
+
27
+ protected async visitMethodInvocation(m: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
28
+ const method = await super.visitMethodInvocation(m, p) as J.MethodInvocation;
29
+ if (this.utilLogMatcher.matches(method.methodType)) {
30
+ maybeRemoveImport(this, "util");
31
+ maybeRemoveImport(this, "util", "log");
32
+ const args = method.arguments.elements;
33
+ return await template`console.log(${args})`.apply(this.cursor, method);
34
+ }
35
+ return method;
36
+ }
37
+ });
38
+ }
39
+ }