forked from MyEtherWallet/MyEtherWallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package-test.js
162 lines (161 loc) · 4.51 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// 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 parsedPackage = require('./package.json');
const packageJson = require('package-json');
const SAFE_TIME = 1000 * 1 * 60 * 60 * 24 * 7; //7days
// webpack has a major update
// copy-webpack-plugin major update
// holding off on husky changes as the cli still has some weird necessary changes to run commitlint
const EXCEPTIONS = [
'multicoin-address-validator',
'postcss-import',
'postcss-url',
'webpack',
'copy-webpack-plugin',
'sass',
'sass-loader',
'husky',
'@aave/protocol-js',
'sass',
'web3',
'web3-core-helpers',
'web3-core-method',
'web3-core-requestmanager',
'web3-utils',
'remark-cli',
'node-fetch',
'vuetify',
'vue-i18n',
'stylelint',
'stylelint-config-standard',
'vue',
'vue-router',
'vuex',
'eslint',
'eslint-plugin-vue',
'imagemin-mozjpeg', // issue with importing it to vue config will look into it more if we need it
// versions for vue3
'@vue/eslint-config-prettier', // creates more warnings
'@vue/test-utils',
'@vue/babel-preset-app',
'@vue/cli-plugin-babel',
'@vue/cli-plugin-eslint',
'@vue/cli-plugin-pwa',
'@vue/cli-plugin-unit-jest',
'@vue/cli-service',
'vue-i18n',
'vue',
'@vue/cli-plugin-e2e-nightwatch',
'@kleros/address-tags-sdk',
'package-json',
'codecov',
'node-polyfill-webpack-plugin',
'@lokalise/node-api',
'@unstoppabledomains/resolution',
'@walletconnect/client',
'@walletconnect/qrcode-modal',
'chromedriver',
'@ethereumjs/common',
'@ethereumjs/tx',
'graphql',
'vue-lazyload',
'@ensdomains/ensjs',
'vue-template-compiler',
'@aave/contract-helpers',
'@aave/math-utils',
'node-sass',
'@ledgerhq/hw-transport-web-ble',
'@ledgerhq/hw-transport-webusb',
'@ledgerhq/hw-app-eth',
'uuid',
'web3-eth-contract',
'is-ipfs',
'axios',
'prettier', // creates more warnings
'@ledgerhq/live-common', // issue with imports
'bip39', // breaks
'ethers', // major update
'patch-package', // major update
'highcharts', // major update
'geckodriver',
'@ensdomains/ens-contracts', // breaks current ENS integration
'@shapeshiftoss/hdwallet-core',
'@shapeshiftoss/hdwallet-keepkey-webusb',
'eslint-plugin-prettier', // breaks
'ethereum-block-by-date',
'@mathieustan/vue-intercom', // major version
'@coolwallet/core',
'@walletconnect/ethereum-provider',
'@mdi/font'
];
const CUSTOM_DIST = {
['babel-core']: 'bridge'
};
const ALL_PACKAGES = Object.assign(
parsedPackage.dependencies,
parsedPackage.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) {
const isBehind =
new Date(latestVersionTime).getTime() <
new Date().getTime() - SAFE_TIME;
const isMewComponentBeta =
_name === '@myetherwallet/mew-components' &&
latestVersion.includes('-beta');
if (isBehind) {
if (!isMewComponentBeta) {
console.error(
'ERROR: Update ' +
_name +
' from ' +
ALL_PACKAGES[_name] +
' to ' +
latestVersion +
'. Released:',
latestVersionTime
);
updatesFound = true;
}
}
}
})
.then(looper);
};
looper();