forked from HadoukenIO/symphony-of
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
74 lines (61 loc) · 2.45 KB
/
build.js
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
const { exec } = require('child_process');
const fs = require('fs');
const env = process.argv[2]
const port = process.argv[3] || '8080'
const isLocalBuild = env === 'local';
const isStagingBuild = env === 'staging';
const isProdBuild = !(isLocalBuild || isStagingBuild);
let targetUrl;
let launchAppUuid;
switch (env) {
case 'staging': {
targetUrl = 'https://cdn.openfin.co/demos/symphony-of-staging/';
launchAppUuid = 'Symphony-OpenFin-Landing-Staging';
}
break;
case 'local': {
targetUrl = `http://localhost:${port}/`;
launchAppUuid = 'Symphony-OpenFin-Landing-Local';
}
break;
default: {
targetUrl = 'https://cdn.openfin.co/demos/symphony-of/';
launchAppUuid = 'Symphony-OpenFin-Landing';
}
}
fs.writeFileSync('./buildtarget.js', `window.targetUrl='${targetUrl}';`);
const fileString = "./buildtarget.js ./js/targetUrl.js ./js/window.js ./js/notify.js ./js/screensnippet.js ./js/main.js ./js/events.js > ./public/bundle.js";
exec('type ' + fileString, (error, stdout, stderr) => {
if (error) {
exec('cat ' + fileString, (error, stdout, stderr) => {
if (error) {
console.error(`build error: ${error}`);
return;
} else {
fs.unlinkSync('./buildtarget.js');
}
});
} else {
fs.unlinkSync('./buildtarget.js');
}
});
if (isLocalBuild) {
let app = require('./public/app.json');
let contentNavigation = app.startup_app.contentNavigation;
app.startup_app.preload = `${targetUrl}bundle.js`;
app.startup_app.url = "https://openfin.symphony.com";
contentNavigation.whitelist = contentNavigation.whitelist.filter(x=>!/localhost/.test(x))
contentNavigation.whitelist.push(targetUrl+'*');
app.startup_app.preload = `${targetUrl}bundle.js`;
app.startup_app.name = `OpenFin-Symphony-Client-Local`;
app.startup_app.uuid = `OpenFin-Symphony-Client-Local`;
fs.writeFileSync('./public/local.json', JSON.stringify(app, null, ' '));
}
const launchAppUrl = `${targetUrl}symphony-launch.html`;
const launchAppDialogLogo = `${targetUrl}symphony-dialog.png`;
let app = require('./public/symphony-launch.json');
app.startup_app.url = launchAppUrl;
app.startup_app.uuid = launchAppUuid;
app.dialogSettings.logo = launchAppDialogLogo;
fs.writeFileSync('./public/symphony-launch.json', JSON.stringify(app, null, ' '));
console.log(`built env: ${targetUrl}`);