@ -1,7 +1,7 @@
#!/usr/bin/env node
// Native
const { resolve } = require ( 'path' )
const { resolve } = require ( 'path' ) ;
// Packages
const chalk = require ( 'chalk' ) ;
@ -38,7 +38,7 @@ const subcommand = argv._[0];
const help = ( ) => {
console . log (
`
$ { chalk . bold ( ` ${ logo } now domains ` ) } < ls | add | rm > < domain >
$ { chalk . bold ( ` ${ logo } now domains ` ) } < ls | add | rm | buy > < domain >
$ { chalk . dim ( 'Options:' ) }
@ -55,9 +55,13 @@ const help = () => {
$ { chalk . cyan ( '$ now domains ls' ) }
$ { chalk . gray ( '–' ) } Buy a new domain :
$ { chalk . cyan ( ` $ now domains buy ${ chalk . underline ( 'domain-name.com' ) } ` ) }
$ { chalk . gray ( '–' ) } Adds a domain name :
$ { chalk . cyan ( ` $ now domains add ${ chalk . underline ( 'my-app.com' ) } ` ) }
$ { chalk . cyan ( ` $ now domains add ${ chalk . underline ( 'domain-name .com' ) } ` ) }
Make sure the domain ' s DNS nameservers are at least 2 of these :
@ -125,7 +129,7 @@ if (argv.help || !subcommand) {
exit ( 1 ) ;
}
try {
await run ( { token , config } ) ;
await run ( { token , config } ) ;
} catch ( err ) {
if ( err . userError ) {
error ( err . message ) ;
@ -137,8 +141,8 @@ if (argv.help || !subcommand) {
} ) ;
}
async function run ( { token , config : { currentTeam , user } } ) {
const domain = new NowDomains ( { apiUrl , token , debug , currentTeam } ) ;
async function run ( { token , config : { currentTeam , user } } ) {
const domain = new NowDomains ( { apiUrl , token , debug , currentTeam } ) ;
const args = argv . _ . slice ( 1 ) ;
switch ( subcommand ) {
@ -154,7 +158,9 @@ async function run({token, config: {currentTeam, user}}) {
domains . sort ( ( a , b ) => new Date ( b . created ) - new Date ( a . created ) ) ;
const current = new Date ( ) ;
const header = [
[ '' , 'id' , 'dns' , 'domain' , 'verified' , 'created' ] . map ( s => chalk . dim ( s ) )
[ '' , 'id' , 'dns' , 'domain' , 'verified' , 'created' ] . map ( s =>
chalk . dim ( s )
)
] ;
const out = domains . length === 0
? null
@ -178,11 +184,7 @@ 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 ) {
@ -274,7 +276,12 @@ async function run({token, config: {currentTeam, user}}) {
break ;
}
case 'buy' : {
await require ( resolve ( __ dirname , 'domains' , 'buy.js' ) ) ( { domains : domain , args , currentTeam , user } ) ;
await require ( resolve ( __ dirname , 'domains' , 'buy.js' ) ) ( {
domains : domain ,
args ,
currentTeam ,
user
} ) ;
break ;
}
default :