-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsyncUiFromUiDemo.js
32 lines (25 loc) · 1.17 KB
/
syncUiFromUiDemo.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
// The idea is that you first upgrade demo and then use this to sync the versions to ui
// The reason behind that is demo is an actual Expo project, and you can then use
// npx expo install --fix
// to make sure all versions we are using are Expo-supported before just upgrading all of ui
const fs = require('fs');
const sourcePackagePath = 'apps/demo/package.json';
const targetPackagePath = 'packages/ui/package.json';
const sourcePackageJson = JSON.parse(fs.readFileSync(sourcePackagePath, 'utf8'));
const targetPackageJson = JSON.parse(fs.readFileSync(targetPackagePath, 'utf8'));
// make a list of all the dependencies and their corresponding versions from the source
const sourceDependencies = {
...sourcePackageJson.dependencies,
...sourcePackageJson.devDependencies,
};
['dependencies', 'devDependencies'].forEach((key) => {
if (!targetPackageJson[key]) {
return;
}
Object.keys(targetPackageJson[key]).forEach((dependency) => {
if (sourceDependencies[dependency]) {
targetPackageJson[key][dependency] = sourceDependencies[dependency];
}
});
});
fs.writeFileSync(targetPackagePath, JSON.stringify(targetPackageJson, null, 2));