Skip to content

Commit 7db2a20

Browse files
committed
Merge package:io into the tools monorepo
2 parents 223daf5 + b44e89f commit 7db2a20

34 files changed

+2241
-0
lines changed

pkgs/io/.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Dependabot configuration file.
2+
# See https://docs.github.com/en/code-security/dependabot/dependabot-version-updates
3+
version: 2
4+
5+
updates:
6+
- package-ecosystem: github-actions
7+
directory: /
8+
schedule:
9+
interval: monthly
10+
labels:
11+
- autosubmit
12+
groups:
13+
github-actions:
14+
patterns:
15+
- "*"

pkgs/io/.github/workflows/ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: ci
2+
3+
on:
4+
# Run on PRs and pushes to the default branch.
5+
push:
6+
branches: [ master ]
7+
pull_request:
8+
branches: [ master ]
9+
schedule:
10+
- cron: "0 0 * * 0"
11+
12+
env:
13+
PUB_ENVIRONMENT: bot.github
14+
15+
jobs:
16+
# Check code formatting and static analysis on a single OS (linux)
17+
# against Dart dev and stable.
18+
analyze:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
sdk: [dev, 3.4]
24+
steps:
25+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
26+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
27+
with:
28+
sdk: ${{ matrix.sdk }}
29+
- id: install
30+
name: Install dependencies
31+
run: dart pub get
32+
- name: Check formatting
33+
run: dart format --output=none --set-exit-if-changed .
34+
if: always() && steps.install.outcome == 'success'
35+
- name: Analyze code
36+
run: dart analyze --fatal-infos
37+
if: always() && steps.install.outcome == 'success'
38+
39+
# Run tests on a matrix consisting of two dimensions:
40+
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
41+
# 2. release channel: dev, stable
42+
test:
43+
needs: analyze
44+
runs-on: ${{ matrix.os }}
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
# Add macos-latest and/or windows-latest if relevant for this package.
49+
os: [ubuntu-latest]
50+
sdk: [dev, 3.4]
51+
steps:
52+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
53+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
54+
with:
55+
sdk: ${{ matrix.sdk }}
56+
- id: install
57+
name: Install dependencies
58+
run: dart pub get
59+
- run: dart test
60+
if: always() && steps.install.outcome == 'success'
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# A workflow to close issues where the author hasn't responded to a request for
2+
# more information; see https://github.com/actions/stale.
3+
4+
name: No Response
5+
6+
# Run as a daily cron.
7+
on:
8+
schedule:
9+
# Every day at 8am
10+
- cron: '0 8 * * *'
11+
12+
# All permissions not specified are set to 'none'.
13+
permissions:
14+
issues: write
15+
pull-requests: write
16+
17+
jobs:
18+
no-response:
19+
runs-on: ubuntu-latest
20+
if: ${{ github.repository_owner == 'dart-lang' }}
21+
steps:
22+
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e
23+
with:
24+
# Don't automatically mark inactive issues+PRs as stale.
25+
days-before-stale: -1
26+
# Close needs-info issues and PRs after 14 days of inactivity.
27+
days-before-close: 14
28+
stale-issue-label: "needs-info"
29+
close-issue-message: >
30+
Without additional information we're not able to resolve this issue.
31+
Feel free to add more info or respond to any questions above and we
32+
can reopen the case. Thanks for your contribution!
33+
stale-pr-label: "needs-info"
34+
close-pr-message: >
35+
Without additional information we're not able to resolve this PR.
36+
Feel free to add more info or respond to any questions above.
37+
Thanks for your contribution!
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# A CI configuration to auto-publish pub packages.
2+
3+
name: Publish
4+
5+
on:
6+
pull_request:
7+
branches: [ master ]
8+
push:
9+
tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ]
10+
11+
jobs:
12+
publish:
13+
if: ${{ github.repository_owner == 'dart-lang' }}
14+
uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main

pkgs/io/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.dart_tool/
2+
.pub/
3+
.packages
4+
pubspec.lock

pkgs/io/AUTHORS

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

pkgs/io/CHANGELOG.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
## 1.0.5-wip
2+
3+
* Require Dart 3.4.
4+
5+
## 1.0.4
6+
7+
* Updates to the readme.
8+
9+
## 1.0.3
10+
11+
* Revert `meta` constraint to `^1.3.0`.
12+
13+
## 1.0.2
14+
15+
* Update `meta` constraint to `>=1.3.0 <3.0.0`.
16+
17+
## 1.0.1
18+
19+
* Update code examples to call the unified `dart` developer tool.
20+
21+
## 1.0.0
22+
23+
* Migrate this package to null-safety.
24+
* Require Dart >=2.12.
25+
26+
## 0.3.5
27+
28+
* Require Dart >=2.1.
29+
* Remove dependency on `package:charcode`.
30+
31+
## 0.3.4
32+
33+
* Fix a number of issues affecting the package score on `pub.dev`.
34+
35+
## 0.3.3
36+
37+
* Updates for Dart 2 constants. Require at least Dart `2.0.0-dev.54`.
38+
39+
* Fix the type of `StartProcess` typedef to match `Process.start` from
40+
`dart:io`.
41+
42+
## 0.3.2+1
43+
44+
* `ansi.dart`
45+
46+
* The "forScript" code paths now ignore the `ansiOutputEnabled` value. Affects
47+
the `escapeForScript` property on `AnsiCode` and the `wrap` and `wrapWith`
48+
functions when `forScript` is true.
49+
50+
## 0.3.2
51+
52+
* `ansi.dart`
53+
54+
* Added `forScript` named argument to top-level `wrapWith` function.
55+
56+
* `AnsiCode`
57+
58+
* Added `String get escapeForScript` property.
59+
60+
* Added `forScript` named argument to `wrap` function.
61+
62+
## 0.3.1
63+
64+
- Added `SharedStdIn.nextLine` (similar to `readLineSync`) and `lines`:
65+
66+
```dart
67+
main() async {
68+
// Prints the first line entered on stdin.
69+
print(await sharedStdIn.nextLine());
70+
71+
// Prints all remaining lines.
72+
await for (final line in sharedStdIn.lines) {
73+
print(line);
74+
}
75+
}
76+
```
77+
78+
- Added a `copyPath` and `copyPathSync` function, similar to `cp -R`.
79+
80+
- Added a dependency on `package:path`.
81+
82+
- Added the remaining missing arguments to `ProcessManager.spawnX` which
83+
forward to `Process.start`. It is now an interchangeable function for running
84+
a process.
85+
86+
## 0.3.0
87+
88+
- **BREAKING CHANGE**: The `arguments` argument to `ProcessManager.spawn` is
89+
now positional (not named) and required. This makes it more similar to the
90+
built-in `Process.start`, and easier to use as a drop in replacement:
91+
92+
```dart
93+
main() {
94+
processManager.spawn('dart', ['--version']);
95+
}
96+
```
97+
98+
- Fixed a bug where processes created from `ProcessManager.spawn` could not
99+
have their `stdout`/`stderr` read through their respective getters (a runtime
100+
error was always thrown).
101+
102+
- Added `ProcessMangaer#spawnBackground`, which does not forward `stdin`.
103+
104+
- Added `ProcessManager#spawnDetached`, which does not forward any I/O.
105+
106+
- Added the `shellSplit()` function, which parses a list of arguments in the
107+
same manner as [the POSIX shell][what_is_posix_shell].
108+
109+
[what_is_posix_shell]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html
110+
111+
## 0.2.0
112+
113+
- Initial commit of...
114+
- `FutureOr<bool> String isExecutable(path)`.
115+
- `ExitCode`
116+
- `ProcessManager` and `Spawn`
117+
- `sharedStdIn` and `SharedStdIn`
118+
- `ansi.dart` library with support for formatting terminal output

pkgs/io/LICENSE

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

pkgs/io/README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
[![ci](https://github.com/dart-lang/io/workflows/ci/badge.svg?branch=master)](https://github.com/dart-lang/io/actions?query=branch%3Amaster)
2+
[![pub package](https://img.shields.io/pub/v/io.svg)](https://pub.dev/packages/io)
3+
[![package publisher](https://img.shields.io/pub/publisher/io.svg)](https://pub.dev/packages/io/publisher)
4+
5+
Contains utilities for the Dart VM's `dart:io`.
6+
7+
## Usage - `io.dart`
8+
9+
### Files
10+
11+
#### `isExecutable`
12+
13+
Returns whether a provided file path is considered _executable_ on the host
14+
operating system.
15+
16+
### Processes
17+
18+
#### `ExitCode`
19+
20+
An `enum`-like class that contains known exit codes.
21+
22+
#### `ProcessManager`
23+
24+
A higher-level service for spawning and communicating with processes.
25+
26+
##### Use `spawn` to create a process with std[in|out|err] forwarded by default
27+
28+
```dart
29+
Future<void> main() async {
30+
final manager = ProcessManager();
31+
32+
// Print `dart` tool version to stdout.
33+
print('** Running `dart --version`');
34+
var spawn = await manager.spawn('dart', ['--version']);
35+
await spawn.exitCode;
36+
37+
// Check formatting and print the result to stdout.
38+
print('** Running `dart format --output=none .`');
39+
spawn = await manager.spawn('dart', ['format', '--output=none', '.']);
40+
await spawn.exitCode;
41+
42+
// Check if a package is ready for publishing.
43+
// Upon hitting a blocking stdin state, you may directly
44+
// output to the processes's stdin via your own, similar to how a bash or
45+
// shell script would spawn a process.
46+
print('** Running pub publish');
47+
spawn = await manager.spawn('dart', ['pub', 'publish', '--dry-run']);
48+
await spawn.exitCode;
49+
50+
// Closes stdin for the entire program.
51+
await sharedStdIn.terminate();
52+
}
53+
```
54+
55+
#### `sharedStdIn`
56+
57+
A safer version of the default `stdin` stream from `dart:io` that allows a
58+
subscriber to cancel their subscription, and then allows a _new_ subscriber to
59+
start listening. This differs from the default behavior where only a single
60+
listener is ever allowed in the application lifecycle:
61+
62+
```dart
63+
test('should allow multiple subscribers', () async {
64+
final logs = <String>[];
65+
final asUtf8 = sharedStdIn.transform(UTF8.decoder);
66+
// Wait for input for the user.
67+
logs.add(await asUtf8.first);
68+
// Wait for more input for the user.
69+
logs.add(await asUtf8.first);
70+
expect(logs, ['Hello World', 'Goodbye World']);
71+
});
72+
```
73+
74+
For testing, an instance of `SharedStdIn` may be created directly.
75+
76+
## Usage - `ansi.dart`
77+
78+
```dart
79+
import 'dart:io' as io;
80+
import 'package:io/ansi.dart';
81+
82+
void main() {
83+
// To use one style, call the `wrap` method on one of the provided top-level
84+
// values.
85+
io.stderr.writeln(red.wrap("Bad error!"));
86+
87+
// To use multiple styles, call `wrapWith`.
88+
print(wrapWith('** Important **', [red, styleBold, styleUnderlined]));
89+
90+
// The wrap functions will simply return the provided value unchanged if
91+
// `ansiOutputEnabled` is false.
92+
//
93+
// You can override the value `ansiOutputEnabled` by wrapping code in
94+
// `overrideAnsiOutput`.
95+
overrideAnsiOutput(false, () {
96+
assert('Normal text' == green.wrap('Normal text'));
97+
});
98+
}
99+
```
100+
101+
## Publishing automation
102+
103+
For information about our publishing automation and release process, see
104+
https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

0 commit comments

Comments
 (0)