-
Notifications
You must be signed in to change notification settings - Fork 57
/
gulpfile.js
122 lines (107 loc) · 2.62 KB
/
gulpfile.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
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
const path = require('path');
const gulp = require('gulp');
const childProcess = require('child_process');
const log = require('fancy-log');
const clc = require('cli-color');
const { promisify } = require('util');
const exec = promisify(childProcess.exec);
process.on('unhandledRejection', err => {
throw err;
});
// LIBRARIES
const libraries = [
'common',
'components/shared',
'components/react',
'components/generic-documentation',
'shared',
];
// Installing libraries
libraries.forEach(lib => {
gulp.task(`${lib}:install`, async () => {
const packageName = path.resolve(__dirname, `./${lib}`);
await install(packageName);
});
});
gulp.task(
'install:libraries',
gulp.parallel(libraries.map(lib => `${lib}:install`)),
);
const install = async dir => {
log.info(
`Installing dependencies of ${clc.magenta(dir.replace(__dirname, ''))}`,
);
try {
await exec(`npm install`, {
cwd: dir,
});
} catch (err) {
log.error(`Failed installing dependencies of ${dir}`);
throw err;
}
};
// CI libraries
libraries.forEach(lib => {
gulp.task(`${lib}:ci`, async () => {
const packageName = path.resolve(__dirname, `./${lib}`);
await ci(packageName);
});
});
gulp.task('ci:libraries', gulp.parallel(libraries.map(lib => `${lib}:ci`)));
const ci = async dir => {
log.info(
`Clean installing dependencies of ${clc.magenta(
dir.replace(__dirname, ''),
)}`,
);
try {
await exec(`npm ci`, {
cwd: dir,
});
} catch (err) {
log.error(`Failed installing dependencies of ${dir}`);
throw err;
}
};
// Building libraries
libraries.forEach(lib => {
gulp.task(`${lib}:build`, async () => {
const packageName = path.resolve(__dirname, `./${lib}`);
await build(packageName);
});
});
gulp.task('build:libraries', gulp.series(libraries.map(lib => `${lib}:build`)));
const build = async dir => {
log.info(`Building library ${clc.magenta(dir.replace(__dirname, ''))}`);
try {
await exec(`npm run build`, {
cwd: dir,
});
} catch (err) {
log.error(`Failed building library ${dir}`);
throw err;
}
};
// Watching libraries
gulp.task('watch:libraries', () => {
libraries.forEach(lib => {
gulp.watch([`./${lib}/src/**/*`], gulp.parallel(`${lib}:build`));
});
});
// APPS
const apps = [
'add-ons',
'compass',
'core',
'core-ui',
'logging',
'service-catalog-ui',
];
// Installing apps
apps.forEach(app => {
gulp.task(`${app}:install`, async () => {
const packageName = path.resolve(__dirname, `./${app}`);
await install(packageName);
});
});
gulp.task('install:apps', gulp.parallel(apps.map(app => `${app}:install`)));