@openrewrite/rewrite 8.68.0-20251202-082117 → 8.68.0-20251202-162533
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/javascript/assertions.d.ts +1 -0
- package/dist/javascript/assertions.d.ts.map +1 -1
- package/dist/javascript/assertions.js +82 -11
- package/dist/javascript/assertions.js.map +1 -1
- package/dist/javascript/dependency-workspace.d.ts +46 -5
- package/dist/javascript/dependency-workspace.d.ts.map +1 -1
- package/dist/javascript/dependency-workspace.js +70 -35
- package/dist/javascript/dependency-workspace.js.map +1 -1
- package/dist/javascript/index.d.ts +2 -0
- package/dist/javascript/index.d.ts.map +1 -1
- package/dist/javascript/index.js +2 -0
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/node-resolution-result.d.ts +204 -0
- package/dist/javascript/node-resolution-result.d.ts.map +1 -0
- package/dist/javascript/node-resolution-result.js +723 -0
- package/dist/javascript/node-resolution-result.js.map +1 -0
- package/dist/javascript/package-json-parser.d.ts +143 -0
- package/dist/javascript/package-json-parser.d.ts.map +1 -0
- package/dist/javascript/package-json-parser.js +773 -0
- package/dist/javascript/package-json-parser.js.map +1 -0
- package/dist/javascript/templating/engine.js +1 -1
- package/dist/javascript/templating/engine.js.map +1 -1
- package/dist/json/parser.js +10 -1
- package/dist/json/parser.js.map +1 -1
- package/dist/json/tree.d.ts +1 -1
- package/dist/json/tree.js +1 -1
- package/dist/json/tree.js.map +1 -1
- package/dist/parser.d.ts +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/rpc/request/parse.d.ts +4 -0
- package/dist/rpc/request/parse.d.ts.map +1 -1
- package/dist/rpc/request/parse.js +17 -1
- package/dist/rpc/request/parse.js.map +1 -1
- package/dist/version.txt +1 -1
- package/package.json +5 -2
- package/src/javascript/assertions.ts +73 -15
- package/src/javascript/dependency-workspace.ts +124 -46
- package/src/javascript/index.ts +2 -0
- package/src/javascript/node-resolution-result.ts +905 -0
- package/src/javascript/package-json-parser.ts +845 -0
- package/src/javascript/templating/engine.ts +1 -1
- package/src/json/parser.ts +18 -1
- package/src/json/tree.ts +1 -1
- package/src/parser.ts +1 -1
- package/src/rpc/request/parse.ts +20 -2
|
@@ -136,7 +136,7 @@ class TemplateCache {
|
|
|
136
136
|
// the same dependencies will automatically share the same workspace
|
|
137
137
|
let workspaceDir: string | undefined;
|
|
138
138
|
if (dependencies && Object.keys(dependencies).length > 0) {
|
|
139
|
-
workspaceDir = await DependencyWorkspace.getOrCreateWorkspace(dependencies);
|
|
139
|
+
workspaceDir = await DependencyWorkspace.getOrCreateWorkspace({dependencies});
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
// Prepend context statements for type attribution context
|
package/src/json/parser.ts
CHANGED
|
@@ -119,8 +119,25 @@ class ParseJsonReader extends ParserSourceReader {
|
|
|
119
119
|
source: parsed.toString(),
|
|
120
120
|
value: parsed,
|
|
121
121
|
} satisfies Json.Literal as Json.Literal;
|
|
122
|
+
} else if (typeof parsed === "boolean") {
|
|
123
|
+
const source = parsed ? "true" : "false";
|
|
124
|
+
this.cursor += source.length;
|
|
125
|
+
return {
|
|
126
|
+
kind: Json.Kind.Literal,
|
|
127
|
+
...base,
|
|
128
|
+
source,
|
|
129
|
+
value: parsed,
|
|
130
|
+
} satisfies Json.Literal as Json.Literal;
|
|
131
|
+
} else if (parsed === null) {
|
|
132
|
+
this.cursor += 4; // "null".length
|
|
133
|
+
return {
|
|
134
|
+
kind: Json.Kind.Literal,
|
|
135
|
+
...base,
|
|
136
|
+
source: "null",
|
|
137
|
+
value: null,
|
|
138
|
+
} satisfies Json.Literal as Json.Literal;
|
|
122
139
|
} else {
|
|
123
|
-
throw new Error(`Unsupported JSON type: ${parsed}`);
|
|
140
|
+
throw new Error(`Unsupported JSON type: ${typeof parsed}`);
|
|
124
141
|
}
|
|
125
142
|
}
|
|
126
143
|
|
package/src/json/tree.ts
CHANGED
|
@@ -32,7 +32,7 @@ export namespace Json {
|
|
|
32
32
|
Object: "org.openrewrite.json.tree.Json$JsonObject",
|
|
33
33
|
Space: "org.openrewrite.json.tree.Space",
|
|
34
34
|
Comment: "org.openrewrite.json.tree.Comment",
|
|
35
|
-
RightPadded: "org.openrewrite.json.tree.
|
|
35
|
+
RightPadded: "org.openrewrite.json.tree.JsonRightPadded"
|
|
36
36
|
} as const
|
|
37
37
|
|
|
38
38
|
export type Key = Identifier | Literal
|
package/src/parser.ts
CHANGED
|
@@ -131,7 +131,7 @@ export function readSourceSync(sourcePath: ParserInput) {
|
|
|
131
131
|
|
|
132
132
|
type ParserConstructor<T extends Parser> = new (options?: ParserOptions) => T;
|
|
133
133
|
|
|
134
|
-
export type ParserType = "javascript";
|
|
134
|
+
export type ParserType = "javascript" | "packageJson";
|
|
135
135
|
|
|
136
136
|
export class Parsers {
|
|
137
137
|
private static registry = new Map<ParserType, ParserConstructor<Parser>>();
|
package/src/rpc/request/parse.ts
CHANGED
|
@@ -15,17 +15,30 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import * as rpc from "vscode-jsonrpc/node";
|
|
17
17
|
import {ExecutionContext} from "../../execution";
|
|
18
|
-
import {ParserInput, Parsers} from "../../parser";
|
|
18
|
+
import {ParserInput, parserInputFile, Parsers, ParserType} from "../../parser";
|
|
19
19
|
import {randomId, UUID} from "../../uuid";
|
|
20
20
|
import {produce} from "immer";
|
|
21
21
|
import {SourceFile} from "../../tree";
|
|
22
22
|
import {withMetrics} from "./metrics";
|
|
23
|
+
import * as path from "path";
|
|
23
24
|
|
|
24
25
|
export class Parse {
|
|
25
26
|
constructor(private readonly inputs: ParserInput[],
|
|
26
27
|
private readonly relativeTo?: string) {
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Determines the parser type based on the file path.
|
|
32
|
+
*/
|
|
33
|
+
private static getParserType(input: ParserInput): ParserType {
|
|
34
|
+
const filePath = parserInputFile(input);
|
|
35
|
+
const fileName = path.basename(filePath);
|
|
36
|
+
if (fileName === 'package.json') {
|
|
37
|
+
return "packageJson";
|
|
38
|
+
}
|
|
39
|
+
return "javascript";
|
|
40
|
+
}
|
|
41
|
+
|
|
29
42
|
static handle(connection: rpc.MessageConnection,
|
|
30
43
|
localObjects: Map<string, ((input: string) => any) | any>,
|
|
31
44
|
metricsCsv?: string): void {
|
|
@@ -40,7 +53,12 @@ export class Parse {
|
|
|
40
53
|
typeof input === 'string' ? input : input.sourcePath
|
|
41
54
|
).join(',');
|
|
42
55
|
|
|
43
|
-
|
|
56
|
+
// Derive parser type from the first input's file path
|
|
57
|
+
const parserType = request.inputs.length > 0
|
|
58
|
+
? Parse.getParserType(request.inputs[0])
|
|
59
|
+
: "javascript";
|
|
60
|
+
|
|
61
|
+
const parser = Parsers.createParser(parserType, {
|
|
44
62
|
ctx: new ExecutionContext(),
|
|
45
63
|
relativeTo: request.relativeTo
|
|
46
64
|
})!;
|