From 875a2515918819db16e1ca9403e1a83b70f16178 Mon Sep 17 00:00:00 2001 From: "Tatsuya Okayama (blendthink)" Date: Fri, 3 May 2024 16:17:20 +0900 Subject: [PATCH 1/6] fix: Change the destination of yumemi_lints to dev_dependencies --- tools/cleanup_template/pubspec.lock | 2 +- tools/cleanup_template/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/cleanup_template/pubspec.lock b/tools/cleanup_template/pubspec.lock index 5ae76e8..4a0e2a6 100644 --- a/tools/cleanup_template/pubspec.lock +++ b/tools/cleanup_template/pubspec.lock @@ -682,7 +682,7 @@ packages: source: hosted version: "3.1.2" yumemi_lints: - dependency: "direct main" + dependency: "direct dev" description: name: yumemi_lints sha256: "51aefbdf37ec2096f0440f91627735c10a1eaacc7cd3e34f372e1e91a8e146f4" diff --git a/tools/cleanup_template/pubspec.yaml b/tools/cleanup_template/pubspec.yaml index 35785dd..18383c6 100644 --- a/tools/cleanup_template/pubspec.yaml +++ b/tools/cleanup_template/pubspec.yaml @@ -14,7 +14,6 @@ dependencies: pub_semver: ^2.1.4 riverpod: ^2.5.1 riverpod_annotation: ^2.3.5 - yumemi_lints: ^1.7.0 dev_dependencies: build_runner: ^2.4.8 @@ -24,3 +23,4 @@ dev_dependencies: riverpod_generator: ^2.4.0 riverpod_lint: ^2.3.10 test: ^1.25.2 + yumemi_lints: ^1.7.0 From 29ca195094671f8561c02ec4fd513f89f5ed8aba Mon Sep 17 00:00:00 2001 From: "Tatsuya Okayama (blendthink)" Date: Fri, 3 May 2024 16:28:32 +0900 Subject: [PATCH 2/6] feat: Update yumemi_lints version to 2.0.0 --- tools/cleanup_template/analysis_options.yaml | 2 +- tools/cleanup_template/pubspec.lock | 8 ++++---- tools/cleanup_template/pubspec.yaml | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/cleanup_template/analysis_options.yaml b/tools/cleanup_template/analysis_options.yaml index 1012654..9a5727f 100644 --- a/tools/cleanup_template/analysis_options.yaml +++ b/tools/cleanup_template/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:yumemi_lints/dart/3.3.0/recommended.yaml +include: package:yumemi_lints/dart/3.3/recommended.yaml analyzer: plugins: diff --git a/tools/cleanup_template/pubspec.lock b/tools/cleanup_template/pubspec.lock index 4a0e2a6..e5bf256 100644 --- a/tools/cleanup_template/pubspec.lock +++ b/tools/cleanup_template/pubspec.lock @@ -213,10 +213,10 @@ packages: dependency: "direct main" description: name: file - sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" url: "https://pub.dev" source: hosted - version: "7.0.0" + version: "6.1.4" fixnum: dependency: transitive description: @@ -685,9 +685,9 @@ packages: dependency: "direct dev" description: name: yumemi_lints - sha256: "51aefbdf37ec2096f0440f91627735c10a1eaacc7cd3e34f372e1e91a8e146f4" + sha256: "073a9a10e8f4b7024cc3f00ccde00455fec6f60326f4e87639feb9e4ce8ab54b" url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "2.0.0" sdks: dart: ">=3.3.0 <4.0.0" diff --git a/tools/cleanup_template/pubspec.yaml b/tools/cleanup_template/pubspec.yaml index 18383c6..4678e2b 100644 --- a/tools/cleanup_template/pubspec.yaml +++ b/tools/cleanup_template/pubspec.yaml @@ -6,7 +6,7 @@ environment: sdk: ^3.3.0 dependencies: - file: ^7.0.0 + file: ^6.1.4 freezed_annotation: ^2.4.1 http: ^1.2.1 json_annotation: ^4.8.1 @@ -23,4 +23,4 @@ dev_dependencies: riverpod_generator: ^2.4.0 riverpod_lint: ^2.3.10 test: ^1.25.2 - yumemi_lints: ^1.7.0 + yumemi_lints: ^2.0.0 From 9cf4f549d3d174fed3c70a55d9d8c97b2a7201ba Mon Sep 17 00:00:00 2001 From: "Tatsuya Okayama (blendthink)" Date: Fri, 3 May 2024 16:31:53 +0900 Subject: [PATCH 3/6] fix: Fix lint warnings `prefer_const_constructors` --- tools/cleanup_template/lib/src/file_system.dart | 2 +- .../lib/src/services/flutter_sdk_service.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/cleanup_template/lib/src/file_system.dart b/tools/cleanup_template/lib/src/file_system.dart index b2ef6c0..eea2d0b 100644 --- a/tools/cleanup_template/lib/src/file_system.dart +++ b/tools/cleanup_template/lib/src/file_system.dart @@ -5,4 +5,4 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'file_system.g.dart'; @Riverpod(dependencies: []) -FileSystem fileSystem(FileSystemRef ref) => LocalFileSystem(); +FileSystem fileSystem(FileSystemRef ref) => const LocalFileSystem(); diff --git a/tools/cleanup_template/lib/src/services/flutter_sdk_service.dart b/tools/cleanup_template/lib/src/services/flutter_sdk_service.dart index 2d6b017..324b6f4 100644 --- a/tools/cleanup_template/lib/src/services/flutter_sdk_service.dart +++ b/tools/cleanup_template/lib/src/services/flutter_sdk_service.dart @@ -34,20 +34,20 @@ class FlutterSdkService { final json = jsonDecode(responseBody); if (json is! Map) { - throw FormatException( + throw const FormatException( 'The type of `json` should be `Map`.', ); } final releases = json['releases']; if (releases is! List) { - throw FormatException( + throw const FormatException( 'The type of `releases` should be `List`.', ); } return releases.map((release) { if (release is! Map) { - throw FormatException( + throw const FormatException( 'The type of `release` should be `Map`.', ); } From c8991b8ca435d7f858be1b7ec682f84604eb6a8e Mon Sep 17 00:00:00 2001 From: "Tatsuya Okayama (blendthink)" Date: Fri, 3 May 2024 16:32:22 +0900 Subject: [PATCH 4/6] style: Disable lint rule `avoid_print` --- tools/cleanup_template/analysis_options.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/cleanup_template/analysis_options.yaml b/tools/cleanup_template/analysis_options.yaml index 9a5727f..b2c23ab 100644 --- a/tools/cleanup_template/analysis_options.yaml +++ b/tools/cleanup_template/analysis_options.yaml @@ -6,3 +6,7 @@ analyzer: errors: # https://pub.dev/packages/freezed invalid_annotation_target: ignore + +linter: + rules: + avoid_print: false From a916c616847188b090f973868a5722fd5d877f54 Mon Sep 17 00:00:00 2001 From: "Tatsuya Okayama (blendthink)" Date: Fri, 3 May 2024 17:06:09 +0900 Subject: [PATCH 5/6] fix: Fix process to override analysis_options.yaml `dart run yumemi_lints update` --- .../lib/src/services/cleanup_service.dart | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/cleanup_template/lib/src/services/cleanup_service.dart b/tools/cleanup_template/lib/src/services/cleanup_service.dart index ef7d02a..ac56616 100644 --- a/tools/cleanup_template/lib/src/services/cleanup_service.dart +++ b/tools/cleanup_template/lib/src/services/cleanup_service.dart @@ -121,14 +121,16 @@ class CleanupService { ).throwExceptionIfFailed(); // override analysis_options.yaml - final analysisOptionsPath = path.join( - tempDir.path, - 'analysis_options.yaml', - ); - _fileSystem.file(analysisOptionsPath).writeAsStringSync(''' -# https://pub.dev/packages/yumemi_lints -include: package:yumemi_lints/flutter/$flutterVersion/recommended.yaml -'''); + Process.runSync( + 'fvm', + [ + 'dart', + 'run', + 'yumemi_lints', + 'update', + ], + workingDirectory: tempDir.path, + ).throwExceptionIfFailed(); // setting dart.flutterSdkPath final githubTemplatesPath = path.join(rootDir.path, '.github/templates'); From 0b78a96c5315b046c4e1ec60f08baf5df9d1de25 Mon Sep 17 00:00:00 2001 From: "Tatsuya Okayama (blendthink)" Date: Fri, 3 May 2024 18:45:09 +0900 Subject: [PATCH 6/6] fix: Add constraints for the Flutter SDK --- .../lib/src/services/cleanup_service.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/cleanup_template/lib/src/services/cleanup_service.dart b/tools/cleanup_template/lib/src/services/cleanup_service.dart index ac56616..32bec27 100644 --- a/tools/cleanup_template/lib/src/services/cleanup_service.dart +++ b/tools/cleanup_template/lib/src/services/cleanup_service.dart @@ -120,6 +120,19 @@ class CleanupService { workingDirectory: tempDir.path, ).throwExceptionIfFailed(); + // add constraints for the Flutter SDK + final pubspecPath = path.join(tempDir.path, 'pubspec.yaml'); + final pubspecFlie = _fileSystem.file(pubspecPath); + final pubspecFileContent = pubspecFlie.readAsStringSync(); + final pubspecFileNewContent = pubspecFileContent.replaceFirstMapped( + RegExp(r'environment:\n sdk:.+\n'), + (match) { + final all = match.group(0)!; + return '$all flutter: ^$flutterVersion\n'; + }, + ); + pubspecFlie.writeAsStringSync(pubspecFileNewContent); + // override analysis_options.yaml Process.runSync( 'fvm',