Skip to content

Commit 7f979c5

Browse files
Preparations to publish the initial version 1.0.0
1 parent f689c8f commit 7f979c5

File tree

4 files changed

+78
-4
lines changed

4 files changed

+78
-4
lines changed

CHANGELOG.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1-
## [0.0.1] - TODO: Add release date.
1+
## [1.0.0] - 2019-12-22
22

3-
* TODO: Describe initial release.
3+
PubspecYaml is a data type representing data stored in pubspec.yaml files.
4+
5+
The following fields are supported:
6+
* Package name
7+
* Package version
8+
* Package description
9+
* Package author/authors
10+
* Package homepage, repository, and issue tracker
11+
* Package documentation
12+
* Package server specification
13+
* Dependency specifications: regular, dev, and overrides
14+
* SDK constraints
15+
* Command-line executables provided by the package
16+
17+
Other fields are accessible via PubspecYaml.customFields as a JSON structure (Map<String, dynamic>).

README.md

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
# Work in progress: pubspec_yaml [![Build Status](https://travis-ci.org/alexei-sintotski/pubspec_yaml.svg?branch=master)](https://travis-ci.org/alexei-sintotski/pubspec_yaml) [![codecov](https://codecov.io/gh/alexei-sintotski/pubspec_yaml/branch/master/graph/badge.svg)](https://codecov.io/gh/alexei-sintotski/pubspec_yaml) [![pubspec_lock version](https://img.shields.io/pub/v/pubspec_yaml?label=pubspec_yaml)](https://pub.dev/packages/pubspec_yaml)
2+
23
Dart library to access and manipulate content of pubpec.yaml files
34

4-
## Class PubspecLock
5+
## Class PubspecYaml
56

67
PubspecYaml is a data type representing data stored in pubspec.yaml files.
78

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+
833
## Usage
934

1035
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:
1338
dependencies:
1439
pubspec_yaml: ^1.0.0
1540
```
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(
57+
(override) => pubspecYaml.dependencies.any((
58+
productionDependency,
59+
) =>
60+
productionDependency.package() == override.package()),
61+
);
62+
63+
if (productionOverrides.isEmpty) {
64+
print('SUCCESS: No overrides of production dependencies detected');
65+
} else {
66+
print('WARNING: Overrides of production dependencies detected:');
67+
productionOverrides.forEach(print);
68+
}
69+
}
70+
```

lib/pubspec_yaml.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@
2525

2626
library pubspec_yaml;
2727

28+
export 'src/dependency_specs/git_package_dependency_spec.dart';
29+
export 'src/dependency_specs/hosted_package_dependency_spec.dart';
30+
export 'src/dependency_specs/path_package_dependency_spec.dart';
31+
export 'src/dependency_specs/sdk_package_dependency_spec.dart';
32+
export 'src/package_dependency_spec.dart';
2833
export 'src/pubspec_yaml.dart';

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: pubspec_yaml
22
description: Dart library to access and manipulate content of pubpec.yaml files
3-
version: 0.0.1
3+
version: 1.0.0
44
homepage: https://github.com/alexei-sintotski/pubspec_yaml
55

66
environment:

0 commit comments

Comments
 (0)