Git Product home page Git Product logo

pubspec-version's Introduction

The project has moved to cider. This package is archived.






CLI tool to set/bump the version key in pubspec.yaml. Semver-compliant (Almost. It uses pub_semver which is a bit different.)

Installing

Install the package from the command line:

pub global activate pubspec_version

This will add the pubver binary to your ~/.pub-cache/bin.

Usage

Bumping the version

pubver bump <part>

where <part> can be either breaking, major, minor, patch or build.

Examples

Before Command After
1.2.3 pubver bump breaking 2.0.0
0.2.1 pubver bump breaking 0.3.0
0.2.1 pubver bump major 1.0.0
0.2.1 pubver bump minor 0.3.0
0.2.1 pubver bump patch 0.2.2
0.2.1 pubver bump build 0.2.1+1
0.2.1+42 pubver bump build 0.2.1+43
0.2.1+foo pubver bump build 0.2.1+foo.1
0.2.1+42.foo pubver bump build 0.2.1+43.foo
0.2.1+foo.bar.1.2 pubver bump build 0.2.1+foo.bar.2.0

The bump build command is a bit tricky. It either increments the first numeric part of the build (if there is a numeric part) setting other numeric parts to zeroes, or appends .1 to the build (otherwise).

Retaining the build number

When bumping either major, minor, or patch versions, it is possible to retain the existing build number (if any). To do so, pass --retain-build (-b) flag.

Before Command After
1.2.3+42 pubver bump breaking 2.0.0
0.2.1+42 pubver bump breaking -b 0.3.0+42
0.2.1+42 pubver bump patch 0.2.2
0.2.1+42 pubver bump patch -b 0.2.2+42

Setting the version

pubver set <version>

where <version> can be any arbitrary version.

Getting the version

pubver get

Output

The tool prints the new version to stdout. This allows post processing, e.g. making a git commit.

git ci . -m "Release $(pubver bump breaking)"

pubspec-version's People

Contributors

f3ath avatar lemz90 avatar rodydavis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pubspec-version's Issues

Retain pubspec.yml contents

Hi there,

thanks for your awesome package! Is there a possibility to retain comments, linebreaks etc. when bumping the version? After bumping the version my pubspec file is very condensed and all comments and linebreaks are deleted.

Directory - flag and default fail.

Followed the instructions.
Here are the results.

gregarnott@Gentles-MVPMBP:~/projects/caretech/Mobile/goodhuman (*)
> pub run pubspec_version:bump patch   

Could not find a file named "pubspec.yaml" in "/Users/gregarnott/.pub-cache/hosted/pub.dartlang.org/async-2.0.8".

gregarnott@Gentles-MVPMBP:~/projects/caretech/Mobile/goodhuman (*)
> pub run pubspec_version:bump patch -d .

Could not find a file named "pubspec.yaml" in "/Users/gregarnott/.pub-cache/hosted/pub.dartlang.org/async-2.0.8".

gregarnott@Gentles-MVPMBP:~/projects/caretech/Mobile/goodhuman (*)
> ls -al
total 56
-rw-r--r--  1 gregarnott  staff   303B 12 Nov 11:14 .metadata
-rw-r--r--  1 gregarnott  staff   4.1K 16 Nov 11:43 .packages
-rw-r--r--  1 gregarnott  staff   147B 12 Nov 11:14 README.md
drwxr-xr-x  8 gregarnott  staff   256B 16 Nov 11:29 android
drwxr-xr-x  6 gregarnott  staff   192B 13 Nov 17:28 ios
drwxr-xr-x  3 gregarnott  staff    96B 12 Nov 11:14 lib
-rw-r--r--  1 gregarnott  staff   6.0K 16 Nov 11:43 pubspec.lock
-rw-r--r--  1 gregarnott  staff   2.3K 16 Nov 10:31 pubspec.yaml
drwxr-xr-x  3 gregarnott  staff    96B 12 Nov 11:14 test

Even trying absolute path fails, ie: pub run pubspec_version:bump patch -d $PWD.

Allow updating {major,minor,patch} and build number

I plan on using this for Flutter. As the build number is mandatory there (for iOS and Android versioning), any change that increments the version number will also require a build number increment for the new version to register as a new one on Android and iOS.

I was thinking of a syntax such as:

$ pubver bump minor build

Generate a version global string in main.dart

PackageInfo works for iOS and Android, but not for Web.
So until someone extends that package to include web, perhaps you could provide some functionality in your cmd line app that would, for example, add a global static variable declaration into main.dart.

That way, we wouldn't actually need to use PackageInfo to get the version info, because it would be in that global variable.

Support for Flutter projects?

running pubver bump patch does not work with a Flutter project.

Unhandled exception:
Bad state: Unable to parse dependency null
#0      new DependencyReference.fromJson (package:pubspec/src/dependency.dart:34:7)
#1      new PubSpec.fromJson.<anonymous closure> (package:pubspec/src/pubspec.dart:99:40)
#2      JsonParser.mapValues.<anonymous closure> (package:stuff/src/json_utils.dart:115:45)
#3      _YamlMap&YamlNode&MapMixin.forEach (org-dartlang-sdk:///sdk/lib/collection/maps.dart:124:13)
#4      JsonParser.mapValues (package:stuff/src/json_utils.dart:114:7)
#5      new PubSpec.fromJson (package:pubspec/src/pubspec.dart:98:25)
#6      PubSpec.loadFile (package:pubspec/src/pubspec.dart:116:11)
<asynchronous suspension>
#7      PubSpec.load (package:pubspec/src/pubspec.dart:112:13)
<asynchronous suspension>
#8      UpdateVersion.run (package:pubspec_version/pubspec_version.dart:95:35)
<asynchronous suspension>
#9      CommandRunner.runCommand (package:args/command_runner.dart:196:27)
<asynchronous suspension>
#10     CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:111:29)
#11     new Future.sync (dart:async/future.dart:224:31)
#12     CommandRunner.run (package:args/command_runner.dart:111:11)
#13     App.run (package:pubspec_version/pubspec_version.dart:30:27)
<asynchronous suspension>
#14     main (file:///Users/developer/.pub-cache/hosted/pub.dartlang.org/pubspec_version-0.2.2/bin/pubver.dart:6:37)
<asynchronous suspension>
#15     _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:287:32)
#16     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

The output of flutter doctor -v

[✓] Flutter (Channel master, v1.3.2-pre.1, on Mac OS X 10.13.6 17G5019, locale en-US)
    • Flutter version 1.3.2-pre.1 at /Users/developer/flutter
    • Framework revision 9f35f6c3a6 (13 days ago), 2019-02-27 17:24:06 -0800
    • Engine revision 3e4e6f5c54
    • Dart version 2.2.1 (build 2.2.1-dev.0.0 40bab34fbd)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/developer/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 1.9.4
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 32.0.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] VS Code (version 1.32.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.24.0

[✓] Connected device (3 available)
    • VIVO GO            • 1120021018087000                     • android-arm • Android 9 (API 28)
    • Rody’s iPad Pro 💻 • 00008027-001544DC2222002E            • ios         • iOS 12.1.4
    • iPhone XR          • 8740478D-307D-484F-BF6D-0C7D1967344D • ios         • iOS 12.1 (simulator)

• No issues found!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.