Skip to content

Commit

Permalink
ask bump method first
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkal committed Mar 10, 2024
1 parent 2df0250 commit 3e1eede
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions scripts/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const main = async () => {

ctx.packages = JSON.parse(list.stdout)

const pwdsCommand = await execa('pnpm', ['recursive', 'exec', 'pwd'])
const pwdsCommand = await execa('pnpm', ['recursive', 'exec', 'pwd']) // use `pnpm recursive exec` to get the correct topological sort order // https://github.com/pnpm/pnpm/issues/7716
const pwds = pwdsCommand.stdout
.split('\n')
.map(s => s.trim())
Expand Down Expand Up @@ -127,7 +127,8 @@ const main = async () => {

let bumpedVersion = await task.prompt(ListrEnquirerPromptAdapter).run<string>({
type: 'Select',
message: `Select semver increment or specify new version (current latest is ${maxVersion})`,
message: `Select semver increment for all packages, specify new version, or publish packages independently`,
hint: `Current latest version across all packageas is ${maxVersion}`,
choices: [
...bumpChoices(maxVersion),
{
Expand All @@ -138,6 +139,18 @@ const main = async () => {
})

if (bumpedVersion === 'independent') {
const bumpMethod = await task.prompt(ListrEnquirerPromptAdapter).run<semver.ReleaseType | null>({
type: 'Select',
message: 'Select semver increment for each package',
choices: [
...allReleaseTypes.map(type => ({message: type, value: type})),
{
message: 'Ask for each package',
value: null,
},
],
})

const rawChanges = await gatherPackageChanges(ctx)
const changes = rawChanges.map(c => {
fs.mkdirSync(path.join(c.pkg.folder, 'changes'), {recursive: true})
Expand All @@ -148,6 +161,7 @@ const main = async () => {
}
return {...c, changelog: null}
})

const include = await task.prompt(ListrEnquirerPromptAdapter).run<string[]>({
type: 'MultiSelect',
message: 'Select packages',
Expand All @@ -158,21 +172,11 @@ const main = async () => {
value: c.pkg.name,
})),
})
const bump = await task.prompt(ListrEnquirerPromptAdapter).run<semver.ReleaseType | 'ask'>({
type: 'Select',
message: 'Select semver increment for each package',
choices: [
...allReleaseTypes.map(type => ({message: type, value: type})),
{
message: 'Ask for each package',
value: 'ask',
},
],
})

ctx.versionStrategy = {
type: 'independent',
include,
bump: bump === 'ask' ? null : bump,
bump: bumpMethod,
}
} else if (bumpedVersion === 'other') {
bumpedVersion = await task.prompt(ListrEnquirerPromptAdapter).run<string>({
Expand Down

0 comments on commit 3e1eede

Please sign in to comment.