@openrewrite/recipes-nodejs 0.35.0-20251201-124457 → 0.35.0-20251201-142102

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;AAepD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,cAAc,QAehD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAoBpD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,cAAc,QAkBhD"}
package/dist/index.js CHANGED
@@ -15,6 +15,9 @@ const process_exit_code_1 = require("./migrate/process-exit-code");
15
15
  const dirent_path_1 = require("./migrate/dirent-path");
16
16
  const util_types_wasm_1 = require("./migrate/util-types-wasm");
17
17
  const zlib_bytes_read_1 = require("./migrate/zlib-bytes-read");
18
+ const fs_truncate_1 = require("./migrate/fs-truncate");
19
+ const upgrade_node_22_1 = require("./migrate/upgrade-node-22");
20
+ const upgrade_node_24_1 = require("./migrate/upgrade-node-24");
18
21
  function activate(registry) {
19
22
  registry.register(util_type_checking_1.UseNativeTypeCheckingMethods);
20
23
  registry.register(buffer_slice_1.ReplaceDeprecatedBufferSlice);
@@ -30,5 +33,8 @@ function activate(registry) {
30
33
  registry.register(dirent_path_1.ReplaceDirentPath);
31
34
  registry.register(util_types_wasm_1.ReplaceIsWebAssemblyCompiledModule);
32
35
  registry.register(zlib_bytes_read_1.ReplaceZlibBytesRead);
36
+ registry.register(fs_truncate_1.ReplaceFsTruncateWithFd);
37
+ registry.register(upgrade_node_22_1.UpgradeNode22);
38
+ registry.register(upgrade_node_24_1.UpgradeNode24);
33
39
  }
34
40
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHAN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aceFsTruncateWithFd extends Recipe {
3
+ readonly name = "org.openrewrite.node.migrate.fs.replace-fs-truncate-fd";
4
+ readonly displayName: string;
5
+ readonly description: string;
6
+ readonly tags: string[];
7
+ editor(): Promise<TreeVisitor<any, ExecutionContext>>;
8
+ }
9
+ //# sourceMappingURL=fs-truncate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-truncate.d.ts","sourceRoot":"","sources":["../../src/migrate/fs-truncate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAI3E,qBAAa,uBAAwB,SAAQ,MAAM;IAC/C,QAAQ,CAAC,IAAI,4DAA2D;IACxE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAsE;IAClG,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAwM;IACpO,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAe;IAEhC,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CA4B9D"}
@@ -0,0 +1,60 @@
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.ReplaceFsTruncateWithFd = void 0;
13
+ const rewrite_1 = require("@openrewrite/rewrite");
14
+ const javascript_1 = require("@openrewrite/rewrite/javascript");
15
+ const java_1 = require("@openrewrite/rewrite/java");
16
+ class ReplaceFsTruncateWithFd extends rewrite_1.Recipe {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.name = "org.openrewrite.node.migrate.fs.replace-fs-truncate-fd";
20
+ this.displayName = "Replace `fs.truncate()` with file descriptor to `fs.ftruncate()`";
21
+ this.description = "Replace deprecated `fs.truncate(fd, ...)` and `fs.truncateSync(fd, ...)` calls with `fs.ftruncate(fd, ...)` and `fs.ftruncateSync(fd, ...)` when the first argument is a file descriptor (number).";
22
+ this.tags = ["DEP0081"];
23
+ }
24
+ editor() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ return new class extends javascript_1.JavaScriptVisitor {
27
+ constructor() {
28
+ super(...arguments);
29
+ this.truncate = new javascript_1.MethodMatcher("fs truncate(..)");
30
+ this.truncateSync = new javascript_1.MethodMatcher("fs truncateSync(..)");
31
+ }
32
+ visitMethodInvocation(method, p) {
33
+ const _super = Object.create(null, {
34
+ visitMethodInvocation: { get: () => super.visitMethodInvocation }
35
+ });
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const m = yield _super.visitMethodInvocation.call(this, method, p);
38
+ const args = m.arguments.elements;
39
+ if (args.length < 1)
40
+ return m;
41
+ const firstArg = args[0].element;
42
+ if (firstArg.type !== java_1.Type.Primitive.Double)
43
+ return m;
44
+ if (this.truncate.matches(m.methodType)) {
45
+ const select = m.select.element;
46
+ return yield (0, javascript_1.template) `${select}.ftruncate(${args})`.apply(m, this.cursor);
47
+ }
48
+ if (this.truncateSync.matches(m.methodType)) {
49
+ const select = m.select.element;
50
+ return yield (0, javascript_1.template) `${select}.ftruncateSync(${args})`.apply(m, this.cursor);
51
+ }
52
+ return m;
53
+ });
54
+ }
55
+ };
56
+ });
57
+ }
58
+ }
59
+ exports.ReplaceFsTruncateWithFd = ReplaceFsTruncateWithFd;
60
+ //# sourceMappingURL=fs-truncate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-truncate.js","sourceRoot":"","sources":["../../src/migrate/fs-truncate.ts"],"names":[],"mappings":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,CAAC,UAAU,CAAC,EAAE,CAAC;4BAC1C,MAAM,MAAM,GAAG,CAAC,CAAC,MAAO,CAAC,OAAO,CAAC;4BACjC,OAAO,MAAM,IAAA,qBAAQ,EAAA,GAAG,MAAM,kBAAkB,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;wBAClF,CAAC;wBAED,OAAO,CAAC,CAAC;oBACb,CAAC;iBAAA;aACJ,CAAC;QACN,CAAC;KAAA;CACJ;AAlCD,0DAkCC"}
@@ -0,0 +1,8 @@
1
+ import { Recipe } from "@openrewrite/rewrite";
2
+ export declare class UpgradeNode22 extends Recipe {
3
+ readonly name = "org.openrewrite.node.migrate.upgrade-node-22";
4
+ readonly displayName = "Upgrade to Node.js 22";
5
+ readonly description = "Migrate deprecated APIs for Node.js 22 compatibility. Addresses Node 22 runtime deprecations and deprecations from earlier versions.";
6
+ recipeList(): Promise<Recipe[]>;
7
+ }
8
+ //# sourceMappingURL=upgrade-node-22.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-node-22.d.ts","sourceRoot":"","sources":["../../src/migrate/upgrade-node-22.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AA8B5C,qBAAa,aAAc,SAAQ,MAAM;IACrC,QAAQ,CAAC,IAAI,kDAAkD;IAC/D,QAAQ,CAAC,WAAW,2BAA2B;IAC/C,QAAQ,CAAC,WAAW,0IAA0I;IAExJ,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAOxC"}
@@ -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.UpgradeNode22 = void 0;
13
+ const rewrite_1 = require("@openrewrite/rewrite");
14
+ const promisify_on_promise_1 = require("./promisify-on-promise");
15
+ const util_types_wasm_1 = require("./util-types-wasm");
16
+ const crypto_constructors_1 = require("./crypto-constructors");
17
+ const process_features_tls_1 = require("./process-features-tls");
18
+ const util_type_checking_1 = require("./util-type-checking");
19
+ const util_extend_1 = require("./util-extend");
20
+ const buffer_slice_1 = require("./buffer-slice");
21
+ const process_exit_code_1 = require("./process-exit-code");
22
+ const node22EolDeprecations = [
23
+ new util_types_wasm_1.ReplaceIsWebAssemblyCompiledModule(),
24
+ ];
25
+ const node22RuntimeDeprecations = [
26
+ new util_type_checking_1.UseNativeTypeCheckingMethods(),
27
+ new util_extend_1.ReplaceUtilExtend(),
28
+ new crypto_constructors_1.ReplaceCryptoConstructors(),
29
+ ];
30
+ const olderDeprecations = [
31
+ new process_exit_code_1.AvoidImplicitCoercionOfExitCode(),
32
+ new buffer_slice_1.ReplaceDeprecatedBufferSlice(),
33
+ new process_features_tls_1.RemoveUsageOfProcessFeaturesTlsConstants(),
34
+ new promisify_on_promise_1.RemovePromisifyOnPromise(),
35
+ ];
36
+ class UpgradeNode22 extends rewrite_1.Recipe {
37
+ constructor() {
38
+ super(...arguments);
39
+ this.name = "org.openrewrite.node.migrate.upgrade-node-22";
40
+ this.displayName = "Upgrade to Node.js 22";
41
+ this.description = "Migrate deprecated APIs for Node.js 22 compatibility. Addresses Node 22 runtime deprecations and deprecations from earlier versions.";
42
+ }
43
+ recipeList() {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ return [
46
+ ...node22EolDeprecations,
47
+ ...node22RuntimeDeprecations,
48
+ ...olderDeprecations,
49
+ ];
50
+ });
51
+ }
52
+ }
53
+ exports.UpgradeNode22 = UpgradeNode22;
54
+ //# sourceMappingURL=upgrade-node-22.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-node-22.js","sourceRoot":"","sources":["../../src/migrate/upgrade-node-22.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA4C;AAC5C,iEAAgE;AAChE,uDAAqE;AACrE,+DAAgE;AAChE,iEAAgF;AAChF,6DAAkE;AAClE,+CAAgD;AAChD,iDAA4D;AAC5D,2DAAoE;AAGpE,MAAM,qBAAqB,GAAa;IACpC,IAAI,oDAAkC,EAAE;CAC3C,CAAC;AAGF,MAAM,yBAAyB,GAAa;IACxC,IAAI,iDAA4B,EAAE;IAClC,IAAI,+BAAiB,EAAE;IACvB,IAAI,+CAAyB,EAAE;CAClC,CAAC;AAGF,MAAM,iBAAiB,GAAa;IAChC,IAAI,mDAA+B,EAAE;IACrC,IAAI,2CAA4B,EAAE;IAClC,IAAI,+DAAwC,EAAE;IAC9C,IAAI,+CAAwB,EAAE;CACjC,CAAC;AAEF,MAAa,aAAc,SAAQ,gBAAM;IAAzC;;QACa,SAAI,GAAG,8CAA8C,CAAC;QACtD,gBAAW,GAAG,uBAAuB,CAAC;QACtC,gBAAW,GAAG,sIAAsI,CAAC;IASlK,CAAC;IAPS,UAAU;;YACZ,OAAO;gBACH,GAAG,qBAAqB;gBACxB,GAAG,yBAAyB;gBAC5B,GAAG,iBAAiB;aACvB,CAAC;QACN,CAAC;KAAA;CACJ;AAZD,sCAYC"}
@@ -0,0 +1,8 @@
1
+ import { Recipe } from "@openrewrite/rewrite";
2
+ export declare class UpgradeNode24 extends Recipe {
3
+ readonly name = "org.openrewrite.node.migrate.upgrade-node-24";
4
+ readonly displayName = "Upgrade to Node.js 24";
5
+ readonly description = "Migrate deprecated APIs for Node.js 24 compatibility. Includes all migrations from Node.js 22, plus Node 23 and Node 24 deprecations.";
6
+ recipeList(): Promise<Recipe[]>;
7
+ }
8
+ //# sourceMappingURL=upgrade-node-24.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-node-24.d.ts","sourceRoot":"","sources":["../../src/migrate/upgrade-node-24.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAqB5C,qBAAa,aAAc,SAAQ,MAAM;IACrC,QAAQ,CAAC,IAAI,kDAAkD;IAC/D,QAAQ,CAAC,WAAW,2BAA2B;IAC/C,QAAQ,CAAC,WAAW,2IAA2I;IAEzJ,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAOxC"}
@@ -0,0 +1,47 @@
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.UpgradeNode24 = void 0;
13
+ const rewrite_1 = require("@openrewrite/rewrite");
14
+ const util_log_1 = require("./util-log");
15
+ const zlib_bytes_read_1 = require("./zlib-bytes-read");
16
+ const crypto_fips_1 = require("./crypto-fips");
17
+ const dirent_path_1 = require("./dirent-path");
18
+ const fs_truncate_1 = require("./fs-truncate");
19
+ const upgrade_node_22_1 = require("./upgrade-node-22");
20
+ const node24EolDeprecations = [
21
+ new util_log_1.ReplaceUtilLog(),
22
+ new zlib_bytes_read_1.ReplaceZlibBytesRead(),
23
+ new fs_truncate_1.ReplaceFsTruncateWithFd(),
24
+ new dirent_path_1.ReplaceDirentPath(),
25
+ ];
26
+ const node24RuntimeDeprecations = [
27
+ new crypto_fips_1.ReplaceCryptoFips(),
28
+ ];
29
+ class UpgradeNode24 extends rewrite_1.Recipe {
30
+ constructor() {
31
+ super(...arguments);
32
+ this.name = "org.openrewrite.node.migrate.upgrade-node-24";
33
+ this.displayName = "Upgrade to Node.js 24";
34
+ this.description = "Migrate deprecated APIs for Node.js 24 compatibility. Includes all migrations from Node.js 22, plus Node 23 and Node 24 deprecations.";
35
+ }
36
+ recipeList() {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ return [
39
+ new upgrade_node_22_1.UpgradeNode22(),
40
+ ...node24EolDeprecations,
41
+ ...node24RuntimeDeprecations,
42
+ ];
43
+ });
44
+ }
45
+ }
46
+ exports.UpgradeNode24 = UpgradeNode24;
47
+ //# sourceMappingURL=upgrade-node-24.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-node-24.js","sourceRoot":"","sources":["../../src/migrate/upgrade-node-24.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA4C;AAC5C,yCAA0C;AAC1C,uDAAuD;AACvD,+CAAgD;AAChD,+CAAgD;AAChD,+CAAsD;AACtD,uDAAgD;AAGhD,MAAM,qBAAqB,GAAa;IACpC,IAAI,yBAAc,EAAE;IACpB,IAAI,sCAAoB,EAAE;IAC1B,IAAI,qCAAuB,EAAE;IAC7B,IAAI,+BAAiB,EAAE;CAC1B,CAAC;AAGF,MAAM,yBAAyB,GAAa;IACxC,IAAI,+BAAiB,EAAE;CAC1B,CAAC;AAEF,MAAa,aAAc,SAAQ,gBAAM;IAAzC;;QACa,SAAI,GAAG,8CAA8C,CAAC;QACtD,gBAAW,GAAG,uBAAuB,CAAC;QACtC,gBAAW,GAAG,uIAAuI,CAAC;IASnK,CAAC;IAPS,UAAU;;YACZ,OAAO;gBACH,IAAI,+BAAa,EAAE;gBACnB,GAAG,qBAAqB;gBACxB,GAAG,yBAAyB;aAC/B,CAAC;QACN,CAAC;KAAA;CACJ;AAZD,sCAYC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openrewrite/recipes-nodejs",
3
- "version": "0.35.0-20251201-124457",
3
+ "version": "0.35.0-20251201-142102",
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
@@ -1,6 +1,6 @@
1
+ import {RecipeRegistry} from "@openrewrite/rewrite";
1
2
  import {UseNativeTypeCheckingMethods} from "./migrate/util-type-checking";
2
3
  import {ReplaceDeprecatedBufferSlice} from "./migrate/buffer-slice";
3
- 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";
@@ -13,6 +13,9 @@ import {AvoidImplicitCoercionOfExitCode} from "./migrate/process-exit-code";
13
13
  import {ReplaceDirentPath} from "./migrate/dirent-path";
14
14
  import {ReplaceIsWebAssemblyCompiledModule} from "./migrate/util-types-wasm";
15
15
  import {ReplaceZlibBytesRead} from "./migrate/zlib-bytes-read";
16
+ import {ReplaceFsTruncateWithFd} from "./migrate/fs-truncate";
17
+ import {UpgradeNode22} from "./migrate/upgrade-node-22";
18
+ import {UpgradeNode24} from "./migrate/upgrade-node-24";
16
19
 
17
20
 
18
21
  export function activate(registry: RecipeRegistry) {
@@ -30,4 +33,7 @@ export function activate(registry: RecipeRegistry) {
30
33
  registry.register(ReplaceDirentPath);
31
34
  registry.register(ReplaceIsWebAssemblyCompiledModule);
32
35
  registry.register(ReplaceZlibBytesRead);
36
+ registry.register(ReplaceFsTruncateWithFd);
37
+ registry.register(UpgradeNode22);
38
+ registry.register(UpgradeNode24);
33
39
  }
@@ -0,0 +1,39 @@
1
+ import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
2
+ import {JavaScriptVisitor, MethodMatcher, template} from "@openrewrite/rewrite/javascript";
3
+ import {J, Type} from "@openrewrite/rewrite/java";
4
+
5
+ export class ReplaceFsTruncateWithFd extends Recipe {
6
+ readonly name = "org.openrewrite.node.migrate.fs.replace-fs-truncate-fd"
7
+ readonly displayName: string = "Replace `fs.truncate()` with file descriptor to `fs.ftruncate()`";
8
+ readonly description: string = "Replace deprecated `fs.truncate(fd, ...)` and `fs.truncateSync(fd, ...)` calls with `fs.ftruncate(fd, ...)` and `fs.ftruncateSync(fd, ...)` when the first argument is a file descriptor (number).";
9
+ readonly tags: string[] = ["DEP0081"];
10
+
11
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
12
+ return new class extends JavaScriptVisitor<ExecutionContext> {
13
+ truncate = new MethodMatcher("fs truncate(..)");
14
+ truncateSync = new MethodMatcher("fs truncateSync(..)");
15
+
16
+ protected async visitMethodInvocation(method: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
17
+ const m = await super.visitMethodInvocation(method, p) as J.MethodInvocation;
18
+
19
+ const args = m.arguments.elements;
20
+ if (args.length < 1) return m;
21
+
22
+ const firstArg = args[0].element;
23
+ if (firstArg.type !== Type.Primitive.Double) return m;
24
+
25
+ if (this.truncate.matches(m.methodType)) {
26
+ const select = m.select!.element;
27
+ return await template`${select}.ftruncate(${args})`.apply(m, this.cursor);
28
+ }
29
+
30
+ if (this.truncateSync.matches(m.methodType)) {
31
+ const select = m.select!.element;
32
+ return await template`${select}.ftruncateSync(${args})`.apply(m, this.cursor);
33
+ }
34
+
35
+ return m;
36
+ }
37
+ };
38
+ }
39
+ }
@@ -0,0 +1,43 @@
1
+ import {Recipe} from "@openrewrite/rewrite";
2
+ import {RemovePromisifyOnPromise} from "./promisify-on-promise";
3
+ import {ReplaceIsWebAssemblyCompiledModule} from "./util-types-wasm";
4
+ import {ReplaceCryptoConstructors} from "./crypto-constructors";
5
+ import {RemoveUsageOfProcessFeaturesTlsConstants} from "./process-features-tls";
6
+ import {UseNativeTypeCheckingMethods} from "./util-type-checking";
7
+ import {ReplaceUtilExtend} from "./util-extend";
8
+ import {ReplaceDeprecatedBufferSlice} from "./buffer-slice";
9
+ import {AvoidImplicitCoercionOfExitCode} from "./process-exit-code";
10
+
11
+ // Node 22 End-of-Life deprecations
12
+ const node22EolDeprecations: Recipe[] = [
13
+ new ReplaceIsWebAssemblyCompiledModule(), // DEP0177: util.types.isWebAssemblyCompiledModule (v21 EOL)
14
+ ];
15
+
16
+ // Node 22 Runtime deprecations (started in v22)
17
+ const node22RuntimeDeprecations: Recipe[] = [
18
+ new UseNativeTypeCheckingMethods(), // DEP0044: util.isArray (runtime in v22)
19
+ new ReplaceUtilExtend(), // DEP0060: util._extend (runtime in v22)
20
+ new ReplaceCryptoConstructors(), // DEP0179, DEP0181: Hash/Hmac constructors
21
+ ];
22
+
23
+ // Deprecations from earlier versions (incl. EOL before v22)
24
+ const olderDeprecations: Recipe[] = [
25
+ new AvoidImplicitCoercionOfExitCode(), // DEP0164: process.exit(code) (v20 EOL)
26
+ new ReplaceDeprecatedBufferSlice(), // DEP0158: buffer.slice (doc-only)
27
+ new RemoveUsageOfProcessFeaturesTlsConstants(), // DEP0189: process.features.tls_* (doc-only)
28
+ new RemovePromisifyOnPromise(), // DEP0174: promisify on promise (doc-only)
29
+ ];
30
+
31
+ export class UpgradeNode22 extends Recipe {
32
+ readonly name = "org.openrewrite.node.migrate.upgrade-node-22";
33
+ readonly displayName = "Upgrade to Node.js 22";
34
+ readonly description = "Migrate deprecated APIs for Node.js 22 compatibility. Addresses Node 22 runtime deprecations and deprecations from earlier versions.";
35
+
36
+ async recipeList(): Promise<Recipe[]> {
37
+ return [
38
+ ...node22EolDeprecations,
39
+ ...node22RuntimeDeprecations,
40
+ ...olderDeprecations,
41
+ ];
42
+ }
43
+ }
@@ -0,0 +1,34 @@
1
+ import {Recipe} from "@openrewrite/rewrite";
2
+ import {ReplaceUtilLog} from "./util-log";
3
+ import {ReplaceZlibBytesRead} from "./zlib-bytes-read";
4
+ import {ReplaceCryptoFips} from "./crypto-fips";
5
+ import {ReplaceDirentPath} from "./dirent-path";
6
+ import {ReplaceFsTruncateWithFd} from "./fs-truncate";
7
+ import {UpgradeNode22} from "./upgrade-node-22";
8
+
9
+ // Node 24 End-of-Life deprecations (includes v23 EOL)
10
+ const node24EolDeprecations: Recipe[] = [
11
+ new ReplaceUtilLog(), // DEP0059: util.log (v23 EOL)
12
+ new ReplaceZlibBytesRead(), // DEP0108: zlib.bytesRead (v23 EOL)
13
+ new ReplaceFsTruncateWithFd(), // DEP0081: fs.truncate() with fd (v24 EOL)
14
+ new ReplaceDirentPath(), // DEP0178: dirent.path (v24 EOL)
15
+ ];
16
+
17
+ // Node 24 Runtime deprecations (includes v23 runtime)
18
+ const node24RuntimeDeprecations: Recipe[] = [
19
+ new ReplaceCryptoFips(), // DEP0093: crypto.fips (v23 runtime)
20
+ ];
21
+
22
+ export class UpgradeNode24 extends Recipe {
23
+ readonly name = "org.openrewrite.node.migrate.upgrade-node-24";
24
+ readonly displayName = "Upgrade to Node.js 24";
25
+ readonly description = "Migrate deprecated APIs for Node.js 24 compatibility. Includes all migrations from Node.js 22, plus Node 23 and Node 24 deprecations.";
26
+
27
+ async recipeList(): Promise<Recipe[]> {
28
+ return [
29
+ new UpgradeNode22(),
30
+ ...node24EolDeprecations,
31
+ ...node24RuntimeDeprecations,
32
+ ];
33
+ }
34
+ }