@openrewrite/recipes-nodejs 0.36.0-20251205-111002 → 0.36.0-20251205-132324

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 ReplaceTlsServerSetOptions extends Recipe {
3
+ readonly name = "org.openrewrite.node.migrate.tls.replace-server-set-options";
4
+ readonly displayName: string;
5
+ readonly description: string;
6
+ readonly tags: string[];
7
+ editor(): Promise<TreeVisitor<any, ExecutionContext>>;
8
+ }
9
+ //# sourceMappingURL=tls-server-set-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tls-server-set-options.d.ts","sourceRoot":"","sources":["../../src/migrate/tls-server-set-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAI3E,qBAAa,0BAA2B,SAAQ,MAAM;IAClD,QAAQ,CAAC,IAAI,iEAAgE;IAC7E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA4E;IACxG,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAwG;IACpI,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAe;IAEhC,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAiC9D"}
@@ -0,0 +1,61 @@
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.ReplaceTlsServerSetOptions = 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 ReplaceTlsServerSetOptions extends rewrite_1.Recipe {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.name = "org.openrewrite.node.migrate.tls.replace-server-set-options";
20
+ this.displayName = "Replace deprecated `tls.Server.setOptions()` with `setSecureContext()`";
21
+ this.description = "Replace deprecated `tls.Server.prototype.setOptions()` with `Server.prototype.setSecureContext()`.";
22
+ this.tags = ["DEP0122"];
23
+ }
24
+ editor() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ return new class extends javascript_1.JavaScriptVisitor {
27
+ isTlsServerType(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 === "tls.Server" || fqn === "node:tls.Server";
34
+ }
35
+ return false;
36
+ }
37
+ visitMethodInvocation(method, p) {
38
+ const _super = Object.create(null, {
39
+ visitMethodInvocation: { get: () => super.visitMethodInvocation }
40
+ });
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const m = yield _super.visitMethodInvocation.call(this, method, p);
43
+ if (m.name.simpleName !== "setOptions") {
44
+ return m;
45
+ }
46
+ if (!m.select) {
47
+ return m;
48
+ }
49
+ const selectType = m.select.element.type;
50
+ if (this.isTlsServerType(selectType)) {
51
+ return (0, javascript_1.template) `${m.select}.setSecureContext(${m.arguments})`.apply(m, this.cursor);
52
+ }
53
+ return m;
54
+ });
55
+ }
56
+ };
57
+ });
58
+ }
59
+ }
60
+ exports.ReplaceTlsServerSetOptions = ReplaceTlsServerSetOptions;
61
+ //# sourceMappingURL=tls-server-set-options.js.map
@@ -0,0 +1 @@
1
+ {"version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Q,EAAA,GAAG,CAAC,CAAC,MAAM,qBAAqB,CAAC,CAAC,SAAS,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;wBACxF,CAAC;wBAED,OAAO,CAAC,CAAC;oBACb,CAAC;iBAAA;aACJ,CAAC;QACN,CAAC;KAAA;CACJ;AAvCD,gEAuCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openrewrite/recipes-nodejs",
3
- "version": "0.36.0-20251205-111002",
3
+ "version": "0.36.0-20251205-132324",
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,44 @@
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 ReplaceTlsServerSetOptions extends Recipe {
6
+ readonly name = "org.openrewrite.node.migrate.tls.replace-server-set-options"
7
+ readonly displayName: string = "Replace deprecated `tls.Server.setOptions()` with `setSecureContext()`";
8
+ readonly description: string = "Replace deprecated `tls.Server.prototype.setOptions()` with `Server.prototype.setSecureContext()`.";
9
+ readonly tags: string[] = ["DEP0122"];
10
+
11
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
12
+ return new class extends JavaScriptVisitor<ExecutionContext> {
13
+ private isTlsServerType(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 === "tls.Server" || fqn === "node:tls.Server";
19
+ }
20
+ return false;
21
+ }
22
+
23
+ override async visitMethodInvocation(method: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
24
+ const m = await super.visitMethodInvocation(method, p) as J.MethodInvocation;
25
+
26
+ if (m.name.simpleName !== "setOptions") {
27
+ return m;
28
+ }
29
+
30
+ if (!m.select) {
31
+ return m;
32
+ }
33
+
34
+
35
+ const selectType = m.select.element.type;
36
+ if (this.isTlsServerType(selectType)) {
37
+ return template`${m.select}.setSecureContext(${m.arguments})`.apply(m, this.cursor);
38
+ }
39
+
40
+ return m;
41
+ }
42
+ };
43
+ }
44
+ }