chore(scripts): add throttling to release script, optional git commit arg
This commit is contained in:
@@ -6,6 +6,7 @@ import execa from 'execa'
|
||||
import fse from 'fs-extra'
|
||||
import minimist from 'minimist'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import pLimit from 'p-limit'
|
||||
import path from 'path'
|
||||
import prompts from 'prompts'
|
||||
import semver from 'semver'
|
||||
@@ -16,6 +17,8 @@ import type { PackageDetails } from './lib/getPackageDetails.js'
|
||||
import { getPackageDetails } from './lib/getPackageDetails.js'
|
||||
import { updateChangelog } from './utils/updateChangelog.js'
|
||||
|
||||
const npmPublishLimit = pLimit(10)
|
||||
|
||||
// Update this list with any packages to publish
|
||||
const packageWhitelist = [
|
||||
'payload',
|
||||
@@ -30,6 +33,14 @@ const packageWhitelist = [
|
||||
|
||||
'create-payload-app',
|
||||
|
||||
// Adapters
|
||||
'email-nodemailer',
|
||||
|
||||
'storage-s3',
|
||||
'storage-azure',
|
||||
'storage-gcs',
|
||||
'storage-vercel-blob',
|
||||
|
||||
// Plugins
|
||||
'plugin-cloud',
|
||||
'plugin-cloud-storage',
|
||||
@@ -58,6 +69,7 @@ const {
|
||||
changelog = false, // Whether to update the changelog. WARNING: This gets throttled on too many commits
|
||||
'dry-run': dryRun,
|
||||
'git-tag': gitTag = true, // Whether to run git tag and commit operations
|
||||
'git-commit': gitCommit = true, // Whether to run git commit operations
|
||||
tag = 'latest',
|
||||
} = args
|
||||
|
||||
@@ -185,7 +197,10 @@ async function main() {
|
||||
|
||||
// Commit all staged changes
|
||||
runCmd(`git add CHANGELOG.md packages/**/package.json package.json`, execOpts)
|
||||
|
||||
if (gitCommit) {
|
||||
runCmd(`git commit -m "chore(release): v${nextReleaseVersion} [skip ci]"`, execOpts)
|
||||
}
|
||||
|
||||
// Tag
|
||||
header(`🏷️ Tagging release v${nextReleaseVersion}`, { enable: gitTag })
|
||||
@@ -198,7 +213,7 @@ async function main() {
|
||||
const results: { name: string; success: boolean; details?: string }[] = []
|
||||
// Sequential publish
|
||||
for (const pkg of packageDetails) {
|
||||
const result = await publishSinglePackage(pkg, { dryRun })
|
||||
const result = await publishPackageThrottled(pkg, { dryRun })
|
||||
results.push(result)
|
||||
}
|
||||
|
||||
@@ -232,6 +247,12 @@ main().catch((error) => {
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
/** Publish with promise concurrency throttling */
|
||||
async function publishPackageThrottled(pkg: PackageDetails, opts?: { dryRun?: boolean }) {
|
||||
const { dryRun = false } = opts ?? {}
|
||||
return npmPublishLimit(() => publishSinglePackage(pkg, { dryRun }))
|
||||
}
|
||||
|
||||
async function publishSinglePackage(pkg: PackageDetails, opts?: { dryRun?: boolean }) {
|
||||
const { dryRun = false } = opts ?? {}
|
||||
console.log(chalk.bold(`🚀 ${pkg.name} publishing...`))
|
||||
|
||||
Reference in New Issue
Block a user