MCPcopy
hub / github.com/triggerdotdev/trigger.dev / updateTriggerPackages

Function updateTriggerPackages

packages/cli-v3/src/commands/update.ts:48–223  ·  view source on GitHub ↗
(
  dir: string,
  options: UpdateCommandOptions,
  embedded?: boolean,
  requireUpdate?: boolean
)

Source from the content-addressed store, hash-verified

46}
47
48export 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;

Callers 3

startDevFunction · 0.90
_deployCommandFunction · 0.90
updateCommandFunction · 0.85

Calls 15

getPackageManagerMethod · 0.95
installMethod · 0.95
getPackageJsonFunction · 0.85
updateCheckFunction · 0.85
prettyWarningFunction · 0.85
getTriggerDependenciesFunction · 0.85
getVersionMismatchesFunction · 0.85
updateConfirmationFunction · 0.85
chalkErrorFunction · 0.85
spinnerFunction · 0.85
revertPackageJsonChangesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…