type: 'confirm', name: 'value', message: `Do you want to install ${chalk.white.bgGreen( '🎈 WordPressify', )} in the current directory?\n${chalk.red(process.cwd())}`,
commander.help((help)=>{ return boxen(`\n${chalk.bold.whiteBright('Cogear.JS – modern static websites generator.')}\n\nv${cogear.package.version}\n\n(help)\n\n${chalk.bold.whiteBright('https://cogearjs.org')}`, { padding: {top: 1, bottom: 1,left: 8,right: 8}, margin: 0, dimBorder: true, align: 'center', borderStyle: 'single-double', borderColor: 'magenta' }) + ` ${chalk.white('Runs in development mode by default (without [command]).')} ${help} More info: ${chalk.bold.whiteBright('https://cogearjs.org')} `; });
it('displays a multi-line help message with exta line when called with 5 args', function (done) { const stdout = streamTestUtils.getWritableStream(function (output) { expect(output, 'output exists').to.be.ok; expect(hasAnsi(output), 'output has color').to.be.true; expect(output, 'output value').to.include(chalk.white(`\nmy message: \n\n ${chalk.yellow('testing')}\n`)); done(); }); stdout.on('error', done); const UI = require(modulePath); const ui = new UI({stdout: stdout}); ui.log('my message', 'testing', 'white', 'cmd', true); });
welcome () { this.log('') this.log(chalk.cyan(' ****************************************************')) this.log(chalk.cyan(' Welcome to'), chalk.white.bold(' Pixel2HTML Generator ')) this.log(chalk.white(' A Yeoman generator for scaffolding web projects')) this.log(chalk.cyan(' Version'), chalk.white.bold(` ${pkg.version}`)) this.log(chalk.cyan(' ****************************************************')) }
/** * Attempt to reconnect to Grapevine */ reconnect() { if (this.active === false) { return; } this.reconnectTimer = setTimeout(() => { if (this.reconnectTimer) { clearTimeout(this.reconnectTimer); } Logger.verbose(chalk.white.bold('Reconnecting to Grapevine...')); this.connect(); }, 5 * 1000); }
execute() { clear(); console.log( chalk.white( figlet.textSync('Test', { horizontalLayout: 'full' }) ) ); }
info(...params) { params.unshift('[INFO]') this._logImpl.call(this, chalk.white.bgBlue.apply(this, params)) }
// eslint-disable-line no-console const utilLogger = (name, msg) => { const { message, error } = msg; let prefix = chalk.white(dateFormat(new Date(), '[HH:MM:ss]')); if (name) { prefix += ` (${name})`; } // TODO: maybe do some fancy indentation logic here...? check first char for '>' or '-' and indent if not found? // be aware that chalk is adding colors tho and they show up if you debug the `message` object console.log(prefix, message); // eslint-disable-line no-console if (error) { debug(error); } }
/** * @description Add a line number to the text * @param {String} str Source string * @return {String} String with line number */ function addLineNumber(str) { function prefixInteger(num, n) { let lineNumber = (Array(n).join(0) + num).slice(-n); return chalk.white(lineNumber + ' | '); } let strArr = str.split("\n"); let newStr = ""; let zeroLen = strArr.length.toString().split('').length; strArr.forEach((s, index) => { newStr += `${prefixInteger(index, zeroLen)}${s} \n`; }); return newStr; }
function showDetails(ui, results, error) { ui.log(chalk.bold.red(`\n${error ? 'Errors' : 'Warnings'}`)); each(results, (list, fileName) => { /* istanbul ignore if */ if (!list.length) { return; } const details = list.map((result) => { if (error && result.fatal) { return `${SPACES}- ${chalk.bold.red('Fatal error:')} ${result.rule.replace(TAGS_REGEX, '')}`; } return `${SPACES}- ${result.rule.replace(TAGS_REGEX, '')}`; }).join('\n'); ui.log(`${chalk.bold.white(`${SPACES}File:`)} ${chalk.white(fileName)}\n${details}\n`); }); }
readConfigFile () { return fs.readJson('./.project.conf') .then(config => { this.options.projectName = config.projectName this.options.qtyScreens = config.qtyScreens this.options.markupLanguage = config.markupLanguage this.options.frontEndFramework = config.frontEndFramework this.options.jQuery = config.jQuery }) .catch(err => { let okayError = err.toString() !== "Error: ENOENT: no such file or directory, open './.project.conf'" if (okayError) { this.log(chalk.cyan('There was an issue:') + '\n') this.log(chalk.white(err) + '\n') } }) }
type: 'confirm', name: 'value', message: `Do you want to install ${chalk.white.bgGreen( '🎈 WordPressify', )} in the current directory?\n${chalk.red(process.cwd())}`,
welcome () { this.log('') this.log(chalk.cyan(' ****************************************************')) this.log(chalk.cyan(' Welcome to'), chalk.white.bold(' Pixel2HTML Generator ')) this.log(chalk.white(' A Yeoman generator for scaffolding web projects')) this.log(chalk.cyan(' Version'), chalk.white.bold(` ${pkg.version}`)) this.log(chalk.cyan(' ****************************************************')) }
/** * Attempt to reconnect to Grapevine */ reconnect() { if (this.active === false) { return; } this.reconnectTimer = setTimeout(() => { if (this.reconnectTimer) { clearTimeout(this.reconnectTimer); } Logger.verbose(chalk.white.bold('Reconnecting to Grapevine...')); this.connect(); }, 5 * 1000); }