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. 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' : ''}`
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(
`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()}`)
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:')}
-h, --help Output usage information
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file
-r ${chalk.bold.underline('RULES_FILE')}, --rules=${chalk.bold.underline('RULES_FILE')} Rules file
-c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
'FILE'
)} Config file
-r ${chalk.bold.underline('RULES_FILE')}, --rules=${chalk.bold.underline(
'RULES_FILE'
)} Rules file
-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:')}
@ -61,7 +67,11 @@ const help = () => {
${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:
@ -73,18 +83,34 @@ const help = () => {
Custom domains work as alias targets:
${chalk.cyan(`$ now alias set ${chalk.underline('api-ownv3nc9f8.now.sh')} ${chalk.underline('my-api.com')}`)}
${chalk.dim('–')} The subcommand ${chalk.dim('`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')}`)}
${chalk.cyan(
`$ now alias set ${chalk.underline(
'api-ownv3nc9f8.now.sh'
)} ${chalk.underline('my-api.com')}`
)}
${chalk.dim('–')} The subcommand ${chalk.dim(
'`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:
${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`)}
@ -207,7 +233,11 @@ async function run({ token, config: { currentTeam, user } }) {
}, 0) + 8
const elapsed_ = ms(new Date() - start_)
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()
@ -254,7 +284,9 @@ async function run({ token, config: { currentTeam, user } }) {
}
} else if (_alias.rules) {
_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) {
urlSpec += underlineWidth
@ -286,7 +318,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (args.length !== 1) {
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)
}
@ -296,7 +330,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (!_alias) {
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
throw err
@ -313,7 +349,9 @@ async function run({ token, config: { currentTeam, user } }) {
await alias.rm(_alias)
const elapsed = ms(new Date() - start)
console.log(
`${chalk.cyan('> Success!')} Alias ${chalk.bold(_alias.uid)} removed [${elapsed}]`
`${chalk.cyan('> Success!')} Alias ${chalk.bold(
_alias.uid
)} removed [${elapsed}]`
)
} catch (err) {
error(err)
@ -330,7 +368,9 @@ async function run({ token, config: { currentTeam, user } }) {
}
if (args.length !== 2) {
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)
}
@ -475,7 +515,11 @@ async function updatePathAlias(alias, aliasName, rules, domains) {
throw err
} else {
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 }) {
const state = {
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: {
label: rightPad('Full Name', 12),
@ -195,13 +199,18 @@ module.exports = function({ creditCards, currentTeam, user }) {
})
stopSpinner()
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) {
stopSpinner()
const linesToClear = state.error ? 13 : 12
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()
}
}

40
bin/now-billing.js

@ -40,9 +40,13 @@ const help = () => {
${chalk.dim('Options:')}
-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]
-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:')}
@ -153,7 +157,9 @@ async function run({ token, config: { currentTeam, user } }) {
const _default = card.id === cards.defaultCardId
? ' ' + 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}`
let address = card.address_line1
@ -184,7 +190,11 @@ async function run({ token, config: { currentTeam, user } }) {
const elapsed = ms(new Date() - start)
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) {
console.log(`\n${text}\n`)
@ -218,7 +228,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (cardId === undefined) {
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)
cardId = await listInput({
@ -246,7 +258,9 @@ async function run({ token, config: { currentTeam, user } }) {
const card = cards.cards.find(card => card.id === cardId)
const elapsed = ms(new Date() - start)
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 {
console.log('No changes made')
@ -273,7 +287,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (cards.cards.length === 0) {
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)
}
@ -282,7 +298,11 @@ async function run({ token, config: { currentTeam, user } }) {
if (cardId === undefined) {
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)
cardId = await listInput({
@ -322,7 +342,9 @@ async function run({ token, config: { currentTeam, user } }) {
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:')}
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:')}
-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]
-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
--key ${chalk.bold.underline('FILE')} Certificate key file
--ca ${chalk.bold.underline('FILE')} CA certificate chain file
@ -58,13 +64,19 @@ const help = () => {
${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.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)
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) {
@ -167,7 +183,9 @@ async function run({ token, config: { currentTeam, user } }) {
} else if (subcommand === 'create') {
if (args.length !== 1) {
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)
}
@ -178,7 +196,9 @@ async function run({ token, config: { currentTeam, user } }) {
// Issue a custom certificate
if (!argv.crt || !argv.key) {
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)
}
@ -198,12 +218,16 @@ async function run({ token, config: { currentTeam, user } }) {
}
const elapsed = ms(new Date() - start)
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') {
if (args.length !== 1) {
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)
}
@ -225,12 +249,16 @@ async function run({ token, config: { currentTeam, user } }) {
await certs.renew(cert.cn)
const elapsed = ms(new Date() - start)
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') {
if (!argv.crt || !argv.key) {
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)
}
@ -255,12 +283,16 @@ async function run({ token, config: { currentTeam, user } }) {
await certs.put(cert.cn, crt, key, ca)
const elapsed = ms(new Date() - start)
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') {
if (args.length !== 1) {
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)
}
@ -281,7 +313,9 @@ async function run({ token, config: { currentTeam, user } }) {
await certs.delete(cert.cn)
const elapsed = ms(new Date() - start)
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 {
error(
@ -334,7 +368,9 @@ async function getCertIdCn(certs, idOrCn, currentTeam, user) {
if (!thecert) {
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
}

101
bin/now-deploy.js

@ -81,7 +81,9 @@ const help = () => {
${chalk.dim('Cloud')}
deploy [path] Performs a deployment ${chalk.bold('(default)')}
deploy [path] Performs a deployment ${chalk.bold(
'(default)'
)}
ls | list [app] List deployments
rm | remove [id] Remove a deployment
ln | alias [id] [url] Configures aliases for deployments
@ -107,20 +109,32 @@ const help = () => {
-h, --help Output usage information
-v, --version Output the version number
-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]
-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, --links Copy symlinks without resolving their target
-p, --public Deployment is public (${chalk.dim('`/_src`')} 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'
-p, --public Deployment is public (${chalk.dim(
'`/_src`'
)} 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
-N, --forward-npm Forward login information to install private npm modules
--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
--docker Docker container
@ -146,9 +160,13 @@ const help = () => {
${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')}
`)
@ -191,7 +209,9 @@ if (argv.config) {
if (Array.isArray(autoAliases)) {
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')
}
@ -235,7 +255,9 @@ async function main() {
`> Logged in successfully. Token saved to ${chalk.bold('~/.now.json')}.`
)
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)
}
@ -300,7 +322,9 @@ async function sync({ token, config: { currentTeam, user } }) {
} else if (isValidRepo) {
const gitRef = gitRepo.ref ? `with "${chalk.bold(gitRepo.ref)}" ` : ''
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 {
stopDeployment(`Could not read directory ${chalk.bold(path)}`)
@ -319,11 +343,17 @@ async function sync({ token, config: { currentTeam, user } }) {
if (gitRepo.main) {
const gitRef = gitRepo.ref ? ` at "${chalk.bold(gitRepo.ref)}" ` : ''
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 {
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)) {
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)
}
@ -433,13 +465,17 @@ async function sync({ token, config: { currentTeam, user } }) {
if (val === undefined) {
if (key in process.env) {
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 @
val = process.env[key].replace(/^@/, '\\@')
} else {
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)
}
@ -451,7 +487,9 @@ async function sync({ token, config: { currentTeam, user } }) {
if (secrets.length === 0) {
if (uidOrName === '') {
error(
`Empty reference provided for env key ${chalk.bold(`"${chalk.bold(key)}"`)}`
`Empty reference provided for env key ${chalk.bold(
`"${chalk.bold(key)}"`
)}`
)
} else {
error(
@ -461,7 +499,9 @@ async function sync({ token, config: { currentTeam, user } }) {
return process.exit(1)
} else if (secrets.length > 1) {
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)
}
@ -515,7 +555,9 @@ async function sync({ token, config: { currentTeam, user } }) {
try {
await copy(url)
console.log(
`${chalk.cyan('> Ready!')} ${chalk.bold(url)} (copied to clipboard) [${elapsed}]`
`${chalk.cyan('> Ready!')} ${chalk.bold(
url
)} (copied to clipboard) [${elapsed}]`
)
} catch (err) {
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 (isTTY) {
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(
@ -589,7 +636,9 @@ async function sync({ token, config: { currentTeam, user } }) {
)
}
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(
`> Upload [:bar] :percent :etas (${size}) [${syncCount}]`,
{
@ -680,7 +729,9 @@ async function readMeta(path, deploymentName, deploymentType, sessionAffinity) {
}
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([
@ -708,7 +759,9 @@ function printLogs(host, token, currentTeam, user) {
if (!quiet) {
if (err && err.type === 'BUILD_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 {
error('Deployment failed')

56
bin/now-dns.js

@ -33,17 +33,25 @@ const subcommand = argv._[0]
const help = () => {
console.log(`
${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> 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.dim('Options:')}
-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]
-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:')}
@ -53,12 +61,16 @@ const help = () => {
${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.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')}
`)
}
@ -102,7 +114,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (subcommand === 'ls' || subcommand === 'list') {
if (args.length > 1) {
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)
}
@ -152,21 +166,33 @@ async function run({ token, config: { currentTeam, user } }) {
}
})
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(''))
} else if (subcommand === 'add') {
const param = parseAddArgs(args)
if (!param) {
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)
}
const record = await domainRecords.create(param.domain, param.data)
const elapsed = ms(new Date() - start)
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') {
if (args.length !== 1) {
@ -194,7 +220,9 @@ async function run({ token, config: { currentTeam, user } }) {
await domainRecords.delete(record.domain, record.id)
const elapsed = ms(new Date() - start)
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 {
error('Please specify a valid subcommand: ls | add | rm')
@ -281,7 +309,11 @@ function readConfirmation(record, msg) {
[
record.id,
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
]

98
bin/now-domains.js

@ -42,11 +42,15 @@ const help = () => {
${chalk.dim('Options:')}
-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]
-e, --external Use external DNS server
-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:')}
@ -64,19 +68,43 @@ const help = () => {
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('london.zeit.world')} ${chalk.dim('178.62.47.76')}
${chalk.gray('–')} ${chalk.underline('newark.zeit.world')} ${chalk.dim('173.255.231.87')}
${chalk.gray('–')} ${chalk.underline('amsterdam.zeit.world')} ${chalk.dim('188.226.197.55')}
${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`')}).
${chalk.gray('–')} ${chalk.underline(
'california.zeit.world'
)} ${chalk.dim('173.255.215.107')}
${chalk.gray('–')} ${chalk.underline(
'london.zeit.world'
)} ${chalk.dim('178.62.47.76')}
${chalk.gray('–')} ${chalk.underline(
'newark.zeit.world'
)} ${chalk.dim('173.255.231.87')}
${chalk.gray('–')} ${chalk.underline(
'amsterdam.zeit.world'
)} ${chalk.dim('188.226.197.55')}
${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')}.
@ -90,13 +118,17 @@ const help = () => {
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')}
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')}
@ -180,7 +212,11 @@ async function run({ token, config: { currentTeam, user } }) {
const elapsed_ = ms(new Date() - start_)
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) {
@ -208,7 +244,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (!_domain) {
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
throw err
@ -229,7 +267,9 @@ async function run({ token, config: { currentTeam, user } }) {
await domain.rm(_domain.name)
const elapsed = ms(new Date() - start)
console.log(
`${chalk.cyan('> Success!')} Domain ${chalk.bold(_domain.uid)} removed [${elapsed}]`
`${chalk.cyan('> Success!')} Domain ${chalk.bold(
_domain.uid
)} removed [${elapsed}]`
)
} catch (err) {
error(err)
@ -254,15 +294,21 @@ async function run({ token, config: { currentTeam, user } }) {
const elapsed = ms(new Date() - start)
if (created) {
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) {
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') {
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 {
console.log(
@ -303,7 +349,11 @@ async function readConfirmation(domain, _domain) {
if (_domain.aliases.length > 0) {
process.stdout.write(
`> ${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`
)
}

22
bin/now-list.js

@ -34,9 +34,13 @@ const help = () => {
${chalk.dim('Options:')}
-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]
-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:')}
@ -145,7 +149,11 @@ async function list({ token, config: { currentTeam, user } }) {
}, 0) + 5
const timeNow = new Date()
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
@ -161,14 +169,18 @@ async function list({ token, config: { currentTeam, user } }) {
}
if (!argv.all && shouldShowAllInfo) {
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()
sorted.forEach(([name, deps]) => {
const listedDeployments = argv.all ? deps : deps.slice(0, 5)
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`
console.log(

4
bin/now-logout.js

@ -26,7 +26,9 @@ const help = () => {
${chalk.dim('Options:')}
-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:')}

24
bin/now-logs.js

@ -36,18 +36,30 @@ const help = () => {
-h, --help output usage information
-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]
-f wait for additional data [off]
-n ${chalk.bold.underline('NUMBER')} number of logs [1000]
-q ${chalk.bold.underline('QUERY')}, --query=${chalk.bold.underline('QUERY')} search query
-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.
-q ${chalk.bold.underline('QUERY')}, --query=${chalk.bold.underline(
'QUERY'
)} search query
-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.gray('–')} Print logs for the deployment ${chalk.dim('`deploymentId`')}
${chalk.gray('–')} Print logs for the deployment ${chalk.dim(
'`deploymentId`'
)}
${chalk.cyan('$ now logs deploymentId')}
`)

28
bin/now-remove.js

@ -31,20 +31,28 @@ const ids = argv._
// Options
const help = () => {
console.log(`
${chalk.bold(`${logo} now remove`)} deploymentId|deploymentName [...deploymentId|deploymentName]
${chalk.bold(
`${logo} now remove`
)} deploymentId|deploymentName [...deploymentId|deploymentName]
${chalk.dim('Options:')}
-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]
-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
--safe Skip deployments with an active alias
${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')}
@ -52,7 +60,9 @@ const help = () => {
${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')}
@ -97,7 +107,9 @@ Promise.resolve().then(async () => {
function readConfirmation(matches) {
return new Promise(resolve => {
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(
@ -118,7 +130,9 @@ function readConfirmation(matches) {
}
process.stdout.write(
`> ${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:')}
-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]
${chalk.dim('Examples:')}
@ -53,15 +55,21 @@ const help = () => {
${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.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.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')}
`)
@ -246,7 +254,9 @@ function printScaleingRules(url, currentReplicas, min, max, elapsed) {
)
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', 'max', chalk.bold(max)))
@ -284,7 +294,9 @@ async function list(scale) {
for (const app of sorted) {
const depls = argv.all ? app[1] : app[1].slice(0, 5)
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()
const urlSpec = `%-${urlLength}s`

54
bin/now-secrets.js

@ -38,9 +38,13 @@ const help = () => {
-h, --help Output usage information
-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]
-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:')}
@ -52,15 +56,21 @@ const help = () => {
${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('–')} If the secret's value is more than one word, wrap it in quotes
${chalk.gray(
'–'
)} 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('–')} Exposes a secret as an env variable:
${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:
@ -121,7 +131,11 @@ async function run({ token, config: { currentTeam, user } }) {
const elapsed = ms(new Date() - start)
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) {
@ -155,7 +169,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (subcommand === 'rm' || subcommand === 'remove') {
if (args.length !== 1) {
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)
}
@ -178,7 +194,9 @@ async function run({ token, config: { currentTeam, user } }) {
const secret = await secrets.rm(args[0])
const elapsed = ms(new Date() - start)
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()
}
@ -186,14 +204,20 @@ async function run({ token, config: { currentTeam, user } }) {
if (subcommand === 'rename') {
if (args.length !== 2) {
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)
}
const secret = await secrets.rename(args[0], args[1])
const elapsed = ms(new Date() - start)
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()
}
@ -201,7 +225,9 @@ async function run({ token, config: { currentTeam, user } }) {
if (subcommand === 'add' || subcommand === 'set') {
if (args.length !== 2) {
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) {
@ -227,7 +253,11 @@ async function run({ token, config: { currentTeam, user } }) {
const elapsed = ms(new Date() - start)
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()
}

12
bin/now-teams.js

@ -36,9 +36,13 @@ const help = () => {
${chalk.dim('Options:')}
-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]
-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:')}
@ -52,7 +56,9 @@ const help = () => {
${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):

28
bin/now-upgrade.js

@ -37,9 +37,13 @@ const help = () => {
${chalk.dim('Options:')}
-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]
-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:')}
@ -47,7 +51,9 @@ const help = () => {
${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`)}
@ -187,7 +193,9 @@ async function run({ token, config: { currentTeam, user } }) {
message = currentTeam
? `${message}/${currentTeam.slug}/settings/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)
planId = await listInput({
@ -212,7 +220,9 @@ async function run({ token, config: { currentTeam, user } }) {
} catch (err) {
if (err.code === 'customer_not_found' || err.code === 'source_not_found') {
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 {
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') {
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) {
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 {
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:')}
-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]
-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:')}

8
bin/now.js

@ -31,8 +31,12 @@ if (process.pkg) {
const update = notifier.update
if (update) {
let message = `Update available! ${chalk.red(update.current)}${chalk.green(update.latest)} \n`
message += `${chalk.magenta('Changelog:')} https://github.com/zeit/now-cli/releases/tag/${update.latest}\n`
let message = `Update available! ${chalk.red(
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) {
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() {
console.log() // Blank line
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()
}
@ -122,8 +124,11 @@ module.exports = async function({ teams, token }) {
teams,
args: [],
token,
introMsg: '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')}`
introMsg:
'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()

4
bin/teams/invite.js

@ -68,7 +68,9 @@ module.exports = async function(
domains.push(user.email.split('@')[1])
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.`
return fatalError(err)
}

109
lib/alias.js

@ -41,7 +41,9 @@ module.exports = class Alias extends Now {
if (!target) {
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
throw err
@ -146,7 +148,9 @@ module.exports = class Alias extends Now {
if (code === 'custom_domain_needs_upgrade') {
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
return bail(err)
@ -154,7 +158,9 @@ module.exports = class Alias extends Now {
if (code === 'alias_in_use') {
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
return bail(err)
@ -177,7 +183,9 @@ module.exports = class Alias extends Now {
if (code === 'cert_missing') {
console.log(
`> Provisioning certificate for ${chalk.underline(chalk.bold(alias))}`
`> Provisioning certificate for ${chalk.underline(
chalk.bold(alias)
)}`
)
try {
@ -236,7 +244,9 @@ module.exports = class Alias extends Now {
const depl = await this.findDeployment(deployment)
if (!depl) {
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
throw err
@ -247,7 +257,10 @@ module.exports = class Alias extends Now {
if (isTTY) {
try {
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`
const confirmation = await promptBool(msg, {
@ -263,7 +276,10 @@ module.exports = class Alias extends Now {
}
} else {
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
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
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.max < 1) {
@ -340,12 +360,18 @@ module.exports = class Alias extends Now {
const newAlias = await this.createAlias(depl, alias)
if (!newAlias) {
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
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) {
try {
await copy(depl.url)
@ -358,14 +384,20 @@ module.exports = class Alias extends Now {
}
} else {
console.log(
`${chalk.cyan('> Success!')} Alias already exists ${chalk.dim(`(${uid})`)}.`
`${chalk.cyan('> Success!')} Alias already exists ${chalk.dim(
`(${uid})`
)}.`
)
}
if (aliasedDeployment && shouldScaleDown) {
const scaleDown = Date.now()
await this.setScale(aliasedDeployment.uid, { min: 0, max: 1 })
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') {
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
return bail(err)
@ -409,7 +443,9 @@ module.exports = class Alias extends Now {
if (code === 'alias_in_use') {
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
return bail(err)
@ -436,7 +472,9 @@ module.exports = class Alias extends Now {
if (code === 'cert_missing') {
console.log(
`> Provisioning certificate for ${chalk.underline(chalk.bold(alias))}`
`> Provisioning certificate for ${chalk.underline(
chalk.bold(alias)
)}`
)
try {
@ -571,7 +609,11 @@ module.exports = class Alias extends Now {
if (canBePurchased && price && period) {
const periodMsg = `${period}yr${period > 1 ? 's' : ''}`
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(
`Buy now for ${chalk.bold(`$${price}`)} (${periodMsg})?`
@ -622,7 +664,9 @@ module.exports = class Alias extends Now {
}
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
@ -665,7 +709,9 @@ module.exports = class Alias extends Now {
throw e
}
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 {
if (usingZeitWorld) {
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)
@ -714,12 +762,14 @@ module.exports = class Alias extends Now {
}
} else {
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(
`> Nameservers: ${nameservers && nameservers.length ? nameservers
.map(ns => chalk.underline(ns))
.join(', ') : chalk.dim('none')}`
`> Nameservers: ${nameservers && nameservers.length
? nameservers.map(ns => chalk.underline(ns)).join(', ')
: chalk.dim('none')}`
)
throw err
}
@ -753,7 +803,9 @@ module.exports = class Alias extends Now {
throw e
}
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) {
if (targets.indexOf(ip) === -1) {
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> ` +
DOMAIN_VERIFICATION_ERROR
`The domain ${domain} has an A record ${chalk.bold(
ip
)} that doesn't resolve to ${chalk.bold(
chalk.underline('alias.zeit.co')
)}.\n> ` + DOMAIN_VERIFICATION_ERROR
)
err.ip = ip
err.userError = true

4
lib/domains.js

@ -61,7 +61,9 @@ module.exports = class Domains extends Now {
ns = res.nameservers
} catch (err) {
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
throw err2

24
lib/errors.js

@ -1,16 +1,28 @@
// Packages
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')})
> ${chalk.gray('-')} ${chalk.underline('california.zeit.world')} ${chalk.dim('173.255.215.107')}
> ${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')}`
> ${chalk.gray('-')} ${chalk.underline('california.zeit.world')} ${chalk.dim(
'173.255.215.107'
)}
> ${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 =
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 = {
DNS_VERIFICATION_ERROR,

3
lib/git.js

@ -148,7 +148,8 @@ const downloadRepo = async repoPath => {
break
}
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
default:
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) {
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)
err.status = res.status
err.retryAfter = 'never'
@ -232,7 +234,9 @@ module.exports = class Now extends EventEmitter {
console.error(
`> \u001B[31mWarning!\u001B[39m ${sizeExceeded} of the files ` +
'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 {
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 {
@ -482,7 +488,9 @@ module.exports = class Now extends EventEmitter {
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)
if (this._debug) {
@ -592,7 +600,9 @@ module.exports = class Now extends EventEmitter {
}
const res = await this._fetch(
`/whois-ns${fallback ? '-fallback' : ''}?domain=${encodeURIComponent(domain)}`
`/whois-ns${fallback ? '-fallback' : ''}?domain=${encodeURIComponent(
domain
)}`
)
if (this._debug) {
@ -663,7 +673,9 @@ module.exports = class Now extends EventEmitter {
if (code === 'custom_domain_needs_upgrade') {
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 {
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) {
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)) {
console.log(
`${chalk.red('Deprecated!')} The property ${chalk.grey('aliases')} will be ` +
`removed from the config file soon.`
`${chalk.red('Deprecated!')} The property ${chalk.grey(
'aliases'
)} will be removed from the config file soon.`
)
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
const end = Math.max(current, max)
linelog(
`${chalk.gray('>')} Scaling to ${chalk.bold(String(targetReplicaCount) + (targetReplicaCount === 1 ? ' instance' : ' instances'))}: ` +
barify(barcurr, end)
`${chalk.gray('>')} Scaling to ${chalk.bold(
String(targetReplicaCount) +
(targetReplicaCount === 1 ? ' instance' : ' instances')
)}: ` + barify(barcurr, end)
)
const instances = await retry(
@ -45,14 +47,19 @@ module.exports = async function(now, url) {
if (barcurr !== res.length) {
barcurr = res.length
linelog(
`${chalk.gray('>')} Scaling to ${chalk.bold(String(targetReplicaCount) + (targetReplicaCount === 1 ? ' instance' : ' instances'))}: ` +
barify(barcurr, end)
`${chalk.gray('>')} Scaling to ${chalk.bold(
String(targetReplicaCount) +
(targetReplicaCount === 1 ? ' instance' : ' instances')
)}: ` + barify(barcurr, end)
)
if (barcurr === targetReplicaCount) {
linelog.clear()
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
}

2
package.json

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

Loading…
Cancel
Save