netlify-cli 17.3.1 → 17.4.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 (210) hide show
  1. package/README.md +3 -139
  2. package/npm-shrinkwrap.json +82 -82
  3. package/package.json +16 -15
  4. package/src/commands/addons/addons-auth.mjs +27 -30
  5. package/src/commands/addons/addons-config.mjs +145 -154
  6. package/src/commands/addons/addons-create.mjs +94 -108
  7. package/src/commands/addons/addons-delete.mjs +36 -41
  8. package/src/commands/addons/addons-list.mjs +38 -42
  9. package/src/commands/addons/addons.mjs +26 -28
  10. package/src/commands/addons/index.mjs +1 -1
  11. package/src/commands/api/api.mjs +45 -53
  12. package/src/commands/api/index.mjs +1 -1
  13. package/src/commands/base-command.mjs +597 -684
  14. package/src/commands/blobs/blobs-delete.mjs +35 -0
  15. package/src/commands/blobs/blobs-get.mjs +44 -0
  16. package/src/commands/blobs/blobs-list.mjs +48 -0
  17. package/src/commands/blobs/blobs-set.mjs +54 -0
  18. package/src/commands/blobs/blobs.mjs +32 -0
  19. package/src/commands/blobs/index.mjs +1 -0
  20. package/src/commands/build/build.mjs +55 -67
  21. package/src/commands/build/index.mjs +1 -1
  22. package/src/commands/completion/completion.mjs +41 -46
  23. package/src/commands/completion/index.mjs +1 -1
  24. package/src/commands/deploy/deploy.mjs +675 -710
  25. package/src/commands/deploy/index.mjs +1 -1
  26. package/src/commands/dev/dev-exec.mjs +20 -32
  27. package/src/commands/dev/dev.mjs +217 -302
  28. package/src/commands/dev/index.mjs +1 -1
  29. package/src/commands/dev/types.d.ts +30 -0
  30. package/src/commands/env/env-clone.mjs +157 -184
  31. package/src/commands/env/env-get.mjs +49 -68
  32. package/src/commands/env/env-import.mjs +100 -119
  33. package/src/commands/env/env-list.mjs +104 -129
  34. package/src/commands/env/env-set.mjs +160 -185
  35. package/src/commands/env/env-unset.mjs +104 -122
  36. package/src/commands/env/env.mjs +28 -30
  37. package/src/commands/env/index.mjs +1 -1
  38. package/src/commands/functions/functions-build.mjs +29 -41
  39. package/src/commands/functions/functions-create.mjs +533 -601
  40. package/src/commands/functions/functions-invoke.mjs +193 -216
  41. package/src/commands/functions/functions-list.mjs +45 -55
  42. package/src/commands/functions/functions-serve.mjs +51 -61
  43. package/src/commands/functions/functions.mjs +26 -32
  44. package/src/commands/functions/index.mjs +1 -1
  45. package/src/commands/index.mjs +2 -2
  46. package/src/commands/init/index.mjs +1 -1
  47. package/src/commands/init/init.mjs +138 -167
  48. package/src/commands/integration/deploy.mjs +337 -399
  49. package/src/commands/integration/index.mjs +12 -13
  50. package/src/commands/link/index.mjs +1 -1
  51. package/src/commands/link/link.mjs +298 -317
  52. package/src/commands/lm/index.mjs +1 -1
  53. package/src/commands/lm/lm-info.mjs +23 -31
  54. package/src/commands/lm/lm-install.mjs +13 -17
  55. package/src/commands/lm/lm-setup.mjs +80 -84
  56. package/src/commands/lm/lm-uninstall.mjs +7 -12
  57. package/src/commands/lm/lm.mjs +18 -22
  58. package/src/commands/login/index.mjs +1 -1
  59. package/src/commands/login/login.mjs +35 -41
  60. package/src/commands/logout/index.mjs +1 -1
  61. package/src/commands/logout/logout.mjs +25 -31
  62. package/src/commands/main.mjs +166 -201
  63. package/src/commands/open/index.mjs +1 -1
  64. package/src/commands/open/open-admin.mjs +15 -18
  65. package/src/commands/open/open-site.mjs +16 -19
  66. package/src/commands/open/open.mjs +24 -27
  67. package/src/commands/recipes/common.mjs +23 -34
  68. package/src/commands/recipes/index.mjs +1 -1
  69. package/src/commands/recipes/recipes-list.mjs +13 -20
  70. package/src/commands/recipes/recipes.mjs +59 -72
  71. package/src/commands/serve/index.mjs +1 -1
  72. package/src/commands/serve/serve.mjs +142 -189
  73. package/src/commands/sites/index.mjs +2 -2
  74. package/src/commands/sites/sites-create-template.mjs +214 -236
  75. package/src/commands/sites/sites-create.mjs +145 -157
  76. package/src/commands/sites/sites-delete.mjs +75 -81
  77. package/src/commands/sites/sites-list.mjs +63 -66
  78. package/src/commands/sites/sites.mjs +18 -20
  79. package/src/commands/status/index.mjs +1 -1
  80. package/src/commands/status/status-hooks.mjs +32 -34
  81. package/src/commands/status/status.mjs +99 -106
  82. package/src/commands/switch/index.mjs +1 -1
  83. package/src/commands/switch/switch.mjs +32 -37
  84. package/src/commands/types.d.ts +31 -0
  85. package/src/commands/unlink/index.mjs +1 -1
  86. package/src/commands/unlink/unlink.mjs +23 -29
  87. package/src/commands/watch/index.mjs +1 -1
  88. package/src/commands/watch/watch.mjs +91 -105
  89. package/src/functions-templates/javascript/hello/{{name}}.js +2 -3
  90. package/src/lib/account.mjs +4 -5
  91. package/src/lib/api.mjs +22 -20
  92. package/src/lib/blobs/blobs.mjs +36 -45
  93. package/src/lib/build.mjs +82 -85
  94. package/src/lib/completion/constants.mjs +2 -4
  95. package/src/lib/completion/generate-autocompletion.mjs +33 -36
  96. package/src/lib/completion/get-autocompletion.mjs +31 -35
  97. package/src/lib/completion/index.mjs +1 -1
  98. package/src/lib/completion/script.mjs +12 -19
  99. package/src/lib/edge-functions/bootstrap.mjs +3 -5
  100. package/src/lib/edge-functions/consts.mjs +9 -10
  101. package/src/lib/edge-functions/deploy.mjs +28 -34
  102. package/src/lib/edge-functions/editor-helper.mjs +29 -42
  103. package/src/lib/edge-functions/headers.mjs +24 -26
  104. package/src/lib/edge-functions/internal.mjs +38 -44
  105. package/src/lib/edge-functions/proxy.mjs +229 -228
  106. package/src/lib/edge-functions/registry.mjs +473 -574
  107. package/src/lib/exec-fetcher.mjs +115 -122
  108. package/src/lib/fs.mjs +28 -27
  109. package/src/lib/functions/background.mjs +16 -20
  110. package/src/lib/functions/config.mjs +12 -9
  111. package/src/lib/functions/form-submissions-handler.mjs +143 -149
  112. package/src/lib/functions/local-proxy.mjs +40 -44
  113. package/src/lib/functions/memoized-build.mjs +19 -21
  114. package/src/lib/functions/netlify-function.mjs +269 -249
  115. package/src/lib/functions/registry.mjs +509 -568
  116. package/src/lib/functions/runtimes/go/index.mjs +62 -71
  117. package/src/lib/functions/runtimes/index.mjs +8 -15
  118. package/src/lib/functions/runtimes/js/builders/netlify-lambda.mjs +55 -64
  119. package/src/lib/functions/runtimes/js/builders/zisi.mjs +135 -154
  120. package/src/lib/functions/runtimes/js/constants.mjs +1 -1
  121. package/src/lib/functions/runtimes/js/index.mjs +92 -109
  122. package/src/lib/functions/runtimes/js/worker.mjs +43 -45
  123. package/src/lib/functions/runtimes/rust/index.mjs +64 -73
  124. package/src/lib/functions/scheduled.mjs +70 -88
  125. package/src/lib/functions/server.mjs +269 -327
  126. package/src/lib/functions/synchronous.mjs +118 -147
  127. package/src/lib/functions/utils.mjs +38 -46
  128. package/src/lib/geo-location.mjs +69 -81
  129. package/src/lib/http-agent.mjs +87 -90
  130. package/src/lib/images/proxy.mjs +97 -89
  131. package/src/lib/log.mjs +6 -9
  132. package/src/lib/path.mjs +2 -1
  133. package/src/lib/render-error-template.mjs +19 -20
  134. package/src/lib/settings.mjs +17 -19
  135. package/src/lib/spinner.mjs +21 -23
  136. package/src/lib/string.mjs +4 -2
  137. package/src/recipes/vscode/index.mjs +69 -85
  138. package/src/recipes/vscode/settings.mjs +53 -58
  139. package/src/utils/addons/compare.mjs +31 -32
  140. package/src/utils/addons/diffs/index.mjs +16 -17
  141. package/src/utils/addons/diffs/options.mjs +99 -101
  142. package/src/utils/addons/prepare.mjs +100 -97
  143. package/src/utils/addons/prompts.mjs +73 -76
  144. package/src/utils/addons/render.mjs +33 -36
  145. package/src/utils/addons/validation.mjs +19 -15
  146. package/src/utils/banner.mjs +11 -16
  147. package/src/utils/build-info.mjs +65 -66
  148. package/src/utils/command-helpers.mjs +185 -199
  149. package/src/utils/create-deferred.mjs +9 -12
  150. package/src/utils/create-stream-promise.mjs +54 -47
  151. package/src/utils/deploy/constants.mjs +9 -11
  152. package/src/utils/deploy/deploy-site.mjs +162 -182
  153. package/src/utils/deploy/hash-config.mjs +21 -21
  154. package/src/utils/deploy/hash-files.mjs +34 -38
  155. package/src/utils/deploy/hash-fns.mjs +149 -154
  156. package/src/utils/deploy/hasher-segments.mjs +58 -52
  157. package/src/utils/deploy/upload-files.mjs +99 -113
  158. package/src/utils/deploy/util.mjs +85 -91
  159. package/src/utils/detect-server-settings.mjs +236 -268
  160. package/src/utils/dev.mjs +163 -178
  161. package/src/utils/dot-env.mjs +37 -42
  162. package/src/utils/env/index.mjs +148 -148
  163. package/src/utils/execa.mjs +9 -13
  164. package/src/utils/feature-flags.mjs +6 -5
  165. package/src/utils/framework-server.mjs +43 -52
  166. package/src/utils/functions/constants.mjs +1 -1
  167. package/src/utils/functions/functions.mjs +30 -40
  168. package/src/utils/functions/get-functions.mjs +28 -29
  169. package/src/utils/functions/index.mjs +3 -3
  170. package/src/utils/get-global-config.mjs +33 -36
  171. package/src/utils/get-package-json.mjs +14 -15
  172. package/src/utils/get-repo-data.mjs +54 -64
  173. package/src/utils/get-site.mjs +14 -14
  174. package/src/utils/gh-auth.mjs +79 -100
  175. package/src/utils/gitignore.mjs +37 -40
  176. package/src/utils/headers.mjs +33 -35
  177. package/src/utils/hooks/requires-site-info.mjs +26 -22
  178. package/src/utils/init/config-github.mjs +207 -219
  179. package/src/utils/init/config-manual.mjs +83 -100
  180. package/src/utils/init/config.mjs +25 -26
  181. package/src/utils/init/node-version.mjs +23 -30
  182. package/src/utils/init/plugins.mjs +12 -8
  183. package/src/utils/init/utils.mjs +152 -172
  184. package/src/utils/live-tunnel.mjs +118 -141
  185. package/src/utils/lm/install.mjs +220 -259
  186. package/src/utils/lm/requirements.mjs +54 -63
  187. package/src/utils/lm/steps.mjs +31 -31
  188. package/src/utils/lm/ui.mjs +13 -20
  189. package/src/utils/open-browser.mjs +31 -32
  190. package/src/utils/parse-raw-flags.mjs +39 -35
  191. package/src/utils/proxy-server.mjs +84 -71
  192. package/src/utils/proxy.mjs +696 -750
  193. package/src/utils/read-repo-url.mjs +48 -47
  194. package/src/utils/redirects.mjs +49 -49
  195. package/src/utils/request-id.mjs +2 -4
  196. package/src/utils/rules-proxy.mjs +96 -100
  197. package/src/utils/run-build.mjs +109 -132
  198. package/src/utils/shell.mjs +99 -106
  199. package/src/utils/sign-redirect.mjs +14 -14
  200. package/src/utils/sites/utils.mjs +48 -55
  201. package/src/utils/state-config.mjs +101 -101
  202. package/src/utils/static-server.mjs +28 -34
  203. package/src/utils/telemetry/index.mjs +2 -2
  204. package/src/utils/telemetry/report-error.mjs +45 -49
  205. package/src/utils/telemetry/request.mjs +36 -43
  206. package/src/utils/telemetry/telemetry.mjs +90 -105
  207. package/src/utils/telemetry/utils.mjs +5 -6
  208. package/src/utils/telemetry/validation.mjs +55 -53
  209. package/src/utils/types.d.ts +46 -0
  210. package/src/utils/validation.mjs +10 -13
@@ -1,32 +1,30 @@
1
- // @ts-check
2
- import { createSitesFromTemplateCommand } from './sites-create-template.mjs'
3
- import { createSitesCreateCommand } from './sites-create.mjs'
4
- import { createSitesDeleteCommand } from './sites-delete.mjs'
5
- import { createSitesListCommand } from './sites-list.mjs'
6
-
1
+ import { createSitesFromTemplateCommand } from './sites-create-template.mjs';
2
+ import { createSitesCreateCommand } from './sites-create.mjs';
3
+ import { createSitesDeleteCommand } from './sites-delete.mjs';
4
+ import { createSitesListCommand } from './sites-list.mjs';
7
5
  /**
8
6
  * The sites command
9
7
  * @param {import('commander').OptionValues} options
10
8
  * @param {import('../base-command.mjs').default} command
11
9
  */
10
+ // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
12
11
  const sites = (options, command) => {
13
- command.help()
14
- }
15
-
12
+ command.help();
13
+ };
16
14
  /**
17
15
  * Creates the `netlify sites` command
18
16
  * @param {import('../base-command.mjs').default} program
19
17
  * @returns
20
18
  */
19
+ // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
21
20
  export const createSitesCommand = (program) => {
22
- createSitesCreateCommand(program)
23
- createSitesFromTemplateCommand(program)
24
- createSitesListCommand(program)
25
- createSitesDeleteCommand(program)
26
-
27
- return program
28
- .command('sites')
29
- .description(`Handle various site operations\nThe sites command will help you manage all your sites`)
30
- .addExamples(['netlify sites:create --name my-new-site', 'netlify sites:list'])
31
- .action(sites)
32
- }
21
+ createSitesCreateCommand(program);
22
+ createSitesFromTemplateCommand(program);
23
+ createSitesListCommand(program);
24
+ createSitesDeleteCommand(program);
25
+ return program
26
+ .command('sites')
27
+ .description(`Handle various site operations\nThe sites command will help you manage all your sites`)
28
+ .addExamples(['netlify sites:create --name my-new-site', 'netlify sites:list'])
29
+ .action(sites);
30
+ };
@@ -1 +1 @@
1
- export { createStatusCommand } from './status.mjs'
1
+ export { createStatusCommand } from './status.mjs';
@@ -1,49 +1,47 @@
1
- // @ts-check
2
- import prettyjson from 'prettyjson'
3
-
4
- import { log } from '../../utils/command-helpers.mjs'
5
- import requiresSiteInfo from '../../utils/hooks/requires-site-info.mjs'
6
-
1
+ import prettyjson from 'prettyjson';
2
+ import { log } from '../../utils/command-helpers.mjs';
3
+ import requiresSiteInfo from '../../utils/hooks/requires-site-info.mjs';
7
4
  /**
8
5
  * The status:hooks command
9
6
  * @param {import('commander').OptionValues} options
10
7
  * @param {import('../base-command.mjs').default} command
11
8
  */
9
+ // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
12
10
  const statusHooks = async (options, command) => {
13
- const { api, siteInfo } = command.netlify
14
-
15
- await command.authenticate()
16
-
17
- const ntlHooks = await api.listHooksBySiteId({ siteId: siteInfo.id })
18
- const data = {
19
- site: siteInfo.name,
20
- hooks: {},
21
- }
22
- ntlHooks.forEach((hook) => {
23
- data.hooks[hook.id] = {
24
- type: hook.type,
25
- event: hook.event,
26
- id: hook.id,
27
- disabled: hook.disabled,
28
- }
29
- if (siteInfo.build_settings?.repo_url) {
30
- data.hooks[hook.id].repo_url = siteInfo.build_settings.repo_url
31
- }
32
- })
33
- log(`─────────────────┐
11
+ const { api, siteInfo } = command.netlify;
12
+ await command.authenticate();
13
+ const ntlHooks = await api.listHooksBySiteId({ siteId: siteInfo.id });
14
+ const data = {
15
+ site: siteInfo.name,
16
+ hooks: {},
17
+ };
18
+ // @ts-expect-error TS(7006) FIXME: Parameter 'hook' implicitly has an 'any' type.
19
+ ntlHooks.forEach((hook) => {
20
+ // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
21
+ data.hooks[hook.id] = {
22
+ type: hook.type,
23
+ event: hook.event,
24
+ id: hook.id,
25
+ disabled: hook.disabled,
26
+ };
27
+ if (siteInfo.build_settings?.repo_url) {
28
+ // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
29
+ data.hooks[hook.id].repo_url = siteInfo.build_settings.repo_url;
30
+ }
31
+ });
32
+ log(`─────────────────┐
34
33
  Site Hook Status │
35
- ─────────────────┘`)
36
- log(prettyjson.render(data))
37
- }
38
-
34
+ ─────────────────┘`);
35
+ log(prettyjson.render(data));
36
+ };
39
37
  /**
40
38
  * Creates the `netlify status:hooks` command
41
39
  * @param {import('../base-command.mjs').default} program
42
40
  * @returns
43
41
  */
44
- export const createStatusHooksCommand = (program) =>
45
- program
42
+ // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
43
+ export const createStatusHooksCommand = (program) => program
46
44
  .command('status:hooks')
47
45
  .description('Print hook information of the linked site')
48
46
  .hook('preAction', requiresSiteInfo)
49
- .action(statusHooks)
47
+ .action(statusHooks);
@@ -1,123 +1,116 @@
1
- // @ts-check
2
- import clean from 'clean-deep'
3
- import prettyjson from 'prettyjson'
4
-
5
- import { chalk, error, exit, getToken, log, logJson, warn } from '../../utils/command-helpers.mjs'
6
-
7
- import { createStatusHooksCommand } from './status-hooks.mjs'
8
-
1
+ import clean from 'clean-deep';
2
+ import prettyjson from 'prettyjson';
3
+ import { chalk, error, exit, getToken, log, logJson, warn } from '../../utils/command-helpers.mjs';
4
+ import { createStatusHooksCommand } from './status-hooks.mjs';
9
5
  /**
10
6
  * The status command
11
7
  * @param {import('commander').OptionValues} options
12
8
  * @param {import('../base-command.mjs').default} command
13
9
  */
10
+ // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
14
11
  const status = async (options, command) => {
15
- const { api, globalConfig, site } = command.netlify
16
- const current = globalConfig.get('userId')
17
- const [accessToken] = await getToken()
18
-
19
- if (!accessToken) {
20
- log(`Not logged in. Please log in to see site status.`)
21
- log()
22
- log('Login with "netlify login" command')
23
- exit()
24
- }
25
-
26
- const siteId = site.id
27
-
28
- log(`──────────────────────┐
12
+ const { api, globalConfig, site } = command.netlify;
13
+ const current = globalConfig.get('userId');
14
+ // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0.
15
+ const [accessToken] = await getToken();
16
+ if (!accessToken) {
17
+ log(`Not logged in. Please log in to see site status.`);
18
+ log();
19
+ log('Login with "netlify login" command');
20
+ exit();
21
+ }
22
+ const siteId = site.id;
23
+ log(`──────────────────────┐
29
24
  Current Netlify User │
30
- ──────────────────────┘`)
31
-
32
- let accounts
33
- let user
34
-
35
- try {
36
- ;[accounts, user] = await Promise.all([api.listAccountsForUser(), api.getCurrentUser()])
37
- } catch (error_) {
38
- if (error_.status === 401) {
39
- error('Your session has expired. Please try to re-authenticate by running `netlify logout` and `netlify login`.')
25
+ ──────────────────────┘`);
26
+ let accounts;
27
+ let user;
28
+ try {
29
+ ;
30
+ [accounts, user] = await Promise.all([api.listAccountsForUser(), api.getCurrentUser()]);
31
+ }
32
+ catch (error_) {
33
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
34
+ if (error_.status === 401) {
35
+ error('Your session has expired. Please try to re-authenticate by running `netlify logout` and `netlify login`.');
36
+ }
37
+ }
38
+ const ghuser = command.netlify.globalConfig.get(`users.${current}.auth.github.user`);
39
+ const accountData = {
40
+ Name: user.full_name,
41
+ Email: user.email,
42
+ GitHub: ghuser,
43
+ };
44
+ const teamsData = {};
45
+ // @ts-expect-error TS(7006) FIXME: Parameter 'team' implicitly has an 'any' type.
46
+ accounts.forEach((team) => {
47
+ // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
48
+ teamsData[team.name] = team.roles_allowed.join(' ');
49
+ });
50
+ // @ts-expect-error TS(2339) FIXME: Property 'Teams' does not exist on type '{ Name: a... Remove this comment to see the full error message
51
+ accountData.Teams = teamsData;
52
+ // @ts-expect-error
53
+ const cleanAccountData = clean(accountData);
54
+ log(prettyjson.render(cleanAccountData));
55
+ if (!siteId) {
56
+ warn('Did you run `netlify link` yet?');
57
+ error(`You don't appear to be in a folder that is linked to a site`);
58
+ }
59
+ let siteData;
60
+ try {
61
+ siteData = await api.getSite({ siteId });
40
62
  }
41
- }
42
-
43
- const ghuser = command.netlify.globalConfig.get(`users.${current}.auth.github.user`)
44
- const accountData = {
45
- Name: user.full_name,
46
- Email: user.email,
47
- GitHub: ghuser,
48
- }
49
- const teamsData = {}
50
-
51
- accounts.forEach((team) => {
52
- teamsData[team.name] = team.roles_allowed.join(' ')
53
- })
54
-
55
- accountData.Teams = teamsData
56
-
57
- const cleanAccountData = clean(accountData)
58
-
59
- log(prettyjson.render(cleanAccountData))
60
-
61
- if (!siteId) {
62
- warn('Did you run `netlify link` yet?')
63
- error(`You don't appear to be in a folder that is linked to a site`)
64
- }
65
- let siteData
66
- try {
67
- siteData = await api.getSite({ siteId })
68
- } catch (error_) {
69
- // unauthorized
70
- if (error_.status === 401) {
71
- warn(`Log in with a different account or re-link to a site you have permission for`)
72
- error(`Not authorized to view the currently linked site (${siteId})`)
63
+ catch (error_) {
64
+ // unauthorized
65
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
66
+ if (error_.status === 401) {
67
+ warn(`Log in with a different account or re-link to a site you have permission for`);
68
+ error(`Not authorized to view the currently linked site (${siteId})`);
69
+ }
70
+ // missing
71
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
72
+ if (error_.status === 404) {
73
+ error(`The site this folder is linked to can't be found`);
74
+ }
75
+ // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message
76
+ error(error_);
73
77
  }
74
- // missing
75
- if (error_.status === 404) {
76
- error(`The site this folder is linked to can't be found`)
78
+ // Json only logs out if --json flag is passed
79
+ if (options.json) {
80
+ logJson({
81
+ account: cleanAccountData,
82
+ siteData: {
83
+ 'site-name': `${siteData.name}`,
84
+ 'config-path': site.configPath,
85
+ 'admin-url': siteData.admin_url,
86
+ 'site-url': siteData.ssl_url || siteData.url,
87
+ 'site-id': siteData.id,
88
+ },
89
+ });
77
90
  }
78
- error(error_)
79
- }
80
-
81
- // Json only logs out if --json flag is passed
82
- if (options.json) {
83
- logJson({
84
- account: cleanAccountData,
85
- siteData: {
86
- 'site-name': `${siteData.name}`,
87
- 'config-path': site.configPath,
88
- 'admin-url': siteData.admin_url,
89
- 'site-url': siteData.ssl_url || siteData.url,
90
- 'site-id': siteData.id,
91
- },
92
- })
93
- }
94
-
95
- log(`────────────────────┐
91
+ log(`────────────────────┐
96
92
  Netlify Site Info │
97
- ────────────────────┘`)
98
- log(
99
- prettyjson.render({
100
- 'Current site': `${siteData.name}`,
101
- 'Netlify TOML': site.configPath,
102
- 'Admin URL': chalk.magentaBright(siteData.admin_url),
103
- 'Site URL': chalk.cyanBright(siteData.ssl_url || siteData.url),
104
- 'Site Id': chalk.yellowBright(siteData.id),
105
- }),
106
- )
107
- log()
108
- }
109
-
93
+ ────────────────────┘`);
94
+ log(prettyjson.render({
95
+ 'Current site': `${siteData.name}`,
96
+ 'Netlify TOML': site.configPath,
97
+ 'Admin URL': chalk.magentaBright(siteData.admin_url),
98
+ 'Site URL': chalk.cyanBright(siteData.ssl_url || siteData.url),
99
+ 'Site Id': chalk.yellowBright(siteData.id),
100
+ }));
101
+ log();
102
+ };
110
103
  /**
111
104
  * Creates the `netlify status` command
112
105
  * @param {import('../base-command.mjs').default} program
113
106
  * @returns
114
107
  */
108
+ // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
115
109
  export const createStatusCommand = (program) => {
116
- createStatusHooksCommand(program)
117
-
118
- return program
119
- .command('status')
120
- .description('Print status information')
121
- .option('--verbose', 'Output system info')
122
- .action(status)
123
- }
110
+ createStatusHooksCommand(program);
111
+ return program
112
+ .command('status')
113
+ .description('Print status information')
114
+ .option('--verbose', 'Output system info')
115
+ .action(status);
116
+ };
@@ -1 +1 @@
1
- export { createSwitchCommand } from './switch.mjs'
1
+ export { createSwitchCommand } from './switch.mjs';
@@ -1,48 +1,43 @@
1
- // @ts-check
2
- import inquirer from 'inquirer'
3
-
4
- import { chalk, log } from '../../utils/command-helpers.mjs'
5
- import { login } from '../login/index.mjs'
6
-
7
- const LOGIN_NEW = 'I would like to login to a new account'
8
-
1
+ import inquirer from 'inquirer';
2
+ import { chalk, log } from '../../utils/command-helpers.mjs';
3
+ import { login } from '../login/index.mjs';
4
+ const LOGIN_NEW = 'I would like to login to a new account';
9
5
  /**
10
6
  * The switch command
11
7
  * @param {import('commander').OptionValues} options
12
8
  * @param {import('../base-command.mjs').default} command
13
9
  */
10
+ // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
14
11
  const switchCommand = async (options, command) => {
15
- const availableUsersChoices = Object.values(command.netlify.globalConfig.get('users') || {}).reduce(
16
- (prev, current) =>
17
- Object.assign(prev, { [current.id]: current.name ? `${current.name} (${current.email})` : current.email }),
18
- {},
19
- )
20
-
21
- const { accountSwitchChoice } = await inquirer.prompt([
22
- {
23
- type: 'list',
24
- name: 'accountSwitchChoice',
25
- message: 'Please select the account you want to use:',
26
- choices: [...Object.entries(availableUsersChoices).map(([, val]) => val), LOGIN_NEW],
27
- },
28
- ])
29
-
30
- if (accountSwitchChoice === LOGIN_NEW) {
31
- await login({ new: true }, command)
32
- } else {
33
- const selectedAccount = Object.entries(availableUsersChoices).find(
34
- ([, availableUsersChoice]) => availableUsersChoice === accountSwitchChoice,
35
- )
36
- command.netlify.globalConfig.set('userId', selectedAccount[0])
37
- log('')
38
- log(`You're now using ${chalk.bold(selectedAccount[1])}.`)
39
- }
40
- }
41
-
12
+ const availableUsersChoices = Object.values(command.netlify.globalConfig.get('users') || {}).reduce((prev, current) =>
13
+ // @ts-expect-error TS(2769) FIXME: No overload matches this call.
14
+ Object.assign(prev, { [current.id]: current.name ? `${current.name} (${current.email})` : current.email }), {});
15
+ const { accountSwitchChoice } = await inquirer.prompt([
16
+ {
17
+ type: 'list',
18
+ name: 'accountSwitchChoice',
19
+ message: 'Please select the account you want to use:',
20
+ // @ts-expect-error TS(2769) FIXME: No overload matches this call.
21
+ choices: [...Object.entries(availableUsersChoices).map(([, val]) => val), LOGIN_NEW],
22
+ },
23
+ ]);
24
+ if (accountSwitchChoice === LOGIN_NEW) {
25
+ await login({ new: true }, command);
26
+ }
27
+ else {
28
+ // @ts-expect-error TS(2769) FIXME: No overload matches this call.
29
+ const selectedAccount = Object.entries(availableUsersChoices).find(([, availableUsersChoice]) => availableUsersChoice === accountSwitchChoice);
30
+ // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
31
+ command.netlify.globalConfig.set('userId', selectedAccount[0]);
32
+ log('');
33
+ // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
34
+ log(`You're now using ${chalk.bold(selectedAccount[1])}.`);
35
+ }
36
+ };
42
37
  /**
43
38
  * Creates the `netlify switch` command
44
39
  * @param {import('../base-command.mjs').default} program
45
40
  * @returns
46
41
  */
47
- export const createSwitchCommand = (program) =>
48
- program.command('switch').description('Switch your active Netlify account').action(switchCommand)
42
+ // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
43
+ export const createSwitchCommand = (program) => program.command('switch').description('Switch your active Netlify account').action(switchCommand);
@@ -0,0 +1,31 @@
1
+ import { NetlifyTOML } from '@netlify/build-info'
2
+ import type { NetlifyAPI } from 'netlify'
3
+
4
+ import StateConfig from '../utils/state-config.mjs'
5
+
6
+ export type NetlifySite = {
7
+ root?: string
8
+ configPath?: string
9
+ siteId?: string
10
+ get id(): string | undefined
11
+ set id(id: string): void
12
+ }
13
+
14
+ /**
15
+ * The netlify object inside each command with the state
16
+ */
17
+ export type NetlifyOptions = {
18
+ api: NetlifyAPI
19
+ apiOpts: unknown
20
+ repositoryRoot: string
21
+ /** Absolute path of the netlify configuration file */
22
+ configFilePath: string
23
+ /** Relative path of the netlify configuration file */
24
+ relConfigFilePath: string
25
+ site: NetlifySite
26
+ siteInfo: unknown
27
+ config: NetlifyTOML
28
+ cachedConfig: Record<string, unknown>
29
+ globalConfig: unknown
30
+ state: StateConfig
31
+ }
@@ -1 +1 @@
1
- export { createUnlinkCommand } from './unlink.mjs'
1
+ export { createUnlinkCommand } from './unlink.mjs';
@@ -1,40 +1,34 @@
1
- // @ts-check
2
- import { exit, log } from '../../utils/command-helpers.mjs'
3
- import { track } from '../../utils/telemetry/index.mjs'
4
-
1
+ import { exit, log } from '../../utils/command-helpers.mjs';
2
+ import { track } from '../../utils/telemetry/index.mjs';
5
3
  /**
6
4
  * The unlink command
7
5
  * @param {import('commander').OptionValues} options
8
6
  * @param {import('../base-command.mjs').default} command
9
7
  */
8
+ // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
10
9
  const unlink = async (options, command) => {
11
- const { site, siteInfo, state } = command.netlify
12
- const siteId = site.id
13
-
14
- if (!siteId) {
15
- log(`Folder is not linked to a Netlify site. Run 'netlify link' to link it`)
16
- return exit()
17
- }
18
-
19
- const siteData = siteInfo
20
-
21
- state.delete('siteId')
22
-
23
- await track('sites_unlinked', {
24
- siteId: siteData.id || siteId,
25
- })
26
-
27
- if (site) {
28
- log(`Unlinked ${site.configPath} from ${siteData ? siteData.name : siteId}`)
29
- } else {
30
- log('Unlinked site')
31
- }
32
- }
33
-
10
+ const { site, siteInfo, state } = command.netlify;
11
+ const siteId = site.id;
12
+ if (!siteId) {
13
+ log(`Folder is not linked to a Netlify site. Run 'netlify link' to link it`);
14
+ return exit();
15
+ }
16
+ const siteData = siteInfo;
17
+ state.delete('siteId');
18
+ await track('sites_unlinked', {
19
+ siteId: siteData.id || siteId,
20
+ });
21
+ if (site) {
22
+ log(`Unlinked ${site.configPath} from ${siteData ? siteData.name : siteId}`);
23
+ }
24
+ else {
25
+ log('Unlinked site');
26
+ }
27
+ };
34
28
  /**
35
29
  * Creates the `netlify unlink` command
36
30
  * @param {import('../base-command.mjs').default} program
37
31
  * @returns
38
32
  */
39
- export const createUnlinkCommand = (program) =>
40
- program.command('unlink').description('Unlink a local folder from a Netlify site').action(unlink)
33
+ // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
34
+ export const createUnlinkCommand = (program) => program.command('unlink').description('Unlink a local folder from a Netlify site').action(unlink);
@@ -1 +1 @@
1
- export { createWatchCommand } from './watch.mjs'
1
+ export { createWatchCommand } from './watch.mjs';