forked from abpframework/abp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-gulp.js
59 lines (53 loc) · 1.41 KB
/
update-gulp.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
const glob = require('glob');
var path = require('path');
const childProcess = require('child_process');
const execa = require('execa');
const fse = require('fs-extra');
const { program } = require('commander');
program.version('0.0.1');
program.option('-r, --rc', 'whether version is rc');
program.parse(process.argv);
const gulp = (folderPath) => {
if (
!fse.existsSync(folderPath + 'gulpfile.js') ||
!glob.sync(folderPath + '*.csproj').length
) {
return;
}
try {
execa.sync(`yarn`, ['install'], { cwd: folderPath, stdio: 'inherit' });
execa.sync(`yarn`, ['gulp'], { cwd: folderPath, stdio: 'inherit' });
} catch (error) {
console.log('\x1b[31m', 'Error: ' + error.message);
}
};
const updatePackages = (pkgJsonPath) => {
try {
const result = childProcess
.execSync(
`ncu "/^@abp.*$/" --packageFile ${pkgJsonPath} -u${
program.rc ? ' --greatest' : ''
}`
)
.toString();
console.log('\x1b[0m', result);
} catch (error) {
console.log('\x1b[31m', 'Error: ' + error.message);
}
};
console.time();
glob('../**/package.json', {}, (er, files) => {
files = files.filter(
(f) =>
f &&
!f.includes('node_modules') &&
!f.includes('wwwroot') &&
!f.includes('bin') &&
!f.includes('obj')
);
files.forEach((file) => {
updatePackages(file);
gulp(file.replace('package.json', ''));
});
console.timeEnd();
});