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.
- package/bin/run.js +4 -2
- package/dist/commands/addons/addons-config.d.ts.map +1 -1
- package/dist/commands/addons/addons-config.js +0 -1
- package/dist/commands/addons/addons-create.d.ts.map +1 -1
- package/dist/commands/addons/addons-create.js +0 -1
- package/dist/commands/addons/addons-delete.d.ts.map +1 -1
- package/dist/commands/addons/addons-delete.js +0 -1
- package/dist/commands/addons/addons.d.ts.map +1 -1
- package/dist/commands/addons/addons.js +0 -1
- package/dist/commands/api/api.d.ts.map +1 -1
- package/dist/commands/api/api.js +0 -1
- package/dist/commands/base-command.d.ts +2 -2
- package/dist/commands/base-command.d.ts.map +1 -1
- package/dist/commands/base-command.js +2 -2
- package/dist/commands/blobs/blobs-delete.d.ts.map +1 -1
- package/dist/commands/blobs/blobs-delete.js +7 -1
- package/dist/commands/blobs/blobs-set.d.ts +1 -0
- package/dist/commands/blobs/blobs-set.d.ts.map +1 -1
- package/dist/commands/blobs/blobs-set.js +10 -2
- package/dist/commands/build/build.d.ts.map +1 -1
- package/dist/commands/build/build.js +0 -1
- package/dist/commands/completion/completion.d.ts.map +1 -1
- package/dist/commands/completion/completion.js +35 -2
- package/dist/commands/deploy/deploy.d.ts.map +1 -1
- package/dist/commands/deploy/deploy.js +3 -5
- package/dist/commands/deploy/index.d.ts.map +1 -1
- package/dist/commands/deploy/index.js +4 -3
- package/dist/commands/env/env-clone.d.ts.map +1 -1
- package/dist/commands/env/env-clone.js +12 -3
- package/dist/commands/env/env-set.d.ts.map +1 -1
- package/dist/commands/env/env-set.js +8 -3
- package/dist/commands/env/env-unset.d.ts.map +1 -1
- package/dist/commands/env/env-unset.js +7 -3
- package/dist/commands/functions/functions-create.d.ts.map +1 -1
- package/dist/commands/functions/functions-create.js +2 -5
- package/dist/commands/functions/functions-invoke.d.ts.map +1 -1
- package/dist/commands/functions/functions-invoke.js +0 -1
- package/dist/commands/init/index.d.ts.map +1 -1
- package/dist/commands/init/index.js +0 -1
- package/dist/commands/integration/deploy.d.ts.map +1 -1
- package/dist/commands/integration/deploy.js +13 -24
- package/dist/commands/link/link.d.ts.map +1 -1
- package/dist/commands/link/link.js +8 -21
- package/dist/commands/lm/lm-setup.d.ts.map +1 -1
- package/dist/commands/lm/lm-setup.js +0 -1
- package/dist/commands/login/login.d.ts.map +1 -1
- package/dist/commands/login/login.js +0 -2
- package/dist/commands/logout/logout.d.ts.map +1 -1
- package/dist/commands/logout/logout.js +0 -1
- package/dist/commands/logs/build.d.ts.map +1 -1
- package/dist/commands/logs/build.js +4 -0
- package/dist/commands/main.d.ts +34 -0
- package/dist/commands/main.d.ts.map +1 -1
- package/dist/commands/main.js +36 -6
- package/dist/commands/sites/sites-create-template.d.ts +2 -2
- package/dist/commands/sites/sites-create-template.d.ts.map +1 -1
- package/dist/commands/sites/sites-create-template.js +113 -101
- package/dist/commands/sites/sites-create.d.ts +2 -2
- package/dist/commands/sites/sites-create.d.ts.map +1 -1
- package/dist/commands/sites/sites-create.js +1 -9
- package/dist/commands/sites/sites-delete.d.ts.map +1 -1
- package/dist/commands/sites/sites-delete.js +3 -3
- package/dist/commands/sites/sites-list.d.ts.map +1 -1
- package/dist/commands/sites/sites-list.js +1 -5
- package/dist/commands/sites/sites.d.ts.map +1 -1
- package/dist/commands/sites/sites.js +0 -1
- package/dist/commands/status/status.js +3 -2
- package/dist/commands/unlink/unlink.js +2 -2
- package/dist/commands/watch/watch.d.ts.map +1 -1
- package/dist/commands/watch/watch.js +0 -1
- package/dist/lib/api.d.ts +2 -1
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/exec-fetcher.d.ts.map +1 -1
- package/dist/lib/exec-fetcher.js +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/addons/prepare.d.ts.map +1 -1
- package/dist/utils/addons/prepare.js +1 -5
- package/dist/utils/command-helpers.d.ts +37 -6
- package/dist/utils/command-helpers.d.ts.map +1 -1
- package/dist/utils/command-helpers.js +21 -9
- package/dist/utils/dev.d.ts.map +1 -1
- package/dist/utils/dev.js +0 -2
- package/dist/utils/framework-server.d.ts.map +1 -1
- package/dist/utils/framework-server.js +2 -3
- package/dist/utils/get-repo-data.d.ts +2 -2
- package/dist/utils/get-repo-data.d.ts.map +1 -1
- package/dist/utils/get-repo-data.js +0 -1
- package/dist/utils/get-site.d.ts.map +1 -1
- package/dist/utils/get-site.js +7 -2
- package/dist/utils/gh-auth.js +1 -1
- package/dist/utils/hooks/requires-site-info.d.ts.map +1 -1
- package/dist/utils/hooks/requires-site-info.js +0 -3
- package/dist/utils/prompts/blob-delete-prompts.d.ts +2 -0
- package/dist/utils/prompts/blob-delete-prompts.d.ts.map +1 -0
- package/dist/utils/prompts/blob-delete-prompts.js +11 -0
- package/dist/utils/prompts/blob-set-prompt.d.ts +2 -0
- package/dist/utils/prompts/blob-set-prompt.d.ts.map +1 -0
- package/dist/utils/prompts/blob-set-prompt.js +11 -0
- package/dist/utils/prompts/confirm-prompt.d.ts +2 -0
- package/dist/utils/prompts/confirm-prompt.d.ts.map +1 -0
- package/dist/utils/prompts/confirm-prompt.js +20 -0
- package/dist/utils/prompts/env-clone-prompt.d.ts +11 -0
- package/dist/utils/prompts/env-clone-prompt.d.ts.map +1 -0
- package/dist/utils/prompts/env-clone-prompt.js +27 -0
- package/dist/utils/prompts/env-set-prompts.d.ts +2 -0
- package/dist/utils/prompts/env-set-prompts.d.ts.map +1 -0
- package/dist/utils/prompts/env-set-prompts.js +11 -0
- package/dist/utils/prompts/env-unset-prompts.d.ts +8 -0
- package/dist/utils/prompts/env-unset-prompts.d.ts.map +1 -0
- package/dist/utils/prompts/env-unset-prompts.js +17 -0
- package/dist/utils/prompts/prompt-messages.d.ts +25 -0
- package/dist/utils/prompts/prompt-messages.d.ts.map +1 -0
- package/dist/utils/prompts/prompt-messages.js +25 -0
- package/dist/utils/run-build.d.ts +2 -0
- package/dist/utils/run-build.d.ts.map +1 -1
- package/dist/utils/run-program.d.ts +3 -0
- package/dist/utils/run-program.d.ts.map +1 -0
- package/dist/utils/run-program.js +12 -0
- package/dist/utils/scripted-commands.d.ts +3 -0
- package/dist/utils/scripted-commands.d.ts.map +1 -0
- package/dist/utils/scripted-commands.js +17 -0
- package/dist/utils/sites/create-template.d.ts +14 -0
- package/dist/utils/sites/create-template.d.ts.map +1 -0
- package/dist/utils/sites/create-template.js +46 -0
- package/dist/utils/sites/utils.d.ts +8 -5
- package/dist/utils/sites/utils.d.ts.map +1 -1
- package/dist/utils/sites/utils.js +23 -11
- package/dist/utils/static-server.d.ts +3 -1
- package/dist/utils/static-server.d.ts.map +1 -1
- package/dist/utils/static-server.js +2 -0
- package/dist/utils/types.d.ts +137 -0
- package/dist/utils/types.d.ts.map +1 -1
- package/functions-templates/javascript/hello-world/{{name}}.mjs +13 -0
- package/functions-templates/javascript/scheduled-function/{{name}}.mjs +11 -0
- package/functions-templates/rust/hello-world/Cargo.toml +1 -1
- package/functions-templates/typescript/hello-world/package-lock.json +15 -15
- package/functions-templates/typescript/hello-world/package.json +1 -1
- package/functions-templates/typescript/hello-world/{{name}}.mts +14 -0
- package/functions-templates/typescript/scheduled-function/package.json +1 -1
- package/functions-templates/typescript/scheduled-function/{{name}}.mts +11 -0
- package/npm-shrinkwrap.json +181 -252
- package/package.json +9 -9
- package/functions-templates/javascript/hello-world/{{name}}.js +0 -17
- package/functions-templates/javascript/identity-signup/.netlify-function-template.mjs +0 -5
- package/functions-templates/javascript/identity-signup/{{name}}.js +0 -29
- package/functions-templates/javascript/sanity-create/.netlify-function-template.mjs +0 -5
- package/functions-templates/javascript/sanity-create/package.json +0 -20
- package/functions-templates/javascript/sanity-create/{{name}}.js +0 -72
- package/functions-templates/javascript/sanity-groq/.netlify-function-template.mjs +0 -5
- package/functions-templates/javascript/sanity-groq/package.json +0 -21
- package/functions-templates/javascript/sanity-groq/{{name}}.js +0 -56
- package/functions-templates/javascript/scheduled-function/{{name}}.js +0 -12
- package/functions-templates/javascript/submission-created/.netlify-function-template.mjs +0 -5
- package/functions-templates/javascript/submission-created/package.json +0 -19
- package/functions-templates/javascript/submission-created/{{name}}.js +0 -29
- package/functions-templates/typescript/hello-world/{{name}}.ts +0 -12
- 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 {
|
|
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 {
|
|
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
|
-
|
|
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
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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:
|
|
4
|
-
name:
|
|
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;
|
|
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,
|
|
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;
|
|
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
|
|
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,
|
|
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(
|
|
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,
|
|
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
|
-
}) =>
|
|
9
|
+
}) => SiteInfo[];
|
|
9
10
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/lib/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"
|
|
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;;;;;;
|
|
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"}
|
package/dist/lib/exec-fetcher.js
CHANGED
|
@@ -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
|
};
|