Skip to content

Commit

Permalink
Update neat log to use new diffy (#1010)
Browse files Browse the repository at this point in the history
* change outputs to fn

* use neat-log diffy version

* fix exit stuff

* update neat-log

* add clear, update neat-log

* fix create output
  • Loading branch information
joehand authored Jul 4, 2018
1 parent 928b8b0 commit c1dde60
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"dat-node": "^3.5.5",
"dat-registry": "^4.0.0",
"debug": "^3.0.0",
"neat-log": "^1.1.0",
"neat-log": "^2.4.0",
"prettier-bytes": "^1.0.3",
"progress-string": "^1.2.1",
"prompt": "^1.0.0",
Expand Down
8 changes: 4 additions & 4 deletions src/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function create (opts) {
}

var welcome = `Welcome to ${chalk.green(`dat`)} program!`
var intro = output`
var intro = output(`
You can turn any folder on your computer into a Dat.
A Dat is a folder with some magic.
Expand All @@ -46,7 +46,7 @@ function create (opts) {
${chalk.dim('Ctrl+C to exit at any time')}
`
`)
var outro

// Force certain options
Expand All @@ -57,7 +57,7 @@ function create (opts) {
if (err && err.name === 'ExistsError') return exitErr('\nArchive already exists.\nYou can use `dat sync` to update.')
if (err) return exitErr(err)

outro = output`
outro = output(`
Created empty Dat in ${dat.path}/.dat
Expand All @@ -66,7 +66,7 @@ function create (opts) {
* Copy the unique dat link and securely share it.
${chalk.blue(`dat://${dat.key.toString('hex')}`)}
`
`)

if (opts.yes) return done()

Expand Down
4 changes: 2 additions & 2 deletions src/lib/discovery-exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ function discoveryExit (state, bus) {
function checkExit () {
if (state.dat.network.connected || !state.opts.exit) return
if (state.dat.network.connecting) return setTimeout(checkExit, 500) // wait to see if any connections resolve
var msg = output`
var msg = output(`
Dat could not find any connections for that link.
There may not be any sources online.
Run 'dat doctor' if you keep having trouble.
`
`)
bus.emit('exit:warn', msg)
}
}
2 changes: 1 addition & 1 deletion src/lib/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function onExit (state, bus) {
bus.on('exit:warn', function (err) {
onError(err, true)
})
process.on('SIGINT', function () {
bus.on('exit', function () {
state.exiting = true
bus.render()
process.exit()
Expand Down
4 changes: 2 additions & 2 deletions src/ui/archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function archiveUI (state) {
}
}

return output`
return output(`
${version(pkg.version)}
${title}
${state.joinNetwork ? '\n' + networkUI(state) : ''}
Expand All @@ -54,5 +54,5 @@ function archiveUI (state) {
${state.opts.sources ? sourcesUI(state) : ''}
${state.warnings ? warningsUI(state) : ''}
${state.exiting ? 'Exiting the Dat program...' : chalk.dim('Ctrl+C to Exit')}
`
`)
}
4 changes: 2 additions & 2 deletions src/ui/components/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ function networkUI (state) {
return '' // no metadata yet
}

return output`
return output(`
${title}
${downBar(stats.downloaded)}
`
`)

function makeBar () {
var total = stats.length
Expand Down
16 changes: 8 additions & 8 deletions src/ui/components/import-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ function importUI (state) {
if (importState.count && !importState.count.done) {
// dry run in progress
if (!importState.count.files) return 'Checking for file updates...'
return output`
return output(`
Metadata created for ${importState.putDone.files} of ${importState.count.files} files ${indexSpeed}
(Calculating file count...)
${fileImport(importState.fileImport)}
`
`)
} else if (importState.putDone.files >= importState.count.files) {
// Initial import done
if (!watch) return 'Archive metadata updated for all files.'
Expand All @@ -32,19 +32,19 @@ function importUI (state) {
}
})

return output`
return output(`
Creating metadata for ${importState.count.files} files ${indexSpeed}
${totalBar(importState.importedBytes)}
${fileImport(importState.fileImport)}
`
`)

function liveImport () {
// Live import
var imports = importState.liveImports.slice(1).slice(-7)
return output`
return output(`
Watching for file updates
${imports.reverse().map(function (file) { return fileImport(file) }).join('\n')}
`
`)
}

function fileImport (file) {
Expand All @@ -58,8 +58,8 @@ function importUI (state) {
// >500 mb show progress
if (total < 5e8 || !file.progress) size = `(${pretty(total)})`
else size = `(${pretty(file.progress)} / ${pretty(total)})`
return output`
return output(`
ADD: ${cliTruncate(name, process.stdout.columns - 7 - size.length, {position: 'start'})} ${size}
`
`)
}
}
4 changes: 2 additions & 2 deletions src/ui/components/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ function networkUI (state) {
if (!network) return ''
var peers = stats.peers.total || 0
// var complete = stats.peers.complete
return output`
return output(`
${peers} ${pluralize('connection', peers)} ${speedUI()}
`
`)

function speedUI () {
var output = '| '
Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ function peersUI (state) {
}
})
var theBar = progress ? bar(progress) : '' // progress bar todo
return output`
return output(`
[${i}] ${peer.closed ? 'CLOSED' : peer.type}: ${peer.host}:${peer.port} ${pretty(peer.speed)}/s
${peer.error ? peer.error : theBar}
`
`)
}
}
8 changes: 4 additions & 4 deletions src/ui/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ module.exports = createUI

function createUI (state) {
if (!state.dat) {
return output`
return output(`
Creating a Dat! Add information to your dat.json file:
`
`)
}

var dat = state.dat
Expand Down Expand Up @@ -42,10 +42,10 @@ function createUI (state) {
progressView = 'Not importing files.'
}

return output`
return output(`
${title}
${progressView}
${state.exiting ? exitMsg : chalk.dim('Ctrl+C to Exit')}
`
`)
}
4 changes: 2 additions & 2 deletions src/ui/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ function statusUI (state) {
var dat = state.dat
var stats = dat.stats.get()

return output`
return output(`
${chalk.blue('dat://' + stringKey(dat.key))}
${stats.files} files (${pretty(stats.byteLength)})
Version: ${chalk.bold(stats.version)}
`
`)
}

0 comments on commit c1dde60

Please sign in to comment.