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

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;AAapD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,cAAc,QAahD"}
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"}
package/dist/index.js CHANGED
@@ -13,6 +13,8 @@ const fs_access_constants_1 = require("./migrate/fs-access-constants");
13
13
  const promisify_on_promise_1 = require("./migrate/promisify-on-promise");
14
14
  const process_exit_code_1 = require("./migrate/process-exit-code");
15
15
  const dirent_path_1 = require("./migrate/dirent-path");
16
+ const util_types_wasm_1 = require("./migrate/util-types-wasm");
17
+ const zlib_bytes_read_1 = require("./migrate/zlib-bytes-read");
16
18
  function activate(registry) {
17
19
  registry.register(util_type_checking_1.UseNativeTypeCheckingMethods);
18
20
  registry.register(buffer_slice_1.ReplaceDeprecatedBufferSlice);
@@ -26,5 +28,7 @@ function activate(registry) {
26
28
  registry.register(promisify_on_promise_1.RemovePromisifyOnPromise);
27
29
  registry.register(process_exit_code_1.AvoidImplicitCoercionOfExitCode);
28
30
  registry.register(dirent_path_1.ReplaceDirentPath);
31
+ registry.register(util_types_wasm_1.ReplaceIsWebAssemblyCompiledModule);
32
+ registry.register(zlib_bytes_read_1.ReplaceZlibBytesRead);
29
33
  }
30
34
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[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AAQ,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;IACrC,QAAQ,CAAC,QAAQ,CAAC,+BAAiB,CAAC,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,+BAAiB,CAAC,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,8CAAwB,CAAC,CAAC;IAC5C,QAAQ,CAAC,QAAQ,CAAC,+CAAwB,CAAC,CAAC;IAC5C,QAAQ,CAAC,QAAQ,CAAC,mDAA+B,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,CAAC,+BAAiB,CAAC,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,oDAAkC,CAAC,CAAC;IACtD,QAAQ,CAAC,QAAQ,CAAC,sCAAoB,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
2
+ export declare class ReplaceZlibBytesRead extends Recipe {
3
+ readonly name = "org.openrewrite.node.migrate.zlib.replace-bytes-read";
4
+ readonly displayName: string;
5
+ readonly description: string;
6
+ readonly tags: string[];
7
+ editor(): Promise<TreeVisitor<any, ExecutionContext>>;
8
+ }
9
+ //# sourceMappingURL=zlib-bytes-read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zlib-bytes-read.d.ts","sourceRoot":"","sources":["../../src/migrate/zlib-bytes-read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAI3E,qBAAa,oBAAqB,SAAQ,MAAM;IAC5C,QAAQ,CAAC,IAAI,0DAAyD;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAkE;IAC9F,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAkF;IAC9G,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAe;IAEhC,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CA8B9D"}
@@ -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.ReplaceZlibBytesRead = 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 ReplaceZlibBytesRead extends rewrite_1.Recipe {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.name = "org.openrewrite.node.migrate.zlib.replace-bytes-read";
20
+ this.displayName = "Replace deprecated `zlib.bytesRead` with `zlib.bytesWritten`";
21
+ this.description = "Replace deprecated `bytesRead` property on zlib streams with `bytesWritten`.";
22
+ this.tags = ["DEP0108"];
23
+ }
24
+ editor() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ return new class extends javascript_1.JavaScriptVisitor {
27
+ isZlibType(type) {
28
+ if (!type)
29
+ return false;
30
+ if (type.kind === java_1.Type.Kind.Class) {
31
+ const classType = type;
32
+ const fqn = classType.fullyQualifiedName;
33
+ return fqn.startsWith("zlib.") || fqn.startsWith("node:zlib.");
34
+ }
35
+ return false;
36
+ }
37
+ isZlibBytesReadAccess(fieldAccess) {
38
+ if (fieldAccess.name.element.simpleName !== "bytesRead") {
39
+ return false;
40
+ }
41
+ return this.isZlibType(fieldAccess.target.type);
42
+ }
43
+ visitFieldAccess(fieldAccess, p) {
44
+ const _super = Object.create(null, {
45
+ visitFieldAccess: { get: () => super.visitFieldAccess }
46
+ });
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const fa = yield _super.visitFieldAccess.call(this, fieldAccess, p);
49
+ if (this.isZlibBytesReadAccess(fa)) {
50
+ return (0, javascript_1.template) `${fa.target}.bytesWritten`.apply(fa, this.cursor);
51
+ }
52
+ return fa;
53
+ });
54
+ }
55
+ };
56
+ });
57
+ }
58
+ }
59
+ exports.ReplaceZlibBytesRead = ReplaceZlibBytesRead;
60
+ //# sourceMappingURL=zlib-bytes-read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zlib-bytes-read.js","sourceRoot":"","sources":["../../src/migrate/zlib-bytes-read.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2E;AAC3E,gEAA4E;AAC5E,oDAAkD;AAElD,MAAa,oBAAqB,SAAQ,gBAAM;IAAhD;;QACa,SAAI,GAAG,sDAAsD,CAAA;QAC7D,gBAAW,GAAW,8DAA8D,CAAC;QACrF,gBAAW,GAAW,8EAA8E,CAAC;QACrG,SAAI,GAAa,CAAC,SAAS,CAAC,CAAC;IAgC1C,CAAC;IA9BS,MAAM;;YACR,OAAO,IAAI,KAAM,SAAQ,8BAAmC;gBAChD,UAAU,CAAC,IAAsB;oBACrC,IAAI,CAAC,IAAI;wBAAE,OAAO,KAAK,CAAC;oBACxB,IAAI,IAAI,CAAC,IAAI,KAAK,WAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;wBAChC,MAAM,SAAS,GAAG,IAAkB,CAAC;wBACrC,MAAM,GAAG,GAAG,SAAS,CAAC,kBAAkB,CAAC;wBACzC,OAAO,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;oBACnE,CAAC;oBACD,OAAO,KAAK,CAAC;gBACjB,CAAC;gBAEO,qBAAqB,CAAC,WAA0B;oBACpD,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,WAAW,EAAE,CAAC;wBACtD,OAAO,KAAK,CAAC;oBACjB,CAAC;oBACD,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACpD,CAAC;gBAEe,gBAAgB,CAAC,WAA0B,EAAE,CAAmB;;;;;wBAC5E,MAAM,EAAE,GAAG,MAAM,OAAM,gBAAgB,YAAC,WAAW,EAAE,CAAC,CAAkB,CAAC;wBAEzE,IAAI,IAAI,CAAC,qBAAqB,CAAC,EAAE,CAAC,EAAE,CAAC;4BACjC,OAAO,IAAA,qBAAQ,EAAA,GAAG,EAAE,CAAC,MAAM,eAAe,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;wBACtE,CAAC;wBAED,OAAO,EAAE,CAAC;oBACd,CAAC;iBAAA;aACJ,CAAC;QACN,CAAC;KAAA;CACJ;AApCD,oDAoCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openrewrite/recipes-nodejs",
3
- "version": "0.35.0-20251201-104019",
3
+ "version": "0.35.0-20251201-124457",
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
@@ -11,6 +11,8 @@ import {ReplaceFsAccessConstants} from "./migrate/fs-access-constants";
11
11
  import {RemovePromisifyOnPromise} from "./migrate/promisify-on-promise";
12
12
  import {AvoidImplicitCoercionOfExitCode} from "./migrate/process-exit-code";
13
13
  import {ReplaceDirentPath} from "./migrate/dirent-path";
14
+ import {ReplaceIsWebAssemblyCompiledModule} from "./migrate/util-types-wasm";
15
+ import {ReplaceZlibBytesRead} from "./migrate/zlib-bytes-read";
14
16
 
15
17
 
16
18
  export function activate(registry: RecipeRegistry) {
@@ -26,4 +28,6 @@ export function activate(registry: RecipeRegistry) {
26
28
  registry.register(RemovePromisifyOnPromise);
27
29
  registry.register(AvoidImplicitCoercionOfExitCode);
28
30
  registry.register(ReplaceDirentPath);
31
+ registry.register(ReplaceIsWebAssemblyCompiledModule);
32
+ registry.register(ReplaceZlibBytesRead);
29
33
  }
@@ -0,0 +1,41 @@
1
+ import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
2
+ import {JavaScriptVisitor, template} from "@openrewrite/rewrite/javascript";
3
+ import {J, Type} from "@openrewrite/rewrite/java";
4
+
5
+ export class ReplaceZlibBytesRead extends Recipe {
6
+ readonly name = "org.openrewrite.node.migrate.zlib.replace-bytes-read"
7
+ readonly displayName: string = "Replace deprecated `zlib.bytesRead` with `zlib.bytesWritten`";
8
+ readonly description: string = "Replace deprecated `bytesRead` property on zlib streams with `bytesWritten`.";
9
+ readonly tags: string[] = ["DEP0108"];
10
+
11
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
12
+ return new class extends JavaScriptVisitor<ExecutionContext> {
13
+ private isZlibType(type: Type | undefined): boolean {
14
+ if (!type) return false;
15
+ if (type.kind === Type.Kind.Class) {
16
+ const classType = type as Type.Class;
17
+ const fqn = classType.fullyQualifiedName;
18
+ return fqn.startsWith("zlib.") || fqn.startsWith("node:zlib.");
19
+ }
20
+ return false;
21
+ }
22
+
23
+ private isZlibBytesReadAccess(fieldAccess: J.FieldAccess): boolean {
24
+ if (fieldAccess.name.element.simpleName !== "bytesRead") {
25
+ return false;
26
+ }
27
+ return this.isZlibType(fieldAccess.target.type);
28
+ }
29
+
30
+ protected async visitFieldAccess(fieldAccess: J.FieldAccess, p: ExecutionContext): Promise<J | undefined> {
31
+ const fa = await super.visitFieldAccess(fieldAccess, p) as J.FieldAccess;
32
+
33
+ if (this.isZlibBytesReadAccess(fa)) {
34
+ return template`${fa.target}.bytesWritten`.apply(fa, this.cursor);
35
+ }
36
+
37
+ return fa;
38
+ }
39
+ };
40
+ }
41
+ }