forked from apim-haufe-io/wicked.env
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassemble-packages.js
55 lines (44 loc) · 1.83 KB
/
assemble-packages.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
'use strict';
var fs = require('fs');
var path = require('path');
var dirs = [
'wicked.portal',
'wicked.portal-api',
'wicked.portal-chatbot',
'wicked.portal-env',
'wicked.portal-kong-adapter',
'wicked.portal-mailer',
'wicked.portal-kickstarter',
'wicked.portal-test/portal-api',
'wicked.portal-test/portal-kong-adapter'
];
var baseDir = path.resolve(path.join(__dirname, '..'));
var allDependencies = {};
for (var i=0; i<dirs.length; ++i) {
var dirName = dirs[i];
var dir = path.join(baseDir, dirName);
console.log('Checking packages.json in: ' + dir);
var pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json')));
for(var depName in pkg.dependencies) {
var depVersion = pkg.dependencies[depName];
if (depVersion.startsWith('..'))
continue;
if (!allDependencies[depName])
allDependencies[depName] = depVersion;
else if (allDependencies[depName] != depVersion) {
console.log('WARNING: Dependency version mismatch for "' + dirName + '": ' + depName + ' - ' + depVersion + ' vs. ' + allDependencies[depName]);
if (depVersion > allDependencies[depName]) {
console.log('WARNING: Taking newer version: ' + depVersion);
allDependencies[depName] = depVersion;
}
}
}
}
// Re-add the portal-env we filtered out above
allDependencies['portal-env'] = '../portal-env.tgz';
var thisPackage = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
thisPackage.dependencies = allDependencies;
console.log(JSON.stringify(thisPackage, null, 2));
var allPackageFileName = path.join(__dirname, 'package.all.json');
console.log('Writing to ' + allPackageFileName);
fs.writeFileSync(allPackageFileName, JSON.stringify(thisPackage, null, 2), 'utf8');