Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclofabbro committed Jul 24, 2023
2 parents b746806 + 4081f35 commit f7dae41
Show file tree
Hide file tree
Showing 153 changed files with 5,118 additions and 664 deletions.
37 changes: 37 additions & 0 deletions align_pkg_mn-peer-deps_to_mn-dev-deps.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { readdirSync, readFileSync, statSync, writeFileSync } from 'fs'
import * as path from 'path'

// https://github.com/lerna/lerna/issues/1892
// https://github.com/lerna/lerna/issues/3014
// https://github.com/lerna/lerna/issues/1575

const __dirname = path.dirname(new URL(import.meta.url).pathname)

const packagesDirs = readdirSync(path.resolve(__dirname, 'packages')).map(pkg_name =>
path.resolve(__dirname, 'packages', pkg_name),
)

packagesDirs.forEach(pkgDir => {
console.log('pkgDir', pkgDir)
const pkgJsonFile = path.resolve(pkgDir, 'package.json')
const pkgJsonFileExists = !!statSync(pkgJsonFile, { throwIfNoEntry: false })
if (!pkgJsonFileExists) return

const pkgJson = JSON.parse(readFileSync(pkgJsonFile, 'utf8'))
const hasMNDevDeps = !!Object.keys(pkgJson.devDependencies ?? {}).find(depName =>
depName.startsWith('@moodlenet/'),
)
if (!hasMNDevDeps) return

Object.keys(pkgJson.peerDependencies ?? {}).forEach(depName => {
if (depName.startsWith('@moodlenet/')) delete pkgJson.peerDependencies[depName]
})

Object.keys(pkgJson.devDependencies).forEach(depName => {
if (!depName.startsWith('@moodlenet/')) return
pkgJson.peerDependencies = pkgJson.peerDependencies ?? {}
pkgJson.peerDependencies[depName] = pkgJson.devDependencies[depName]
})

writeFileSync(pkgJsonFile, JSON.stringify(pkgJson, null, 2) + '\n')
})
Loading

0 comments on commit f7dae41

Please sign in to comment.