forked from MyEtherWallet/MyEtherWallet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
package-test.js
130 lines (129 loc) · 3.78 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
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
// package-test.js: check to make sure that all dependcies are sufficiently up
// to date. If dependencies are too outdated, exit with an error, failing `npm
// run update:packages` and thus eventually the entire build.
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)
// @aave/protocol-js - freezes the whole page
const EXCEPTIONS = [
'postcss-import',
'postcss-url',
'webpack',
'canvas',
'ethereum-ens',
'babel-jest',
'multicoin-address-validator',
'vee-validate',
'@xkeshi/vue-qrcode',
'@vue/test-utils',
'graphql',
'@myetherwallet/eth-token-balance',
'@makerdao/dai',
'bootstrap-vue',
'web3',
'web3-core-helpers',
'web3-core-method',
'web3-core-requestmanager',
'web3-utils',
'i18n-iso-countries',
'@myetherwallet/mewconnect-web-client',
'@walletconnect/browser',
'@walletconnect/qrcode-modal',
'ethereumjs-wallet',
'@makerdao/dai-plugin-mcd',
'@makerdao/dai-plugin-migrations',
'ethereumjs-util',
'@makerdao/dai-plugin-migrations',
'worker-loader',
'eslint-plugin-vue',
'@vue/cli-plugin-babel',
'@vue/cli-plugin-eslint',
'@vue/cli-plugin-pwa',
'@vue/cli-plugin-unit-jest',
'@vue/cli-service',
'postcss-import',
'postcss-url',
'webpack',
'copy-webpack-plugin',
'@aave/protocol-js',
// look into updating this after release
'is-ipfs',
'@stripe/stripe-js',
// probably hold off on these ones until next iteration
'@sentry/browser',
'@sentry/integrations',
'sass-loader',
'stylelint',
'@unstoppabledomains/resolution',
'vue-stripe-elements-plus'
];
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) {
console.error(
'\nREFUSING TO CONTINUE because above packages are TOO FAR OUT OF DATE!'
);
console.error(
'In order to build MyEtherWallet, you must edit package.json.'
);
console.error(
'Update the versions for the packages above to their current versions.'
);
console.error('Then run `npm update`.');
console.error();
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 in 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(
'ERROR: Update ' +
_name +
' from ' +
ALL_PACKAGES[_name] +
' to ' +
latestVersion +
'. Released:',
latestVersionTime
);
updatesFound = true;
}
})
.then(looper);
};
looper();