Skip to content

Commit

Permalink
Fixes before publish (#749)
Browse files Browse the repository at this point in the history
* Fixes before publish

* Fix comment

* Fix library name

* Remove deps on `lints`

* Add test restriction to vm
  • Loading branch information
mosuem committed Nov 27, 2023
1 parent 9f65bb3 commit f02f748
Show file tree
Hide file tree
Showing 19 changed files with 173 additions and 43 deletions.
27 changes: 27 additions & 0 deletions pkgs/messages/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2023, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion pkgs/messages/lib/src/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class StringMessage extends Message {
/// Maps argument indices to their position in the string, where they are to
/// be inserted.
///
/// This list is expected to be sorted by [stringIndex]
/// This list is expected to be sorted by `argPositions.stringIndex`
final List<({int stringIndex, int argIndex})> argPositions;

StringMessage(this.value, {this.argPositions = const [], String? id})
Expand Down
2 changes: 1 addition & 1 deletion pkgs/messages/lib/src/message_list_json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:messages_deserializer/messages_deserializer_json.dart';
import 'package:messages_deserializer/messages_deserializer.dart';

import 'intl_object.dart';
import 'message_format.dart';
Expand Down
4 changes: 1 addition & 3 deletions pkgs/messages/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: messages
description: A lightweight modular library for localization (l10n) functionality.
version: 0.1.0
publish_to: none
repository: https://github.com/dart-lang/i18n/tree/main/pkgs/messages

environment:
Expand All @@ -13,6 +12,5 @@ dependencies:
messages_deserializer: ^0.1.0

dev_dependencies:
dart_flutter_team_lints: ^1.0.0
lints: ^2.0.0
dart_flutter_team_lints: ^2.1.1
test: ^1.16.0
27 changes: 27 additions & 0 deletions pkgs/messages_builder/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2023, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion pkgs/messages_builder/lib/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class BuildStepGenerator {
/// unpacked at runtime so that the messages can be read from it.
///
/// Returns the list of indices of the messages which are visible to the user.
Future<void> writeDataFile<T>(MessagesWithMetadata messages) async {
Future<void> writeDataFile(MessagesWithMetadata messages) async {
final serialization = serializer.serialize(
messages.hash,
messages.locale,
Expand Down
4 changes: 1 addition & 3 deletions pkgs/messages_builder/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: messages_builder
description: Build the messages for consumption by package:messages
version: 0.1.0
publish_to: none
repository: https://github.com/dart-lang/i18n/pkgs/messages_builder

environment:
Expand All @@ -23,7 +22,6 @@ dependencies:
dev_dependencies:
build_runner: ^2.0.0
build_web_compilers: ^4.0.5
dart_flutter_team_lints: ^1.0.0
lints: ^2.0.0
dart_flutter_team_lints: ^2.1.1
messages_deserializer: ^0.1.0
test: ^1.16.0
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:messages/messages.dart';
import 'package:messages/package_intl_object.dart';
import 'package:messages_builder/arb_parser.dart';
import 'package:messages_builder/message_with_metadata.dart';
import 'package:messages_deserializer/messages_deserializer_json.dart';
import 'package:messages_deserializer/messages_deserializer.dart';
import 'package:messages_serializer/messages_serializer.dart';
import 'package:test/test.dart';

Expand Down
27 changes: 27 additions & 0 deletions pkgs/messages_deserializer/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2023, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 0 additions & 2 deletions pkgs/messages_deserializer/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: messages_deserializer
description: Deserialization of messages for package:messages.
version: 0.1.0
publish_to: none
repository: https://github.com/dart-lang/i18n/tree/main/pkgs/messages_deserializer

environment:
Expand All @@ -14,5 +13,4 @@ dependencies:

dev_dependencies:
dart_flutter_team_lints: ^2.0.0
lints: ^2.0.0
test: ^1.21.0
27 changes: 27 additions & 0 deletions pkgs/messages_serializer/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2023, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 changes: 7 additions & 7 deletions pkgs/messages_serializer/lib/src/serializer_json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class JsonSerializer extends Serializer<String> {
if ((message.id == null || isVisible == false) && !containsArgs) {
return message.value;
}
final m = [];
final m = <Object>[];
addId(message, m, isVisible);
m.add(message.value);
if (containsArgs) {
Expand All @@ -106,7 +106,7 @@ class JsonSerializer extends Serializer<String> {
/// * Map\<String, int\> | the cases:
/// * MapEntry\<String, int\> | a case mapped to the message it represents
List encodeSelect(SelectMessage message, bool isVisible) {
final m = [];
final m = <Object>[];
m.add(SelectMessage.type);
addId(message, m, isVisible);
m.add(message.argIndex);
Expand All @@ -129,12 +129,12 @@ class JsonSerializer extends Serializer<String> {
/// * int | the case index as encoded by the constants in `Plural`
/// * int | the message index of the case
List encodePlural(PluralMessage message, bool isVisible) {
final m = [];
final m = <Object>[];
m.add(PluralMessage.type);
addId(message, m, isVisible);
m.add(message.argIndex);
m.add(encodeMessage(message.other));
final caseIndices = [];
final caseIndices = <Object>[];
if (message.few != null) {
caseIndices.add(Plural.few);
caseIndices.add(encodeMessage(message.few!));
Expand Down Expand Up @@ -178,7 +178,7 @@ class JsonSerializer extends Serializer<String> {
/// * List\<int\> | the submessage IDs
/// * int | the index of the submessage
List encodeCombined(CombinedMessage message, bool isVisible) {
final m = [];
final m = <Object>[];
m.add(CombinedMessage.type);
addId(message, m, isVisible);
for (var submessage in message.messages) {
Expand All @@ -197,12 +197,12 @@ class JsonSerializer extends Serializer<String> {
/// * int | the case index as encoded by the constants in `Gender`
/// * int | the message index of the case
List encodeGender(GenderMessage message, bool isVisible) {
final m = [];
final m = <Object>[];
m.add(GenderMessage.type);
addId(message, m, isVisible);
m.add(message.argIndex);
m.add(encodeMessage(message.other));
final caseIndices = [];
final caseIndices = <Object>[];
if (message.female != null) {
caseIndices.add(Gender.female);
caseIndices.add(encodeMessage(message.female!));
Expand Down
4 changes: 1 addition & 3 deletions pkgs/messages_serializer/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: messages_serializer
description: Serialization of messages for package:messages.
version: 0.1.0
publish_to: none
repository: https://github.com/dart-lang/i18n/tree/main/pkgs/messages_serializer

environment:
Expand All @@ -12,7 +11,6 @@ dependencies:
messages: ^0.1.0

dev_dependencies:
dart_flutter_team_lints: ^1.0.0
lints: ^2.0.0
dart_flutter_team_lints: ^2.1.1
messages_deserializer: ^0.1.0
test: ^1.21.0
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dart:math';

import 'package:messages/messages_json.dart';
import 'package:messages/package_intl_object.dart';
import 'package:messages_deserializer/messages_deserializer_json.dart';
import 'package:messages_deserializer/messages_deserializer.dart';
import 'package:messages_serializer/messages_serializer.dart';
import 'package:test/test.dart';

Expand Down
27 changes: 27 additions & 0 deletions pkgs/messages_shrinker/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2023, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion pkgs/messages_shrinker/lib/messages_shrinker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dart:convert';
import 'dart:io';

import 'package:messages/package_intl_object.dart';
import 'package:messages_deserializer/messages_deserializer_json.dart';
import 'package:messages_deserializer/messages_deserializer.dart';
import 'package:messages_serializer/messages_serializer.dart';

class MessageShrinker {
Expand Down
2 changes: 0 additions & 2 deletions pkgs/messages_shrinker/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: messages_shrinker
description: A starting point for Dart libraries or applications.
version: 0.1.0
publish_to: none
repository: https://github.com/dart-lang/i18n/pkgs/messages_shrinker

environment:
Expand All @@ -19,5 +18,4 @@ dependencies:

dev_dependencies:
dart_flutter_team_lints: ^2.0.0
lints: ^2.0.0
test: ^1.21.0
39 changes: 22 additions & 17 deletions pkgs/messages_shrinker/test/message_shrinker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

@TestOn('vm')
library;

import 'dart:convert';
import 'dart:io';

import 'package:build/build.dart';
import 'package:messages/package_intl_object.dart';
import 'package:messages_builder/arb_parser.dart';
import 'package:messages_deserializer/messages_deserializer_json.dart';
import 'package:messages_deserializer/messages_deserializer.dart';
import 'package:messages_serializer/messages_serializer.dart';
import 'package:messages_shrinker/messages_shrinker.dart';
import 'package:test/test.dart';
Expand Down Expand Up @@ -37,23 +40,25 @@ void main() {
final generateStringAtIndex = deserialize.generateStringAtIndex(1, args);
expect(generateStringAtIndex, getMessage(messageIndex, args));
});
test(
'Shrink a json with const from file',
() {
final outputFile = '/tmp/shrunkFile.json';
MessageShrinker().shrink(
dataFile,
'test/const_files.json',
outputFile,
);

test('Shrink a json with const from file', () {
final outputFile = '/tmp/shrunkFile.json';
MessageShrinker().shrink(
dataFile,
'test/const_files.json',
outputFile,
);

final dataFileContentsShrunk = File(outputFile).readAsStringSync();
expect(dataFileContentsShrunk.length, lessThan(dataFileContents.length));
final deserialize =
JsonDeserializer(dataFileContentsShrunk).deserialize(intl);
final args = [2];
final generateStringAtIndex = deserialize.generateStringAtIndex(1, args);
expect(generateStringAtIndex, getMessage(1, args));
});
final dataFileContentsShrunk = File(outputFile).readAsStringSync();
expect(dataFileContentsShrunk.length, lessThan(dataFileContents.length));
final deserialize =
JsonDeserializer(dataFileContentsShrunk).deserialize(intl);
final args = [2];
final generateStringAtIndex = deserialize.generateStringAtIndex(1, args);
expect(generateStringAtIndex, getMessage(1, args));
},
);
}

String readArbFileToDataFile() {
Expand Down

0 comments on commit f02f748

Please sign in to comment.