From 68dffaec4f800c5bf0ec79a074e735900bc66231 Mon Sep 17 00:00:00 2001 From: neo773 <62795688+neo773@users.noreply.github.com> Date: Sun, 27 Aug 2023 23:15:01 +0530 Subject: [PATCH 1/2] feat: Add update checker for CLI --- packages/cli/src/commands/dev.ts | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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; From 48611b58a770bdf06593b99650addb9651eb3222 Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Mon, 28 Aug 2023 09:36:40 +0100 Subject: [PATCH 2/2] Create soft-hounds-clap.md --- .changeset/soft-hounds-clap.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/soft-hounds-clap.md 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