uppy/private/release/commit-and-open-pr.js
Artur Paikin f1952bf0e2
meta: warn about not merging PR manually (#3492)
* warn about not merging PR manually

* Update commit-and-open-pr.js
2022-02-17 19:05:27 +00:00

29 lines
1.4 KiB
JavaScript

import { spawnSync } from 'node:child_process'
import { fileURLToPath } from 'node:url'
import prompts from 'prompts'
import { REPO_OWNER, REPO_NAME } from './config.js'
export default async function commit (spawnOptions, ...files) {
console.log(`Now is the time to do manual edits to ${files.join(',')}.`)
await prompts({
type: 'toggle',
name: 'value',
message: 'Ready to commit?',
initial: true,
active: 'yes',
inactive: 'yes',
})
spawnSync('git', ['add', ...files.map(url => fileURLToPath(url))], spawnOptions)
spawnSync('git', ['commit', '-n', '-m', 'Prepare next release'], { ...spawnOptions, stdio: 'inherit' })
const sha = spawnSync('git', ['rev-parse', 'HEAD'], spawnOptions).stdout.toString().trim()
const getRemoteCommamnd = `git remote -v | grep '${REPO_OWNER}/${REPO_NAME}' | awk '($3 == "(push)") { print $1; exit }'`
const remote = spawnSync('/bin/sh', ['-c', getRemoteCommamnd]).stdout.toString().trim()
|| `git@github.com:${REPO_OWNER}/${REPO_NAME}.git`
console.log(`Please run \`git push ${remote} ${sha}:refs/heads/release\`.`)
console.log(`An automation will kick off and open a release candidate PR
on the GitHub repository. Do not merge it manually! Review the PR (you may need to close and
re-open so the CI and test will run on it). If everything looks good, approve the PR —
this will publish updated packages to npm, then the PR will be merged.`)
}