Skip to content

Commit 08588bf

Browse files
renovate[bot]renovate-boteduardoboucaserezrokah
authored
fix(deps): update netlify packages (major) (#2059)
* fix(deps): update netlify packages * fix: use new functionsDirectory property from config * chore: update package-lock * chore: update functions directory syntax in tests * fix: use new functionsDirectory config property * chore: remove unnecessary usage of dot-prop * chore: update log message to new functions directory * test(command-functions): update netlify toml to new format * chore: upgrade @netlify/config and @netlify/build Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: Eduardo Bouças <[email protected]> Co-authored-by: erezrokah <[email protected]>
1 parent 0dd7815 commit 08588bf

File tree

10 files changed

+90
-334
lines changed

10 files changed

+90
-334
lines changed

package-lock.json

Lines changed: 47 additions & 295 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@
7474
"prettier": "--ignore-path .gitignore --loglevel=warn \"{src,scripts,site,tests,.github}/**/*.{js,md,yml,json,html}\" \"*.{js,yml,json,html}\" \".*.{js,yml,json,html}\" \"!CHANGELOG.md\" \"!package-lock.json\""
7575
},
7676
"dependencies": {
77-
"@netlify/build": "^9.19.1",
78-
"@netlify/config": "^4.3.0",
77+
"@netlify/build": "^10.1.0",
78+
"@netlify/config": "^5.1.0",
7979
"@netlify/framework-info": "^3.2.1",
8080
"@netlify/plugin-edge-handlers": "^1.11.6",
8181
"@netlify/plugins-list": "^2.5.1",

src/commands/deploy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const validateDeployFolder = async ({ deployFolder, error }) => {
9494
const getFunctionsFolder = ({ flags, config, site, siteData }) => {
9595
let functionsFolder
9696
// Support "functions" and "Functions"
97-
const funcConfig = get(config, 'build.functions') || get(config, 'build.Functions')
97+
const funcConfig = config.functionsDirectory
9898
if (flags.functions) {
9999
functionsFolder = path.resolve(process.cwd(), flags.functions)
100100
} else if (funcConfig) {

src/commands/dev/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class DevCommand extends Command {
217217
config.build = { ...config.build }
218218
const devConfig = {
219219
framework: '#auto',
220-
...(config.build.functions && { functions: config.build.functions }),
220+
...(config.functionsDirectory && { functions: config.functionsDirectory }),
221221
...(config.build.publish && { publish: config.build.publish }),
222222
...config.dev,
223223
...flags,

src/commands/functions/build.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ class FunctionsBuildCommand extends Command {
2121
const dst =
2222
flags.functions ||
2323
(config.dev && config.dev.functions) ||
24-
(config.build && config.build.functions) ||
24+
config.functionsDirectory ||
2525
flags.Functions ||
26-
(config.dev && config.dev.Functions) ||
27-
(config.build && config.build.Functions)
26+
(config.dev && config.dev.Functions)
2827

2928
if (src === dst) {
3029
this.log(`${NETLIFYDEVERR} Source and destination for function build can't be the same`)

src/commands/functions/create.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ const DEFAULT_PRIORITY = 999
199199

200200
/* get functions dir (and make it if necessary) */
201201
const ensureFunctionDirExists = function (context, flags, config) {
202-
const functionsDir = config.build && config.build.functions
202+
const functionsDir = config.functionsDirectory
203203
if (!functionsDir) {
204204
context.log(`${NETLIFYDEVLOG} No functions folder specified in netlify.toml`)
205205
process.exit(1)

src/commands/functions/invoke.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ class FunctionsInvokeCommand extends Command {
3434
const { flags, args } = this.parse(FunctionsInvokeCommand)
3535
const { config } = this.netlify
3636

37-
const functionsDir =
38-
flags.functions || (config.dev && config.dev.functions) || (config.build && config.build.functions)
37+
const functionsDir = flags.functions || (config.dev && config.dev.functions) || config.functionsDirectory
3938
if (typeof functionsDir === 'undefined') {
4039
this.error('functions directory is undefined, did you forget to set it in netlify.toml?')
4140
}

src/commands/functions/list.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,13 @@ class FunctionsListCommand extends Command {
4646
const functionsDir =
4747
flags.functions ||
4848
(config.dev && config.dev.functions) ||
49-
(config.build && config.build.functions) ||
49+
config.functionsDirectory ||
5050
flags.Functions ||
51-
(config.dev && config.dev.Functions) ||
52-
(config.build && config.build.Functions)
51+
(config.dev && config.dev.Functions)
5352

5453
if (typeof functionsDir === 'undefined') {
5554
this.log('Functions directory is undefined')
56-
this.log('Please verify build.functions is set in your Netlify configuration file (netlify.toml/yml/json)')
55+
this.log('Please verify functions.directory is set in your Netlify configuration file (netlify.toml/yml/json)')
5756
this.log('See https://docs.netlify.com/configure-builds/file-based-configuration/ for more information')
5857
process.exit(1)
5958
}

tests/command.dev.test.js

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ testMatrix.forEach(({ args }) => {
150150

151151
test(testName('should return response from a function with setTimeout', args), async (t) => {
152152
await withSiteBuilder('site-with-set-timeout-function', async (builder) => {
153-
builder.withNetlifyToml({ config: { build: { functions: 'functions' } } }).withFunction({
153+
builder.withNetlifyToml({ config: { functions: { directory: 'functions' } } }).withFunction({
154154
path: 'timeout.js',
155155
handler: async () => {
156156
console.log('ding')
@@ -177,7 +177,7 @@ testMatrix.forEach(({ args }) => {
177177

178178
test(testName('should serve function from a subdirectory', args), async (t) => {
179179
await withSiteBuilder('site-with-from-subdirectory', async (builder) => {
180-
builder.withNetlifyToml({ config: { build: { functions: 'functions' } } }).withFunction({
180+
builder.withNetlifyToml({ config: { functions: { directory: 'functions' } } }).withFunction({
181181
path: path.join('echo', 'echo.js'),
182182
handler: async () => ({
183183
statusCode: 200,
@@ -197,7 +197,7 @@ testMatrix.forEach(({ args }) => {
197197
test(testName('should pass .env.development vars to function', args), async (t) => {
198198
await withSiteBuilder('site-with-env-development', async (builder) => {
199199
builder
200-
.withNetlifyToml({ config: { build: { functions: 'functions' } } })
200+
.withNetlifyToml({ config: { functions: { directory: 'functions' } } })
201201
.withEnvFile({ path: '.env.development', env: { TEST: 'FROM_DEV_FILE' } })
202202
.withFunction({
203203
path: 'env.js',
@@ -218,7 +218,7 @@ testMatrix.forEach(({ args }) => {
218218

219219
test(testName('should pass process env vars to function', args), async (t) => {
220220
await withSiteBuilder('site-with-process-env', async (builder) => {
221-
builder.withNetlifyToml({ config: { build: { functions: 'functions' } } }).withFunction({
221+
builder.withNetlifyToml({ config: { functions: { directory: 'functions' } } }).withFunction({
222222
path: 'env.js',
223223
handler: async () => ({
224224
statusCode: 200,
@@ -238,7 +238,9 @@ testMatrix.forEach(({ args }) => {
238238
test(testName('should pass [build.environment] env vars to function', args), async (t) => {
239239
await withSiteBuilder('site-with-build-environment', async (builder) => {
240240
builder
241-
.withNetlifyToml({ config: { build: { environment: { TEST: 'FROM_CONFIG_FILE' }, functions: 'functions' } } })
241+
.withNetlifyToml({
242+
config: { build: { environment: { TEST: 'FROM_CONFIG_FILE' } }, functions: { directory: 'functions' } },
243+
})
242244
.withFunction({
243245
path: 'env.js',
244246
handler: async () => ({
@@ -261,8 +263,9 @@ testMatrix.forEach(({ args }) => {
261263
builder
262264
.withNetlifyToml({
263265
config: {
264-
build: { environment: { TEST: 'DEFAULT_CONTEXT' }, functions: 'functions' },
266+
build: { environment: { TEST: 'DEFAULT_CONTEXT' } },
265267
context: { dev: { environment: { TEST: 'DEV_CONTEXT' } } },
268+
functions: { directory: 'functions' },
266269
},
267270
})
268271
.withFunction({
@@ -287,8 +290,9 @@ testMatrix.forEach(({ args }) => {
287290
builder
288291
.withNetlifyToml({
289292
config: {
290-
build: { environment: { TEST: 'DEFAULT_CONTEXT' }, functions: 'functions' },
293+
build: { environment: { TEST: 'DEFAULT_CONTEXT' } },
291294
context: { production: { environment: { TEST: 'PRODUCTION_CONTEXT' } } },
295+
functions: { directory: 'functions' },
292296
},
293297
})
294298
.withFunction({
@@ -311,7 +315,7 @@ testMatrix.forEach(({ args }) => {
311315
test(testName('should override .env.development with process env', args), async (t) => {
312316
await withSiteBuilder('site-with-override', async (builder) => {
313317
builder
314-
.withNetlifyToml({ config: { build: { functions: 'functions' } } })
318+
.withNetlifyToml({ config: { functions: { directory: 'functions' } } })
315319
.withEnvFile({ path: '.env.development', env: { TEST: 'FROM_DEV_FILE' } })
316320
.withFunction({
317321
path: 'env.js',
@@ -333,7 +337,9 @@ testMatrix.forEach(({ args }) => {
333337
test(testName('should override [build.environment] with process env', args), async (t) => {
334338
await withSiteBuilder('site-with-build-environment-override', async (builder) => {
335339
builder
336-
.withNetlifyToml({ config: { build: { environment: { TEST: 'FROM_CONFIG_FILE' }, functions: 'functions' } } })
340+
.withNetlifyToml({
341+
config: { build: { environment: { TEST: 'FROM_CONFIG_FILE' } }, functions: { directory: 'functions' } },
342+
})
337343
.withFunction({
338344
path: 'env.js',
339345
handler: async () => ({
@@ -353,7 +359,7 @@ testMatrix.forEach(({ args }) => {
353359

354360
test(testName('should override value of the NETLIFY_DEV env variable', args), async (t) => {
355361
await withSiteBuilder('site-with-netlify-dev-override', async (builder) => {
356-
builder.withNetlifyToml({ config: { build: { functions: 'functions' } } }).withFunction({
362+
builder.withNetlifyToml({ config: { functions: { directory: 'functions' } } }).withFunction({
357363
path: 'env.js',
358364
handler: async () => ({
359365
statusCode: 200,
@@ -375,7 +381,7 @@ testMatrix.forEach(({ args }) => {
375381

376382
test(testName('should set value of the CONTEXT env variable', args), async (t) => {
377383
await withSiteBuilder('site-with-context-override', async (builder) => {
378-
builder.withNetlifyToml({ config: { build: { functions: 'functions' } } }).withFunction({
384+
builder.withNetlifyToml({ config: { functions: { directory: 'functions' } } }).withFunction({
379385
path: 'env.js',
380386
handler: async () => ({
381387
statusCode: 200,
@@ -397,7 +403,7 @@ testMatrix.forEach(({ args }) => {
397403
builder
398404
.withNetlifyToml({
399405
config: {
400-
build: { functions: 'functions' },
406+
functions: { directory: 'functions' },
401407
redirects: [{ from: '/api/*', to: '/.netlify/functions/:splat', status: 200 }],
402408
},
403409
})
@@ -423,7 +429,7 @@ testMatrix.forEach(({ args }) => {
423429
builder
424430
.withNetlifyToml({
425431
config: {
426-
build: { functions: 'functions' },
432+
functions: { directory: 'functions' },
427433
redirects: [{ from: '/api/*', to: '/.netlify/functions/:splat', status: 200 }],
428434
},
429435
})
@@ -454,7 +460,7 @@ testMatrix.forEach(({ args }) => {
454460
builder
455461
.withNetlifyToml({
456462
config: {
457-
build: { functions: 'functions' },
463+
functions: { directory: 'functions' },
458464
redirects: [{ from: '/api/*', to: '/.netlify/functions/:splat', status: 200 }],
459465
},
460466
})
@@ -495,7 +501,7 @@ testMatrix.forEach(({ args }) => {
495501
builder
496502
.withNetlifyToml({
497503
config: {
498-
build: { functions: 'functions' },
504+
functions: { directory: 'functions' },
499505
redirects: [{ from: '/api/*', to: '/.netlify/functions/:splat', status: 200 }],
500506
},
501507
})
@@ -527,7 +533,7 @@ testMatrix.forEach(({ args }) => {
527533
builder
528534
.withNetlifyToml({
529535
config: {
530-
build: { functions: 'functions' },
536+
functions: { directory: 'functions' },
531537
redirects: [{ from: '/api/*', to: '/.netlify/functions/:splat', status: 200 }],
532538
},
533539
})
@@ -570,7 +576,7 @@ testMatrix.forEach(({ args }) => {
570576
await withSiteBuilder('site-with-missing-function', async (builder) => {
571577
builder.withNetlifyToml({
572578
config: {
573-
build: { functions: 'functions' },
579+
functions: { directory: 'functions' },
574580
redirects: [{ from: '/api/*', to: '/.netlify/functions/:splat', status: 200 }],
575581
},
576582
})
@@ -594,7 +600,7 @@ testMatrix.forEach(({ args }) => {
594600
builder
595601
.withNetlifyToml({
596602
config: {
597-
build: { functions: 'functions' },
603+
functions: { directory: 'functions' },
598604
},
599605
})
600606
.withFunction({
@@ -626,7 +632,7 @@ testMatrix.forEach(({ args }) => {
626632
})
627633
.withNetlifyToml({
628634
config: {
629-
build: { functions: 'functions' },
635+
functions: { directory: 'functions' },
630636
},
631637
})
632638
.withFunction({
@@ -691,7 +697,7 @@ testMatrix.forEach(({ args }) => {
691697
})
692698
.withNetlifyToml({
693699
config: {
694-
build: { functions: 'functions' },
700+
functions: { directory: 'functions' },
695701
},
696702
})
697703
.withFunction({
@@ -1036,7 +1042,7 @@ testMatrix.forEach(({ args }) => {
10361042
await withSiteBuilder('site-with-post-no-content-type', async (builder) => {
10371043
builder.withNetlifyToml({
10381044
config: {
1039-
build: { functions: 'functions' },
1045+
functions: { directory: 'functions' },
10401046
redirects: [{ from: '/api/*', to: '/other/:splat', status: 200 }],
10411047
},
10421048
})
@@ -1164,7 +1170,7 @@ testMatrix.forEach(({ args }) => {
11641170

11651171
test(testName('should return 202 ok and empty response for background function', args), async (t) => {
11661172
await withSiteBuilder('site-with-background-function', async (builder) => {
1167-
builder.withNetlifyToml({ config: { build: { functions: 'functions' } } }).withFunction({
1173+
builder.withNetlifyToml({ config: { functions: { directory: 'functions' } } }).withFunction({
11681174
path: 'hello-background.js',
11691175
handler: () => {
11701176
console.log("Look at me I'm a background task")
@@ -1379,7 +1385,7 @@ testMatrix.forEach(({ args }) => {
13791385
await withSiteBuilder('site-with-functions', async (builder) => {
13801386
const functionsPort = 6666
13811387
await builder
1382-
.withNetlifyToml({ config: { build: { functions: 'functions' }, dev: { functionsPort } } })
1388+
.withNetlifyToml({ config: { functions: { directory: 'functions' }, dev: { functionsPort } } })
13831389
.buildAsync()
13841390

13851391
await withDevServer({ cwd: builder.directory, args }, async ({ url, port }) => {
@@ -1405,7 +1411,8 @@ testMatrix.forEach(({ args }) => {
14051411
})
14061412
.withNetlifyToml({
14071413
config: {
1408-
build: { functions: 'functions', publish: 'public' },
1414+
build: { publish: 'public' },
1415+
functions: { directory: 'functions' },
14091416
},
14101417
})
14111418
.withRedirectsFile({

tests/command.functions.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { withSiteBuilder } = require('./utils/site-builder')
99

1010
test('should return function response when invoked', async (t) => {
1111
await withSiteBuilder('site-with-ping-function', async (builder) => {
12-
builder.withNetlifyToml({ config: { build: { functions: 'functions' } } }).withFunction({
12+
builder.withNetlifyToml({ config: { functions: { directory: 'functions' } } }).withFunction({
1313
path: 'ping.js',
1414
handler: async () => ({
1515
statusCode: 200,

0 commit comments

Comments
 (0)