run method

  1. @override
void run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
void run() {
  final args = argResults!;
  final project = _project(this);
  final changelog = args.option('changelog') ?? project.changelog;
  final appstore = args.option('appstore') ?? project.appStoreMetadata;

  // Refused rather than passed: checking nothing and reporting success is the
  // failure this command exists to prevent, so having nothing to check is
  // itself the finding.
  if (changelog == null && appstore == null) {
    stderr.writeln(
      'cux_ship verify: nothing to check — no CHANGELOG.md and no App Store '
      'metadata tree were found, and neither was named.',
    );
    exitCode = 1;
    return;
  }

  final problems = <ReleaseProblem>[
    if (changelog != null) ...checkChangelogFile(changelog),
    if (appstore != null)
      ...checkAppStoreTree(
        appstore,
        requireScreenshotTypes: args
            .multiOption('require-screenshot-type')
            .toSet(),
        requireLocales: args.multiOption('require-locale').toSet(),
      ),
  ];

  if (problems.isEmpty) {
    stdout.writeln('==> release inputs are publishable');
    return;
  }
  // Every problem at once. Reported one at a time, the second is found only
  // after the first is fixed and pushed.
  stderr.writeln('cux_ship verify: ${problems.length} problem(s)');
  for (final problem in problems) {
    stderr.writeln('  $problem');
  }
  exitCode = 1;
}