@openrewrite/recipes-nodejs 0.35.0-20251120-132843 → 0.35.0-20251120-140517
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/slow-buffer.d.ts +9 -0
- package/dist/migrate/slow-buffer.d.ts.map +1 -0
- package/dist/migrate/slow-buffer.js +60 -0
- package/dist/migrate/slow-buffer.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/migrate/slow-buffer.ts +47 -0
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AASpD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,cAAc,QAShD"}
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const crypto_constructors_1 = require("./migrate/crypto-constructors");
|
|
|
8
8
|
const util_log_1 = require("./migrate/util-log");
|
|
9
9
|
const util_extend_1 = require("./migrate/util-extend");
|
|
10
10
|
const crypto_fips_1 = require("./migrate/crypto-fips");
|
|
11
|
+
const slow_buffer_1 = require("./migrate/slow-buffer");
|
|
11
12
|
function activate(registry) {
|
|
12
13
|
registry.register(util_type_checking_1.UseNativeTypeCheckingMethods);
|
|
13
14
|
registry.register(buffer_slice_1.ReplaceDeprecatedBufferSlice);
|
|
@@ -16,5 +17,6 @@ function activate(registry) {
|
|
|
16
17
|
registry.register(util_log_1.ReplaceUtilLog);
|
|
17
18
|
registry.register(util_extend_1.ReplaceUtilExtend);
|
|
18
19
|
registry.register(crypto_fips_1.ReplaceCryptoFips);
|
|
20
|
+
registry.register(slow_buffer_1.ReplaceSlowBuffer);
|
|
19
21
|
}
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
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":";;AAWA,4BASC;AApBD,qEAA0E;AAC1E,yDAAoE;AAEpE,yEAAwF;AACxF,uEAAwE;AACxE,iDAAkD;AAClD,uDAAwD;AACxD,uDAAwD;AACxD,uDAAwD;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;AACzC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class ReplaceSlowBuffer extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.node.migrate.buffer.replace-slow-buffer";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly tags: string[];
|
|
7
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=slow-buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slow-buffer.d.ts","sourceRoot":"","sources":["../../src/migrate/slow-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAO3E,qBAAa,iBAAkB,SAAQ,MAAM;IACzC,QAAQ,CAAC,IAAI,6DAA4D;IACzE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAqE;IACjG,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAmO;IAC/P,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAe;IAEhC,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAiC9D"}
|
|
@@ -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.ReplaceSlowBuffer = 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 ReplaceSlowBuffer extends rewrite_1.Recipe {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.name = "org.openrewrite.node.migrate.buffer.replace-slow-buffer";
|
|
20
|
+
this.displayName = "Replace deprecated `SlowBuffer` with `Buffer.allocUnsafeSlow()`";
|
|
21
|
+
this.description = "Replace deprecated `new SlowBuffer(size)` calls with `Buffer.allocUnsafeSlow(size)`. SlowBuffer was used to create un-pooled Buffer instances, but has been removed in favor of the explicit Buffer.allocUnsafeSlow() method.";
|
|
22
|
+
this.tags = ["DEP0030"];
|
|
23
|
+
}
|
|
24
|
+
editor() {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return new class extends javascript_1.JavaScriptVisitor {
|
|
27
|
+
visitNewClass(nc, p) {
|
|
28
|
+
const _super = Object.create(null, {
|
|
29
|
+
visitNewClass: { get: () => super.visitNewClass }
|
|
30
|
+
});
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
var _a;
|
|
33
|
+
const newClass = yield _super.visitNewClass.call(this, nc, p);
|
|
34
|
+
const clazz = newClass.class;
|
|
35
|
+
const args = (_a = newClass.arguments) === null || _a === void 0 ? void 0 : _a.elements;
|
|
36
|
+
if (!args || args.length !== 1) {
|
|
37
|
+
return newClass;
|
|
38
|
+
}
|
|
39
|
+
const sizeArg = args[0].element;
|
|
40
|
+
if (clazz && clazz.kind === java_1.J.Kind.Identifier) {
|
|
41
|
+
const constructorType = newClass.constructorType;
|
|
42
|
+
if ((constructorType === null || constructorType === void 0 ? void 0 : constructorType.declaringType.kind) === java_1.Type.Kind.Class &&
|
|
43
|
+
constructorType.name === "SlowBuffer") {
|
|
44
|
+
const declaringClass = constructorType.declaringType;
|
|
45
|
+
if (declaringClass.fullyQualifiedName === "buffer") {
|
|
46
|
+
(0, javascript_1.maybeRemoveImport)(this, "buffer", "SlowBuffer");
|
|
47
|
+
(0, javascript_1.maybeRemoveImport)(this, "node:buffer", "SlowBuffer");
|
|
48
|
+
return yield (0, javascript_1.template) `Buffer.allocUnsafeSlow(${sizeArg})`.apply(newClass, this.cursor);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return _super.visitNewClass.call(this, newClass, p);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.ReplaceSlowBuffer = ReplaceSlowBuffer;
|
|
60
|
+
//# sourceMappingURL=slow-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slow-buffer.js","sourceRoot":"","sources":["../../src/migrate/slow-buffer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2E;AAC3E,gEAA+F;AAC/F,oDAAkD;AAKlD,MAAa,iBAAkB,SAAQ,gBAAM;IAA7C;;QACa,SAAI,GAAG,yDAAyD,CAAA;QAChE,gBAAW,GAAW,iEAAiE,CAAC;QACxF,gBAAW,GAAW,+NAA+N,CAAC;QACtP,SAAI,GAAa,CAAC,SAAS,CAAC,CAAC;IAmC1C,CAAC;IAjCS,MAAM;;YACR,OAAO,IAAI,KAAM,SAAQ,8BAAmC;gBAExC,aAAa,CAAC,EAAc,EAAE,CAAmB;;;;;;wBAC7D,MAAM,QAAQ,GAAG,MAAM,OAAM,aAAa,YAAC,EAAE,EAAE,CAAC,CAAe,CAAC;wBAEhE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;wBAC7B,MAAM,IAAI,GAAG,MAAA,QAAQ,CAAC,SAAS,0CAAE,QAAQ,CAAC;wBAE1C,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;4BAC7B,OAAO,QAAQ,CAAC;wBACpB,CAAC;wBAED,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;wBAEhC,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;4BAC5C,MAAM,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC;4BACjD,IAAI,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,aAAa,CAAC,IAAI,MAAK,WAAI,CAAC,IAAI,CAAC,KAAK;gCACvD,eAAe,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gCACxC,MAAM,cAAc,GAAG,eAAe,CAAC,aAA2B,CAAC;gCAEnE,IAAI,cAAc,CAAC,kBAAkB,KAAK,QAAQ,EAAE,CAAC;oCACjD,IAAA,8BAAiB,EAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;oCAChD,IAAA,8BAAiB,EAAC,IAAI,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;oCACrD,OAAO,MAAM,IAAA,qBAAQ,EAAA,0BAA0B,OAAO,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;gCAC3F,CAAC;4BACL,CAAC;wBACL,CAAC;wBAED,OAAO,OAAM,aAAa,YAAC,QAAQ,EAAE,CAAC,EAAE;oBAC5C,CAAC;iBAAA;aACJ,CAAC;QACN,CAAC;KAAA;CACJ;AAvCD,8CAuCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrewrite/recipes-nodejs",
|
|
3
|
-
"version": "0.35.0-20251120-
|
|
3
|
+
"version": "0.35.0-20251120-140517",
|
|
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
|
@@ -6,6 +6,7 @@ import {ReplaceCryptoConstructors} from "./migrate/crypto-constructors";
|
|
|
6
6
|
import {ReplaceUtilLog} from "./migrate/util-log";
|
|
7
7
|
import {ReplaceUtilExtend} from "./migrate/util-extend";
|
|
8
8
|
import {ReplaceCryptoFips} from "./migrate/crypto-fips";
|
|
9
|
+
import {ReplaceSlowBuffer} from "./migrate/slow-buffer";
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
export function activate(registry: RecipeRegistry) {
|
|
@@ -16,4 +17,5 @@ export function activate(registry: RecipeRegistry) {
|
|
|
16
17
|
registry.register(ReplaceUtilLog);
|
|
17
18
|
registry.register(ReplaceUtilExtend);
|
|
18
19
|
registry.register(ReplaceCryptoFips);
|
|
20
|
+
registry.register(ReplaceSlowBuffer);
|
|
19
21
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* Replace deprecated SlowBuffer with Buffer.allocUnsafeSlow()
|
|
7
|
+
*/
|
|
8
|
+
export class ReplaceSlowBuffer extends Recipe {
|
|
9
|
+
readonly name = "org.openrewrite.node.migrate.buffer.replace-slow-buffer"
|
|
10
|
+
readonly displayName: string = "Replace deprecated `SlowBuffer` with `Buffer.allocUnsafeSlow()`";
|
|
11
|
+
readonly description: string = "Replace deprecated `new SlowBuffer(size)` calls with `Buffer.allocUnsafeSlow(size)`. SlowBuffer was used to create un-pooled Buffer instances, but has been removed in favor of the explicit Buffer.allocUnsafeSlow() method.";
|
|
12
|
+
readonly tags: string[] = ["DEP0030"];
|
|
13
|
+
|
|
14
|
+
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
15
|
+
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
16
|
+
|
|
17
|
+
protected async visitNewClass(nc: J.NewClass, p: ExecutionContext): Promise<J | undefined> {
|
|
18
|
+
const newClass = await super.visitNewClass(nc, p) as J.NewClass;
|
|
19
|
+
|
|
20
|
+
const clazz = newClass.class;
|
|
21
|
+
const args = newClass.arguments?.elements;
|
|
22
|
+
|
|
23
|
+
if (!args || args.length !== 1) {
|
|
24
|
+
return newClass;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const sizeArg = args[0].element;
|
|
28
|
+
|
|
29
|
+
if (clazz && clazz.kind === J.Kind.Identifier) {
|
|
30
|
+
const constructorType = newClass.constructorType;
|
|
31
|
+
if (constructorType?.declaringType.kind === Type.Kind.Class &&
|
|
32
|
+
constructorType.name === "SlowBuffer") {
|
|
33
|
+
const declaringClass = constructorType.declaringType as Type.Class;
|
|
34
|
+
|
|
35
|
+
if (declaringClass.fullyQualifiedName === "buffer") {
|
|
36
|
+
maybeRemoveImport(this, "buffer", "SlowBuffer");
|
|
37
|
+
maybeRemoveImport(this, "node:buffer", "SlowBuffer");
|
|
38
|
+
return await template`Buffer.allocUnsafeSlow(${sizeArg})`.apply(newClass, this.cursor);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return super.visitNewClass(newClass, p);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|