@netlify/config 16.0.6 → 17.0.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/README.md +4 -4
- package/package.json +6 -5
- package/src/api/build_settings.js +2 -6
- package/src/api/client.js +3 -9
- package/src/api/site_info.js +2 -6
- package/src/base.js +4 -8
- package/src/bin/flags.js +5 -8
- package/src/bin/main.js +12 -13
- package/src/build_dir.js +3 -7
- package/src/cached_config.js +3 -7
- package/src/case.js +1 -5
- package/src/context.js +9 -13
- package/src/default.js +3 -7
- package/src/env/git.js +3 -7
- package/src/env/main.js +5 -9
- package/src/error.js +2 -6
- package/src/events.js +1 -5
- package/src/files.js +11 -15
- package/src/functions_config.js +6 -10
- package/src/headers.js +5 -9
- package/src/inline_config.js +3 -7
- package/src/log/cleanup.js +4 -8
- package/src/log/logger.js +9 -13
- package/src/log/main.js +7 -11
- package/src/log/messages.js +9 -21
- package/src/log/options.js +4 -8
- package/src/log/serialize.js +2 -6
- package/src/log/theme.js +6 -15
- package/src/main.js +24 -33
- package/src/merge.js +5 -9
- package/src/merge_normalize.js +8 -15
- package/src/mutations/apply.js +6 -10
- package/src/mutations/config_prop_name.js +1 -5
- package/src/mutations/update.js +14 -18
- package/src/normalize.js +5 -9
- package/src/options/base.js +5 -9
- package/src/options/branch.js +2 -6
- package/src/options/feature_flags.js +2 -6
- package/src/options/main.js +13 -17
- package/src/options/repository_root.js +3 -7
- package/src/origin.js +6 -10
- package/src/parse.js +8 -12
- package/src/path.js +5 -9
- package/src/redirects.js +5 -11
- package/src/simplify.js +6 -10
- package/src/utils/group.js +1 -5
- package/src/utils/remove_falsy.js +5 -9
- package/src/utils/set.js +2 -6
- package/src/utils/toml.js +4 -8
- package/src/validate/context.js +3 -7
- package/src/validate/example.js +4 -8
- package/src/validate/helpers.js +6 -16
- package/src/validate/identical.js +2 -6
- package/src/validate/main.js +10 -20
- package/src/validate/validations.js +10 -19
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { dirname } from 'path'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const findUp = require('find-up')
|
|
3
|
+
import findUp from 'find-up'
|
|
6
4
|
|
|
7
5
|
// Find out repository root among (in priority order):
|
|
8
6
|
// - `repositoryRoot` option
|
|
9
7
|
// - find a `.git` directory up from `cwd`
|
|
10
8
|
// - `cwd` (fallback)
|
|
11
|
-
const getRepositoryRoot = async function ({ repositoryRoot, cwd }) {
|
|
9
|
+
export const getRepositoryRoot = async function ({ repositoryRoot, cwd }) {
|
|
12
10
|
if (repositoryRoot !== undefined) {
|
|
13
11
|
return repositoryRoot
|
|
14
12
|
}
|
|
@@ -21,5 +19,3 @@ const getRepositoryRoot = async function ({ repositoryRoot, cwd }) {
|
|
|
21
19
|
|
|
22
20
|
return dirname(repositoryRootA)
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
module.exports = { getRepositoryRoot }
|
package/src/origin.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { isTruthy } = require('./utils/remove_falsy')
|
|
1
|
+
import { isTruthy } from './utils/remove_falsy.js'
|
|
4
2
|
|
|
5
3
|
// `build.commandOrigin`, `build.publishOrigin` and `plugins[*].origin` constants
|
|
6
|
-
const UI_ORIGIN = 'ui'
|
|
7
|
-
const CONFIG_ORIGIN = 'config'
|
|
8
|
-
const DEFAULT_ORIGIN = 'default'
|
|
9
|
-
const INLINE_ORIGIN = 'inline'
|
|
4
|
+
export const UI_ORIGIN = 'ui'
|
|
5
|
+
export const CONFIG_ORIGIN = 'config'
|
|
6
|
+
export const DEFAULT_ORIGIN = 'default'
|
|
7
|
+
export const INLINE_ORIGIN = 'inline'
|
|
10
8
|
|
|
11
9
|
// Add `build.commandOrigin`, `build.publishOrigin` and `plugins[*].origin`.
|
|
12
10
|
// This shows whether those properties came from the `ui` or from the `config`.
|
|
13
|
-
const addOrigins = function (config, origin) {
|
|
11
|
+
export const addOrigins = function (config, origin) {
|
|
14
12
|
const configA = addBuildCommandOrigin({ config, origin })
|
|
15
13
|
const configB = addBuildPublishOrigin({ config: configA, origin })
|
|
16
14
|
const configC = addConfigPluginOrigin({ config: configB, origin })
|
|
@@ -38,5 +36,3 @@ const addHeadersOrigin = function ({ config, config: { headers }, origin }) {
|
|
|
38
36
|
const addRedirectsOrigin = function ({ config, config: { redirects }, origin }) {
|
|
39
37
|
return isTruthy(redirects) ? { ...config, redirectsOrigin: origin } : config
|
|
40
38
|
}
|
|
41
|
-
|
|
42
|
-
module.exports = { addOrigins, UI_ORIGIN, CONFIG_ORIGIN, DEFAULT_ORIGIN, INLINE_ORIGIN }
|
package/src/parse.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { readFile } from 'fs'
|
|
2
|
+
import { promisify } from 'util'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const { promisify } = require('util')
|
|
4
|
+
import pathExists from 'path-exists'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const { throwOnInvalidTomlSequence } = require('./log/messages')
|
|
10
|
-
const { parseToml } = require('./utils/toml')
|
|
6
|
+
import { throwUserError } from './error.js'
|
|
7
|
+
import { throwOnInvalidTomlSequence } from './log/messages.js'
|
|
8
|
+
import { parseToml } from './utils/toml.js'
|
|
11
9
|
|
|
12
10
|
const pReadFile = promisify(readFile)
|
|
13
11
|
|
|
14
12
|
// Load the configuration file and parse it (TOML)
|
|
15
|
-
const parseConfig = async function (configPath) {
|
|
13
|
+
export const parseConfig = async function (configPath) {
|
|
16
14
|
if (configPath === undefined) {
|
|
17
15
|
return {}
|
|
18
16
|
}
|
|
@@ -26,7 +24,7 @@ const parseConfig = async function (configPath) {
|
|
|
26
24
|
|
|
27
25
|
// Same but `configPath` is required and `configPath` might point to a
|
|
28
26
|
// non-existing file.
|
|
29
|
-
const parseOptionalConfig = async function (configPath) {
|
|
27
|
+
export const parseOptionalConfig = async function (configPath) {
|
|
30
28
|
if (!(await pathExists(configPath))) {
|
|
31
29
|
return {}
|
|
32
30
|
}
|
|
@@ -72,5 +70,3 @@ const validateTomlBlackslashes = function (configString) {
|
|
|
72
70
|
// Also, """ strings can use trailing backslashes.
|
|
73
71
|
const INVALID_TOML_BLACKSLASH =
|
|
74
72
|
/\n[a-zA-Z]+ *= *(?:(?:""".*(?<!\\)(\\[^"\\btnfruU\n]).*""")|(?:"(?!")[^\n]*(?<!\\)(\\[^"\\btnfruU])[^\n]*"))/su
|
|
75
|
-
|
|
76
|
-
module.exports = { parseConfig, parseOptionalConfig }
|
package/src/path.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { resolve } from 'path'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const pLocate = require('p-locate')
|
|
7
|
-
const pathExists = require('path-exists')
|
|
3
|
+
import findUp from 'find-up'
|
|
4
|
+
import pLocate from 'p-locate'
|
|
5
|
+
import pathExists from 'path-exists'
|
|
8
6
|
|
|
9
7
|
// Configuration location can be:
|
|
10
8
|
// - a local path with the --config CLI flag
|
|
11
9
|
// - a `netlify.*` file in the `repositoryRoot/{base}`
|
|
12
10
|
// - a `netlify.*` file in the `repositoryRoot`
|
|
13
11
|
// - a `netlify.*` file in the current directory or any parent
|
|
14
|
-
const getConfigPath = async function ({ configOpt, cwd, repositoryRoot, configBase }) {
|
|
12
|
+
export const getConfigPath = async function ({ configOpt, cwd, repositoryRoot, configBase }) {
|
|
15
13
|
const configPath = await pLocate(
|
|
16
14
|
[
|
|
17
15
|
searchConfigOpt(cwd, configOpt),
|
|
@@ -52,5 +50,3 @@ const searchConfigFile = async function (cwd) {
|
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
const FILENAME = 'netlify.toml'
|
|
55
|
-
|
|
56
|
-
module.exports = { getConfigPath }
|
package/src/redirects.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { resolve } from 'path'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { parseAllRedirects } from 'netlify-redirect-parser'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
const netlifyRedirectParser = import('netlify-redirect-parser')
|
|
7
|
-
|
|
8
|
-
const { warnRedirectsParsing } = require('./log/messages')
|
|
5
|
+
import { warnRedirectsParsing } from './log/messages.js'
|
|
9
6
|
|
|
10
7
|
// Retrieve path to `_redirects` file (even if it does not exist yet)
|
|
11
|
-
const getRedirectsPath = function ({ build: { publish } }) {
|
|
8
|
+
export const getRedirectsPath = function ({ build: { publish } }) {
|
|
12
9
|
return resolve(publish, REDIRECTS_FILENAME)
|
|
13
10
|
}
|
|
14
11
|
|
|
15
12
|
const REDIRECTS_FILENAME = '_redirects'
|
|
16
13
|
|
|
17
14
|
// Add `config.redirects`
|
|
18
|
-
const addRedirects = async function ({ redirects: configRedirects, ...config }, redirectsPath, logs) {
|
|
19
|
-
const { parseAllRedirects } = await netlifyRedirectParser
|
|
15
|
+
export const addRedirects = async function ({ redirects: configRedirects, ...config }, redirectsPath, logs) {
|
|
20
16
|
const { redirects, errors } = await parseAllRedirects({
|
|
21
17
|
redirectsFiles: [redirectsPath],
|
|
22
18
|
configRedirects,
|
|
@@ -25,5 +21,3 @@ const addRedirects = async function ({ redirects: configRedirects, ...config },
|
|
|
25
21
|
warnRedirectsParsing(logs, errors)
|
|
26
22
|
return { ...config, redirects }
|
|
27
23
|
}
|
|
28
|
-
|
|
29
|
-
module.exports = { getRedirectsPath, addRedirects }
|
package/src/simplify.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import isPlainObj from 'is-plain-obj'
|
|
2
|
+
import mapObj from 'map-obj'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const mapObj = require('map-obj')
|
|
5
|
-
|
|
6
|
-
const { removeFalsy } = require('./utils/remove_falsy')
|
|
4
|
+
import { removeFalsy } from './utils/remove_falsy.js'
|
|
7
5
|
|
|
8
6
|
// Removes default values (empty objects and arrays) from the configuration.
|
|
9
|
-
const simplifyConfig = function ({
|
|
7
|
+
export const simplifyConfig = function ({
|
|
10
8
|
build: { environment, processing: { css, html, images, js, ...processing } = {}, services, ...build } = {},
|
|
11
9
|
functions,
|
|
12
10
|
plugins,
|
|
@@ -87,7 +85,7 @@ const removeDefaultValue = function (value, propName, defaultValue) {
|
|
|
87
85
|
return value === defaultValue ? {} : { [propName]: value }
|
|
88
86
|
}
|
|
89
87
|
|
|
90
|
-
const removeEmptyObject = function (object, propName) {
|
|
88
|
+
export const removeEmptyObject = function (object, propName) {
|
|
91
89
|
if (!isPlainObj(object)) {
|
|
92
90
|
return {}
|
|
93
91
|
}
|
|
@@ -96,12 +94,10 @@ const removeEmptyObject = function (object, propName) {
|
|
|
96
94
|
return Object.keys(objectA).length === 0 ? {} : { [propName]: objectA }
|
|
97
95
|
}
|
|
98
96
|
|
|
99
|
-
const removeEmptyArray = function (array, propName) {
|
|
97
|
+
export const removeEmptyArray = function (array, propName) {
|
|
100
98
|
if (!Array.isArray(array)) {
|
|
101
99
|
return {}
|
|
102
100
|
}
|
|
103
101
|
|
|
104
102
|
return array.length === 0 ? {} : { [propName]: array }
|
|
105
103
|
}
|
|
106
|
-
|
|
107
|
-
module.exports = { simplifyConfig, removeEmptyObject, removeEmptyArray }
|
package/src/utils/group.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
// Group objects according to a key attribute.
|
|
4
2
|
// The key must exist in each object and be a string.
|
|
5
|
-
const groupBy = function (objects, keyName) {
|
|
3
|
+
export const groupBy = function (objects, keyName) {
|
|
6
4
|
const keys = [...new Set(objects.map((object) => object[keyName]))]
|
|
7
5
|
return keys.map((key) => groupObjects(objects, keyName, key))
|
|
8
6
|
}
|
|
@@ -10,5 +8,3 @@ const groupBy = function (objects, keyName) {
|
|
|
10
8
|
const groupObjects = function (objects, keyName, key) {
|
|
11
9
|
return objects.filter((object) => object[keyName] === key)
|
|
12
10
|
}
|
|
13
|
-
|
|
14
|
-
module.exports = { groupBy }
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const filterObj = require('filter-obj')
|
|
1
|
+
import filterObj from 'filter-obj'
|
|
4
2
|
|
|
5
3
|
// Remove falsy values from object
|
|
6
|
-
const removeFalsy = function (obj) {
|
|
4
|
+
export const removeFalsy = function (obj) {
|
|
7
5
|
return filterObj(obj, (key, value) => isTruthy(value))
|
|
8
6
|
}
|
|
9
7
|
|
|
10
|
-
const removeUndefined = function (obj) {
|
|
8
|
+
export const removeUndefined = function (obj) {
|
|
11
9
|
return filterObj(obj, (key, value) => isDefined(value))
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
const isTruthy = function (value) {
|
|
12
|
+
export const isTruthy = function (value) {
|
|
15
13
|
return isDefined(value) && (typeof value !== 'string' || value.trim() !== '')
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
const isDefined = function (value) {
|
|
16
|
+
export const isDefined = function (value) {
|
|
19
17
|
return value !== undefined && value !== null
|
|
20
18
|
}
|
|
21
|
-
|
|
22
|
-
module.exports = { removeFalsy, removeUndefined, isTruthy, isDefined }
|
package/src/utils/set.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const isPlainObj = require('is-plain-obj')
|
|
1
|
+
import isPlainObj from 'is-plain-obj'
|
|
4
2
|
|
|
5
3
|
// Set a property deeply using an array of `keys` which can be either strings
|
|
6
4
|
// (object properties) or integers (array indices).
|
|
7
5
|
// Adds default values when intermediary properties are undefined or have the
|
|
8
6
|
// wrong type. Also extends arrays when they are too small for a given index.
|
|
9
7
|
// Does not mutate.
|
|
10
|
-
const setProp = function (parent, keys, value) {
|
|
8
|
+
export const setProp = function (parent, keys, value) {
|
|
11
9
|
if (keys.length === 0) {
|
|
12
10
|
return value
|
|
13
11
|
}
|
|
@@ -33,5 +31,3 @@ const setObjectProp = function (parent, [key, ...keys], value) {
|
|
|
33
31
|
const newValue = setProp(objectParent[key], keys, value)
|
|
34
32
|
return { ...objectParent, [key]: newValue }
|
|
35
33
|
}
|
|
36
|
-
|
|
37
|
-
module.exports = { setProp }
|
package/src/utils/toml.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { parse: loadToml } = require('toml')
|
|
4
|
-
const tomlify = require('tomlify-j0.4')
|
|
1
|
+
import { parse as loadToml } from 'toml'
|
|
2
|
+
import tomlify from 'tomlify-j0.4'
|
|
5
3
|
|
|
6
4
|
// Parse from TOML to JavaScript
|
|
7
|
-
const parseToml = function (configString) {
|
|
5
|
+
export const parseToml = function (configString) {
|
|
8
6
|
const config = loadToml(configString)
|
|
9
7
|
// `toml.parse()` returns a object with `null` prototype deeply, which can
|
|
10
8
|
// sometimes create problems with some utilities. We convert it.
|
|
@@ -14,7 +12,7 @@ const parseToml = function (configString) {
|
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
// Serialize JavaScript object to TOML
|
|
17
|
-
const serializeToml = function (object) {
|
|
15
|
+
export const serializeToml = function (object) {
|
|
18
16
|
return tomlify.toToml(object, { space: 2, replace: replaceTomlValue })
|
|
19
17
|
}
|
|
20
18
|
|
|
@@ -23,5 +21,3 @@ const serializeToml = function (object) {
|
|
|
23
21
|
const replaceTomlValue = function (key, value) {
|
|
24
22
|
return Number.isInteger(value) ? String(value) : false
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
module.exports = { parseToml, serializeToml }
|
package/src/validate/context.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { warnContextPluginConfig, throwContextPluginsConfig } = require('../log/messages')
|
|
4
|
-
const { UI_ORIGIN } = require('../origin')
|
|
1
|
+
import { warnContextPluginConfig, throwContextPluginsConfig } from '../log/messages.js'
|
|
2
|
+
import { UI_ORIGIN } from '../origin.js'
|
|
5
3
|
|
|
6
4
|
// The only reason to specify both `[[plugins]]` and
|
|
7
5
|
// `[[contexts.{context}.plugins]]` is to configure context-specific plugin
|
|
@@ -14,7 +12,7 @@ const { UI_ORIGIN } = require('../origin')
|
|
|
14
12
|
// - `package` is the only property in `[[contexts.{context}.plugins]]`, i.e.
|
|
15
13
|
// there are no context-specific `inputs`
|
|
16
14
|
// - The current build is not in `context`
|
|
17
|
-
const validateContextsPluginsConfig = function ({ contextProps, plugins, contexts, logs }) {
|
|
15
|
+
export const validateContextsPluginsConfig = function ({ contextProps, plugins, contexts, logs }) {
|
|
18
16
|
Object.entries(contextProps).forEach(([givenContext, givenContextProps]) => {
|
|
19
17
|
validateContextPluginsConfig({ givenContextProps, plugins, givenContext, contexts, logs })
|
|
20
18
|
})
|
|
@@ -57,5 +55,3 @@ const isContextFreePlugin = function (plugins, packageName) {
|
|
|
57
55
|
const isPluginConfigError = function (contexts, givenContext, inputs) {
|
|
58
56
|
return contexts.every((context) => context !== givenContext) && Object.keys(inputs).length === 0
|
|
59
57
|
}
|
|
60
|
-
|
|
61
|
-
module.exports = { validateContextsPluginsConfig }
|
package/src/validate/example.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import indentString from 'indent-string'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { THEME } = require('../log/theme')
|
|
6
|
-
const { serializeToml } = require('../utils/toml')
|
|
3
|
+
import { THEME } from '../log/theme.js'
|
|
4
|
+
import { serializeToml } from '../utils/toml.js'
|
|
7
5
|
|
|
8
6
|
// Print invalid value and example netlify.toml
|
|
9
|
-
const getExample = function ({ value, key, prevPath, example, formatInvalid }) {
|
|
7
|
+
export const getExample = function ({ value, key, prevPath, example, formatInvalid }) {
|
|
10
8
|
const exampleA = typeof example === 'function' ? example(value, key, prevPath) : example
|
|
11
9
|
return `
|
|
12
10
|
${THEME.errorSubHeader('Invalid syntax')}
|
|
@@ -37,5 +35,3 @@ const setInvalidValuePart = function (value, part) {
|
|
|
37
35
|
|
|
38
36
|
return value === undefined ? {} : { [part]: value }
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
module.exports = { getExample }
|
package/src/validate/helpers.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import isPlainObj from 'is-plain-obj'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const isArrayOfObjects = function (value) {
|
|
3
|
+
export const isArrayOfObjects = function (value) {
|
|
6
4
|
return Array.isArray(value) && value.every(isPlainObj)
|
|
7
5
|
}
|
|
8
6
|
|
|
9
|
-
const isArrayOfStrings = function (value) {
|
|
7
|
+
export const isArrayOfStrings = function (value) {
|
|
10
8
|
return Array.isArray(value) && value.every(isString)
|
|
11
9
|
}
|
|
12
10
|
|
|
13
|
-
const isString = function (value) {
|
|
11
|
+
export const isString = function (value) {
|
|
14
12
|
return typeof value === 'string'
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
// Check an object valid properties, including legacy ones
|
|
18
|
-
const validProperties = function (propNames, legacyPropNames) {
|
|
16
|
+
export const validProperties = function (propNames, legacyPropNames) {
|
|
19
17
|
return {
|
|
20
18
|
check: (value) => checkValidProperty(value, [...propNames, ...legacyPropNames]),
|
|
21
19
|
message: `has unknown properties. Valid properties are:
|
|
@@ -27,15 +25,7 @@ const checkValidProperty = function (value, propNames) {
|
|
|
27
25
|
return Object.keys(value).every((propName) => propNames.includes(propName))
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
const functionsDirectoryCheck = {
|
|
28
|
+
export const functionsDirectoryCheck = {
|
|
31
29
|
formatInvalid: ({ functionsDirectory } = {}) => ({ functions: { directory: functionsDirectory } }),
|
|
32
30
|
propertyName: 'functions.directory',
|
|
33
31
|
}
|
|
34
|
-
|
|
35
|
-
module.exports = {
|
|
36
|
-
isArrayOfObjects,
|
|
37
|
-
isArrayOfStrings,
|
|
38
|
-
isString,
|
|
39
|
-
validProperties,
|
|
40
|
-
functionsDirectoryCheck,
|
|
41
|
-
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { throwUserError } = require('../error')
|
|
1
|
+
import { throwUserError } from '../error.js'
|
|
4
2
|
|
|
5
3
|
// Validate that plugin are configured only once per origin
|
|
6
4
|
// (`netlify.toml` or UI).
|
|
7
5
|
// Exception: context-specific configuration since we allow context-specific
|
|
8
6
|
// overrides. This does not validate them since contexts have not been merged
|
|
9
7
|
// yet.
|
|
10
|
-
const validateIdenticalPlugins = function ({ plugins = [] }) {
|
|
8
|
+
export const validateIdenticalPlugins = function ({ plugins = [] }) {
|
|
11
9
|
plugins.filter(hasIdenticalPlugin).forEach(throwIndenticalPlugin)
|
|
12
10
|
}
|
|
13
11
|
|
|
@@ -20,5 +18,3 @@ const throwIndenticalPlugin = function ({ package: packageName, origin }) {
|
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
const ORIGINS = { config: 'netlify.toml', ui: 'the app' }
|
|
23
|
-
|
|
24
|
-
module.exports = { validateIdenticalPlugins }
|
package/src/validate/main.js
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
import { throwUserError } from '../error.js'
|
|
2
|
+
import { THEME } from '../log/theme.js'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { getExample } = require('./example')
|
|
7
|
-
const {
|
|
4
|
+
import { getExample } from './example.js'
|
|
5
|
+
import {
|
|
8
6
|
PRE_CASE_NORMALIZE_VALIDATIONS,
|
|
9
7
|
PRE_MERGE_VALIDATIONS,
|
|
10
8
|
PRE_CONTEXT_VALIDATIONS,
|
|
11
9
|
PRE_NORMALIZE_VALIDATIONS,
|
|
12
10
|
POST_NORMALIZE_VALIDATIONS,
|
|
13
|
-
}
|
|
11
|
+
} from './validations.js'
|
|
14
12
|
|
|
15
13
|
// Validate the configuration file, before case normalization.
|
|
16
|
-
const validatePreCaseNormalize = function (config) {
|
|
14
|
+
export const validatePreCaseNormalize = function (config) {
|
|
17
15
|
validateConfig(config, PRE_CASE_NORMALIZE_VALIDATIONS)
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
// Validate the configuration file, before `defaultConfig` merge.
|
|
21
|
-
const validatePreMergeConfig = function (config) {
|
|
19
|
+
export const validatePreMergeConfig = function (config) {
|
|
22
20
|
validateConfig(config, PRE_MERGE_VALIDATIONS)
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
// Validate the configuration file, before context merge.
|
|
26
|
-
const validatePreContextConfig = function (config) {
|
|
24
|
+
export const validatePreContextConfig = function (config) {
|
|
27
25
|
validateConfig(config, PRE_CONTEXT_VALIDATIONS)
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
// Validate the configuration file, before normalization.
|
|
31
|
-
const validatePreNormalizeConfig = function (config) {
|
|
29
|
+
export const validatePreNormalizeConfig = function (config) {
|
|
32
30
|
validateConfig(config, PRE_NORMALIZE_VALIDATIONS)
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
// Validate the configuration file, after normalization.
|
|
36
|
-
const validatePostNormalizeConfig = function (config) {
|
|
34
|
+
export const validatePostNormalizeConfig = function (config) {
|
|
37
35
|
validateConfig(config, POST_NORMALIZE_VALIDATIONS)
|
|
38
36
|
}
|
|
39
37
|
|
|
@@ -143,11 +141,3 @@ const validateChildProp = function ({ childProp, value, nextPath, propPath, prev
|
|
|
143
141
|
key: childProp,
|
|
144
142
|
})
|
|
145
143
|
}
|
|
146
|
-
|
|
147
|
-
module.exports = {
|
|
148
|
-
validatePreCaseNormalize,
|
|
149
|
-
validatePreMergeConfig,
|
|
150
|
-
validatePreContextConfig,
|
|
151
|
-
validatePreNormalizeConfig,
|
|
152
|
-
validatePostNormalizeConfig,
|
|
153
|
-
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
|
-
'use strict'
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import CronParser from 'cron-parser'
|
|
4
|
+
import isPlainObj from 'is-plain-obj'
|
|
5
|
+
import validateNpmPackageName from 'validate-npm-package-name'
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
import { bundlers, WILDCARD_ALL as FUNCTIONS_CONFIG_WILDCARD_ALL } from '../functions_config.js'
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
import { functionsDirectoryCheck, isArrayOfObjects, isArrayOfStrings, isString, validProperties } from './helpers.js'
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* @param {string} cron
|
|
@@ -38,7 +37,7 @@ const isValidCronExpression = (cron) => {
|
|
|
38
37
|
// We use this instead of JSON schema (or others) to get nicer error messages.
|
|
39
38
|
|
|
40
39
|
// Validations done before case normalization
|
|
41
|
-
const PRE_CASE_NORMALIZE_VALIDATIONS = [
|
|
40
|
+
export const PRE_CASE_NORMALIZE_VALIDATIONS = [
|
|
42
41
|
{
|
|
43
42
|
property: 'build',
|
|
44
43
|
check: isPlainObj,
|
|
@@ -66,10 +65,10 @@ const ORIGIN_VALIDATIONS = [
|
|
|
66
65
|
]
|
|
67
66
|
|
|
68
67
|
// Validations done before `defaultConfig` merge
|
|
69
|
-
const PRE_MERGE_VALIDATIONS = [...ORIGIN_VALIDATIONS]
|
|
68
|
+
export const PRE_MERGE_VALIDATIONS = [...ORIGIN_VALIDATIONS]
|
|
70
69
|
|
|
71
70
|
// Validations done before context merge
|
|
72
|
-
const PRE_CONTEXT_VALIDATIONS = [
|
|
71
|
+
export const PRE_CONTEXT_VALIDATIONS = [
|
|
73
72
|
{
|
|
74
73
|
property: 'context',
|
|
75
74
|
check: isPlainObj,
|
|
@@ -85,7 +84,7 @@ const PRE_CONTEXT_VALIDATIONS = [
|
|
|
85
84
|
]
|
|
86
85
|
|
|
87
86
|
// Validations done before normalization
|
|
88
|
-
const PRE_NORMALIZE_VALIDATIONS = [
|
|
87
|
+
export const PRE_NORMALIZE_VALIDATIONS = [
|
|
89
88
|
...ORIGIN_VALIDATIONS,
|
|
90
89
|
{
|
|
91
90
|
property: 'functions',
|
|
@@ -108,7 +107,7 @@ const PRE_NORMALIZE_VALIDATIONS = [
|
|
|
108
107
|
const EXAMPLE_PORT = 80
|
|
109
108
|
|
|
110
109
|
// Validations done after normalization
|
|
111
|
-
const POST_NORMALIZE_VALIDATIONS = [
|
|
110
|
+
export const POST_NORMALIZE_VALIDATIONS = [
|
|
112
111
|
{
|
|
113
112
|
property: 'plugins.*',
|
|
114
113
|
...validProperties(['package', 'pinned_version', 'inputs'], ['origin']),
|
|
@@ -244,12 +243,4 @@ const POST_NORMALIZE_VALIDATIONS = [
|
|
|
244
243
|
}),
|
|
245
244
|
},
|
|
246
245
|
]
|
|
247
|
-
|
|
248
|
-
module.exports = {
|
|
249
|
-
PRE_CASE_NORMALIZE_VALIDATIONS,
|
|
250
|
-
PRE_MERGE_VALIDATIONS,
|
|
251
|
-
PRE_CONTEXT_VALIDATIONS,
|
|
252
|
-
PRE_NORMALIZE_VALIDATIONS,
|
|
253
|
-
POST_NORMALIZE_VALIDATIONS,
|
|
254
|
-
}
|
|
255
246
|
/* eslint-enable max-lines */
|