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,32 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { createSitesListCommand } from './sites-list.mjs'
|
|
6
|
-
|
|
1
|
+
import { createSitesFromTemplateCommand } from './sites-create-template.mjs';
|
|
2
|
+
import { createSitesCreateCommand } from './sites-create.mjs';
|
|
3
|
+
import { createSitesDeleteCommand } from './sites-delete.mjs';
|
|
4
|
+
import { createSitesListCommand } from './sites-list.mjs';
|
|
7
5
|
/**
|
|
8
6
|
* The sites command
|
|
9
7
|
* @param {import('commander').OptionValues} options
|
|
10
8
|
* @param {import('../base-command.mjs').default} command
|
|
11
9
|
*/
|
|
10
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
|
|
12
11
|
const sites = (options, command) => {
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
12
|
+
command.help();
|
|
13
|
+
};
|
|
16
14
|
/**
|
|
17
15
|
* Creates the `netlify sites` command
|
|
18
16
|
* @param {import('../base-command.mjs').default} program
|
|
19
17
|
* @returns
|
|
20
18
|
*/
|
|
19
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
21
20
|
export const createSitesCommand = (program) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
21
|
+
createSitesCreateCommand(program);
|
|
22
|
+
createSitesFromTemplateCommand(program);
|
|
23
|
+
createSitesListCommand(program);
|
|
24
|
+
createSitesDeleteCommand(program);
|
|
25
|
+
return program
|
|
26
|
+
.command('sites')
|
|
27
|
+
.description(`Handle various site operations\nThe sites command will help you manage all your sites`)
|
|
28
|
+
.addExamples(['netlify sites:create --name my-new-site', 'netlify sites:list'])
|
|
29
|
+
.action(sites);
|
|
30
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createStatusCommand } from './status.mjs'
|
|
1
|
+
export { createStatusCommand } from './status.mjs';
|
|
@@ -1,49 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import { log } from '../../utils/command-helpers.mjs'
|
|
5
|
-
import requiresSiteInfo from '../../utils/hooks/requires-site-info.mjs'
|
|
6
|
-
|
|
1
|
+
import prettyjson from 'prettyjson';
|
|
2
|
+
import { log } from '../../utils/command-helpers.mjs';
|
|
3
|
+
import requiresSiteInfo from '../../utils/hooks/requires-site-info.mjs';
|
|
7
4
|
/**
|
|
8
5
|
* The status:hooks command
|
|
9
6
|
* @param {import('commander').OptionValues} options
|
|
10
7
|
* @param {import('../base-command.mjs').default} command
|
|
11
8
|
*/
|
|
9
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
|
|
12
10
|
const statusHooks = async (options, command) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
const { api, siteInfo } = command.netlify;
|
|
12
|
+
await command.authenticate();
|
|
13
|
+
const ntlHooks = await api.listHooksBySiteId({ siteId: siteInfo.id });
|
|
14
|
+
const data = {
|
|
15
|
+
site: siteInfo.name,
|
|
16
|
+
hooks: {},
|
|
17
|
+
};
|
|
18
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'hook' implicitly has an 'any' type.
|
|
19
|
+
ntlHooks.forEach((hook) => {
|
|
20
|
+
// @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
|
21
|
+
data.hooks[hook.id] = {
|
|
22
|
+
type: hook.type,
|
|
23
|
+
event: hook.event,
|
|
24
|
+
id: hook.id,
|
|
25
|
+
disabled: hook.disabled,
|
|
26
|
+
};
|
|
27
|
+
if (siteInfo.build_settings?.repo_url) {
|
|
28
|
+
// @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
|
29
|
+
data.hooks[hook.id].repo_url = siteInfo.build_settings.repo_url;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
log(`─────────────────┐
|
|
34
33
|
Site Hook Status │
|
|
35
|
-
─────────────────┘`)
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
34
|
+
─────────────────┘`);
|
|
35
|
+
log(prettyjson.render(data));
|
|
36
|
+
};
|
|
39
37
|
/**
|
|
40
38
|
* Creates the `netlify status:hooks` command
|
|
41
39
|
* @param {import('../base-command.mjs').default} program
|
|
42
40
|
* @returns
|
|
43
41
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
43
|
+
export const createStatusHooksCommand = (program) => program
|
|
46
44
|
.command('status:hooks')
|
|
47
45
|
.description('Print hook information of the linked site')
|
|
48
46
|
.hook('preAction', requiresSiteInfo)
|
|
49
|
-
.action(statusHooks)
|
|
47
|
+
.action(statusHooks);
|
|
@@ -1,123 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { chalk, error, exit, getToken, log, logJson, warn } from '../../utils/command-helpers.mjs'
|
|
6
|
-
|
|
7
|
-
import { createStatusHooksCommand } from './status-hooks.mjs'
|
|
8
|
-
|
|
1
|
+
import clean from 'clean-deep';
|
|
2
|
+
import prettyjson from 'prettyjson';
|
|
3
|
+
import { chalk, error, exit, getToken, log, logJson, warn } from '../../utils/command-helpers.mjs';
|
|
4
|
+
import { createStatusHooksCommand } from './status-hooks.mjs';
|
|
9
5
|
/**
|
|
10
6
|
* The status command
|
|
11
7
|
* @param {import('commander').OptionValues} options
|
|
12
8
|
* @param {import('../base-command.mjs').default} command
|
|
13
9
|
*/
|
|
10
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
|
|
14
11
|
const status = async (options, command) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
log(`──────────────────────┐
|
|
12
|
+
const { api, globalConfig, site } = command.netlify;
|
|
13
|
+
const current = globalConfig.get('userId');
|
|
14
|
+
// @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0.
|
|
15
|
+
const [accessToken] = await getToken();
|
|
16
|
+
if (!accessToken) {
|
|
17
|
+
log(`Not logged in. Please log in to see site status.`);
|
|
18
|
+
log();
|
|
19
|
+
log('Login with "netlify login" command');
|
|
20
|
+
exit();
|
|
21
|
+
}
|
|
22
|
+
const siteId = site.id;
|
|
23
|
+
log(`──────────────────────┐
|
|
29
24
|
Current Netlify User │
|
|
30
|
-
──────────────────────┘`)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
──────────────────────┘`);
|
|
26
|
+
let accounts;
|
|
27
|
+
let user;
|
|
28
|
+
try {
|
|
29
|
+
;
|
|
30
|
+
[accounts, user] = await Promise.all([api.listAccountsForUser(), api.getCurrentUser()]);
|
|
31
|
+
}
|
|
32
|
+
catch (error_) {
|
|
33
|
+
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
34
|
+
if (error_.status === 401) {
|
|
35
|
+
error('Your session has expired. Please try to re-authenticate by running `netlify logout` and `netlify login`.');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const ghuser = command.netlify.globalConfig.get(`users.${current}.auth.github.user`);
|
|
39
|
+
const accountData = {
|
|
40
|
+
Name: user.full_name,
|
|
41
|
+
Email: user.email,
|
|
42
|
+
GitHub: ghuser,
|
|
43
|
+
};
|
|
44
|
+
const teamsData = {};
|
|
45
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'team' implicitly has an 'any' type.
|
|
46
|
+
accounts.forEach((team) => {
|
|
47
|
+
// @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
|
48
|
+
teamsData[team.name] = team.roles_allowed.join(' ');
|
|
49
|
+
});
|
|
50
|
+
// @ts-expect-error TS(2339) FIXME: Property 'Teams' does not exist on type '{ Name: a... Remove this comment to see the full error message
|
|
51
|
+
accountData.Teams = teamsData;
|
|
52
|
+
// @ts-expect-error
|
|
53
|
+
const cleanAccountData = clean(accountData);
|
|
54
|
+
log(prettyjson.render(cleanAccountData));
|
|
55
|
+
if (!siteId) {
|
|
56
|
+
warn('Did you run `netlify link` yet?');
|
|
57
|
+
error(`You don't appear to be in a folder that is linked to a site`);
|
|
58
|
+
}
|
|
59
|
+
let siteData;
|
|
60
|
+
try {
|
|
61
|
+
siteData = await api.getSite({ siteId });
|
|
40
62
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
accountData.Teams = teamsData
|
|
56
|
-
|
|
57
|
-
const cleanAccountData = clean(accountData)
|
|
58
|
-
|
|
59
|
-
log(prettyjson.render(cleanAccountData))
|
|
60
|
-
|
|
61
|
-
if (!siteId) {
|
|
62
|
-
warn('Did you run `netlify link` yet?')
|
|
63
|
-
error(`You don't appear to be in a folder that is linked to a site`)
|
|
64
|
-
}
|
|
65
|
-
let siteData
|
|
66
|
-
try {
|
|
67
|
-
siteData = await api.getSite({ siteId })
|
|
68
|
-
} catch (error_) {
|
|
69
|
-
// unauthorized
|
|
70
|
-
if (error_.status === 401) {
|
|
71
|
-
warn(`Log in with a different account or re-link to a site you have permission for`)
|
|
72
|
-
error(`Not authorized to view the currently linked site (${siteId})`)
|
|
63
|
+
catch (error_) {
|
|
64
|
+
// unauthorized
|
|
65
|
+
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
66
|
+
if (error_.status === 401) {
|
|
67
|
+
warn(`Log in with a different account or re-link to a site you have permission for`);
|
|
68
|
+
error(`Not authorized to view the currently linked site (${siteId})`);
|
|
69
|
+
}
|
|
70
|
+
// missing
|
|
71
|
+
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
72
|
+
if (error_.status === 404) {
|
|
73
|
+
error(`The site this folder is linked to can't be found`);
|
|
74
|
+
}
|
|
75
|
+
// @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message
|
|
76
|
+
error(error_);
|
|
73
77
|
}
|
|
74
|
-
//
|
|
75
|
-
if (
|
|
76
|
-
|
|
78
|
+
// Json only logs out if --json flag is passed
|
|
79
|
+
if (options.json) {
|
|
80
|
+
logJson({
|
|
81
|
+
account: cleanAccountData,
|
|
82
|
+
siteData: {
|
|
83
|
+
'site-name': `${siteData.name}`,
|
|
84
|
+
'config-path': site.configPath,
|
|
85
|
+
'admin-url': siteData.admin_url,
|
|
86
|
+
'site-url': siteData.ssl_url || siteData.url,
|
|
87
|
+
'site-id': siteData.id,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
77
90
|
}
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Json only logs out if --json flag is passed
|
|
82
|
-
if (options.json) {
|
|
83
|
-
logJson({
|
|
84
|
-
account: cleanAccountData,
|
|
85
|
-
siteData: {
|
|
86
|
-
'site-name': `${siteData.name}`,
|
|
87
|
-
'config-path': site.configPath,
|
|
88
|
-
'admin-url': siteData.admin_url,
|
|
89
|
-
'site-url': siteData.ssl_url || siteData.url,
|
|
90
|
-
'site-id': siteData.id,
|
|
91
|
-
},
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
log(`────────────────────┐
|
|
91
|
+
log(`────────────────────┐
|
|
96
92
|
Netlify Site Info │
|
|
97
|
-
────────────────────┘`)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
log()
|
|
108
|
-
}
|
|
109
|
-
|
|
93
|
+
────────────────────┘`);
|
|
94
|
+
log(prettyjson.render({
|
|
95
|
+
'Current site': `${siteData.name}`,
|
|
96
|
+
'Netlify TOML': site.configPath,
|
|
97
|
+
'Admin URL': chalk.magentaBright(siteData.admin_url),
|
|
98
|
+
'Site URL': chalk.cyanBright(siteData.ssl_url || siteData.url),
|
|
99
|
+
'Site Id': chalk.yellowBright(siteData.id),
|
|
100
|
+
}));
|
|
101
|
+
log();
|
|
102
|
+
};
|
|
110
103
|
/**
|
|
111
104
|
* Creates the `netlify status` command
|
|
112
105
|
* @param {import('../base-command.mjs').default} program
|
|
113
106
|
* @returns
|
|
114
107
|
*/
|
|
108
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
115
109
|
export const createStatusCommand = (program) => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
110
|
+
createStatusHooksCommand(program);
|
|
111
|
+
return program
|
|
112
|
+
.command('status')
|
|
113
|
+
.description('Print status information')
|
|
114
|
+
.option('--verbose', 'Output system info')
|
|
115
|
+
.action(status);
|
|
116
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createSwitchCommand } from './switch.mjs'
|
|
1
|
+
export { createSwitchCommand } from './switch.mjs';
|
|
@@ -1,48 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { login } from '../login/index.mjs'
|
|
6
|
-
|
|
7
|
-
const LOGIN_NEW = 'I would like to login to a new account'
|
|
8
|
-
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import { chalk, log } from '../../utils/command-helpers.mjs';
|
|
3
|
+
import { login } from '../login/index.mjs';
|
|
4
|
+
const LOGIN_NEW = 'I would like to login to a new account';
|
|
9
5
|
/**
|
|
10
6
|
* The switch command
|
|
11
7
|
* @param {import('commander').OptionValues} options
|
|
12
8
|
* @param {import('../base-command.mjs').default} command
|
|
13
9
|
*/
|
|
10
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
|
|
14
11
|
const switchCommand = async (options, command) => {
|
|
15
|
-
|
|
16
|
-
(
|
|
17
|
-
|
|
18
|
-
{}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
12
|
+
const availableUsersChoices = Object.values(command.netlify.globalConfig.get('users') || {}).reduce((prev, current) =>
|
|
13
|
+
// @ts-expect-error TS(2769) FIXME: No overload matches this call.
|
|
14
|
+
Object.assign(prev, { [current.id]: current.name ? `${current.name} (${current.email})` : current.email }), {});
|
|
15
|
+
const { accountSwitchChoice } = await inquirer.prompt([
|
|
16
|
+
{
|
|
17
|
+
type: 'list',
|
|
18
|
+
name: 'accountSwitchChoice',
|
|
19
|
+
message: 'Please select the account you want to use:',
|
|
20
|
+
// @ts-expect-error TS(2769) FIXME: No overload matches this call.
|
|
21
|
+
choices: [...Object.entries(availableUsersChoices).map(([, val]) => val), LOGIN_NEW],
|
|
22
|
+
},
|
|
23
|
+
]);
|
|
24
|
+
if (accountSwitchChoice === LOGIN_NEW) {
|
|
25
|
+
await login({ new: true }, command);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// @ts-expect-error TS(2769) FIXME: No overload matches this call.
|
|
29
|
+
const selectedAccount = Object.entries(availableUsersChoices).find(([, availableUsersChoice]) => availableUsersChoice === accountSwitchChoice);
|
|
30
|
+
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
31
|
+
command.netlify.globalConfig.set('userId', selectedAccount[0]);
|
|
32
|
+
log('');
|
|
33
|
+
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
34
|
+
log(`You're now using ${chalk.bold(selectedAccount[1])}.`);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
42
37
|
/**
|
|
43
38
|
* Creates the `netlify switch` command
|
|
44
39
|
* @param {import('../base-command.mjs').default} program
|
|
45
40
|
* @returns
|
|
46
41
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
43
|
+
export const createSwitchCommand = (program) => program.command('switch').description('Switch your active Netlify account').action(switchCommand);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { NetlifyTOML } from '@netlify/build-info'
|
|
2
|
+
import type { NetlifyAPI } from 'netlify'
|
|
3
|
+
|
|
4
|
+
import StateConfig from '../utils/state-config.mjs'
|
|
5
|
+
|
|
6
|
+
export type NetlifySite = {
|
|
7
|
+
root?: string
|
|
8
|
+
configPath?: string
|
|
9
|
+
siteId?: string
|
|
10
|
+
get id(): string | undefined
|
|
11
|
+
set id(id: string): void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The netlify object inside each command with the state
|
|
16
|
+
*/
|
|
17
|
+
export type NetlifyOptions = {
|
|
18
|
+
api: NetlifyAPI
|
|
19
|
+
apiOpts: unknown
|
|
20
|
+
repositoryRoot: string
|
|
21
|
+
/** Absolute path of the netlify configuration file */
|
|
22
|
+
configFilePath: string
|
|
23
|
+
/** Relative path of the netlify configuration file */
|
|
24
|
+
relConfigFilePath: string
|
|
25
|
+
site: NetlifySite
|
|
26
|
+
siteInfo: unknown
|
|
27
|
+
config: NetlifyTOML
|
|
28
|
+
cachedConfig: Record<string, unknown>
|
|
29
|
+
globalConfig: unknown
|
|
30
|
+
state: StateConfig
|
|
31
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createUnlinkCommand } from './unlink.mjs'
|
|
1
|
+
export { createUnlinkCommand } from './unlink.mjs';
|
|
@@ -1,40 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { track } from '../../utils/telemetry/index.mjs'
|
|
4
|
-
|
|
1
|
+
import { exit, log } from '../../utils/command-helpers.mjs';
|
|
2
|
+
import { track } from '../../utils/telemetry/index.mjs';
|
|
5
3
|
/**
|
|
6
4
|
* The unlink command
|
|
7
5
|
* @param {import('commander').OptionValues} options
|
|
8
6
|
* @param {import('../base-command.mjs').default} command
|
|
9
7
|
*/
|
|
8
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
|
|
10
9
|
const unlink = async (options, command) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} else {
|
|
30
|
-
log('Unlinked site')
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
10
|
+
const { site, siteInfo, state } = command.netlify;
|
|
11
|
+
const siteId = site.id;
|
|
12
|
+
if (!siteId) {
|
|
13
|
+
log(`Folder is not linked to a Netlify site. Run 'netlify link' to link it`);
|
|
14
|
+
return exit();
|
|
15
|
+
}
|
|
16
|
+
const siteData = siteInfo;
|
|
17
|
+
state.delete('siteId');
|
|
18
|
+
await track('sites_unlinked', {
|
|
19
|
+
siteId: siteData.id || siteId,
|
|
20
|
+
});
|
|
21
|
+
if (site) {
|
|
22
|
+
log(`Unlinked ${site.configPath} from ${siteData ? siteData.name : siteId}`);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
log('Unlinked site');
|
|
26
|
+
}
|
|
27
|
+
};
|
|
34
28
|
/**
|
|
35
29
|
* Creates the `netlify unlink` command
|
|
36
30
|
* @param {import('../base-command.mjs').default} program
|
|
37
31
|
* @returns
|
|
38
32
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
34
|
+
export const createUnlinkCommand = (program) => program.command('unlink').description('Unlink a local folder from a Netlify site').action(unlink);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createWatchCommand } from './watch.mjs'
|
|
1
|
+
export { createWatchCommand } from './watch.mjs';
|