@netlify/config 17.0.1 → 17.0.5

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": "17.0.1",
3
+ "version": "17.0.5",
4
4
  "description": "Netlify config module",
5
5
  "type": "module",
6
6
  "exports": "./src/main.js",
@@ -63,11 +63,10 @@
63
63
  "indent-string": "^4.0.0",
64
64
  "is-plain-obj": "^3.0.0",
65
65
  "js-yaml": "^4.0.0",
66
- "make-dir": "^3.1.0",
67
66
  "map-obj": "^4.0.0",
68
- "netlify": "^10.0.0",
69
- "netlify-headers-parser": "^6.0.0",
70
- "netlify-redirect-parser": "^13.0.0",
67
+ "netlify": "^10.1.2",
68
+ "netlify-headers-parser": "^6.0.1",
69
+ "netlify-redirect-parser": "^13.0.1",
71
70
  "omit.js": "^2.0.2",
72
71
  "p-locate": "^5.0.0",
73
72
  "path-exists": "^4.0.0",
@@ -75,11 +74,11 @@
75
74
  "toml": "^3.0.0",
76
75
  "tomlify-j0.4": "^3.0.0",
77
76
  "validate-npm-package-name": "^3.0.0",
78
- "yargs": "^15.3.0"
77
+ "yargs": "^17.3.1"
79
78
  },
80
79
  "devDependencies": {
81
80
  "ava": "^3.15.0",
82
- "del": "^5.1.0",
81
+ "del": "^6.0.0",
83
82
  "has-ansi": "^4.0.0",
84
83
  "is-ci": "^3.0.0",
85
84
  "tmp-promise": "^3.0.2"
package/src/bin/flags.js CHANGED
@@ -1,19 +1,29 @@
1
1
  /* eslint-disable max-lines */
2
2
 
3
+ import process from 'process'
4
+
3
5
  import filterObj from 'filter-obj'
4
6
  import yargs from 'yargs'
7
+ import { hideBin } from 'yargs/helpers'
5
8
 
6
9
  import { normalizeCliFeatureFlags } from '../options/feature_flags.js'
7
10
 
8
11
  // Parse CLI flags
9
12
  export const parseFlags = function () {
10
- const { featureFlags: cliFeatureFlags = '', ...flags } = yargs.options(FLAGS).usage(USAGE).parse()
13
+ const { featureFlags: cliFeatureFlags = '', ...flags } = yargs(hideBin(process.argv))
14
+ .options(FLAGS)
15
+ .usage(USAGE)
16
+ .parse()
11
17
  const featureFlags = normalizeCliFeatureFlags(cliFeatureFlags)
12
18
  const flagsA = { ...flags, featureFlags }
13
19
  const flagsB = filterObj(flagsA, isUserFlag)
14
20
  return flagsB
15
21
  }
16
22
 
23
+ const jsonParse = function (value) {
24
+ return value === undefined ? undefined : JSON.parse(value)
25
+ }
26
+
17
27
  // List of CLI flags
18
28
  const FLAGS = {
19
29
  config: {
@@ -26,7 +36,7 @@ Defaults to any netlify.toml in the git repository root directory or the base di
26
36
  describe: `JSON configuration object containing default values.
27
37
  Each configuration default value is used unless overriden through the main configuration file.
28
38
  Default: none.`,
29
- coerce: JSON.parse,
39
+ coerce: jsonParse,
30
40
  hidden: true,
31
41
  },
32
42
  cachedConfig: {
@@ -35,7 +45,7 @@ Default: none.`,
35
45
  or when using @netlify/config programmatically.
36
46
  This is done as a performance optimization to cache the configuration loading logic.
37
47
  Default: none.`,
38
- coerce: JSON.parse,
48
+ coerce: jsonParse,
39
49
  hidden: true,
40
50
  },
41
51
  cachedConfigPath: {
@@ -50,7 +60,7 @@ Default: none.`,
50
60
  string: true,
51
61
  describe: `JSON configuration object overriding the configuration file and other settings.
52
62
  Default: none.`,
53
- coerce: JSON.parse,
63
+ coerce: jsonParse,
54
64
  hidden: true,
55
65
  },
56
66
  configMutations: {
@@ -61,7 +71,7 @@ Each change must be an object with three properties:
61
71
  - "value": new value of that property
62
72
  - "event": build event when this change was applied, e.g. "onPreBuild"
63
73
  Default: empty array.`,
64
- coerce: JSON.parse,
74
+ coerce: jsonParse,
65
75
  hidden: true,
66
76
  },
67
77
  cwd: {
package/src/bin/main.js CHANGED
@@ -1,12 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { writeFile } from 'fs'
3
+ import { promises as fs } from 'fs'
4
4
  import { dirname } from 'path'
5
5
  import process from 'process'
6
- import { promisify } from 'util'
7
6
 
8
7
  import fastSafeStringify from 'fast-safe-stringify'
9
- import makeDir from 'make-dir'
10
8
  import omit from 'omit.js'
11
9
 
12
10
  import { isUserError } from '../error.js'
@@ -14,8 +12,6 @@ import { resolveConfig } from '../main.js'
14
12
 
15
13
  import { parseFlags } from './flags.js'
16
14
 
17
- const pWriteFile = promisify(writeFile)
18
-
19
15
  // CLI entry point
20
16
  const runCli = async function () {
21
17
  try {
@@ -45,8 +41,8 @@ const outputResult = async function (resultJson, output) {
45
41
  return
46
42
  }
47
43
 
48
- await makeDir(dirname(output))
49
- await pWriteFile(output, resultJson)
44
+ await fs.mkdir(dirname(output), { recursive: true })
45
+ await fs.writeFile(output, resultJson)
50
46
  }
51
47
 
52
48
  // `api` is not JSON-serializable, so we remove it
@@ -1,7 +1,4 @@
1
- import { readFile } from 'fs'
2
- import { promisify } from 'util'
3
-
4
- const pReadFile = promisify(readFile)
1
+ import { promises as fs } from 'fs'
5
2
 
6
3
  // Performance optimization when @netlify/config caller has already previously
7
4
  // called it and cached the result.
@@ -27,6 +24,6 @@ const parseCachedConfig = async function (cachedConfig, cachedConfigPath) {
27
24
  }
28
25
 
29
26
  if (cachedConfigPath !== undefined) {
30
- return JSON.parse(await pReadFile(cachedConfigPath, 'utf8'))
27
+ return JSON.parse(await fs.readFile(cachedConfigPath))
31
28
  }
32
29
  }
package/src/env/git.js CHANGED
@@ -19,5 +19,5 @@ const git = async function (args, cwd) {
19
19
  try {
20
20
  const { stdout } = await execa('git', args, { cwd })
21
21
  return stdout
22
- } catch (error) {}
22
+ } catch {}
23
23
  }
@@ -1,5 +1,5 @@
1
1
  import { dump } from 'js-yaml'
2
2
 
3
3
  export const serializeObject = function (object) {
4
- return dump(object, { noRefs: true, sortKeys: true, lineWidth: Number.POSITIVE_INFINITY }).trimRight()
4
+ return dump(object, { noRefs: true, sortKeys: true, lineWidth: Number.POSITIVE_INFINITY }).trimEnd()
5
5
  }
@@ -1,7 +1,5 @@
1
- import { writeFile, unlink, copyFile } from 'fs'
2
- import { promisify } from 'util'
1
+ import { promises as fs } from 'fs'
3
2
 
4
- import makeDir from 'make-dir'
5
3
  import pathExists from 'path-exists'
6
4
 
7
5
  import { ensureConfigPriority } from '../context.js'
@@ -14,10 +12,6 @@ import { serializeToml } from '../utils/toml.js'
14
12
 
15
13
  import { applyMutations } from './apply.js'
16
14
 
17
- const pWriteFile = promisify(writeFile)
18
- const pUnlink = promisify(unlink)
19
- const pCopyFile = promisify(copyFile)
20
-
21
15
  // Persist configuration changes to `netlify.toml`.
22
16
  // If `netlify.toml` does not exist, creates it. Otherwise, merges the changes.
23
17
  export const updateConfig = async function (
@@ -52,7 +46,7 @@ const mergeWithConfig = async function (normalizedInlineConfig, configPath) {
52
46
  // Serialize the changes to `netlify.toml`
53
47
  const saveConfig = async function (configPath, simplifiedConfig) {
54
48
  const serializedConfig = serializeToml(simplifiedConfig)
55
- await pWriteFile(configPath, serializedConfig)
49
+ await fs.writeFile(configPath, serializedConfig)
56
50
  }
57
51
 
58
52
  // Deletes `_headers/_redirects` since they are merged to `netlify.toml`,
@@ -62,7 +56,7 @@ const deleteSideFile = async function (filePath) {
62
56
  return
63
57
  }
64
58
 
65
- await pUnlink(filePath)
59
+ await fs.unlink(filePath)
66
60
  }
67
61
 
68
62
  // Modifications to `netlify.toml` and `_headers/_redirects` are only meant for
@@ -71,7 +65,7 @@ const deleteSideFile = async function (filePath) {
71
65
  // We do this by backing them up inside some sibling directory.
72
66
  const backupConfig = async function ({ buildDir, configPath, headersPath, redirectsPath }) {
73
67
  const tempDir = getTempDir(buildDir)
74
- await makeDir(tempDir)
68
+ await fs.mkdir(tempDir, { recursive: true })
75
69
  await Promise.all([
76
70
  backupFile(configPath, `${tempDir}/netlify.toml`),
77
71
  backupFile(headersPath, `${tempDir}/_headers`),
@@ -104,18 +98,18 @@ const backupFile = async function (original, backup) {
104
98
  return
105
99
  }
106
100
 
107
- await pCopyFile(original, backup)
101
+ await fs.copyFile(original, backup)
108
102
  }
109
103
 
110
104
  const deleteNoError = async (path) => {
111
105
  try {
112
- await pUnlink(path)
113
- } catch (_) {}
106
+ await fs.unlink(path)
107
+ } catch {}
114
108
  }
115
109
 
116
110
  const copyOrDelete = async function (src, dest) {
117
111
  if (await pathExists(src)) {
118
- await pCopyFile(src, dest)
112
+ await fs.copyFile(src, dest)
119
113
  return
120
114
  }
121
115
 
@@ -1,11 +1,8 @@
1
- import { realpath } from 'fs'
1
+ import { promises as fs } from 'fs'
2
2
  import { dirname, relative, sep } from 'path'
3
- import { promisify } from 'util'
4
3
 
5
4
  import pathExists from 'path-exists'
6
5
 
7
- const pRealpath = promisify(realpath)
8
-
9
6
  // Retrieve `base` override.
10
7
  // This uses any directory below `repositoryRoot` and above (or equal to)
11
8
  // `cwd` that has a `.netlify` or `netlify.toml`. This allows Netlify CLI users
@@ -17,7 +14,7 @@ export const getBaseOverride = async function ({ repositoryRoot, cwd }) {
17
14
  return {}
18
15
  }
19
16
 
20
- const [repositoryRootA, cwdA] = await Promise.all([pRealpath(repositoryRoot), pRealpath(cwd)])
17
+ const [repositoryRootA, cwdA] = await Promise.all([fs.realpath(repositoryRoot), fs.realpath(cwd)])
21
18
  const basePaths = getBasePaths(repositoryRootA, cwdA)
22
19
  const basePath = await locatePath(basePaths)
23
20
 
@@ -28,7 +28,7 @@ const getGitBranch = async function (repositoryRoot, gitRef) {
28
28
  try {
29
29
  const { stdout } = await execa.command(`git rev-parse --abbrev-ref ${gitRef}`, { cwd: repositoryRoot })
30
30
  return stdout
31
- } catch (error) {}
31
+ } catch {}
32
32
  }
33
33
 
34
34
  const FALLBACK_BRANCH = 'master'
package/src/parse.js CHANGED
@@ -1,5 +1,4 @@
1
- import { readFile } from 'fs'
2
- import { promisify } from 'util'
1
+ import { promises as fs } from 'fs'
3
2
 
4
3
  import pathExists from 'path-exists'
5
4
 
@@ -7,8 +6,6 @@ import { throwUserError } from './error.js'
7
6
  import { throwOnInvalidTomlSequence } from './log/messages.js'
8
7
  import { parseToml } from './utils/toml.js'
9
8
 
10
- const pReadFile = promisify(readFile)
11
-
12
9
  // Load the configuration file and parse it (TOML)
13
10
  export const parseConfig = async function (configPath) {
14
11
  if (configPath === undefined) {
@@ -47,7 +44,7 @@ const readConfigPath = async function (configPath) {
47
44
  // Reach the configuration file's raw content
48
45
  const readConfig = async function (configPath) {
49
46
  try {
50
- return await pReadFile(configPath, 'utf8')
47
+ return await fs.readFile(configPath, 'utf8')
51
48
  } catch (error) {
52
49
  throwUserError('Could not read configuration file', error)
53
50
  }
@@ -16,7 +16,7 @@ const isValidCronExpression = (cron) => {
16
16
  try {
17
17
  CronParser.parseExpression(cron)
18
18
  return true
19
- } catch (error) {
19
+ } catch {
20
20
  return false
21
21
  }
22
22
  }