forked from aluxian/Messenger-for-Desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
141 lines (117 loc) · 6.04 KB
/
gulpfile.coffee
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
131
132
133
134
135
136
137
138
139
140
141
gulp = require 'gulp'
shelljs = require 'shelljs'
mergeStream = require 'merge-stream'
runSequence = require 'run-sequence'
manifest = require './package.json'
$ = require('gulp-load-plugins')()
# Remove directories used by the tasks
gulp.task 'clean', ->
shelljs.rm '-rf', './build'
shelljs.rm '-rf', './dist'
# Build for each platform; on OSX/Linux, you need Wine installed to build win32 (or remove winIco below)
['win32', 'osx64', 'linux32', 'linux64'].forEach (platform) ->
gulp.task 'build:' + platform, ->
if process.argv.indexOf('--toolbar') > 0
shelljs.sed '-i', '"toolbar": false', '"toolbar": true', './src/package.json'
gulp.src [
'./src/**'
'!./src/node_modules/copy-paste/node_modules/execSync'
]
.pipe $.nodeWebkitBuilder
platforms: [platform]
version: '0.12.2'
winIco: if process.argv.indexOf('--noicon') > 0 then undefined else './assets-windows/icon.ico'
macIcns: './assets-osx/icon.icns'
macZip: true
macPlist:
NSHumanReadableCopyright: 'aluxian.com'
CFBundleIdentifier: 'com.aluxian.messengerfordesktop'
.on 'end', ->
if process.argv.indexOf('--toolbar') > 0
shelljs.sed '-i', '"toolbar": true', '"toolbar": false', './src/package.json'
# Build for each platform; on OSX/Linux, you need Wine installed to build win32 (or remove winIco below)
['win32', 'osx64', 'linux32', 'linux64'].forEach (platform) ->
gulp.task 'build:' + platform, ->
if process.argv.indexOf('--toolbar') > 0
shelljs.sed '-i', '"toolbar": false', '"toolbar": true', './src/package.json'
gulp.src './src/**'
.pipe $.nodeWebkitBuilder
platforms: [platform]
version: '0.12.2'
winIco: if process.argv.indexOf('--noicon') > 0 then undefined else './assets-windows/icon.ico'
macIcns: './assets-osx/icon.icns'
macZip: true
macPlist:
NSHumanReadableCopyright: 'aluxian.com'
CFBundleIdentifier: 'com.aluxian.messengerfordesktop'
.on 'end', ->
if process.argv.indexOf('--toolbar') > 0
shelljs.sed '-i', '"toolbar": true', '"toolbar": false', './src/package.json'
# Only runs on OSX (requires XCode properly configured)
gulp.task 'sign:osx64', ['build:osx64'], ->
shelljs.exec 'codesign -v -f -s "Alexandru Rosianu Apps" ./build/Messenger/osx64/Messenger.app/Contents/Frameworks/*'
shelljs.exec 'codesign -v -f -s "Alexandru Rosianu Apps" ./build/Messenger/osx64/Messenger.app'
shelljs.exec 'codesign -v --display ./build/Messenger/osx64/Messenger.app'
shelljs.exec 'codesign -v --verify ./build/Messenger/osx64/Messenger.app'
# Create a DMG for osx64; only works on OS X because of appdmg
gulp.task 'pack:osx64', ['sign:osx64'], ->
shelljs.mkdir '-p', './dist' # appdmg fails if ./dist doesn't exist
shelljs.rm '-f', './dist/Messenger.dmg' # appdmg fails if the dmg already exists
gulp.src []
.pipe require('gulp-appdmg')
source: './assets-osx/dmg.json'
target: './dist/Messenger.dmg'
# Create a nsis installer for win32; must have `makensis` installed
gulp.task 'pack:win32', ['build:win32'], ->
shelljs.exec 'makensis ./assets-windows/installer.nsi'
# Create packages for linux
[32, 64].forEach (arch) ->
['deb', 'rpm'].forEach (target) ->
gulp.task "pack:linux#{arch}:#{target}", ['build:linux' + arch], ->
shelljs.rm '-rf', './build/linux'
move_opt = gulp.src [
'./assets-linux/messengerfordesktop.desktop'
'./assets-linux/after-install.sh'
'./assets-linux/after-remove.sh'
'./build/Messenger/linux' + arch + '/**'
]
.pipe gulp.dest './build/linux/opt/MessengerForDesktop'
move_png48 = gulp.src './assets-linux/icons/48/messengerfordesktop.png'
.pipe gulp.dest './build/linux/usr/share/icons/hicolor/48x48/apps'
move_png256 = gulp.src './assets-linux/icons/256/messengerfordesktop.png'
.pipe gulp.dest './build/linux/usr/share/icons/hicolor/256x256/apps'
move_svg = gulp.src './assets-linux/icons/scalable/messengerfordesktop.png'
.pipe gulp.dest './build/linux/usr/share/icons/hicolor/scalable/apps'
mergeStream move_opt, move_png48, move_png256, move_svg
.on 'end', ->
shelljs.cd './build/linux'
port = if arch == 32 then 'i386' else 'amd64'
output = "../../dist/Messenger_linux#{arch}.#{target}"
shelljs.mkdir '-p', '../../dist' # it fails if the dir doesn't exist
shelljs.rm '-f', output # it fails if the package already exists
shelljs.exec "fpm -s dir -t #{target} -a #{port} -n messengerfordesktop --after-install ./opt/MessengerForDesktop/after-install.sh --after-remove ./opt/MessengerForDesktop/after-remove.sh --license MIT --category Chat --url \"https://messengerfordesktop.com\" --description \"A simple and beautiful app for Facebook Messenger. Chat without distractions on any OS.\" -m \"Alexandru Rosianu <me@aluxian.com>\" -p #{output} -v #{manifest.version} ."
shelljs.cd '../..'
# Make packages for all platforms
gulp.task 'pack:all', (callback) ->
runSequence 'pack:osx64', 'pack:win32', 'pack:linux32:deb', 'pack:linux64:deb', callback
# Build osx64 and run it
gulp.task 'run:osx64', ['build:osx64'], ->
shelljs.exec 'open ./build/Messenger/osx64/Messenger.app'
# Run osx64 without building
gulp.task 'open:osx64', ->
shelljs.exec 'open ./build/Messenger/osx64/Messenger.app'
# Upload release to GitHub
gulp.task 'release', ['pack:all'], (callback) ->
gulp.src './dist/*'
.pipe $.githubRelease
draft: true
manifest: manifest
# Change the version of the manifest files
# Use like this: gulp version --1.2.0
gulp.task 'version', ->
version = process.argv[3].substring(2)
shelljs.sed '-i', /"version": ".*",/, '"version": "' + version + '",', './package.json'
shelljs.sed '-i', /"version": ".*",/, '"version": "' + version + '",', './src/package.json'
shelljs.sed '-i', /download\/v.*\/Messenger/g, 'download/v' + version + '/Messenger', './src/package.json'
# Make packages for all platforms by default
gulp.task 'default', ['pack:all']