aws-amplify / amplify-cli

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

add update functions hooks does not contain function name and other options #8681

Open goldwareJapan opened 2 years ago

goldwareJapan commented 2 years ago

Before opening, please confirm:

How did you install the Amplify CLI?

npm install -g @aws-amplify/cli

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

v12.22.1

Amplify CLI Version

6.3.1

What operating system are you using?

Mac

Amplify Categories

function

Amplify Commands

add, update

Describe the bug

created post-update-function.js and post-add-function.js

const fs = require('fs');

const parameters = JSON.parse(fs.readFileSync(0, { encoding: 'utf8' }));

// Get the running Amplify CLI major version number
const currentCLIMajorVersion = parameters.data.amplify.version.split('.')[0];
console.log(
  'πŸš€ ~ file: post-add-function.js ~ line 7 ~ parameters.data',
  parameters.data,
);

Then added function. also updated function. (function name is aTest)

Hooks called. but data does not contain what options I chose on questions. I can't know what is the function name

output:

----- πŸͺ post-update-function execution start -----
πŸš€ ~ file: post-update-function.js ~ line 7 ~ parameters.data {
  "data": {
    "amplify": {
      "environment": {
        "projectPath": "/*****/",
        "defaultEditor": "vscode",
        "envName": "staging"
      },
      "command": "update",
      "subCommand": "function",
      "argv": [
        "/Users/*****/.nvm/versions/node/v12.22.1/bin/node",
        "/Users/*****/.nvm/versions/node/v12.22.1/bin/amplify",
        "function",
        "update"
      ],
      "version": "6.3.1"
    }
  }
}
Amplify CLI major version:  6
Minimum required Amplify CLI major version:  5
Minimum CLI version requirement met.
----- πŸͺ post-update-function execution end -----

Expected behavior

options i selected or inputted on cli questions to be includedI

Reproduction steps

created post-update-function.js and post-add-function.js

const fs = require('fs');

const parameters = JSON.parse(fs.readFileSync(0, { encoding: 'utf8' }));

// Get the running Amplify CLI major version number
const currentCLIMajorVersion = parameters.data.amplify.version.split('.')[0];
console.log(
  'πŸš€ ~ file: post-add-function.js ~ line 7 ~ parameters.data',
  parameters.data,
);

Then added function. also updated function. (function name is aTest)

Hooks called. but data does not contain what options I chose on questions. I can't know what is the function name

output:

----- πŸͺ post-update-function execution start -----
πŸš€ ~ file: post-update-function.js ~ line 7 ~ parameters.data {
  "data": {
    "amplify": {
      "environment": {
        "projectPath": "/*****/",
        "defaultEditor": "vscode",
        "envName": "staging"
      },
      "command": "update",
      "subCommand": "function",
      "argv": [
        "/Users/*****/.nvm/versions/node/v12.22.1/bin/node",
        "/Users/*****/.nvm/versions/node/v12.22.1/bin/amplify",
        "function",
        "update"
      ],
      "version": "6.3.1"
    }
  }
}
Amplify CLI major version:  6
Minimum required Amplify CLI major version:  5
Minimum CLI version requirement met.
----- πŸͺ post-update-function execution end -----

GraphQL schema(s)

No response

Log output

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

Additional information

No response

dave-moser commented 2 years ago

It would be very helpful to have access to the name of the function that was added in the pre/post-add-function hooks. This would allow you to take action on that specific function's content.