From 21891c3be407450e57081855647fb243a1278385 Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Tue, 24 Jan 2017 17:37:54 -0800 Subject: [PATCH 01/40] Provide initial project structure --- pkgs/platform/.analysis_options | 67 +++++++++++++++++++++++++++++++++ pkgs/platform/.gitignore | 16 ++++++++ pkgs/platform/AUTHORS | 6 +++ pkgs/platform/CHANGELOG.md | 3 ++ pkgs/platform/CONTRIBUTING.md | 24 ++++++++++++ pkgs/platform/LICENSE | 26 +++++++++++++ pkgs/platform/README.md | 13 +++++++ pkgs/platform/dev/setup.sh | 6 +++ pkgs/platform/dev/travis.sh | 30 +++++++++++++++ pkgs/platform/pubspec.yaml | 12 ++++++ 10 files changed, 203 insertions(+) create mode 100644 pkgs/platform/.analysis_options create mode 100644 pkgs/platform/.gitignore create mode 100644 pkgs/platform/AUTHORS create mode 100644 pkgs/platform/CHANGELOG.md create mode 100644 pkgs/platform/CONTRIBUTING.md create mode 100644 pkgs/platform/LICENSE create mode 100644 pkgs/platform/README.md create mode 100755 pkgs/platform/dev/setup.sh create mode 100755 pkgs/platform/dev/travis.sh create mode 100644 pkgs/platform/pubspec.yaml diff --git a/pkgs/platform/.analysis_options b/pkgs/platform/.analysis_options new file mode 100644 index 00000000..9f8e801f --- /dev/null +++ b/pkgs/platform/.analysis_options @@ -0,0 +1,67 @@ +analyzer: + language: + enableStrictCallChecks: true + enableSuperMixins: true + strong-mode: true + errors: + # Allow having TODOs in the code + todo: ignore + +linter: + rules: + # these rules are documented on and in the same order as + # the Dart Lint rules page to make maintenance easier + # http://dart-lang.github.io/linter/lints/ + + # === error rules === + - avoid_empty_else + - comment_references + - cancel_subscriptions + - close_sinks + - control_flow_in_finally + - empty_statements + - hash_and_equals + - invariant_booleans + - iterable_contains_unrelated_type + - list_remove_unrelated_type + - literal_only_boolean_expressions + - test_types_in_equals + - throw_in_finally + - unrelated_type_equality_checks + - valid_regexps + + # === style rules === + - always_declare_return_types + - always_specify_types + - annotate_overrides + - avoid_as + - avoid_init_to_null + - avoid_return_types_on_setters + - await_only_futures + - camel_case_types + - constant_identifier_names + - control_flow_in_finally + - empty_constructor_bodies + - implementation_imports + - library_names + - library_prefixes + - non_constant_identifier_names + - one_member_abstracts + - only_throw_errors + - overridden_fields + - package_api_docs + - package_prefixed_library_names + - prefer_is_not_empty + - public_member_api_docs + - slash_for_doc_comments + - sort_constructors_first + - sort_unnamed_constructors_first + - super_goes_last + - type_annotate_public_apis + - type_init_formals + - unawaited_futures + - unnecessary_brace_in_string_interp + - unnecessary_getters_setters + + # === pub rules === + - package_names diff --git a/pkgs/platform/.gitignore b/pkgs/platform/.gitignore new file mode 100644 index 00000000..5a472d63 --- /dev/null +++ b/pkgs/platform/.gitignore @@ -0,0 +1,16 @@ +### Dart template +# Don’t commit the following directories created by pub. +.buildlog +.pub/ +build/ +packages +.packages + +# Include when developing application packages. +pubspec.lock + +# IDE +.project +.settings +.idea +.c9 diff --git a/pkgs/platform/AUTHORS b/pkgs/platform/AUTHORS new file mode 100644 index 00000000..ad59f118 --- /dev/null +++ b/pkgs/platform/AUTHORS @@ -0,0 +1,6 @@ +# Below is a list of people and organizations that have contributed +# to the Process project. Names should be added to the list like so: +# +# Name/Organization + +Google Inc. diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md new file mode 100644 index 00000000..d26bcddc --- /dev/null +++ b/pkgs/platform/CHANGELOG.md @@ -0,0 +1,3 @@ +#### 1.0.0 + +* Initial version diff --git a/pkgs/platform/CONTRIBUTING.md b/pkgs/platform/CONTRIBUTING.md new file mode 100644 index 00000000..0786fdf4 --- /dev/null +++ b/pkgs/platform/CONTRIBUTING.md @@ -0,0 +1,24 @@ +# How to contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement. You (or your employer) retain the copyright to your contribution, +this simply gives us permission to use and redistribute your contributions as +part of the project. Head over to to see +your current agreements on file or to sign a new one. + +You generally only need to submit a CLA once, so if you've already submitted one +(even if it was for a different project), you probably don't need to do it +again. + +## Code reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult [GitHub Help] for more +information on using pull requests. + +[GitHub Help]: https://help.github.com/articles/about-pull-requests/ diff --git a/pkgs/platform/LICENSE b/pkgs/platform/LICENSE new file mode 100644 index 00000000..389ce985 --- /dev/null +++ b/pkgs/platform/LICENSE @@ -0,0 +1,26 @@ +Copyright 2017, the Dart project authors. All rights reserved. +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 Inc. 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. diff --git a/pkgs/platform/README.md b/pkgs/platform/README.md new file mode 100644 index 00000000..b01d741f --- /dev/null +++ b/pkgs/platform/README.md @@ -0,0 +1,13 @@ +# Platform + +[![Build Status -](https://travis-ci.org/tvolkert/platform.svg?branch=master)](https://travis-ci.org/tvolkert/platform) +[![Coverage Status -](https://coveralls.io/repos/github/tvolkert/platform/badge.svg?branch=master)](https://coveralls.io/github/tvolkert/platform?branch=master) + +A generic platform abstraction for Dart. + +Like `dart:io`, `package:platform` supplies a rich, Dart-idiomatic API for +accessing platform-specific information. + +`package:platform` provides a lightweight wrapper around the static `Platform` +properties that exist in `dart:io`. However, it uses instance properties rather +than static properties, making it possible to mock out in tests. diff --git a/pkgs/platform/dev/setup.sh b/pkgs/platform/dev/setup.sh new file mode 100755 index 00000000..99ec2843 --- /dev/null +++ b/pkgs/platform/dev/setup.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +# 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. + +pub upgrade diff --git a/pkgs/platform/dev/travis.sh b/pkgs/platform/dev/travis.sh new file mode 100755 index 00000000..866b361a --- /dev/null +++ b/pkgs/platform/dev/travis.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +# 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. + +# Make sure dartfmt is run on everything +echo "Checking dartfmt..." +needs_dartfmt="$(dartfmt -n lib test dev)" +if [[ -n "$needs_dartfmt" ]]; then + echo "FAILED" + echo "$needs_dartfmt" + exit 1 +fi +echo "PASSED" + +# Make sure we pass the analyzer +echo "Checking dartanalyzer..." +fails_analyzer="$(find lib test dev -name "*.dart" | xargs dartanalyzer --options .analysis_options)" +if [[ "$fails_analyzer" == *"[error]"* ]]; then + echo "FAILED" + echo "$fails_analyzer" + exit 1 +fi +echo "PASSED" + +# Fast fail the script on failures. +set -e + +# Run the tests. +pub run test diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml new file mode 100644 index 00000000..0c955961 --- /dev/null +++ b/pkgs/platform/pubspec.yaml @@ -0,0 +1,12 @@ +name: platform +version: 1.0.0 +authors: +- Todd Volkert +description: A pluggable, mockable platform abstraction for Dart. +homepage: https://github.com/tvolkert/platform + +dev_dependencies: + test: ^0.12.10 + +environment: + sdk: '>=1.19.0 <2.0.0' From 9b36c2d34bf8ba61baa4716a44c4cb55f244d113 Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Tue, 24 Jan 2017 20:15:06 -0800 Subject: [PATCH 02/40] Add `Platform` interface files (dart-lang/platform#1) --- pkgs/platform/lib/platform.dart | 6 + .../lib/src/interface/local_platform.dart | 46 ++++++++ pkgs/platform/lib/src/interface/platform.dart | 111 ++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 pkgs/platform/lib/platform.dart create mode 100644 pkgs/platform/lib/src/interface/local_platform.dart create mode 100644 pkgs/platform/lib/src/interface/platform.dart diff --git a/pkgs/platform/lib/platform.dart b/pkgs/platform/lib/platform.dart new file mode 100644 index 00000000..c4eca7c3 --- /dev/null +++ b/pkgs/platform/lib/platform.dart @@ -0,0 +1,6 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// 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. + +export 'src/interface/local_platform.dart'; +export 'src/interface/platform.dart'; diff --git a/pkgs/platform/lib/src/interface/local_platform.dart b/pkgs/platform/lib/src/interface/local_platform.dart new file mode 100644 index 00000000..0cd117d9 --- /dev/null +++ b/pkgs/platform/lib/src/interface/local_platform.dart @@ -0,0 +1,46 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// 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 'dart:io' as io show Platform; + +import 'platform.dart'; + +/// `Platform` implementation that delegates directly to `dart:io`. +class LocalPlatform extends Platform { + @override + int get numberOfProcessors => io.Platform.numberOfProcessors; + + @override + String get pathSeparator => io.Platform.pathSeparator; + + @override + String get operatingSystem => io.Platform.operatingSystem; + + @override + String get localHostname => io.Platform.localHostname; + + @override + Map get environment => io.Platform.environment; + + @override + String get executable => io.Platform.executable; + + @override + String get resolvedExecutable => io.Platform.resolvedExecutable; + + @override + Uri get script => io.Platform.script; + + @override + List get executableArguments => io.Platform.executableArguments; + + @override + String get packageRoot => io.Platform.packageRoot; + + @override + String get packageConfig => io.Platform.packageConfig; + + @override + String get version => io.Platform.version; +} diff --git a/pkgs/platform/lib/src/interface/platform.dart b/pkgs/platform/lib/src/interface/platform.dart new file mode 100644 index 00000000..19454d93 --- /dev/null +++ b/pkgs/platform/lib/src/interface/platform.dart @@ -0,0 +1,111 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// 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. + +/// Provides API parity with the `Platform` class in `dart:io`, but using +/// instance properties rather than static properties. This difference enables +/// the use of these APIs in tests, where you can provide mock implementations. +abstract class Platform { + /// The number of processors of the machine. + int get numberOfProcessors; + + /// The path separator used by the operating system to separate + /// components in file paths. + String get pathSeparator; + + /// A string (`linux`, `macos`, `windows`, `android`, `ios`, or `fuchsia`) + /// representing the operating system. + String get operatingSystem; + + /// Get the local hostname for the system. + String get localHostname; + + /// True if the operating system is Linux. + bool get isLinux => (operatingSystem == "linux"); + + /// True if the operating system is OS X. + bool get isMacOS => (operatingSystem == "macos"); + + /// True if the operating system is Windows. + bool get isWindows => (operatingSystem == "windows"); + + /// True if the operating system is Android. + bool get isAndroid => (operatingSystem == "android"); + + /// True if the operating system is iOS. + bool get isIOS => (operatingSystem == "ios"); + + /// True if the operating system is Fuchsia + bool get isFuchsia => (operatingSystem == "fuchsia"); + + /// The environment for this process. + /// + /// The returned environment is an unmodifiable map whose content is + /// retrieved from the operating system on its first use. + /// + /// Environment variables on Windows are case-insensitive. The map + /// returned on Windows is therefore case-insensitive and will convert + /// all keys to upper case. On other platforms the returned map is + /// a standard case-sensitive map. + Map get environment; + + /// The path of the executable used to run the script in this isolate. + /// + /// The path returned is the literal path used to run the script. This + /// path might be relative or just be a name from which the executable + /// was found by searching the `PATH`. + /// + /// To get the absolute path to the resolved executable use + /// [resolvedExecutable]. + String get executable; + + /// The path of the executable used to run the script in this + /// isolate after it has been resolved by the OS. + /// + /// This is the absolute path, with all symlinks resolved, to the + /// executable used to run the script. + String get resolvedExecutable; + + /// The absolute URI of the script being run in this + /// isolate. + /// + /// If the script argument on the command line is relative, + /// it is resolved to an absolute URI before fetching the script, and + /// this absolute URI is returned. + /// + /// URI resolution only does string manipulation on the script path, and this + /// may be different from the file system's path resolution behavior. For + /// example, a symbolic link immediately followed by '..' will not be + /// looked up. + /// + /// If the executable environment does not support [script] an empty + /// [Uri] is returned. + Uri get script; + + /// The flags passed to the executable used to run the script in this + /// isolate. These are the command-line flags between the executable name + /// and the script name. Each fetch of `executableArguments` returns a new + /// list containing the flags passed to the executable. + List get executableArguments; + + /// The value of the `--package-root` flag passed to the executable + /// used to run the script in this isolate. This is the directory in which + /// Dart packages are looked up. + /// + /// If there is no `--package-root` flag, `null` is returned. + String get packageRoot; + + /// The value of the `--packages` flag passed to the executable + /// used to run the script in this isolate. This is the configuration which + /// specifies how Dart packages are looked up. + /// + /// If there is no `--packages` flag, `null` is returned. + String get packageConfig; + + /// The version of the current Dart runtime. + /// + /// The returned `String` is formatted as the [semver](http://semver.org) + /// version string of the current dart runtime, possibly followed by + /// whitespace and other version and build details. + String get version; +} From bbba132aeebb15f1fe6309e93fab204ac0fe946c Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Wed, 25 Jan 2017 12:24:27 -0800 Subject: [PATCH 03/40] Add FakePlatform (dart-lang/platform#2) --- pkgs/platform/lib/platform.dart | 1 + pkgs/platform/lib/src/interface/platform.dart | 20 ++++ .../lib/src/testing/fake_platform.dart | 104 ++++++++++++++++++ pkgs/platform/test/fake_platform_test.dart | 85 ++++++++++++++ pkgs/platform/test/platform.json | 19 ++++ 5 files changed, 229 insertions(+) create mode 100644 pkgs/platform/lib/src/testing/fake_platform.dart create mode 100644 pkgs/platform/test/fake_platform_test.dart create mode 100644 pkgs/platform/test/platform.json diff --git a/pkgs/platform/lib/platform.dart b/pkgs/platform/lib/platform.dart index c4eca7c3..4d74f32e 100644 --- a/pkgs/platform/lib/platform.dart +++ b/pkgs/platform/lib/platform.dart @@ -4,3 +4,4 @@ export 'src/interface/local_platform.dart'; export 'src/interface/platform.dart'; +export 'src/testing/fake_platform.dart'; diff --git a/pkgs/platform/lib/src/interface/platform.dart b/pkgs/platform/lib/src/interface/platform.dart index 19454d93..f0d5ca75 100644 --- a/pkgs/platform/lib/src/interface/platform.dart +++ b/pkgs/platform/lib/src/interface/platform.dart @@ -2,6 +2,8 @@ // 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 'dart:convert'; + /// Provides API parity with the `Platform` class in `dart:io`, but using /// instance properties rather than static properties. This difference enables /// the use of these APIs in tests, where you can provide mock implementations. @@ -108,4 +110,22 @@ abstract class Platform { /// version string of the current dart runtime, possibly followed by /// whitespace and other version and build details. String get version; + + /// Returns a JSON-encoded representation of this platform. + String toJson() { + return const JsonEncoder.withIndent(' ').convert({ + 'numberOfProcessors': numberOfProcessors, + 'pathSeparator': pathSeparator, + 'operatingSystem': operatingSystem, + 'localHostname': localHostname, + 'environment': environment, + 'executable': executable, + 'resolvedExecutable': resolvedExecutable, + 'script': script.toString(), + 'executableArguments': executableArguments, + 'packageRoot': packageRoot, + 'packageConfig': packageConfig, + 'version': version, + }); + } } diff --git a/pkgs/platform/lib/src/testing/fake_platform.dart b/pkgs/platform/lib/src/testing/fake_platform.dart new file mode 100644 index 00000000..6256d140 --- /dev/null +++ b/pkgs/platform/lib/src/testing/fake_platform.dart @@ -0,0 +1,104 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// 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 'dart:convert'; + +import '../interface/platform.dart'; + +/// Provides a mutable implementation of the [Platform] interface. +class FakePlatform extends Platform { + /// Creates a new [FakePlatform] with the specified properties. + /// + /// Unspecified properties will *not* be assigned default values (they will + /// remain `null`). + FakePlatform({ + this.numberOfProcessors, + this.pathSeparator, + this.operatingSystem, + this.localHostname, + this.environment, + this.executable, + this.resolvedExecutable, + this.script, + this.executableArguments, + this.packageRoot, + this.packageConfig, + this.version, + }); + + /// Creates a new [FakePlatform] with properties whose initial values mirror + /// the specified [platform]. + FakePlatform.fromPlatform(Platform platform) + : numberOfProcessors = platform.numberOfProcessors, + pathSeparator = platform.pathSeparator, + operatingSystem = platform.operatingSystem, + localHostname = platform.localHostname, + environment = new Map.from(platform.environment), + executable = platform.executable, + resolvedExecutable = platform.resolvedExecutable, + script = platform.script, + executableArguments = new List.from(platform.executableArguments), + packageRoot = platform.packageRoot, + packageConfig = platform.packageConfig, + version = platform.version; + + /// Creates a new [FakePlatform] with properties extracted from the encoded + /// JSON string. + /// + /// [json] must be a JSON string that matches the encoding produced by + /// [toJson]. + factory FakePlatform.fromJson(String json) { + Map map = new JsonDecoder().convert(json); + return new FakePlatform( + numberOfProcessors: map['numberOfProcessors'], + pathSeparator : map['pathSeparator'], + operatingSystem : map['operatingSystem'], + localHostname : map['localHostname'], + environment : map['environment'], + executable : map['executable'], + resolvedExecutable : map['resolvedExecutable'], + script : Uri.parse(map['script']), + executableArguments : map['executableArguments'], + packageRoot : map['packageRoot'], + packageConfig : map['packageConfig'], + version : map['version'], + ); + } + + @override + int numberOfProcessors; + + @override + String pathSeparator; + + @override + String operatingSystem; + + @override + String localHostname; + + @override + Map environment; + + @override + String executable; + + @override + String resolvedExecutable; + + @override + Uri script; + + @override + List executableArguments; + + @override + String packageRoot; + + @override + String packageConfig; + + @override + String version; +} diff --git a/pkgs/platform/test/fake_platform_test.dart b/pkgs/platform/test/fake_platform_test.dart new file mode 100644 index 00000000..5699c6b9 --- /dev/null +++ b/pkgs/platform/test/fake_platform_test.dart @@ -0,0 +1,85 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// 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 'dart:io' as io; + +import 'package:platform/platform.dart'; +import 'package:test/test.dart'; + +void _expectPlatformsEqual(Platform actual, Platform expected) { + expect(actual.numberOfProcessors, expected.numberOfProcessors); + expect(actual.pathSeparator, expected.pathSeparator); + expect(actual.operatingSystem, expected.operatingSystem); + expect(actual.localHostname, expected.localHostname); + expect(actual.environment, expected.environment); + expect(actual.executable, expected.executable); + expect(actual.resolvedExecutable, expected.resolvedExecutable); + expect(actual.script, expected.script); + expect(actual.executableArguments, expected.executableArguments); + expect(actual.packageRoot, expected.packageRoot); + expect(actual.packageConfig, expected.packageConfig); + expect(actual.version, expected.version); +} + +void main() { + group('FakePlatform', () { + FakePlatform fake; + LocalPlatform local; + + setUp(() { + fake = new FakePlatform(); + local = new LocalPlatform(); + }); + + group('fromPlatform', () { + setUp(() { + fake = new FakePlatform.fromPlatform(local); + }); + + test('copiesAllProperties', () { + _expectPlatformsEqual(fake, local); + }); + + test('convertsPropertiesToMutable', () { + String key = fake.environment.keys.first; + + expect(fake.environment[key], local.environment[key]); + fake.environment[key] = 'FAKE'; + expect(fake.environment[key], 'FAKE'); + + expect(fake.executableArguments.length, + local.executableArguments.length); + fake.executableArguments.add('ARG'); + expect(fake.executableArguments.last, 'ARG'); + }); + }); + + group('json', () { + test('fromJson', () { + String json = new io.File('test/platform.json').readAsStringSync(); + fake = new FakePlatform.fromJson(json); + expect(fake.numberOfProcessors, 8); + expect(fake.pathSeparator, '/'); + expect(fake.operatingSystem, 'macos'); + expect(fake.localHostname, 'platform.test.org'); + expect(fake.environment, { + 'PATH': '/bin', + 'PWD': '/platform', + }); + expect(fake.executable, '/bin/dart'); + expect(fake.resolvedExecutable, '/bin/dart'); + expect(fake.script, new Uri.file('/platform/test/fake_platform_test.dart')); + expect(fake.executableArguments, ['--checked']); + expect(fake.packageRoot, null); + expect(fake.packageConfig, null); + expect(fake.version, '1.22.0'); + }); + + test('fromJsonToJson', () { + fake = new FakePlatform.fromJson(local.toJson()); + _expectPlatformsEqual(fake, local); + }); + }); + }); +} diff --git a/pkgs/platform/test/platform.json b/pkgs/platform/test/platform.json new file mode 100644 index 00000000..df772c6d --- /dev/null +++ b/pkgs/platform/test/platform.json @@ -0,0 +1,19 @@ +{ + "numberOfProcessors": 8, + "pathSeparator": "/", + "operatingSystem": "macos", + "localHostname": "platform.test.org", + "environment": { + "PATH": "/bin", + "PWD": "/platform" + }, + "executable": "/bin/dart", + "resolvedExecutable": "/bin/dart", + "script": "file:///platform/test/fake_platform_test.dart", + "executableArguments": [ + "--checked" + ], + "packageRoot": null, + "packageConfig": null, + "version": "1.22.0" +} \ No newline at end of file From d3fff15a3a0328eede12e9a6e5e55a245f18bc2a Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Wed, 25 Jan 2017 12:57:32 -0800 Subject: [PATCH 04/40] Add const constructors for Platform and LocalPlatform --- pkgs/platform/lib/src/interface/local_platform.dart | 3 +++ pkgs/platform/lib/src/interface/platform.dart | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pkgs/platform/lib/src/interface/local_platform.dart b/pkgs/platform/lib/src/interface/local_platform.dart index 0cd117d9..a0406c35 100644 --- a/pkgs/platform/lib/src/interface/local_platform.dart +++ b/pkgs/platform/lib/src/interface/local_platform.dart @@ -8,6 +8,9 @@ import 'platform.dart'; /// `Platform` implementation that delegates directly to `dart:io`. class LocalPlatform extends Platform { + /// Creates a new [LocalPlatform]. + const LocalPlatform(); + @override int get numberOfProcessors => io.Platform.numberOfProcessors; diff --git a/pkgs/platform/lib/src/interface/platform.dart b/pkgs/platform/lib/src/interface/platform.dart index f0d5ca75..35b111b2 100644 --- a/pkgs/platform/lib/src/interface/platform.dart +++ b/pkgs/platform/lib/src/interface/platform.dart @@ -8,6 +8,9 @@ import 'dart:convert'; /// instance properties rather than static properties. This difference enables /// the use of these APIs in tests, where you can provide mock implementations. abstract class Platform { + /// Creates a new [Platform]. + const Platform(); + /// The number of processors of the machine. int get numberOfProcessors; From 39dc5d5800445267286e3747495bde72cde4212e Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Wed, 25 Jan 2017 12:58:34 -0800 Subject: [PATCH 05/40] 1.0.1 release --- pkgs/platform/CHANGELOG.md | 4 ++++ pkgs/platform/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index d26bcddc..d5f8f48a 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,7 @@ +#### 1.0.1 + +* Added const constructors for `Platform` and `LocalPlatform` + #### 1.0.0 * Initial version diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 0c955961..8d45807d 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,5 +1,5 @@ name: platform -version: 1.0.0 +version: 1.0.1 authors: - Todd Volkert description: A pluggable, mockable platform abstraction for Dart. From 20cebd7efa2bc939b9f07968251571ad05967145 Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Thu, 26 Jan 2017 14:56:20 -0800 Subject: [PATCH 06/40] Add disclaimer --- pkgs/platform/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/platform/README.md b/pkgs/platform/README.md index b01d741f..35f69726 100644 --- a/pkgs/platform/README.md +++ b/pkgs/platform/README.md @@ -11,3 +11,7 @@ accessing platform-specific information. `package:platform` provides a lightweight wrapper around the static `Platform` properties that exist in `dart:io`. However, it uses instance properties rather than static properties, making it possible to mock out in tests. + +### Disclaimer + +This is not an official Google product. From 77cc161ea7f8baeb57b62e03f2a4fe83d2190ecc Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Mon, 13 Feb 2017 09:54:32 -0800 Subject: [PATCH 07/40] Minor doc updates --- pkgs/platform/CHANGELOG.md | 4 ++++ pkgs/platform/README.md | 8 ++------ pkgs/platform/lib/platform.dart | 1 + pkgs/platform/pubspec.yaml | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index d5f8f48a..104fc679 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,7 @@ +#### 1.0.2 + +* Minor doc updates + #### 1.0.1 * Added const constructors for `Platform` and `LocalPlatform` diff --git a/pkgs/platform/README.md b/pkgs/platform/README.md index 35f69726..00f07734 100644 --- a/pkgs/platform/README.md +++ b/pkgs/platform/README.md @@ -1,7 +1,7 @@ # Platform -[![Build Status -](https://travis-ci.org/tvolkert/platform.svg?branch=master)](https://travis-ci.org/tvolkert/platform) -[![Coverage Status -](https://coveralls.io/repos/github/tvolkert/platform/badge.svg?branch=master)](https://coveralls.io/github/tvolkert/platform?branch=master) +[![Build Status -](https://travis-ci.org/google/platform.dart.svg?branch=master)](https://travis-ci.org/google/platform.dart) +[![Coverage Status -](https://coveralls.io/repos/github/google/platform.dart/badge.svg?branch=master)](https://coveralls.io/github/google/platform.dart?branch=master) A generic platform abstraction for Dart. @@ -11,7 +11,3 @@ accessing platform-specific information. `package:platform` provides a lightweight wrapper around the static `Platform` properties that exist in `dart:io`. However, it uses instance properties rather than static properties, making it possible to mock out in tests. - -### Disclaimer - -This is not an official Google product. diff --git a/pkgs/platform/lib/platform.dart b/pkgs/platform/lib/platform.dart index 4d74f32e..27702195 100644 --- a/pkgs/platform/lib/platform.dart +++ b/pkgs/platform/lib/platform.dart @@ -2,6 +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. +/// Core interfaces & classes. export 'src/interface/local_platform.dart'; export 'src/interface/platform.dart'; export 'src/testing/fake_platform.dart'; diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 8d45807d..a5e3575c 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,9 +1,9 @@ name: platform -version: 1.0.1 +version: 1.0.2 authors: - Todd Volkert description: A pluggable, mockable platform abstraction for Dart. -homepage: https://github.com/tvolkert/platform +homepage: https://github.com/google/platform.dart dev_dependencies: test: ^0.12.10 From fb245766cbb543d3138b6be61c66e1040dad836d Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 16 Mar 2017 16:28:39 -0700 Subject: [PATCH 08/40] add ansiSupported (dart-lang/platform#4) * add ansiSupported * review comments --- pkgs/platform/CHANGELOG.md | 5 +++++ pkgs/platform/lib/src/interface/local_platform.dart | 3 +++ pkgs/platform/lib/src/interface/platform.dart | 7 +++++++ pkgs/platform/lib/src/testing/fake_platform.dart | 8 +++++++- pkgs/platform/pubspec.yaml | 4 ++-- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index 104fc679..418f0a05 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,8 @@ +### 1.1.0 + +* Added `ansiSupported` +* Bumped minimum Dart SDK version to 1.23.0-dev.9.0 + #### 1.0.2 * Minor doc updates diff --git a/pkgs/platform/lib/src/interface/local_platform.dart b/pkgs/platform/lib/src/interface/local_platform.dart index a0406c35..178c683c 100644 --- a/pkgs/platform/lib/src/interface/local_platform.dart +++ b/pkgs/platform/lib/src/interface/local_platform.dart @@ -46,4 +46,7 @@ class LocalPlatform extends Platform { @override String get version => io.Platform.version; + + @override + bool get ansiSupported => io.Platform.ansiSupported; } diff --git a/pkgs/platform/lib/src/interface/platform.dart b/pkgs/platform/lib/src/interface/platform.dart index 35b111b2..a603e3c8 100644 --- a/pkgs/platform/lib/src/interface/platform.dart +++ b/pkgs/platform/lib/src/interface/platform.dart @@ -114,6 +114,12 @@ abstract class Platform { /// whitespace and other version and build details. String get version; + /// When stdio is connected to a terminal, whether ANSI codes are supported. + /// + /// This value is hard-coded to true, except on Windows where only more recent + /// versions of Windows 10 support the codes. + bool get ansiSupported; + /// Returns a JSON-encoded representation of this platform. String toJson() { return const JsonEncoder.withIndent(' ').convert({ @@ -129,6 +135,7 @@ abstract class Platform { 'packageRoot': packageRoot, 'packageConfig': packageConfig, 'version': version, + 'ansiSupported': ansiSupported, }); } } diff --git a/pkgs/platform/lib/src/testing/fake_platform.dart b/pkgs/platform/lib/src/testing/fake_platform.dart index 6256d140..04df6fe7 100644 --- a/pkgs/platform/lib/src/testing/fake_platform.dart +++ b/pkgs/platform/lib/src/testing/fake_platform.dart @@ -25,6 +25,7 @@ class FakePlatform extends Platform { this.packageRoot, this.packageConfig, this.version, + this.ansiSupported, }); /// Creates a new [FakePlatform] with properties whose initial values mirror @@ -41,7 +42,8 @@ class FakePlatform extends Platform { executableArguments = new List.from(platform.executableArguments), packageRoot = platform.packageRoot, packageConfig = platform.packageConfig, - version = platform.version; + version = platform.version, + ansiSupported = platform.ansiSupported; /// Creates a new [FakePlatform] with properties extracted from the encoded /// JSON string. @@ -63,6 +65,7 @@ class FakePlatform extends Platform { packageRoot : map['packageRoot'], packageConfig : map['packageConfig'], version : map['version'], + ansiSupported: map['ansiSupported'], ); } @@ -101,4 +104,7 @@ class FakePlatform extends Platform { @override String version; + + @override + bool ansiSupported; } diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index a5e3575c..af6d7992 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,5 +1,5 @@ name: platform -version: 1.0.2 +version: 1.1.0 authors: - Todd Volkert description: A pluggable, mockable platform abstraction for Dart. @@ -9,4 +9,4 @@ dev_dependencies: test: ^0.12.10 environment: - sdk: '>=1.19.0 <2.0.0' + sdk: '>=1.23.0-dev.9.0 <2.0.0' From 307f68db60256897fbc3a3566fa0eee1a431ca87 Mon Sep 17 00:00:00 2001 From: Phil Quitslund Date: Tue, 28 Mar 2017 14:04:58 -0700 Subject: [PATCH 09/40] Udpate to new io.stdin.supportsAnsiEscapes. (dart-lang/platform#5) --- pkgs/platform/CHANGELOG.md | 5 +++++ pkgs/platform/lib/src/interface/local_platform.dart | 4 ++-- pkgs/platform/pubspec.yaml | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index 418f0a05..8ec72a79 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,8 @@ +### 1.1.1 + +* Updated `LocalPlatform` to use new `dart.io` API for ansi color support queries +* Bumped minimum Dart SDK version to 1.23.0-dev.10.0 + ### 1.1.0 * Added `ansiSupported` diff --git a/pkgs/platform/lib/src/interface/local_platform.dart b/pkgs/platform/lib/src/interface/local_platform.dart index 178c683c..e9e7bfbb 100644 --- a/pkgs/platform/lib/src/interface/local_platform.dart +++ b/pkgs/platform/lib/src/interface/local_platform.dart @@ -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 'dart:io' as io show Platform; +import 'dart:io' as io show Platform, stdin; import 'platform.dart'; @@ -48,5 +48,5 @@ class LocalPlatform extends Platform { String get version => io.Platform.version; @override - bool get ansiSupported => io.Platform.ansiSupported; + bool get ansiSupported => io.stdin.supportsAnsiEscapes; } diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index af6d7992..ad38383b 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -9,4 +9,4 @@ dev_dependencies: test: ^0.12.10 environment: - sdk: '>=1.23.0-dev.9.0 <2.0.0' + sdk: '>=1.23.0-dev.10.0 <2.0.0' From 6b3e70774573b1cf5ae1b73bccc0fa31662cdf3f Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Tue, 28 Mar 2017 14:14:18 -0700 Subject: [PATCH 10/40] Add .travis.yml (dart-lang/platform#6) --- pkgs/platform/.travis.yml | 16 ++++++++++++ .../lib/src/testing/fake_platform.dart | 25 ++++++++++--------- pkgs/platform/test/fake_platform_test.dart | 7 +++--- 3 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 pkgs/platform/.travis.yml diff --git a/pkgs/platform/.travis.yml b/pkgs/platform/.travis.yml new file mode 100644 index 00000000..83a837cf --- /dev/null +++ b/pkgs/platform/.travis.yml @@ -0,0 +1,16 @@ +language: dart +sudo: false +dart: + - stable + - dev +install: + - gem install coveralls-lcov +before_script: + - ./dev/setup.sh +script: + - ./dev/travis.sh +after_success: + - (coveralls-lcov coverage/lcov.info) +cache: + directories: + - $HOME/.pub-cache diff --git a/pkgs/platform/lib/src/testing/fake_platform.dart b/pkgs/platform/lib/src/testing/fake_platform.dart index 04df6fe7..ceba4cdd 100644 --- a/pkgs/platform/lib/src/testing/fake_platform.dart +++ b/pkgs/platform/lib/src/testing/fake_platform.dart @@ -39,7 +39,8 @@ class FakePlatform extends Platform { executable = platform.executable, resolvedExecutable = platform.resolvedExecutable, script = platform.script, - executableArguments = new List.from(platform.executableArguments), + executableArguments = + new List.from(platform.executableArguments), packageRoot = platform.packageRoot, packageConfig = platform.packageConfig, version = platform.version, @@ -54,17 +55,17 @@ class FakePlatform extends Platform { Map map = new JsonDecoder().convert(json); return new FakePlatform( numberOfProcessors: map['numberOfProcessors'], - pathSeparator : map['pathSeparator'], - operatingSystem : map['operatingSystem'], - localHostname : map['localHostname'], - environment : map['environment'], - executable : map['executable'], - resolvedExecutable : map['resolvedExecutable'], - script : Uri.parse(map['script']), - executableArguments : map['executableArguments'], - packageRoot : map['packageRoot'], - packageConfig : map['packageConfig'], - version : map['version'], + pathSeparator: map['pathSeparator'], + operatingSystem: map['operatingSystem'], + localHostname: map['localHostname'], + environment: map['environment'], + executable: map['executable'], + resolvedExecutable: map['resolvedExecutable'], + script: Uri.parse(map['script']), + executableArguments: map['executableArguments'], + packageRoot: map['packageRoot'], + packageConfig: map['packageConfig'], + version: map['version'], ansiSupported: map['ansiSupported'], ); } diff --git a/pkgs/platform/test/fake_platform_test.dart b/pkgs/platform/test/fake_platform_test.dart index 5699c6b9..c294dd91 100644 --- a/pkgs/platform/test/fake_platform_test.dart +++ b/pkgs/platform/test/fake_platform_test.dart @@ -48,8 +48,8 @@ void main() { fake.environment[key] = 'FAKE'; expect(fake.environment[key], 'FAKE'); - expect(fake.executableArguments.length, - local.executableArguments.length); + expect( + fake.executableArguments.length, local.executableArguments.length); fake.executableArguments.add('ARG'); expect(fake.executableArguments.last, 'ARG'); }); @@ -69,7 +69,8 @@ void main() { }); expect(fake.executable, '/bin/dart'); expect(fake.resolvedExecutable, '/bin/dart'); - expect(fake.script, new Uri.file('/platform/test/fake_platform_test.dart')); + expect(fake.script, + new Uri.file('/platform/test/fake_platform_test.dart')); expect(fake.executableArguments, ['--checked']); expect(fake.packageRoot, null); expect(fake.packageConfig, null); From b3d03d39890523e1f8a86c308baa66da24c91bb3 Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Tue, 28 Mar 2017 14:17:44 -0700 Subject: [PATCH 11/40] Bump version to 1.1.1 (dart-lang/platform#7) --- pkgs/platform/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index ad38383b..74f5564b 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,5 +1,5 @@ name: platform -version: 1.1.0 +version: 1.1.1 authors: - Todd Volkert description: A pluggable, mockable platform abstraction for Dart. From e2c09c9aa661131ed138bcb95f347578bd414343 Mon Sep 17 00:00:00 2001 From: Phil Quitslund Date: Tue, 28 Mar 2017 14:26:27 -0700 Subject: [PATCH 12/40] Add pub shield. (dart-lang/platform#8) --- pkgs/platform/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/platform/README.md b/pkgs/platform/README.md index 00f07734..0487c5c5 100644 --- a/pkgs/platform/README.md +++ b/pkgs/platform/README.md @@ -2,6 +2,7 @@ [![Build Status -](https://travis-ci.org/google/platform.dart.svg?branch=master)](https://travis-ci.org/google/platform.dart) [![Coverage Status -](https://coveralls.io/repos/github/google/platform.dart/badge.svg?branch=master)](https://coveralls.io/github/google/platform.dart?branch=master) +[![Pub](https://img.shields.io/pub/v/platform.svg)](https://pub.dartlang.org/packages/platform) A generic platform abstraction for Dart. From 0e313d6fcbe93ead4c93f23a3154b00263d0b1b2 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Wed, 5 Apr 2017 14:29:25 -0700 Subject: [PATCH 13/40] Added stdinSupportsAnsi and stdinSupportsAnsi (dart-lang/platform#9) --- pkgs/platform/CHANGELOG.md | 4 ++++ .../platform/lib/src/interface/local_platform.dart | 7 +++++-- pkgs/platform/lib/src/interface/platform.dart | 13 +++++++------ pkgs/platform/lib/src/testing/fake_platform.dart | 14 ++++++++++---- pkgs/platform/pubspec.yaml | 2 +- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index 8ec72a79..25d0ae28 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,7 @@ +### 2.0.0 +* Added `stdinSupportsAnsi` and `stdinSupportsAnsi` +* Removed `ansiSupported` + ### 1.1.1 * Updated `LocalPlatform` to use new `dart.io` API for ansi color support queries diff --git a/pkgs/platform/lib/src/interface/local_platform.dart b/pkgs/platform/lib/src/interface/local_platform.dart index e9e7bfbb..c90256a1 100644 --- a/pkgs/platform/lib/src/interface/local_platform.dart +++ b/pkgs/platform/lib/src/interface/local_platform.dart @@ -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 'dart:io' as io show Platform, stdin; +import 'dart:io' as io show Platform, stdin, stdout; import 'platform.dart'; @@ -48,5 +48,8 @@ class LocalPlatform extends Platform { String get version => io.Platform.version; @override - bool get ansiSupported => io.stdin.supportsAnsiEscapes; + bool get stdinSupportsAnsi => io.stdin.supportsAnsiEscapes; + + @override + bool get stdoutSupportsAnsi => io.stdout.supportsAnsiEscapes; } diff --git a/pkgs/platform/lib/src/interface/platform.dart b/pkgs/platform/lib/src/interface/platform.dart index a603e3c8..c7501084 100644 --- a/pkgs/platform/lib/src/interface/platform.dart +++ b/pkgs/platform/lib/src/interface/platform.dart @@ -114,11 +114,11 @@ abstract class Platform { /// whitespace and other version and build details. String get version; - /// When stdio is connected to a terminal, whether ANSI codes are supported. - /// - /// This value is hard-coded to true, except on Windows where only more recent - /// versions of Windows 10 support the codes. - bool get ansiSupported; + /// When stdin is connected to a terminal, whether ANSI codes are supported. + bool get stdinSupportsAnsi; + + /// When stdout is connected to a terminal, whether ANSI codes are supported. + bool get stdoutSupportsAnsi; /// Returns a JSON-encoded representation of this platform. String toJson() { @@ -135,7 +135,8 @@ abstract class Platform { 'packageRoot': packageRoot, 'packageConfig': packageConfig, 'version': version, - 'ansiSupported': ansiSupported, + 'stdinSupportsAnsi': stdinSupportsAnsi, + 'stdoutSupportsAnsi': stdoutSupportsAnsi, }); } } diff --git a/pkgs/platform/lib/src/testing/fake_platform.dart b/pkgs/platform/lib/src/testing/fake_platform.dart index ceba4cdd..16b80927 100644 --- a/pkgs/platform/lib/src/testing/fake_platform.dart +++ b/pkgs/platform/lib/src/testing/fake_platform.dart @@ -25,7 +25,8 @@ class FakePlatform extends Platform { this.packageRoot, this.packageConfig, this.version, - this.ansiSupported, + this.stdinSupportsAnsi, + this.stdoutSupportsAnsi, }); /// Creates a new [FakePlatform] with properties whose initial values mirror @@ -44,7 +45,8 @@ class FakePlatform extends Platform { packageRoot = platform.packageRoot, packageConfig = platform.packageConfig, version = platform.version, - ansiSupported = platform.ansiSupported; + stdinSupportsAnsi = platform.stdinSupportsAnsi, + stdoutSupportsAnsi = platform.stdoutSupportsAnsi; /// Creates a new [FakePlatform] with properties extracted from the encoded /// JSON string. @@ -66,7 +68,8 @@ class FakePlatform extends Platform { packageRoot: map['packageRoot'], packageConfig: map['packageConfig'], version: map['version'], - ansiSupported: map['ansiSupported'], + stdinSupportsAnsi: map['stdinSupportsAnsi'], + stdoutSupportsAnsi: map['stdoutSupportsAnsi'], ); } @@ -107,5 +110,8 @@ class FakePlatform extends Platform { String version; @override - bool ansiSupported; + bool stdinSupportsAnsi; + + @override + bool stdoutSupportsAnsi; } diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 74f5564b..ab7c8e94 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,5 +1,5 @@ name: platform -version: 1.1.1 +version: 2.0.0 authors: - Todd Volkert description: A pluggable, mockable platform abstraction for Dart. From 0af81be960237b515e92b0eb27e1baafbd2907bc Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Fri, 19 May 2017 09:22:45 -0700 Subject: [PATCH 14/40] Add (dart-lang/platform#12) --- pkgs/platform/CHANGELOG.md | 6 ++++++ pkgs/platform/lib/src/interface/local_platform.dart | 3 +++ pkgs/platform/lib/src/interface/platform.dart | 4 ++++ pkgs/platform/lib/src/testing/fake_platform.dart | 8 +++++++- pkgs/platform/pubspec.yaml | 4 ++-- pkgs/platform/test/fake_platform_test.dart | 2 ++ pkgs/platform/test/platform.json | 3 ++- 7 files changed, 26 insertions(+), 4 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index 25d0ae28..42ce77f6 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,4 +1,10 @@ +### 2.1.0 + +* Added `localeName` +* Bumped minimum Dart SDK version to 1.24.0-dev.0.0 + ### 2.0.0 + * Added `stdinSupportsAnsi` and `stdinSupportsAnsi` * Removed `ansiSupported` diff --git a/pkgs/platform/lib/src/interface/local_platform.dart b/pkgs/platform/lib/src/interface/local_platform.dart index c90256a1..27c18713 100644 --- a/pkgs/platform/lib/src/interface/local_platform.dart +++ b/pkgs/platform/lib/src/interface/local_platform.dart @@ -52,4 +52,7 @@ class LocalPlatform extends Platform { @override bool get stdoutSupportsAnsi => io.stdout.supportsAnsiEscapes; + + @override + String get localeName => io.Platform.localeName; } diff --git a/pkgs/platform/lib/src/interface/platform.dart b/pkgs/platform/lib/src/interface/platform.dart index c7501084..1ebc5a96 100644 --- a/pkgs/platform/lib/src/interface/platform.dart +++ b/pkgs/platform/lib/src/interface/platform.dart @@ -120,6 +120,9 @@ abstract class Platform { /// When stdout is connected to a terminal, whether ANSI codes are supported. bool get stdoutSupportsAnsi; + /// Get the name of the current locale. + String get localeName; + /// Returns a JSON-encoded representation of this platform. String toJson() { return const JsonEncoder.withIndent(' ').convert({ @@ -137,6 +140,7 @@ abstract class Platform { 'version': version, 'stdinSupportsAnsi': stdinSupportsAnsi, 'stdoutSupportsAnsi': stdoutSupportsAnsi, + 'localeName': localeName, }); } } diff --git a/pkgs/platform/lib/src/testing/fake_platform.dart b/pkgs/platform/lib/src/testing/fake_platform.dart index 16b80927..062930d7 100644 --- a/pkgs/platform/lib/src/testing/fake_platform.dart +++ b/pkgs/platform/lib/src/testing/fake_platform.dart @@ -27,6 +27,7 @@ class FakePlatform extends Platform { this.version, this.stdinSupportsAnsi, this.stdoutSupportsAnsi, + this.localeName, }); /// Creates a new [FakePlatform] with properties whose initial values mirror @@ -46,7 +47,8 @@ class FakePlatform extends Platform { packageConfig = platform.packageConfig, version = platform.version, stdinSupportsAnsi = platform.stdinSupportsAnsi, - stdoutSupportsAnsi = platform.stdoutSupportsAnsi; + stdoutSupportsAnsi = platform.stdoutSupportsAnsi, + localeName = platform.localeName; /// Creates a new [FakePlatform] with properties extracted from the encoded /// JSON string. @@ -70,6 +72,7 @@ class FakePlatform extends Platform { version: map['version'], stdinSupportsAnsi: map['stdinSupportsAnsi'], stdoutSupportsAnsi: map['stdoutSupportsAnsi'], + localeName: map['localeName'], ); } @@ -114,4 +117,7 @@ class FakePlatform extends Platform { @override bool stdoutSupportsAnsi; + + @override + String localeName; } diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index ab7c8e94..591da6fc 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,5 +1,5 @@ name: platform -version: 2.0.0 +version: 2.1.0 authors: - Todd Volkert description: A pluggable, mockable platform abstraction for Dart. @@ -9,4 +9,4 @@ dev_dependencies: test: ^0.12.10 environment: - sdk: '>=1.23.0-dev.10.0 <2.0.0' + sdk: '>=1.24.0-dev.0.0 <2.0.0' diff --git a/pkgs/platform/test/fake_platform_test.dart b/pkgs/platform/test/fake_platform_test.dart index c294dd91..1fa7e8fd 100644 --- a/pkgs/platform/test/fake_platform_test.dart +++ b/pkgs/platform/test/fake_platform_test.dart @@ -20,6 +20,7 @@ void _expectPlatformsEqual(Platform actual, Platform expected) { expect(actual.packageRoot, expected.packageRoot); expect(actual.packageConfig, expected.packageConfig); expect(actual.version, expected.version); + expect(actual.localeName, expected.localeName); } void main() { @@ -75,6 +76,7 @@ void main() { expect(fake.packageRoot, null); expect(fake.packageConfig, null); expect(fake.version, '1.22.0'); + expect(fake.localeName, 'de/de'); }); test('fromJsonToJson', () { diff --git a/pkgs/platform/test/platform.json b/pkgs/platform/test/platform.json index df772c6d..a39381c3 100644 --- a/pkgs/platform/test/platform.json +++ b/pkgs/platform/test/platform.json @@ -15,5 +15,6 @@ ], "packageRoot": null, "packageConfig": null, - "version": "1.22.0" + "version": "1.22.0", + "localeName": "de/de" } \ No newline at end of file From 481c456b43cb7efb497b93090344dace0e08ba76 Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Thu, 13 Jul 2017 11:32:20 -0700 Subject: [PATCH 15/40] Bump max Dart SDK version to 2.0.0-dev.infinity (dart-lang/platform#13) --- pkgs/platform/CHANGELOG.md | 4 ++++ pkgs/platform/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index 42ce77f6..3c99300b 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,7 @@ +### 2.1.1 + +* Bumped maximum Dart SDK version to 2.0.0-dev.infinity + ### 2.1.0 * Added `localeName` diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 591da6fc..f12e9f14 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,5 +1,5 @@ name: platform -version: 2.1.0 +version: 2.1.1 authors: - Todd Volkert description: A pluggable, mockable platform abstraction for Dart. @@ -9,4 +9,4 @@ dev_dependencies: test: ^0.12.10 environment: - sdk: '>=1.24.0-dev.0.0 <2.0.0' + sdk: '>=1.24.0-dev.0.0 <2.0.0-dev.infinity ' From 5e5db556b1189aceeab39a8a596c6bdbae482474 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Mon, 12 Feb 2018 10:37:18 -0800 Subject: [PATCH 16/40] Update sdk constraint to <2.0.0. Drop '-dev.infinity' (dart-lang/platform#14) --- pkgs/platform/CHANGELOG.md | 4 ++++ pkgs/platform/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index 3c99300b..a16b3330 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,7 @@ +### 2.1.2 + +* Relax sdk upper bound constraint to '<2.0.0' to allow 'edge' dart sdk use. + ### 2.1.1 * Bumped maximum Dart SDK version to 2.0.0-dev.infinity diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index f12e9f14..a841972d 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,5 +1,5 @@ name: platform -version: 2.1.1 +version: 2.1.2 authors: - Todd Volkert description: A pluggable, mockable platform abstraction for Dart. @@ -9,4 +9,4 @@ dev_dependencies: test: ^0.12.10 environment: - sdk: '>=1.24.0-dev.0.0 <2.0.0-dev.infinity ' + sdk: '>=1.24.0-dev.0.0 <2.0.0' From a12f988d8c71ef5cfa959f8bd76791e5538710e6 Mon Sep 17 00:00:00 2001 From: BC Ko Date: Thu, 24 May 2018 09:19:16 -0700 Subject: [PATCH 17/40] Update .gitignore to new `dart_tool` pub cache (dart-lang/platform#15) Update .gitignore to new `dart_tool` pub cache --- pkgs/platform/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/platform/.gitignore b/pkgs/platform/.gitignore index 5a472d63..dfbf1b43 100644 --- a/pkgs/platform/.gitignore +++ b/pkgs/platform/.gitignore @@ -1,6 +1,7 @@ ### Dart template # Don’t commit the following directories created by pub. .buildlog +.dart_tool/ .pub/ build/ packages From 196213c69ecf2a079a4cefe2157d149cf1127f37 Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Mon, 13 Aug 2018 11:05:22 -0700 Subject: [PATCH 18/40] 2.2.0 release (dart-lang/platform#18) * Update package:test dependency * Declare compatibility with Dart 2 stable * Fix Dart 2 errors --- pkgs/platform/CHANGELOG.md | 5 +++++ pkgs/platform/lib/src/testing/fake_platform.dart | 4 ++-- pkgs/platform/pubspec.yaml | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index a16b3330..a3151330 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,8 @@ +### 2.2.0 + +* Declare compatibility with Dart 2 stable +* Update dependency on `package:test` to 1.0 + ### 2.1.2 * Relax sdk upper bound constraint to '<2.0.0' to allow 'edge' dart sdk use. diff --git a/pkgs/platform/lib/src/testing/fake_platform.dart b/pkgs/platform/lib/src/testing/fake_platform.dart index 062930d7..3626d54c 100644 --- a/pkgs/platform/lib/src/testing/fake_platform.dart +++ b/pkgs/platform/lib/src/testing/fake_platform.dart @@ -62,11 +62,11 @@ class FakePlatform extends Platform { pathSeparator: map['pathSeparator'], operatingSystem: map['operatingSystem'], localHostname: map['localHostname'], - environment: map['environment'], + environment: map['environment'].cast(), executable: map['executable'], resolvedExecutable: map['resolvedExecutable'], script: Uri.parse(map['script']), - executableArguments: map['executableArguments'], + executableArguments: map['executableArguments'].cast(), packageRoot: map['packageRoot'], packageConfig: map['packageConfig'], version: map['version'], diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index a841972d..12090143 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,12 +1,12 @@ name: platform -version: 2.1.2 +version: 2.2.0 authors: - Todd Volkert description: A pluggable, mockable platform abstraction for Dart. homepage: https://github.com/google/platform.dart dev_dependencies: - test: ^0.12.10 + test: ^1.0.0 environment: - sdk: '>=1.24.0-dev.0.0 <2.0.0' + sdk: '>=1.24.0-dev.0.0 <3.0.0' From 4a4774350a38d273decd21585f32e2d4ee6ff93e Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Sun, 28 Jul 2019 21:12:43 -0500 Subject: [PATCH 19/40] Add operatingSystemVersion (dart-lang/platform#19) --- pkgs/platform/lib/src/interface/local_platform.dart | 3 +++ pkgs/platform/lib/src/interface/platform.dart | 4 ++++ pkgs/platform/lib/src/testing/fake_platform.dart | 6 ++++++ pkgs/platform/test/fake_platform_test.dart | 2 ++ pkgs/platform/test/platform.json | 1 + 5 files changed, 16 insertions(+) diff --git a/pkgs/platform/lib/src/interface/local_platform.dart b/pkgs/platform/lib/src/interface/local_platform.dart index 27c18713..20b4bbe2 100644 --- a/pkgs/platform/lib/src/interface/local_platform.dart +++ b/pkgs/platform/lib/src/interface/local_platform.dart @@ -20,6 +20,9 @@ class LocalPlatform extends Platform { @override String get operatingSystem => io.Platform.operatingSystem; + @override + String get operatingSystemVersion => io.Platform.operatingSystemVersion; + @override String get localHostname => io.Platform.localHostname; diff --git a/pkgs/platform/lib/src/interface/platform.dart b/pkgs/platform/lib/src/interface/platform.dart index 1ebc5a96..afc527ac 100644 --- a/pkgs/platform/lib/src/interface/platform.dart +++ b/pkgs/platform/lib/src/interface/platform.dart @@ -22,6 +22,9 @@ abstract class Platform { /// representing the operating system. String get operatingSystem; + /// A string representing the version of the operating system or platform. + String get operatingSystemVersion; + /// Get the local hostname for the system. String get localHostname; @@ -129,6 +132,7 @@ abstract class Platform { 'numberOfProcessors': numberOfProcessors, 'pathSeparator': pathSeparator, 'operatingSystem': operatingSystem, + 'operatingSystemVersion': operatingSystemVersion, 'localHostname': localHostname, 'environment': environment, 'executable': executable, diff --git a/pkgs/platform/lib/src/testing/fake_platform.dart b/pkgs/platform/lib/src/testing/fake_platform.dart index 3626d54c..0d868bd1 100644 --- a/pkgs/platform/lib/src/testing/fake_platform.dart +++ b/pkgs/platform/lib/src/testing/fake_platform.dart @@ -16,6 +16,7 @@ class FakePlatform extends Platform { this.numberOfProcessors, this.pathSeparator, this.operatingSystem, + this.operatingSystemVersion, this.localHostname, this.environment, this.executable, @@ -36,6 +37,7 @@ class FakePlatform extends Platform { : numberOfProcessors = platform.numberOfProcessors, pathSeparator = platform.pathSeparator, operatingSystem = platform.operatingSystem, + operatingSystemVersion = platform.operatingSystemVersion, localHostname = platform.localHostname, environment = new Map.from(platform.environment), executable = platform.executable, @@ -61,6 +63,7 @@ class FakePlatform extends Platform { numberOfProcessors: map['numberOfProcessors'], pathSeparator: map['pathSeparator'], operatingSystem: map['operatingSystem'], + operatingSystemVersion: map['operatingSystemVersion'], localHostname: map['localHostname'], environment: map['environment'].cast(), executable: map['executable'], @@ -85,6 +88,9 @@ class FakePlatform extends Platform { @override String operatingSystem; + @override + String operatingSystemVersion; + @override String localHostname; diff --git a/pkgs/platform/test/fake_platform_test.dart b/pkgs/platform/test/fake_platform_test.dart index 1fa7e8fd..90d8209d 100644 --- a/pkgs/platform/test/fake_platform_test.dart +++ b/pkgs/platform/test/fake_platform_test.dart @@ -11,6 +11,7 @@ void _expectPlatformsEqual(Platform actual, Platform expected) { expect(actual.numberOfProcessors, expected.numberOfProcessors); expect(actual.pathSeparator, expected.pathSeparator); expect(actual.operatingSystem, expected.operatingSystem); + expect(actual.operatingSystemVersion, expected.operatingSystemVersion); expect(actual.localHostname, expected.localHostname); expect(actual.environment, expected.environment); expect(actual.executable, expected.executable); @@ -63,6 +64,7 @@ void main() { expect(fake.numberOfProcessors, 8); expect(fake.pathSeparator, '/'); expect(fake.operatingSystem, 'macos'); + expect(fake.operatingSystemVersion, '10.14.5'); expect(fake.localHostname, 'platform.test.org'); expect(fake.environment, { 'PATH': '/bin', diff --git a/pkgs/platform/test/platform.json b/pkgs/platform/test/platform.json index a39381c3..8fb41eeb 100644 --- a/pkgs/platform/test/platform.json +++ b/pkgs/platform/test/platform.json @@ -2,6 +2,7 @@ "numberOfProcessors": 8, "pathSeparator": "/", "operatingSystem": "macos", + "operatingSystemVersion": "10.14.5", "localHostname": "platform.test.org", "environment": { "PATH": "/bin", From 9d67b0f2116dcb0b5d1db1cc156a69c489b77843 Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Sun, 28 Jul 2019 19:17:02 -0700 Subject: [PATCH 20/40] Bump version (dart-lang/platform#20) --- pkgs/platform/CHANGELOG.md | 4 ++++ pkgs/platform/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index a3151330..e42859a9 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,7 @@ +### 2.2.1 + +* Add `operatingSystemVersion` + ### 2.2.0 * Declare compatibility with Dart 2 stable diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 12090143..1e3c40aa 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,5 +1,5 @@ name: platform -version: 2.2.0 +version: 2.2.1 authors: - Todd Volkert description: A pluggable, mockable platform abstraction for Dart. From becef4b62d1921e974d94c0334f1fc7ea90b1612 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Wed, 29 Jul 2020 16:24:42 -0700 Subject: [PATCH 21/40] [null-safety] migrate platform to null-safe dart (dart-lang/platform#24) Migrate platform to null-safety. Remove stable travis shard since that does not support null safety --- pkgs/platform/.travis.yml | 1 - pkgs/platform/CHANGELOG.md | 4 + ...analysis_options => analysis_options.yaml} | 9 +- pkgs/platform/dev/travis.sh | 4 +- pkgs/platform/lib/platform.dart | 1 + .../lib/src/interface/local_platform.dart | 6 +- pkgs/platform/lib/src/interface/platform.dart | 9 +- .../lib/src/testing/fake_platform.dart | 133 +++++++++++------- pkgs/platform/pubspec.yaml | 6 +- pkgs/platform/test/fake_platform_test.dart | 21 ++- 10 files changed, 126 insertions(+), 68 deletions(-) rename pkgs/platform/{.analysis_options => analysis_options.yaml} (89%) diff --git a/pkgs/platform/.travis.yml b/pkgs/platform/.travis.yml index 83a837cf..5722c5b4 100644 --- a/pkgs/platform/.travis.yml +++ b/pkgs/platform/.travis.yml @@ -1,7 +1,6 @@ language: dart sudo: false dart: - - stable - dev install: - gem install coveralls-lcov diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index e42859a9..a5f2c99e 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,7 @@ +### 3.0.0-nullsafety + +* Migrate package to null-safe dart. + ### 2.2.1 * Add `operatingSystemVersion` diff --git a/pkgs/platform/.analysis_options b/pkgs/platform/analysis_options.yaml similarity index 89% rename from pkgs/platform/.analysis_options rename to pkgs/platform/analysis_options.yaml index 9f8e801f..1b14e091 100644 --- a/pkgs/platform/.analysis_options +++ b/pkgs/platform/analysis_options.yaml @@ -1,8 +1,6 @@ analyzer: - language: - enableStrictCallChecks: true - enableSuperMixins: true - strong-mode: true + enable-experiment: + - non-nullable errors: # Allow having TODOs in the code todo: ignore @@ -40,7 +38,6 @@ linter: - await_only_futures - camel_case_types - constant_identifier_names - - control_flow_in_finally - empty_constructor_bodies - implementation_imports - library_names @@ -56,11 +53,9 @@ linter: - slash_for_doc_comments - sort_constructors_first - sort_unnamed_constructors_first - - super_goes_last - type_annotate_public_apis - type_init_formals - unawaited_futures - - unnecessary_brace_in_string_interp - unnecessary_getters_setters # === pub rules === diff --git a/pkgs/platform/dev/travis.sh b/pkgs/platform/dev/travis.sh index 866b361a..722d4d80 100755 --- a/pkgs/platform/dev/travis.sh +++ b/pkgs/platform/dev/travis.sh @@ -15,7 +15,7 @@ echo "PASSED" # Make sure we pass the analyzer echo "Checking dartanalyzer..." -fails_analyzer="$(find lib test dev -name "*.dart" | xargs dartanalyzer --options .analysis_options)" +fails_analyzer="$(find lib test dev -name "*.dart" | xargs dartanalyzer --options analysis_options.yaml)" if [[ "$fails_analyzer" == *"[error]"* ]]; then echo "FAILED" echo "$fails_analyzer" @@ -27,4 +27,4 @@ echo "PASSED" set -e # Run the tests. -pub run test +pub run --enable-experiment=non-nullable test diff --git a/pkgs/platform/lib/platform.dart b/pkgs/platform/lib/platform.dart index 27702195..8110dd17 100644 --- a/pkgs/platform/lib/platform.dart +++ b/pkgs/platform/lib/platform.dart @@ -2,6 +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. +// @dart=2.10 /// Core interfaces & classes. export 'src/interface/local_platform.dart'; export 'src/interface/platform.dart'; diff --git a/pkgs/platform/lib/src/interface/local_platform.dart b/pkgs/platform/lib/src/interface/local_platform.dart index 20b4bbe2..f0c44bba 100644 --- a/pkgs/platform/lib/src/interface/local_platform.dart +++ b/pkgs/platform/lib/src/interface/local_platform.dart @@ -2,6 +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. +// @dart=2.10 import 'dart:io' as io show Platform, stdin, stdout; import 'platform.dart'; @@ -42,10 +43,11 @@ class LocalPlatform extends Platform { List get executableArguments => io.Platform.executableArguments; @override - String get packageRoot => io.Platform.packageRoot; + String? get packageRoot => + io.Platform.packageRoot; // ignore: deprecated_member_use @override - String get packageConfig => io.Platform.packageConfig; + String? get packageConfig => io.Platform.packageConfig; @override String get version => io.Platform.version; diff --git a/pkgs/platform/lib/src/interface/platform.dart b/pkgs/platform/lib/src/interface/platform.dart index afc527ac..ee7d28ed 100644 --- a/pkgs/platform/lib/src/interface/platform.dart +++ b/pkgs/platform/lib/src/interface/platform.dart @@ -2,6 +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. +// @dart=2.10 import 'dart:convert'; /// Provides API parity with the `Platform` class in `dart:io`, but using @@ -101,14 +102,15 @@ abstract class Platform { /// Dart packages are looked up. /// /// If there is no `--package-root` flag, `null` is returned. - String get packageRoot; + @deprecated + String? get packageRoot; /// The value of the `--packages` flag passed to the executable /// used to run the script in this isolate. This is the configuration which /// specifies how Dart packages are looked up. /// /// If there is no `--packages` flag, `null` is returned. - String get packageConfig; + String? get packageConfig; /// The version of the current Dart runtime. /// @@ -139,7 +141,8 @@ abstract class Platform { 'resolvedExecutable': resolvedExecutable, 'script': script.toString(), 'executableArguments': executableArguments, - 'packageRoot': packageRoot, + 'packageRoot': + packageRoot, // ignore: deprecated_member_use_from_same_package 'packageConfig': packageConfig, 'version': version, 'stdinSupportsAnsi': stdinSupportsAnsi, diff --git a/pkgs/platform/lib/src/testing/fake_platform.dart b/pkgs/platform/lib/src/testing/fake_platform.dart index 0d868bd1..0af10bce 100644 --- a/pkgs/platform/lib/src/testing/fake_platform.dart +++ b/pkgs/platform/lib/src/testing/fake_platform.dart @@ -2,6 +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. +// @dart=2.10 import 'dart:convert'; import '../interface/platform.dart'; @@ -11,46 +12,60 @@ class FakePlatform extends Platform { /// Creates a new [FakePlatform] with the specified properties. /// /// Unspecified properties will *not* be assigned default values (they will - /// remain `null`). + /// remain `null`). If an unset non-null value is read, a [StateError] will + /// be thrown instead of returnin `null`. FakePlatform({ - this.numberOfProcessors, - this.pathSeparator, - this.operatingSystem, - this.operatingSystemVersion, - this.localHostname, - this.environment, - this.executable, - this.resolvedExecutable, - this.script, - this.executableArguments, + int? numberOfProcessors, + String? pathSeparator, + String? operatingSystem, + String? operatingSystemVersion, + String? localHostname, + Map? environment, + String? executable, + String? resolvedExecutable, + Uri? script, + List? executableArguments, this.packageRoot, this.packageConfig, - this.version, - this.stdinSupportsAnsi, - this.stdoutSupportsAnsi, - this.localeName, - }); + String? version, + bool? stdinSupportsAnsi, + bool? stdoutSupportsAnsi, + String? localeName, + }) : _numberOfProcessors = numberOfProcessors, + _pathSeparator = pathSeparator, + _operatingSystem = operatingSystem, + _operatingSystemVersion = operatingSystemVersion, + _localHostname = localHostname, + _environment = environment, + _executable = executable, + _resolvedExecutable = resolvedExecutable, + _script = script, + _executableArguments = executableArguments, + _version = version, + _stdinSupportsAnsi = stdinSupportsAnsi, + _stdoutSupportsAnsi = stdoutSupportsAnsi, + _localeName = localeName; /// Creates a new [FakePlatform] with properties whose initial values mirror /// the specified [platform]. FakePlatform.fromPlatform(Platform platform) - : numberOfProcessors = platform.numberOfProcessors, - pathSeparator = platform.pathSeparator, - operatingSystem = platform.operatingSystem, - operatingSystemVersion = platform.operatingSystemVersion, - localHostname = platform.localHostname, - environment = new Map.from(platform.environment), - executable = platform.executable, - resolvedExecutable = platform.resolvedExecutable, - script = platform.script, - executableArguments = - new List.from(platform.executableArguments), - packageRoot = platform.packageRoot, + : _numberOfProcessors = platform.numberOfProcessors, + _pathSeparator = platform.pathSeparator, + _operatingSystem = platform.operatingSystem, + _operatingSystemVersion = platform.operatingSystemVersion, + _localHostname = platform.localHostname, + _environment = Map.from(platform.environment), + _executable = platform.executable, + _resolvedExecutable = platform.resolvedExecutable, + _script = platform.script, + _executableArguments = List.from(platform.executableArguments), + packageRoot = platform + .packageRoot, // ignore: deprecated_member_use_from_same_package packageConfig = platform.packageConfig, - version = platform.version, - stdinSupportsAnsi = platform.stdinSupportsAnsi, - stdoutSupportsAnsi = platform.stdoutSupportsAnsi, - localeName = platform.localeName; + _version = platform.version, + _stdinSupportsAnsi = platform.stdinSupportsAnsi, + _stdoutSupportsAnsi = platform.stdoutSupportsAnsi, + _localeName = platform.localeName; /// Creates a new [FakePlatform] with properties extracted from the encoded /// JSON string. @@ -80,50 +95,72 @@ class FakePlatform extends Platform { } @override - int numberOfProcessors; + int get numberOfProcessors => _throwIfNull(_numberOfProcessors); + int? _numberOfProcessors; @override - String pathSeparator; + String get pathSeparator => _throwIfNull(_pathSeparator); + String? _pathSeparator; @override - String operatingSystem; + String get operatingSystem => _throwIfNull(_operatingSystem); + String? _operatingSystem; @override - String operatingSystemVersion; + String get operatingSystemVersion => _throwIfNull(_operatingSystemVersion); + String? _operatingSystemVersion; @override - String localHostname; + String get localHostname => _throwIfNull(_localHostname); + String? _localHostname; @override - Map environment; + Map get environment => _throwIfNull(_environment); + Map? _environment; @override - String executable; + String get executable => _throwIfNull(_executable); + String? _executable; @override - String resolvedExecutable; + String get resolvedExecutable => _throwIfNull(_resolvedExecutable); + String? _resolvedExecutable; @override - Uri script; + Uri get script => _throwIfNull(_script); + Uri? _script; @override - List executableArguments; + List get executableArguments => _throwIfNull(_executableArguments); + List? _executableArguments; @override - String packageRoot; + String? packageRoot; @override - String packageConfig; + String? packageConfig; @override - String version; + String get version => _throwIfNull(_version); + String? _version; @override - bool stdinSupportsAnsi; + bool get stdinSupportsAnsi => _throwIfNull(_stdinSupportsAnsi); + bool? _stdinSupportsAnsi; @override - bool stdoutSupportsAnsi; + bool get stdoutSupportsAnsi => _throwIfNull(_stdoutSupportsAnsi); + bool? _stdoutSupportsAnsi; @override - String localeName; + String get localeName => _throwIfNull(_localeName); + String? _localeName; + + T _throwIfNull(T? value) { + if (value == null) { + throw StateError( + 'Tried to read property of FakePlatform but it was unset.'); + } + return value; + } } diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 1e3c40aa..6f22a33b 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,7 +1,5 @@ name: platform -version: 2.2.1 -authors: -- Todd Volkert +version: 3.0.0-nullsafety description: A pluggable, mockable platform abstraction for Dart. homepage: https://github.com/google/platform.dart @@ -9,4 +7,4 @@ dev_dependencies: test: ^1.0.0 environment: - sdk: '>=1.24.0-dev.0.0 <3.0.0' + sdk: '>=2.9.0 <3.0.0' diff --git a/pkgs/platform/test/fake_platform_test.dart b/pkgs/platform/test/fake_platform_test.dart index 90d8209d..0ef8d23b 100644 --- a/pkgs/platform/test/fake_platform_test.dart +++ b/pkgs/platform/test/fake_platform_test.dart @@ -18,7 +18,9 @@ void _expectPlatformsEqual(Platform actual, Platform expected) { expect(actual.resolvedExecutable, expected.resolvedExecutable); expect(actual.script, expected.script); expect(actual.executableArguments, expected.executableArguments); - expect(actual.packageRoot, expected.packageRoot); + expect( + actual.packageRoot, // ignore: deprecated_member_use_from_same_package + expected.packageRoot); // ignore: deprecated_member_use_from_same_package expect(actual.packageConfig, expected.packageConfig); expect(actual.version, expected.version); expect(actual.localeName, expected.localeName); @@ -87,4 +89,21 @@ void main() { }); }); }); + + test('Throws when unset non-null values are read', () { + final FakePlatform platform = FakePlatform(); + + expect(() => platform.numberOfProcessors, throwsA(isStateError)); + expect(() => platform.pathSeparator, throwsA(isStateError)); + expect(() => platform.operatingSystem, throwsA(isStateError)); + expect(() => platform.operatingSystemVersion, throwsA(isStateError)); + expect(() => platform.localHostname, throwsA(isStateError)); + expect(() => platform.environment, throwsA(isStateError)); + expect(() => platform.executable, throwsA(isStateError)); + expect(() => platform.resolvedExecutable, throwsA(isStateError)); + expect(() => platform.script, throwsA(isStateError)); + expect(() => platform.executableArguments, throwsA(isStateError)); + expect(() => platform.version, throwsA(isStateError)); + expect(() => platform.localeName, throwsA(isStateError)); + }); } From 8c33d8503c588104df3aedcd253201293ff166c0 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 10 Aug 2020 16:56:22 -0700 Subject: [PATCH 22/40] publishable null-safety release (dart-lang/platform#25) publishable null-safety release Co-authored-by: Jacob MacDonald --- pkgs/platform/CHANGELOG.md | 2 +- pkgs/platform/dev/travis.sh | 2 +- pkgs/platform/lib/platform.dart | 1 - pkgs/platform/lib/src/interface/local_platform.dart | 1 - pkgs/platform/lib/src/interface/platform.dart | 1 - pkgs/platform/lib/src/testing/fake_platform.dart | 1 - pkgs/platform/pubspec.yaml | 6 +++--- pkgs/platform/test/fake_platform_test.dart | 4 ++-- 8 files changed, 7 insertions(+), 11 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index a5f2c99e..b0ffdb0d 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,4 +1,4 @@ -### 3.0.0-nullsafety +### 3.0.0-nullsafety.1 * Migrate package to null-safe dart. diff --git a/pkgs/platform/dev/travis.sh b/pkgs/platform/dev/travis.sh index 722d4d80..6f80e56b 100755 --- a/pkgs/platform/dev/travis.sh +++ b/pkgs/platform/dev/travis.sh @@ -27,4 +27,4 @@ echo "PASSED" set -e # Run the tests. -pub run --enable-experiment=non-nullable test +pub run test diff --git a/pkgs/platform/lib/platform.dart b/pkgs/platform/lib/platform.dart index 8110dd17..27702195 100644 --- a/pkgs/platform/lib/platform.dart +++ b/pkgs/platform/lib/platform.dart @@ -2,7 +2,6 @@ // 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. -// @dart=2.10 /// Core interfaces & classes. export 'src/interface/local_platform.dart'; export 'src/interface/platform.dart'; diff --git a/pkgs/platform/lib/src/interface/local_platform.dart b/pkgs/platform/lib/src/interface/local_platform.dart index f0c44bba..c8573bd7 100644 --- a/pkgs/platform/lib/src/interface/local_platform.dart +++ b/pkgs/platform/lib/src/interface/local_platform.dart @@ -2,7 +2,6 @@ // 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. -// @dart=2.10 import 'dart:io' as io show Platform, stdin, stdout; import 'platform.dart'; diff --git a/pkgs/platform/lib/src/interface/platform.dart b/pkgs/platform/lib/src/interface/platform.dart index ee7d28ed..82c8bfe2 100644 --- a/pkgs/platform/lib/src/interface/platform.dart +++ b/pkgs/platform/lib/src/interface/platform.dart @@ -2,7 +2,6 @@ // 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. -// @dart=2.10 import 'dart:convert'; /// Provides API parity with the `Platform` class in `dart:io`, but using diff --git a/pkgs/platform/lib/src/testing/fake_platform.dart b/pkgs/platform/lib/src/testing/fake_platform.dart index 0af10bce..d28d0591 100644 --- a/pkgs/platform/lib/src/testing/fake_platform.dart +++ b/pkgs/platform/lib/src/testing/fake_platform.dart @@ -2,7 +2,6 @@ // 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. -// @dart=2.10 import 'dart:convert'; import '../interface/platform.dart'; diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 6f22a33b..0cc5ec67 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,10 +1,10 @@ name: platform -version: 3.0.0-nullsafety +version: 3.0.0-nullsafety.1 description: A pluggable, mockable platform abstraction for Dart. homepage: https://github.com/google/platform.dart dev_dependencies: - test: ^1.0.0 + test: ^1.16.0-nullsafety.1 environment: - sdk: '>=2.9.0 <3.0.0' + sdk: '>=2.10.0-4.0.dev <2.10.0' diff --git a/pkgs/platform/test/fake_platform_test.dart b/pkgs/platform/test/fake_platform_test.dart index 0ef8d23b..7dc28ec9 100644 --- a/pkgs/platform/test/fake_platform_test.dart +++ b/pkgs/platform/test/fake_platform_test.dart @@ -28,8 +28,8 @@ void _expectPlatformsEqual(Platform actual, Platform expected) { void main() { group('FakePlatform', () { - FakePlatform fake; - LocalPlatform local; + late FakePlatform fake; + late LocalPlatform local; setUp(() { fake = new FakePlatform(); From c857e30390971ae97b5f53c78162a87fd3a985b6 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Tue, 22 Sep 2020 13:41:37 -0700 Subject: [PATCH 23/40] update sdk contraint for 2.11 (dart-lang/platform#26) * update sdk contraint for 2.11 --- pkgs/platform/CHANGELOG.md | 4 ++++ pkgs/platform/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index b0ffdb0d..0997a122 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,7 @@ +### 3.0.0-nullsafety.2 + +* Update supported SDK range. + ### 3.0.0-nullsafety.1 * Migrate package to null-safe dart. diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 0cc5ec67..1f761a5e 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,5 +1,5 @@ name: platform -version: 3.0.0-nullsafety.1 +version: 3.0.0-nullsafety.2 description: A pluggable, mockable platform abstraction for Dart. homepage: https://github.com/google/platform.dart @@ -7,4 +7,4 @@ dev_dependencies: test: ^1.16.0-nullsafety.1 environment: - sdk: '>=2.10.0-4.0.dev <2.10.0' + sdk: '>=2.10.0-0.0 <2.11.0' From 2214b7ae9c44488b7007048302bbfaa73739e176 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 22 Oct 2020 10:05:18 -0700 Subject: [PATCH 24/40] updaet SDK constraint for null safety (dart-lang/platform#27) --- pkgs/platform/CHANGELOG.md | 4 ++++ pkgs/platform/pubspec.yaml | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index 0997a122..2980e251 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,7 @@ +### 3.0.0-nullsafety.3 + +* Update supported SDK range. + ### 3.0.0-nullsafety.2 * Update supported SDK range. diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 1f761a5e..4b5d08f1 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,10 +1,10 @@ name: platform -version: 3.0.0-nullsafety.2 +version: 3.0.0-nullsafety.3 description: A pluggable, mockable platform abstraction for Dart. homepage: https://github.com/google/platform.dart +environment: + sdk: '>=2.10.0-0.0 <2.12.0' + dev_dependencies: test: ^1.16.0-nullsafety.1 - -environment: - sdk: '>=2.10.0-0.0 <2.11.0' From 27031e6b2f32b51424f9c773f9d5744af37f222c Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Wed, 4 Nov 2020 10:29:23 -0800 Subject: [PATCH 25/40] Update for beta release (dart-lang/platform#28) --- pkgs/platform/CHANGELOG.md | 4 ++++ pkgs/platform/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index 2980e251..7d6b6fb1 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,7 @@ +### 3.0.0-nullsafety.4 + +* Update supported SDK range. + ### 3.0.0-nullsafety.3 * Update supported SDK range. diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 4b5d08f1..484dd2d5 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,10 +1,10 @@ name: platform -version: 3.0.0-nullsafety.3 +version: 3.0.0-nullsafety.4 description: A pluggable, mockable platform abstraction for Dart. homepage: https://github.com/google/platform.dart environment: - sdk: '>=2.10.0-0.0 <2.12.0' + sdk: '>=2.12.0-0 <3.0.0' dev_dependencies: test: ^1.16.0-nullsafety.1 From 17c8306b6c69a732ef9e020fe8cce13c2a953a3f Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Wed, 3 Feb 2021 09:43:48 -0800 Subject: [PATCH 26/40] stable release for null safety (dart-lang/platform#29) --- pkgs/platform/CHANGELOG.md | 4 ++++ pkgs/platform/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index 7d6b6fb1..558aeb13 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,7 @@ +### 3.0.0 + +* First stable null safe release. + ### 3.0.0-nullsafety.4 * Update supported SDK range. diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 484dd2d5..54803974 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,5 +1,5 @@ name: platform -version: 3.0.0-nullsafety.4 +version: 3.0.0 description: A pluggable, mockable platform abstraction for Dart. homepage: https://github.com/google/platform.dart From 2cf2ae9ee8fe96fdf27138b79ff89dc34c0564b2 Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Thu, 1 Apr 2021 21:28:39 -0700 Subject: [PATCH 27/40] Add OS constants for use in switch statements (dart-lang/platform#30) --- pkgs/platform/CHANGELOG.md | 5 ++ pkgs/platform/lib/src/interface/platform.dart | 75 +++++++++++++++++-- pkgs/platform/pubspec.yaml | 4 +- 3 files changed, 76 insertions(+), 8 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index 558aeb13..664defd8 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,8 @@ +### 3.0.1 + +* Added string constants for each of the supported platforms for use in switch + statements. + ### 3.0.0 * First stable null safe release. diff --git a/pkgs/platform/lib/src/interface/platform.dart b/pkgs/platform/lib/src/interface/platform.dart index 82c8bfe2..7f9262fa 100644 --- a/pkgs/platform/lib/src/interface/platform.dart +++ b/pkgs/platform/lib/src/interface/platform.dart @@ -11,6 +11,64 @@ abstract class Platform { /// Creates a new [Platform]. const Platform(); + /// A string constant to compare with [operatingSystem] to see if the platform + /// is Linux. + /// + /// Useful in case statements when switching on [operatingSystem]. + /// + /// To just check if the platform is Linux, use [isLinux]. + static const String linux = 'linux'; + + /// A string constant to compare with [operatingSystem] to see if the platform + /// is Windows. + /// + /// Useful in case statements when switching on [operatingSystem]. + /// + /// To just check if the platform is Windows, use [isWindows]. + static const String windows = 'windows'; + + /// A string constant to compare with [operatingSystem] to see if the platform + /// is macOS. + /// + /// Useful in case statements when switching on [operatingSystem]. + /// + /// To just check if the platform is macOS, use [isMacOS]. + static const String macOS = 'macos'; + + /// A string constant to compare with [operatingSystem] to see if the platform + /// is Android. + /// + /// Useful in case statements when switching on [operatingSystem]. + /// + /// To just check if the platform is Android, use [isAndroid]. + static const String android = 'android'; + + /// A string constant to compare with [operatingSystem] to see if the platform + /// is iOS. + /// + /// Useful in case statements when switching on [operatingSystem]. + /// + /// To just check if the platform is iOS, use [isIOS]. + static const String iOS = 'ios'; + + /// A string constant to compare with [operatingSystem] to see if the platform + /// is Fuchsia. + /// + /// Useful in case statements when switching on [operatingSystem]. + /// + /// To just check if the platform is Fuchsia, use [isFuchsia]. + static const String fuchsia = 'fuchsia'; + + /// A list of the possible values that [operatingSystem] can return. + static const List operatingSystemValues = [ + linux, + macOS, + windows, + android, + iOS, + fuchsia, + ]; + /// The number of processors of the machine. int get numberOfProcessors; @@ -20,6 +78,11 @@ abstract class Platform { /// A string (`linux`, `macos`, `windows`, `android`, `ios`, or `fuchsia`) /// representing the operating system. + /// + /// The possible return values are available from [operatingSystemValues], and + /// there are constants for each of the platforms to use in switch statements + /// or conditionals (See [linux], [macOS], [windows], [android], [iOS], and + /// [fuchsia]). String get operatingSystem; /// A string representing the version of the operating system or platform. @@ -29,22 +92,22 @@ abstract class Platform { String get localHostname; /// True if the operating system is Linux. - bool get isLinux => (operatingSystem == "linux"); + bool get isLinux => operatingSystem == linux; /// True if the operating system is OS X. - bool get isMacOS => (operatingSystem == "macos"); + bool get isMacOS => operatingSystem == macOS; /// True if the operating system is Windows. - bool get isWindows => (operatingSystem == "windows"); + bool get isWindows => operatingSystem == windows; /// True if the operating system is Android. - bool get isAndroid => (operatingSystem == "android"); + bool get isAndroid => operatingSystem == android; /// True if the operating system is iOS. - bool get isIOS => (operatingSystem == "ios"); + bool get isIOS => operatingSystem == iOS; /// True if the operating system is Fuchsia - bool get isFuchsia => (operatingSystem == "fuchsia"); + bool get isFuchsia => operatingSystem == fuchsia; /// The environment for this process. /// diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 54803974..480f98e9 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,5 +1,5 @@ name: platform -version: 3.0.0 +version: 3.0.1 description: A pluggable, mockable platform abstraction for Dart. homepage: https://github.com/google/platform.dart @@ -7,4 +7,4 @@ environment: sdk: '>=2.12.0-0 <3.0.0' dev_dependencies: - test: ^1.16.0-nullsafety.1 + test: ^1.16.8 From 768a096f940590030eff73c81b87306d124e685b Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Mon, 16 Aug 2021 15:54:26 -0700 Subject: [PATCH 28/40] Add FakePlatform.copyWith to allow overriding some values only (dart-lang/platform#33) This adds a copyWith function to FakePlatform so that it is easy to override just one value from another platform. This can cut down a lot on duplicate code in tests, since you can make one template platform, and then just customize bits of it in each test. Also, updated travis.sh to work with "dart format" instead of "dartfmt", and bumped the version number. --- pkgs/platform/CHANGELOG.md | 4 ++ pkgs/platform/dev/travis.sh | 6 +- .../lib/src/testing/fake_platform.dart | 40 ++++++++++++ pkgs/platform/pubspec.yaml | 2 +- pkgs/platform/test/fake_platform_test.dart | 64 +++++++++++++++++++ 5 files changed, 112 insertions(+), 4 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index 664defd8..bd9140b9 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,7 @@ +### 3.0.2 + +* Added `FakePlatform.copyWith` function. + ### 3.0.1 * Added string constants for each of the supported platforms for use in switch diff --git a/pkgs/platform/dev/travis.sh b/pkgs/platform/dev/travis.sh index 6f80e56b..a805dbdb 100755 --- a/pkgs/platform/dev/travis.sh +++ b/pkgs/platform/dev/travis.sh @@ -4,9 +4,9 @@ # BSD-style license that can be found in the LICENSE file. # Make sure dartfmt is run on everything -echo "Checking dartfmt..." -needs_dartfmt="$(dartfmt -n lib test dev)" -if [[ -n "$needs_dartfmt" ]]; then +echo "Checking dart format..." +needs_dartfmt="$(dart format --set-exit-if-changed --output=none lib test dev)" +if [[ $? != 0 ]]; then echo "FAILED" echo "$needs_dartfmt" exit 1 diff --git a/pkgs/platform/lib/src/testing/fake_platform.dart b/pkgs/platform/lib/src/testing/fake_platform.dart index d28d0591..046dd0ac 100644 --- a/pkgs/platform/lib/src/testing/fake_platform.dart +++ b/pkgs/platform/lib/src/testing/fake_platform.dart @@ -93,6 +93,46 @@ class FakePlatform extends Platform { ); } + /// Creates a new [FakePlatform] from this one, with some properties replaced by the given properties. + FakePlatform copyWith({ + int? numberOfProcessors, + String? pathSeparator, + String? operatingSystem, + String? operatingSystemVersion, + String? localHostname, + Map? environment, + String? executable, + String? resolvedExecutable, + Uri? script, + List? executableArguments, + String? packageRoot, + String? packageConfig, + String? version, + bool? stdinSupportsAnsi, + bool? stdoutSupportsAnsi, + String? localeName, + }) { + return FakePlatform( + numberOfProcessors: numberOfProcessors ?? this.numberOfProcessors, + pathSeparator: pathSeparator ?? this.pathSeparator, + operatingSystem: operatingSystem ?? this.operatingSystem, + operatingSystemVersion: + operatingSystemVersion ?? this.operatingSystemVersion, + localHostname: localHostname ?? this.localHostname, + environment: environment ?? this.environment, + executable: executable ?? this.executable, + resolvedExecutable: resolvedExecutable ?? this.resolvedExecutable, + script: script ?? this.script, + executableArguments: executableArguments ?? this.executableArguments, + packageRoot: packageRoot ?? this.packageRoot, + packageConfig: packageConfig ?? this.packageConfig, + version: version ?? this.version, + stdinSupportsAnsi: stdinSupportsAnsi ?? this.stdinSupportsAnsi, + stdoutSupportsAnsi: stdoutSupportsAnsi ?? this.stdoutSupportsAnsi, + localeName: localeName ?? this.localeName, + ); + } + @override int get numberOfProcessors => _throwIfNull(_numberOfProcessors); int? _numberOfProcessors; diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 480f98e9..de10923c 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,5 +1,5 @@ name: platform -version: 3.0.1 +version: 3.0.2 description: A pluggable, mockable platform abstraction for Dart. homepage: https://github.com/google/platform.dart diff --git a/pkgs/platform/test/fake_platform_test.dart b/pkgs/platform/test/fake_platform_test.dart index 7dc28ec9..3f954b60 100644 --- a/pkgs/platform/test/fake_platform_test.dart +++ b/pkgs/platform/test/fake_platform_test.dart @@ -59,6 +59,70 @@ void main() { }); }); + group('copyWith', () { + setUp(() { + fake = new FakePlatform.fromPlatform(local); + }); + + test('overrides a value, but leaves others intact', () { + FakePlatform copy = fake.copyWith( + numberOfProcessors: -1, + ); + expect(copy.numberOfProcessors, equals(-1)); + expect(copy.pathSeparator, local.pathSeparator); + expect(copy.operatingSystem, local.operatingSystem); + expect(copy.operatingSystemVersion, local.operatingSystemVersion); + expect(copy.localHostname, local.localHostname); + expect(copy.environment, local.environment); + expect(copy.executable, local.executable); + expect(copy.resolvedExecutable, local.resolvedExecutable); + expect(copy.script, local.script); + expect(copy.executableArguments, local.executableArguments); + // ignore: deprecated_member_use_from_same_package + expect(copy.packageRoot, local.packageRoot); + expect(copy.packageConfig, local.packageConfig); + expect(copy.version, local.version); + expect(copy.localeName, local.localeName); + }); + test('can override all values', () { + fake = new FakePlatform( + numberOfProcessors: 8, + pathSeparator: ':', + operatingSystem: 'fake', + operatingSystemVersion: '0.1.0', + localHostname: 'host', + environment: {'PATH': '.'}, + executable: 'executable', + resolvedExecutable: '/executable', + script: new Uri.file('/platform/test/fake_platform_test.dart'), + executableArguments: ['scriptarg'], + version: '0.1.1', + stdinSupportsAnsi: false, + stdoutSupportsAnsi: true, + localeName: 'local', + ); + FakePlatform copy = fake.copyWith( + numberOfProcessors: local.numberOfProcessors, + pathSeparator: local.pathSeparator, + operatingSystem: local.operatingSystem, + operatingSystemVersion: local.operatingSystemVersion, + localHostname: local.localHostname, + environment: local.environment, + executable: local.executable, + resolvedExecutable: local.resolvedExecutable, + script: local.script, + executableArguments: local.executableArguments, + packageRoot: local.packageRoot, + packageConfig: local.packageConfig, + version: local.version, + stdinSupportsAnsi: local.stdinSupportsAnsi, + stdoutSupportsAnsi: local.stdoutSupportsAnsi, + localeName: local.localeName, + ); + _expectPlatformsEqual(copy, local); + }); + }); + group('json', () { test('fromJson', () { String json = new io.File('test/platform.json').readAsStringSync(); From 396db1f975f106fffe4ff7dd80d12bcd84efbd94 Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Mon, 16 Aug 2021 17:25:01 -0700 Subject: [PATCH 29/40] Fix sdk version constraint to no longer be pre-release (dart-lang/platform#34) Fixed the Dart SDK constraint to no longer be a pre-release constraint (i.e. 2.12.0 instead of 2.12.0-0). Also, added a pre-commit publish check. --- pkgs/platform/dev/travis.sh | 16 +++++++++++++--- pkgs/platform/pubspec.yaml | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pkgs/platform/dev/travis.sh b/pkgs/platform/dev/travis.sh index a805dbdb..03d489c3 100755 --- a/pkgs/platform/dev/travis.sh +++ b/pkgs/platform/dev/travis.sh @@ -5,17 +5,17 @@ # Make sure dartfmt is run on everything echo "Checking dart format..." -needs_dartfmt="$(dart format --set-exit-if-changed --output=none lib test dev)" +needs_dart_format="$(dart format --set-exit-if-changed --output=none lib test dev 2>&1)" if [[ $? != 0 ]]; then echo "FAILED" - echo "$needs_dartfmt" + echo "$needs_dart_format" exit 1 fi echo "PASSED" # Make sure we pass the analyzer echo "Checking dartanalyzer..." -fails_analyzer="$(find lib test dev -name "*.dart" | xargs dartanalyzer --options analysis_options.yaml)" +fails_analyzer="$(find lib test dev -name "*.dart" --print0 | xargs -0 dartanalyzer --options analysis_options.yaml 2>&1)" if [[ "$fails_analyzer" == *"[error]"* ]]; then echo "FAILED" echo "$fails_analyzer" @@ -23,6 +23,16 @@ if [[ "$fails_analyzer" == *"[error]"* ]]; then fi echo "PASSED" +# Make sure we could publish if we wanted to. +echo "Checking publishing..." +fails_publish="$(pub publish --dry-run 2>&1)" +if [[ $? != 0 ]]; then + echo "FAILED" + echo "$fails_publish" + exit 1 +fi +echo "PASSED" + # Fast fail the script on failures. set -e diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index de10923c..efe79e0e 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -4,7 +4,7 @@ description: A pluggable, mockable platform abstraction for Dart. homepage: https://github.com/google/platform.dart environment: - sdk: '>=2.12.0-0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dev_dependencies: test: ^1.16.8 From 01783eb6f15c25a0a5e1719092125c00a55a1b21 Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Mon, 30 Aug 2021 16:38:32 -0700 Subject: [PATCH 30/40] Switch to GitHub actions, update analysis options, fix analysis issues. (dart-lang/platform#35) This removes Travis configuration and switches to GitHub actions. Also, updated the analysis options to use package:lints/recommended.yaml. --- pkgs/platform/.github/workflows/platform.yml | 38 ++++++++++++ pkgs/platform/.travis.yml | 15 ----- pkgs/platform/analysis_options.yaml | 60 +------------------ pkgs/platform/dev/setup.sh | 6 -- pkgs/platform/dev/travis.sh | 40 ------------- .../lib/src/interface/local_platform.dart | 3 +- pkgs/platform/lib/src/interface/platform.dart | 12 ++-- .../lib/src/testing/fake_platform.dart | 4 +- pkgs/platform/pubspec.yaml | 1 + pkgs/platform/test/fake_platform_test.dart | 20 +++---- 10 files changed, 61 insertions(+), 138 deletions(-) create mode 100644 pkgs/platform/.github/workflows/platform.yml delete mode 100644 pkgs/platform/.travis.yml delete mode 100755 pkgs/platform/dev/setup.sh delete mode 100755 pkgs/platform/dev/travis.sh diff --git a/pkgs/platform/.github/workflows/platform.yml b/pkgs/platform/.github/workflows/platform.yml new file mode 100644 index 00000000..dfcf6cdf --- /dev/null +++ b/pkgs/platform/.github/workflows/platform.yml @@ -0,0 +1,38 @@ +name: Process Package + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + workflow_dispatch: + +jobs: + correctness: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f + - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 + with: + sdk: dev + - name: Install dependencies + run: dart pub upgrade + - name: Verify formatting + run: dart format --output=none --set-exit-if-changed . + - name: Analyze project source + run: dart analyze --fatal-infos + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + sdk: [stable, beta, dev] + steps: + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f + - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 + with: + sdk: ${{ matrix.sdk }} + - name: Install dependencies + run: dart pub upgrade + - name: Run Tests + run: dart test diff --git a/pkgs/platform/.travis.yml b/pkgs/platform/.travis.yml deleted file mode 100644 index 5722c5b4..00000000 --- a/pkgs/platform/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: dart -sudo: false -dart: - - dev -install: - - gem install coveralls-lcov -before_script: - - ./dev/setup.sh -script: - - ./dev/travis.sh -after_success: - - (coveralls-lcov coverage/lcov.info) -cache: - directories: - - $HOME/.pub-cache diff --git a/pkgs/platform/analysis_options.yaml b/pkgs/platform/analysis_options.yaml index 1b14e091..8fbd2e44 100644 --- a/pkgs/platform/analysis_options.yaml +++ b/pkgs/platform/analysis_options.yaml @@ -1,62 +1,6 @@ +include: package:lints/recommended.yaml + analyzer: - enable-experiment: - - non-nullable errors: # Allow having TODOs in the code todo: ignore - -linter: - rules: - # these rules are documented on and in the same order as - # the Dart Lint rules page to make maintenance easier - # http://dart-lang.github.io/linter/lints/ - - # === error rules === - - avoid_empty_else - - comment_references - - cancel_subscriptions - - close_sinks - - control_flow_in_finally - - empty_statements - - hash_and_equals - - invariant_booleans - - iterable_contains_unrelated_type - - list_remove_unrelated_type - - literal_only_boolean_expressions - - test_types_in_equals - - throw_in_finally - - unrelated_type_equality_checks - - valid_regexps - - # === style rules === - - always_declare_return_types - - always_specify_types - - annotate_overrides - - avoid_as - - avoid_init_to_null - - avoid_return_types_on_setters - - await_only_futures - - camel_case_types - - constant_identifier_names - - empty_constructor_bodies - - implementation_imports - - library_names - - library_prefixes - - non_constant_identifier_names - - one_member_abstracts - - only_throw_errors - - overridden_fields - - package_api_docs - - package_prefixed_library_names - - prefer_is_not_empty - - public_member_api_docs - - slash_for_doc_comments - - sort_constructors_first - - sort_unnamed_constructors_first - - type_annotate_public_apis - - type_init_formals - - unawaited_futures - - unnecessary_getters_setters - - # === pub rules === - - package_names diff --git a/pkgs/platform/dev/setup.sh b/pkgs/platform/dev/setup.sh deleted file mode 100755 index 99ec2843..00000000 --- a/pkgs/platform/dev/setup.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file -# 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. - -pub upgrade diff --git a/pkgs/platform/dev/travis.sh b/pkgs/platform/dev/travis.sh deleted file mode 100755 index 03d489c3..00000000 --- a/pkgs/platform/dev/travis.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file -# 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. - -# Make sure dartfmt is run on everything -echo "Checking dart format..." -needs_dart_format="$(dart format --set-exit-if-changed --output=none lib test dev 2>&1)" -if [[ $? != 0 ]]; then - echo "FAILED" - echo "$needs_dart_format" - exit 1 -fi -echo "PASSED" - -# Make sure we pass the analyzer -echo "Checking dartanalyzer..." -fails_analyzer="$(find lib test dev -name "*.dart" --print0 | xargs -0 dartanalyzer --options analysis_options.yaml 2>&1)" -if [[ "$fails_analyzer" == *"[error]"* ]]; then - echo "FAILED" - echo "$fails_analyzer" - exit 1 -fi -echo "PASSED" - -# Make sure we could publish if we wanted to. -echo "Checking publishing..." -fails_publish="$(pub publish --dry-run 2>&1)" -if [[ $? != 0 ]]; then - echo "FAILED" - echo "$fails_publish" - exit 1 -fi -echo "PASSED" - -# Fast fail the script on failures. -set -e - -# Run the tests. -pub run test diff --git a/pkgs/platform/lib/src/interface/local_platform.dart b/pkgs/platform/lib/src/interface/local_platform.dart index c8573bd7..2abd4347 100644 --- a/pkgs/platform/lib/src/interface/local_platform.dart +++ b/pkgs/platform/lib/src/interface/local_platform.dart @@ -42,8 +42,7 @@ class LocalPlatform extends Platform { List get executableArguments => io.Platform.executableArguments; @override - String? get packageRoot => - io.Platform.packageRoot; // ignore: deprecated_member_use + String? get packageRoot => null; @override String? get packageConfig => io.Platform.packageConfig; diff --git a/pkgs/platform/lib/src/interface/platform.dart b/pkgs/platform/lib/src/interface/platform.dart index 7f9262fa..70a7130b 100644 --- a/pkgs/platform/lib/src/interface/platform.dart +++ b/pkgs/platform/lib/src/interface/platform.dart @@ -159,12 +159,14 @@ abstract class Platform { /// list containing the flags passed to the executable. List get executableArguments; - /// The value of the `--package-root` flag passed to the executable - /// used to run the script in this isolate. This is the directory in which - /// Dart packages are looked up. + /// Deprecated, do not use. /// - /// If there is no `--package-root` flag, `null` is returned. - @deprecated + /// This used to be the value of the `--package-root` flag passed to the + /// executable used to run the script in this isolate, but is no longer + /// supported in Dart 2. + /// + /// Always returns null. + @Deprecated('packages/ directory resolution is not supported in Dart 2.') String? get packageRoot; /// The value of the `--packages` flag passed to the executable diff --git a/pkgs/platform/lib/src/testing/fake_platform.dart b/pkgs/platform/lib/src/testing/fake_platform.dart index 046dd0ac..8fe49c95 100644 --- a/pkgs/platform/lib/src/testing/fake_platform.dart +++ b/pkgs/platform/lib/src/testing/fake_platform.dart @@ -72,8 +72,8 @@ class FakePlatform extends Platform { /// [json] must be a JSON string that matches the encoding produced by /// [toJson]. factory FakePlatform.fromJson(String json) { - Map map = new JsonDecoder().convert(json); - return new FakePlatform( + Map map = JsonDecoder().convert(json); + return FakePlatform( numberOfProcessors: map['numberOfProcessors'], pathSeparator: map['pathSeparator'], operatingSystem: map['operatingSystem'], diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index efe79e0e..123723bf 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -7,4 +7,5 @@ environment: sdk: '>=2.12.0 <3.0.0' dev_dependencies: + lints: ^1.0.1 test: ^1.16.8 diff --git a/pkgs/platform/test/fake_platform_test.dart b/pkgs/platform/test/fake_platform_test.dart index 3f954b60..2203852f 100644 --- a/pkgs/platform/test/fake_platform_test.dart +++ b/pkgs/platform/test/fake_platform_test.dart @@ -32,13 +32,13 @@ void main() { late LocalPlatform local; setUp(() { - fake = new FakePlatform(); - local = new LocalPlatform(); + fake = FakePlatform(); + local = LocalPlatform(); }); group('fromPlatform', () { setUp(() { - fake = new FakePlatform.fromPlatform(local); + fake = FakePlatform.fromPlatform(local); }); test('copiesAllProperties', () { @@ -61,7 +61,7 @@ void main() { group('copyWith', () { setUp(() { - fake = new FakePlatform.fromPlatform(local); + fake = FakePlatform.fromPlatform(local); }); test('overrides a value, but leaves others intact', () { @@ -85,7 +85,7 @@ void main() { expect(copy.localeName, local.localeName); }); test('can override all values', () { - fake = new FakePlatform( + fake = FakePlatform( numberOfProcessors: 8, pathSeparator: ':', operatingSystem: 'fake', @@ -94,7 +94,7 @@ void main() { environment: {'PATH': '.'}, executable: 'executable', resolvedExecutable: '/executable', - script: new Uri.file('/platform/test/fake_platform_test.dart'), + script: Uri.file('/platform/test/fake_platform_test.dart'), executableArguments: ['scriptarg'], version: '0.1.1', stdinSupportsAnsi: false, @@ -125,8 +125,8 @@ void main() { group('json', () { test('fromJson', () { - String json = new io.File('test/platform.json').readAsStringSync(); - fake = new FakePlatform.fromJson(json); + String json = io.File('test/platform.json').readAsStringSync(); + fake = FakePlatform.fromJson(json); expect(fake.numberOfProcessors, 8); expect(fake.pathSeparator, '/'); expect(fake.operatingSystem, 'macos'); @@ -139,7 +139,7 @@ void main() { expect(fake.executable, '/bin/dart'); expect(fake.resolvedExecutable, '/bin/dart'); expect(fake.script, - new Uri.file('/platform/test/fake_platform_test.dart')); + Uri.file('/platform/test/fake_platform_test.dart')); expect(fake.executableArguments, ['--checked']); expect(fake.packageRoot, null); expect(fake.packageConfig, null); @@ -148,7 +148,7 @@ void main() { }); test('fromJsonToJson', () { - fake = new FakePlatform.fromJson(local.toJson()); + fake = FakePlatform.fromJson(local.toJson()); _expectPlatformsEqual(fake, local); }); }); From d8e96ef699a127631128ce45351b722b66514990 Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Tue, 31 Aug 2021 16:59:34 -0700 Subject: [PATCH 31/40] Fix formatting (dart-lang/platform#36) --- pkgs/platform/.github/workflows/platform.yml | 2 +- pkgs/platform/test/fake_platform_test.dart | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/platform/.github/workflows/platform.yml b/pkgs/platform/.github/workflows/platform.yml index dfcf6cdf..5cd3faed 100644 --- a/pkgs/platform/.github/workflows/platform.yml +++ b/pkgs/platform/.github/workflows/platform.yml @@ -1,4 +1,4 @@ -name: Process Package +name: Platform Package on: push: diff --git a/pkgs/platform/test/fake_platform_test.dart b/pkgs/platform/test/fake_platform_test.dart index 2203852f..f9374bed 100644 --- a/pkgs/platform/test/fake_platform_test.dart +++ b/pkgs/platform/test/fake_platform_test.dart @@ -138,8 +138,7 @@ void main() { }); expect(fake.executable, '/bin/dart'); expect(fake.resolvedExecutable, '/bin/dart'); - expect(fake.script, - Uri.file('/platform/test/fake_platform_test.dart')); + expect(fake.script, Uri.file('/platform/test/fake_platform_test.dart')); expect(fake.executableArguments, ['--checked']); expect(fake.packageRoot, null); expect(fake.packageConfig, null); From cf1b5715a5310162b5344c2f65e9c221a68dabfe Mon Sep 17 00:00:00 2001 From: Michael Thomsen Date: Thu, 2 Dec 2021 19:11:55 +0100 Subject: [PATCH 32/40] Remove package root (dart-lang/platform#38) Merging on behalf of @mit-mit --- pkgs/platform/CHANGELOG.md | 5 +++++ pkgs/platform/lib/src/interface/local_platform.dart | 3 --- pkgs/platform/lib/src/interface/platform.dart | 12 ------------ pkgs/platform/lib/src/testing/fake_platform.dart | 9 --------- pkgs/platform/pubspec.yaml | 4 ++-- pkgs/platform/test/fake_platform_test.dart | 7 ------- pkgs/platform/test/platform.json | 1 - 7 files changed, 7 insertions(+), 34 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index bd9140b9..6c662b75 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,8 @@ +### 3.1.0 + +* Removed `Platform.packageRoot`, which was already marked deprecated, and which + didn't work in Dart 2. + ### 3.0.2 * Added `FakePlatform.copyWith` function. diff --git a/pkgs/platform/lib/src/interface/local_platform.dart b/pkgs/platform/lib/src/interface/local_platform.dart index 2abd4347..d4b18abe 100644 --- a/pkgs/platform/lib/src/interface/local_platform.dart +++ b/pkgs/platform/lib/src/interface/local_platform.dart @@ -41,9 +41,6 @@ class LocalPlatform extends Platform { @override List get executableArguments => io.Platform.executableArguments; - @override - String? get packageRoot => null; - @override String? get packageConfig => io.Platform.packageConfig; diff --git a/pkgs/platform/lib/src/interface/platform.dart b/pkgs/platform/lib/src/interface/platform.dart index 70a7130b..354ae072 100644 --- a/pkgs/platform/lib/src/interface/platform.dart +++ b/pkgs/platform/lib/src/interface/platform.dart @@ -159,16 +159,6 @@ abstract class Platform { /// list containing the flags passed to the executable. List get executableArguments; - /// Deprecated, do not use. - /// - /// This used to be the value of the `--package-root` flag passed to the - /// executable used to run the script in this isolate, but is no longer - /// supported in Dart 2. - /// - /// Always returns null. - @Deprecated('packages/ directory resolution is not supported in Dart 2.') - String? get packageRoot; - /// The value of the `--packages` flag passed to the executable /// used to run the script in this isolate. This is the configuration which /// specifies how Dart packages are looked up. @@ -205,8 +195,6 @@ abstract class Platform { 'resolvedExecutable': resolvedExecutable, 'script': script.toString(), 'executableArguments': executableArguments, - 'packageRoot': - packageRoot, // ignore: deprecated_member_use_from_same_package 'packageConfig': packageConfig, 'version': version, 'stdinSupportsAnsi': stdinSupportsAnsi, diff --git a/pkgs/platform/lib/src/testing/fake_platform.dart b/pkgs/platform/lib/src/testing/fake_platform.dart index 8fe49c95..7b407cde 100644 --- a/pkgs/platform/lib/src/testing/fake_platform.dart +++ b/pkgs/platform/lib/src/testing/fake_platform.dart @@ -24,7 +24,6 @@ class FakePlatform extends Platform { String? resolvedExecutable, Uri? script, List? executableArguments, - this.packageRoot, this.packageConfig, String? version, bool? stdinSupportsAnsi, @@ -58,8 +57,6 @@ class FakePlatform extends Platform { _resolvedExecutable = platform.resolvedExecutable, _script = platform.script, _executableArguments = List.from(platform.executableArguments), - packageRoot = platform - .packageRoot, // ignore: deprecated_member_use_from_same_package packageConfig = platform.packageConfig, _version = platform.version, _stdinSupportsAnsi = platform.stdinSupportsAnsi, @@ -84,7 +81,6 @@ class FakePlatform extends Platform { resolvedExecutable: map['resolvedExecutable'], script: Uri.parse(map['script']), executableArguments: map['executableArguments'].cast(), - packageRoot: map['packageRoot'], packageConfig: map['packageConfig'], version: map['version'], stdinSupportsAnsi: map['stdinSupportsAnsi'], @@ -105,7 +101,6 @@ class FakePlatform extends Platform { String? resolvedExecutable, Uri? script, List? executableArguments, - String? packageRoot, String? packageConfig, String? version, bool? stdinSupportsAnsi, @@ -124,7 +119,6 @@ class FakePlatform extends Platform { resolvedExecutable: resolvedExecutable ?? this.resolvedExecutable, script: script ?? this.script, executableArguments: executableArguments ?? this.executableArguments, - packageRoot: packageRoot ?? this.packageRoot, packageConfig: packageConfig ?? this.packageConfig, version: version ?? this.version, stdinSupportsAnsi: stdinSupportsAnsi ?? this.stdinSupportsAnsi, @@ -173,9 +167,6 @@ class FakePlatform extends Platform { List get executableArguments => _throwIfNull(_executableArguments); List? _executableArguments; - @override - String? packageRoot; - @override String? packageConfig; diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 123723bf..1914ca5a 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,10 +1,10 @@ name: platform -version: 3.0.2 +version: 3.1.0 description: A pluggable, mockable platform abstraction for Dart. homepage: https://github.com/google/platform.dart environment: - sdk: '>=2.12.0 <3.0.0' + sdk: ">=2.12.0 <3.0.0" dev_dependencies: lints: ^1.0.1 diff --git a/pkgs/platform/test/fake_platform_test.dart b/pkgs/platform/test/fake_platform_test.dart index f9374bed..0c6034c2 100644 --- a/pkgs/platform/test/fake_platform_test.dart +++ b/pkgs/platform/test/fake_platform_test.dart @@ -18,9 +18,6 @@ void _expectPlatformsEqual(Platform actual, Platform expected) { expect(actual.resolvedExecutable, expected.resolvedExecutable); expect(actual.script, expected.script); expect(actual.executableArguments, expected.executableArguments); - expect( - actual.packageRoot, // ignore: deprecated_member_use_from_same_package - expected.packageRoot); // ignore: deprecated_member_use_from_same_package expect(actual.packageConfig, expected.packageConfig); expect(actual.version, expected.version); expect(actual.localeName, expected.localeName); @@ -78,8 +75,6 @@ void main() { expect(copy.resolvedExecutable, local.resolvedExecutable); expect(copy.script, local.script); expect(copy.executableArguments, local.executableArguments); - // ignore: deprecated_member_use_from_same_package - expect(copy.packageRoot, local.packageRoot); expect(copy.packageConfig, local.packageConfig); expect(copy.version, local.version); expect(copy.localeName, local.localeName); @@ -112,7 +107,6 @@ void main() { resolvedExecutable: local.resolvedExecutable, script: local.script, executableArguments: local.executableArguments, - packageRoot: local.packageRoot, packageConfig: local.packageConfig, version: local.version, stdinSupportsAnsi: local.stdinSupportsAnsi, @@ -140,7 +134,6 @@ void main() { expect(fake.resolvedExecutable, '/bin/dart'); expect(fake.script, Uri.file('/platform/test/fake_platform_test.dart')); expect(fake.executableArguments, ['--checked']); - expect(fake.packageRoot, null); expect(fake.packageConfig, null); expect(fake.version, '1.22.0'); expect(fake.localeName, 'de/de'); diff --git a/pkgs/platform/test/platform.json b/pkgs/platform/test/platform.json index 8fb41eeb..60b7c139 100644 --- a/pkgs/platform/test/platform.json +++ b/pkgs/platform/test/platform.json @@ -14,7 +14,6 @@ "executableArguments": [ "--checked" ], - "packageRoot": null, "packageConfig": null, "version": "1.22.0", "localeName": "de/de" From 078763d3ba01d48582385cd5f83456834c6c1834 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 14 Feb 2022 12:25:44 -0800 Subject: [PATCH 33/40] Update readme: drop broken coverage and CI badges (dart-lang/platform#40) drop broken coverage and CI badges --- pkgs/platform/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkgs/platform/README.md b/pkgs/platform/README.md index 0487c5c5..44932a67 100644 --- a/pkgs/platform/README.md +++ b/pkgs/platform/README.md @@ -1,7 +1,3 @@ -# Platform - -[![Build Status -](https://travis-ci.org/google/platform.dart.svg?branch=master)](https://travis-ci.org/google/platform.dart) -[![Coverage Status -](https://coveralls.io/repos/github/google/platform.dart/badge.svg?branch=master)](https://coveralls.io/github/google/platform.dart?branch=master) [![Pub](https://img.shields.io/pub/v/platform.svg)](https://pub.dartlang.org/packages/platform) A generic platform abstraction for Dart. From 85fcfd43801ea3ada41f5d353aa265e119b0c5cf Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Mon, 28 Aug 2023 13:20:03 -0400 Subject: [PATCH 34/40] Point to new repo location in README --- pkgs/platform/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/platform/README.md b/pkgs/platform/README.md index 44932a67..85d2b804 100644 --- a/pkgs/platform/README.md +++ b/pkgs/platform/README.md @@ -1,5 +1,12 @@ [![Pub](https://img.shields.io/pub/v/platform.svg)](https://pub.dartlang.org/packages/platform) +## Moved + +The source for the `platform` package has moved to [the `flutter/packages` +repository](https://github.com/flutter/packages/tree/main/packages/platform). + +----- + A generic platform abstraction for Dart. Like `dart:io`, `package:platform` supplies a rich, Dart-idiomatic API for From 37bec96f5195d33b55aa34c3f11a97ef530bd0d0 Mon Sep 17 00:00:00 2001 From: Michael Thomsen Date: Mon, 10 Jun 2024 15:39:15 +0200 Subject: [PATCH 35/40] Bring over latest files from flutter/packages (dart-lang/platform#46) * Bring over latest files from flutter/packages * Replace Flutter example with Dart example --- pkgs/platform/CHANGELOG.md | 63 +++++++++++++------ pkgs/platform/README.md | 7 --- pkgs/platform/analysis_options.yaml | 2 +- pkgs/platform/example/.gitignore | 3 + pkgs/platform/example/README.md | 2 + pkgs/platform/example/analysis_options.yaml | 30 +++++++++ pkgs/platform/example/bin/example.dart | 15 +++++ pkgs/platform/example/pubspec.yaml | 14 +++++ pkgs/platform/lib/platform.dart | 8 +-- .../lib/src/interface/local_platform.dart | 6 +- pkgs/platform/lib/src/interface/platform.dart | 6 +- .../lib/src/testing/fake_platform.dart | 45 ++++++------- pkgs/platform/pubspec.yaml | 15 +++-- pkgs/platform/test/fake_platform_test.dart | 18 +++--- 14 files changed, 162 insertions(+), 72 deletions(-) create mode 100644 pkgs/platform/example/.gitignore create mode 100644 pkgs/platform/example/README.md create mode 100644 pkgs/platform/example/analysis_options.yaml create mode 100644 pkgs/platform/example/bin/example.dart create mode 100644 pkgs/platform/example/pubspec.yaml diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index 6c662b75..b83040fc 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,82 +1,107 @@ -### 3.1.0 +## NEXT + +* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2. +* Transfers the package source from https://github.com/flutter/packages + to https://github.com/dart-lang/platform. + +## 3.1.4 + +* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0. +* Fixes new lint warnings. + +## 3.1.3 + +* Adds example app. + +## 3.1.2 + +* Adds pub topics to package metadata. +* Updates minimum supported SDK version to Flutter 3.7/Dart 2.19. + +## 3.1.1 + +* Transfers the package source from https://github.com/google/platform.dart to + https://github.com/flutter/packages. + +## 3.1.0 * Removed `Platform.packageRoot`, which was already marked deprecated, and which didn't work in Dart 2. -### 3.0.2 +## 3.0.2 * Added `FakePlatform.copyWith` function. -### 3.0.1 +## 3.0.1 * Added string constants for each of the supported platforms for use in switch statements. -### 3.0.0 +## 3.0.0 * First stable null safe release. -### 3.0.0-nullsafety.4 +## 3.0.0-nullsafety.4 * Update supported SDK range. -### 3.0.0-nullsafety.3 +## 3.0.0-nullsafety.3 * Update supported SDK range. -### 3.0.0-nullsafety.2 +## 3.0.0-nullsafety.2 * Update supported SDK range. -### 3.0.0-nullsafety.1 +## 3.0.0-nullsafety.1 * Migrate package to null-safe dart. -### 2.2.1 +## 2.2.1 * Add `operatingSystemVersion` -### 2.2.0 +## 2.2.0 * Declare compatibility with Dart 2 stable * Update dependency on `package:test` to 1.0 -### 2.1.2 +## 2.1.2 * Relax sdk upper bound constraint to '<2.0.0' to allow 'edge' dart sdk use. -### 2.1.1 +## 2.1.1 * Bumped maximum Dart SDK version to 2.0.0-dev.infinity -### 2.1.0 +## 2.1.0 * Added `localeName` * Bumped minimum Dart SDK version to 1.24.0-dev.0.0 -### 2.0.0 +## 2.0.0 * Added `stdinSupportsAnsi` and `stdinSupportsAnsi` * Removed `ansiSupported` -### 1.1.1 +## 1.1.1 * Updated `LocalPlatform` to use new `dart.io` API for ansi color support queries * Bumped minimum Dart SDK version to 1.23.0-dev.10.0 -### 1.1.0 +## 1.1.0 * Added `ansiSupported` * Bumped minimum Dart SDK version to 1.23.0-dev.9.0 -#### 1.0.2 +## 1.0.2 * Minor doc updates -#### 1.0.1 +## 1.0.1 * Added const constructors for `Platform` and `LocalPlatform` -#### 1.0.0 +## 1.0.0 * Initial version diff --git a/pkgs/platform/README.md b/pkgs/platform/README.md index 85d2b804..44932a67 100644 --- a/pkgs/platform/README.md +++ b/pkgs/platform/README.md @@ -1,12 +1,5 @@ [![Pub](https://img.shields.io/pub/v/platform.svg)](https://pub.dartlang.org/packages/platform) -## Moved - -The source for the `platform` package has moved to [the `flutter/packages` -repository](https://github.com/flutter/packages/tree/main/packages/platform). - ------ - A generic platform abstraction for Dart. Like `dart:io`, `package:platform` supplies a rich, Dart-idiomatic API for diff --git a/pkgs/platform/analysis_options.yaml b/pkgs/platform/analysis_options.yaml index 8fbd2e44..45444423 100644 --- a/pkgs/platform/analysis_options.yaml +++ b/pkgs/platform/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:lints/recommended.yaml +include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: errors: diff --git a/pkgs/platform/example/.gitignore b/pkgs/platform/example/.gitignore new file mode 100644 index 00000000..3a857904 --- /dev/null +++ b/pkgs/platform/example/.gitignore @@ -0,0 +1,3 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ diff --git a/pkgs/platform/example/README.md b/pkgs/platform/example/README.md new file mode 100644 index 00000000..b0bf20bf --- /dev/null +++ b/pkgs/platform/example/README.md @@ -0,0 +1,2 @@ +A small example application demonstrating how to use the platform information +APIs in `package:platform`. \ No newline at end of file diff --git a/pkgs/platform/example/analysis_options.yaml b/pkgs/platform/example/analysis_options.yaml new file mode 100644 index 00000000..dee8927a --- /dev/null +++ b/pkgs/platform/example/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/platform/example/bin/example.dart b/pkgs/platform/example/bin/example.dart new file mode 100644 index 00000000..59693e35 --- /dev/null +++ b/pkgs/platform/example/bin/example.dart @@ -0,0 +1,15 @@ +import 'package:platform/platform.dart'; + +void main(List arguments) { + const LocalPlatform platform = LocalPlatform(); + + print('Operating System: ${platform.operatingSystem}.'); + print('Local Hostname: ${platform.localHostname}.'); + print('Number of Processors: ${platform.numberOfProcessors}.'); + print('Path Separator: ${platform.pathSeparator}.'); + print('Locale Name: ${platform.localeName}.'); + print('Stdin Supports ANSI: ${platform.stdinSupportsAnsi}.'); + print('Stdout Supports ANSI: ${platform.stdoutSupportsAnsi}.'); + print('Executable Arguments: ${platform.executableArguments}.'); + print('Dart Version: ${platform.version}.'); +} diff --git a/pkgs/platform/example/pubspec.yaml b/pkgs/platform/example/pubspec.yaml new file mode 100644 index 00000000..35107a7f --- /dev/null +++ b/pkgs/platform/example/pubspec.yaml @@ -0,0 +1,14 @@ +name: example +description: Demonstrates how to use the platform api. +version: 1.0.0 +publish_to: none + +environment: + sdk: ^3.2.0 + +dependencies: + platform: + path: ../ + +dev_dependencies: + lints: ^4.0.0 diff --git a/pkgs/platform/lib/platform.dart b/pkgs/platform/lib/platform.dart index 27702195..f096dcb4 100644 --- a/pkgs/platform/lib/platform.dart +++ b/pkgs/platform/lib/platform.dart @@ -1,8 +1,8 @@ -// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file -// 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. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. -/// Core interfaces & classes. +// Core interfaces & classes. export 'src/interface/local_platform.dart'; export 'src/interface/platform.dart'; export 'src/testing/fake_platform.dart'; diff --git a/pkgs/platform/lib/src/interface/local_platform.dart b/pkgs/platform/lib/src/interface/local_platform.dart index d4b18abe..c24c01be 100644 --- a/pkgs/platform/lib/src/interface/local_platform.dart +++ b/pkgs/platform/lib/src/interface/local_platform.dart @@ -1,6 +1,6 @@ -// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file -// 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. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. import 'dart:io' as io show Platform, stdin, stdout; diff --git a/pkgs/platform/lib/src/interface/platform.dart b/pkgs/platform/lib/src/interface/platform.dart index 354ae072..dcc47be8 100644 --- a/pkgs/platform/lib/src/interface/platform.dart +++ b/pkgs/platform/lib/src/interface/platform.dart @@ -1,6 +1,6 @@ -// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file -// 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. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. import 'dart:convert'; diff --git a/pkgs/platform/lib/src/testing/fake_platform.dart b/pkgs/platform/lib/src/testing/fake_platform.dart index 7b407cde..0c028ca4 100644 --- a/pkgs/platform/lib/src/testing/fake_platform.dart +++ b/pkgs/platform/lib/src/testing/fake_platform.dart @@ -1,6 +1,6 @@ -// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file -// 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. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. import 'dart:convert'; @@ -12,7 +12,7 @@ class FakePlatform extends Platform { /// /// Unspecified properties will *not* be assigned default values (they will /// remain `null`). If an unset non-null value is read, a [StateError] will - /// be thrown instead of returnin `null`. + /// be thrown instead of returning `null`. FakePlatform({ int? numberOfProcessors, String? pathSeparator, @@ -69,27 +69,30 @@ class FakePlatform extends Platform { /// [json] must be a JSON string that matches the encoding produced by /// [toJson]. factory FakePlatform.fromJson(String json) { - Map map = JsonDecoder().convert(json); + final map = const JsonDecoder().convert(json) as Map; return FakePlatform( - numberOfProcessors: map['numberOfProcessors'], - pathSeparator: map['pathSeparator'], - operatingSystem: map['operatingSystem'], - operatingSystemVersion: map['operatingSystemVersion'], - localHostname: map['localHostname'], - environment: map['environment'].cast(), - executable: map['executable'], - resolvedExecutable: map['resolvedExecutable'], - script: Uri.parse(map['script']), - executableArguments: map['executableArguments'].cast(), - packageConfig: map['packageConfig'], - version: map['version'], - stdinSupportsAnsi: map['stdinSupportsAnsi'], - stdoutSupportsAnsi: map['stdoutSupportsAnsi'], - localeName: map['localeName'], + numberOfProcessors: map['numberOfProcessors'] as int?, + pathSeparator: map['pathSeparator'] as String?, + operatingSystem: map['operatingSystem'] as String?, + operatingSystemVersion: map['operatingSystemVersion'] as String?, + localHostname: map['localHostname'] as String?, + environment: + (map['environment'] as Map).cast(), + executable: map['executable'] as String?, + resolvedExecutable: map['resolvedExecutable'] as String?, + script: Uri.parse(map['script'] as String), + executableArguments: + (map['executableArguments'] as List).cast(), + packageConfig: map['packageConfig'] as String?, + version: map['version'] as String?, + stdinSupportsAnsi: map['stdinSupportsAnsi'] as bool?, + stdoutSupportsAnsi: map['stdoutSupportsAnsi'] as bool?, + localeName: map['localeName'] as String?, ); } - /// Creates a new [FakePlatform] from this one, with some properties replaced by the given properties. + /// Creates a new [FakePlatform] from this one, with some properties replaced + /// by the given properties. FakePlatform copyWith({ int? numberOfProcessors, String? pathSeparator, diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 1914ca5a..0c60d5a8 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,11 +1,16 @@ name: platform -version: 3.1.0 -description: A pluggable, mockable platform abstraction for Dart. -homepage: https://github.com/google/platform.dart +description: A pluggable, mockable platform information abstraction for Dart. +repository: https://github.com/dart-lang/platform +issue_tracker: https://github.com/dart-lang/platform/issues +version: 3.1.4 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ^3.2.0 dev_dependencies: - lints: ^1.0.1 + dart_flutter_team_lints: ^3.1.0 test: ^1.16.8 + +topics: + - information + - platform diff --git a/pkgs/platform/test/fake_platform_test.dart b/pkgs/platform/test/fake_platform_test.dart index 0c6034c2..1aa7cbf6 100644 --- a/pkgs/platform/test/fake_platform_test.dart +++ b/pkgs/platform/test/fake_platform_test.dart @@ -1,6 +1,6 @@ -// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file -// 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. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. import 'dart:io' as io; @@ -30,7 +30,7 @@ void main() { setUp(() { fake = FakePlatform(); - local = LocalPlatform(); + local = const LocalPlatform(); }); group('fromPlatform', () { @@ -43,7 +43,7 @@ void main() { }); test('convertsPropertiesToMutable', () { - String key = fake.environment.keys.first; + final key = fake.environment.keys.first; expect(fake.environment[key], local.environment[key]); fake.environment[key] = 'FAKE'; @@ -62,7 +62,7 @@ void main() { }); test('overrides a value, but leaves others intact', () { - FakePlatform copy = fake.copyWith( + final copy = fake.copyWith( numberOfProcessors: -1, ); expect(copy.numberOfProcessors, equals(-1)); @@ -96,7 +96,7 @@ void main() { stdoutSupportsAnsi: true, localeName: 'local', ); - FakePlatform copy = fake.copyWith( + final copy = fake.copyWith( numberOfProcessors: local.numberOfProcessors, pathSeparator: local.pathSeparator, operatingSystem: local.operatingSystem, @@ -119,7 +119,7 @@ void main() { group('json', () { test('fromJson', () { - String json = io.File('test/platform.json').readAsStringSync(); + final json = io.File('test/platform.json').readAsStringSync(); fake = FakePlatform.fromJson(json); expect(fake.numberOfProcessors, 8); expect(fake.pathSeparator, '/'); @@ -147,7 +147,7 @@ void main() { }); test('Throws when unset non-null values are read', () { - final FakePlatform platform = FakePlatform(); + final platform = FakePlatform(); expect(() => platform.numberOfProcessors, throwsA(isStateError)); expect(() => platform.pathSeparator, throwsA(isStateError)); From 5b429afc9e361e26a66a61d3d7c8f493478fd604 Mon Sep 17 00:00:00 2001 From: Michael Thomsen Date: Mon, 10 Jun 2024 16:22:21 +0200 Subject: [PATCH 36/40] Prepare for publishing (dart-lang/platform#47) --- pkgs/platform/CHANGELOG.md | 2 +- pkgs/platform/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index b83040fc..26950c88 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,4 +1,4 @@ -## NEXT +## 3.1.5 * Updates minimum supported SDK version to Flutter 3.16/Dart 3.2. * Transfers the package source from https://github.com/flutter/packages diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 0c60d5a8..5d1d177e 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -2,7 +2,7 @@ name: platform description: A pluggable, mockable platform information abstraction for Dart. repository: https://github.com/dart-lang/platform issue_tracker: https://github.com/dart-lang/platform/issues -version: 3.1.4 +version: 3.1.5 environment: sdk: ^3.2.0 From a22b849e34f63d8524d6864c2e761a87aa2a4486 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 16 Oct 2024 16:29:20 +0200 Subject: [PATCH 37/40] Add issue template and other fixes --- .github/ISSUE_TEMPLATE/platform.md | 5 +++++ pkgs/platform/CONTRIBUTING.md | 24 ------------------------ pkgs/platform/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 25 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/platform.md delete mode 100644 pkgs/platform/CONTRIBUTING.md diff --git a/.github/ISSUE_TEMPLATE/platform.md b/.github/ISSUE_TEMPLATE/platform.md new file mode 100644 index 00000000..4a168fdf --- /dev/null +++ b/.github/ISSUE_TEMPLATE/platform.md @@ -0,0 +1,5 @@ +--- +name: "package:platform" +about: "Create a bug or file a feature request against package:platform." +labels: "package:platform" +--- \ No newline at end of file diff --git a/pkgs/platform/CONTRIBUTING.md b/pkgs/platform/CONTRIBUTING.md deleted file mode 100644 index 0786fdf4..00000000 --- a/pkgs/platform/CONTRIBUTING.md +++ /dev/null @@ -1,24 +0,0 @@ -# How to contribute - -We'd love to accept your patches and contributions to this project. There are -just a few small guidelines you need to follow. - -## Contributor License Agreement - -Contributions to this project must be accompanied by a Contributor License -Agreement. You (or your employer) retain the copyright to your contribution, -this simply gives us permission to use and redistribute your contributions as -part of the project. Head over to to see -your current agreements on file or to sign a new one. - -You generally only need to submit a CLA once, so if you've already submitted one -(even if it was for a different project), you probably don't need to do it -again. - -## Code reviews - -All submissions, including submissions by project members, require review. We -use GitHub pull requests for this purpose. Consult [GitHub Help] for more -information on using pull requests. - -[GitHub Help]: https://help.github.com/articles/about-pull-requests/ diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index 5d1d177e..ba26ce4e 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,6 +1,6 @@ name: platform description: A pluggable, mockable platform information abstraction for Dart. -repository: https://github.com/dart-lang/platform +repository: https://github.com/dart-lang/core/tree/main/pkgs/platform issue_tracker: https://github.com/dart-lang/platform/issues version: 3.1.5 From ddf9f2549e0f344372d47312355d9184dc68bddc Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 16 Oct 2024 16:33:33 +0200 Subject: [PATCH 38/40] Moving fixes --- .github/labeler.yml | 4 ++++ .../workflows/platform.yaml | 20 ++++++++++++++++--- README.md | 1 + pkgs/platform/CHANGELOG.md | 4 ++++ pkgs/platform/pubspec.yaml | 11 +++++----- 5 files changed, 32 insertions(+), 8 deletions(-) rename pkgs/platform/.github/workflows/platform.yml => .github/workflows/platform.yaml (71%) diff --git a/.github/labeler.yml b/.github/labeler.yml index fc71da29..fbd79e9b 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -23,3 +23,7 @@ "package:fixnum": - changed-files: - any-glob-to-any-file: 'pkgs/fixnum/**' + +"package:platform": + - changed-files: + - any-glob-to-any-file: 'pkgs/platform/**' diff --git a/pkgs/platform/.github/workflows/platform.yml b/.github/workflows/platform.yaml similarity index 71% rename from pkgs/platform/.github/workflows/platform.yml rename to .github/workflows/platform.yaml index 5cd3faed..6364e447 100644 --- a/pkgs/platform/.github/workflows/platform.yml +++ b/.github/workflows/platform.yaml @@ -1,11 +1,25 @@ name: Platform Package on: + # Run CI on pushes to the main branch, and on PRs against main. push: - branches: [ master ] + branches: [ main ] + paths: + - '.github/workflows/platform.yaml' + - 'pkgs/platform/**' pull_request: - branches: [ master ] - workflow_dispatch: + branches: [ main ] + paths: + - '.github/workflows/platform.yaml' + - 'pkgs/platform/**' + schedule: + - cron: "0 0 * * 0" +env: + PUB_ENVIRONMENT: bot.github + +defaults: + run: + working-directory: pkgs/platform/ jobs: correctness: diff --git a/README.md b/README.md index 77c5fdb3..45b26698 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ This repository is home to various Dart packages under the [dart.dev](https://pu | [convert](pkgs/convert/) | Utilities for converting between data representations. | [![pub package](https://img.shields.io/pub/v/convert.svg)](https://pub.dev/packages/convert) | | [crypto](pkgs/crypto/) | Implementations of SHA, MD5, and HMAC cryptographic functions. | [![pub package](https://img.shields.io/pub/v/crypto.svg)](https://pub.dev/packages/crypto) | | [fixnum](pkgs/fixnum/) | Library for 32- and 64-bit signed fixed-width integers. | [![pub package](https://img.shields.io/pub/v/fixnum.svg)](https://pub.dev/packages/fixnum) | +| [platform](pkgs/platform/) | A pluggable, mockable platform information abstraction for Dart. | [![pub package](https://img.shields.io/pub/v/platform.svg)](https://pub.dev/packages/platform) | ## Publishing automation diff --git a/pkgs/platform/CHANGELOG.md b/pkgs/platform/CHANGELOG.md index 26950c88..1e8c4d57 100644 --- a/pkgs/platform/CHANGELOG.md +++ b/pkgs/platform/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.1.6 + +* Move to `dart-lang/core` monorepo. + ## 3.1.5 * Updates minimum supported SDK version to Flutter 3.16/Dart 3.2. diff --git a/pkgs/platform/pubspec.yaml b/pkgs/platform/pubspec.yaml index ba26ce4e..25076724 100644 --- a/pkgs/platform/pubspec.yaml +++ b/pkgs/platform/pubspec.yaml @@ -1,8 +1,12 @@ name: platform description: A pluggable, mockable platform information abstraction for Dart. repository: https://github.com/dart-lang/core/tree/main/pkgs/platform -issue_tracker: https://github.com/dart-lang/platform/issues -version: 3.1.5 +issue_tracker: https://github.com/dart-lang/core/issues +version: 3.1.6 + +topics: + - information + - platform environment: sdk: ^3.2.0 @@ -11,6 +15,3 @@ dev_dependencies: dart_flutter_team_lints: ^3.1.0 test: ^1.16.8 -topics: - - information - - platform From cecb4b4531962310fd814f78af3c4a1356119b58 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 16 Oct 2024 16:39:32 +0200 Subject: [PATCH 39/40] Ignore licenses for package:platform --- .github/workflows/health.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index f258f8b6..cf26962a 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -9,6 +9,6 @@ jobs: uses: dart-lang/ecosystem/.github/workflows/health.yaml@main with: ignore_coverage: "**.mock.dart,**.g.dart" - ignore_license: "**.mock.dart,**.g.dart,**.mocks.dart" + ignore_license: "**.mock.dart,**.g.dart,**.mocks.dart,pkgs/platform/*" permissions: pull-requests: write From 08428e803e85125df68b26234cd019a95a6a2e3b Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 17 Oct 2024 13:40:45 +0200 Subject: [PATCH 40/40] Update .github/workflows/platform.yaml Co-authored-by: Devon Carew --- .github/workflows/platform.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/platform.yaml b/.github/workflows/platform.yaml index 6364e447..52c9c469 100644 --- a/.github/workflows/platform.yaml +++ b/.github/workflows/platform.yaml @@ -1,4 +1,4 @@ -name: Platform Package +name: package:platform on: # Run CI on pushes to the main branch, and on PRs against main.