|
1 | 1 | import { confirm, intro, isCancel, log, outro } from "@clack/prompts";
|
2 |
| -import { RunOptions, run as ncuRun } from "npm-check-updates"; |
3 | 2 | import { z } from "zod";
|
4 | 3 | import { readJSONFile, removeFile, writeJSONFile } from "../utilities/fileSystem.js";
|
5 | 4 | import { spinner } from "../utilities/windows.js";
|
@@ -40,9 +39,6 @@ export function configureUpdateCommand(program: Command) {
|
40 | 39 | });
|
41 | 40 | }
|
42 | 41 |
|
43 |
| -const NcuRunResult = z.record(z.string()); |
44 |
| -type NcuRunResult = z.infer<typeof NcuRunResult>; |
45 |
| - |
46 | 42 | const triggerPackageFilter = /^@trigger\.dev/;
|
47 | 43 |
|
48 | 44 | export async function updateCommand(dir: string, options: UpdateCommandOptions) {
|
@@ -265,20 +261,6 @@ function mutatePackageJsonWithUpdatedPackages(
|
265 | 261 | }
|
266 | 262 | }
|
267 | 263 |
|
268 |
| -function getNcuTargetVersion(version: string): RunOptions["target"] { |
269 |
| - switch (version) { |
270 |
| - case "latest": |
271 |
| - case "newest": |
272 |
| - case "greatest": |
273 |
| - case "minor": |
274 |
| - case "patch": |
275 |
| - case "semver": |
276 |
| - return version; |
277 |
| - default: |
278 |
| - return `@${version}`; |
279 |
| - } |
280 |
| -} |
281 |
| - |
282 | 264 | function printUpdateTable(depsToUpdate: Dependency[], targetVersion: string): void {
|
283 | 265 | log.message("Suggested updates");
|
284 | 266 |
|
@@ -310,49 +292,3 @@ export async function getPackageJson(absoluteProjectPath: string) {
|
310 | 292 |
|
311 | 293 | return { packageJson, readonlyPackageJson, packageJsonPath };
|
312 | 294 | }
|
313 |
| - |
314 |
| -export async function checkForPackageUpdates( |
315 |
| - packageJson: PackageJson, |
316 |
| - targetVersion: string, |
317 |
| - existingSpinner?: ReturnType<typeof spinner> |
318 |
| -) { |
319 |
| - const updateCheckSpinner = existingSpinner ?? spinner(); |
320 |
| - |
321 |
| - updateCheckSpinner[existingSpinner ? "message" : "start"]("Checking for updates"); |
322 |
| - |
323 |
| - const normalizedTarget = getNcuTargetVersion(targetVersion); |
324 |
| - |
325 |
| - // Use npm-check-updates to get updated dependency versions |
326 |
| - const ncuOptions: RunOptions = { |
327 |
| - packageData: packageJson as RunOptions["packageData"], |
328 |
| - target: normalizedTarget, |
329 |
| - filter: triggerPackageFilter, |
330 |
| - }; |
331 |
| - |
332 |
| - logger.debug({ ncuOptions: JSON.stringify(ncuOptions, undefined, 2) }); |
333 |
| - |
334 |
| - // Check for new versions of @trigger.dev packages |
335 |
| - const ncuRunResult = await ncuRun(ncuOptions); |
336 |
| - logger.debug({ ncuRunResult }); |
337 |
| - |
338 |
| - const triggerDepsToUpdate = NcuRunResult.safeParse(ncuRunResult); |
339 |
| - |
340 |
| - if (!triggerDepsToUpdate.success) { |
341 |
| - logger.error("Failed to parse ncu result", { ncuRunResult }); |
342 |
| - updateCheckSpinner.stop("Couldn't update dependencies"); |
343 |
| - return; |
344 |
| - } |
345 |
| - |
346 |
| - console.log({ triggerDepsToUpdate: triggerDepsToUpdate.data }); |
347 |
| - |
348 |
| - const totalToUpdate = Object.keys(triggerDepsToUpdate.data).length; |
349 |
| - |
350 |
| - if (totalToUpdate === 0) { |
351 |
| - updateCheckSpinner.stop("No package updates found"); |
352 |
| - return; |
353 |
| - } |
354 |
| - |
355 |
| - updateCheckSpinner.stop("Found packages to update"); |
356 |
| - |
357 |
| - return triggerDepsToUpdate.data; |
358 |
| -} |
0 commit comments