From 3a62daf897e11494517c6924b782bd0909b4a80e Mon Sep 17 00:00:00 2001 From: wenchieh Date: Wed, 24 May 2023 23:57:53 +0800 Subject: [PATCH] Enable alias parsing flutter_project_dir and Update Ci (#92) --- .github/workflows/build.yml | 4 ++-- .github/workflows/publish.yml | 2 +- example/pubspec.yaml | 2 +- ios/tencent_kit.podspec | 10 +++++++++- pubspec.yaml | 2 +- test/tencent_kit_method_channel_test.dart | 7 +++++-- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e317892..987a04a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: - run: clang-format -style=file -i ios/Classes/*.h ios/Classes/*.m --dry-run --Werror - run: flutter --version - run: flutter pub get - - run: flutter format --dry-run --set-exit-if-changed . + - run: dart format --set-exit-if-changed . - run: flutter pub publish --dry-run - run: flutter analyze lib example/lib - run: cd example; flutter build ios --no-codesign @@ -46,7 +46,7 @@ jobs: channel: 'stable' - run: flutter --version - run: flutter pub get - - run: flutter format --dry-run --set-exit-if-changed . + - run: dart format --set-exit-if-changed . - run: flutter pub publish --dry-run - run: flutter analyze lib example/lib - run: cd example; flutter build apk --debug diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b50fd8b..b137eac 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,7 +25,7 @@ jobs: echo $CREDENTIALS > $PUB_CACHE/credentials.json - run: flutter --version - run: flutter pub get - - run: flutter format --dry-run --set-exit-if-changed . + - run: dart format --set-exit-if-changed . - run: echo "y" | flutter pub publish - name: Run pub.dev/update-credentials@shell env: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 1d670d6..37a9bf6 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -8,7 +8,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+100 environment: - sdk: ">=2.17.0 <3.0.0" + sdk: ">=2.17.0 <4.0.0" # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/ios/tencent_kit.podspec b/ios/tencent_kit.podspec index 05200c6..9769fd0 100644 --- a/ios/tencent_kit.podspec +++ b/ios/tencent_kit.podspec @@ -10,7 +10,15 @@ current_dir = Dir.pwd calling_dir = File.dirname(__FILE__) project_dir = calling_dir.slice(0..(calling_dir.index('/.symlinks'))) flutter_project_dir = calling_dir.slice(0..(calling_dir.index('/ios/.symlinks'))) -cfg = YAML.load_file(File.join(flutter_project_dir, 'pubspec.yaml')) + +psych_version_gte_500 = Gem::Version.new(Psych::VERSION) >= Gem::Version.new('5.0.0') +if psych_version_gte_500 == true + cfg = YAML.load_file(File.join(flutter_project_dir, 'pubspec.yaml'), aliases: true) +else + cfg = YAML.load_file(File.join(flutter_project_dir, 'pubspec.yaml')) +end + + if cfg['tencent_kit'] && cfg['tencent_kit']['app_id'] app_id = cfg['tencent_kit']['app_id'] universal_link = cfg['tencent_kit']['universal_link'] diff --git a/pubspec.yaml b/pubspec.yaml index a872a09..b5a9a66 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ repository: https://github.com/RxReader/tencent_kit.git issue_tracker: https://github.com/RxReader/tencent_kit/issues environment: - sdk: ">=2.17.0 <3.0.0" + sdk: ">=2.17.0 <4.0.0" flutter: ">=2.5.0" dependencies: diff --git a/test/tencent_kit_method_channel_test.dart b/test/tencent_kit_method_channel_test.dart index 7ed56de..d2e0c74 100644 --- a/test/tencent_kit_method_channel_test.dart +++ b/test/tencent_kit_method_channel_test.dart @@ -9,16 +9,19 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); setUp(() { - channel.setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, (MethodCall methodCall) async { switch (methodCall.method) { case 'isQQInstalled': return true; } + return null; }); }); tearDown(() { - channel.setMockMethodCallHandler(null); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, null); }); test('isQQInstalled', () async {