├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── bin └── pubver.dart ├── example └── readme.md ├── lib ├── pubspec_version.dart └── src │ ├── cli │ ├── build_app.dart │ ├── command_container.dart │ └── pub_spec_command.dart │ ├── console.dart │ ├── next_build.dart │ ├── pubspec_version_app.dart │ └── version_transform.dart ├── pubspec.yaml └── test ├── functional_test.dart ├── pubspec_sample.yaml └── unit └── version_transform_test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | .packages 2 | pubspec.lock 3 | .dart_tool 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: dart 2 | dart: 3 | - stable 4 | dart_task: 5 | - test: --platform vm 6 | - dartfmt: true 7 | - dartanalyzer: --fatal-infos --fatal-warnings lib test bin 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [Unreleased] 8 | ## [0.6.1] - 2019-09-02 9 | ### Added 10 | - the documentation section about retaining the build number 11 | ### Fixed 12 | - function tests failing randomly due to missing `await` 13 | 14 | ## [0.6.0] - 2019-09-02 15 | ### Added 16 | - the `--retain-build` (`-b`) flag to retain the build number when bumping versions 17 | 18 | ## [0.5.0] - 2019-08-18 19 | ### Changed 20 | - the `bump build` command sets the subsequent numeric build parts to zeroes 21 | 22 | ## [0.4.0] - 2019-08-18 23 | ### Added 24 | - the `bump build` command 25 | 26 | ## [0.3.0] - 2019-05-29 27 | ### Added 28 | - the `get` command ([PR](https://github.com/f3ath/pubspec-version/pull/14)) 29 | 30 | ## [0.2.2] - 2018-11-16 31 | ### Changed 32 | - Minor documentation changes. 33 | 34 | ## [0.2.1] - 2018-11-16 35 | ### Changed 36 | - Minor documentation changes. 37 | 38 | ## [0.2.0] - 2018-11-16 39 | ### Breaking change 40 | - This is now a standalone cli app. 41 | 42 | ## [0.1.0] - 2018-10-05 43 | ### Changed 44 | - Binary names 45 | 46 | ## [0.0.2] - 2018-10-04 47 | ### Fixed 48 | - Removed double `await` statement (#1) 49 | 50 | ## 0.0.1 - 2018-10-03 51 | ### Added 52 | - Initial version 53 | 54 | [Unreleased]: https://github.com/f3ath/pubspec-version/compare/0.6.1...HEAD 55 | [0.6.1]: https://github.com/f3ath/pubspec-version/compare/0.6.0...0.6.1 56 | [0.6.0]: https://github.com/f3ath/pubspec-version/compare/0.5.0...0.6.0 57 | [0.5.0]: https://github.com/f3ath/pubspec-version/compare/0.4.0...0.5.0 58 | [0.4.0]: https://github.com/f3ath/pubspec-version/compare/0.3.0...0.4.0 59 | [0.3.0]: https://github.com/f3ath/pubspec-version/compare/0.2.2...0.3.0 60 | [0.2.2]: https://github.com/f3ath/pubspec-version/compare/0.2.1...0.2.2 61 | [0.2.1]: https://github.com/f3ath/pubspec-version/compare/0.2.0...0.2.1 62 | [0.2.0]: https://github.com/f3ath/pubspec-version/compare/0.1.0...0.2.0 63 | [0.1.0]: https://github.com/f3ath/pubspec-version/compare/0.0.2...0.1.0 64 | [0.0.2]: https://github.com/f3ath/pubspec-version/compare/0.0.1...0.0.2 65 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alexey 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The project has moved to [cider](https://pub.dev/packages/cider). This package is archived. 2 | --- 3 | --- 4 | --- 5 | --- 6 | --- 7 | 8 | CLI tool to set/bump the `version` key in pubspec.yaml. Semver-compliant (Almost. 9 | It uses [pub_semver](https://pub.dartlang.org/packages/pub_semver) which is a bit different.) 10 | 11 | ## Installing 12 | Install the package from the command line: 13 | ``` 14 | pub global activate pubspec_version 15 | ``` 16 | 17 | This will add the **pubver** binary to your `~/.pub-cache/bin`. 18 | ## Usage 19 | ### Bumping the version 20 | ``` 21 | pubver bump 22 | ``` 23 | where `` can be either **breaking**, **major**, **minor**, **patch** or **build**. 24 | 25 | #### Examples 26 | Before | Command | After 27 | --- | --- | --- 28 | 1.2.3 | `pubver bump breaking` | 2.0.0 29 | 0.2.1 | `pubver bump breaking` | 0.3.0 30 | 0.2.1 | `pubver bump major` | 1.0.0 31 | 0.2.1 | `pubver bump minor` | 0.3.0 32 | 0.2.1 | `pubver bump patch` | 0.2.2 33 | 0.2.1 | `pubver bump build` | 0.2.1+1 34 | 0.2.1+42 | `pubver bump build` | 0.2.1+43 35 | 0.2.1+foo | `pubver bump build` | 0.2.1+foo.1 36 | 0.2.1+42.foo | `pubver bump build` | 0.2.1+43.foo 37 | 0.2.1+foo.bar.1.2 | `pubver bump build` | 0.2.1+foo.bar.2.0 38 | 39 | The `bump build` command is a bit tricky. It either increments the first numeric part of the build (if there is a 40 | numeric part) setting other numeric parts to zeroes, or appends `.1` to the build (otherwise). 41 | 42 | ### Retaining the build number 43 | When bumping either **major**, **minor**, or **patch** versions, it is possible to retain the existing build number (if any). 44 | To do so, pass `--retain-build` (`-b`) flag. 45 | 46 | Before | Command | After 47 | --- | --- | --- 48 | 1.2.3+42 | `pubver bump breaking` | 2.0.0 49 | 0.2.1+42 | `pubver bump breaking -b` | 0.3.0+42 50 | 0.2.1+42 | `pubver bump patch` | 0.2.2 51 | 0.2.1+42 | `pubver bump patch -b` | 0.2.2+42 52 | 53 | 54 | ### Setting the version 55 | ``` 56 | pubver set 57 | ``` 58 | where `` can be any arbitrary version. 59 | 60 | ### Getting the version 61 | ``` 62 | pubver get 63 | ``` 64 | 65 | ### Output 66 | The tool prints the new version to stdout. This allows post processing, e.g. making a git commit. 67 | ```bash 68 | git ci . -m "Release $(pubver bump breaking)" 69 | ``` 70 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:pedantic/analysis_options.yaml 2 | -------------------------------------------------------------------------------- /bin/pubver.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:pubspec_version/pubspec_version.dart'; 4 | 5 | void main(List args) async => 6 | exit((await buildApp(Console.stdio()).run(args)) ?? 0); 7 | -------------------------------------------------------------------------------- /example/readme.md: -------------------------------------------------------------------------------- 1 | #### Examples 2 | Before | Command | After 3 | --- | --- | --- 4 | 1.2.3 | `pubver bump breaking` | 2.0.0 5 | 0.2.1 | `pubver bump breaking` | 0.3.0 6 | 0.2.1 | `pubver bump major` | 1.0.0 7 | 0.2.1 | `pubver bump minor` | 0.3.0 8 | 0.2.1 | `pubver bump patch` | 0.2.1 9 | 0.2.1 | `pubver set 5.4.3-dev` | 5.4.3-dev -------------------------------------------------------------------------------- /lib/pubspec_version.dart: -------------------------------------------------------------------------------- 1 | export 'package:pubspec_version/src/cli/build_app.dart'; 2 | export 'package:pubspec_version/src/console.dart'; 3 | -------------------------------------------------------------------------------- /lib/src/cli/build_app.dart: -------------------------------------------------------------------------------- 1 | import 'package:args/command_runner.dart'; 2 | import 'package:pubspec_version/src/cli/command_container.dart'; 3 | import 'package:pubspec_version/src/cli/pub_spec_command.dart'; 4 | import 'package:pubspec_version/src/console.dart'; 5 | 6 | CommandRunner buildApp(Console console) => 7 | CommandRunner('pubver', 'Package version manager.') 8 | ..addCommand(CommandContainer( 9 | 'bump', 10 | 'Bumps the package version.', 11 | [ 12 | PubSpecCommand( 13 | 'breaking', 14 | 'Bumps the version to the next breaking.', 15 | (_) async { 16 | await _.bumpBreaking(); 17 | console.log(await _.readVersion()); 18 | return 0; 19 | }, 20 | ), 21 | PubSpecCommand( 22 | 'major', 23 | 'Bumps the major version.', 24 | (_) async { 25 | await _.bumpMajor(); 26 | console.log(await _.readVersion()); 27 | return 0; 28 | }, 29 | ), 30 | PubSpecCommand( 31 | 'minor', 32 | 'Bumps the minor version.', 33 | (_) async { 34 | await _.bumpMinor(); 35 | console.log(await _.readVersion()); 36 | return 0; 37 | }, 38 | ), 39 | PubSpecCommand( 40 | 'patch', 41 | 'Bumps the patch version.', 42 | (_) async { 43 | await _.bumpPatch(); 44 | console.log(await _.readVersion()); 45 | return 0; 46 | }, 47 | ), 48 | PubSpecCommand( 49 | 'build', 50 | 'Bumps the first numeric part of the build version.', 51 | (_) async { 52 | await _.bumpBuild(); 53 | console.log(await _.readVersion()); 54 | return 0; 55 | }, 56 | ), 57 | ], 58 | )) 59 | ..addCommand(PubSpecCommand( 60 | 'set', 61 | 'Sets the package version.', 62 | (_) async { 63 | if (_.arguments.length < 2) { 64 | console.error( 65 | 'Please provide the version' + '\n' * 2 + 'Example: set 3.2.1'); 66 | return 64; 67 | } 68 | await _.writeVersion(_.getArgument(1)); 69 | console.log(await _.readVersion()); 70 | return 0; 71 | }, 72 | )) 73 | ..addCommand(PubSpecCommand( 74 | 'get', 75 | 'Gets the current package version.', 76 | (_) async { 77 | console.log(await _.readVersion()); 78 | return 0; 79 | }, 80 | )) 81 | ..argParser.addOption('pubspec-dir', 82 | abbr: 'd', 83 | help: 'Directory containing pubspec.yaml.', 84 | defaultsTo: '.') 85 | ..argParser.addFlag('retain-build', 86 | abbr: 'b', 87 | help: 'Retain build when bumping major, minor, or patch.', 88 | defaultsTo: false); 89 | -------------------------------------------------------------------------------- /lib/src/cli/command_container.dart: -------------------------------------------------------------------------------- 1 | import 'package:args/command_runner.dart'; 2 | 3 | class CommandContainer extends Command { 4 | @override 5 | final String name; 6 | @override 7 | final String description; 8 | 9 | CommandContainer(this.name, this.description, List> subcommands) { 10 | subcommands.forEach(addSubcommand); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/src/cli/pub_spec_command.dart: -------------------------------------------------------------------------------- 1 | import 'package:args/command_runner.dart'; 2 | import 'package:pubspec_version/src/pubspec_version_app.dart'; 3 | 4 | class PubSpecCommand extends Command { 5 | @override 6 | final String description; 7 | @override 8 | final String name; 9 | final _Payload _payload; 10 | 11 | PubSpecCommand(this.name, this.description, this._payload); 12 | 13 | bool get retainBuild => globalResults['retain-build']; 14 | 15 | Future readVersion() async => (await _app.readVersion()).toString(); 16 | 17 | Future writeVersion(String version) => _app.writeVersionString(version); 18 | 19 | Future bumpBreaking() => _app.bumpBreaking(retainBuild: retainBuild); 20 | 21 | Future bumpMajor() => _app.bumpMajor(retainBuild: retainBuild); 22 | 23 | Future bumpMinor() => _app.bumpMinor(retainBuild: retainBuild); 24 | 25 | Future bumpPatch() => _app.bumpPatch(retainBuild: retainBuild); 26 | 27 | Future bumpBuild() => _app.bumpBuild(); 28 | 29 | String getArgument(int index) => globalResults.arguments[index]; 30 | 31 | List get arguments => globalResults.arguments; 32 | 33 | @override 34 | Future run() => _payload(this); 35 | 36 | PubSpecVersionApp get _app => PubSpecVersionApp(globalResults['pubspec-dir']); 37 | } 38 | 39 | typedef _Payload = Future Function(PubSpecCommand command); 40 | -------------------------------------------------------------------------------- /lib/src/console.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | /// A very simple Console output abstraction. 4 | /// Allows to print log messages and error messages. 5 | class Console { 6 | final Stdout _output; 7 | final Stdout _error; 8 | 9 | /// Creates an instance with 10 | const Console(this._output, this._error); 11 | 12 | Console.stdio() : this(stdout, stderr); 13 | 14 | /// Writes the [message] to the error sink 15 | void error(Object message) => _error.writeln(message.toString()); 16 | 17 | /// Writes the [message] the to the normal output sink 18 | void log(Object message) => _output.writeln(message.toString()); 19 | } 20 | -------------------------------------------------------------------------------- /lib/src/next_build.dart: -------------------------------------------------------------------------------- 1 | import 'package:pub_semver/pub_semver.dart'; 2 | 3 | Version nextBuild(Version v) { 4 | var incremented = false; 5 | final build = v.build.map((part) { 6 | if (part is! int) return part; 7 | if (incremented) return 0; 8 | incremented = true; 9 | return part + 1; 10 | }).toList(); 11 | if (!incremented) build.add(1); 12 | return Version(v.major, v.minor, v.patch, build: build.join('.')); 13 | } 14 | -------------------------------------------------------------------------------- /lib/src/pubspec_version_app.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:pub_semver/pub_semver.dart'; 4 | import 'package:pubspec/pubspec.dart' as ps; 5 | import 'package:pubspec_version/src/version_transform.dart'; 6 | 7 | class PubSpecVersionApp { 8 | final Directory _dir; 9 | 10 | PubSpecVersionApp(String path) : _dir = Directory(path); 11 | 12 | Future readVersion() async { 13 | final pubSpec = await _load(); 14 | return VersionTransform(pubSpec.version); 15 | } 16 | 17 | Future writeVersion(VersionTransform version) async { 18 | final pubSpec = await _load(); 19 | await pubSpec.copy(version: version.version).save(_dir); 20 | } 21 | 22 | Future writeVersionString(String version) => 23 | writeVersion(VersionTransform(Version.parse(version))); 24 | 25 | Future bumpBreaking({bool retainBuild = false}) => 26 | _update((_) => _.bumpBreaking(), retainBuild: retainBuild); 27 | 28 | Future bumpMajor({bool retainBuild = false}) => 29 | _update((_) => _.bumpMajor(), retainBuild: retainBuild); 30 | 31 | Future bumpMinor({bool retainBuild = false}) => 32 | _update((_) => _.bumpMinor(), retainBuild: retainBuild); 33 | 34 | Future bumpPatch({bool retainBuild = false}) => 35 | _update((_) => _.bumpPatch(), retainBuild: retainBuild); 36 | 37 | Future bumpBuild() => _update((_) => _.bumpBuild()); 38 | 39 | Future _update(VersionTransform Function(VersionTransform v) mutate, 40 | {bool retainBuild = false}) async { 41 | final version = await readVersion(); 42 | var newVersion = 43 | retainBuild ? mutate(version).withBuildFrom(version) : mutate(version); 44 | await writeVersion(newVersion); 45 | } 46 | 47 | Future _load() => ps.PubSpec.load(_dir); 48 | } 49 | -------------------------------------------------------------------------------- /lib/src/version_transform.dart: -------------------------------------------------------------------------------- 1 | import 'package:pub_semver/pub_semver.dart'; 2 | 3 | class VersionTransform { 4 | final Version version; 5 | 6 | VersionTransform(this.version); 7 | 8 | VersionTransform bumpBreaking() => VersionTransform(version.nextBreaking); 9 | 10 | VersionTransform bumpMajor() => VersionTransform(version.nextMajor); 11 | 12 | VersionTransform bumpMinor() => VersionTransform(version.nextMinor); 13 | 14 | VersionTransform bumpPatch() => VersionTransform(version.nextPatch); 15 | 16 | VersionTransform bumpBuild() { 17 | var incremented = false; 18 | final build = version.build.map((part) { 19 | if (part is! int) return part; 20 | if (incremented) return 0; 21 | incremented = true; 22 | return part + 1; 23 | }).toList(); 24 | if (!incremented) build.add(1); 25 | return withBuild(build); 26 | } 27 | 28 | VersionTransform withBuild(List build) => 29 | VersionTransform(Version(version.major, version.minor, version.patch, 30 | build: build.join('.'))); 31 | 32 | VersionTransform withBuildFrom(VersionTransform other) => 33 | withBuild(other.version.build); 34 | 35 | @override 36 | String toString() => version.toString(); 37 | } 38 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | description: "A CLI tool to set/bump the package version in pubspec.yaml. The \"npm version\" for Dart." 2 | homepage: "https://github.com/f3ath/pubspec-version" 3 | name: "pubspec_version" 4 | version: "0.6.1+1" 5 | dependencies: 6 | args: "^1.5.0" 7 | pub_semver: "^1.4.2" 8 | pubspec: "^0.1.0" 9 | dev_dependencies: 10 | pedantic: ^1.0.0 11 | mockito: "^3.0.0" 12 | test: "^1.0.0" 13 | environment: 14 | sdk: ">=2.3.0 <3.0.0" 15 | executables: 16 | pubver: "pubver" 17 | -------------------------------------------------------------------------------- /test/functional_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:args/command_runner.dart'; 4 | import 'package:mockito/mockito.dart'; 5 | import 'package:pubspec/pubspec.dart'; 6 | import 'package:pubspec_version/pubspec_version.dart'; 7 | import 'package:test/test.dart'; 8 | 9 | class MockConsole extends Mock implements Console {} 10 | 11 | void main() { 12 | Directory temp; 13 | MockConsole mockConsole; 14 | CommandRunner app; 15 | 16 | void expectVersion(String v) async { 17 | expect((await PubSpec.load(Directory(temp.path))).version.toString(), v); 18 | expect( 19 | verify(mockConsole.log(captureAny)).captured.map((_) => _.toString()), 20 | [v]); 21 | } 22 | 23 | setUp(() async { 24 | temp = await Directory.systemTemp.createTemp(); 25 | await File('test/pubspec_sample.yaml').copy('${temp.path}/pubspec.yaml'); 26 | mockConsole = MockConsole(); 27 | app = buildApp(mockConsole); 28 | }); 29 | 30 | tearDown(() async { 31 | await temp.delete(recursive: true); 32 | }); 33 | 34 | test('bump breaking', () async { 35 | final code = await app.run(['bump', 'breaking', '-d', temp.path]); 36 | expect(code, 0); 37 | await expectVersion('0.4.0'); 38 | }); 39 | 40 | test('bump breaking retaining build', () async { 41 | final code = await app.run(['bump', 'breaking', '-d', temp.path, '-b']); 42 | expect(code, 0); 43 | await expectVersion('0.4.0+42'); 44 | }); 45 | 46 | test('bump major', () async { 47 | final code = await app.run(['bump', 'major', '-d', temp.path]); 48 | expect(code, 0); 49 | await expectVersion('1.0.0'); 50 | }); 51 | 52 | test('bump major retaining build', () async { 53 | final code = await app.run(['bump', 'major', '-d', temp.path, '-b']); 54 | expect(code, 0); 55 | await expectVersion('1.0.0+42'); 56 | }); 57 | 58 | test('bump minor', () async { 59 | final code = await app.run(['bump', 'minor', '-d', temp.path]); 60 | expect(code, 0); 61 | await expectVersion('0.4.0'); 62 | }); 63 | 64 | test('bump minor retaining build', () async { 65 | final code = await app.run(['bump', 'minor', '-d', temp.path, '-b']); 66 | expect(code, 0); 67 | await expectVersion('0.4.0+42'); 68 | }); 69 | 70 | test('bump patch', () async { 71 | final code = await app.run(['bump', 'patch', '-d', temp.path]); 72 | expect(code, 0); 73 | await expectVersion('0.3.3'); 74 | }); 75 | 76 | test('bump patch retaining build', () async { 77 | final code = await app.run(['bump', 'patch', '-d', temp.path, '-b']); 78 | expect(code, 0); 79 | await expectVersion('0.3.3+42'); 80 | }); 81 | 82 | test('bump build', () async { 83 | final code = await app.run(['bump', 'build', '-d', temp.path]); 84 | expect(code, 0); 85 | await expectVersion('0.3.2+43'); 86 | }); 87 | 88 | test('set', () async { 89 | final code = await app.run(['set', '5.4.321+12', '-d', temp.path]); 90 | expect(code, 0); 91 | await expectVersion('5.4.321+12'); 92 | }); 93 | 94 | test('set called without version', () async { 95 | final code = await app.run(['set']); 96 | expect(code, 64); 97 | expect(verify(mockConsole.error(captureAny)).captured, 98 | ['Please provide the version\n\nExample: set 3.2.1']); 99 | }); 100 | 101 | test('get', () async { 102 | final code = await app.run(['get', '-d', temp.path]); 103 | expect(code, 0); 104 | await expectVersion('0.3.2+42'); 105 | }); 106 | } 107 | -------------------------------------------------------------------------------- /test/pubspec_sample.yaml: -------------------------------------------------------------------------------- 1 | description: "A CLI tool to set/bump the `version` key in pubspec.yaml." 2 | name: "pubspec_version" 3 | version: "0.3.2+42" 4 | dependencies: 5 | args: "^1.5.0" 6 | pub_semver: "^1.4.2" 7 | pubspec: "^0.1.0" 8 | dev_dependencies: 9 | test: "^1.0.0" 10 | environment: 11 | sdk: ">=2.0.0 <3.0.0" 12 | executables: 13 | pubver: "pubver" 14 | -------------------------------------------------------------------------------- /test/unit/version_transform_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:pub_semver/pub_semver.dart'; 2 | import 'package:pubspec_version/src/version_transform.dart'; 3 | import 'package:test/test.dart'; 4 | 5 | void main() { 6 | test('bumping empty build sets it to 1', () async { 7 | final v = Version.parse('1.2.3'); 8 | expect(VersionTransform(v).bumpBuild().toString(), '1.2.3+1'); 9 | }); 10 | 11 | test('non-numeric build gets ".1" appended to it', () async { 12 | final v = Version.parse('1.2.3+foo42'); 13 | expect(VersionTransform(v).bumpBuild().toString(), '1.2.3+foo42.1'); 14 | }); 15 | 16 | test('in a complex build the first numeric part gets incremented', () async { 17 | final v = Version.parse('1.2.3+foo.1.2.3.bar'); 18 | expect(VersionTransform(v).bumpBuild().toString(), '1.2.3+foo.2.0.0.bar'); 19 | }); 20 | } 21 | --------------------------------------------------------------------------------