<commit_before>var inquirer = require('inquirer');
var commander = require('commander');
var path = require('path');
var fs = require('fs');
var exec = require('child_process').exec;
var spawn = require('child_process').spawn;

// Setup default api request.
// OAuth consumer key and secret setup, etc.
var apiRequest = require('request').defaults({
  baseUrl: 'https://api.bitbucket.org',
  oauth: {
    consumer_key: process.env.BITBUCKET_KEY,
    consumer_secret: process.env.BITBUCKET_SECRET
  },
  json: true
});

var packageInfo = null;

commander
  .command('new <slug> [owner]')
  .description('Create a html boilerplate. Owner defaults to "inclusive-activities"')
  .action(function(slug, owner){
    owner = owner || 'inclusive-activities';

    if(!slug){
      throw new Error('Missing slug name!');
    }

    // If local directory already exist, stop it.
    var directoryPath = path.join(process.cwd(), slug);
    if(fs.existsSync(directoryPath)){
      throw new Error('Directory: "' + directoryPath + '" already exists!');
    }

    // If remote repository exists, directly clone the repository. Otherwise,
    // go through step by step to create a brand new application.
    createRemoteRepo(owner, slug).then(function(remoteRepoExist){
      if(remoteRepoExist){
        return cloneRemoteRepo(owner, slug);
      }
      else{
        return createLocalRepo(slug).then(function(){
          return setupHooks(owner, slug);
        }).then(function(){
          return setDeploymentKey(owner, slug);
        }).then(function(){
          return setRemotes(owner, slug);
        }).then(function(){
          return firstCommit(slug);
        });
      }
    }).catch(function(error){
      console.log(error);
    });
  });

function cloneRemoteRepo(owner, slug){
  console.log('Remote repository already exist, directly clone the repository. You might want to double check the name.')
  return new Promise(function(resolve, reject){
    var params = ['clone', '<EMAIL>:'+owner+'/'+slug+'.git'];
    var operation = spawn('git', params, {stdio: 'inherit'});
    operation.on('exit', function(code){
      if(code === 0){
        console.log('Local repository created.');
        resolve();
      }
      else{
        throw new Error('An error has happened during local repository creation. Exit code: ' + code);
      }
    });<commit_msg>Remove deployment key setup step.<commit_after>var inquirer = require('inquirer');
var commander = require('commander');
var path = require('path');
var fs = require('fs');
var exec = require('child_process').exec;
var spawn = require('child_process').spawn;

// Setup default api request.
// OAuth consumer key and secret setup, etc.
var apiRequest = require('request').defaults({
  baseUrl: 'https://api.bitbucket.org',
  oauth: {
    consumer_key: process.env.BITBUCKET_KEY,
    consumer_secret: process.env.BITBUCKET_SECRET
  },
  json: true
});

var packageInfo = null;

commander
  .command('new <slug> [owner]')
  .description('Create a html boilerplate. Owner defaults to "inclusive-activities"')
  .action(function(slug, owner){
    owner = owner || 'inclusive-activities';

    if(!slug){
      throw new Error('Missing slug name!');
    }

    // If local directory already exist, stop it.
    var directoryPath = path.join(process.cwd(), slug);
    if(fs.existsSync(directoryPath)){
      throw new Error('Directory: "' + directoryPath + '" already exists!');
    }

    // If remote repository exists, directly clone the repository. Otherwise,
    // go through step by step to create a brand new application.
    createRemoteRepo(owner, slug).then(function(remoteRepoExist){
      if(remoteRepoExist){
        return cloneRemoteRepo(owner, slug);
      }
      else{
        return createLocalRepo(slug).then(function(){
          return setupHooks(owner, slug);
        // }).then(function(){
        //   return setDeploymentKey(owner, slug);
        }).then(function(){
          return setRemotes(owner, slug);
        }).then(function(){
          return firstCommit(slug);
        });
      }
    }).catch(function(error){
      console.log(error);
    });
  });

function cloneRemoteRepo(owner, slug){
  console.log('Remote repository already exist, directly clone the repository. You might want to double check the name.')
  return new Promise(function(resolve, reject){
    var params = ['clone', '<EMAIL>:'+owner+'/'+slug+'.git'];
    var operation = spawn('git', params, {stdio: 'inherit'});
    operation.on('exit', function(code){
      if(code === 0){
        console.log('Local repository created.');
        resolve();
      }
      else{
        throw new Error('An error has happened during local repository creation. Exit code: ' + code);
      }
    });
{'fraction_non_alphanumeric': 0.14258635214827295, 'fraction_numerical': 0.00042122999157540015, 'mean_word_length': 3.2706834532374103, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3890878', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1351, 'n_words': 374}