Skip to content
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

Add modern logs for Serverless Framework v3 #646

Merged
merged 12 commits into from
Nov 25, 2021
Merged

Conversation

pgrzesik
Copy link
Collaborator

Configured in a way that would allow support both for v2 and v3 versions of the Framework

@pgrzesik pgrzesik self-assigned this Nov 23, 2021
@pgrzesik pgrzesik force-pushed the add-modern-logs branch 2 times, most recently from 0bc3ef9 to 6558824 Compare November 24, 2021 09:40
@pgrzesik pgrzesik force-pushed the add-modern-logs branch 2 times, most recently from ea17323 to 0149309 Compare November 24, 2021 21:19
lib/clean.js Outdated
if (this.serverless) {
this.serverless.cli.log(`Removing static caches at: ${cacheLocation}`);
if (this.progress && this.log) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine to check just for this.log (also later, when we may want to unconditionally switch to modern logs, it'll make easier to pick all those conditionals by searching if (this.log)

lib/clean.js Outdated
@@ -50,10 +57,19 @@ function cleanupCache() {
.forEach((file) => {
promises.push(fse.removeAsync(file));
});
return BbPromise.all(promises);
return BbPromise.all(promises)
.then(() => cleanupProgress && cleanupProgress.remove())
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use .finally

lib/docker.js Show resolved Hide resolved
lib/inject.js Outdated
if (this.serverless.service.package.individually) {
return BbPromise.resolve(this.targetFuncs)
returnPromise = BbPromise.resolve(this.targetFuncs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not simply convert it to async function, and use finally?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

great suggestion

lib/layer.js Outdated
return BbPromise.bind(this)
.then(zipRequirements)
.then(createLayers)
.then(() => layerProgress && layerProgress.remove())
Copy link
Contributor

Choose a reason for hiding this comment

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

.finally

lib/zip.js Outdated
).then((zip) => writeZip(zip, `${f.module}/.requirements.zip`));
return addTree(new JSZip(), `.serverless/${f.module}/requirements`)
.then((zip) => writeZip(zip, `${f.module}/.requirements.zip`))
.then(() => packProgress && packProgress.remove())
Copy link
Contributor

Choose a reason for hiding this comment

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

.finally

/^python.*/
try {
if (this.serverless.service.package.individually) {
await BbPromise.resolve(this.targetFuncs)
Copy link
Contributor

Choose a reason for hiding this comment

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

It should return await to work in same way (but not sure, maybe it won't make difference)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've skipped that return because the result is not actually used anywhere

);
});
} else if (!this.options.zip) {
await injectRequirements(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

lib/zip.js Outdated
.then((zip) =>
writeZip(zip, path.join(this.servicePath, '.requirements.zip'))
)
.then(() => packProgress && packProgress.remove())
Copy link
Contributor

Choose a reason for hiding this comment

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

finally

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

Great work 👍

@pgrzesik pgrzesik merged commit 9479a90 into master Nov 25, 2021
@pgrzesik pgrzesik deleted the add-modern-logs branch November 25, 2021 14:32
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.

None yet

2 participants