Skip to content

Commit b9ab069

Browse files
committed
chore: moved unnecessary logs to Level.CONFIG. Updated pub versions in preparation for release.
1 parent 4171115 commit b9ab069

File tree

12 files changed

+74
-91
lines changed

12 files changed

+74
-91
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ flutter/dart projects. (see example)
2020

2121
This repo contains the following dart libraries
2222

23-
| Library | Description | latest version |
24-
|-------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
25-
| openapi-generator | Dev dependency for generating openapi sdk via dart source gen [see here for usage](https://pub.dev/packages/openapi_generator) | [![pub package](https://img.shields.io/pub/v/openapi_generator.svg)](https://pub.dev/packages/openapi_generator) |
26-
| openapi-generator-annotations | Annotations for annotating dart class with instructions for generating openapi sdk [see here for usage](https://pub.dev/packages/openapi_generator_annotations) | [![pub package](https://img.shields.io/pub/v/openapi_generator_annotations.svg)](https://pub.dev/packages/openapi_generator) |
27-
| openapi-generator-cli | Cli code openapi sdk generator for dart [see here for usage](https://pub.dev/packages/openapi_generator_cli) | [![pub package](https://img.shields.io/pub/v/openapi_generator_cli.svg)](https://pub.dev/packages/openapi_generator_cli) |
23+
| Library | Description | latest version |
24+
|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
25+
| openapi-generator | Dev dependency for generating openapi client sdk via dart source gen [see here for usage](https://pub.dev/packages/openapi_generator) | [![pub package](https://img.shields.io/pub/v/openapi_generator.svg)](https://pub.dev/packages/openapi_generator) |
26+
| openapi-generator-annotations | Annotations for annotating dart class with instructions for generating openapi client sdk [see here for usage](https://pub.dev/packages/openapi_generator_annotations) | [![pub package](https://img.shields.io/pub/v/openapi_generator_annotations.svg)](https://pub.dev/packages/openapi_generator) |
27+
| openapi-generator-cli | CLI only generator. [see here for usage](https://pub.dev/packages/openapi_generator_cli) | [![pub package](https://img.shields.io/pub/v/openapi_generator_cli.svg)](https://pub.dev/packages/openapi_generator_cli) |
2828

2929
## Usage
3030

example/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void main() {
1212
typeMappings: {'Pet': 'ExamplePet'},
1313
generatorName: Generator.dio,
1414
runSourceGenOnOutput: true,
15-
alwaysRun: true,
15+
useNextGen: true,
1616
outputDirectory: 'api/petstore_api',
1717
)
1818
class MyApp extends StatelessWidget {
@@ -123,4 +123,4 @@ class _MyHomePageState extends State<MyHomePage> {
123123
), // This trailing comma makes auto-formatting nicer for build methods.
124124
);
125125
}
126-
}
126+
}

openapi-generator-annotations/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 4.12.0
2+
3+
- Added spec diff tracking. This means you Openapi generator now tracks changes to your spec and only regenerates the
4+
code if there are changes. This is useful if you have a large spec and you want to avoid regenerating the code every
5+
time you run your build. This is enabled by default. You can read more about it [here](../README.md#next-generation).
6+
Credits - [@Nexushunter](https://github.com/Nexushunter)
7+
- Improved test coverage
8+
19
## 4.11.0
210

311
- Bumped dart-ogurets (_dioAlt_) generator to 7.2
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: openapi_generator_annotations
22
description: Annotation package for openapi_generator https://pub.dev/packages/openapi_generator.
3-
version: 4.11.0
3+
version: 4.12.0
44
homepage: https://github.com/gibahjoe/openapi-generator-dart
55

66

@@ -10,4 +10,4 @@ environment:
1010
dev_dependencies:
1111
test:
1212
source_gen_test: ^1.0.6
13-
lint:
13+
lint:

openapi-generator-cli/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: openapi_generator_cli
22
description: A dart wrapper around openapi-generator inspired by the node implementation.
3-
version: 4.11.0
3+
version: 4.12.0
44
homepage: https://github.com/gibahjoe/openapi-generator-dart
55

66
environment:

openapi-generator/CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
## 4.12.0
2+
3+
- Added spec diff tracking. This means you Openapi generator now tracks changes to your spec and only regenerates the
4+
code if there are changes. This is useful if you have a large spec and you want to avoid regenerating the code every
5+
time you run your build. This is enabled by default. You can read more about it [here](../README.md#next-generation).
6+
Credits - [@Nexushunter](https://github.com/Nexushunter)
7+
- Improved test coverage
8+
19
## 4.11.1
210

3-
- Removed ```log.severe``` that shows event though generation is successful
11+
- Removed ```log.severe``` that shows even though generation is successful
412
- Updated documentation
513

614
## 4.11.0

openapi-generator/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# projects at Google. For details and rationale,
33
# see https://github.com/dart-lang/pedantic#enabled-lints.
44
include: package:pedantic/analysis_options.yaml
5+
include: package:lints/recommended.yaml
56

67
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
78
# Uncomment to specify additional rules.

openapi-generator/lib/src/openapi_generator_runner.dart

Lines changed: 28 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
3333
':::::::::::::::::::::::::::::::::::::::::::',
3434
':: Openapi generator for dart ::',
3535
':::::::::::::::::::::::::::::::::::::::::::',
36+
'',
3637
].join('\n'),
3738
),
3839
);
@@ -74,8 +75,8 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
7475
log: log,
7576
communication: OutputMessage(
7677
message:
77-
'- :: Library exists definition at [$path] exists and configuration is annotated with alwaysRun: [${args.alwaysRun}]. This option will be removed in a future version. ::',
78-
level: Level.WARNING,
78+
'Generated client already exists at [$path] and configuration is annotated with alwaysRun: [${args.alwaysRun}]. Therefore, skipping this build. Note that the "alwaysRun" config will be removed in future versions.',
79+
level: Level.INFO,
7980
),
8081
);
8182
return '';
@@ -98,7 +99,7 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
9899
late OutputMessage communication;
99100
if (e is! OutputMessage) {
100101
communication = OutputMessage(
101-
message: '- :: There was an error generating the spec. ::',
102+
message: ' - There was an error generating the spec.',
102103
level: Level.SEVERE,
103104
additionalContext: e,
104105
stackTrace: st,
@@ -109,12 +110,12 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
109110

110111
logOutputMessage(log: log, communication: communication);
111112
} finally {
112-
logOutputMessage(
113-
log: log,
114-
communication: OutputMessage(
115-
message: ':::::::::::::::::::::::::::::::::::::::::::',
116-
),
117-
);
113+
// logOutputMessage(
114+
// log: log,
115+
// communication: OutputMessage(
116+
// message: ':::::::::::::::::::::::::::::::::::::::::::',
117+
// ),
118+
// );
118119
}
119120
return '';
120121
}
@@ -125,7 +126,8 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
125126
logOutputMessage(
126127
log: log,
127128
communication: OutputMessage(
128-
message: 'OpenapiGenerator :: [ ${args.join(' ')} ]',
129+
message:
130+
'Running following command to generate openapi client - [ ${args.join(' ')} ]',
129131
),
130132
);
131133

@@ -152,19 +154,11 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
152154
} else {
153155
result = ProcessResult(999999, 0, null, null);
154156
}
155-
return genName;
156-
}
157157

158-
String appendTemplateDirCommandArgs(
159-
ConstantReader annotation, String command, String separator) {
160-
var templateDir =
161-
_readFieldValueAsString(annotation, 'templateDirectory', '');
162-
if (templateDir.isNotEmpty) {
163-
command = '$command$separator-t$separator$templateDir';
164158
if (result.exitCode != 0) {
165159
return Future.error(
166160
OutputMessage(
167-
message: ':: Codegen Failed. Generator output: ::',
161+
message: 'Codegen Failed. Generator output: ',
168162
level: Level.SEVERE,
169163
additionalContext: result.stderr,
170164
stackTrace: StackTrace.current,
@@ -176,19 +170,13 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
176170
communication: OutputMessage(
177171
message: [
178172
if (arguments.isDebug) result.stdout,
179-
':: Codegen completed successfully. ::',
173+
'Openapi generator completed successfully. ',
180174
].join('\n'),
181175
),
182176
);
183177
}
184-
return command;
185178
}
186179

187-
String appendInputFileCommandArgs(
188-
ConstantReader annotation, String command, String separator) {
189-
var inputFile = _readFieldValueAsString(annotation, 'inputSpecFile', '');
190-
if (inputFile.isNotEmpty) {
191-
command = '$command$separator-i$separator$inputFile';
192180
/// Next-gen of the generation.
193181
///
194182
/// Proposal for reworking how to generated the user's changes based on spec
@@ -204,33 +192,24 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
204192
log: log,
205193
communication: OutputMessage(
206194
message:
207-
':: Using a remote specification, a cache will still be create but may be outdated. ::',
195+
'Using a remote specification, a cache will still be create but may be outdated.',
208196
level: Level.WARNING,
209197
),
210198
);
211199
}
212-
return command;
213-
}
214-
215-
String appendSkipValidateSpecCommandArgs(
216-
ConstantReader annotation, String command, String separator) {
217-
var skipSpecValidation =
218-
_readFieldValueAsBool(annotation, 'skipSpecValidation', false)!;
219-
if (skipSpecValidation) {
220-
command = '$command$separator--skip-validate-spec';
221200
try {
222201
if (!await hasDiff(args: args)) {
223202
logOutputMessage(
224203
log: log,
225204
communication: OutputMessage(
226-
message: ':: No diff between versions, not running generator. ::',
205+
message: 'No diff between versions, not running generator.',
227206
),
228207
);
229208
} else {
230209
logOutputMessage(
231210
log: log,
232211
communication: OutputMessage(
233-
message: ':: Dirty Spec found. Running generation. ::',
212+
message: 'Dirty Spec found. Running generation.',
234213
),
235214
);
236215
await runOpenApiJar(arguments: args);
@@ -240,14 +219,16 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
240219
logOutputMessage(
241220
log: log,
242221
communication: OutputMessage(
243-
message: ':: No local cache found. Creating one. ::',
222+
message: 'No local cache found. Creating one.',
223+
level: Level.CONFIG,
244224
),
245225
);
246226
} else {
247227
logOutputMessage(
248228
log: log,
249229
communication: OutputMessage(
250-
message: ':: Local cache found. Overwriting existing one. ::',
230+
message: 'Local cache found. Overwriting existing one.',
231+
level: Level.CONFIG,
251232
),
252233
);
253234
}
@@ -257,15 +238,15 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
257238
logOutputMessage(
258239
log: log,
259240
communication: OutputMessage(
260-
message: ':: Successfully cached spec changes. ::',
241+
message: 'Successfully cached spec changes.',
261242
),
262243
);
263244
}
264245
} catch (e, st) {
265246
logOutputMessage(
266247
log: log,
267248
communication: OutputMessage(
268-
message: ':: Failed to generate content. ::',
249+
message: 'Failed to generate content.',
269250
additionalContext: e,
270251
stackTrace: st,
271252
level: Level.SEVERE,
@@ -276,25 +257,20 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
276257
(_) => logOutputMessage(
277258
log: log,
278259
communication: OutputMessage(
279-
message: ':: Successfully updated annotated file. ::',
260+
message: 'Successfully updated annotated file.',
261+
level: Level.CONFIG,
280262
),
281263
),
282264
onError: (e, st) => logOutputMessage(
283265
log: log,
284266
communication: OutputMessage(
285-
message: 'Failed to update annotated class file.',
286-
level: Level.SEVERE,
267+
message: 'Failed to update annotated class file. Failing silently.',
268+
level: Level.WARNING,
287269
additionalContext: e,
288270
stackTrace: st,
289271
),
290272
),
291273
);
292-
logOutputMessage(
293-
log: log,
294-
communication: OutputMessage(
295-
message: ':::::::::::::::::::::::::::::::::',
296-
),
297-
);
298274
}
299275
return '';
300276
}
@@ -308,7 +284,7 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
308284
log: log,
309285
communication: OutputMessage(
310286
message: [
311-
':: Loaded cached and current spec files. ::',
287+
'Loaded cached and current spec files.',
312288
if (args.isDebug) ...[jsonEncode(cachedSpec), jsonEncode(loadedSpec)],
313289
].join('\n'),
314290
),

openapi-generator/lib/src/utils.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,4 @@ String Function(String, MapEntry<String, dynamic>) foldStringMap({
5959
(String prev, MapEntry<String, dynamic> curr) =>
6060
'${prev.trim().isEmpty ? '' : '$prev,'}${keyModifier != null ? keyModifier(curr.key) : curr.key}=${valueModifier != null ? valueModifier(curr.value) : curr.value}';
6161

62-
final lastRunPlaceHolder =
63-
'// GENERATED DO NOT MODIFY BY HAND: openapi-generator-last-run';
62+
final lastRunPlaceHolder = '// Openapi Generator last run: ';

openapi-generator/pubspec.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: openapi_generator
22
description: Generator for openapi client sdk inspired by the npm implementation of openapi-generator-cli.
3-
version: 4.11.1
3+
version: 4.12.0
44
homepage: https://github.com/gibahjoe/openapi-generator-dart
55

66
environment:
@@ -23,7 +23,8 @@ dev_dependencies:
2323
source_gen_test: ^1.0.6
2424
pedantic:
2525
coverage: ^1.6.3
26+
lints: ^2.1.1
2627

2728
dependency_overrides:
2829
openapi_generator_annotations:
29-
path: ../openapi-generator-annotations
30+
path: ../openapi-generator-annotations

0 commit comments

Comments
 (0)