components icon indicating copy to clipboard operation
components copied to clipboard

Cannot run custom method

Open sheerun opened this issue 6 years ago • 8 comments

Description

npm install -g serverless
mkdir foobar
cd foobar
npm init -f
npm install serverless-next.js --save-dev
echo "myNextApplication:\n  component: serverless-next.js" > serverless.yml
sls build

Result:

error: Error: "component" input is required to run custom methods at Proxy. (/usr/local/lib/node_modules/serverless/node_modules/@serverless/template/utils.js:350:13) at Object.runComponents (/usr/local/lib/node_modules/serverless/node_modules/@serverless/cli/src/index.js:209:40)

Expected:

build custom method of component is executed

sheerun avatar Nov 04 '19 20:11 sheerun

I'm running into this same issue too when attempting to try out the website component. In my case, nothing is deployed during the first deploy and then any subsequent attempt results in the error above.

mpetito-envative avatar Nov 07 '19 13:11 mpetito-envative

@sheerun try:

sls --component=targetComponent build

Because there can be multiple components in 1 project, the cli can only assume methods like default and remove to be present on all of them. When running a custom method, you need to first specify which component you are talking about

dodgeblaster avatar Nov 23 '19 23:11 dodgeblaster

Is there documentation for this somewhere? I tried to find it but I failed

sheerun avatar Nov 25 '19 21:11 sheerun

(for --component flag)

sheerun avatar Nov 25 '19 21:11 sheerun

not that I can find, I figured it out by diving into the source code. I think if the error message was updated to be more clearer, that would solve a lot of confusion. Also, it should be documented.

dodgeblaster avatar Nov 25 '19 21:11 dodgeblaster

@sheerun did running --component work for you?

dodgeblaster avatar Nov 25 '19 21:11 dodgeblaster

I'd just suggest instead of documenting it, to make it a positional argument so it's easy to deploy single component or run custom function of some component, so:

  • sls targetComponent deploy deploys single component
  • sls targetComponent remove removes single component
  • sls targetComponent build runs custom build method of single component
  • sls build - informs user that you can't run custom method without specifying component

sheerun avatar Nov 25 '19 21:11 sheerun

(--component flag works)

Also maybe a good a default, when only one component is defined, is to run custom method of that component.

sheerun avatar Nov 25 '19 21:11 sheerun