How to use prettyjson - 10 common examples

To help you get started, we’ve selected a few prettyjson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SpencerCDixon / redux-cli / src / sub-commands / config.js View on Github external
run() {
    const finalConfig = Object.assign({}, this.settings.settings);
    delete finalConfig.configs;
    delete finalConfig.allConfigs;
    delete finalConfig['_'];
    this.ui.write(this.cliLogo() + '\n');
    this.ui.writeInfo('Config Files');
    console.log(prettyjson.render(this.settings.settings.configs, {}, 8));
    // this.settings.settings.configs.forEach(configFile => {this.ui.writeInfo(`  * ${configFile}`)})
    this.ui.writeInfo('Config Data');
    console.log(prettyjson.render(finalConfig, {}, 10));
    this.ui.writeInfo('Blueprint Paths');
    console.log(prettyjson.render(this.settings.blueprints.searchPaths, {}, 8));
    this.ui.writeInfo('Blueprints');
    console.log(prettyjson.render(this.settings.blueprints.allNames(), {}, 8));
  }
}
github aperpen / clash-royale-client / logic / commands / help.js View on Github external
module.exports.run = (session, args) => {
  let help = ''
  if (args[0]) {
    let command = commands.match(args[0])
    if (command) {
      if (command.help) {
        command.help.legend = {
          '': 'Required param',
          '[param]': 'Optional param'
        }
        command.help.alias = command.config.alias
        help += prettyjson.render(command.help)
      } else {
        help = 'Command has not help'
      }
    } else {
      help = 'Command not found'
    }
  } else {
    help = 'Avaiable commands:\n' + commands.list.map(cmd => cmd.config.name)
    help += '\n\nFor custom command help type: help command\nExample: help top'
  }
  console.log(help)
}
github cloudrig / CloudRIG / cli / index.js View on Github external
cloudrig.validateRequiredConfig(config, function(err) {
			if (err) {
				console.log("Invalid AWS credentials. Please check your configuration");
				configMenu(validateAndSetConfig.bind(null, cb));
			} else {
				console.log("Setting config");
				var displayConfig = Object.assign({}, config);
				displayConfig.ParsecServerId = "(set)";

				console.log(prettyjson.render(displayConfig, null, 4));
				cloudrig.setConfig(config);

				cb();
			}
		});
	}
github angeloashmore / gatsby-source-shopify / src / lib.js View on Github external
export const printGraphQLError = e => {
  const prettyjsonOptions = { keysColor: 'red', dashColor: 'red' }

  if (e.response && e.response.errors)
    console.error(prettyjson.render(e.response.errors, prettyjsonOptions))

  if (e.request) console.error(prettyjson.render(e.request, prettyjsonOptions))
}
github 3scale / 3scale-cli / lib / 3scale-cli.js View on Github external
exports.print = print = function(options) {
     if (options && options.message) {
       var data ="";
       var msg = "";
        if(typeof options.message === "string"){
          msg = options.message.toString();
        }

        if(options.data){
          data = prettyjson.render(options.data)
        }

        if(options.table){
          var items = [];
          if(_.isArray(options.table)){ //array of objects
            _.each(options.table, function(item){ //flatten to an array without links
              var exclude = ["links"]
              if(_.isArray(options.excludes)){
                exclude.push(options.excludes)
              }

              items.push(_.omit(item[options.key],exclude))
            })
          }else{
            var exclude = ["links"]
            if(_.isArray(options.excludes)){
github RobinBuschmann / sequelize-typescript / example / app.ts View on Github external
.then(posts => {
      console.log('--------------- POST FULL SCOPE ---------------------');
      console.log(prettyjson.renderString(JSON.stringify(posts)));
    })
  )
github jesusprubio / bluebox-ng / bin / lib / utils / logger.js View on Github external
module.exports.json = json => process.stdout.write(`${prettyjson.render(json)}\n`);
github wKovacs64 / pwned / src / commands / search.ts View on Github external
domainFilter: domain,
  truncate,
  raw,
}: SearchHandlerOptions): Promise => {
  if (!raw) {
    spinner.start();
  }

  try {
    const searchData = await search(account, { domain, truncate, userAgent });
    const foundData = !!(searchData.breaches || searchData.pastes);
    if (foundData && raw) {
      logger.log(JSON.stringify(searchData));
    } else if (foundData) {
      spinner.stop();
      logger.log(prettyjson.render(searchData));
    } else if (!foundData && !raw) {
      spinner.succeed('Good news — no pwnage found!');
    }
  } catch (err) {
    if (!raw) {
      spinner.fail(err.message);
    } else {
      logger.error(err.message);
    }
  }
};
github cts / cts-cli / release / dscrape.js View on Github external
var printData = function(data, opts) {
  var formatted = "";
  if (opts.format == "json") {
    formatted = JSON.stringify(data);
  } else if (opts.format == "pretty") {
    formatted = prettyjson.render(data);
  }
  printLine(formatted);
};
github netlify / cli / src / commands / whoami / index.js View on Github external
const data = {
        'Account name': get(personal, 'name'),
        'Account slug': get(personal, 'slug'),
        'Account id': get(personal, 'id'),
        Name: get(personal, 'billing_name'),
        Email: get(personal, 'billing_email')
      }
      const teamsData = {}

      teams.forEach(team => {
        return (teamsData[team.name] = team.roles_allowed.join(' '))
      })

      data.Teams = teamsData

      this.log(prettyjson.render(clean(data)))
    } else {
      this.error(`Not logged in`)
    }
  }
}

prettyjson

Package for formatting JSON data in a coloured YAML-style, perfect for CLI output

MIT
Latest version published 2 years ago

Package Health Score

71 / 100
Full package analysis

Popular prettyjson functions