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

feat: add option to save resulting pr information into json #2405

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
27 changes: 27 additions & 0 deletions src/bin/release-please.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import {coerceOption} from '../util/coerce-option';
import * as yargs from 'yargs';
import {writeFile} from 'fs';
import {GitHub, GH_API_URL, GH_GRAPHQL_URL} from '../github';
import {Manifest, ManifestOptions, ROOT_PROJECT_PATH} from '../manifest';
import {ChangelogSection, buildChangelogSections} from '../changelog-notes';
Expand Down Expand Up @@ -396,6 +397,10 @@ function manifestOptions(yargs: yargs.Argv): yargs.Argv {
default: 'release-please-config.json',
describe: 'where can the config file be found in the project?',
})
.option('json', {
default: null,
describe: 'save json output to a file',
})
.option('manifest-file', {
default: '.release-please-manifest.json',
describe: 'where can the manifest file be found in the project?',
Expand Down Expand Up @@ -533,6 +538,17 @@ const createReleasePullRequestCommand: yargs.CommandModule<
}
} else {
const pullRequestNumbers = await manifest.createPullRequests();
if (argv.json) {
writeFile(
argv.json.toString(),
JSON.stringify(pullRequestNumbers, null, 2),
err => {
if (err) {
console.error('Error writing file:', err);
}
}
);
}
console.log(pullRequestNumbers);
}
},
Expand Down Expand Up @@ -598,6 +614,17 @@ const createReleaseCommand: yargs.CommandModule<{}, CreateReleaseArgs> = {
}
} else {
const releaseNumbers = await manifest.createReleases();
if (argv.json) {
writeFile(
argv.json.toString(),
JSON.stringify(releaseNumbers, null, 2),
err => {
if (err) {
console.error('Error writing file:', err);
}
}
);
}
console.log(releaseNumbers);
}
},
Expand Down