Skip to content

Commit c90e95b

Browse files
authored
Merge pull request #1660 from dart-lang/merge-term_glyph-package
Merge `package:term_glyph`
2 parents 4dcd4d9 + 983e272 commit c90e95b

19 files changed

+1461
-0
lines changed

.github/ISSUE_TEMPLATE/term_glyph.md

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

.github/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
- changed-files:
109109
- any-glob-to-any-file: 'pkgs/sse/**'
110110

111+
'package:term_glyph':
112+
- changed-files:
113+
- any-glob-to-any-file: 'pkgs/term_glyph/**'
114+
111115
'package:test_reflective_loader':
112116
- changed-files:
113117
- any-glob-to-any-file: 'pkgs/test_reflective_loader/**'

.github/workflows/term_glyph.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: package:term_glyph
2+
3+
on:
4+
# Run on PRs and pushes to the default branch.
5+
push:
6+
branches: [ main ]
7+
paths:
8+
- '.github/workflows/term_glyph.yaml'
9+
- 'pkgs/term_glyph/**'
10+
pull_request:
11+
branches: [ main ]
12+
paths:
13+
- '.github/workflows/term_glyph.yaml'
14+
- 'pkgs/term_glyph/**'
15+
schedule:
16+
- cron: "0 0 * * 0"
17+
18+
env:
19+
PUB_ENVIRONMENT: bot.github
20+
21+
22+
defaults:
23+
run:
24+
working-directory: pkgs/term_glyph/
25+
26+
jobs:
27+
# Check code formatting and static analysis on a single OS (linux)
28+
# against Dart dev.
29+
analyze:
30+
runs-on: ubuntu-latest
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
sdk: [dev]
35+
steps:
36+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
37+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
38+
with:
39+
sdk: ${{ matrix.sdk }}
40+
- id: install
41+
name: Install dependencies
42+
run: dart pub get
43+
- name: Check formatting
44+
run: dart format --output=none --set-exit-if-changed .
45+
if: always() && steps.install.outcome == 'success'
46+
- name: Analyze code
47+
run: dart analyze --fatal-infos
48+
if: always() && steps.install.outcome == 'success'
49+
50+
# Run tests on a matrix consisting of two dimensions:
51+
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
52+
# 2. release channel: dev
53+
test:
54+
needs: analyze
55+
runs-on: ${{ matrix.os }}
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
# Add macos-latest and/or windows-latest if relevant for this package.
60+
os: [ubuntu-latest]
61+
sdk: [3.1, dev]
62+
steps:
63+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
64+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
65+
with:
66+
sdk: ${{ matrix.sdk }}
67+
- id: install
68+
name: Install dependencies
69+
run: dart pub get
70+
- name: Run VM tests
71+
run: dart test --platform vm
72+
if: always() && steps.install.outcome == 'success'

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ don't naturally belong to other topic monorepos (like
4040
| [source_maps](pkgs/source_maps/) | A library to programmatically manipulate source map files. | [![package issues](https://img.shields.io/badge/package:source_maps-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_maps) | [![pub package](https://img.shields.io/pub/v/source_maps.svg)](https://pub.dev/packages/source_maps) |
4141
| [source_span](pkgs/source_span/) | Provides a standard representation for source code locations and spans. | [![package issues](https://img.shields.io/badge/package:source_span-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_span) | [![pub package](https://img.shields.io/pub/v/source_span.svg)](https://pub.dev/packages/source_span) |
4242
| [sse](pkgs/sse/) | Provides client and server functionality for setting up bi-directional communication through Server Sent Events (SSE) and corresponding POST requests. | [![package issues](https://img.shields.io/badge/package:sse-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asse) | [![pub package](https://img.shields.io/pub/v/sse.svg)](https://pub.dev/packages/sse) |
43+
| [term_glyph](pkgs/term_glyph/) | Useful Unicode glyphs and ASCII substitutes. | [![package issues](https://img.shields.io/badge/package:term_glyph-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aterm_glyph) | [![pub package](https://img.shields.io/pub/v/term_glyph.svg)](https://pub.dev/packages/term_glyph) |
4344
| [test_reflective_loader](pkgs/test_reflective_loader/) | Support for discovering tests and test suites using reflection. | [![package issues](https://img.shields.io/badge/package:test_reflective_loader-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Atest_reflective_loader) | [![pub package](https://img.shields.io/pub/v/test_reflective_loader.svg)](https://pub.dev/packages/test_reflective_loader) |
4445
| [timing](pkgs/timing/) | A simple package for tracking the performance of synchronous and asynchronous actions. | [![package issues](https://img.shields.io/badge/package:timing-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Atiming) | [![pub package](https://img.shields.io/pub/v/timing.svg)](https://pub.dev/packages/timing) |
4546
| [unified_analytics](pkgs/unified_analytics/) | A package for logging analytics for all Dart and Flutter related tooling to Google Analytics. | [![package issues](https://img.shields.io/badge/package:unified_analytics-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aunified_analytics) | [![pub package](https://img.shields.io/pub/v/unified_analytics.svg)](https://pub.dev/packages/unified_analytics) |

pkgs/term_glyph/.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/term_glyph/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 project. Names should be added to the list like so:
3+
#
4+
# Name/Organization <email address>
5+
6+
Google Inc.

pkgs/term_glyph/CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## 1.2.2
2+
3+
* Require Dart 3.1
4+
* Move to `dart-lang/tools` monorepo.
5+
6+
## 1.2.1
7+
8+
* Migrate to `package:lints`.
9+
* Populate the pubspec `repository` field.
10+
11+
## 1.2.0
12+
13+
* Stable release for null safety.
14+
* Update SDK constraints to `>=2.12.0-0 <3.0.0` based on beta release
15+
guidelines.
16+
17+
## 1.1.0
18+
19+
* Add a `GlyphSet` class that can be used to easily choose which set of glyphs
20+
to use for a particular chunk of code.
21+
22+
* Add `asciiGlyphs`, `unicodeGlyphs`, and `glyphs` getters that provide access
23+
to `GlyphSet`s.
24+
25+
## 1.0.1
26+
27+
* Set max SDK version to `<3.0.0`.
28+
29+
## 1.0.0
30+
31+
* Initial version.

pkgs/term_glyph/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/term_glyph/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[![Build Status](https://github.com/dart-lang/tools/actions/workflows/term_glyph.yaml/badge.svg)](https://github.com/dart-lang/tools/actions/workflows/term_glyph.yaml)
2+
[![pub package](https://img.shields.io/pub/v/term_glyph.svg)](https://pub.dev/packages/term_glyph)
3+
[![package publisher](https://img.shields.io/pub/publisher/term_glyph.svg)](https://pub.dev/packages/term_glyph/publisher)
4+
5+
This library contains getters for useful Unicode glyphs as well as plain ASCII
6+
alternatives. It's intended to be used in command-line applications that may run
7+
in places where Unicode isn't well-supported and libraries that may be used by
8+
those applications.
9+
10+
We recommend that you import this library with the prefix "glyph". For example:
11+
12+
```dart
13+
import 'package:term_glyph/term_glyph.dart' as glyph;
14+
15+
/// Formats [items] into a bulleted list, with one item per line.
16+
String bulletedList(List<String> items) =>
17+
items.map((item) => "${glyph.bullet} $item").join("\n");
18+
```
19+
20+
## ASCII Mode
21+
22+
Some shells are unable to display Unicode characters, so this package is able to
23+
transparently switch its glyphs to ASCII alternatives by setting [the `ascii`
24+
attribute][ascii]. When this attribute is `true`, all glyphs use ASCII
25+
characters instead. It currently defaults to `false`, although in the future it
26+
may default to `true` for applications running on the Dart VM on Windows. For
27+
example:
28+
29+
[ascii]: https://pub.dev/documentation/term_glyph/latest/term_glyph/ascii.html
30+
31+
```dart
32+
import 'dart:io';
33+
34+
import 'package:term_glyph/term_glyph.dart' as glyph;
35+
36+
void main() {
37+
glyph.ascii = Platform.isWindows;
38+
39+
// Prints "Unicode => ASCII" on Windows, "Unicode ━▶ ASCII" everywhere else.
40+
print("Unicode ${glyph.rightArrow} ASCII");
41+
}
42+
```
43+
44+
All ASCII glyphs are guaranteed to be the same number of characters as the
45+
corresponding Unicode glyphs, so that they line up properly when printed on a
46+
terminal. The specific ASCII text for a given Unicode glyph may change over
47+
time; this is not considered a breaking change.

pkgs/term_glyph/analysis_options.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# https://dart.dev/guides/language/analysis-options
2+
include: package:dart_flutter_team_lints/analysis_options.yaml
3+
4+
analyzer:
5+
language:
6+
strict-casts: true
7+
strict-inference: true
8+
strict-raw-types: true
9+
10+
linter:
11+
rules:
12+
- avoid_bool_literals_in_conditional_expressions
13+
- avoid_classes_with_only_static_members
14+
- avoid_private_typedef_functions
15+
- avoid_redundant_argument_values
16+
- avoid_returning_this
17+
- avoid_unused_constructor_parameters
18+
- avoid_void_async
19+
- cancel_subscriptions
20+
- join_return_with_assignment
21+
- literal_only_boolean_expressions
22+
- missing_whitespace_between_adjacent_strings
23+
- no_adjacent_strings_in_list
24+
- no_runtimeType_toString
25+
- prefer_const_declarations
26+
- prefer_expression_function_bodies
27+
- prefer_final_locals
28+
- unnecessary_await_in_return
29+
- unnecessary_breaks
30+
- use_if_null_to_convert_nulls_to_bools
31+
- use_raw_strings
32+
- use_string_buffers

0 commit comments

Comments
 (0)