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: make deploy command bundle edge functions #4562

Merged
merged 18 commits into from
May 6, 2022
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
51fb231
feat: make deploy command bundle edge functions
jackiewmacharia Apr 25, 2022
9edb7b1
Merge branch 'main' into feat/make-deploy-bundle-edge-functions
jackiewmacharia Apr 25, 2022
e6cbd64
chore: use options used by buildSite
jackiewmacharia Apr 27, 2022
34d70c3
chore: update contributors field
jackiewmacharia Apr 27, 2022
04a710d
chore: remove no longer needed constants
jackiewmacharia Apr 27, 2022
625d4b0
Merge branch 'feat/make-deploy-bundle-edge-functions' of github.com:n…
jackiewmacharia Apr 27, 2022
0a0e13f
chore: import runCoreSteps from @Netlify/build instead
jackiewmacharia Apr 28, 2022
9fbdac0
Merge branch 'main' into feat/make-deploy-bundle-edge-functions
jackiewmacharia Apr 28, 2022
df2a622
Merge branch 'main' into feat/make-deploy-bundle-edge-functions
jackiewmacharia May 4, 2022
f2ca95a
chore: update netlify/build
jackiewmacharia May 4, 2022
b13fc27
Revert "chore: update netlify/build"
jackiewmacharia May 4, 2022
74bef38
chore: update netlify/build
jackiewmacharia May 4, 2022
bd6b888
Merge branch 'main' into feat/make-deploy-bundle-edge-functions
jackiewmacharia May 4, 2022
470b8ca
chore: handle for failed bundling
jackiewmacharia May 4, 2022
cdd90bc
Revert "chore: update netlify/build"
jackiewmacharia May 4, 2022
2e3984f
Merge branch 'main' into feat/make-deploy-bundle-edge-functions
jackiewmacharia May 4, 2022
624dd09
Merge branch 'main' into feat/make-deploy-bundle-edge-functions
jackiewmacharia May 6, 2022
707b122
refactor: add progress messages
eduardoboucas May 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/commands/deploy/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const inquirer = require('inquirer')
const isObject = require('lodash/isObject')
const prettyjson = require('prettyjson')

const runCoreStepPromise = import('@netlify/build')
const netlifyConfigPromise = import('@netlify/config')

const { cancelDeploy } = require('../../lib/api')
Expand Down Expand Up @@ -274,6 +275,10 @@ const deployProgressCb = function () {
}
return
}
case 'error':
stopSpinner({ error: true, spinner: events[event.type], text: event.msg })
delete events[event.type]
return
case 'stop':
default: {
stopSpinner({ spinner: events[event.type], text: event.msg })
Expand Down Expand Up @@ -381,6 +386,40 @@ const handleBuild = async ({ cachedConfig, options }) => {
return { newConfig, configMutations }
}

/**
*
* @param {object} options Bundling options
* @returns
*/
const bundleEdgeFunctions = async (options) => {
const { runCoreSteps } = await runCoreStepPromise
const statusCb = options.silent ? () => {} : deployProgressCb()

statusCb({
type: 'edge-functions-bundling',
msg: 'Bundling edge functions...\n',
phase: 'start',
})

const { severityCode, success } = await runCoreSteps(['edge_functions_bundling'], { ...options, buffer: true })
jackiewmacharia marked this conversation as resolved.
Show resolved Hide resolved

if (!success) {
statusCb({
type: 'edge-functions-bundling',
msg: 'Deploy aborted due to error while bundling edge functions',
phase: 'error',
})

exit(severityCode)
}

statusCb({
type: 'edge-functions-bundling',
msg: 'Finished bundling edge functions',
phase: 'stop',
})
}

/**
*
* @param {object} config
Expand Down Expand Up @@ -526,6 +565,12 @@ const deploy = async (options, command) => {
const deployFolder = await getDeployFolder({ options, config, site, siteData })
const functionsFolder = getFunctionsFolder({ options, config, site, siteData })
const { configPath } = site
const edgeFunctionsConfig = command.netlify.config.edge_functions

// build flag wasn't used and edge functions exist
if (!options.build && edgeFunctionsConfig && edgeFunctionsConfig.length !== 0) {
jackiewmacharia marked this conversation as resolved.
Show resolved Hide resolved
await bundleEdgeFunctions(options)
}

log(
prettyjson.render({
Expand Down