forked from MyEtherWallet/MyEtherWallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package-test.js
71 lines (71 loc) · 2.12 KB
/
package-test.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
const package = require('./package.json');
const packageJson = require('package-json');
const SAFE_TIME = 1000 * 1 * 60 * 60 * 24 * 7; //7days
// babel-jest 24.0.0 is breaking all the tests [2-1-19]
//@xkeshi/vue-qrcode no longer maintained, forked out to mew
//multicoin-address-validator not enough downloads
// waiting for vee-validate 3.0 to be more stable (https://github.com/baianat/vee-validate/issues/2248)
// Matching exceptions with package.json
// Lock @vue packages due to complications on updating
// @vue/test-utils - breaking tests beginning at 5.2.5-hotfix-2 (with version 1.0.0-beta.30)
const EXCEPTIONS = [
'@myetherwallet/mewconnect-web-client',
'canvas',
'ethereum-ens',
'babel-jest',
'multicoin-address-validator',
'vee-validate',
'@xkeshi/vue-qrcode',
'web3',
'web3-core-helpers',
'web3-core-method',
'web3-utils',
'@vue/test-utils',
'trezor-connect'
];
const CUSTOM_DIST = {
['babel-core']: 'bridge'
};
const ALL_PACKAGES = Object.assign(
package.dependencies,
package.devDependencies
);
const names = Object.keys(ALL_PACKAGES);
let updatesFound = false;
const looper = () => {
if (!names.length) {
if (updatesFound) process.exit(1);
else process.exit(0);
}
const _name = names.shift();
if (EXCEPTIONS.includes(_name)) return looper();
if (ALL_PACKAGES[_name].includes('^') || ALL_PACKAGES[_name].includes('~')) {
console.error(
'Invalid character ~ or ^ found on package.json version string, only fixed versions are allowed'
);
process.exit(1);
}
packageJson(_name, {
fullMetadata: true,
allVersions: true
})
.then(info => {
const latestVersion = info['dist-tags'][CUSTOM_DIST[_name] || 'latest'];
const latestVersionTime = info['time'][latestVersion];
if (
ALL_PACKAGES[_name] !== latestVersion &&
new Date(latestVersionTime).getTime() < new Date().getTime() - SAFE_TIME
) {
console.error(
'new update found',
_name,
ALL_PACKAGES[_name],
latestVersion,
latestVersionTime
);
updatesFound = true;
}
})
.then(looper);
};
looper();