aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.83k stars 823 forks source link

context.exeInfo isn't available on PrePush event #11268

Open letsbelopez opened 2 years ago

letsbelopez commented 2 years ago

Before opening, please confirm:

How did you install the Amplify CLI?

yarn setup-dev

If applicable, what version of Node.js are you using?

v17.3.1

Amplify CLI Version

10.3.1

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

no

Amplify Categories

Not applicable

Amplify Commands

push

Describe the bug

I'm developing a new event handler, Pre Push, for the amplify-util-uibuilder package. Here is my feature branch with the handler: https://github.com/letsbelopez/amplify-cli/blob/util-uibuilder/detached-forms/packages/amplify-util-uibuilder/src/event-handlers/handle-PrePush.ts#L10

While developing the Pre Push handler, I had access the context.exeInfo.projectConfig. Checking this object verifies we have the right context to continue executing the pre push handler. Here is the check: https://github.com/letsbelopez/amplify-cli/blob/util-uibuilder/detached-forms/packages/amplify-util-uibuilder/src/commands/utils/shouldRenderComponents.ts#L20

I just rebased my commit with the dev branch, and now context.exeInfo is not defined inside the Pre Push handler. It is defined on Post Pull and Post Push though.

Expected behavior

context.exeInfo.projectConfig is defined on a Pre Push event.

Reproduction steps

  1. Clone my feature branch with a Pre Push handler: https://github.com/letsbelopez/amplify-cli/blob/util-uibuilder/detached-forms/packages/amplify-util-uibuilder/src/commands/utils/shouldRenderComponents.ts#L20
  2. yarn setup-dev
  3. try an amplify-dev push and there won't be a context.exeInfo.projectConfig defined
  4. try an amplify-dev pull and context.exeInfo.projectConfig will be defined
  5. try it using the --debug flag for the output messaging

GraphQL schema(s)

```graphql # Put schemas below this line ```

Project Identifier

9726834578f7eb008dd7840e038459ec

inside a non prod environment if that makes a difference

Log output

``` # Put your logs below this line ```

Additional information

No response

letsbelopez commented 2 years ago

This may be related, but I noticed our Post Env Add event stopped working because of a similar issue.

Here's the event handler: https://github.com/aws-amplify/amplify-cli/blob/dev/packages/amplify-util-uibuilder/src/event-handlers/handle-PostEnvAdd.ts#L11

And this line hits the error:

TypeError: Cannot read property 'awscloudformation' of undefined

This error only shows with the --debug flag