diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index 264ab7549eb..27a37a1e238 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -7,6 +7,8 @@ FROM buildpack-deps:yakkety-curl # install modern multi-thread xz # ldconfig - see 4.6. liblzma.so (or similar) not found when running xz +# python for node-gyp + ENV XZ_VERSION 5.2.2 # we don't use our bundled 7za because it is better to build for specific platform - not generic @@ -18,7 +20,7 @@ ENV FORCE_COLOR true ENV DEBIAN_FRONTEND noninteractive RUN curl -L https://yarnpkg.com/latest.tar.gz | tar xvz && mv dist yarn && apt-get update -y && apt-get upgrade -y && \ - apt-get install --no-install-recommends -y xvfb git snapcraft qtbase5-dev xorriso bsdtar build-essential autoconf libssl-dev icnsutils libopenjp2-7 graphicsmagick gcc-multilib g++-multilib libgnome-keyring-dev lzip rpm yasm && \ + apt-get install --no-install-recommends -y xvfb git snapcraft qtbase5-dev xorriso bsdtar build-essential autoconf libssl-dev icnsutils libopenjp2-7 graphicsmagick gcc-multilib g++-multilib libgnome-keyring-dev lzip rpm yasm python && \ curl -O http://mirrors.kernel.org/ubuntu/pool/universe/libi/libicns/libicns1_0.8.1-3.1_amd64.deb && dpkg --install libicns1_0.8.1-3.1_amd64.deb && unlink libicns1_0.8.1-3.1_amd64.deb && \ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \ apt-get update && apt-get install -y google-chrome-stable && \ diff --git a/docs/Docker.md b/docs/Docker.md index 5d52c3e75d6..2448530f906 100644 --- a/docs/Docker.md +++ b/docs/Docker.md @@ -1,9 +1,11 @@ To build Linux or Windows (only if you don't have native dependencies) on any platform: 1. Run docker container: + ```sh docker run --rm -ti -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder:wine ``` + 2. Type in `npm install && npm prune && npm run dist` If you don't have `dist` npm script in your `package.json`, call `./node_modules/.bin/build` directly. diff --git a/package.json b/package.json index 4a8a0bb6df6..0834fcbe0e9 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,10 @@ { - "name": "electron-builder", - "description": "A complete solution to package and build a ready for distribution Electron app for MacOS, Windows and Linux with “auto update” support out of the box", - "version": "0.0.0-semantic-release", - "main": "out/index.js", - "files": [ - "out", - "templates", - "certs/root_certs.keychain" - ], - "bin": { - "build": "./out/cli/build-cli.js", - "install-app-deps": "./out/cli/install-app-deps.js", - "node-gyp-rebuild": "./out/cli/node-gyp-rebuild.js" - }, + "private": true, + "license": "MIT", "scripts": { "compile": "ts-babel packages/electron-builder-http packages/electron-builder packages/electron-auto-updater test", "lint": "node ./packages/lint.js", - "pretest": "node ./test/vendor/yarn.js run compile && node ./test/vendor/yarn.js run lint", + "pretest": "node ./test/vendor/yarn.js compile && node ./test/vendor/yarn.js lint && node ./test/vendor/yarn.js check-deps", "check-deps": "node ./test/out/helpers/checkDeps.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", @@ -26,36 +14,9 @@ "whitespace": "whitespace 'src/**/*.ts'", "docker-images": "docker/build.sh", "test-deps-mac": "brew install rpm dpkg mono lzip gnu-tar graphicsmagick xz && brew install wine --without-x11", - "postinstall": "lerna bootstrap" + "postinstall": "lerna bootstrap", + "update-deps": "lerna exec -- npm-check-updates --reject 'electron-builder-http'" }, - "repository": "electron-userland/electron-builder", - "engines": { - "node": ">=0.4.0" - }, - "keywords": [ - "electron", - "builder", - "build", - "installer", - "install", - "packager", - "pack", - "nsis", - "app", - "dmg", - "msi", - "exe", - "setup", - "Windows", - "OS X", - "MacOS", - "Mac", - "appx" - ], - "author": "Stefan Judis", - "license": "MIT", - "bugs": "https://github.com/electron-userland/electron-builder/issues", - "homepage": "https://github.com/electron-userland/electron-builder", "devDependencies": { "@develar/semantic-release": "^6.3.26", "@types/electron": "^1.4.30", diff --git a/packages/electron-auto-updater/tsconfig.json b/packages/electron-auto-updater/tsconfig.json index 8713872de3b..54213f1a5ae 100755 --- a/packages/electron-auto-updater/tsconfig.json +++ b/packages/electron-auto-updater/tsconfig.json @@ -1,19 +1,7 @@ { + "extends": "../tsconfig-base.json", "compilerOptions": { - "module": "es2015", - "target": "es2017", - "noImplicitAny": true, - "outDir": "out", - "newLine": "LF", - "noEmitOnError": true, - "inlineSources": true, - "sourceMap": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "noEmitHelpers": true, - "noFallthroughCasesInSwitch": true, - "noUnusedLocals": true, - "skipLibCheck": true + "outDir": "out" }, "declaration": { "electron-auto-updater": "out/electron-auto-updater.d.ts" diff --git a/packages/electron-builder-http/tsconfig.json b/packages/electron-builder-http/tsconfig.json index 2779367b101..e4f253cc93e 100755 --- a/packages/electron-builder-http/tsconfig.json +++ b/packages/electron-builder-http/tsconfig.json @@ -1,19 +1,7 @@ { + "extends": "../tsconfig-base.json", "compilerOptions": { - "module": "es2015", - "target": "es2017", - "noImplicitAny": true, - "outDir": "out", - "newLine": "LF", - "noEmitOnError": true, - "inlineSources": true, - "sourceMap": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "noEmitHelpers": true, - "noFallthroughCasesInSwitch": true, - "noUnusedLocals": true, - "skipLibCheck": true + "outDir": "out" }, "declaration": { "electron-builder-http": "out/electron-builder-http.d.ts" diff --git a/packages/electron-builder/package.json b/packages/electron-builder/package.json index 05197077a52..684bb3b99b3 100644 --- a/packages/electron-builder/package.json +++ b/packages/electron-builder/package.json @@ -52,17 +52,15 @@ "chromium-pickle-js": "^0.2.0", "cli-cursor": "^1.0.2", "cuint": "^0.2.2", - "debug": "2.5.2", + "debug": "2.6.0", "electron-download-tf": "3.1.0", "electron-macos-sign": "~1.4.0", "fs-extra-p": "^3.0.3", "hosted-git-info": "^2.1.5", "ini": "^1.3.4", - "interactive": "^0.1.9", "is-ci": "^1.0.10", "isbinaryfile": "^3.0.1", "js-yaml": "^3.7.0", - "lodash.template": "^4.4.0", "mime": "^1.3.4", "minimatch": "^3.0.3", "node-emoji": "^1.4.3", @@ -80,7 +78,7 @@ "tunnel-agent": "^0.4.3", "update-notifier": "^1.0.3", "uuid-1345": "^0.99.6", - "yargs": "^6.5.0", + "yargs": "^6.6.0", "electron-builder-http": "0.0.0-semantic-release" }, "typings": "./out/electron-builder.d.ts", diff --git a/packages/electron-builder/src/targets/fpm.ts b/packages/electron-builder/src/targets/fpm.ts index ea97e2ef786..50816f2de99 100644 --- a/packages/electron-builder/src/targets/fpm.ts +++ b/packages/electron-builder/src/targets/fpm.ts @@ -9,12 +9,10 @@ import { LinuxTargetHelper, installPrefix } from "./LinuxTargetHelper" import * as errorMessages from "../errorMessages" import { TmpDir } from "../util/tmp" import { LinuxPackager } from "../linuxPackager" -import { log } from "../util/log" +import { log, warn } from "../util/log" import { Target } from "./targetFactory" import { unlinkIfExists } from "../util/fs" -const template = require("lodash.template") - const fpmPath = (process.platform === "win32" || process.env.USE_SYSTEM_FPM === "true") ? BluebirdPromise.resolve("fpm") : downloadFpm() @@ -172,11 +170,21 @@ export default class FpmTarget extends Target { } async function writeConfigFile(tmpDir: TmpDir, templatePath: string, options: any): Promise { - const config = template(await readFile(templatePath, "utf8"), - { - // set interpolate explicitly to avoid troubles with templating of installer.nsi.tpl - interpolate: /<%=([\s\S]+?)%>/g - })(options) + //noinspection JSUnusedLocalSymbols + function replacer(match: string, p1: string) { + if (p1 in options) { + return options[p1] + } + else { + throw new Error(`Macro ${p1} is not defined`) + } + } + const config = (await readFile(templatePath, "utf8")) + .replace(/\$\{([a-zA-Z]+)\}/g, replacer) + .replace(/<%=([a-zA-Z]+)%>/g, (match, p1) => { + warn("<%= varName %> is deprecated, please use ${varName} instead") + return replacer(match, p1.trim()) + }) const outputPath = await tmpDir.getTempFile(path.basename(templatePath, ".tpl")) await outputFile(outputPath, config) diff --git a/packages/electron-builder/templates/linux/after-install.tpl b/packages/electron-builder/templates/linux/after-install.tpl index 083ecc7e52a..6c2f3ea8cb5 100644 --- a/packages/electron-builder/templates/linux/after-install.tpl +++ b/packages/electron-builder/templates/linux/after-install.tpl @@ -1,4 +1,4 @@ #!/bin/bash # Link to the binary -ln -sf '/opt/<%= productFilename %>/<%= executable %>' '/usr/local/bin/<%= executable %>' +ln -sf '/opt/${productFilename}/${executable}' '/usr/local/bin/${executable}' diff --git a/packages/electron-builder/templates/linux/after-remove.tpl b/packages/electron-builder/templates/linux/after-remove.tpl index f7014bc8d70..6a1c910f3c0 100644 --- a/packages/electron-builder/templates/linux/after-remove.tpl +++ b/packages/electron-builder/templates/linux/after-remove.tpl @@ -1,4 +1,4 @@ #!/bin/bash # Delete the link to the binary -rm -f '/usr/local/bin/<%= executable %>' +rm -f '/usr/local/bin/${executable}' diff --git a/packages/electron-builder/tsconfig.json b/packages/electron-builder/tsconfig.json index 146862f9650..0e4e72507aa 100755 --- a/packages/electron-builder/tsconfig.json +++ b/packages/electron-builder/tsconfig.json @@ -1,24 +1,11 @@ { + "extends": "../tsconfig-base.json", "compilerOptions": { - "module": "es2015", - "target": "es2017", - "noImplicitAny": true, - "outDir": "out", - "newLine": "LF", - "noEmitOnError": true, - "inlineSources": true, - "sourceMap": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "noEmitHelpers": true, - "noFallthroughCasesInSwitch": true, - "noUnusedLocals": true, - "skipLibCheck": true + "outDir": "out" }, "declaration": { "electron-builder": "out/electron-builder.d.ts" }, - "docs": "../../docs/Options.md", "files": [ "node_modules/fs-extra-p/index.d.ts", "node_modules/bluebird-lst-c/index.d.ts", diff --git a/packages/tsconfig-base.json b/packages/tsconfig-base.json new file mode 100644 index 00000000000..a05e33e4e5c --- /dev/null +++ b/packages/tsconfig-base.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "es2015", + "target": "es2017", + "noImplicitAny": true, + "newLine": "LF", + "noEmitOnError": true, + "inlineSources": true, + "sourceMap": true, + "noImplicitReturns": true, + "strictNullChecks": true, + "noEmitHelpers": true, + "noFallthroughCasesInSwitch": true, + "noUnusedLocals": true, + "skipLibCheck": true + } +} \ No newline at end of file diff --git a/test/src/helpers/checkDeps.ts b/test/src/helpers/checkDeps.ts index 6b34b8eb527..450c189b1d8 100644 --- a/test/src/helpers/checkDeps.ts +++ b/test/src/helpers/checkDeps.ts @@ -3,7 +3,7 @@ import { readJson } from "fs-extra-p" import BluebirdPromise from "bluebird-lst-c" import depCheck, { DepCheckResult } from "depcheck" -const printErrorAndExit = require("../../../out/util/promise").printErrorAndExit +const printErrorAndExit = require("../../../packages/electron-builder/out/util/promise").printErrorAndExit const knownUnusedDevDependencies = new Set([ "@develar/types", @@ -17,14 +17,15 @@ const knownUnusedDevDependencies = new Set([ ]) async function main(): Promise { - const projectDir = path.join(__dirname, "..", "..", "..") + const rootDir = path.join(__dirname, "../../..") + const projectDir = path.join(rootDir, "packages/electron-builder") console.log(`Checking ${projectDir}`) const result = await new BluebirdPromise(function (resolve) { depCheck(projectDir, { ignoreDirs: [ - "out", "test", "docs", "typings", "docker", "certs", "templates", ".idea", ".github", + "out", "test", "docs", "typings", "docker", "certs", "templates", "vendor", ], }, resolve) }) @@ -43,7 +44,12 @@ async function main(): Promise { } const packageData = await readJson(path.join(projectDir, "package.json")) - for (const name of Object.keys(packageData.devDependencies)) { + const devPackageData = await readJson(path.join(rootDir, "package.json")) + for (const name of Object.keys(devPackageData.devDependencies)) { + if (packageData.dependencies[name] != null) { + continue + } + const usages = result.using[name] if (usages == null || usages.length === 0) { continue