Skip to content

Commit

Permalink
update auth commands for new diffy
Browse files Browse the repository at this point in the history
  • Loading branch information
joehand committed Jul 5, 2018
1 parent c1dde60 commit 0e8a19c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions src/commands/auth/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ function login (opts) {
var Registry = require('../../registry')

if (opts._[0]) opts.server = opts._[0]
var welcome = output`
var welcome = output(`
Welcome to ${chalk.green(`dat`)} program!
Login to publish your dats.
`
`)
console.log(welcome)

var schema = {
Expand Down Expand Up @@ -70,13 +70,13 @@ function login (opts) {
if (err && err.message) return exitErr(err.message)
else if (err) return exitErr(err.toString())

console.log(output`
console.log(output(`
Logged you in to ${chalk.green(opts.server)}!
Now you can publish dats and share:
* Run ${chalk.green(`dat publish`)} to publish a dat!
* View & Share your dats at ${opts.server}
`)
`))
process.exit(0)
})
}
Expand Down
8 changes: 4 additions & 4 deletions src/commands/auth/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ function register (opts) {

// TODO: check if logged in?
if (opts._[0]) opts.server = opts._[0]
var welcome = output`
var welcome = output(`
Welcome to ${chalk.green(`dat`)} program!
Create a new account with a Dat registry.
`
`)
console.log(welcome)

var schema = {
Expand Down Expand Up @@ -76,11 +76,11 @@ function register (opts) {
}, function (err) {
if (err && err.message) return exitErr(err.message)
else if (err) return exitErr(err.toString())
console.log(output`
console.log(output(`
Created account on ${chalk.green(opts.server)}!
Login to start publishing: ${chalk.green(`dat login`)}
`)
`))
process.exit(0)
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/auth/whoami.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function whoami (opts) {
if (!opts.server) return exitErr('No login information found.')
return exitErr('No login information found for that server.')
}
console.log(output`
console.log(output(`
Your active Dat registry information:
---
Expand All @@ -39,7 +39,7 @@ function whoami (opts) {
Change your registry by logging in again:
${chalk.dim.green('dat login <registry-url>')}
`)
`))
process.exit(0)
}

Expand Down
24 changes: 12 additions & 12 deletions src/commands/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function publish (opts) {
var client = Registry(opts)
var whoami = client.whoami()
if (!whoami || !whoami.token) {
var loginErr = output`
var loginErr = output(`
Welcome to ${chalk.green(`dat`)} program!
Publish your dats to ${chalk.green(opts.server)}.
Expand All @@ -45,7 +45,7 @@ function publish (opts) {
${chalk.green('dat register')}
Explore public dats at ${chalk.blue('datbase.org/explore')}
`
`)
return exitErr(loginErr)
}

Expand All @@ -69,10 +69,10 @@ function publish (opts) {
title: opts.title,
description: opts.description
}, data)
var welcome = output`
var welcome = output(`
Publishing dat to ${chalk.green(opts.server)}!
`
`)
console.log(welcome)

if (datInfo.name) return makeRequest(datInfo)
Expand Down Expand Up @@ -101,9 +101,9 @@ function publish (opts) {
if (err) {
if (err.message) {
if (err.message === 'timed out') {
return exitErr(output`${chalk.red('\nERROR: ' + opts.server + ' could not connect to your computer.')}
return exitErr(output(`${chalk.red('\nERROR: ' + opts.server + ' could not connect to your computer.')}
Troubleshoot here: ${chalk.green('https://docs.datproject.org/troubleshooting#networking-issues')}
`)
`))
}
var str = err.message.trim()
if (str === 'jwt expired') return exitErr(`Session expired, please ${chalk.green('dat login')} again`)
Expand All @@ -118,26 +118,26 @@ function publish (opts) {
datjson.write(datInfo, function (err) {
if (err) return exitErr(err)
// TODO: write published url to dat.json (need spec)
var msg = output`
var msg = output(`
We ${body.updated === 1 ? 'updated' : 'published'} your dat!
${chalk.blue.underline(`${opts.server}/${whoami.username}/${datInfo.name}`)}
`// TODO: get url back? it'd be better to confirm link than guess username/datname structure
`)// TODO: get url back? it'd be better to confirm link than guess username/datname structure

console.log(msg)
if (body.updated === 1) {
console.log(output`
console.log(output(`
${chalk.dim.green('Cool fact #21')}
${opts.server} will live update when you are sharing your dat!
You only need to publish again if your dat link changes.
`)
`))
} else {
console.log(output`
console.log(output(`
Remember to use ${chalk.green('dat share')} before sharing.
This will make sure your dat is available.
`)
`))
}
process.exit(0)
})
Expand Down
4 changes: 2 additions & 2 deletions src/commands/unpublish.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ function unpublish (opts) {
var client = Registry(opts)
var whoami = client.whoami()
if (!whoami || !whoami.token) {
var loginErr = output`
var loginErr = output(`
Welcome to ${chalk.green(`dat`)} program!
${chalk.bold('You must login before unpublishing.')}
${chalk.green('dat login')}
`
`)
return exitErr(loginErr)
}

Expand Down

0 comments on commit 0e8a19c

Please sign in to comment.