Skip to content

Commit 07aff97

Browse files
authored
Merge pull request #404 from dart-lang/merge-platform-package
Merge `package:platform`
2 parents 010a343 + a11bf72 commit 07aff97

23 files changed

+975
-1
lines changed

.github/ISSUE_TEMPLATE/platform.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
name: "package:platform"
3+
about: "Create a bug or file a feature request against package:platform."
4+
labels: "package:platform"
5+
---

.github/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@
3535
"package:path":
3636
- changed-files:
3737
- any-glob-to-any-file: 'pkgs/path/**'
38+
39+
"package:platform":
40+
- changed-files:
41+
- any-glob-to-any-file: 'pkgs/platform/**'

.github/workflows/health.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ jobs:
99
uses: dart-lang/ecosystem/.github/workflows/health.yaml@main
1010
with:
1111
ignore_coverage: "**.mock.dart,**.g.dart"
12-
ignore_license: "**.mock.dart,**.g.dart,**.mocks.dart"
12+
ignore_license: "**.mock.dart,**.g.dart,**.mocks.dart,pkgs/platform/*"
1313
permissions:
1414
pull-requests: write

.github/workflows/platform.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: package:platform
2+
3+
on:
4+
# Run CI on pushes to the main branch, and on PRs against main.
5+
push:
6+
branches: [ main ]
7+
paths:
8+
- '.github/workflows/platform.yaml'
9+
- 'pkgs/platform/**'
10+
pull_request:
11+
branches: [ main ]
12+
paths:
13+
- '.github/workflows/platform.yaml'
14+
- 'pkgs/platform/**'
15+
schedule:
16+
- cron: "0 0 * * 0"
17+
env:
18+
PUB_ENVIRONMENT: bot.github
19+
20+
defaults:
21+
run:
22+
working-directory: pkgs/platform/
23+
24+
jobs:
25+
correctness:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
29+
- uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603
30+
with:
31+
sdk: dev
32+
- name: Install dependencies
33+
run: dart pub upgrade
34+
- name: Verify formatting
35+
run: dart format --output=none --set-exit-if-changed .
36+
- name: Analyze project source
37+
run: dart analyze --fatal-infos
38+
test:
39+
runs-on: ${{ matrix.os }}
40+
strategy:
41+
matrix:
42+
os: [ubuntu-latest, macos-latest, windows-latest]
43+
sdk: [stable, beta, dev]
44+
steps:
45+
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
46+
- uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603
47+
with:
48+
sdk: ${{ matrix.sdk }}
49+
- name: Install dependencies
50+
run: dart pub upgrade
51+
- name: Run Tests
52+
run: dart test

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This repository is home to various Dart packages under the [dart.dev](https://pu
1717
| [logging](pkgs/logging/) | Provides APIs for debugging and error logging. | [![pub package](https://img.shields.io/pub/v/logging.svg)](https://pub.dev/packages/logging) |
1818
| [os_detect](pkgs/os_detect/) | Platform independent OS detection. | [![pub package](https://img.shields.io/pub/v/os_detect.svg)](https://pub.dev/packages/os_detect) |
1919
| [path](pkgs/path/) | A string-based path manipulation library for all of the path operations you know and love. | [![pub package](https://img.shields.io/pub/v/path.svg)](https://pub.dev/packages/path) |
20+
| [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) |
2021

2122
## Publishing automation
2223

pkgs/platform/.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
### Dart template
2+
# Don’t commit the following directories created by pub.
3+
.buildlog
4+
.dart_tool/
5+
.pub/
6+
build/
7+
packages
8+
.packages
9+
10+
# Include when developing application packages.
11+
pubspec.lock
12+
13+
# IDE
14+
.project
15+
.settings
16+
.idea
17+
.c9

pkgs/platform/AUTHORS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Below is a list of people and organizations that have contributed
2+
# to the Process project. Names should be added to the list like so:
3+
#
4+
# Name/Organization <email address>
5+
6+
Google Inc.

pkgs/platform/CHANGELOG.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
## 3.1.6
2+
3+
* Move to `dart-lang/core` monorepo.
4+
5+
## 3.1.5
6+
7+
* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
8+
* Transfers the package source from https://github.com/flutter/packages
9+
to https://github.com/dart-lang/platform.
10+
11+
## 3.1.4
12+
13+
* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.
14+
* Fixes new lint warnings.
15+
16+
## 3.1.3
17+
18+
* Adds example app.
19+
20+
## 3.1.2
21+
22+
* Adds pub topics to package metadata.
23+
* Updates minimum supported SDK version to Flutter 3.7/Dart 2.19.
24+
25+
## 3.1.1
26+
27+
* Transfers the package source from https://github.com/google/platform.dart to
28+
https://github.com/flutter/packages.
29+
30+
## 3.1.0
31+
32+
* Removed `Platform.packageRoot`, which was already marked deprecated, and which
33+
didn't work in Dart 2.
34+
35+
## 3.0.2
36+
37+
* Added `FakePlatform.copyWith` function.
38+
39+
## 3.0.1
40+
41+
* Added string constants for each of the supported platforms for use in switch
42+
statements.
43+
44+
## 3.0.0
45+
46+
* First stable null safe release.
47+
48+
## 3.0.0-nullsafety.4
49+
50+
* Update supported SDK range.
51+
52+
## 3.0.0-nullsafety.3
53+
54+
* Update supported SDK range.
55+
56+
## 3.0.0-nullsafety.2
57+
58+
* Update supported SDK range.
59+
60+
## 3.0.0-nullsafety.1
61+
62+
* Migrate package to null-safe dart.
63+
64+
## 2.2.1
65+
66+
* Add `operatingSystemVersion`
67+
68+
## 2.2.0
69+
70+
* Declare compatibility with Dart 2 stable
71+
* Update dependency on `package:test` to 1.0
72+
73+
## 2.1.2
74+
75+
* Relax sdk upper bound constraint to '<2.0.0' to allow 'edge' dart sdk use.
76+
77+
## 2.1.1
78+
79+
* Bumped maximum Dart SDK version to 2.0.0-dev.infinity
80+
81+
## 2.1.0
82+
83+
* Added `localeName`
84+
* Bumped minimum Dart SDK version to 1.24.0-dev.0.0
85+
86+
## 2.0.0
87+
88+
* Added `stdinSupportsAnsi` and `stdinSupportsAnsi`
89+
* Removed `ansiSupported`
90+
91+
## 1.1.1
92+
93+
* Updated `LocalPlatform` to use new `dart.io` API for ansi color support queries
94+
* Bumped minimum Dart SDK version to 1.23.0-dev.10.0
95+
96+
## 1.1.0
97+
98+
* Added `ansiSupported`
99+
* Bumped minimum Dart SDK version to 1.23.0-dev.9.0
100+
101+
## 1.0.2
102+
103+
* Minor doc updates
104+
105+
## 1.0.1
106+
107+
* Added const constructors for `Platform` and `LocalPlatform`
108+
109+
## 1.0.0
110+
111+
* Initial version

pkgs/platform/LICENSE

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright 2017, the Dart project authors. All rights reserved.
2+
Redistribution and use in source and binary forms, with or without
3+
modification, are permitted provided that the following conditions are
4+
met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pkgs/platform/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[![Pub](https://img.shields.io/pub/v/platform.svg)](https://pub.dartlang.org/packages/platform)
2+
3+
A generic platform abstraction for Dart.
4+
5+
Like `dart:io`, `package:platform` supplies a rich, Dart-idiomatic API for
6+
accessing platform-specific information.
7+
8+
`package:platform` provides a lightweight wrapper around the static `Platform`
9+
properties that exist in `dart:io`. However, it uses instance properties rather
10+
than static properties, making it possible to mock out in tests.

pkgs/platform/analysis_options.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include: package:dart_flutter_team_lints/analysis_options.yaml
2+
3+
analyzer:
4+
errors:
5+
# Allow having TODOs in the code
6+
todo: ignore

pkgs/platform/example/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://dart.dev/guides/libraries/private-files
2+
# Created by `dart pub`
3+
.dart_tool/

pkgs/platform/example/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
A small example application demonstrating how to use the platform information
2+
APIs in `package:platform`.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file configures the static analysis results for your project (errors,
2+
# warnings, and lints).
3+
#
4+
# This enables the 'recommended' set of lints from `package:lints`.
5+
# This set helps identify many issues that may lead to problems when running
6+
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
7+
# style and format.
8+
#
9+
# If you want a smaller set of lints you can change this to specify
10+
# 'package:lints/core.yaml'. These are just the most critical lints
11+
# (the recommended set includes the core lints).
12+
# The core lints are also what is used by pub.dev for scoring packages.
13+
14+
include: package:lints/recommended.yaml
15+
16+
# Uncomment the following section to specify additional rules.
17+
18+
# linter:
19+
# rules:
20+
# - camel_case_types
21+
22+
# analyzer:
23+
# exclude:
24+
# - path/to/excluded/files/**
25+
26+
# For more information about the core and recommended set of lints, see
27+
# https://dart.dev/go/core-lints
28+
29+
# For additional information about configuring this file, see
30+
# https://dart.dev/guides/language/analysis-options
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import 'package:platform/platform.dart';
2+
3+
void main(List<String> arguments) {
4+
const LocalPlatform platform = LocalPlatform();
5+
6+
print('Operating System: ${platform.operatingSystem}.');
7+
print('Local Hostname: ${platform.localHostname}.');
8+
print('Number of Processors: ${platform.numberOfProcessors}.');
9+
print('Path Separator: ${platform.pathSeparator}.');
10+
print('Locale Name: ${platform.localeName}.');
11+
print('Stdin Supports ANSI: ${platform.stdinSupportsAnsi}.');
12+
print('Stdout Supports ANSI: ${platform.stdoutSupportsAnsi}.');
13+
print('Executable Arguments: ${platform.executableArguments}.');
14+
print('Dart Version: ${platform.version}.');
15+
}

pkgs/platform/example/pubspec.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: example
2+
description: Demonstrates how to use the platform api.
3+
version: 1.0.0
4+
publish_to: none
5+
6+
environment:
7+
sdk: ^3.2.0
8+
9+
dependencies:
10+
platform:
11+
path: ../
12+
13+
dev_dependencies:
14+
lints: ^4.0.0

pkgs/platform/lib/platform.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Core interfaces & classes.
6+
export 'src/interface/local_platform.dart';
7+
export 'src/interface/platform.dart';
8+
export 'src/testing/fake_platform.dart';

0 commit comments

Comments
 (0)