start function

Future<void> start()

process of start

Implementation

Future<void> start() async {
  // Cometプロジェクトかどうか
  final cometYaml = readCometYaml();
  if (cometYaml == null) {
    print('Not found $cometYamlName');
    return;
  }

  ProgressStar.start('building..');

  await Process.run(
    'comet',
    [
      'build',
    ],
    runInShell: true,
  );

  ProgressStar.message('flutter run..');

  await runFlutterRun(
    cometYaml.flutterProject.root,
    (process) async {
      // on process started
      final shelfFolders = await resolveSrcShelves(cometYaml);
      watchSrc(
        shelfFolders,
        onEditFolder: (srcPath) async {
          await _runCometBuild();
          await runFlutterRestart(process);
        },
        onEditPage: (srcPath) async {
          await buildOnlyPage(srcPath, cometYaml);
          await runFlutterRestart(process);
        },
      );
      watchFlutterLib(
        cometYaml.flutterProject.root,
        onEdit: (srcPath) async {
          await runFlutterRestart(process);
        },
      );
    },
    () {
      // maybe app started
      ProgressStar.blink('watching .md..');
    },
  );

  // on app finished
  ProgressStar.stop();
  exit(0);
}