diff --git a/package.json b/package.json index 18a7f1be85..ab7e2e27de 100644 --- a/package.json +++ b/package.json @@ -100,11 +100,11 @@ "ipfs-bitswap": "^0.26.0", "ipfs-block": "~0.8.1", "ipfs-block-service": "~0.16.0", - "ipfs-http-client": "^39.0.2", + "ipfs-http-client": "ipfs/js-ipfs-http-client#fix/repo-stat", "ipfs-http-response": "~0.4.0", "ipfs-mfs": "^0.13.0", "ipfs-multipart": "^0.2.0", - "ipfs-repo": "^0.29.0", + "ipfs-repo": "^0.29.1", "ipfs-unixfs": "~0.1.16", "ipfs-unixfs-exporter": "^0.38.0", "ipfs-unixfs-importer": "^0.40.0", @@ -204,7 +204,7 @@ "execa": "^3.0.0", "form-data": "^3.0.0", "hat": "0.0.3", - "interface-ipfs-core": "^0.119.0", + "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#test/add-human-option-test-repo-stat", "ipfs-interop": "^0.1.1", "ipfsd-ctl": "^0.47.2", "libp2p-websocket-star": "~0.10.2", diff --git a/src/cli/commands/repo/stat.js b/src/cli/commands/repo/stat.js index 067dbeb975..a6e0f4adce 100644 --- a/src/cli/commands/repo/stat.js +++ b/src/cli/commands/repo/stat.js @@ -16,12 +16,12 @@ module.exports = { argv.resolve((async () => { const ipfs = await argv.getIpfs() const stats = await ipfs.repo.stat({ human: argv.human }) - argv.print(`repo status - number of objects: ${stats.numObjects} - repo size: ${stats.repoSize} - repo path: ${stats.repoPath} - version: ${stats.version} - maximum storage: ${stats.storageMax}`) + argv.print( +`NumObjects: ${stats.numObjects} +RepoSize: ${stats.repoSize} +StorageMax: ${stats.storageMax} +RepoPath: ${stats.repoPath} +Version: ${stats.version}`) })()) } } diff --git a/test/cli/repo.js b/test/cli/repo.js index f5e47d7eb7..084775244f 100644 --- a/test/cli/repo.js +++ b/test/cli/repo.js @@ -16,4 +16,17 @@ describe('repo', () => runOnAndOff((thing) => { const out = await ipfs('repo version') expect(out).to.eql(`${repoVersion}\n`) }) + + it('get repo stats', async () => { + const stats = await ipfs('repo stat') + expect(stats).to.match(/^RepoSize:\s\d+$/gm) + expect(stats).to.match(/^StorageMax:\s\d+$/gm) + }) + + it('get human readable repo stats', async () => { + const stats = await ipfs('repo stat --human') + + expect(stats).to.match(/^RepoSize:\s+[\d.]+\s[PTGMK]?B$/gm) + expect(stats).to.match(/^StorageMax:\s+[\d.]+\s[PTGMK]?B$/gm) + }) }))