From 98300f61669e9f973ce39e6dffc67db256ba707c Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 16 Nov 2023 12:07:11 +0100 Subject: [PATCH] Changes as per review --- pkgs/messages/example_json/pubspec.yaml | 1 - pkgs/messages/pubspec.yaml | 5 +--- pkgs/messages_builder/lib/arb_parser.dart | 2 +- .../lib/generation_options.dart | 23 +++++++++++++++++++ .../lib/message_parser/message_parser.dart | 4 ++-- pkgs/messages_builder/pubspec.yaml | 15 +++--------- pkgs/messages_deserializer/pubspec.yaml | 7 ++---- pkgs/messages_serializer/pubspec.yaml | 10 ++------ pkgs/messages_shrinker/pubspec.yaml | 20 ++++------------ 9 files changed, 38 insertions(+), 49 deletions(-) diff --git a/pkgs/messages/example_json/pubspec.yaml b/pkgs/messages/example_json/pubspec.yaml index 3726c25c..2128dde2 100644 --- a/pkgs/messages/example_json/pubspec.yaml +++ b/pkgs/messages/example_json/pubspec.yaml @@ -1,6 +1,5 @@ name: example_json description: An example on how to use `package:messages`. -version: 1.0.0 publish_to: none environment: diff --git a/pkgs/messages/pubspec.yaml b/pkgs/messages/pubspec.yaml index 20012b36..36c3b20b 100644 --- a/pkgs/messages/pubspec.yaml +++ b/pkgs/messages/pubspec.yaml @@ -10,10 +10,7 @@ environment: dependencies: collection: ^1.17.1 intl: ^0.18.0 - messages_deserializer: - git: - url: git@github.com:dart-lang/i18n.git - path: pkgs/messages_deserializer + messages_deserializer: ^0.1.0 dev_dependencies: dart_flutter_team_lints: ^1.0.0 diff --git a/pkgs/messages_builder/lib/arb_parser.dart b/pkgs/messages_builder/lib/arb_parser.dart index b879764e..0646efc3 100644 --- a/pkgs/messages_builder/lib/arb_parser.dart +++ b/pkgs/messages_builder/lib/arb_parser.dart @@ -54,7 +54,7 @@ class ArbParser { debugString, messageContent, messageKey, - addName, + addId: addName, ); final messageMetadata = arb['@$messageKey']; if (messageMetadata != null) { diff --git a/pkgs/messages_builder/lib/generation_options.dart b/pkgs/messages_builder/lib/generation_options.dart index 26f4fd12..477d443c 100644 --- a/pkgs/messages_builder/lib/generation_options.dart +++ b/pkgs/messages_builder/lib/generation_options.dart @@ -6,11 +6,34 @@ import 'package:build/build.dart'; import 'package:glob/glob.dart'; import 'package:yaml/yaml.dart'; +/// Options for the message data file and code generation. class GenerationOptions { + /// Whether to generate named message calls. Example: + /// An arb file like this + /// ```json + /// { + /// "helloName": "Hello {name}" + /// } + /// ``` + /// leads to + /// ```dart + /// String helloName(String name) { + /// ``` + /// being generated. final bool messageCalls; + + /// Whether to generate a method to fetch a message by its id. Leads to the + /// ids being stored in the data file. final bool findById; + + /// How the messages should be indexed, either through `int`s or an `enum` final IndexType indexType; + + /// The data file serialization, either json or (TBD) binary. final SerializationType serialization; + + /// The data file deserialization, either through browser functionalities or + /// dart native code. final DeserializationType deserialization; GenerationOptions({ diff --git a/pkgs/messages_builder/lib/message_parser/message_parser.dart b/pkgs/messages_builder/lib/message_parser/message_parser.dart index 23b61b04..bf9b7fb6 100644 --- a/pkgs/messages_builder/lib/message_parser/message_parser.dart +++ b/pkgs/messages_builder/lib/message_parser/message_parser.dart @@ -13,9 +13,9 @@ class MessageParser { static MessageWithMetadata parse( String debugString, String fileContents, - String name, [ + String name, { bool addId = false, - ]) { + }) { final node = Parser(name, debugString, fileContents).parse(); final arguments = []; final message = diff --git a/pkgs/messages_builder/pubspec.yaml b/pkgs/messages_builder/pubspec.yaml index 459dab30..9eb4bba7 100644 --- a/pkgs/messages_builder/pubspec.yaml +++ b/pkgs/messages_builder/pubspec.yaml @@ -15,14 +15,8 @@ dependencies: dart_style: ^2.2.4 glob: ^2.1.1 intl: ^0.18.0 - messages: - git: - url: git@github.com:dart-lang/i18n.git - path: pkgs/messages - messages_serializer: - git: - url: git@github.com:dart-lang/i18n.git - path: pkgs/messages_serializer + messages: ^0.1.0 + messages_serializer: ^0.1.0 path: ^1.8.2 yaml: ^3.1.1 @@ -31,8 +25,5 @@ dev_dependencies: build_web_compilers: ^4.0.5 dart_flutter_team_lints: ^1.0.0 lints: ^2.0.0 - messages_deserializer: - git: - url: git@github.com:dart-lang/i18n.git - path: pkgs/messages_deserializer + messages_deserializer: ^0.1.0 test: ^1.16.0 diff --git a/pkgs/messages_deserializer/pubspec.yaml b/pkgs/messages_deserializer/pubspec.yaml index 33563689..41d189cc 100644 --- a/pkgs/messages_deserializer/pubspec.yaml +++ b/pkgs/messages_deserializer/pubspec.yaml @@ -10,12 +10,9 @@ environment: # Add regular dependencies here. dependencies: js: ^0.6.5 - messages: - git: - url: git@github.com:dart-lang/i18n.git - path: pkgs/messages + messages: ^0.1.0 dev_dependencies: - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 lints: ^2.0.0 test: ^1.21.0 diff --git a/pkgs/messages_serializer/pubspec.yaml b/pkgs/messages_serializer/pubspec.yaml index fbba77aa..a2927960 100644 --- a/pkgs/messages_serializer/pubspec.yaml +++ b/pkgs/messages_serializer/pubspec.yaml @@ -9,16 +9,10 @@ environment: # Add regular dependencies here. dependencies: - messages: - git: - url: git@github.com:dart-lang/i18n.git - path: pkgs/messages + messages: ^0.1.0 dev_dependencies: dart_flutter_team_lints: ^1.0.0 lints: ^2.0.0 - messages_deserializer: - git: - url: git@github.com:dart-lang/i18n.git - path: pkgs/messages_deserializer + messages_deserializer: ^0.1.0 test: ^1.21.0 diff --git a/pkgs/messages_shrinker/pubspec.yaml b/pkgs/messages_shrinker/pubspec.yaml index 00ffd634..9c0edda0 100644 --- a/pkgs/messages_shrinker/pubspec.yaml +++ b/pkgs/messages_shrinker/pubspec.yaml @@ -12,22 +12,10 @@ dependencies: analyzer: ^6.2.0 args: ^2.4.2 build: ^2.4.1 - messages: - git: - url: git@github.com:dart-lang/i18n.git - path: pkgs/messages - messages_builder: - git: - url: git@github.com:dart-lang/i18n.git - path: pkgs/messages_builder - messages_deserializer: - git: - url: git@github.com:dart-lang/i18n.git - path: pkgs/messages_deserializer - messages_serializer: - git: - url: git@github.com:dart-lang/i18n.git - path: pkgs/messages_serializer + messages: ^0.1.0 + messages_builder: ^0.1.0 + messages_deserializer: ^0.1.0 + messages_serializer: ^0.1.0 dev_dependencies: dart_flutter_team_lints: ^2.0.0