@netlify/config 15.7.4 → 15.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "15.7.4",
3
+ "version": "15.8.2",
4
4
  "description": "Netlify config module",
5
5
  "main": "src/main.js",
6
6
  "bin": {
@@ -52,6 +52,7 @@
52
52
  "@ungap/from-entries": "^0.2.1",
53
53
  "array-flat-polyfill": "^1.0.1",
54
54
  "chalk": "^4.1.2",
55
+ "cron-parser": "^4.1.0",
55
56
  "deepmerge": "^4.2.2",
56
57
  "dot-prop": "^5.3.0",
57
58
  "execa": "^5.1.1",
@@ -64,9 +65,9 @@
64
65
  "js-yaml": "^4.0.0",
65
66
  "make-dir": "^3.1.0",
66
67
  "map-obj": "^4.0.0",
67
- "netlify": "^8.0.2",
68
+ "netlify": "^8.0.4",
68
69
  "netlify-headers-parser": "^4.0.1",
69
- "netlify-redirect-parser": "^11.0.2",
70
+ "netlify-redirect-parser": "^11.0.3",
70
71
  "omit.js": "^2.0.2",
71
72
  "p-locate": "^5.0.0",
72
73
  "path-exists": "^4.0.0",
@@ -55,6 +55,7 @@ const FUNCTION_CONFIG_PROPERTIES = new Set([
55
55
  'ignored_node_modules',
56
56
  'included_files',
57
57
  'node_bundler',
58
+ 'schedule',
58
59
  ])
59
60
 
60
61
  // Takes a functions configuration object and looks for the functions directory
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable max-lines */
2
2
  'use strict'
3
3
 
4
+ const CronParser = require('cron-parser')
4
5
  const isPlainObj = require('is-plain-obj')
5
6
  const validateNpmPackageName = require('validate-npm-package-name')
6
7
 
@@ -8,6 +9,19 @@ const { bundlers, WILDCARD_ALL: FUNCTIONS_CONFIG_WILDCARD_ALL } = require('../fu
8
9
 
9
10
  const { functionsDirectoryCheck, isArrayOfObjects, isArrayOfStrings, isString, validProperties } = require('./helpers')
10
11
 
12
+ /**
13
+ * @param {string} cron
14
+ * @returns {boolean}
15
+ */
16
+ const isValidCronExpression = (cron) => {
17
+ try {
18
+ CronParser.parseExpression(cron)
19
+ return true
20
+ } catch (error) {
21
+ return false
22
+ }
23
+ }
24
+
11
25
  // List of validations performed on the configuration file.
12
26
  // Validation are performed in order: parent should be before children.
13
27
  // Each validation is an object with the following properties:
@@ -212,6 +226,14 @@ const POST_NORMALIZE_VALIDATIONS = [
212
226
  functions: { directory: 'my-functions' },
213
227
  }),
214
228
  },
229
+ {
230
+ property: 'functions.*.schedule',
231
+ check: isValidCronExpression,
232
+ message: 'must be a valid cron expression (see https://ntl.fyi/cron-syntax).',
233
+ example: (value, key, prevPath) => ({
234
+ functions: { [prevPath[1]]: { schedule: '5 4 * * *' } },
235
+ }),
236
+ },
215
237
  {
216
238
  property: 'functionsDirectory',
217
239
  check: isString,