@@ -12,6 +12,8 @@ import { getTriggerApiDetails } from "../utils/getTriggerApiDetails";
12
12
import { logger } from "../utils/logger" ;
13
13
import { resolvePath } from "../utils/parseNameAndPath" ;
14
14
import { TriggerApi } from "../utils/triggerApi" ;
15
+ import { run as ncuRun } from 'npm-check-updates'
16
+ import chalk from "chalk" ;
15
17
16
18
const asyncExecFile = util . promisify ( childProcess . execFile ) ;
17
19
@@ -45,6 +47,7 @@ export async function devCommand(path: string, anyOptions: any) {
45
47
const options = result . data ;
46
48
47
49
const resolvedPath = resolvePath ( path ) ;
50
+ await checkForOutdatedPackages ( resolvedPath )
48
51
49
52
// Read from package.json to get the endpointId
50
53
const endpointId = await getEndpointIdFromPackageJson ( resolvedPath , options ) ;
@@ -205,6 +208,36 @@ export async function devCommand(path: string, anyOptions: any) {
205
208
throttle ( refresh , throttleTimeMs ) ;
206
209
}
207
210
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
+
208
241
export async function getEndpointIdFromPackageJson ( path : string , options : DevCommandOptions ) {
209
242
if ( options . clientId ) {
210
243
return options . clientId ;
0 commit comments