Skip to content

Commit

Permalink
Merge pull request #294 from ardriveapp/dev
Browse files Browse the repository at this point in the history
PE-1898: Release CLI v1.17.0
  • Loading branch information
matibat authored Jul 19, 2022
2 parents bd32822 + bc38673 commit e7af9e8
Show file tree
Hide file tree
Showing 27 changed files with 118 additions and 30 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ ardrive upload-file --wallet-file /path/to/my/wallet.json --parent-folder-id "f0
8. [Limitations](#limitations)
3. [Using the CLI](#using-the-cli)
1. [CLI Help](#cli-help)
2. [Wallet Operations](#wallet-operations)
3. [Working With Entities](#working-with-entities)
2. [CLI Version](#cli-version)
3. [Wallet Operations](#wallet-operations)
4. [Working With Entities](#working-with-entities)
1. [Dry Run](#dry-run)
4. [Working With Drives](#working-with-drives)
5. [Working With Drives](#working-with-drives)
1. [Understanding Drive Hierarchies](#understanding-drive-hierarchies)
1. [Fetching Drive Info](#drive-info)
2. [Understanding Drive and File Keys](#understanding-drive-and-file-keys)
Expand All @@ -104,13 +105,13 @@ ardrive upload-file --wallet-file /path/to/my/wallet.json --parent-folder-id "f0
1. [Get Share Links for Files in the Drive](#get-share-links)
2. [Get Total Size of Files in the Drive](#get-total-size)
3. [Get Total Count of Files in the Drive](#get-file-count)
5. [Working With Folders](#working-with-folders)
6. [Working With Folders](#working-with-folders)
1. [Creating Folders](#creating-folders)
2. [Moving Folders](#moving-folders)
3. [Renaming Folders](#rename-folder)
4. [Viewing Folder Metadata](#viewing-folder-metadata)
5. [Listing Contents of a Folder](#listing-contents-of-a-folder)
6. [Working With Files](#working-with-files)
7. [Working With Files](#working-with-files)
1. [Uploading a Single File](#uploading-a-single-file)
2. [Download a Single File (BETA)](#download-file)
3. [Rename a Single File](#rename-file)
Expand All @@ -129,7 +130,7 @@ ardrive upload-file --wallet-file /path/to/my/wallet.json --parent-folder-id "f0
16. [Hosting a Webpage with Manifest](#hosting-a-webpage-with-manifest)
17. [Uploading With a Custom Content Type](#custom-content-type)
18. [Uploading a Custom Manifest](#custom-manifest)
7. [Other Utility Operations](#other-utility-operations)
8. [Other Utility Operations](#other-utility-operations)
1. [Monitoring Transactions](#monitoring-transactions)
2. [Dealing With Network Congestion](#dealing-with-network-congestion)
3. [Check for network congestion before uploading](#check-congestion)
Expand Down Expand Up @@ -278,6 +279,15 @@ Learn to use any command:
ardrive --help
```

## CLI Version

You can print out the version by running any of:

```shell
ardrive --version
ardrive -V
```

## Wallet Operations

Browsing of ArDrive public data is possible without the need for an [Arweave wallet][kb-wallets]. However, for all write operations, or read operations without encryption/decryption keys, you'll need a wallet.
Expand Down
2 changes: 2 additions & 0 deletions bats_test/base-reward/base-reward.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# Assertions
Expand Down
4 changes: 3 additions & 1 deletion bats_test/create-drive/create-drive.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# Assertions
Expand Down Expand Up @@ -43,4 +45,4 @@ load '/home/node/packages/node_modules/bats-assert/load.bash'

# [ "${lines[0]}" = "${lines[1]}" ]
# assert_line -n 2 'null'
# }
# }
2 changes: 2 additions & 0 deletions bats_test/create-drive/drive-name-validation.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# Assertions
Expand Down
2 changes: 2 additions & 0 deletions bats_test/downloads/drive-downloads/error_outputs.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# File methods. DEPENDS on SUPPORT lib.
Expand Down
2 changes: 2 additions & 0 deletions bats_test/downloads/drive-downloads/happy_paths.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# File methods. DEPENDS on SUPPORT lib.
Expand Down
2 changes: 2 additions & 0 deletions bats_test/downloads/file-downloads/public_files.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# File methods. DEPENDS on SUPPORT lib.
Expand Down
2 changes: 2 additions & 0 deletions bats_test/downloads/folder-downloads/error_outputs.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# File methods. DEPENDS on SUPPORT lib.
Expand Down
2 changes: 2 additions & 0 deletions bats_test/downloads/folder-downloads/happy_paths.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# File methods. DEPENDS on SUPPORT lib.
Expand Down
8 changes: 5 additions & 3 deletions bats_test/generate-wallet/generate-wallet.bats
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# Assertions
load '/home/node/packages/node_modules/bats-assert/load.bash'

@test "generate-wallet creates canonical wallet" {

run -0 bash -c "yarn ardrive generate-wallet -s 'this is an example twelve word seed phrase that you could use' | jq .kty,.n,.e,.d,.p,.q,.dp,.dq,.qi,.kid"

assert_line -n 0 '"RSA"'
Expand All @@ -22,11 +24,11 @@ load '/home/node/packages/node_modules/bats-assert/load.bash'
}

@test "generate-wallet rejects short and long seed phrases" {

run -1 bash -c "yarn ardrive generate-wallet -s 'invalid seed phrase'"

assert_line -n 0 "Error: 'invalid seed phrase' is not a valid 12 word seed phrase!"

run -1 bash -c "yarn ardrive generate-wallet -s 'this invalid seed phrase has thirteen words and is expected to be rejected'"

assert_line -n 0 "Error: 'this invalid seed phrase has thirteen words and is expected to be rejected' is not a valid 12 word seed phrase!"
Expand Down
8 changes: 5 additions & 3 deletions bats_test/get-address/get-address.bats
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# Assertions
load '/home/node/packages/node_modules/bats-assert/load.bash'

@test "get-address finds the correct address of a canonical seed phrase" {

run -0 bash -c "yarn ardrive get-address -s 'this is an example twelve word seed phrase that you could use'"

assert_line -n 0 'HTTn8F92tR32N8wuo-NIDkjmqPknrbl10JWo5MZ9x2k'
}

@test "get-address rejects short and long seed phrases" {

run -1 bash -c "yarn ardrive get-address -s 'invalid seed phrase'"

assert_line -n 0 "Error: 'invalid seed phrase' is not a valid 12 word seed phrase!"

run -1 bash -c "yarn ardrive get-address -s 'this invalid seed phrase has thirteen words and is expected to be rejected'"

assert_line -n 0 "Error: 'this invalid seed phrase has thirteen words and is expected to be rejected' is not a valid 12 word seed phrase!"
Expand Down
2 changes: 2 additions & 0 deletions bats_test/get-mempool/get-mempool.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# Assertions
Expand Down
2 changes: 2 additions & 0 deletions bats_test/help/base-reward.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# Assertions
Expand Down
2 changes: 2 additions & 0 deletions bats_test/help/get-mempool.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# Assertions
Expand Down
16 changes: 10 additions & 6 deletions bats_test/help/no_command.bats
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

help="Usage: ardrive [command] [command-specific options]
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
Expand Down Expand Up @@ -33,23 +36,24 @@ Commands:
rename-drive [options]
rename-file [options]
rename-folder [options]
retry-tx [options]
send-ar [options]
send-tx [options]
tx-status [options]
upload-file [options]
help [command] display help for command"

@test "'ardrive' with no input arguments prints general help with all expected commands" {
run -0 yarn ardrive
[[ "$output" = "$help" ]]
run -0 yarn ardrive
[[ "$output" = "$help" ]]
}

@test "'ardrive -h' prints general help with all expected commands" {
run -0 yarn ardrive -h
[[ "$output" = "$help" ]]
run -0 yarn ardrive -h
[[ "$output" = "$help" ]]
}

@test "'ardrive --help' prints general help with all expected commands" {
run -0 yarn ardrive --help
[[ "$output" = "$help" ]]
run -0 yarn ardrive --help
[[ "$output" = "$help" ]]
}
2 changes: 2 additions & 0 deletions bats_test/rename/rename-drive/rename_public_drive.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# File methods. DEPENDS on SUPPORT lib.
Expand Down
2 changes: 2 additions & 0 deletions bats_test/rename/rename-file/rename_public_file.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# File methods. DEPENDS on SUPPORT lib.
Expand Down
3 changes: 2 additions & 1 deletion bats_test/rename/rename-folder/rename_public_folder.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# File methods. DEPENDS on SUPPORT lib.
Expand All @@ -18,7 +20,6 @@ load './rename_same_name.sh'
# Constants
load '../../constants.sh'


DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")" >/dev/null 2>&1 && pwd)"

setup_file() {
Expand Down
2 changes: 2 additions & 0 deletions bats_test/upload-file/file-name-validation.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# Assertions
Expand Down
3 changes: 2 additions & 1 deletion bats_test/upload-file/reward-test.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# Assertions
Expand All @@ -18,4 +20,3 @@ setup_file() {

[ "$rewardFromUpload" = "$rewardFromNetwork" ]
}

5 changes: 3 additions & 2 deletions bats_test/upload-file/single-bundled-files.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

# Support lib
load '/home/node/packages/node_modules/bats-support/load.bash'
# Assertions
Expand All @@ -19,7 +21,6 @@ setup_file() {
cd /home/node/ardrive-cli
}


@test "upload-file creates a bundled transaction by default" {
run -0 bash -c "yarn ardrive upload-file --dry-run --local-path '/home/node/10Chunks.txt' -F $PUB_FOLD_ID -w $WALLET | jq '.created[] .type'"

Expand Down Expand Up @@ -49,7 +50,7 @@ setup_file() {
assert_line -n 1 '"file"'
assert_line -n 2 '"bundle"'
assert_line -n 3 ''

}

@test "upload-file used on a bulk folder returns the expected results" {
Expand Down
21 changes: 21 additions & 0 deletions bats_test/version/version.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

EXPECTED_VERSION=$(jq -r '.version' ./package.json)

@test "'ardrive --version' prints the version" {
run -0 yarn ardrive --version
[[ "$output" = "$EXPECTED_VERSION" ]]

}

@test "'ardrive -V' prints the version" {
run -0 yarn ardrive -V
[[ "$output" = "$EXPECTED_VERSION" ]]
}

@test "'ardrive <SOME COMMAND> -V' ONLY prints the version" {
run -0 yarn ardrive tx-status -V
[[ "$output" = "$EXPECTED_VERSION" ]]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ardrive-cli",
"version": "1.16.0",
"version": "1.17.0",
"description": "The ArDrive Command Line Interface (CLI is a Node.js application for terminal-based ArDrive workflows. It also offers utility operations for securely interacting with Arweave wallets and inspecting various Arweave blockchain conditions.",
"main": "./lib/index.js",
"bin": {
Expand Down
1 change: 1 addition & 0 deletions src/CLICommand/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export abstract class CliApiObject {
abstract usage(usage: string): CliApiObject;
abstract outputHelp(): void;
abstract exitOverride(callback?: (commanderError: CommanderError) => void): CliApiObject;
abstract version(str: string, flags?: string, description?: string): CliApiObject;
}

export type ActionCallback = (options: ParsedParameters) => ActionReturnType; // commander action callback
Expand Down
7 changes: 7 additions & 0 deletions src/CLICommand/cli_command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,20 @@ class TestCliApiObject {
name = stub(this.program, 'name').returnsThis();
usage = stub(this.program, 'usage').returnsThis();
outputHelp = stub(this.program, 'outputHelp');
version = stub(this.program, 'version');
}

describe('CLICommand class', () => {
let stubbedProgram: SinonStubbedInstance<CliApiObject>;
const program: CliApiObject = new Command() as CliApiObject;

before(() => {
program.name('ardrive');
program.addHelpCommand(true);
program.usage('[command] [command-specific options]');
// Override the commander's default exit (process.exit()) to avoid abruptly interrupting the script execution
program.exitOverride();

stubbedProgram = new TestCliApiObject(program);
});

Expand Down
Loading

0 comments on commit e7af9e8

Please sign in to comment.