netlify-cli 17.3.2 → 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 +2 -138
- package/npm-shrinkwrap.json +76 -76
- 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 -99
- 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,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import openBrowser from '../../utils/open-browser.mjs'
|
|
5
|
-
|
|
1
|
+
import { ADDON_VALIDATION, prepareAddonCommand } from '../../utils/addons/prepare.mjs';
|
|
2
|
+
import { exit, log } from '../../utils/command-helpers.mjs';
|
|
3
|
+
import openBrowser from '../../utils/open-browser.mjs';
|
|
6
4
|
/**
|
|
7
5
|
* The addons:auth command
|
|
8
6
|
* @param {string} addonName
|
|
@@ -10,39 +8,38 @@ import openBrowser from '../../utils/open-browser.mjs'
|
|
|
10
8
|
* @param {import('../base-command.mjs').default} command
|
|
11
9
|
* @returns {Promise<boolean>}
|
|
12
10
|
*/
|
|
11
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message
|
|
13
12
|
const addonsAuth = async (addonName, options, command) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
exit()
|
|
33
|
-
}
|
|
34
|
-
|
|
13
|
+
const { addon } = await prepareAddonCommand({
|
|
14
|
+
command,
|
|
15
|
+
addonName,
|
|
16
|
+
validation: ADDON_VALIDATION.EXISTS,
|
|
17
|
+
});
|
|
18
|
+
if (!addon.auth_url) {
|
|
19
|
+
log(`No Admin URL found for the "${addonName} add-on"`);
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
log();
|
|
23
|
+
log(`Opening ${addonName} add-on admin URL:`);
|
|
24
|
+
log();
|
|
25
|
+
log(addon.auth_url);
|
|
26
|
+
log();
|
|
27
|
+
// @ts-expect-error TS(2345) FIXME: Argument of type '{ url: any; }' is not assignable... Remove this comment to see the full error message
|
|
28
|
+
await openBrowser({ url: addon.auth_url });
|
|
29
|
+
exit();
|
|
30
|
+
};
|
|
35
31
|
/**
|
|
36
32
|
* Creates the `netlify addons:auth` command
|
|
37
33
|
* @param {import('../base-command.mjs').default} program
|
|
38
34
|
* @returns
|
|
39
35
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
37
|
+
export const createAddonsAuthCommand = (program) => program
|
|
42
38
|
.command('addons:auth', { hidden: true })
|
|
43
39
|
.alias('addon:auth')
|
|
44
40
|
.argument('<name>', 'Add-on slug')
|
|
45
41
|
.description('Login to add-on provider')
|
|
42
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message
|
|
46
43
|
.action(async (addonName, options, command) => {
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
await addonsAuth(addonName, options, command);
|
|
45
|
+
});
|
|
@@ -1,42 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
import { parseRawFlags } from '../../utils/parse-raw-flags.mjs'
|
|
13
|
-
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import isEmpty from 'lodash/isEmpty.js';
|
|
3
|
+
import compare from '../../utils/addons/compare.mjs';
|
|
4
|
+
import diffValues from '../../utils/addons/diffs/index.mjs';
|
|
5
|
+
import { ADDON_VALIDATION, prepareAddonCommand } from '../../utils/addons/prepare.mjs';
|
|
6
|
+
import generatePrompts from '../../utils/addons/prompts.mjs';
|
|
7
|
+
import { renderConfigValues } from '../../utils/addons/render.mjs';
|
|
8
|
+
import { missingConfigValues, requiredConfigValues, updateConfigValues } from '../../utils/addons/validation.mjs';
|
|
9
|
+
import { chalk, error, log } from '../../utils/command-helpers.mjs';
|
|
10
|
+
import { parseRawFlags } from '../../utils/parse-raw-flags.mjs';
|
|
11
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'addonName' implicitly has an 'any... Remove this comment to see the full error message
|
|
14
12
|
const update = async function ({ addonName, api, currentConfig, instanceId, newConfig, siteId }) {
|
|
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
|
-
|
|
13
|
+
const codeDiff = diffValues(currentConfig, newConfig);
|
|
14
|
+
if (!codeDiff) {
|
|
15
|
+
log('No changes, exiting early');
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
log();
|
|
19
|
+
const msg = `Updating ${addonName} add-on config values...`;
|
|
20
|
+
log(`${chalk.white.bold(msg)}`);
|
|
21
|
+
log();
|
|
22
|
+
log(`${codeDiff}\n`);
|
|
23
|
+
log();
|
|
24
|
+
try {
|
|
25
|
+
await api.updateServiceInstance({
|
|
26
|
+
siteId,
|
|
27
|
+
addon: addonName,
|
|
28
|
+
instanceId,
|
|
29
|
+
body: { config: newConfig },
|
|
30
|
+
});
|
|
31
|
+
log(`Add-on "${addonName}" successfully updated`);
|
|
32
|
+
}
|
|
33
|
+
catch (error_) {
|
|
34
|
+
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
35
|
+
error(error_.message);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
40
38
|
/**
|
|
41
39
|
* The addons:config command
|
|
42
40
|
* @param {string} addonName
|
|
@@ -44,136 +42,129 @@ const update = async function ({ addonName, api, currentConfig, instanceId, newC
|
|
|
44
42
|
* @param {import('../base-command.mjs').default} command
|
|
45
43
|
* @returns {Promise<boolean>}
|
|
46
44
|
*/
|
|
45
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message
|
|
47
46
|
const addonsConfig = async (addonName, options, command) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
addonName,
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
validation: ADDON_VALIDATION.EXISTS,
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const { api, site } = command.netlify
|
|
56
|
-
const siteId = site.id
|
|
57
|
-
|
|
58
|
-
const hasConfig = !isEmpty(manifest.config)
|
|
59
|
-
// Parse flags
|
|
60
|
-
const rawFlags = parseRawFlags(command.args)
|
|
61
|
-
// Get Existing Config
|
|
62
|
-
const currentConfig = addon.config || {}
|
|
63
|
-
|
|
64
|
-
const words = `Current "${addonName} add-on" Settings:`
|
|
65
|
-
log(` ${chalk.yellowBright.bold(words)}`)
|
|
66
|
-
if (hasConfig) {
|
|
67
|
-
if (!rawFlags.silent) {
|
|
68
|
-
renderConfigValues(addonName, manifest.config, currentConfig)
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
// For addons without manifest. TODO remove once we enforce manifests
|
|
72
|
-
Object.keys(currentConfig).forEach((key) => {
|
|
73
|
-
log(`${key} - ${currentConfig[key]}`)
|
|
74
|
-
})
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (hasConfig) {
|
|
78
|
-
const required = requiredConfigValues(manifest.config)
|
|
79
|
-
const missingValues = missingConfigValues(required, rawFlags)
|
|
80
|
-
|
|
81
|
-
/* Config set by command line flags */
|
|
82
|
-
if (rawFlags && missingValues.length === 0) {
|
|
83
|
-
const newConfig = updateConfigValues(manifest.config, currentConfig, rawFlags)
|
|
84
|
-
|
|
85
|
-
await update({
|
|
47
|
+
const { addon, manifest, siteData } = await prepareAddonCommand({
|
|
48
|
+
command,
|
|
86
49
|
addonName,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
},
|
|
103
|
-
])
|
|
104
|
-
if (!updatePrompt.updateNow) {
|
|
105
|
-
log('Sounds good! Exiting configuration...')
|
|
106
|
-
return false
|
|
50
|
+
validation: ADDON_VALIDATION.EXISTS,
|
|
51
|
+
});
|
|
52
|
+
const { api, site } = command.netlify;
|
|
53
|
+
const siteId = site.id;
|
|
54
|
+
const hasConfig = !isEmpty(manifest.config);
|
|
55
|
+
// Parse flags
|
|
56
|
+
const rawFlags = parseRawFlags(command.args);
|
|
57
|
+
// Get Existing Config
|
|
58
|
+
const currentConfig = addon.config || {};
|
|
59
|
+
const words = `Current "${addonName} add-on" Settings:`;
|
|
60
|
+
log(` ${chalk.yellowBright.bold(words)}`);
|
|
61
|
+
if (hasConfig) {
|
|
62
|
+
if (!rawFlags.silent) {
|
|
63
|
+
renderConfigValues(addonName, manifest.config, currentConfig);
|
|
64
|
+
}
|
|
107
65
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
log(` You will need to verify the changed before we push them to your live site!`)
|
|
114
|
-
log()
|
|
115
|
-
const prompts = generatePrompts({
|
|
116
|
-
config: manifest.config,
|
|
117
|
-
configValues: currentConfig,
|
|
118
|
-
})
|
|
119
|
-
const userInput = await inquirer.prompt(prompts)
|
|
120
|
-
// Merge user input with the flags specified
|
|
121
|
-
const newConfig = updateConfigValues(manifest.config, currentConfig, userInput)
|
|
122
|
-
|
|
123
|
-
const diffs = compare(currentConfig, newConfig)
|
|
124
|
-
// log('compare', diffs)
|
|
125
|
-
if (diffs.isEqual) {
|
|
126
|
-
log(`No changes. exiting early`)
|
|
127
|
-
return false
|
|
66
|
+
else {
|
|
67
|
+
// For addons without manifest. TODO remove once we enforce manifests
|
|
68
|
+
Object.keys(currentConfig).forEach((key) => {
|
|
69
|
+
log(`${key} - ${currentConfig[key]}`);
|
|
70
|
+
});
|
|
128
71
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
72
|
+
if (hasConfig) {
|
|
73
|
+
const required = requiredConfigValues(manifest.config);
|
|
74
|
+
const missingValues = missingConfigValues(required, rawFlags);
|
|
75
|
+
/* Config set by command line flags */
|
|
76
|
+
if (rawFlags && missingValues.length === 0) {
|
|
77
|
+
const newConfig = updateConfigValues(manifest.config, currentConfig, rawFlags);
|
|
78
|
+
await update({
|
|
79
|
+
addonName,
|
|
80
|
+
currentConfig,
|
|
81
|
+
newConfig,
|
|
82
|
+
siteId,
|
|
83
|
+
instanceId: addon.id,
|
|
84
|
+
api,
|
|
85
|
+
});
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
const updatePrompt = await inquirer.prompt([
|
|
89
|
+
{
|
|
90
|
+
type: 'confirm',
|
|
91
|
+
name: 'updateNow',
|
|
92
|
+
message: `Do you want to update config values?`,
|
|
93
|
+
default: false,
|
|
94
|
+
},
|
|
95
|
+
]);
|
|
96
|
+
if (!updatePrompt.updateNow) {
|
|
97
|
+
log('Sounds good! Exiting configuration...');
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
log();
|
|
101
|
+
log(` - Hit ${chalk.white.bold('enter')} to keep the existing value in (parentheses)`);
|
|
102
|
+
log(` - Hit ${chalk.white.bold('down arrow')} to remove the value`);
|
|
103
|
+
log(` - Hit ${chalk.white.bold('ctrl + C')} to cancel & exit configuration`);
|
|
104
|
+
log();
|
|
105
|
+
log(` You will need to verify the changed before we push them to your live site!`);
|
|
106
|
+
log();
|
|
107
|
+
const prompts = generatePrompts({
|
|
108
|
+
config: manifest.config,
|
|
109
|
+
configValues: currentConfig,
|
|
110
|
+
});
|
|
111
|
+
const userInput = await inquirer.prompt(prompts);
|
|
112
|
+
// Merge user input with the flags specified
|
|
113
|
+
const newConfig = updateConfigValues(manifest.config, currentConfig, userInput);
|
|
114
|
+
const diffs = compare(currentConfig, newConfig);
|
|
115
|
+
// log('compare', diffs)
|
|
116
|
+
// @ts-expect-error TS(2339) FIXME: Property 'isEqual' does not exist on type 'string'... Remove this comment to see the full error message
|
|
117
|
+
if (diffs.isEqual) {
|
|
118
|
+
log(`No changes. exiting early`);
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
log();
|
|
122
|
+
log(`${chalk.yellowBright.bold.underline('Confirm your updates:')}`);
|
|
123
|
+
log();
|
|
124
|
+
// @ts-expect-error TS(2339) FIXME: Property 'keys' does not exist on type 'string'.
|
|
125
|
+
diffs.keys.forEach((key) => {
|
|
126
|
+
// @ts-expect-error TS(2339) FIXME: Property 'diffs' does not exist on type 'string'.
|
|
127
|
+
const { newValue, oldValue } = diffs.diffs[key];
|
|
128
|
+
const oldVal = oldValue || 'NO VALUE';
|
|
129
|
+
log(`${chalk.cyan(key)} changed from ${chalk.whiteBright(oldVal)} to ${chalk.green(newValue)}`);
|
|
130
|
+
});
|
|
131
|
+
log();
|
|
132
|
+
const confirmPrompt = await inquirer.prompt([
|
|
133
|
+
{
|
|
134
|
+
type: 'confirm',
|
|
135
|
+
name: 'confirmChange',
|
|
136
|
+
message: `Do you want to publish the updated "${addonName} add-on" settings for ${chalk.cyan(siteData.name)}?`,
|
|
137
|
+
default: false,
|
|
138
|
+
},
|
|
139
|
+
]);
|
|
140
|
+
if (!confirmPrompt.confirmChange) {
|
|
141
|
+
log('Canceling changes... You are good to go!');
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
await update({
|
|
145
|
+
addonName,
|
|
146
|
+
currentConfig,
|
|
147
|
+
newConfig,
|
|
148
|
+
siteId,
|
|
149
|
+
instanceId: addon.id,
|
|
150
|
+
api,
|
|
151
|
+
});
|
|
151
152
|
}
|
|
152
|
-
|
|
153
|
-
await update({
|
|
154
|
-
addonName,
|
|
155
|
-
currentConfig,
|
|
156
|
-
newConfig,
|
|
157
|
-
siteId,
|
|
158
|
-
instanceId: addon.id,
|
|
159
|
-
api,
|
|
160
|
-
})
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
153
|
+
};
|
|
164
154
|
/**
|
|
165
155
|
* Creates the `netlify addons:config` command
|
|
166
156
|
* @param {import('../base-command.mjs').default} program
|
|
167
157
|
* @returns
|
|
168
158
|
*/
|
|
169
|
-
|
|
170
|
-
|
|
159
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
160
|
+
export const createAddonsConfigCommand = (program) => program
|
|
171
161
|
.command('addons:config', { hidden: true })
|
|
172
162
|
.alias('addon:config')
|
|
173
163
|
.argument('<name>', 'Add-on namespace')
|
|
174
164
|
.description('Configure add-on settings')
|
|
175
165
|
// allow for any flags. Handy for variadic configuration options
|
|
176
166
|
.allowUnknownOption(true)
|
|
167
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message
|
|
177
168
|
.action(async (addonName, options, command) => {
|
|
178
|
-
|
|
179
|
-
|
|
169
|
+
await addonsConfig(addonName, options, command);
|
|
170
|
+
});
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
import { parseRawFlags } from '../../utils/parse-raw-flags.mjs'
|
|
11
|
-
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import isEmpty from 'lodash/isEmpty.js';
|
|
3
|
+
import { ADDON_VALIDATION, prepareAddonCommand } from '../../utils/addons/prepare.mjs';
|
|
4
|
+
import generatePrompts from '../../utils/addons/prompts.mjs';
|
|
5
|
+
import { renderConfigValues, renderMissingValues } from '../../utils/addons/render.mjs';
|
|
6
|
+
import { missingConfigValues, requiredConfigValues, updateConfigValues } from '../../utils/addons/validation.mjs';
|
|
7
|
+
import { chalk, error, log } from '../../utils/command-helpers.mjs';
|
|
8
|
+
import { parseRawFlags } from '../../utils/parse-raw-flags.mjs';
|
|
9
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'addonName' implicitly has an 'any... Remove this comment to see the full error message
|
|
12
10
|
const createAddon = async ({ addonName, api, config, siteData, siteId }) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
try {
|
|
12
|
+
const response = await api.createServiceInstance({
|
|
13
|
+
siteId,
|
|
14
|
+
addon: addonName,
|
|
15
|
+
body: { config },
|
|
16
|
+
});
|
|
17
|
+
log(`Add-on "${addonName}" created for ${siteData.name}`);
|
|
18
|
+
if (response.config && response.config.message) {
|
|
19
|
+
log();
|
|
20
|
+
log(`${response.config.message}`);
|
|
21
|
+
}
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
23
|
+
catch (error_) {
|
|
24
|
+
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
25
|
+
error(error_.message);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
29
28
|
/**
|
|
30
29
|
* The addons:create command
|
|
31
30
|
* @param {string} addonName
|
|
@@ -33,98 +32,85 @@ const createAddon = async ({ addonName, api, config, siteData, siteId }) => {
|
|
|
33
32
|
* @param {import('../base-command.mjs').default} command
|
|
34
33
|
* @returns {Promise<boolean>}
|
|
35
34
|
*/
|
|
35
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message
|
|
36
36
|
const addonsCreate = async (addonName, options, command) => {
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
log()
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const userInput = await inquirer.prompt(prompts)
|
|
98
|
-
// Merge user input with the flags specified
|
|
99
|
-
configValues = updateConfigValues(manifest.config, rawFlags, userInput)
|
|
100
|
-
const missingRequiredValues = missingConfigValues(required, configValues)
|
|
101
|
-
if (missingRequiredValues && missingRequiredValues.length !== 0) {
|
|
102
|
-
missingRequiredValues.forEach((val) => {
|
|
103
|
-
log(`Missing required value "${val}". Please run the command again`)
|
|
104
|
-
})
|
|
105
|
-
return false
|
|
37
|
+
const { manifest, siteData } = await prepareAddonCommand({
|
|
38
|
+
command,
|
|
39
|
+
addonName,
|
|
40
|
+
validation: ADDON_VALIDATION.NOT_EXISTS,
|
|
41
|
+
});
|
|
42
|
+
const { api, site } = command.netlify;
|
|
43
|
+
const siteId = site.id;
|
|
44
|
+
// GET flags from `raw` data
|
|
45
|
+
const rawFlags = parseRawFlags(command.args);
|
|
46
|
+
const hasConfig = !isEmpty(manifest.config);
|
|
47
|
+
let configValues = rawFlags;
|
|
48
|
+
if (hasConfig) {
|
|
49
|
+
const required = requiredConfigValues(manifest.config);
|
|
50
|
+
const missingValues = missingConfigValues(required, rawFlags);
|
|
51
|
+
log(`Starting the setup for "${addonName} add-on"`);
|
|
52
|
+
log();
|
|
53
|
+
if (Object.keys(rawFlags).length !== 0) {
|
|
54
|
+
const newConfig = updateConfigValues(manifest.config, {}, rawFlags);
|
|
55
|
+
if (missingValues.length !== 0) {
|
|
56
|
+
/* Warn user of missing required values */
|
|
57
|
+
log(`${chalk.redBright.underline.bold(`Error: Missing required configuration for "${addonName} add-on"`)}`);
|
|
58
|
+
log();
|
|
59
|
+
renderMissingValues(missingValues, manifest);
|
|
60
|
+
log();
|
|
61
|
+
const msg = `netlify addons:create ${addonName}`;
|
|
62
|
+
log(`Please supply the configuration values as CLI flags`);
|
|
63
|
+
log();
|
|
64
|
+
log(`Alternatively, you can run ${chalk.cyan(msg)} with no flags to walk through the setup steps`);
|
|
65
|
+
log();
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
await createAddon({ api, siteId, addonName, config: newConfig, siteData });
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const words = `The ${addonName} add-on has the following configurable options:`;
|
|
72
|
+
log(` ${chalk.yellowBright.bold(words)}`);
|
|
73
|
+
// @ts-expect-error TS(2554) FIXME: Expected 3 arguments, but got 2.
|
|
74
|
+
renderConfigValues(addonName, manifest.config);
|
|
75
|
+
log();
|
|
76
|
+
log(` ${chalk.greenBright.bold('Lets configure those!')}`);
|
|
77
|
+
log();
|
|
78
|
+
log(` - Hit ${chalk.white.bold('enter')} to confirm value or set empty value`);
|
|
79
|
+
log(` - Hit ${chalk.white.bold('ctrl + C')} to cancel & exit configuration`);
|
|
80
|
+
log();
|
|
81
|
+
const prompts = generatePrompts({
|
|
82
|
+
config: manifest.config,
|
|
83
|
+
configValues: rawFlags,
|
|
84
|
+
});
|
|
85
|
+
const userInput = await inquirer.prompt(prompts);
|
|
86
|
+
// Merge user input with the flags specified
|
|
87
|
+
configValues = updateConfigValues(manifest.config, rawFlags, userInput);
|
|
88
|
+
const missingRequiredValues = missingConfigValues(required, configValues);
|
|
89
|
+
if (missingRequiredValues && missingRequiredValues.length !== 0) {
|
|
90
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'val' implicitly has an 'any' type.
|
|
91
|
+
missingRequiredValues.forEach((val) => {
|
|
92
|
+
log(`Missing required value "${val}". Please run the command again`);
|
|
93
|
+
});
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
106
96
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
await createAddon({ api, siteId, addonName, config: configValues, siteData })
|
|
110
|
-
}
|
|
111
|
-
|
|
97
|
+
await createAddon({ api, siteId, addonName, config: configValues, siteData });
|
|
98
|
+
};
|
|
112
99
|
/**
|
|
113
100
|
* Creates the `netlify addons:create` command
|
|
114
101
|
* @param {import('../base-command.mjs').default} program
|
|
115
102
|
* @returns
|
|
116
103
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
104
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
105
|
+
export const createAddonsCreateCommand = (program) => program
|
|
119
106
|
.command('addons:create', { hidden: true })
|
|
120
107
|
.alias('addon:create')
|
|
121
108
|
.argument('<name>', 'Add-on namespace')
|
|
122
|
-
.description(
|
|
123
|
-
|
|
124
|
-
Add-ons are a way to extend the functionality of your Netlify site`,
|
|
125
|
-
)
|
|
109
|
+
.description(`Add an add-on extension to your site
|
|
110
|
+
Add-ons are a way to extend the functionality of your Netlify site`)
|
|
126
111
|
// allow for any flags. Handy for variadic configuration options
|
|
127
112
|
.allowUnknownOption(true)
|
|
113
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message
|
|
128
114
|
.action(async (addonName, options, command) => {
|
|
129
|
-
|
|
130
|
-
|
|
115
|
+
await addonsCreate(addonName, options, command);
|
|
116
|
+
});
|