Browse Source

Add a flag for skipping DNS verification (#94)

Some registrars requires that the DNS records are already setup
before delegating the domain to a nameserver.
master
Olli Vanhoja 8 years ago
committed by Tony Kovanen
parent
commit
530a9fb357
  1. 6
      bin/now-domains.js
  2. 6
      lib/domains.js

6
bin/now-domains.js

@ -16,11 +16,12 @@ import NowDomains from '../lib/domains'
const argv = minimist(process.argv.slice(2), { const argv = minimist(process.argv.slice(2), {
string: ['config', 'token'], string: ['config', 'token'],
boolean: ['help', 'debug'], boolean: ['help', 'debug', 'force'],
alias: { alias: {
help: 'h', help: 'h',
config: 'c', config: 'c',
debug: 'd', debug: 'd',
force: 'f',
token: 't' token: 't'
} }
}) })
@ -36,6 +37,7 @@ const help = () => {
-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]
-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:')}
@ -207,7 +209,7 @@ async function run(token) {
const start = new Date() const start = new Date()
const name = String(args[0]) const name = String(args[0])
const {uid, created} = await domain.add(name) const {uid, created} = await domain.add(name, argv.force)
const elapsed = ms(new Date() - start) const elapsed = ms(new Date() - start)
if (created) { if (created) {
console.log(`${chalk.cyan('> Success!')} Domain ${chalk.bold(chalk.underline(name))} ${chalk.dim(`(${uid})`)} added [${elapsed}]`) console.log(`${chalk.cyan('> Success!')} Domain ${chalk.bold(chalk.underline(name))} ${chalk.dim(`(${uid})`)} added [${elapsed}]`)

6
lib/domains.js

@ -50,13 +50,17 @@ export default class Domains extends Now {
}) })
} }
async add(domain) { async add(domain, skipVerification) {
if (!domainRegex.test(domain)) { if (!domainRegex.test(domain)) {
const err = new Error(`The supplied value ${chalk.bold(`"${domain}"`)} is not a valid domain.`) const err = new Error(`The supplied value ${chalk.bold(`"${domain}"`)} is not a valid domain.`)
err.userError = true err.userError = true
throw err throw err
} }
if (skipVerification) {
return this.setupDomain(domain)
}
let ns let ns
try { try {

Loading…
Cancel
Save