Skip to content

Commit

Permalink
Merge pull request #68 from yumemi-inc/issue/63
Browse files Browse the repository at this point in the history
yumemi_lints 2.0.0 に対応
  • Loading branch information
blendthink authored May 6, 2024
2 parents 2669d4a + 0b78a96 commit f3506ac
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 20 deletions.
6 changes: 5 additions & 1 deletion tools/cleanup_template/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
include: package:yumemi_lints/dart/3.3.0/recommended.yaml
include: package:yumemi_lints/dart/3.3/recommended.yaml

analyzer:
plugins:
- custom_lint
errors:
# https://pub.dev/packages/freezed
invalid_annotation_target: ignore

linter:
rules:
avoid_print: false
2 changes: 1 addition & 1 deletion tools/cleanup_template/lib/src/file_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
31 changes: 23 additions & 8 deletions tools/cleanup_template/lib/src/services/cleanup_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,30 @@ class CleanupService {
workingDirectory: tempDir.path,
).throwExceptionIfFailed();

// override analysis_options.yaml
final analysisOptionsPath = path.join(
tempDir.path,
'analysis_options.yaml',
// 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';
},
);
_fileSystem.file(analysisOptionsPath).writeAsStringSync('''
# https://pub.dev/packages/yumemi_lints
include: package:yumemi_lints/flutter/$flutterVersion/recommended.yaml
''');
pubspecFlie.writeAsStringSync(pubspecFileNewContent);

// override analysis_options.yaml
Process.runSync(
'fvm',
[
'dart',
'run',
'yumemi_lints',
'update',
],
workingDirectory: tempDir.path,
).throwExceptionIfFailed();

// setting dart.flutterSdkPath
final githubTemplatesPath = path.join(rootDir.path, '.github/templates');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ class FlutterSdkService {

final json = jsonDecode(responseBody);
if (json is! Map<String, dynamic>) {
throw FormatException(
throw const FormatException(
'The type of `json` should be `Map<String, dynamic>`.',
);
}
final releases = json['releases'];
if (releases is! List<dynamic>) {
throw FormatException(
throw const FormatException(
'The type of `releases` should be `List<dynamic>`.',
);
}

return releases.map((release) {
if (release is! Map<String, dynamic>) {
throw FormatException(
throw const FormatException(
'The type of `release` should be `Map<String, dynamic>`.',
);
}
Expand Down
10 changes: 5 additions & 5 deletions tools/cleanup_template/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -682,12 +682,12 @@ packages:
source: hosted
version: "3.1.2"
yumemi_lints:
dependency: "direct main"
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"
4 changes: 2 additions & 2 deletions tools/cleanup_template/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ 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
path: ^1.9.0
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
Expand All @@ -24,3 +23,4 @@ dev_dependencies:
riverpod_generator: ^2.4.0
riverpod_lint: ^2.3.10
test: ^1.25.2
yumemi_lints: ^2.0.0

0 comments on commit f3506ac

Please sign in to comment.