cloudux-starter-kit
Version:
Starter kit for UX developers in MediaCentral - NPM package
26 lines • 1.34 kB
JavaScript
const functions = require('./functions');
const CURR_DIR = process.cwd();
const logger = require.main.require('log4js').getLogger(`cloudux-starter-kit ${__filename}`);
module.exports = function (options) {
let path = CURR_DIR;
logger.debug('------ Creating new project ------');
logger.trace('Passed options', options);
if (options.projectPath !== undefined) path = options.projectPath;
try {
if (!options.projectName.match(/^([a-z0-9\-]{1,253})$/gm)) throw new Error("A project name should be up to maximum length of 253 characters and consist of lower case alphanumeric characters and -");
} catch (e) {
logger.error(e.message);
return e;
}
const projectName = options.projectName;
const projectChoice = options.projectChoice;
const projectDescription = options.projectDescription;
const projectHostIp = options.projectHostIp;
const projectHostPort = options.projectPort;
const configPath = `${path}/${projectName}/src/project.config.json`;
const srcPackagePath = `${path}/${projectName}/src/package.json`;
functions.copyProjectTemplate(projectName, projectChoice, path);
functions.writeUserConfig(projectName, projectDescription, projectHostIp, projectHostPort, configPath, srcPackagePath);
logger.debug('Created project ', projectName, 'in path', path);
return console.log(`done`);
};