dryRun method

PurgeReport dryRun()

Compute (without deleting) every directory the rebuild step would purge. Safe to call on partial / broken projects — missing entries are reported in PurgeReport.alreadyMissing instead of raising.

Implementation

PurgeReport dryRun() {
  final List<String> toDelete = <String>[];
  final List<String> missing = <String>[];
  final List<String> rejected = <String>[];

  for (final String candidate in _candidatePaths()) {
    final String abs = p.normalize(p.absolute(candidate));

    // Sanity check #1: must live inside outputDir.
    if (!_isInsideOutput(abs)) {
      rejected.add(abs);
      continue;
    }

    // Sanity check #2: must not be the outputDir itself.
    if (p.equals(abs, _outputRoot.path)) {
      rejected.add(abs);
      continue;
    }

    // Sanity check #3: must not be a Firebase artefact / config file.
    if (_isProtectedPath(abs)) {
      rejected.add(abs);
      continue;
    }

    if (Directory(abs).existsSync()) {
      toDelete.add(abs);
    } else {
      missing.add(abs);
    }
  }

  return PurgeReport(
    directoriesToDelete: toDelete,
    alreadyMissing: missing,
    rejected: rejected,
  );
}