netlify-cli 12.2.10 → 12.3.0

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.
Files changed (139) hide show
  1. package/npm-shrinkwrap.json +315 -1191
  2. package/package.json +3 -7
  3. package/src/commands/addons/addons-auth.mjs +2 -3
  4. package/src/commands/addons/addons-config.mjs +2 -3
  5. package/src/commands/addons/addons-create.mjs +2 -3
  6. package/src/commands/addons/addons-delete.mjs +1 -3
  7. package/src/commands/addons/addons-list.mjs +1 -3
  8. package/src/commands/api/api.mjs +1 -3
  9. package/src/commands/base-command.mjs +3 -3
  10. package/src/commands/build/build.mjs +3 -3
  11. package/src/commands/deploy/deploy.mjs +14 -17
  12. package/src/commands/dev/dev-exec.mjs +2 -3
  13. package/src/commands/dev/dev.mjs +15 -21
  14. package/src/commands/env/env-clone.mjs +2 -3
  15. package/src/commands/env/env-get.mjs +2 -3
  16. package/src/commands/env/env-import.mjs +2 -3
  17. package/src/commands/env/env-list.mjs +2 -4
  18. package/src/commands/env/env-set.mjs +3 -8
  19. package/src/commands/env/env-unset.mjs +2 -3
  20. package/src/commands/functions/functions-build.mjs +1 -3
  21. package/src/commands/functions/functions-create.mjs +3 -3
  22. package/src/commands/functions/functions-invoke.mjs +1 -3
  23. package/src/commands/functions/functions-list.mjs +1 -3
  24. package/src/commands/functions/functions-serve.mjs +1 -2
  25. package/src/commands/functions/functions.mjs +1 -1
  26. package/src/commands/graph/graph-config-write.mjs +1 -3
  27. package/src/commands/graph/graph-edit.mjs +2 -3
  28. package/src/commands/graph/graph-handler.mjs +1 -3
  29. package/src/commands/graph/graph-init.mjs +2 -3
  30. package/src/commands/graph/graph-library.mjs +1 -3
  31. package/src/commands/graph/graph-operations.mjs +1 -3
  32. package/src/commands/graph/graph-pull.mjs +1 -3
  33. package/src/commands/init/init.mjs +2 -4
  34. package/src/commands/link/link.mjs +1 -3
  35. package/src/commands/lm/lm-setup.mjs +2 -3
  36. package/src/commands/login/login.mjs +1 -3
  37. package/src/commands/logout/logout.mjs +1 -3
  38. package/src/commands/main.mjs +3 -3
  39. package/src/commands/open/open-admin.mjs +2 -3
  40. package/src/commands/open/open-site.mjs +2 -3
  41. package/src/commands/open/open.mjs +1 -3
  42. package/src/commands/recipes/recipes.mjs +3 -3
  43. package/src/commands/sites/sites-create-template.mjs +7 -8
  44. package/src/commands/sites/sites-create.mjs +2 -4
  45. package/src/commands/sites/sites-delete.mjs +1 -3
  46. package/src/commands/sites/sites-list.mjs +1 -3
  47. package/src/commands/status/status-hooks.mjs +1 -3
  48. package/src/commands/status/status.mjs +1 -3
  49. package/src/commands/switch/switch.mjs +1 -3
  50. package/src/commands/unlink/unlink.mjs +1 -3
  51. package/src/commands/watch/watch.mjs +1 -3
  52. package/src/lib/account.mjs +14 -0
  53. package/src/lib/api.mjs +1 -1
  54. package/src/lib/completion/generate-autocompletion.mjs +1 -1
  55. package/src/lib/edge-functions/consts.mjs +4 -0
  56. package/src/lib/edge-functions/{deploy.cjs → deploy.mjs} +7 -13
  57. package/src/lib/edge-functions/{headers.cjs → headers.mjs} +3 -1
  58. package/src/lib/edge-functions/{internal.cjs → internal.mjs} +19 -15
  59. package/src/lib/edge-functions/{proxy.cjs → proxy.mjs} +19 -20
  60. package/src/lib/edge-functions/{registry.cjs → registry.mjs} +3 -5
  61. package/src/lib/{exec-fetcher.cjs → exec-fetcher.mjs} +17 -12
  62. package/src/lib/functions/{background.cjs → background.mjs} +4 -6
  63. package/src/lib/functions/{config.cjs → config.mjs} +1 -3
  64. package/src/lib/functions/form-submissions-handler.mjs +2 -2
  65. package/src/lib/functions/{local-proxy.cjs → local-proxy.mjs} +4 -6
  66. package/src/lib/functions/{memoized-build.cjs → memoized-build.mjs} +1 -3
  67. package/src/lib/functions/{netlify-function.cjs → netlify-function.mjs} +5 -8
  68. package/src/lib/functions/{registry.cjs → registry.mjs} +12 -14
  69. package/src/lib/functions/runtimes/go/{index.cjs → index.mjs} +10 -10
  70. package/src/lib/functions/runtimes/{index.cjs → index.mjs} +12 -7
  71. package/src/lib/functions/runtimes/js/builders/{netlify-lambda.cjs → netlify-lambda.mjs} +13 -10
  72. package/src/lib/functions/runtimes/js/builders/{zisi.cjs → zisi.mjs} +15 -13
  73. package/src/lib/functions/runtimes/js/{index.cjs → index.mjs} +12 -12
  74. package/src/lib/functions/runtimes/rust/{index.cjs → index.mjs} +15 -15
  75. package/src/lib/functions/scheduled.mjs +1 -1
  76. package/src/lib/functions/server.mjs +6 -7
  77. package/src/lib/functions/{synchronous.cjs → synchronous.mjs} +5 -7
  78. package/src/lib/functions/{utils.cjs → utils.mjs} +6 -21
  79. package/src/lib/{geo-location.cjs → geo-location.mjs} +3 -5
  80. package/src/lib/http-agent.mjs +1 -1
  81. package/src/lib/{log.cjs → log.mjs} +3 -7
  82. package/src/lib/one-graph/cli-client.mjs +2 -2
  83. package/src/lib/one-graph/cli-netlify-graph.mjs +2 -3
  84. package/src/lib/path.mjs +1 -0
  85. package/src/lib/{render-error-remplate.cjs → render-error-template.mjs} +8 -4
  86. package/src/lib/{string.cjs → string.mjs} +1 -3
  87. package/src/recipes/vscode/index.mjs +1 -1
  88. package/src/utils/addons/diffs/options.mjs +1 -1
  89. package/src/utils/addons/prepare.mjs +1 -1
  90. package/src/utils/addons/prompts.mjs +1 -1
  91. package/src/utils/addons/render.mjs +1 -1
  92. package/src/utils/{command-helpers.cjs → command-helpers.mjs} +45 -64
  93. package/src/utils/{deferred.cjs → create-deferred.mjs} +1 -1
  94. package/src/utils/deploy/constants.mjs +19 -0
  95. package/src/utils/deploy/{deploy-site.cjs → deploy-site.mjs} +15 -17
  96. package/src/utils/deploy/{hash-files.cjs → hash-files.mjs} +7 -5
  97. package/src/utils/deploy/{hash-fns.cjs → hash-fns.mjs} +11 -8
  98. package/src/utils/deploy/{hasher-segments.cjs → hasher-segments.mjs} +10 -17
  99. package/src/utils/deploy/{upload-files.cjs → upload-files.mjs} +5 -5
  100. package/src/utils/deploy/{util.cjs → util.mjs} +8 -20
  101. package/src/utils/detect-server-settings.mjs +2 -2
  102. package/src/utils/{dev.cjs → dev.mjs} +13 -21
  103. package/src/utils/{dot-env.cjs → dot-env.mjs} +7 -9
  104. package/src/utils/env/{index.cjs → index.mjs} +11 -24
  105. package/src/utils/execa.mjs +17 -0
  106. package/src/utils/get-global-config.mjs +40 -0
  107. package/src/utils/get-repo-data.mjs +1 -1
  108. package/src/utils/{gh-auth.cjs → gh-auth.mjs} +10 -12
  109. package/src/utils/gitignore.mjs +1 -1
  110. package/src/utils/{headers.cjs → headers.mjs} +4 -11
  111. package/src/utils/init/{config-github.cjs → config-github.mjs} +6 -8
  112. package/src/utils/init/{config-manual.cjs → config-manual.mjs} +4 -4
  113. package/src/utils/init/{config.cjs → config.mjs} +4 -5
  114. package/src/utils/init/{frameworks.cjs → frameworks.mjs} +2 -5
  115. package/src/utils/init/{node-version.cjs → node-version.mjs} +6 -8
  116. package/src/utils/init/{plugins.cjs → plugins.mjs} +3 -5
  117. package/src/utils/init/{utils.cjs → utils.mjs} +27 -23
  118. package/src/utils/live-tunnel.mjs +3 -3
  119. package/src/utils/lm/install.mjs +3 -3
  120. package/src/utils/lm/requirements.mjs +1 -1
  121. package/src/utils/lm/steps.mjs +1 -1
  122. package/src/utils/lm/ui.mjs +1 -1
  123. package/src/utils/{open-browser.cjs → open-browser.mjs} +5 -5
  124. package/src/utils/{parse-raw-flags.cjs → parse-raw-flags.mjs} +2 -7
  125. package/src/utils/proxy.mjs +14 -10
  126. package/src/utils/{redirects.cjs → redirects.mjs} +3 -7
  127. package/src/utils/{rules-proxy.cjs → rules-proxy.mjs} +19 -19
  128. package/src/utils/sites/{utils.cjs → utils.mjs} +6 -6
  129. package/src/utils/telemetry/telemetry.mjs +2 -2
  130. package/src/utils/telemetry/validation.mjs +1 -1
  131. package/src/lib/account.cjs +0 -9
  132. package/src/lib/edge-functions/consts.cjs +0 -11
  133. package/src/lib/edge-functions/index.cjs +0 -6
  134. package/src/lib/path.cjs +0 -3
  135. package/src/utils/deploy/constants.cjs +0 -31
  136. package/src/utils/deploy/index.cjs +0 -4
  137. package/src/utils/execa.cjs +0 -12
  138. package/src/utils/get-global-config.cjs +0 -47
  139. package/src/utils/index.cjs +0 -22
@@ -10,7 +10,7 @@
10
10
  // // rawFlags = {stuff: yay!}
11
11
  //
12
12
 
13
- const parseRawFlags = function (raw) {
13
+ export const parseRawFlags = function (raw) {
14
14
  const rawFlags = raw.reduce((acc, curr, index, array) => {
15
15
  if (/^-{1,2}/.test(curr)) {
16
16
  const key = curr.replace(/^-{1,2}/, '')
@@ -28,7 +28,7 @@ const parseRawFlags = function (raw) {
28
28
  return rawFlags
29
29
  }
30
30
 
31
- const aggressiveJSONParse = function (value) {
31
+ export const aggressiveJSONParse = function (value) {
32
32
  if (value === 'true') {
33
33
  return true
34
34
  }
@@ -47,8 +47,3 @@ const aggressiveJSONParse = function (value) {
47
47
  }
48
48
  return parsed
49
49
  }
50
-
51
- module.exports = {
52
- parseRawFlags,
53
- aggressiveJSONParse,
54
- }
@@ -20,14 +20,18 @@ import locatePath from 'locate-path'
20
20
  import pFilter from 'p-filter'
21
21
  import toReadableStream from 'to-readable-stream'
22
22
 
23
- import edgeFunctions from '../lib/edge-functions/index.cjs'
23
+ import {
24
+ handleProxyRequest,
25
+ initializeProxy as initializeEdgeFunctionsProxy,
26
+ isEdgeFunctionsRequest,
27
+ } from '../lib/edge-functions/proxy.mjs'
24
28
  import { fileExistsAsync, isFileAsync } from '../lib/fs.cjs'
25
- import renderErrorTemplate from '../lib/render-error-remplate.cjs'
29
+ import renderErrorTemplate from '../lib/render-error-template.mjs'
26
30
 
27
- import { NETLIFYDEVLOG, NETLIFYDEVWARN } from './command-helpers.cjs'
31
+ import { NETLIFYDEVLOG, NETLIFYDEVWARN } from './command-helpers.mjs'
28
32
  import createStreamPromise from './create-stream-promise.mjs'
29
- import { headersForPath, parseHeaders } from './headers.cjs'
30
- import { createRewriter, onChanges } from './rules-proxy.cjs'
33
+ import { headersForPath, parseHeaders } from './headers.mjs'
34
+ import { createRewriter, onChanges } from './rules-proxy.mjs'
31
35
 
32
36
  const decompress = util.promisify(zlib.gunzip)
33
37
  const shouldGenerateETag = Symbol('Internal: response should generate ETag')
@@ -338,15 +342,15 @@ const initializeProxy = async function ({ configPath, distDir, host, port, proje
338
342
  'Content-Type': 'text/plain',
339
343
  })
340
344
 
341
- const message = edgeFunctions.isEdgeFunctionsRequest(req)
345
+ const message = isEdgeFunctionsRequest(req)
342
346
  ? 'There was an error with an Edge Function. Please check the terminal for more details.'
343
347
  : 'Could not proxy request.'
344
348
 
345
349
  res.end(message)
346
350
  })
347
351
  proxy.on('proxyReq', (proxyReq, req) => {
348
- if (edgeFunctions.isEdgeFunctionsRequest(req)) {
349
- edgeFunctions.handleProxyRequest(req, proxyReq)
352
+ if (isEdgeFunctionsRequest(req)) {
353
+ handleProxyRequest(req, proxyReq)
350
354
  }
351
355
 
352
356
  // eslint-disable-next-line no-underscore-dangle
@@ -428,7 +432,7 @@ const initializeProxy = async function ({ configPath, distDir, host, port, proje
428
432
 
429
433
  const isUncaughtError = proxyRes.headers['x-nf-uncaught-error'] === '1'
430
434
 
431
- if (edgeFunctions.isEdgeFunctionsRequest(req) && isUncaughtError) {
435
+ if (isEdgeFunctionsRequest(req) && isUncaughtError) {
432
436
  const acceptsHtml = req.headers && req.headers.accept && req.headers.accept.includes('text/html')
433
437
  const decompressedBody = await decompress(responseBody)
434
438
  const formattedBody = formatEdgeFunctionError(decompressedBody, acceptsHtml)
@@ -541,7 +545,7 @@ export const startProxy = async function ({
541
545
  state,
542
546
  }) {
543
547
  const functionsServer = settings.functionsPort ? `http://127.0.0.1:${settings.functionsPort}` : null
544
- const edgeFunctionsProxy = await edgeFunctions.initializeProxy({
548
+ const edgeFunctionsProxy = await initializeEdgeFunctionsProxy({
545
549
  config,
546
550
  configPath,
547
551
  env,
@@ -1,13 +1,11 @@
1
1
  // @ts-check
2
- // TODO: use static `import` after migrating this repository to pure ES modules
3
- const netlifyRedirectParser = import('netlify-redirect-parser')
2
+ import { parseAllRedirects } from 'netlify-redirect-parser'
4
3
 
5
- const { NETLIFYDEVERR, log } = require('./command-helpers.cjs')
4
+ import { NETLIFYDEVERR, log } from './command-helpers.mjs'
6
5
 
7
6
  // Parse, normalize and validate all redirects from `_redirects` files
8
7
  // and `netlify.toml`
9
- const parseRedirects = async function ({ configPath, redirectsFiles }) {
10
- const { parseAllRedirects } = await netlifyRedirectParser
8
+ export const parseRedirects = async function ({ configPath, redirectsFiles }) {
11
9
  const { errors, redirects } = await parseAllRedirects({
12
10
  redirectsFiles,
13
11
  netlifyConfigPath: configPath,
@@ -52,5 +50,3 @@ const normalizeRedirect = function ({
52
50
  },
53
51
  }
54
52
  }
55
-
56
- module.exports = { parseRedirects }
@@ -1,19 +1,19 @@
1
1
  // @ts-check
2
- const path = require('path')
2
+ import path from 'path'
3
3
 
4
- const chokidar = require('chokidar')
5
- const cookie = require('cookie')
6
- const redirector = require('netlify-redirector')
7
- const pFilter = require('p-filter')
4
+ import chokidar from 'chokidar'
5
+ import cookie from 'cookie'
6
+ import redirector from 'netlify-redirector'
7
+ import pFilter from 'p-filter'
8
8
 
9
- const { fileExistsAsync } = require('../lib/fs.cjs')
9
+ import { fileExistsAsync } from '../lib/fs.cjs'
10
10
 
11
- const { NETLIFYDEVLOG } = require('./command-helpers.cjs')
12
- const { parseRedirects } = require('./redirects.cjs')
11
+ import { NETLIFYDEVLOG } from './command-helpers.mjs'
12
+ import { parseRedirects } from './redirects.mjs'
13
13
 
14
14
  const watchers = []
15
15
 
16
- const onChanges = function (files, listener) {
16
+ export const onChanges = function (files, listener) {
17
17
  files.forEach((file) => {
18
18
  const watcher = chokidar.watch(file)
19
19
  watcher.on('change', listener)
@@ -22,18 +22,25 @@ const onChanges = function (files, listener) {
22
22
  })
23
23
  }
24
24
 
25
- const getWatchers = function () {
25
+ export const getWatchers = function () {
26
26
  return watchers
27
27
  }
28
28
 
29
- const getLanguage = function (headers) {
29
+ export const getLanguage = function (headers) {
30
30
  if (headers['accept-language']) {
31
31
  return headers['accept-language'].split(',')[0].slice(0, 2)
32
32
  }
33
33
  return 'en'
34
34
  }
35
35
 
36
- const createRewriter = async function ({ configPath, distDir, geoCountry, jwtRoleClaim, jwtSecret, projectDir }) {
36
+ export const createRewriter = async function ({
37
+ configPath,
38
+ distDir,
39
+ geoCountry,
40
+ jwtRoleClaim,
41
+ jwtSecret,
42
+ projectDir,
43
+ }) {
37
44
  let matcher = null
38
45
  const redirectsFiles = [...new Set([path.resolve(distDir, '_redirects'), path.resolve(projectDir, '_redirects')])]
39
46
  let redirects = await parseRedirects({ redirectsFiles, configPath })
@@ -95,10 +102,3 @@ const createRewriter = async function ({ configPath, distDir, geoCountry, jwtRol
95
102
  return match
96
103
  }
97
104
  }
98
-
99
- module.exports = {
100
- onChanges,
101
- getLanguage,
102
- createRewriter,
103
- getWatchers,
104
- }
@@ -1,6 +1,6 @@
1
- const fetch = require('node-fetch')
1
+ import fetch from 'node-fetch'
2
2
 
3
- const getTemplatesFromGitHub = async (token) => {
3
+ export const getTemplatesFromGitHub = async (token) => {
4
4
  const getPublicGitHubReposFromOrg = new URL(`https://api.github.com/orgs/netlify-templates/repos`)
5
5
  // GitHub returns 30 by default and we want to avoid our limit
6
6
  // due to our archived repositories at any given time
@@ -21,7 +21,7 @@ const getTemplatesFromGitHub = async (token) => {
21
21
  return allTemplates
22
22
  }
23
23
 
24
- const validateTemplate = async ({ ghToken, templateName }) => {
24
+ export const validateTemplate = async ({ ghToken, templateName }) => {
25
25
  const response = await fetch(`https://api.github.com/repos/${templateName}`, {
26
26
  headers: {
27
27
  Authorization: `token ${ghToken}`,
@@ -37,10 +37,11 @@ const validateTemplate = async ({ ghToken, templateName }) => {
37
37
  }
38
38
 
39
39
  const data = await response.json()
40
+
40
41
  return { exists: true, isTemplate: data.is_template }
41
42
  }
42
43
 
43
- const createRepo = async (templateName, ghToken, siteName) => {
44
+ export const createRepo = async (templateName, ghToken, siteName) => {
44
45
  const resp = await fetch(`https://api.github.com/repos/${templateName}/generate`, {
45
46
  method: 'POST',
46
47
  headers: {
@@ -52,7 +53,6 @@ const createRepo = async (templateName, ghToken, siteName) => {
52
53
  })
53
54
 
54
55
  const data = await resp.json()
56
+
55
57
  return data
56
58
  }
57
-
58
- module.exports = { getTemplatesFromGitHub, createRepo, validateTemplate }
@@ -5,8 +5,8 @@ import { fileURLToPath } from 'url'
5
5
 
6
6
  import { isCI } from 'ci-info'
7
7
 
8
- import execa from '../execa.cjs'
9
- import getGlobalConfig from '../get-global-config.cjs'
8
+ import execa from '../execa.mjs'
9
+ import getGlobalConfig from '../get-global-config.mjs'
10
10
 
11
11
  import isValidEventName from './validation.mjs'
12
12
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Utility to validating analytic event names for clean data
3
3
  */
4
- import { log } from '../command-helpers.cjs'
4
+ import { log } from '../command-helpers.mjs'
5
5
 
6
6
  export default function isValidEventName(eventName, config) {
7
7
  const validProject = [config.projectName]
@@ -1,9 +0,0 @@
1
- const dotProp = require('dot-prop')
2
-
3
- const supportsBooleanCapability = (account, capability) => dotProp.get(account, `capabilities.${capability}.included`)
4
-
5
- const supportsBackgroundFunctions = (account) => supportsBooleanCapability(account, 'background_functions')
6
-
7
- module.exports = {
8
- supportsBackgroundFunctions,
9
- }
@@ -1,11 +0,0 @@
1
- const DIST_IMPORT_MAP_PATH = 'edge-functions-import-map.json'
2
- const INTERNAL_EDGE_FUNCTIONS_FOLDER = 'edge-functions'
3
- const EDGE_FUNCTIONS_FOLDER = 'edge-functions-dist'
4
- const PUBLIC_URL_PATH = '.netlify/internal/edge-functions'
5
-
6
- module.exports = {
7
- DIST_IMPORT_MAP_PATH,
8
- INTERNAL_EDGE_FUNCTIONS_FOLDER,
9
- EDGE_FUNCTIONS_FOLDER,
10
- PUBLIC_URL_PATH,
11
- }
@@ -1,6 +0,0 @@
1
- // @ts-check
2
- const constants = require('./consts.cjs')
3
- const deploy = require('./deploy.cjs')
4
- const proxy = require('./proxy.cjs')
5
-
6
- module.exports = { ...constants, ...deploy, ...proxy }
package/src/lib/path.cjs DELETED
@@ -1,3 +0,0 @@
1
- const normalizeBackslash = (path) => path.replace(/\\/g, '/')
2
-
3
- module.exports = { normalizeBackslash }
@@ -1,31 +0,0 @@
1
- // Local deploy timeout: 20 mins
2
- const DEFAULT_DEPLOY_TIMEOUT = 1.2e6
3
- // Concurrent file hash calls
4
- const DEFAULT_CONCURRENT_HASH = 1e2
5
- // Number of concurrent uploads
6
- const DEFAULT_CONCURRENT_UPLOAD = 5
7
- // Number of files
8
- const DEFAULT_SYNC_LIMIT = 1e2
9
- // Number of times to retry an upload
10
- const DEFAULT_MAX_RETRY = 5
11
-
12
- const UPLOAD_RANDOM_FACTOR = 0.5
13
- // 5 seconds
14
- const UPLOAD_INITIAL_DELAY = 5e3
15
- // 1.5 minute
16
- const UPLOAD_MAX_DELAY = 9e4
17
-
18
- // 1 second
19
- const DEPLOY_POLL = 1e3
20
-
21
- module.exports = {
22
- DEFAULT_DEPLOY_TIMEOUT,
23
- DEFAULT_CONCURRENT_HASH,
24
- DEFAULT_CONCURRENT_UPLOAD,
25
- DEFAULT_SYNC_LIMIT,
26
- DEFAULT_MAX_RETRY,
27
- UPLOAD_RANDOM_FACTOR,
28
- UPLOAD_INITIAL_DELAY,
29
- UPLOAD_MAX_DELAY,
30
- DEPLOY_POLL,
31
- }
@@ -1,4 +0,0 @@
1
- // @ts-check
2
- const { deploySite } = require('./deploy-site.cjs')
3
-
4
- module.exports = { deploySite }
@@ -1,12 +0,0 @@
1
- const { env } = require('process')
2
-
3
- const execaLib = require('execa')
4
-
5
- // This is a thin layer on top of `execa` that allows consumers to provide an
6
- // alternative path to the module location, making it easier to mock its logic
7
- // in tests (see `tests/utils/mock-execa.js`).
8
-
9
- // eslint-disable-next-line import/no-dynamic-require
10
- const execa = env.NETLIFY_CLI_EXECA_PATH ? require(env.NETLIFY_CLI_EXECA_PATH) : execaLib
11
-
12
- module.exports = execa
@@ -1,47 +0,0 @@
1
- const { readFile } = require('fs').promises
2
-
3
- const Configstore = require('configstore')
4
- const memoizeOne = require('memoize-one')
5
- const { v4: uuidv4 } = require('uuid')
6
-
7
- const { getLegacyPathInHome, getPathInHome } = require('../lib/settings.cjs')
8
-
9
- const globalConfigDefaults = {
10
- /* disable stats from being sent to Netlify */
11
- telemetryDisabled: false,
12
- /* cliId */
13
- cliId: uuidv4(),
14
- }
15
-
16
- const getGlobalConfigOnce = async function () {
17
- const configPath = getPathInHome(['config.json'])
18
- // Legacy config file in home ~/.netlify/config.json
19
- const legacyPath = getLegacyPathInHome(['config.json'])
20
- let legacyConfig
21
- // Read legacy config if exists
22
- try {
23
- legacyConfig = JSON.parse(await readFile(legacyPath))
24
- } catch {}
25
- // Use legacy config as default values
26
- const defaults = { ...globalConfigDefaults, ...legacyConfig }
27
- const configStore = new Configstore(null, defaults, { configPath })
28
-
29
- return configStore
30
- }
31
-
32
- const getGlobalConfig = async function () {
33
- const retries = 3
34
- // eslint-disable-next-line fp/no-loops
35
- for (let retry = 1; retry <= retries; retry++) {
36
- try {
37
- return await getGlobalConfigOnce()
38
- } catch (error) {
39
- if (retry === retries) {
40
- throw error
41
- }
42
- }
43
- }
44
- }
45
-
46
- // Memoise config result so that we only load it once
47
- module.exports = memoizeOne(getGlobalConfig)
@@ -1,22 +0,0 @@
1
- // @ts-check
2
- const commandHelpers = require('./command-helpers.cjs')
3
- const deploy = require('./deploy/index.cjs')
4
- const dev = require('./dev.cjs')
5
- const env = require('./env/index.cjs')
6
- const execa = require('./execa.cjs')
7
- const getGlobalConfig = require('./get-global-config.cjs')
8
- const ghAuth = require('./gh-auth.cjs')
9
- const openBrowser = require('./open-browser.cjs')
10
- const parseRawFlags = require('./parse-raw-flags.cjs')
11
-
12
- module.exports = {
13
- ...commandHelpers,
14
- ...deploy,
15
- ...dev,
16
- ...env,
17
- ...ghAuth,
18
- ...openBrowser,
19
- ...parseRawFlags,
20
- execa,
21
- getGlobalConfig,
22
- }