Skip to content

Commit 8934289

Browse files
authored
Merge branch 'main' into merge-pub_semver-package
2 parents 5a6d593 + 7cbd039 commit 8934289

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+5773
-0
lines changed
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
name: "package:package_config"
3+
about: "Create a bug or file a feature request against package:package_config."
4+
labels: "package:package_config"
5+
---

.github/ISSUE_TEMPLATE/pool.md

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

.github/labeler.yml

+8
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@
8080
- changed-files:
8181
- any-glob-to-any-file: 'pkgs/oauth2/**'
8282

83+
'package:package_config':
84+
- changed-files:
85+
- any-glob-to-any-file: 'pkgs/package_config/**'
86+
87+
'package:pool':
88+
- changed-files:
89+
- any-glob-to-any-file: 'pkgs/pool/**'
90+
8391
'package:pub_semver':
8492
- changed-files:
8593
- any-glob-to-any-file: 'pkgs/pub_semver/**'

.github/workflows/package_config.yaml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: package:package_config
2+
3+
on:
4+
# Run on PRs and pushes to the default branch.
5+
push:
6+
branches: [ main ]
7+
paths:
8+
- '.github/workflows/package_config.yml'
9+
- 'pkgs/package_config/**'
10+
pull_request:
11+
branches: [ main ]
12+
paths:
13+
- '.github/workflows/package_config.yml'
14+
- 'pkgs/package_config/**'
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/package_config/
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+
os: [ubuntu-latest, windows-latest]
60+
sdk: [3.4, dev]
61+
steps:
62+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
63+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
64+
with:
65+
sdk: ${{ matrix.sdk }}
66+
- id: install
67+
name: Install dependencies
68+
run: dart pub get
69+
- name: Run tests
70+
run: dart test -p chrome,vm
71+
if: always() && steps.install.outcome == 'success'

.github/workflows/pool.yaml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: package:pool
2+
3+
on:
4+
# Run on PRs and pushes to the default branch.
5+
push:
6+
branches: [ main ]
7+
paths:
8+
- '.github/workflows/pool.yaml'
9+
- 'pkgs/pool/**'
10+
pull_request:
11+
branches: [ main ]
12+
paths:
13+
- '.github/workflows/pool.yaml'
14+
- 'pkgs/pool/**'
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/pool/
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.4, 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'
73+
- name: Run Chrome tests
74+
run: dart test --platform chrome
75+
if: always() && steps.install.outcome == 'success'
76+
- name: Run Chrome tests - wasm
77+
run: dart test --platform chrome -c dart2wasm
78+
if: always() && steps.install.outcome == 'success' && matrix.sdk == 'dev'

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ don't naturally belong to other topic monorepos (like
3333
| [json_rpc_2](pkgs/json_rpc_2/) | Utilities to write a client or server using the JSON-RPC 2.0 spec. | [![package issues](https://img.shields.io/badge/package:json_rpc_2-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ajson_rpc_2) | [![pub package](https://img.shields.io/pub/v/json_rpc_2.svg)](https://pub.dev/packages/json_rpc_2) |
3434
| [mime](pkgs/mime/) | Utilities for handling media (MIME) types, including determining a type from a file extension and file contents. | [![package issues](https://img.shields.io/badge/package:mime-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Amime) | [![pub package](https://img.shields.io/pub/v/mime.svg)](https://pub.dev/packages/mime) |
3535
| [oauth2](pkgs/oauth2/) | A client library for authenticating with a remote service via OAuth2 on behalf of a user, and making authorized HTTP requests with the user's OAuth2 credentials. | [![package issues](https://img.shields.io/badge/package:oauth2-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aoauth2) | [![pub package](https://img.shields.io/pub/v/oauth2.svg)](https://pub.dev/packages/oauth2) |
36+
| [package_config](pkgs/package_config/) | Support for reading and writing Dart Package Configuration files. | [![package issues](https://img.shields.io/badge/package:package_config-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Apackage_config) | [![pub package](https://img.shields.io/pub/v/package_config.svg)](https://pub.dev/packages/package_config) |
37+
| [pool](pkgs/pool/) | Manage a finite pool of resources. Useful for controlling concurrent file system or network requests. | [![package issues](https://img.shields.io/badge/package:pool-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Apool) | [![pub package](https://img.shields.io/pub/v/pool.svg)](https://pub.dev/packages/pool) |
3638
| [pub_semver](pkgs/pub_semver/) | Versions and version constraints implementing pub's versioning policy. This is very similar to vanilla semver, with a few corner cases. | [![package issues](https://img.shields.io/badge/package:pub_semver-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Apub_semver) | [![pub package](https://img.shields.io/pub/v/pub_semver.svg)](https://pub.dev/packages/pub_semver) |
3739
| [source_map_stack_trace](pkgs/source_map_stack_trace/) | A package for applying source maps to stack traces. | [![package issues](https://img.shields.io/badge/package:source_map_stack_trace-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_map_stack_trace) | [![pub package](https://img.shields.io/pub/v/source_map_stack_trace.svg)](https://pub.dev/packages/source_map_stack_trace) |
3840
| [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/package_config/.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.packages
2+
.pub
3+
.dart_tool/
4+
.vscode/
5+
packages
6+
pubspec.lock
7+
doc/api/

pkgs/package_config/AUTHORS

+6
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/package_config/CHANGELOG.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
## 2.1.1
2+
3+
- Require Dart 3.4
4+
- Move to `dart-lang/tools` monorepo.
5+
6+
## 2.1.0
7+
8+
- Adds `minVersion` to `findPackageConfig` and `findPackageConfigVersion`
9+
which allows ignoring earlier versions (which currently only means
10+
ignoring version 1, aka. `.packages` files.)
11+
12+
- Changes the version number of `SimplePackageConfig.empty` to the
13+
current maximum version.
14+
15+
- Improve file read performance; improve lookup performance.
16+
- Emit an error when a package is inside the package root of another package.
17+
- Fix a link in the readme.
18+
19+
## 2.0.2
20+
21+
- Update package description and README.
22+
- Change to package:lints for style checking.
23+
- Add an example.
24+
25+
## 2.0.1
26+
27+
- Use unique library names to correct docs issue.
28+
29+
## 2.0.0
30+
31+
- Migrate to null safety.
32+
- Remove legacy APIs.
33+
- Adds `relativeRoot` property to `Package` which controls whether to
34+
make the root URI relative when writing a configuration file.
35+
36+
## 1.9.3
37+
38+
- Fix `Package` constructor not accepting relative `packageUriRoot`.
39+
40+
## 1.9.2
41+
42+
- Updated to support new rules for picking `package_config.json` over
43+
a specified `.packages`.
44+
- Deduce package root from `.packages` derived package configuration,
45+
and default all such packages to language version 2.7.
46+
47+
## 1.9.1
48+
49+
- Remove accidental transitive import of `dart:io` from entrypoints that are
50+
supposed to be cross-platform compatible.
51+
52+
## 1.9.0
53+
54+
- Based on new JSON file format with more content.
55+
- This version includes all the new functionality intended for a 2.0.0
56+
version, as well as the, now deprecated, version 1 functionality.
57+
When we release 2.0.0, the deprecated functionality will be removed.
58+
59+
## 1.1.0
60+
61+
- Allow parsing files with default-package entries and metadata.
62+
A default-package entry has an empty key and a valid package name
63+
as value.
64+
Metadata is attached as fragments to base URIs.
65+
66+
## 1.0.5
67+
68+
- Fix usage of SDK constants.
69+
70+
## 1.0.4
71+
72+
- Set max SDK version to <3.0.0.
73+
74+
## 1.0.3
75+
76+
- Removed unneeded dependency constraint on SDK.
77+
78+
## 1.0.2
79+
80+
- Update SDK constraint to be 2.0.0 dev friendly.
81+
82+
## 1.0.1
83+
84+
- Fix test to not write to sink after it's closed.
85+
86+
## 1.0.0
87+
88+
- Public API marked stable.
89+
90+
## 0.1.5
91+
92+
- `FilePackagesDirectoryPackages.getBase(..)` performance improvements.
93+
94+
## 0.1.4
95+
96+
- Strong mode fixes.
97+
98+
## 0.1.3
99+
100+
- Invalid test cleanup (to keep up with changes in `Uri`).
101+
102+
## 0.1.1
103+
104+
- Syntax updates.
105+
106+
## 0.1.0
107+
108+
- Initial implementation.

pkgs/package_config/LICENSE

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2019, 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/package_config/README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[![Build Status](https://github.com/dart-lang/tools/actions/workflows/package_config.yaml/badge.svg)](https://github.com/dart-lang/tools/actions/workflows/package_config.yaml)
2+
[![pub package](https://img.shields.io/pub/v/package_config.svg)](https://pub.dev/packages/package_config)
3+
[![package publisher](https://img.shields.io/pub/publisher/package_config.svg)](https://pub.dev/packages/package_config/publisher)
4+
5+
Support for working with **Package Configuration** files as described
6+
in the Package Configuration v2 [design document](https://github.com/dart-lang/language/blob/master/accepted/2.8/language-versioning/package-config-file-v2.md).
7+
8+
A Dart package configuration file is used to resolve Dart package names (e.g.
9+
`foobar`) to Dart files containing the source code for that package (e.g.
10+
`file:///Users/myuser/.pub-cache/hosted/pub.dartlang.org/foobar-1.1.0`). The
11+
standard package configuration file is `.dart_tool/package_config.json`, and is
12+
written by the Dart tool when the command `dart pub get` is run.
13+
14+
The primary libraries of this package are
15+
* `package_config.dart`:
16+
Defines the `PackageConfig` class and other types needed to use
17+
package configurations, and provides functions to find, read and
18+
write package configuration files.
19+
20+
* `package_config_types.dart`:
21+
Just the `PackageConfig` class and other types needed to use
22+
package configurations. This library does not depend on `dart:io`.
23+
24+
The package includes deprecated backwards compatible functionality to
25+
work with the `.packages` file. This functionality will not be maintained,
26+
and will be removed in a future version of this package.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
# for details. All rights reserved. Use of this source code is governed by a
3+
# BSD-style license that can be found in the LICENSE file.
4+
5+
include: package:dart_flutter_team_lints/analysis_options.yaml

pkgs/package_config/example/main.dart

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:io' show Directory;
6+
7+
import 'package:package_config/package_config.dart';
8+
9+
void main() async {
10+
var packageConfig = await findPackageConfig(Directory.current);
11+
if (packageConfig == null) {
12+
print('Failed to locate or read package config.');
13+
} else {
14+
print('This package depends on ${packageConfig.packages.length} packages:');
15+
for (var package in packageConfig.packages) {
16+
print('- ${package.name}');
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)