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
Allow 3rd-party plugin to CDK override #9601
Allow 3rd-party plugin to CDK override #9601
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9601 +/- ##
==========================================
+ Coverage 46.67% 46.78% +0.10%
==========================================
Files 706 708 +2
Lines 35268 35273 +5
Branches 7148 7149 +1
==========================================
+ Hits 16462 16502 +40
+ Misses 17014 16981 -33
+ Partials 1792 1790 -2
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
@akshbhu @ammarkarachi @jhockett @kaustavghosh06 |
Hey @fossamagna, sorry for the delayed response. One of our team's internal goals is to reduce the usage of the |
const pluginInfo = context.amplify.getCategoryPluginInfo(context, resource.category, resource.resourceName); | ||
const { transformCategoryStack } = pluginInfo ? await import(pluginInfo.packageLocation) : { transformCategoryStack: null }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this PR was reduced to these lines here, I think that would achieve the majority of use cases for #9226. Thoughts @fossamagna?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @jhockett
If this PR was reduced to these lines here, I think that would achieve the majority of use cases for #9226.
Yes, I think so.
What is the use case for the changes made to auth, storage, and api?
I added context
object to use CLIInputSchemaValidator
on 3rd-party plugin at following.
I think that it will be resolved by implementing equivalent CLIInputSchemaValidator
in 3rd-party plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand now, thanks for the examples! I think we should include the plugin support for the schema generator too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jhockett
I think that it is unnecessary modify to support for the schema generator, because generated schema path resolved by relative path. If I overlooking what should be support for the schema generator, I would like to seek your advice on this.
amplify-cli/packages/amplify-cli-core/src/category-interfaces/category-base-schema-generator.ts
Lines 32 to 33 in ae7b001
TYPES_SRC_ROOT = path.join('.', 'src', 'provider-utils', 'awscloudformation', 'service-walkthrough-types'); | |
SCHEMA_FILES_ROOT = path.join('.', 'resources', 'schemas'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fossamagna The schema generator takes a category's TypeScript type for the input state and returns a JSON schema that the category's cli-inputs.json
should conform to.
Example input state schema for REST APIs: https://github.com/aws-amplify/amplify-cli/blob/ae7b001f274f327a29c99c67fe851272c6208e84/packages/amplify-category-api/resources/schemas/aPIGateway/APIGatewayCLIInputs.schema.json
Where the schema validation logic is invoked:
amplify-cli/packages/amplify-category-api/src/provider-utils/awscloudformation/apigw-input-state.ts
Line 217 in ae7b001
public isCLIInputsValid(cliInputs?: ApigwInputs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jhockett I understand now, schema generator is pointing to CLIInputSchemaValidator
class in category-base-schema-genereator.ts
, not CLIInputSchemaGenerator
class.
Then, I don't think I have any part of this PR that needs to be corrected.
What do you think on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @fossamagna, sorry for the delayed response. Thinking about it more, this approach LGTM 👍
const pluginInfo = context.amplify.getCategoryPluginInfo(context, resource.category, resource.resourceName); | ||
const { transformCategoryStack } = pluginInfo ? await import(pluginInfo.packageLocation) : { transformCategoryStack: null }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @fossamagna, sorry for the delayed response. Thinking about it more, this approach LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM @fossamagna! I have one requested change above regarding a removed export and I'd also like to see a unit test for custom plugins to make sure we avoid regressions here.
Thank you for the contribution!
@jhockett Thank you for the review many times. |
@jhockett Is this RP has blockers? Is there anything I can do? |
Apologies for the delayed review @fossamagna, LGTM Thank you for your contribution! |
@fossamagna Thanks for the PR this is good work, A PR got merged would need rebasing |
@ammarkarachi Thank you for your review. |
It's good we are going to squash the commits anyway |
path to schema json restricted to starts with `@aws-amplify/amplify-category-` literal, changed to use package location in pluginInfo as loading path of schema json ref aws-amplify#9226
652e404
to
4c4a37d
Compare
Description of changes
Allow 3rd-party plugin to CDK override. Some restricted points to starts with
@aws-amplify/amplify-category-
literal changed to use package location in pluginInfo.Issue #, if available
fix #9226
Description of how you validated changes
git clone -b allow-3rd-party-override git@github.com:fossamagna/amplify-cli.git
cd amlify-cli
yarn setup-dev
git clone -b override git@github.com:fossamagna/amplify-category-console-notification.git
cd amplify-category-console-notification
amplify-cli-core
inpackage.json
to the path to localamplify-cli-core
you checked out in the previous step.yarn build
amplify-dev plugin add $(pwd)/amplify-category-console-notification
amplify-dev plugin scan
amplify-dev init
. initialize sample project in order to testadd
command.amplify-dev add consolenotification
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.