Skip to content

Commit fe137fc

Browse files
committed
feat(linux): use ${macro} syntax for linux templates
1 parent b6ae449 commit fe137fc

File tree

12 files changed

+63
-106
lines changed

12 files changed

+63
-106
lines changed

docker/base/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ FROM buildpack-deps:yakkety-curl
77
# install modern multi-thread xz
88
# ldconfig - see 4.6. liblzma.so (or similar) not found when running xz
99

10+
# python for node-gyp
11+
1012
ENV XZ_VERSION 5.2.2
1113

1214
# 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
1820
ENV DEBIAN_FRONTEND noninteractive
1921

2022
RUN curl -L https://yarnpkg.com/latest.tar.gz | tar xvz && mv dist yarn && apt-get update -y && apt-get upgrade -y && \
21-
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 && \
23+
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 && \
2224
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 && \
2325
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 && \
2426
apt-get update && apt-get install -y google-chrome-stable && \

docs/Docker.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
To build Linux or Windows (only if you don't have native dependencies) on any platform:
22

33
1. Run docker container:
4+
45
```sh
56
docker run --rm -ti -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder:wine
67
```
8+
79
2. Type in `npm install && npm prune && npm run dist`
810

911
If you don't have `dist` npm script in your `package.json`, call `./node_modules/.bin/build` directly.

package.json

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
{
2-
"name": "electron-builder",
3-
"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",
4-
"version": "0.0.0-semantic-release",
5-
"main": "out/index.js",
6-
"files": [
7-
"out",
8-
"templates",
9-
"certs/root_certs.keychain"
10-
],
11-
"bin": {
12-
"build": "./out/cli/build-cli.js",
13-
"install-app-deps": "./out/cli/install-app-deps.js",
14-
"node-gyp-rebuild": "./out/cli/node-gyp-rebuild.js"
15-
},
2+
"private": true,
3+
"license": "MIT",
164
"scripts": {
175
"compile": "ts-babel packages/electron-builder-http packages/electron-builder packages/electron-auto-updater test",
186
"lint": "node ./packages/lint.js",
19-
"pretest": "node ./test/vendor/yarn.js run compile && node ./test/vendor/yarn.js run lint",
7+
"pretest": "node ./test/vendor/yarn.js compile && node ./test/vendor/yarn.js lint && node ./test/vendor/yarn.js check-deps",
208
"check-deps": "node ./test/out/helpers/checkDeps.js",
219
"test": "node ./test/out/helpers/runTests.js",
2210
"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 @@
2614
"whitespace": "whitespace 'src/**/*.ts'",
2715
"docker-images": "docker/build.sh",
2816
"test-deps-mac": "brew install rpm dpkg mono lzip gnu-tar graphicsmagick xz && brew install wine --without-x11",
29-
"postinstall": "lerna bootstrap"
17+
"postinstall": "lerna bootstrap",
18+
"update-deps": "lerna exec -- npm-check-updates --reject 'electron-builder-http'"
3019
},
31-
"repository": "electron-userland/electron-builder",
32-
"engines": {
33-
"node": ">=0.4.0"
34-
},
35-
"keywords": [
36-
"electron",
37-
"builder",
38-
"build",
39-
"installer",
40-
"install",
41-
"packager",
42-
"pack",
43-
"nsis",
44-
"app",
45-
"dmg",
46-
"msi",
47-
"exe",
48-
"setup",
49-
"Windows",
50-
"OS X",
51-
"MacOS",
52-
"Mac",
53-
"appx"
54-
],
55-
"author": "Stefan Judis",
56-
"license": "MIT",
57-
"bugs": "https://github.com/electron-userland/electron-builder/issues",
58-
"homepage": "https://github.com/electron-userland/electron-builder",
5920
"devDependencies": {
6021
"@develar/semantic-release": "^6.3.26",
6122
"@types/electron": "^1.4.30",

packages/electron-auto-updater/tsconfig.json

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
{
2+
"extends": "../tsconfig-base.json",
23
"compilerOptions": {
3-
"module": "es2015",
4-
"target": "es2017",
5-
"noImplicitAny": true,
6-
"outDir": "out",
7-
"newLine": "LF",
8-
"noEmitOnError": true,
9-
"inlineSources": true,
10-
"sourceMap": true,
11-
"noImplicitReturns": true,
12-
"strictNullChecks": true,
13-
"noEmitHelpers": true,
14-
"noFallthroughCasesInSwitch": true,
15-
"noUnusedLocals": true,
16-
"skipLibCheck": true
4+
"outDir": "out"
175
},
186
"declaration": {
197
"electron-auto-updater": "out/electron-auto-updater.d.ts"

packages/electron-builder-http/tsconfig.json

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
{
2+
"extends": "../tsconfig-base.json",
23
"compilerOptions": {
3-
"module": "es2015",
4-
"target": "es2017",
5-
"noImplicitAny": true,
6-
"outDir": "out",
7-
"newLine": "LF",
8-
"noEmitOnError": true,
9-
"inlineSources": true,
10-
"sourceMap": true,
11-
"noImplicitReturns": true,
12-
"strictNullChecks": true,
13-
"noEmitHelpers": true,
14-
"noFallthroughCasesInSwitch": true,
15-
"noUnusedLocals": true,
16-
"skipLibCheck": true
4+
"outDir": "out"
175
},
186
"declaration": {
197
"electron-builder-http": "out/electron-builder-http.d.ts"

packages/electron-builder/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,15 @@
5252
"chromium-pickle-js": "^0.2.0",
5353
"cli-cursor": "^1.0.2",
5454
"cuint": "^0.2.2",
55-
"debug": "2.5.2",
55+
"debug": "2.6.0",
5656
"electron-download-tf": "3.1.0",
5757
"electron-macos-sign": "~1.4.0",
5858
"fs-extra-p": "^3.0.3",
5959
"hosted-git-info": "^2.1.5",
6060
"ini": "^1.3.4",
61-
"interactive": "^0.1.9",
6261
"is-ci": "^1.0.10",
6362
"isbinaryfile": "^3.0.1",
6463
"js-yaml": "^3.7.0",
65-
"lodash.template": "^4.4.0",
6664
"mime": "^1.3.4",
6765
"minimatch": "^3.0.3",
6866
"node-emoji": "^1.4.3",
@@ -80,7 +78,7 @@
8078
"tunnel-agent": "^0.4.3",
8179
"update-notifier": "^1.0.3",
8280
"uuid-1345": "^0.99.6",
83-
"yargs": "^6.5.0",
81+
"yargs": "^6.6.0",
8482
"electron-builder-http": "0.0.0-semantic-release"
8583
},
8684
"typings": "./out/electron-builder.d.ts",

packages/electron-builder/src/targets/fpm.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ import { LinuxTargetHelper, installPrefix } from "./LinuxTargetHelper"
99
import * as errorMessages from "../errorMessages"
1010
import { TmpDir } from "../util/tmp"
1111
import { LinuxPackager } from "../linuxPackager"
12-
import { log } from "../util/log"
12+
import { log, warn } from "../util/log"
1313
import { Target } from "./targetFactory"
1414
import { unlinkIfExists } from "../util/fs"
1515

16-
const template = require("lodash.template")
17-
1816
const fpmPath = (process.platform === "win32" || process.env.USE_SYSTEM_FPM === "true") ?
1917
BluebirdPromise.resolve("fpm") : downloadFpm()
2018

@@ -172,11 +170,21 @@ export default class FpmTarget extends Target {
172170
}
173171

174172
async function writeConfigFile(tmpDir: TmpDir, templatePath: string, options: any): Promise<string> {
175-
const config = template(await readFile(templatePath, "utf8"),
176-
{
177-
// set interpolate explicitly to avoid troubles with templating of installer.nsi.tpl
178-
interpolate: /<%=([\s\S]+?)%>/g
179-
})(options)
173+
//noinspection JSUnusedLocalSymbols
174+
function replacer(match: string, p1: string) {
175+
if (p1 in options) {
176+
return options[p1]
177+
}
178+
else {
179+
throw new Error(`Macro ${p1} is not defined`)
180+
}
181+
}
182+
const config = (await readFile(templatePath, "utf8"))
183+
.replace(/\$\{([a-zA-Z]+)\}/g, replacer)
184+
.replace(/<%=([a-zA-Z]+)%>/g, (match, p1) => {
185+
warn("<%= varName %> is deprecated, please use ${varName} instead")
186+
return replacer(match, p1.trim())
187+
})
180188

181189
const outputPath = await tmpDir.getTempFile(path.basename(templatePath, ".tpl"))
182190
await outputFile(outputPath, config)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

33
# Link to the binary
4-
ln -sf '/opt/<%= productFilename %>/<%= executable %>' '/usr/local/bin/<%= executable %>'
4+
ln -sf '/opt/${productFilename}/${executable}' '/usr/local/bin/${executable}'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

33
# Delete the link to the binary
4-
rm -f '/usr/local/bin/<%= executable %>'
4+
rm -f '/usr/local/bin/${executable}'

packages/electron-builder/tsconfig.json

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
11
{
2+
"extends": "../tsconfig-base.json",
23
"compilerOptions": {
3-
"module": "es2015",
4-
"target": "es2017",
5-
"noImplicitAny": true,
6-
"outDir": "out",
7-
"newLine": "LF",
8-
"noEmitOnError": true,
9-
"inlineSources": true,
10-
"sourceMap": true,
11-
"noImplicitReturns": true,
12-
"strictNullChecks": true,
13-
"noEmitHelpers": true,
14-
"noFallthroughCasesInSwitch": true,
15-
"noUnusedLocals": true,
16-
"skipLibCheck": true
4+
"outDir": "out"
175
},
186
"declaration": {
197
"electron-builder": "out/electron-builder.d.ts"
208
},
21-
"docs": "../../docs/Options.md",
229
"files": [
2310
"node_modules/fs-extra-p/index.d.ts",
2411
"node_modules/bluebird-lst-c/index.d.ts",

0 commit comments

Comments
 (0)