@@ -12,6 +12,8 @@ import { getTriggerApiDetails } from "../utils/getTriggerApiDetails";
1212import { logger } from "../utils/logger" ;
1313import { resolvePath } from "../utils/parseNameAndPath" ;
1414import { TriggerApi } from "../utils/triggerApi" ;
15+ import { run as ncuRun } from 'npm-check-updates'
16+ import chalk from "chalk" ;
1517
1618const asyncExecFile = util . promisify ( childProcess . execFile ) ;
1719
@@ -45,6 +47,7 @@ export async function devCommand(path: string, anyOptions: any) {
4547 const options = result . data ;
4648
4749 const resolvedPath = resolvePath ( path ) ;
50+ await checkForOutdatedPackages ( resolvedPath )
4851
4952 // Read from package.json to get the endpointId
5053 const endpointId = await getEndpointIdFromPackageJson ( resolvedPath , options ) ;
@@ -205,6 +208,36 @@ export async function devCommand(path: string, anyOptions: any) {
205208 throttle ( refresh , throttleTimeMs ) ;
206209}
207210
211+ export async function checkForOutdatedPackages ( path : string ) {
212+
213+ const updates = await ncuRun ( {
214+ packageFile : `${ path } /package.json` ,
215+ filter : "/trigger.dev\/.+$/" ,
216+ upgrade : false ,
217+ } ) as {
218+ [ key : string ] : string ;
219+ }
220+
221+ if ( typeof updates === 'undefined' || Object . keys ( updates ) . length === 0 ) {
222+ return ;
223+ }
224+
225+ const packageFile = await fs . readFile ( `${ path } /package.json` ) ;
226+ const data = JSON . parse ( Buffer . from ( packageFile ) . toString ( 'utf8' ) ) ;
227+ const dependencies = data . dependencies ;
228+ console . log (
229+ chalk . bgYellow ( 'Updates available for trigger.dev packages' )
230+ ) ;
231+ console . log (
232+ chalk . bgBlue ( 'Run npx @trigger.dev/cli@latest update' )
233+ ) ;
234+
235+ for ( let dep in updates ) {
236+ console . log ( `${ dep } ${ dependencies [ dep ] } → ${ updates [ dep ] } ` ) ;
237+ }
238+
239+ }
240+
208241export async function getEndpointIdFromPackageJson ( path : string , options : DevCommandOptions ) {
209242 if ( options . clientId ) {
210243 return options . clientId ;
0 commit comments