-
Notifications
You must be signed in to change notification settings - Fork 77
/
listBreakingChanges.js
86 lines (66 loc) · 2.8 KB
/
listBreakingChanges.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
const https = require('https');
const currentVersions = require('../versions.json');
const majorVersionRegexp = /(\d*?)\./;
const getUrl = (url) => {
return new Promise((resolve, reject) => {
https.get(url, (resp) => {
let data = '';
resp.on('data', (chunk) => {
data += chunk;
});
resp.on('end', () => {
resolve(data);
});
}).on("error", (err) => reject(err));
});
}
const versionsDiffer = (previous, current) => {
const currentMajor = current.match(majorVersionRegexp)[1];
const previousMajor = previous.match(majorVersionRegexp)[1];
return parseInt(currentMajor, 10) > parseInt(previousMajor, 10);
}
const printChangesForProduct = (name, key, previousProduct, currentProduct) => {
const currentVersion = currentProduct[key];
const previousVersion = previousProduct[key];
if(!currentVersion && !previousVersion) {
return;
}
if(!currentVersion && previousVersion) {
console.log(`${name} ${key} version was removed in the current version`);
return;
}
if(!previousVersion && currentVersion) {
console.log(`${name} ${key} version didn't exist in the previous version`);
return;
}
if(!currentVersion.match(majorVersionRegexp) || !previousVersion.match(majorVersionRegexp)) {
console.log(`${name} ${key} has non-numeric version`);
return
}
if(versionsDiffer(previousVersion, currentVersion)) {
console.log(`Breaking change! Current ${key} version of ${name} is ${currentVersion}, previous was ${previousVersion}`);
}
}
const printChanges = async (previousVersion) => {
console.log(`Searching for changes between current and version ${previousVersion}`);
const previousVersions = JSON.parse(await getUrl(`https://raw.githubusercontent.com/vaadin/platform/${previousVersion}/versions.json`));
for (let [key, value] of Object.entries(currentVersions.core)) {
if(!previousVersions.core[key]) {
// console.log(`${key} didn't exist in the previous version`);
continue;
}
printChangesForProduct(key, 'javaVersion', previousVersions.core[key], value);
printChangesForProduct(key, 'jsVersion', previousVersions.core[key], value);
}
for (let [key, value] of Object.entries(currentVersions.vaadin)) {
if(!previousVersions.vaadin[key]) {
// console.log(`${key} didn't exist in the previous version`);
continue;
}
printChangesForProduct(key, 'javaVersion', previousVersions.vaadin[key], value);
printChangesForProduct(key, 'jsVersion', previousVersions.vaadin[key], value);
}
}
//so, so naive
const previousVersion = process.argv[2] || '10.0';
printChanges(previousVersion);