-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,21 @@ Flags: | |
const EXPECTED_BRANCH = 'v2' | ||
// this package will use tags like v1.0.0 while the rest will use the full package name like @pinia/[email protected] | ||
const MAIN_PKG_NAME = 'pinia' | ||
// whether the main package is at the root of the mono repo or this is not a mono repo | ||
const IS_MAIN_PKG_ROOT = false | ||
// array of folders of packages to release | ||
const PKG_FOLDERS = [ | ||
// comment for multiline format | ||
join(__dirname, '../packages/pinia'), | ||
join(__dirname, '../packages/testing'), | ||
join(__dirname, '../packages/nuxt'), | ||
] | ||
// files to add and commit after building a new version | ||
const FILES_TO_COMMIT = [ | ||
// comment for multiline format | ||
'packages/*/package.json', | ||
'packages/*/CHANGELOG.md', | ||
] | ||
|
||
/** | ||
* @type {typeof execa} | ||
|
@@ -60,7 +75,7 @@ const run = (bin, args, opts = {}) => | |
* @param args {string[]} | ||
* @param opts {import('execa').Options} | ||
*/ | ||
const dryRun = (bin, args, opts = {}) => | ||
const dryRun = async (bin, args, opts = {}) => | ||
console.log(chalk.blue(`[dry-run] ${bin} ${args.join(' ')}`), opts) | ||
const runIfNotDry = isDryRun ? dryRun : run | ||
|
||
|
@@ -112,13 +127,7 @@ async function main() { | |
} | ||
} | ||
|
||
const packagesFolders = [ | ||
join(__dirname, '../packages/pinia'), | ||
join(__dirname, '../packages/testing'), | ||
join(__dirname, '../packages/nuxt'), | ||
] | ||
|
||
const changedPackages = await getChangedPackages(...packagesFolders) | ||
const changedPackages = await getChangedPackages(...PKG_FOLDERS) | ||
|
||
if (!changedPackages.length) { | ||
console.log(chalk.red(`No packages have changed since last release`)) | ||
|
@@ -129,24 +138,29 @@ async function main() { | |
console.log(`\n${chalk.bold.blue('This is a dry run')}\n`) | ||
} | ||
|
||
// allow to select which packages | ||
const { pickedPackages } = await prompts({ | ||
type: 'multiselect', | ||
name: 'pickedPackages', | ||
message: 'What packages do you want to release?', | ||
instructions: false, | ||
min: 1, | ||
choices: changedPackages.map((pkg) => ({ | ||
title: pkg.name, | ||
value: pkg.name, | ||
selected: true, | ||
})), | ||
}) | ||
let packagesToRelease = changedPackages | ||
|
||
// if there are more than one package, ask which ones to release | ||
if (packagesToRelease.length > 1) { | ||
// allow to select which packages | ||
const { pickedPackages } = await prompts({ | ||
type: 'multiselect', | ||
name: 'pickedPackages', | ||
message: 'What packages do you want to release?', | ||
instructions: false, | ||
min: 1, | ||
choices: changedPackages.map((pkg) => ({ | ||
title: pkg.name, | ||
value: pkg.name, | ||
selected: true, | ||
})), | ||
}) | ||
|
||
// const packagesToRelease = changedPackages | ||
const packagesToRelease = changedPackages.filter((pkg) => | ||
pickedPackages.includes(pkg.name) | ||
) | ||
// const packagesToRelease = changedPackages | ||
packagesToRelease = changedPackages.filter((pkg) => | ||
pickedPackages.includes(pkg.name) | ||
) | ||
} | ||
|
||
step( | ||
`Ready to release ${packagesToRelease.map(({ name }) => chalk.bold.white(name)).join(', ')}` | ||
|
@@ -271,8 +285,9 @@ async function main() { | |
changelogExists ? '1' : '0', | ||
'--commit-path', | ||
'.', | ||
'--lerna-package', | ||
pkg.name, | ||
...(pkg.name === MAIN_PKG_NAME && IS_MAIN_PKG_ROOT | ||
? [] | ||
: ['--lerna-package', pkg.name]), | ||
...(pkg.name === MAIN_PKG_NAME | ||
? [] | ||
: ['--tag-prefix', `${pkg.name}@`]), | ||
|
@@ -312,11 +327,7 @@ async function main() { | |
const { stdout } = await run('git', ['diff'], { stdio: 'pipe' }) | ||
if (stdout) { | ||
step('\nCommitting changes...') | ||
await runIfNotDry('git', [ | ||
'add', | ||
'packages/*/CHANGELOG.md', | ||
'packages/*/package.json', | ||
]) | ||
await runIfNotDry('git', ['add', ...FILES_TO_COMMIT]) | ||
await runIfNotDry('git', [ | ||
'commit', | ||
'-m', | ||
|