Skip to content

Commit d55d543

Browse files
committed
update maintenance scripts
1 parent 4bb5829 commit d55d543

File tree

3 files changed

+26
-33
lines changed

3 files changed

+26
-33
lines changed

cleanup.js

+19-26
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,31 @@ var exec = require('child_process').execSync;
33
var fs = require('fs');
44
var commandExists = require('command-exists');
55
const path = require('path');
6-
7-
var installCommand = 'npm install';
8-
9-
var excludedDirectories = ['css', 'dist','node_modules','webdriver-java'];
6+
const rimraf = require('rimraf');
107

118
function rmIfExists(base, name) {
129
let dir = path.join(base, name);
1310
if(fs.existsSync(dir)) {
14-
let cleanCommand = 'rm -r '+name;
15-
console.log("Executing "+cleanCommand+" in "+base);
16-
exec(cleanCommand, {
17-
cwd: base,
18-
stdio: 'inherit'
19-
});
11+
console.log("Clean ",dir);
12+
rimraf.sync(dir);
2013
}
2114
}
2215

23-
_.each(fs.readdirSync('.'), function(name) {
24-
if(fs.statSync(name).isDirectory() && name[0] !== '.' && excludedDirectories.indexOf(name)==-1) {
25-
if(fs.existsSync(name+"/node_modules")) {
26-
let cleanCommand = 'rm -r node_modules';
27-
console.log("Executing "+cleanCommand+" in "+name);
28-
exec(cleanCommand, {
29-
cwd: name,
30-
stdio: 'inherit'
31-
});
16+
for (let keyedType of ['keyed', 'non-keyed']) {
17+
let dir = path.resolve('frameworks', keyedType);
18+
let directories = fs.readdirSync(dir);
19+
20+
for (let name of directories) {
21+
let fd = path.resolve(dir, name);
22+
console.log('cleaning ', fd);
23+
if(fs.existsSync(fd+"/node_modules")) {
24+
rimraf.sync(fd+"/node_modules");
3225
}
33-
rmIfExists(name, "package-lock.json");
34-
rmIfExists(name, "yarn.lock");
35-
rmIfExists(name, "dist");
36-
rmIfExists(name, "elm-stuff");
37-
rmIfExists(name, "bower_components");
38-
rmIfExists(name, "node_modules");
26+
rmIfExists(fd, "package-lock.json");
27+
rmIfExists(fd, "yarn.lock");
28+
rmIfExists(fd, "dist");
29+
rmIfExists(fd, "elm-stuff");
30+
rmIfExists(fd, "bower_components");
31+
rmIfExists(fd, "node_modules");
3932
}
40-
});
33+
}

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@
3131
"command-exists": "^1.0.2",
3232
"fs-extra": "^0.30.0",
3333
"http-server": "^0.10.0",
34-
"lodash": "^4.15.0"
34+
"lodash": "^4.15.0",
35+
"rimraf": "^2.6.2",
36+
"semver": "^5.5.0"
3537
},
3638
"devDependencies": {
39+
"npm-check-updates": "^2.14.2",
3740
"yargs": "^6.6.0"
3841
}
3942
}

updateFrameworks.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,15 @@ async function main() {
3232
loglevel: 'silent'
3333
});
3434
if (upgraded) {
35-
// console.log('ncu result', upgraded);
3635
let newVersion = upgraded[packageName];
36+
if (newVersion && newVersion.startsWith('^')) newVersion = newVersion.substring(1);
37+
if (newVersion && newVersion.startsWith('~')) newVersion = newVersion.substring(1);
3738
if (newVersion) {
38-
console.log('new version', newVersion);
3939
if (!semver.satisfies(newVersion, '~'+version)) {
40-
console.log(`Update ${packageName} old version is ${version}, new version ${newVersion}`);
40+
console.log(`*** Update ${packageName} old version is ${version}, new version ${newVersion}`);
4141
mustRebuildFrameworks.push(p);
4242
await ncu.run({
4343
packageFile: packageJSONFile,
44-
silent: true,
45-
jsonUpgraded: true,
46-
loglevel: 'silent',
4744
upgrade: true
4845
});
4946
}

0 commit comments

Comments
 (0)