Skip to content

Commit

Permalink
feat: add --dependent-preid option (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
blaugold authored Oct 4, 2022
1 parent 5400499 commit b620136
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
12 changes: 11 additions & 1 deletion docs/commands/version.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,17 @@ melos version -a
When run with this option, `melos version` will increment prerelease versions using the specified prerelease identifier, e.g. using a "beta" preid along with the --prerelease flag would result in a version in the format "1.0.0-1.0.beta.0". Applies only to Conventional Commits based versioning.

```bash
melos version --preid=beta
melos version --prerelease --preid=beta
```

## --dependent-preid

This option is the same as --preid, but only applies to packages that are versioned due to a
change in a dependency version. When this option is not provided but the --preid option is, the
value of the --preid option will be used instead.

```bash
melos version --prerelease --dependent-preid=beta
```

## --message (-m)
Expand Down
9 changes: 9 additions & 0 deletions packages/melos/lib/src/command_runner/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ class VersionCommand extends MelosCommand {
'result in a version in the format "1.0.0-1.0.nullsafety.0". '
'Applies only to Conventional Commits based versioning.',
);
argParser.addOption(
'dependent-preid',
help: 'This option is the same as --preid, but only applies to packages '
'that are versioned due to a change in a dependency version. '
'When this option is not provided but the --preid option is, the '
'value of the --preid option will be used instead.',
);
argParser.addMultiOption(
'manual-version',
abbr: 'V',
Expand Down Expand Up @@ -194,6 +201,7 @@ class VersionCommand extends MelosCommand {
var updateDependentsVersions = argResults!['dependent-versions'] as bool;
final versionPrivatePackages = argResults!['all'] as bool;
final preid = argResults!['preid'] as String?;
final dependentPreid = argResults!['dependent-preid'] as String?;
final manualVersionArgs = argResults!['manual-version'] as List<String>;

final manualVersions = _parseManualVersions(manualVersionArgs);
Expand Down Expand Up @@ -227,6 +235,7 @@ class VersionCommand extends MelosCommand {
updateDependentsConstraints: updateDependentsConstraints,
updateDependentsVersions: updateDependentsVersions,
preid: preid,
dependentPreid: dependentPreid,
asPrerelease: asPrerelease,
asStableRelease: asStableRelease,
message: commitMessage,
Expand Down
7 changes: 2 additions & 5 deletions packages/melos/lib/src/commands/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mixin _VersionMixin on _RunMixin {
// all
bool showPrivatePackages = false,
String? preid,
String? dependentPreid,
bool versionPrivatePackages = false,
Map<String, versioning.ManualVersionChange> manualVersions = const {},
}) async {
Expand Down Expand Up @@ -237,11 +238,7 @@ mixin _VersionMixin on _RunMixin {
// specifically excluded.
// graduate: false,
prerelease: asPrerelease,
// TODO Should dependent packages also get the same preid, can we
// expose this as an option?
// TODO In the case of "nullsafety" it doesn't make sense for
// dependent packages to also become nullsafety preid versions.
// preid: preid,
preid: dependentPreid ?? preid,
logger: logger,
),
);
Expand Down

0 comments on commit b620136

Please sign in to comment.