@openrewrite/recipes-nodejs 0.35.0-20251201-142102 → 0.35.0-20251201-160236
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.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/migrate/outgoing-message-headers.d.ts +9 -0
- package/dist/migrate/outgoing-message-headers.d.ts.map +1 -0
- package/dist/migrate/outgoing-message-headers.js +127 -0
- package/dist/migrate/outgoing-message-headers.js.map +1 -0
- package/dist/migrate/upgrade-node-24.d.ts.map +1 -1
- package/dist/migrate/upgrade-node-24.js +2 -0
- package/dist/migrate/upgrade-node-24.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/migrate/outgoing-message-headers.ts +115 -0
- package/src/migrate/upgrade-node-24.ts +2 -0
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAqBpD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,cAAc,QAmBhD"}
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ 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
18
|
const fs_truncate_1 = require("./migrate/fs-truncate");
|
|
19
|
+
const outgoing_message_headers_1 = require("./migrate/outgoing-message-headers");
|
|
19
20
|
const upgrade_node_22_1 = require("./migrate/upgrade-node-22");
|
|
20
21
|
const upgrade_node_24_1 = require("./migrate/upgrade-node-24");
|
|
21
22
|
function activate(registry) {
|
|
@@ -34,6 +35,7 @@ function activate(registry) {
|
|
|
34
35
|
registry.register(util_types_wasm_1.ReplaceIsWebAssemblyCompiledModule);
|
|
35
36
|
registry.register(zlib_bytes_read_1.ReplaceZlibBytesRead);
|
|
36
37
|
registry.register(fs_truncate_1.ReplaceFsTruncateWithFd);
|
|
38
|
+
registry.register(outgoing_message_headers_1.ReplaceOutgoingMessageHeaders);
|
|
37
39
|
registry.register(upgrade_node_22_1.UpgradeNode22);
|
|
38
40
|
registry.register(upgrade_node_24_1.UpgradeNode24);
|
|
39
41
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAqBA,4BAmBC;AAvCD,qEAA0E;AAC1E,yDAAoE;AACpE,yEAAwF;AACxF,uEAAwE;AACxE,iDAAkD;AAClD,uDAAwD;AACxD,uDAAwD;AACxD,uDAAwD;AACxD,uEAAuE;AACvE,yEAAwE;AACxE,mEAA4E;AAC5E,uDAAwD;AACxD,+DAA6E;AAC7E,+DAA+D;AAC/D,uDAA8D;AAC9D,iFAAiF;AACjF,+DAAwD;AACxD,+DAAwD;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;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;IACxC,QAAQ,CAAC,QAAQ,CAAC,qCAAuB,CAAC,CAAC;IAC3C,QAAQ,CAAC,QAAQ,CAAC,wDAA6B,CAAC,CAAC;IACjD,QAAQ,CAAC,QAAQ,CAAC,+BAAa,CAAC,CAAC;IACjC,QAAQ,CAAC,QAAQ,CAAC,+BAAa,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class ReplaceOutgoingMessageHeaders extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.node.migrate.http.replace-outgoing-message-headers";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly tags: string[];
|
|
7
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=outgoing-message-headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outgoing-message-headers.d.ts","sourceRoot":"","sources":["../../src/migrate/outgoing-message-headers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAI3E,qBAAa,6BAA8B,SAAQ,MAAM;IACrD,QAAQ,CAAC,IAAI,wEAAuE;IACpF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAgF;IAC5G,QAAQ,CAAC,WAAW,EAAE,MAAM,CAEU;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAe;IAEhC,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAsG9D"}
|
|
@@ -0,0 +1,127 @@
|
|
|
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.ReplaceOutgoingMessageHeaders = 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 ReplaceOutgoingMessageHeaders extends rewrite_1.Recipe {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.name = "org.openrewrite.node.migrate.http.replace-outgoing-message-headers";
|
|
20
|
+
this.displayName = "Replace `OutgoingMessage._headers` and `._headerNames` with public methods";
|
|
21
|
+
this.description = "Replace deprecated `OutgoingMessage.prototype._headers` with `getHeaders()`, " +
|
|
22
|
+
"`setHeader()`, `removeHeader()` and `OutgoingMessage.prototype._headerNames` with `getHeaderNames()` " +
|
|
23
|
+
"to address DEP0066 deprecation.";
|
|
24
|
+
this.tags = ["DEP0066"];
|
|
25
|
+
}
|
|
26
|
+
editor() {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return new class extends javascript_1.JavaScriptVisitor {
|
|
29
|
+
isOutgoingMessageType(type) {
|
|
30
|
+
if (!type)
|
|
31
|
+
return false;
|
|
32
|
+
if (type.kind === java_1.Type.Kind.Class) {
|
|
33
|
+
const classType = type;
|
|
34
|
+
const fqn = classType.fullyQualifiedName;
|
|
35
|
+
return fqn === "http.OutgoingMessage" ||
|
|
36
|
+
fqn === "http.ServerResponse" ||
|
|
37
|
+
fqn === "http.ClientRequest" ||
|
|
38
|
+
fqn === "node:http.OutgoingMessage" ||
|
|
39
|
+
fqn === "node:http.ServerResponse" ||
|
|
40
|
+
fqn === "node:http.ClientRequest";
|
|
41
|
+
}
|
|
42
|
+
if (type.kind === java_1.Type.Kind.Parameterized) {
|
|
43
|
+
const paramType = type;
|
|
44
|
+
return this.isOutgoingMessageType(paramType.type);
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
isHeadersAccess(node) {
|
|
49
|
+
if (node.kind === java_1.J.Kind.FieldAccess) {
|
|
50
|
+
const fa = node;
|
|
51
|
+
if (this.isOutgoingMessageType(fa.target.type)) {
|
|
52
|
+
const fieldName = fa.name.element.simpleName;
|
|
53
|
+
if (fieldName === "_headers") {
|
|
54
|
+
return { target: fa.target, isHeaders: true, isHeaderNames: false };
|
|
55
|
+
}
|
|
56
|
+
if (fieldName === "_headerNames") {
|
|
57
|
+
return { target: fa.target, isHeaders: false, isHeaderNames: true };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
visitAssignment(assignment, p) {
|
|
64
|
+
const _super = Object.create(null, {
|
|
65
|
+
visitAssignment: { get: () => super.visitAssignment }
|
|
66
|
+
});
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const assign = yield _super.visitAssignment.call(this, assignment, p);
|
|
69
|
+
if (assign.variable.kind === java_1.J.Kind.ArrayAccess) {
|
|
70
|
+
const arrayAccess = assign.variable;
|
|
71
|
+
const headersAccess = this.isHeadersAccess(arrayAccess.indexed);
|
|
72
|
+
if (headersAccess === null || headersAccess === void 0 ? void 0 : headersAccess.isHeaders) {
|
|
73
|
+
const key = arrayAccess.dimension.index.element;
|
|
74
|
+
const value = assign.assignment.element;
|
|
75
|
+
return (0, javascript_1.template) `${headersAccess.target}.setHeader(${key}, ${value})`.apply(assign, this.cursor);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return assign;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
visitDelete(del, p) {
|
|
82
|
+
const _super = Object.create(null, {
|
|
83
|
+
visitDelete: { get: () => super.visitDelete }
|
|
84
|
+
});
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const d = yield _super.visitDelete.call(this, del, p);
|
|
87
|
+
if (d.expression.kind === java_1.J.Kind.ArrayAccess) {
|
|
88
|
+
const arrayAccess = d.expression;
|
|
89
|
+
const headersAccess = this.isHeadersAccess(arrayAccess.indexed);
|
|
90
|
+
if (headersAccess === null || headersAccess === void 0 ? void 0 : headersAccess.isHeaders) {
|
|
91
|
+
const key = arrayAccess.dimension.index.element;
|
|
92
|
+
return (0, javascript_1.template) `${headersAccess.target}.removeHeader(${key})`.apply(d, this.cursor);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return d;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
visitFieldAccess(fieldAccess, p) {
|
|
99
|
+
const _super = Object.create(null, {
|
|
100
|
+
visitFieldAccess: { get: () => super.visitFieldAccess }
|
|
101
|
+
});
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
var _a;
|
|
104
|
+
const fa = yield _super.visitFieldAccess.call(this, fieldAccess, p);
|
|
105
|
+
const headersAccess = this.isHeadersAccess(fa);
|
|
106
|
+
if (!headersAccess) {
|
|
107
|
+
return fa;
|
|
108
|
+
}
|
|
109
|
+
const parent = (_a = this.cursor.parent) === null || _a === void 0 ? void 0 : _a.value;
|
|
110
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.kind) === java_1.J.Kind.ArrayAccess) {
|
|
111
|
+
return fa;
|
|
112
|
+
}
|
|
113
|
+
if (headersAccess.isHeaders) {
|
|
114
|
+
return (0, javascript_1.template) `${fa.target}.getHeaders()`.apply(fa, this.cursor);
|
|
115
|
+
}
|
|
116
|
+
if (headersAccess.isHeaderNames) {
|
|
117
|
+
return (0, javascript_1.template) `${fa.target}.getHeaderNames()`.apply(fa, this.cursor);
|
|
118
|
+
}
|
|
119
|
+
return fa;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.ReplaceOutgoingMessageHeaders = ReplaceOutgoingMessageHeaders;
|
|
127
|
+
//# sourceMappingURL=outgoing-message-headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outgoing-message-headers.js","sourceRoot":"","sources":["../../src/migrate/outgoing-message-headers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2E;AAC3E,gEAAgF;AAChF,oDAAkD;AAElD,MAAa,6BAA8B,SAAQ,gBAAM;IAAzD;;QACa,SAAI,GAAG,oEAAoE,CAAA;QAC3E,gBAAW,GAAW,4EAA4E,CAAC;QACnG,gBAAW,GAAW,+EAA+E;YAC1G,uGAAuG;YACvG,iCAAiC,CAAC;QAC7B,SAAI,GAAa,CAAC,SAAS,CAAC,CAAC;IAwG1C,CAAC;IAtGS,MAAM;;YACR,OAAO,IAAI,KAAM,SAAQ,8BAAmC;gBAEhD,qBAAqB,CAAC,IAAsB;oBAChD,IAAI,CA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EAAE,CAAC;oBACd,CAAC;iBAAA;aACJ,CAAC;QACN,CAAC;KAAA;CACJ;AA9GD,sEA8GC"}
|
|
@@ -1 +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;
|
|
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;AAuB5C,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"}
|
|
@@ -16,10 +16,12 @@ const zlib_bytes_read_1 = require("./zlib-bytes-read");
|
|
|
16
16
|
const crypto_fips_1 = require("./crypto-fips");
|
|
17
17
|
const dirent_path_1 = require("./dirent-path");
|
|
18
18
|
const fs_truncate_1 = require("./fs-truncate");
|
|
19
|
+
const outgoing_message_headers_1 = require("./outgoing-message-headers");
|
|
19
20
|
const upgrade_node_22_1 = require("./upgrade-node-22");
|
|
20
21
|
const node24EolDeprecations = [
|
|
21
22
|
new util_log_1.ReplaceUtilLog(),
|
|
22
23
|
new zlib_bytes_read_1.ReplaceZlibBytesRead(),
|
|
24
|
+
new outgoing_message_headers_1.ReplaceOutgoingMessageHeaders(),
|
|
23
25
|
new fs_truncate_1.ReplaceFsTruncateWithFd(),
|
|
24
26
|
new dirent_path_1.ReplaceDirentPath(),
|
|
25
27
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-node-24.js","sourceRoot":"","sources":["../../src/migrate/upgrade-node-24.ts"],"names":[],"mappings":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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-
|
|
3
|
+
"version": "0.35.0-20251201-160236",
|
|
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
|
@@ -14,6 +14,7 @@ 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
16
|
import {ReplaceFsTruncateWithFd} from "./migrate/fs-truncate";
|
|
17
|
+
import {ReplaceOutgoingMessageHeaders} from "./migrate/outgoing-message-headers";
|
|
17
18
|
import {UpgradeNode22} from "./migrate/upgrade-node-22";
|
|
18
19
|
import {UpgradeNode24} from "./migrate/upgrade-node-24";
|
|
19
20
|
|
|
@@ -34,6 +35,7 @@ export function activate(registry: RecipeRegistry) {
|
|
|
34
35
|
registry.register(ReplaceIsWebAssemblyCompiledModule);
|
|
35
36
|
registry.register(ReplaceZlibBytesRead);
|
|
36
37
|
registry.register(ReplaceFsTruncateWithFd);
|
|
38
|
+
registry.register(ReplaceOutgoingMessageHeaders);
|
|
37
39
|
registry.register(UpgradeNode22);
|
|
38
40
|
registry.register(UpgradeNode24);
|
|
39
41
|
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, JS, template} from "@openrewrite/rewrite/javascript";
|
|
3
|
+
import {J, Type} from "@openrewrite/rewrite/java";
|
|
4
|
+
|
|
5
|
+
export class ReplaceOutgoingMessageHeaders extends Recipe {
|
|
6
|
+
readonly name = "org.openrewrite.node.migrate.http.replace-outgoing-message-headers"
|
|
7
|
+
readonly displayName: string = "Replace `OutgoingMessage._headers` and `._headerNames` with public methods";
|
|
8
|
+
readonly description: string = "Replace deprecated `OutgoingMessage.prototype._headers` with `getHeaders()`, " +
|
|
9
|
+
"`setHeader()`, `removeHeader()` and `OutgoingMessage.prototype._headerNames` with `getHeaderNames()` " +
|
|
10
|
+
"to address DEP0066 deprecation.";
|
|
11
|
+
readonly tags: string[] = ["DEP0066"];
|
|
12
|
+
|
|
13
|
+
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
14
|
+
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
15
|
+
|
|
16
|
+
private isOutgoingMessageType(type: Type | undefined): boolean {
|
|
17
|
+
if (!type) return false;
|
|
18
|
+
|
|
19
|
+
if (type.kind === Type.Kind.Class) {
|
|
20
|
+
const classType = type as Type.Class;
|
|
21
|
+
const fqn = classType.fullyQualifiedName;
|
|
22
|
+
return fqn === "http.OutgoingMessage" ||
|
|
23
|
+
fqn === "http.ServerResponse" ||
|
|
24
|
+
fqn === "http.ClientRequest" ||
|
|
25
|
+
fqn === "node:http.OutgoingMessage" ||
|
|
26
|
+
fqn === "node:http.ServerResponse" ||
|
|
27
|
+
fqn === "node:http.ClientRequest";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (type.kind === Type.Kind.Parameterized) {
|
|
31
|
+
const paramType = type as Type.Parameterized;
|
|
32
|
+
return this.isOutgoingMessageType(paramType.type);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private isHeadersAccess(node: J): { target: J, isHeaders: boolean, isHeaderNames: boolean } | undefined {
|
|
39
|
+
if (node.kind === J.Kind.FieldAccess) {
|
|
40
|
+
const fa = node as J.FieldAccess;
|
|
41
|
+
if (this.isOutgoingMessageType(fa.target.type)) {
|
|
42
|
+
const fieldName = fa.name.element.simpleName;
|
|
43
|
+
if (fieldName === "_headers") {
|
|
44
|
+
return { target: fa.target, isHeaders: true, isHeaderNames: false };
|
|
45
|
+
}
|
|
46
|
+
if (fieldName === "_headerNames") {
|
|
47
|
+
return { target: fa.target, isHeaders: false, isHeaderNames: true };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
protected async visitAssignment(assignment: J.Assignment, p: ExecutionContext): Promise<J | undefined> {
|
|
55
|
+
const assign = await super.visitAssignment(assignment, p) as J.Assignment;
|
|
56
|
+
|
|
57
|
+
// Handle: res._headers['key'] = value -> res.setHeader('key', value)
|
|
58
|
+
if (assign.variable.kind === J.Kind.ArrayAccess) {
|
|
59
|
+
const arrayAccess = assign.variable as J.ArrayAccess;
|
|
60
|
+
const headersAccess = this.isHeadersAccess(arrayAccess.indexed);
|
|
61
|
+
|
|
62
|
+
if (headersAccess?.isHeaders) {
|
|
63
|
+
const key = arrayAccess.dimension.index.element;
|
|
64
|
+
const value = assign.assignment.element;
|
|
65
|
+
return template`${headersAccess.target}.setHeader(${key}, ${value})`.apply(assign, this.cursor);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return assign;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
protected async visitDelete(del: JS.Delete, p: ExecutionContext): Promise<J | undefined> {
|
|
73
|
+
const d = await super.visitDelete(del, p) as JS.Delete;
|
|
74
|
+
|
|
75
|
+
// Handle: delete res._headers['key'] -> res.removeHeader('key')
|
|
76
|
+
if (d.expression.kind === J.Kind.ArrayAccess) {
|
|
77
|
+
const arrayAccess = d.expression as J.ArrayAccess;
|
|
78
|
+
const headersAccess = this.isHeadersAccess(arrayAccess.indexed);
|
|
79
|
+
|
|
80
|
+
if (headersAccess?.isHeaders) {
|
|
81
|
+
const key = arrayAccess.dimension.index.element;
|
|
82
|
+
return template`${headersAccess.target}.removeHeader(${key})`.apply(d, this.cursor);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return d;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
protected async visitFieldAccess(fieldAccess: J.FieldAccess, p: ExecutionContext): Promise<J | undefined> {
|
|
90
|
+
const fa = await super.visitFieldAccess(fieldAccess, p) as J.FieldAccess;
|
|
91
|
+
|
|
92
|
+
const headersAccess = this.isHeadersAccess(fa);
|
|
93
|
+
if (!headersAccess) {
|
|
94
|
+
return fa;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Skip if this is part of an array access that will be handled by visitAssignment/visitUnary
|
|
98
|
+
const parent = this.cursor.parent?.value;
|
|
99
|
+
if (parent?.kind === J.Kind.ArrayAccess) {
|
|
100
|
+
return fa;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (headersAccess.isHeaders) {
|
|
104
|
+
return template`${fa.target}.getHeaders()`.apply(fa, this.cursor);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (headersAccess.isHeaderNames) {
|
|
108
|
+
return template`${fa.target}.getHeaderNames()`.apply(fa, this.cursor);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return fa;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -4,12 +4,14 @@ import {ReplaceZlibBytesRead} from "./zlib-bytes-read";
|
|
|
4
4
|
import {ReplaceCryptoFips} from "./crypto-fips";
|
|
5
5
|
import {ReplaceDirentPath} from "./dirent-path";
|
|
6
6
|
import {ReplaceFsTruncateWithFd} from "./fs-truncate";
|
|
7
|
+
import {ReplaceOutgoingMessageHeaders} from "./outgoing-message-headers";
|
|
7
8
|
import {UpgradeNode22} from "./upgrade-node-22";
|
|
8
9
|
|
|
9
10
|
// Node 24 End-of-Life deprecations (includes v23 EOL)
|
|
10
11
|
const node24EolDeprecations: Recipe[] = [
|
|
11
12
|
new ReplaceUtilLog(), // DEP0059: util.log (v23 EOL)
|
|
12
13
|
new ReplaceZlibBytesRead(), // DEP0108: zlib.bytesRead (v23 EOL)
|
|
14
|
+
new ReplaceOutgoingMessageHeaders(), // DEP0066: OutgoingMessage._headers (v24 EOL)
|
|
13
15
|
new ReplaceFsTruncateWithFd(), // DEP0081: fs.truncate() with fd (v24 EOL)
|
|
14
16
|
new ReplaceDirentPath(), // DEP0178: dirent.path (v24 EOL)
|
|
15
17
|
];
|