Update publish to skip private package (#40822)

Follow-up to https://github.com/vercel/next.js/pull/40815 ensures we
skip attempting to publish private packages like `next-swc`

x-ref:
https://github.com/vercel/next.js/actions/runs/3109438515/jobs/5039954716
This commit is contained in:
JJ Kasper 2022-09-22 17:49:44 -07:00 committed by GitHub
parent 8e1256d024
commit f19241bf33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View file

@ -16,8 +16,5 @@
"prepublishOnly": "cd ../../ && turbo run build",
"dev": "tsc -d -w -p tsconfig.json",
"typescript": "tsec --noEmit -p tsconfig.json"
},
"publishConfig": {
"access": "public"
}
}

View file

@ -4,11 +4,12 @@
const path = require('path')
const { readdir } = require('fs/promises')
const { execSync } = require('child_process')
const { readJson } = require('fs-extra')
const cwd = process.cwd()
;(async function () {
let isCanary = false
let isCanary = true
if (!process.env.NPM_TOKEN) {
console.log('No NPM_TOKEN, exiting...')
@ -18,7 +19,10 @@ const cwd = process.cwd()
try {
const tagOutput = execSync('git describe --exact-match').toString()
console.log(tagOutput)
isCanary = tagOutput.includes('-canary')
if (tagOutput.trim().startsWith('v')) {
isCanary = tagOutput.includes('-canary')
}
} catch (err) {
console.log(err)
@ -72,6 +76,14 @@ const cwd = process.cwd()
}
for (const packageDir of packageDirs) {
const pkgJson = await readJson(
path.join(packagesDir, packageDir, 'package.json')
)
if (pkgJson.private) {
console.log(`Skipping private package ${packageDir}`)
continue
}
await publish(packageDir)
}
})()