From 702ad031ee052ee67b810fc1357cfca0b62ab46a Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 21 Dec 2023 15:26:49 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Update=20tool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cronet.yml | 2 +- .../tool/prepare_for_embedded.dart | 31 ++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index ebcea17bcc..37e38d5415 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -62,4 +62,4 @@ jobs: target: ${{ matrix.package == 'cronet_http_embedded' && 'default' || 'playstore' }} arch: x86_64 profile: pixel - script: cd 'pkgs/${{ matrix.package }}/example' && flutter test --timeout=1500s integration_test/ + script: cd 'pkgs/${{ matrix.package }}/example' && flutter test --timeout=1200s integration_test/ diff --git a/pkgs/cronet_http/tool/prepare_for_embedded.dart b/pkgs/cronet_http/tool/prepare_for_embedded.dart index e73543c33f..f98eb8f0af 100644 --- a/pkgs/cronet_http/tool/prepare_for_embedded.dart +++ b/pkgs/cronet_http/tool/prepare_for_embedded.dart @@ -51,10 +51,10 @@ void main(List args) async { final latestVersion = await _getLatestCronetVersion(); updateCronetDependency(latestVersion); - if (args.isNotEmpty && args.first == 'publish') { - updatePubSpec(); - updateReadme(); - } + updatePubSpec(); + updateReadme(); + updateImports(); + updateEntryPoint(); } Future _getLatestCronetVersion() async { @@ -115,3 +115,26 @@ void updateReadme() { File('${_packageDirectory.path}/README_EMBEDDED.md') .renameSync('${_packageDirectory.path}/README.md'); } + +void updateImports() { + for (final f in _packageDirectory.listSync( + recursive: true, + followLinks: false, + )) { + if (f case final file when file is File && file.path.endsWith('.dart')) { + final updatedSource = file.readAsStringSync().replaceAll( + 'package:cronet_http_embedded/cronet_http_embedded.dart', + 'package:cronet_http_embedded/cronet_http_embedded.dart', + ); + file.writeAsStringSync(updatedSource); + } + } +} + +void updateEntryPoint() { + File( + '${_packageDirectory.path}/lib/cronet_http.dart', + ).renameSync( + '${_packageDirectory.path}/lib/cronet_http_embedded.dart', + ); +}