<commit_before>/* Magic Mirror
 * Node Helper: MagicMirror-Moduler-Manager
 *
 * By <NAME> https://rodrigoramirez.com
 * MIT Licensed.
 */

var NodeHelper = require("node_helper");
var request = require("request");
var url = require("url");
var querystring = require('querystring');


module.exports = NodeHelper.create({
	// Override start method.
	start: function() {
		var self = this;

		console.log("Starting node helper for: " + this.name);
		this.extraRoutes();
		this.setConfig();
	},


	setConfig: function() {
		this.config = {};
		this.config.urlApiModule = 'http://beta.magicmirror.builders/api/module';
		this.config.limit = 20;
	},


	// Override socketNotificationReceived method.
	socketNotificationReceived: function(notification, payload) {
	},


	// create routes for module manager.
	// recive request and send response
	extraRoutes: function() {
		var self = this;
		this.expressApp.get("/module-manager/modules/availables", function(req, res) {
			self.getModulesAvailables(req, res);
		});
	},


	// get modules from API config
	getModulesAvailables: function(req, res) {
		var query = url.parse(req.url, true).query;
		var urlApi = this.config.urlApiModule;
		if (Object.keys(query).length > 0) {
			urlApi += "?" + querystring.stringify(query);
		}
		request({uri: urlApi, encoding: null, headers: this.getHeaderRequest()}).pipe(res);
	},


	getHeaderRequest: function() {
		nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
		headers =  {"User-Agent": "Mozilla/5.0 (Node.js "+ nodeVersion + ") MagicMirror/"  + global.version +  " (https://github.com/MichMich/MagicMirror/)"}
		return headers;
	}

});<commit_msg>add clone function<commit_after>/* Magic Mirror
 * Node Helper: MagicMirror-Moduler-Manager
 *
 * By <NAME> https://rodrigoramirez.com
 * MIT Licensed.
 */

var NodeHelper = require("node_helper");
var request = require("request");
var url = require("url");
var querystring = require('querystring');
var simpleGit = require("simple-git");
var path = require("path");


module.exports = NodeHelper.create({
	// Override start method.
	start: function() {
		var self = this;

		console.log("Starting node helper for: " + this.name);
		this.extraRoutes();
		this.setConfig();
	},


	setConfig: function() {
		this.config = {};
		this.config.urlApiModule = 'http://beta.magicmirror.builders/api/module';
		this.config.limit = 20;
	},


	// Override socketNotificationReceived method.
	socketNotificationReceived: function(notification, payload) {
	},


	// create routes for module manager.
	// recive request and send response
	extraRoutes: function() {
		var self = this;
		this.expressApp.get("/module-manager/modules/availables", function(req, res) {
			self.getModulesAvailables(req, res);
		});
	},


	// get modules from API config
	getModulesAvailables: function(req, res) {
		var query = url.parse(req.url, true).query;
		var urlApi = this.config.urlApiModule;
		if (Object.keys(query).length > 0) {
			urlApi += "?" + querystring.stringify(query);
		}
		request({uri: urlApi, encoding: null, headers: this.getHeaderRequest()}).pipe(res);
	},


	getHeaderRequest: function() {
		nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
		headers =  {"User-Agent": "Mozilla/5.0 (Node.js "+ nodeVersion + ") MagicMirror/"  + global.version +  " (https://github.com/MichMich/MagicMirror/)"}
		return headers;
	},


	// clone repository pass by params into Third modules directory
	cloneRepository: function(url, name) {
		path_to_clone = path.resolve(global.root_path + "/modules/third/" + name);
		var git = simpleGit();
		git.clone(url, path_to_clone);
	}

});
{'fraction_non_alphanumeric': 0.16114790286975716, 'fraction_numerical': 0.0033112582781456954, 'mean_word_length': 4.141843971631205, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 4, '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': '1402986', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1156, 'n_words': 255}