Skip to content

Commit

Permalink
chore: update publish script to sync package versions with the same n…
Browse files Browse the repository at this point in the history
…pm scope
  • Loading branch information
beeman committed Nov 30, 2023
1 parent a3d882d commit 7a01541
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/scripts/publish.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { execSync } from 'child_process'
import { readFileSync, writeFileSync } from 'fs'

import devkit from '@nx/devkit'

const { readCachedProjectGraph } = devkit

function invariant(condition, message) {
Expand Down Expand Up @@ -48,6 +49,17 @@ process.chdir(outputPath)
try {
const json = JSON.parse(readFileSync(`package.json`).toString())
json.version = version

// Update all dependencies with the same scope to the same version
const deps = json.dependencies || {}
const npmScope = json.name.split('/')[0]
const packages = Object.keys(deps).filter((dep) => dep.includes(`${npmScope}/`))

json.dependencies = {
...deps,
...packages.reduce((acc, dep) => ({...acc, [dep]: version}), {}),
}

writeFileSync(`package.json`, JSON.stringify(json, null, 2))
} catch (e) {
console.error(`Error reading package.json file from library build output.`)
Expand Down

0 comments on commit 7a01541

Please sign in to comment.