Skip to content

Commit

Permalink
feat(infrastructure): restore the fix to bump peer dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc committed May 2, 2023
1 parent 579fc01 commit b287651
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 33 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,12 @@ pkgs-screenshots: ##@1 packages generate screenshots for packages readme (websit
@node scripts/capture.mjs

pkgs-publish-dry-run: ##@1 packages dry run for packages publication
@$(MAKE) pkgs-build
#@$(MAKE) pkgs-build
@pnpm lerna publish \
--exact \
--no-git-tag-version \
--no-push \
--force-publish \
--registry "http://localhost:4873" \
--loglevel verbose

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"scripts": {
"make:init": "make init",
"build": "echo 'nothing to do, please use make for available commands'",
"version": "node scripts/bump-peer-deps.mjs",
"heroku-postbuild": "make pkgs-build && cd api && pnpm build"
},
"engines": {
Expand Down
32 changes: 0 additions & 32 deletions scripts/bump-peer-deps.js

This file was deleted.

39 changes: 39 additions & 0 deletions scripts/bump-peer-deps.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { readdirSync, readFileSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'

const files = {}
const packages = {}
const versions = {}

readdirSync('./packages', { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => join('packages', dirent.name, 'package.json'))
.forEach(file => {
const pkg = JSON.parse(readFileSync(file, 'utf-8'))
files[pkg.name] = file
packages[pkg.name] = pkg
versions[pkg.name] = pkg.version
})

for (const [pkgName, pkg] of Object.entries(packages)) {
for (const [peerDep, currentVersion] of Object.entries(pkg.peerDependencies || {})) {
if (!peerDep.startsWith('@nivo/')) continue

if (!(peerDep in versions)) {
throw new Error(`Unable to find ${peerDep} in packages`)
}

const version = versions[peerDep]
pkg.peerDependencies[peerDep] = version

console.log(
`Bumping peerDependency ${peerDep} in ${pkgName} to ${version} (was ${currentVersion})`
)
}

writeFileSync(
files[pkgName],
JSON.stringify(pkg, null, 4) + '\n',
{ encoding: 'utf-8' }
)
}

1 comment on commit b287651

@vercel
Copy link

@vercel vercel bot commented on b287651 May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nivo – ./

nivo-plouc.vercel.app
nivo-git-master-plouc.vercel.app
nivo.vercel.app
www.nivo.rocks
nivo.rocks

Please sign in to comment.