8000 Merge branch 'main' into renovate/netlify-serverless-functions-api-1.x · netlify/cli@56dddf3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 56dddf3

Browse files
Merge branch 'main' into renovate/netlify-serverless-functions-api-1.x
2 parents ccc8986 + c7fb082 commit 56dddf3

File tree

7 files changed

+196
-174
lines changed

7 files changed

+196
-174
lines changed

src/commands/build/build.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const build = async (options, command) => {
4848

4949
const buildOptions = await getBuildOptions({
5050
cachedConfig,
51+
packagePath: command.workspacePackage,
5152
token,
5253
options,
5354
})

src/commands/deploy/deploy.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,16 +400,18 @@ const runDeploy = async ({
400400
*
401401
* @param {object} config
402402
* @param {*} config.cachedConfig
403+
* @param {string} [config.packagePath]
403404
* @param {import('commander').OptionValues} config.options The options of the command
404405
* @returns
405406
*/
406-
const handleBuild = async ({ cachedConfig, options }) => {
407+
const handleBuild = async ({ cachedConfig, options, packagePath }) => {
407408
if (!options.build) {
408409
return {}
409410
}
410411
const [token] = await getToken()
411412
const resolvedOptions = await getBuildOptions({
412413
8000 cachedConfig,
414+
packagePath,
413415
token,
414416
options,
415417
})
@@ -589,6 +591,7 @@ const deploy = async (options, command) => {
589591
}
590592

591593
const { configMutations = [], newConfig } = await handleBuild({
594+
packagePath: command.workspacePackage,
592595
cachedConfig: command.netlify.cachedConfig,
593596
options,
594597
})

src/lib/build.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@ import { featureFlags as edgeFunctionsFeatureFlags } from './edge-functions/cons
1919
*
2020
* @param {object} config
2121
* @param {*} config.cachedConfig
22+
* @param {string} [config.packagePath]
2223
* @param {string} config.token
2324
* @param {import('commander').OptionValues} config.options
2425
* @returns {BuildConfig}
2526
*/
2627
export const getBuildOptions = ({
2728
cachedConfig,
2829
options: { context, cwd, debug, dry, json, offline, silent },
30+
packagePath,
2931
token,
3032
}) => ({
3133
cachedConfig,
3234
siteId: cachedConfig.siteInfo.id,
35+
packagePath,
3336
token,
3437
dry,
3538
debug,

src/lib/functions/server.mjs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,20 @@ const getFunctionsServer = (options) => {
219219
return app
220220
}
221221

222+
/**
223+
*
224+
* @param {object} options
225+
* @param {import('../../commands/base-command.mjs').default} options.command
226+
* @param {*} options.capabilities
227+
* @param {*} options.config
228+
* @param {boolean} options.debug
229+
* @param {*} options.loadDistFunctions
230+
* @param {*} options.settings
231+
* @param {*} options.site
232+
* @param {string} options.siteUrl
233+
* @param {*} options.timeouts
234+
* @returns
235+
*/
222236
export const startFunctionsServer = async (options) => {
223237
const { capabilities, command, config, debug, loadDistFunctions, settings, site, siteUrl, timeouts } = options
224238
const internalFunctionsDir = await getInternalFunctionsDir({ base: site.root })
@@ -260,15 +274,22 @@ export const startFunctionsServer = async (options) => {
260274

261275
const server = await getFunctionsServer(Object.assign(options, { functionsRegistry }))
262276

263-
await startWebServer({ server, settings })
277+
await startWebServer({ server, settings, debug })
264278
}
265279

266-
const startWebServer = async ({ server, settings }) => {
267-
await new Promise((resolve) => {
268-
server.listen(settings.functionsPort, (err) => {
280+
/**
281+
*
282+
* @param {object} config
283+
* @param {boolean} config.debug
284+
* @param {ReturnType<Awaited<typeof getFunctionsServer>>} config.server
285+
* @param {*} config.settings
286+
*/
287+
const startWebServer = async ({ debug, server, settings }) => {
288+
await new Promise((/** @type {(resolve: void) => void} */ resolve) => {
289+
server.listen(settings.functionsPort, (/** @type {unknown} */ err) => {
269290
if (err) {
270291
errorExit(`${NETLIFYDEVERR} Unable to start functions server: ${err}`)
271-
} else {
292+
} else if (debug) {
272293
log(`${NETLIFYDEVLOG} Functions server is listening on ${settings.functionsPort}`)
273294
}
274295
resolve()

0 commit comments

Comments
 (0)
0