runInteractive method

Future<void> runInteractive()

Menu of integrations that are not fully present yet.

Implementation

Future<void> runInteractive() async {
  final inspected = await ProjectInspector.inspect();
  final options = <String>[];
  final actions = <Future<void> Function()>[];

  if (!inspected.firebaseReady) {
    options.add('Firebase');
    actions.add(firebase);
  }
  if (!inspected.secretKeyReady) {
    options.add('Secret key');
    actions.add(secretKey);
  }
  if (!inspected.ciReady) {
    options.add('CI/CD');
    actions.add(ciCd);
  }
  if (inspected.missingPlatforms.isNotEmpty) {
    options.add('Additional platforms');
    actions.add(platforms);
  }

  if (options.isEmpty) {
    logger.success('Optional integrations are already set up.');
    logger.info(
      'You can still re-run a command directly, for example '
      '`xproject setup ci` to replace CI/CD.',
    );
    return;
  }

  logger.info('\nAdd an integration to this XProject app.\n');
  final index = Select(
    prompt: 'Choose integration',
    options: options,
  ).interact();
  await actions[index]();
}