From 2aecaf2fef8a39aaaba9a20dbb4275f41c0c125c Mon Sep 17 00:00:00 2001 From: "Tatsuya Okayama (blendthink)" Date: Thu, 19 Sep 2024 07:36:16 +0900 Subject: [PATCH 1/5] fix: Run format --- .../src/command_services/update_command_service.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/yumemi_lints/lib/src/command_services/update_command_service.dart b/packages/yumemi_lints/lib/src/command_services/update_command_service.dart index 9183022..b161c0f 100644 --- a/packages/yumemi_lints/lib/src/command_services/update_command_service.dart +++ b/packages/yumemi_lints/lib/src/command_services/update_command_service.dart @@ -160,16 +160,16 @@ class UpdateCommandService { ); throw const CompatibleVersionException(); } - + // If higher than the oldest supported version and lower than the latest // supported version, but does not match any of the supported versions, // print an error message and exit with an error. printMessage( - 'The version of ${projectType.formalName} $specifiedVersion specified ' - 'in pubspec.yaml does not exist. Please specify the version ' - 'that exists.', - ); - throw const CompatibleVersionException(); + 'The version of ${projectType.formalName} $specifiedVersion specified ' + 'in pubspec.yaml does not exist. Please specify the version ' + 'that exists.', + ); + throw const CompatibleVersionException(); } @visibleForTesting From a930d65b58b1621f874572f8fd24b23ae8c7f251 Mon Sep 17 00:00:00 2001 From: "Tatsuya Okayama (blendthink)" Date: Thu, 19 Sep 2024 07:43:15 +0900 Subject: [PATCH 2/5] chore: Change to not use the path package --- .../src/command_services/update_command_service.dart | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/yumemi_lints/lib/src/command_services/update_command_service.dart b/packages/yumemi_lints/lib/src/command_services/update_command_service.dart index b161c0f..174caba 100644 --- a/packages/yumemi_lints/lib/src/command_services/update_command_service.dart +++ b/packages/yumemi_lints/lib/src/command_services/update_command_service.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'dart:isolate'; import 'package:meta/meta.dart'; -import 'package:path/path.dart' as path; import 'package:pub_semver/pub_semver.dart'; import 'package:yaml/yaml.dart'; import 'package:yumemi_lints/src/models/exceptions.dart'; @@ -61,12 +60,8 @@ class UpdateCommandService { File _getPubspecFile() { final pubspecFile = File( - path.join( - Directory.current.path, - 'pubspec.yaml', - ), + '${Directory.current.path}/pubspec.yaml', ); - if (!pubspecFile.existsSync()) { throw Exception( 'The pubspec.yaml file could not be found in the current directory. ' @@ -232,7 +227,7 @@ class UpdateCommandService { void _updateAnalysisOptionsFile(String includeLine) { final analysisOptionsFile = File( - path.join(Directory.current.path, 'analysis_options.yaml'), + '${Directory.current.path}/analysis_options.yaml', ); if (!analysisOptionsFile.existsSync()) { // Create analysis_options.yaml if it does not exist @@ -280,6 +275,6 @@ extension _ProjectTypeFormalName on ProjectType { extension _FileSystemEntityName on FileSystemEntity { String get name { - return this.path.split('/').last; + return path.split('/').last; } } From c8cdd4615c742077bb9819f15cd3232aad5ba19f Mon Sep 17 00:00:00 2001 From: "Tatsuya Okayama (blendthink)" Date: Thu, 19 Sep 2024 07:43:43 +0900 Subject: [PATCH 3/5] chore: Remove the path package --- packages/yumemi_lints/pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/yumemi_lints/pubspec.yaml b/packages/yumemi_lints/pubspec.yaml index 229f6fb..e3cdbf7 100644 --- a/packages/yumemi_lints/pubspec.yaml +++ b/packages/yumemi_lints/pubspec.yaml @@ -10,7 +10,6 @@ dependencies: args: ^2.3.1 file: ^6.1.4 meta: ^1.7.0 - path: ^1.8.1 pub_semver: ^2.1.4 yaml: ^3.1.1 From e0fa4343082a894c3091532ae046f3e249c9438d Mon Sep 17 00:00:00 2001 From: "Tatsuya Okayama (blendthink)" Date: Thu, 19 Sep 2024 07:46:49 +0900 Subject: [PATCH 4/5] chore: Update the CHANGELOG --- packages/yumemi_lints/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/yumemi_lints/CHANGELOG.md b/packages/yumemi_lints/CHANGELOG.md index 82d9959..2dad713 100644 --- a/packages/yumemi_lints/CHANGELOG.md +++ b/packages/yumemi_lints/CHANGELOG.md @@ -21,6 +21,12 @@ Examples of version updates are as follows: > [!NOTE] > Changes to `tools/update_lint_rules` don't affect versioning. +## 2.2.1 + +### Improvements + +- Changed to be independent of the `path` package. + ## 2.2.0 ### Features From d8412c1e855fbefde4f029268e658ae33d8a0b99 Mon Sep 17 00:00:00 2001 From: "Tatsuya Okayama (blendthink)" Date: Thu, 19 Sep 2024 08:22:12 +0900 Subject: [PATCH 5/5] fix: Change separator based on whether the path is in Windows style --- .../update_command_service.dart | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/yumemi_lints/lib/src/command_services/update_command_service.dart b/packages/yumemi_lints/lib/src/command_services/update_command_service.dart index 174caba..dcbba5a 100644 --- a/packages/yumemi_lints/lib/src/command_services/update_command_service.dart +++ b/packages/yumemi_lints/lib/src/command_services/update_command_service.dart @@ -60,7 +60,10 @@ class UpdateCommandService { File _getPubspecFile() { final pubspecFile = File( - '${Directory.current.path}/pubspec.yaml', + [ + Directory.current.path, + 'pubspec.yaml', + ].join(_separator), ); if (!pubspecFile.existsSync()) { throw Exception( @@ -227,7 +230,10 @@ class UpdateCommandService { void _updateAnalysisOptionsFile(String includeLine) { final analysisOptionsFile = File( - '${Directory.current.path}/analysis_options.yaml', + [ + Directory.current.path, + 'analysis_options.yaml', + ].join(_separator), ); if (!analysisOptionsFile.existsSync()) { // Create analysis_options.yaml if it does not exist @@ -278,3 +284,20 @@ extension _FileSystemEntityName on FileSystemEntity { return path.split('/').last; } } + +bool get _isWindowsStyle { + if (Uri.base.scheme != 'file') { + return false; + } + if (!Uri.base.path.endsWith('/')) { + return false; + } + return Uri(path: 'a/b').toFilePath() == r'a\b'; +} + +String get _separator { + if (_isWindowsStyle) { + return r'\'; + } + return '/'; +}