@openrewrite/rewrite 8.68.0-20251204-054843 → 8.68.0-20251204-145030
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/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/javascript/index.d.ts +3 -0
- package/dist/javascript/index.d.ts.map +1 -1
- package/dist/javascript/index.js +3 -0
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/package-json-parser.d.ts +0 -5
- package/dist/javascript/package-json-parser.d.ts.map +1 -1
- package/dist/javascript/package-json-parser.js +13 -25
- package/dist/javascript/package-json-parser.js.map +1 -1
- package/dist/javascript/package-manager.d.ts +131 -0
- package/dist/javascript/package-manager.d.ts.map +1 -0
- package/dist/javascript/package-manager.js +372 -0
- package/dist/javascript/package-manager.js.map +1 -0
- package/dist/javascript/recipes/index.d.ts +2 -0
- package/dist/javascript/recipes/index.d.ts.map +1 -0
- package/dist/javascript/recipes/index.js +33 -0
- package/dist/javascript/recipes/index.js.map +1 -0
- package/dist/javascript/recipes/upgrade-dependency-version.d.ts +105 -0
- package/dist/javascript/recipes/upgrade-dependency-version.d.ts.map +1 -0
- package/dist/javascript/recipes/upgrade-dependency-version.js +493 -0
- package/dist/javascript/recipes/upgrade-dependency-version.js.map +1 -0
- package/dist/javascript/search/find-dependency.d.ts +32 -0
- package/dist/javascript/search/find-dependency.d.ts.map +1 -0
- package/dist/javascript/search/find-dependency.js +312 -0
- package/dist/javascript/search/find-dependency.js.map +1 -0
- package/dist/javascript/search/index.d.ts +1 -0
- package/dist/javascript/search/index.d.ts.map +1 -1
- package/dist/javascript/search/index.js +1 -0
- package/dist/javascript/search/index.js.map +1 -1
- package/dist/json/print.js +1 -1
- package/dist/json/print.js.map +1 -1
- package/dist/markers.d.ts +67 -0
- package/dist/markers.d.ts.map +1 -1
- package/dist/markers.js +101 -0
- package/dist/markers.js.map +1 -1
- package/dist/print.d.ts.map +1 -1
- package/dist/print.js +0 -1
- package/dist/print.js.map +1 -1
- package/dist/recipe.js +3 -3
- package/dist/recipe.js.map +1 -1
- package/dist/rpc/index.js +72 -0
- package/dist/rpc/index.js.map +1 -1
- package/dist/rpc/request/generate.js +1 -1
- package/dist/rpc/request/generate.js.map +1 -1
- package/dist/rpc/request/get-languages.d.ts.map +1 -1
- package/dist/rpc/request/get-languages.js +2 -1
- package/dist/rpc/request/get-languages.js.map +1 -1
- package/dist/rpc/request/visit.d.ts.map +1 -1
- package/dist/rpc/request/visit.js +27 -0
- package/dist/rpc/request/visit.js.map +1 -1
- package/dist/run.js +2 -2
- package/dist/run.js.map +1 -1
- package/dist/test/rewrite-test.js +1 -1
- package/dist/test/rewrite-test.js.map +1 -1
- package/dist/version.txt +1 -1
- package/package.json +1 -1
- package/src/index.ts +4 -0
- package/src/javascript/index.ts +3 -0
- package/src/javascript/package-json-parser.ts +14 -33
- package/src/javascript/package-manager.ts +428 -0
- package/src/javascript/recipes/index.ts +17 -0
- package/src/javascript/recipes/upgrade-dependency-version.ts +586 -0
- package/src/javascript/search/find-dependency.ts +303 -0
- package/src/javascript/search/index.ts +1 -0
- package/src/json/print.ts +1 -1
- package/src/markers.ts +146 -0
- package/src/print.ts +0 -1
- package/src/recipe.ts +3 -3
- package/src/rpc/index.ts +65 -1
- package/src/rpc/request/generate.ts +1 -1
- package/src/rpc/request/get-languages.ts +2 -1
- package/src/rpc/request/visit.ts +32 -1
- package/src/run.ts +2 -2
- package/src/test/rewrite-test.ts +1 -1
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2025 the original author or authors.
|
|
4
|
+
* <p>
|
|
5
|
+
* Licensed under the Moderne Source Available License (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* <p>
|
|
9
|
+
* https://docs.moderne.io/licensing/moderne-source-available-license
|
|
10
|
+
* <p>
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.detectPackageManager = detectPackageManager;
|
|
52
|
+
exports.getLockFileDetectionConfig = getLockFileDetectionConfig;
|
|
53
|
+
exports.getPackageManagerConfig = getPackageManagerConfig;
|
|
54
|
+
exports.getLockFileName = getLockFileName;
|
|
55
|
+
exports.getAllLockFileNames = getAllLockFileNames;
|
|
56
|
+
exports.isLockFile = isLockFile;
|
|
57
|
+
exports.runInstall = runInstall;
|
|
58
|
+
exports.runAddPackage = runAddPackage;
|
|
59
|
+
exports.runList = runList;
|
|
60
|
+
exports.isPackageManagerAvailable = isPackageManagerAvailable;
|
|
61
|
+
exports.getPackageManagerDisplayName = getPackageManagerDisplayName;
|
|
62
|
+
const node_resolution_result_1 = require("./node-resolution-result");
|
|
63
|
+
const fs = __importStar(require("fs"));
|
|
64
|
+
const path = __importStar(require("path"));
|
|
65
|
+
const child_process_1 = require("child_process");
|
|
66
|
+
/**
|
|
67
|
+
* Package manager configurations.
|
|
68
|
+
*/
|
|
69
|
+
const PACKAGE_MANAGER_CONFIGS = {
|
|
70
|
+
[node_resolution_result_1.PackageManager.Npm]: {
|
|
71
|
+
lockFile: 'package-lock.json',
|
|
72
|
+
installLockOnlyCommand: ['npm', 'install', '--package-lock-only'],
|
|
73
|
+
installCommand: ['npm', 'install'],
|
|
74
|
+
listCommand: ['npm', 'list', '--json', '--all'],
|
|
75
|
+
},
|
|
76
|
+
[node_resolution_result_1.PackageManager.YarnClassic]: {
|
|
77
|
+
lockFile: 'yarn.lock',
|
|
78
|
+
// Yarn Classic doesn't have a lock-only mode
|
|
79
|
+
installLockOnlyCommand: ['yarn', 'install', '--ignore-scripts'],
|
|
80
|
+
installCommand: ['yarn', 'install'],
|
|
81
|
+
listCommand: ['yarn', 'list', '--json'],
|
|
82
|
+
},
|
|
83
|
+
[node_resolution_result_1.PackageManager.YarnBerry]: {
|
|
84
|
+
lockFile: 'yarn.lock',
|
|
85
|
+
// Yarn Berry's mode skip-build skips post-install scripts
|
|
86
|
+
installLockOnlyCommand: ['yarn', 'install', '--mode', 'skip-build'],
|
|
87
|
+
installCommand: ['yarn', 'install'],
|
|
88
|
+
listCommand: ['yarn', 'info', '--all', '--json'],
|
|
89
|
+
},
|
|
90
|
+
[node_resolution_result_1.PackageManager.Pnpm]: {
|
|
91
|
+
lockFile: 'pnpm-lock.yaml',
|
|
92
|
+
installLockOnlyCommand: ['pnpm', 'install', '--lockfile-only'],
|
|
93
|
+
installCommand: ['pnpm', 'install'],
|
|
94
|
+
listCommand: ['pnpm', 'list', '--json', '--depth=Infinity'],
|
|
95
|
+
},
|
|
96
|
+
[node_resolution_result_1.PackageManager.Bun]: {
|
|
97
|
+
lockFile: 'bun.lock',
|
|
98
|
+
// Bun doesn't have a lock-only mode, but is very fast anyway
|
|
99
|
+
installLockOnlyCommand: ['bun', 'install', '--ignore-scripts'],
|
|
100
|
+
installCommand: ['bun', 'install'],
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Lock file detection configuration with priority order.
|
|
105
|
+
* Priority order determines which package manager is detected when multiple lock files exist.
|
|
106
|
+
*/
|
|
107
|
+
const LOCK_FILE_DETECTION = [
|
|
108
|
+
{ filename: 'package-lock.json', packageManager: node_resolution_result_1.PackageManager.Npm },
|
|
109
|
+
{ filename: 'bun.lock', packageManager: node_resolution_result_1.PackageManager.Bun },
|
|
110
|
+
{ filename: 'pnpm-lock.yaml', packageManager: node_resolution_result_1.PackageManager.Pnpm, preferNodeModules: true },
|
|
111
|
+
{
|
|
112
|
+
filename: 'yarn.lock',
|
|
113
|
+
packageManager: (content) => content.includes('__metadata:') ? node_resolution_result_1.PackageManager.YarnBerry : node_resolution_result_1.PackageManager.YarnClassic,
|
|
114
|
+
// yarn.lock omits transitive dependency details (engines/license), so prefer node_modules
|
|
115
|
+
preferNodeModules: true
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
/**
|
|
119
|
+
* Detects the package manager used in a directory by checking for lock files.
|
|
120
|
+
*
|
|
121
|
+
* @param dir The directory to check
|
|
122
|
+
* @returns The detected package manager, or undefined if none found
|
|
123
|
+
*/
|
|
124
|
+
function detectPackageManager(dir) {
|
|
125
|
+
for (const config of LOCK_FILE_DETECTION) {
|
|
126
|
+
const lockPath = path.join(dir, config.filename);
|
|
127
|
+
if (fs.existsSync(lockPath)) {
|
|
128
|
+
if (typeof config.packageManager === 'function') {
|
|
129
|
+
try {
|
|
130
|
+
const content = fs.readFileSync(lockPath, 'utf-8');
|
|
131
|
+
return config.packageManager(content);
|
|
132
|
+
}
|
|
133
|
+
catch (_a) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return config.packageManager;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Gets the lock file detection configuration.
|
|
144
|
+
* Returns the array of lock file configs in priority order.
|
|
145
|
+
*/
|
|
146
|
+
function getLockFileDetectionConfig() {
|
|
147
|
+
return LOCK_FILE_DETECTION;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Gets the configuration for a package manager.
|
|
151
|
+
*/
|
|
152
|
+
function getPackageManagerConfig(pm) {
|
|
153
|
+
return PACKAGE_MANAGER_CONFIGS[pm];
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Gets the lock file name for a package manager.
|
|
157
|
+
*/
|
|
158
|
+
function getLockFileName(pm) {
|
|
159
|
+
return PACKAGE_MANAGER_CONFIGS[pm].lockFile;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Gets all supported lock file names.
|
|
163
|
+
*/
|
|
164
|
+
function getAllLockFileNames() {
|
|
165
|
+
return LOCK_FILE_DETECTION.map(c => c.filename);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Checks if a file path is a lock file.
|
|
169
|
+
*/
|
|
170
|
+
function isLockFile(filePath) {
|
|
171
|
+
const fileName = path.basename(filePath);
|
|
172
|
+
return getAllLockFileNames().includes(fileName);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Runs the package manager install command.
|
|
176
|
+
*
|
|
177
|
+
* @param pm The package manager to use
|
|
178
|
+
* @param options Install options
|
|
179
|
+
* @returns Result of the install command
|
|
180
|
+
*/
|
|
181
|
+
function runInstall(pm, options) {
|
|
182
|
+
var _a;
|
|
183
|
+
const config = PACKAGE_MANAGER_CONFIGS[pm];
|
|
184
|
+
const command = options.lockOnly ? config.installLockOnlyCommand : config.installCommand;
|
|
185
|
+
const [cmd, ...args] = command;
|
|
186
|
+
try {
|
|
187
|
+
const result = (0, child_process_1.spawnSync)(cmd, args, {
|
|
188
|
+
cwd: options.cwd,
|
|
189
|
+
encoding: 'utf-8',
|
|
190
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
191
|
+
timeout: (_a = options.timeout) !== null && _a !== void 0 ? _a : 120000,
|
|
192
|
+
env: options.env ? Object.assign(Object.assign({}, process.env), options.env) : process.env,
|
|
193
|
+
});
|
|
194
|
+
if (result.error) {
|
|
195
|
+
return {
|
|
196
|
+
success: false,
|
|
197
|
+
error: result.error.message,
|
|
198
|
+
stderr: result.stderr,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
if (result.status !== 0) {
|
|
202
|
+
return {
|
|
203
|
+
success: false,
|
|
204
|
+
stdout: result.stdout,
|
|
205
|
+
stderr: result.stderr,
|
|
206
|
+
error: `Command exited with code ${result.status}`,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
success: true,
|
|
211
|
+
stdout: result.stdout,
|
|
212
|
+
stderr: result.stderr,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
return {
|
|
217
|
+
success: false,
|
|
218
|
+
error: error.message,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Runs a package manager command to add or upgrade a package.
|
|
224
|
+
* This updates both package.json and the lock file.
|
|
225
|
+
*
|
|
226
|
+
* @param pm The package manager to use
|
|
227
|
+
* @param options Add package options
|
|
228
|
+
* @returns Result of the command
|
|
229
|
+
*/
|
|
230
|
+
function runAddPackage(pm, options) {
|
|
231
|
+
var _a;
|
|
232
|
+
const packageSpec = `${options.packageName}@${options.version}`;
|
|
233
|
+
// Build command based on package manager
|
|
234
|
+
let cmd;
|
|
235
|
+
let args;
|
|
236
|
+
switch (pm) {
|
|
237
|
+
case node_resolution_result_1.PackageManager.Npm:
|
|
238
|
+
cmd = 'npm';
|
|
239
|
+
args = ['install', packageSpec];
|
|
240
|
+
if (options.lockOnly) {
|
|
241
|
+
args.push('--package-lock-only');
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
244
|
+
case node_resolution_result_1.PackageManager.YarnClassic:
|
|
245
|
+
cmd = 'yarn';
|
|
246
|
+
args = ['add', packageSpec];
|
|
247
|
+
if (options.lockOnly) {
|
|
248
|
+
args.push('--ignore-scripts');
|
|
249
|
+
}
|
|
250
|
+
break;
|
|
251
|
+
case node_resolution_result_1.PackageManager.YarnBerry:
|
|
252
|
+
cmd = 'yarn';
|
|
253
|
+
args = ['add', packageSpec];
|
|
254
|
+
if (options.lockOnly) {
|
|
255
|
+
args.push('--mode', 'skip-build');
|
|
256
|
+
}
|
|
257
|
+
break;
|
|
258
|
+
case node_resolution_result_1.PackageManager.Pnpm:
|
|
259
|
+
cmd = 'pnpm';
|
|
260
|
+
args = ['add', packageSpec];
|
|
261
|
+
if (options.lockOnly) {
|
|
262
|
+
args.push('--lockfile-only');
|
|
263
|
+
}
|
|
264
|
+
break;
|
|
265
|
+
case node_resolution_result_1.PackageManager.Bun:
|
|
266
|
+
cmd = 'bun';
|
|
267
|
+
args = ['add', packageSpec];
|
|
268
|
+
if (options.lockOnly) {
|
|
269
|
+
args.push('--ignore-scripts');
|
|
270
|
+
}
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
const result = (0, child_process_1.spawnSync)(cmd, args, {
|
|
275
|
+
cwd: options.cwd,
|
|
276
|
+
encoding: 'utf-8',
|
|
277
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
278
|
+
timeout: (_a = options.timeout) !== null && _a !== void 0 ? _a : 120000,
|
|
279
|
+
env: options.env ? Object.assign(Object.assign({}, process.env), options.env) : process.env,
|
|
280
|
+
});
|
|
281
|
+
if (result.error) {
|
|
282
|
+
return {
|
|
283
|
+
success: false,
|
|
284
|
+
error: result.error.message,
|
|
285
|
+
stderr: result.stderr,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
if (result.status !== 0) {
|
|
289
|
+
return {
|
|
290
|
+
success: false,
|
|
291
|
+
stdout: result.stdout,
|
|
292
|
+
stderr: result.stderr,
|
|
293
|
+
error: `Command exited with code ${result.status}`,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
success: true,
|
|
298
|
+
stdout: result.stdout,
|
|
299
|
+
stderr: result.stderr,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
return {
|
|
304
|
+
success: false,
|
|
305
|
+
error: error.message,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Runs a package manager list command to get dependency information.
|
|
311
|
+
*
|
|
312
|
+
* @param pm The package manager to use
|
|
313
|
+
* @param cwd Working directory
|
|
314
|
+
* @param timeout Timeout in milliseconds
|
|
315
|
+
* @returns The JSON output, or undefined if failed
|
|
316
|
+
*/
|
|
317
|
+
function runList(pm, cwd, timeout = 30000) {
|
|
318
|
+
const config = PACKAGE_MANAGER_CONFIGS[pm];
|
|
319
|
+
if (!config.listCommand) {
|
|
320
|
+
return undefined;
|
|
321
|
+
}
|
|
322
|
+
const [cmd, ...args] = config.listCommand;
|
|
323
|
+
const result = (0, child_process_1.spawnSync)(cmd, args, {
|
|
324
|
+
cwd,
|
|
325
|
+
encoding: 'utf-8',
|
|
326
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
327
|
+
timeout,
|
|
328
|
+
});
|
|
329
|
+
if (result.error || result.status !== 0) {
|
|
330
|
+
return undefined;
|
|
331
|
+
}
|
|
332
|
+
return result.stdout;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Checks if a package manager is available on the system.
|
|
336
|
+
*
|
|
337
|
+
* @param pm The package manager to check
|
|
338
|
+
* @returns True if the package manager is available
|
|
339
|
+
*/
|
|
340
|
+
function isPackageManagerAvailable(pm) {
|
|
341
|
+
const config = PACKAGE_MANAGER_CONFIGS[pm];
|
|
342
|
+
const cmd = config.installCommand[0];
|
|
343
|
+
try {
|
|
344
|
+
const result = (0, child_process_1.spawnSync)(cmd, ['--version'], {
|
|
345
|
+
encoding: 'utf-8',
|
|
346
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
347
|
+
timeout: 5000,
|
|
348
|
+
});
|
|
349
|
+
return result.status === 0;
|
|
350
|
+
}
|
|
351
|
+
catch (_a) {
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Gets a human-readable name for a package manager.
|
|
357
|
+
*/
|
|
358
|
+
function getPackageManagerDisplayName(pm) {
|
|
359
|
+
switch (pm) {
|
|
360
|
+
case node_resolution_result_1.PackageManager.Npm:
|
|
361
|
+
return 'npm';
|
|
362
|
+
case node_resolution_result_1.PackageManager.YarnClassic:
|
|
363
|
+
return 'Yarn Classic';
|
|
364
|
+
case node_resolution_result_1.PackageManager.YarnBerry:
|
|
365
|
+
return 'Yarn Berry';
|
|
366
|
+
case node_resolution_result_1.PackageManager.Pnpm:
|
|
367
|
+
return 'pnpm';
|
|
368
|
+
case node_resolution_result_1.PackageManager.Bun:
|
|
369
|
+
return 'Bun';
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
//# sourceMappingURL=package-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-manager.js","sourceRoot":"","sources":["../../src/javascript/package-manager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4HH,oDAgBC;AAMD,gEAEC;AAKD,0DAEC;AAKD,0CAEC;AAKD,kDAEC;AAKD,gCAGC;AASD,gCA0CC;AAiCD,sCAkFC;AAUD,0BAoBC;AAQD,8DAcC;AAKD,oEAaC;AA3ZD,qEAAwD;AACxD,uCAAyB;AACzB,2CAA6B;AAC7B,iDAAwC;AAmBxC;;GAEG;AACH,MAAM,uBAAuB,GAAiD;IAC1E,CAAC,uCAAc,CAAC,GAAG,CAAC,EAAE;QAClB,QAAQ,EAAE,mBAAmB;QAC7B,sBAAsB,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,qBAAqB,CAAC;QACjE,cAAc,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC;QAClC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC;KAClD;IACD,CAAC,uCAAc,CAAC,WAAW,CAAC,EAAE;QAC1B,QAAQ,EAAE,WAAW;QACrB,6CAA6C;QAC7C,sBAAsB,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,kBAAkB,CAAC;QAC/D,cAAc,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;QACnC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;KAC1C;IACD,CAAC,uCAAc,CAAC,SAAS,CAAC,EAAE;QACxB,QAAQ,EAAE,WAAW;QACrB,0DAA0D;QAC1D,sBAAsB,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAC;QACnE,cAAc,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;QACnC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CAAC,CAAC;IAC/B,CAAC;IAAC,WAAM,CAAC;QACL,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAgB,4BAA4B,CAAC,EAAkB;IAC3D,QAAQ,EAAE,EAAE,CAAC;QACT,KAAK,uCAAc,CAAC,GAAG;YACnB,OAAO,KAAK,CAAC;QACjB,KAAK,uCAAc,CAAC,WAAW;YAC3B,OAAO,cAAc,CAAC;QAC1B,KAAK,uCAAc,CAAC,SAAS;YACzB,OAAO,YAAY,CAAC;QACxB,KAAK,uCAAc,CAAC,IAAI;YACpB,OAAO,MAAM,CAAC;QAClB,KAAK,uCAAc,CAAC,GAAG;YACnB,OAAO,KAAK,CAAC;IACrB,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/javascript/recipes/index.ts"],"names":[],"mappings":"AAgBA,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2025 the original author or authors.
|
|
4
|
+
* <p>
|
|
5
|
+
* Licensed under the Moderne Source Available License (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* <p>
|
|
9
|
+
* https://docs.moderne.io/licensing/moderne-source-available-license
|
|
10
|
+
* <p>
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
29
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
__exportStar(require("./upgrade-dependency-version"), exports);
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/javascript/recipes/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,+DAA6C"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { ScanningRecipe } from "../../recipe";
|
|
2
|
+
import { ExecutionContext } from "../../execution";
|
|
3
|
+
import { TreeVisitor } from "../../visitor";
|
|
4
|
+
import { PackageManager } from "../node-resolution-result";
|
|
5
|
+
/**
|
|
6
|
+
* Represents a dependency scope in package.json
|
|
7
|
+
*/
|
|
8
|
+
type DependencyScope = 'dependencies' | 'devDependencies' | 'peerDependencies' | 'optionalDependencies';
|
|
9
|
+
/**
|
|
10
|
+
* Information about a project that needs updating
|
|
11
|
+
*/
|
|
12
|
+
interface ProjectUpdateInfo {
|
|
13
|
+
/** Absolute path to the project directory */
|
|
14
|
+
projectDir: string;
|
|
15
|
+
/** Relative path to package.json (from source root) */
|
|
16
|
+
packageJsonPath: string;
|
|
17
|
+
/** Original package.json content */
|
|
18
|
+
originalPackageJson: string;
|
|
19
|
+
/** The scope where the dependency was found */
|
|
20
|
+
dependencyScope: DependencyScope;
|
|
21
|
+
/** Current version constraint */
|
|
22
|
+
currentVersion: string;
|
|
23
|
+
/** New version constraint to apply */
|
|
24
|
+
newVersion: string;
|
|
25
|
+
/** The package manager used by this project */
|
|
26
|
+
packageManager: PackageManager;
|
|
27
|
+
/**
|
|
28
|
+
* If true, skip running the package manager because the resolved version
|
|
29
|
+
* already satisfies the new constraint. Only package.json needs updating.
|
|
30
|
+
*/
|
|
31
|
+
skipInstall: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Accumulator for tracking state across scanning and editing phases
|
|
35
|
+
*/
|
|
36
|
+
interface Accumulator {
|
|
37
|
+
/** Projects that need updating: packageJsonPath -> update info */
|
|
38
|
+
projectsToUpdate: Map<string, ProjectUpdateInfo>;
|
|
39
|
+
/** After running package manager, store the updated lock file content */
|
|
40
|
+
updatedLockFiles: Map<string, string>;
|
|
41
|
+
/** Updated package.json content (after npm install may have modified it) */
|
|
42
|
+
updatedPackageJsons: Map<string, string>;
|
|
43
|
+
/** Track which projects have been processed (npm install has run) */
|
|
44
|
+
processedProjects: Set<string>;
|
|
45
|
+
/** Track projects where npm install failed: packageJsonPath -> error message */
|
|
46
|
+
failedProjects: Map<string, string>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Upgrades the version of a dependency in package.json and updates the lock file.
|
|
50
|
+
*
|
|
51
|
+
* This recipe:
|
|
52
|
+
* 1. Finds package.json files containing the specified dependency
|
|
53
|
+
* 2. Updates the version constraint to the new version
|
|
54
|
+
* 3. Runs the package manager to update the lock file
|
|
55
|
+
* 4. Updates the NodeResolutionResult marker with new dependency info
|
|
56
|
+
*
|
|
57
|
+
* TODO: Consider adding a `resolveToLatestMatching` option that would use `npm install <pkg>@<version>`
|
|
58
|
+
* to let the package manager resolve the constraint to the latest matching version.
|
|
59
|
+
* For example, `^22.0.0` would become `^22.19.1` (the latest version satisfying ^22.0.0).
|
|
60
|
+
* This would be similar to how Maven's UpgradeDependencyVersion works with version selectors.
|
|
61
|
+
*/
|
|
62
|
+
export declare class UpgradeDependencyVersion extends ScanningRecipe<Accumulator> {
|
|
63
|
+
readonly name = "org.openrewrite.javascript.dependencies.upgrade-dependency-version";
|
|
64
|
+
readonly displayName = "Upgrade npm dependency version";
|
|
65
|
+
readonly description = "Upgrades the version of a dependency in `package.json` and updates the lock file by running the package manager.";
|
|
66
|
+
packageName: string;
|
|
67
|
+
newVersion: string;
|
|
68
|
+
initialValue(_ctx: ExecutionContext): Accumulator;
|
|
69
|
+
/**
|
|
70
|
+
* Determines if the dependency should be upgraded from currentVersion to newVersion.
|
|
71
|
+
* Returns true only if the new version constraint represents a strictly newer version.
|
|
72
|
+
*
|
|
73
|
+
* This prevents:
|
|
74
|
+
* - Re-applying the same version (idempotency)
|
|
75
|
+
* - Downgrading to an older version
|
|
76
|
+
*
|
|
77
|
+
* @param currentVersion Current version constraint (e.g., "^4.17.20")
|
|
78
|
+
* @param newVersion New version constraint to apply (e.g., "^4.17.21")
|
|
79
|
+
* @returns true if upgrade should proceed, false otherwise
|
|
80
|
+
*/
|
|
81
|
+
shouldUpgrade(currentVersion: string, newVersion: string): boolean;
|
|
82
|
+
scanner(acc: Accumulator): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
83
|
+
editorWithData(acc: Accumulator): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
84
|
+
/**
|
|
85
|
+
* Runs the package manager in a temporary directory to update the lock file.
|
|
86
|
+
* Writes a modified package.json with the new version, then runs install to update the lock file.
|
|
87
|
+
*/
|
|
88
|
+
private runPackageManagerInstall;
|
|
89
|
+
/**
|
|
90
|
+
* Creates a modified package.json with the updated dependency version.
|
|
91
|
+
* Used for the temp directory to validate the version exists.
|
|
92
|
+
*/
|
|
93
|
+
private createModifiedPackageJson;
|
|
94
|
+
/**
|
|
95
|
+
* Updates the NodeResolutionResult marker with new dependency information.
|
|
96
|
+
*/
|
|
97
|
+
private updateMarker;
|
|
98
|
+
/**
|
|
99
|
+
* Updates just the versionConstraint in the marker for the target dependency.
|
|
100
|
+
* Used when skipInstall is true - the resolved version is unchanged.
|
|
101
|
+
*/
|
|
102
|
+
private updateMarkerVersionConstraint;
|
|
103
|
+
}
|
|
104
|
+
export {};
|
|
105
|
+
//# sourceMappingURL=upgrade-dependency-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade-dependency-version.d.ts","sourceRoot":"","sources":["../../../src/javascript/recipes/upgrade-dependency-version.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAS,cAAc,EAAC,MAAM,cAAc,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,OAAO,EAKH,cAAc,EAEjB,MAAM,2BAA2B,CAAC;AAcnC;;GAEG;AACH,KAAK,eAAe,GAAG,cAAc,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,sBAAsB,CAAC;AAExG;;GAEG;AACH,UAAU,iBAAiB;IACvB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,eAAe,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,+CAA+C;IAC/C,eAAe,EAAE,eAAe,CAAC;IACjC,iCAAiC;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,cAAc,EAAE,cAAc,CAAC;IAC/B;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,UAAU,WAAW;IACjB,kEAAkE;IAClE,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAEjD,yEAAyE;IACzE,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,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