Skip to content

Commit

Permalink
Merge pull request #271 from ardriveapp/dev
Browse files Browse the repository at this point in the history
PE-1148: Release ArDrive CLI v1.12.0
  • Loading branch information
fedellen authored Mar 24, 2022
2 parents 3d2d724 + 8525568 commit a529243
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 141 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.
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ ardrive upload-file --wallet-file /path/to/my/wallet.json --parent-folder-id "f0
4. [Front-run Congestion By Boosting Miner Rewards](#boost)
5. [Send AR Transactions From a Cold Wallet](#cold-tx)
6. [Using a Custom Arweave Gateway](#using-a-custom-arweave-gateway)
7. [Persistent Caching of ArFS Entity Metadata](#metadata-caching)
4. [All ArDrive CLI Commands](#all-ardrive-cli-commands)
5. [Getting Help](#getting-help)

Expand Down Expand Up @@ -478,6 +479,9 @@ Useful notes on listing the contents of drives:
# List everything in a private drive
ardrive list-drive -d "c7f87712-b54e-4491-bc96-1c5fa7b1da50" -w /path/to/my/wallet.json -P

# List a private drive including the `fileKey` and/or `driveKey` of all listed entitites
ardrive list-drive -d "c7f87712-b54e-4491-bc96-1c5fa7b1da50" -w /path/to/my/wallet.json -P --with-keys

# List the contents of a public drive up to and including those in the grandchild folders of the root folder
ardrive list-drive -d "c7f87712-b54e-4491-bc96-1c5fa7b1da50" --max-depth 2
```
Expand Down Expand Up @@ -580,7 +584,7 @@ ardrive folder-info --folder-id "9af694f6-4cfc-4eee-88a8-1b02704760c0"

### Listing Contents of a Folder

Similar to drives, the `list-folder` command can be used to fetch the metadata of each entity within a folder. But by default, the command will fetch only the immediate children of that folder (`--maxdepth 0`):
Similar to drives, the `list-folder` command can be used to fetch the metadata of each entity within a folder. But by default, the command will fetch only the immediate children of that folder (`--max-depth 0`):

```shell
# List immediate children of folder "My Public Folder"
Expand Down Expand Up @@ -666,9 +670,21 @@ Example output:
]
```

To list further than the immediate children, you can make use of the flags: `--all` and `--max-depth`.

```shell
# List all contents of a folder
# List all contents of a public folder
ardrive list-folder --parent-folder-id "9af694f6-4cfc-4eee-88a8-1b02704760c0" --all

# List the contents of a public folder with custom depth
ardrive list-folder --parent-folder-id "9af694f6-4cfc-4eee-88a8-1b02704760c0" --max-depth 2
```

In the case of private entitites, the `--with-keys` flag will make the command to include the keys in the output.

```shell
# List all contents of a private folder including the `fileKey` and/or `driveKey` of all listed entitites
ardrive list-folder --parent-folder-id "1b027047-4cfc-4eee-88a8-9af694f660c0" -w /my/wallet.json --with-keys
```

## Working With Files
Expand Down Expand Up @@ -1213,6 +1229,23 @@ ardrive list-drive -d { drive id from create drive }
ardrive download-file -f { file id from upload file }
```
### Persistent Caching of ArFS Entity Metadata<a id="metadata-caching"></a>
To avoid redundant requests to the Arweave network for immutable ArFS entity metadata, a persistent file cache is created and maintained at:
```
Windows: <os.homedir()>/ardrive-caches/metadata
Non-Windows: <os.homedir()>/.ardrive/caches/metadata
```
The `XDG_CACHE_HOME` environment variable is honored, where applicable, and will be used in place of `os.homedir()` in the scenarios described above.
Metadata cache logging to stderr can be enabled by setting the `ARDRIVE_CACHE_LOG` environment variable to `1`.
Cache performance is UNDEFINED for multi-process scenarios, but is presumed to be generally usable.
The cache can be manually cleared safely at any time that any integrating app is not in operation.
# All ArDrive CLI Commands
```shell
Expand Down
3 changes: 0 additions & 3 deletions bats_test/downloads/drive-downloads/happy_paths.bats
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ setup() {
}

@test "Download drive to a custom folder using a custom depth of 0" {
# Skipped for now as test is failing, but the command itself is working properly. PE-1066
skip

cd "${DIR}"
run -0 download_public_drive "${MY_DRIVE_ID}" "${DIR}/MyCustomFolderName" "0"

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "ardrive-cli",
"version": "1.11.0",
"version": "1.12.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": {
"ardrive": "./lib/index.js"
},
"types": "./lib/index.d.ts",
"dependencies": {
"ardrive-core-js": "1.10.1",
"ardrive-core-js": "1.11.0",
"arweave": "1.10.18",
"axios": "^0.21.1",
"commander": "^8.2.0",
Expand Down
6 changes: 3 additions & 3 deletions src/CLICommand/parameters_helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import '../parameter_declarations';
import { CLIAction } from './action';
import { SUCCESS_EXIT_CODE } from './error_codes';
import { ArweaveAddress, EID, urlEncodeHashKey } from 'ardrive-core-js';
import { ArweaveAddress, EID } from 'ardrive-core-js';

const expectedArweaveAddress = new ArweaveAddress('P8aFJizMVBl7HeoRAz2i1dNYkG_KoN7oB9tZpIw6lo4');

Expand Down Expand Up @@ -462,7 +462,7 @@ describe('ParametersHelper class', () => {
driveId: EID('00000000-0000-0000-0000-000000000000')
});
return driveKeyPromise.then((driveKey) =>
expect(urlEncodeHashKey(driveKey)).to.equal('Fqjb/eoHUHkoPwyTe52VUJkUkOtLg0eoWdV1u03DDzg')
expect(driveKey.toString()).to.equal('Fqjb/eoHUHkoPwyTe52VUJkUkOtLg0eoWdV1u03DDzg')
);
});
});
Expand All @@ -480,7 +480,7 @@ describe('ParametersHelper class', () => {
return parameters
.getDriveKey({ driveId: EID('00000000-0000-0000-0000-000000000000') })
.then((driveKey) =>
expect(urlEncodeHashKey(driveKey)).to.equal('Fqjb/eoHUHkoPwyTe52VUJkUkOtLg0eoWdV1u03DDzg')
expect(driveKey.toString()).to.equal('Fqjb/eoHUHkoPwyTe52VUJkUkOtLg0eoWdV1u03DDzg')
);
});
});
Expand Down
90 changes: 0 additions & 90 deletions src/commands/upload_file.test.ts

This file was deleted.

58 changes: 27 additions & 31 deletions src/commands/upload_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
FolderID,
ArFSFileToUpload,
ArFSFolderToUpload,
ArFSResult,
DriveKey,
wrapFileOrFolder,
EID,
Expand Down Expand Up @@ -121,16 +120,6 @@ function getSingleFile(parameters: ParametersHelper, parentFolderId: FolderID):
return [singleParameter];
}

export const formatResults = (results: ArFSResult[]): ArFSResult =>
results.reduce(
(previousValue, currentValue) => ({
created: [...previousValue.created, ...currentValue.created],
tips: [...previousValue.tips, ...currentValue.tips],
fees: { ...previousValue.fees, ...currentValue.fees }
}),
{ created: [], tips: [], fees: {} }
);

new CLICommand({
name: 'upload-file',
parameters: [
Expand Down Expand Up @@ -188,26 +177,33 @@ new CLICommand({
arweave
});

const uploadStats: ArDriveUploadStats[] = await Promise.all(
filesToUpload.map(
async ({ parentFolderId, wrappedEntity, destinationFileName, driveKey, drivePassword }) => {
driveKey ??= (await parameters.getIsPrivate())
? await parameters.getDriveKey({
driveId: await arDrive.getDriveIdForFolderId(parentFolderId),
drivePassword,
useCache: true
})
: undefined;

return {
wrappedEntity,
driveKey,
destFolderId: parentFolderId,
destName: destinationFileName
};
}
)
);
const uploadStats: ArDriveUploadStats[] = await (async () => {
const uploadStats: ArDriveUploadStats[] = [];

for (const {
parentFolderId,
wrappedEntity,
destinationFileName,
driveKey,
drivePassword
} of filesToUpload) {
uploadStats.push({
wrappedEntity,
driveKey:
driveKey ?? (await parameters.getIsPrivate())
? await parameters.getDriveKey({
driveId: await arDrive.getDriveIdForFolderId(parentFolderId),
drivePassword,
useCache: true
})
: undefined,
destFolderId: parentFolderId,
destName: destinationFileName
});
}

return uploadStats;
})();

const results = await arDrive.uploadAllEntities({
entitiesToUpload: uploadStats,
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ __metadata:
"@types/source-map-support": ^0
"@typescript-eslint/eslint-plugin": ^4.18.0
"@typescript-eslint/parser": ^4.18.0
ardrive-core-js: 1.10.1
ardrive-core-js: 1.11.0
arweave: 1.10.18
axios: ^0.21.1
chai: ^4.3.4
Expand All @@ -1564,9 +1564,9 @@ __metadata:
languageName: unknown
linkType: soft

"ardrive-core-js@npm:1.10.1":
version: 1.10.1
resolution: "ardrive-core-js@npm:1.10.1"
"ardrive-core-js@npm:1.11.0":
version: 1.11.0
resolution: "ardrive-core-js@npm:1.11.0"
dependencies:
"@alexsasharegan/simple-cache": ^3.3.3
arbundles: ^0.5.5
Expand All @@ -1584,7 +1584,7 @@ __metadata:
smartweave: ^0.4.45
utf8: ^3.0.0
uuid: ^8.3.2
checksum: 1fa53eb705cf07fdfb705539760ea1abc935f124ea5e4c122e1719019e2a37531a4002bf0f1531935ec7e6739580013cb0c78ef0f359e00f06fe9b6209f95ca0
checksum: d3528d9923bae2b624b6b5963754457db696eaed8063718fcbffd75ec71235efe85f594afd2479a2ecabfc8983ae1e7c9274607ffd7f3af3779628eb061c1cc2
languageName: node
linkType: hard

Expand Down

0 comments on commit a529243

Please sign in to comment.