|
1 | 1 | 'use strict'; |
| 2 | + |
| 3 | +const builder = require("electron-builder"); |
| 4 | +const Platform = builder.Platform; |
| 5 | +const download = require('./download.js'); |
| 6 | +const reqs = require('../requirements-darwin.json'); |
| 7 | +const config = require('./config.js'); |
| 8 | +const copy = require('gulp-copy'); |
| 9 | +const rename = require('gulp-rename'); |
| 10 | +const runSequence = require('run-sequence'); |
| 11 | +const pjson = require('../package.json'); |
| 12 | +const fs = require('fs-extra'); |
| 13 | + |
2 | 14 | module.exports = function(gulp) { |
| 15 | + |
| 16 | + // prefetch all the installer dependencies so we can package them up into the .exe |
| 17 | + gulp.task('prefetch', ['create-prefetch-cache-dir'], function() { |
| 18 | + return download.prefetch(reqs, 'yes', config.prefetchFolder); |
| 19 | + }); |
| 20 | + |
| 21 | + gulp.task('dist', function(){ |
| 22 | + return runSequence('clean','dist-simple','dist-bundle'); |
| 23 | + }); |
| 24 | + |
| 25 | + gulp.task('update-package',['update-requirements'], function() { |
| 26 | + return Promise.resolve().then(()=> { |
| 27 | + pjson.version = pjson.version.replace('GA','Alpha1'); |
| 28 | + }).then(()=>{ |
| 29 | + fs.writeFile('./transpiled/package.json', JSON.stringify(pjson, null, 2)); |
| 30 | + }).catch((err)=>{ |
| 31 | + console.log(err); |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | + gulp.task('dist-bundle', ['prefetch','update-package'], function() { |
| 36 | + const builder = require("electron-builder") |
| 37 | + const Platform = builder.Platform |
| 38 | + |
| 39 | + // Promise is returned |
| 40 | + return builder.build({ |
| 41 | + targets: Platform.MAC.createTarget(), |
| 42 | + devMetadata: { |
| 43 | + build: { |
| 44 | + appId: "com.redhat.devsuite.installer", |
| 45 | + category: "public.app-category.developer-tools", |
| 46 | + mac: { |
| 47 | + icon: "resources/devsuite.icns", |
| 48 | + target: "zip" |
| 49 | + }, |
| 50 | + extraFiles: [{ |
| 51 | + "from": "requirements-cache", |
| 52 | + "to": ".", |
| 53 | + "filter": ["*"] |
| 54 | + }] |
| 55 | + }, |
| 56 | + directories: { |
| 57 | + app : "transpiled" |
| 58 | + }, |
| 59 | + |
| 60 | + } |
| 61 | + }).then(() => { |
| 62 | + let pn =pjson.productName; |
| 63 | + let pv =pjson.version; |
| 64 | + return gulp.src(`dist/mac/${pn}-${pv}-mac.zip`) |
| 65 | + .pipe(rename(`devsuite-${pv}-bundle-installer-mac.zip`)) |
| 66 | + .pipe(gulp.dest(`dist/`)); |
| 67 | + }).catch((error) => { |
| 68 | + // handle error |
| 69 | + }); |
| 70 | + }); |
| 71 | + |
| 72 | + gulp.task('dist-simple', ['update-package'], function() { |
| 73 | + const builder = require("electron-builder") |
| 74 | + const Platform = builder.Platform |
| 75 | + |
| 76 | + // Promise is returned |
| 77 | + return builder.build({ |
| 78 | + targets: Platform.MAC.createTarget(), |
| 79 | + devMetadata: { |
| 80 | + build: { |
| 81 | + appId: "com.redhat.devsuite.installer", |
| 82 | + category: "public.app-category.developer-tools", |
| 83 | + mac: { |
| 84 | + icon: "resources/devsuite.icns", |
| 85 | + target: "zip" |
| 86 | + } |
| 87 | + }, |
| 88 | + directories: { |
| 89 | + app : "transpiled" |
| 90 | + }, |
| 91 | + |
| 92 | + } |
| 93 | + }).then(() => { |
| 94 | + let pn =pjson.productName; |
| 95 | + let pv =pjson.version; |
| 96 | + return gulp.src(`dist/mac/${pn}-${pv}-mac.zip`) |
| 97 | + .pipe(rename(`devsuite-${pv}-installer-mac.zip`)) |
| 98 | + .pipe(gulp.dest(`dist/`)); |
| 99 | + }).catch((error) => { |
| 100 | + |
| 101 | + }); |
| 102 | + }); |
| 103 | + |
3 | 104 | } |
0 commit comments