mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

I plan to extend the prepare_package.dart script to upload the flutter preview device ([design doc](https://docs.google.com/document/d/1AzI-_Uk2v1LA2kKKFJ7gVD4xcakXJ6yVZiS5Ek6RHtg/edit#heading=h.byp03plw7mg9)). However, given that that script is one large >1k line file, I decided to organize it into smaller libraries in this PR. There should be no behavioral change in this PR, this is a cleanup only. I made the following changes: 1. Created a //dev/bots/prepare_package/ directory to contain helper libraries 2. Moved everything but the `main()` function in //dev/bots/prepare_package.dart into one of 4 helper libraries under the new directory from step 1: a. archive_creator.dart which contains the code that creates archive directory locally on disk b. archive_publisher.dart which contains the code that uploads the archive to cloud storage c. common.dart for shared constants and definitions d. process_runner.dart for an abstraction over running sub-processes 3. Changed all definitions to `File` and `Directory` from `dart:io` to use the testable versions from `package:file`. This allowed me to use the `MemoryFileSystem` in the unit tests, rather than creating real temp file system directories.
47 lines
1.5 KiB
Dart
47 lines
1.5 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'dart:io' hide Platform;
|
|
|
|
const String gobMirror = 'https://flutter.googlesource.com/mirrors/flutter';
|
|
const String githubRepo = 'https://github.com/flutter/flutter.git';
|
|
const String mingitForWindowsUrl = 'https://storage.googleapis.com/flutter_infra_release/mingit/'
|
|
'603511c649b00bbef0a6122a827ac419b656bc19/mingit.zip';
|
|
const String releaseFolder = '/releases';
|
|
const String gsBase = 'gs://flutter_infra_release';
|
|
const String gsReleaseFolder = '$gsBase$releaseFolder';
|
|
const String baseUrl = 'https://storage.googleapis.com/flutter_infra_release';
|
|
const int shortCacheSeconds = 60;
|
|
const String frameworkVersionTag = 'frameworkVersionFromGit';
|
|
const String dartVersionTag = 'dartSdkVersion';
|
|
const String dartTargetArchTag = 'dartTargetArch';
|
|
|
|
enum Branch {
|
|
beta,
|
|
stable,
|
|
master,
|
|
main;
|
|
}
|
|
|
|
/// Exception class for when a process fails to run, so we can catch
|
|
/// it and provide something more readable than a stack trace.
|
|
class PreparePackageException implements Exception {
|
|
PreparePackageException(this.message, [this.result]);
|
|
|
|
final String message;
|
|
final ProcessResult? result;
|
|
int get exitCode => result?.exitCode ?? -1;
|
|
|
|
@override
|
|
String toString() {
|
|
String output = runtimeType.toString();
|
|
output += ': $message';
|
|
final String stderr = result?.stderr as String? ?? '';
|
|
if (stderr.isNotEmpty) {
|
|
output += ':\n$stderr';
|
|
}
|
|
return output;
|
|
}
|
|
}
|