Skip to content

Commit 98701e1

Browse files
committed
Merge package:yaml_edit into the tools monorepo
2 parents 5590447 + 86982d0 commit 98701e1

File tree

86 files changed

+9035
-0
lines changed

Some content is hidden

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

86 files changed

+9035
-0
lines changed

pkgs/yaml_edit/.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+
- "*"
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Comment on the pull request
2+
3+
on:
4+
# Trigger this workflow after the Publish workflow completes. This workflow
5+
# will have permissions to do things like create comments on the PR, even if
6+
# the original workflow couldn't.
7+
workflow_run:
8+
workflows:
9+
- Publish
10+
types:
11+
- completed
12+
13+
jobs:
14+
upload:
15+
uses: dart-lang/ecosystem/.github/workflows/post_summaries.yaml@main
16+
permissions:
17+
pull-requests: write
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# A CI configuration to auto-publish pub packages.
2+
3+
name: Publish
4+
5+
on:
6+
pull_request:
7+
branches: [ main ]
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
15+
with:
16+
write-comments: false
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Dart CI
2+
3+
on:
4+
# Run on PRs and pushes to the default branch.
5+
push:
6+
branches: [ main ]
7+
pull_request:
8+
branches: [ main ]
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+
# Add macos-latest and/or windows-latest if relevant for this package.
49+
os: [ubuntu-latest]
50+
sdk: ['3.1', stable, dev]
51+
platform: [vm, chrome]
52+
steps:
53+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
54+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
55+
with:
56+
sdk: ${{ matrix.sdk }}
57+
- id: install
58+
name: Install dependencies
59+
run: dart pub get
60+
- name: Run tests on ${{ matrix.platform }}
61+
run: dart test --platform ${{ matrix.platform }} --coverage=./coverage
62+
if: always() && steps.install.outcome == 'success'
63+
# We don't collect code coverage from 2.12.0, because it doesn't work
64+
- name: Convert coverage to lcov
65+
run: dart run coverage:format_coverage -i ./coverage -o ./coverage/lcov.info --lcov --report-on lib/
66+
if: always() && steps.install.outcome == 'success' && matrix.sdk != '2.12.0'
67+
- uses: coverallsapp/github-action@cfd0633edbd2411b532b808ba7a8b5e04f76d2c8
68+
if: always() && steps.install.outcome == 'success' && matrix.sdk != '2.12.0'
69+
with:
70+
flag-name: os:${{ matrix.os }}/dart:${{ matrix.sdk }}/platform:${{ matrix.platform }}
71+
parallel: true
72+
73+
report-coverage:
74+
needs: test
75+
if: ${{ always() }}
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: coverallsapp/github-action@cfd0633edbd2411b532b808ba7a8b5e04f76d2c8
79+
with:
80+
parallel-finished: true

pkgs/yaml_edit/.gitignore

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

pkgs/yaml_edit/CHANGELOG.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
## 2.2.2-wip
2+
3+
- Suppress warnings previously printed to `stdout` when parsing YAML internally.
4+
- Fix error thrown when inserting duplicate keys to different maps in the same
5+
list.
6+
([#69](https://github.com/dart-lang/yaml_edit/issues/69))
7+
8+
- Fix error thrown when inserting in nested list using `spliceList` method
9+
([#83](https://github.com/dart-lang/yaml_edit/issues/83))
10+
11+
- Fix error thrown when string has spaces when applying `ScalarStyle.FOLDED`.
12+
([#41](https://github.com/dart-lang/yaml_edit/issues/41)). Resolves
13+
([[#86](https://github.com/dart-lang/yaml_edit/issues/86)]).
14+
15+
- Require Dart 3.1
16+
17+
## 2.2.1
18+
19+
- Require Dart 3.0
20+
- Fix removal of last key in blockmap when key has no value
21+
([#55](https://github.com/dart-lang/yaml_edit/issues/55)).
22+
23+
## 2.2.0
24+
25+
- Fix inconsistent line endings when inserting maps into a document using `\r\n`.
26+
([#65](https://github.com/dart-lang/yaml_edit/issues/65))
27+
28+
- `AliasError` is changed to `AliasException` and exposed in the public API.
29+
30+
All node-mutating methods on `YamlEditor`, i.e. `update()`, `appendToList()`,
31+
`prependToList()`, `insertIntoList()`, `spliceList()`, `remove()` will now
32+
throw an exception instead of an error when encountering an alias on the path
33+
to modify.
34+
35+
This allows catching and handling when this is happening.
36+
37+
## 2.1.1
38+
39+
- Require Dart 2.19
40+
41+
## 2.1.0
42+
43+
- **Breaking** `wrapAsYamlNode(value, collectionStyle, scalarStyle)` will apply
44+
`collectionStyle` and `scalarStyle` recursively when wrapping a children of
45+
`Map` and `List`.
46+
While this may change the style of the YAML documents written by applications
47+
that rely on the old behavior, such YAML documents should still be valid.
48+
Hence, we hope it is reasonable to make this change in a minor release.
49+
- Fix for cases that can't be encoded correctly with
50+
`scalarStyle: ScalarStyle.SINGLE_QUOTED`.
51+
- Fix YamlEditor `appendToList` and `insertIntoList` functions inserts new item into next yaml item
52+
rather than at end of list.
53+
([#23](https://github.com/dart-lang/yaml_edit/issues/23))
54+
55+
## 2.0.3
56+
57+
- Updated the value of the pubspec `repository` field.
58+
59+
## 2.0.2
60+
61+
- Fix trailing whitespace after adding new key with block-value to map
62+
([#15](https://github.com/dart-lang/yaml_edit/issues/15)).
63+
- Updated `repository` and other meta-data in `pubspec.yaml`.
64+
65+
## 2.0.1
66+
67+
- License changed to BSD, as this package is now maintained by the Dart team.
68+
- Fixed minor lints.
69+
70+
## 2.0.0
71+
72+
- Migrated to null-safety.
73+
- API will no-longer return `null` in-place of a `YamlNode`, instead a
74+
`YamlNode` with `YamlNode.value == null` should be used. These are easily
75+
created with `wrapAsYamlNode(null)`.
76+
77+
## 1.0.3
78+
79+
- Fixed bug in adding an empty map as a map value.
80+
81+
## 1.0.2
82+
83+
- Throws an error if the final YAML after edit is not parsable.
84+
- Fixed bug in adding to empty map values, when it is followed by other content.
85+
86+
## 1.0.1
87+
88+
- Updated behavior surrounding list and map removal.
89+
- Fixed bug in dealing with empty values.
90+
91+
## 1.0.0
92+
93+
- Initial release.

pkgs/yaml_edit/LICENSE

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

pkgs/yaml_edit/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
[![Dart CI](https://github.com/dart-lang/yaml_edit/actions/workflows/test-package.yml/badge.svg)](https://github.com/dart-lang/yaml_edit/actions/workflows/test-package.yml)
2+
[![pub package](https://img.shields.io/pub/v/yaml_edit.svg)](https://pub.dev/packages/yaml_edit)
3+
[![package publisher](https://img.shields.io/pub/publisher/yaml_edit.svg)](https://pub.dev/packages/yaml_edit/publisher)
4+
[![Coverage Status](https://coveralls.io/repos/github/dart-lang/yaml_edit/badge.svg)](https://coveralls.io/github/dart-lang/yaml_edit)
5+
6+
A library for [YAML](https://yaml.org) manipulation while preserving comments.
7+
8+
## Usage
9+
10+
A simple usage example:
11+
12+
```dart
13+
import 'package:yaml_edit/yaml_edit.dart';
14+
15+
void main() {
16+
final yamlEditor = YamlEditor('{YAML: YAML}');
17+
yamlEditor.update(['YAML'], "YAML Ain't Markup Language");
18+
print(yamlEditor);
19+
// Expected output:
20+
// {YAML: YAML Ain't Markup Language}
21+
}
22+
```
23+
24+
### Example: Converting JSON to YAML (block formatted)
25+
26+
```dart
27+
void main() {
28+
final jsonString = r'''
29+
{
30+
"key": "value",
31+
"list": [
32+
"first",
33+
"second",
34+
"last entry in the list"
35+
],
36+
"map": {
37+
"multiline": "this is a fairly long string with\nline breaks..."
38+
}
39+
}
40+
''';
41+
final jsonValue = json.decode(jsonString);
42+
43+
// Convert jsonValue to YAML
44+
final yamlEditor = YamlEditor('');
45+
yamlEditor.update([], jsonValue);
46+
print(yamlEditor.toString());
47+
}
48+
```
49+
50+
## Testing
51+
52+
Testing is done in two strategies: Unit testing (`/test/editor_test.dart`) and
53+
Golden testing (`/test/golden_test.dart`). More information on Golden testing
54+
and the input/output format can be found at `/test/testdata/README.md`.
55+
56+
These tests are automatically run with `pub run test`.
57+
58+
## Limitations
59+
60+
1. Users are not allowed to define tags in the modifications.
61+
2. Map keys will always be added in the flow style.

pkgs/yaml_edit/analysis_options.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
include: package:dart_flutter_team_lints/analysis_options.yaml
2+
3+
analyzer:
4+
errors:
5+
inference_failure_on_collection_literal: ignore
6+
inference_failure_on_function_invocation: ignore
7+
inference_failure_on_function_return_type: ignore
8+
inference_failure_on_instance_creation: ignore

0 commit comments

Comments
 (0)