Skip to content

Commit

Permalink
Merge branch 'feature-packager' into 1.4.0
Browse files Browse the repository at this point in the history
* feature-packager:
  corrects zip and adds tar.gz
  • Loading branch information
averissimo committed Dec 1, 2016
2 parents 53de285 + 5d00b6c commit 2521e4d
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 8 deletions.
73 changes: 65 additions & 8 deletions gulpfile.coffee
Expand Up @@ -13,10 +13,14 @@ autoReload = require 'gulp-auto-reload'
changed = require 'gulp-changed'
rename = require 'gulp-rename'
packager = require 'electron-packager'
zip = require 'gulp-zip'
filter = require 'gulp-filter'
Q = require 'q'
Stream = require 'stream'
spawn = require('child_process').spawn

#
#
# Options

outapp = './app'
outui = outapp + '/ui'
Expand All @@ -36,6 +40,10 @@ paths =
'./src/**/*.ttf', './src/**/*.woff',
'./src/**/*.woff2']

#
#
# Options for packaging app
#
outdeploy = path.join __dirname, 'dist'

platformOpts = ['linux', 'darwin', 'win32']
Expand All @@ -56,6 +64,10 @@ deploy_options = {
platform: platformOpts.join ','
}

#
#
# End of options

# setup package stuff (README, package.json)
gulp.task 'package', ->
gulp.src paths.README
Expand Down Expand Up @@ -204,6 +216,51 @@ platformOpts.map (plat) ->
#
gulp.task 'deploy', gulp.series('default', allNames)

zipIt = (folder, filePrefix, done) ->
ext = 'zip'
zipName = path.join outdeploy, "#{filePrefix}.#{ext}"
folder = path.basename folder
#
args = ['-r', '-q', '-y', '-X', zipName, folder]
opts = {
cwd: outdeploy
stdio: [0, 1, 'pipe']
}
compressIt('zip', args, opts, zipName, done)

tarIt = (folder, filePrefix, done) ->
ext = 'tar.gz'
zipName = path.join outdeploy, "#{filePrefix}.#{ext}"
folder = path.basename folder
#
args = ['-czf', zipName, folder]
opts = {
cwd: outdeploy
stdio: [0, 1, 'pipe']
}
compressIt('tar', args, opts, zipName, done)

compressIt = (cmd, args, opts, zipName, done) ->
#
# create child process
child = spawn cmd
, args
, opts
# log all errors
child.on 'error', (err) ->
console.log 'Error: ' + err
process.exit(1)
# show err
child.on 'exit', (code) ->
if code == 0
console.log "Created archive (#{zipName})"
done()
else
console.log "Possible problem with archive #{zipname} " +
"-- (exit with #{code})"
done()
process.exit(1)

#
#
deploy = (platform, arch) ->
Expand Down Expand Up @@ -232,11 +289,11 @@ deploy = (platform, arch) ->
console.log ('Error: ' + err) if err?
else if appPaths?.length > 0
json = JSON.parse(fs.readFileSync('./package.json'))
zippaths = [appPaths[0] + '**/**', "!#{appPaths[0]}*"]
console.log "Compressing #{zippaths.join(', ')}"
gulp.src zippaths
.pipe zip "yakyak-#{json.version}-#{platform}-#{arch}.zip"
.pipe gulp.dest outdeploy
.pipe gulpCallback ()->
deferred.resolve()
zippath = "#{appPaths[0]}/"
fileprefix = "yakyak-#{json.version}-#{platform}-#{arch}"

if platform == 'linux'
tarIt zippath, fileprefix, -> deferred.resolve()
else
zipIt zippath, fileprefix, -> deferred.resolve()
deferred.promise
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -53,10 +53,13 @@
"gulp-coffee": "^2.3.1",
"gulp-concat": "^2.6.0",
"gulp-filter": "^4.0.0",
"gulp-gzip": "^1.4.0",
"gulp-install": "^0.6.0",
"gulp-less": "^3.0.5",
"gulp-print": "^2.0.1",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^1.5.2",
"gulp-spawn": "^0.3.0",
"gulp-util": "^3.0.6",
"gulp-zip": "^3.2.0",
"mocha": "^2.2.5",
Expand Down

3 comments on commit 2521e4d

@kecinzer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask, why this release don't have green YakYak icon?

@averissimo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kecinzer a bad path was defined, the branch 1.4.0 it has the green icon now (just pushed it)

sorry about that, but in my defense this is still in beta :p

@averissimo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's the commit 1530a2f

Please sign in to comment.