Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge package:yaml_edit #1662

Merged
merged 90 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
9b95570
Added yaml_edit (dart-lang/yaml_edit#52)
walnutdust Aug 7, 2020
1e2508d
Updated issue template and nits for yaml_edit
jonasfj Aug 7, 2020
6f88523
Using runZoned to remove test pollution (dart-lang/yaml_edit#54)
walnutdust Aug 10, 2020
578743c
Updated Travis configuration to allow packages to be tested in parall…
walnutdust Aug 24, 2020
50b12f3
Updating package:yaml_edit to deal with empty nodes (dart-lang/yaml_e…
walnutdust Aug 24, 2020
b4aa7c1
Remove yaml_edit dependency on quiver_hashcode (dart-lang/yaml_edit#61)
jonasfj Aug 27, 2020
8c7e3ee
Fixed bug in adding to empty map values, when it is followed by other…
walnutdust Aug 31, 2020
8228c8f
Removed @alwaysThrows (dart-lang/yaml_edit#64)
walnutdust Aug 31, 2020
1642a34
Minor documentation fixes for yaml_edit (dart-lang/yaml_edit#75)
walnutdust Oct 27, 2020
eef8815
Fixed bug with adding empty map (dart-lang/yaml_edit#78)
walnutdust Oct 30, 2020
bfda78d
Yaml edit/1.0.3 (dart-lang/yaml_edit#82)
walnutdust Nov 2, 2020
fb2335b
Random lint cleanup (dart-lang/yaml_edit#112)
kevmoo Mar 18, 2021
2104fb4
Add tests for parseAt with null values (dart-lang/yaml_edit#110)
asartalo Mar 19, 2021
2c15633
yaml_edit nullsafety (dart-lang/yaml_edit#107)
asartalo Apr 28, 2021
3dad073
Prepare yaml_edit version 2.0.0 (dart-lang/yaml_edit#126)
jonasfj Apr 28, 2021
ecade4f
yaml_edit null safety minor refactorings (dart-lang/yaml_edit#128)
asartalo May 17, 2021
39b3d1c
Fix a number of hints and lints (dart-lang/yaml_edit#151)
kevmoo Jul 20, 2021
ca7d53d
Bump mono_repo to v5.0.1 (dart-lang/yaml_edit#150)
kevmoo Jul 20, 2021
9dda1f5
Migrate out of mono_repo
jonasfj Sep 13, 2021
ad4f6fd
Configure github actions (dart-lang/yaml_edit#2)
jonasfj Sep 14, 2021
82b8144
Re-license under BSD as used by the Dart project. (dart-lang/yaml_edi…
jonasfj Sep 22, 2021
3d574c9
Use package:lints instead of pedantic (dart-lang/yaml_edit#4)
szakarias Sep 24, 2021
ecfbd2e
Bump to version 2.0.1 (dart-lang/yaml_edit#5)
szakarias Sep 27, 2021
dcb6ea3
Fix repo location (dart-lang/yaml_edit#6)
mit-mit Sep 27, 2021
70680cf
Drop unneeded dependency on pkg:pedantic (dart-lang/yaml_edit#8)
kevmoo Oct 25, 2021
9ecf569
Only run the golden tests on the vm (dart-lang/yaml_edit#9)
kevmoo Nov 5, 2021
64dff03
CI: fix the branch (dart-lang/yaml_edit#10)
kevmoo Nov 5, 2021
03646c4
Fix example usage in README and dartdoc (dart-lang/yaml_edit#17)
srawlins Mar 17, 2022
785f5b2
Do not add trailing whitespace to new map keys (dart-lang/yaml_edit#16)
srawlins Mar 17, 2022
524210f
Prepare 2.0.2 release (dart-lang/yaml_edit#7)
jonasfj Mar 17, 2022
d1c0e97
Ignore hint in test – not sure we want to refactor this (yet) (dart-l…
kevmoo Apr 7, 2022
828e993
Update pubspec.yaml (dart-lang/yaml_edit#20)
devoncarew Apr 25, 2022
b8efc78
prep for publishing 2.0.3 (dart-lang/yaml_edit#22)
devoncarew May 12, 2022
3ddc863
blast_repo fixes (dart-lang/yaml_edit#25)
kevmoo Nov 10, 2022
c8c3064
Bump actions/checkout from 3.1.0 to 3.2.0 (dart-lang/yaml_edit#27)
dependabot[bot] Jan 3, 2023
6340888
Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/yaml_edit#31)
dependabot[bot] Feb 1, 2023
065ce33
Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/yaml_edit#30)
dependabot[bot] Feb 1, 2023
c85d298
fixed typo (dart-lang/yaml_edit#36)
MikiPAUL Feb 24, 2023
9fbef94
Fix for issue dart-lang/yaml_edit#23 (dart-lang/yaml_edit#34)
Ishad-M-I-M Feb 28, 2023
dedf495
Update CHANGELOG.md (dart-lang/yaml_edit#37)
Ishad-M-I-M Mar 1, 2023
abb3cb5
Wrap recursively, prepare release (dart-lang/yaml_edit#28)
jonasfj Mar 2, 2023
6523e6b
Add code coverage (dart-lang/yaml_edit#38)
jonasfj Mar 2, 2023
6d3e93f
blast_repo fixes (dart-lang/yaml_edit#46)
kevmoo Mar 8, 2023
3930dad
updates for the next version of package:yaml (dart-lang/yaml_edit#45)
devoncarew Mar 8, 2023
d2d82cd
Fix YamlEditor.update method leaving trailing spaces at eol (dart-lan…
Ishad-M-I-M Mar 9, 2023
f467292
Require Dart 2.19, update to latest lints
kevmoo Mar 9, 2023
53f2bcc
Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/yaml_edit#49)
dependabot[bot] Apr 3, 2023
f407caa
Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/yaml_edit#48)
dependabot[bot] Apr 4, 2023
3ea66cf
Prepare 2.1.1 release (dart-lang/yaml_edit#52)
jonasfj May 2, 2023
8fadd3d
Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/yaml_edit#51)
dependabot[bot] May 8, 2023
fc3a05c
blast_repo fixes (dart-lang/yaml_edit#53)
devoncarew May 10, 2023
4c1b8c5
Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/yaml_edit#54)
dependabot[bot] Jul 1, 2023
ec7691b
Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/yaml_edit#56)
dependabot[bot] Sep 1, 2023
4109d9e
Change AliasError to AliasException (dart-lang/yaml_edit#57)
sigurdm Sep 28, 2023
bd61adf
Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/yaml_edit#59)
dependabot[bot] Oct 1, 2023
3962a92
Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/yaml_edit#58)
dependabot[bot] Oct 1, 2023
aa6047d
Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/yaml_edit#60)
dependabot[bot] Nov 1, 2023
c32e754
Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/yaml_edit#61)
dependabot[bot] Nov 1, 2023
9295cec
blast_repo fixes (dart-lang/yaml_edit#62)
kevmoo Dec 20, 2023
83c1f50
Bump actions/stale from 8.0.0 to 9.0.0 (dart-lang/yaml_edit#63)
dependabot[bot] Jan 1, 2024
49dd891
Bump dart-lang/setup-dart from 1.6.0 to 1.6.2 (dart-lang/yaml_edit#64)
dependabot[bot] Feb 1, 2024
085f605
update the publish workflow (dart-lang/yaml_edit#67)
devoncarew Feb 20, 2024
5e7e143
Fix line endings for inserted maps on Windows (dart-lang/yaml_edit#66)
DanTup Feb 21, 2024
6586faf
update to the latest sdk; update lints (dart-lang/yaml_edit#68)
devoncarew Feb 23, 2024
265b9bf
Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/yaml_edit#70)
dependabot[bot] Apr 1, 2024
01477c1
Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (dart-lang/yaml_edit#73)
dependabot[bot] May 1, 2024
7470d5b
Bump coverallsapp/github-action from 2.0.0.pre.rc1 to 2.2.3 (dart-lan…
dependabot[bot] May 1, 2024
5cf17f7
Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/yaml_edit#74)
dependabot[bot] May 1, 2024
43110ad
Fix 55 (dart-lang/yaml_edit#75)
jonasfj May 2, 2024
e81707f
Consume until end of document if there is no newline when removing fr…
jonasfj May 6, 2024
a32ff55
A few more tests to reduce risk of regressions (dart-lang/yaml_edit#77)
jonasfj May 6, 2024
4b482c7
blast_repo fixes (dart-lang/yaml_edit#78)
devoncarew May 13, 2024
df0986d
Bump the github-actions group with 2 updates (dart-lang/yaml_edit#79)
dependabot[bot] May 13, 2024
0c06c32
Better logging in random_test.dart, and less overall noise from warni…
jonasfj May 30, 2024
2ff5c64
Update CHANGELOG.md (dart-lang/yaml_edit#82)
jonasfj May 30, 2024
4c759a5
Fix error thrown when inserting keys (dart-lang/yaml_edit#80)
kekavc24 May 31, 2024
b8daf91
Bump actions/checkout from 4.1.5 to 4.1.6 in the github-actions group…
dependabot[bot] Jun 1, 2024
aafb9aa
Fix splice list insertion (dart-lang/yaml_edit#84)
kekavc24 Jun 6, 2024
0b605dd
Fix line folding (dart-lang/yaml_edit#87)
kekavc24 Jun 27, 2024
4a635ee
Bump the github-actions group with 2 updates (dart-lang/yaml_edit#92)
dependabot[bot] Jul 1, 2024
9719932
Fix fold literal encoding with trailing line break (dart-lang/yaml_ed…
kekavc24 Jul 4, 2024
ad84210
Bump and fix lints, require Dart 3.1 (dart-lang/yaml_edit#95)
kevmoo Jul 29, 2024
4e49bdf
fix lints (dart-lang/yaml_edit#97)
kevmoo Oct 7, 2024
42e46a6
Bump the github-actions group across 1 directory with 2 updates (dart…
dependabot[bot] Nov 1, 2024
b1f008e
Fix unused param in a private ctor lint (dart-lang/yaml_edit#99)
kevmoo Nov 18, 2024
86982d0
Bump dart-lang/setup-dart in the github-actions group (dart-lang/yaml…
dependabot[bot] Dec 1, 2024
98701e1
Merge package:yaml_edit into the tools monorepo
mosuem Dec 11, 2024
f3cddde
Add issue template and other fixes
mosuem Dec 11, 2024
9a4c94d
Moving fixes
mosuem Dec 11, 2024
cc22c3d
Merge branch 'main' into merge-yaml_edit-package
mosuem Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/yaml_edit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:yaml_edit"
about: "Create a bug or file a feature request against package:yaml_edit."
labels: "package:yaml_edit"
---
6 changes: 5 additions & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,8 @@

'package:yaml':
- changed-files:
- any-glob-to-any-file: 'pkgs/yaml/**'
- any-glob-to-any-file: 'pkgs/yaml/**'

'package:yaml_edit':
- changed-files:
- any-glob-to-any-file: 'pkgs/yaml_edit/**'
91 changes: 91 additions & 0 deletions .github/workflows/yaml_edit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: package:yaml_edit

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ main ]
paths:
- '.github/workflows/yaml_edit.yaml'
- 'pkgs/yaml_edit/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/yaml_edit.yaml'
- 'pkgs/yaml_edit/**'
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github


defaults:
run:
working-directory: pkgs/yaml_edit/

jobs:
# Check code formatting and static analysis on a single OS (linux)
# against Dart dev.
analyze:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- name: Analyze code
run: dart analyze --fatal-infos
if: always() && steps.install.outcome == 'success'

# Run tests on a matrix consisting of two dimensions:
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
# 2. release channel: dev
test:
needs: analyze
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: ['3.1', stable, dev]
platform: [vm, chrome]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Run tests on ${{ matrix.platform }}
run: dart test --platform ${{ matrix.platform }} --coverage=./coverage
if: always() && steps.install.outcome == 'success'
# We don't collect code coverage from 2.12.0, because it doesn't work
- name: Convert coverage to lcov
run: dart run coverage:format_coverage -i ./coverage -o ./coverage/lcov.info --lcov --report-on lib/
if: always() && steps.install.outcome == 'success' && matrix.sdk != '2.12.0'
- uses: coverallsapp/github-action@cfd0633edbd2411b532b808ba7a8b5e04f76d2c8
if: always() && steps.install.outcome == 'success' && matrix.sdk != '2.12.0'
with:
flag-name: os:${{ matrix.os }}/dart:${{ matrix.sdk }}/platform:${{ matrix.platform }}
parallel: true

report-coverage:
needs: test
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- uses: coverallsapp/github-action@cfd0633edbd2411b532b808ba7a8b5e04f76d2c8
with:
parallel-finished: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ don't naturally belong to other topic monorepos (like
| [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) |
| [watcher](pkgs/watcher/) | Monitor directories and send notifications when the contents change. | [![package issues](https://img.shields.io/badge/package:watcher-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Awatcher) | [![pub package](https://img.shields.io/pub/v/watcher.svg)](https://pub.dev/packages/watcher) |
| [yaml](pkgs/yaml/) | A parser for YAML, a human-friendly data serialization standard | [![package issues](https://img.shields.io/badge/package:yaml-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ayaml) | [![pub package](https://img.shields.io/pub/v/yaml.svg)](https://pub.dev/packages/yaml) |
| [yaml_edit](pkgs/yaml_edit/) | A library for YAML manipulation with comment and whitespace preservation. | [![package issues](https://img.shields.io/badge/package:yaml_edit-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ayaml_edit) | [![pub package](https://img.shields.io/pub/v/yaml_edit.svg)](https://pub.dev/packages/yaml_edit) |

## Publishing automation

Expand Down
3 changes: 3 additions & 0 deletions pkgs/yaml_edit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.dart_tool/
/.packages
/pubspec.lock
95 changes: 95 additions & 0 deletions pkgs/yaml_edit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
## 2.2.2

- Suppress warnings previously printed to `stdout` when parsing YAML internally.
- Fix error thrown when inserting duplicate keys to different maps in the same
list.
([#69](https://github.com/dart-lang/yaml_edit/issues/69))

- Fix error thrown when inserting in nested list using `spliceList` method
([#83](https://github.com/dart-lang/yaml_edit/issues/83))

- Fix error thrown when string has spaces when applying `ScalarStyle.FOLDED`.
([#41](https://github.com/dart-lang/yaml_edit/issues/41)). Resolves
([[#86](https://github.com/dart-lang/yaml_edit/issues/86)]).

- Require Dart 3.1

- Move to `dart-lang/tools` monorepo.

## 2.2.1

- Require Dart 3.0
- Fix removal of last key in blockmap when key has no value
([#55](https://github.com/dart-lang/yaml_edit/issues/55)).

## 2.2.0

- Fix inconsistent line endings when inserting maps into a document using `\r\n`.
([#65](https://github.com/dart-lang/yaml_edit/issues/65))

- `AliasError` is changed to `AliasException` and exposed in the public API.

All node-mutating methods on `YamlEditor`, i.e. `update()`, `appendToList()`,
`prependToList()`, `insertIntoList()`, `spliceList()`, `remove()` will now
throw an exception instead of an error when encountering an alias on the path
to modify.

This allows catching and handling when this is happening.

## 2.1.1

- Require Dart 2.19

## 2.1.0

- **Breaking** `wrapAsYamlNode(value, collectionStyle, scalarStyle)` will apply
`collectionStyle` and `scalarStyle` recursively when wrapping a children of
`Map` and `List`.
While this may change the style of the YAML documents written by applications
that rely on the old behavior, such YAML documents should still be valid.
Hence, we hope it is reasonable to make this change in a minor release.
- Fix for cases that can't be encoded correctly with
`scalarStyle: ScalarStyle.SINGLE_QUOTED`.
- Fix YamlEditor `appendToList` and `insertIntoList` functions inserts new item into next yaml item
rather than at end of list.
([#23](https://github.com/dart-lang/yaml_edit/issues/23))

## 2.0.3

- Updated the value of the pubspec `repository` field.

## 2.0.2

- Fix trailing whitespace after adding new key with block-value to map
([#15](https://github.com/dart-lang/yaml_edit/issues/15)).
- Updated `repository` and other meta-data in `pubspec.yaml`.

## 2.0.1

- License changed to BSD, as this package is now maintained by the Dart team.
- Fixed minor lints.

## 2.0.0

- Migrated to null-safety.
- API will no-longer return `null` in-place of a `YamlNode`, instead a
`YamlNode` with `YamlNode.value == null` should be used. These are easily
created with `wrapAsYamlNode(null)`.

## 1.0.3

- Fixed bug in adding an empty map as a map value.

## 1.0.2

- Throws an error if the final YAML after edit is not parsable.
- Fixed bug in adding to empty map values, when it is followed by other content.

## 1.0.1

- Updated behavior surrounding list and map removal.
- Fixed bug in dealing with empty values.

## 1.0.0

- Initial release.
26 changes: 26 additions & 0 deletions pkgs/yaml_edit/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright 2020, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 changes: 61 additions & 0 deletions pkgs/yaml_edit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[![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)
[![pub package](https://img.shields.io/pub/v/yaml_edit.svg)](https://pub.dev/packages/yaml_edit)
[![package publisher](https://img.shields.io/pub/publisher/yaml_edit.svg)](https://pub.dev/packages/yaml_edit/publisher)
[![Coverage Status](https://coveralls.io/repos/github/dart-lang/yaml_edit/badge.svg)](https://coveralls.io/github/dart-lang/yaml_edit)

A library for [YAML](https://yaml.org) manipulation while preserving comments.

## Usage

A simple usage example:

```dart
import 'package:yaml_edit/yaml_edit.dart';

void main() {
final yamlEditor = YamlEditor('{YAML: YAML}');
yamlEditor.update(['YAML'], "YAML Ain't Markup Language");
print(yamlEditor);
// Expected output:
// {YAML: YAML Ain't Markup Language}
}
```

### Example: Converting JSON to YAML (block formatted)

```dart
void main() {
final jsonString = r'''
{
"key": "value",
"list": [
"first",
"second",
"last entry in the list"
],
"map": {
"multiline": "this is a fairly long string with\nline breaks..."
}
}
''';
final jsonValue = json.decode(jsonString);

// Convert jsonValue to YAML
final yamlEditor = YamlEditor('');
yamlEditor.update([], jsonValue);
print(yamlEditor.toString());
}
```

## Testing

Testing is done in two strategies: Unit testing (`/test/editor_test.dart`) and
Golden testing (`/test/golden_test.dart`). More information on Golden testing
and the input/output format can be found at `/test/testdata/README.md`.

These tests are automatically run with `pub run test`.

## Limitations

1. Users are not allowed to define tags in the modifications.
2. Map keys will always be added in the flow style.
8 changes: 8 additions & 0 deletions pkgs/yaml_edit/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
errors:
inference_failure_on_collection_literal: ignore
inference_failure_on_function_invocation: ignore
inference_failure_on_function_return_type: ignore
inference_failure_on_instance_creation: ignore
12 changes: 12 additions & 0 deletions pkgs/yaml_edit/example/example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:yaml_edit/yaml_edit.dart';

void main() {
final doc = YamlEditor('''
- 0 # comment 0
- 1 # comment 1
- 2 # comment 2
''');
doc.remove([1]);

print(doc);
}
28 changes: 28 additions & 0 deletions pkgs/yaml_edit/example/json2yaml.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:convert' show json;

import 'package:yaml_edit/yaml_edit.dart';

void main() {
final jsonString = r'''
{
"key": "value",
"list": [
"first",
"second",
"last entry in the list"
],
"map": {
"multiline": "this is a fairly long string with\nline breaks..."
}
}
''';
final jsonValue = json.decode(jsonString);

final yamlEditor = YamlEditor('');
yamlEditor.update([], jsonValue);
print(yamlEditor.toString());
}
Loading
Loading