netlify-cli 17.37.1 → 17.38.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 (157) hide show
  1. package/bin/run.js +4 -2
  2. package/dist/commands/addons/addons-config.d.ts.map +1 -1
  3. package/dist/commands/addons/addons-config.js +0 -1
  4. package/dist/commands/addons/addons-create.d.ts.map +1 -1
  5. package/dist/commands/addons/addons-create.js +0 -1
  6. package/dist/commands/addons/addons-delete.d.ts.map +1 -1
  7. package/dist/commands/addons/addons-delete.js +0 -1
  8. package/dist/commands/addons/addons.d.ts.map +1 -1
  9. package/dist/commands/addons/addons.js +0 -1
  10. package/dist/commands/api/api.d.ts.map +1 -1
  11. package/dist/commands/api/api.js +0 -1
  12. package/dist/commands/base-command.d.ts +2 -2
  13. package/dist/commands/base-command.d.ts.map +1 -1
  14. package/dist/commands/base-command.js +2 -2
  15. package/dist/commands/blobs/blobs-delete.d.ts.map +1 -1
  16. package/dist/commands/blobs/blobs-delete.js +7 -1
  17. package/dist/commands/blobs/blobs-set.d.ts +1 -0
  18. package/dist/commands/blobs/blobs-set.d.ts.map +1 -1
  19. package/dist/commands/blobs/blobs-set.js +10 -2
  20. package/dist/commands/build/build.d.ts.map +1 -1
  21. package/dist/commands/build/build.js +0 -1
  22. package/dist/commands/completion/completion.d.ts.map +1 -1
  23. package/dist/commands/completion/completion.js +35 -2
  24. package/dist/commands/deploy/deploy.d.ts.map +1 -1
  25. package/dist/commands/deploy/deploy.js +3 -5
  26. package/dist/commands/deploy/index.d.ts.map +1 -1
  27. package/dist/commands/deploy/index.js +4 -3
  28. package/dist/commands/env/env-clone.d.ts.map +1 -1
  29. package/dist/commands/env/env-clone.js +12 -3
  30. package/dist/commands/env/env-set.d.ts.map +1 -1
  31. package/dist/commands/env/env-set.js +8 -3
  32. package/dist/commands/env/env-unset.d.ts.map +1 -1
  33. package/dist/commands/env/env-unset.js +7 -3
  34. package/dist/commands/functions/functions-create.d.ts.map +1 -1
  35. package/dist/commands/functions/functions-create.js +2 -5
  36. package/dist/commands/functions/functions-invoke.d.ts.map +1 -1
  37. package/dist/commands/functions/functions-invoke.js +0 -1
  38. package/dist/commands/init/index.d.ts.map +1 -1
  39. package/dist/commands/init/index.js +0 -1
  40. package/dist/commands/integration/deploy.d.ts.map +1 -1
  41. package/dist/commands/integration/deploy.js +13 -24
  42. package/dist/commands/link/link.d.ts.map +1 -1
  43. package/dist/commands/link/link.js +8 -21
  44. package/dist/commands/lm/lm-setup.d.ts.map +1 -1
  45. package/dist/commands/lm/lm-setup.js +0 -1
  46. package/dist/commands/login/login.d.ts.map +1 -1
  47. package/dist/commands/login/login.js +0 -2
  48. package/dist/commands/logout/logout.d.ts.map +1 -1
  49. package/dist/commands/logout/logout.js +0 -1
  50. package/dist/commands/logs/build.d.ts.map +1 -1
  51. package/dist/commands/logs/build.js +4 -0
  52. package/dist/commands/main.d.ts +34 -0
  53. package/dist/commands/main.d.ts.map +1 -1
  54. package/dist/commands/main.js +36 -6
  55. package/dist/commands/sites/sites-create-template.d.ts +2 -2
  56. package/dist/commands/sites/sites-create-template.d.ts.map +1 -1
  57. package/dist/commands/sites/sites-create-template.js +113 -101
  58. package/dist/commands/sites/sites-create.d.ts +2 -2
  59. package/dist/commands/sites/sites-create.d.ts.map +1 -1
  60. package/dist/commands/sites/sites-create.js +1 -9
  61. package/dist/commands/sites/sites-delete.d.ts.map +1 -1
  62. package/dist/commands/sites/sites-delete.js +3 -3
  63. package/dist/commands/sites/sites-list.d.ts.map +1 -1
  64. package/dist/commands/sites/sites-list.js +1 -5
  65. package/dist/commands/sites/sites.d.ts.map +1 -1
  66. package/dist/commands/sites/sites.js +0 -1
  67. package/dist/commands/status/status.js +3 -2
  68. package/dist/commands/unlink/unlink.js +2 -2
  69. package/dist/commands/watch/watch.d.ts.map +1 -1
  70. package/dist/commands/watch/watch.js +0 -1
  71. package/dist/lib/api.d.ts +2 -1
  72. package/dist/lib/api.d.ts.map +1 -1
  73. package/dist/lib/exec-fetcher.d.ts.map +1 -1
  74. package/dist/lib/exec-fetcher.js +0 -1
  75. package/dist/tsconfig.tsbuildinfo +1 -1
  76. package/dist/utils/addons/prepare.d.ts.map +1 -1
  77. package/dist/utils/addons/prepare.js +1 -5
  78. package/dist/utils/command-helpers.d.ts +37 -6
  79. package/dist/utils/command-helpers.d.ts.map +1 -1
  80. package/dist/utils/command-helpers.js +21 -9
  81. package/dist/utils/dev.d.ts.map +1 -1
  82. package/dist/utils/dev.js +0 -2
  83. package/dist/utils/framework-server.d.ts.map +1 -1
  84. package/dist/utils/framework-server.js +2 -3
  85. package/dist/utils/get-repo-data.d.ts +2 -2
  86. package/dist/utils/get-repo-data.d.ts.map +1 -1
  87. package/dist/utils/get-repo-data.js +0 -1
  88. package/dist/utils/get-site.d.ts.map +1 -1
  89. package/dist/utils/get-site.js +7 -2
  90. package/dist/utils/gh-auth.js +1 -1
  91. package/dist/utils/hooks/requires-site-info.d.ts.map +1 -1
  92. package/dist/utils/hooks/requires-site-info.js +0 -3
  93. package/dist/utils/prompts/blob-delete-prompts.d.ts +2 -0
  94. package/dist/utils/prompts/blob-delete-prompts.d.ts.map +1 -0
  95. package/dist/utils/prompts/blob-delete-prompts.js +11 -0
  96. package/dist/utils/prompts/blob-set-prompt.d.ts +2 -0
  97. package/dist/utils/prompts/blob-set-prompt.d.ts.map +1 -0
  98. package/dist/utils/prompts/blob-set-prompt.js +11 -0
  99. package/dist/utils/prompts/confirm-prompt.d.ts +2 -0
  100. package/dist/utils/prompts/confirm-prompt.d.ts.map +1 -0
  101. package/dist/utils/prompts/confirm-prompt.js +20 -0
  102. package/dist/utils/prompts/env-clone-prompt.d.ts +11 -0
  103. package/dist/utils/prompts/env-clone-prompt.d.ts.map +1 -0
  104. package/dist/utils/prompts/env-clone-prompt.js +27 -0
  105. package/dist/utils/prompts/env-set-prompts.d.ts +2 -0
  106. package/dist/utils/prompts/env-set-prompts.d.ts.map +1 -0
  107. package/dist/utils/prompts/env-set-prompts.js +11 -0
  108. package/dist/utils/prompts/env-unset-prompts.d.ts +8 -0
  109. package/dist/utils/prompts/env-unset-prompts.d.ts.map +1 -0
  110. package/dist/utils/prompts/env-unset-prompts.js +17 -0
  111. package/dist/utils/prompts/prompt-messages.d.ts +25 -0
  112. package/dist/utils/prompts/prompt-messages.d.ts.map +1 -0
  113. package/dist/utils/prompts/prompt-messages.js +25 -0
  114. package/dist/utils/run-build.d.ts +2 -0
  115. package/dist/utils/run-build.d.ts.map +1 -1
  116. package/dist/utils/run-program.d.ts +3 -0
  117. package/dist/utils/run-program.d.ts.map +1 -0
  118. package/dist/utils/run-program.js +12 -0
  119. package/dist/utils/scripted-commands.d.ts +3 -0
  120. package/dist/utils/scripted-commands.d.ts.map +1 -0
  121. package/dist/utils/scripted-commands.js +17 -0
  122. package/dist/utils/sites/create-template.d.ts +14 -0
  123. package/dist/utils/sites/create-template.d.ts.map +1 -0
  124. package/dist/utils/sites/create-template.js +46 -0
  125. package/dist/utils/sites/utils.d.ts +8 -5
  126. package/dist/utils/sites/utils.d.ts.map +1 -1
  127. package/dist/utils/sites/utils.js +23 -11
  128. package/dist/utils/static-server.d.ts +3 -1
  129. package/dist/utils/static-server.d.ts.map +1 -1
  130. package/dist/utils/static-server.js +2 -0
  131. package/dist/utils/types.d.ts +137 -0
  132. package/dist/utils/types.d.ts.map +1 -1
  133. package/functions-templates/javascript/hello-world/{{name}}.mjs +13 -0
  134. package/functions-templates/javascript/scheduled-function/{{name}}.mjs +11 -0
  135. package/functions-templates/rust/hello-world/Cargo.toml +1 -1
  136. package/functions-templates/typescript/hello-world/package-lock.json +15 -15
  137. package/functions-templates/typescript/hello-world/package.json +1 -1
  138. package/functions-templates/typescript/hello-world/{{name}}.mts +14 -0
  139. package/functions-templates/typescript/scheduled-function/package.json +1 -1
  140. package/functions-templates/typescript/scheduled-function/{{name}}.mts +11 -0
  141. package/npm-shrinkwrap.json +181 -252
  142. package/package.json +9 -9
  143. package/functions-templates/javascript/hello-world/{{name}}.js +0 -17
  144. package/functions-templates/javascript/identity-signup/.netlify-function-template.mjs +0 -5
  145. package/functions-templates/javascript/identity-signup/{{name}}.js +0 -29
  146. package/functions-templates/javascript/sanity-create/.netlify-function-template.mjs +0 -5
  147. package/functions-templates/javascript/sanity-create/package.json +0 -20
  148. package/functions-templates/javascript/sanity-create/{{name}}.js +0 -72
  149. package/functions-templates/javascript/sanity-groq/.netlify-function-template.mjs +0 -5
  150. package/functions-templates/javascript/sanity-groq/package.json +0 -21
  151. package/functions-templates/javascript/sanity-groq/{{name}}.js +0 -56
  152. package/functions-templates/javascript/scheduled-function/{{name}}.js +0 -12
  153. package/functions-templates/javascript/submission-created/.netlify-function-template.mjs +0 -5
  154. package/functions-templates/javascript/submission-created/package.json +0 -19
  155. package/functions-templates/javascript/submission-created/{{name}}.js +0 -29
  156. package/functions-templates/typescript/hello-world/{{name}}.ts +0 -12
  157. package/functions-templates/typescript/scheduled-function/{{name}}.ts +0 -12
@@ -1,59 +1,18 @@
1
1
  import inquirer from 'inquirer';
2
2
  import pick from 'lodash/pick.js';
3
- // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'pars... Remove this comment to see the full error message
4
- import parseGitHubUrl from 'parse-github-url';
5
3
  import { render } from 'prettyjson';
6
- import { chalk, error, getTerminalLink, log, logJson, warn } from '../../utils/command-helpers.js';
4
+ import { v4 as uuid } from 'uuid';
5
+ import path from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+ import { chalk, error, getTerminalLink, log, logJson, warn, GitHubAPIError, } from '../../utils/command-helpers.js';
7
8
  import execa from '../../utils/execa.js';
8
9
  import getRepoData from '../../utils/get-repo-data.js';
9
10
  import { getGitHubToken } from '../../utils/init/config-github.js';
10
11
  import { configureRepo } from '../../utils/init/config.js';
11
- import { createRepo, getTemplatesFromGitHub, validateTemplate } from '../../utils/sites/utils.js';
12
+ import { deployedSiteExists, getGitHubLink, getTemplateName } from '../../utils/sites/create-template.js';
13
+ import { callLinkSite, createRepo, validateTemplate } from '../../utils/sites/utils.js';
12
14
  import { track } from '../../utils/telemetry/index.js';
13
15
  import { getSiteNameInput } from './sites-create.js';
14
- // @ts-expect-error TS(7006) FIXME: Parameter 'token' implicitly has an 'any' type.
15
- export const fetchTemplates = async (token) => {
16
- const templatesFromGithubOrg = await getTemplatesFromGitHub(token);
17
- return (
18
- // @ts-expect-error TS(18046) - 'templatesFromGithubOrg' if of type 'unknown'
19
- templatesFromGithubOrg
20
- // @ts-expect-error TS(7006) FIXME: Parameter 'repo' implicitly has an 'any' type.
21
- .filter((repo) => !repo.archived && !repo.disabled)
22
- // @ts-expect-error TS(7006) FIXME: Parameter 'template' implicitly has an 'any' type.
23
- .map((template) => ({
24
- name: template.name,
25
- sourceCodeUrl: template.html_url,
26
- slug: template.full_name,
27
- })));
28
- };
29
- // @ts-expect-error TS(7031) FIXME: Binding element 'ghToken' implicitly has an 'any' ... Remove this comment to see the full error message
30
- const getTemplateName = async ({ ghToken, options, repository }) => {
31
- if (repository) {
32
- const { repo } = parseGitHubUrl(repository);
33
- return repo || `netlify-templates/${repository}`;
34
- }
35
- if (options.url) {
36
- const urlFromOptions = new URL(options.url);
37
- return urlFromOptions.pathname.slice(1);
38
- }
39
- const templates = await fetchTemplates(ghToken);
40
- log(`Choose one of our starter templates. Netlify will create a new repo for this template in your GitHub account.`);
41
- const { templateName } = await inquirer.prompt([
42
- {
43
- type: 'list',
44
- name: 'templateName',
45
- message: 'Template:',
46
- // @ts-expect-error TS(7006) FIXME: Parameter 'template' implicitly has an 'any' type.
47
- choices: templates.map((template) => ({
48
- value: template.slug,
49
- name: template.name,
50
- })),
51
- },
52
- ]);
53
- return templateName;
54
- };
55
- // @ts-expect-error TS(7031) FIXME: Binding element 'options' implicitly has an 'any' ... Remove this comment to see the full error message
56
- const getGitHubLink = ({ options, templateName }) => options.url || `https://github.com/${templateName}`;
57
16
  export const sitesCreateTemplate = async (repository, options, command) => {
58
17
  const { api } = command.netlify;
59
18
  await command.authenticate();
@@ -79,7 +38,6 @@ export const sitesCreateTemplate = async (repository, options, command) => {
79
38
  type: 'list',
80
39
  name: 'accountSlug',
81
40
  message: 'Team:',
82
- // @ts-expect-error TS(7006) FIXME: Parameter 'account' implicitly has an 'any' type.
83
41
  choices: accounts.map((account) => ({
84
42
  value: account.slug,
85
43
  name: account.name,
@@ -92,98 +50,152 @@ export const sitesCreateTemplate = async (repository, options, command) => {
92
50
  let site;
93
51
  let repoResp;
94
52
  // Allow the user to reenter site name if selected one isn't available
95
- // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type.
96
- const inputSiteName = async (name) => {
53
+ const inputSiteName = async (name, hasExistingRepo) => {
97
54
  const { name: inputName } = await getSiteNameInput(name);
55
+ const siteName = inputName.trim();
56
+ if (siteName && (await deployedSiteExists(siteName))) {
57
+ log('A site with that name already exists');
58
+ return inputSiteName();
59
+ }
98
60
  try {
99
- const siteName = inputName.trim();
100
- // Create new repo from template
101
- repoResp = await createRepo(templateName, ghToken, siteName || templateName);
102
- // @ts-expect-error TS(18046) - 'repoResp' if of type 'unknown'
103
- if (repoResp.errors) {
104
- // @ts-expect-error TS(18046) - 'repoResp' if of type 'unknown'
105
- if (repoResp.errors[0].includes('Name already exists on this account')) {
106
- warn(`Oh no! We found already a repository with this name. It seems you have already created a template with the name ${templateName}. Please try to run the command again and provide a different name.`);
107
- // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0.
108
- await inputSiteName();
61
+ const sites = await api.listSites({ name: siteName, filter: 'all' });
62
+ const siteFoundByName = sites.find((filteredSite) => filteredSite.name === siteName);
63
+ if (siteFoundByName) {
64
+ log('A site with that name already exists on your account');
65
+ return inputSiteName();
66
+ }
67
+ }
68
+ catch (error_) {
69
+ error(error_);
70
+ }
71
+ if (!hasExistingRepo) {
72
+ try {
73
+ // Create new repo from template
74
+ let gitHubInputName = siteName || templateName;
75
+ repoResp = await createRepo(templateName, ghToken, gitHubInputName);
76
+ if (repoResp.errors && repoResp.errors[0].includes('Name already exists on this account')) {
77
+ if (gitHubInputName === templateName) {
78
+ gitHubInputName += `-${uuid().split('-')[0]}`;
79
+ repoResp = await createRepo(templateName, ghToken, gitHubInputName);
80
+ }
81
+ else {
82
+ warn(`It seems you have already created a repository with the name ${gitHubInputName}.`);
83
+ return inputSiteName();
84
+ }
85
+ }
86
+ if (!repoResp.id) {
87
+ throw new GitHubAPIError(repoResp.status, repoResp.message);
88
+ }
89
+ hasExistingRepo = true;
90
+ }
91
+ catch (error_) {
92
+ if (error_.status === '404') {
93
+ error(`Could not create repository: ${error_.message}. Ensure that your GitHub personal access token grants permission to create repositories`);
109
94
  }
110
95
  else {
111
- throw new Error(
112
- // @ts-expect-error TS(18046) - 'repoResp' if of type 'unknown'
113
- `Oops! Seems like something went wrong trying to create the repository. We're getting the following error: '${repoResp.errors[0]}'. You can try to re-run this command again or open an issue in our repository: https://github.com/netlify/cli/issues`);
96
+ error(`Something went wrong trying to create the repository. We're getting the following error: '${error_.message}'. You can try to re-run this command again or open an issue in our repository: https://github.com/netlify/cli/issues`);
114
97
  }
115
98
  }
116
- else {
117
- site = await api.createSiteInTeam({
118
- accountSlug,
119
- body: {
120
- repo: {
121
- provider: 'github',
122
- // @ts-expect-error TS(18046) - 'repoResp' if of type 'unknown'
123
- repo: repoResp.full_name,
124
- // @ts-expect-error TS(18046) - 'repoResp' if of type 'unknown'
125
- private: repoResp.private,
126
- // @ts-expect-error TS(18046) - 'repoResp' if of type 'unknown'
127
- branch: repoResp.default_branch,
128
- },
129
- name: siteName,
99
+ }
100
+ try {
101
+ site = await api.createSiteInTeam({
102
+ accountSlug,
103
+ body: {
104
+ repo: {
105
+ provider: 'github',
106
+ repo: repoResp.full_name,
107
+ private: repoResp.private,
108
+ branch: repoResp.default_branch,
130
109
  },
131
- });
132
- }
110
+ name: siteName,
111
+ },
112
+ });
133
113
  }
134
114
  catch (error_) {
135
- // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
136
- if (error_.status === 422 || error_.message === 'Duplicate repo') {
137
- warn(`${name}.netlify.app already exists or a repository named ${name} already exists on this account. Please try a different slug.`);
138
- // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0.
139
- await inputSiteName();
140
- }
141
- else {
142
- // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
143
- error(`createSiteInTeam error: ${error_.status}: ${error_.message}`);
115
+ if (error_.status === 422) {
116
+ log(`createSiteInTeam error: ${error_.status}: ${error_.message}`);
117
+ log('Cannot create a site with that name. Site name may already exist. Please try a new name.');
118
+ return inputSiteName(undefined, hasExistingRepo);
144
119
  }
120
+ error(`createSiteInTeam error: ${error_.status}: ${error_.message}`);
145
121
  }
122
+ return [site, repoResp];
146
123
  };
147
- await inputSiteName(nameFlag);
124
+ [site, repoResp] = await inputSiteName(nameFlag);
148
125
  log();
149
126
  log(chalk.greenBright.bold.underline(`Site Created`));
150
127
  log();
151
- // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
152
128
  const siteUrl = site.ssl_url || site.url;
153
129
  log(render({
154
- // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
155
130
  'Admin URL': site.admin_url,
156
131
  URL: siteUrl,
157
- // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
158
132
  'Site ID': site.id,
159
- // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
160
133
  'Repo URL': site.build_settings.repo_url,
161
134
  }));
162
135
  track('sites_createdFromTemplate', {
163
- // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
164
136
  siteId: site.id,
165
- // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
166
137
  adminUrl: site.admin_url,
167
138
  siteUrl,
168
139
  });
169
140
  const { cloneConfirm } = await inquirer.prompt({
170
141
  type: 'confirm',
171
142
  name: 'cloneConfirm',
172
- message: `Do you want to clone the repository?`,
143
+ message: `Do you want to clone the repository to your local machine?`,
173
144
  default: true,
174
145
  });
175
146
  if (cloneConfirm) {
176
147
  log();
177
- // @ts-expect-error TS(18046) - 'repoResp' if of type 'unknown'
178
- await execa('git', ['clone', repoResp.clone_url, `${repoResp.name}`]);
179
- // @ts-expect-error TS(18046) - 'repoResp' if of type 'unknown'
148
+ if (repoResp.clone_url) {
149
+ await execa('git', ['clone', repoResp.clone_url, `${repoResp.name}`]);
150
+ }
180
151
  log(`🚀 Repository cloned successfully. You can find it under the ${chalk.magenta(repoResp.name)} folder`);
152
+ const { linkConfirm } = await inquirer.prompt({
153
+ type: 'confirm',
154
+ name: 'linkConfirm',
155
+ message: `Do you want to link the cloned directory to the site?`,
156
+ default: true,
157
+ });
158
+ if (linkConfirm) {
159
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
160
+ const cliPath = path.resolve(__dirname, '../../../bin/run.js');
161
+ let stdout;
162
+ if (repoResp.name) {
163
+ stdout = await callLinkSite(cliPath, repoResp.name, '\n');
164
+ }
165
+ else {
166
+ error();
167
+ return;
168
+ }
169
+ const linkedSiteUrlRegex = /Site url:\s+(\S+)/;
170
+ const lineMatch = linkedSiteUrlRegex.exec(stdout);
171
+ const urlMatch = lineMatch ? lineMatch[1] : undefined;
172
+ if (urlMatch) {
173
+ log(`\nDirectory ${chalk.cyanBright(repoResp.name)} linked to site ${chalk.cyanBright(urlMatch)}\n`);
174
+ log(`${chalk.cyanBright.bold('cd', repoResp.name)} to use other netlify cli commands in the cloned directory.\n`);
175
+ }
176
+ else {
177
+ const linkedSiteMatch = /Site already linked to\s+(\S+)/.exec(stdout);
178
+ const linkedSiteNameMatch = linkedSiteMatch ? linkedSiteMatch[1] : undefined;
179
+ if (linkedSiteNameMatch) {
180
+ log(`\nThis directory appears to be linked to ${chalk.cyanBright(linkedSiteNameMatch)}`);
181
+ log('This can happen if you cloned the template into a subdirectory of an existing Netlify project.');
182
+ log(`You may need to move the ${chalk.cyanBright(repoResp.name)} directory out of its parent directory and then re-run the ${chalk.cyanBright('link')} command manually\n`);
183
+ }
184
+ else {
185
+ log('A problem occurred linking the site');
186
+ log('You can try again manually by running:');
187
+ log(chalk.cyanBright(`cd ${repoResp.name} && netlify link\n`));
188
+ }
189
+ }
190
+ }
191
+ else {
192
+ log('To link the cloned directory manually, run:');
193
+ log(chalk.cyanBright(`cd ${repoResp.name} && netlify link\n`));
194
+ }
181
195
  }
182
196
  if (options.withCi) {
183
197
  log('Configuring CI');
184
- // @ts-expect-error TS(2345) FIXME: Argument of type '{ workingDir: any; }' is not ass... Remove this comment to see the full error message
185
198
  const repoData = await getRepoData({ workingDir: command.workingDir });
186
- // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
187
199
  await configureRepo({ command, siteId: site.id, repoData, manual: options.manual });
188
200
  }
189
201
  if (options.json) {
@@ -1,7 +1,7 @@
1
1
  import { OptionValues } from 'commander';
2
2
  import BaseCommand from '../base-command.js';
3
- export declare const getSiteNameInput: (name: any) => Promise<{
4
- name: any;
3
+ export declare const getSiteNameInput: (name: string | undefined) => Promise<{
4
+ name: string;
5
5
  }>;
6
6
  export declare const sitesCreate: (options: OptionValues, command: BaseCommand) => Promise<undefined>;
7
7
  //# sourceMappingURL=sites-create.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sites-create.d.ts","sourceRoot":"","sources":["../../../src/commands/sites/sites-create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AASxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAI5C,eAAO,MAAM,gBAAgB;;EAe5B,CAAA;AAED,eAAO,MAAM,WAAW,YAAmB,YAAY,WAAW,WAAW,uBA4H5E,CAAA"}
1
+ {"version":3,"file":"sites-create.d.ts","sourceRoot":"","sources":["../../../src/commands/sites/sites-create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAUxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAG5C,eAAO,MAAM,gBAAgB,SAAgB,MAAM,GAAG,SAAS;UAAmB,MAAM;EAevF,CAAA;AAED,eAAO,MAAM,WAAW,YAAmB,YAAY,WAAW,WAAW,uBAuH5E,CAAA"}
@@ -6,7 +6,6 @@ import getRepoData from '../../utils/get-repo-data.js';
6
6
  import { configureRepo } from '../../utils/init/config.js';
7
7
  import { track } from '../../utils/telemetry/index.js';
8
8
  import { link } from '../link/link.js';
9
- // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type.
10
9
  export const getSiteNameInput = async (name) => {
11
10
  if (!name) {
12
11
  const { name: nameInput } = await inquirer.prompt([
@@ -17,7 +16,7 @@ export const getSiteNameInput = async (name) => {
17
16
  validate: (input) => /^[a-zA-Z\d-]+$/.test(input || undefined) || 'Only alphanumeric characters and hyphens are allowed',
18
17
  },
19
18
  ]);
20
- name = nameInput || '';
19
+ name = typeof nameInput === 'string' ? nameInput : '';
21
20
  }
22
21
  return { name };
23
22
  };
@@ -32,7 +31,6 @@ export const sitesCreate = async (options, command) => {
32
31
  type: 'list',
33
32
  name: 'accountSlug',
34
33
  message: 'Team:',
35
- // @ts-expect-error TS(7006) FIXME: Parameter 'account' implicitly has an 'any' type.
36
34
  choices: accounts.map((account) => ({
37
35
  value: account.slug,
38
36
  name: account.name,
@@ -43,12 +41,10 @@ export const sitesCreate = async (options, command) => {
43
41
  }
44
42
  let site;
45
43
  // Allow the user to reenter site name if selected one isn't available
46
- // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type.
47
44
  const inputSiteName = async (name) => {
48
45
  const { name: siteName } = await getSiteNameInput(name);
49
46
  const body = {};
50
47
  if (typeof siteName === 'string') {
51
- // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type '{}'.
52
48
  body.name = siteName.trim();
53
49
  }
54
50
  try {
@@ -58,14 +54,11 @@ export const sitesCreate = async (options, command) => {
58
54
  });
59
55
  }
60
56
  catch (error_) {
61
- // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
62
57
  if (error_.status === 422) {
63
58
  warn(`${siteName}.netlify.app already exists. Please try a different slug.`);
64
- // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0.
65
59
  await inputSiteName();
66
60
  }
67
61
  else {
68
- // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
69
62
  error(`createSiteInTeam error: ${error_.status}: ${error_.message}`);
70
63
  }
71
64
  }
@@ -92,7 +85,6 @@ export const sitesCreate = async (options, command) => {
92
85
  });
93
86
  if (options.withCi) {
94
87
  log('Configuring CI');
95
- // @ts-expect-error TS(2345) FIXME: Argument of type '{ workingDir: any; }' is not ass... Remove this comment to see the full error message
96
88
  const repoData = await getRepoData({ workingDir: command.workingDir });
97
89
  // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
98
90
  await configureRepo({ command, siteId: site.id, repoData, manual: options.manual });
@@ -1 +1 @@
1
- {"version":3,"file":"sites-delete.d.ts","sourceRoot":"","sources":["../../../src/commands/sites/sites-delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,eAAO,MAAM,WAAW,WAAkB,MAAM,WAAW,YAAY,WAAW,WAAW,kBA+E5F,CAAA"}
1
+ {"version":3,"file":"sites-delete.d.ts","sourceRoot":"","sources":["../../../src/commands/sites/sites-delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,eAAO,MAAM,WAAW,WAAkB,MAAM,WAAW,YAAY,WAAW,WAAW,kBA8E5F,CAAA"}
@@ -11,10 +11,12 @@ export const sitesDelete = async (siteId, options, command) => {
11
11
  siteData = await api.getSite({ siteId });
12
12
  }
13
13
  catch (error_) {
14
- // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
15
14
  if (error_.status === 404) {
16
15
  error(`No site with id ${siteId} found. Please verify the siteId & try again.`);
17
16
  }
17
+ else {
18
+ error(error_);
19
+ }
18
20
  }
19
21
  if (!siteData) {
20
22
  error(`Unable to process site`);
@@ -63,12 +65,10 @@ export const sitesDelete = async (siteId, options, command) => {
63
65
  await api.deleteSite({ site_id: siteId });
64
66
  }
65
67
  catch (error_) {
66
- // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
67
68
  if (error_.status === 404) {
68
69
  error(`No site with id ${siteId} found. Please verify the siteId & try again.`);
69
70
  }
70
71
  else {
71
- // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
72
72
  error(`Delete Site error: ${error_.status}: ${error_.message}`);
73
73
  }
74
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sites-list.d.ts","sourceRoot":"","sources":["../../../src/commands/sites/sites-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAKxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,eAAO,MAAM,SAAS,YAAmB,YAAY,WAAW,WAAW,+BAmE1E,CAAA"}
1
+ {"version":3,"file":"sites-list.d.ts","sourceRoot":"","sources":["../../../src/commands/sites/sites-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAMxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,eAAO,MAAM,SAAS,YAAmB,YAAY,WAAW,WAAW,+BA+D1E,CAAA"}
@@ -15,7 +15,6 @@ export const sitesList = async (options, command) => {
15
15
  stopSpinner({ spinner });
16
16
  }
17
17
  if (sites && sites.length !== 0) {
18
- // @ts-expect-error TS(7006) FIXME: Parameter 'site' implicitly has an 'any' type.
19
18
  const logSites = sites.map((site) => {
20
19
  const siteInfo = {
21
20
  id: site.id,
@@ -24,16 +23,14 @@ export const sitesList = async (options, command) => {
24
23
  account_name: site.account_name,
25
24
  };
26
25
  if (site.build_settings && site.build_settings.repo_url) {
27
- // @ts-expect-error TS(2339) FIXME: Property 'repo_url' does not exist on type '{ id: ... Remove this comment to see the full error message
28
26
  siteInfo.repo_url = site.build_settings.repo_url;
29
27
  }
30
28
  return siteInfo;
31
29
  });
32
30
  // Json response for piping commands
33
31
  if (options.json) {
34
- // @ts-expect-error TS(7006) FIXME: Parameter 'site' implicitly has an 'any' type.
35
32
  const redactedSites = sites.map((site) => {
36
- if (site && site.build_settings) {
33
+ if (site?.build_settings?.env) {
37
34
  delete site.build_settings.env;
38
35
  }
39
36
  return site;
@@ -48,7 +45,6 @@ export const sitesList = async (options, command) => {
48
45
 
49
46
  Count: ${logSites.length}
50
47
  `);
51
- // @ts-expect-error TS(7006) FIXME: Parameter 'logSite' implicitly has an 'any' type.
52
48
  logSites.forEach((logSite) => {
53
49
  log(`${chalk.greenBright(logSite.name)} - ${logSite.id}`);
54
50
  log(` ${chalk.whiteBright.bold('url:')} ${chalk.yellowBright(logSite.ssl_url)}`);
@@ -1 +1 @@
1
- {"version":3,"file":"sites.d.ts","sourceRoot":"","sources":["../../../src/commands/sites/sites.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAkB5C,eAAO,MAAM,8BAA8B,YAAa,WAAW,SAsBlE,CAAA;AAED,eAAO,MAAM,wBAAwB,YAAa,WAAW,SAoB5D,CAAA;AAED,eAAO,MAAM,kBAAkB,YAAa,WAAW,gBA6BtD,CAAA"}
1
+ {"version":3,"file":"sites.d.ts","sourceRoot":"","sources":["../../../src/commands/sites/sites.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAkB5C,eAAO,MAAM,8BAA8B,YAAa,WAAW,SAsBlE,CAAA;AAED,eAAO,MAAM,wBAAwB,YAAa,WAAW,SAoB5D,CAAA;AAED,eAAO,MAAM,kBAAkB,YAAa,WAAW,gBA4BtD,CAAA"}
@@ -63,7 +63,6 @@ export const createSitesCommand = (program) => {
63
63
  .command('sites:delete')
64
64
  .description('Delete a site\nThis command will permanently delete the site on Netlify. Use with caution.')
65
65
  .argument('<siteId>', 'Site ID to delete.')
66
- .option('-f, --force', 'delete without prompting (useful for CI)')
67
66
  .addExamples(['netlify sites:delete 1234-3262-1211'])
68
67
  .action(async (siteId, options, command) => {
69
68
  const { sitesDelete } = await import('./sites-delete.js');
@@ -4,7 +4,6 @@ import { chalk, error, exit, getToken, log, logJson, warn } from '../../utils/co
4
4
  export const status = async (options, command) => {
5
5
  const { api, globalConfig, site, siteInfo } = command.netlify;
6
6
  const current = globalConfig.get('userId');
7
- // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0.
8
7
  const [accessToken] = await getToken();
9
8
  if (!accessToken) {
10
9
  log(`Not logged in. Please log in to see site status.`);
@@ -24,10 +23,12 @@ export const status = async (options, command) => {
24
23
  [accounts, user] = await Promise.all([api.listAccountsForUser(), api.getCurrentUser()]);
25
24
  }
26
25
  catch (error_) {
27
- // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
28
26
  if (error_.status === 401) {
29
27
  error('Your session has expired. Please try to re-authenticate by running `netlify logout` and `netlify login`.');
30
28
  }
29
+ else {
30
+ error(error_);
31
+ }
31
32
  }
32
33
  const ghuser = command.netlify.globalConfig.get(`users.${current}.auth.github.user`);
33
34
  const accountData = {
@@ -12,10 +12,10 @@ export const unlink = async (options, command) => {
12
12
  await track('sites_unlinked', {
13
13
  siteId: siteData.id || siteId,
14
14
  });
15
- if (site) {
15
+ if (site && site.configPath) {
16
16
  log(`Unlinked ${site.configPath} from ${siteData ? siteData.name : siteId}`);
17
17
  }
18
18
  else {
19
- log('Unlinked site');
19
+ log(`Unlinked from ${siteData ? siteData.name : siteId}`);
20
20
  }
21
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../../src/commands/watch/watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAMxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAoD5C,eAAO,MAAM,KAAK,YAAmB,YAAY,WAAW,WAAW,kBA6DtE,CAAA"}
1
+ {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../../src/commands/watch/watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAMxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAoD5C,eAAO,MAAM,KAAK,YAAmB,YAAY,WAAW,WAAW,kBA4DtE,CAAA"}
@@ -94,7 +94,6 @@ export const watch = async (options, command) => {
94
94
  console.timeEnd('Deploy time');
95
95
  }
96
96
  catch (error_) {
97
- // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message
98
97
  error(error_);
99
98
  }
100
99
  };
package/dist/lib/api.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { SiteInfo } from '../utils/types.js';
1
2
  export declare const cancelDeploy: ({ api, deployId }: {
2
3
  api: any;
3
4
  deployId: any;
@@ -5,5 +6,5 @@ export declare const cancelDeploy: ({ api, deployId }: {
5
6
  export declare const listSites: ({ api, options }: {
6
7
  api: any;
7
8
  options: any;
8
- }) => any;
9
+ }) => SiteInfo[];
9
10
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY;;;mBAOxB,CAAA;AAMD,eAAO,MAAM,SAAS;;;SAQrB,CAAA"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAG5C,eAAO,MAAM,YAAY;;;mBAOxB,CAAA;AAOD,eAAO,MAAM,SAAS;;;MAA6B,QAAQ,EAQ1D,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"exec-fetcher.d.ts","sourceRoot":"","sources":["../../src/lib/exec-fetcher.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,WAAW;;SAAiE,CAAA;AAsBzF,eAAO,MAAM,wBAAwB;;;;;;;sBA+CpC,CAAA;AAED,eAAO,MAAM,OAAO,0HASnB,CAAA;AAED;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,kBAAkB;;;;;;mBA6C9B,CAAA"}
1
+ {"version":3,"file":"exec-fetcher.d.ts","sourceRoot":"","sources":["../../src/lib/exec-fetcher.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,WAAW;;SAAiE,CAAA;AAsBzF,eAAO,MAAM,wBAAwB;;;;;;;sBA+CpC,CAAA;AAED,eAAO,MAAM,OAAO,0HASnB,CAAA;AAED;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,kBAAkB;;;;;;mBA2C9B,CAAA"}
@@ -126,7 +126,6 @@ export const fetchLatestVersion = async ({ destination, execName, extension, lat
126
126
  Please open up an issue on our CLI repository so that we can support it:
127
127
  ${issueLink}`);
128
128
  }
129
- // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message
130
129
  error(error_);
131
130
  }
132
131
  };