cli.dart 2.17 KB
Newer Older
1 2 3 4 5 6 7 8 9
// 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.

// See: https://github.com/flutter/flutter/wiki/Release-process

import 'dart:io' as io;

import 'package:args/command_runner.dart';
10
import 'package:conductor_core/conductor_core.dart';
11 12 13 14 15
import 'package:file/file.dart';
import 'package:file/local.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart';

16 17
const String readmeUrl = 'https://github.com/flutter/flutter/tree/master/dev/conductor/README.md';

18
Future<void> main(List<String> args) async {
19 20 21 22 23 24 25 26 27 28
  const FileSystem fileSystem = LocalFileSystem();
  const ProcessManager processManager = LocalProcessManager();
  const Platform platform = LocalPlatform();
  final Stdio stdio = VerboseStdio(
    stdout: io.stdout,
    stderr: io.stderr,
    stdin: io.stdin,
  );
  final Checkouts checkouts = Checkouts(
    fileSystem: fileSystem,
29
    parentDirectory: localFlutterRoot.parent,
30 31
    platform: platform,
    processManager: processManager,
32
    stdio: stdio,
33
  );
34

35 36
  final CommandRunner<void> runner = CommandRunner<void>(
    'conductor',
37 38
    'A tool for coordinating Flutter releases. For more documentation on '
    'usage, please see $readmeUrl.',
39 40 41 42
    usageLineLength: 80,
  );

  <Command<void>>[
43 44
    RollDevCommand(
      checkouts: checkouts,
45 46 47 48
      fileSystem: fileSystem,
      platform: platform,
      stdio: stdio,
    ),
49 50 51 52
    CodesignCommand(
      checkouts: checkouts,
      flutterRoot: localFlutterRoot,
    ),
53 54 55 56 57 58 59 60 61 62
    StatusCommand(
      checkouts: checkouts,
    ),
    StartCommand(
      checkouts: checkouts,
      flutterRoot: localFlutterRoot,
    ),
    CleanCommand(
      checkouts: checkouts,
    ),
63 64 65 66
    CandidatesCommand(
      checkouts: checkouts,
      flutterRoot: localFlutterRoot,
    ),
67 68 69
    NextCommand(
      checkouts: checkouts,
    ),
70 71 72 73 74 75 76 77
  ].forEach(runner.addCommand);

  if (!assertsEnabled()) {
    stdio.printError('The conductor tool must be run with --enable-asserts.');
    io.exit(1);
  }

  try {
78
    await runner.run(args);
79 80
  } on Exception catch (e, stacktrace) {
    stdio.printError('$e\n\n$stacktrace');
81 82 83
    io.exit(1);
  }
}