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

Feat: edge handlers deploy #1244

Merged
merged 14 commits into from
Sep 21, 2020
Merged

Feat: edge handlers deploy #1244

merged 14 commits into from
Sep 21, 2020

Conversation

erezrokah
Copy link
Contributor

@erezrokah erezrokah commented Sep 16, 2020

- Summary

Fixes #1236

This is a draft PR not to be reviewed yet (needs some cleanup and tests).
Opening for visibility.

Depends on netlify/js-client#155 and branched out from #1240

The flow is:

  1. Create the deploy (used to be in js-client)
  2. Upload Edge Handlers if .netlify/edge-handlers exists or passed as an argument via --edgeHandlers
  3. Run deploy from js-client with the created deployId

Will add comments after #1240 is merged and I do a rebase.

- Test plan

  • Going to add dedicated tests for the deploy command (similar to addons and env).

- Description for the changelog

Support deploying Edge Handlers as a part of the deploy command.

- A picture of a cute animal (not mandatory but encouraged)

🐻

@github-actions github-actions bot added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Sep 16, 2020
@erezrokah erezrokah force-pushed the feat/edge_handlers_deploy branch 2 times, most recently from e4ba7b7 to d6b994d Compare September 17, 2020 08:46
@@ -16,8 +14,8 @@ const isObject = require('lodash.isobject')
const SitesCreateCommand = require('./sites/create')
const LinkCommand = require('./link')
const { NETLIFYDEV, NETLIFYDEVLOG, NETLIFYDEVERR } = require('../utils/logo')

const statAsync = promisify(fs.stat)
const { statAsync } = require('../lib/fs')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have a few places in the code that we used promisify with fs.
Moved those to a shared lib

@@ -170,15 +168,27 @@ const runDeploy = async ({
log('Deploying to draft URL...')
}

const draft = !deployToProduction && !alias
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We first create the deploy, then upload edge handlers and finally let js-client finalise the deploy and upload files and functions.

@@ -212,7 +222,6 @@ const runDeploy = async ({
const logsUrl = `${get(results, 'deploy.admin_url')}/deploys/${get(results, 'deploy.id')}`

return {
name: results.deploy.deployId,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

results.deploy.deployId is always undefined, this should be either results.deploy.id or results.deployId.
Since name was never printed, and deployId is already part of the result, I chose to remove the line entirely.

@erezrokah erezrokah marked this pull request as ready for review September 17, 2020 09:07
@erezrokah
Copy link
Contributor Author

@ehmicky, going to add some tests, but this is ready to review.

} catch (e) {
updateProgress(spinner, `Failed deploying Edge Handlers: ${e.message}`, logSymbols.error)
try {
await api.cancelSiteDeploy({ deploy_id: deployId })
Copy link
Contributor Author

@erezrokah erezrokah Sep 17, 2020

Choose a reason for hiding this comment

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

This cleanup can also be moved to the main deploy function if that makes more sense

Copy link
Contributor

@ehmicky ehmicky left a comment

Choose a reason for hiding this comment

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

We are moving super fast on this! 🎉

src/utils/edge-handlers.js Outdated Show resolved Hide resolved
src/commands/deploy.js Outdated Show resolved Hide resolved
src/utils/gitignore.js Outdated Show resolved Hide resolved
src/utils/edge-handlers.js Outdated Show resolved Hide resolved
src/commands/deploy.js Outdated Show resolved Hide resolved
src/utils/edge-handlers.js Show resolved Hide resolved
src/utils/edge-handlers.js Outdated Show resolved Hide resolved
@@ -179,21 +197,7 @@ class BaseCommand extends Command {
* @return {[string, string]} - tokenValue & location of resolved Netlify API token
*/
getConfigToken(tokenFromFlag) {
Copy link
Contributor Author

@erezrokah erezrokah Sep 17, 2020

Choose a reason for hiding this comment

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

Can't remove this since it's used in child classes

@@ -291,4 +295,5 @@ BaseCommand.flags = {
}),
}

BaseCommand.getToken = getToken
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used in the tests


const siteName =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved most of the site creating logic into './utils/createLiveTestSite'

if (!spinner) {
return
}
const symbol = error ? logSymbols.error : logSymbols.success
Copy link
Contributor

@ehmicky ehmicky Sep 17, 2020

Choose a reason for hiding this comment

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

Nice touch :)
(Hiding logSymbols behind an error property)

Copy link
Contributor

@ehmicky ehmicky left a comment

Choose a reason for hiding this comment

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

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deploy edge handlers locally
2 participants