Skip to content
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

PE-7109: feat(cli) add custom Arweave tags support #216

Conversation

thiagocarvalhodev
Copy link
Collaborator

  • Add tags option to CLI for specifying custom Arweave tags
  • Implement tag parsing utility for CLI input format (name/value pairs)
  • Update upload file options to include tags parameter
  • Add types for tag support in UploadFileOptions
  • Forward parsed tags to upload methods

Example usage:

turbo upload-file --tags Content-Type image/png App-Name MyApp

image

- Add tags option to CLI for specifying custom Arweave tags
- Implement tag parsing utility for CLI input format (name/value pairs)
- Update upload file options to include tags parameter
- Add types for tag support in UploadFileOptions
- Forward parsed tags to upload methods

Example usage:
turbo upload-file --tags Content-Type image/png App-Name MyApp
@thiagocarvalhodev thiagocarvalhodev requested a review from a team as a code owner January 17, 2025 15:23
@thiagocarvalhodev thiagocarvalhodev self-assigned this Jan 17, 2025
@thiagocarvalhodev thiagocarvalhodev changed the base branch from main to alpha January 17, 2025 15:41
src/cli/options.ts Outdated Show resolved Hide resolved
@arielmelendez
Copy link
Contributor

Seems like rogue file .turbo/daemon/56c39e22af4d63cb-turbo.log.2025-01-17 needs to be removed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this?

CHANGELOG.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to rebase if this is here?

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.40%. Comparing base (d81f33a) to head (923bd59).
Report is 8 commits behind head on alpha.

Additional details and impacted files
@@           Coverage Diff           @@
##            alpha     #216   +/-   ##
=======================================
  Coverage   93.40%   93.40%           
=======================================
  Files          25       25           
  Lines        3562     3562           
  Branches      161      161           
=======================================
  Hits         3327     3327           
  Misses        235      235           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/cli/utils.ts Outdated

const tags: { name: string; value: string }[] = [];

for (let i = 0; i < tagsArr.length; i += 2) {
Copy link
Contributor

@arielmelendez arielmelendez Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change this but another way to do this in fewer lines of code:

while(a.length) {
  const tag = { name: tagsArr.shift(), value: tagsArr.shift() };
  if (tag.name === undefined || tag.value === undefined) {
    throw new Error(
        'Invalid tag format. Each tag must have both a name and value.',
      );
  }
  tags.push(tag);
}

While loops can be risky but the risks are pretty contained here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QUICK NOTE: Empty strings are falsey in js. Double check on the validity of empty tag names and values.

tags: {
description:
'An array of additional tags for the write action, in "--tags name1 value1 name2 value2" format',
alias: '--tags <tags...>',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the correct use of alias? Seems like no alias is being assigned.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it looks good. We could include a short code alias here but need to check if they conflict with other short codes

image

thiagocarvalhodev and others added 4 commits January 17, 2025 14:12
Co-authored-by: Derek Sonnenberg <derek@ardrive.io>
- Add tags option to upload commands
- Integrate tag support in uploadFile and uploadFolder commands
- Add tags to UploadOptions interface
…tent-type' of github.com:ardriveapp/turbo-sdk into PE-7109-upload-file-turbo-cli-allow-custom-tags-and-content-type
@thiagocarvalhodev thiagocarvalhodev merged commit c0214ba into alpha Jan 22, 2025
9 checks passed
@thiagocarvalhodev thiagocarvalhodev deleted the PE-7109-upload-file-turbo-cli-allow-custom-tags-and-content-type branch January 22, 2025 18:05
@dtfiedler
Copy link
Collaborator

🎉 This PR is included in version 1.22.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dtfiedler
Copy link
Collaborator

🎉 This PR is included in version 1.22.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants