-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[publish]
- Loading branch information
Showing
3 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const { sep } = require('path'); | ||
const { execSync } = require('child_process'); | ||
const { readFileSync, writeFileSync } = require('fs'); | ||
|
||
const packages = JSON.parse(execSync('lerna ls --json').toString('utf-8')); | ||
|
||
const firebaseAppPackageName = '@react-native-firebase/app'; | ||
const firebaseAppPackageVersion = packages.find(package => package.name == firebaseAppPackageName) | ||
.version; | ||
|
||
packages.forEach(package => { | ||
if (package.name == firebaseAppPackageName) return; | ||
const { name, version, location } = package; | ||
|
||
// --------------------------- | ||
// Fix Changelog Links | ||
// --------------------------- | ||
// Links to commits/PRs are broken on conventional-commits-changelog | ||
const changelogPath = `${location}${sep}/CHANGELOG.md`; | ||
let changelogContents = readFileSync(changelogPath).toString('utf-8'); | ||
changelogContents = changelogContents.replace( | ||
/github\.com\/invertase\/react-native-firebase\/(tree\/master\/packages\/[a-z-]*\/)/gm, | ||
'github.com/invertase/react-native-firebase/', | ||
); | ||
writeFileSync(changelogPath, changelogContents); | ||
|
||
// --------------------------- | ||
// Format Changelog | ||
// --------------------------- | ||
execSync(`prettier --write ${changelogPath}`); | ||
|
||
// --------------------------- | ||
// Update Peer Dependencies | ||
// --------------------------- | ||
const packageJsonPath = `${location}${sep}/package.json`; | ||
const packageJsonContents = JSON.parse(readFileSync(packageJsonPath).toString('utf-8')); | ||
if (!packageJsonContents.peerDependencies) return; | ||
if (!packageJsonContents.peerDependencies[firebaseAppPackageName]) return; | ||
if (packageJsonContents.peerDependencies[firebaseAppPackageName] === firebaseAppPackageVersion) { | ||
return; | ||
} | ||
|
||
packageJsonContents.peerDependencies[firebaseAppPackageName] = firebaseAppPackageVersion; | ||
|
||
writeFileSync(packageJsonPath, JSON.stringify(packageJsonContents, null, 2) + '\n'); | ||
|
||
console.log( | ||
`Updated '${firebaseAppPackageName}' peer dependency on package`, | ||
packageJsonContents.name, | ||
'to', | ||
packageJsonContents.peerDependencies[firebaseAppPackageName], | ||
); | ||
}); |