fix: use simple-update-notifier instead of update-notifier

This commit is contained in:
Amin Yahyaabadi 2023-05-24 22:07:48 -07:00
parent f5342df15b
commit 5c3b317006
18 changed files with 412 additions and 508 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,7 +31,7 @@
"build.docker.arch": "pnpm build && docker build -f ./dev/docker/arch_node.dockerfile -t setup-cpp:arch .",
"build.docker.fedora": "pnpm build && docker build -f ./dev/docker/fedora_node.dockerfile -t setup-cpp:fedora .",
"build.docker.ubuntu": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup-cpp:ubuntu .",
"build.parcel": "cross-env NODE_ENV=production parcel build && babel ./dist --out-dir dist --plugins @upleveled/babel-plugin-remove-node-prefix --compact --no-babelrc --source-maps true",
"build.parcel": "cross-env NODE_ENV=production parcel build --detailed-report 10 && babel ./dist --out-dir dist --plugins @upleveled/babel-plugin-remove-node-prefix --compact --no-babelrc --source-maps true",
"bump": "ncu -u -x numerous && pnpm update",
"clean": "shx rm -rf .parcel-cache dist exe",
"copy.matchers": "shx cp ./src/gcc/gcc_matcher.json ./dist/node12/ && shx cp ./src/msvc/msvc_matcher.json ./dist/node12/ && shx cp ./src/python/python_matcher.json ./dist/node12/ && shx cp ./src/llvm/llvm_matcher.json ./dist/node12/ && shx cp ./dist/node12/*.json ./dist/node16/",
@ -63,8 +63,6 @@
"update-notifier": "^5.1.0"
},
"devDependencies": {
"@types/resolve": "^1.20.2",
"resolve": "^1.22.2",
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3",
@ -95,6 +93,7 @@
"exec-powershell": "workspace:*",
"execa": "^7.1.1",
"fast-glob": "^3.2.12",
"find-up": "^6.3.0",
"gen-readme": "^1.6.0",
"is-url-online": "^1.5.0",
"jest": "^29.5.0",
@ -114,6 +113,7 @@
"semver": "7.5.1",
"setup-python": "github:actions/setup-python#v4.6.1",
"shx": "0.3.4",
"simple-update-notifier": "^1.1.0",
"terser-config-atomic": "^0.1.1",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"ts-jest": "^29.1.0",

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,11 @@
import { warning } from "ci-log"
import { promises } from "fs"
const { readFile } = promises
import { join } from "path"
import { isInstalled } from "./utils/std/resolve"
import updateNotifier from "simple-update-notifier"
import packageJson from "../package.json" assert { type: "json" }
// auto self update notifier
export async function checkUpdates() {
try {
if (await isInstalled("update-notifier")) {
const [un, packageJsonString] = await Promise.all([
import("update-notifier"),
readFile(join(__dirname, "..", "package.json"), "utf8"),
])
const packageJson = JSON.parse(packageJsonString)
// the types do not match the actual export
const updateNotifier = un as unknown as (typeof un)["default"]
updateNotifier({ pkg: packageJson }).notify()
} else {
warning("setup-cpp could not find its dependency update-notifier, skipping check for updates")
}
await updateNotifier({ pkg: packageJson })
} catch (err) {
warning(`Failed to check for updates: ${err instanceof Error ? err.message + err.stack : err}`)
}

View File

@ -1,31 +0,0 @@
import resolveCb from "resolve"
interface PackageMeta {
name: string
version: string
[key: string]: any
}
/** Promise wrapper for resolve */
export async function resolve(id: string): Promise<{ resolved: string; pkg?: PackageMeta }> {
return new Promise((resolve, reject) => {
resolveCb(id, (err, resolved, pkg) => {
if (err) {
reject(err)
} else if (resolved === undefined) {
reject(new Error(`Could not resolve ${id}`))
} else {
resolve({ resolved, pkg })
}
})
})
}
export async function isInstalled(id: string) {
try {
await resolve(id)
return true
} catch {
return false
}
}