Skip to content

Commit

Permalink
fix: peer dependency versions
Browse files Browse the repository at this point in the history
[publish]
  • Loading branch information
Salakar committed May 13, 2020
1 parent af05b7e commit 35edafa
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ jobs:
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm whoami
git diff --exit-code
yarn lerna publish --yes
yarn lerna version --yes
yarn lerna publish from-package --yes
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ Pods/*
.idea/**/*
**/Pods/**
**/dist/
**/version.js
packages/**/version.js
typedoc.raw.json
tests/ios/Firebase
tests/ios/resetXcode.sh
Expand Down
53 changes: 53 additions & 0 deletions scripts/version.js
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],
);
});

0 comments on commit 35edafa

Please sign in to comment.