@openrewrite/recipes-nodejs 0.35.0-20251129-170526 → 0.35.0-20251201-104019
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.
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class ReplaceIsWebAssemblyCompiledModule extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.node.migrate.util.replace-is-webassembly-compiled-module";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly tags: string[];
|
|
7
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=util-types-wasm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util-types-wasm.d.ts","sourceRoot":"","sources":["../../src/migrate/util-types-wasm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAI3E,qBAAa,kCAAmC,SAAQ,MAAM;IAC1D,QAAQ,CAAC,IAAI,8EAA6E;IAC1F,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAmE;IAC/F,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAyG;IACrI,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAe;IAEhC,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAsC9D"}
|
|
@@ -0,0 +1,72 @@
|
|
|
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.ReplaceIsWebAssemblyCompiledModule = 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 ReplaceIsWebAssemblyCompiledModule extends rewrite_1.Recipe {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.name = "org.openrewrite.node.migrate.util.replace-is-webassembly-compiled-module";
|
|
20
|
+
this.displayName = "Replace deprecated `util.types.isWebAssemblyCompiledModule()`";
|
|
21
|
+
this.description = "Replace `util.types.isWebAssemblyCompiledModule(value)` with `value instanceof WebAssembly.Module`.";
|
|
22
|
+
this.tags = ["DEP0177"];
|
|
23
|
+
}
|
|
24
|
+
editor() {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return new class extends javascript_1.JavaScriptVisitor {
|
|
27
|
+
isUtilModule(type) {
|
|
28
|
+
if (!type)
|
|
29
|
+
return false;
|
|
30
|
+
if (type.kind === java_1.Type.Kind.Class) {
|
|
31
|
+
const classType = type;
|
|
32
|
+
return classType.fullyQualifiedName === "util" ||
|
|
33
|
+
classType.fullyQualifiedName === "node:util";
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
isUtilTypesAccess(select) {
|
|
38
|
+
if (!select)
|
|
39
|
+
return false;
|
|
40
|
+
if (select.kind !== java_1.J.Kind.FieldAccess)
|
|
41
|
+
return false;
|
|
42
|
+
const fieldAccess = select;
|
|
43
|
+
if (fieldAccess.name.element.simpleName !== "types")
|
|
44
|
+
return false;
|
|
45
|
+
if (fieldAccess.target.kind !== java_1.J.Kind.Identifier)
|
|
46
|
+
return false;
|
|
47
|
+
const identifier = fieldAccess.target;
|
|
48
|
+
return this.isUtilModule(identifier.type);
|
|
49
|
+
}
|
|
50
|
+
visitMethodInvocation(method, p) {
|
|
51
|
+
const _super = Object.create(null, {
|
|
52
|
+
visitMethodInvocation: { get: () => super.visitMethodInvocation }
|
|
53
|
+
});
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
var _a;
|
|
56
|
+
const m = yield _super.visitMethodInvocation.call(this, method, p);
|
|
57
|
+
if (m.name.simpleName === "isWebAssemblyCompiledModule" &&
|
|
58
|
+
this.isUtilTypesAccess((_a = m.select) === null || _a === void 0 ? void 0 : _a.element)) {
|
|
59
|
+
const arg = m.arguments.elements[0].element;
|
|
60
|
+
(0, javascript_1.maybeRemoveImport)(this, "util");
|
|
61
|
+
(0, javascript_1.maybeRemoveImport)(this, "util", "types");
|
|
62
|
+
return yield (0, javascript_1.template) `${arg} instanceof WebAssembly.Module`.apply(m, this.cursor);
|
|
63
|
+
}
|
|
64
|
+
return m;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.ReplaceIsWebAssemblyCompiledModule = ReplaceIsWebAssemblyCompiledModule;
|
|
72
|
+
//# sourceMappingURL=util-types-wasm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util-types-wasm.js","sourceRoot":"","sources":["../../src/migrate/util-types-wasm.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2E;AAC3E,gEAA+F;AAC/F,oDAAkD;AAElD,MAAa,kCAAmC,SAAQ,gBAAM;IAA9D;;QACa,SAAI,GAAG,0EAA0E,CAAA;QACjF,gBAAW,GAAW,+DAA+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IAAI,CAAC,iBAAiB,CAAC,MAAA,CAAC,CAAC,MAAM,0CAAE,OAAO,CAAC,EAAE,CAAC;4BAC5C,MAAM,GAAG,GAAG,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;4BAC5C,IAAA,8BAAiB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;4BAChC,IAAA,8BAAiB,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;4BACzC,OAAO,MAAM,IAAA,qBAAQ,EAAA,GAAG,GAAG,gCAAgC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;wBACtF,CAAC;wBACD,OAAO,CAAC,CAAC;oBACb,CAAC;iBAAA;aACJ,CAAC;QACN,CAAC;KAAA;CACJ;AA5CD,gFA4CC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrewrite/recipes-nodejs",
|
|
3
|
-
"version": "0.35.0-
|
|
3
|
+
"version": "0.35.0-20251201-104019",
|
|
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",
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, maybeRemoveImport, template} from "@openrewrite/rewrite/javascript";
|
|
3
|
+
import {J, Type} from "@openrewrite/rewrite/java";
|
|
4
|
+
|
|
5
|
+
export class ReplaceIsWebAssemblyCompiledModule extends Recipe {
|
|
6
|
+
readonly name = "org.openrewrite.node.migrate.util.replace-is-webassembly-compiled-module"
|
|
7
|
+
readonly displayName: string = "Replace deprecated `util.types.isWebAssemblyCompiledModule()`";
|
|
8
|
+
readonly description: string = "Replace `util.types.isWebAssemblyCompiledModule(value)` with `value instanceof WebAssembly.Module`.";
|
|
9
|
+
readonly tags: string[] = ["DEP0177"];
|
|
10
|
+
|
|
11
|
+
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
12
|
+
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
13
|
+
private isUtilModule(type: Type | undefined): boolean {
|
|
14
|
+
if (!type) return false;
|
|
15
|
+
if (type.kind === Type.Kind.Class) {
|
|
16
|
+
const classType = type as Type.Class;
|
|
17
|
+
return classType.fullyQualifiedName === "util" ||
|
|
18
|
+
classType.fullyQualifiedName === "node:util";
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private isUtilTypesAccess(select: J | undefined): boolean {
|
|
24
|
+
if (!select) return false;
|
|
25
|
+
if (select.kind !== J.Kind.FieldAccess) return false;
|
|
26
|
+
|
|
27
|
+
const fieldAccess = select as J.FieldAccess;
|
|
28
|
+
if (fieldAccess.name.element.simpleName !== "types") return false;
|
|
29
|
+
if (fieldAccess.target.kind !== J.Kind.Identifier) return false;
|
|
30
|
+
|
|
31
|
+
const identifier = fieldAccess.target as J.Identifier;
|
|
32
|
+
return this.isUtilModule(identifier.type);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
protected async visitMethodInvocation(method: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
|
|
36
|
+
const m = await super.visitMethodInvocation(method, p) as J.MethodInvocation;
|
|
37
|
+
|
|
38
|
+
if (m.name.simpleName === "isWebAssemblyCompiledModule" &&
|
|
39
|
+
this.isUtilTypesAccess(m.select?.element)) {
|
|
40
|
+
const arg = m.arguments.elements[0].element;
|
|
41
|
+
maybeRemoveImport(this, "util");
|
|
42
|
+
maybeRemoveImport(this, "util", "types");
|
|
43
|
+
return await template`${arg} instanceof WebAssembly.Module`.apply(m, this.cursor);
|
|
44
|
+
}
|
|
45
|
+
return m;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|