Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace update-notifier and update deps #7078

Merged
merged 6 commits into from Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fluffy-cobras-beg.md
@@ -0,0 +1,5 @@
---
"electron-builder": patch
---

fix: replace update-notifier with simple-update-notifier due to security alert
7 changes: 3 additions & 4 deletions packages/electron-builder/package.json
Expand Up @@ -60,13 +60,12 @@
"is-ci": "^3.0.0",
"lazy-val": "^1.0.5",
"read-config-file": "6.2.0",
"update-notifier": "^5.1.0",
"yargs": "^17.0.1"
"simple-update-notifier": "^1.0.7",
"yargs": "^17.5.1"
},
"devDependencies": {
"@types/fs-extra": "9.0.13",
"@types/is-ci": "3.0.0",
"@types/update-notifier": "5.1.0"
"@types/is-ci": "3.0.0"
},
"typings": "./out/index.d.ts",
"publishConfig": {
Expand Down
31 changes: 9 additions & 22 deletions packages/electron-builder/src/cli/cli.ts
Expand Up @@ -3,11 +3,10 @@
import { InvalidConfigurationError, log } from "builder-util"
import * as chalk from "chalk"
import { getElectronVersion } from "app-builder-lib/out/electron/electronVersion"
import { pathExists, readJson } from "fs-extra"
import { readJson } from "fs-extra"
import * as isCi from "is-ci"
import * as path from "path"
import { loadEnv } from "read-config-file"
import * as updateNotifier from "update-notifier"
import { ExecError } from "builder-util/out/util"
import { build, configureBuildCommand, createYargs } from "../builder"
import { createSelfSignedCert } from "./create-self-signed-cert"
Expand Down Expand Up @@ -47,7 +46,7 @@ void createYargs()

function wrap(task: (args: any) => Promise<any>) {
return (args: any) => {
checkIsOutdated()
checkIsOutdated().catch(e => log.warn({ error: e }, "cannot check updates"))
loadEnv(path.join(process.cwd(), "electron-builder.env"))
.then(() => task(args))
.catch(error => {
Expand All @@ -63,29 +62,17 @@ function wrap(task: (args: any) => Promise<any>) {
}
}

function checkIsOutdated() {
async function checkIsOutdated() {
if (isCi || process.env.NO_UPDATE_NOTIFIER != null) {
return
}

readJson(path.join(__dirname, "..", "..", "package.json"))
.then(async it => {
if (it.version === "0.0.0-semantic-release") {
return
}

const packageManager = (await pathExists(path.join(__dirname, "..", "..", "package-lock.json"))) ? "npm" : "yarn"

const notifier = updateNotifier({ pkg: it })
if (notifier.update != null) {
notifier.notify({
message: `Update available ${chalk.dim(notifier.update.current)}${chalk.reset(" → ")}${chalk.green(notifier.update.latest)} \nRun ${chalk.cyan(
`${packageManager} upgrade electron-builder`
)} to update`,
})
}
})
.catch(e => log.warn({ error: e }, "cannot check updates"))
const pkg = await readJson(path.join(__dirname, "..", "..", "package.json"))
if (pkg.version === "0.0.0-semantic-release") {
return
}
const UpdateNotifier = require("simple-update-notifier")
await UpdateNotifier({ pkg })
}

async function rebuildAppNativeCode(args: any) {
Expand Down