publishProjectToGithub static method

Future<void> publishProjectToGithub()

Implementation

static Future<void> publishProjectToGithub() async {
  bool publishToGitHub = await _askToPublishToGitHub();

  if (publishToGitHub) {
    // get user repository url
    stdout.write('๐Ÿ˜Ž Enter your repository url: ');
    final repoUrl = stdin.readLineSync()?.trim() ?? "";

    // get user  repository commit message [ by default is init project ]
    stdout.write(
        '๐Ÿ˜Ž Enter your repository commit message [ by default is init project ]: ');
    final repoCommitMessage = stdin.readLineSync()?.trim() ?? "init project";

    await RunInCmd.runInCmd('git init');
    await RunInCmd.runInCmd('git add .');
    await RunInCmd.runInCmd('git commit -m "$repoCommitMessage"');
    await RunInCmd.runInCmd('git branch -M main');
    await RunInCmd.runInCmd('git remote add origin $repoUrl');
    await RunInCmd.runInCmd('git push -u origin main');

    print("โšกโšก Publish to GitHub completed successfully\n");
    print("๐Ÿ”—๐Ÿ”— Repo link: $repoUrl\n");
  }
}