jonataslaw / jonataslaw/get_cli

Error on parsing pubspec.yaml while generating locales

Open
#92 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
654
Forks
193
PR merge metrics
No merged PRs in 30d

Description

When I use a hosted dependency in my pubspec and then I want to generate locales I face an error as below:

```
Bad state: expecting only one entry for dependency
#0 new DependencyReference.fromJson (package:pubspec/src/dependency.dart:19:9)
#1 new PubSpec.fromJson. (package:pubspec/src/pubspec.dart:103:68)
#2 JsonParser.mapValues. (package:pubspec/src/json_utils.dart:113:45)
#3 MapMixin.forEach (dart:collection/maps.dart:123:13)
#4 JsonParser.mapValues (package:pubspec/src/json_utils.dart:112:7)
#5 new PubSpec.fromJson (package:pubspec/src/pubspec.dart:103:15)
#6 new PubSpec.fromYamlString (package:pubspec/src/pubspec.dart:113:15)
#7 PubspecUtils.pubSpec (package:get_cli/common/utils/pubspec/pubspec_utils.dart:21:15)
#8 PubspecUtils._mapName. (package:get_cli/common/utils/pubspec/pubspec_utils.dart:36:51)
#9 _PubValue.value (package:get_cli/common/utils/pubspec/pubspec_utils.dart:159:26)
#10 PubspecUtils.projectName (package:get_cli/common/utils/pubspec/pubspec_utils.dart:37:46)
#11 sortImports (package:get_cli/functions/sorter_imports/sort.dart:17:45)
#12 writeFile (package:get_cli/functions/create/create_single_file.dart:40:21)
#13 Sample.create (package:get_cli/samples/interface/sample_interface.dart:28:12)
#14 GenerateLocalesCommand.execute (package:get_cli/commands/impl/generate/locales/locales.dart:97:10)

#15 main. (file:///C:/Users/fepco/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/get_cli-1.5.0/bin/get.dart)

```

I traced the error and I figured that pubspec package cuases this error while it wants to pars pubspec.yaml

the standard hosted structure is like this

```yaml
some_package_name:
version: ^x.x.x
hosted:
name: some_package_name
url: https://some_url
```

the pubspec parser package allows only one child below any dependency, and looks for version as a child of hosted property while it should be in the same level of hosted not its child!

I will appreciate if you take care of this issue!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.