Skip to content

Make deploy function lifecycle events more fine grain - #2561

Merged
austencollins merged 11 commits into
serverless:masterfrom
doapp-ryanp:master
Nov 14, 2016
Merged

austencollins merged 11 commits into
serverless:masterfrom
doapp-ryanp:master

Conversation

@doapp-ryanp

Copy link
Copy Markdown
Contributor

What did you implement:

Exposed new lifecycle events for sls deploy function

Currently there is no way to hook into the different phases of sls deploy function. This prevents things like being able to browserify/webpack during sls deploy function. This can be done on the sls deploy via the deploy:createDeploymentArtifacts hook, so this PR adds equivalent capabilities.

How did you implement it:

Exposed 2 new lifecycleEvents to deploy.function

How can we verify it:

Just run sls deploy function -f <name> and verify function deploys the same it did before this PR.

_Is this ready for review?:_ YES

@austencollins

Copy link
Copy Markdown
Member

Looks good. I've also been needing this functionality. Let's have one other person on the team check it out before merging :) @eahefnawy are you available for this one?

@doapp-ryanp

Copy link
Copy Markdown
Contributor Author

Hold off on merging this. Looks like there are some issues with deployFunction/index.js not honoring what is documented about artifact:

Serverless won't zip your service if this is configured

However this is not the case when you do sls deploy function -f <name>. I'm writing a plugin that relies on setting the artifact so I can browserify code and create zip.

I probably wont get to fixing deployFunction/index.js until early next week.

@doapp-ryanp

Copy link
Copy Markdown
Contributor Author

OK this is good to go from my perspective. Having a defined package.artifact does indeed bypass default packaging, I just had a typo in my code. I've added logging for clarity on why default packaging is skipped.

The CI error is a lint error not introduced by my code, so not sure why its failing...

@doapp-ryanp

Copy link
Copy Markdown
Contributor Author

@eahefnawy any chance of this making it in next release? I got a few plugins dependent on it.

@austencollins

Copy link
Copy Markdown
Member

Ping @flomotlik @eahefnawy @pmuens

pmuens
pmuens previously requested changes Nov 14, 2016

@pmuens pmuens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @doapp-ryanp thanks for submitting this 👍 💯 !

Really like the new, multiple lifecycle events instead of a single deploy lifecycle event (which is very general).

Just added a few comments.


zipFunction() {
packageFunction() {
this.serverless.cli.log(`Packaging function: ${this.options.function}...`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would be great if we could add the ellipsis at the end (instead of three dots).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not quite sure what you mean, can you elaborate? An ellipsis is 3 trailing dots.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@doapp-ryanp to be precise an ellipsis is a character that looks like three dots

… <- ellipsis
... <- 3 dots

@gertjvr gertjvr Nov 15, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is ellipsis favored over 3 dots it renders poorly in non uni-code consoles.

Serverless: Packaging service…
Serverless: Deleted .env file from D:\Source\.env
Serverless: Uploading CloudFormation file to S3…
Serverless: Uploading function .zip files to S3…
Serverless: Updating Stack…
Serverless: Checking Stack update progress…

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thx for the heads up @gertjvr. I don't think we knew this. cc @nikgraf

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

good point @gertjvr, I didn't expect anyone still running without a terminal without unicode 😱

let's go back to 3 dots for terminal output? @flomotlik @ac360

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@nikgraf some of use still use windows as our main os 😱

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh, that's a bummer. just opened a PR to improve to fix the experience on Windows again: #2714

});

it('should run promise chain in order', () => {
describe('hooks', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure about this describe block as we've not used it anywhere else

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm fine with whatever eye catcher string you wish to use

functionObject.artifact = null; // reset the current artifact

if (funcPackageConfig.artifact) {
if (process.env.SLS_DEBUG) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Love the ability to get debug information about the current status. Although I'm not sure if we should add it that way or find a more general way to deal with it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'd prefer a method in the sls framework that is something like utils.debug() that handles the env var checking. However I felt like adding that function to the core is outside the scope of this feature branch/pr.

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.

5 participants