feat: check for the setup-cpp updates and notify

This commit is contained in:
Amin Yahyaabadi 2023-04-21 21:14:22 -07:00
parent 6e6418d7b6
commit 67e7d24a8b
4 changed files with 30 additions and 3 deletions

View File

@ -7,4 +7,3 @@ stats.html
src/python/setup-python/
src/msvc/msvc-dev-cmd/
dev/cpp_vcpkg_project
package.json

View File

@ -59,6 +59,9 @@
"test.unit": "jest --runInBand"
},
"prettier": "prettier-config-atomic",
"dependencies": {
"update-notifier": "^6.0.2"
},
"devDependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
@ -153,7 +156,9 @@
"engines": {
"node": ">=12.x"
},
"includeNodeModules": true,
"includeNodeModules": {
"update-notifier": false
},
"optimize": true,
"outputFormat": "commonjs"
},
@ -162,7 +167,9 @@
"engines": {
"node": ">=16.x"
},
"includeNodeModules": true,
"includeNodeModules": {
"update-notifier": false
},
"optimize": true,
"outputFormat": "commonjs"
}

15
src/check-updates.ts Normal file
View File

@ -0,0 +1,15 @@
import { warning } from "ci-log"
import { readFile } from "fs/promises"
import { join } from "path"
// auto self update notifier
export async function checkUpdates() {
try {
const updateNotifier = (await import("update-notifier")).default
const packageJsonString = await readFile(join(__dirname, "..", "package.json"), "utf8")
const packageJson = JSON.parse(packageJsonString)
updateNotifier({ pkg: packageJson }).notify()
} catch (err) {
warning(`Failed to check for updates: ${err}`)
}
}

View File

@ -16,6 +16,7 @@ import { untildifyUser } from "untildify-user"
import { setupBazel } from "./bazel/bazel"
import { setupBrew } from "./brew/brew"
import { setupCcache } from "./ccache/ccache"
import { checkUpdates } from "./check-updates"
import { setupChocolatey } from "./chocolatey/chocolatey"
import { setupCmake } from "./cmake/cmake"
import { setupConan } from "./conan/conan"
@ -89,7 +90,9 @@ const inputs: Array<Inputs> = ["compiler", "architecture", ...tools]
/** The main entry function */
export async function main(args: string[]): Promise<number> {
let checkUpdatePromise = Promise.resolve()
if (!GITHUB_ACTIONS) {
checkUpdatePromise = checkUpdates()
process.env.ACTIONS_ALLOW_UNSECURE_COMMANDS = "true"
}
@ -297,8 +300,11 @@ export async function main(args: string[]): Promise<number> {
}
}
await checkUpdatePromise
return errorMessages.length === 0 ? 0 : 1 // exit with non-zero if any error message
}
// Run main
main(process.argv)
.then((ret) => {