<commit_before>var mout = require('mout');
var fs = require('../util/fs');
var path = require('path');
var Q = require('q');
var endpointParser = require('bower-endpoint-parser');
var Project = require('../core/Project');
var defaultConfig = require('../config');
var GitHubResolver = require('../core/resolvers/GitHubResolver');
var cmd = require('../util/cmd');
var createError = require('../util/createError');

function init(logger, config) {
    var project;

    config = config || {};

    if (!config.cwd) {
        config.cwd = process.cwd();
    }

    config = defaultConfig(config);

    // This command requires interactive to be enabled
    if (!config.interactive) {
        throw createError('Register requires an interactive shell', 'ENOINT', {
            details: 'Note that you can manually force an interactive shell with --config.interactive'
        });
    }

    project = new Project(config, logger);

    // Start with existing JSON details
    return readJson(project, logger)
    // Fill in defaults
    .then(setDefaults.bind(null, config))
    // Now prompt user to make changes
    .then(promptUser.bind(null, logger))
    // Set ignore based on the response
    .spread(setIgnore.bind(null, config))
    // Set dependencies based on the response
    .spread(setDependencies.bind(null, project))
    // All done!
    .spread(saveJson.bind(null, project, logger));
}

function readJson(project, logger) {
    return project.hasJson()
    .then(function (json) {
        if (json) {
            logger.warn('existing', 'The existing ' + path.basename(json) + ' file will be used and filled in');
        }

        return project.getJson();
    });
}

function saveJson(project, logger, json) {
    // Cleanup empty props (null values, empty strings, objects and arrays)
    mout.object.forOwn(json, function (value, key) {
        if (!validConfigValue(value)) {
            delete json[key];
        }
    });

    logger.info('json', 'Generated json', { json: json });

    // Confirm the json with the user
    return Q.nfcall(logger.prompt.bind(logger), {
        type: 'confirm',
        message: 'Looks good?',<commit_msg>init command does not enforce project name<commit_after>var mout = require('mout');
var fs = require('../util/fs');
var path = require('path');
var Q = require('q');
var endpointParser = require('bower-endpoint-parser');
var Project = require('../core/Project');
var defaultConfig = require('../config');
var GitHubResolver = require('../core/resolvers/GitHubResolver');
var cmd = require('../util/cmd');
var createError = require('../util/createError');

function init(logger, config) {
    var project;

    config = config || {};

    if (!config.cwd) {
        config.cwd = process.cwd();
    }

    config = defaultConfig(config);

    // This command requires interactive to be enabled
    if (!config.interactive) {
        throw createError('Register requires an interactive shell', 'ENOINT', {
            details: 'Note that you can manually force an interactive shell with --config.interactive'
        });
    }

    project = new Project(config, logger);

    // Start with existing JSON details
    return readJson(project, logger)
    // Fill in defaults
    .then(setDefaults.bind(null, config))
    // Now prompt user to make changes
    .then(promptUser.bind(null, logger))
    // Set ignore based on the response
    .spread(setIgnore.bind(null, config))
    // Set dependencies based on the response
    .spread(setDependencies.bind(null, project))
    // All done!
    .spread(saveJson.bind(null, project, logger));
}

function readJson(project, logger) {
    return project.hasJson()
    .then(function (json) {
        if (json) {
            logger.warn('existing', 'The existing ' + path.basename(json) + ' file will be used and filled in');
        }

        return project.getJson({
            enforceNameExists: false
        });
    });
}

function saveJson(project, logger, json) {
    // Cleanup empty props (null values, empty strings, objects and arrays)
    mout.object.forOwn(json, function (value, key) {
        if (!validConfigValue(value)) {
            delete json[key];
        }
    });

    logger.info('json', 'Generated json', { json: json });

    // Confirm the json with the user
    return Q.nfcall(logger.prompt.bind(logger), {
        type: 'confirm',
        message: 'Looks good?',
{'fraction_non_alphanumeric': 0.1390216154721274, 'fraction_numerical': 0.0, 'mean_word_length': 2.897163120567376, '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': '1315905', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1215, 'n_words': 365}