@openrewrite/rewrite 8.69.0-20251207-220615 → 8.69.0-20251208-071356
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/autodetect.d.ts +45 -0
- package/dist/javascript/autodetect.d.ts.map +1 -0
- package/dist/javascript/autodetect.js +303 -0
- package/dist/javascript/autodetect.js.map +1 -0
- package/dist/javascript/format.d.ts +13 -2
- package/dist/javascript/format.d.ts.map +1 -1
- package/dist/javascript/format.js +100 -21
- package/dist/javascript/format.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/recipes/auto-format.d.ts +25 -13
- package/dist/javascript/recipes/auto-format.d.ts.map +1 -1
- package/dist/javascript/recipes/auto-format.js +38 -13
- package/dist/javascript/recipes/auto-format.js.map +1 -1
- package/dist/javascript/style.d.ts +9 -0
- package/dist/javascript/style.d.ts.map +1 -1
- package/dist/javascript/style.js +30 -0
- package/dist/javascript/style.js.map +1 -1
- package/dist/run.d.ts +6 -5
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +36 -37
- package/dist/run.js.map +1 -1
- package/dist/test/rewrite-test.d.ts +17 -0
- package/dist/test/rewrite-test.d.ts.map +1 -1
- package/dist/test/rewrite-test.js +1 -0
- package/dist/test/rewrite-test.js.map +1 -1
- package/dist/version.txt +1 -1
- package/package.json +1 -1
- package/src/javascript/autodetect.ts +302 -0
- package/src/javascript/format.ts +97 -28
- package/src/javascript/index.ts +1 -0
- package/src/javascript/recipes/auto-format.ts +49 -14
- package/src/javascript/style.ts +32 -0
- package/src/run.ts +20 -20
- package/src/test/rewrite-test.ts +1 -1
package/src/run.ts
CHANGED
|
@@ -78,13 +78,14 @@ export type ProgressCallback = (phase: 'parsing' | 'scanning' | 'processing', cu
|
|
|
78
78
|
* Streaming version of scheduleRun that yields results as soon as each file is processed.
|
|
79
79
|
* This allows callers to print diffs immediately and free memory earlier.
|
|
80
80
|
*
|
|
81
|
-
* Accepts either an array or an async iterable of source files.
|
|
82
|
-
*
|
|
83
|
-
*
|
|
81
|
+
* Accepts either an array or an async iterable of source files. Files are processed
|
|
82
|
+
* immediately as they're yielded from the iterable, avoiding the need to collect all
|
|
83
|
+
* files into memory before starting work.
|
|
84
84
|
*
|
|
85
|
-
* For scanning recipes,
|
|
85
|
+
* For scanning recipes, each file is scanned immediately as it's pulled from the generator,
|
|
86
|
+
* then stored for the edit phase. The scan phase completes before any results are yielded.
|
|
86
87
|
*
|
|
87
|
-
* @param onProgress Optional callback for progress updates during
|
|
88
|
+
* @param onProgress Optional callback for progress updates during scanning and processing phases.
|
|
88
89
|
*/
|
|
89
90
|
export async function* scheduleRunStreaming(
|
|
90
91
|
recipe: Recipe,
|
|
@@ -96,23 +97,20 @@ export async function* scheduleRunStreaming(
|
|
|
96
97
|
const isScanning = await hasScanningRecipe(recipe);
|
|
97
98
|
|
|
98
99
|
if (isScanning) {
|
|
99
|
-
// For scanning recipes,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
files.push(sf);
|
|
105
|
-
parseCount++;
|
|
106
|
-
onProgress?.('parsing', parseCount, -1, sf.sourcePath); // -1 = unknown total
|
|
107
|
-
}
|
|
108
|
-
}
|
|
100
|
+
// For scanning recipes, pull files from the generator and scan them immediately.
|
|
101
|
+
// Files are stored for the later edit phase.
|
|
102
|
+
const files: SourceFile[] = [];
|
|
103
|
+
const iterable = Array.isArray(before) ? before : before;
|
|
104
|
+
const knownTotal = Array.isArray(before) ? before.length : -1; // -1 = unknown total
|
|
109
105
|
|
|
110
|
-
|
|
106
|
+
// Phase 1: Pull files from generator and scan each immediately
|
|
107
|
+
let scanCount = 0;
|
|
108
|
+
for await (const b of iterable) {
|
|
109
|
+
files.push(b);
|
|
110
|
+
scanCount++;
|
|
111
|
+
onProgress?.('scanning', scanCount, knownTotal, b.sourcePath);
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
for (let i = 0; i < files.length; i++) {
|
|
114
|
-
const b = files[i];
|
|
115
|
-
onProgress?.('scanning', i + 1, totalFiles, b.sourcePath);
|
|
113
|
+
// Scan this file immediately
|
|
116
114
|
await recurseRecipeList(recipe, b, async (recipe, b2) => {
|
|
117
115
|
if (recipe instanceof ScanningRecipe) {
|
|
118
116
|
return (await recipe.scanner(recipe.accumulator(cursor, ctx))).visit(b2, ctx, cursor)
|
|
@@ -120,6 +118,8 @@ export async function* scheduleRunStreaming(
|
|
|
120
118
|
});
|
|
121
119
|
}
|
|
122
120
|
|
|
121
|
+
const totalFiles = files.length;
|
|
122
|
+
|
|
123
123
|
// Phase 2: Collect generated files
|
|
124
124
|
const generated = (await recurseRecipeList(recipe, [] as SourceFile[], async (recipe, generated) => {
|
|
125
125
|
if (recipe instanceof ScanningRecipe) {
|
package/src/test/rewrite-test.ts
CHANGED
|
@@ -257,7 +257,7 @@ export type AfterRecipeText = string | ((actual: string) => string | undefined)
|
|
|
257
257
|
* - ` code\n` → `code` (trailing newline removed)
|
|
258
258
|
* - ` code\n\n` → `code\n` (first trailing newline removed, second preserved)
|
|
259
259
|
*/
|
|
260
|
-
function dedent(s: string): string {
|
|
260
|
+
export function dedent(s: string): string {
|
|
261
261
|
if (!s) return s;
|
|
262
262
|
|
|
263
263
|
// Remove single leading newline for ergonomics
|