Browse Source

Update prettier to the latest version 🚀 (#626)

* chore(package): update prettier to version 1.4.1

* Prettified everything

* Fixed linting
master
greenkeeper[bot] 8 years ago
committed by Leo Lamprecht
parent
commit
f1a42eb6ab
  1. 8
      bin/domains/buy.js
  2. 84
      bin/now-alias.js
  3. 15
      bin/now-billing-add.js
  4. 40
      bin/now-billing.js
  5. 70
      bin/now-certs.js
  6. 101
      bin/now-deploy.js
  7. 56
      bin/now-dns.js
  8. 98
      bin/now-domains.js
  9. 22
      bin/now-list.js
  10. 4
      bin/now-logout.js
  11. 24
      bin/now-logs.js
  12. 28
      bin/now-remove.js
  13. 24
      bin/now-scale.js
  14. 54
      bin/now-secrets.js
  15. 12
      bin/now-teams.js
  16. 28
      bin/now-upgrade.js
  17. 8
      bin/now-whoami.js
  18. 8
      bin/now.js
  19. 11
      bin/teams/add.js
  20. 4
      bin/teams/invite.js
  21. 109
      lib/alias.js
  22. 4
      lib/domains.js
  23. 24
      lib/errors.js
  24. 3
      lib/git.js
  25. 24
      lib/index.js
  26. 4
      lib/login.js
  27. 5
      lib/re-alias.js
  28. 17
      lib/scale-info.js
  29. 4
      lib/utils/input/prompt-bool.js
  30. 2
      package.json

8
bin/domains/buy.js

@ -46,7 +46,9 @@ module.exports = async function({ domains, args, currentTeam, user }) {
} }
const periodMsg = `${period}yr${period > 1 ? 's' : ''}` const periodMsg = `${period}yr${period > 1 ? 's' : ''}`
info( info(
`The domain ${nameParam} is ${italic('available')} to buy under ${bold((currentTeam && currentTeam.slug) || user.username || user.email)}! ${elapsed()}` `The domain ${nameParam} is ${italic('available')} to buy under ${bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}! ${elapsed()}`
) )
const confirmation = await promptBool( const confirmation = await promptBool(
`Buy now for ${bold(`$${price}`)} (${periodMsg})?` `Buy now for ${bold(`$${price}`)} (${periodMsg})?`
@ -71,6 +73,8 @@ module.exports = async function({ domains, args, currentTeam, user }) {
success(`Domain purchased and created ${uid(domain.uid)} ${elapsed()}`) success(`Domain purchased and created ${uid(domain.uid)} ${elapsed()}`)
info( info(
`You may now use your domain as an alias to your deployments. Run ${cmd('now alias --help')}` `You may now use your domain as an alias to your deployments. Run ${cmd(
'now alias --help'
)}`
) )
} }

84
bin/now-alias.js

@ -48,10 +48,16 @@ const help = () => {
${chalk.dim('Options:')} ${chalk.dim('Options:')}
-h, --help Output usage information -h, --help Output usage information
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
-r ${chalk.bold.underline('RULES_FILE')}, --rules=${chalk.bold.underline('RULES_FILE')} Rules file 'FILE'
)} Config file
-r ${chalk.bold.underline('RULES_FILE')}, --rules=${chalk.bold.underline(
'RULES_FILE'
)} Rules file
-d, --debug Debug mode [off] -d, --debug Debug mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} Login token -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}
@ -61,7 +67,11 @@ const help = () => {
${chalk.gray('–')} Adds a new alias to ${chalk.underline('my-api.now.sh')}: ${chalk.gray('–')} Adds a new alias to ${chalk.underline('my-api.now.sh')}:
${chalk.cyan(`$ now alias set ${chalk.underline('api-ownv3nc9f8.now.sh')} ${chalk.underline('my-api.now.sh')}`)} ${chalk.cyan(
`$ now alias set ${chalk.underline(
'api-ownv3nc9f8.now.sh'
)} ${chalk.underline('my-api.now.sh')}`
)}
The ${chalk.dim('`.now.sh`')} suffix can be ommited: The ${chalk.dim('`.now.sh`')} suffix can be ommited:
@ -73,18 +83,34 @@ const help = () => {
Custom domains work as alias targets: Custom domains work as alias targets:
${chalk.cyan(`$ now alias set ${chalk.underline('api-ownv3nc9f8.now.sh')} ${chalk.underline('my-api.com')}`)} ${chalk.cyan(
`$ now alias set ${chalk.underline(
${chalk.dim('–')} The subcommand ${chalk.dim('`set`')} is the default and can be skipped. 'api-ownv3nc9f8.now.sh'
${chalk.dim('–')} ${chalk.dim('`http(s)://`')} in the URLs is unneeded / ignored. )} ${chalk.underline('my-api.com')}`
)}
${chalk.gray('–')} Add and modify path based aliases for ${chalk.underline('zeit.ninja')}:
${chalk.dim('–')} The subcommand ${chalk.dim(
${chalk.cyan(`$ now alias ${chalk.underline('zeit.ninja')} -r ${chalk.underline('rules.json')}`)} '`set`'
)} is the default and can be skipped.
${chalk.dim('–')} ${chalk.dim(
'`http(s)://`'
)} in the URLs is unneeded / ignored.
${chalk.gray('–')} Add and modify path based aliases for ${chalk.underline(
'zeit.ninja'
)}:
${chalk.cyan(
`$ now alias ${chalk.underline('zeit.ninja')} -r ${chalk.underline(
'rules.json'
)}`
)}
Export effective routing rules: Export effective routing rules:
${chalk.cyan(`$ now alias ls aliasId --json > ${chalk.underline('rules.json')}`)} ${chalk.cyan(
`$ now alias ls aliasId --json > ${chalk.underline('rules.json')}`
)}
${chalk.cyan(`$ now alias ls zeit.ninja`)} ${chalk.cyan(`$ now alias ls zeit.ninja`)}
@ -207,7 +233,11 @@ async function run({ token, config: { currentTeam, user } }) {
}, 0) + 8 }, 0) + 8
const elapsed_ = ms(new Date() - start_) const elapsed_ = ms(new Date() - start_)
console.log( console.log(
`> ${aliases.length} alias${aliases.length === 1 ? '' : 'es'} found ${chalk.gray(`[${elapsed_}]`)} under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)}` `> ${aliases.length} alias${aliases.length === 1
? ''
: 'es'} found ${chalk.gray(`[${elapsed_}]`)} under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}`
) )
console.log() console.log()
@ -254,7 +284,9 @@ async function run({ token, config: { currentTeam, user } }) {
} }
} else if (_alias.rules) { } else if (_alias.rules) {
_sourceUrl = chalk.gray( _sourceUrl = chalk.gray(
`[${_alias.rules.length} custom rule${_alias.rules.length > 1 ? 's' : ''}]` `[${_alias.rules.length} custom rule${_alias.rules.length > 1
? 's'
: ''}]`
) )
if (supportsColor) { if (supportsColor) {
urlSpec += underlineWidth urlSpec += underlineWidth
@ -286,7 +318,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (args.length !== 1) { if (args.length !== 1) {
error( error(
`Invalid number of arguments. Usage: ${chalk.cyan('`now alias rm <id>`')}` `Invalid number of arguments. Usage: ${chalk.cyan(
'`now alias rm <id>`'
)}`
) )
return exit(1) return exit(1)
} }
@ -296,7 +330,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (!_alias) { if (!_alias) {
const err = new Error( const err = new Error(
`Alias not found by "${_target}" under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)}. Run ${chalk.dim('`now alias ls`')} to see your aliases.` `Alias not found by "${_target}" under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}. Run ${chalk.dim('`now alias ls`')} to see your aliases.`
) )
err.userError = true err.userError = true
throw err throw err
@ -313,7 +349,9 @@ async function run({ token, config: { currentTeam, user } }) {
await alias.rm(_alias) await alias.rm(_alias)
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`${chalk.cyan('> Success!')} Alias ${chalk.bold(_alias.uid)} removed [${elapsed}]` `${chalk.cyan('> Success!')} Alias ${chalk.bold(
_alias.uid
)} removed [${elapsed}]`
) )
} catch (err) { } catch (err) {
error(err) error(err)
@ -330,7 +368,9 @@ async function run({ token, config: { currentTeam, user } }) {
} }
if (args.length !== 2) { if (args.length !== 2) {
error( error(
`Invalid number of arguments. Usage: ${chalk.cyan('`now alias set <id> <domain>`')}` `Invalid number of arguments. Usage: ${chalk.cyan(
'`now alias set <id> <domain>`'
)}`
) )
return exit(1) return exit(1)
} }
@ -475,7 +515,11 @@ async function updatePathAlias(alias, aliasName, rules, domains) {
throw err throw err
} else { } else {
console.log( console.log(
`${chalk.cyan('> Success!')} ${res.ruleCount} rules configured for ${chalk.underline(res.alias)} [${elapsed}]` `${chalk.cyan(
'> Success!'
)} ${res.ruleCount} rules configured for ${chalk.underline(
res.alias
)} [${elapsed}]`
) )
} }
} }

15
bin/now-billing-add.js

@ -22,7 +22,11 @@ function expDateMiddleware(data) {
module.exports = function({ creditCards, currentTeam, user }) { module.exports = function({ creditCards, currentTeam, user }) {
const state = { const state = {
error: undefined, error: undefined,
cardGroupLabel: `> ${chalk.bold(`Enter your card details for ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)}`)}`, cardGroupLabel: `> ${chalk.bold(
`Enter your card details for ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}`
)}`,
name: { name: {
label: rightPad('Full Name', 12), label: rightPad('Full Name', 12),
@ -195,13 +199,18 @@ module.exports = function({ creditCards, currentTeam, user }) {
}) })
stopSpinner() stopSpinner()
success( success(
`${state.cardNumber.brand} ending in ${res.last4} was added to ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)}` `${state.cardNumber
.brand} ending in ${res.last4} was added to ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}`
) )
} catch (err) { } catch (err) {
stopSpinner() stopSpinner()
const linesToClear = state.error ? 13 : 12 const linesToClear = state.error ? 13 : 12
process.stdout.write(ansiEscapes.eraseLines(linesToClear)) process.stdout.write(ansiEscapes.eraseLines(linesToClear))
state.error = `${chalk.red('> Error!')} ${err.message} Please make sure the info is correct` state.error = `${chalk.red(
'> Error!'
)} ${err.message} Please make sure the info is correct`
await render() await render()
} }
} }

40
bin/now-billing.js

@ -40,9 +40,13 @@ const help = () => {
${chalk.dim('Options:')} ${chalk.dim('Options:')}
-h, --help Output usage information -h, --help Output usage information
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} Config file
-d, --debug Debug mode [off] -d, --debug Debug mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} Login token -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}
@ -153,7 +157,9 @@ async function run({ token, config: { currentTeam, user } }) {
const _default = card.id === cards.defaultCardId const _default = card.id === cards.defaultCardId
? ' ' + chalk.bold('(default)') ? ' ' + chalk.bold('(default)')
: '' : ''
const id = `${chalk.gray('-')} ${chalk.cyan(`ID: ${card.id}`)}${_default}` const id = `${chalk.gray('-')} ${chalk.cyan(
`ID: ${card.id}`
)}${_default}`
const number = `${chalk.gray('#### ').repeat(3)}${card.last4}` const number = `${chalk.gray('#### ').repeat(3)}${card.last4}`
let address = card.address_line1 let address = card.address_line1
@ -184,7 +190,11 @@ async function run({ token, config: { currentTeam, user } }) {
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`> ${cards.cards.length} card${cards.cards.length === 1 ? '' : 's'} found under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)} ${chalk.gray(`[${elapsed}]`)}` `> ${cards.cards.length} card${cards.cards.length === 1
? ''
: 's'} found under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)} ${chalk.gray(`[${elapsed}]`)}`
) )
if (text) { if (text) {
console.log(`\n${text}\n`) console.log(`\n${text}\n`)
@ -218,7 +228,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (cardId === undefined) { if (cardId === undefined) {
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
const message = `Selecting a new default payment card for ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)} ${chalk.gray(`[${elapsed}]`)}` const message = `Selecting a new default payment card for ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)} ${chalk.gray(`[${elapsed}]`)}`
const choices = buildInquirerChoices(cards) const choices = buildInquirerChoices(cards)
cardId = await listInput({ cardId = await listInput({
@ -246,7 +258,9 @@ async function run({ token, config: { currentTeam, user } }) {
const card = cards.cards.find(card => card.id === cardId) const card = cards.cards.find(card => card.id === cardId)
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
success( success(
`${card.brand} ending in ${card.last4} is now the default ${chalk.gray(`[${elapsed}]`)}` `${card.brand} ending in ${card.last4} is now the default ${chalk.gray(
`[${elapsed}]`
)}`
) )
} else { } else {
console.log('No changes made') console.log('No changes made')
@ -273,7 +287,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (cards.cards.length === 0) { if (cards.cards.length === 0) {
error( error(
`You have no credit cards to choose from to delete under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)}` `You have no credit cards to choose from to delete under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}`
) )
return exit(0) return exit(0)
} }
@ -282,7 +298,11 @@ async function run({ token, config: { currentTeam, user } }) {
if (cardId === undefined) { if (cardId === undefined) {
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
const message = `Selecting a card to ${chalk.underline('remove')} under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)} ${chalk.gray(`[${elapsed}]`)}` const message = `Selecting a card to ${chalk.underline(
'remove'
)} under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)} ${chalk.gray(`[${elapsed}]`)}`
const choices = buildInquirerChoices(cards) const choices = buildInquirerChoices(cards)
cardId = await listInput({ cardId = await listInput({
@ -322,7 +342,9 @@ async function run({ token, config: { currentTeam, user } }) {
card => card.id === cards.defaultCardId card => card.id === cards.defaultCardId
) )
text += `\n${newDefaultCard.brand} ending in ${newDefaultCard.last4} in now default for ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)}` text += `\n${newDefaultCard.brand} ending in ${newDefaultCard.last4} in now default for ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}`
} }
} }

70
bin/now-certs.js

@ -36,14 +36,20 @@ const help = () => {
${chalk.dim('Note:')} ${chalk.dim('Note:')}
This command is intended for advanced use only, normally ${chalk.bold('now')} manages your certificates automatically. This command is intended for advanced use only, normally ${chalk.bold(
'now'
)} manages your certificates automatically.
${chalk.dim('Options:')} ${chalk.dim('Options:')}
-h, --help Output usage information -h, --help Output usage information
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} Config file
-d, --debug Debug mode [off] -d, --debug Debug mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} Login token -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
--crt ${chalk.bold.underline('FILE')} Certificate file --crt ${chalk.bold.underline('FILE')} Certificate file
--key ${chalk.bold.underline('FILE')} Certificate key file --key ${chalk.bold.underline('FILE')} Certificate key file
--ca ${chalk.bold.underline('FILE')} CA certificate chain file --ca ${chalk.bold.underline('FILE')} CA certificate chain file
@ -58,13 +64,19 @@ const help = () => {
${chalk.cyan('$ now certs create domain.com')} ${chalk.cyan('$ now certs create domain.com')}
${chalk.gray('–')} Renewing an existing certificate issued with ${chalk.bold('now')}: ${chalk.gray('–')} Renewing an existing certificate issued with ${chalk.bold(
'now'
)}:
${chalk.cyan('$ now certs renew domain.com')} ${chalk.cyan('$ now certs renew domain.com')}
${chalk.gray('–')} Replacing an existing certificate with a user-supplied certificate: ${chalk.gray(
'–'
)} Replacing an existing certificate with a user-supplied certificate:
${chalk.cyan('$ now certs replace --crt domain.crt --key domain.key --ca ca_chain.crt domain.com')} ${chalk.cyan(
'$ now certs replace --crt domain.crt --key domain.key --ca ca_chain.crt domain.com'
)}
`) `)
} }
@ -124,7 +136,11 @@ async function run({ token, config: { currentTeam, user } }) {
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`> ${list.length} certificate${list.length === 1 ? '' : 's'} found ${chalk.gray(`[${elapsed}]`)} under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)}` `> ${list.length} certificate${list.length === 1
? ''
: 's'} found ${chalk.gray(`[${elapsed}]`)} under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}`
) )
if (list.length > 0) { if (list.length > 0) {
@ -167,7 +183,9 @@ async function run({ token, config: { currentTeam, user } }) {
} else if (subcommand === 'create') { } else if (subcommand === 'create') {
if (args.length !== 1) { if (args.length !== 1) {
error( error(
`Invalid number of arguments. Usage: ${chalk.cyan('`now certs create <cn>`')}` `Invalid number of arguments. Usage: ${chalk.cyan(
'`now certs create <cn>`'
)}`
) )
return exit(1) return exit(1)
} }
@ -178,7 +196,9 @@ async function run({ token, config: { currentTeam, user } }) {
// Issue a custom certificate // Issue a custom certificate
if (!argv.crt || !argv.key) { if (!argv.crt || !argv.key) {
error( error(
`Missing required arguments for a custom certificate entry. Usage: ${chalk.cyan('`now certs create --crt DOMAIN.CRT --key DOMAIN.KEY [--ca CA.CRT] <id | cn>`')}` `Missing required arguments for a custom certificate entry. Usage: ${chalk.cyan(
'`now certs create --crt DOMAIN.CRT --key DOMAIN.KEY [--ca CA.CRT] <id | cn>`'
)}`
) )
return exit(1) return exit(1)
} }
@ -198,12 +218,16 @@ async function run({ token, config: { currentTeam, user } }) {
} }
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`${chalk.cyan('> Success!')} Certificate entry ${chalk.bold(cn)} ${chalk.gray(`(${cert.uid})`)} created ${chalk.gray(`[${elapsed}]`)}` `${chalk.cyan('> Success!')} Certificate entry ${chalk.bold(
cn
)} ${chalk.gray(`(${cert.uid})`)} created ${chalk.gray(`[${elapsed}]`)}`
) )
} else if (subcommand === 'renew') { } else if (subcommand === 'renew') {
if (args.length !== 1) { if (args.length !== 1) {
error( error(
`Invalid number of arguments. Usage: ${chalk.cyan('`now certs renew <id | cn>`')}` `Invalid number of arguments. Usage: ${chalk.cyan(
'`now certs renew <id | cn>`'
)}`
) )
return exit(1) return exit(1)
} }
@ -225,12 +249,16 @@ async function run({ token, config: { currentTeam, user } }) {
await certs.renew(cert.cn) await certs.renew(cert.cn)
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`${chalk.cyan('> Success!')} Certificate ${chalk.bold(cert.cn)} ${chalk.gray(`(${cert.uid})`)} renewed ${chalk.gray(`[${elapsed}]`)}` `${chalk.cyan('> Success!')} Certificate ${chalk.bold(
cert.cn
)} ${chalk.gray(`(${cert.uid})`)} renewed ${chalk.gray(`[${elapsed}]`)}`
) )
} else if (subcommand === 'replace') { } else if (subcommand === 'replace') {
if (!argv.crt || !argv.key) { if (!argv.crt || !argv.key) {
error( error(
`Invalid number of arguments. Usage: ${chalk.cyan('`now certs replace --crt DOMAIN.CRT --key DOMAIN.KEY [--ca CA.CRT] <id | cn>`')}` `Invalid number of arguments. Usage: ${chalk.cyan(
'`now certs replace --crt DOMAIN.CRT --key DOMAIN.KEY [--ca CA.CRT] <id | cn>`'
)}`
) )
return exit(1) return exit(1)
} }
@ -255,12 +283,16 @@ async function run({ token, config: { currentTeam, user } }) {
await certs.put(cert.cn, crt, key, ca) await certs.put(cert.cn, crt, key, ca)
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`${chalk.cyan('> Success!')} Certificate ${chalk.bold(cert.cn)} ${chalk.gray(`(${cert.uid})`)} replaced ${chalk.gray(`[${elapsed}]`)}` `${chalk.cyan('> Success!')} Certificate ${chalk.bold(
cert.cn
)} ${chalk.gray(`(${cert.uid})`)} replaced ${chalk.gray(`[${elapsed}]`)}`
) )
} else if (subcommand === 'rm' || subcommand === 'remove') { } else if (subcommand === 'rm' || subcommand === 'remove') {
if (args.length !== 1) { if (args.length !== 1) {
error( error(
`Invalid number of arguments. Usage: ${chalk.cyan('`now certs rm <id | cn>`')}` `Invalid number of arguments. Usage: ${chalk.cyan(
'`now certs rm <id | cn>`'
)}`
) )
return exit(1) return exit(1)
} }
@ -281,7 +313,9 @@ async function run({ token, config: { currentTeam, user } }) {
await certs.delete(cert.cn) await certs.delete(cert.cn)
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`${chalk.cyan('> Success!')} Certificate ${chalk.bold(cert.cn)} ${chalk.gray(`(${cert.uid})`)} removed ${chalk.gray(`[${elapsed}]`)}` `${chalk.cyan('> Success!')} Certificate ${chalk.bold(
cert.cn
)} ${chalk.gray(`(${cert.uid})`)} removed ${chalk.gray(`[${elapsed}]`)}`
) )
} else { } else {
error( error(
@ -334,7 +368,9 @@ async function getCertIdCn(certs, idOrCn, currentTeam, user) {
if (!thecert) { if (!thecert) {
error( error(
`No certificate found by id or cn "${idOrCn}" under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)}` `No certificate found by id or cn "${idOrCn}" under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}`
) )
return null return null
} }

101
bin/now-deploy.js

@ -81,7 +81,9 @@ const help = () => {
${chalk.dim('Cloud')} ${chalk.dim('Cloud')}
deploy [path] Performs a deployment ${chalk.bold('(default)')} deploy [path] Performs a deployment ${chalk.bold(
'(default)'
)}
ls | list [app] List deployments ls | list [app] List deployments
rm | remove [id] Remove a deployment rm | remove [id] Remove a deployment
ln | alias [id] [url] Configures aliases for deployments ln | alias [id] [url] Configures aliases for deployments
@ -107,20 +109,32 @@ const help = () => {
-h, --help Output usage information -h, --help Output usage information
-v, --version Output the version number -v, --version Output the version number
-n, --name Set the name of the deployment -n, --name Set the name of the deployment
-c ${chalk.underline('FILE')}, --config=${chalk.underline('FILE')} Config file -c ${chalk.underline('FILE')}, --config=${chalk.underline(
'FILE'
)} Config file
-d, --debug Debug mode [off] -d, --debug Debug mode [off]
-f, --force Force a new deployment even if nothing has changed -f, --force Force a new deployment even if nothing has changed
-t ${chalk.underline('TOKEN')}, --token=${chalk.underline('TOKEN')} Login token -t ${chalk.underline('TOKEN')}, --token=${chalk.underline(
'TOKEN'
)} Login token
-L, --login Configure login -L, --login Configure login
-l, --links Copy symlinks without resolving their target -l, --links Copy symlinks without resolving their target
-p, --public Deployment is public (${chalk.dim('`/_src`')} is exposed) [on for oss, off for premium] -p, --public Deployment is public (${chalk.dim(
-e, --env Include an env var (e.g.: ${chalk.dim('`-e KEY=value`')}). Can appear many times. '`/_src`'
-E ${chalk.underline('FILE')}, --dotenv=${chalk.underline('FILE')} Include env vars from .env file. Defaults to '.env' )} is exposed) [on for oss, off for premium]
-e, --env Include an env var (e.g.: ${chalk.dim(
'`-e KEY=value`'
)}). Can appear many times.
-E ${chalk.underline('FILE')}, --dotenv=${chalk.underline(
'FILE'
)} Include env vars from .env file. Defaults to '.env'
-C, --no-clipboard Do not attempt to copy URL to clipboard -C, --no-clipboard Do not attempt to copy URL to clipboard
-N, --forward-npm Forward login information to install private npm modules -N, --forward-npm Forward login information to install private npm modules
--session-affinity Session affinity, \`ip\` (default) or \`random\` to control session affinity. --session-affinity Session affinity, \`ip\` (default) or \`random\` to control session affinity.
${chalk.dim('Enforcable Types (when both package.json and Dockerfile exist):')} ${chalk.dim(
'Enforcable Types (when both package.json and Dockerfile exist):'
)}
--npm Node.js application --npm Node.js application
--docker Docker container --docker Docker container
@ -146,9 +160,13 @@ const help = () => {
${chalk.gray('–')} Deploys with ENV vars ${chalk.gray('–')} Deploys with ENV vars
${chalk.cyan('$ now -e NODE_ENV=production -e MYSQL_PASSWORD=@mysql-password')} ${chalk.cyan(
'$ now -e NODE_ENV=production -e MYSQL_PASSWORD=@mysql-password'
)}
${chalk.gray('–')} Displays comprehensive help for the subcommand ${chalk.dim('`list`')} ${chalk.gray('–')} Displays comprehensive help for the subcommand ${chalk.dim(
'`list`'
)}
${chalk.cyan('$ now help list')} ${chalk.cyan('$ now help list')}
`) `)
@ -191,7 +209,9 @@ if (argv.config) {
if (Array.isArray(autoAliases)) { if (Array.isArray(autoAliases)) {
console.log( console.log(
`${chalk.red('Deprecated!')} The option ${chalk.grey('--alias')} will be removed soon.` `${chalk.red('Deprecated!')} The option ${chalk.grey(
'--alias'
)} will be removed soon.`
) )
console.log('Read more about the new way here: http://bit.ly/2l2v5Fg\n') console.log('Read more about the new way here: http://bit.ly/2l2v5Fg\n')
} }
@ -235,7 +255,9 @@ async function main() {
`> Logged in successfully. Token saved to ${chalk.bold('~/.now.json')}.` `> Logged in successfully. Token saved to ${chalk.bold('~/.now.json')}.`
) )
console.log( console.log(
`> Run ${cmd('now')} to deploy the current directory, or ${cmd('now --help')} for usage info.\n` `> Run ${cmd('now')} to deploy the current directory, or ${cmd(
'now --help'
)} for usage info.\n`
) )
return exit(0) return exit(0)
} }
@ -300,7 +322,9 @@ async function sync({ token, config: { currentTeam, user } }) {
} else if (isValidRepo) { } else if (isValidRepo) {
const gitRef = gitRepo.ref ? `with "${chalk.bold(gitRepo.ref)}" ` : '' const gitRef = gitRepo.ref ? `with "${chalk.bold(gitRepo.ref)}" ` : ''
stopDeployment( stopDeployment(
`There's no repository named "${chalk.bold(gitRepo.main)}" ${gitRef}on ${gitRepo.type}` `There's no repository named "${chalk.bold(
gitRepo.main
)}" ${gitRef}on ${gitRepo.type}`
) )
} else { } else {
stopDeployment(`Could not read directory ${chalk.bold(path)}`) stopDeployment(`Could not read directory ${chalk.bold(path)}`)
@ -319,11 +343,17 @@ async function sync({ token, config: { currentTeam, user } }) {
if (gitRepo.main) { if (gitRepo.main) {
const gitRef = gitRepo.ref ? ` at "${chalk.bold(gitRepo.ref)}" ` : '' const gitRef = gitRepo.ref ? ` at "${chalk.bold(gitRepo.ref)}" ` : ''
console.log( console.log(
`> Deploying ${gitRepo.type} repository "${chalk.bold(gitRepo.main)}" ${gitRef} under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)}` `> Deploying ${gitRepo.type} repository "${chalk.bold(
gitRepo.main
)}" ${gitRef} under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}`
) )
} else { } else {
console.log( console.log(
`> Deploying ${chalk.bold(toHumanPath(path))} under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)}` `> Deploying ${chalk.bold(toHumanPath(path))} under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}`
) )
} }
} }
@ -420,7 +450,9 @@ async function sync({ token, config: { currentTeam, user } }) {
if (/[^A-z0-9_]/i.test(key)) { if (/[^A-z0-9_]/i.test(key)) {
error( error(
`Invalid ${chalk.dim('-e')} key ${chalk.bold(`"${chalk.bold(key)}"`)}. Only letters, digits and underscores are allowed.` `Invalid ${chalk.dim('-e')} key ${chalk.bold(
`"${chalk.bold(key)}"`
)}. Only letters, digits and underscores are allowed.`
) )
return process.exit(1) return process.exit(1)
} }
@ -433,13 +465,17 @@ async function sync({ token, config: { currentTeam, user } }) {
if (val === undefined) { if (val === undefined) {
if (key in process.env) { if (key in process.env) {
console.log( console.log(
`> Reading ${chalk.bold(`"${chalk.bold(key)}"`)} from your env (as no value was specified)` `> Reading ${chalk.bold(
`"${chalk.bold(key)}"`
)} from your env (as no value was specified)`
) )
// Escape value if it begins with @ // Escape value if it begins with @
val = process.env[key].replace(/^@/, '\\@') val = process.env[key].replace(/^@/, '\\@')
} else { } else {
error( error(
`No value specified for env ${chalk.bold(`"${chalk.bold(key)}"`)} and it was not found in your env.` `No value specified for env ${chalk.bold(
`"${chalk.bold(key)}"`
)} and it was not found in your env.`
) )
return process.exit(1) return process.exit(1)
} }
@ -451,7 +487,9 @@ async function sync({ token, config: { currentTeam, user } }) {
if (secrets.length === 0) { if (secrets.length === 0) {
if (uidOrName === '') { if (uidOrName === '') {
error( error(
`Empty reference provided for env key ${chalk.bold(`"${chalk.bold(key)}"`)}` `Empty reference provided for env key ${chalk.bold(
`"${chalk.bold(key)}"`
)}`
) )
} else { } else {
error( error(
@ -461,7 +499,9 @@ async function sync({ token, config: { currentTeam, user } }) {
return process.exit(1) return process.exit(1)
} else if (secrets.length > 1) { } else if (secrets.length > 1) {
error( error(
`Ambiguous secret ${chalk.bold(`"${uidOrName}"`)} (matches ${chalk.bold(secrets.length)} secrets)` `Ambiguous secret ${chalk.bold(
`"${uidOrName}"`
)} (matches ${chalk.bold(secrets.length)} secrets)`
) )
return process.exit(1) return process.exit(1)
} }
@ -515,7 +555,9 @@ async function sync({ token, config: { currentTeam, user } }) {
try { try {
await copy(url) await copy(url)
console.log( console.log(
`${chalk.cyan('> Ready!')} ${chalk.bold(url)} (copied to clipboard) [${elapsed}]` `${chalk.cyan('> Ready!')} ${chalk.bold(
url
)} (copied to clipboard) [${elapsed}]`
) )
} catch (err) { } catch (err) {
console.log(`${chalk.cyan('> Ready!')} ${chalk.bold(url)} [${elapsed}]`) console.log(`${chalk.cyan('> Ready!')} ${chalk.bold(url)} [${elapsed}]`)
@ -556,7 +598,12 @@ async function sync({ token, config: { currentTeam, user } }) {
if (plan.id === 'oss' && !wantsPublic) { if (plan.id === 'oss' && !wantsPublic) {
if (isTTY) { if (isTTY) {
info( info(
`${chalk.bold((currentTeam && `${currentTeam.slug} is`) || `You (${user.username || user.email}) are`)} on the OSS plan. Your code and logs will be made ${chalk.bold('public')}.` `${chalk.bold(
(currentTeam && `${currentTeam.slug} is`) ||
`You (${user.username || user.email}) are`
)} on the OSS plan. Your code and logs will be made ${chalk.bold(
'public'
)}.`
) )
const proceed = await promptBool( const proceed = await promptBool(
@ -589,7 +636,9 @@ async function sync({ token, config: { currentTeam, user } }) {
) )
} }
const size = bytes(now.syncAmount) const size = bytes(now.syncAmount)
const syncCount = `${now.syncFileCount} file${now.syncFileCount > 1 ? 's' : ''}` const syncCount = `${now.syncFileCount} file${now.syncFileCount > 1
? 's'
: ''}`
const bar = new Progress( const bar = new Progress(
`> Upload [:bar] :percent :etas (${size}) [${syncCount}]`, `> Upload [:bar] :percent :etas (${size}) [${syncCount}]`,
{ {
@ -680,7 +729,9 @@ async function readMeta(path, deploymentName, deploymentType, sessionAffinity) {
} }
console.log( console.log(
`> Two manifests found. Press [${chalk.bold('n')}] to deploy or re-run with --flag` `> Two manifests found. Press [${chalk.bold(
'n'
)}] to deploy or re-run with --flag`
) )
deploymentType = await promptOptions([ deploymentType = await promptOptions([
@ -708,7 +759,9 @@ function printLogs(host, token, currentTeam, user) {
if (!quiet) { if (!quiet) {
if (err && err.type === 'BUILD_ERROR') { if (err && err.type === 'BUILD_ERROR') {
error( error(
`The build step of your project failed. To retry, run ${cmd('now --force')}.` `The build step of your project failed. To retry, run ${cmd(
'now --force'
)}.`
) )
} else { } else {
error('Deployment failed') error('Deployment failed')

56
bin/now-dns.js

@ -33,17 +33,25 @@ const subcommand = argv._[0]
const help = () => { const help = () => {
console.log(` console.log(`
${chalk.bold(`${logo} now dns ls`)} [domain] ${chalk.bold(`${logo} now dns ls`)} [domain]
${chalk.bold(`${logo} now dns add`)} <domain> <name> <A | AAAA | ALIAS | CNAME | TXT> <value> ${chalk.bold(
`${logo} now dns add`
)} <domain> <name> <A | AAAA | ALIAS | CNAME | TXT> <value>
${chalk.bold(`${logo} now dns add`)} <domain> <name> MX <value> <mx_priority> ${chalk.bold(`${logo} now dns add`)} <domain> <name> MX <value> <mx_priority>
${chalk.bold(`${logo} now dns add`)} <domain> <name> SRV <priority> <weight> <port> <target> ${chalk.bold(
`${logo} now dns add`
)} <domain> <name> SRV <priority> <weight> <port> <target>
${chalk.bold(`${logo} now dns rm`)} <id> ${chalk.bold(`${logo} now dns rm`)} <id>
${chalk.dim('Options:')} ${chalk.dim('Options:')}
-h, --help output usage information -h, --help output usage information
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} config file
-d, --debug debug mode [off] -d, --debug debug mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} login token -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} login token
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}
@ -53,12 +61,16 @@ const help = () => {
${chalk.gray('–')} Add an A record for a subdomain ${chalk.gray('–')} Add an A record for a subdomain
${chalk.cyan('$ now dns add <YOUR DOMAIN> <SUBDOMAIN NAME> A <RECORD VALUE>')} ${chalk.cyan(
'$ now dns add <YOUR DOMAIN> <SUBDOMAIN NAME> A <RECORD VALUE>'
)}
${chalk.cyan('$ now dns add zeit.rocks api A 198.51.100.100')} ${chalk.cyan('$ now dns add zeit.rocks api A 198.51.100.100')}
${chalk.gray('–')} Add an MX record (@ as a name refers to the domain) ${chalk.gray('–')} Add an MX record (@ as a name refers to the domain)
${chalk.cyan('$ now dns add <YOUR DOMAIN> @ MX <RECORD VALUE> <PRIORITY>')} ${chalk.cyan(
'$ now dns add <YOUR DOMAIN> @ MX <RECORD VALUE> <PRIORITY>'
)}
${chalk.cyan('$ now dns add zeit.rocks @ MX mail.zeit.rocks 10')} ${chalk.cyan('$ now dns add zeit.rocks @ MX mail.zeit.rocks 10')}
`) `)
} }
@ -102,7 +114,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (subcommand === 'ls' || subcommand === 'list') { if (subcommand === 'ls' || subcommand === 'list') {
if (args.length > 1) { if (args.length > 1) {
error( error(
`Invalid number of arguments. Usage: ${chalk.cyan('`now dns ls [domain]`')}` `Invalid number of arguments. Usage: ${chalk.cyan(
'`now dns ls [domain]`'
)}`
) )
return exit(1) return exit(1)
} }
@ -152,21 +166,33 @@ async function run({ token, config: { currentTeam, user } }) {
} }
}) })
console.log( console.log(
`> ${count} record${count === 1 ? '' : 's'} found ${chalk.gray(`[${elapsed}]`)} under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)}` `> ${count} record${count === 1 ? '' : 's'} found ${chalk.gray(
`[${elapsed}]`
)} under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}`
) )
console.log(text.join('')) console.log(text.join(''))
} else if (subcommand === 'add') { } else if (subcommand === 'add') {
const param = parseAddArgs(args) const param = parseAddArgs(args)
if (!param) { if (!param) {
error( error(
`Invalid number of arguments. See: ${chalk.cyan('`now dns --help`')} for usage.` `Invalid number of arguments. See: ${chalk.cyan(
'`now dns --help`'
)} for usage.`
) )
return exit(1) return exit(1)
} }
const record = await domainRecords.create(param.domain, param.data) const record = await domainRecords.create(param.domain, param.data)
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`${chalk.cyan('> Success!')} A new DNS record for domain ${chalk.bold(param.domain)} ${chalk.gray(`(${record.uid})`)} created ${chalk.gray(`[${elapsed}]`)} (${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)})` `${chalk.cyan('> Success!')} A new DNS record for domain ${chalk.bold(
param.domain
)} ${chalk.gray(`(${record.uid})`)} created ${chalk.gray(
`[${elapsed}]`
)} (${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)})`
) )
} else if (subcommand === 'rm' || subcommand === 'remove') { } else if (subcommand === 'rm' || subcommand === 'remove') {
if (args.length !== 1) { if (args.length !== 1) {
@ -194,7 +220,9 @@ async function run({ token, config: { currentTeam, user } }) {
await domainRecords.delete(record.domain, record.id) await domainRecords.delete(record.domain, record.id)
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`${chalk.cyan('> Success!')} Record ${chalk.gray(`${record.id}`)} removed ${chalk.gray(`[${elapsed}]`)}` `${chalk.cyan('> Success!')} Record ${chalk.gray(
`${record.id}`
)} removed ${chalk.gray(`[${elapsed}]`)}`
) )
} else { } else {
error('Please specify a valid subcommand: ls | add | rm') error('Please specify a valid subcommand: ls | add | rm')
@ -281,7 +309,11 @@ function readConfirmation(record, msg) {
[ [
record.id, record.id,
chalk.bold( chalk.bold(
`${record.name.length > 0 ? record.name + '.' : ''}${record.domain} ${record.type} ${record.value} ${record.mxPriority ? record.mxPriority : ''}` `${record.name.length > 0
? record.name + '.'
: ''}${record.domain} ${record.type} ${record.value} ${record.mxPriority
? record.mxPriority
: ''}`
), ),
time time
] ]

98
bin/now-domains.js

@ -42,11 +42,15 @@ const help = () => {
${chalk.dim('Options:')} ${chalk.dim('Options:')}
-h, --help Output usage information -h, --help Output usage information
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} Config file
-d, --debug Debug mode [off] -d, --debug Debug mode [off]
-e, --external Use external DNS server -e, --external Use external DNS server
-f, --force Skip DNS verification -f, --force Skip DNS verification
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} Login token -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}
@ -64,19 +68,43 @@ const help = () => {
Make sure the domain's DNS nameservers are at least 2 of these: Make sure the domain's DNS nameservers are at least 2 of these:
${chalk.gray('–')} ${chalk.underline('california.zeit.world')} ${chalk.dim('173.255.215.107')} ${chalk.gray('–')} ${chalk.underline(
${chalk.gray('–')} ${chalk.underline('london.zeit.world')} ${chalk.dim('178.62.47.76')} 'california.zeit.world'
${chalk.gray('–')} ${chalk.underline('newark.zeit.world')} ${chalk.dim('173.255.231.87')} )} ${chalk.dim('173.255.215.107')}
${chalk.gray('–')} ${chalk.underline('amsterdam.zeit.world')} ${chalk.dim('188.226.197.55')} ${chalk.gray('–')} ${chalk.underline(
${chalk.gray('–')} ${chalk.underline('dallas.zeit.world')} ${chalk.dim('173.192.101.194')} 'london.zeit.world'
${chalk.gray('–')} ${chalk.underline('paris.zeit.world')} ${chalk.dim('37.123.115.172')} )} ${chalk.dim('178.62.47.76')}
${chalk.gray('–')} ${chalk.underline('singapore.zeit.world')} ${chalk.dim('119.81.97.170')} ${chalk.gray('–')} ${chalk.underline(
${chalk.gray('–')} ${chalk.underline('sydney.zeit.world')} ${chalk.dim('52.64.171.200')} 'newark.zeit.world'
${chalk.gray('–')} ${chalk.underline('frankfurt.zeit.world')} ${chalk.dim('91.109.245.139')} )} ${chalk.dim('173.255.231.87')}
${chalk.gray('–')} ${chalk.underline('iowa.zeit.world')} ${chalk.dim('23.236.59.22')} ${chalk.gray('–')} ${chalk.underline(
'amsterdam.zeit.world'
${chalk.yellow('NOTE:')} running ${chalk.dim('`now alias`')} will automatically register your domain )} ${chalk.dim('188.226.197.55')}
if it's configured with these nameservers (no need to ${chalk.dim('`domain add`')}). ${chalk.gray('–')} ${chalk.underline(
'dallas.zeit.world'
)} ${chalk.dim('173.192.101.194')}
${chalk.gray('–')} ${chalk.underline(
'paris.zeit.world'
)} ${chalk.dim('37.123.115.172')}
${chalk.gray('–')} ${chalk.underline(
'singapore.zeit.world'
)} ${chalk.dim('119.81.97.170')}
${chalk.gray('–')} ${chalk.underline(
'sydney.zeit.world'
)} ${chalk.dim('52.64.171.200')}
${chalk.gray('–')} ${chalk.underline(
'frankfurt.zeit.world'
)} ${chalk.dim('91.109.245.139')}
${chalk.gray('–')} ${chalk.underline(
'iowa.zeit.world'
)} ${chalk.dim('23.236.59.22')}
${chalk.yellow('NOTE:')} running ${chalk.dim(
'`now alias`'
)} will automatically register your domain
if it's configured with these nameservers (no need to ${chalk.dim(
'`domain add`'
)}).
For more details head to ${chalk.underline('https://zeit.world')}. For more details head to ${chalk.underline('https://zeit.world')}.
@ -90,13 +118,17 @@ const help = () => {
To get the list of domain ids, use ${chalk.dim('`now domains ls`')}. To get the list of domain ids, use ${chalk.dim('`now domains ls`')}.
${chalk.gray('–')} Adding and verifying a domain name using zeit.world nameservers: ${chalk.gray(
'–'
)} Adding and verifying a domain name using zeit.world nameservers:
${chalk.cyan('$ now domain add my-app.com')} ${chalk.cyan('$ now domain add my-app.com')}
The command will tell you if the domain was verified succesfully. In case the domain was not verified succesfully you should retry adding the domain after some time. The command will tell you if the domain was verified succesfully. In case the domain was not verified succesfully you should retry adding the domain after some time.
${chalk.gray('–')} Adding and verifying a domain name using an external nameserver: ${chalk.gray(
'–'
)} Adding and verifying a domain name using an external nameserver:
${chalk.cyan('$ now domain add -e my-app.com')} ${chalk.cyan('$ now domain add -e my-app.com')}
@ -180,7 +212,11 @@ async function run({ token, config: { currentTeam, user } }) {
const elapsed_ = ms(new Date() - start_) const elapsed_ = ms(new Date() - start_)
console.log( console.log(
`> ${domains.length} domain${domains.length === 1 ? '' : 's'} found under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)} ${chalk.gray(`[${elapsed_}]`)}` `> ${domains.length} domain${domains.length === 1
? ''
: 's'} found under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)} ${chalk.gray(`[${elapsed_}]`)}`
) )
if (out) { if (out) {
@ -208,7 +244,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (!_domain) { if (!_domain) {
const err = new Error( const err = new Error(
`Domain not found by "${_target}". Run ${chalk.dim('`now domains ls`')} to see your domains.` `Domain not found by "${_target}". Run ${chalk.dim(
'`now domains ls`'
)} to see your domains.`
) )
err.userError = true err.userError = true
throw err throw err
@ -229,7 +267,9 @@ async function run({ token, config: { currentTeam, user } }) {
await domain.rm(_domain.name) await domain.rm(_domain.name)
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`${chalk.cyan('> Success!')} Domain ${chalk.bold(_domain.uid)} removed [${elapsed}]` `${chalk.cyan('> Success!')} Domain ${chalk.bold(
_domain.uid
)} removed [${elapsed}]`
) )
} catch (err) { } catch (err) {
error(err) error(err)
@ -254,15 +294,21 @@ async function run({ token, config: { currentTeam, user } }) {
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
if (created) { if (created) {
console.log( console.log(
`${chalk.cyan('> Success!')} Domain ${chalk.bold(chalk.underline(name))} ${chalk.dim(`(${uid})`)} added [${elapsed}]` `${chalk.cyan('> Success!')} Domain ${chalk.bold(
chalk.underline(name)
)} ${chalk.dim(`(${uid})`)} added [${elapsed}]`
) )
} else if (verified) { } else if (verified) {
console.log( console.log(
`${chalk.cyan('> Success!')} Domain ${chalk.bold(chalk.underline(name))} ${chalk.dim(`(${uid})`)} verified [${elapsed}]` `${chalk.cyan('> Success!')} Domain ${chalk.bold(
chalk.underline(name)
)} ${chalk.dim(`(${uid})`)} verified [${elapsed}]`
) )
} else if (code === 'not_modified') { } else if (code === 'not_modified') {
console.log( console.log(
`${chalk.cyan('> Success!')} Domain ${chalk.bold(chalk.underline(name))} ${chalk.dim(`(${uid})`)} already exists [${elapsed}]` `${chalk.cyan('> Success!')} Domain ${chalk.bold(
chalk.underline(name)
)} ${chalk.dim(`(${uid})`)} already exists [${elapsed}]`
) )
} else { } else {
console.log( console.log(
@ -303,7 +349,11 @@ async function readConfirmation(domain, _domain) {
if (_domain.aliases.length > 0) { if (_domain.aliases.length > 0) {
process.stdout.write( process.stdout.write(
`> ${chalk.yellow('Warning!')} This domain's ` + `> ${chalk.yellow('Warning!')} This domain's ` +
`${chalk.bold(_domain.aliases.length + ' alias' + (_domain.aliases.length === 1 ? '' : 'es'))} ` + `${chalk.bold(
_domain.aliases.length +
' alias' +
(_domain.aliases.length === 1 ? '' : 'es')
)} ` +
`will be removed. Run ${chalk.dim('`now alias ls`')} to list.\n` `will be removed. Run ${chalk.dim('`now alias ls`')} to list.\n`
) )
} }

22
bin/now-list.js

@ -34,9 +34,13 @@ const help = () => {
${chalk.dim('Options:')} ${chalk.dim('Options:')}
-h, --help Output usage information -h, --help Output usage information
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} Config file
-d, --debug Debug mode [off] -d, --debug Debug mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} Login token -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}
@ -145,7 +149,11 @@ async function list({ token, config: { currentTeam, user } }) {
}, 0) + 5 }, 0) + 5
const timeNow = new Date() const timeNow = new Date()
console.log( console.log(
`> ${deployments.length} deployment${deployments.length === 1 ? '' : 's'} found under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)} ${chalk.grey('[' + ms(timeNow - start) + ']')}` `> ${deployments.length} deployment${deployments.length === 1
? ''
: 's'} found under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)} ${chalk.grey('[' + ms(timeNow - start) + ']')}`
) )
let shouldShowAllInfo = false let shouldShowAllInfo = false
@ -161,14 +169,18 @@ async function list({ token, config: { currentTeam, user } }) {
} }
if (!argv.all && shouldShowAllInfo) { if (!argv.all && shouldShowAllInfo) {
console.log( console.log(
`> To expand the list and see instances run ${chalk.cyan('`now ls --all [app]`')}` `> To expand the list and see instances run ${chalk.cyan(
'`now ls --all [app]`'
)}`
) )
} }
console.log() console.log()
sorted.forEach(([name, deps]) => { sorted.forEach(([name, deps]) => {
const listedDeployments = argv.all ? deps : deps.slice(0, 5) const listedDeployments = argv.all ? deps : deps.slice(0, 5)
console.log( console.log(
`${chalk.bold(name)} ${chalk.gray('(' + listedDeployments.length + ' of ' + deps.length + ' total)')}` `${chalk.bold(name)} ${chalk.gray(
'(' + listedDeployments.length + ' of ' + deps.length + ' total)'
)}`
) )
const urlSpec = `%-${urlLength}s` const urlSpec = `%-${urlLength}s`
console.log( console.log(

4
bin/now-logout.js

@ -26,7 +26,9 @@ const help = () => {
${chalk.dim('Options:')} ${chalk.dim('Options:')}
-h, --help output usage information -h, --help output usage information
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} config file
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}

24
bin/now-logs.js

@ -36,18 +36,30 @@ const help = () => {
-h, --help output usage information -h, --help output usage information
-a, --all include access logs -a, --all include access logs
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} config file
-d, --debug debug mode [off] -d, --debug debug mode [off]
-f wait for additional data [off] -f wait for additional data [off]
-n ${chalk.bold.underline('NUMBER')} number of logs [1000] -n ${chalk.bold.underline('NUMBER')} number of logs [1000]
-q ${chalk.bold.underline('QUERY')}, --query=${chalk.bold.underline('QUERY')} search query -q ${chalk.bold.underline('QUERY')}, --query=${chalk.bold.underline(
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} login token 'QUERY'
--since=${chalk.bold.underline('SINCE')} only return logs after date (ISO 8601) )} search query
--until=${chalk.bold.underline('UNTIL')} only return logs before date (ISO 8601), ignored if the f option is enbled. -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} login token
--since=${chalk.bold.underline(
'SINCE'
)} only return logs after date (ISO 8601)
--until=${chalk.bold.underline(
'UNTIL'
)} only return logs before date (ISO 8601), ignored if the f option is enbled.
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}
${chalk.gray('–')} Print logs for the deployment ${chalk.dim('`deploymentId`')} ${chalk.gray('–')} Print logs for the deployment ${chalk.dim(
'`deploymentId`'
)}
${chalk.cyan('$ now logs deploymentId')} ${chalk.cyan('$ now logs deploymentId')}
`) `)

28
bin/now-remove.js

@ -31,20 +31,28 @@ const ids = argv._
// Options // Options
const help = () => { const help = () => {
console.log(` console.log(`
${chalk.bold(`${logo} now remove`)} deploymentId|deploymentName [...deploymentId|deploymentName] ${chalk.bold(
`${logo} now remove`
)} deploymentId|deploymentName [...deploymentId|deploymentName]
${chalk.dim('Options:')} ${chalk.dim('Options:')}
-h, --help Output usage information -h, --help Output usage information
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} Config file
-d, --debug Debug mode [off] -d, --debug Debug mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} Login token -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-y, --yes Skip confirmation -y, --yes Skip confirmation
--safe Skip deployments with an active alias --safe Skip deployments with an active alias
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}
${chalk.gray('–')} Remove a deployment identified by ${chalk.dim('`deploymentId`')}: ${chalk.gray('–')} Remove a deployment identified by ${chalk.dim(
'`deploymentId`'
)}:
${chalk.cyan('$ now rm deploymentId')} ${chalk.cyan('$ now rm deploymentId')}
@ -52,7 +60,9 @@ const help = () => {
${chalk.cyan('$ now rm my-app')} ${chalk.cyan('$ now rm my-app')}
${chalk.gray('–')} Remove two deployments with IDs ${chalk.dim('`eyWt6zuSdeus`')} and ${chalk.dim('`uWHoA9RQ1d1o`')}: ${chalk.gray('–')} Remove two deployments with IDs ${chalk.dim(
'`eyWt6zuSdeus`'
)} and ${chalk.dim('`uWHoA9RQ1d1o`')}:
${chalk.cyan('$ now rm eyWt6zuSdeus uWHoA9RQ1d1o')} ${chalk.cyan('$ now rm eyWt6zuSdeus uWHoA9RQ1d1o')}
@ -97,7 +107,9 @@ Promise.resolve().then(async () => {
function readConfirmation(matches) { function readConfirmation(matches) {
return new Promise(resolve => { return new Promise(resolve => {
process.stdout.write( process.stdout.write(
`> The following deployment${matches.length === 1 ? '' : 's'} will be removed permanently:\n` `> The following deployment${matches.length === 1
? ''
: 's'} will be removed permanently:\n`
) )
const tbl = table( const tbl = table(
@ -118,7 +130,9 @@ function readConfirmation(matches) {
} }
process.stdout.write( process.stdout.write(
`> ${chalk.yellow('Warning!')} Deployment ${chalk.bold(depl.uid)} ` + `> ${chalk.yellow('Warning!')} Deployment ${chalk.bold(depl.uid)} ` +
`is an alias for ${chalk.underline(`https://${alias.alias}`)} and will be removed.\n` `is an alias for ${chalk.underline(
`https://${alias.alias}`
)} and will be removed.\n`
) )
} }
} }

24
bin/now-scale.js

@ -40,7 +40,9 @@ const help = () => {
${chalk.dim('Options:')} ${chalk.dim('Options:')}
-h, --help Output usage information -h, --help Output usage information
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} Config file
-d, --debug Debug mode [off] -d, --debug Debug mode [off]
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}
@ -53,15 +55,21 @@ const help = () => {
${chalk.cyan('$ now scale my-deployment-ntahoeato.now.sh 1 5')} ${chalk.cyan('$ now scale my-deployment-ntahoeato.now.sh 1 5')}
${chalk.gray('–')} Create an automatically scaling deployment without specifying max: ${chalk.gray(
'–'
)} Create an automatically scaling deployment without specifying max:
${chalk.cyan('$ now scale my-deployment-ntahoeato.now.sh 1 auto')} ${chalk.cyan('$ now scale my-deployment-ntahoeato.now.sh 1 auto')}
${chalk.gray('–')} Create an automatically scaling deployment without specifying min or max: ${chalk.gray(
'–'
)} Create an automatically scaling deployment without specifying min or max:
${chalk.cyan('$ now scale my-deployment-ntahoeato.now.sh auto')} ${chalk.cyan('$ now scale my-deployment-ntahoeato.now.sh auto')}
${chalk.gray('–')} Create an deployment that is always active and never "sleeps": ${chalk.gray(
'–'
)} Create an deployment that is always active and never "sleeps":
${chalk.cyan('$ now scale my-deployment-ntahoeato.now.sh 1')} ${chalk.cyan('$ now scale my-deployment-ntahoeato.now.sh 1')}
`) `)
@ -246,7 +254,9 @@ function printScaleingRules(url, currentReplicas, min, max, elapsed) {
) )
log() log()
log( log(
`${chalk.bold(url)} (${chalk.gray(currentReplicas)} ${chalk.gray('current')})` `${chalk.bold(url)} (${chalk.gray(currentReplicas)} ${chalk.gray(
'current'
)})`
) )
log(printf('%6s %s', 'min', chalk.bold(min))) log(printf('%6s %s', 'min', chalk.bold(min)))
log(printf('%6s %s', 'max', chalk.bold(max))) log(printf('%6s %s', 'max', chalk.bold(max)))
@ -284,7 +294,9 @@ async function list(scale) {
for (const app of sorted) { for (const app of sorted) {
const depls = argv.all ? app[1] : app[1].slice(0, 5) const depls = argv.all ? app[1] : app[1].slice(0, 5)
console.log( console.log(
`${chalk.bold(app[0])} ${chalk.gray('(' + depls.length + ' of ' + app[1].length + ' total)')}` `${chalk.bold(app[0])} ${chalk.gray(
'(' + depls.length + ' of ' + app[1].length + ' total)'
)}`
) )
console.log() console.log()
const urlSpec = `%-${urlLength}s` const urlSpec = `%-${urlLength}s`

54
bin/now-secrets.js

@ -38,9 +38,13 @@ const help = () => {
-h, --help Output usage information -h, --help Output usage information
-b, --base64 Treat value as base64-encoded -b, --base64 Treat value as base64-encoded
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} Config file
-d, --debug Debug mode [off] -d, --debug Debug mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} Login token -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}
@ -52,15 +56,21 @@ const help = () => {
${chalk.cyan('$ now secrets add my-secret "my value"')} ${chalk.cyan('$ now secrets add my-secret "my value"')}
${chalk.gray('–')} Once added, a secret's value can't be retrieved in plaintext anymore ${chalk.gray(
${chalk.gray('–')} If the secret's value is more than one word, wrap it in quotes '–'
)} Once added, a secret's value can't be retrieved in plaintext anymore
${chalk.gray(
'–'
)} If the secret's value is more than one word, wrap it in quotes
${chalk.gray('–')} Actually, when in doubt, wrap your value in quotes ${chalk.gray('–')} Actually, when in doubt, wrap your value in quotes
${chalk.gray('–')} Exposes a secret as an env variable: ${chalk.gray('–')} Exposes a secret as an env variable:
${chalk.cyan(`$ now -e MY_SECRET=${chalk.bold('@my-secret')}`)} ${chalk.cyan(`$ now -e MY_SECRET=${chalk.bold('@my-secret')}`)}
Notice the ${chalk.cyan.bold('`@`')} symbol which makes the value a secret reference. Notice the ${chalk.cyan.bold(
'`@`'
)} symbol which makes the value a secret reference.
${chalk.gray('–')} Renames a secret: ${chalk.gray('–')} Renames a secret:
@ -121,7 +131,11 @@ async function run({ token, config: { currentTeam, user } }) {
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`> ${list.length} secret${list.length === 1 ? '' : 's'} found under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)} ${chalk.gray(`[${elapsed}]`)}` `> ${list.length} secret${list.length === 1
? ''
: 's'} found under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)} ${chalk.gray(`[${elapsed}]`)}`
) )
if (list.length > 0) { if (list.length > 0) {
@ -155,7 +169,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (subcommand === 'rm' || subcommand === 'remove') { if (subcommand === 'rm' || subcommand === 'remove') {
if (args.length !== 1) { if (args.length !== 1) {
error( error(
`Invalid number of arguments. Usage: ${chalk.cyan('`now secret rm <id | name>`')}` `Invalid number of arguments. Usage: ${chalk.cyan(
'`now secret rm <id | name>`'
)}`
) )
return exit(1) return exit(1)
} }
@ -178,7 +194,9 @@ async function run({ token, config: { currentTeam, user } }) {
const secret = await secrets.rm(args[0]) const secret = await secrets.rm(args[0])
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`${chalk.cyan('> Success!')} Secret ${chalk.bold(secret.name)} ${chalk.gray(`(${secret.uid})`)} removed ${chalk.gray(`[${elapsed}]`)}` `${chalk.cyan('> Success!')} Secret ${chalk.bold(
secret.name
)} ${chalk.gray(`(${secret.uid})`)} removed ${chalk.gray(`[${elapsed}]`)}`
) )
return secrets.close() return secrets.close()
} }
@ -186,14 +204,20 @@ async function run({ token, config: { currentTeam, user } }) {
if (subcommand === 'rename') { if (subcommand === 'rename') {
if (args.length !== 2) { if (args.length !== 2) {
error( error(
`Invalid number of arguments. Usage: ${chalk.cyan('`now secret rename <old-name> <new-name>`')}` `Invalid number of arguments. Usage: ${chalk.cyan(
'`now secret rename <old-name> <new-name>`'
)}`
) )
return exit(1) return exit(1)
} }
const secret = await secrets.rename(args[0], args[1]) const secret = await secrets.rename(args[0], args[1])
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`${chalk.cyan('> Success!')} Secret ${chalk.bold(secret.oldName)} ${chalk.gray(`(${secret.uid})`)} renamed to ${chalk.bold(args[1])} ${chalk.gray(`[${elapsed}]`)}` `${chalk.cyan('> Success!')} Secret ${chalk.bold(
secret.oldName
)} ${chalk.gray(`(${secret.uid})`)} renamed to ${chalk.bold(
args[1]
)} ${chalk.gray(`[${elapsed}]`)}`
) )
return secrets.close() return secrets.close()
} }
@ -201,7 +225,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (subcommand === 'add' || subcommand === 'set') { if (subcommand === 'add' || subcommand === 'set') {
if (args.length !== 2) { if (args.length !== 2) {
error( error(
`Invalid number of arguments. Usage: ${chalk.cyan('`now secret add <name> <value>`')}` `Invalid number of arguments. Usage: ${chalk.cyan(
'`now secret add <name> <value>`'
)}`
) )
if (args.length > 2) { if (args.length > 2) {
@ -227,7 +253,11 @@ async function run({ token, config: { currentTeam, user } }) {
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
console.log( console.log(
`${chalk.cyan('> Success!')} Secret ${chalk.bold(name.toLowerCase())} ${chalk.gray(`(${secret.uid})`)} added (${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)}) ${chalk.gray(`[${elapsed}]`)}` `${chalk.cyan('> Success!')} Secret ${chalk.bold(
name.toLowerCase()
)} ${chalk.gray(`(${secret.uid})`)} added (${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}) ${chalk.gray(`[${elapsed}]`)}`
) )
return secrets.close() return secrets.close()
} }

12
bin/now-teams.js

@ -36,9 +36,13 @@ const help = () => {
${chalk.dim('Options:')} ${chalk.dim('Options:')}
-h, --help Output usage information -h, --help Output usage information
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} Config file
-d, --debug Debug mode [off] -d, --debug Debug mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} Login token -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}
@ -52,7 +56,9 @@ const help = () => {
${chalk.gray('–')} If the id is omitted, you can choose interactively ${chalk.gray('–')} If the id is omitted, you can choose interactively
${chalk.yellow('NOTE:')} When you switch, everything you add, list or remove will be scoped that team! ${chalk.yellow(
'NOTE:'
)} When you switch, everything you add, list or remove will be scoped that team!
${chalk.gray('–')} Invite new members (interactively): ${chalk.gray('–')} Invite new members (interactively):

28
bin/now-upgrade.js

@ -37,9 +37,13 @@ const help = () => {
${chalk.dim('Options:')} ${chalk.dim('Options:')}
-h, --help Output usage information -h, --help Output usage information
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} Config file
-d, --debug Debug mode [off] -d, --debug Debug mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} Login token -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}
@ -47,7 +51,9 @@ const help = () => {
${chalk.cyan('$ now upgrade')} ${chalk.cyan('$ now upgrade')}
${chalk.yellow('NOTE:')} ${chalk.gray('Make sure you have a payment method, or add one:')} ${chalk.yellow('NOTE:')} ${chalk.gray(
'Make sure you have a payment method, or add one:'
)}
${chalk.cyan(`$ now billing add`)} ${chalk.cyan(`$ now billing add`)}
@ -187,7 +193,9 @@ async function run({ token, config: { currentTeam, user } }) {
message = currentTeam message = currentTeam
? `${message}/${currentTeam.slug}/settings/plan` ? `${message}/${currentTeam.slug}/settings/plan`
: `${message}/account/plan` : `${message}/account/plan`
message += `\n> Select a plan for ${bold((currentTeam && currentTeam.slug) || user.username || user.email)} ${chalk.gray(`[${elapsed}]`)}` message += `\n> Select a plan for ${bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)} ${chalk.gray(`[${elapsed}]`)}`
const choices = buildInquirerChoices(currentPlan.id, currentPlan.until) const choices = buildInquirerChoices(currentPlan.id, currentPlan.until)
planId = await listInput({ planId = await listInput({
@ -212,7 +220,9 @@ async function run({ token, config: { currentTeam, user } }) {
} catch (err) { } catch (err) {
if (err.code === 'customer_not_found' || err.code === 'source_not_found') { if (err.code === 'customer_not_found' || err.code === 'source_not_found') {
error( error(
`You have no payment methods available. Run ${cmd('now billing add')} to add one` `You have no payment methods available. Run ${cmd(
'now billing add'
)} to add one`
) )
} else { } else {
error(`An unknow error occured. Please try again later ${err.message}`) error(`An unknow error occured. Please try again later ${err.message}`)
@ -223,11 +233,15 @@ async function run({ token, config: { currentTeam, user } }) {
if (currentPlan.until && newPlan.id !== 'oss') { if (currentPlan.until && newPlan.id !== 'oss') {
success( success(
`The cancelation has been undone. You're back on the ${chalk.bold(`${newPlan.name} plan`)}` `The cancelation has been undone. You're back on the ${chalk.bold(
`${newPlan.name} plan`
)}`
) )
} else if (newPlan.until) { } else if (newPlan.until) {
success( success(
`Your plan will be switched to ${chalk.bold(newPlan.name)} in ${chalk.bold(newPlan.until)}. Your card will not be charged again` `Your plan will be switched to ${chalk.bold(
newPlan.name
)} in ${chalk.bold(newPlan.until)}. Your card will not be charged again`
) )
} else { } else {
success(`You're now on the ${chalk.bold(`${newPlan.name} plan`)}`) success(`You're now on the ${chalk.bold(`${newPlan.name} plan`)}`)

8
bin/now-whoami.js

@ -28,9 +28,13 @@ const help = () => {
${chalk.dim('Options:')} ${chalk.dim('Options:')}
-h, --help Output usage information -h, --help Output usage information
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} Config file
-d, --debug Debug mode [off] -d, --debug Debug mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} Login token -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
${chalk.dim('Examples:')} ${chalk.dim('Examples:')}

8
bin/now.js

@ -31,8 +31,12 @@ if (process.pkg) {
const update = notifier.update const update = notifier.update
if (update) { if (update) {
let message = `Update available! ${chalk.red(update.current)}${chalk.green(update.latest)} \n` let message = `Update available! ${chalk.red(
message += `${chalk.magenta('Changelog:')} https://github.com/zeit/now-cli/releases/tag/${update.latest}\n` update.current
)} ${chalk.green(update.latest)} \n`
message += `${chalk.magenta(
'Changelog:'
)} https://github.com/zeit/now-cli/releases/tag/${update.latest}\n`
if (pkg._npmPkg) { if (pkg._npmPkg) {
message += `Run ${chalk.magenta('npm i -g now')} to update!` message += `Run ${chalk.magenta('npm i -g now')} to update!`

11
bin/teams/add.js

@ -26,7 +26,9 @@ function validateSlugKeypress(data, value) {
function gracefulExit() { function gracefulExit() {
console.log() // Blank line console.log() // Blank line
note( note(
`Your team is now active for all ${cmd('now')} commands!\n Run ${cmd('now switch')} to change it in the future.` `Your team is now active for all ${cmd('now')} commands!\n Run ${cmd(
'now switch'
)} to change it in the future.`
) )
return exit() return exit()
} }
@ -122,8 +124,11 @@ module.exports = async function({ teams, token }) {
teams, teams,
args: [], args: [],
token, token,
introMsg: 'Invite your team mates! When done, press enter on an empty field', introMsg:
noopMsg: `You can invite team mates later by running ${cmd('now teams invite')}` 'Invite your team mates! When done, press enter on an empty field',
noopMsg: `You can invite team mates later by running ${cmd(
'now teams invite'
)}`
}) })
gracefulExit() gracefulExit()

4
bin/teams/invite.js

@ -68,7 +68,9 @@ module.exports = async function(
domains.push(user.email.split('@')[1]) domains.push(user.email.split('@')[1])
if (!currentTeam) { if (!currentTeam) {
let err = `You can't run this command under ${param(user.username || user.email)}.\n` let err = `You can't run this command under ${param(
user.username || user.email
)}.\n`
err += `${chalk.gray('>')} Run ${cmd('now switch')} to choose to a team.` err += `${chalk.gray('>')} Run ${cmd('now switch')} to choose to a team.`
return fatalError(err) return fatalError(err)
} }

109
lib/alias.js

@ -41,7 +41,9 @@ module.exports = class Alias extends Now {
if (!target) { if (!target) {
const err = new Error( const err = new Error(
`Aliases not found by "${deployment}". Run ${chalk.dim('`now alias ls`')} to see your aliases.` `Aliases not found by "${deployment}". Run ${chalk.dim(
'`now alias ls`'
)} to see your aliases.`
) )
err.userError = true err.userError = true
throw err throw err
@ -146,7 +148,9 @@ module.exports = class Alias extends Now {
if (code === 'custom_domain_needs_upgrade') { if (code === 'custom_domain_needs_upgrade') {
const err = new Error( const err = new Error(
`Custom domains are only enabled for premium accounts. Please upgrade by running ${chalk.gray('`')}${chalk.cyan('now upgrade')}${chalk.gray('`')}.` `Custom domains are only enabled for premium accounts. Please upgrade by running ${chalk.gray(
'`'
)}${chalk.cyan('now upgrade')}${chalk.gray('`')}.`
) )
err.userError = true err.userError = true
return bail(err) return bail(err)
@ -154,7 +158,9 @@ module.exports = class Alias extends Now {
if (code === 'alias_in_use') { if (code === 'alias_in_use') {
const err = new Error( const err = new Error(
`The alias you are trying to configure (${chalk.underline(chalk.bold(alias))}) is already in use by a different account.` `The alias you are trying to configure (${chalk.underline(
chalk.bold(alias)
)}) is already in use by a different account.`
) )
err.userError = true err.userError = true
return bail(err) return bail(err)
@ -177,7 +183,9 @@ module.exports = class Alias extends Now {
if (code === 'cert_missing') { if (code === 'cert_missing') {
console.log( console.log(
`> Provisioning certificate for ${chalk.underline(chalk.bold(alias))}` `> Provisioning certificate for ${chalk.underline(
chalk.bold(alias)
)}`
) )
try { try {
@ -236,7 +244,9 @@ module.exports = class Alias extends Now {
const depl = await this.findDeployment(deployment) const depl = await this.findDeployment(deployment)
if (!depl) { if (!depl) {
const err = new Error( const err = new Error(
`Deployment not found by "${deployment}". Run ${chalk.dim('`now ls`')} to see your deployments.` `Deployment not found by "${deployment}". Run ${chalk.dim(
'`now ls`'
)} to see your deployments.`
) )
err.userError = true err.userError = true
throw err throw err
@ -247,7 +257,10 @@ module.exports = class Alias extends Now {
if (isTTY) { if (isTTY) {
try { try {
const msg = const msg =
`> Path alias exists with ${aliasDepl.rules.length} rule${aliasDepl.rules.length > 1 ? 's' : ''}.\n` + `> Path alias exists with ${aliasDepl.rules.length} rule${aliasDepl
.rules.length > 1
? 's'
: ''}.\n` +
`> Are you sure you want to update ${alias} to be a normal alias?\n` `> Are you sure you want to update ${alias} to be a normal alias?\n`
const confirmation = await promptBool(msg, { const confirmation = await promptBool(msg, {
@ -263,7 +276,10 @@ module.exports = class Alias extends Now {
} }
} else { } else {
console.log( console.log(
`Overwriting path alias with ${aliasDepl.rules.length} rule${aliasDepl.rules.length > 1 ? 's' : ''} to be a normal alias.` `Overwriting path alias with ${aliasDepl.rules.length} rule${aliasDepl
.rules.length > 1
? 's'
: ''} to be a normal alias.`
) )
} }
} }
@ -282,11 +298,15 @@ module.exports = class Alias extends Now {
) { ) {
shouldScaleDown = true shouldScaleDown = true
console.log( console.log(
`> Alias ${alias} points to ${chalk.bold(aliasedDeployment.url)} (${chalk.bold(aliasedDeployment.scale.current + ' instances')})` `> Alias ${alias} points to ${chalk.bold(
aliasedDeployment.url
)} (${chalk.bold(aliasedDeployment.scale.current + ' instances')})`
) )
// Test if we need to change the scale or just update the rules // Test if we need to change the scale or just update the rules
console.log( console.log(
`> Scaling ${depl.url} to ${chalk.bold(aliasedDeployment.scale.current + ' instances')} atomically` `> Scaling ${depl.url} to ${chalk.bold(
aliasedDeployment.scale.current + ' instances'
)} atomically`
) )
if (depl.scale.current !== aliasedDeployment.scale.current) { if (depl.scale.current !== aliasedDeployment.scale.current) {
if (depl.scale.max < 1) { if (depl.scale.max < 1) {
@ -340,12 +360,18 @@ module.exports = class Alias extends Now {
const newAlias = await this.createAlias(depl, alias) const newAlias = await this.createAlias(depl, alias)
if (!newAlias) { if (!newAlias) {
throw new Error( throw new Error(
`Unexpected error occurred while setting up alias: ${JSON.stringify(newAlias)}` `Unexpected error occurred while setting up alias: ${JSON.stringify(
newAlias
)}`
) )
} }
const { created, uid } = newAlias const { created, uid } = newAlias
if (created) { if (created) {
const output = `${chalk.cyan('> Success!')} ${alias} now points to ${chalk.bold(depl.url)}! ${chalk.grey('[' + ms(Date.now() - aliasTime) + ']')}` const output = `${chalk.cyan(
'> Success!'
)} ${alias} now points to ${chalk.bold(depl.url)}! ${chalk.grey(
'[' + ms(Date.now() - aliasTime) + ']'
)}`
if (isTTY && clipboard) { if (isTTY && clipboard) {
try { try {
await copy(depl.url) await copy(depl.url)
@ -358,14 +384,20 @@ module.exports = class Alias extends Now {
} }
} else { } else {
console.log( console.log(
`${chalk.cyan('> Success!')} Alias already exists ${chalk.dim(`(${uid})`)}.` `${chalk.cyan('> Success!')} Alias already exists ${chalk.dim(
`(${uid})`
)}.`
) )
} }
if (aliasedDeployment && shouldScaleDown) { if (aliasedDeployment && shouldScaleDown) {
const scaleDown = Date.now() const scaleDown = Date.now()
await this.setScale(aliasedDeployment.uid, { min: 0, max: 1 }) await this.setScale(aliasedDeployment.uid, { min: 0, max: 1 })
console.log( console.log(
`> Scaled ${chalk.gray(aliasedDeployment.url)} down to 1 instance ${chalk.gray('[' + ms(Date.now() - scaleDown) + ']')}` `> Scaled ${chalk.gray(
aliasedDeployment.url
)} down to 1 instance ${chalk.gray(
'[' + ms(Date.now() - scaleDown) + ']'
)}`
) )
} }
} }
@ -401,7 +433,9 @@ module.exports = class Alias extends Now {
if (code === 'custom_domain_needs_upgrade') { if (code === 'custom_domain_needs_upgrade') {
const err = new Error( const err = new Error(
`Custom domains are only enabled for premium accounts. Please upgrade by running ${chalk.gray('`')}${chalk.cyan('now upgrade')}${chalk.gray('`')}.` `Custom domains are only enabled for premium accounts. Please upgrade by running ${chalk.gray(
'`'
)}${chalk.cyan('now upgrade')}${chalk.gray('`')}.`
) )
err.userError = true err.userError = true
return bail(err) return bail(err)
@ -409,7 +443,9 @@ module.exports = class Alias extends Now {
if (code === 'alias_in_use') { if (code === 'alias_in_use') {
const err = new Error( const err = new Error(
`The alias you are trying to configure (${chalk.underline(chalk.bold(alias))}) is already in use by a different account.` `The alias you are trying to configure (${chalk.underline(
chalk.bold(alias)
)}) is already in use by a different account.`
) )
err.userError = true err.userError = true
return bail(err) return bail(err)
@ -436,7 +472,9 @@ module.exports = class Alias extends Now {
if (code === 'cert_missing') { if (code === 'cert_missing') {
console.log( console.log(
`> Provisioning certificate for ${chalk.underline(chalk.bold(alias))}` `> Provisioning certificate for ${chalk.underline(
chalk.bold(alias)
)}`
) )
try { try {
@ -571,7 +609,11 @@ module.exports = class Alias extends Now {
if (canBePurchased && price && period) { if (canBePurchased && price && period) {
const periodMsg = `${period}yr${period > 1 ? 's' : ''}` const periodMsg = `${period}yr${period > 1 ? 's' : ''}`
info( info(
`The domain ${aliasParam} is ${chalk.italic('available')} to buy under ${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)}! ${elapsed()}` `The domain ${aliasParam} is ${chalk.italic(
'available'
)} to buy under ${chalk.bold(
(currentTeam && currentTeam.slug) || user.username || user.email
)}! ${elapsed()}`
) )
const confirmation = await promptBool( const confirmation = await promptBool(
`Buy now for ${chalk.bold(`$${price}`)} (${periodMsg})?` `Buy now for ${chalk.bold(`$${price}`)} (${periodMsg})?`
@ -622,7 +664,9 @@ module.exports = class Alias extends Now {
} }
console.log( console.log(
`> Verifying the DNS settings for ${chalk.bold(chalk.underline(alias))} (see ${chalk.underline('https://zeit.world')} for help)` `> Verifying the DNS settings for ${chalk.bold(
chalk.underline(alias)
)} (see ${chalk.underline('https://zeit.world')} for help)`
) )
const _domain = publicSuffixList.parse(alias).domain const _domain = publicSuffixList.parse(alias).domain
@ -665,7 +709,9 @@ module.exports = class Alias extends Now {
throw e throw e
} }
console.log( console.log(
`${chalk.cyan('> Success!')} Domain ${chalk.bold(chalk.underline(domain))} verified` `${chalk.cyan('> Success!')} Domain ${chalk.bold(
chalk.underline(domain)
)} verified`
) )
} }
} }
@ -682,7 +728,9 @@ module.exports = class Alias extends Now {
try { try {
if (usingZeitWorld) { if (usingZeitWorld) {
console.log( console.log(
`> Detected ${chalk.bold(chalk.underline('zeit.world'))} nameservers! Configuring records.` `> Detected ${chalk.bold(
chalk.underline('zeit.world')
)} nameservers! Configuring records.`
) )
const record = alias.substr(0, alias.length - domain.length) const record = alias.substr(0, alias.length - domain.length)
@ -714,12 +762,14 @@ module.exports = class Alias extends Now {
} }
} else { } else {
console.log( console.log(
`> Resolved IP: ${err.ip ? `${chalk.underline(err.ip)} (unknown)` : chalk.dim('none')}` `> Resolved IP: ${err.ip
? `${chalk.underline(err.ip)} (unknown)`
: chalk.dim('none')}`
) )
console.log( console.log(
`> Nameservers: ${nameservers && nameservers.length ? nameservers `> Nameservers: ${nameservers && nameservers.length
.map(ns => chalk.underline(ns)) ? nameservers.map(ns => chalk.underline(ns)).join(', ')
.join(', ') : chalk.dim('none')}` : chalk.dim('none')}`
) )
throw err throw err
} }
@ -753,7 +803,9 @@ module.exports = class Alias extends Now {
throw e throw e
} }
console.log( console.log(
`${chalk.cyan('> Success!')} Domain ${chalk.bold(chalk.underline(domain))} ${chalk.dim(`(${uid})`)} added` `${chalk.cyan('> Success!')} Domain ${chalk.bold(
chalk.underline(domain)
)} ${chalk.dim(`(${uid})`)} added`
) )
} }
@ -802,8 +854,11 @@ module.exports = class Alias extends Now {
for (const ip of ips) { for (const ip of ips) {
if (targets.indexOf(ip) === -1) { if (targets.indexOf(ip) === -1) {
const err = new Error( const err = new Error(
`The domain ${domain} has an A record ${chalk.bold(ip)} that doesn't resolve to ${chalk.bold(chalk.underline('alias.zeit.co'))}.\n> ` + `The domain ${domain} has an A record ${chalk.bold(
DOMAIN_VERIFICATION_ERROR ip
)} that doesn't resolve to ${chalk.bold(
chalk.underline('alias.zeit.co')
)}.\n> ` + DOMAIN_VERIFICATION_ERROR
) )
err.ip = ip err.ip = ip
err.userError = true err.userError = true

4
lib/domains.js

@ -61,7 +61,9 @@ module.exports = class Domains extends Now {
ns = res.nameservers ns = res.nameservers
} catch (err) { } catch (err) {
const err2 = new Error( const err2 = new Error(
`Unable to fetch nameservers for ${chalk.underline(chalk.bold(domain))}.` `Unable to fetch nameservers for ${chalk.underline(
chalk.bold(domain)
)}.`
) )
err2.userError = true err2.userError = true
throw err2 throw err2

24
lib/errors.js

@ -1,16 +1,28 @@
// Packages // Packages
const chalk = require('chalk') const chalk = require('chalk')
const DNS_VERIFICATION_ERROR = `Please make sure that your nameservers point to ${chalk.underline('zeit.world')}. const DNS_VERIFICATION_ERROR = `Please make sure that your nameservers point to ${chalk.underline(
'zeit.world'
)}.
> Examples: (full list at ${chalk.underline('https://zeit.world')}) > Examples: (full list at ${chalk.underline('https://zeit.world')})
> ${chalk.gray('-')} ${chalk.underline('california.zeit.world')} ${chalk.dim('173.255.215.107')} > ${chalk.gray('-')} ${chalk.underline('california.zeit.world')} ${chalk.dim(
> ${chalk.gray('-')} ${chalk.underline('newark.zeit.world')} ${chalk.dim('173.255.231.87')} '173.255.215.107'
> ${chalk.gray('-')} ${chalk.underline('london.zeit.world')} ${chalk.dim('178.62.47.76')} )}
> ${chalk.gray('-')} ${chalk.underline('singapore.zeit.world')} ${chalk.dim('119.81.97.170')}` > ${chalk.gray('-')} ${chalk.underline('newark.zeit.world')} ${chalk.dim(
'173.255.231.87'
)}
> ${chalk.gray('-')} ${chalk.underline('london.zeit.world')} ${chalk.dim(
'178.62.47.76'
)}
> ${chalk.gray('-')} ${chalk.underline('singapore.zeit.world')} ${chalk.dim(
'119.81.97.170'
)}`
const DOMAIN_VERIFICATION_ERROR = const DOMAIN_VERIFICATION_ERROR =
DNS_VERIFICATION_ERROR + DNS_VERIFICATION_ERROR +
`\n> Alternatively, ensure it resolves to ${chalk.underline('alias.zeit.co')} via ${chalk.dim('CNAME')} / ${chalk.dim('ALIAS')}.` `\n> Alternatively, ensure it resolves to ${chalk.underline(
'alias.zeit.co'
)} via ${chalk.dim('CNAME')} / ${chalk.dim('ALIAS')}.`
module.exports = { module.exports = {
DNS_VERIFICATION_ERROR, DNS_VERIFICATION_ERROR,

3
lib/git.js

@ -148,7 +148,8 @@ const downloadRepo = async repoPath => {
break break
} }
case 'Bitbucket': case 'Bitbucket':
url = `https://bitbucket.org/${pathParts.main}/get/${pathParts.ref || 'default'}.zip` url = `https://bitbucket.org/${pathParts.main}/get/${pathParts.ref ||
'default'}.zip`
break break
default: default:
url = `https://api.github.com/repos/${pathParts.main}/tarball/${pathParts.ref}` url = `https://api.github.com/repos/${pathParts.main}/tarball/${pathParts.ref}`

24
lib/index.js

@ -186,7 +186,9 @@ module.exports = class Now extends EventEmitter {
if (res.status === 429) { if (res.status === 429) {
let msg = `You reached your 20 deployments limit in the OSS plan.\n` let msg = `You reached your 20 deployments limit in the OSS plan.\n`
msg += `${chalk.gray('>')} Please run ${chalk.gray('`')}${chalk.cyan('now upgrade')}${chalk.gray('`')} to proceed` msg += `${chalk.gray('>')} Please run ${chalk.gray('`')}${chalk.cyan(
'now upgrade'
)}${chalk.gray('`')} to proceed`
const err = new Error(msg) const err = new Error(msg)
err.status = res.status err.status = res.status
err.retryAfter = 'never' err.retryAfter = 'never'
@ -232,7 +234,9 @@ module.exports = class Now extends EventEmitter {
console.error( console.error(
`> \u001B[31mWarning!\u001B[39m ${sizeExceeded} of the files ` + `> \u001B[31mWarning!\u001B[39m ${sizeExceeded} of the files ` +
'exceeded the limit for your plan.\n' + 'exceeded the limit for your plan.\n' +
`> Please run ${chalk.gray('`')}${chalk.cyan('now upgrade')}${chalk.gray('`')} to upgrade.` `> Please run ${chalk.gray('`')}${chalk.cyan(
'now upgrade'
)}${chalk.gray('`')} to upgrade.`
) )
} }
} }
@ -245,7 +249,9 @@ module.exports = class Now extends EventEmitter {
) )
} else { } else {
console.log( console.log(
`> Using Node.js ${chalk.bold(deployment.nodeVersion)} (requested: ${chalk.dim(`\`${engines.node}\``)})` `> Using Node.js ${chalk.bold(
deployment.nodeVersion
)} (requested: ${chalk.dim(`\`${engines.node}\``)})`
) )
} }
} else { } else {
@ -482,7 +488,9 @@ module.exports = class Now extends EventEmitter {
console.time('> [debug] /logs') console.time('> [debug] /logs')
} }
const url = `/now/deployments/${encodeURIComponent(deploymentIdOrURL)}/logs?${q}` const url = `/now/deployments/${encodeURIComponent(
deploymentIdOrURL
)}/logs?${q}`
const res = await this._fetch(url) const res = await this._fetch(url)
if (this._debug) { if (this._debug) {
@ -592,7 +600,9 @@ module.exports = class Now extends EventEmitter {
} }
const res = await this._fetch( const res = await this._fetch(
`/whois-ns${fallback ? '-fallback' : ''}?domain=${encodeURIComponent(domain)}` `/whois-ns${fallback ? '-fallback' : ''}?domain=${encodeURIComponent(
domain
)}`
) )
if (this._debug) { if (this._debug) {
@ -663,7 +673,9 @@ module.exports = class Now extends EventEmitter {
if (code === 'custom_domain_needs_upgrade') { if (code === 'custom_domain_needs_upgrade') {
err = new Error( err = new Error(
`Custom domains are only enabled for premium accounts. Please upgrade at ${chalk.underline('https://zeit.co/account')}.` `Custom domains are only enabled for premium accounts. Please upgrade at ${chalk.underline(
'https://zeit.co/account'
)}.`
) )
} else { } else {
err = new Error(`Not authorized to access domain ${name}`) err = new Error(`Not authorized to access domain ${name}`)

4
lib/login.js

@ -80,7 +80,9 @@ async function register(url, { retryEmail = false } = {}) {
if (securityCode) { if (securityCode) {
console.log( console.log(
`> Verify that the provided security code in the email matches ${chalk.cyan(chalk.bold(securityCode))}.` `> Verify that the provided security code in the email matches ${chalk.cyan(
chalk.bold(securityCode)
)}.`
) )
} }

5
lib/re-alias.js

@ -99,8 +99,9 @@ exports.reAlias = async (
if (nowConfig.aliases && Array.isArray(nowConfig.aliases)) { if (nowConfig.aliases && Array.isArray(nowConfig.aliases)) {
console.log( console.log(
`${chalk.red('Deprecated!')} The property ${chalk.grey('aliases')} will be ` + `${chalk.red('Deprecated!')} The property ${chalk.grey(
`removed from the config file soon.` 'aliases'
)} will be removed from the config file soon.`
) )
console.log('Read more about the new way here: http://bit.ly/2l2v5Fg\n') console.log('Read more about the new way here: http://bit.ly/2l2v5Fg\n')

17
lib/scale-info.js

@ -35,8 +35,10 @@ module.exports = async function(now, url) {
let barcurr = current let barcurr = current
const end = Math.max(current, max) const end = Math.max(current, max)
linelog( linelog(
`${chalk.gray('>')} Scaling to ${chalk.bold(String(targetReplicaCount) + (targetReplicaCount === 1 ? ' instance' : ' instances'))}: ` + `${chalk.gray('>')} Scaling to ${chalk.bold(
barify(barcurr, end) String(targetReplicaCount) +
(targetReplicaCount === 1 ? ' instance' : ' instances')
)}: ` + barify(barcurr, end)
) )
const instances = await retry( const instances = await retry(
@ -45,14 +47,19 @@ module.exports = async function(now, url) {
if (barcurr !== res.length) { if (barcurr !== res.length) {
barcurr = res.length barcurr = res.length
linelog( linelog(
`${chalk.gray('>')} Scaling to ${chalk.bold(String(targetReplicaCount) + (targetReplicaCount === 1 ? ' instance' : ' instances'))}: ` + `${chalk.gray('>')} Scaling to ${chalk.bold(
barify(barcurr, end) String(targetReplicaCount) +
(targetReplicaCount === 1 ? ' instance' : ' instances')
)}: ` + barify(barcurr, end)
) )
if (barcurr === targetReplicaCount) { if (barcurr === targetReplicaCount) {
linelog.clear() linelog.clear()
linelog( linelog(
`> Scaled to ${chalk.bold(String(targetReplicaCount) + (targetReplicaCount === 1 ? ' instance' : ' instances'))}: ${chalk.gray('[' + ms(Date.now() - startTime) + ']')}\n` `> Scaled to ${chalk.bold(
String(targetReplicaCount) +
(targetReplicaCount === 1 ? ' instance' : ' instances')
)}: ${chalk.gray('[' + ms(Date.now() - startTime) + ']')}\n`
) )
return res return res
} }

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

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

2
package.json

@ -95,7 +95,7 @@
"node-fetch": "1.7.1", "node-fetch": "1.7.1",
"ora": "1.2.0", "ora": "1.2.0",
"pkg": "3.0.6", "pkg": "3.0.6",
"prettier": "1.3.1", "prettier": "1.4.1",
"printf": "0.2.5", "printf": "0.2.5",
"progress": "2.0.0", "progress": "2.0.0",
"psl": "1.1.18", "psl": "1.1.18",

Loading…
Cancel
Save