-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild.sh
executable file
·135 lines (123 loc) · 4.59 KB
/
build.sh
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#! /usr/bin/env node
console.log("running from shell script");
var shell = require('shelljs');
var argv = require('yargs').argv;
var config = require("./src_new/config.js");
var prebidRepoPath = argv.prebidpath || "../Prebid.js/";
var task = argv.task || "wrapper";
console.log("ARGV ==>", argv);
var prebidTaskName = "";
var openwrapBuildTaskName = "";
var openwrapWebpackTaskName = "";
var CREATIVE_TASK = "creative";
var profileMode = "--profile="+(argv.profile == undefined ? "OW" : argv.profile);
if (task == CREATIVE_TASK) {
console.log("inside creative");
console.time("Cleaning Gulp");
shell.exec("gulp clean");
console.timeEnd("Cleaning Gulp");
if (shell.exec("gulp webpack-creative --mode=" + argv.mode).code !== 0) {
shell.echo('Error: webpack bundle and dist creative task failed');
shell.exit(1);
}
if (shell.exec("gulp bundle-creative --mode=" + argv.mode).code !== 0) {
shell.echo('Error:creative build task failed');
shell.exit(1);
}
} else {
console.log("Switching To Build Task");
if (shell.cd(prebidRepoPath).code !== 0) {
shell.echo("Couldnt change the dir to Prebid repo");
shell.exit(1);
}
if (argv.mode){
switch (argv.mode) {
case "test-build":
console.log("Executing test-build");
prebidTaskName = "build-bundle-dev --modules=modules.json "+profileMode;
openwrapBuildTaskName = "devbundle";
openwrapWebpackTaskName = "devpack";
break;
case "dev-build":
console.log("Executing build");
prebidTaskName = "build --modules=modules.json "+profileMode;
openwrapBuildTaskName = "bundle";
openwrapWebpackTaskName = "webpack";
break;
case "build" :
console.log("Executing build");
if(!prebidTaskName){
prebidTaskName = "bundle --modules=modules.json "+profileMode;
}
openwrapBuildTaskName = "bundle-prod";
openwrapWebpackTaskName = "webpack";
break;
case "build-all" :
console.log("Executing build");
prebidTaskName = "build-bundle-dev --modules=modules.json "+profileMode;
openwrapBuildTaskName = "devbundle";
openwrapWebpackTaskName = "devpack";
break;
default:
console.log("No mode supplied, Too few arguments");
shell.exit(1);
break;
}
}
else {
console.log("No mode supplied, Too few arguments");
shell.exit(1);
}
console.time("Executing Prebid Build");
if(shell.exec("time gulp " + prebidTaskName + " --mode=" + argv.mode).code !== 0) {
shell.echo('Error: buidlinng of project failed');
shell.exit(1);
}
console.timeEnd("Executing Prebid Build");
shell.cd("../OpenWrap/");
if (argv.mode == "test-build") {
if(shell.exec("gulp testall" + " --mode=" + argv.mode + " --prebidpath=" + prebidRepoPath).code !== 0) {
shell.echo('Error: test cases failed');
shell.exit(1);
}
}
// console.time("Cleaning Gulp");
// shell.exec("gulp clean");
// console.timeEnd("Cleaning Gulp");
/*if(shell.exec("gulp " + openwrapWebpackTaskName + " --mode=" + argv.mode + " --prebidpath=" + prebidRepoPath).code !== 0) {
shell.echo('Error: webpack wrapper task failed');
shell.exit(1);
}*/
if(shell.exec("time gulp " + openwrapBuildTaskName + " --mode=" + argv.mode + " " + profileMode + " --prebidpath=" + prebidRepoPath).code !== 0) {
shell.echo('Error: wrapper build task failed');
shell.exit(1);
}
if(config.isUsePrebidKeysEnabled() === false && config.isPrebidPubMaticAnalyticsEnabled() === true){
console.log("We need to use PWT keys, so changing targeting keys in PrebidJS config");
prebidTaskName = "build-bundle-prod --modules=modules.json";
if(shell.exec("time gulp bundle-pwt-keys").code !== 0) {
shell.echo('Error: Changing PrebidJS targeting keys failed');
shell.exit(1);
}
} else {
console.log("We need to use Prebid keys, so changing targeting keys in PrebidJS config");
if(shell.exec("time gulp bundle-pb-keys").code !== 0) {
shell.echo('Error: Changing PrebidJS targeting keys failed');
shell.exit(1);
}
}
if(config.isUsePrebidKeysEnabled() === true){
console.log("We need to use Prebid keys for Native, so changing targeting keys in PrebidJS config");
prebidTaskName = "build-bundle-prod --modules=modules.json";
if(shell.exec("time gulp bundle-native-pb-keys").code !== 0) {
shell.echo('Error: Changing PrebidJS targeting keys for Native failed');
shell.exit(1);
}
} else {
console.log("We need to use PWT keys for Native, so changing targeting keys in PrebidJS config");
if(shell.exec("time gulp bundle-native-pwt-keys").code !== 0) {
shell.echo('Error: Changing PrebidJS targeting keys for Native failed');
shell.exit(1);
}
}
}