-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
2,662 additions
and
2,626 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import boxen from "boxen"; | ||
import chalk from "chalk"; | ||
import { version } from "../package.json"; | ||
import semver from "semver"; | ||
|
||
async function checkProductionCLIVersion() { | ||
try { | ||
const response = await fetch( | ||
"https://raw.githubusercontent.com/sfcompute/cli/refs/heads/main/package.json", | ||
); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
const data = await response.json(); | ||
const latestVersion = data.version; | ||
return latestVersion; | ||
} catch (error) { | ||
console.error("Failed to check for latest CLI version:", error); | ||
return null; | ||
} | ||
} | ||
|
||
export async function checkVersion() { | ||
const latestVersion = await checkProductionCLIVersion(); | ||
if (latestVersion && version !== latestVersion) { | ||
const isOutdated = semver.lt(version, latestVersion); | ||
if (isOutdated) { | ||
const message = ` | ||
Please update your CLI. | ||
Your version: ${version} | ||
Latest version: ${latestVersion} | ||
Run 'sf upgrade' to update to the latest version | ||
`; | ||
console.log( | ||
boxen(chalk.yellow(message), { | ||
padding: 1, | ||
borderColor: "yellow", | ||
borderStyle: "round", | ||
}), | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.