netlify-cli 17.37.2 → 17.38.1-rc-ds
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/base-command.d.ts.map +1 -1
- package/dist/commands/base-command.js +5 -3
- 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/completion/completion.d.ts.map +1 -1
- package/dist/commands/completion/completion.js +7 -0
- package/dist/commands/deploy/deploy.js +2 -2
- 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/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 +11 -20
- package/dist/commands/main.d.ts +30 -0
- package/dist/commands/main.d.ts.map +1 -1
- package/dist/commands/main.js +35 -10
- package/dist/commands/sites/sites-create-template.d.ts +2 -3
- package/dist/commands/sites/sites-create-template.d.ts.map +1 -1
- package/dist/commands/sites/sites-create-template.js +114 -94
- package/dist/commands/sites/sites-create.d.ts.map +1 -1
- package/dist/commands/sites/sites-create.js +1 -2
- package/dist/commands/sites/sites.d.ts.map +1 -1
- package/dist/commands/sites/sites.js +0 -1
- package/dist/commands/status/status.d.ts.map +1 -1
- package/dist/commands/status/status.js +2 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/addons/prepare.d.ts +0 -21
- package/dist/utils/addons/prepare.d.ts.map +1 -1
- package/dist/utils/addons/prepare.js +1 -85
- package/dist/utils/command-helpers.d.ts +16 -0
- package/dist/utils/command-helpers.d.ts.map +1 -1
- package/dist/utils/command-helpers.js +7 -0
- package/dist/utils/framework-server.d.ts.map +1 -1
- package/dist/utils/framework-server.js +3 -3
- package/dist/utils/gh-auth.js +1 -1
- package/dist/utils/headers.js +1 -1
- 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/redirects.js +1 -1
- package/dist/utils/run-build.d.ts +2 -0
- package/dist/utils/run-build.d.ts.map +1 -1
- package/dist/utils/run-build.js +6 -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 -6
- package/dist/utils/sites/utils.d.ts.map +1 -1
- package/dist/utils/sites/utils.js +10 -4
- 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 +19 -12
- 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/package.json +1 -1
- 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 +31 -31
- package/functions-templates/typescript/hello-world/package.json +2 -2
- package/functions-templates/typescript/hello-world/{{name}}.mts +14 -0
- package/functions-templates/typescript/scheduled-function/package.json +2 -2
- package/functions-templates/typescript/scheduled-function/{{name}}.mts +11 -0
- package/npm-shrinkwrap.json +951 -1083
- package/package.json +16 -19
- package/dist/commands/addons/addons-auth.d.ts +0 -4
- package/dist/commands/addons/addons-auth.d.ts.map +0 -1
- package/dist/commands/addons/addons-auth.js +0 -22
- package/dist/commands/addons/addons-config.d.ts +0 -4
- package/dist/commands/addons/addons-config.d.ts.map +0 -1
- package/dist/commands/addons/addons-config.js +0 -144
- package/dist/commands/addons/addons-create.d.ts +0 -4
- package/dist/commands/addons/addons-create.d.ts.map +0 -1
- package/dist/commands/addons/addons-create.js +0 -89
- package/dist/commands/addons/addons-delete.d.ts +0 -4
- package/dist/commands/addons/addons-delete.d.ts.map +0 -1
- package/dist/commands/addons/addons-delete.js +0 -32
- package/dist/commands/addons/addons-list.d.ts +0 -4
- package/dist/commands/addons/addons-list.d.ts.map +0 -1
- package/dist/commands/addons/addons-list.js +0 -33
- package/dist/commands/addons/addons.d.ts +0 -3
- package/dist/commands/addons/addons.d.ts.map +0 -1
- package/dist/commands/addons/addons.js +0 -68
- package/dist/commands/addons/index.d.ts +0 -2
- package/dist/commands/addons/index.d.ts.map +0 -1
- package/dist/commands/addons/index.js +0 -1
- package/dist/commands/lm/index.d.ts +0 -2
- package/dist/commands/lm/index.d.ts.map +0 -1
- package/dist/commands/lm/index.js +0 -1
- package/dist/commands/lm/lm-info.d.ts +0 -5
- package/dist/commands/lm/lm-info.d.ts.map +0 -1
- package/dist/commands/lm/lm-info.js +0 -25
- package/dist/commands/lm/lm-install.d.ts +0 -3
- package/dist/commands/lm/lm-install.d.ts.map +0 -1
- package/dist/commands/lm/lm-install.js +0 -8
- package/dist/commands/lm/lm-setup.d.ts +0 -4
- package/dist/commands/lm/lm-setup.d.ts.map +0 -1
- package/dist/commands/lm/lm-setup.js +0 -79
- package/dist/commands/lm/lm-uninstall.d.ts +0 -5
- package/dist/commands/lm/lm-uninstall.d.ts.map +0 -1
- package/dist/commands/lm/lm-uninstall.js +0 -7
- package/dist/commands/lm/lm.d.ts +0 -3
- package/dist/commands/lm/lm.d.ts.map +0 -1
- package/dist/commands/lm/lm.js +0 -46
- package/dist/utils/addons/render.d.ts +0 -3
- package/dist/utils/addons/render.d.ts.map +0 -1
- package/dist/utils/addons/render.js +0 -36
- package/dist/utils/lm/install.d.ts +0 -11
- package/dist/utils/lm/install.d.ts.map +0 -1
- package/dist/utils/lm/install.js +0 -248
- package/dist/utils/lm/requirements.d.ts +0 -5
- package/dist/utils/lm/requirements.d.ts.map +0 -1
- package/dist/utils/lm/requirements.js +0 -56
- package/dist/utils/lm/steps.d.ts +0 -17
- package/dist/utils/lm/steps.d.ts.map +0 -1
- package/dist/utils/lm/steps.js +0 -35
- package/dist/utils/lm/ui.d.ts +0 -5
- package/dist/utils/lm/ui.d.ts.map +0 -1
- package/dist/utils/lm/ui.js +0 -17
- 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
package/dist/commands/main.js
CHANGED
|
@@ -9,7 +9,6 @@ import execa from '../utils/execa.js';
|
|
|
9
9
|
import getGlobalConfig from '../utils/get-global-config.js';
|
|
10
10
|
import getPackageJson from '../utils/get-package-json.js';
|
|
11
11
|
import { track, reportError } from '../utils/telemetry/index.js';
|
|
12
|
-
import { createAddonsCommand } from './addons/index.js';
|
|
13
12
|
import { createApiCommand } from './api/index.js';
|
|
14
13
|
import BaseCommand from './base-command.js';
|
|
15
14
|
import { createBlobsCommand } from './blobs/blobs.js';
|
|
@@ -22,7 +21,6 @@ import { createFunctionsCommand } from './functions/index.js';
|
|
|
22
21
|
import { createInitCommand } from './init/index.js';
|
|
23
22
|
import { createIntegrationCommand } from './integration/index.js';
|
|
24
23
|
import { createLinkCommand } from './link/index.js';
|
|
25
|
-
import { createLmCommand } from './lm/index.js';
|
|
26
24
|
import { createLoginCommand } from './login/index.js';
|
|
27
25
|
import { createLogoutCommand } from './logout/index.js';
|
|
28
26
|
import { createLogsCommand } from './logs/index.js';
|
|
@@ -35,13 +33,35 @@ import { createSwitchCommand } from './switch/index.js';
|
|
|
35
33
|
import { createUnlinkCommand } from './unlink/index.js';
|
|
36
34
|
import { createWatchCommand } from './watch/index.js';
|
|
37
35
|
const SUGGESTION_TIMEOUT = 1e4;
|
|
36
|
+
// These commands run with the --force flag in non-interactive and CI environments
|
|
37
|
+
export const CI_FORCED_COMMANDS = {
|
|
38
|
+
'env:set': { options: '--force', description: 'Bypasses prompts & Force the command to run.' },
|
|
39
|
+
'env:unset': { options: '--force', description: 'Bypasses prompts & Force the command to run.' },
|
|
40
|
+
'env:clone': { options: '--force', description: 'Bypasses prompts & Force the command to run.' },
|
|
41
|
+
'blobs:set': { options: '--force', description: 'Bypasses prompts & Force the command to run.' },
|
|
42
|
+
'blobs:delete': { options: '--force', description: 'Bypasses prompts & Force the command to run.' },
|
|
43
|
+
init: { options: '--force', description: 'Reinitialize CI hooks if the linked site is already configured to use CI' },
|
|
44
|
+
'sites:delete': { options: '-f, --force', description: 'Delete without prompting (useful for CI).' },
|
|
45
|
+
};
|
|
38
46
|
process.on('uncaughtException', async (err) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
if ('code' in err && err.code === 'EADDRINUSE') {
|
|
48
|
+
error(`${chalk.red(`Port ${err.port} is already in use`)}\n\n` +
|
|
49
|
+
`Your serverless functions might be initializing a server\n` +
|
|
50
|
+
`to listen on specific port without properly closing it.\n\n` +
|
|
51
|
+
`This behavior is generally not advised\n` +
|
|
52
|
+
`To resolve this issue, try the following:\n` +
|
|
53
|
+
`1. If you NEED your serverless function to listen on a specific port,\n` +
|
|
54
|
+
`use a randomly assigned port as we do not officially support this.\n` +
|
|
55
|
+
`2. Review your serverless functions for lingering server connections, close them\n` +
|
|
56
|
+
`3. Check if any other applications are using port ${err.port}\n`, { exit: false });
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
error(`${chalk.red('Netlify CLI has terminated unexpectedly')}\nThis is a problem with the Netlify CLI, not with your application.\nIf you recently updated the CLI, consider reverting to an older version by running:\n\n${chalk.bold('npm install -g netlify-cli@VERSION')}\n\nYou can use any version from ${chalk.underline('https://ntl.fyi/cli-versions')}.\n\nPlease report this problem at ${chalk.underline('https://ntl.fyi/cli-error')} including the error details below.\n`, { exit: false });
|
|
60
|
+
const systemInfo = await getSystemInfo();
|
|
61
|
+
console.log(chalk.dim(err.stack || err));
|
|
62
|
+
console.log(chalk.dim(systemInfo));
|
|
63
|
+
reportError(err, { severity: 'error' });
|
|
64
|
+
}
|
|
45
65
|
process.exit(1);
|
|
46
66
|
});
|
|
47
67
|
const getSystemInfo = () => envinfo.run({
|
|
@@ -147,7 +167,6 @@ const mainCommand = async function (options, command) {
|
|
|
147
167
|
export const createMainCommand = () => {
|
|
148
168
|
const program = new BaseCommand('netlify');
|
|
149
169
|
// register all the commands
|
|
150
|
-
createAddonsCommand(program);
|
|
151
170
|
createApiCommand(program);
|
|
152
171
|
createBlobsCommand(program);
|
|
153
172
|
createBuildCommand(program);
|
|
@@ -160,7 +179,6 @@ export const createMainCommand = () => {
|
|
|
160
179
|
createInitCommand(program);
|
|
161
180
|
createIntegrationCommand(program);
|
|
162
181
|
createLinkCommand(program);
|
|
163
|
-
createLmCommand(program);
|
|
164
182
|
createLoginCommand(program);
|
|
165
183
|
createLogoutCommand(program);
|
|
166
184
|
createOpenCommand(program);
|
|
@@ -188,5 +206,12 @@ export const createMainCommand = () => {
|
|
|
188
206
|
},
|
|
189
207
|
})
|
|
190
208
|
.action(mainCommand);
|
|
209
|
+
program.commands.forEach((cmd) => {
|
|
210
|
+
const cmdName = cmd.name();
|
|
211
|
+
if (cmdName in CI_FORCED_COMMANDS) {
|
|
212
|
+
const { description, options } = CI_FORCED_COMMANDS[cmdName];
|
|
213
|
+
cmd.option(options, description);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
191
216
|
return program;
|
|
192
217
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { OptionValues } from 'commander';
|
|
2
|
+
import { SiteInfo } from '../../utils/types.js';
|
|
2
3
|
import BaseCommand from '../base-command.js';
|
|
3
|
-
|
|
4
|
-
export declare const fetchTemplates: (token: string) => Promise<Template[]>;
|
|
5
|
-
export declare const sitesCreateTemplate: (repository: string, options: OptionValues, command: BaseCommand) => Promise<undefined>;
|
|
4
|
+
export declare const sitesCreateTemplate: (repository: string, options: OptionValues, command: BaseCommand) => Promise<SiteInfo | undefined>;
|
|
6
5
|
//# sourceMappingURL=sites-create-template.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sites-create-template.d.ts","sourceRoot":"","sources":["../../../src/commands/sites/sites-create-template.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sites-create-template.d.ts","sourceRoot":"","sources":["../../../src/commands/sites/sites-create-template.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAwBxC,OAAO,EAAW,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAI5C,eAAO,MAAM,mBAAmB,eAAsB,MAAM,WAAW,YAAY,WAAW,WAAW,kCA6PxG,CAAA"}
|
|
@@ -1,55 +1,20 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
1
3
|
import inquirer from 'inquirer';
|
|
2
4
|
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
5
|
import { render } from 'prettyjson';
|
|
6
|
-
import {
|
|
6
|
+
import { v4 as uuid } from 'uuid';
|
|
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
|
-
export const fetchTemplates = async (token) => {
|
|
15
|
-
const templatesFromGithubOrg = await getTemplatesFromGitHub(token);
|
|
16
|
-
return templatesFromGithubOrg
|
|
17
|
-
.filter((repo) => !repo.archived && !repo.disabled)
|
|
18
|
-
.map((template) => ({
|
|
19
|
-
name: template.name,
|
|
20
|
-
sourceCodeUrl: template.html_url,
|
|
21
|
-
slug: template.full_name,
|
|
22
|
-
}));
|
|
23
|
-
};
|
|
24
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'ghToken' implicitly has an 'any' ... Remove this comment to see the full error message
|
|
25
|
-
const getTemplateName = async ({ ghToken, options, repository }) => {
|
|
26
|
-
if (repository) {
|
|
27
|
-
const { repo } = parseGitHubUrl(repository);
|
|
28
|
-
return repo || `netlify-templates/${repository}`;
|
|
29
|
-
}
|
|
30
|
-
if (options.url) {
|
|
31
|
-
const urlFromOptions = new URL(options.url);
|
|
32
|
-
return urlFromOptions.pathname.slice(1);
|
|
33
|
-
}
|
|
34
|
-
const templates = await fetchTemplates(ghToken);
|
|
35
|
-
log(`Choose one of our starter templates. Netlify will create a new repo for this template in your GitHub account.`);
|
|
36
|
-
const { templateName } = await inquirer.prompt([
|
|
37
|
-
{
|
|
38
|
-
type: 'list',
|
|
39
|
-
name: 'templateName',
|
|
40
|
-
message: 'Template:',
|
|
41
|
-
choices: templates.map((template) => ({
|
|
42
|
-
value: template.slug,
|
|
43
|
-
name: template.name,
|
|
44
|
-
})),
|
|
45
|
-
},
|
|
46
|
-
]);
|
|
47
|
-
return templateName;
|
|
48
|
-
};
|
|
49
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'options' implicitly has an 'any' ... Remove this comment to see the full error message
|
|
50
|
-
const getGitHubLink = ({ options, templateName }) => options.url || `https://github.com/${templateName}`;
|
|
51
16
|
export const sitesCreateTemplate = async (repository, options, command) => {
|
|
52
|
-
const { api } = command.netlify;
|
|
17
|
+
const { accounts, api } = command.netlify;
|
|
53
18
|
await command.authenticate();
|
|
54
19
|
const { globalConfig } = command.netlify;
|
|
55
20
|
const ghToken = await getGitHubToken({ globalConfig });
|
|
@@ -65,7 +30,6 @@ export const sitesCreateTemplate = async (repository, options, command) => {
|
|
|
65
30
|
error(`${getTerminalLink(chalk.bold(templateName), githubLink)} is not a valid GitHub template`);
|
|
66
31
|
return;
|
|
67
32
|
}
|
|
68
|
-
const accounts = await api.listAccountsForUser();
|
|
69
33
|
let { accountSlug } = options;
|
|
70
34
|
if (!accountSlug) {
|
|
71
35
|
const { accountSlug: accountSlugInput } = await inquirer.prompt([
|
|
@@ -73,7 +37,6 @@ export const sitesCreateTemplate = async (repository, options, command) => {
|
|
|
73
37
|
type: 'list',
|
|
74
38
|
name: 'accountSlug',
|
|
75
39
|
message: 'Team:',
|
|
76
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'account' implicitly has an 'any' type.
|
|
77
40
|
choices: accounts.map((account) => ({
|
|
78
41
|
value: account.slug,
|
|
79
42
|
name: account.name,
|
|
@@ -86,95 +49,152 @@ export const sitesCreateTemplate = async (repository, options, command) => {
|
|
|
86
49
|
let site;
|
|
87
50
|
let repoResp;
|
|
88
51
|
// Allow the user to reenter site name if selected one isn't available
|
|
89
|
-
|
|
90
|
-
const inputSiteName = async (name) => {
|
|
52
|
+
const inputSiteName = async (name, hasExistingRepo) => {
|
|
91
53
|
const { name: inputName } = await getSiteNameInput(name);
|
|
54
|
+
const siteName = inputName.trim();
|
|
55
|
+
if (siteName && (await deployedSiteExists(siteName))) {
|
|
56
|
+
log('A site with that name already exists');
|
|
57
|
+
return inputSiteName();
|
|
58
|
+
}
|
|
92
59
|
try {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
60
|
+
const sites = await api.listSites({ name: siteName, filter: 'all' });
|
|
61
|
+
const siteFoundByName = sites.find((filteredSite) => filteredSite.name === siteName);
|
|
62
|
+
if (siteFoundByName) {
|
|
63
|
+
log('A site with that name already exists on your account');
|
|
64
|
+
return inputSiteName();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error_) {
|
|
68
|
+
error(error_);
|
|
69
|
+
}
|
|
70
|
+
if (!hasExistingRepo) {
|
|
71
|
+
try {
|
|
72
|
+
// Create new repo from template
|
|
73
|
+
let gitHubInputName = siteName || templateName;
|
|
74
|
+
repoResp = await createRepo(templateName, ghToken, gitHubInputName);
|
|
75
|
+
if (repoResp.errors && repoResp.errors[0].includes('Name already exists on this account')) {
|
|
76
|
+
if (gitHubInputName === templateName) {
|
|
77
|
+
gitHubInputName += `-${uuid().split('-')[0]}`;
|
|
78
|
+
repoResp = await createRepo(templateName, ghToken, gitHubInputName);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
warn(`It seems you have already created a repository with the name ${gitHubInputName}.`);
|
|
82
|
+
return inputSiteName();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!repoResp.id) {
|
|
86
|
+
throw new GitHubAPIError(repoResp.status, repoResp.message);
|
|
87
|
+
}
|
|
88
|
+
hasExistingRepo = true;
|
|
89
|
+
}
|
|
90
|
+
catch (error_) {
|
|
91
|
+
if (error_.status === '404') {
|
|
92
|
+
error(`Could not create repository: ${error_.message}. Ensure that your GitHub personal access token grants permission to create repositories`);
|
|
103
93
|
}
|
|
104
94
|
else {
|
|
105
|
-
|
|
106
|
-
// @ts-expect-error TS(18046) - 'repoResp' if of type 'unknown'
|
|
107
|
-
`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`);
|
|
95
|
+
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`);
|
|
108
96
|
}
|
|
109
97
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// @ts-expect-error TS(18046) - 'repoResp' if of type 'unknown'
|
|
121
|
-
branch: repoResp.default_branch,
|
|
122
|
-
},
|
|
123
|
-
name: siteName,
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
site = await api.createSiteInTeam({
|
|
101
|
+
accountSlug,
|
|
102
|
+
body: {
|
|
103
|
+
repo: {
|
|
104
|
+
provider: 'github',
|
|
105
|
+
repo: repoResp.full_name,
|
|
106
|
+
private: repoResp.private,
|
|
107
|
+
branch: repoResp.default_branch,
|
|
124
108
|
},
|
|
125
|
-
|
|
126
|
-
|
|
109
|
+
name: siteName,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
127
112
|
}
|
|
128
113
|
catch (error_) {
|
|
129
|
-
if (error_.status === 422
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
error(`createSiteInTeam error: ${error_.status}: ${error_.message}`);
|
|
114
|
+
if (error_.status === 422) {
|
|
115
|
+
log(`createSiteInTeam error: ${error_.status}: ${error_.message}`);
|
|
116
|
+
log('Cannot create a site with that name. Site name may already exist. Please try a new name.');
|
|
117
|
+
return inputSiteName(undefined, hasExistingRepo);
|
|
136
118
|
}
|
|
119
|
+
error(`createSiteInTeam error: ${error_.status}: ${error_.message}`);
|
|
137
120
|
}
|
|
121
|
+
return [site, repoResp];
|
|
138
122
|
};
|
|
139
|
-
await inputSiteName(nameFlag);
|
|
123
|
+
[site, repoResp] = await inputSiteName(nameFlag);
|
|
140
124
|
log();
|
|
141
125
|
log(chalk.greenBright.bold.underline(`Site Created`));
|
|
142
126
|
log();
|
|
143
|
-
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
144
127
|
const siteUrl = site.ssl_url || site.url;
|
|
145
128
|
log(render({
|
|
146
|
-
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
147
129
|
'Admin URL': site.admin_url,
|
|
148
130
|
URL: siteUrl,
|
|
149
|
-
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
150
131
|
'Site ID': site.id,
|
|
151
|
-
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
152
132
|
'Repo URL': site.build_settings.repo_url,
|
|
153
133
|
}));
|
|
154
134
|
track('sites_createdFromTemplate', {
|
|
155
|
-
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
156
135
|
siteId: site.id,
|
|
157
|
-
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
158
136
|
adminUrl: site.admin_url,
|
|
159
137
|
siteUrl,
|
|
160
138
|
});
|
|
161
139
|
const { cloneConfirm } = await inquirer.prompt({
|
|
162
140
|
type: 'confirm',
|
|
163
141
|
name: 'cloneConfirm',
|
|
164
|
-
message: `Do you want to clone the repository?`,
|
|
142
|
+
message: `Do you want to clone the repository to your local machine?`,
|
|
165
143
|
default: true,
|
|
166
144
|
});
|
|
167
145
|
if (cloneConfirm) {
|
|
168
146
|
log();
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
147
|
+
if (repoResp.clone_url) {
|
|
148
|
+
await execa('git', ['clone', repoResp.clone_url, `${repoResp.name}`]);
|
|
149
|
+
}
|
|
172
150
|
log(`🚀 Repository cloned successfully. You can find it under the ${chalk.magenta(repoResp.name)} folder`);
|
|
151
|
+
const { linkConfirm } = await inquirer.prompt({
|
|
152
|
+
type: 'confirm',
|
|
153
|
+
name: 'linkConfirm',
|
|
154
|
+
message: `Do you want to link the cloned directory to the site?`,
|
|
155
|
+
default: true,
|
|
156
|
+
});
|
|
157
|
+
if (linkConfirm) {
|
|
158
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
159
|
+
const cliPath = path.resolve(__dirname, '../../../bin/run.js');
|
|
160
|
+
let stdout;
|
|
161
|
+
if (repoResp.name) {
|
|
162
|
+
stdout = await callLinkSite(cliPath, repoResp.name, '\n');
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
error();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const linkedSiteUrlRegex = /Site url:\s+(\S+)/;
|
|
169
|
+
const lineMatch = linkedSiteUrlRegex.exec(stdout);
|
|
170
|
+
const urlMatch = lineMatch ? lineMatch[1] : undefined;
|
|
171
|
+
if (urlMatch) {
|
|
172
|
+
log(`\nDirectory ${chalk.cyanBright(repoResp.name)} linked to site ${chalk.cyanBright(urlMatch)}\n`);
|
|
173
|
+
log(`${chalk.cyanBright.bold('cd', repoResp.name)} to use other netlify cli commands in the cloned directory.\n`);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
const linkedSiteMatch = /Site already linked to\s+(\S+)/.exec(stdout);
|
|
177
|
+
const linkedSiteNameMatch = linkedSiteMatch ? linkedSiteMatch[1] : undefined;
|
|
178
|
+
if (linkedSiteNameMatch) {
|
|
179
|
+
log(`\nThis directory appears to be linked to ${chalk.cyanBright(linkedSiteNameMatch)}`);
|
|
180
|
+
log('This can happen if you cloned the template into a subdirectory of an existing Netlify project.');
|
|
181
|
+
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`);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
log('A problem occurred linking the site');
|
|
185
|
+
log('You can try again manually by running:');
|
|
186
|
+
log(chalk.cyanBright(`cd ${repoResp.name} && netlify link\n`));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
log('To link the cloned directory manually, run:');
|
|
192
|
+
log(chalk.cyanBright(`cd ${repoResp.name} && netlify link\n`));
|
|
193
|
+
}
|
|
173
194
|
}
|
|
174
195
|
if (options.withCi) {
|
|
175
196
|
log('Configuring CI');
|
|
176
197
|
const repoData = await getRepoData({ workingDir: command.workingDir });
|
|
177
|
-
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
178
198
|
await configureRepo({ command, siteId: site.id, repoData, manual: options.manual });
|
|
179
199
|
}
|
|
180
200
|
if (options.json) {
|
|
@@ -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,uBAqH5E,CAAA"}
|
|
@@ -21,9 +21,8 @@ export const getSiteNameInput = async (name) => {
|
|
|
21
21
|
return { name };
|
|
22
22
|
};
|
|
23
23
|
export const sitesCreate = async (options, command) => {
|
|
24
|
-
const { api } = command.netlify;
|
|
24
|
+
const { accounts, api } = command.netlify;
|
|
25
25
|
await command.authenticate();
|
|
26
|
-
const accounts = await api.listAccountsForUser();
|
|
27
26
|
let { accountSlug } = options;
|
|
28
27
|
if (!accountSlug) {
|
|
29
28
|
const { accountSlug: accountSlugInput } = await inquirer.prompt([
|
|
@@ -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');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/status/status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,eAAO,MAAM,MAAM,YAAmB,YAAY,WAAW,WAAW,
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/status/status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,eAAO,MAAM,MAAM,YAAmB,YAAY,WAAW,WAAW,kBAuFvE,CAAA"}
|
|
@@ -2,7 +2,7 @@ import clean from 'clean-deep';
|
|
|
2
2
|
import prettyjson from 'prettyjson';
|
|
3
3
|
import { chalk, error, exit, getToken, log, logJson, warn } from '../../utils/command-helpers.js';
|
|
4
4
|
export const status = async (options, command) => {
|
|
5
|
-
const { api, globalConfig, site, siteInfo } = command.netlify;
|
|
5
|
+
const { accounts, api, globalConfig, site, siteInfo } = command.netlify;
|
|
6
6
|
const current = globalConfig.get('userId');
|
|
7
7
|
const [accessToken] = await getToken();
|
|
8
8
|
if (!accessToken) {
|
|
@@ -15,12 +15,9 @@ export const status = async (options, command) => {
|
|
|
15
15
|
log(`──────────────────────┐
|
|
16
16
|
Current Netlify User │
|
|
17
17
|
──────────────────────┘`);
|
|
18
|
-
let accounts;
|
|
19
18
|
let user;
|
|
20
19
|
try {
|
|
21
|
-
|
|
22
|
-
;
|
|
23
|
-
[accounts, user] = await Promise.all([api.listAccountsForUser(), api.getCurrentUser()]);
|
|
20
|
+
user = await api.getCurrentUser();
|
|
24
21
|
}
|
|
25
22
|
catch (error_) {
|
|
26
23
|
if (error_.status === 401) {
|
|
@@ -37,7 +34,6 @@ export const status = async (options, command) => {
|
|
|
37
34
|
GitHub: ghuser,
|
|
38
35
|
};
|
|
39
36
|
const teamsData = {};
|
|
40
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'team' implicitly has an 'any' type.
|
|
41
37
|
accounts.forEach((team) => {
|
|
42
38
|
// @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
|
43
39
|
teamsData[team.name] = team.roles_allowed.join(' ');
|