<commit_before>#! /usr/bin/env node

/* global require, process */

var program = require('commander'),
	fs = require('fs'),
	cwd = process.cwd(),
	cliPath = cwd + '/node_modules/wee-core/cli.js',
	initCommand = require('./wee-init'),
	command = process.argv[2];

// Register version and init command
program
	.version(require('../package').version)
	.usage('[command] [options]')
	.command('init', 'create a new project');

// Register init command
// Stop further registration of commands as
// All other commands require being inside wee project
if (command === 'init') {
	return;
}

// Register commands in wee-core and project specific commands
// These commands must be called from within a proper wee project to work
fs.stat(cliPath, function(error) {
	if (error) {
		// Process early and stop if no command, or help command called
		// and we are not inside of a proper project
		if (! command || command === '-h' || command === '--help') {
			// TODO: Show how to initialize project - custom feedback
			program.parse(process.argv);
			return;
		}

		fs.stat('./package.json', function(error) {
			if (error) {
				console.log('Wee package.json not found in current directory');
				return;
			}

			fs.readFile('./package.json', function(error, data) {
				if (error) {
					console.log(error);
					return;
				}

				// Check for valid Wee installation
				var config = JSON.parse(data);

				if (config.name == 'wee-framework' || config.name == 'wee') {
					console.log('Run "npm install" to install Wee core');
				} else {
					console.log('The package.json is not compatible with Wee');
				}
			});
		});

		return;
	}

	// Set help as default command if nothing found
	program
		.on('*', () => {
			program.outputHelp();
		});

	// Register all other commands from specific project
	require(cliPath)(cwd, program);

	// Process cli input and execute command
	program.parse(process.argv);
});<commit_msg>Separate init from other cli commands<commit_after>#! /usr/bin/env node

/* global require, process */

var program = require('commander'),
	fs = require('fs'),
	cwd = process.cwd(),
	cliPath = cwd + '/node_modules/wee-core/cli.js',
	command = process.argv[2];

// Register version and init command
program
	.version(require('../package').version)
	.usage('[command] [options]');

// Register init command
// Stop further registration of commands as
// all other commands require being inside wee project
if (command === 'init') {
	require('./wee-init');

	program.command('init', 'create a new project');

	return;
}

// Register commands in wee-core and project specific commands
// These commands must be called from within a proper wee project to work
fs.stat(cliPath, function(error) {
	if (error) {
		// Process early and stop if no command, or help command called
		// and we are not inside of a proper project
		if (! command || command === '-h' || command === '--help') {
			// TODO: Show how to initialize project - custom feedback
			program.parse(process.argv);
			return;
		}

		fs.stat('./package.json', function(error) {
			if (error) {
				console.log('Wee package.json not found in current directory');
				return;
			}

			fs.readFile('./package.json', function(error, data) {
				if (error) {
					console.log(error);
					return;
				}

				// Check for valid Wee installation
				var config = JSON.parse(data);

				if (config.name == 'wee-framework' || config.name == 'wee') {
					console.log('Run "npm install" to install Wee core');
				} else {
					console.log('The package.json is not compatible with Wee');
				}
			});
		});

		return;
	}

	// Set help as default command if nothing found
	program
		.on('*', () => {
			program.outputHelp();
		});

	// Register all other commands from specific project
	require(cliPath)(cwd, program);

	// Process cli input and execute command
	program.parse(process.argv);
});
{'fraction_non_alphanumeric': 0.14648033126293997, 'fraction_numerical': 0.0005175983436853002, 'mean_word_length': 3.237938596491228, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6379959', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1151, 'n_words': 386}