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

var _ = require('lodash');
var fs = require('fs-extra');
var inquirer = require('inquirer');
var path = require('path');
var userhome = require('userhome');

var configFilePath = path.join(userhome(), '.lws.json');

function Instance(username, password, host, port, portalVersion) {
	this.username = username || '<EMAIL>';
	this.password = password || '<PASSWORD>';
	this.host = host || 'localhost';
	this.port = port || '8080';
	this.portalVersion = portalVersion || 'master';

	return this;
}

// Reads the config file in the user's home folder
function getConfig() {
	return fs.readJSONSync(configFilePath);
}

// Writes to the config file in the user's home folder
function setConfig(config) {
	fs.writeJSONSync(configFilePath, config);
}

var config = getConfig();

// Writes the default instance configuration to a config file in the user's home folder
module.exports.init = function() {
	var defaultInstance = new Instance();

	var configObject = {
		instances: {
			default: defaultInstance
		},
		currentInstance: 'default'
	};

	setConfig(configObject);
}

// Returns the name of of the currently active instance configuration
module.exports.getCurrentInstanceName = function() {
	return config.currentInstance;
}

// Returns an array of instance configuration names
module.exports.getInstanceConfigList = function() {
	return _.keys(config.instances);
}

// Returns all the instance configuration objects
module.exports.getInstanceConfigs = function() {
	return config.instances;
}

// Returns a single instance configuration
module.exports.getInstanceConfig = function(configName) {
	return config.instances[configName];
}

// Returns the currently active instance configuration
module.exports.getCurrentInstanceConfig = function() {
	return module.exports.getInstanceConfig(config.currentInstance);
}

// Sets the active instance configuration
module.exports.setCurrentInstanceConfig = function(configName) {
	config.currentInstance = configName;

	setConfig(config);
}

// Writes an instance configuration to the config file
module.exports.setInstanceConfig = function(name, username, password, host, port, portalVersion) {
	var newInstance = new Instance(username, password, host, port, portalVersion);

	config.instances[name] = newInstance;

	setConfig(config);
}

// Deletes an instance configuration from the config file
module.exports.deleteInstanceConfig = function(instanceConfigName) {
	delete config.instances[instanceConfigName];

	setConfig(config);
}





<commit_msg>Source format config.js<commit_after>#!/usr/bin/env node

var _ = require('lodash');
var fs = require('fs-extra');
var inquirer = require('inquirer');
var path = require('path');
var userhome = require('userhome');

var configFilePath = path.join(userhome(), '.lws.json');

function Instance(username, password, host, port, portalVersion) {
	this.username = username || '<EMAIL>';
	this.password = password || '<PASSWORD>';
	this.host = host || 'localhost';
	this.port = port || '8080';
	this.portalVersion = portalVersion || 'master';

	return this;
}

// Reads the config file in the user's home folder
function getConfig() {
	return fs.readJSONSync(configFilePath);
}

// Writes to the config file in the user's home folder
function setConfig(config) {
	fs.writeJSONSync(configFilePath, config);
}

var config = getConfig();

// Deletes an instance configuration from the config file
module.exports.deleteInstanceConfig = function(instanceConfigName) {
	delete config.instances[instanceConfigName];

	setConfig(config);
}

// Returns the currently active instance configuration
module.exports.getCurrentInstanceConfig = function() {
	return module.exports.getInstanceConfig(config.currentInstance);
}

// Returns the name of of the currently active instance configuration
module.exports.getCurrentInstanceName = function() {
	return config.currentInstance;
}

// Returns a single instance configuration
module.exports.getInstanceConfig = function(configName) {
	return config.instances[configName];
}

// Returns an array of instance configuration names
module.exports.getInstanceConfigList = function() {
	return _.keys(config.instances);
}

// Returns all the instance configuration objects
module.exports.getInstanceConfigs = function() {
	return config.instances;
}

// Writes the default instance configuration to a config file in the user's home folder
module.exports.init = function() {
	var defaultInstance = new Instance();

	var configObject = {
		instances: {
			default: defaultInstance
		},
		currentInstance: 'default'
	};

	setConfig(configObject);
}

// Sets the active instance configuration
module.exports.setCurrentInstanceConfig = function(configName) {
	config.currentInstance = configName;

	setConfig(config);
}

// Writes an instance configuration to the config file
module.exports.setInstanceConfig = function(name, username, password, host, port, portalVersion) {
	var newInstance = new Instance(username, password, host, port, portalVersion);

	config.instances[name] = newInstance;

	setConfig(config);
}

{'fraction_non_alphanumeric': 0.11071640023682652, 'fraction_numerical': 0.0015788434971383462, 'mean_word_length': 5.342928660826033, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1400791', 'n_tokens_mistral': 1402, 'n_tokens_neox': 1365, 'n_words': 410}