-
Notifications
You must be signed in to change notification settings - Fork 24
feat: implement upload history #679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a17aea2
feat: implement history save and list for uploads
bc7ebf0
feat: add show command and use history log for feeds
ac7c5d2
feat: fix type issue
90fbe04
test: update test coverage
github-actions[bot] 22d75e7
feat: move history file to config folder
0339b57
Merge branch 'feat/implement-upload-history' of github.com:etherspher…
e6448c8
feat: add get by index method for history items
e545a7f
feat: add tests
d78a7d7
feat: test teardown
458eaf3
test: update test coverage [skip ci]
github-actions[bot] a0f3c2f
fix: file name and upload type
351aab4
Merge branch 'feat/implement-upload-history' of github.com:etherspher…
b0a4693
fix: update import path
2645f16
fix: update spec
4cf5f86
test: update test coverage [skip ci]
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { RootCommand } from '../root-command' | ||
|
|
||
| export class HistoryCommand extends RootCommand {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { GroupCommand } from 'furious-commander' | ||
| import { List } from './list' | ||
| import { Show } from './show' | ||
|
|
||
| export class History implements GroupCommand { | ||
| public readonly name = 'history' | ||
|
|
||
| public readonly description = 'Get upload history' | ||
|
|
||
| public subCommandClasses = [List, Show] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { HistoryCommand } from './history-command' | ||
| import { History } from '../../service/history' | ||
| import Table from 'cli-table3' | ||
| import { LeafCommand } from 'furious-commander' | ||
| import { ellipsis } from '../../utils/text' | ||
| import { HistoryItem } from '../../service/history/types/history-item' | ||
|
|
||
| export class List extends HistoryCommand implements LeafCommand { | ||
| public readonly name = 'list' | ||
|
|
||
| public readonly alias = 'ls' | ||
|
|
||
| public readonly description = 'Get upload history list' | ||
|
|
||
| public run() { | ||
| super.init() | ||
| const table = new Table({ | ||
| head: ['Index', 'Timestamp', 'Reference', 'Postage stamp batch ID', 'File path', 'Upload type'], | ||
| style: { | ||
| head: ['green', 'bold'], | ||
| }, | ||
| wordWrap: true, | ||
| }) | ||
|
|
||
| const history = new History(this.commandConfig.configFolderPath, this.console) | ||
| table.push( | ||
| ...history | ||
| .getItems() | ||
| .map((h: HistoryItem) => [ | ||
| h.index, | ||
| new Date(h.timestamp).toLocaleString(), | ||
| h.reference.slice(0, 12), | ||
| ellipsis(h.stamp, 6, -6), | ||
| h.path, | ||
| h.uploadType, | ||
| ]), | ||
| ) | ||
| this.console.log(table.toString()) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { HistoryCommand } from './history-command' | ||
| import { Argument, LeafCommand } from 'furious-commander' | ||
| import { createKeyValue } from '../../utils/text' | ||
| import { exit } from 'process' | ||
| import { History } from '../../service/history' | ||
|
|
||
| export class Show extends HistoryCommand implements LeafCommand { | ||
| public readonly name = 'show' | ||
|
|
||
| public readonly description = 'Get upload history item' | ||
|
|
||
| @Argument({ | ||
| key: 'index', | ||
| description: 'Index of the history item', | ||
| required: true, | ||
| type: 'number', | ||
| }) | ||
| public index!: number | ||
|
|
||
| public run() { | ||
| super.init() | ||
| const history = new History(this.commandConfig.configFolderPath, this.console) | ||
| const historyItem = history.getItemByIndex(this.index) | ||
|
|
||
| if (historyItem === undefined) { | ||
| this.console.error(`Cound not find history item with index '${this.index}'`) | ||
| exit(1) | ||
| } | ||
| this.console.log(createKeyValue('Timestamp', new Date(historyItem.timestamp).toUTCString())) | ||
| this.console.log(createKeyValue('Swarm hash', historyItem.reference)) | ||
| this.console.log(createKeyValue('Stamp ID', historyItem.stamp)) | ||
| this.console.log(createKeyValue('Upload type', historyItem.uploadType)) | ||
|
|
||
| if (historyItem.path) { | ||
| this.console.log(createKeyValue('Path', historyItem.path)) | ||
| } | ||
|
|
||
| if (historyItem.feedAddress) { | ||
| this.console.log(createKeyValue('Feed address', historyItem.feedAddress)) | ||
| } | ||
|
|
||
| if (historyItem.feedIdentity) { | ||
| this.console.log(createKeyValue('Feed identity', historyItem.feedIdentity)) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add alias
ls