netlify-cli 17.3.1 → 17.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -139
- package/npm-shrinkwrap.json +82 -82
- package/package.json +16 -15
- package/src/commands/addons/addons-auth.mjs +27 -30
- package/src/commands/addons/addons-config.mjs +145 -154
- package/src/commands/addons/addons-create.mjs +94 -108
- package/src/commands/addons/addons-delete.mjs +36 -41
- package/src/commands/addons/addons-list.mjs +38 -42
- package/src/commands/addons/addons.mjs +26 -28
- package/src/commands/addons/index.mjs +1 -1
- package/src/commands/api/api.mjs +45 -53
- package/src/commands/api/index.mjs +1 -1
- package/src/commands/base-command.mjs +597 -684
- package/src/commands/blobs/blobs-delete.mjs +35 -0
- package/src/commands/blobs/blobs-get.mjs +44 -0
- package/src/commands/blobs/blobs-list.mjs +48 -0
- package/src/commands/blobs/blobs-set.mjs +54 -0
- package/src/commands/blobs/blobs.mjs +32 -0
- package/src/commands/blobs/index.mjs +1 -0
- package/src/commands/build/build.mjs +55 -67
- package/src/commands/build/index.mjs +1 -1
- package/src/commands/completion/completion.mjs +41 -46
- package/src/commands/completion/index.mjs +1 -1
- package/src/commands/deploy/deploy.mjs +675 -710
- package/src/commands/deploy/index.mjs +1 -1
- package/src/commands/dev/dev-exec.mjs +20 -32
- package/src/commands/dev/dev.mjs +217 -302
- package/src/commands/dev/index.mjs +1 -1
- package/src/commands/dev/types.d.ts +30 -0
- package/src/commands/env/env-clone.mjs +157 -184
- package/src/commands/env/env-get.mjs +49 -68
- package/src/commands/env/env-import.mjs +100 -119
- package/src/commands/env/env-list.mjs +104 -129
- package/src/commands/env/env-set.mjs +160 -185
- package/src/commands/env/env-unset.mjs +104 -122
- package/src/commands/env/env.mjs +28 -30
- package/src/commands/env/index.mjs +1 -1
- package/src/commands/functions/functions-build.mjs +29 -41
- package/src/commands/functions/functions-create.mjs +533 -601
- package/src/commands/functions/functions-invoke.mjs +193 -216
- package/src/commands/functions/functions-list.mjs +45 -55
- package/src/commands/functions/functions-serve.mjs +51 -61
- package/src/commands/functions/functions.mjs +26 -32
- package/src/commands/functions/index.mjs +1 -1
- package/src/commands/index.mjs +2 -2
- package/src/commands/init/index.mjs +1 -1
- package/src/commands/init/init.mjs +138 -167
- package/src/commands/integration/deploy.mjs +337 -399
- package/src/commands/integration/index.mjs +12 -13
- package/src/commands/link/index.mjs +1 -1
- package/src/commands/link/link.mjs +298 -317
- package/src/commands/lm/index.mjs +1 -1
- package/src/commands/lm/lm-info.mjs +23 -31
- package/src/commands/lm/lm-install.mjs +13 -17
- package/src/commands/lm/lm-setup.mjs +80 -84
- package/src/commands/lm/lm-uninstall.mjs +7 -12
- package/src/commands/lm/lm.mjs +18 -22
- package/src/commands/login/index.mjs +1 -1
- package/src/commands/login/login.mjs +35 -41
- package/src/commands/logout/index.mjs +1 -1
- package/src/commands/logout/logout.mjs +25 -31
- package/src/commands/main.mjs +166 -201
- package/src/commands/open/index.mjs +1 -1
- package/src/commands/open/open-admin.mjs +15 -18
- package/src/commands/open/open-site.mjs +16 -19
- package/src/commands/open/open.mjs +24 -27
- package/src/commands/recipes/common.mjs +23 -34
- package/src/commands/recipes/index.mjs +1 -1
- package/src/commands/recipes/recipes-list.mjs +13 -20
- package/src/commands/recipes/recipes.mjs +59 -72
- package/src/commands/serve/index.mjs +1 -1
- package/src/commands/serve/serve.mjs +142 -189
- package/src/commands/sites/index.mjs +2 -2
- package/src/commands/sites/sites-create-template.mjs +214 -236
- package/src/commands/sites/sites-create.mjs +145 -157
- package/src/commands/sites/sites-delete.mjs +75 -81
- package/src/commands/sites/sites-list.mjs +63 -66
- package/src/commands/sites/sites.mjs +18 -20
- package/src/commands/status/index.mjs +1 -1
- package/src/commands/status/status-hooks.mjs +32 -34
- package/src/commands/status/status.mjs +99 -106
- package/src/commands/switch/index.mjs +1 -1
- package/src/commands/switch/switch.mjs +32 -37
- package/src/commands/types.d.ts +31 -0
- package/src/commands/unlink/index.mjs +1 -1
- package/src/commands/unlink/unlink.mjs +23 -29
- package/src/commands/watch/index.mjs +1 -1
- package/src/commands/watch/watch.mjs +91 -105
- package/src/functions-templates/javascript/hello/{{name}}.js +2 -3
- package/src/lib/account.mjs +4 -5
- package/src/lib/api.mjs +22 -20
- package/src/lib/blobs/blobs.mjs +36 -45
- package/src/lib/build.mjs +82 -85
- package/src/lib/completion/constants.mjs +2 -4
- package/src/lib/completion/generate-autocompletion.mjs +33 -36
- package/src/lib/completion/get-autocompletion.mjs +31 -35
- package/src/lib/completion/index.mjs +1 -1
- package/src/lib/completion/script.mjs +12 -19
- package/src/lib/edge-functions/bootstrap.mjs +3 -5
- package/src/lib/edge-functions/consts.mjs +9 -10
- package/src/lib/edge-functions/deploy.mjs +28 -34
- package/src/lib/edge-functions/editor-helper.mjs +29 -42
- package/src/lib/edge-functions/headers.mjs +24 -26
- package/src/lib/edge-functions/internal.mjs +38 -44
- package/src/lib/edge-functions/proxy.mjs +229 -228
- package/src/lib/edge-functions/registry.mjs +473 -574
- package/src/lib/exec-fetcher.mjs +115 -122
- package/src/lib/fs.mjs +28 -27
- package/src/lib/functions/background.mjs +16 -20
- package/src/lib/functions/config.mjs +12 -9
- package/src/lib/functions/form-submissions-handler.mjs +143 -149
- package/src/lib/functions/local-proxy.mjs +40 -44
- package/src/lib/functions/memoized-build.mjs +19 -21
- package/src/lib/functions/netlify-function.mjs +269 -249
- package/src/lib/functions/registry.mjs +509 -568
- package/src/lib/functions/runtimes/go/index.mjs +62 -71
- package/src/lib/functions/runtimes/index.mjs +8 -15
- package/src/lib/functions/runtimes/js/builders/netlify-lambda.mjs +55 -64
- package/src/lib/functions/runtimes/js/builders/zisi.mjs +135 -154
- package/src/lib/functions/runtimes/js/constants.mjs +1 -1
- package/src/lib/functions/runtimes/js/index.mjs +92 -109
- package/src/lib/functions/runtimes/js/worker.mjs +43 -45
- package/src/lib/functions/runtimes/rust/index.mjs +64 -73
- package/src/lib/functions/scheduled.mjs +70 -88
- package/src/lib/functions/server.mjs +269 -327
- package/src/lib/functions/synchronous.mjs +118 -147
- package/src/lib/functions/utils.mjs +38 -46
- package/src/lib/geo-location.mjs +69 -81
- package/src/lib/http-agent.mjs +87 -90
- package/src/lib/images/proxy.mjs +97 -89
- package/src/lib/log.mjs +6 -9
- package/src/lib/path.mjs +2 -1
- package/src/lib/render-error-template.mjs +19 -20
- package/src/lib/settings.mjs +17 -19
- package/src/lib/spinner.mjs +21 -23
- package/src/lib/string.mjs +4 -2
- package/src/recipes/vscode/index.mjs +69 -85
- package/src/recipes/vscode/settings.mjs +53 -58
- package/src/utils/addons/compare.mjs +31 -32
- package/src/utils/addons/diffs/index.mjs +16 -17
- package/src/utils/addons/diffs/options.mjs +99 -101
- package/src/utils/addons/prepare.mjs +100 -97
- package/src/utils/addons/prompts.mjs +73 -76
- package/src/utils/addons/render.mjs +33 -36
- package/src/utils/addons/validation.mjs +19 -15
- package/src/utils/banner.mjs +11 -16
- package/src/utils/build-info.mjs +65 -66
- package/src/utils/command-helpers.mjs +185 -199
- package/src/utils/create-deferred.mjs +9 -12
- package/src/utils/create-stream-promise.mjs +54 -47
- package/src/utils/deploy/constants.mjs +9 -11
- package/src/utils/deploy/deploy-site.mjs +162 -182
- package/src/utils/deploy/hash-config.mjs +21 -21
- package/src/utils/deploy/hash-files.mjs +34 -38
- package/src/utils/deploy/hash-fns.mjs +149 -154
- package/src/utils/deploy/hasher-segments.mjs +58 -52
- package/src/utils/deploy/upload-files.mjs +99 -113
- package/src/utils/deploy/util.mjs +85 -91
- package/src/utils/detect-server-settings.mjs +236 -268
- package/src/utils/dev.mjs +163 -178
- package/src/utils/dot-env.mjs +37 -42
- package/src/utils/env/index.mjs +148 -148
- package/src/utils/execa.mjs +9 -13
- package/src/utils/feature-flags.mjs +6 -5
- package/src/utils/framework-server.mjs +43 -52
- package/src/utils/functions/constants.mjs +1 -1
- package/src/utils/functions/functions.mjs +30 -40
- package/src/utils/functions/get-functions.mjs +28 -29
- package/src/utils/functions/index.mjs +3 -3
- package/src/utils/get-global-config.mjs +33 -36
- package/src/utils/get-package-json.mjs +14 -15
- package/src/utils/get-repo-data.mjs +54 -64
- package/src/utils/get-site.mjs +14 -14
- package/src/utils/gh-auth.mjs +79 -100
- package/src/utils/gitignore.mjs +37 -40
- package/src/utils/headers.mjs +33 -35
- package/src/utils/hooks/requires-site-info.mjs +26 -22
- package/src/utils/init/config-github.mjs +207 -219
- package/src/utils/init/config-manual.mjs +83 -100
- package/src/utils/init/config.mjs +25 -26
- package/src/utils/init/node-version.mjs +23 -30
- package/src/utils/init/plugins.mjs +12 -8
- package/src/utils/init/utils.mjs +152 -172
- package/src/utils/live-tunnel.mjs +118 -141
- package/src/utils/lm/install.mjs +220 -259
- package/src/utils/lm/requirements.mjs +54 -63
- package/src/utils/lm/steps.mjs +31 -31
- package/src/utils/lm/ui.mjs +13 -20
- package/src/utils/open-browser.mjs +31 -32
- package/src/utils/parse-raw-flags.mjs +39 -35
- package/src/utils/proxy-server.mjs +84 -71
- package/src/utils/proxy.mjs +696 -750
- package/src/utils/read-repo-url.mjs +48 -47
- package/src/utils/redirects.mjs +49 -49
- package/src/utils/request-id.mjs +2 -4
- package/src/utils/rules-proxy.mjs +96 -100
- package/src/utils/run-build.mjs +109 -132
- package/src/utils/shell.mjs +99 -106
- package/src/utils/sign-redirect.mjs +14 -14
- package/src/utils/sites/utils.mjs +48 -55
- package/src/utils/state-config.mjs +101 -101
- package/src/utils/static-server.mjs +28 -34
- package/src/utils/telemetry/index.mjs +2 -2
- package/src/utils/telemetry/report-error.mjs +45 -49
- package/src/utils/telemetry/request.mjs +36 -43
- package/src/utils/telemetry/telemetry.mjs +90 -105
- package/src/utils/telemetry/utils.mjs +5 -6
- package/src/utils/telemetry/validation.mjs +55 -53
- package/src/utils/types.d.ts +46 -0
- package/src/utils/validation.mjs +10 -13
|
@@ -1,178 +1,166 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import { link } from '../link/index.mjs'
|
|
12
|
-
|
|
1
|
+
import { InvalidArgumentError } from 'commander';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import pick from 'lodash/pick.js';
|
|
4
|
+
import prettyjson from 'prettyjson';
|
|
5
|
+
import { chalk, error, log, logJson, warn } from '../../utils/command-helpers.mjs';
|
|
6
|
+
import getRepoData from '../../utils/get-repo-data.mjs';
|
|
7
|
+
import { configureRepo } from '../../utils/init/config.mjs';
|
|
8
|
+
import { track } from '../../utils/telemetry/index.mjs';
|
|
9
|
+
import { link } from '../link/index.mjs';
|
|
10
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type.
|
|
13
11
|
export const getSiteNameInput = async (name) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return { name }
|
|
28
|
-
}
|
|
29
|
-
|
|
12
|
+
if (!name) {
|
|
13
|
+
const { name: nameInput } = await inquirer.prompt([
|
|
14
|
+
{
|
|
15
|
+
type: 'input',
|
|
16
|
+
name: 'name',
|
|
17
|
+
message: 'Site name (leave blank for a random name; you can change it later):',
|
|
18
|
+
validate: (input) => /^[a-zA-Z\d-]+$/.test(input || undefined) || 'Only alphanumeric characters and hyphens are allowed',
|
|
19
|
+
},
|
|
20
|
+
]);
|
|
21
|
+
name = nameInput || '';
|
|
22
|
+
}
|
|
23
|
+
return { name };
|
|
24
|
+
};
|
|
30
25
|
/**
|
|
31
26
|
* The sites:create command
|
|
32
27
|
* @param {import('commander').OptionValues} options
|
|
33
28
|
* @param {import('../base-command.mjs').default} command
|
|
34
29
|
*/
|
|
30
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
|
|
35
31
|
export const sitesCreate = async (options, command) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
32
|
+
const { api } = command.netlify;
|
|
33
|
+
await command.authenticate();
|
|
34
|
+
const accounts = await api.listAccountsForUser();
|
|
35
|
+
let { accountSlug } = options;
|
|
36
|
+
if (!accountSlug) {
|
|
37
|
+
const { accountSlug: accountSlugInput } = await inquirer.prompt([
|
|
38
|
+
{
|
|
39
|
+
type: 'list',
|
|
40
|
+
name: 'accountSlug',
|
|
41
|
+
message: 'Team:',
|
|
42
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'account' implicitly has an 'any' type.
|
|
43
|
+
choices: accounts.map((account) => ({
|
|
44
|
+
value: account.slug,
|
|
45
|
+
name: account.name,
|
|
46
|
+
})),
|
|
47
|
+
},
|
|
48
|
+
]);
|
|
49
|
+
accountSlug = accountSlugInput;
|
|
50
|
+
}
|
|
51
|
+
let site;
|
|
52
|
+
// Allow the user to reenter site name if selected one isn't available
|
|
53
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type.
|
|
54
|
+
const inputSiteName = async (name) => {
|
|
55
|
+
const { name: siteName } = await getSiteNameInput(name);
|
|
56
|
+
const body = {};
|
|
57
|
+
if (typeof siteName === 'string') {
|
|
58
|
+
// @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type '{}'.
|
|
59
|
+
body.name = siteName.trim();
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
site = await api.createSiteInTeam({
|
|
63
|
+
accountSlug,
|
|
64
|
+
body,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error_) {
|
|
68
|
+
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
69
|
+
if (error_.status === 422) {
|
|
70
|
+
warn(`${siteName}.netlify.app already exists. Please try a different slug.`);
|
|
71
|
+
// @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0.
|
|
72
|
+
await inputSiteName();
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
76
|
+
error(`createSiteInTeam error: ${error_.status}: ${error_.message}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
await inputSiteName(options.name);
|
|
81
|
+
log();
|
|
82
|
+
log(chalk.greenBright.bold.underline(`Site Created`));
|
|
83
|
+
log();
|
|
84
|
+
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
85
|
+
const siteUrl = site.ssl_url || site.url;
|
|
86
|
+
log(prettyjson.render({
|
|
87
|
+
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
88
|
+
'Admin URL': site.admin_url,
|
|
89
|
+
URL: siteUrl,
|
|
90
|
+
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
91
|
+
'Site ID': site.id,
|
|
92
|
+
}));
|
|
93
|
+
track('sites_created', {
|
|
94
|
+
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
95
|
+
siteId: site.id,
|
|
96
|
+
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
97
|
+
adminUrl: site.admin_url,
|
|
98
|
+
siteUrl,
|
|
99
|
+
});
|
|
100
|
+
if (options.withCi) {
|
|
101
|
+
log('Configuring CI');
|
|
102
|
+
// @ts-expect-error TS(2345) FIXME: Argument of type '{ workingDir: any; }' is not ass... Remove this comment to see the full error message
|
|
103
|
+
const repoData = await getRepoData({ workingDir: command.workingDir });
|
|
104
|
+
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
105
|
+
await configureRepo({ command, siteId: site.id, repoData, manual: options.manual });
|
|
67
106
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
107
|
+
if (options.json) {
|
|
108
|
+
logJson(pick(site, [
|
|
109
|
+
'id',
|
|
110
|
+
'state',
|
|
111
|
+
'plan',
|
|
112
|
+
'name',
|
|
113
|
+
'custom_domain',
|
|
114
|
+
'domain_aliases',
|
|
115
|
+
'url',
|
|
116
|
+
'ssl_url',
|
|
117
|
+
'admin_url',
|
|
118
|
+
'screenshot_url',
|
|
119
|
+
'created_at',
|
|
120
|
+
'updated_at',
|
|
121
|
+
'user_id',
|
|
122
|
+
'ssl',
|
|
123
|
+
'force_ssl',
|
|
124
|
+
'managed_dns',
|
|
125
|
+
'deploy_url',
|
|
126
|
+
'account_name',
|
|
127
|
+
'account_slug',
|
|
128
|
+
'git_provider',
|
|
129
|
+
'deploy_hook',
|
|
130
|
+
'capabilities',
|
|
131
|
+
'id_domain',
|
|
132
|
+
]));
|
|
80
133
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
prettyjson.render({
|
|
91
|
-
'Admin URL': site.admin_url,
|
|
92
|
-
URL: siteUrl,
|
|
93
|
-
'Site ID': site.id,
|
|
94
|
-
}),
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
track('sites_created', {
|
|
98
|
-
siteId: site.id,
|
|
99
|
-
adminUrl: site.admin_url,
|
|
100
|
-
siteUrl,
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
if (options.withCi) {
|
|
104
|
-
log('Configuring CI')
|
|
105
|
-
const repoData = await getRepoData({ workingDir: command.workingDir })
|
|
106
|
-
await configureRepo({ command, siteId: site.id, repoData, manual: options.manual })
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (options.json) {
|
|
110
|
-
logJson(
|
|
111
|
-
pick(site, [
|
|
112
|
-
'id',
|
|
113
|
-
'state',
|
|
114
|
-
'plan',
|
|
115
|
-
'name',
|
|
116
|
-
'custom_domain',
|
|
117
|
-
'domain_aliases',
|
|
118
|
-
'url',
|
|
119
|
-
'ssl_url',
|
|
120
|
-
'admin_url',
|
|
121
|
-
'screenshot_url',
|
|
122
|
-
'created_at',
|
|
123
|
-
'updated_at',
|
|
124
|
-
'user_id',
|
|
125
|
-
'ssl',
|
|
126
|
-
'force_ssl',
|
|
127
|
-
'managed_dns',
|
|
128
|
-
'deploy_url',
|
|
129
|
-
'account_name',
|
|
130
|
-
'account_slug',
|
|
131
|
-
'git_provider',
|
|
132
|
-
'deploy_hook',
|
|
133
|
-
'capabilities',
|
|
134
|
-
'id_domain',
|
|
135
|
-
]),
|
|
136
|
-
)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (!options.disableLinking) {
|
|
140
|
-
log()
|
|
141
|
-
await link({ id: site.id }, command)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return site
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const MAX_SITE_NAME_LENGTH = 63
|
|
134
|
+
if (!options.disableLinking) {
|
|
135
|
+
log();
|
|
136
|
+
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
137
|
+
await link({ id: site.id }, command);
|
|
138
|
+
}
|
|
139
|
+
return site;
|
|
140
|
+
};
|
|
141
|
+
const MAX_SITE_NAME_LENGTH = 63;
|
|
142
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type.
|
|
148
143
|
const validateName = function (value) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
144
|
+
// netlify sites:create --name <A string of more than 63 words>
|
|
145
|
+
if (typeof value === 'string' && value.length > MAX_SITE_NAME_LENGTH) {
|
|
146
|
+
throw new InvalidArgumentError(`--name should be less than 64 characters, input length: ${value.length}`);
|
|
147
|
+
}
|
|
148
|
+
return value;
|
|
149
|
+
};
|
|
157
150
|
/**
|
|
158
151
|
* Creates the `netlify sites:create` command
|
|
159
152
|
* @param {import('../base-command.mjs').default} program
|
|
160
153
|
* @returns
|
|
161
154
|
*/
|
|
162
|
-
|
|
163
|
-
|
|
155
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
156
|
+
export const createSitesCreateCommand = (program) => program
|
|
164
157
|
.command('sites:create')
|
|
165
|
-
.description(
|
|
166
|
-
|
|
167
|
-
Create a blank site that isn't associated with any git remote. Will link the site to the current working directory.`,
|
|
168
|
-
)
|
|
158
|
+
.description(`Create an empty site (advanced)
|
|
159
|
+
Create a blank site that isn't associated with any git remote. Will link the site to the current working directory.`)
|
|
169
160
|
.option('-n, --name <name>', 'name of site', validateName)
|
|
170
161
|
.option('-a, --account-slug <slug>', 'account slug to create the site under')
|
|
171
162
|
.option('-c, --with-ci', 'initialize CI hooks during site creation')
|
|
172
163
|
.option('-m, --manual', 'force manual CI setup. Used --with-ci flag')
|
|
173
164
|
.option('--disable-linking', 'create the site without linking it to current directory')
|
|
174
|
-
.addHelpText(
|
|
175
|
-
|
|
176
|
-
`Create a blank site that isn't associated with any git remote. Will link the site to the current working directory.`,
|
|
177
|
-
)
|
|
178
|
-
.action(sitesCreate)
|
|
165
|
+
.addHelpText('after', `Create a blank site that isn't associated with any git remote. Will link the site to the current working directory.`)
|
|
166
|
+
.action(sitesCreate);
|
|
@@ -1,102 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import { chalk, error, exit, log } from '../../utils/command-helpers.mjs'
|
|
5
|
-
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import { chalk, error, exit, log } from '../../utils/command-helpers.mjs';
|
|
6
3
|
/**
|
|
7
4
|
* The sites:delete command
|
|
8
5
|
* @param {string} siteId
|
|
9
6
|
* @param {import('commander').OptionValues} options
|
|
10
7
|
* @param {import('../base-command.mjs').default} command
|
|
11
8
|
*/
|
|
9
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'siteId' implicitly has an 'any' type.
|
|
12
10
|
const sitesDelete = async (siteId, options, command) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let siteData
|
|
22
|
-
try {
|
|
23
|
-
siteData = await api.getSite({ siteId })
|
|
24
|
-
} catch (error_) {
|
|
25
|
-
if (error_.status === 404) {
|
|
26
|
-
error(`No site with id ${siteId} found. Please verify the siteId & try again.`)
|
|
11
|
+
command.setAnalyticsPayload({ force: options.force });
|
|
12
|
+
const { api, site } = command.netlify;
|
|
13
|
+
const cwdSiteId = site.id;
|
|
14
|
+
// 1. Prompt user for verification
|
|
15
|
+
await command.authenticate(options.auth);
|
|
16
|
+
let siteData;
|
|
17
|
+
try {
|
|
18
|
+
siteData = await api.getSite({ siteId });
|
|
27
19
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const noForce = options.force !== true
|
|
35
|
-
|
|
36
|
-
/* Verify the user wants to delete the site */
|
|
37
|
-
if (noForce) {
|
|
38
|
-
log(`${chalk.redBright('Warning')}: You are about to permanently delete "${chalk.bold(siteData.name)}"`)
|
|
39
|
-
log(` Verify this siteID "${siteId}" supplied is correct and proceed.`)
|
|
40
|
-
log(' To skip this prompt, pass a --force flag to the delete command')
|
|
41
|
-
log()
|
|
42
|
-
log(`${chalk.bold('Be careful here. There is no undo!')}`)
|
|
43
|
-
log()
|
|
44
|
-
const { wantsToDelete } = await inquirer.prompt({
|
|
45
|
-
type: 'confirm',
|
|
46
|
-
name: 'wantsToDelete',
|
|
47
|
-
message: `WARNING: Are you sure you want to delete the "${siteData.name}" site?`,
|
|
48
|
-
default: false,
|
|
49
|
-
})
|
|
50
|
-
log()
|
|
51
|
-
if (!wantsToDelete) {
|
|
52
|
-
exit()
|
|
20
|
+
catch (error_) {
|
|
21
|
+
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
22
|
+
if (error_.status === 404) {
|
|
23
|
+
error(`No site with id ${siteId} found. Please verify the siteId & try again.`);
|
|
24
|
+
}
|
|
53
25
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/* Validation logic if siteId passed in does not match current site ID */
|
|
57
|
-
if (noForce && cwdSiteId && cwdSiteId !== siteId) {
|
|
58
|
-
log(`${chalk.redBright('Warning')}: The siteId supplied does not match the current working directory siteId`)
|
|
59
|
-
log()
|
|
60
|
-
log(`Supplied: "${siteId}"`)
|
|
61
|
-
log(`Current Site: "${cwdSiteId}"`)
|
|
62
|
-
log()
|
|
63
|
-
log(`Verify this siteID "${siteId}" supplied is correct and proceed.`)
|
|
64
|
-
log('To skip this prompt, pass a --force flag to the delete command')
|
|
65
|
-
const { wantsToDelete } = await inquirer.prompt({
|
|
66
|
-
type: 'confirm',
|
|
67
|
-
name: 'wantsToDelete',
|
|
68
|
-
message: `Verify & Proceed with deletion of site "${siteId}"?`,
|
|
69
|
-
default: false,
|
|
70
|
-
})
|
|
71
|
-
if (!wantsToDelete) {
|
|
72
|
-
exit()
|
|
26
|
+
if (!siteData) {
|
|
27
|
+
error(`Unable to process site`);
|
|
73
28
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
29
|
+
const noForce = options.force !== true;
|
|
30
|
+
/* Verify the user wants to delete the site */
|
|
31
|
+
if (noForce) {
|
|
32
|
+
log(`${chalk.redBright('Warning')}: You are about to permanently delete "${chalk.bold(siteData.name)}"`);
|
|
33
|
+
log(` Verify this siteID "${siteId}" supplied is correct and proceed.`);
|
|
34
|
+
log(' To skip this prompt, pass a --force flag to the delete command');
|
|
35
|
+
log();
|
|
36
|
+
log(`${chalk.bold('Be careful here. There is no undo!')}`);
|
|
37
|
+
log();
|
|
38
|
+
const { wantsToDelete } = await inquirer.prompt({
|
|
39
|
+
type: 'confirm',
|
|
40
|
+
name: 'wantsToDelete',
|
|
41
|
+
message: `WARNING: Are you sure you want to delete the "${siteData.name}" site?`,
|
|
42
|
+
default: false,
|
|
43
|
+
});
|
|
44
|
+
log();
|
|
45
|
+
if (!wantsToDelete) {
|
|
46
|
+
exit();
|
|
47
|
+
}
|
|
85
48
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
49
|
+
/* Validation logic if siteId passed in does not match current site ID */
|
|
50
|
+
if (noForce && cwdSiteId && cwdSiteId !== siteId) {
|
|
51
|
+
log(`${chalk.redBright('Warning')}: The siteId supplied does not match the current working directory siteId`);
|
|
52
|
+
log();
|
|
53
|
+
log(`Supplied: "${siteId}"`);
|
|
54
|
+
log(`Current Site: "${cwdSiteId}"`);
|
|
55
|
+
log();
|
|
56
|
+
log(`Verify this siteID "${siteId}" supplied is correct and proceed.`);
|
|
57
|
+
log('To skip this prompt, pass a --force flag to the delete command');
|
|
58
|
+
const { wantsToDelete } = await inquirer.prompt({
|
|
59
|
+
type: 'confirm',
|
|
60
|
+
name: 'wantsToDelete',
|
|
61
|
+
message: `Verify & Proceed with deletion of site "${siteId}"?`,
|
|
62
|
+
default: false,
|
|
63
|
+
});
|
|
64
|
+
if (!wantsToDelete) {
|
|
65
|
+
exit();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
log(`Deleting site "${siteId}"...`);
|
|
69
|
+
try {
|
|
70
|
+
await api.deleteSite({ site_id: siteId });
|
|
71
|
+
}
|
|
72
|
+
catch (error_) {
|
|
73
|
+
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
74
|
+
if (error_.status === 404) {
|
|
75
|
+
error(`No site with id ${siteId} found. Please verify the siteId & try again.`);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
79
|
+
error(`Delete Site error: ${error_.status}: ${error_.message}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
log(`Site "${siteId}" successfully deleted!`);
|
|
83
|
+
};
|
|
90
84
|
/**
|
|
91
85
|
* Creates the `netlify sites:delete` command
|
|
92
86
|
* @param {import('../base-command.mjs').default} program
|
|
93
87
|
* @returns
|
|
94
88
|
*/
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
90
|
+
export const createSitesDeleteCommand = (program) => program
|
|
97
91
|
.command('sites:delete')
|
|
98
92
|
.description('Delete a site\nThis command will permanently delete the site on Netlify. Use with caution.')
|
|
99
93
|
.argument('<siteId>', 'Site ID to delete.')
|
|
100
94
|
.option('-f, --force', 'delete without prompting (useful for CI)')
|
|
101
95
|
.addExamples(['netlify sites:delete 1234-3262-1211'])
|
|
102
|
-
.action(sitesDelete)
|
|
96
|
+
.action(sitesDelete);
|
|
@@ -1,87 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { chalk, log, logJson } from '../../utils/command-helpers.mjs'
|
|
5
|
-
|
|
1
|
+
import { listSites } from '../../lib/api.mjs';
|
|
2
|
+
import { startSpinner, stopSpinner } from '../../lib/spinner.mjs';
|
|
3
|
+
import { chalk, log, logJson } from '../../utils/command-helpers.mjs';
|
|
6
4
|
/**
|
|
7
5
|
* The sites:list command
|
|
8
6
|
* @param {import('commander').OptionValues} options
|
|
9
7
|
* @param {import('../base-command.mjs').default} command
|
|
10
8
|
* @returns {Promise<{ id: any; name: any; ssl_url: any; account_name: any; }|boolean>}
|
|
11
9
|
*/
|
|
10
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
|
|
12
11
|
const sitesList = async (options, command) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
await command.authenticate()
|
|
20
|
-
|
|
21
|
-
const sites = await listSites({ api, options: { filter: 'all' } })
|
|
22
|
-
if (!options.json) {
|
|
23
|
-
stopSpinner({ spinner })
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (sites && sites.length !== 0) {
|
|
27
|
-
const logSites = sites.map((site) => {
|
|
28
|
-
const siteInfo = {
|
|
29
|
-
id: site.id,
|
|
30
|
-
name: site.name,
|
|
31
|
-
ssl_url: site.ssl_url,
|
|
32
|
-
account_name: site.account_name,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (site.build_settings && site.build_settings.repo_url) {
|
|
36
|
-
siteInfo.repo_url = site.build_settings.repo_url
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return siteInfo
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
// Json response for piping commands
|
|
43
|
-
if (options.json) {
|
|
44
|
-
const redactedSites = sites.map((site) => {
|
|
45
|
-
if (site && site.build_settings) {
|
|
46
|
-
delete site.build_settings.env
|
|
47
|
-
}
|
|
48
|
-
return site
|
|
49
|
-
})
|
|
50
|
-
logJson(redactedSites)
|
|
51
|
-
return false
|
|
12
|
+
const { api } = command.netlify;
|
|
13
|
+
/** @type {import('ora').Ora} */
|
|
14
|
+
let spinner;
|
|
15
|
+
if (!options.json) {
|
|
16
|
+
spinner = startSpinner({ text: 'Loading your sites' });
|
|
52
17
|
}
|
|
53
|
-
|
|
54
|
-
|
|
18
|
+
await command.authenticate();
|
|
19
|
+
const sites = await listSites({ api, options: { filter: 'all' } });
|
|
20
|
+
if (!options.json) {
|
|
21
|
+
// @ts-expect-error TS(2345) FIXME: Argument of type '{ spinner: Ora | undefined; }' i... Remove this comment to see the full error message
|
|
22
|
+
stopSpinner({ spinner });
|
|
23
|
+
}
|
|
24
|
+
if (sites && sites.length !== 0) {
|
|
25
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'site' implicitly has an 'any' type.
|
|
26
|
+
const logSites = sites.map((site) => {
|
|
27
|
+
const siteInfo = {
|
|
28
|
+
id: site.id,
|
|
29
|
+
name: site.name,
|
|
30
|
+
ssl_url: site.ssl_url,
|
|
31
|
+
account_name: site.account_name,
|
|
32
|
+
};
|
|
33
|
+
if (site.build_settings && site.build_settings.repo_url) {
|
|
34
|
+
// @ts-expect-error TS(2339) FIXME: Property 'repo_url' does not exist on type '{ id: ... Remove this comment to see the full error message
|
|
35
|
+
siteInfo.repo_url = site.build_settings.repo_url;
|
|
36
|
+
}
|
|
37
|
+
return siteInfo;
|
|
38
|
+
});
|
|
39
|
+
// Json response for piping commands
|
|
40
|
+
if (options.json) {
|
|
41
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'site' implicitly has an 'any' type.
|
|
42
|
+
const redactedSites = sites.map((site) => {
|
|
43
|
+
if (site && site.build_settings) {
|
|
44
|
+
delete site.build_settings.env;
|
|
45
|
+
}
|
|
46
|
+
return site;
|
|
47
|
+
});
|
|
48
|
+
logJson(redactedSites);
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
log(`
|
|
55
52
|
────────────────────────────┐
|
|
56
53
|
Current Netlify Sites │
|
|
57
54
|
────────────────────────────┘
|
|
58
55
|
|
|
59
56
|
Count: ${logSites.length}
|
|
60
|
-
`)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
57
|
+
`);
|
|
58
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'logSite' implicitly has an 'any' type.
|
|
59
|
+
logSites.forEach((logSite) => {
|
|
60
|
+
log(`${chalk.greenBright(logSite.name)} - ${logSite.id}`);
|
|
61
|
+
log(` ${chalk.whiteBright.bold('url:')} ${chalk.yellowBright(logSite.ssl_url)}`);
|
|
62
|
+
if (logSite.repo_url) {
|
|
63
|
+
log(` ${chalk.whiteBright.bold('repo:')} ${chalk.white(logSite.repo_url)}`);
|
|
64
|
+
}
|
|
65
|
+
if (logSite.account_name) {
|
|
66
|
+
log(` ${chalk.whiteBright.bold('account:')} ${chalk.white(logSite.account_name)}`);
|
|
67
|
+
}
|
|
68
|
+
log(`─────────────────────────────────────────────────`);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
76
72
|
/**
|
|
77
73
|
* Creates the `netlify sites:list` command
|
|
78
74
|
* @param {import('../base-command.mjs').default} program
|
|
79
75
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
77
|
+
export const createSitesListCommand = (program) => program
|
|
82
78
|
.command('sites:list')
|
|
83
79
|
.description('List all sites you have access to')
|
|
84
80
|
.option('--json', 'Output site data as JSON')
|
|
81
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
|
|
85
82
|
.action(async (options, command) => {
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
await sitesList(options, command);
|
|
84
|
+
});
|