-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
13 changed files
with
91 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import 'package:args/command_runner.dart'; | ||
|
||
class BumpVersion<T> extends Command<T> { | ||
class BumpVersionCommand<T> extends Command<T> { | ||
final name = 'bump'; | ||
final description = 'Bumps the package version.'; | ||
|
||
BumpVersion(List<Command<T>> subcommands) { | ||
BumpVersionCommand(List<Command<T>> subcommands) { | ||
subcommands.forEach(addSubcommand); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import 'package:pub_semver/pub_semver.dart'; | ||
import 'package:pubspec_version/src/update_version.dart'; | ||
import 'package:pubspec_version/src/version_command.dart'; | ||
|
||
import 'console.dart'; | ||
|
||
class Bumper extends UpdateVersion { | ||
class Bumper extends VersionCommand { | ||
final String name; | ||
final String description; | ||
final _Mutator mutator; | ||
|
||
Bumper(this.name, this.description, Console c) : super(c); | ||
Bumper(this.name, this.description, Console c, this.mutator) : super(c); | ||
|
||
Version nextVersion(Version v) => { | ||
'breaking': () => v.nextBreaking, | ||
'major': () => v.nextMajor, | ||
'minor': () => v.nextMinor, | ||
'patch': () => v.nextPatch, | ||
}[name](); | ||
Version nextVersion(Version v) => mutator(v); | ||
} | ||
|
||
typedef Version _Mutator(Version v); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:pub_semver/pub_semver.dart'; | ||
|
||
Version nextBuild(Version v) { | ||
final build = List.from(v.build); | ||
final firstIntegerIndex = build.indexWhere((_) => _ is int); | ||
if (firstIntegerIndex == -1) return _withBuild(v, (build + [1]).join('.')); | ||
build[firstIntegerIndex] += 1; | ||
return _withBuild(v, (build).join('.')); | ||
} | ||
|
||
Version _withBuild(Version v, String build) => | ||
Version(v.major, v.minor, v.patch, build: build); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:pub_semver/pub_semver.dart'; | ||
import 'package:pubspec_version/src/next_build.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('bumping empty build sets it to 1', () async { | ||
final v = Version.parse('1.2.3'); | ||
expect(nextBuild(v).toString(), '1.2.3+1'); | ||
}); | ||
|
||
test('non-numeric build gets ".1" appended to it', () async { | ||
final v = Version.parse('1.2.3+foo42'); | ||
expect(nextBuild(v).toString(), '1.2.3+foo42.1'); | ||
}); | ||
|
||
test('in a complex build the first numeric part gets incremented', () async { | ||
final v = Version.parse('1.2.3+foo.1.2.3.bar'); | ||
expect(nextBuild(v).toString(), '1.2.3+foo.2.2.3.bar'); | ||
}); | ||
} |