st.once('testserver', server => { if (cli.flags.verbose) { stats.data = { server: map(server) }; } setState('download'); const ping = Math.round(server.bestPing); stats.ping = cli.flags.json ? ping : chalk.cyan(ping + chalk.dim(' ms')); });
st.once('uploadspeed', speed => { setState(''); speed *= multiplier; const upload = roundTo(speed, speed >= 10 && !cli.flags.json ? 0 : 1); stats.upload = cli.flags.json ? upload : chalk.cyan(upload + ' ' + chalk.dim(unit)); });
const downloadColor = string => ((data.isDone || data.uploadSpeed) ? chalk.green(string) : chalk.cyan(string))
const displayError = async (text, options = {}) => { console.error(''); console.error(chalk.cyan('Cube.js Error ---------------------------------------')); console.error(''); if (Array.isArray(text)) { text.forEach((str) => console.error(str)); } else { console.error(text); } console.error(''); console.error(chalk.yellow('Need some help? -------------------------------------')); await event('Error', { error: Array.isArray(text) ? text.join('\n') : text.toString(), ...options }); console.error(''); console.error(`${chalk.yellow(' Ask this question in Cube.js Slack:')} https://slack.cube.dev`); console.error(`${chalk.yellow(' Post an issue:')} https://github.com/cube-js/cube.js/issues`); console.error(''); process.exit(1); }
function render() { if (cli.flags.json) { console.log(JSON.stringify(stats)); return; } let output = ` Ping ${getSpinnerFromState('ping')}${stats.ping} Download ${getSpinnerFromState('download')}${stats.download} Upload ${getSpinnerFromState('upload')}${stats.upload}`; if (cli.flags.verbose) { output += [ '', ' Server ' + (stats.data === undefined ? '' : chalk.cyan(stats.data.server.host)), ' Location ' + (stats.data === undefined ? '' : chalk.cyan(stats.data.server.location + chalk.dim(' (' + stats.data.server.country + ')'))), ' Distance ' + (stats.data === undefined ? '' : chalk.cyan(roundTo(stats.data.server.distance, 1) + chalk.dim(' km'))) ].join('\n'); } logUpdate(output); }
const token = async (options = {}) => { event('Generate Token'); const CubejsServer = await requireFromPackage('@cubejs-backend/server'); const { expiry = defaultExpiry, secret = CubejsServer.apiSecret() } = options; if (!secret) throw new Error('No app secret found').message; const extraOptions = {}; if (expiry !== '0') extraOptions.expiresIn = expiry; const payload = parsePayload(options.payload); console.log('Generating Cube.js JWT token'); console.log(''); console.log(`${chalk.yellow('-----------------------------------------------------------------------------------------')}`); console.log(` ${chalk.yellow('Use these manually generated tokens in production with caution.')}`); console.log(` ${chalk.yellow(`Please refer to ${chalk.cyan('https://cube.dev/docs/security')} for production security best practices.`)}`); console.log(`${chalk.yellow('-----------------------------------------------------------------------------------------')}`); console.log(''); console.log(`Expires in: ${chalk.green(expiry)}`); console.log(`Payload: ${chalk.green(JSON.stringify(payload))}`); console.log(''); const signedToken = jwt.sign(payload, secret, extraOptions); console.log(`Token: ${chalk.green(signedToken)}`); await event('Generate Token Success'); return signedToken; }
const uploadColor = string => (data.isDone ? chalk.green(string) : chalk.cyan(string))
str = chalk.cyan(chunk.toString('utf-8').trim()) } else { str = chalk.green(chunk.toString('utf-8').trim())
clearConsole(); console.log(chalk.cyan('Starting the development server...\n')); openBrowser(urls.localUrlForBrowser); });
console.log(warnings.join('\n\n')); console.log(`\nSearch for the ${chalk.underline(chalk.yellow('keywords'))} to learn more about each warning.`); console.log(`To ignore, add ${chalk.cyan('// eslint-disable-next-line')} to the line before.\n`); } else { console.log(chalk.green('Compiled successfully.\n'));
console.log(chalk.cyan('\nCleaning stale files...')); shell.exec('yarn clean'); console.log(chalk.cyan('\nInstalling dependencies...')); shell.exec('yarn'); console.log(chalk.cyan('\nCompiling react code...')); shell.exec('yarn react:build'); console.log(chalk.cyan('\nCompiling electron code...')); shell.exec('yarn electron:build'); console.log(chalk.cyan('\nBundling your app...')); shell.exec('yarn env-cmd -f ./.env.local electron-builder --win --mac --linux --publish=always'); console.log(chalk.cyan('\nTagging the release...')); shell.exec(`git tag v${newVersion}`); shell.exec(`git push origin v${newVersion}`);
init() { if (this._getCommitsPath().exist === false) { this._createFile(this._getCommitsPath().path, []); console.log( `${chalk.cyan('Your life has been initialized successfully!')}` ); return; } else { return this._errorMessage( 'Your life had been initialized. Start commit now!' ); } }
console.error( chalk.red( `We cannot create a project called ${chalk.green( projectName )} because a dependency with the same name exists.\n` + `Due to the way npm works, the following names are not allowed:\n\n` ) + chalk.cyan(dependencies.map(depName => ` ${depName}`).join('\n')) + chalk.red('\n\nPlease choose a different project name.') );
st.once('downloadspeed', speed => { setState('upload'); speed *= multiplier; const download = roundTo(speed, speed >= 10 && !cli.flags.json ? 0 : 1); stats.download = cli.flags.json ? download : chalk.cyan(download + ' ' + chalk.dim(unit)); });
console.error( chalk.red( `We cannot create a project called ${chalk.green( projectName )} because a dependency with the same name exists.\n` + `Due to the way npm works, the following names are not allowed:\n\n` ) + chalk.cyan(dependencies.map(depName => ` ${depName}`).join('\n')) + chalk.red('\n\nPlease choose a different project name.') );