f3ath/pubspec-version

Support for Flutter projects?

Closed this issue · 10 comments

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!

Flutter supports version number in the pubspec.yaml

version: 1.0.0+28

or

version: 1.0.0
f3ath commented

Hi @AppleEducate thanks for submitting the issue. Could you please provide an example of pubspec.yaml you're having issues with?

f3ath commented

Possibly related: Andersmholmgren/pubspec#8

name: get_version
description: Get the Version Name, Version Code, Platform and OS Version, and App ID on iOS and Android.
version: 0.0.8+5
author: Rody Davis <rody.davis.jr@gmail.com>
homepage: https://github.com/AppleEducate/plugins

environment:
  sdk: ">=2.0.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  package_info: ^0.4.0+1

flutter:
  plugin:
    androidPackage: com.appleeducate.getversion
    pluginClass: GetVersionPlugin
f3ath commented

I was not able to reproduce the issue with the file posted above. Is this the entire file? The stack trace looks similar to if there was a dependency without version constraint, e.g.

dependencies:
  package_info:

Do you have any unconstrained dependencies in pubspec.yaml?

Ill keep testing but I do not you do not alway have to add a dependency number, it is optional but highly recommended, does this tool always require a number with the dependencies?

f3ath commented

pubspec_version depends on pubspec which I believe has a bug and can not parse the empty constraint. I have opened a PR so hopefully it will be fixed soon. Meanwhile if this is actually your case, you can use "any" in the version constraint as a workaround.

f3ath commented

You can test with this project:
https://github.com/AppleEducate/plugins/tree/master/packages/get_version

Could not repro:

[f3ath@glider get_version]$ cat pubspec.yaml 
name: get_version
description: Get the Version Name, Version Code, Platform and OS Version, and App ID on iOS and Android.
version: 0.0.8+5
author: Rody Davis <rody.davis.jr@gmail.com>
homepage: https://github.com/AppleEducate/plugins

environment:
  sdk: ">=2.0.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  package_info: ^0.4.0+1

flutter:
  plugin:
    androidPackage: com.appleeducate.getversion
    pluginClass: GetVersionPlugin[f3ath@glider get_version]$ pubver bump patch
0.0.9
[f3ath@glider get_version]$ cat pubspec.yaml 
author: "Rody Davis <rody.davis.jr@gmail.com>"
description: "Get the Version Name, Version Code, Platform and OS Version, and App ID on iOS and Android."
homepage: "https://github.com/AppleEducate/plugins"
name: "get_version"
version: "0.0.9"
dependencies: 
  package_info: "^0.4.0+1"
  flutter: 
    sdk: "flutter"
environment: 
  sdk: ">=2.0.0 <3.0.0"
flutter: 
  plugin: 
    androidPackage: "com.appleeducate.getversion"
    pluginClass: "GetVersionPlugin"
[f3ath@glider get_version]$ 

Ok it may have been on another plugin with an unconstrained dependency. I’ll close this for now and submit another or reopen this if it is still not working 👍🏼