Skip to content

Commit 4bddff0

Browse files
committed
Merge package:glob into the tools monorepo
2 parents ce30034 + 07d9ee5 commit 4bddff0

20 files changed

+2832
-0
lines changed

pkgs/glob/.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Dependabot configuration file.
2+
version: 2
3+
4+
updates:
5+
- package-ecosystem: github-actions
6+
directory: /
7+
schedule:
8+
interval: monthly
9+
labels:
10+
- autosubmit
11+
groups:
12+
github-actions:
13+
patterns:
14+
- "*"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# A CI configuration to auto-publish pub packages.
2+
3+
name: Publish
4+
5+
on:
6+
pull_request:
7+
branches: [ master ]
8+
types: [opened, synchronize, reopened, labeled, unlabeled]
9+
push:
10+
tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ]
11+
12+
jobs:
13+
publish:
14+
if: ${{ github.repository_owner == 'dart-lang' }}
15+
uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main
16+
with:
17+
sdk: dev
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Dart 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+
permissions: read-all
13+
14+
env:
15+
PUB_ENVIRONMENT: bot.github
16+
17+
jobs:
18+
# Check code formatting and static analysis on a single OS (linux)
19+
# against Dart dev.
20+
analyze:
21+
runs-on: ubuntu-latest
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
sdk: [dev]
26+
steps:
27+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
28+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
29+
with:
30+
channel: ${{ matrix.sdk }}
31+
- id: install
32+
name: Install dependencies
33+
run: dart pub get
34+
- name: Check formatting
35+
run: dart format --output=none --set-exit-if-changed .
36+
if: always() && steps.install.outcome == 'success'
37+
- name: Analyze code
38+
run: dart analyze --fatal-infos
39+
if: always() && steps.install.outcome == 'success'
40+
41+
# Run tests on a matrix consisting of two dimensions:
42+
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
43+
# 2. release channel: dev
44+
test:
45+
needs: analyze
46+
runs-on: ${{ matrix.os }}
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
# Add macos-latest and/or windows-latest if relevant for this package.
51+
os: [ubuntu-latest]
52+
sdk: [3.3, dev]
53+
steps:
54+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
55+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
56+
with:
57+
channel: ${{ matrix.sdk }}
58+
- id: install
59+
name: Install dependencies
60+
run: dart pub get
61+
- name: Run VM tests
62+
run: dart test --platform vm
63+
if: always() && steps.install.outcome == 'success'
64+
- name: Run Chrome tests
65+
run: dart test --platform chrome
66+
if: always() && steps.install.outcome == 'success'
67+
- name: Run Node tests
68+
run: dart test --platform node
69+
if: always() && steps.install.outcome == 'success'
70+
- name: Run Chrome tests - wasm
71+
run: dart test --platform chrome --compiler dart2wasm
72+
if: always() && steps.install.outcome == 'success' && matrix.sdk == 'dev'

pkgs/glob/.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Don’t commit the following directories created by pub.
2+
.buildlog
3+
.dart_tool/
4+
.pub/
5+
build/
6+
packages
7+
.packages
8+
9+
# Or the files created by dart2js.
10+
*.dart.js
11+
*.js_
12+
*.js.deps
13+
*.js.map
14+
15+
# Include when developing application packages.
16+
pubspec.lock

pkgs/glob/CHANGELOG.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
## 2.1.3-wip
2+
3+
- Require Dart 3.3.
4+
5+
## 2.1.2
6+
7+
- Allow `file` version `7.x`.
8+
- Require Dart 2.19.
9+
10+
## 2.1.1
11+
12+
- Updated the dependency on `package:file` to require at least `6.1.3`.
13+
14+
## 2.1.0
15+
16+
- Return empty results instead of throwing when trying to list a path that does
17+
not exist.
18+
19+
## 2.0.2
20+
21+
- Drop package:pedantic dependency, use package:lints instead.
22+
- Update SDK lower bound to `2.15.0`
23+
24+
## 2.0.1
25+
26+
- Update example in README for new import.
27+
28+
## 2.0.0
29+
30+
- Stable null safety release.
31+
32+
### Breaking Change
33+
34+
The `list*` apis on `Glob` have been renamed to `listFileSystem*` and they now
35+
require a `FileSystem` object from `package:file`.
36+
37+
There is a new convenience import, `package:glob/list_local_fs.dart` which
38+
provides the old methods as extensions, and automatically passes a
39+
`LocalFileSystem`.
40+
41+
## 1.2.1
42+
43+
- Add an empty list_local_fs.dart to ease upgrade from 1x to 2x
44+
45+
## 1.2.0
46+
47+
- Support running on Node.js.
48+
49+
## 1.1.7
50+
51+
- Set max SDK version to `<3.0.0`, and adjust other dependencies.
52+
53+
## 1.1.6
54+
55+
- Improve support for Dart 2 runtime semantics.
56+
57+
## 1.1.5
58+
59+
- Declare support for `async` 2.0.0.
60+
61+
- Require Dart 1.23.0.
62+
63+
## 1.1.4
64+
65+
- Throw an exception when listing globs whose initial paths don't exist in
66+
case-insensitive mode. This matches the case-sensitive behavior.
67+
68+
## 1.1.3
69+
70+
- Support `string_scanner` 1.0.0.
71+
72+
## 1.1.2
73+
74+
- Fix all strong mode errors and warnings.
75+
76+
## 1.1.1
77+
78+
- Fix a bug where listing an absolute glob with `caseInsensitive: false` failed.
79+
80+
## 1.1.0
81+
82+
- Add a `caseSensitive` named parameter to `new Glob()` that controls whether
83+
the glob is case-sensitive. This defaults to `false` on Windows and `true`
84+
elsewhere.
85+
86+
Matching case-insensitively on Windows is a behavioral change, but since it
87+
more closely matches the semantics of Windows paths it's considered a bug fix
88+
rather than a breaking change.
89+
90+
## 1.0.5
91+
92+
- Narrow the dependency on `path`. Previously, this allowed versions that didn't
93+
support all the functionality this package needs.
94+
95+
- Upgrade to the new test runner.
96+
97+
## 1.0.4
98+
99+
- Added overlooked `collection` dependency.
100+
101+
## 1.0.3
102+
103+
- Fix a bug where `Glob.list()` and `Glob.listSync()` would incorrectly throw
104+
exceptions when a directory didn't exist on the filesystem.
105+
106+
## 1.0.2
107+
108+
- Fixed `Glob.list()` on Windows.
109+
110+
## 1.0.1
111+
112+
- Fix several analyzer warnings.
113+
114+
- Fix the tests on Windows.

pkgs/glob/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2014, 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/glob/README.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
[![Dart CI](https://github.com/dart-lang/glob/actions/workflows/test-package.yml/badge.svg)](https://github.com/dart-lang/glob/actions/workflows/test-package.yml)
2+
[![pub package](https://img.shields.io/pub/v/glob.svg)](https://pub.dev/packages/glob)
3+
[![package publisher](https://img.shields.io/pub/publisher/glob.svg)](https://pub.dev/packages/glob/publisher)
4+
5+
`glob` is a file and directory globbing library that supports both checking
6+
whether a path matches a glob and listing all entities that match a glob.
7+
8+
A "glob" is a pattern designed specifically to match files and directories. Most
9+
shells support globs natively.
10+
11+
## Usage
12+
13+
To construct a glob, just use `Glob()`. As with `RegExp`s, it's a good idea to
14+
keep around a glob if you'll be using it more than once so that it doesn't have
15+
to be compiled over and over. You can check whether a path matches the glob
16+
using `Glob.matches()`:
17+
18+
```dart
19+
import 'package:glob/glob.dart';
20+
21+
final dartFile = Glob("**.dart");
22+
23+
// Print all command-line arguments that are Dart files.
24+
void main(List<String> arguments) {
25+
for (var argument in arguments) {
26+
if (dartFile.matches(argument)) print(argument);
27+
}
28+
}
29+
```
30+
31+
You can also list all files that match a glob using `Glob.list()` or
32+
`Glob.listSync()`:
33+
34+
```dart
35+
import 'package:glob/glob.dart';
36+
import 'package:glob/list_local_fs.dart';
37+
38+
final dartFile = Glob("**.dart");
39+
40+
// Recursively list all Dart files in the current directory.
41+
void main(List<String> arguments) {
42+
for (var entity in dartFile.listSync()) {
43+
print(entity.path);
44+
}
45+
}
46+
```
47+
48+
## Syntax
49+
50+
The glob syntax hews closely to the widely-known Bash glob syntax, with a few
51+
exceptions that are outlined below.
52+
53+
In order to be as cross-platform and as close to the Bash syntax as possible,
54+
all globs use POSIX path syntax, including using `/` as a directory separator
55+
regardless of which platform they're on. This is true even for Windows roots;
56+
for example, a glob matching all files in the C drive would be `C:/*`.
57+
58+
Globs are case-sensitive by default on Posix systems and browsers, and
59+
case-insensitive by default on Windows.
60+
61+
### Match any characters in a filename: `*`
62+
63+
The `*` character matches zero or more of any character other than `/`. This
64+
means that it can be used to match all files in a given directory that match a
65+
pattern without also matching files in a subdirectory. For example, `lib/*.dart`
66+
will match `lib/glob.dart` but not `lib/src/utils.dart`.
67+
68+
### Match any characters across directories: `**`
69+
70+
`**` is like `*`, but matches `/` as well. It's useful for matching files or
71+
listing directories recursively. For example, `lib/**.dart` will match both
72+
`lib/glob.dart` and `lib/src/utils.dart`.
73+
74+
If `**` appears at the beginning of a glob, it won't match absolute paths or
75+
paths beginning with `../`. For example, `**.dart` won't match `/foo.dart`,
76+
although `/**.dart` will. This is to ensure that listing a bunch of paths and
77+
checking whether they match a glob produces the same results as listing that
78+
glob. In the previous example, `/foo.dart` wouldn't be listed for `**.dart`, so
79+
it shouldn't be matched by it either.
80+
81+
This is an extension to Bash glob syntax that's widely supported by other glob
82+
implementations.
83+
84+
### Match any single character: `?`
85+
86+
The `?` character matches a single character other than `/`. Unlike `*`, it
87+
won't match any more or fewer than one character. For example, `test?.dart` will
88+
match `test1.dart` but not `test10.dart` or `test.dart`.
89+
90+
### Match a range of characters: `[...]`
91+
92+
The `[...]` construction matches one of several characters. It can contain
93+
individual characters, such as `[abc]`, in which case it will match any of those
94+
characters; it can contain ranges, such as `[a-zA-Z]`, in which case it will
95+
match any characters that fall within the range; or it can contain a mix of
96+
both. It will only ever match a single character. For example,
97+
`test[a-zA-Z_].dart` will match `testx.dart`, `testA.dart`, and `test_.dart`,
98+
but not `test-.dart`.
99+
100+
If it starts with `^` or `!`, the construction will instead match all characters
101+
_not_ mentioned. For example, `test[^a-z].dart` will match `test1.dart` but not
102+
`testa.dart`.
103+
104+
This construction never matches `/`.
105+
106+
### Match one of several possibilities: `{...,...}`
107+
108+
The `{...,...}` construction matches one of several options, each of which is a
109+
glob itself. For example, `lib/{*.dart,src/*}` matches `lib/glob.dart` and
110+
`lib/src/data.txt`. It can contain any number of options greater than one, and
111+
can even contain nested options.
112+
113+
This is an extension to Bash glob syntax, although it is supported by other
114+
layers of Bash and is often used in conjunction with globs.
115+
116+
### Escaping a character: `\`
117+
118+
The `\` character can be used in any context to escape a character that would
119+
otherwise be semantically meaningful. For example, `\*.dart` matches `*.dart`
120+
but not `test.dart`.
121+
122+
### Syntax errors
123+
124+
Because they're used as part of the shell, almost all strings are valid Bash
125+
globs. This implementation is more picky, and performs some validation to ensure
126+
that globs are meaningful. For instance, unclosed `{` and `[` are disallowed.
127+
128+
### Reserved syntax: `(...)`
129+
130+
Parentheses are reserved in case this package adds support for Bash extended
131+
globbing in the future. For the time being, using them will throw an error
132+
unless they're escaped.

0 commit comments

Comments
 (0)