mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
 - update codemod script - upgrade both release scripts, not sure which one is correct <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> --------- Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> Co-authored-by: JJ Kasper <[email protected]>
94 lines
2.6 KiB
JavaScript
94 lines
2.6 KiB
JavaScript
// @ts-check
|
|
const path = require('path')
|
|
const execa = require('execa')
|
|
const resolveFrom = require('resolve-from')
|
|
|
|
const SEMVER_TYPES = ['patch', 'minor', 'major']
|
|
|
|
async function main() {
|
|
const args = process.argv
|
|
const releaseType = args[args.indexOf('--release-type') + 1]
|
|
const semverType = args[args.indexOf('--semver-type') + 1]
|
|
const isCanary = releaseType === 'canary'
|
|
const isReleaseCandidate = releaseType === 'release-candidate'
|
|
const isBeta = releaseType === 'beta'
|
|
|
|
if (
|
|
releaseType !== 'stable' &&
|
|
releaseType !== 'canary' &&
|
|
releaseType !== 'release-candidate' &&
|
|
releaseType !== 'beta'
|
|
) {
|
|
console.log(
|
|
`Invalid release type ${releaseType}, must be stable, canary, release-candidate, or beta`
|
|
)
|
|
return
|
|
}
|
|
if (!isCanary && !SEMVER_TYPES.includes(semverType)) {
|
|
console.log(
|
|
`Invalid semver type ${semverType}, must be one of ${SEMVER_TYPES.join(
|
|
', '
|
|
)}`
|
|
)
|
|
return
|
|
}
|
|
|
|
const githubToken = process.env.RELEASE_BOT_GITHUB_TOKEN
|
|
|
|
if (!githubToken) {
|
|
console.log(`Missing RELEASE_BOT_GITHUB_TOKEN`)
|
|
return
|
|
}
|
|
|
|
const configStorePath = resolveFrom(
|
|
path.join(process.cwd(), 'node_modules/release'),
|
|
'configstore'
|
|
)
|
|
const ConfigStore = require(configStorePath)
|
|
|
|
const config = new ConfigStore('release')
|
|
config.set('token', githubToken)
|
|
|
|
await execa(
|
|
`git remote set-url origin https://nextjs-bot:${githubToken}@github.com/vercel/next.js.git`,
|
|
{ stdio: 'inherit', shell: true }
|
|
)
|
|
await execa(`git config user.name "nextjs-bot"`, {
|
|
stdio: 'inherit',
|
|
shell: true,
|
|
})
|
|
await execa(`git config user.email "[email protected]"`, {
|
|
stdio: 'inherit',
|
|
shell: true,
|
|
})
|
|
|
|
console.log(`Running pnpm release-${isCanary ? 'canary' : 'stable'}...`)
|
|
const preleaseType =
|
|
semverType === 'major'
|
|
? 'premajor'
|
|
: semverType === 'minor'
|
|
? 'preminor'
|
|
: 'prerelease'
|
|
|
|
const child = execa(
|
|
isCanary
|
|
? `pnpm lerna version ${preleaseType} --preid canary --force-publish -y && pnpm release --pre --skip-questions --show-url`
|
|
: isReleaseCandidate
|
|
? `pnpm lerna version ${preleaseType} --preid rc --force-publish -y && pnpm release --pre --skip-questions --show-url`
|
|
: isBeta
|
|
? `pnpm lerna version ${preleaseType} --preid beta --force-publish -y && pnpm release --pre --skip-questions --show-url`
|
|
: `pnpm lerna version ${semverType} --force-publish -y`,
|
|
{
|
|
stdio: 'pipe',
|
|
shell: true,
|
|
}
|
|
)
|
|
|
|
child.stdout?.pipe(process.stdout)
|
|
child.stderr?.pipe(process.stderr)
|
|
await child
|
|
console.log('Release process is finished')
|
|
}
|
|
|
|
main()
|