diff --git a/docker/7/Dockerfile b/docker/7/Dockerfile index 71aa8514924..96a6466c4d6 100644 --- a/docker/7/Dockerfile +++ b/docker/7/Dockerfile @@ -1,6 +1,6 @@ FROM electronuserland/electron-builder:base -ENV NODE_VERSION 7.1.0 +ENV NODE_VERSION 7.2.0 # https://github.com/npm/npm/issues/4531 RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \ diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index 1eb54385db5..1f9fa2ffd8b 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -1,4 +1,4 @@ -FROM buildpack-deps:yakkety-curl +FROM buildpack-deps:xenial-curl # rpm is required for FPM to build rpm package # yasm is required to build p7zip @@ -15,9 +15,8 @@ ENV USE_SYSTEM_7ZA true ENV DEBUG_COLORS true ENV FORCE_COLOR true -RUN apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg && echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ -apt-get update -y && \ - apt-get install --no-install-recommends -y git snapcraft yarn xorriso bsdtar build-essential autoconf libssl-dev icnsutils graphicsmagick gcc-multilib g++-multilib libgnome-keyring-dev lzip rpm yasm && \ +RUN curl -L https://yarnpkg.com/latest.tar.gz | tar xvz && mv dist yarn && ln -s /yarn/bin/yarn /usr/local/bin/yarn && apt-get update -y && \ + apt-get install --no-install-recommends -y git snapcraft xorriso bsdtar build-essential autoconf libssl-dev icnsutils graphicsmagick gcc-multilib g++-multilib libgnome-keyring-dev lzip rpm yasm && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ curl -L http://tukaani.org/xz/xz-$XZ_VERSION.tar.xz | tar -xJ && cd xz-$XZ_VERSION && ./configure && make && make install && cd .. && rm -rf xz-$XZ_VERSION && ldconfig && \ @@ -48,4 +47,5 @@ WORKDIR /project RUN locale-gen en_US.UTF-8 ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en -ENV LC_ALL en_US.UTF-8 \ No newline at end of file +ENV LC_ALL en_US.UTF-8 +ENV PATH "$HOME/.yarn/bin:$PATH" \ No newline at end of file diff --git a/docker/wine/Dockerfile b/docker/wine/Dockerfile index df96a42f3a5..6967f5c7796 100644 --- a/docker/wine/Dockerfile +++ b/docker/wine/Dockerfile @@ -2,7 +2,7 @@ FROM electronuserland/electron-builder:latest # libgnome-keyring-dev — to build keytar RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F9CB8DB0 && \ -echo "deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu yakkety main " | tee /etc/apt/sources.list.d/wine.list && \ +echo "deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial main " | tee /etc/apt/sources.list.d/wine.list && \ dpkg --add-architecture i386 && \ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \ echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /etc/apt/sources.list.d/mono-xamarin.list && \ diff --git a/nsis-auto-updater/package.json b/nsis-auto-updater/package.json index d806ab18260..22950c61d44 100644 --- a/nsis-auto-updater/package.json +++ b/nsis-auto-updater/package.json @@ -14,7 +14,7 @@ "dependencies": { "bluebird-lst-c": "^1.0.5", "debug": "^2.3.3", - "fs-extra-p": "^3.0.2", + "fs-extra-p": "^3.0.3", "ini": "^1.3.4", "js-yaml": "^3.7.0", "semver": "^5.3.0", diff --git a/package.json b/package.json index 80e5195de3b..8f19849470f 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "lint": "node ./test/lint.js", "pretest": "yarn run compile && yarn run lint", "check-deps": "node ./test/out/helpers/checkDeps.js", - "test": "node --trace-warnings ./test/out/helpers/runTests.js", + "test": "node ./test/out/helpers/runTests.js", "test-linux": "docker run --rm -ti -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder:wine /test.sh", "pack-updater": "cd nsis-auto-updater && yarn --production && cd ..", "semantic-release": "semantic-release pre && npm publish && semantic-release post", @@ -70,7 +70,7 @@ "debug": "^2.3.3", "electron-download-tf": "3.1.0", "electron-macos-sign": "^1.3.4", - "fs-extra-p": "^3.0.2", + "fs-extra-p": "^3.0.3", "hosted-git-info": "^2.1.5", "ini": "^1.3.4", "is-ci": "^1.0.10", diff --git a/src/cli/create-self-signed-cert.ts b/src/cli/create-self-signed-cert.ts index 3bfe53b09c8..4cf33fc69fe 100644 --- a/src/cli/create-self-signed-cert.ts +++ b/src/cli/create-self-signed-cert.ts @@ -16,7 +16,7 @@ async function main() { const tmpDir = new TmpDir() const targetDir = process.cwd() - const tempPrefix = path.join(await tmpDir.getTempFile(null), sanitizeFileName(args.publisher)) + const tempPrefix = path.join(await tmpDir.getTempFile(""), sanitizeFileName(args.publisher)) const cer = `${tempPrefix}.cer` const pvk = `${tempPrefix}.pvk` diff --git a/src/targets/nsis.ts b/src/targets/nsis.ts index bf8b7d783ef..f0156ccd250 100644 --- a/src/targets/nsis.ts +++ b/src/targets/nsis.ts @@ -94,6 +94,7 @@ export default class NsisTarget extends Target { APP_GUID: guid, PRODUCT_NAME: appInfo.productName, PRODUCT_FILENAME: appInfo.productFilename, + APP_FILENAME: appInfo.name, APP_DESCRIPTION: appInfo.description, VERSION: version, diff --git a/src/util/tmp.ts b/src/util/tmp.ts index ff6410ff4cb..61aa319213a 100644 --- a/src/util/tmp.ts +++ b/src/util/tmp.ts @@ -1,75 +1,90 @@ import { tmpdir } from "os" -import { remove, mkdirs, removeSync } from "fs-extra-p" +import { remove, mkdirs, removeSync, mkdtemp } from "fs-extra-p" import * as path from "path" import { getTempName } from "./util" import BluebirdPromise from "bluebird-lst-c" import { warn } from "./log" - -const mkdtemp: any | null = require("fs-extra-p").mkdtemp +import { all } from "./promise" process.setMaxListeners(30) -export class TmpDir { - private tmpFileCounter = 0 - private tempDirectoryPromise: Promise - - private dir: string | null +let tempDirPromise: Promise | null +let tempDir: string | null - getTempFile(suffix: string | null): Promise { - if (this.tempDirectoryPromise == null) { - let promise: Promise - if (mkdtemp == null) { - const dir = path.join(tmpdir(), getTempName("electron-builder")) - promise = mkdirs(dir, {mode: 448}).then(() => dir) - } - else { - promise = mkdtemp(`${path.join(process.env.TEST_DIR || tmpdir(), "electron-builder")}-`) - } +function getTempDir() { + if (tempDirPromise == null) { + let promise: Promise + const systemTmpDir = process.env.TEST_DIR || tmpdir() + if (mkdtemp == null) { + const dir = path.join(systemTmpDir, getTempName("electron-builder")) + promise = mkdirs(dir, {mode: 448}).then(() => dir) + } + else { + promise = mkdtemp(`${path.join(systemTmpDir, "electron-builder")}-`) + } - this.tempDirectoryPromise = promise - .then(dir => { - this.dir = dir - const cleanup = () => { - if (this.dir == null) { - return - } + tempDirPromise = promise + .then(dir => { + tempDir = dir + const cleanup = () => { + if (tempDir == null) { + return + } - this.dir = null - try { - removeSync(dir) - } - catch (e) { - if (e.code !== "EPERM") { - warn(`Cannot delete temporary dir "${dir}": ${(e.stack || e).toString()}`) - } + tempDir = null + try { + removeSync(dir) + } + catch (e) { + if (e.code !== "EPERM") { + warn(`Cannot delete temporary dir "${dir}": ${(e.stack || e).toString()}`) } } - process.on("exit", cleanup) - process.on("uncaughtException", cleanup) - process.on("SIGINT", cleanup) - return dir - }) + } + process.on("exit", cleanup) + process.on("uncaughtException", cleanup) + process.on("SIGINT", cleanup) + return dir + }) + } + + return tempDirPromise +} + +let tmpFileCounter = 0 + +export class TmpDir { + private tempPrefixPromise: Promise | null + private tempFiles: Array = [] + + getTempFile(suffix: string): Promise { + if (this.tempPrefixPromise == null) { + this.tempPrefixPromise = getTempDir().then(it => path.join(it, (tmpFileCounter++).toString(16))) } - return this.tempDirectoryPromise - .then(it => suffix == null ? it : path.join(it, `t-${process.pid.toString(16)}-${(this.tmpFileCounter++).toString(16)}${suffix.startsWith(".") ? suffix : `-${suffix}`}`)) + return this.tempPrefixPromise + .then(it => { + const result = `${it}-${(tmpFileCounter++).toString(16)}${suffix.length === 0 || suffix.startsWith(".") ? suffix : `-${suffix}`}` + this.tempFiles.push(result) + return result + }) } cleanup(): Promise { - const dir = this.dir - if (dir == null) { + const tempFiles = this.tempFiles + if (tempFiles.length === 0) { return BluebirdPromise.resolve() } - this.dir = null - return remove(dir) + this.tempFiles = [] + this.tempPrefixPromise = null + + return all(tempFiles.map(it => remove(it) .catch(e => { - if (e.code === "EPERM") { - this.dir = dir - } - else { - warn(`Cannot delete temporary dir "${dir}": ${(e.stack || e).toString()}`) + if (e.code !== "EPERM") { + warn(`Cannot delete temporary dir "${it}": ${(e.stack || e).toString()}`) } }) + )) } } diff --git a/src/util/util.ts b/src/util/util.ts index 2986513e8f7..2ee98b2095e 100644 --- a/src/util/util.ts +++ b/src/util/util.ts @@ -224,7 +224,7 @@ export function debug7zArgs(command: "a" | "x"): Array { return args } -let tmpDirCounter = 0 +export let tmpDirCounter = 0 // add date to avoid use stale temp dir const tempDirPrefix = `${process.pid.toString(16)}-${Date.now().toString(16)}` diff --git a/templates/nsis/multiUser.nsh b/templates/nsis/multiUser.nsh index 01df12146d2..9b59f4db435 100644 --- a/templates/nsis/multiUser.nsh +++ b/templates/nsis/multiUser.nsh @@ -29,7 +29,7 @@ Var installMode StrCpy $0 $1 System::Call 'Ole32::CoTaskMemFree(ir2)' ${endif} - StrCpy $INSTDIR "$0\${PRODUCT_FILENAME}\${VERSION}" + StrCpy $INSTDIR "$0\${APP_FILENAME}" !endif # сhecks registry for previous installation path — for uninstall only, currently, installation path is not customizable @@ -49,11 +49,11 @@ Var installMode StrCpy $installMode all SetShellVarContext all - StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCT_FILENAME}\${VERSION}" + StrCpy $INSTDIR "$PROGRAMFILES\${APP_FILENAME}" !ifdef APP_64 ${if} ${RunningX64} - StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCT_FILENAME}\${VERSION}" + StrCpy $INSTDIR "$PROGRAMFILES64\${APP_FILENAME}" ${endif} !endif diff --git a/templates/nsis/uninstaller.nsh b/templates/nsis/uninstaller.nsh index 09717a144c7..8c890b80986 100644 --- a/templates/nsis/uninstaller.nsh +++ b/templates/nsis/uninstaller.nsh @@ -50,7 +50,7 @@ Section "un.install" ${if} $installMode == "all" SetShellVarContext current ${endif} - RMDir /r "$APPDATA\${PRODUCT_FILENAME}" + RMDir /r "$APPDATA\${APP_FILENAME}" ${if} $installMode == "all" SetShellVarContext all ${endif} diff --git a/yarn.lock b/yarn.lock index f817d054cce..78b2722dc69 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1363,9 +1363,9 @@ from@~0: version "0.1.3" resolved "https://registry.yarnpkg.com/from/-/from-0.1.3.tgz#ef63ac2062ac32acf7862e0d40b44b896f22f3bc" -fs-extra-p@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/fs-extra-p/-/fs-extra-p-3.0.2.tgz#074e44ca8ae535fe6999458458ff2eb7c956d0c8" +fs-extra-p@^3.0.2, fs-extra-p@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/fs-extra-p/-/fs-extra-p-3.0.3.tgz#2e48b1e6c196feb75ac6f0c6419760ce8b847f33" dependencies: bluebird-lst-c "^1.0.5" fs-extra "^1.0.0" @@ -3422,8 +3422,8 @@ throttleit@0.0.2: resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-0.0.2.tgz#cfedf88e60c00dd9697b61fdd2a8343a9b680eaf" through2@^2.0.0, through2@^2.0.2, through2@~2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.2.tgz#316d3a4f444af641496aa7f45a713be72576baf4" + version "2.0.3" + resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" dependencies: readable-stream "^2.1.5" xtend "~4.0.1"