Skip to content

WIP: Assets plugin #230

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

Merged
merged 26 commits into from
Apr 30, 2021
Merged

WIP: Assets plugin #230

merged 26 commits into from
Apr 30, 2021

Conversation

philnash
Copy link
Contributor

This is a new Twilio CLI plugin that can create a new Twilio Runtime Service to be used as a bucket to store assets. You can then upload assets to the bucket and list the currently available assets.

I am starting a draft PR to get feedback on the code and on how is best to release this. Should we get it out as a version 1 alongside the major release of all other serverless toolkit packages?

It includes some changes to serverless-api, though these are really just exporting a couple of functions that weren't previously exported.

Contributing to Twilio

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.

  • I acknowledge that all my contributions will be made under the project's license.

@philnash philnash added this to the v3 milestone Apr 16, 2021
@dkundel
Copy link
Contributor

dkundel commented Apr 16, 2021

I think this looks great overall and I'm happy to release it alongside the rest. The only thing I'd say is that because it's not a standalone like twilio-run you should use the built-in Twilio CLI output and logging mechanisms (I think using spinners makes sense) so that -l for log levels and -o for machine readable output works. I think especially for this plugin and the assets:list command having machine readable output is useful.

@philnash
Copy link
Contributor Author

Ah yes, I did mean to include those bits.

I'm actually holding off including this until twilio-cli-core#118 is deployed with the CLI this week. That way I can dump the configStore and use the new built in storage commands in the CLI (and throw an error with a message to upgrade the Twilio CLI if someone tries to use this with an older version).

I meant to add tests too 😄 I can get to them after v1 though.

@philnash philnash marked this pull request as ready for review April 25, 2021 10:49
@philnash
Copy link
Contributor Author

I think this is ready for a real review now. It works with all the basic Twilio CLI flags and while it does still lack tests, it works!

} catch (error) {
logger.debug(error.toString());
throw new TwilioCliError(
`Could not fetch asset service environment with config:
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be useful to provide some steps here as to why / how to fix it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a message to run in debug mode for more detail. Many of the errors throughout these scripts should not occur unless there is a network error or the user has edited the config file by hand and changed the SIDs.

newAsset.sid = existingAsset.sid;
spinner.start('Overwriting existing asset');
} else if (answers.conflict === 'Rename') {
let newNameAnswers = await inquirer.prompt([
Copy link
Contributor

Choose a reason for hiding this comment

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

We should do verification here that it doesn't contain invalid characters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Invalid characters are ;,?:@+&$()' " and fragments, so #.

Most of these can actually be uri encoded and still work fine. Rather than confuse the code (we should also check filenames which are passed in as the original file, for example) for an edge case I would prefer for now to fail the asset version upload with a better error message (I've added the asset path to the failure message).

We can add this sort of checking in later, if required.


const spinner = ora();

const upload = async ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you break the different steps in this function into individual functions? Just makes reading this and debugging it easier.

@philnash philnash requested a review from dkundel April 28, 2021 07:52
@philnash philnash merged commit f90c112 into main Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants