-
-
Notifications
You must be signed in to change notification settings - Fork 5
feat: add automated dependency bump checker and changelog validator #186
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
71ff282
8ee555d
084415e
2a87c2e
88d116a
044b46e
ccc66e2
48221f2
045331a
8af5181
19c3ccd
0d1de51
49b197d
b53e89c
2f73bd8
259d980
703e1c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Introduces a new tool to automatically detect dependency version changes and validate/update changelog entries accordingly. Features: - Detects dependency bumps from git diffs in package.json files - Validates changelog entries with exact version matching - Automatically updates changelogs with missing or outdated entries - Smart PR reference concatenation when updating existing entries - Dynamically reads repository URLs and package names - Validates by default with optional --fix flag for updates Usage: yarn check-dependency-bumps # Validate changelogs yarn check-dependency-bumps --fix # Auto-update changelogs yarn check-dependency-bumps --fix --pr 1234 # With PR number
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,32 @@ | ||
| import yargs from 'yargs/yargs'; | ||
| import { hideBin } from 'yargs/helpers'; | ||
|
|
||
| export type CommandLineArguments = { | ||
| export type ReleaseCommandArguments = { | ||
| _: string[]; | ||
| command: 'release'; | ||
| projectDirectory: string; | ||
| tempDirectory: string | undefined; | ||
| tempDirectory?: string; | ||
| reset: boolean; | ||
| backport: boolean; | ||
| defaultBranch: string; | ||
| interactive: boolean; | ||
| port: number; | ||
| }; | ||
|
|
||
| export type CheckDepsCommandArguments = { | ||
| _: string[]; | ||
| command: 'check-deps'; | ||
| fromRef?: string; | ||
| toRef?: string; | ||
| defaultBranch: string; | ||
| fix?: boolean; | ||
| pr?: string; | ||
| }; | ||
|
|
||
| export type CommandLineArguments = | ||
| | ReleaseCommandArguments | ||
| | CheckDepsCommandArguments; | ||
|
|
||
| /** | ||
| * Parses the arguments provided on the command line using `yargs`. | ||
| * | ||
|
|
@@ -21,52 +37,118 @@ export type CommandLineArguments = { | |
| export async function readCommandLineArguments( | ||
| argv: string[], | ||
| ): Promise<CommandLineArguments> { | ||
| return await yargs(hideBin(argv)) | ||
| .usage( | ||
| 'This tool prepares your project for a new release by bumping versions and updating changelogs.', | ||
| const args = await yargs(hideBin(argv)) | ||
| .scriptName('create-release-branch') | ||
| .usage('$0 <command> [options]') | ||
| .command( | ||
| ['release', '$0'], | ||
| 'Prepare your project for a new release by bumping versions and updating changelogs', | ||
| (commandYargs) => | ||
| commandYargs | ||
| .option('project-directory', { | ||
| alias: 'd', | ||
| describe: 'The directory that holds your project.', | ||
| default: '.', | ||
| }) | ||
| .option('temp-directory', { | ||
| describe: | ||
| 'The directory that is used to hold temporary files, such as the release spec template.', | ||
| type: 'string', | ||
| }) | ||
| .option('reset', { | ||
| describe: | ||
| 'Removes any cached files from a previous run that may have been created.', | ||
| type: 'boolean', | ||
| default: false, | ||
| }) | ||
| .option('backport', { | ||
| describe: | ||
| 'Instructs the tool to bump the second part of the version rather than the first for a backport release.', | ||
| type: 'boolean', | ||
| default: false, | ||
| }) | ||
| .option('default-branch', { | ||
| alias: 'b', | ||
| describe: 'The name of the default branch in the repository.', | ||
| default: 'main', | ||
| type: 'string', | ||
| }) | ||
| .option('interactive', { | ||
| alias: 'i', | ||
| describe: | ||
| 'Start an interactive web UI for selecting package versions to release', | ||
| type: 'boolean', | ||
| default: false, | ||
| }) | ||
| .option('port', { | ||
| describe: | ||
| 'Port to run the interactive web UI server (only used with --interactive)', | ||
| type: 'number', | ||
| default: 3000, | ||
| }), | ||
| ) | ||
| .command( | ||
| 'check-deps', | ||
| 'Check dependency version bumps between git references', | ||
| (commandYargs) => | ||
| commandYargs | ||
| .option('from', { | ||
| describe: | ||
| 'The starting git reference (commit, branch, or tag). If not provided, auto-detects from merge base with default branch.', | ||
| type: 'string', | ||
| }) | ||
| .option('to', { | ||
| describe: 'The ending git reference (commit, branch, or tag).', | ||
| type: 'string', | ||
| default: 'HEAD', | ||
| }) | ||
| .option('default-branch', { | ||
| alias: 'b', | ||
| describe: | ||
| 'The name of the default branch to compare against when auto-detecting.', | ||
| default: 'main', | ||
| type: 'string', | ||
| }) | ||
| .option('fix', { | ||
| describe: | ||
| 'Automatically update changelogs with missing dependency bump entries.', | ||
| type: 'boolean', | ||
| default: false, | ||
| }) | ||
| .option('pr', { | ||
| describe: | ||
| 'PR number to use in changelog entries (uses placeholder if not provided).', | ||
| type: 'string', | ||
| }), | ||
| ) | ||
| .option('project-directory', { | ||
| alias: 'd', | ||
| describe: 'The directory that holds your project.', | ||
| default: '.', | ||
| }) | ||
| .option('temp-directory', { | ||
| describe: | ||
| 'The directory that is used to hold temporary files, such as the release spec template.', | ||
| type: 'string', | ||
| }) | ||
| .option('reset', { | ||
| describe: | ||
| 'Removes any cached files from a previous run that may have been created.', | ||
| type: 'boolean', | ||
| default: false, | ||
| }) | ||
| .option('backport', { | ||
| describe: | ||
| 'Instructs the tool to bump the second part of the version rather than the first for a backport release.', | ||
| type: 'boolean', | ||
| default: false, | ||
| }) | ||
| .option('default-branch', { | ||
| alias: 'b', | ||
| describe: 'The name of the default branch in the repository.', | ||
| default: 'main', | ||
| type: 'string', | ||
| }) | ||
| .option('interactive', { | ||
| alias: 'i', | ||
| describe: | ||
| 'Start an interactive web UI for selecting package versions to release', | ||
| type: 'boolean', | ||
| default: false, | ||
| }) | ||
| .option('port', { | ||
| describe: | ||
| 'Port to run the interactive web UI server (only used with --interactive)', | ||
| type: 'number', | ||
| default: 3000, | ||
| }) | ||
| .help() | ||
| .strict() | ||
| .demandCommand(0, 1) | ||
| .parse(); | ||
|
|
||
| const command = args._[0] || 'release'; | ||
|
|
||
| if (command === 'check-deps') { | ||
| return { | ||
| ...args, | ||
| command: 'check-deps', | ||
| fromRef: args.from, | ||
| toRef: args.to, | ||
| defaultBranch: args.defaultBranch, | ||
| fix: args.fix, | ||
| pr: args.pr, | ||
| } as CheckDepsCommandArguments; | ||
| } | ||
|
|
||
| return { | ||
| ...args, | ||
| command: 'release', | ||
| projectDirectory: args.projectDirectory, | ||
| tempDirectory: args.tempDirectory, | ||
| reset: args.reset, | ||
| backport: args.backport, | ||
| defaultBranch: args.defaultBranch, | ||
| interactive: args.interactive, | ||
| port: args.port, | ||
| } as ReleaseCommandArguments; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that this type assertion can be removed if you undo the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that the |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was is this for? Do we need to return this from
readCommandLineArguments? It doesn't seem to be used anywhere.