Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/iNavFlight/inav-configurator.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto García Hierro <alberto@garciahierro.com>2017-09-04 18:42:46 +0300
committerAlberto García Hierro <alberto@garciahierro.com>2017-09-04 18:59:01 +0300
commit4c41ccb71995deeeea590570a0b6075be9c0aa7f (patch)
tree37be24d847b5cdeeabdcf925ebe2d61dd53ce892 /gulpfile.js
parent528f223a06e2c071e66b7673baeb50e65b0f9fef (diff)
Add support for creating a macOS .zip from gulp
This produces a nice .zip which can be distributed as is. Unfortunately, the only way to produce a signed binary is by generating the macOS app on macOS.
Diffstat (limited to 'gulpfile.js')
-rw-r--r--gulpfile.js51
1 files changed, 45 insertions, 6 deletions
diff --git a/gulpfile.js b/gulpfile.js
index 2b826061..ee27bd4d 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1,11 +1,16 @@
'use strict';
+var child_process = require('child_process');
+var fs = require('fs');
+var path = require('path');
+
+var archiver = require('archiver');
+var del = require('del');
+var NwBuilder = require('nw-builder');
+
var gulp = require('gulp');
-var rename = require('gulp-rename');
var concat = require('gulp-concat');
-var del = require('del');
var runSequence = require('run-sequence');
-var NwBuilder = require('nw-builder');
// Each key in the *sources* variable must be an array of
@@ -134,6 +139,7 @@ var output = {
var outputDir = './build/';
var distDir = './dist/';
+var appsDir = './apps/';
function get_task_name(key) {
return 'build-' + key.replace(/([A-Z])/g, function($1){return "-"+$1.toLowerCase();});
@@ -196,11 +202,11 @@ gulp.task('dist', function() {
return runSequence('clean', 'dist-build');
});
-// Create app packages in ./apps
-gulp.task('release', ['dist'], function(done) {
+// Create app directories in ./apps
+gulp.task('apps', ['dist'], function(done) {
var builder = new NwBuilder({
files: './dist/**/*',
- buildDir: './apps',
+ buildDir: appsDir,
platforms: ['win32', 'osx64', 'linux64'],
flavor: 'normal',
macIcns: './images/inav.icns',
@@ -210,11 +216,44 @@ gulp.task('release', ['dist'], function(done) {
builder.build(function (err) {
if (err) {
console.log("Error building NW apps:" + err);
+ done();
+ return;
}
+ // Package apps as .zip files
done();
});
});
+function get_release_filename(platform, ext) {
+ var pkg = require('./package.json');
+ return 'INAV-Configurator_' + platform + '_' + pkg.version + '.' + ext;
+}
+
+gulp.task('release-macos', function() {
+ var pkg = require('./package.json');
+ var src = path.join(appsDir, pkg.name, 'osx64', pkg.name + '.app');
+ // Check if we want to sign the .app bundle
+ if (process.env.CODESIGN_IDENTITY) {
+ var sign_cmd = 'codesign --verbose --force --sign "' + process.env.CODESIGN_IDENTITY + '" ' + src;
+ child_process.execSync(sign_cmd);
+ }
+ var output = fs.createWriteStream(path.join(appsDir, get_release_filename('macOS', 'zip')));
+ var archive = archiver('zip', {
+ zlib: { level: 9 }
+ });
+ archive.on('warning', function(err) { throw err; });
+ archive.on('error', function(err) { throw err; });
+ archive.pipe(output);
+ archive.directory(src, 'INAV Configurator.app');
+ return archive.finalize();
+});
+
+// Create distributable .zip files in ./apps
+gulp.task('release', function() {
+ // TODO: Windows, Linux
+ return runSequence('apps', 'release-macos');
+});
+
gulp.task('watch', function () {
for(var k in output) {
gulp.watch(sources[k], [get_task_name(k)]);