Skip to content

Commit

Permalink
Merge pull request #253 from ardriveapp/dev
Browse files Browse the repository at this point in the history
PE-1039: Release ArDrive CLI v1.9.0
  • Loading branch information
fedellen authored Feb 23, 2022
2 parents 596eff0 + a2376e9 commit 6aeadb4
Show file tree
Hide file tree
Showing 24 changed files with 369 additions and 117 deletions.
10 changes: 5 additions & 5 deletions .pnp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ ardrive upload-file --wallet-file /path/to/my/wallet.json --parent-folder-id "f0
12. [Moving Files](#moving-files)
13. [Uploading Manifests](#uploading-manifests)
14. [Hosting a Webpage with Manifest](#hosting-a-webpage-with-manifest)
15. [Uploading With a Custom Content Type](#custom-content-type)
16. [Uploading a Custom Manifest](#custom-manifest)
7. [Other Utility Operations](#other-utility-operations)
1. [Monitoring Transactions](#monitoring-transactions)
2. [Dealing With Network Congestion](#dealing-with-network-congestion)
Expand Down Expand Up @@ -251,6 +253,7 @@ To ensure your environment is compatible, we also recommend the following VSCode

**Number of files in a bulk upload:** Theoretically unlimited<br>
**Max individual file size**: 2GB (Node.js limitation)<br>
**Max file name length**: 255 bytes<br>
**Max ANS-104 bundled transaction size:** Not yet implemented. 2GB per bundle. App will handle creating multiple bundles.<br>
**Max ANS-104 data item counts per bundled transaction:** Not yet implemented. Also not adequately specified, though a very large number of data items per bundle is associated with increased rates of GQL indexing failure.

Expand Down Expand Up @@ -959,6 +962,8 @@ If you'd like to preview the contents of your manifest before uploading, you can
ardrive create-manifest -w /path/to/wallet -f "6c312b3e-4778-4a18-8243-f2b346f5e7cb" --dry-run | jq '{manifest}.manifest'
```
<a id="manifest-json"></a>
```json
{
"manifest": "arweave/paths",
Expand Down Expand Up @@ -1033,6 +1038,50 @@ In the return output, the top link will be a link to the deployed web app:
This is effectively hosting a web app with ArDrive. Check out the ArDrive Price Calculator React App hosted as an [ArDrive Manifest][example-manifest-webpage].
### Uploading With a Custom Content Type<a id="custom-content-type"></a>
Each file uploaded to the Arweave network receives a `"Content-Type"` GraphQL tag that contains the MIME type for the file. The gateway will use this content type to determine how to serve that file's data transaction at the `arweave.net/{data tx id}` endpoint.
By default, the CLI will attempt to derive this content type from the file extension of the provided file. In most cases, the content type that is derived will be correct and the gateway will properly serve the file.
The CLI also provides the option for users to upload files with a custom content type using the `--content-type` flag:
```shell
ardrive upload-file --content-type "application/json" --local-path /path/to/file --parent-folder-id "9af694f6-4cfc-4eee-88a8-1b02704760c0" -w /path/to/wallet.json
```
It is currently possible to set this value to any given string, but the gateway will still only serve valid content types. Check out this list of commonly used MIME types to ensure you're providing a valid content type: [Common MIME types][mozilla-mime-types].
Note: In the case of multi-file uploads or recursive folder uploads, setting this `--content-type` flag will set the provided custom content type on EVERY file entity within a given upload.
### Uploading a Custom Manifest<a id="custom-manifest"></a>
Using the custom content type feature, it is possible for users to upload their own custom manifests. The Arweave gateways use this special content type in order to identify an uploaded file as a manifest:
```shell
application/x.arweave-manifest+json
```
In addition to this content type, the manifest must also adhere to the [correct JSON structure](#manifest-json) of an Arweave manifest. A user can create their own manifest from scratch, or start by piping a generated manifest to a JSON file and editing it to their specifications:
```shell
ardrive create-manifest -w /path/to/wallet -f "6c312b3e-4778-4a18-8243-f2b346f5e7cb" --dry-run | jq '{manifest}.manifest' > my-custom-manifest.json
```
After editing the generated manifest, simply perform an `upload-file` command with the custom Arweave manifest content type to any PUBLIC folder:
```shell
ardrive upload-file --content-type "application/x.arweave-manifest+json" --local-path my-custom-manifest.json --parent-folder-id "9af694f6-4cfc-4eee-88a8-1b02704760c0" -w /path/to/wallet.json
```
The returned `dataTxId` field on the created `file` entity will be the endpoint that the manifest can be found on Arweave, just as explained in the [manifest sections](#uploading-manifests) above:
```shell
https://arweave.net/{dataTxId}
https://arweave.net/{dataTxId}/custom-file-1
https://arweave.net/{dataTxId}/custom-file-2
```
## Other Utility Operations
### Monitoring Transactions
Expand Down Expand Up @@ -1220,3 +1269,4 @@ ardrive <command> --help
[kb-wallets]: https://ardrive.atlassian.net/l/c/FpK8FuoQ
[arweave-manifests]: https://github.com/ArweaveTeam/arweave/wiki/Path-Manifests
[example-manifest-webpage]: https://arweave.net/qozq9YIUPEHfZhoTp9DkBpJuA_KNULBnfLiMroj5pZI
[mozilla-mime-types]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
2 changes: 2 additions & 0 deletions bats_test/constants.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# String with 256 characters
ENTITY_NAME_LONG='+==============================================================================================================================================================================================================================================================='
20 changes: 20 additions & 0 deletions bats_test/create-drive/drive-name-validation.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bats

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

@test "create drive with empty name results in an error message and exit code 1" {
run -1 bash -c "yarn ardrive create-drive --dry-run -n '' -w $WALLET"

assert_line -n 0 "Error: Required parameter driveName wasn't provided!"
}

@test "create drive with long name results in an error message and exit code 1" {
run -1 bash -c "yarn ardrive create-drive --dry-run -n $ENTITY_NAME_LONG -w $WALLET"

assert_line -n 0 'Error: The drive name must not exceed 255 bytes'
}
33 changes: 33 additions & 0 deletions bats_test/generate-wallet/generate-wallet.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bats

# 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"'
assert_line -n 1 '"jw8e2rH-iNRaLsoutq7UIVrcK0wxqQzG7wJ8ip0J6uNDXDKzFB9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swd_5cJbWco61KpPq3kKWpWnpPteN2UJHMlA1ye6qkh81Wkv9UD5Rw_kNV0Icnof08ELEHMkmsM4cwVnm3G5zLzRwuFYDt3Mn1LTXAFLC1VIAFisrEAKJr_GpUyvNIklCbvFXa0Fwc4old3WUrdGk-ebnUKx2tJxinuSJwg0N154GmCw0ueVFSTgI3QItxy0YWWMa7NFVyQfjL5T2Gmr8sAndimAyEtj6mz77oPPi11JzA58ek4XeIJTYGks1ehnVcv52wQ"'
assert_line -n 7 '"B_WrEgZ8qY_3vLlJHsr5kJ26VqPgKiQRnJIsb6fsQdKOoUofTP3A0rzmZRAB1ltA-tChyBCMf9leBfgFtovYms-EFgtNliV6PyblqUUaRuI2yYdUny2k-am2dB2yVVnrgtM7htUFWKULC8u6NgwDgV9qm1nxlq8m900wqUiPiMp89248RgggOBtoB9AMQ_N1Xppp3s3eMokBTRN4urr1SZ-bjkQegTbnFZ9Zwv-TKUBKZ2Gd5VtbqZ2c5t62gauIJ2XcO3VkEjtsYzOP26fzbWmCfI8jzV0WDsxj0qEdKhzxVPLDERyvbN6VCwfiMUTLef1y_G1QJP3uYlkmz0ZvCQ"'
assert_line -n 8 '"TgjJGFXrggHszRCRaccjeFJOHP22RMakqddAgImnMtStAFwOKdlNA1WND0xd4e1zVJso_IFRO9-kMrMv8JmLj-3QloS5-UFDlvfywfqHwPiyy3KVQtgGnm6PJ6WR2qbA2dcBgiGpM-lbC-t-mRa4YeNANmrTchr5RIlXNg4pVaFZUjG6-QDb4WL_CFmA5KgC70HFzaXFHvKFM2SYRo_lUytjINzsv6oayB6nFfhq0e1EyouyOY5cU5B57Lu9QSfMWdnbNdwW7pHNkZwOd9BqrRhBcO1JncHKsyr8bplWO1ffTftpMmSseDzaSd_Zi1n2h8dblu8jMh6pNAiWF46bBA"'
assert_line -n 9 '"2011-04-29"'
}

@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!"
}
46 changes: 46 additions & 0 deletions bats_test/get-address/get-address.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bats

# 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!"
}

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

WALLET='
{
"kty": "RSA",
"n": "jw8e2rH-iNRaLsoutq7UIVrcK0wxqQzG7wJ8ip0J6uNDXDKzFB9H0WwcHXYZyhE2faS73J47Tob5KtpTlBXt6lCOnl8Vp0Ud3Y025lDhxMevnSVkTBY8SIxSsAOwwUDPFIJE9W2f9ZZ4DZh5hWy7n0wYWi4APWiwD7tfvxX8xHUcOOvZRiTY-JOmN7pOnFvwzblX4Mpg1kON-b31VLxhyZKUYFhDuEXsxX8mHT_kpbUdHV24DMch44SbzNkRSYKJ3IqSW6fBZo5Zt9wzpFe7VhhRrfM8ZEOVYWdebLQfMc0lxt4zXQCHpmrUub8e13GGCB2kL3q38sR7XU_fa1PyiTsPtYjH0v4cdvkK58dfnTZDlhfSJjoyNYi_MVuhdtw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k-am2dB2yVVnrgtM7htUFWKULC8u6NgwDgV9qm1nxlq8m900wqUiPiMp89248RgggOBtoB9AMQ_N1Xppp3s3eMokBTRN4urr1SZ-bjkQegTbnFZ9Zwv-TKUBKZ2Gd5VtbqZ2c5t62gauIJ2XcO3VkEjtsYzOP26fzbWmCfI8jzV0WDsxj0qEdKhzxVPLDERyvbN6VCwfiMUTLef1y_G1QJP3uYlkmz0ZvCQ",
"qi": "TgjJGFXrggHszRCRaccjeFJOHP22RMakqddAgImnMtStAFwOKdlNA1WND0xd4e1zVJso_IFRO9-kMrMv8JmLj-3QloS5-UFDlvfywfqHwPiyy3KVQtgGnm6PJ6WR2qbA2dcBgiGpM-lbC-t-mRa4YeNANmrTchr5RIlXNg4pVaFZUjG6-QDb4WL_CFmA5KgC70HFzaXFHvKFM2SYRo_lUytjINzsv6oayB6nFfhq0e1EyouyOY5cU5B57Lu9QSfMWdnbNdwW7pHNkZwOd9BqrRhBcO1JncHKsyr8bplWO1ffTftpMmSseDzaSd_Zi1n2h8dblu8jMh6pNAiWF46bBA",
"kid": "2011-04-29"
}
'

run -0 bash -c 'echo $WALLET | yarn ardrive get-address -w /dev/stdin'

assert_line -n 0 'HTTn8F92tR32N8wuo-NIDkjmqPknrbl10JWo5MZ9x2k'
}
6 changes: 2 additions & 4 deletions bats_test/rename/rename-drive/rename_invalid_names.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/bin/bash

# Depends on ./rename_drive.sh
# Depends on ../..constants.sh

rename_invalid_names() {
echo "$(rename_drive "${PUB_DRIVE_ID}" " leading spaces.txt")"
echo "$(rename_drive "${PUB_DRIVE_ID}" "trailing spaces.png ")"
echo "$(rename_drive "${PUB_DRIVE_ID}" "trailing dots.doc.")"
echo "$(rename_drive "${PUB_DRIVE_ID}" "reserved characters :*.txt")"
echo "$(rename_drive "${PUB_DRIVE_ID}" "$ENTITY_NAME_LONG")"
}
7 changes: 3 additions & 4 deletions bats_test/rename/rename-drive/rename_public_drive.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ load './rename_drive.sh'
load './rename_invalid_names.sh'
# A function which triggers a rename with exactly the same name. DEPENDS on rename_drive.sh
load './rename_same_name.sh'
# Constants
load '../../constants.sh'

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

Expand All @@ -26,10 +28,7 @@ setup_file() {
# Note 1: The above function runs the command with multiple invalid examples, so we get multiple lines logged in this case
# Note 2: We don't assert for the exit code (a.k.a. "${status}") here because of `Note 1`, so we assert the error by reading the output

assert_line -n 0 "Error: The drive name cannot start with spaces"
assert_line -n 1 "Error: The drive name cannot have trailing dots or spaces"
assert_line -n 2 "Error: The drive name cannot have trailing dots or spaces"
assert_line -n 3 "Error: The drive name cannot contain reserved characters (i.e. '\\\\', '/', ':', '*', '?', '\"', '<', '>', '|')"
assert_line -n 0 'Error: The drive name must not exceed 255 bytes'
}

@test 'Errors out if renaming would end up having no effect' {
Expand Down
6 changes: 2 additions & 4 deletions bats_test/rename/rename-file/rename_invalid_names.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/bin/bash

# Depends on ./rename_file.sh
# Depends on ../..constants.sh

rename_invalid_names() {
echo "$(rename_file "${PUB_FILE_ID}" " leading spaces.txt")"
echo "$(rename_file "${PUB_FILE_ID}" "trailing spaces.png ")"
echo "$(rename_file "${PUB_FILE_ID}" "trailing dots.doc.")"
echo "$(rename_file "${PUB_FILE_ID}" "reserved characters :*.txt")"
echo "$(rename_file "${PUB_FILE_ID}" "$ENTITY_NAME_LONG")"
}
7 changes: 3 additions & 4 deletions bats_test/rename/rename-file/rename_public_file.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ load './rename_invalid_names.sh'
load './rename_colliding_name.sh'
# A function which triggers a rename with exactly the same name. DEPENDS on rename_file.sh
load './rename_same_name.sh'
# Constants
load '../../constants.sh'

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

Expand All @@ -28,10 +30,7 @@ setup_file() {
# Note 1: The above function runs the command with multiple invalid examples, so we get multiple lines logged in this case
# Note 2: We don't assert for the exit code (a.k.a. "${status}") here because of `Note 1`, so we assert the error by reading the output

assert_line -n 0 "Error: The file name cannot start with spaces"
assert_line -n 1 "Error: The file name cannot have trailing dots or spaces"
assert_line -n 2 "Error: The file name cannot have trailing dots or spaces"
assert_line -n 3 "Error: The file name cannot contain reserved characters (i.e. '\\\\', '/', ':', '*', '?', '\"', '<', '>', '|')"
assert_line -n 0 'Error: The file name must not exceed 255 bytes'
}

@test 'Errors out if the rename would end up in a name collision' {
Expand Down
Loading

0 comments on commit 6aeadb4

Please sign in to comment.