@openrewrite/rewrite 8.83.3 → 8.83.4
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/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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
8.83.
|
|
1
|
+
8.83.4
|
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,wCAA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AC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;CACJ,CAAC,CAAC;AAEH,iBAAS,CAAC,aAAa,CAAC,qBAAW,CAAC,WAAW,EAAE;IAC7C,KAAK,CAAC,UAAU,CAAC,MAAmB,EAAE,CAAkB;QACpD,OAAO,IAAA,sBAAe,EAAC,MAAM,EAAE;YAC3B,EAAE,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9B,OAAO,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;YACxC,MAAM,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;SACzC,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAkB,EAAE,CAAe;QAC7C,MAAM,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,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,MAAa,iBAAiB;IAC1B,YACqB,KAAqC,EAC7C,GAAe;QADP,UAAK,GAAL,KAAK,CAAgC;QAC7C,QAAG,GAAH,GAAG,CAAY;IAE5B,CAAC;IAED,sFAAsF;IACtF,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAuB,EAAE;;QACxC,MAAM,SAAS,GAAG,MAAA,IAAI,CAAC,SAAS,mCAAI,iBAAiB,EAAE,CAAC;QACxD,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACX,0CAA0C;gBAC1C,6DAA6D;gBAC7D,sCAAsC,CACzC,CAAC;QACN,CAAC;QAED,MAAM,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClD,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,0CAA0C,CAAC,CAAC;QAC5E,IAAI,IAAI,CAAC,cAAc;YAAE,IAAI,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,cAAc,EA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,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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewrite-rpc.d.ts","sourceRoot":"","sources":["../../src/rpc/rewrite-rpc.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,MAAM,EAAoC,UAAU,EAAE,IAAI,EAAC,MAAM,SAAS,CAAC;AAoBnF,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AACnC,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAiB,sBAAsB,EAAC,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAG1C,qBAAa,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O,CAAC,WAAW;IAUnB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,SAAS;CAgBjE"}
|
package/dist/rpc/rewrite-rpc.js
CHANGED
|
@@ -97,18 +97,40 @@ class RewriteRpc {
|
|
|
97
97
|
this.traceGetObject = request;
|
|
98
98
|
return true;
|
|
99
99
|
});
|
|
100
|
-
|
|
100
|
+
// Clears local caches. Captured here so it can close over the
|
|
101
|
+
// constructor-local `preparedRecipes` while still being callable
|
|
102
|
+
// from the public `reset()` method on the class.
|
|
103
|
+
const clearLocalState = () => {
|
|
101
104
|
this.localObjects.clear();
|
|
102
105
|
this.localObjectIds.clear();
|
|
103
106
|
this.remoteObjects.clear();
|
|
104
107
|
this.remoteRefs.clear();
|
|
105
108
|
this.localRefs.clear();
|
|
106
109
|
preparedRecipes.clear();
|
|
110
|
+
this.remoteLanguages = undefined;
|
|
111
|
+
};
|
|
112
|
+
this.clearLocalState = clearLocalState;
|
|
113
|
+
this.connection.onRequest(new rpc.RequestType0("Reset"), async () => {
|
|
114
|
+
// Inbound Reset only clears local state — never sends a Reset
|
|
115
|
+
// back to the originator. Mirrors the Java handler in
|
|
116
|
+
// RewriteRpc.java around line 222.
|
|
117
|
+
clearLocalState();
|
|
107
118
|
return true;
|
|
108
119
|
});
|
|
109
120
|
RewriteRpc.set(this);
|
|
110
121
|
this.connection.listen();
|
|
111
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Reset both the remote and local RPC caches. Sends a `Reset` request to the
|
|
125
|
+
* remote — which clears the remote's state without sending one back — and
|
|
126
|
+
* then clears local caches. Use this between independent operations (e.g.
|
|
127
|
+
* between tests) so accumulated objects and prepared recipes don't leak
|
|
128
|
+
* across boundaries.
|
|
129
|
+
*/
|
|
130
|
+
async reset() {
|
|
131
|
+
await this.connection.sendRequest(new rpc.RequestType0("Reset"));
|
|
132
|
+
this.clearLocalState();
|
|
133
|
+
}
|
|
112
134
|
static set(value) {
|
|
113
135
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AAC;QACnC,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtC,CAAC;IACL,CAAC;IAED,GAAG,CAAC,GAAQ;QACR,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtC,CAAC;IACL,CAAC;IAED,GAAG,CAAC,GAAQ;QACR,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtC,CAAC;IACL,CAAC;IAED,KAAK;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,OAAO,EAAe,CAAC;QAC5C,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACJ"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vitest fixture for tests that need to drive Java recipes via a spawned
|
|
3
|
+
* `org.openrewrite.maven.rpc.JavaRewriteRpc` process. Provides a worker-scoped
|
|
4
|
+
* JVM (one process per vitest worker) wrapped in a test-scoped fixture that
|
|
5
|
+
* resets accumulated state before each test.
|
|
6
|
+
*
|
|
7
|
+
* Typical use:
|
|
8
|
+
* ```
|
|
9
|
+
* import {testJavaRpc, describeJavaRpc} from "@openrewrite/rewrite/test/java-rpc";
|
|
10
|
+
*
|
|
11
|
+
* describeJavaRpc("AddDependency", () => {
|
|
12
|
+
* testJavaRpc("adds a dep to package.json", async ({javaRpc}) => {
|
|
13
|
+
* const spec = new RecipeSpec();
|
|
14
|
+
* spec.recipe = await javaRpc.rpc.prepareRecipe(
|
|
15
|
+
* "org.openrewrite.javascript.AddDependency", {name: "lodash", version: "^4.17.21"},
|
|
16
|
+
* );
|
|
17
|
+
* await spec.rewriteRun(packageJson(before, after));
|
|
18
|
+
* });
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* The classpath is resolved via {@link findTestClasspath}; the suite is skipped
|
|
23
|
+
* (via {@link describeJavaRpc}) when no classpath has been configured.
|
|
24
|
+
*/
|
|
25
|
+
import { type SuiteAPI } from "vitest";
|
|
26
|
+
import { JavaRpcTestServer } from "../rpc/java-rpc-client";
|
|
27
|
+
export { findTestClasspath, JavaRpcTestServer } from "../rpc/java-rpc-client";
|
|
28
|
+
export type { JavaRpcOptions } from "../rpc/java-rpc-client";
|
|
29
|
+
/**
|
|
30
|
+
* Vitest test API extended with a {@link JavaRpcTestServer} fixture. The JVM
|
|
31
|
+
* is spawned once per worker; state is reset before every test.
|
|
32
|
+
*/
|
|
33
|
+
export declare const testJavaRpc: import("vitest").TestAPI<{
|
|
34
|
+
_javaRpcServer: JavaRpcTestServer;
|
|
35
|
+
javaRpc: JavaRpcTestServer;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* `describe` wrapper that skips the suite when the Java RPC test classpath has
|
|
39
|
+
* not been configured (env var or generated file). Use in place of `describe`
|
|
40
|
+
* for any suite that uses {@link testJavaRpc}.
|
|
41
|
+
*
|
|
42
|
+
* Run `./gradlew :rewrite-javascript:generateTestClasspath` to enable, or set
|
|
43
|
+
* the `REWRITE_JAVASCRIPT_CLASSPATH` environment variable.
|
|
44
|
+
*/
|
|
45
|
+
export declare const describeJavaRpc: SuiteAPI;
|
|
46
|
+
//# sourceMappingURL=java-rpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java-rpc.d.ts","sourceRoot":"","sources":["../../src/test/java-rpc.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAW,KAAK,QAAQ,EAAe,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAoB,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAE5E,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAC5E,YAAY,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAkB3D;;;GAGG;AACH,eAAO,MAAM,WAAW;;;EAgBtB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,QAC6C,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describeJavaRpc = exports.testJavaRpc = exports.JavaRpcTestServer = exports.findTestClasspath = void 0;
|
|
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
|
+
/**
|
|
20
|
+
* Vitest fixture for tests that need to drive Java recipes via a spawned
|
|
21
|
+
* `org.openrewrite.maven.rpc.JavaRewriteRpc` process. Provides a worker-scoped
|
|
22
|
+
* JVM (one process per vitest worker) wrapped in a test-scoped fixture that
|
|
23
|
+
* resets accumulated state before each test.
|
|
24
|
+
*
|
|
25
|
+
* Typical use:
|
|
26
|
+
* ```
|
|
27
|
+
* import {testJavaRpc, describeJavaRpc} from "@openrewrite/rewrite/test/java-rpc";
|
|
28
|
+
*
|
|
29
|
+
* describeJavaRpc("AddDependency", () => {
|
|
30
|
+
* testJavaRpc("adds a dep to package.json", async ({javaRpc}) => {
|
|
31
|
+
* const spec = new RecipeSpec();
|
|
32
|
+
* spec.recipe = await javaRpc.rpc.prepareRecipe(
|
|
33
|
+
* "org.openrewrite.javascript.AddDependency", {name: "lodash", version: "^4.17.21"},
|
|
34
|
+
* );
|
|
35
|
+
* await spec.rewriteRun(packageJson(before, after));
|
|
36
|
+
* });
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* The classpath is resolved via {@link findTestClasspath}; the suite is skipped
|
|
41
|
+
* (via {@link describeJavaRpc}) when no classpath has been configured.
|
|
42
|
+
*/
|
|
43
|
+
const vitest_1 = require("vitest");
|
|
44
|
+
const java_rpc_client_1 = require("../rpc/java-rpc-client");
|
|
45
|
+
var java_rpc_client_2 = require("../rpc/java-rpc-client");
|
|
46
|
+
Object.defineProperty(exports, "findTestClasspath", { enumerable: true, get: function () { return java_rpc_client_2.findTestClasspath; } });
|
|
47
|
+
Object.defineProperty(exports, "JavaRpcTestServer", { enumerable: true, get: function () { return java_rpc_client_2.JavaRpcTestServer; } });
|
|
48
|
+
/**
|
|
49
|
+
* Vitest test API extended with a {@link JavaRpcTestServer} fixture. The JVM
|
|
50
|
+
* is spawned once per worker; state is reset before every test.
|
|
51
|
+
*/
|
|
52
|
+
exports.testJavaRpc = vitest_1.test.extend({
|
|
53
|
+
_javaRpcServer: [
|
|
54
|
+
async ({}, use) => {
|
|
55
|
+
const server = await java_rpc_client_1.JavaRpcTestServer.start();
|
|
56
|
+
try {
|
|
57
|
+
await use(server);
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
await server.dispose();
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{ scope: "worker" },
|
|
64
|
+
],
|
|
65
|
+
javaRpc: async ({ _javaRpcServer }, use) => {
|
|
66
|
+
await _javaRpcServer.reset();
|
|
67
|
+
await use(_javaRpcServer);
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* `describe` wrapper that skips the suite when the Java RPC test classpath has
|
|
72
|
+
* not been configured (env var or generated file). Use in place of `describe`
|
|
73
|
+
* for any suite that uses {@link testJavaRpc}.
|
|
74
|
+
*
|
|
75
|
+
* Run `./gradlew :rewrite-javascript:generateTestClasspath` to enable, or set
|
|
76
|
+
* the `REWRITE_JAVASCRIPT_CLASSPATH` environment variable.
|
|
77
|
+
*/
|
|
78
|
+
exports.describeJavaRpc = (0, java_rpc_client_1.findTestClasspath)() ? vitest_1.describe : vitest_1.describe.skip;
|
|
79
|
+
//# sourceMappingURL=java-rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java-rpc.js","sourceRoot":"","sources":["../../src/test/java-rpc.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,mCAA6D;AAC7D,4DAA4E;AAE5E,0DAA4E;AAApE,oHAAA,iBAAiB,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAmB5C;;;GAGG;AACU,QAAA,WAAW,GAAG,aAAI,CAAC,MAAM,CAAkB;IACpD,cAAc,EAAE;QACZ,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE;YACd,MAAM,MAAM,GAAG,MAAM,mCAAiB,CAAC,KAAK,EAAE,CAAC;YAC/C,IAAI,CAAC;gBACD,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC;YACtB,CAAC;oBAAS,CAAC;gBACP,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;YAC3B,CAAC;QACL,CAAC;QACD,EAAC,KAAK,EAAE,QAAQ,EAAC;KACpB;IACD,OAAO,EAAE,KAAK,EAAE,EAAC,cAAc,EAAC,EAAE,GAAG,EAAE,EAAE;QACrC,MAAM,cAAc,CAAC,KAAK,EAAE,CAAC;QAC7B,MAAM,GAAG,CAAC,cAAc,CAAC,CAAC;IAC9B,CAAC;CACJ,CAAC,CAAC;AAEH;;;;;;;GAOG;AACU,QAAA,eAAe,GACxB,IAAA,mCAAiB,GAAE,CAAC,CAAC,CAAC,iBAAQ,CAAC,CAAC,CAAE,iBAAQ,CAAC,IAA4B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrewrite/rewrite",
|
|
3
|
-
"version": "8.83.
|
|
3
|
+
"version": "8.83.4",
|
|
4
4
|
"license": "Moderne Source Available License",
|
|
5
5
|
"description": "OpenRewrite JavaScript.",
|
|
6
6
|
"repository": {
|
|
@@ -44,6 +44,10 @@
|
|
|
44
44
|
"types": "./dist/test/index.d.ts",
|
|
45
45
|
"default": "./dist/test/index.js"
|
|
46
46
|
},
|
|
47
|
+
"./test/java-rpc": {
|
|
48
|
+
"types": "./dist/test/java-rpc.d.ts",
|
|
49
|
+
"default": "./dist/test/java-rpc.js"
|
|
50
|
+
},
|
|
47
51
|
"./yaml": {
|
|
48
52
|
"types": "./dist/yaml/index.d.ts",
|
|
49
53
|
"default": "./dist/yaml/index.js"
|
package/src/rpc/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {updateIfChanged} from "../util";
|
|
|
22
22
|
export * from "./queue";
|
|
23
23
|
export * from "../reference";
|
|
24
24
|
export {RewriteRpc} from "./rewrite-rpc";
|
|
25
|
+
export {prepareJavaRecipe} from "./java-recipe";
|
|
25
26
|
|
|
26
27
|
RpcCodecs.registerCodec(TreeKind.Checksum, {
|
|
27
28
|
async rpcReceive(before: Checksum, q: RpcReceiveQueue): Promise<Checksum> {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 the original author or authors.
|
|
3
|
+
* <p>
|
|
4
|
+
* Licensed under the Moderne Source Available License (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
* <p>
|
|
8
|
+
* https://docs.moderne.io/licensing/moderne-source-available-license
|
|
9
|
+
* <p>
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import {RewriteRpc} from "./rewrite-rpc";
|
|
17
|
+
import type {RpcRecipe} from "./recipe";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Prepare a Java recipe via the active {@link RewriteRpc} connection.
|
|
21
|
+
*
|
|
22
|
+
* Routes a `PrepareRecipe` request to whichever side hosts the Java
|
|
23
|
+
* implementation:
|
|
24
|
+
* - in production, the Java host that spawned the TS server (`dist/rpc/server.js`);
|
|
25
|
+
* - in tests, the JVM spawned via `JavaRpcTestServer` (see
|
|
26
|
+
* `@openrewrite/rewrite/test/java-rpc`).
|
|
27
|
+
*
|
|
28
|
+
* The returned {@link RpcRecipe} extends `Recipe`, so it can be used directly
|
|
29
|
+
* as a recipe — e.g. assigned to `RecipeSpec.recipe` — or composed inside a
|
|
30
|
+
* larger TS recipe (as the editor of a `check(usesType(...), ...)`
|
|
31
|
+
* precondition, or as a step in `recipeList()`).
|
|
32
|
+
*
|
|
33
|
+
* Top-level convenience functions for specific Java recipes (e.g.
|
|
34
|
+
* `addDependency`, `changeType`) sit naturally on top of this primitive:
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* export function addDependency(options: AddDependencyOptions): Promise<Recipe> {
|
|
38
|
+
* return prepareJavaRecipe("org.openrewrite.javascript.AddDependency", options);
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* There is no in-process fallback by design: a Java recipe's editor is the
|
|
43
|
+
* single source of truth — we don't reimplement editing recipes in TS. For
|
|
44
|
+
* preconditions that need a graceful no-RPC fallback, use the {@link RecipeRef}
|
|
45
|
+
* pattern via `usesType` / `usesMethod`, which carries a `localVisitor`.
|
|
46
|
+
*
|
|
47
|
+
* @throws Error when no active {@link RewriteRpc} connection is registered.
|
|
48
|
+
*/
|
|
49
|
+
export async function prepareJavaRecipe(
|
|
50
|
+
id: string,
|
|
51
|
+
options?: Record<string, any>,
|
|
52
|
+
): Promise<RpcRecipe> {
|
|
53
|
+
const rpc = RewriteRpc.get();
|
|
54
|
+
if (!rpc) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Cannot prepare Java recipe "${id}": no active RewriteRpc connection.\n` +
|
|
57
|
+
" • Tests: spawn one via JavaRpcTestServer.start() — see " +
|
|
58
|
+
"@openrewrite/rewrite/test/java-rpc.\n" +
|
|
59
|
+
" • Production: the Java host provides one automatically when it " +
|
|
60
|
+
"loads the TS recipe artifact."
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return rpc.prepareRecipe(id, options);
|
|
64
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 the original author or authors.
|
|
3
|
+
* <p>
|
|
4
|
+
* Licensed under the Moderne Source Available License (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
* <p>
|
|
8
|
+
* https://docs.moderne.io/licensing/moderne-source-available-license
|
|
9
|
+
* <p>
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import * as fs from "node:fs";
|
|
17
|
+
import * as path from "node:path";
|
|
18
|
+
import * as readline from "node:readline";
|
|
19
|
+
import {ChildProcessWithoutNullStreams, spawn} from "node:child_process";
|
|
20
|
+
import * as rpc from "vscode-jsonrpc/node";
|
|
21
|
+
import {RewriteRpc} from "./rewrite-rpc";
|
|
22
|
+
import {RecipeMarketplace} from "../marketplace";
|
|
23
|
+
|
|
24
|
+
export interface JavaRpcOptions {
|
|
25
|
+
/** Explicit classpath override. Falls back to env var, then test-classpath.txt. */
|
|
26
|
+
classpath?: string;
|
|
27
|
+
/** JAVA_HOME to use. Falls back to process.env.JAVA_HOME, then `java` on PATH. */
|
|
28
|
+
javaHome?: string;
|
|
29
|
+
/** Optional logger forwarded to the underlying RewriteRpc instance. */
|
|
30
|
+
logger?: rpc.Logger;
|
|
31
|
+
/** Optional path to a marketplace CSV — passed via `--marketplace=` to the Java process. */
|
|
32
|
+
marketplaceCsv?: string;
|
|
33
|
+
/** Enable RPC tracing on the Java side (passed as `--trace`). */
|
|
34
|
+
trace?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Pre-built {@link RecipeMarketplace} for the TS-side {@link RewriteRpc} instance
|
|
37
|
+
* only. Does NOT configure the Java side — for that, use {@link marketplaceCsv}.
|
|
38
|
+
*/
|
|
39
|
+
marketplace?: RecipeMarketplace;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Test-only wrapper around a spawned `org.openrewrite.maven.rpc.JavaRewriteRpc` process,
|
|
44
|
+
* exposing a {@link RewriteRpc} client wired to its stdio over JSON-RPC.
|
|
45
|
+
*
|
|
46
|
+
* Typical use:
|
|
47
|
+
* ```
|
|
48
|
+
* const server = await JavaRpcTestServer.start();
|
|
49
|
+
* try {
|
|
50
|
+
* const recipe = await server.rpc.prepareRecipe("org.openrewrite.text.FindAndReplace", {...});
|
|
51
|
+
* const result = await server.rpc.visit(parsed, recipe.editVisitor, ctx);
|
|
52
|
+
* } finally {
|
|
53
|
+
* await server.dispose();
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export class JavaRpcTestServer {
|
|
58
|
+
private constructor(
|
|
59
|
+
private readonly child: ChildProcessWithoutNullStreams,
|
|
60
|
+
readonly rpc: RewriteRpc,
|
|
61
|
+
) {
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Spawn the Java RPC server and connect a {@link RewriteRpc} client to its stdio. */
|
|
65
|
+
static async start(opts: JavaRpcOptions = {}): Promise<JavaRpcTestServer> {
|
|
66
|
+
const classpath = opts.classpath ?? findTestClasspath();
|
|
67
|
+
if (!classpath) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
"Java RPC test classpath not configured. " +
|
|
70
|
+
"Run `./gradlew :rewrite-javascript:generateTestClasspath`, " +
|
|
71
|
+
"or set REWRITE_JAVASCRIPT_CLASSPATH."
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const javaCmd = resolveJavaCommand(opts.javaHome);
|
|
76
|
+
const args = ["-cp", classpath, "org.openrewrite.maven.rpc.JavaRewriteRpc"];
|
|
77
|
+
if (opts.marketplaceCsv) args.push(`--marketplace=${opts.marketplaceCsv}`);
|
|
78
|
+
if (opts.trace) args.push("--trace");
|
|
79
|
+
|
|
80
|
+
const child = spawn(javaCmd, args);
|
|
81
|
+
|
|
82
|
+
// Forward Java stderr line-by-line so stack traces surface in the test output.
|
|
83
|
+
// `readline` handles partial-line buffering and flushes a non-newline-terminated
|
|
84
|
+
// final line on `close` (a hand-rolled split would silently drop it).
|
|
85
|
+
readline.createInterface({input: child.stderr, crlfDelay: Infinity})
|
|
86
|
+
.on("line", line => {
|
|
87
|
+
if (line.length > 0) process.stderr.write(`[Java RPC] ${line}\n`);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// If the JVM dies before we can talk to it, surface that immediately rather
|
|
91
|
+
// than letting the first RPC request hang waiting for a response. Capture the
|
|
92
|
+
// listener so we can detach it after the race resolves — otherwise the normal
|
|
93
|
+
// exit during dispose() fires it, rejecting a Promise nobody is observing
|
|
94
|
+
// (UnhandledPromiseRejection under Node 15+).
|
|
95
|
+
let onEarlyExit!: (code: number | null, signal: NodeJS.Signals | null) => void;
|
|
96
|
+
const earlyExit = new Promise<never>((_, reject) => {
|
|
97
|
+
onEarlyExit = (code, signal) => {
|
|
98
|
+
reject(new Error(
|
|
99
|
+
`Java RPC server exited before any request was sent ` +
|
|
100
|
+
`(code=${code}, signal=${signal}). Check the [Java RPC] stderr above.`
|
|
101
|
+
));
|
|
102
|
+
};
|
|
103
|
+
child.once("exit", onEarlyExit);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const connection = rpc.createMessageConnection(
|
|
107
|
+
new rpc.StreamMessageReader(child.stdout),
|
|
108
|
+
new rpc.StreamMessageWriter(child.stdin),
|
|
109
|
+
opts.logger,
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// RewriteRpc's constructor calls connection.listen() — no need to call it ourselves.
|
|
113
|
+
const rewriteRpc = new RewriteRpc(connection, {
|
|
114
|
+
marketplace: opts.marketplace,
|
|
115
|
+
logger: opts.logger,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Hand back control once we know either (a) the JVM is up and the connection is
|
|
119
|
+
// listening, or (b) the JVM died early. A trivial round-trip (GetLanguages) does both.
|
|
120
|
+
try {
|
|
121
|
+
await Promise.race([
|
|
122
|
+
rewriteRpc.languages(),
|
|
123
|
+
earlyExit,
|
|
124
|
+
]);
|
|
125
|
+
} catch (e) {
|
|
126
|
+
child.kill("SIGKILL");
|
|
127
|
+
throw e;
|
|
128
|
+
} finally {
|
|
129
|
+
child.removeListener("exit", onEarlyExit);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return new JavaRpcTestServer(child, rewriteRpc);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Reset accumulated state on both the Java side and the TS-side
|
|
137
|
+
* {@link RewriteRpc} caches so the next test starts clean.
|
|
138
|
+
*/
|
|
139
|
+
async reset(): Promise<void> {
|
|
140
|
+
await this.rpc.reset();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* End the JSON-RPC connection and wait for the Java process to exit. Falls back
|
|
145
|
+
* to SIGKILL after a short grace period to ensure no orphan JVMs are left behind.
|
|
146
|
+
*/
|
|
147
|
+
async dispose(): Promise<void> {
|
|
148
|
+
// Attach the exit listener BEFORE signalling shutdown so we never miss the
|
|
149
|
+
// event in a TOCTOU race between checking exitCode and registering the
|
|
150
|
+
// listener. The Promise also resolves immediately if the process is
|
|
151
|
+
// already gone — see the exitCode shortcut below.
|
|
152
|
+
const exited = new Promise<void>((resolve) => {
|
|
153
|
+
this.child.once("exit", resolve);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
if (this.child.exitCode !== null) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// End the connection before killing the process: this triggers an EOF on the
|
|
161
|
+
// Java side's stdin reader, which lets it shut down cleanly. Killing first
|
|
162
|
+
// can race with in-flight requests and leak the connection-close handler.
|
|
163
|
+
try {
|
|
164
|
+
this.rpc.end();
|
|
165
|
+
} catch { /* ignore — already closed */ }
|
|
166
|
+
|
|
167
|
+
const grace = setTimeout(() => {
|
|
168
|
+
this.child.kill("SIGKILL");
|
|
169
|
+
}, 5_000);
|
|
170
|
+
try {
|
|
171
|
+
await exited;
|
|
172
|
+
} finally {
|
|
173
|
+
clearTimeout(grace);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Find the classpath for spawning the Java RPC server.
|
|
180
|
+
*
|
|
181
|
+
* Resolution order:
|
|
182
|
+
* 1. `REWRITE_JAVASCRIPT_CLASSPATH` environment variable.
|
|
183
|
+
* 2. `test-classpath.txt` written by the `:rewrite-javascript:generateTestClasspath`
|
|
184
|
+
* Gradle task. Walks up from this source file (works both when running directly
|
|
185
|
+
* via vitest and when running from `dist/`).
|
|
186
|
+
*
|
|
187
|
+
* @returns the classpath string, or `undefined` if no source is configured.
|
|
188
|
+
*/
|
|
189
|
+
export function findTestClasspath(): string | undefined {
|
|
190
|
+
const env = process.env.REWRITE_JAVASCRIPT_CLASSPATH;
|
|
191
|
+
if (env && env.length > 0) {
|
|
192
|
+
return env;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// From src/rpc/ (vitest source mode) or dist/rpc/ (compiled), the classpath
|
|
196
|
+
// sits two levels up at the package root. The cwd fallback handles
|
|
197
|
+
// consumer projects where this module is in node_modules but the file
|
|
198
|
+
// lives next to the consumer's package root.
|
|
199
|
+
const candidates = [
|
|
200
|
+
path.resolve(__dirname, "..", "..", "test-classpath.txt"),
|
|
201
|
+
path.resolve(process.cwd(), "test-classpath.txt"),
|
|
202
|
+
];
|
|
203
|
+
for (const candidate of candidates) {
|
|
204
|
+
if (fs.existsSync(candidate)) {
|
|
205
|
+
return fs.readFileSync(candidate, "utf8").trim();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function resolveJavaCommand(javaHome?: string): string {
|
|
212
|
+
const home = 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
|
+
}
|
package/src/rpc/rewrite-rpc.ts
CHANGED
|
@@ -108,15 +108,27 @@ export class RewriteRpc {
|
|
|
108
108
|
}
|
|
109
109
|
)
|
|
110
110
|
|
|
111
|
+
// Clears local caches. Captured here so it can close over the
|
|
112
|
+
// constructor-local `preparedRecipes` while still being callable
|
|
113
|
+
// from the public `reset()` method on the class.
|
|
114
|
+
const clearLocalState = () => {
|
|
115
|
+
this.localObjects.clear();
|
|
116
|
+
this.localObjectIds.clear();
|
|
117
|
+
this.remoteObjects.clear();
|
|
118
|
+
this.remoteRefs.clear();
|
|
119
|
+
this.localRefs.clear();
|
|
120
|
+
preparedRecipes.clear();
|
|
121
|
+
this.remoteLanguages = undefined;
|
|
122
|
+
};
|
|
123
|
+
this.clearLocalState = clearLocalState;
|
|
124
|
+
|
|
111
125
|
this.connection.onRequest(
|
|
112
126
|
new rpc.RequestType0<boolean, Error>("Reset"),
|
|
113
127
|
async () => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.localRefs.clear();
|
|
119
|
-
preparedRecipes.clear();
|
|
128
|
+
// Inbound Reset only clears local state — never sends a Reset
|
|
129
|
+
// back to the originator. Mirrors the Java handler in
|
|
130
|
+
// RewriteRpc.java around line 222.
|
|
131
|
+
clearLocalState();
|
|
120
132
|
return true;
|
|
121
133
|
}
|
|
122
134
|
)
|
|
@@ -125,6 +137,22 @@ export class RewriteRpc {
|
|
|
125
137
|
this.connection.listen();
|
|
126
138
|
}
|
|
127
139
|
|
|
140
|
+
private readonly clearLocalState!: () => void;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Reset both the remote and local RPC caches. Sends a `Reset` request to the
|
|
144
|
+
* remote — which clears the remote's state without sending one back — and
|
|
145
|
+
* then clears local caches. Use this between independent operations (e.g.
|
|
146
|
+
* between tests) so accumulated objects and prepared recipes don't leak
|
|
147
|
+
* across boundaries.
|
|
148
|
+
*/
|
|
149
|
+
async reset(): Promise<void> {
|
|
150
|
+
await this.connection.sendRequest(
|
|
151
|
+
new rpc.RequestType0<boolean, Error>("Reset"),
|
|
152
|
+
);
|
|
153
|
+
this.clearLocalState();
|
|
154
|
+
}
|
|
155
|
+
|
|
128
156
|
static set(value: RewriteRpc) {
|
|
129
157
|
this._global = value;
|
|
130
158
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 the original author or authors.
|
|
3
|
+
* <p>
|
|
4
|
+
* Licensed under the Moderne Source Available License (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
* <p>
|
|
8
|
+
* https://docs.moderne.io/licensing/moderne-source-available-license
|
|
9
|
+
* <p>
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Vitest fixture for tests that need to drive Java recipes via a spawned
|
|
18
|
+
* `org.openrewrite.maven.rpc.JavaRewriteRpc` process. Provides a worker-scoped
|
|
19
|
+
* JVM (one process per vitest worker) wrapped in a test-scoped fixture that
|
|
20
|
+
* resets accumulated state before each test.
|
|
21
|
+
*
|
|
22
|
+
* Typical use:
|
|
23
|
+
* ```
|
|
24
|
+
* import {testJavaRpc, describeJavaRpc} from "@openrewrite/rewrite/test/java-rpc";
|
|
25
|
+
*
|
|
26
|
+
* describeJavaRpc("AddDependency", () => {
|
|
27
|
+
* testJavaRpc("adds a dep to package.json", async ({javaRpc}) => {
|
|
28
|
+
* const spec = new RecipeSpec();
|
|
29
|
+
* spec.recipe = await javaRpc.rpc.prepareRecipe(
|
|
30
|
+
* "org.openrewrite.javascript.AddDependency", {name: "lodash", version: "^4.17.21"},
|
|
31
|
+
* );
|
|
32
|
+
* await spec.rewriteRun(packageJson(before, after));
|
|
33
|
+
* });
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* The classpath is resolved via {@link findTestClasspath}; the suite is skipped
|
|
38
|
+
* (via {@link describeJavaRpc}) when no classpath has been configured.
|
|
39
|
+
*/
|
|
40
|
+
import {describe, type SuiteAPI, test as base} from "vitest";
|
|
41
|
+
import {findTestClasspath, JavaRpcTestServer} from "../rpc/java-rpc-client";
|
|
42
|
+
|
|
43
|
+
export {findTestClasspath, JavaRpcTestServer} from "../rpc/java-rpc-client";
|
|
44
|
+
export type {JavaRpcOptions} from "../rpc/java-rpc-client";
|
|
45
|
+
|
|
46
|
+
interface JavaRpcFixtures {
|
|
47
|
+
/**
|
|
48
|
+
* Internal worker-scoped fixture holding the spawned JVM. Test code should
|
|
49
|
+
* use {@link javaRpc} instead — it depends on this fixture but adds a
|
|
50
|
+
* per-test reset.
|
|
51
|
+
*/
|
|
52
|
+
_javaRpcServer: JavaRpcTestServer;
|
|
53
|
+
/**
|
|
54
|
+
* The {@link JavaRpcTestServer} for this test. State on both the Java
|
|
55
|
+
* side and the TS-side {@link RewriteRpc} is reset before the test runs,
|
|
56
|
+
* so each test gets a clean slate even though the JVM persists across
|
|
57
|
+
* tests within the same vitest worker.
|
|
58
|
+
*/
|
|
59
|
+
javaRpc: JavaRpcTestServer;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Vitest test API extended with a {@link JavaRpcTestServer} fixture. The JVM
|
|
64
|
+
* is spawned once per worker; state is reset before every test.
|
|
65
|
+
*/
|
|
66
|
+
export const testJavaRpc = base.extend<JavaRpcFixtures>({
|
|
67
|
+
_javaRpcServer: [
|
|
68
|
+
async ({}, use) => {
|
|
69
|
+
const server = await JavaRpcTestServer.start();
|
|
70
|
+
try {
|
|
71
|
+
await use(server);
|
|
72
|
+
} finally {
|
|
73
|
+
await server.dispose();
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{scope: "worker"},
|
|
77
|
+
],
|
|
78
|
+
javaRpc: async ({_javaRpcServer}, use) => {
|
|
79
|
+
await _javaRpcServer.reset();
|
|
80
|
+
await use(_javaRpcServer);
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* `describe` wrapper that skips the suite when the Java RPC test classpath has
|
|
86
|
+
* not been configured (env var or generated file). Use in place of `describe`
|
|
87
|
+
* for any suite that uses {@link testJavaRpc}.
|
|
88
|
+
*
|
|
89
|
+
* Run `./gradlew :rewrite-javascript:generateTestClasspath` to enable, or set
|
|
90
|
+
* the `REWRITE_JAVASCRIPT_CLASSPATH` environment variable.
|
|
91
|
+
*/
|
|
92
|
+
export const describeJavaRpc: SuiteAPI =
|
|
93
|
+
findTestClasspath() ? describe : (describe.skip as unknown as SuiteAPI);
|