netlify-cli 17.6.0 → 17.7.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 (295) hide show
  1. package/bin/{run.mjs → run.js} +3 -3
  2. package/npm-shrinkwrap.json +4 -4
  3. package/package.json +8 -9
  4. package/scripts/{postinstall.mjs → postinstall.js} +3 -4
  5. package/src/commands/addons/addons-auth.js +22 -0
  6. package/src/commands/addons/{addons-config.mjs → addons-config.js} +9 -34
  7. package/src/commands/addons/{addons-create.mjs → addons-create.js} +7 -33
  8. package/src/commands/addons/addons-delete.js +33 -0
  9. package/src/commands/addons/{addons-list.mjs → addons-list.js} +3 -25
  10. package/src/commands/addons/addons.js +68 -0
  11. package/src/commands/addons/index.js +1 -0
  12. package/src/commands/api/{api.mjs → api.js} +2 -24
  13. package/src/commands/api/index.js +13 -0
  14. package/src/commands/{base-command.mjs → base-command.js} +7 -7
  15. package/src/commands/blobs/blobs-delete.js +20 -0
  16. package/src/commands/blobs/{blobs-get.mjs → blobs-get.js} +2 -15
  17. package/src/commands/blobs/{blobs-list.mjs → blobs-list.js} +2 -16
  18. package/src/commands/blobs/{blobs-set.mjs → blobs-set.js} +2 -17
  19. package/src/commands/blobs/blobs.js +74 -0
  20. package/src/commands/blobs/index.js +1 -0
  21. package/src/commands/build/{build.mjs → build.js} +7 -28
  22. package/src/commands/build/index.js +13 -0
  23. package/src/commands/completion/completion.js +29 -0
  24. package/src/commands/completion/index.js +26 -0
  25. package/src/commands/deploy/{deploy.mjs → deploy.js} +17 -133
  26. package/src/commands/deploy/index.js +106 -0
  27. package/src/commands/dev/{dev-exec.mjs → dev-exec.js} +3 -15
  28. package/src/commands/dev/{dev.mjs → dev.js} +19 -38
  29. package/src/commands/dev/index.js +1 -0
  30. package/src/commands/env/{env-clone.mjs → env-clone.js} +71 -94
  31. package/src/commands/env/env-get.js +34 -0
  32. package/src/commands/env/{env-import.mjs → env-import.js} +38 -65
  33. package/src/commands/env/{env-list.mjs → env-list.js} +3 -37
  34. package/src/commands/env/{env-set.mjs → env-set.js} +36 -81
  35. package/src/commands/env/{env-unset.mjs → env-unset.js} +30 -62
  36. package/src/commands/env/env.js +127 -0
  37. package/src/commands/env/index.js +1 -0
  38. package/src/commands/functions/{functions-build.mjs → functions-build.js} +3 -22
  39. package/src/commands/functions/{functions-create.mjs → functions-create.js} +20 -47
  40. package/src/commands/functions/{functions-invoke.mjs → functions-invoke.js} +3 -41
  41. package/src/commands/functions/{functions-list.mjs → functions-list.js} +3 -27
  42. package/src/commands/functions/{functions-serve.mjs → functions-serve.js} +6 -28
  43. package/src/commands/functions/functions.js +98 -0
  44. package/src/commands/functions/index.js +1 -0
  45. package/src/commands/index.js +2 -0
  46. package/src/commands/init/index.js +12 -0
  47. package/src/commands/init/{init.mjs → init.js} +10 -31
  48. package/src/commands/integration/{deploy.mjs → deploy.js} +7 -28
  49. package/src/commands/integration/index.js +26 -0
  50. package/src/commands/link/index.js +13 -0
  51. package/src/commands/link/{link.mjs → link.js} +6 -28
  52. package/src/commands/lm/index.js +1 -0
  53. package/src/commands/lm/{lm-info.mjs → lm-info.js} +2 -9
  54. package/src/commands/lm/lm-install.js +8 -0
  55. package/src/commands/lm/{lm-setup.mjs → lm-setup.js} +6 -25
  56. package/src/commands/lm/lm-uninstall.js +7 -0
  57. package/src/commands/lm/lm.js +46 -0
  58. package/src/commands/login/index.js +9 -0
  59. package/src/commands/login/{login.mjs → login.js} +1 -19
  60. package/src/commands/logout/index.js +7 -0
  61. package/src/commands/logout/{logout.mjs → logout.js} +3 -16
  62. package/src/commands/logs/{build.mjs → build.js} +3 -8
  63. package/src/commands/logs/{functions.mjs → functions.js} +4 -27
  64. package/src/commands/logs/index.js +39 -0
  65. package/src/commands/logs/log-levels.js +11 -0
  66. package/src/commands/{main.mjs → main.js} +32 -32
  67. package/src/commands/open/index.js +31 -0
  68. package/src/commands/open/open-admin.js +11 -0
  69. package/src/commands/open/open-site.js +12 -0
  70. package/src/commands/open/open.js +13 -0
  71. package/src/commands/recipes/{common.mjs → common.js} +2 -2
  72. package/src/commands/recipes/index.js +20 -0
  73. package/src/commands/recipes/recipes-list.js +14 -0
  74. package/src/commands/recipes/{recipes.mjs → recipes.js} +8 -32
  75. package/src/commands/serve/index.js +27 -0
  76. package/src/commands/serve/{serve.mjs → serve.js} +14 -51
  77. package/src/commands/sites/index.js +1 -0
  78. package/src/commands/sites/{sites-create-template.mjs → sites-create-template.js} +9 -38
  79. package/src/commands/sites/{sites-create.mjs → sites-create.js} +5 -38
  80. package/src/commands/sites/{sites-delete.mjs → sites-delete.js} +2 -22
  81. package/src/commands/sites/{sites-list.mjs → sites-list.js} +4 -24
  82. package/src/commands/sites/sites.js +77 -0
  83. package/src/commands/status/index.js +19 -0
  84. package/src/commands/status/{status-hooks.mjs → status-hooks.js} +2 -20
  85. package/src/commands/status/{status.mjs → status.js} +2 -23
  86. package/src/commands/switch/index.js +7 -0
  87. package/src/commands/switch/{switch.mjs → switch.js} +3 -16
  88. package/src/commands/unlink/index.js +7 -0
  89. package/src/commands/unlink/unlink.js +21 -0
  90. package/src/commands/watch/index.js +8 -0
  91. package/src/commands/watch/{watch.mjs → watch.js} +4 -21
  92. package/src/lib/{api.mjs → api.js} +1 -1
  93. package/src/lib/blobs/{blobs.mjs → blobs.js} +2 -2
  94. package/src/lib/{build.mjs → build.js} +3 -3
  95. package/src/lib/completion/{constants.mjs → constants.js} +1 -1
  96. package/src/lib/completion/{generate-autocompletion.mjs → generate-autocompletion.js} +3 -3
  97. package/src/lib/completion/{index.mjs → index.js} +1 -1
  98. package/src/lib/completion/{script.mjs → script.js} +3 -3
  99. package/src/lib/edge-functions/{deploy.mjs → deploy.js} +2 -2
  100. package/src/lib/edge-functions/{editor-helper.mjs → editor-helper.js} +1 -1
  101. package/src/lib/edge-functions/{internal.mjs → internal.js} +2 -2
  102. package/src/lib/edge-functions/{proxy.mjs → proxy.js} +10 -11
  103. package/src/lib/edge-functions/{registry.mjs → registry.js} +1 -1
  104. package/src/lib/{exec-fetcher.mjs → exec-fetcher.js} +2 -2
  105. package/src/lib/functions/{background.mjs → background.js} +2 -2
  106. package/src/lib/functions/{form-submissions-handler.mjs → form-submissions-handler.js} +3 -3
  107. package/src/lib/functions/{local-proxy.mjs → local-proxy.js} +1 -1
  108. package/src/lib/functions/{netlify-function.mjs → netlify-function.js} +3 -3
  109. package/src/lib/functions/{registry.mjs → registry.js} +9 -9
  110. package/src/lib/functions/runtimes/go/{index.mjs → index.js} +2 -2
  111. package/src/lib/functions/runtimes/{index.mjs → index.js} +3 -4
  112. package/src/lib/functions/runtimes/js/builders/{netlify-lambda.mjs → netlify-lambda.js} +3 -3
  113. package/src/lib/functions/runtimes/js/builders/{zisi.mjs → zisi.js} +6 -6
  114. package/src/lib/functions/runtimes/js/{index.mjs → index.js} +4 -4
  115. package/src/lib/functions/runtimes/rust/{index.mjs → index.js} +4 -4
  116. package/src/lib/functions/{scheduled.mjs → scheduled.js} +2 -2
  117. package/src/lib/functions/{server.mjs → server.js} +15 -15
  118. package/src/lib/functions/{synchronous.mjs → synchronous.js} +3 -3
  119. package/src/lib/functions/{utils.mjs → utils.js} +2 -2
  120. package/src/lib/{geo-location.mjs → geo-location.js} +1 -1
  121. package/src/lib/{http-agent.mjs → http-agent.js} +1 -1
  122. package/src/lib/images/{proxy.mjs → proxy.js} +2 -2
  123. package/src/lib/{log.mjs → log.js} +1 -1
  124. package/src/recipes/vscode/{index.mjs → index.js} +2 -2
  125. package/src/recipes/vscode/{settings.mjs → settings.js} +0 -1
  126. package/src/utils/addons/diffs/{index.mjs → index.js} +1 -1
  127. package/src/utils/addons/diffs/{options.mjs → options.js} +0 -1
  128. package/src/utils/addons/{prepare.mjs → prepare.js} +2 -2
  129. package/src/utils/addons/{prompts.mjs → prompts.js} +1 -1
  130. package/src/utils/addons/{render.mjs → render.js} +1 -1
  131. package/src/utils/{banner.mjs → banner.js} +1 -1
  132. package/src/utils/{build-info.mjs → build-info.js} +3 -3
  133. package/src/utils/{command-helpers.mjs → command-helpers.js} +4 -9
  134. package/src/utils/deploy/{deploy-site.mjs → deploy-site.js} +8 -8
  135. package/src/utils/deploy/{hash-files.mjs → hash-files.js} +1 -1
  136. package/src/utils/deploy/{hash-fns.mjs → hash-fns.js} +3 -3
  137. package/src/utils/deploy/{hasher-segments.mjs → hasher-segments.js} +1 -1
  138. package/src/utils/deploy/{upload-files.mjs → upload-files.js} +1 -1
  139. package/src/utils/deploy/{util.mjs → util.js} +1 -1
  140. package/src/utils/{detect-server-settings.mjs → detect-server-settings.js} +6 -7
  141. package/src/utils/{dev.mjs → dev.js} +3 -3
  142. package/src/utils/{dot-env.mjs → dot-env.js} +2 -2
  143. package/src/utils/env/{index.mjs → index.js} +1 -1
  144. package/src/utils/{framework-server.mjs → framework-server.js} +4 -4
  145. package/src/utils/functions/{functions.mjs → functions.js} +2 -2
  146. package/src/utils/functions/{get-functions.mjs → get-functions.js} +1 -1
  147. package/src/utils/functions/index.js +3 -0
  148. package/src/utils/{get-global-config.mjs → get-global-config.js} +1 -1
  149. package/src/utils/{get-repo-data.mjs → get-repo-data.js} +1 -1
  150. package/src/utils/{get-site.mjs → get-site.js} +1 -1
  151. package/src/utils/{gh-auth.mjs → gh-auth.js} +3 -3
  152. package/src/utils/{gitignore.mjs → gitignore.js} +2 -2
  153. package/src/utils/{headers.mjs → headers.js} +1 -1
  154. package/src/utils/hooks/{requires-site-info.mjs → requires-site-info.js} +1 -1
  155. package/src/utils/init/{config-github.mjs → config-github.js} +4 -4
  156. package/src/utils/init/{config-manual.mjs → config-manual.js} +5 -5
  157. package/src/utils/init/{config.mjs → config.js} +4 -4
  158. package/src/utils/init/{node-version.mjs → node-version.js} +1 -1
  159. package/src/utils/init/{utils.mjs → utils.js} +7 -7
  160. package/src/utils/{live-tunnel.mjs → live-tunnel.js} +4 -4
  161. package/src/utils/lm/{install.mjs → install.js} +6 -6
  162. package/src/utils/lm/{requirements.mjs → requirements.js} +1 -1
  163. package/src/utils/lm/{steps.mjs → steps.js} +2 -2
  164. package/src/utils/lm/{ui.mjs → ui.js} +2 -2
  165. package/src/utils/{open-browser.mjs → open-browser.js} +1 -1
  166. package/src/utils/{proxy-server.mjs → proxy-server.js} +5 -5
  167. package/src/utils/{proxy.mjs → proxy.js} +11 -11
  168. package/src/utils/{redirects.mjs → redirects.js} +1 -1
  169. package/src/utils/{rules-proxy.mjs → rules-proxy.js} +3 -3
  170. package/src/utils/{run-build.mjs → run-build.js} +8 -8
  171. package/src/utils/{shell.mjs → shell.js} +2 -2
  172. package/src/utils/{state-config.mjs → state-config.js} +1 -1
  173. package/src/utils/{static-server.mjs → static-server.js} +1 -1
  174. package/src/utils/telemetry/index.js +2 -0
  175. package/src/utils/telemetry/{report-error.mjs → report-error.js} +4 -4
  176. package/src/utils/telemetry/{request.mjs → request.js} +1 -1
  177. package/src/utils/telemetry/{telemetry.mjs → telemetry.js} +5 -5
  178. package/src/utils/telemetry/{utils.mjs → utils.js} +1 -1
  179. package/src/utils/telemetry/{validation.mjs → validation.js} +1 -1
  180. package/src/utils/{validation.mjs → validation.js} +1 -1
  181. package/src/commands/addons/addons-auth.mjs +0 -45
  182. package/src/commands/addons/addons-delete.mjs +0 -53
  183. package/src/commands/addons/addons.mjs +0 -39
  184. package/src/commands/addons/index.mjs +0 -1
  185. package/src/commands/api/index.mjs +0 -1
  186. package/src/commands/blobs/blobs-delete.mjs +0 -35
  187. package/src/commands/blobs/blobs.mjs +0 -32
  188. package/src/commands/blobs/index.mjs +0 -1
  189. package/src/commands/build/index.mjs +0 -1
  190. package/src/commands/completion/completion.mjs +0 -53
  191. package/src/commands/completion/index.mjs +0 -1
  192. package/src/commands/deploy/index.mjs +0 -1
  193. package/src/commands/dev/index.mjs +0 -1
  194. package/src/commands/dev/types.d.ts +0 -30
  195. package/src/commands/env/env-get.mjs +0 -66
  196. package/src/commands/env/env.mjs +0 -41
  197. package/src/commands/env/index.mjs +0 -1
  198. package/src/commands/functions/functions.mjs +0 -39
  199. package/src/commands/functions/index.mjs +0 -1
  200. package/src/commands/index.mjs +0 -2
  201. package/src/commands/init/index.mjs +0 -1
  202. package/src/commands/integration/index.mjs +0 -24
  203. package/src/commands/link/index.mjs +0 -1
  204. package/src/commands/lm/index.mjs +0 -1
  205. package/src/commands/lm/lm-install.mjs +0 -27
  206. package/src/commands/lm/lm-uninstall.mjs +0 -18
  207. package/src/commands/lm/lm.mjs +0 -30
  208. package/src/commands/login/index.mjs +0 -1
  209. package/src/commands/logout/index.mjs +0 -1
  210. package/src/commands/logs/index.mjs +0 -12
  211. package/src/commands/open/index.mjs +0 -1
  212. package/src/commands/open/open-admin.mjs +0 -30
  213. package/src/commands/open/open-site.mjs +0 -31
  214. package/src/commands/open/open.mjs +0 -36
  215. package/src/commands/recipes/index.mjs +0 -1
  216. package/src/commands/recipes/recipes-list.mjs +0 -25
  217. package/src/commands/serve/index.mjs +0 -1
  218. package/src/commands/sites/index.mjs +0 -2
  219. package/src/commands/sites/sites.mjs +0 -30
  220. package/src/commands/status/index.mjs +0 -1
  221. package/src/commands/switch/index.mjs +0 -1
  222. package/src/commands/types.d.ts +0 -31
  223. package/src/commands/unlink/index.mjs +0 -1
  224. package/src/commands/unlink/unlink.mjs +0 -34
  225. package/src/commands/watch/index.mjs +0 -1
  226. package/src/functions-templates/typescript/abtest/{{name}}.ts +0 -31
  227. package/src/functions-templates/typescript/geolocation/{{name}}.ts +0 -24
  228. package/src/functions-templates/typescript/hello-world/{{name}}.ts +0 -12
  229. package/src/functions-templates/typescript/json/{{name}}.ts +0 -5
  230. package/src/functions-templates/typescript/log/{{name}}.ts +0 -9
  231. package/src/functions-templates/typescript/scheduled-function/{{name}}.ts +0 -12
  232. package/src/functions-templates/typescript/set-cookies/{{name}}.ts +0 -29
  233. package/src/functions-templates/typescript/set-req-header/{{name}}.ts +0 -5
  234. package/src/functions-templates/typescript/set-res-header/{{name}}.ts +0 -7
  235. package/src/functions-templates/typescript/transform-response/{{name}}.ts +0 -13
  236. package/src/utils/functions/index.mjs +0 -3
  237. package/src/utils/telemetry/index.mjs +0 -2
  238. package/src/utils/types.d.ts +0 -46
  239. /package/src/functions-templates/go/hello-world/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  240. /package/src/functions-templates/javascript/hello/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  241. /package/src/functions-templates/javascript/hello-world/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  242. /package/src/functions-templates/javascript/identity-signup/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  243. /package/src/functions-templates/javascript/image-external/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  244. /package/src/functions-templates/javascript/localized-content/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  245. /package/src/functions-templates/javascript/sanity-create/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  246. /package/src/functions-templates/javascript/sanity-groq/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  247. /package/src/functions-templates/javascript/scheduled-function/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  248. /package/src/functions-templates/javascript/set-cookies/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  249. /package/src/functions-templates/javascript/set-req-header/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  250. /package/src/functions-templates/javascript/set-res-header/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  251. /package/src/functions-templates/javascript/submission-created/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  252. /package/src/functions-templates/javascript/transform-response/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  253. /package/src/functions-templates/rust/hello-world/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  254. /package/src/functions-templates/typescript/abtest/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  255. /package/src/functions-templates/typescript/geolocation/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  256. /package/src/functions-templates/typescript/hello-world/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  257. /package/src/functions-templates/typescript/json/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  258. /package/src/functions-templates/typescript/log/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  259. /package/src/functions-templates/typescript/scheduled-function/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  260. /package/src/functions-templates/typescript/set-cookies/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  261. /package/src/functions-templates/typescript/set-req-header/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  262. /package/src/functions-templates/typescript/set-res-header/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  263. /package/src/functions-templates/typescript/transform-response/{.netlify-function-template.mjs → .netlify-function-template.js} +0 -0
  264. /package/src/lib/{account.mjs → account.js} +0 -0
  265. /package/src/lib/completion/{get-autocompletion.mjs → get-autocompletion.js} +0 -0
  266. /package/src/lib/edge-functions/{bootstrap.mjs → bootstrap.js} +0 -0
  267. /package/src/lib/edge-functions/{consts.mjs → consts.js} +0 -0
  268. /package/src/lib/edge-functions/{headers.mjs → headers.js} +0 -0
  269. /package/src/lib/{fs.mjs → fs.js} +0 -0
  270. /package/src/lib/functions/{config.mjs → config.js} +0 -0
  271. /package/src/lib/functions/{memoized-build.mjs → memoized-build.js} +0 -0
  272. /package/src/lib/functions/runtimes/js/{constants.mjs → constants.js} +0 -0
  273. /package/src/lib/functions/runtimes/js/{worker.mjs → worker.js} +0 -0
  274. /package/src/lib/{path.mjs → path.js} +0 -0
  275. /package/src/lib/{render-error-template.mjs → render-error-template.js} +0 -0
  276. /package/src/lib/{settings.mjs → settings.js} +0 -0
  277. /package/src/lib/{spinner.mjs → spinner.js} +0 -0
  278. /package/src/lib/{string.mjs → string.js} +0 -0
  279. /package/src/utils/addons/{compare.mjs → compare.js} +0 -0
  280. /package/src/utils/addons/{validation.mjs → validation.js} +0 -0
  281. /package/src/utils/{create-deferred.mjs → create-deferred.js} +0 -0
  282. /package/src/utils/{create-stream-promise.mjs → create-stream-promise.js} +0 -0
  283. /package/src/utils/deploy/{constants.mjs → constants.js} +0 -0
  284. /package/src/utils/deploy/{hash-config.mjs → hash-config.js} +0 -0
  285. /package/src/utils/{execa.mjs → execa.js} +0 -0
  286. /package/src/utils/{feature-flags.mjs → feature-flags.js} +0 -0
  287. /package/src/utils/functions/{constants.mjs → constants.js} +0 -0
  288. /package/src/utils/{get-package-json.mjs → get-package-json.js} +0 -0
  289. /package/src/utils/init/{plugins.mjs → plugins.js} +0 -0
  290. /package/src/utils/{parse-raw-flags.mjs → parse-raw-flags.js} +0 -0
  291. /package/src/utils/{read-repo-url.mjs → read-repo-url.js} +0 -0
  292. /package/src/utils/{request-id.mjs → request-id.js} +0 -0
  293. /package/src/utils/{sign-redirect.mjs → sign-redirect.js} +0 -0
  294. /package/src/utils/sites/{utils.mjs → utils.js} +0 -0
  295. /package/src/utils/websockets/{index.mjs → index.js} +0 -0
@@ -1,41 +1,5 @@
1
- import { chalk, error, log, logJson } from '../../utils/command-helpers.mjs';
2
- import { AVAILABLE_CONTEXTS, normalizeContext, translateFromEnvelopeToMongo } from '../../utils/env/index.mjs';
3
- /**
4
- * The env:unset command
5
- * @param {string} key Environment variable key
6
- * @param {import('commander').OptionValues} options
7
- * @param {import('../base-command.mjs').default} command
8
- * @returns {Promise<boolean>}
9
- */
10
- // @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type.
11
- const envUnset = async (key, options, command) => {
12
- const { context } = options;
13
- const { api, cachedConfig, site } = command.netlify;
14
- const siteId = site.id;
15
- if (!siteId) {
16
- log('No site id found, please run inside a site folder or `netlify link`');
17
- return false;
18
- }
19
- const { siteInfo } = cachedConfig;
20
- let finalEnv;
21
- if (siteInfo.use_envelope) {
22
- finalEnv = await unsetInEnvelope({ api, context, siteInfo, key });
23
- }
24
- else if (context) {
25
- error(`To specify a context, please run ${chalk.yellow('netlify open:admin')} to open the Netlify UI and opt in to the new environment variables experience from Site settings`);
26
- return false;
27
- }
28
- else {
29
- finalEnv = await unsetInMongo({ api, siteInfo, key });
30
- }
31
- // Return new environment variables of site if using json flag
32
- if (options.json) {
33
- logJson(finalEnv);
34
- return false;
35
- }
36
- const contextType = AVAILABLE_CONTEXTS.includes(context || 'all') ? 'context' : 'branch';
37
- log(`Unset environment variable ${chalk.yellow(key)} in the ${chalk.magenta(context || 'all')} ${contextType}`);
38
- };
1
+ import { chalk, error, log, logJson } from '../../utils/command-helpers.js';
2
+ import { AVAILABLE_CONTEXTS, translateFromEnvelopeToMongo } from '../../utils/env/index.js';
39
3
  /**
40
4
  * Deletes a given key from the env of a site record
41
5
  * @returns {Promise<object>}
@@ -109,27 +73,31 @@ const unsetInEnvelope = async ({ api, context, key, siteInfo }) => {
109
73
  delete env[key];
110
74
  return env;
111
75
  };
112
- /**
113
- * Creates the `netlify env:unset` command
114
- * @param {import('../base-command.mjs').default} program
115
- * @returns
116
- */
117
- // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
118
- export const createEnvUnsetCommand = (program) => program
119
- .command('env:unset')
120
- .aliases(['env:delete', 'env:remove'])
121
- .argument('<key>', 'Environment variable key')
122
- .option('-c, --context <context...>', 'Specify a deploy context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev") (default: all contexts)',
123
- // spread over an array for variadic options
124
- // @ts-expect-error TS(7006) FIXME: Parameter 'context' implicitly has an 'any' type.
125
- (context, previous = []) => [...previous, normalizeContext(context)])
126
- .addExamples([
127
- 'netlify env:unset VAR_NAME # unset in all contexts',
128
- 'netlify env:unset VAR_NAME --context production',
129
- 'netlify env:unset VAR_NAME --context production deploy-preview',
130
- ])
131
- .description('Unset an environment variable which removes it from the UI')
132
- // @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type.
133
- .action(async (key, options, command) => {
134
- await envUnset(key, options, command);
135
- });
76
+ export const envUnset = async (key, options, command) => {
77
+ const { context } = options;
78
+ const { api, cachedConfig, site } = command.netlify;
79
+ const siteId = site.id;
80
+ if (!siteId) {
81
+ log('No site id found, please run inside a site folder or `netlify link`');
82
+ return false;
83
+ }
84
+ const { siteInfo } = cachedConfig;
85
+ let finalEnv;
86
+ if (siteInfo.use_envelope) {
87
+ finalEnv = await unsetInEnvelope({ api, context, siteInfo, key });
88
+ }
89
+ else if (context) {
90
+ error(`To specify a context, please run ${chalk.yellow('netlify open:admin')} to open the Netlify UI and opt in to the new environment variables experience from Site settings`);
91
+ return false;
92
+ }
93
+ else {
94
+ finalEnv = await unsetInMongo({ api, siteInfo, key });
95
+ }
96
+ // Return new environment variables of site if using json flag
97
+ if (options.json) {
98
+ logJson(finalEnv);
99
+ return false;
100
+ }
101
+ const contextType = AVAILABLE_CONTEXTS.includes(context || 'all') ? 'context' : 'branch';
102
+ log(`Unset environment variable ${chalk.yellow(key)} in the ${chalk.magenta(context || 'all')} ${contextType}`);
103
+ };
@@ -0,0 +1,127 @@
1
+ import { Option } from 'commander';
2
+ import { normalizeContext } from '../../utils/env/index.js';
3
+ const env = (options, command) => {
4
+ command.help();
5
+ };
6
+ export const createEnvCommand = (program) => {
7
+ program
8
+ .command('env:get')
9
+ .argument('<name>', 'Environment variable name')
10
+ .option('-c, --context <context>', 'Specify a deploy context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev")', normalizeContext, 'dev')
11
+ .addOption(new Option('-s, --scope <scope>', 'Specify a scope')
12
+ .choices(['builds', 'functions', 'post-processing', 'runtime', 'any'])
13
+ .default('any'))
14
+ .addExamples([
15
+ 'netlify env:get MY_VAR # get value for MY_VAR in dev context',
16
+ 'netlify env:get MY_VAR --context production',
17
+ 'netlify env:get MY_VAR --context branch:staging',
18
+ 'netlify env:get MY_VAR --scope functions',
19
+ ])
20
+ .description('Get resolved value of specified environment variable (includes netlify.toml)')
21
+ .action(async (name, options, command) => {
22
+ const { envGet } = await import('./env-get.js');
23
+ await envGet(name, options, command);
24
+ });
25
+ program
26
+ .command('env:import')
27
+ .argument('<fileName>', '.env file to import')
28
+ .addOption(new Option('-r --replaceExisting', 'Old, prefer --replace-existing. Replace all existing variables instead of merging them with the current ones')
29
+ .default(false)
30
+ .hideHelp(true))
31
+ .option('-r, --replace-existing', 'Replace all existing variables instead of merging them with the current ones', false)
32
+ .description('Import and set environment variables from .env file')
33
+ .action(async (fileName, options, command) => {
34
+ const { envImport } = await import('./env-import.js');
35
+ await envImport(fileName, options, command);
36
+ });
37
+ program
38
+ .command('env:list')
39
+ .option('-c, --context <context>', 'Specify a deploy context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev")', normalizeContext, 'dev')
40
+ .option('--json', 'Output environment variables as JSON')
41
+ .addOption(new Option('--plain', 'Output environment variables as plaintext').conflicts('json'))
42
+ .addOption(new Option('-s, --scope <scope>', 'Specify a scope')
43
+ .choices(['builds', 'functions', 'post-processing', 'runtime', 'any'])
44
+ .default('any'))
45
+ .addExamples([
46
+ 'netlify env:list # list variables with values in the dev context and with any scope',
47
+ 'netlify env:list --context production',
48
+ 'netlify env:list --context branch:staging',
49
+ 'netlify env:list --scope functions',
50
+ 'netlify env:list --plain',
51
+ ])
52
+ .description('Lists resolved environment variables for site (includes netlify.toml)')
53
+ .action(async (options, command) => {
54
+ const { envList } = await import('./env-list.js');
55
+ await envList(options, command);
56
+ });
57
+ program
58
+ .command('env:set')
59
+ .argument('<key>', 'Environment variable key')
60
+ .argument('[value]', 'Value to set to', '')
61
+ .option('-c, --context <context...>', 'Specify a deploy context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev") (default: all contexts)',
62
+ // spread over an array for variadic options
63
+ // @ts-expect-error TS(7006) FIXME: Parameter 'context' implicitly has an 'any' type.
64
+ (context, previous = []) => [...previous, normalizeContext(context)])
65
+ .addOption(new Option('-s, --scope <scope...>', 'Specify a scope (default: all scopes)').choices([
66
+ 'builds',
67
+ 'functions',
68
+ 'post-processing',
69
+ 'runtime',
70
+ ]))
71
+ .option('--secret', 'Indicate whether the environment variable value can be read again.')
72
+ .description('Set value of environment variable')
73
+ .addExamples([
74
+ 'netlify env:set VAR_NAME value # set in all contexts and scopes',
75
+ 'netlify env:set VAR_NAME value --context production',
76
+ 'netlify env:set VAR_NAME value --context production deploy-preview',
77
+ 'netlify env:set VAR_NAME value --context production --secret',
78
+ 'netlify env:set VAR_NAME value --scope builds',
79
+ 'netlify env:set VAR_NAME value --scope builds functions',
80
+ 'netlify env:set VAR_NAME --secret # convert existing variable to secret',
81
+ ])
82
+ .action(async (key, value, options, command) => {
83
+ const { envSet } = await import('./env-set.js');
84
+ await envSet(key, value, options, command);
85
+ });
86
+ program
87
+ .command('env:unset')
88
+ .aliases(['env:delete', 'env:remove'])
89
+ .argument('<key>', 'Environment variable key')
90
+ .option('-c, --context <context...>', 'Specify a deploy context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev") (default: all contexts)',
91
+ // spread over an array for variadic options
92
+ // @ts-expect-error TS(7006) FIXME: Parameter 'context' implicitly has an 'any' type.
93
+ (context, previous = []) => [...previous, normalizeContext(context)])
94
+ .addExamples([
95
+ 'netlify env:unset VAR_NAME # unset in all contexts',
96
+ 'netlify env:unset VAR_NAME --context production',
97
+ 'netlify env:unset VAR_NAME --context production deploy-preview',
98
+ ])
99
+ .description('Unset an environment variable which removes it from the UI')
100
+ .action(async (key, options, command) => {
101
+ const { envUnset } = await import('./env-unset.js');
102
+ await envUnset(key, options, command);
103
+ });
104
+ program
105
+ .command('env:clone')
106
+ .alias('env:migrate')
107
+ .option('-f, --from <from>', 'Site ID (From)')
108
+ .requiredOption('-t, --to <to>', 'Site ID (To)')
109
+ .description(`Clone environment variables from one site to another`)
110
+ .addExamples(['netlify env:clone --to <to-site-id>', 'netlify env:clone --to <to-site-id> --from <from-site-id>'])
111
+ .action(async (options, command) => {
112
+ const { envClone } = await import('./env-clone.js');
113
+ await envClone(options, command);
114
+ });
115
+ return program
116
+ .command('env')
117
+ .description('Control environment variables for the current site')
118
+ .addExamples([
119
+ 'netlify env:list',
120
+ 'netlify env:get VAR_NAME',
121
+ 'netlify env:set VAR_NAME value',
122
+ 'netlify env:unset VAR_NAME',
123
+ 'netlify env:import fileName',
124
+ 'netlify env:clone --to <to-site-id>',
125
+ ])
126
+ .action(env);
127
+ };
@@ -0,0 +1 @@
1
+ export { createEnvCommand } from './env.js';
@@ -1,14 +1,8 @@
1
1
  import { mkdir } from 'fs/promises';
2
2
  import { zipFunctions } from '@netlify/zip-it-and-ship-it';
3
- import { NETLIFYDEVERR, NETLIFYDEVLOG, exit, log } from '../../utils/command-helpers.mjs';
4
- import { getFunctionsDir } from '../../utils/functions/index.mjs';
5
- /**
6
- * The functions:build command
7
- * @param {import('commander').OptionValues} options
8
- * @param {import('../base-command.mjs').default} command
9
- */
10
- // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
11
- const functionsBuild = async (options, command) => {
3
+ import { NETLIFYDEVERR, NETLIFYDEVLOG, exit, log } from '../../utils/command-helpers.js';
4
+ import { getFunctionsDir } from '../../utils/functions/index.js';
5
+ export const functionsBuild = async (options, command) => {
12
6
  const { config } = command.netlify;
13
7
  const src = options.src || config.build.functionsSource;
14
8
  // @ts-expect-error TS(2554) FIXME: Expected 2 arguments, but got 1.
@@ -30,16 +24,3 @@ const functionsBuild = async (options, command) => {
30
24
  zipFunctions(src, dst, { skipGo: true });
31
25
  log(`${NETLIFYDEVLOG} Functions built to `, dst);
32
26
  };
33
- /**
34
- * Creates the `netlify functions:build` command
35
- * @param {import('../base-command.mjs').default} program
36
- * @returns
37
- */
38
- // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
39
- export const createFunctionsBuildCommand = (program) => program
40
- .command('functions:build')
41
- .alias('function:build')
42
- .description('Build functions locally')
43
- .option('-f, --functions <directory>', 'Specify a functions directory to build to')
44
- .option('-s, --src <directory>', 'Specify the source directory for the functions')
45
- .action(functionsBuild);
@@ -14,13 +14,13 @@ import inquirer from 'inquirer';
14
14
  // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message
15
15
  import fetch from 'node-fetch';
16
16
  import ora from 'ora';
17
- import { fileExistsAsync } from '../../lib/fs.mjs';
18
- import { getAddons, getCurrentAddon, getSiteData } from '../../utils/addons/prepare.mjs';
19
- import { NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, error, log } from '../../utils/command-helpers.mjs';
20
- import { getDotEnvVariables, injectEnvVariables } from '../../utils/dev.mjs';
17
+ import { fileExistsAsync } from '../../lib/fs.js';
18
+ import { getAddons, getCurrentAddon, getSiteData } from '../../utils/addons/prepare.js';
19
+ import { NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, error, log } from '../../utils/command-helpers.js';
20
+ import { getDotEnvVariables, injectEnvVariables } from '../../utils/dev.js';
21
21
  // @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message
22
- import execa from '../../utils/execa.mjs';
23
- import { readRepoURL, validateRepoURL } from '../../utils/read-repo-url.mjs';
22
+ import execa from '../../utils/execa.js';
23
+ import { readRepoURL, validateRepoURL } from '../../utils/read-repo-url.js';
24
24
  const copyTemplateDir = promisify(copyTemplateDirOriginal);
25
25
  const require = createRequire(import.meta.url);
26
26
  const templatesDir = path.resolve(dirname(fileURLToPath(import.meta.url)), '../../functions-templates');
@@ -97,7 +97,7 @@ const formatRegistryArrayForInquirer = async function (lang, funcType) {
97
97
  .filter((folder) => Boolean(folder?.isDirectory()))
98
98
  .map(async ({ name }) => {
99
99
  try {
100
- const templatePath = path.join(templatesDir, lang, name, '.netlify-function-template.mjs');
100
+ const templatePath = path.join(templatesDir, lang, name, '.netlify-function-template.js');
101
101
  // @ts-expect-error TS(7036) FIXME: Dynamic import's specifier must be of type 'string... Remove this comment to see the full error message
102
102
  const template = await import(pathToFileURL(templatePath));
103
103
  return template.default;
@@ -216,7 +216,7 @@ const selectTypeOfFunc = async () => {
216
216
  return functionType;
217
217
  };
218
218
  /**
219
- * @param {import('../base-command.mjs').default} command
219
+ * @param {import('../base-command.js').default} command
220
220
  */
221
221
  // @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type.
222
222
  const ensureEdgeFuncDirExists = function (command) {
@@ -236,7 +236,7 @@ const ensureEdgeFuncDirExists = function (command) {
236
236
  };
237
237
  /**
238
238
  * Prompts the user to choose a functions directory
239
- * @param {import('../base-command.mjs').default} command
239
+ * @param {import('../base-command.js').default} command
240
240
  * @returns {Promise<string>} - functions directory or throws an error
241
241
  */
242
242
  // @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type.
@@ -273,7 +273,7 @@ const promptFunctionsDirectory = async (command) => {
273
273
  };
274
274
  /**
275
275
  * Get functions directory (and make it if necessary)
276
- * @param {import('../base-command.mjs').default} command
276
+ * @param {import('../base-command.js').default} command
277
277
  * @returns {Promise<string>} - functions directory or throws an error
278
278
  */
279
279
  // @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type.
@@ -290,7 +290,7 @@ const ensureFunctionDirExists = async function (command) {
290
290
  };
291
291
  /**
292
292
  * Download files from a given GitHub URL
293
- * @param {import('../base-command.mjs').default} command
293
+ * @param {import('../base-command.js').default} command
294
294
  * @param {import('commander').OptionValues} options
295
295
  * @param {string} argumentName
296
296
  * @param {string} functionsDir
@@ -329,7 +329,7 @@ const downloadFromURL = async function (command, options, argumentName, function
329
329
  log(`${NETLIFYDEVLOG} Installing dependencies for ${nameToUse} complete `);
330
330
  });
331
331
  // read, execute, and delete function template file if exists
332
- const fnTemplateFile = path.join(fnFolder, '.netlify-function-template.mjs');
332
+ const fnTemplateFile = path.join(fnFolder, '.netlify-function-template.js');
333
333
  if (await fileExistsAsync(fnTemplateFile)) {
334
334
  const { default: { addons = [], onComplete }, } = await import(pathToFileURL(fnTemplateFile).href);
335
335
  await installAddons(command, addons, path.resolve(fnFolder));
@@ -394,7 +394,7 @@ const installDeps = async ({ functionPackageJson, functionPath, functionsDir })
394
394
  };
395
395
  /**
396
396
  * no --url flag specified, pick from a provided template
397
- * @param {import('../base-command.mjs').default} command
397
+ * @param {import('../base-command.js').default} command
398
398
  * @param {import('commander').OptionValues} options
399
399
  * @param {string} argumentName
400
400
  * @param {string} functionsDir Absolute path of the functions directory
@@ -443,7 +443,7 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun
443
443
  let functionPackageJson;
444
444
  // These files will not be part of the log message because they'll likely
445
445
  // be removed before the command finishes.
446
- const omittedFromOutput = new Set(['.netlify-function-template.mjs', 'package.json', 'package-lock.json']);
446
+ const omittedFromOutput = new Set(['.netlify-function-template.js', 'package.json', 'package-lock.json']);
447
447
  const createdFiles = await copyTemplateDir(pathToTemplate, functionPath, vars);
448
448
  // @ts-expect-error TS(7006) FIXME: Parameter 'filePath' implicitly has an 'any' type.
449
449
  createdFiles.forEach((filePath) => {
@@ -457,7 +457,7 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun
457
457
  }
458
458
  });
459
459
  // delete function template file that was copied over by copydir
460
- await unlink(path.join(functionPath, '.netlify-function-template.mjs'));
460
+ await unlink(path.join(functionPath, '.netlify-function-template.js'));
461
461
  // npm install
462
462
  if (functionPackageJson !== undefined) {
463
463
  const spinner = ora({
@@ -499,8 +499,8 @@ const createFunctionAddon = async function ({ addonName, addons, api, siteData,
499
499
  /**
500
500
  *
501
501
  * @param {object} config
502
- * @param {import('../base-command.mjs').default} config.command
503
- * @param {(command: import('../base-command.mjs').default) => any} config.onComplete
502
+ * @param {import('../base-command.js').default} config.command
503
+ * @param {(command: import('../base-command.js').default) => any} config.onComplete
504
504
  */
505
505
  // @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message
506
506
  const handleOnComplete = async ({ command, onComplete }) => {
@@ -520,7 +520,7 @@ const handleOnComplete = async ({ command, onComplete }) => {
520
520
  * @param {object} config
521
521
  * @param {*} config.addonCreated
522
522
  * @param {*} config.addonDidInstall
523
- * @param {import('../base-command.mjs').default} config.command
523
+ * @param {import('../base-command.js').default} config.command
524
524
  * @param {string} config.fnPath
525
525
  */
526
526
  // @ts-expect-error TS(7031) FIXME: Binding element 'addonCreated' implicitly has an '... Remove this comment to see the full error message
@@ -549,7 +549,7 @@ const handleAddonDidInstall = async ({ addonCreated, addonDidInstall, command, f
549
549
  };
550
550
  /**
551
551
  *
552
- * @param {import('../base-command.mjs').default} command
552
+ * @param {import('../base-command.js').default} command
553
553
  * @param {*} functionAddons
554
554
  * @param {*} fnPath
555
555
  * @returns
@@ -638,37 +638,10 @@ const ensureFunctionPathIsOk = function (functionsDir, name) {
638
638
  }
639
639
  return functionPath;
640
640
  };
641
- /**
642
- * The functions:create command
643
- * @param {string} name
644
- * @param {import('commander').OptionValues} options
645
- * @param {import('../base-command.mjs').default} command
646
- */
647
- // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type.
648
- const functionsCreate = async (name, options, command) => {
641
+ export const functionsCreate = async (name, options, command) => {
649
642
  const functionType = await selectTypeOfFunc();
650
643
  const functionsDir = functionType === 'edge' ? await ensureEdgeFuncDirExists(command) : await ensureFunctionDirExists(command);
651
644
  /* either download from URL or scaffold from template */
652
645
  const mainFunc = options.url ? downloadFromURL : scaffoldFromTemplate;
653
646
  await mainFunc(command, options, name, functionsDir, functionType);
654
647
  };
655
- /**
656
- * Creates the `netlify functions:create` command
657
- * @param {import('../base-command.mjs').default} program
658
- * @returns
659
- */
660
- // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
661
- export const createFunctionsCreateCommand = (program) => program
662
- .command('functions:create')
663
- .alias('function:create')
664
- .argument('[name]', 'name of your new function file inside your functions directory')
665
- .description('Create a new function locally')
666
- .option('-n, --name <name>', 'function name')
667
- .option('-u, --url <url>', 'pull template from URL')
668
- .option('-l, --language <lang>', 'function language')
669
- .addExamples([
670
- 'netlify functions:create',
671
- 'netlify functions:create hello-world',
672
- 'netlify functions:create --name hello-world',
673
- ])
674
- .action(functionsCreate);
@@ -4,8 +4,8 @@ import path from 'path';
4
4
  import inquirer from 'inquirer';
5
5
  // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message
6
6
  import fetch from 'node-fetch';
7
- import { NETLIFYDEVWARN, chalk, error, exit } from '../../utils/command-helpers.mjs';
8
- import { BACKGROUND, CLOCKWORK_USERAGENT, getFunctions } from '../../utils/functions/index.mjs';
7
+ import { NETLIFYDEVWARN, chalk, error, exit } from '../../utils/command-helpers.js';
8
+ import { BACKGROUND, CLOCKWORK_USERAGENT, getFunctions } from '../../utils/functions/index.js';
9
9
  const require = createRequire(import.meta.url);
10
10
  // https://docs.netlify.com/functions/trigger-on-events/
11
11
  const events = [
@@ -122,14 +122,7 @@ const getFunctionToTrigger = function (options, argumentName) {
122
122
  }
123
123
  return argumentName;
124
124
  };
125
- /**
126
- * The functions:invoke command
127
- * @param {string} nameArgument
128
- * @param {import('commander').OptionValues} options
129
- * @param {import('../base-command.mjs').default} command
130
- */
131
- // @ts-expect-error TS(7006) FIXME: Parameter 'nameArgument' implicitly has an 'any' t... Remove this comment to see the full error message
132
- const functionsInvoke = async (nameArgument, options, command) => {
125
+ export const functionsInvoke = async (nameArgument, options, command) => {
133
126
  const { config, relConfigFilePath } = command.netlify;
134
127
  const functionsDir = options.functions || (config.dev && config.dev.functions) || config.functionsDirectory;
135
128
  if (typeof functionsDir === 'undefined') {
@@ -216,34 +209,3 @@ const functionsInvoke = async (nameArgument, options, command) => {
216
209
  error(`Ran into an error invoking your function: ${error_.message}`);
217
210
  }
218
211
  };
219
- /**
220
- * Creates the `netlify functions:invoke` command
221
- * @param {import('../base-command.mjs').default} program
222
- * @returns
223
- */
224
- // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
225
- export const createFunctionsInvokeCommand = (program) => program
226
- .command('functions:invoke')
227
- .alias('function:trigger')
228
- .argument('[name]', 'function name to invoke')
229
- .description(`Trigger a function while in netlify dev with simulated data, good for testing function calls including Netlify's Event Triggered Functions`)
230
- .option('-n, --name <name>', 'function name to invoke')
231
- .option('-f, --functions <dir>', 'Specify a functions folder to parse, overriding netlify.toml')
232
- .option('-q, --querystring <query>', 'Querystring to add to your function invocation')
233
- .option('-p, --payload <data>', 'Supply POST payload in stringified json, or a path to a json file')
234
- // TODO: refactor to not need the `undefined` state by removing the --identity flag (value `identity` will be then always defined to true or false)
235
- .option('--identity', 'simulate Netlify Identity authentication JWT. pass --identity to affirm unauthenticated request')
236
- .option('--no-identity', 'simulate Netlify Identity authentication JWT. pass --no-identity to affirm unauthenticated request')
237
- // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type.
238
- .option('--port <port>', 'Port where netlify dev is accessible. e.g. 8888', (value) => Number.parseInt(value))
239
- .addExamples([
240
- 'netlify functions:invoke',
241
- 'netlify functions:invoke myfunction',
242
- 'netlify functions:invoke --name myfunction',
243
- 'netlify functions:invoke --name myfunction --identity',
244
- 'netlify functions:invoke --name myfunction --no-identity',
245
- `netlify functions:invoke myfunction --payload '{"foo": 1}'`,
246
- 'netlify functions:invoke myfunction --querystring "foo=1',
247
- 'netlify functions:invoke myfunction --payload "./pathTo.json"',
248
- ])
249
- .action(functionsInvoke);
@@ -1,20 +1,13 @@
1
1
  import AsciiTable from 'ascii-table';
2
- import { exit, log, logJson } from '../../utils/command-helpers.mjs';
3
- import { getFunctions, getFunctionsDir } from '../../utils/functions/index.mjs';
4
- import requiresSiteInfo from '../../utils/hooks/requires-site-info.mjs';
2
+ import { exit, log, logJson } from '../../utils/command-helpers.js';
3
+ import { getFunctions, getFunctionsDir } from '../../utils/functions/index.js';
5
4
  // @ts-expect-error TS(7006) FIXME: Parameter 'deployedFunctions' implicitly has an 'a... Remove this comment to see the full error message
6
5
  const normalizeFunction = function (deployedFunctions, { name, urlPath: url }) {
7
6
  // @ts-expect-error TS(7006) FIXME: Parameter 'deployedFunction' implicitly has an 'an... Remove this comment to see the full error message
8
7
  const isDeployed = deployedFunctions.some((deployedFunction) => deployedFunction.n === name);
9
8
  return { name, url, isDeployed };
10
9
  };
11
- /**
12
- * The functions:list command
13
- * @param {import('commander').OptionValues} options
14
- * @param {import('../base-command.mjs').default} command
15
- */
16
- // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
17
- const functionsList = async (options, command) => {
10
+ export const functionsList = async (options, command) => {
18
11
  const { config, relConfigFilePath, siteInfo } = command.netlify;
19
12
  const deploy = siteInfo.published_deploy || {};
20
13
  const deployedFunctions = deploy.available_functions || [];
@@ -45,20 +38,3 @@ const functionsList = async (options, command) => {
45
38
  });
46
39
  log(table.toString());
47
40
  };
48
- /**
49
- * Creates the `netlify functions:list` command
50
- * @param {import('../base-command.mjs').default} program
51
- * @returns
52
- */
53
- // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
54
- export const createFunctionsListCommand = (program) => program
55
- .command('functions:list')
56
- .alias('function:list')
57
- .description(`List functions that exist locally
58
- Helpful for making sure that you have formatted your functions correctly
59
-
60
- NOT the same as listing the functions that have been deployed. For that info you need to go to your Netlify deploy log.`)
61
- .option('-f, --functions <dir>', 'Specify a functions directory to list')
62
- .option('--json', 'Output function data as JSON')
63
- .hook('preAction', requiresSiteInfo)
64
- .action(functionsList);
@@ -1,17 +1,11 @@
1
1
  import { join } from 'path';
2
- import { startFunctionsServer } from '../../lib/functions/server.mjs';
3
- import { printBanner } from '../../utils/banner.mjs';
4
- import { acquirePort, getDotEnvVariables, getSiteInformation, injectEnvVariables } from '../../utils/dev.mjs';
5
- import { getFunctionsDir } from '../../utils/functions/index.mjs';
6
- import { getProxyUrl } from '../../utils/proxy.mjs';
2
+ import { startFunctionsServer } from '../../lib/functions/server.js';
3
+ import { printBanner } from '../../utils/banner.js';
4
+ import { acquirePort, getDotEnvVariables, getSiteInformation, injectEnvVariables } from '../../utils/dev.js';
5
+ import { getFunctionsDir } from '../../utils/functions/index.js';
6
+ import { getProxyUrl } from '../../utils/proxy.js';
7
7
  const DEFAULT_PORT = 9999;
8
- /**
9
- * The functions:serve command
10
- * @param {import('commander').OptionValues} options
11
- * @param {import('../base-command.mjs').default} command
12
- */
13
- // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
14
- const functionsServe = async (options, command) => {
8
+ export const functionsServe = async (options, command) => {
15
9
  const { api, config, site, siteInfo, state } = command.netlify;
16
10
  const functionsDir = getFunctionsDir({ options, config }, join('netlify', 'functions'));
17
11
  let { env } = command.netlify.cachedConfig;
@@ -51,19 +45,3 @@ const functionsServe = async (options, command) => {
51
45
  const url = getProxyUrl({ port: functionsPort });
52
46
  printBanner({ url });
53
47
  };
54
- /**
55
- * Creates the `netlify functions:serve` command
56
- * @param {import('../base-command.mjs').default} program
57
- * @returns
58
- */
59
- // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
60
- export const createFunctionsServeCommand = (program) => program
61
- .command('functions:serve')
62
- .alias('function:serve')
63
- .description('Serve functions locally')
64
- .option('-f, --functions <dir>', 'Specify a functions directory to serve')
65
- // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type.
66
- .option('-p, --port <port>', 'Specify a port for the functions server', (value) => Number.parseInt(value))
67
- .option('-o, --offline', 'disables any features that require network access')
68
- .addHelpText('after', 'Helpful for debugging functions.')
69
- .action(functionsServe);