diff --git a/.changeset/soft-hounds-clap.md b/.changeset/soft-hounds-clap.md new file mode 100644 index 00000000000..01acc7be6fc --- /dev/null +++ b/.changeset/soft-hounds-clap.md @@ -0,0 +1,5 @@ +--- +"@trigger.dev/cli": patch +--- + +feat: Checks for outdated packages when running the dev command with instructions on how to update diff --git a/packages/cli/src/commands/dev.ts b/packages/cli/src/commands/dev.ts index 1afcd03d3cf..55f88b1fb4b 100644 --- a/packages/cli/src/commands/dev.ts +++ b/packages/cli/src/commands/dev.ts @@ -12,6 +12,8 @@ import { getTriggerApiDetails } from "../utils/getTriggerApiDetails"; import { logger } from "../utils/logger"; import { resolvePath } from "../utils/parseNameAndPath"; import { TriggerApi } from "../utils/triggerApi"; +import { run as ncuRun } from 'npm-check-updates' +import chalk from "chalk"; const asyncExecFile = util.promisify(childProcess.execFile); @@ -45,6 +47,7 @@ export async function devCommand(path: string, anyOptions: any) { const options = result.data; const resolvedPath = resolvePath(path); + await checkForOutdatedPackages(resolvedPath) // Read from package.json to get the endpointId const endpointId = await getEndpointIdFromPackageJson(resolvedPath, options); @@ -205,6 +208,36 @@ export async function devCommand(path: string, anyOptions: any) { throttle(refresh, throttleTimeMs); } +export async function checkForOutdatedPackages(path: string) { + + const updates = await ncuRun({ + packageFile: `${path}/package.json`, + filter: "/trigger.dev\/.+$/", + upgrade: false, + }) as { + [key: string]: string; + } + + if (typeof updates === 'undefined' || Object.keys(updates).length === 0) { + return; + } + + const packageFile = await fs.readFile(`${path}/package.json`); + const data = JSON.parse(Buffer.from(packageFile).toString('utf8')); + const dependencies = data.dependencies; + console.log( + chalk.bgYellow('Updates available for trigger.dev packages') + ); + console.log( + chalk.bgBlue('Run npx @trigger.dev/cli@latest update') + ); + + for (let dep in updates) { + console.log(`${dep} ${dependencies[dep]} → ${updates[dep]}`); + } + +} + export async function getEndpointIdFromPackageJson(path: string, options: DevCommandOptions) { if (options.clientId) { return options.clientId;