@openrewrite/recipes-nodejs 0.35.0-20251127-170523 → 0.35.0-20251128-143647
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/dirent-path.d.ts +9 -0
- package/dist/migrate/dirent-path.d.ts.map +1 -0
- package/dist/migrate/dirent-path.js +65 -0
- package/dist/migrate/dirent-path.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/migrate/dirent-path.ts +50 -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;AAapD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,cAAc,QAahD"}
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const slow_buffer_1 = require("./migrate/slow-buffer");
|
|
|
12
12
|
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
|
+
const dirent_path_1 = require("./migrate/dirent-path");
|
|
15
16
|
function activate(registry) {
|
|
16
17
|
registry.register(util_type_checking_1.UseNativeTypeCheckingMethods);
|
|
17
18
|
registry.register(buffer_slice_1.ReplaceDeprecatedBufferSlice);
|
|
@@ -24,5 +25,6 @@ function activate(registry) {
|
|
|
24
25
|
registry.register(fs_access_constants_1.ReplaceFsAccessConstants);
|
|
25
26
|
registry.register(promisify_on_promise_1.RemovePromisifyOnPromise);
|
|
26
27
|
registry.register(process_exit_code_1.AvoidImplicitCoercionOfExitCode);
|
|
28
|
+
registry.register(dirent_path_1.ReplaceDirentPath);
|
|
27
29
|
}
|
|
28
30
|
//# 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":";;AAeA,4BAaC;AA5BD,qEAA0E;AAC1E,yDAAoE;AAEpE,yEAAwF;AACxF,uEAAwE;AACxE,iDAAkD;AAClD,uDAAwD;AACxD,uDAAwD;AACxD,uDAAwD;AACxD,uEAAuE;AACvE,yEAAwE;AACxE,mEAA4E;AAC5E,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;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;AACzC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class ReplaceDirentPath extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.node.migrate.fs.replace-dirent-path";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly tags: string[];
|
|
7
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=dirent-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dirent-path.d.ts","sourceRoot":"","sources":["../../src/migrate/dirent-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAI3E,qBAAa,iBAAkB,SAAQ,MAAM;IACzC,QAAQ,CAAC,IAAI,yDAAwD;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAoD;IAChF,QAAQ,CAAC,WAAW,EAAE,MAAM,CACmC;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAe;IAEhC,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAsC9D"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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.ReplaceDirentPath = 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 ReplaceDirentPath extends rewrite_1.Recipe {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.name = "org.openrewrite.node.migrate.fs.replace-dirent-path";
|
|
20
|
+
this.displayName = "Replace `dirent.path` with `dirent.parentPath`";
|
|
21
|
+
this.description = "Replaces deprecated `dirent.path` property access with `dirent.parentPath` " +
|
|
22
|
+
"on `fs.Dirent` instances to address DEP0178 deprecation.";
|
|
23
|
+
this.tags = ["DEP0178"];
|
|
24
|
+
}
|
|
25
|
+
editor() {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return new class extends javascript_1.JavaScriptVisitor {
|
|
28
|
+
isDirentType(type) {
|
|
29
|
+
if (!type)
|
|
30
|
+
return false;
|
|
31
|
+
if (type.kind === java_1.Type.Kind.Class) {
|
|
32
|
+
const classType = type;
|
|
33
|
+
const fqn = classType.fullyQualifiedName;
|
|
34
|
+
return fqn === "fs.Dirent" || fqn === "node:fs.Dirent";
|
|
35
|
+
}
|
|
36
|
+
if (type.kind === java_1.Type.Kind.Parameterized) {
|
|
37
|
+
const paramType = type;
|
|
38
|
+
return this.isDirentType(paramType.type);
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
isDirentPathAccess(fieldAccess) {
|
|
43
|
+
if (fieldAccess.name.element.simpleName !== "path") {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return this.isDirentType(fieldAccess.target.type);
|
|
47
|
+
}
|
|
48
|
+
visitFieldAccess(fieldAccess, p) {
|
|
49
|
+
const _super = Object.create(null, {
|
|
50
|
+
visitFieldAccess: { get: () => super.visitFieldAccess }
|
|
51
|
+
});
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const fa = yield _super.visitFieldAccess.call(this, fieldAccess, p);
|
|
54
|
+
if (this.isDirentPathAccess(fa)) {
|
|
55
|
+
return (0, javascript_1.template) `${fa.target}.parentPath`.apply(fa, this.cursor);
|
|
56
|
+
}
|
|
57
|
+
return fa;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.ReplaceDirentPath = ReplaceDirentPath;
|
|
65
|
+
//# sourceMappingURL=dirent-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dirent-path.js","sourceRoot":"","sources":["../../src/migrate/dirent-path.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2E;AAC3E,gEAA4E;AAC5E,oDAAkD;AAElD,MAAa,iBAAkB,SAAQ,gBAAM;IAA7C;;QACa,SAAI,GAAG,qDAAqD,CAAA;QAC5D,gBAAW,GAAW,gDAAgD,CAAC;QACvE,gBAAW,GAAW,6EAA6E;YACxG,0DAA0D,CAAC;QACtD,SAAI,GAAa,CAAC,SAAS,CAAC,CAAC;IAwC1C,CAAC;IAtCS,MAAM;;YACR,OAAO,IAAI,KAAM,SAAQ,8BAAmC;gBAEhD,YAAY,CAAC,IAAsB;oBACvC,IAAI,CAAC,IAAI;wBAAE,OAAO,KAAK,CAAC;oBAExB,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,KAAK,WAAW,IAAI,GAAG,KAAK,gBAAgB,CAAC;oBAC3D,CAAC;oBAED,IAAI,IAAI,CAAC,IAAI,KAAK,WAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;wBACxC,MAAM,SAAS,GAAG,IAA0B,CAAC;wBAC7C,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;oBAC7C,CAAC;oBAED,OAAO,KAAK,CAAC;gBACjB,CAAC;gBAEO,kBAAkB,CAAC,WAA0B;oBACjD,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;wBACjD,OAAO,KAAK,CAAC;oBACjB,CAAC;oBACD,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACtD,CAAC;gBAEe,gBAAgB,CAAC,WAA0B,EAAE,CAAmB;;;;;wBAC5E,MAAM,EAAE,GAAG,MAAM,OAAM,gBAAgB,YAAC,WAAW,EAAE,CAAC,CAAkB,CAAC;wBAEzE,IAAI,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC;4BAC9B,OAAO,IAAA,qBAAQ,EAAA,GAAG,EAAE,CAAC,MAAM,aAAa,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;wBACpE,CAAC;wBAED,OAAO,EAAE,CAAC;oBACd,CAAC;iBAAA;aACJ,CAAC;QACN,CAAC;KAAA;CACJ;AA7CD,8CA6CC"}
|
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-20251128-143647",
|
|
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
|
@@ -10,6 +10,7 @@ import {ReplaceSlowBuffer} from "./migrate/slow-buffer";
|
|
|
10
10
|
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
|
+
import {ReplaceDirentPath} from "./migrate/dirent-path";
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
export function activate(registry: RecipeRegistry) {
|
|
@@ -24,4 +25,5 @@ export function activate(registry: RecipeRegistry) {
|
|
|
24
25
|
registry.register(ReplaceFsAccessConstants);
|
|
25
26
|
registry.register(RemovePromisifyOnPromise);
|
|
26
27
|
registry.register(AvoidImplicitCoercionOfExitCode);
|
|
28
|
+
registry.register(ReplaceDirentPath);
|
|
27
29
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 ReplaceDirentPath extends Recipe {
|
|
6
|
+
readonly name = "org.openrewrite.node.migrate.fs.replace-dirent-path"
|
|
7
|
+
readonly displayName: string = "Replace `dirent.path` with `dirent.parentPath`";
|
|
8
|
+
readonly description: string = "Replaces deprecated `dirent.path` property access with `dirent.parentPath` " +
|
|
9
|
+
"on `fs.Dirent` instances to address DEP0178 deprecation.";
|
|
10
|
+
readonly tags: string[] = ["DEP0178"];
|
|
11
|
+
|
|
12
|
+
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
13
|
+
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
14
|
+
|
|
15
|
+
private isDirentType(type: Type | undefined): boolean {
|
|
16
|
+
if (!type) return false;
|
|
17
|
+
|
|
18
|
+
if (type.kind === Type.Kind.Class) {
|
|
19
|
+
const classType = type as Type.Class;
|
|
20
|
+
const fqn = classType.fullyQualifiedName;
|
|
21
|
+
return fqn === "fs.Dirent" || fqn === "node:fs.Dirent";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (type.kind === Type.Kind.Parameterized) {
|
|
25
|
+
const paramType = type as Type.Parameterized;
|
|
26
|
+
return this.isDirentType(paramType.type);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private isDirentPathAccess(fieldAccess: J.FieldAccess): boolean {
|
|
33
|
+
if (fieldAccess.name.element.simpleName !== "path") {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return this.isDirentType(fieldAccess.target.type);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
protected async visitFieldAccess(fieldAccess: J.FieldAccess, p: ExecutionContext): Promise<J | undefined> {
|
|
40
|
+
const fa = await super.visitFieldAccess(fieldAccess, p) as J.FieldAccess;
|
|
41
|
+
|
|
42
|
+
if (this.isDirentPathAccess(fa)) {
|
|
43
|
+
return template`${fa.target}.parentPath`.apply(fa, this.cursor);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return fa;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|