Skip to content

Commit 4ed467e

Browse files
committed
Merge package:package_config into the tools monorepo
2 parents 223daf5 + adca221 commit 4ed467e

29 files changed

+4315
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Set update schedule for GitHub Actions
2+
# See https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot
3+
4+
version: 2
5+
updates:
6+
7+
- package-ecosystem: github-actions
8+
directory: /
9+
schedule:
10+
interval: monthly
11+
labels:
12+
- autosubmit
13+
groups:
14+
github-actions:
15+
patterns:
16+
- "*"
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
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.
18+
analyze:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
sdk: [dev]
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
42+
test:
43+
needs: analyze
44+
runs-on: ${{ matrix.os }}
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
os: [ubuntu-latest, windows-latest]
49+
sdk: [3.4, dev]
50+
steps:
51+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
52+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
53+
with:
54+
sdk: ${{ matrix.sdk }}
55+
- id: install
56+
name: Install dependencies
57+
run: dart pub get
58+
- name: Run tests
59+
run: dart test -p chrome,vm
60+
if: always() && steps.install.outcome == 'success'

pkgs/package_config/.gitignore

Lines changed: 7 additions & 0 deletions
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

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

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

pkgs/package_config/CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Want to contribute? Great! First, read this page (including the small print at
2+
the end).
3+
4+
### Before you contribute
5+
Before we can use your code, you must sign the
6+
[Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual)
7+
(CLA), which you can do online. The CLA is necessary mainly because you own the
8+
copyright to your changes, even after your contribution becomes part of our
9+
codebase, so we need your permission to use and distribute your code. We also
10+
need to be sure of various other things—for instance that you'll tell us if you
11+
know that your code infringes on other people's patents. You don't have to sign
12+
the CLA until after you've submitted your code for review and a member has
13+
approved it, but you must do it before we can put your code into our codebase.
14+
15+
Before you start working on a larger contribution, you should get in touch with
16+
us first through the issue tracker with your idea so that we can help out and
17+
possibly guide you. Coordinating up front makes it much easier to avoid
18+
frustration later on.
19+
20+
### Code reviews
21+
All submissions, including submissions by project members, require review.
22+
23+
### File headers
24+
All files in the project must start with the following header.
25+
26+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
27+
// for details. All rights reserved. Use of this source code is governed by a
28+
// BSD-style license that can be found in the LICENSE file.
29+
30+
### The small print
31+
Contributions made by corporations are covered by a different agreement than the
32+
one above, the
33+
[Software Grant and Corporate Contributor License Agreement](https://developers.google.com/open-source/cla/corporate).

pkgs/package_config/LICENSE

Lines changed: 27 additions & 0 deletions
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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[![Build Status](https://github.com/dart-lang/package_config/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/package_config/actions?query=workflow%3A"Dart+CI"+branch%3Amaster)
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.
Lines changed: 5 additions & 0 deletions
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

Lines changed: 19 additions & 0 deletions
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)