github static method

Future<void> github()

Implementation

static Future<void> github() async {
  final projectPath = DirectoryService.choosePath();

  final usernameGithub = InputService.getValidatedInput(
      consoleMessage: Constants.kEnterUsernameGithub,
      errorMessage: Constants.kInvalidValue,
      functionValidator: Validator.isValidString
  );

  final repositoryGithub = InputService.getValidatedInput(
      consoleMessage: Constants.kEnterRepositoryGithub,
      errorMessage: Constants.kInvalidValue,
      functionValidator: Validator.isValidRepositoryGithub
  );

  _runGitCommand(projectPath, ['init']);
  _runGitCommand(projectPath, ['add', '--all']);
  _runGitCommand(projectPath, ['commit', '-m', 'first commit']);
  _runGitCommand(projectPath, ['branch', '-M', 'main']);
  _runGitCommand(
      projectPath,
      ['remote', 'add', 'origin', 'https://github.com/$usernameGithub/$repositoryGithub.git']
  );
  _runGitCommand(projectPath, ['push', '-u', 'origin', 'main']);

  Console.writeLine(dcli.green('✅  The project has connected to Github successfully!'));
}