Skip to content

Commit

Permalink
migrate from yarn to pnpm (#45652)
Browse files Browse the repository at this point in the history
  • Loading branch information
jankaifer committed Feb 7, 2023
1 parent 12e4175 commit 588a9c1
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions .github/actions/next-stats-action/src/prepare/repo-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module.exports = (actionInfo) => {
if (!pkgData.files) {
pkgData.files = []
}
pkgData.files.push('native')
pkgData.files.push('native/*')
require('console').log(
'using swc binaries: ',
await exec(`ls ${path.join(path.dirname(pkgDataPath), 'native')}`)
Expand All @@ -154,11 +154,18 @@ module.exports = (actionInfo) => {
pkgData.dependencies['@next/swc'] =
pkgDatas.get('@next/swc').packedPkgPath
} else {
pkgData.files.push('native')
pkgData.files.push('native/*')
}
}
}

if (pkgData?.scripts?.prepublishOnly) {
// There's a bug in `pnpm pack` where it will run
// the prepublishOnly script and that will fail.
// See https://github.com/pnpm/pnpm/issues/2941
delete pkgData.scripts.prepublishOnly
}

await fs.writeFile(
pkgDataPath,
JSON.stringify(pkgData, null, 2),
Expand All @@ -170,11 +177,19 @@ module.exports = (actionInfo) => {
// to the correct versions
await Promise.all(
Array.from(pkgDatas.keys()).map(async (pkgName) => {
const { pkg, pkgPath } = pkgDatas.get(pkgName)
await exec(
`cd ${pkgPath} && yarn pack -f '${pkg}-packed.tgz'`,
true
const { pkg, pkgPath, pkgData, packedPkgPath } =
pkgDatas.get(pkgName)
// Copied from pnpm source: https://github.com/pnpm/pnpm/blob/5a5512f14c47f4778b8d2b6d957fb12c7ef40127/releasing/plugin-commands-publishing/src/pack.ts#L96
const tmpTarball = path.join(
pkgPath,
`${pkgData.name.replace('@', '').replace('/', '-')}-${
pkgData.version
}.tgz`
)
await execa('pnpm', ['pack'], {
cwd: pkgPath,
})
await fs.copyFile(tmpTarball, packedPkgPath)
})
)

Expand Down

0 comments on commit 588a9c1

Please sign in to comment.