Skip to content

Commit

Permalink
using from git
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyokone committed Apr 23, 2024
1 parent 7f7cce7 commit 68e1b86
Showing 1 changed file with 76 additions and 1 deletion.
77 changes: 76 additions & 1 deletion packages/flutterfire_cli/lib/src/commands/install.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ class InstallCommand extends FlutterFireCommand {
final jsonString = await response.transform(utf8.decoder).join();
final json = jsonDecode(jsonString) as Map<String, dynamic>;

if (bomVersion == 'latest') {
if (bomVersion == 'latest' ||
bomVersion == 'master' ||

Check warning on line 130 in packages/flutterfire_cli/lib/src/commands/install.dart

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/master/gi
bomVersion == 'main' ||
bomVersion.contains('git')) {
// The latest version is the first key in the JSON
return ((json[json.keys.first] as Map)['packages'] as Map)
.cast<String, String>();
Expand Down Expand Up @@ -231,6 +234,78 @@ class InstallCommand extends FlutterFireCommand {

installingSpinner.done();

// Overriding using git branch
if (bomVersion == 'master' ||

Check warning on line 238 in packages/flutterfire_cli/lib/src/commands/install.dart

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/master/gi
bomVersion == 'main' ||
bomVersion.contains('git')) {
final gitBranch = bomVersion.contains('git')
? bomVersion.replaceFirst('git:', '')
: 'master';

Check warning on line 243 in packages/flutterfire_cli/lib/src/commands/install.dart

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/master/gi
final gitSpinner = spinner(
(done) {
if (!done) {
return 'Overriding using git branch $gitBranch ... ';
}
return 'Override using git branch $gitBranch done.';
},
);

final gitInstructions = selectedPlugins.map(
(e) =>
'override:${e.name}:{"git":{"url":"https://github.com/firebase/flutterfire.git","ref":"$gitBranch","path":"packages/${e.name}/${e.name}"}}',
);
final result = await Process.run(
'flutter',
[
'pub',
'add',
...gitInstructions,
'--directory',
'.',
],
workingDirectory: flutterApp!.package.path,
);

gitSpinner.done();

if (result.exitCode != 0) {
throw Exception(
AnsiStyles.red('Failed to install plugins.\n\n${result.stderr}'),
);
}
} else {
// Remove the git overrides
final gitOverrides = pubSpec.dependencyOverrides.keys
.where(
(element) =>
FlutterFirePlugins.allPluginsPublicNames.contains(element),
)
.toList();

if (gitOverrides.isNotEmpty) {
final gitOverrideSpinner = spinner(
(done) {
if (!done) {
return 'Removing git overrides ... ';
}
return 'Git overrides removed.';
},
);

await Process.run(
'flutter',
[
'pub',
'remove',
...gitOverrides.map((e) => 'override:$e'),
],
workingDirectory: flutterApp!.package.path,
);

gitOverrideSpinner.done();
}
}

stdout.writeln(
AnsiStyles.green(
'Successfully installed BoM version $bomVersion 🚀',
Expand Down

0 comments on commit 68e1b86

Please sign in to comment.