@openrewrite/rewrite 8.72.2 → 8.72.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/execution.js +3 -16
- package/dist/execution.js.map +1 -1
- package/dist/index.js +34 -49
- package/dist/index.js.map +1 -1
- package/dist/java/markers.js +12 -29
- package/dist/java/markers.js.map +1 -1
- package/dist/java/print.js +2 -13
- package/dist/java/print.js.map +1 -1
- package/dist/java/rpc.js +1344 -1725
- package/dist/java/rpc.js.map +1 -1
- package/dist/java/type-visitor.js +143 -184
- package/dist/java/type-visitor.js.map +1 -1
- package/dist/java/visitor.js +1072 -1249
- package/dist/java/visitor.js.map +1 -1
- package/dist/javascript/add-import.js +495 -534
- package/dist/javascript/add-import.js.map +1 -1
- package/dist/javascript/autodetect.js +116 -159
- package/dist/javascript/autodetect.js.map +1 -1
- package/dist/javascript/cleanup/add-parse-int-radix.js +41 -57
- package/dist/javascript/cleanup/add-parse-int-radix.js.map +1 -1
- package/dist/javascript/cleanup/prefer-optional-chain.js +89 -105
- package/dist/javascript/cleanup/prefer-optional-chain.js.map +1 -1
- package/dist/javascript/cleanup/use-object-property-shorthand.js +74 -95
- package/dist/javascript/cleanup/use-object-property-shorthand.js.map +1 -1
- package/dist/javascript/comparator.js +815 -1167
- package/dist/javascript/comparator.js.map +1 -1
- package/dist/javascript/dependency-workspace.js +206 -219
- package/dist/javascript/dependency-workspace.js.map +1 -1
- package/dist/javascript/format/format.js +682 -908
- package/dist/javascript/format/format.js.map +1 -1
- package/dist/javascript/format/minimum-viable-spacing-visitor.js +152 -231
- package/dist/javascript/format/minimum-viable-spacing-visitor.js.map +1 -1
- package/dist/javascript/format/normalize-whitespace-visitor.js +12 -31
- package/dist/javascript/format/normalize-whitespace-visitor.js.map +1 -1
- package/dist/javascript/format/prettier-config-loader.js +134 -153
- package/dist/javascript/format/prettier-config-loader.js.map +1 -1
- package/dist/javascript/format/prettier-format.js +112 -129
- package/dist/javascript/format/prettier-format.js.map +1 -1
- package/dist/javascript/format/tabs-and-indents-visitor.js +112 -136
- package/dist/javascript/format/tabs-and-indents-visitor.js.map +1 -1
- package/dist/javascript/markers.js +59 -92
- package/dist/javascript/markers.js.map +1 -1
- package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.js +39 -52
- package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.js.map +1 -1
- package/dist/javascript/migrate/es6/modernize-octal-literals.js +25 -38
- package/dist/javascript/migrate/es6/modernize-octal-literals.js.map +1 -1
- package/dist/javascript/migrate/es6/remove-duplicate-object-keys.js +66 -82
- package/dist/javascript/migrate/es6/remove-duplicate-object-keys.js.map +1 -1
- package/dist/javascript/migrate/typescript/export-assignment-to-export-default.js +10 -23
- package/dist/javascript/migrate/typescript/export-assignment-to-export-default.js.map +1 -1
- package/dist/javascript/node-resolution-result.js +137 -166
- package/dist/javascript/node-resolution-result.js.map +1 -1
- package/dist/javascript/package-json-parser.js +312 -343
- package/dist/javascript/package-json-parser.js.map +1 -1
- package/dist/javascript/package-manager.js +145 -170
- package/dist/javascript/package-manager.js.map +1 -1
- package/dist/javascript/parser.d.ts.map +1 -1
- package/dist/javascript/parser.js +94 -68
- package/dist/javascript/parser.js.map +1 -1
- package/dist/javascript/print.js +1572 -1835
- package/dist/javascript/print.js.map +1 -1
- package/dist/javascript/project-parser.js +151 -172
- package/dist/javascript/project-parser.js.map +1 -1
- package/dist/javascript/recipes/add-dependency.js +140 -175
- package/dist/javascript/recipes/add-dependency.js.map +1 -1
- package/dist/javascript/recipes/async-callback-in-sync-array-method.js +20 -36
- package/dist/javascript/recipes/async-callback-in-sync-array-method.js.map +1 -1
- package/dist/javascript/recipes/auto-format.js +3 -14
- package/dist/javascript/recipes/auto-format.js.map +1 -1
- package/dist/javascript/recipes/change-import.js +447 -495
- package/dist/javascript/recipes/change-import.js.map +1 -1
- package/dist/javascript/recipes/order-imports.js +162 -175
- package/dist/javascript/recipes/order-imports.js.map +1 -1
- package/dist/javascript/recipes/upgrade-dependency-version.js +167 -197
- package/dist/javascript/recipes/upgrade-dependency-version.js.map +1 -1
- package/dist/javascript/recipes/upgrade-transitive-dependency-version.js +166 -193
- package/dist/javascript/recipes/upgrade-transitive-dependency-version.js.map +1 -1
- package/dist/javascript/remove-import.js +689 -724
- package/dist/javascript/remove-import.js.map +1 -1
- package/dist/javascript/rpc.js +1007 -1332
- package/dist/javascript/rpc.js.map +1 -1
- package/dist/javascript/search/find-dependency.js +84 -110
- package/dist/javascript/search/find-dependency.js.map +1 -1
- package/dist/javascript/search/uses-method.js +5 -19
- package/dist/javascript/search/uses-method.js.map +1 -1
- package/dist/javascript/search/uses-type.js +9 -20
- package/dist/javascript/search/uses-type.js.map +1 -1
- package/dist/javascript/templating/comparator.js +737 -822
- package/dist/javascript/templating/comparator.js.map +1 -1
- package/dist/javascript/templating/engine.js +211 -245
- package/dist/javascript/templating/engine.js.map +1 -1
- package/dist/javascript/templating/pattern.js +169 -190
- package/dist/javascript/templating/pattern.js.map +1 -1
- package/dist/javascript/templating/placeholder-replacement.js +172 -210
- package/dist/javascript/templating/placeholder-replacement.js.map +1 -1
- package/dist/javascript/templating/rewrite.js +75 -97
- package/dist/javascript/templating/rewrite.js.map +1 -1
- package/dist/javascript/templating/template.js +69 -82
- package/dist/javascript/templating/template.js.map +1 -1
- package/dist/javascript/tree-debug.js +109 -137
- package/dist/javascript/tree-debug.js.map +1 -1
- package/dist/javascript/visitor.js +1090 -1254
- package/dist/javascript/visitor.js.map +1 -1
- package/dist/json/print.js +72 -103
- package/dist/json/print.js.map +1 -1
- package/dist/json/rpc.js +120 -181
- package/dist/json/rpc.js.map +1 -1
- package/dist/json/visitor.js +69 -100
- package/dist/json/visitor.js.map +1 -1
- package/dist/marketplace.js +20 -33
- package/dist/marketplace.js.map +1 -1
- package/dist/parse-error.js +41 -62
- package/dist/parse-error.js.map +1 -1
- package/dist/parser.js +7 -18
- package/dist/parser.js.map +1 -1
- package/dist/path-utils.js +46 -59
- package/dist/path-utils.js.map +1 -1
- package/dist/preconditions.js +30 -47
- package/dist/preconditions.js.map +1 -1
- package/dist/print.js +6 -19
- package/dist/print.js.map +1 -1
- package/dist/recipe.js +42 -73
- package/dist/recipe.js.map +1 -1
- package/dist/rpc/index.js +74 -115
- package/dist/rpc/index.js.map +1 -1
- package/dist/rpc/queue.js +71 -90
- package/dist/rpc/queue.js.map +1 -1
- package/dist/rpc/recipe.js +32 -57
- package/dist/rpc/recipe.js.map +1 -1
- package/dist/rpc/request/generate.js +4 -13
- package/dist/rpc/request/generate.js.map +1 -1
- package/dist/rpc/request/get-languages.js +2 -11
- package/dist/rpc/request/get-languages.js.map +1 -1
- package/dist/rpc/request/get-marketplace.js +9 -20
- package/dist/rpc/request/get-marketplace.js.map +1 -1
- package/dist/rpc/request/get-object.js +4 -13
- package/dist/rpc/request/get-object.js.map +1 -1
- package/dist/rpc/request/install-recipes.js +25 -36
- package/dist/rpc/request/install-recipes.js.map +1 -1
- package/dist/rpc/request/metrics.js +8 -17
- package/dist/rpc/request/metrics.js.map +1 -1
- package/dist/rpc/request/parse-project.js +36 -45
- package/dist/rpc/request/parse-project.js.map +1 -1
- package/dist/rpc/request/parse.js +5 -14
- package/dist/rpc/request/parse.js.map +1 -1
- package/dist/rpc/request/prepare-recipe.js +37 -52
- package/dist/rpc/request/prepare-recipe.js.map +1 -1
- package/dist/rpc/request/print.js +5 -14
- package/dist/rpc/request/print.js.map +1 -1
- package/dist/rpc/request/visit.js +56 -71
- package/dist/rpc/request/visit.js.map +1 -1
- package/dist/rpc/rewrite-rpc.js +70 -97
- package/dist/rpc/rewrite-rpc.js.map +1 -1
- package/dist/rpc/server.js +76 -89
- package/dist/rpc/server.js.map +1 -1
- package/dist/run.js +47 -66
- package/dist/run.js.map +1 -1
- package/dist/search/is-source-file.js +8 -19
- package/dist/search/is-source-file.js.map +1 -1
- package/dist/test/rewrite-test.js +154 -188
- package/dist/test/rewrite-test.js.map +1 -1
- package/dist/text/print.js +23 -38
- package/dist/text/print.js.map +1 -1
- package/dist/text/rpc.js +29 -44
- package/dist/text/rpc.js.map +1 -1
- package/dist/text/visitor.js +16 -33
- package/dist/text/visitor.js.map +1 -1
- package/dist/util.js +13 -24
- package/dist/util.js.map +1 -1
- package/dist/version.txt +1 -1
- package/dist/visitor.js +84 -115
- package/dist/visitor.js.map +1 -1
- package/dist/yaml/index.d.ts +2 -0
- package/dist/yaml/index.d.ts.map +1 -1
- package/dist/yaml/index.js +2 -0
- package/dist/yaml/index.js.map +1 -1
- package/dist/yaml/markers.d.ts +21 -0
- package/dist/yaml/markers.d.ts.map +1 -0
- package/dist/yaml/markers.js +37 -0
- package/dist/yaml/markers.js.map +1 -0
- package/dist/yaml/parser.d.ts.map +1 -1
- package/dist/yaml/parser.js +4 -1
- package/dist/yaml/parser.js.map +1 -1
- package/dist/yaml/print.d.ts +1 -1
- package/dist/yaml/print.d.ts.map +1 -1
- package/dist/yaml/print.js +175 -208
- package/dist/yaml/print.js.map +1 -1
- package/dist/yaml/rpc.js +154 -219
- package/dist/yaml/rpc.js.map +1 -1
- package/dist/yaml/visitor.js +78 -113
- package/dist/yaml/visitor.js.map +1 -1
- package/package.json +1 -1
- package/src/javascript/parser.ts +56 -14
- package/src/yaml/index.ts +2 -0
- package/src/yaml/markers.ts +70 -0
- package/src/yaml/parser.ts +5 -1
- package/src/yaml/print.ts +5 -2
|
@@ -32,15 +32,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
36
|
exports.PrettierConfigLoader = void 0;
|
|
46
37
|
exports.clearPrettierModuleCache = clearPrettierModuleCache;
|
|
@@ -119,41 +110,39 @@ function isPrettierCached(version) {
|
|
|
119
110
|
/**
|
|
120
111
|
* Installs a specific Prettier version to the cache directory.
|
|
121
112
|
*/
|
|
122
|
-
function installPrettierToCache(version) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
prettier: version
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
yield fsp.writeFile(path.join(cacheDir, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
138
|
-
// Run npm install
|
|
139
|
-
const result = (0, child_process_1.spawnSync)((0, shell_utils_1.getPlatformCommand)('npm'), ['install', '--silent'], {
|
|
140
|
-
cwd: cacheDir,
|
|
141
|
-
encoding: 'utf-8',
|
|
142
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
143
|
-
timeout: 120000 // 2 minutes
|
|
144
|
-
});
|
|
145
|
-
if (result.error) {
|
|
146
|
-
throw new Error(`Failed to install Prettier ${version}: ${result.error.message}`);
|
|
147
|
-
}
|
|
148
|
-
if (result.status !== 0) {
|
|
149
|
-
const stderr = ((_a = result.stderr) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
150
|
-
throw new Error(`Failed to install Prettier ${version}: npm exited with code ${result.status}${stderr ? '\n' + stderr : ''}`);
|
|
151
|
-
}
|
|
152
|
-
// Verify installation
|
|
153
|
-
if (!isPrettierCached(version)) {
|
|
154
|
-
throw new Error(`Prettier ${version} installation verification failed`);
|
|
113
|
+
async function installPrettierToCache(version) {
|
|
114
|
+
var _a;
|
|
115
|
+
const cacheDir = getPrettierCacheDir(version);
|
|
116
|
+
// Create directory structure
|
|
117
|
+
await fsp.mkdir(cacheDir, { recursive: true });
|
|
118
|
+
// Create minimal package.json
|
|
119
|
+
const packageJson = {
|
|
120
|
+
name: `prettier-cache-${version}`,
|
|
121
|
+
version: '1.0.0',
|
|
122
|
+
private: true,
|
|
123
|
+
dependencies: {
|
|
124
|
+
prettier: version
|
|
155
125
|
}
|
|
126
|
+
};
|
|
127
|
+
await fsp.writeFile(path.join(cacheDir, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
128
|
+
// Run npm install
|
|
129
|
+
const result = (0, child_process_1.spawnSync)((0, shell_utils_1.getPlatformCommand)('npm'), ['install', '--silent'], {
|
|
130
|
+
cwd: cacheDir,
|
|
131
|
+
encoding: 'utf-8',
|
|
132
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
133
|
+
timeout: 120000 // 2 minutes
|
|
156
134
|
});
|
|
135
|
+
if (result.error) {
|
|
136
|
+
throw new Error(`Failed to install Prettier ${version}: ${result.error.message}`);
|
|
137
|
+
}
|
|
138
|
+
if (result.status !== 0) {
|
|
139
|
+
const stderr = ((_a = result.stderr) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
140
|
+
throw new Error(`Failed to install Prettier ${version}: npm exited with code ${result.status}${stderr ? '\n' + stderr : ''}`);
|
|
141
|
+
}
|
|
142
|
+
// Verify installation
|
|
143
|
+
if (!isPrettierCached(version)) {
|
|
144
|
+
throw new Error(`Prettier ${version} installation verification failed`);
|
|
145
|
+
}
|
|
157
146
|
}
|
|
158
147
|
/**
|
|
159
148
|
* Loads Prettier from the cache directory for a specific version.
|
|
@@ -194,42 +183,40 @@ class PrettierConfigLoader {
|
|
|
194
183
|
* Detects Prettier in the project and loads our bundled version for config resolution.
|
|
195
184
|
* Call this once at the start of parsing.
|
|
196
185
|
*/
|
|
197
|
-
detectPrettier() {
|
|
198
|
-
|
|
199
|
-
|
|
186
|
+
async detectPrettier() {
|
|
187
|
+
if (this.detection) {
|
|
188
|
+
return this.detection;
|
|
189
|
+
}
|
|
190
|
+
this.detection = { available: false };
|
|
191
|
+
try {
|
|
192
|
+
// Get the project's Prettier version from package.json or node_modules
|
|
193
|
+
const version = this.getPrettierVersionFromProject();
|
|
194
|
+
if (!version) {
|
|
200
195
|
return this.detection;
|
|
201
196
|
}
|
|
202
|
-
|
|
197
|
+
// Load our bundled Prettier for config resolution
|
|
198
|
+
// We use dynamic require to handle cases where Prettier isn't installed
|
|
199
|
+
let bundledPrettier;
|
|
203
200
|
try {
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
if (!version) {
|
|
207
|
-
return this.detection;
|
|
208
|
-
}
|
|
209
|
-
// Load our bundled Prettier for config resolution
|
|
210
|
-
// We use dynamic require to handle cases where Prettier isn't installed
|
|
211
|
-
let bundledPrettier;
|
|
212
|
-
try {
|
|
213
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
214
|
-
bundledPrettier = require('prettier');
|
|
215
|
-
}
|
|
216
|
-
catch (e) {
|
|
217
|
-
// Our bundled Prettier isn't available
|
|
218
|
-
console.warn('PrettierConfigLoader: Failed to load bundled Prettier:', e);
|
|
219
|
-
return this.detection;
|
|
220
|
-
}
|
|
221
|
-
this.detection = {
|
|
222
|
-
available: true,
|
|
223
|
-
version,
|
|
224
|
-
bundledPrettier
|
|
225
|
-
};
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
202
|
+
bundledPrettier = require('prettier');
|
|
226
203
|
}
|
|
227
|
-
catch (
|
|
228
|
-
//
|
|
229
|
-
|
|
204
|
+
catch (e) {
|
|
205
|
+
// Our bundled Prettier isn't available
|
|
206
|
+
console.warn('PrettierConfigLoader: Failed to load bundled Prettier:', e);
|
|
207
|
+
return this.detection;
|
|
230
208
|
}
|
|
231
|
-
|
|
232
|
-
|
|
209
|
+
this.detection = {
|
|
210
|
+
available: true,
|
|
211
|
+
version,
|
|
212
|
+
bundledPrettier
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
catch (_a) {
|
|
216
|
+
// Any error means Prettier isn't properly set up
|
|
217
|
+
this.detection = { available: false };
|
|
218
|
+
}
|
|
219
|
+
return this.detection;
|
|
233
220
|
}
|
|
234
221
|
/**
|
|
235
222
|
* Gets the Prettier version from the project's package.json or node_modules.
|
|
@@ -304,46 +291,44 @@ class PrettierConfigLoader {
|
|
|
304
291
|
*
|
|
305
292
|
* @param filePath Absolute path to the source file
|
|
306
293
|
*/
|
|
307
|
-
getConfigMarker(filePath) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
294
|
+
async getConfigMarker(filePath) {
|
|
295
|
+
var _a, _b;
|
|
296
|
+
if (!((_a = this.detection) === null || _a === void 0 ? void 0 : _a.available) || !this.detection.bundledPrettier) {
|
|
297
|
+
return undefined;
|
|
298
|
+
}
|
|
299
|
+
try {
|
|
300
|
+
// Resolve path against projectRoot if not absolute
|
|
301
|
+
const absolutePath = path.isAbsolute(filePath)
|
|
302
|
+
? filePath
|
|
303
|
+
: path.join(this.projectRoot, filePath);
|
|
304
|
+
// Check if file is ignored by .prettierignore
|
|
305
|
+
const ignorePath = this.findPrettierIgnore();
|
|
306
|
+
let ignored = false;
|
|
307
|
+
if (ignorePath) {
|
|
308
|
+
const fileInfo = await this.detection.bundledPrettier.getFileInfo(absolutePath, { ignorePath });
|
|
309
|
+
ignored = fileInfo.ignored;
|
|
312
310
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
if (ignorePath) {
|
|
322
|
-
const fileInfo = yield this.detection.bundledPrettier.getFileInfo(absolutePath, { ignorePath });
|
|
323
|
-
ignored = fileInfo.ignored;
|
|
324
|
-
}
|
|
325
|
-
// Resolve config for this specific file (applies overrides)
|
|
326
|
-
// If no config file exists, use empty config (Prettier defaults)
|
|
327
|
-
const config = (_b = yield this.detection.bundledPrettier.resolveConfig(absolutePath)) !== null && _b !== void 0 ? _b : {};
|
|
328
|
-
// Create a cache key from the resolved config + version + ignored status
|
|
329
|
-
const configKey = JSON.stringify({ config, version: this.detection.version, ignored });
|
|
330
|
-
// Check cache for existing marker with same config
|
|
331
|
-
let marker = this.configCache.get(configKey);
|
|
332
|
-
if (marker) {
|
|
333
|
-
return marker;
|
|
334
|
-
}
|
|
335
|
-
// Create new PrettierStyle instance
|
|
336
|
-
marker = (0, style_1.prettierStyle)((0, uuid_1.randomId)(), config, this.detection.version, ignored);
|
|
337
|
-
// Cache and return
|
|
338
|
-
this.configCache.set(configKey, marker);
|
|
311
|
+
// Resolve config for this specific file (applies overrides)
|
|
312
|
+
// If no config file exists, use empty config (Prettier defaults)
|
|
313
|
+
const config = (_b = await this.detection.bundledPrettier.resolveConfig(absolutePath)) !== null && _b !== void 0 ? _b : {};
|
|
314
|
+
// Create a cache key from the resolved config + version + ignored status
|
|
315
|
+
const configKey = JSON.stringify({ config, version: this.detection.version, ignored });
|
|
316
|
+
// Check cache for existing marker with same config
|
|
317
|
+
let marker = this.configCache.get(configKey);
|
|
318
|
+
if (marker) {
|
|
339
319
|
return marker;
|
|
340
320
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
321
|
+
// Create new PrettierStyle instance
|
|
322
|
+
marker = (0, style_1.prettierStyle)((0, uuid_1.randomId)(), config, this.detection.version, ignored);
|
|
323
|
+
// Cache and return
|
|
324
|
+
this.configCache.set(configKey, marker);
|
|
325
|
+
return marker;
|
|
326
|
+
}
|
|
327
|
+
catch (e) {
|
|
328
|
+
// Config resolution failed for this file
|
|
329
|
+
console.warn(`PrettierConfigLoader: Failed to resolve config for ${filePath}:`, e);
|
|
330
|
+
return undefined;
|
|
331
|
+
}
|
|
347
332
|
}
|
|
348
333
|
/**
|
|
349
334
|
* Clears the config cache. Call this between parse batches if needed.
|
|
@@ -367,54 +352,50 @@ exports.PrettierConfigLoader = PrettierConfigLoader;
|
|
|
367
352
|
* @param version The Prettier version to load (e.g., "3.4.2")
|
|
368
353
|
* @returns The loaded Prettier module
|
|
369
354
|
*/
|
|
370
|
-
function loadPrettierVersion(version) {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
});
|
|
355
|
+
async function loadPrettierVersion(version) {
|
|
356
|
+
// Check in-memory cache first
|
|
357
|
+
const cached = prettierModuleCache.get(version);
|
|
358
|
+
if (cached) {
|
|
359
|
+
return cached;
|
|
360
|
+
}
|
|
361
|
+
// Check if there's already a pending load for this version
|
|
362
|
+
const pending = pendingLoads.get(version);
|
|
363
|
+
if (pending) {
|
|
364
|
+
return pending;
|
|
365
|
+
}
|
|
366
|
+
// Create and cache the load promise to prevent concurrent duplicate loads
|
|
367
|
+
const loadPromise = loadPrettierVersionInternal(version);
|
|
368
|
+
pendingLoads.set(version, loadPromise);
|
|
369
|
+
try {
|
|
370
|
+
const prettier = await loadPromise;
|
|
371
|
+
prettierModuleCache.set(version, prettier);
|
|
372
|
+
return prettier;
|
|
373
|
+
}
|
|
374
|
+
finally {
|
|
375
|
+
pendingLoads.delete(version);
|
|
376
|
+
}
|
|
394
377
|
}
|
|
395
378
|
/**
|
|
396
379
|
* Internal implementation of Prettier version loading.
|
|
397
380
|
*/
|
|
398
|
-
function loadPrettierVersionInternal(version) {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
return localPrettier;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
catch (_a) {
|
|
409
|
-
// Local prettier not available
|
|
410
|
-
}
|
|
411
|
-
// Check if version is cached on disk
|
|
412
|
-
if (isPrettierCached(version)) {
|
|
413
|
-
return loadPrettierFromCache(version);
|
|
381
|
+
async function loadPrettierVersionInternal(version) {
|
|
382
|
+
// Try to load from local node_modules if version matches
|
|
383
|
+
try {
|
|
384
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
385
|
+
const localPrettier = require('prettier');
|
|
386
|
+
if (localPrettier.version === version) {
|
|
387
|
+
return localPrettier;
|
|
414
388
|
}
|
|
415
|
-
|
|
416
|
-
|
|
389
|
+
}
|
|
390
|
+
catch (_a) {
|
|
391
|
+
// Local prettier not available
|
|
392
|
+
}
|
|
393
|
+
// Check if version is cached on disk
|
|
394
|
+
if (isPrettierCached(version)) {
|
|
417
395
|
return loadPrettierFromCache(version);
|
|
418
|
-
}
|
|
396
|
+
}
|
|
397
|
+
// Install to cache and load
|
|
398
|
+
await installPrettierToCache(version);
|
|
399
|
+
return loadPrettierFromCache(version);
|
|
419
400
|
}
|
|
420
401
|
//# sourceMappingURL=prettier-config-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prettier-config-loader.js","sourceRoot":"","sources":["../../../src/javascript/format/prettier-config-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prettier-config-loader.js","sourceRoot":"","sources":["../../../src/javascript/format/prettier-config-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,4DAGC;AAsUD,kDAwBC;AA7YD;;;;;;;;;;;;;;GAcG;AACH,2CAA6B;AAC7B,uCAAyB;AACzB,iDAAmC;AACnC,uCAAyB;AACzB,iDAAwC;AACxC,oCAAsD;AACtD,qCAAoC;AACpC,mDAAqD;AAErD;;;;;;GAMG;AACH,MAAM,mBAAmB,GAA2C,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