Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove singlePackage flag #61

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,10 @@ yargs(process.argv.slice(2))
.command(
'prepare',
`Edits the package.json and changelog files to prepare for release.`,
(yargs) =>
fromStdin(yargs).option('singlePackage', {
type: 'string',
description:
'Allows you to run this command in a non monorepo and define the package name',
}),
(yargs) => fromStdin(yargs),
async function (opts) {
const { prepare } = await import('./prepare.js');
const solution = await prepare(
await newChangelogContent(opts),
opts.singlePackage,
);
const solution = await prepare(await newChangelogContent(opts));
const { explain } = await import('./plan.js');
process.stdout.write(explain(solution));
process.stdout.write(`\nSuccessfully prepared released\n`);
Expand Down Expand Up @@ -99,17 +91,11 @@ yargs(process.argv.slice(2))
.command(
'explain-plan',
`Explains which packages need to be released at what versions and why.`,
(yargs) =>
fromStdin(yargs).option('singlePackage', {
type: 'string',
description:
'Allows you to run this command in a non monorepo and define the package name',
}),
(yargs) => fromStdin(yargs),
async function (opts) {
const { planVersionBumps, explain } = await import('./plan.js');
const solution = planVersionBumps(
parseChangeLogOrExit(await newChangelogContent(opts)),
opts.singlePackage,
);
console.log(explain(solution));
},
Expand Down
17 changes: 3 additions & 14 deletions src/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,7 @@ export function explain(solution: Solution) {
return output.join('\n');
}

export function planVersionBumps(
changed: ParsedChangelog,
singlePackage?: string,
): Solution {
export function planVersionBumps(changed: ParsedChangelog): Solution {
const plan = new Plan();
for (const section of changed.sections) {
if ('unlabeled' in section) {
Expand All @@ -234,20 +231,12 @@ export function planVersionBumps(
process.exit(-1);
}

if (singlePackage) {
for (const pkg of section.packages) {
plan.addConstraint(
singlePackage,
pkg,
section.impact,
`Appears in changelog section ${section.heading}`,
);
} else {
for (const pkg of section.packages) {
plan.addConstraint(
pkg,
section.impact,
`Appears in changelog section ${section.heading}`,
);
}
}
}

Expand Down
7 changes: 2 additions & 5 deletions src/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,9 @@ function updateVersions(solution: Solution) {
}
}

export async function prepare(
newChangelogContent: string,
singlePackage?: string,
) {
export async function prepare(newChangelogContent: string) {
const changes = parseChangeLogOrExit(newChangelogContent);
const solution = planVersionBumps(changes, singlePackage);
const solution = planVersionBumps(changes);
updateVersions(solution);
const description = updateChangelog(newChangelogContent, solution);
saveSolution(solution, description);
Expand Down
Loading