( dir: string, options: UpdateCommandOptions, embedded?: boolean, requireUpdate?: boolean )
| 46 | } |
| 47 | |
| 48 | export async function updateTriggerPackages( |
| 49 | dir: string, |
| 50 | options: UpdateCommandOptions, |
| 51 | embedded?: boolean, |
| 52 | requireUpdate?: boolean |
| 53 | ): Promise<boolean> { |
| 54 | let hasOutput = false; |
| 55 | |
| 56 | if (!embedded) { |
| 57 | intro("Updating packages"); |
| 58 | } |
| 59 | |
| 60 | const projectPath = resolve(process.cwd(), dir); |
| 61 | |
| 62 | const { packageJson, readonlyPackageJson, packageJsonPath } = await getPackageJson(projectPath); |
| 63 | |
| 64 | if (!packageJson) { |
| 65 | log.error("Failed to load package.json. Try to re-run with `-l debug` to see what's going on."); |
| 66 | return false; |
| 67 | } |
| 68 | |
| 69 | const cliVersion = getVersion(); |
| 70 | const newCliVersion = await updateCheck(); |
| 71 | |
| 72 | if (newCliVersion) { |
| 73 | prettyWarning( |
| 74 | "You're not running the latest CLI version, please consider updating ASAP", |
| 75 | `Current: ${cliVersion}\nLatest: ${newCliVersion}`, |
| 76 | "Run latest: npx trigger.dev@beta" |
| 77 | ); |
| 78 | |
| 79 | hasOutput = true; |
| 80 | } |
| 81 | |
| 82 | const triggerDependencies = getTriggerDependencies(packageJson); |
| 83 | |
| 84 | function getVersionMismatches(deps: Dependency[], targetVersion: string): Dependency[] { |
| 85 | const mismatches: Dependency[] = []; |
| 86 | |
| 87 | for (const dep of deps) { |
| 88 | if (dep.version === targetVersion) { |
| 89 | continue; |
| 90 | } |
| 91 | |
| 92 | mismatches.push(dep); |
| 93 | } |
| 94 | |
| 95 | return mismatches; |
| 96 | } |
| 97 | |
| 98 | const versionMismatches = getVersionMismatches(triggerDependencies, cliVersion); |
| 99 | |
| 100 | if (versionMismatches.length === 0) { |
| 101 | if (!embedded) { |
| 102 | outro(`Nothing to do${newCliVersion ? " ..but you should really update your CLI!" : ""}`); |
| 103 | return hasOutput; |
| 104 | } |
| 105 | return hasOutput; |
no test coverage detected
searching dependent graphs…