netlify-cli 12.2.7 → 12.2.8

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 (112) hide show
  1. package/bin/run.mjs +2 -3
  2. package/npm-shrinkwrap.json +93 -90
  3. package/package.json +4 -4
  4. package/scripts/postinstall.mjs +2 -2
  5. package/src/commands/base-command.mjs +8 -12
  6. package/src/commands/build/build.mjs +2 -2
  7. package/src/commands/completion/completion.mjs +3 -3
  8. package/src/commands/deploy/deploy.mjs +4 -5
  9. package/src/commands/dev/{dev-exec.cjs → dev-exec.mjs} +5 -5
  10. package/src/commands/dev/{dev.cjs → dev.mjs} +32 -32
  11. package/src/commands/dev/index.mjs +1 -0
  12. package/src/commands/env/{env-clone.cjs → env-clone.mjs} +7 -16
  13. package/src/commands/env/{env-get.cjs → env-get.mjs} +5 -13
  14. package/src/commands/env/{env-import.cjs → env-import.mjs} +8 -15
  15. package/src/commands/env/{env-list.cjs → env-list.mjs} +13 -25
  16. package/src/commands/env/{env-set.cjs → env-set.mjs} +5 -5
  17. package/src/commands/env/{env-unset.cjs → env-unset.mjs} +4 -12
  18. package/src/commands/env/{env.cjs → env.mjs} +7 -9
  19. package/src/commands/env/index.mjs +1 -0
  20. package/src/commands/functions/functions-build.mjs +2 -1
  21. package/src/commands/functions/functions-create.mjs +2 -12
  22. package/src/commands/functions/functions-invoke.mjs +2 -1
  23. package/src/commands/functions/functions-list.mjs +2 -1
  24. package/src/commands/functions/functions-serve.mjs +3 -2
  25. package/src/commands/graph/{graph-config-write.cjs → graph-config-write.mjs} +8 -8
  26. package/src/commands/graph/{graph-edit.cjs → graph-edit.mjs} +9 -14
  27. package/src/commands/graph/{graph-handler.cjs → graph-handler.mjs} +6 -6
  28. package/src/commands/graph/{graph-init.cjs → graph-init.mjs} +12 -20
  29. package/src/commands/graph/{graph-library.cjs → graph-library.mjs} +8 -8
  30. package/src/commands/graph/{graph-operations.cjs → graph-operations.mjs} +7 -7
  31. package/src/commands/graph/{graph-pull.cjs → graph-pull.mjs} +8 -12
  32. package/src/commands/graph/{graph.cjs → graph.mjs} +8 -10
  33. package/src/commands/graph/index.mjs +1 -0
  34. package/src/commands/init/init.mjs +5 -2
  35. package/src/commands/link/index.mjs +1 -0
  36. package/src/commands/link/{link.cjs → link.mjs} +15 -13
  37. package/src/commands/lm/index.mjs +1 -0
  38. package/src/commands/lm/{lm-info.cjs → lm-info.mjs} +4 -6
  39. package/src/commands/lm/{lm-install.cjs → lm-install.mjs} +3 -5
  40. package/src/commands/lm/{lm-setup.cjs → lm-setup.mjs} +8 -8
  41. package/src/commands/lm/{lm-uninstall.cjs → lm-uninstall.mjs} +2 -4
  42. package/src/commands/lm/{lm.cjs → lm.mjs} +5 -7
  43. package/src/commands/logout/logout.mjs +2 -1
  44. package/src/commands/main.mjs +10 -12
  45. package/src/commands/recipes/common.mjs +36 -0
  46. package/src/commands/recipes/index.mjs +1 -0
  47. package/src/commands/recipes/{recipes-list.cjs → recipes-list.mjs} +3 -5
  48. package/src/commands/recipes/{recipes.cjs → recipes.mjs} +12 -10
  49. package/src/commands/sites/sites-create-template.mjs +3 -1
  50. package/src/commands/sites/sites-create.mjs +4 -2
  51. package/src/commands/sites/sites-list.mjs +1 -1
  52. package/src/commands/unlink/unlink.mjs +2 -1
  53. package/src/functions-templates/go/hello-world/go.mod +1 -1
  54. package/src/functions-templates/javascript/stripe-charge/package-lock.json +6 -6
  55. package/src/functions-templates/javascript/stripe-subscription/package-lock.json +6 -6
  56. package/src/functions-templates/javascript/token-hider/package-lock.json +6 -6
  57. package/src/functions-templates/rust/hello-world/Cargo.toml +1 -1
  58. package/src/functions-templates/typescript/hello-world/package-lock.json +6 -6
  59. package/src/lib/account.cjs +0 -3
  60. package/src/lib/{api.cjs → api.mjs} +3 -5
  61. package/src/lib/{build.cjs → build.mjs} +9 -9
  62. package/src/lib/completion/constants.mjs +4 -0
  63. package/src/lib/completion/{generate-autocompletion.cjs → generate-autocompletion.mjs} +6 -6
  64. package/src/lib/completion/{script.cjs → get-autocompletion.mjs} +1 -25
  65. package/src/lib/completion/index.mjs +1 -0
  66. package/src/lib/completion/script.mjs +35 -0
  67. package/src/lib/edge-functions/{editor-helper.cjs → editor-helper.mjs} +4 -6
  68. package/src/lib/edge-functions/index.cjs +1 -2
  69. package/src/lib/exec-fetcher.cjs +0 -2
  70. package/src/lib/functions/{form-submissions-handler.cjs → form-submissions-handler.mjs} +26 -28
  71. package/src/lib/functions/{scheduled.cjs → scheduled.mjs} +6 -8
  72. package/src/lib/functions/{server.cjs → server.mjs} +20 -29
  73. package/src/lib/geo-location.cjs +1 -1
  74. package/src/lib/{http-agent.cjs → http-agent.mjs} +7 -8
  75. package/src/lib/one-graph/{cli-client.cjs → cli-client.mjs} +46 -74
  76. package/src/lib/one-graph/{cli-netlify-graph.cjs → cli-netlify-graph.mjs} +35 -43
  77. package/src/recipes/vscode/{index.cjs → index.mjs} +7 -9
  78. package/src/recipes/vscode/{settings.cjs → settings.mjs} +10 -12
  79. package/src/utils/{create-stream-promise.cjs → create-stream-promise.mjs} +2 -2
  80. package/src/utils/{detect-server-settings.cjs → detect-server-settings.mjs} +14 -20
  81. package/src/utils/functions/constants.mjs +1 -0
  82. package/src/utils/functions/{functions.cjs → functions.mjs} +6 -8
  83. package/src/utils/functions/{get-functions.cjs → get-functions.mjs} +4 -25
  84. package/src/utils/functions/index.mjs +3 -0
  85. package/src/utils/get-package-json.mjs +16 -0
  86. package/src/utils/{get-repo-data.cjs → get-repo-data.mjs} +15 -12
  87. package/src/utils/{gitignore.cjs → gitignore.mjs} +6 -8
  88. package/src/utils/index.cjs +0 -20
  89. package/src/utils/{live-tunnel.cjs → live-tunnel.mjs} +8 -10
  90. package/src/utils/lm/{install.cjs → install.mjs} +26 -25
  91. package/src/utils/lm/{requirements.cjs → requirements.mjs} +6 -13
  92. package/src/utils/lm/{steps.cjs → steps.mjs} +6 -8
  93. package/src/utils/lm/{ui.cjs → ui.mjs} +5 -7
  94. package/src/utils/{proxy.cjs → proxy.mjs} +31 -34
  95. package/src/utils/{read-repo-url.cjs → read-repo-url.mjs} +6 -11
  96. package/src/utils/{state-config.cjs → state-config.mjs} +8 -10
  97. package/src/utils/telemetry/index.mjs +1 -0
  98. package/src/utils/telemetry/{request.cjs → request.mjs} +5 -3
  99. package/src/utils/telemetry/{telemetry.cjs → telemetry.mjs} +12 -14
  100. package/src/utils/telemetry/{validation.cjs → validation.mjs} +2 -2
  101. package/src/commands/dev/index.cjs +0 -5
  102. package/src/commands/env/index.cjs +0 -5
  103. package/src/commands/graph/index.cjs +0 -5
  104. package/src/commands/link/index.cjs +0 -6
  105. package/src/commands/lm/index.cjs +0 -5
  106. package/src/commands/recipes/common.cjs +0 -33
  107. package/src/commands/recipes/index.cjs +0 -8
  108. package/src/lib/completion/constants.cjs +0 -6
  109. package/src/lib/completion/index.cjs +0 -5
  110. package/src/utils/functions/constants.cjs +0 -5
  111. package/src/utils/functions/index.cjs +0 -12
  112. package/src/utils/telemetry/index.cjs +0 -5
@@ -1,21 +1,15 @@
1
1
  // @ts-check
2
- const { Buffer } = require('buffer')
3
- const process = require('process')
4
-
5
- const { OneGraphClient } = require('netlify-onegraph-internal')
6
- const { v4: uuidv4 } = require('uuid')
7
-
8
- const { OneGraphCliClient, ensureCLISession } = require('../../lib/one-graph/cli-client.cjs')
9
- const { getNetlifyGraphConfig } = require('../../lib/one-graph/cli-netlify-graph.cjs')
10
- const {
11
- NETLIFYDEVERR,
12
- chalk,
13
- error,
14
- exit,
15
- getToken,
16
- log,
17
- translateFromEnvelopeToMongo,
18
- } = require('../../utils/index.cjs')
2
+ import { Buffer } from 'buffer'
3
+ import process from 'process'
4
+
5
+ import { OneGraphClient } from 'netlify-onegraph-internal'
6
+ import { v4 as uuidv4 } from 'uuid'
7
+
8
+ import { OneGraphCliClient, ensureCLISession } from '../../lib/one-graph/cli-client.mjs'
9
+ import { getNetlifyGraphConfig } from '../../lib/one-graph/cli-netlify-graph.mjs'
10
+ import utils from '../../utils/index.cjs'
11
+
12
+ const { NETLIFYDEVERR, chalk, error, exit, getToken, log, translateFromEnvelopeToMongo } = utils
19
13
 
20
14
  const { ensureAppForSite, executeCreateApiTokenMutation } = OneGraphCliClient
21
15
 
@@ -161,12 +155,10 @@ const graphInit = async (options, command) => {
161
155
  * @param {import('../base-command.mjs').default} program
162
156
  * @returns
163
157
  */
164
- const createGraphInitCommand = (program) =>
158
+ export const createGraphInitCommand = (program) =>
165
159
  program
166
160
  .command('graph:init')
167
161
  .description('Initialize all the resources for Netlify Graph')
168
162
  .action(async (options, command) => {
169
163
  await graphInit(options, command)
170
164
  })
171
-
172
- module.exports = { createGraphInitCommand }
@@ -1,8 +1,8 @@
1
1
  // @ts-check
2
- const { GraphQL } = require('netlify-onegraph-internal')
2
+ import { GraphQL } from 'netlify-onegraph-internal'
3
3
 
4
- const { readLockfile } = require('../../lib/one-graph/cli-client.cjs')
5
- const {
4
+ import { readLockfile } from '../../lib/one-graph/cli-client.mjs'
5
+ import {
6
6
  buildSchema,
7
7
  defaultExampleOperationsDoc,
8
8
  extractFunctionsFromOperationDoc,
@@ -11,8 +11,10 @@ const {
11
11
  parse,
12
12
  readGraphQLOperationsSourceFile,
13
13
  readGraphQLSchemaFile,
14
- } = require('../../lib/one-graph/cli-netlify-graph.cjs')
15
- const { NETLIFYDEVERR, chalk, error, log } = require('../../utils/index.cjs')
14
+ } from '../../lib/one-graph/cli-netlify-graph.mjs'
15
+ import utils from '../../utils/index.cjs'
16
+
17
+ const { NETLIFYDEVERR, chalk, error, log } = utils
16
18
 
17
19
  /**
18
20
  * Creates the `netlify graph:library` command
@@ -79,12 +81,10 @@ const graphLibrary = async (options, command) => {
79
81
  * @param {import('../base-command.mjs').default} program
80
82
  * @returns
81
83
  */
82
- const createGraphLibraryCommand = (program) =>
84
+ export const createGraphLibraryCommand = (program) =>
83
85
  program
84
86
  .command('graph:library')
85
87
  .description('Generate the Graph function library')
86
88
  .action(async (options, command) => {
87
89
  await graphLibrary(options, command)
88
90
  })
89
-
90
- module.exports = { createGraphLibraryCommand }
@@ -1,13 +1,15 @@
1
1
  // @ts-check
2
- const { GraphQL } = require('netlify-onegraph-internal')
2
+ import { GraphQL } from 'netlify-onegraph-internal'
3
3
 
4
- const {
4
+ import {
5
5
  defaultExampleOperationsDoc,
6
6
  extractFunctionsFromOperationDoc,
7
7
  getNetlifyGraphConfig,
8
8
  readGraphQLOperationsSourceFile,
9
- } = require('../../lib/one-graph/cli-netlify-graph.cjs')
10
- const { log } = require('../../utils/index.cjs')
9
+ } from '../../lib/one-graph/cli-netlify-graph.mjs'
10
+ import utils from '../../utils/index.cjs'
11
+
12
+ const { log } = utils
11
13
 
12
14
  const { parse } = GraphQL
13
15
 
@@ -107,12 +109,10 @@ const graphOperations = async (options, command) => {
107
109
  * @param {import('../base-command.mjs').default} program
108
110
  * @returns
109
111
  */
110
- const createGraphOperationsCommand = (program) =>
112
+ export const createGraphOperationsCommand = (program) =>
111
113
  program
112
114
  .command('graph:operations')
113
115
  .description('List all of the locally available operations')
114
116
  .action(async (options, command) => {
115
117
  await graphOperations(options, command)
116
118
  })
117
-
118
- module.exports = { createGraphOperationsCommand }
@@ -1,9 +1,9 @@
1
1
  // @ts-check
2
2
  /* eslint-disable eslint-comments/disable-enable-pair */
3
3
  /* eslint-disable fp/no-loops */
4
- const { OneGraphClient } = require('netlify-onegraph-internal')
4
+ import { OneGraphClient } from 'netlify-onegraph-internal'
5
5
 
6
- const {
6
+ import {
7
7
  OneGraphCliClient,
8
8
  ensureCLISession,
9
9
  handleCliSessionEvent,
@@ -11,13 +11,11 @@ const {
11
11
  readLockfile,
12
12
  readSchemaIdFromLockfile,
13
13
  refetchAndGenerateFromOneGraph,
14
- } = require('../../lib/one-graph/cli-client.cjs')
15
- const {
16
- buildSchema,
17
- getNetlifyGraphConfig,
18
- readGraphQLSchemaFile,
19
- } = require('../../lib/one-graph/cli-netlify-graph.cjs')
20
- const { NETLIFYDEVERR, chalk, error, log, warn } = require('../../utils/index.cjs')
14
+ } from '../../lib/one-graph/cli-client.mjs'
15
+ import { buildSchema, getNetlifyGraphConfig, readGraphQLSchemaFile } from '../../lib/one-graph/cli-netlify-graph.mjs'
16
+ import utils from '../../utils/index.cjs'
17
+
18
+ const { NETLIFYDEVERR, chalk, error, log, warn } = utils
21
19
 
22
20
  /**
23
21
  * Creates the `netlify graph:pull` command
@@ -163,12 +161,10 @@ ${JSON.stringify(error_, null, 2)}`)
163
161
  * @param {import('../base-command.mjs').default} program
164
162
  * @returns
165
163
  */
166
- const createGraphPullCommand = (program) =>
164
+ export const createGraphPullCommand = (program) =>
167
165
  program
168
166
  .command('graph:pull')
169
167
  .description('Pull your remote Netlify Graph schema locally, and process pending Graph edit events')
170
168
  .action(async (options, command) => {
171
169
  await graphPull(options, command)
172
170
  })
173
-
174
- module.exports = { createGraphPullCommand }
@@ -1,11 +1,11 @@
1
1
  // @ts-check
2
- const { createGraphConfigWriteCommand } = require('./graph-config-write.cjs')
3
- const { createGraphEditCommand } = require('./graph-edit.cjs')
4
- const { createGraphHandlerCommand } = require('./graph-handler.cjs')
5
- const { createGraphInitCommand } = require('./graph-init.cjs')
6
- const { createGraphLibraryCommand } = require('./graph-library.cjs')
7
- const { createGraphOperationsCommand } = require('./graph-operations.cjs')
8
- const { createGraphPullCommand } = require('./graph-pull.cjs')
2
+ import { createGraphConfigWriteCommand } from './graph-config-write.mjs'
3
+ import { createGraphEditCommand } from './graph-edit.mjs'
4
+ import { createGraphHandlerCommand } from './graph-handler.mjs'
5
+ import { createGraphInitCommand } from './graph-init.mjs'
6
+ import { createGraphLibraryCommand } from './graph-library.mjs'
7
+ import { createGraphOperationsCommand } from './graph-operations.mjs'
8
+ import { createGraphPullCommand } from './graph-pull.mjs'
9
9
 
10
10
  /**
11
11
  * The graph command
@@ -21,7 +21,7 @@ const graph = (options, command) => {
21
21
  * @param {import('../base-command.mjs').default} program
22
22
  * @returns
23
23
  */
24
- const createGraphCommand = (program) => {
24
+ export const createGraphCommand = (program) => {
25
25
  createGraphConfigWriteCommand(program)
26
26
  createGraphEditCommand(program)
27
27
  createGraphHandlerCommand(program)
@@ -36,5 +36,3 @@ const createGraphCommand = (program) => {
36
36
  .addExamples(['netlify graph:pull', 'netlify graph:edit'])
37
37
  .action(graph)
38
38
  }
39
-
40
- module.exports = { createGraphCommand }
@@ -0,0 +1 @@
1
+ export { createGraphCommand } from './graph.mjs'
@@ -3,12 +3,15 @@ import dotProp from 'dot-prop'
3
3
  import inquirer from 'inquirer'
4
4
  import isEmpty from 'lodash/isEmpty.js'
5
5
 
6
+ import getRepoData from '../../utils/get-repo-data.mjs'
7
+ import { ensureNetlifyIgnore } from '../../utils/gitignore.mjs'
6
8
  import utils from '../../utils/index.cjs'
7
9
  import { configureRepo } from '../../utils/init/config.cjs'
8
- import { link } from '../link/index.cjs'
10
+ import { track } from '../../utils/telemetry/index.mjs'
11
+ import { link } from '../link/index.mjs'
9
12
  import { sitesCreate } from '../sites/index.mjs'
10
13
 
11
- const { chalk, ensureNetlifyIgnore, exit, getRepoData, log, track } = utils
14
+ const { chalk, exit, log } = utils
12
15
 
13
16
  const persistState = ({ siteInfo, state }) => {
14
17
  // Save to .netlify/state.json file
@@ -0,0 +1 @@
1
+ export { createLinkCommand, link } from './link.mjs'
@@ -1,13 +1,17 @@
1
1
  // @ts-check
2
- const inquirer = require('inquirer')
3
- const isEmpty = require('lodash/isEmpty')
2
+ import inquirer from 'inquirer'
4
3
 
5
- const { listSites } = require('../../lib/api.cjs')
6
- const { chalk, ensureNetlifyIgnore, error, exit, getRepoData, log, track } = require('../../utils/index.cjs')
4
+ import { listSites } from '../../lib/api.mjs'
5
+ import getRepoData from '../../utils/get-repo-data.mjs'
6
+ import { ensureNetlifyIgnore } from '../../utils/gitignore.mjs'
7
+ import utils from '../../utils/index.cjs'
8
+ import { track } from '../../utils/telemetry/index.mjs'
9
+
10
+ const { chalk, error, exit, log } = utils
7
11
 
8
12
  /**
9
13
  *
10
- * @param {import('../base-command').NetlifyOptions} netlify
14
+ * @param {import('../base-command.mjs').NetlifyOptions} netlify
11
15
  * @param {import('commander').OptionValues} options
12
16
  */
13
17
  const linkPrompt = async (netlify, options) => {
@@ -51,7 +55,7 @@ const linkPrompt = async (netlify, options) => {
51
55
  log()
52
56
  const sites = await listSites({ api, options: { filter: 'all' } })
53
57
 
54
- if (isEmpty(sites)) {
58
+ if (sites.length === 0) {
55
59
  error(`You don't have any sites yet. Run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
56
60
  }
57
61
 
@@ -60,7 +64,7 @@ const linkPrompt = async (netlify, options) => {
60
64
  )
61
65
 
62
66
  // If no remote matches. Throw error
63
- if (isEmpty(matchingSites)) {
67
+ if (matchingSites.length === 0) {
64
68
  log(chalk.redBright.bold.underline(`No Matching Site Found`))
65
69
  log()
66
70
  log(`No site found with the remote ${repoData.httpsUrl}.
@@ -125,7 +129,7 @@ Run ${chalk.cyanBright('git remote -v')} to see a list of your git remotes.`)
125
129
  }
126
130
  }
127
131
 
128
- if (isEmpty(matchingSites)) {
132
+ if (!matchingSites || matchingSites.length === 0) {
129
133
  error(`No site names found containing '${searchTerm}'.
130
134
 
131
135
  Run ${chalk.cyanBright('netlify link')} again to try a new search,
@@ -165,7 +169,7 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
165
169
  error(error_)
166
170
  }
167
171
 
168
- if (isEmpty(sites)) {
172
+ if (!sites || sites.length === 0) {
169
173
  error(`You don't have any sites yet. Run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
170
174
  }
171
175
 
@@ -240,7 +244,7 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
240
244
  * @param {import('commander').OptionValues} options
241
245
  * @param {import('../base-command.mjs').default} command
242
246
  */
243
- const link = async (options, command) => {
247
+ export const link = async (options, command) => {
244
248
  await command.authenticate()
245
249
 
246
250
  const {
@@ -337,7 +341,7 @@ const link = async (options, command) => {
337
341
  * @param {import('../base-command.mjs').default} program
338
342
  * @returns
339
343
  */
340
- const createLinkCommand = (program) =>
344
+ export const createLinkCommand = (program) =>
341
345
  program
342
346
  .command('link')
343
347
  .description('Link a local repo or project folder to an existing site on Netlify')
@@ -346,5 +350,3 @@ const createLinkCommand = (program) =>
346
350
  .option('--gitRemoteName <name>', 'Name of Git remote to use. e.g. "origin"')
347
351
  .addExamples(['netlify link', 'netlify link --id 123-123-123-123', 'netlify link --name my-site-name'])
348
352
  .action(link)
349
-
350
- module.exports = { createLinkCommand, link }
@@ -0,0 +1 @@
1
+ export { createLmCommand } from './lm.mjs'
@@ -1,12 +1,12 @@
1
1
  // @ts-check
2
- const Listr = require('listr')
2
+ import Listr from 'listr'
3
3
 
4
- const {
4
+ import {
5
5
  checkGitLFSVersionStep,
6
6
  checkGitVersionStep,
7
7
  checkHelperVersionStep,
8
8
  checkLFSFiltersStep,
9
- } = require('../../utils/lm/steps.cjs')
9
+ } from '../../utils/lm/steps.mjs'
10
10
 
11
11
  /**
12
12
  * The lm:info command
@@ -36,7 +36,5 @@ const lmInfo = async () => {
36
36
  * @param {import('../base-command.mjs').default} program
37
37
  * @returns
38
38
  */
39
- const createLmInfoCommand = (program) =>
39
+ export const createLmInfoCommand = (program) =>
40
40
  program.command('lm:info').description('Show large media requirements information.').action(lmInfo)
41
-
42
- module.exports = { createLmInfoCommand }
@@ -1,6 +1,6 @@
1
1
  // @ts-check
2
- const { installPlatform } = require('../../utils/lm/install.cjs')
3
- const { printBanner } = require('../../utils/lm/ui.cjs')
2
+ import { installPlatform } from '../../utils/lm/install.mjs'
3
+ import { printBanner } from '../../utils/lm/ui.mjs'
4
4
 
5
5
  /**
6
6
  * The lm:install command
@@ -18,7 +18,7 @@ const lmInstall = async ({ force }) => {
18
18
  * @param {import('../base-command.mjs').default} program
19
19
  * @returns
20
20
  */
21
- const createLmInstallCommand = (program) =>
21
+ export const createLmInstallCommand = (program) =>
22
22
  program
23
23
  .command('lm:install')
24
24
  .alias('lm:init')
@@ -29,5 +29,3 @@ and configures your Git environment with the right credentials.`,
29
29
  )
30
30
  .option('-f, --force', 'Force the credentials helper installation')
31
31
  .action(lmInstall)
32
-
33
- module.exports = { createLmInstallCommand }
@@ -1,10 +1,12 @@
1
1
  // @ts-check
2
- const Listr = require('listr')
2
+ import Listr from 'listr'
3
3
 
4
- const { error, execa } = require('../../utils/index.cjs')
5
- const { installPlatform } = require('../../utils/lm/install.cjs')
6
- const { checkHelperVersion } = require('../../utils/lm/requirements.cjs')
7
- const { printBanner } = require('../../utils/lm/ui.cjs')
4
+ import utils from '../../utils/index.cjs'
5
+ import { installPlatform } from '../../utils/lm/install.mjs'
6
+ import { checkHelperVersion } from '../../utils/lm/requirements.mjs'
7
+ import { printBanner } from '../../utils/lm/ui.mjs'
8
+
9
+ const { error, execa } = utils
8
10
 
9
11
  const installHelperIfMissing = async function ({ force }) {
10
12
  let installHelper = false
@@ -94,7 +96,7 @@ const lmSetup = async (options, command) => {
94
96
  * @param {import('../base-command.mjs').default} program
95
97
  * @returns
96
98
  */
97
- const createLmSetupCommand = (program) =>
99
+ export const createLmSetupCommand = (program) =>
98
100
  program
99
101
  .command('lm:setup')
100
102
  .description('Configures your site to use Netlify Large Media')
@@ -102,5 +104,3 @@ const createLmSetupCommand = (program) =>
102
104
  .option('-f, --force-install', 'Force the credentials helper installation')
103
105
  .addHelpText('after', 'It runs the install command if you have not installed the dependencies yet.')
104
106
  .action(lmSetup)
105
-
106
- module.exports = { createLmSetupCommand }
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- const { uninstall } = require('../../utils/lm/install.cjs')
2
+ import { uninstall } from '../../utils/lm/install.mjs'
3
3
 
4
4
  /**
5
5
  * The lm:uninstall command
@@ -13,7 +13,7 @@ const lmUninstall = async () => {
13
13
  * @param {import('../base-command.mjs').default} program
14
14
  * @returns
15
15
  */
16
- const createLmUninstallCommand = (program) =>
16
+ export const createLmUninstallCommand = (program) =>
17
17
  program
18
18
  .command('lm:uninstall', { hidden: true })
19
19
  .alias('lm:remove')
@@ -21,5 +21,3 @@ const createLmUninstallCommand = (program) =>
21
21
  'Uninstalls Netlify git credentials helper and cleans up any related configuration changes made by the install command.',
22
22
  )
23
23
  .action(lmUninstall)
24
-
25
- module.exports = { createLmUninstallCommand }
@@ -1,8 +1,8 @@
1
1
  // @ts-check
2
- const { createLmInfoCommand } = require('./lm-info.cjs')
3
- const { createLmInstallCommand } = require('./lm-install.cjs')
4
- const { createLmSetupCommand } = require('./lm-setup.cjs')
5
- const { createLmUninstallCommand } = require('./lm-uninstall.cjs')
2
+ import { createLmInfoCommand } from './lm-info.mjs'
3
+ import { createLmInstallCommand } from './lm-install.mjs'
4
+ import { createLmSetupCommand } from './lm-setup.mjs'
5
+ import { createLmUninstallCommand } from './lm-uninstall.mjs'
6
6
 
7
7
  /**
8
8
  * The lm command
@@ -18,7 +18,7 @@ const lm = (options, command) => {
18
18
  * @param {import('../base-command.mjs').default} program
19
19
  * @returns
20
20
  */
21
- const createLmCommand = (program) => {
21
+ export const createLmCommand = (program) => {
22
22
  createLmInfoCommand(program)
23
23
  createLmInstallCommand(program)
24
24
  createLmSetupCommand(program)
@@ -30,5 +30,3 @@ const createLmCommand = (program) => {
30
30
  .addExamples(['netlify lm:info', 'netlify lm:install', 'netlify lm:setup'])
31
31
  .action(lm)
32
32
  }
33
-
34
- module.exports = { createLmCommand }
@@ -1,7 +1,8 @@
1
1
  // @ts-check
2
2
  import utils from '../../utils/index.cjs'
3
+ import { track } from '../../utils/telemetry/index.mjs'
3
4
 
4
- const { exit, getToken, log, track } = utils
5
+ const { exit, getToken, log } = utils
5
6
 
6
7
  /**
7
8
  * The logout command
@@ -1,14 +1,13 @@
1
1
  // @ts-check
2
- import { readFile } from 'fs/promises'
3
2
  import process from 'process'
4
- import { fileURLToPath } from 'url'
5
3
 
6
4
  import { Option } from 'commander'
7
5
  import inquirer from 'inquirer'
8
6
  import { findBestMatch } from 'string-similarity'
9
7
 
10
- // TODO: use named imports again once the imported file is esm
8
+ import getPackageJson from '../utils/get-package-json.mjs'
11
9
  import utils from '../utils/index.cjs'
10
+ import { track } from '../utils/telemetry/index.mjs'
12
11
 
13
12
  import { createAddonsCommand } from './addons/index.mjs'
14
13
  import { createApiCommand } from './api/index.mjs'
@@ -16,24 +15,24 @@ import BaseCommand from './base-command.mjs'
16
15
  import { createBuildCommand } from './build/index.mjs'
17
16
  import { createCompletionCommand } from './completion/index.mjs'
18
17
  import { createDeployCommand } from './deploy/index.mjs'
19
- import { createDevCommand } from './dev/index.cjs'
20
- import { createEnvCommand } from './env/index.cjs'
18
+ import { createDevCommand } from './dev/index.mjs'
19
+ import { createEnvCommand } from './env/index.mjs'
21
20
  import { createFunctionsCommand } from './functions/index.mjs'
22
- import { createGraphCommand } from './graph/index.cjs'
21
+ import { createGraphCommand } from './graph/index.mjs'
23
22
  import { createInitCommand } from './init/index.mjs'
24
- import { createLinkCommand } from './link/index.cjs'
25
- import { createLmCommand } from './lm/index.cjs'
23
+ import { createLinkCommand } from './link/index.mjs'
24
+ import { createLmCommand } from './lm/index.mjs'
26
25
  import { createLoginCommand } from './login/index.mjs'
27
26
  import { createLogoutCommand } from './logout/index.mjs'
28
27
  import { createOpenCommand } from './open/index.mjs'
29
- import { createRecipesCommand, createRecipesListCommand } from './recipes/index.cjs'
28
+ import { createRecipesCommand } from './recipes/index.mjs'
30
29
  import { createSitesCommand } from './sites/index.mjs'
31
30
  import { createStatusCommand } from './status/index.mjs'
32
31
  import { createSwitchCommand } from './switch/index.mjs'
33
32
  import { createUnlinkCommand } from './unlink/index.mjs'
34
33
  import { createWatchCommand } from './watch/index.mjs'
35
34
 
36
- const { BANG, NETLIFY_CYAN, USER_AGENT, chalk, error, execa, exit, getGlobalConfig, log, track, warn } = utils
35
+ const { BANG, NETLIFY_CYAN, USER_AGENT, chalk, error, execa, exit, getGlobalConfig, log, warn } = utils
37
36
 
38
37
  const SUGGESTION_TIMEOUT = 1e4
39
38
 
@@ -90,7 +89,7 @@ const mainCommand = async function (options, command) {
90
89
 
91
90
  // if no command show the header and the help
92
91
  if (command.args.length === 0) {
93
- const pkg = JSON.parse(await readFile(fileURLToPath(new URL('../../package.json', import.meta.url))), 'utf-8')
92
+ const pkg = await getPackageJson()
94
93
 
95
94
  const title = `${chalk.bgBlack.cyan('⬥ Netlify CLI')}`
96
95
  const docsMsg = `${chalk.greenBright('Read the docs:')} https://docs.netlify.com/cli/get-started/`
@@ -167,7 +166,6 @@ export const createMainCommand = () => {
167
166
  createEnvCommand(program)
168
167
  createFunctionsCommand(program)
169
168
  createRecipesCommand(program)
170
- createRecipesListCommand(program)
171
169
  createGraphCommand(program)
172
170
  createInitCommand(program)
173
171
  createLinkCommand(program)
@@ -0,0 +1,36 @@
1
+ import fs from 'fs/promises'
2
+ import { dirname, join, resolve } from 'path'
3
+ import { fileURLToPath, pathToFileURL } from 'url'
4
+
5
+ const directoryPath = dirname(fileURLToPath(import.meta.url))
6
+
7
+ export const getRecipe = async (name) => {
8
+ const recipePath = resolve(directoryPath, '../../recipes', name, 'index.mjs')
9
+
10
+ // windows needs a URL for absolute paths
11
+ // eslint-disable-next-line import/no-dynamic-require
12
+ const recipe = await import(pathToFileURL(recipePath).href)
13
+
14
+ return recipe
15
+ }
16
+
17
+ export const listRecipes = async () => {
18
+ const recipesPath = resolve(directoryPath, '../../recipes')
19
+ const recipeNames = await fs.readdir(recipesPath)
20
+ const recipes = await Promise.all(
21
+ recipeNames.map(async (name) => {
22
+ const recipePath = join(recipesPath, name, 'index.mjs')
23
+
24
+ // windows needs a URL for absolute paths
25
+ // eslint-disable-next-line import/no-dynamic-require
26
+ const recipe = await import(pathToFileURL(recipePath).href)
27
+
28
+ return {
29
+ ...recipe,
30
+ name,
31
+ }
32
+ }),
33
+ )
34
+
35
+ return recipes
36
+ }
@@ -0,0 +1 @@
1
+ export { createRecipesCommand, runRecipe } from './recipes.mjs'
@@ -1,7 +1,7 @@
1
1
  // @ts-check
2
- const AsciiTable = require('ascii-table')
2
+ import AsciiTable from 'ascii-table'
3
3
 
4
- const { listRecipes } = require('./common.cjs')
4
+ import { listRecipes } from './common.mjs'
5
5
 
6
6
  /**
7
7
  * The recipes:list command
@@ -24,11 +24,9 @@ const recipesListCommand = async () => {
24
24
  * @param {import('../base-command.mjs').default} program
25
25
  * @returns
26
26
  */
27
- const createRecipesListCommand = (program) =>
27
+ export const createRecipesListCommand = (program) =>
28
28
  program
29
29
  .command('recipes:list')
30
30
  .description(`(Beta) List the recipes available to create and modify files in a project`)
31
31
  .addExamples(['netlify recipes:list'])
32
32
  .action(recipesListCommand)
33
-
34
- module.exports = { createRecipesListCommand }
@@ -1,12 +1,13 @@
1
1
  // @ts-check
2
- const { basename } = require('path')
2
+ import { basename } from 'path'
3
3
 
4
- const inquirer = require('inquirer')
5
- const { findBestMatch } = require('string-similarity')
4
+ import inquirer from 'inquirer'
5
+ import { findBestMatch } from 'string-similarity'
6
6
 
7
- const utils = require('../../utils/command-helpers.cjs')
7
+ import utils from '../../utils/command-helpers.cjs'
8
8
 
9
- const { getRecipe, listRecipes } = require('./common.cjs')
9
+ import { getRecipe, listRecipes } from './common.mjs'
10
+ import { createRecipesListCommand } from './recipes-list.mjs'
10
11
 
11
12
  const SUGGESTION_TIMEOUT = 1e4
12
13
 
@@ -62,8 +63,8 @@ const recipesCommand = async (recipeName, options, command) => {
62
63
  }
63
64
  }
64
65
 
65
- const runRecipe = ({ config, recipeName, repositoryRoot }) => {
66
- const recipe = getRecipe(recipeName)
66
+ export const runRecipe = async ({ config, recipeName, repositoryRoot }) => {
67
+ const recipe = await getRecipe(recipeName)
67
68
 
68
69
  return recipe.run({ config, repositoryRoot })
69
70
  }
@@ -73,7 +74,9 @@ const runRecipe = ({ config, recipeName, repositoryRoot }) => {
73
74
  * @param {import('../base-command.mjs').default} program
74
75
  * @returns
75
76
  */
76
- const createRecipesCommand = (program) =>
77
+ export const createRecipesCommand = (program) => {
78
+ createRecipesListCommand(program)
79
+
77
80
  program
78
81
  .command('recipes')
79
82
  .argument('[name]', 'name of the recipe')
@@ -81,5 +84,4 @@ const createRecipesCommand = (program) =>
81
84
  .option('-n, --name <name>', 'recipe name to use')
82
85
  .addExamples(['netlify recipes my-recipe', 'netlify recipes --name my-recipe'])
83
86
  .action(recipesCommand)
84
-
85
- module.exports = { createRecipesCommand, runRecipe }
87
+ }
@@ -5,14 +5,16 @@ import pick from 'lodash/pick.js'
5
5
  import parseGitHubUrl from 'parse-github-url'
6
6
  import prettyjson from 'prettyjson'
7
7
 
8
+ import getRepoData from '../../utils/get-repo-data.mjs'
8
9
  import utils from '../../utils/index.cjs'
9
10
  import { getGitHubToken } from '../../utils/init/config-github.cjs'
10
11
  import { configureRepo } from '../../utils/init/config.cjs'
11
12
  import { createRepo, getTemplatesFromGitHub, validateTemplate } from '../../utils/sites/utils.cjs'
13
+ import { track } from '../../utils/telemetry/index.mjs'
12
14
 
13
15
  import { getSiteNameInput } from './sites-create.mjs'
14
16
 
15
- const { chalk, error, execa, getRepoData, getTerminalLink, log, logJson, track, warn } = utils
17
+ const { chalk, error, execa, getTerminalLink, log, logJson, warn } = utils
16
18
 
17
19
  export const fetchTemplates = async (token) => {
18
20
  const templatesFromGithubOrg = await getTemplatesFromGitHub(token)