@openrewrite/rewrite 8.70.0-20251219-160440 → 8.70.0-20251219-215811
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/cli/cli-utils.d.ts +6 -6
- package/dist/cli/cli-utils.d.ts.map +1 -1
- package/dist/cli/cli-utils.js +50 -228
- package/dist/cli/cli-utils.js.map +1 -1
- package/dist/javascript/assertions.d.ts.map +1 -1
- package/dist/javascript/assertions.js +87 -12
- package/dist/javascript/assertions.js.map +1 -1
- package/dist/javascript/autodetect.d.ts +11 -11
- package/dist/javascript/autodetect.d.ts.map +1 -1
- package/dist/javascript/autodetect.js +18 -21
- package/dist/javascript/autodetect.js.map +1 -1
- package/dist/javascript/format/prettier-config-loader.d.ts.map +1 -1
- package/dist/javascript/format/prettier-config-loader.js +1 -1
- package/dist/javascript/format/prettier-config-loader.js.map +1 -1
- package/dist/javascript/index.d.ts +1 -0
- package/dist/javascript/index.d.ts.map +1 -1
- package/dist/javascript/index.js +1 -0
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/markers.d.ts.map +1 -1
- package/dist/javascript/markers.js +135 -6
- package/dist/javascript/markers.js.map +1 -1
- package/dist/javascript/node-resolution-result.d.ts +4 -1
- package/dist/javascript/node-resolution-result.d.ts.map +1 -1
- package/dist/javascript/node-resolution-result.js +22 -1
- package/dist/javascript/node-resolution-result.js.map +1 -1
- package/dist/javascript/package-json-parser.d.ts +7 -0
- package/dist/javascript/package-json-parser.d.ts.map +1 -1
- package/dist/javascript/package-json-parser.js +19 -1
- package/dist/javascript/package-json-parser.js.map +1 -1
- package/dist/javascript/parser.d.ts.map +1 -1
- package/dist/javascript/parser.js +1 -13
- package/dist/javascript/parser.js.map +1 -1
- package/dist/javascript/preconditions.js +4 -4
- package/dist/javascript/preconditions.js.map +1 -1
- package/dist/javascript/project-parser.d.ts +137 -0
- package/dist/javascript/project-parser.d.ts.map +1 -0
- package/dist/javascript/project-parser.js +726 -0
- package/dist/javascript/project-parser.js.map +1 -0
- package/dist/javascript/style.d.ts +9 -26
- package/dist/javascript/style.d.ts.map +1 -1
- package/dist/javascript/style.js +18 -42
- package/dist/javascript/style.js.map +1 -1
- package/dist/json/parser.d.ts.map +1 -1
- package/dist/json/parser.js +1 -0
- package/dist/json/parser.js.map +1 -1
- package/dist/markers.d.ts +1 -1
- package/dist/markers.js +1 -1
- package/dist/markers.js.map +1 -1
- package/dist/parser.d.ts +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/rpc/index.d.ts +0 -1
- package/dist/rpc/index.d.ts.map +1 -1
- package/dist/rpc/index.js +4 -2
- package/dist/rpc/index.js.map +1 -1
- package/dist/rpc/request/index.d.ts +1 -0
- package/dist/rpc/request/index.d.ts.map +1 -1
- package/dist/rpc/request/index.js +1 -0
- package/dist/rpc/request/index.js.map +1 -1
- package/dist/rpc/request/parse-project.d.ts +25 -0
- package/dist/rpc/request/parse-project.d.ts.map +1 -0
- package/dist/rpc/request/parse-project.js +304 -0
- package/dist/rpc/request/parse-project.js.map +1 -0
- package/dist/rpc/rewrite-rpc.d.ts.map +1 -1
- package/dist/rpc/rewrite-rpc.js +1 -0
- package/dist/rpc/rewrite-rpc.js.map +1 -1
- package/dist/text/parser.d.ts.map +1 -1
- package/dist/text/parser.js +1 -0
- package/dist/text/parser.js.map +1 -1
- package/dist/version.txt +1 -1
- package/dist/yaml/parser.d.ts.map +1 -1
- package/dist/yaml/parser.js +52 -4
- package/dist/yaml/parser.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/cli-utils.ts +46 -237
- package/src/javascript/assertions.ts +74 -10
- package/src/javascript/autodetect.ts +22 -15
- package/src/javascript/format/prettier-config-loader.ts +2 -2
- package/src/javascript/index.ts +1 -0
- package/src/javascript/markers.ts +157 -7
- package/src/javascript/node-resolution-result.ts +23 -2
- package/src/javascript/package-json-parser.ts +19 -1
- package/src/javascript/parser.ts +1 -16
- package/src/javascript/preconditions.ts +1 -1
- package/src/javascript/project-parser.ts +657 -0
- package/src/javascript/style.ts +43 -28
- package/src/json/parser.ts +3 -1
- package/src/markers.ts +1 -1
- package/src/parser.ts +1 -1
- package/src/rpc/index.ts +7 -5
- package/src/rpc/request/index.ts +1 -0
- package/src/rpc/request/parse-project.ts +283 -0
- package/src/rpc/rewrite-rpc.ts +2 -0
- package/src/text/parser.ts +3 -1
- package/src/yaml/parser.ts +53 -5
|
@@ -18,22 +18,22 @@ exports.usesType = usesType;
|
|
|
18
18
|
* See the License for the specific language governing permissions and
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
|
-
const
|
|
21
|
+
const rewrite_rpc_1 = require("../rpc/rewrite-rpc");
|
|
22
22
|
const search_1 = require("./search");
|
|
23
23
|
const search_2 = require("../search");
|
|
24
24
|
function hasSourcePath(filePattern) {
|
|
25
|
-
return
|
|
25
|
+
return rewrite_rpc_1.RewriteRpc.get() ? rewrite_rpc_1.RewriteRpc.get().prepareRecipe("org.openrewrite.FindSourceFiles", {
|
|
26
26
|
filePattern
|
|
27
27
|
}) : new search_2.IsSourceFile(filePattern);
|
|
28
28
|
}
|
|
29
29
|
function usesMethod(methodPattern, matchOverrides = false) {
|
|
30
|
-
return
|
|
30
|
+
return rewrite_rpc_1.RewriteRpc.get() ? rewrite_rpc_1.RewriteRpc.get().prepareRecipe("org.openrewrite.java.search.HasMethod", {
|
|
31
31
|
methodPattern,
|
|
32
32
|
matchOverrides
|
|
33
33
|
}) : new search_1.UsesMethod(methodPattern);
|
|
34
34
|
}
|
|
35
35
|
function usesType(fullyQualifiedType) {
|
|
36
|
-
return
|
|
36
|
+
return rewrite_rpc_1.RewriteRpc.get() ? rewrite_rpc_1.RewriteRpc.get().prepareRecipe("org.openrewrite.java.search.HasType", {
|
|
37
37
|
fullyQualifiedType,
|
|
38
38
|
checkAssignability: false
|
|
39
39
|
}) : new search_1.UsesType(fullyQualifiedType);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preconditions.js","sourceRoot":"","sources":["../../src/javascript/preconditions.ts"],"names":[],"mappings":";;AAsBA,sCAIC;AAED,gCAKC;AAED,4BAKC;AAxCD;;;;;;;;;;;;;;GAcG;AACH,
|
|
1
|
+
{"version":3,"file":"preconditions.js","sourceRoot":"","sources":["../../src/javascript/preconditions.ts"],"names":[],"mappings":";;AAsBA,sCAIC;AAED,gCAKC;AAED,4BAKC;AAxCD;;;;;;;;;;;;;;GAcG;AACH,oDAA8C;AAC9C,qCAA8C;AAG9C,sCAAuC;AAGvC,SAAgB,aAAa,CAAC,WAAmB;IAC7C,OAAO,wBAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,wBAAU,CAAC,GAAG,EAAG,CAAC,aAAa,CAAC,iCAAiC,EAAE;QACzF,WAAW;KACd,CAAC,CAAC,CAAC,CAAC,IAAI,qBAAY,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC;AAED,SAAgB,UAAU,CAAC,aAAqB,EAAE,iBAA0B,KAAK;IAC7E,OAAO,wBAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,wBAAU,CAAC,GAAG,EAAG,CAAC,aAAa,CAAC,uCAAuC,EAAE;QAC/F,aAAa;QACb,cAAc;KACjB,CAAC,CAAC,CAAC,CAAC,IAAI,mBAAU,CAAC,aAAa,CAAC,CAAC;AACvC,CAAC;AAED,SAAgB,QAAQ,CAAC,kBAA0B;IAC/C,OAAO,wBAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,wBAAU,CAAC,GAAG,EAAG,CAAC,aAAa,CAAC,qCAAqC,EAAE;QAC7F,kBAAkB;QAClB,kBAAkB,EAAE,KAAK;KAC5B,CAAC,CAAC,CAAC,CAAC,IAAI,iBAAQ,CAAC,kBAAkB,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { SourceFile } from "../tree";
|
|
2
|
+
import { PrettierConfigLoader } from "./format/prettier-config-loader";
|
|
3
|
+
import { ExecutionContext } from "../execution";
|
|
4
|
+
import { Marker } from "../markers";
|
|
5
|
+
/**
|
|
6
|
+
* Options for project parsing.
|
|
7
|
+
*/
|
|
8
|
+
export interface ProjectParserOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Optional execution context.
|
|
11
|
+
*/
|
|
12
|
+
ctx?: ExecutionContext;
|
|
13
|
+
/**
|
|
14
|
+
* Glob patterns to exclude from source file discovery.
|
|
15
|
+
* Default excludes: node_modules, dist, build, .git, coverage, *.min.js, *.bundle.js
|
|
16
|
+
*/
|
|
17
|
+
exclusions?: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Whether to use git to discover files (respects .gitignore).
|
|
20
|
+
* Default: true if in a git repository.
|
|
21
|
+
*/
|
|
22
|
+
useGit?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Progress callback for file parsing.
|
|
25
|
+
*/
|
|
26
|
+
onProgress?: (phase: "discovering" | "parsing", current: number, total: number, filePath?: string) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Whether to enable verbose logging.
|
|
29
|
+
*/
|
|
30
|
+
verbose?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Optional predicate to filter which files should be parsed.
|
|
33
|
+
* Called with the absolute file path after file discovery.
|
|
34
|
+
* Return true to include the file, false to exclude it.
|
|
35
|
+
* If not provided, all discovered files are parsed.
|
|
36
|
+
*/
|
|
37
|
+
fileFilter?: (absolutePath: string) => boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Result of file discovery.
|
|
41
|
+
*/
|
|
42
|
+
export interface DiscoveredFiles {
|
|
43
|
+
/** package.json files - parsed with PackageJsonParser for NodeResolutionResult */
|
|
44
|
+
packageJsonFiles: string[];
|
|
45
|
+
/** Lock files grouped by parser type */
|
|
46
|
+
lockFiles: {
|
|
47
|
+
json: string[];
|
|
48
|
+
yaml: string[];
|
|
49
|
+
text: string[];
|
|
50
|
+
};
|
|
51
|
+
/** JavaScript/TypeScript files (includes .prettierrc.js, prettier.config.js) */
|
|
52
|
+
jsFiles: string[];
|
|
53
|
+
/** JSON files (tsconfig.json, .prettierrc.json, other .json) */
|
|
54
|
+
jsonFiles: string[];
|
|
55
|
+
/** YAML files (.prettierrc.yaml, other .yaml/.yml) */
|
|
56
|
+
yamlFiles: string[];
|
|
57
|
+
/** Plain text config files (.prettierignore, .gitignore, etc.) */
|
|
58
|
+
textFiles: string[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Default exclusion patterns for file discovery.
|
|
62
|
+
*/
|
|
63
|
+
export declare const DEFAULT_EXCLUSIONS: string[];
|
|
64
|
+
/**
|
|
65
|
+
* Parses an entire JavaScript/TypeScript project.
|
|
66
|
+
*
|
|
67
|
+
* This class handles:
|
|
68
|
+
* - File discovery (source files, package.json, lock files)
|
|
69
|
+
* - Prettier configuration detection (once per project)
|
|
70
|
+
* - Parsing all files with appropriate parsers
|
|
71
|
+
* - Sharing PrettierConfigLoader across all JavaScript parsers
|
|
72
|
+
*
|
|
73
|
+
* Can be used directly for CLI tools or wrapped by RPC handlers.
|
|
74
|
+
*/
|
|
75
|
+
export declare class ProjectParser {
|
|
76
|
+
private readonly projectPath;
|
|
77
|
+
private readonly exclusions;
|
|
78
|
+
private readonly ctx;
|
|
79
|
+
private readonly useGit;
|
|
80
|
+
private readonly onProgress?;
|
|
81
|
+
private readonly verbose;
|
|
82
|
+
private readonly fileFilter?;
|
|
83
|
+
constructor(projectPath: string, options?: ProjectParserOptions);
|
|
84
|
+
/**
|
|
85
|
+
* Creates and initializes a PrettierConfigLoader for this project.
|
|
86
|
+
* Use this when you need to handle Prettier detection separately from parsing.
|
|
87
|
+
*/
|
|
88
|
+
createPrettierLoader(): Promise<PrettierConfigLoader>;
|
|
89
|
+
/**
|
|
90
|
+
* Builds an Autodetect marker from the given source files.
|
|
91
|
+
* Samples all files to detect common formatting styles.
|
|
92
|
+
* Uses dynamic import to avoid circular dependencies.
|
|
93
|
+
*/
|
|
94
|
+
buildAutodetectMarker(sourceFiles: SourceFile[]): Promise<Marker>;
|
|
95
|
+
/**
|
|
96
|
+
* Parses all source files in the project.
|
|
97
|
+
* Yields source files as they are parsed.
|
|
98
|
+
*/
|
|
99
|
+
parse(): AsyncGenerator<SourceFile>;
|
|
100
|
+
/**
|
|
101
|
+
* Discovers all files in the project that should be parsed.
|
|
102
|
+
*/
|
|
103
|
+
discoverFiles(): Promise<DiscoveredFiles>;
|
|
104
|
+
/**
|
|
105
|
+
* Discovers files using git ls-files (respects .gitignore).
|
|
106
|
+
*/
|
|
107
|
+
private discoverFilesWithGit;
|
|
108
|
+
/**
|
|
109
|
+
* Discovers files by walking the directory tree.
|
|
110
|
+
*/
|
|
111
|
+
private discoverFilesWithWalk;
|
|
112
|
+
/**
|
|
113
|
+
* Checks if a file should be accepted for parsing.
|
|
114
|
+
*/
|
|
115
|
+
private isAcceptedFile;
|
|
116
|
+
/**
|
|
117
|
+
* Classifies a yarn.lock file as YAML (Berry) or text (Classic).
|
|
118
|
+
*/
|
|
119
|
+
private classifyYarnLockFile;
|
|
120
|
+
/**
|
|
121
|
+
* Checks if the project is a git repository.
|
|
122
|
+
*/
|
|
123
|
+
private isGitRepository;
|
|
124
|
+
/**
|
|
125
|
+
* Counts total files to parse.
|
|
126
|
+
*/
|
|
127
|
+
private countFiles;
|
|
128
|
+
/**
|
|
129
|
+
* Applies the file filter to discovered files.
|
|
130
|
+
*/
|
|
131
|
+
private applyFileFilter;
|
|
132
|
+
/**
|
|
133
|
+
* Logs a message if verbose mode is enabled.
|
|
134
|
+
*/
|
|
135
|
+
private log;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=project-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-parser.d.ts","sourceRoot":"","sources":["../../src/javascript/project-parser.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AACrE,O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