From d414214d36bd22aa486350c91d95fe40d5ad47ce Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sat, 4 Nov 2023 14:22:34 +0100 Subject: [PATCH] feat(dynamite): allow to configure the pageWidth for the dart formatter Signed-off-by: Nikolas Rimikis --- packages/dynamite/dynamite/README.md | 1 + .../src/models/dynamite_config/config.dart | 3 ++ .../src/models/dynamite_config/config.g.dart | 30 ++++++++++++++++--- .../dynamite/lib/src/openapi_builder.dart | 2 +- .../dynamite_end_to_end_test/build.yaml | 1 + packages/nextcloud/build.yaml | 1 + 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/packages/dynamite/dynamite/README.md b/packages/dynamite/dynamite/README.md index dc49e7b7..fd7d03a0 100644 --- a/packages/dynamite/dynamite/README.md +++ b/packages/dynamite/dynamite/README.md @@ -15,6 +15,7 @@ targets: # Options configure how source code is generated. # # The following are sensible default values that ignores the schemas for the coverage. + pageWidth: 120 analyzer_ignores: - camel_case_types - discarded_futures diff --git a/packages/dynamite/dynamite/lib/src/models/dynamite_config/config.dart b/packages/dynamite/dynamite/lib/src/models/dynamite_config/config.dart index 5f98f322..6c643908 100644 --- a/packages/dynamite/dynamite/lib/src/models/dynamite_config/config.dart +++ b/packages/dynamite/dynamite/lib/src/models/dynamite_config/config.dart @@ -30,6 +30,9 @@ abstract class DynamiteConfig implements Built? get coverageIgnores; + + /// The specified line with the formatter should use. + int? get pageWidth; } @SerializersFor([ diff --git a/packages/dynamite/dynamite/lib/src/models/dynamite_config/config.g.dart b/packages/dynamite/dynamite/lib/src/models/dynamite_config/config.g.dart index 0901cf81..0903b8d2 100644 --- a/packages/dynamite/dynamite/lib/src/models/dynamite_config/config.g.dart +++ b/packages/dynamite/dynamite/lib/src/models/dynamite_config/config.g.dart @@ -36,6 +36,12 @@ class _$DynamiteConfigSerializer implements StructuredSerializer ..add('coverage_ignores') ..add(serializers.serialize(value, specifiedType: const FullType(BuiltSet, [FullType(String)]))); } + value = object.pageWidth; + if (value != null) { + result + ..add('pageWidth') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } return result; } @@ -58,6 +64,9 @@ class _$DynamiteConfigSerializer implements StructuredSerializer result.coverageIgnores.replace(serializers.deserialize(value, specifiedType: const FullType(BuiltSet, [FullType(String)]))! as BuiltSet); break; + case 'pageWidth': + result.pageWidth = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; } } @@ -70,11 +79,13 @@ class _$DynamiteConfig extends DynamiteConfig { final BuiltSet? analyzerIgnores; @override final BuiltSet? coverageIgnores; + @override + final int? pageWidth; factory _$DynamiteConfig([void Function(DynamiteConfigBuilder)? updates]) => (DynamiteConfigBuilder()..update(updates))._build(); - _$DynamiteConfig._({this.analyzerIgnores, this.coverageIgnores}) : super._(); + _$DynamiteConfig._({this.analyzerIgnores, this.coverageIgnores, this.pageWidth}) : super._(); @override DynamiteConfig rebuild(void Function(DynamiteConfigBuilder) updates) => (toBuilder()..update(updates)).build(); @@ -87,7 +98,8 @@ class _$DynamiteConfig extends DynamiteConfig { if (identical(other, this)) return true; return other is DynamiteConfig && analyzerIgnores == other.analyzerIgnores && - coverageIgnores == other.coverageIgnores; + coverageIgnores == other.coverageIgnores && + pageWidth == other.pageWidth; } @override @@ -95,6 +107,7 @@ class _$DynamiteConfig extends DynamiteConfig { var _$hash = 0; _$hash = $jc(_$hash, analyzerIgnores.hashCode); _$hash = $jc(_$hash, coverageIgnores.hashCode); + _$hash = $jc(_$hash, pageWidth.hashCode); _$hash = $jf(_$hash); return _$hash; } @@ -103,7 +116,8 @@ class _$DynamiteConfig extends DynamiteConfig { String toString() { return (newBuiltValueToStringHelper(r'DynamiteConfig') ..add('analyzerIgnores', analyzerIgnores) - ..add('coverageIgnores', coverageIgnores)) + ..add('coverageIgnores', coverageIgnores) + ..add('pageWidth', pageWidth)) .toString(); } } @@ -119,6 +133,10 @@ class DynamiteConfigBuilder implements Builder get coverageIgnores => _$this._coverageIgnores ??= SetBuilder(); set coverageIgnores(SetBuilder? coverageIgnores) => _$this._coverageIgnores = coverageIgnores; + int? _pageWidth; + int? get pageWidth => _$this._pageWidth; + set pageWidth(int? pageWidth) => _$this._pageWidth = pageWidth; + DynamiteConfigBuilder(); DynamiteConfigBuilder get _$this { @@ -126,6 +144,7 @@ class DynamiteConfigBuilder implements Builder