Skip to content

Commit

Permalink
🔖 release chopper generator v6.0.3 (#449)
Browse files Browse the repository at this point in the history
# chopper_generator

## 6.0.3

* [CHORE] #448
  • Loading branch information
techouse authored Jul 5, 2023
1 parent b19f402 commit f1c929c
Show file tree
Hide file tree
Showing 17 changed files with 1,205 additions and 235 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,16 @@ jobs:
- job_001
- job_002
job_004:
name: "unit_test; PKGS: chopper, chopper_built_value; `dart pub global run coverage:test_with_coverage`"
name: "unit_test; PKGS: chopper, chopper_built_value, chopper_generator; `dart pub global run coverage:test_with_coverage`"
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable;packages:chopper-chopper_built_value;commands:test_with_coverage"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable;packages:chopper-chopper_built_value-chopper_generator;commands:test_with_coverage"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted;sdk:stable;packages:chopper-chopper_built_value
os:ubuntu-latest;pub-cache-hosted;sdk:stable;packages:chopper-chopper_built_value-chopper_generator
os:ubuntu-latest;pub-cache-hosted;sdk:stable
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
Expand Down Expand Up @@ -179,6 +179,21 @@ jobs:
files: chopper_built_value/coverage/lcov.info
fail_ci_if_error: true
name: coverage_01
- id: chopper_generator_pub_upgrade
name: chopper_generator; dart pub upgrade
run: dart pub upgrade
if: "always() && steps.checkout.conclusion == 'success'"
working-directory: chopper_generator
- name: "chopper_generator; dart pub global run coverage:test_with_coverage"
run: "dart pub global run coverage:test_with_coverage"
if: "always() && steps.chopper_generator_pub_upgrade.conclusion == 'success'"
working-directory: chopper_generator
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@main
with:
files: chopper_generator/coverage/lcov.info
fail_ci_if_error: true
name: coverage_02
needs:
- job_001
- job_002
Expand Down
1 change: 1 addition & 0 deletions chopper/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies:
dev_dependencies:
build_runner: ^2.0.0
build_test: ^2.0.0
build_verify: ^3.1.0
collection: ^1.16.0
coverage: ^1.0.2
dart_code_metrics: '>=4.8.1 <6.0.0'
Expand Down
16 changes: 16 additions & 0 deletions chopper/test/ensure_build_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@TestOn('vm')
@Timeout(Duration(seconds: 120))
import 'package:build_verify/build_verify.dart';
import 'package:test/test.dart';

void main() {
test(
'ensure_build',
() => expectBuildClean(
packageRelativeDirectory: 'chopper',
gitDiffPathArguments: [
'test/test_service.chopper.dart',
],
),
);
}
13 changes: 13 additions & 0 deletions chopper_generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 6.0.3

- Simplify library export
- Extract PartBuilder into its own file
- Extract constant variables into an enum
- Extract helper methods into a Utils class
- Use a const constructor
- Make all methods static
- Ensure all immutable variables are final
- Simplify syntax
- Add API documentation
- Update README

## 6.0.2

- Add support for generating files in different directories ([#444](https://github.com/lejard-h/chopper/pull/444))
Expand Down
4 changes: 4 additions & 0 deletions chopper_generator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ install:
@# Help: Install all the project's packages
dart pub get

tests:
@# Help: Run Dart unit and widget tests for the current project.
dart test

upgrade:
@# Help: Upgrade all the project's packages.
dart pub upgrade
9 changes: 9 additions & 0 deletions chopper_generator/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# chopper_generator

[![pub package](https://img.shields.io/pub/v/chopper_generator.svg)](https://pub.dartlang.org/packages/chopper_generator)

This package provides the code generator for the [Chopper](https://github.com/lejard-h/chopper) package.

## Usage

For examples please refer to the main [Chopper](https://github.com/lejard-h/chopper) package and/or read the
[documentation](https://hadrien-lejard.gitbook.io/chopper).
7 changes: 1 addition & 6 deletions chopper_generator/lib/chopper_generator.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
library chopper_generator.dart;

import 'package:build/build.dart';

import 'src/generator.dart';

Builder chopperGeneratorFactory(BuilderOptions options) =>
chopperGeneratorFactoryBuilder(options);
export 'src/builder_factory.dart';
23 changes: 23 additions & 0 deletions chopper_generator/lib/src/builder_factory.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:build/build.dart';
import 'package:chopper/chopper.dart' show ChopperApi;
import 'package:source_gen/source_gen.dart';

import 'generator.dart';

/// Creates a [PartBuilder] used to generate code for [ChopperApi] annotated
/// classes. The [options] are provided by Dart's build system and read from the
/// `build.yaml` file.
Builder chopperGeneratorFactory(BuilderOptions options) => PartBuilder(
[const ChopperGenerator()],
'.chopper.dart',
header: options.config['header'],
formatOutput:
PartBuilder([const ChopperGenerator()], '.chopper.dart').formatOutput,
options: !options.config.containsKey('build_extensions')
? options.overrideWith(
BuilderOptions({
'build_extensions': {'.dart': '.chopper.dart'},
}),
)
: options,
);
6 changes: 6 additions & 0 deletions chopper_generator/lib/src/extensions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';

extension DartTypeExtension on DartType {
bool get isNullable => nullabilitySuffix != NullabilitySuffix.none;
}
Loading

0 comments on commit f1c929c

Please sign in to comment.