Browse Source

Prettified everything

master
Leo Lamprecht 8 years ago
parent
commit
b2a4c7e7f5
  1. 39
      bin/now-alias.js
  2. 10
      bin/now-billing.js
  3. 10
      bin/now-deploy.js
  4. 39
      bin/now-domains.js
  5. 5
      lib/alias.js
  6. 5
      lib/get-files.js
  7. 11
      lib/utils/input/prompt-bool.js

39
bin/now-alias.js

@ -189,25 +189,26 @@ async function run({ token, config: { currentTeam, user } }) {
const header = [
['', 'pathname', 'method', 'dest'].map(s => chalk.dim(s))
]
const text = list.length === 0
? null
: table(
header.concat(
item.rules.map(rule => {
return [
'',
rule.pathname ? rule.pathname : '',
rule.method ? rule.method : '*',
rule.dest
]
})
),
{
align: ['l', 'l', 'l', 'l'],
hsep: ' '.repeat(2),
stringLength: strlen
}
)
const text =
list.length === 0
? null
: table(
header.concat(
item.rules.map(rule => {
return [
'',
rule.pathname ? rule.pathname : '',
rule.method ? rule.method : '*',
rule.dest
]
})
),
{
align: ['l', 'l', 'l', 'l'],
hsep: ' '.repeat(2),
stringLength: strlen
}
)
console.log(text)
}

10
bin/now-billing.js

@ -123,9 +123,8 @@ if (argv.help || !subcommand) {
// Builds a `choices` object that can be passesd to inquirer.prompt()
function buildInquirerChoices(cards) {
return cards.cards.map(card => {
const _default = card.id === cards.defaultCardId
? ' ' + chalk.bold('(default)')
: ''
const _default =
card.id === cards.defaultCardId ? ' ' + chalk.bold('(default)') : ''
const id = `${chalk.cyan(`ID: ${card.id}`)}${_default}`
const number = `${chalk.gray('#### ').repeat(3)}${card.last4}`
const str = [
@ -159,9 +158,8 @@ async function run({ token, config: { currentTeam, user } }) {
}
const text = cards.cards
.map(card => {
const _default = card.id === cards.defaultCardId
? ' ' + chalk.bold('(default)')
: ''
const _default =
card.id === cards.defaultCardId ? ' ' + chalk.bold('(default)') : ''
const id = `${chalk.gray('-')} ${chalk.cyan(
`ID: ${card.id}`
)}${_default}`

10
bin/now-deploy.js

@ -200,9 +200,8 @@ const wantsPublic = argv.public
const apiUrl = argv.url || 'https://api.zeit.co'
const isTTY = process.stdout.isTTY
const quiet = !isTTY
const autoAliases = typeof argv.alias === 'undefined'
? false
: flatten([argv.alias])
const autoAliases =
typeof argv.alias === 'undefined' ? false : flatten([argv.alias])
if (argv.config) {
cfg.setConfigFile(argv.config)
@ -449,9 +448,8 @@ async function sync({ token, config: { currentTeam, user } }) {
}
if (dotenvOption) {
const dotenvFileName = typeof dotenvOption === 'string'
? dotenvOption
: '.env'
const dotenvFileName =
typeof dotenvOption === 'string' ? dotenvOption : '.env'
if (!fs.existsSync(dotenvFileName)) {
error(`--dotenv flag is set but ${dotenvFileName} file is missing`)

39
bin/now-domains.js

@ -197,25 +197,26 @@ async function run({ token, config: { currentTeam, user } }) {
const header = [
['', 'domain', 'dns', 'verified', 'created'].map(s => chalk.dim(s))
]
const out = domains.length === 0
? null
: table(
header.concat(
domains.map(domain => {
const ns = domain.isExternal ? 'external' : 'zeit.world'
const url = chalk.bold(domain.name)
const time = chalk.gray(
ms(current - new Date(domain.created)) + ' ago'
)
return ['', url, ns, domain.verified, time]
})
),
{
align: ['l', 'l', 'l', 'l', 'l'],
hsep: ' '.repeat(2),
stringLength: strlen
}
)
const out =
domains.length === 0
? null
: table(
header.concat(
domains.map(domain => {
const ns = domain.isExternal ? 'external' : 'zeit.world'
const url = chalk.bold(domain.name)
const time = chalk.gray(
ms(current - new Date(domain.created)) + ' ago'
)
return ['', url, ns, domain.verified, time]
})
),
{
align: ['l', 'l', 'l', 'l', 'l'],
hsep: ' '.repeat(2),
stringLength: strlen
}
)
const elapsed_ = ms(new Date() - start_)
console.log(

5
lib/alias.js

@ -671,9 +671,8 @@ module.exports = class Alias extends Now {
const _domain = publicSuffixList.parse(alias).domain
const _domainInfo = await this.getDomain(_domain)
const domainInfo = _domainInfo && !_domainInfo.error
? _domainInfo
: undefined
const domainInfo =
_domainInfo && !_domainInfo.error ? _domainInfo : undefined
const { domain, nameservers } = domainInfo
? { domain: _domain }
: await this.getNameservers(alias)

5
lib/get-files.js

@ -176,9 +176,8 @@ async function npm(
// Compile list of ignored patterns and files
const npmIgnore = await maybeRead(resolve(path, '.npmignore'), null)
const gitIgnore = npmIgnore === null
? await maybeRead(resolve(path, '.gitignore'))
: null
const gitIgnore =
npmIgnore === null ? await maybeRead(resolve(path, '.gitignore')) : null
const filter = ignore()
.add(

11
lib/utils/input/prompt-bool.js

@ -46,11 +46,12 @@ module.exports = (
}
}
const defaultText = defaultValue === null
? `[${yesChar}|${noChar}]`
: defaultValue
? `[${chalk.bold(yesChar.toUpperCase())}|${noChar}]`
: `[${yesChar}|${chalk.bold(noChar.toUpperCase())}]`
const defaultText =
defaultValue === null
? `[${yesChar}|${noChar}]`
: defaultValue
? `[${chalk.bold(yesChar.toUpperCase())}|${noChar}]`
: `[${yesChar}|${chalk.bold(noChar.toUpperCase())}]`
stdout.write(`${chalk.gray('>')} ${label} ${chalk.gray(defaultText)} `)
stdin.on('data', onData)
})

Loading…
Cancel
Save