Skip to content

Commit 0828df7

Browse files
committed
JBDS-4193 Build Bundle Installer for macOS
Fix refactors mac build to use electron-builder API instead of configuration and implements dist gulp task for macOS. Fix includes version update from GA to Alpha1 for macOS.
1 parent 209b2df commit 0828df7

3 files changed

Lines changed: 104 additions & 22 deletions

File tree

gulp-tasks/dist-darwin.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,104 @@
11
'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+
214
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+
3104
}

gulpfile.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ gulp.task('create-dist-dir', function(cb) {
7171
return mkdirp(config.buildFolderPath, cb);
7272
})
7373

74-
gulp.task('generate', ['create-modules-link','transpile:app'], function(cb) {
74+
gulp.task('generate', ['create-modules-link','update-requirements'], function(cb) {
7575
var electronVersion = pjson.devDependencies['electron'];
7676
var cmd = path.join('node_modules', '.bin') + path.sep + 'electron-packager transpiled ' + config.artifactName + ' --platform=' + config.artifactPlatform + ' --arch=' + config.artifactArch;
7777
cmd += ' --version=' + electronVersion + ' --out="' + config.buildFolderPath + '" --overwrite --asar=true';
@@ -133,23 +133,12 @@ gulp.task('update-requirements',['transpile:app'], function() {
133133
.then(updateDevStudioVersion)
134134
.then(updateDevStudioSha)
135135
.then(()=>{
136-
fs.writeFile('./transpiled/requirements.json', JSON.stringify(reqs, null, 2));
136+
fs.writeFile('./transpiled/requirements-' + process.platform + '.json', JSON.stringify(reqs, null, 2));
137137
}).catch((err)=>{
138138
console.log(err);
139139
});
140140
});
141141

142-
gulp.task('update-package-meta', function() {
143-
let appPackage = require('./transpiled/package.json');
144-
delete appPackage.build;
145-
return Promise.resolve()
146-
.then(()=>{
147-
fs.writeFile('./transpiled/package.json', JSON.stringify(appPackage, null, 2));
148-
}).catch((err)=>{
149-
console.log(err);
150-
});
151-
});
152-
153142
gulp.task('test', function() {
154143
return runSequence('unit-test');
155144
});

package.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414
"url": "https://issues.jboss.org/projects/JBDS/summary"
1515
},
1616
"homepage": "https://github.com/redhat-developer-tooling/developer-platform-install#readme",
17-
"build": {
18-
"appId": "com.redhat.devsuite.installer",
19-
"category": "public.app-category.developer-tools",
20-
"mac": {
21-
"icon": "resources/devsuite.icns",
22-
"target": "zip"
23-
}
24-
},
2517
"directories": {
2618
"app" : "transpiled"
2719
},
@@ -34,7 +26,7 @@
3426
"test": "gulp test",
3527
"ui-test": "gulp ui-test",
3628
"system-test": "gulp system-test",
37-
"dist:mac": "gulp clean && gulp transpile:app && gulp update-package-meta && node_modules/.bin/build"
29+
"dist:mac": "gulp dist"
3830
},
3931
"dependencies": {
4032
"angular": "1.5.8",

0 commit comments

Comments
 (0)