Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit fe635ea

Browse files
committed
support for building windows squirrel and msi installers
Fixes #999
1 parent baae081 commit fe635ea

File tree

9 files changed

+292
-9
lines changed

9 files changed

+292
-9
lines changed

app/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
const debug = require('debug')('main')
1818
debug('starting')
1919

20+
// handle squirrel install and update events
21+
if (require('electron-squirrel-startup')) return
22+
2023
const electron = require('electron'),
2124
{ app } = electron
2225

app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131
"nyc": "^11.3.0"
3232
},
3333
"dependencies": {
34+
"about-window": "^1.11.0",
3435
"adm-zip": "^0.4.7",
3536
"colors": "^1.2.1",
3637
"columnify": "^1.5.4",
3738
"debug": "^3.1.0",
38-
"about-window": "^1.11.0",
3939
"electron-editor-context-menu": "^1.1.1",
40+
"electron-squirrel-startup": "^1.0.0",
4041
"es6-promise-pool": "^2.5.0",
4142
"expand-home-dir": "0.0.3",
4243
"inquirer": "^3.3.0",

dist/build.sh

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
11
#!/usr/bin/env bash
22

3+
#
4+
# Copyright 2017-2018 IBM Corporation
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
319
#
420
# input params: choose a platform to build for (default: all)
521
#
622
PLATFORM=${1-all}
723

824
# product name
9-
PRODUCT_NAME="${PRODUCT_NAME-`cat ../app/build/config.json | jq --raw-output .productName`}"
25+
export PRODUCT_NAME="${PRODUCT_NAME-`cat ../app/build/config.json | jq --raw-output .productName`}"
1026

1127
# filesystem icons
1228
ICON_MAC=`cat ../app/build/config.json | jq --raw-output .filesystemIcons.darwin`
1329
ICON_WIN32=`cat ../app/build/config.json | jq --raw-output .filesystemIcons.win32`
1430
ICON_LINUX=`cat ../app/build/config.json | jq --raw-output .filesystemIcons.linux`
1531

1632
VERSION=`git rev-parse master`
17-
BUILDDIR=build
33+
export BUILDDIR=build
1834

1935
# if we're running a test against a dist build, then we need to tell
2036
# electron-packager to keep around devDependencies
@@ -85,6 +101,10 @@ function win32 {
85101
#
86102
if [ -z "$NO_INSTALLER" ]; then
87103
(cd $BUILDDIR && zip -q -r "${PRODUCT_NAME}-win32-x64" "${PRODUCT_NAME}-win32-x64" -x \*~)
104+
105+
# build squirrel and msi installers
106+
# SETUP_ICON=$ICON_WIN32 node builders/squirrel.js
107+
# SETUP_ICON=$ICON_WIN32 node builders/msi.js
88108
fi
89109
fi
90110
}
@@ -151,11 +171,7 @@ function linux {
151171

152172
if [ -z "$NO_INSTALLER" ]; then
153173
(cd $BUILDDIR && zip -q -r "${PRODUCT_NAME}-linux-x64" "${PRODUCT_NAME}-linux-x64" -x \*~)
154-
rm -f "${BUILDDIR}/installers/*.deb"
155-
DEBUG=electron-installer-debian ./node_modules/.bin/electron-installer-debian --src "${BUILDDIR}/${PRODUCT_NAME}-linux-x64" --dest ${BUILDDIR}/installers/ --arch amd64 --config dpkg-config.json
156-
for deb in "${BUILDDIR}/installers/*.deb"; do
157-
mv -f $deb "${BUILDDIR}/${PRODUCT_NAME}-linux-x64.deb"
158-
done
174+
./builders/deb.sh
159175
fi
160176
fi
161177
}

dist/builders/deb.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Copyright 2018 IBM Corporation
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
# directory of script
20+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
21+
ROOTDIR="$DIR/.."
22+
23+
cd "$ROOTDIR"
24+
25+
rm -f "${BUILDDIR}/installers/*.deb"
26+
27+
./node_modules/.bin/electron-installer-debian --src "${BUILDDIR}/${PRODUCT_NAME}-linux-x64" --dest ${BUILDDIR}/installers/ --arch amd64 --config dpkg-config.json
28+
29+
for deb in "${BUILDDIR}/installers/*.deb"; do
30+
mv -f $deb "${BUILDDIR}/${PRODUCT_NAME}-linux-x64.deb"
31+
done

dist/builders/msi.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2018 IBM Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
const path = require('path')
18+
const { MSICreator } = require('electron-wix-msi')
19+
20+
const BUILDDIR = path.join(__dirname, '..', process.env.BUILDDIR)
21+
const { PRODUCT_NAME, SETUP_ICON:setupIcon } = process.env
22+
23+
const appDirectory = path.join(BUILDDIR, `${PRODUCT_NAME}-win32-x64`)
24+
const outputDirectory = path.join(BUILDDIR, 'installers/win32-x64')
25+
26+
console.log('Windows msi build started')
27+
28+
const creator = new MSICreator({
29+
appDirectory,
30+
outputDirectory,
31+
setupIcon,
32+
name: 'fsh',
33+
setupExe: `${PRODUCT_NAME}.exe`,
34+
exe: 'fsh'
35+
})
36+
37+
creator.create()
38+
.then(() => creator.compile())
39+
.then(() => {
40+
console.log('Windows msi build succeeded')
41+
})
42+
.catch(err => {
43+
console.error(err)
44+
process.exit(1)
45+
})

dist/builders/squirrel.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2018 IBM Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
const path = require('path')
18+
const electronInstaller = require('electron-winstaller')
19+
20+
const BUILDDIR = path.join(__dirname, '..', process.env.BUILDDIR)
21+
const { PRODUCT_NAME, SETUP_ICON:setupIcon } = process.env
22+
23+
const appDirectory = path.join(BUILDDIR, `${PRODUCT_NAME}-win32-x64`)
24+
const outputDirectory = path.join(BUILDDIR, 'installers/win32-x64')
25+
26+
console.log('Windows squirrel build started')
27+
28+
electronInstaller.createWindowsInstaller({
29+
appDirectory,
30+
outputDirectory,
31+
setupIcon,
32+
name: 'fsh',
33+
setupExe: `${PRODUCT_NAME}.exe`,
34+
exe: 'fsh'
35+
})
36+
.then(() => {
37+
console.log('Windows squirrel build succeeded')
38+
})
39+
.catch(err => {
40+
console.error(err)
41+
process.exit(1)
42+
})

dist/compile.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
#!/usr/bin/env node
22

3+
/*
4+
* Copyright 2017 IBM Corporation
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
319
const compile = require('../app/plugins/modules/plugin/lib/compile'),
420
path = require('path')
521

dist/package-lock.json

Lines changed: 128 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8-
"postinstall": "if [ `uname` == Darwin ]; then brew install fakeroot dpkg; fi"
8+
"postinstall": "if [ `uname` == Darwin ]; then brew install fakeroot dpkg mono; fi"
99
},
1010
"author": "",
1111
"license": "Apache-2.0",
1212
"devDependencies": {
1313
"electron-installer-debian": "^0.8.1",
1414
"electron-installer-dmg": "^0.2.1",
1515
"electron-packager": "^8.7.2",
16+
"electron-wix-msi": "^1.3.0",
1617
"minifier": "^0.8.1"
1718
},
1819
"dependencies": {}

0 commit comments

Comments
 (0)