dvCloudSourceExcluded function

bool dvCloudSourceExcluded(
  1. String path, {
  2. String app = '.',
})

Whether path, relative to the project with / separators, stays out of the source a cloud build uploads.

Build output and tool caches are rebuilt by the worker and are most of a project's size. .env files are left out because they hold the values Secrets and Environments exists to keep off other machines; signing and store credentials go to the Cloud credential store instead. .env.example is a template and is kept.

app is the application's directory within the source, whose own build/ is output as the source root's is.

Implementation

bool dvCloudSourceExcluded(String path, {String app = '.'}) {
  final List<String> parts = path.split('/').where((String s) => s.isNotEmpty).toList();
  if (parts.isEmpty) return true;
  if (parts.any(_alwaysExcluded.contains)) return true;
  if (parts.first == 'build') return true;
  final List<String> appParts = app.split('/').where((String s) => s.isNotEmpty && s != '.').toList();
  if (appParts.isNotEmpty &&
      parts.length > appParts.length &&
      parts.take(appParts.length).join('/') == appParts.join('/') &&
      parts[appParts.length] == 'build') {
    return true;
  }
  for (int i = 1; i < parts.length; i++) {
    if (parts[i] == 'build' && _platformDirectories.contains(parts[i - 1])) return true;
    if (i >= 2 && parts[i] == 'build' && parts[i - 1] == 'app' && parts[i - 2] == 'android') {
      return true;
    }
  }
  final String name = parts.last;
  if ((name == '.env' || name.startsWith('.env.')) && name != '.env.example') return true;
  return false;
}