You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Work in progress: pubspec_yaml [](https://travis-ci.org/alexei-sintotski/pubspec_yaml)[](https://codecov.io/gh/alexei-sintotski/pubspec_yaml)[](https://pub.dev/packages/pubspec_yaml)
2
+
2
3
Dart library to access and manipulate content of pubpec.yaml files
3
4
4
-
## Class PubspecLock
5
+
## Class PubspecYaml
5
6
6
7
PubspecYaml is a data type representing data stored in pubspec.yaml files.
7
8
9
+
The following fields are supported:
10
+
* Package name
11
+
* Package version
12
+
* Package description
13
+
* Package author/authors
14
+
* Package homepage, repository, and issue tracker
15
+
* Package documentation
16
+
* Package server specification
17
+
* Dependency specifications: regular, dev, and overrides
18
+
* SDK constraints
19
+
* Command-line executables provided by the package
20
+
21
+
Other fields are accessible via PubspecYaml.customFields as a JSON structure (Map<String, dynamic>).
22
+
23
+
## YAML Import / Export
24
+
25
+
PubspecYaml provides two methods to serialize pubspec.yaml content:
26
+
* The factory method PubspecYaml.loadFromYamlString() creates an object from a string with pubspec.yaml content
27
+
* PubspecYaml.toYamlString() produces pubspec.yaml content that can be written to a file
28
+
29
+
## Data Manipulation
30
+
31
+
PubspecYaml uses functional_data extensions to enable equality operations and lenses (https://pub.dev/packages/functional_data).
32
+
8
33
## Usage
9
34
10
35
To use pubspec_yaml, add the following dependency to pubspec.yaml:
@@ -13,3 +38,33 @@ To use pubspec_yaml, add the following dependency to pubspec.yaml:
13
38
dependencies:
14
39
pubspec_yaml: ^1.0.0
15
40
```
41
+
42
+
## Example
43
+
44
+
The following Dart script checks whether production dependencies have overrides:
45
+
```
46
+
import 'dart:io';
47
+
48
+
import 'package:pubspec_yaml/pubspec_yaml.dart';
49
+
50
+
// ignore_for_file: avoid_print
51
+
52
+
void main() {
53
+
final pubspecYamlContent = File('pubspec.yaml').readAsStringSync();
54
+
final pubspecYaml = PubspecYaml.loadFromYamlString(pubspecYamlContent);
55
+
56
+
final productionOverrides = pubspecYaml.dependencyOverrides.where(
0 commit comments