@openrewrite/rewrite 8.83.3 → 8.83.5
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 +1 -5
- package/dist/index.js.map +1 -1
- package/dist/java/rpc.d.ts.map +1 -1
- package/dist/java/rpc.js +2 -0
- package/dist/java/rpc.js.map +1 -1
- package/dist/java/tree.d.ts +1 -0
- package/dist/java/tree.d.ts.map +1 -1
- package/dist/java/tree.js.map +1 -1
- package/dist/java/visitor.d.ts.map +1 -1
- package/dist/java/visitor.js +1 -0
- package/dist/java/visitor.js.map +1 -1
- package/dist/javascript/parser.d.ts.map +1 -1
- package/dist/javascript/parser.js +8 -0
- package/dist/javascript/parser.js.map +1 -1
- package/dist/javascript/recipes/dependencies.d.ts +63 -0
- package/dist/javascript/recipes/dependencies.d.ts.map +1 -0
- package/dist/javascript/recipes/dependencies.js +49 -0
- package/dist/javascript/recipes/dependencies.js.map +1 -0
- package/dist/javascript/recipes/index.d.ts +1 -4
- package/dist/javascript/recipes/index.d.ts.map +1 -1
- package/dist/javascript/recipes/index.js +1 -4
- package/dist/javascript/recipes/index.js.map +1 -1
- package/dist/rewrite-javascript-version.txt +1 -1
- package/dist/rpc/index.d.ts +1 -0
- package/dist/rpc/index.d.ts.map +1 -1
- package/dist/rpc/index.js +3 -1
- package/dist/rpc/index.js.map +1 -1
- package/dist/rpc/java-recipe.d.ts +33 -0
- package/dist/rpc/java-recipe.d.ts.map +1 -0
- package/dist/rpc/java-recipe.js +61 -0
- package/dist/rpc/java-recipe.js.map +1 -0
- package/dist/rpc/java-rpc-client.d.ts +65 -0
- package/dist/rpc/java-rpc-client.d.ts.map +1 -0
- package/dist/rpc/java-rpc-client.js +221 -0
- package/dist/rpc/java-rpc-client.js.map +1 -0
- package/dist/rpc/rewrite-rpc.d.ts +9 -0
- package/dist/rpc/rewrite-rpc.d.ts.map +1 -1
- package/dist/rpc/rewrite-rpc.js +23 -1
- package/dist/rpc/rewrite-rpc.js.map +1 -1
- package/dist/test/java-rpc.d.ts +46 -0
- package/dist/test/java-rpc.d.ts.map +1 -0
- package/dist/test/java-rpc.js +79 -0
- package/dist/test/java-rpc.js.map +1 -0
- package/package.json +5 -1
- package/src/index.ts +0 -8
- package/src/java/rpc.ts +2 -0
- package/src/java/tree.ts +1 -0
- package/src/java/visitor.ts +1 -0
- package/src/javascript/parser.ts +8 -0
- package/src/javascript/recipes/dependencies.ts +108 -0
- package/src/javascript/recipes/index.ts +1 -4
- package/src/rpc/index.ts +1 -0
- package/src/rpc/java-recipe.ts +64 -0
- package/src/rpc/java-rpc-client.ts +220 -0
- package/src/rpc/rewrite-rpc.ts +34 -6
- package/src/test/java-rpc.ts +93 -0
- package/dist/javascript/recipes/add-dependency.d.ts +0 -61
- package/dist/javascript/recipes/add-dependency.d.ts.map +0 -1
- package/dist/javascript/recipes/add-dependency.js +0 -430
- package/dist/javascript/recipes/add-dependency.js.map +0 -1
- package/dist/javascript/recipes/remove-dependency.d.ts +0 -29
- package/dist/javascript/recipes/remove-dependency.d.ts.map +0 -1
- package/dist/javascript/recipes/remove-dependency.js +0 -261
- package/dist/javascript/recipes/remove-dependency.js.map +0 -1
- package/dist/javascript/recipes/upgrade-dependency-version.d.ts +0 -74
- package/dist/javascript/recipes/upgrade-dependency-version.d.ts.map +0 -1
- package/dist/javascript/recipes/upgrade-dependency-version.js +0 -387
- package/dist/javascript/recipes/upgrade-dependency-version.js.map +0 -1
- package/dist/javascript/recipes/upgrade-transitive-dependency-version.d.ts +0 -68
- package/dist/javascript/recipes/upgrade-transitive-dependency-version.d.ts.map +0 -1
- package/dist/javascript/recipes/upgrade-transitive-dependency-version.js +0 -307
- package/dist/javascript/recipes/upgrade-transitive-dependency-version.js.map +0 -1
- package/src/javascript/recipes/add-dependency.ts +0 -549
- package/src/javascript/recipes/remove-dependency.ts +0 -345
- package/src/javascript/recipes/upgrade-dependency-version.ts +0 -486
- package/src/javascript/recipes/upgrade-transitive-dependency-version.ts +0 -403
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Recipe } from "../../recipe";
|
|
2
|
+
/**
|
|
3
|
+
* Scope of an npm dependency entry. Maps to the keys in `package.json` that
|
|
4
|
+
* the dependency-management recipes accept; `null` / undefined means the
|
|
5
|
+
* recipe's default (typically `"dependencies"`).
|
|
6
|
+
*/
|
|
7
|
+
export type NpmDependencyScope = "dependencies" | "devDependencies" | "peerDependencies" | "optionalDependencies";
|
|
8
|
+
export interface AddDependencyOptions {
|
|
9
|
+
packageName: string;
|
|
10
|
+
version: string;
|
|
11
|
+
scope?: NpmDependencyScope;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Add an npm dependency to `package.json`, regenerate the lock file, and
|
|
15
|
+
* refresh the `NodeResolutionResult` marker. Delegates to the Java recipe
|
|
16
|
+
* `org.openrewrite.javascript.AddDependency` via RPC.
|
|
17
|
+
*/
|
|
18
|
+
export declare function addDependency(options: AddDependencyOptions): Promise<Recipe>;
|
|
19
|
+
export interface RemoveDependencyOptions {
|
|
20
|
+
packageName: string;
|
|
21
|
+
scope?: NpmDependencyScope;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Remove an npm dependency from `package.json`, regenerate the lock file, and
|
|
25
|
+
* refresh the `NodeResolutionResult` marker. Delegates to the Java recipe
|
|
26
|
+
* `org.openrewrite.javascript.RemoveDependency` via RPC.
|
|
27
|
+
*/
|
|
28
|
+
export declare function removeDependency(options: RemoveDependencyOptions): Promise<Recipe>;
|
|
29
|
+
export interface UpgradeDependencyVersionOptions {
|
|
30
|
+
packageName?: string;
|
|
31
|
+
packagePattern?: string;
|
|
32
|
+
newVersion: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Upgrade an npm dependency to a new version (exactly one of `packageName` or
|
|
36
|
+
* `packagePattern` must be provided). Delegates to the Java recipe
|
|
37
|
+
* `org.openrewrite.javascript.UpgradeDependencyVersion` via RPC.
|
|
38
|
+
*/
|
|
39
|
+
export declare function upgradeDependencyVersion(options: UpgradeDependencyVersionOptions): Promise<Recipe>;
|
|
40
|
+
export interface ChangeDependencyOptions {
|
|
41
|
+
oldPackageName: string;
|
|
42
|
+
newPackageName: string;
|
|
43
|
+
newVersion?: string;
|
|
44
|
+
scope?: NpmDependencyScope;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Rename a dependency (and optionally pin a new version) in `package.json`.
|
|
48
|
+
* Delegates to the Java recipe `org.openrewrite.javascript.ChangeDependency`
|
|
49
|
+
* via RPC.
|
|
50
|
+
*/
|
|
51
|
+
export declare function changeDependency(options: ChangeDependencyOptions): Promise<Recipe>;
|
|
52
|
+
export interface UpgradeTransitiveDependencyVersionOptions {
|
|
53
|
+
packageName: string;
|
|
54
|
+
newVersion: string;
|
|
55
|
+
dependencyPath?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Upgrade a transitive npm dependency via an `overrides`/`resolutions` block.
|
|
59
|
+
* Delegates to the Java recipe
|
|
60
|
+
* `org.openrewrite.javascript.UpgradeTransitiveDependencyVersion` via RPC.
|
|
61
|
+
*/
|
|
62
|
+
export declare function upgradeTransitiveDependencyVersion(options: UpgradeTransitiveDependencyVersionOptions): Promise<Recipe>;
|
|
63
|
+
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../src/javascript/recipes/dependencies.ts"],"names":[],"mappings":"AAeA,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAGpC;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GACxB,cAAc,GACd,iBAAiB,GACjB,kBAAkB,GAClB,sBAAsB,CAAC;AAE7B,MAAM,WAAW,oBAAoB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CAE5E;AAED,MAAM,WAAW,uBAAuB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAElF;AAED,MAAM,WAAW,+BAA+B;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,MAAM,CAAC,CAElG;AAED,MAAM,WAAW,uBAAuB;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAElF;AAED,MAAM,WAAW,yCAAyC;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CAC9C,OAAO,EAAE,yCAAyC,GACnD,OAAO,CAAC,MAAM,CAAC,CAKjB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addDependency = addDependency;
|
|
4
|
+
exports.removeDependency = removeDependency;
|
|
5
|
+
exports.upgradeDependencyVersion = upgradeDependencyVersion;
|
|
6
|
+
exports.changeDependency = changeDependency;
|
|
7
|
+
exports.upgradeTransitiveDependencyVersion = upgradeTransitiveDependencyVersion;
|
|
8
|
+
const java_recipe_1 = require("../../rpc/java-recipe");
|
|
9
|
+
/**
|
|
10
|
+
* Add an npm dependency to `package.json`, regenerate the lock file, and
|
|
11
|
+
* refresh the `NodeResolutionResult` marker. Delegates to the Java recipe
|
|
12
|
+
* `org.openrewrite.javascript.AddDependency` via RPC.
|
|
13
|
+
*/
|
|
14
|
+
function addDependency(options) {
|
|
15
|
+
return (0, java_recipe_1.prepareJavaRecipe)("org.openrewrite.javascript.AddDependency", options);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Remove an npm dependency from `package.json`, regenerate the lock file, and
|
|
19
|
+
* refresh the `NodeResolutionResult` marker. Delegates to the Java recipe
|
|
20
|
+
* `org.openrewrite.javascript.RemoveDependency` via RPC.
|
|
21
|
+
*/
|
|
22
|
+
function removeDependency(options) {
|
|
23
|
+
return (0, java_recipe_1.prepareJavaRecipe)("org.openrewrite.javascript.RemoveDependency", options);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Upgrade an npm dependency to a new version (exactly one of `packageName` or
|
|
27
|
+
* `packagePattern` must be provided). Delegates to the Java recipe
|
|
28
|
+
* `org.openrewrite.javascript.UpgradeDependencyVersion` via RPC.
|
|
29
|
+
*/
|
|
30
|
+
function upgradeDependencyVersion(options) {
|
|
31
|
+
return (0, java_recipe_1.prepareJavaRecipe)("org.openrewrite.javascript.UpgradeDependencyVersion", options);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Rename a dependency (and optionally pin a new version) in `package.json`.
|
|
35
|
+
* Delegates to the Java recipe `org.openrewrite.javascript.ChangeDependency`
|
|
36
|
+
* via RPC.
|
|
37
|
+
*/
|
|
38
|
+
function changeDependency(options) {
|
|
39
|
+
return (0, java_recipe_1.prepareJavaRecipe)("org.openrewrite.javascript.ChangeDependency", options);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Upgrade a transitive npm dependency via an `overrides`/`resolutions` block.
|
|
43
|
+
* Delegates to the Java recipe
|
|
44
|
+
* `org.openrewrite.javascript.UpgradeTransitiveDependencyVersion` via RPC.
|
|
45
|
+
*/
|
|
46
|
+
function upgradeTransitiveDependencyVersion(options) {
|
|
47
|
+
return (0, java_recipe_1.prepareJavaRecipe)("org.openrewrite.javascript.UpgradeTransitiveDependencyVersion", options);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../src/javascript/recipes/dependencies.ts"],"names":[],"mappings":";;AAwCA,sCAEC;AAYD,4CAEC;AAaD,4DAEC;AAcD,4CAEC;AAaD,gFAOC;AA3FD,uDAAwD;AAmBxD;;;;GAIG;AACH,SAAgB,aAAa,CAAC,OAA6B;IACvD,OAAO,IAAA,+BAAiB,EAAC,0CAA0C,EAAE,OAAO,CAAC,CAAC;AAClF,CAAC;AAOD;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,OAAgC;IAC7D,OAAO,IAAA,+BAAiB,EAAC,6CAA6C,EAAE,OAAO,CAAC,CAAC;AACrF,CAAC;AAQD;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,OAAwC;IAC7E,OAAO,IAAA,+BAAiB,EAAC,qDAAqD,EAAE,OAAO,CAAC,CAAC;AAC7F,CAAC;AASD;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,OAAgC;IAC7D,OAAO,IAAA,+BAAiB,EAAC,6CAA6C,EAAE,OAAO,CAAC,CAAC;AACrF,CAAC;AAQD;;;;GAIG;AACH,SAAgB,kCAAkC,CAC9C,OAAkD;IAElD,OAAO,IAAA,+BAAiB,EACpB,+DAA+D,EAC/D,OAAO,CACV,CAAC;AACN,CAAC"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
export * from "./add-dependency";
|
|
2
1
|
export * from "./async-callback-in-sync-array-method";
|
|
3
2
|
export * from "./auto-format";
|
|
4
|
-
export * from "./remove-dependency";
|
|
5
|
-
export * from "./upgrade-dependency-version";
|
|
6
|
-
export * from "./upgrade-transitive-dependency-version";
|
|
7
3
|
export * from "./order-imports";
|
|
8
4
|
export * from "./change-import";
|
|
5
|
+
export * from "./dependencies";
|
|
9
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/javascript/recipes/index.ts"],"names":[],"mappings":"AAgBA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/javascript/recipes/index.ts"],"names":[],"mappings":"AAgBA,cAAc,uCAAuC,CAAC;AACtD,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
|
|
@@ -29,12 +29,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
29
29
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
__exportStar(require("./add-dependency"), exports);
|
|
33
32
|
__exportStar(require("./async-callback-in-sync-array-method"), exports);
|
|
34
33
|
__exportStar(require("./auto-format"), exports);
|
|
35
|
-
__exportStar(require("./remove-dependency"), exports);
|
|
36
|
-
__exportStar(require("./upgrade-dependency-version"), exports);
|
|
37
|
-
__exportStar(require("./upgrade-transitive-dependency-version"), exports);
|
|
38
34
|
__exportStar(require("./order-imports"), exports);
|
|
39
35
|
__exportStar(require("./change-import"), exports);
|
|
36
|
+
__exportStar(require("./dependencies"), exports);
|
|
40
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/javascript/recipes/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/javascript/recipes/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,wEAAsD;AACtD,gDAA8B;AAC9B,kDAAgC;AAChC,kDAAgC;AAChC,iDAA+B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
8.83.
|
|
1
|
+
8.83.5
|
package/dist/rpc/index.d.ts
CHANGED
package/dist/rpc/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rpc/index.ts"],"names":[],"mappings":"AAqBA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rpc/index.ts"],"names":[],"mappings":"AAqBA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC"}
|
package/dist/rpc/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.RewriteRpc = void 0;
|
|
17
|
+
exports.prepareJavaRecipe = exports.RewriteRpc = void 0;
|
|
18
18
|
/*
|
|
19
19
|
* Copyright 2025 the original author or authors.
|
|
20
20
|
* <p>
|
|
@@ -39,6 +39,8 @@ __exportStar(require("./queue"), exports);
|
|
|
39
39
|
__exportStar(require("../reference"), exports);
|
|
40
40
|
var rewrite_rpc_1 = require("./rewrite-rpc");
|
|
41
41
|
Object.defineProperty(exports, "RewriteRpc", { enumerable: true, get: function () { return rewrite_rpc_1.RewriteRpc; } });
|
|
42
|
+
var java_recipe_1 = require("./java-recipe");
|
|
43
|
+
Object.defineProperty(exports, "prepareJavaRecipe", { enumerable: true, get: function () { return java_recipe_1.prepareJavaRecipe; } });
|
|
42
44
|
queue_1.RpcCodecs.registerCodec(tree_1.TreeKind.Checksum, {
|
|
43
45
|
async rpcReceive(before, q) {
|
|
44
46
|
return (0, util_1.updateIfChanged)(before, {
|
package/dist/rpc/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rpc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,kCAA2D;AAC3D,mCAAiE;AACjE,wCAAgH;AAChH,4CAAmC;AACnC,kCAAwC;AAExC,0CAAwB;AACxB,+CAA6B;AAC7B,6CAAyC;AAAjC,yGAAA,UAAU,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rpc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,kCAA2D;AAC3D,mCAAiE;AACjE,wCAAgH;AAChH,4CAAmC;AACnC,kCAAwC;AAExC,0CAAwB;AACxB,+CAA6B;AAC7B,6CAAyC;AAAjC,yGAAA,UAAU,OAAA;AAClB,6CAAgD;AAAxC,gHAAA,iBAAiB,OAAA;AAEzB,iBAAS,CAAC,aAAa,CAAC,eAAQ,CAAC,QAAQ,EAAE;IACvC,KAAK,CAAC,UAAU,CAAC,MAAgB,EAAE,CAAkB;QACjD,OAAO,IAAA,sBAAe,EAAC,MAAM,EAAE;YAC3B,SAAS,EAAE,MAAM,CAAC,CAAC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C,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACrC,MAAM,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RpcRecipe } from "./recipe";
|
|
2
|
+
/**
|
|
3
|
+
* Prepare a Java recipe via the active {@link RewriteRpc} connection.
|
|
4
|
+
*
|
|
5
|
+
* Routes a `PrepareRecipe` request to whichever side hosts the Java
|
|
6
|
+
* implementation:
|
|
7
|
+
* - in production, the Java host that spawned the TS server (`dist/rpc/server.js`);
|
|
8
|
+
* - in tests, the JVM spawned via `JavaRpcTestServer` (see
|
|
9
|
+
* `@openrewrite/rewrite/test/java-rpc`).
|
|
10
|
+
*
|
|
11
|
+
* The returned {@link RpcRecipe} extends `Recipe`, so it can be used directly
|
|
12
|
+
* as a recipe — e.g. assigned to `RecipeSpec.recipe` — or composed inside a
|
|
13
|
+
* larger TS recipe (as the editor of a `check(usesType(...), ...)`
|
|
14
|
+
* precondition, or as a step in `recipeList()`).
|
|
15
|
+
*
|
|
16
|
+
* Top-level convenience functions for specific Java recipes (e.g.
|
|
17
|
+
* `addDependency`, `changeType`) sit naturally on top of this primitive:
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* export function addDependency(options: AddDependencyOptions): Promise<Recipe> {
|
|
21
|
+
* return prepareJavaRecipe("org.openrewrite.javascript.AddDependency", options);
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* There is no in-process fallback by design: a Java recipe's editor is the
|
|
26
|
+
* single source of truth — we don't reimplement editing recipes in TS. For
|
|
27
|
+
* preconditions that need a graceful no-RPC fallback, use the {@link RecipeRef}
|
|
28
|
+
* pattern via `usesType` / `usesMethod`, which carries a `localVisitor`.
|
|
29
|
+
*
|
|
30
|
+
* @throws Error when no active {@link RewriteRpc} connection is registered.
|
|
31
|
+
*/
|
|
32
|
+
export declare function prepareJavaRecipe(id: string, options?: Record<string, any>): Promise<RpcRecipe>;
|
|
33
|
+
//# sourceMappingURL=java-recipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java-recipe.d.ts","sourceRoot":"","sources":["../../src/rpc/java-recipe.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,iBAAiB,CACnC,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC9B,OAAO,CAAC,SAAS,CAAC,CAYpB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prepareJavaRecipe = prepareJavaRecipe;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2025 the original author or authors.
|
|
6
|
+
* <p>
|
|
7
|
+
* Licensed under the Moderne Source Available License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
* <p>
|
|
11
|
+
* https://docs.moderne.io/licensing/moderne-source-available-license
|
|
12
|
+
* <p>
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
const rewrite_rpc_1 = require("./rewrite-rpc");
|
|
20
|
+
/**
|
|
21
|
+
* Prepare a Java recipe via the active {@link RewriteRpc} connection.
|
|
22
|
+
*
|
|
23
|
+
* Routes a `PrepareRecipe` request to whichever side hosts the Java
|
|
24
|
+
* implementation:
|
|
25
|
+
* - in production, the Java host that spawned the TS server (`dist/rpc/server.js`);
|
|
26
|
+
* - in tests, the JVM spawned via `JavaRpcTestServer` (see
|
|
27
|
+
* `@openrewrite/rewrite/test/java-rpc`).
|
|
28
|
+
*
|
|
29
|
+
* The returned {@link RpcRecipe} extends `Recipe`, so it can be used directly
|
|
30
|
+
* as a recipe — e.g. assigned to `RecipeSpec.recipe` — or composed inside a
|
|
31
|
+
* larger TS recipe (as the editor of a `check(usesType(...), ...)`
|
|
32
|
+
* precondition, or as a step in `recipeList()`).
|
|
33
|
+
*
|
|
34
|
+
* Top-level convenience functions for specific Java recipes (e.g.
|
|
35
|
+
* `addDependency`, `changeType`) sit naturally on top of this primitive:
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* export function addDependency(options: AddDependencyOptions): Promise<Recipe> {
|
|
39
|
+
* return prepareJavaRecipe("org.openrewrite.javascript.AddDependency", options);
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* There is no in-process fallback by design: a Java recipe's editor is the
|
|
44
|
+
* single source of truth — we don't reimplement editing recipes in TS. For
|
|
45
|
+
* preconditions that need a graceful no-RPC fallback, use the {@link RecipeRef}
|
|
46
|
+
* pattern via `usesType` / `usesMethod`, which carries a `localVisitor`.
|
|
47
|
+
*
|
|
48
|
+
* @throws Error when no active {@link RewriteRpc} connection is registered.
|
|
49
|
+
*/
|
|
50
|
+
async function prepareJavaRecipe(id, options) {
|
|
51
|
+
const rpc = rewrite_rpc_1.RewriteRpc.get();
|
|
52
|
+
if (!rpc) {
|
|
53
|
+
throw new Error(`Cannot prepare Java recipe "${id}": no active RewriteRpc connection.\n` +
|
|
54
|
+
" • Tests: spawn one via JavaRpcTestServer.start() — see " +
|
|
55
|
+
"@openrewrite/rewrite/test/java-rpc.\n" +
|
|
56
|
+
" • Production: the Java host provides one automatically when it " +
|
|
57
|
+
"loads the TS recipe artifact.");
|
|
58
|
+
}
|
|
59
|
+
return rpc.prepareRecipe(id, options);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=java-recipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java-recipe.js","sourceRoot":"","sources":["../../src/rpc/java-recipe.ts"],"names":[],"mappings":";;AAgDA,8CAeC;AA/DD;;;;;;;;;;;;;;GAcG;AACH,+CAAyC;AAGzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACI,KAAK,UAAU,iBAAiB,CACnC,EAAU,EACV,OAA6B;IAE7B,MAAM,GAAG,GAAG,wBAAU,CAAC,GAAG,EAAE,CAAC;IAC7B,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,MAAM,IAAI,KAAK,CACX,+BAA+B,EAAE,uCAAuC;YACxE,2DAA2D;YAC3D,uCAAuC;YACvC,mEAAmE;YACnE,+BAA+B,CAClC,CAAC;IACN,CAAC;IACD,OAAO,GAAG,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as rpc from "vscode-jsonrpc/node";
|
|
2
|
+
import { RewriteRpc } from "./rewrite-rpc";
|
|
3
|
+
import { RecipeMarketplace } from "../marketplace";
|
|
4
|
+
export interface JavaRpcOptions {
|
|
5
|
+
/** Explicit classpath override. Falls back to env var, then test-classpath.txt. */
|
|
6
|
+
classpath?: string;
|
|
7
|
+
/** JAVA_HOME to use. Falls back to process.env.JAVA_HOME, then `java` on PATH. */
|
|
8
|
+
javaHome?: string;
|
|
9
|
+
/** Optional logger forwarded to the underlying RewriteRpc instance. */
|
|
10
|
+
logger?: rpc.Logger;
|
|
11
|
+
/** Optional path to a marketplace CSV — passed via `--marketplace=` to the Java process. */
|
|
12
|
+
marketplaceCsv?: string;
|
|
13
|
+
/** Enable RPC tracing on the Java side (passed as `--trace`). */
|
|
14
|
+
trace?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Pre-built {@link RecipeMarketplace} for the TS-side {@link RewriteRpc} instance
|
|
17
|
+
* only. Does NOT configure the Java side — for that, use {@link marketplaceCsv}.
|
|
18
|
+
*/
|
|
19
|
+
marketplace?: RecipeMarketplace;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Test-only wrapper around a spawned `org.openrewrite.maven.rpc.JavaRewriteRpc` process,
|
|
23
|
+
* exposing a {@link RewriteRpc} client wired to its stdio over JSON-RPC.
|
|
24
|
+
*
|
|
25
|
+
* Typical use:
|
|
26
|
+
* ```
|
|
27
|
+
* const server = await JavaRpcTestServer.start();
|
|
28
|
+
* try {
|
|
29
|
+
* const recipe = await server.rpc.prepareRecipe("org.openrewrite.text.FindAndReplace", {...});
|
|
30
|
+
* const result = await server.rpc.visit(parsed, recipe.editVisitor, ctx);
|
|
31
|
+
* } finally {
|
|
32
|
+
* await server.dispose();
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class JavaRpcTestServer {
|
|
37
|
+
private readonly child;
|
|
38
|
+
readonly rpc: RewriteRpc;
|
|
39
|
+
private constructor();
|
|
40
|
+
/** Spawn the Java RPC server and connect a {@link RewriteRpc} client to its stdio. */
|
|
41
|
+
static start(opts?: JavaRpcOptions): Promise<JavaRpcTestServer>;
|
|
42
|
+
/**
|
|
43
|
+
* Reset accumulated state on both the Java side and the TS-side
|
|
44
|
+
* {@link RewriteRpc} caches so the next test starts clean.
|
|
45
|
+
*/
|
|
46
|
+
reset(): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* End the JSON-RPC connection and wait for the Java process to exit. Falls back
|
|
49
|
+
* to SIGKILL after a short grace period to ensure no orphan JVMs are left behind.
|
|
50
|
+
*/
|
|
51
|
+
dispose(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Find the classpath for spawning the Java RPC server.
|
|
55
|
+
*
|
|
56
|
+
* Resolution order:
|
|
57
|
+
* 1. `REWRITE_JAVASCRIPT_CLASSPATH` environment variable.
|
|
58
|
+
* 2. `test-classpath.txt` written by the `:rewrite-javascript:generateTestClasspath`
|
|
59
|
+
* Gradle task. Walks up from this source file (works both when running directly
|
|
60
|
+
* via vitest and when running from `dist/`).
|
|
61
|
+
*
|
|
62
|
+
* @returns the classpath string, or `undefined` if no source is configured.
|
|
63
|
+
*/
|
|
64
|
+
export declare function findTestClasspath(): string | undefined;
|
|
65
|
+
//# sourceMappingURL=java-rpc-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java-rpc-client.d.ts","sourceRoot":"","sources":["../../src/rpc/java-rpc-client.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAEjD,MAAM,WAAW,cAAc;IAC3B,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;IACpB,4FAA4F;IAC5F,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iEAAiE;IACjE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,iBAAiB;IAEtB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,QAAQ,CAAC,GAAG,EAAE,UAAU;IAF5B,OAAO;IAMP,sFAAsF;WACzE,KAAK,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAsEzE;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CA6BjC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAoBtD"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.JavaRpcTestServer = void 0;
|
|
37
|
+
exports.findTestClasspath = findTestClasspath;
|
|
38
|
+
/*
|
|
39
|
+
* Copyright 2025 the original author or authors.
|
|
40
|
+
* <p>
|
|
41
|
+
* Licensed under the Moderne Source Available License (the "License");
|
|
42
|
+
* you may not use this file except in compliance with the License.
|
|
43
|
+
* You may obtain a copy of the License at
|
|
44
|
+
* <p>
|
|
45
|
+
* https://docs.moderne.io/licensing/moderne-source-available-license
|
|
46
|
+
* <p>
|
|
47
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
48
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
49
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
50
|
+
* See the License for the specific language governing permissions and
|
|
51
|
+
* limitations under the License.
|
|
52
|
+
*/
|
|
53
|
+
const fs = __importStar(require("node:fs"));
|
|
54
|
+
const path = __importStar(require("node:path"));
|
|
55
|
+
const readline = __importStar(require("node:readline"));
|
|
56
|
+
const node_child_process_1 = require("node:child_process");
|
|
57
|
+
const rpc = __importStar(require("vscode-jsonrpc/node"));
|
|
58
|
+
const rewrite_rpc_1 = require("./rewrite-rpc");
|
|
59
|
+
/**
|
|
60
|
+
* Test-only wrapper around a spawned `org.openrewrite.maven.rpc.JavaRewriteRpc` process,
|
|
61
|
+
* exposing a {@link RewriteRpc} client wired to its stdio over JSON-RPC.
|
|
62
|
+
*
|
|
63
|
+
* Typical use:
|
|
64
|
+
* ```
|
|
65
|
+
* const server = await JavaRpcTestServer.start();
|
|
66
|
+
* try {
|
|
67
|
+
* const recipe = await server.rpc.prepareRecipe("org.openrewrite.text.FindAndReplace", {...});
|
|
68
|
+
* const result = await server.rpc.visit(parsed, recipe.editVisitor, ctx);
|
|
69
|
+
* } finally {
|
|
70
|
+
* await server.dispose();
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
class JavaRpcTestServer {
|
|
75
|
+
constructor(child, rpc) {
|
|
76
|
+
this.child = child;
|
|
77
|
+
this.rpc = rpc;
|
|
78
|
+
}
|
|
79
|
+
/** Spawn the Java RPC server and connect a {@link RewriteRpc} client to its stdio. */
|
|
80
|
+
static async start(opts = {}) {
|
|
81
|
+
var _a;
|
|
82
|
+
const classpath = (_a = opts.classpath) !== null && _a !== void 0 ? _a : findTestClasspath();
|
|
83
|
+
if (!classpath) {
|
|
84
|
+
throw new Error("Java RPC test classpath not configured. " +
|
|
85
|
+
"Run `./gradlew :rewrite-javascript:generateTestClasspath`, " +
|
|
86
|
+
"or set REWRITE_JAVASCRIPT_CLASSPATH.");
|
|
87
|
+
}
|
|
88
|
+
const javaCmd = resolveJavaCommand(opts.javaHome);
|
|
89
|
+
const args = ["-cp", classpath, "org.openrewrite.maven.rpc.JavaRewriteRpc"];
|
|
90
|
+
if (opts.marketplaceCsv)
|
|
91
|
+
args.push(`--marketplace=${opts.marketplaceCsv}`);
|
|
92
|
+
if (opts.trace)
|
|
93
|
+
args.push("--trace");
|
|
94
|
+
const child = (0, node_child_process_1.spawn)(javaCmd, args);
|
|
95
|
+
// Forward Java stderr line-by-line so stack traces surface in the test output.
|
|
96
|
+
// `readline` handles partial-line buffering and flushes a non-newline-terminated
|
|
97
|
+
// final line on `close` (a hand-rolled split would silently drop it).
|
|
98
|
+
readline.createInterface({ input: child.stderr, crlfDelay: Infinity })
|
|
99
|
+
.on("line", line => {
|
|
100
|
+
if (line.length > 0)
|
|
101
|
+
process.stderr.write(`[Java RPC] ${line}\n`);
|
|
102
|
+
});
|
|
103
|
+
// If the JVM dies before we can talk to it, surface that immediately rather
|
|
104
|
+
// than letting the first RPC request hang waiting for a response. Capture the
|
|
105
|
+
// listener so we can detach it after the race resolves — otherwise the normal
|
|
106
|
+
// exit during dispose() fires it, rejecting a Promise nobody is observing
|
|
107
|
+
// (UnhandledPromiseRejection under Node 15+).
|
|
108
|
+
let onEarlyExit;
|
|
109
|
+
const earlyExit = new Promise((_, reject) => {
|
|
110
|
+
onEarlyExit = (code, signal) => {
|
|
111
|
+
reject(new Error(`Java RPC server exited before any request was sent ` +
|
|
112
|
+
`(code=${code}, signal=${signal}). Check the [Java RPC] stderr above.`));
|
|
113
|
+
};
|
|
114
|
+
child.once("exit", onEarlyExit);
|
|
115
|
+
});
|
|
116
|
+
const connection = rpc.createMessageConnection(new rpc.StreamMessageReader(child.stdout), new rpc.StreamMessageWriter(child.stdin), opts.logger);
|
|
117
|
+
// RewriteRpc's constructor calls connection.listen() — no need to call it ourselves.
|
|
118
|
+
const rewriteRpc = new rewrite_rpc_1.RewriteRpc(connection, {
|
|
119
|
+
marketplace: opts.marketplace,
|
|
120
|
+
logger: opts.logger,
|
|
121
|
+
});
|
|
122
|
+
// Hand back control once we know either (a) the JVM is up and the connection is
|
|
123
|
+
// listening, or (b) the JVM died early. A trivial round-trip (GetLanguages) does both.
|
|
124
|
+
try {
|
|
125
|
+
await Promise.race([
|
|
126
|
+
rewriteRpc.languages(),
|
|
127
|
+
earlyExit,
|
|
128
|
+
]);
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
child.kill("SIGKILL");
|
|
132
|
+
throw e;
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
child.removeListener("exit", onEarlyExit);
|
|
136
|
+
}
|
|
137
|
+
return new JavaRpcTestServer(child, rewriteRpc);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Reset accumulated state on both the Java side and the TS-side
|
|
141
|
+
* {@link RewriteRpc} caches so the next test starts clean.
|
|
142
|
+
*/
|
|
143
|
+
async reset() {
|
|
144
|
+
await this.rpc.reset();
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* End the JSON-RPC connection and wait for the Java process to exit. Falls back
|
|
148
|
+
* to SIGKILL after a short grace period to ensure no orphan JVMs are left behind.
|
|
149
|
+
*/
|
|
150
|
+
async dispose() {
|
|
151
|
+
// Attach the exit listener BEFORE signalling shutdown so we never miss the
|
|
152
|
+
// event in a TOCTOU race between checking exitCode and registering the
|
|
153
|
+
// listener. The Promise also resolves immediately if the process is
|
|
154
|
+
// already gone — see the exitCode shortcut below.
|
|
155
|
+
const exited = new Promise((resolve) => {
|
|
156
|
+
this.child.once("exit", resolve);
|
|
157
|
+
});
|
|
158
|
+
if (this.child.exitCode !== null) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
// End the connection before killing the process: this triggers an EOF on the
|
|
162
|
+
// Java side's stdin reader, which lets it shut down cleanly. Killing first
|
|
163
|
+
// can race with in-flight requests and leak the connection-close handler.
|
|
164
|
+
try {
|
|
165
|
+
this.rpc.end();
|
|
166
|
+
}
|
|
167
|
+
catch ( /* ignore — already closed */_a) { /* ignore — already closed */ }
|
|
168
|
+
const grace = setTimeout(() => {
|
|
169
|
+
this.child.kill("SIGKILL");
|
|
170
|
+
}, 5000);
|
|
171
|
+
try {
|
|
172
|
+
await exited;
|
|
173
|
+
}
|
|
174
|
+
finally {
|
|
175
|
+
clearTimeout(grace);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
exports.JavaRpcTestServer = JavaRpcTestServer;
|
|
180
|
+
/**
|
|
181
|
+
* Find the classpath for spawning the Java RPC server.
|
|
182
|
+
*
|
|
183
|
+
* Resolution order:
|
|
184
|
+
* 1. `REWRITE_JAVASCRIPT_CLASSPATH` environment variable.
|
|
185
|
+
* 2. `test-classpath.txt` written by the `:rewrite-javascript:generateTestClasspath`
|
|
186
|
+
* Gradle task. Walks up from this source file (works both when running directly
|
|
187
|
+
* via vitest and when running from `dist/`).
|
|
188
|
+
*
|
|
189
|
+
* @returns the classpath string, or `undefined` if no source is configured.
|
|
190
|
+
*/
|
|
191
|
+
function findTestClasspath() {
|
|
192
|
+
const env = process.env.REWRITE_JAVASCRIPT_CLASSPATH;
|
|
193
|
+
if (env && env.length > 0) {
|
|
194
|
+
return env;
|
|
195
|
+
}
|
|
196
|
+
// From src/rpc/ (vitest source mode) or dist/rpc/ (compiled), the classpath
|
|
197
|
+
// sits two levels up at the package root. The cwd fallback handles
|
|
198
|
+
// consumer projects where this module is in node_modules but the file
|
|
199
|
+
// lives next to the consumer's package root.
|
|
200
|
+
const candidates = [
|
|
201
|
+
path.resolve(__dirname, "..", "..", "test-classpath.txt"),
|
|
202
|
+
path.resolve(process.cwd(), "test-classpath.txt"),
|
|
203
|
+
];
|
|
204
|
+
for (const candidate of candidates) {
|
|
205
|
+
if (fs.existsSync(candidate)) {
|
|
206
|
+
return fs.readFileSync(candidate, "utf8").trim();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return undefined;
|
|
210
|
+
}
|
|
211
|
+
function resolveJavaCommand(javaHome) {
|
|
212
|
+
const home = javaHome !== null && javaHome !== void 0 ? javaHome : process.env.JAVA_HOME;
|
|
213
|
+
if (home) {
|
|
214
|
+
const candidate = path.join(home, "bin", process.platform === "win32" ? "java.exe" : "java");
|
|
215
|
+
if (fs.existsSync(candidate)) {
|
|
216
|
+
return candidate;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return "java";
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=java-rpc-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java-rpc-client.js","sourceRoot":"","sources":["../../src/rpc/java-rpc-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4LA,8CAoBC;AAhND;;;;;;;;;;;;;;GAcG;AACH,4CAA8B;AAC9B,gDAAkC;AAClC,wDAA0C;AAC1C,2DAAyE;AACzE,yDAA2C;AAC3C,+CAAyC;AAqBzC;;;;;;;;;;;;;;GAcG;AACH,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AAC,OAAO,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC;KACpD,CAAC;IACF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACjC,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,OAAO,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;QACrD,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAiB;IACzC,MAAM,IAAI,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IAC/C,IAAI,IAAI,EAAE,CAAC;QACP,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC7F,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -26,6 +26,15 @@ export declare class RewriteRpc {
|
|
|
26
26
|
metricsCsv?: string;
|
|
27
27
|
recipeInstallDir?: string;
|
|
28
28
|
});
|
|
29
|
+
private readonly clearLocalState;
|
|
30
|
+
/**
|
|
31
|
+
* Reset both the remote and local RPC caches. Sends a `Reset` request to the
|
|
32
|
+
* remote — which clears the remote's state without sending one back — and
|
|
33
|
+
* then clears local caches. Use this between independent operations (e.g.
|
|
34
|
+
* between tests) so accumulated objects and prepared recipes don't leak
|
|
35
|
+
* across boundaries.
|
|
36
|
+
*/
|
|
37
|
+
reset(): Promise<void>;
|
|
29
38
|
static set(value: RewriteRpc): void;
|
|
30
39
|
static get(): RewriteRpc | undefined;
|
|
31
40
|
end(): RewriteRpc;
|