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

if (process.argv.length < 3)
{
	console.log("usage: get-latest-activator.js service_name [debug_port]");
	console.log("options:");
	console.log("  service_name: Name of the service for which you want activator parameters.");
	console.log("  [debug_port]: Port number on which we want debugging to be enabled.")
	console.log("                By default debugging is disabled.");
	return;
}

function getServiceName(services)
{
	var name = "CATO_FRONTEND";

	if (process.argv.length >= 3)
	{
		var inputName = process.argv[2];
		if (services.hasOwnProperty(inputName))
		{
			console.log("Using service name: ", inputName);
			name = inputName;
		}
		else
		{
			console.log("Invalid service name: ", inputName, ". Using default: ", name);
		}
	}
	else
	{
		console.log("No service name specified. Using default: ", name);
	}

	return name;
}

var clipboard = require("copy-paste");
var fs = require("fs");
var path = require("path");

var servicesPath = path.join(process.env.WORKSPACE, "service-manager-config/services.json");
console.log("\n" + servicesPath);

var services = JSON.parse(fs.readFileSync(servicesPath, "utf8"));
var command = "activator";

var serviceName = getServiceName(services);
var catoConfig = services[serviceName].binary.cmd;

for (var index = 0; index < catoConfig.length; index++)
{
	var param = catoConfig[index];
	if (param.indexOf("-Dapplication") == -1 && param.indexOf("-Dfeature") == -1)
		continue;

	command += " " + param;
}

if (process.argv.length >= 4)
{
	command += " -jvm-debug " + process.argv[3];
}

console.log(command);
clipboard.copy(command, function ()
{
	console.log("Script copied to clipboard.\n");
});<commit_msg>SM-HELPER to parse cwd name and use it as a service name.<commit_after>#!/usr/bin/env node

if (["-h", "--help", "?"].indexOf(process.argv[2]) !== -1)
{
	console.log("usage: sm-helper [service_name] [debug_port]");
	console.log("options:");
	console.log("  [service_name]: Name of the service for which you want activator parameters.");
    console.log("                  By default it will take name of current directory.");
	console.log("  [debug_port]: Port number on which we want debugging to be enabled.");
	console.log("                By default debugging is disabled.");
	return;
}

function getServiceName(services)
{
	var name = null;
    var expectedServiceName = null;

	if (process.argv.length >= 3)
	{
		expectedServiceName = process.argv[2];
	}
	else
	{
        var cwdPath = __dirname.split(path.sep);
        expectedServiceName = cwdPath[cwdPath.length - 1].toUpperCase().replace(/\-/g, "_");
	}

    if (services.hasOwnProperty(expectedServiceName))
    {
        console.log("Using service name: ", expectedServiceName);
        name = expectedServiceName;
    }
    else
    {
        console.log("Invalid service name: ", expectedServiceName);
    }

	return name;
}

var clipboard = require("copy-paste");
var fs = require("fs");
var path = require("path");

var servicesPath = path.join(process.env.WORKSPACE, "service-manager-config/services.json");
console.log("\n" + servicesPath);

var services = JSON.parse(fs.readFileSync(servicesPath, "utf8"));

var serviceName = getServiceName(services);
if (serviceName !== null)
{
    var command = "activator";
    var catoConfig = services[serviceName].binary.cmd;

    for (var index = 0; index < catoConfig.length; index++)
    {
        var param = catoConfig[index];
        if (param.indexOf("-Dapplication") == -1 && param.indexOf("-Dfeature") == -1)
            continue;

        command += " " + param;
    }

    if (process.argv.length >= 4)
    {
        command += " -jvm-debug " + process.argv[3];
    }

    console.log(command);
    clipboard.copy(command, function ()
    {
        console.log("Script copied to clipboard.\n");
    });
}
{'fraction_non_alphanumeric': 0.15682174594877157, 'fraction_numerical': 0.005227391531625719, 'mean_word_length': 3.5397390272835114, 'pattern_counts': {'":': 0, '<': 6, '<?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': '1125641', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1204, 'n_words': 298}