forked from ipfs/ipfs-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pkg.js
executable file
·130 lines (115 loc) · 3.02 KB
/
pkg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env node
// Taken from https://github.com/chentsulin/electron-react-boilerplate/blob/master/package.js
var os = require('os')
var packager = require('electron-packager')
var assign = require('object-assign')
var del = require('del')
var exec = require('child_process').exec
var argv = require('minimist')(process.argv.slice(2))
var pkgInfo = require('./package.json')
// Need to customize this list to avoid issues with missing
// dependencies
var ignoreDeps = [
'babel',
'babel-core',
'babel-eslint',
'babel-loader',
'babel-plugin-react-transform',
'css-loader',
'electron-debug',
'electron-packager',
'electron-prebuilt',
'eslint',
'eslint-config-standard',
'eslint-config-standard-react',
'eslint-plugin-react',
'eslint-plugin-standard',
'express',
'file-loader',
'less',
'less-loader',
'pre-commit',
'react-transform-catch-errors',
'react-transform-hmr',
'redbox-react',
'standard',
'style-loader',
'webpack',
'webpack-dev-middleware',
'webpack-hot-middleware',
'webpack-target-electron-renderer'
]
var appName = argv.name || argv.n || 'Station'
var shouldUseAsar = argv.asar || argv.a || false
var shouldBuildAll = argv.all || false
var DEFAULT_OPTS = {
dir: './',
name: appName,
asar: shouldUseAsar,
'app-version': pkgInfo.version,
ignore: [
'/test($|/)',
'/tools($|/)',
'/release($|/)',
'/app.log'
].concat(ignoreDeps.map(function (name) {
return '/node_modules/' + name + '($|/)'
}))
}
var icon = argv.icon || argv.i || './node_modules/ipfs-logo/platform-icons/ipfs.icns'
if (icon) {
DEFAULT_OPTS.icon = icon
}
var version = argv.version || argv.v
if (version) {
DEFAULT_OPTS.version = version
startPack()
} else {
// use the same version as the currently-installed electron-prebuilt
exec('npm list | grep electron-prebuilt', function (err, stdout, stderr) {
if (err) {
DEFAULT_OPTS.version = '0.28.3'
} else {
DEFAULT_OPTS.version = stdout.split('@')[1].replace(/\s/g, '')
}
startPack()
})
}
function startPack () {
console.log('start pack...')
del('release')
.then(function (paths) {
if (shouldBuildAll) {
// build for all platforms
var archs = ['ia32', 'x64']
var platforms = ['linux', 'win32', 'darwin']
platforms.forEach(function (plat) {
archs.forEach(function (arch) {
pack(plat, arch, log(plat, arch))
})
})
} else {
// build for current platform only
pack(os.platform(), os.arch(), log(os.platform(), os.arch()))
}
})
.catch(function (err) {
console.error(err)
})
}
function pack (plat, arch, cb) {
// there is no darwin ia32 electron
if (plat === 'darwin' && arch === 'ia32') return
var opts = assign({}, DEFAULT_OPTS, {
platform: plat,
arch: arch,
out: 'release/' + plat + '-' + arch
})
packager(opts, cb)
}
function log (plat, arch) {
return function (err, filepath) {
if (err) return console.error(err)
console.log(plat + '-' + arch + ' finished!')
}
}