<commit_before>var fs = require('fs');
var ff = require('ff');
var path = require('path');

var color = require('cli-color');

var commands = require('./index');
var apps = require('../apps');

var BaseCommand = require('../util/BaseCommand').BaseCommand;

var InitCommand = Class(BaseCommand, function (supr) {

  this.name = 'init';
  this.description = 'creates a new devkit app';

  this.exec = function (args, cb) {

    // check the app name
    var appName = args.shift();
    if (!appName) {
      throw new Error('No app name provided');
    }

    if (!/[a-z][a-z0-9]+/i.test(appName)) {
      throw new Error('App name must start with a letter and consist only of letters and numbers');
    }

    // create the directory
    if (!fs.existsSync(appName)) {
      fs.mkdirSync(appName);
    }

    var f = ff(this, function () {
      apps.create(appName, f());
    }, function (app) {
      process.chdir(app.paths.root);
      commands.get('install').exec([], f());
    }).error(bind(this, function (err) {
      this.logger.error(err);
    })).success(bind(this, function () {
      this.logger.log(color.cyanBright('created new app'), color.yellowBright(appName));
    })).cb(cb);
  };
});
<commit_msg>devkit init: fix appName test and support full paths as arguments<commit_after>var fs = require('fs');
var ff = require('ff');
var path = require('path');

var color = require('cli-color');

var commands = require('./index');
var apps = require('../apps');

var BaseCommand = require('../util/BaseCommand').BaseCommand;

var InitCommand = Class(BaseCommand, function (supr) {

  this.name = 'init';
  this.description = 'creates a new devkit app';

  this.exec = function (args, cb) {

    // check the app name
    var appPath = args.shift();
    var appName = path.basename(appPath)
    appPath = path.resolve(process.cwd(), appPath);
    if (!appName) {
      throw new Error('No app name provided');
    }

    if (!/^[a-z][a-z0-9]+$/i.test(appName)) {
      throw new Error('App name must start with a letter and consist only of letters and numbers');
    }

    // create the directory
    if (!fs.existsSync(appPath)) {
      fs.mkdirSync(appPath);
    }

    var f = ff(this, function () {
      apps.create(appPath, f());
    }, function (app) {
      process.chdir(app.paths.root);
      commands.get('install').exec([], f());
    }).error(bind(this, function (err) {
      this.logger.error(err);
    })).success(bind(this, function () {
      this.logger.log(color.cyanBright('created new app'), color.yellowBright(appName));
    })).cb(cb);
  };
});

{'fraction_non_alphanumeric': 0.17681271810779373, 'fraction_numerical': 0.0015509887553315238, 'mean_word_length': 3.161290322580645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '769597', 'n_tokens_mistral': 843, 'n_tokens_neox': 819, 'n_words': 214}