Skip to content

Commit

Permalink
👷 Remove args
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Dec 7, 2023
1 parent 91e5ba6 commit bcf7b89
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions pkgs/cronet_http/tool/prepare_for_embedded.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ final _cronetVersionUri = Uri.https(
'android/maven2/org/chromium/net/group-index.xml',
);

/// Runs `prepare_for_embedded.dart true` for publishing,
/// or only the Android dependency will be modified.
void main(List<String> args) async {
void main() async {
if (Directory.current.path.endsWith('tool')) {
_packageDirectory = Directory.current.parent;
} else {
Expand All @@ -51,10 +49,8 @@ void main(List<String> args) async {

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

Future<String> _getLatestCronetVersion() async {
Expand All @@ -73,7 +69,7 @@ Future<String> _getLatestCronetVersion() async {
return versions.last;
}

/// Update android/build.gradle
/// Update android/build.gradle.
void updateCronetDependency(String latestVersion) {
final fBuildGradle = File('${_packageDirectory.path}/android/build.gradle');
final gradleContent = fBuildGradle.readAsStringSync();
Expand All @@ -92,22 +88,25 @@ void updateCronetDependency(String latestVersion) {
fBuildGradle.writeAsStringSync(newGradleContent);
}

/// Update pubspec.yaml and example/pubspec.yaml
/// Update pubspec.yaml and example/pubspec.yaml.
void updatePubSpec() {
print('Updating pubspec.yaml');
final fPubspec = File('${_packageDirectory.path}/pubspec.yaml');
final yamlEditor = YamlEditor(fPubspec.readAsStringSync())
..update(['name'], _packageName)
..update(['description'], _packageDescription);
fPubspec.writeAsStringSync(yamlEditor.toString());
final examplePubspec = File('${_packageDirectory.path}/pubspec.yaml');
print('Updating example/pubspec.yaml');
final examplePubspec = File('${_packageDirectory.path}/example/pubspec.yaml');
final replaced = examplePubspec
.readAsStringSync()
.replaceAll('cronet_http:', 'cronet_http_embedded:');
examplePubspec.writeAsStringSync(replaced);
}

/// Move README_EMBEDDED.md to replace README.md
/// Move README_EMBEDDED.md to replace README.md.
void updateReadme() {
print('Updating README.md from README_EMBEDDED.md');
File('${_packageDirectory.path}/README.md').deleteSync();
File('${_packageDirectory.path}/README_EMBEDDED.md')
.renameSync('${_packageDirectory.path}/README.md');
Expand Down

0 comments on commit bcf7b89

Please sign in to comment.