Skip to content

Commit

Permalink
🔨 Update tool
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Dec 21, 2023
1 parent 05d63a8 commit 702ad03
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cronet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
31 changes: 27 additions & 4 deletions pkgs/cronet_http/tool/prepare_for_embedded.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ void main(List<String> args) async {

final latestVersion = await _getLatestCronetVersion();
updateCronetDependency(latestVersion);
if (args.isNotEmpty && args.first == 'publish') {
updatePubSpec();
updateReadme();
}
updatePubSpec();
updateReadme();
updateImports();
updateEntryPoint();
}

Future<String> _getLatestCronetVersion() async {
Expand Down Expand Up @@ -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',
);
}

0 comments on commit 702ad03

Please sign in to comment.