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,106 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { applySettings, getSettings, writeSettings } from './settings.mjs'
|
|
11
|
-
|
|
12
|
-
export const description = 'Create VS Code settings for an optimal experience with Netlify projects'
|
|
13
|
-
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { DenoBridge } from '@netlify/edge-bundler';
|
|
3
|
+
import execa from 'execa';
|
|
4
|
+
import inquirer from 'inquirer';
|
|
5
|
+
import { NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, error, log } from '../../utils/command-helpers.mjs';
|
|
6
|
+
import { applySettings, getSettings, writeSettings } from './settings.mjs';
|
|
7
|
+
export const description = 'Create VS Code settings for an optimal experience with Netlify projects';
|
|
8
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'fileExists' implicitly has an 'an... Remove this comment to see the full error message
|
|
14
9
|
const getPrompt = ({ fileExists, path }) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const getEdgeFunctionsPath = ({ config, repositoryRoot }) =>
|
|
29
|
-
config.build.edge_functions || join(repositoryRoot, 'netlify', 'edge-functions')
|
|
30
|
-
|
|
10
|
+
const formattedPath = chalk.underline(path);
|
|
11
|
+
const message = fileExists
|
|
12
|
+
? `There is a VS Code settings file at ${formattedPath}. Can we update it?`
|
|
13
|
+
: `A new VS Code settings file will be created at ${formattedPath}`;
|
|
14
|
+
return inquirer.prompt({
|
|
15
|
+
type: 'confirm',
|
|
16
|
+
name: 'confirm',
|
|
17
|
+
message,
|
|
18
|
+
default: true,
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message
|
|
22
|
+
const getEdgeFunctionsPath = ({ config, repositoryRoot }) => config.build.edge_functions || join(repositoryRoot, 'netlify', 'edge-functions');
|
|
31
23
|
/**
|
|
32
24
|
* @param {string} repositoryRoot
|
|
33
25
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'repositoryRoot' implicitly has an 'any'... Remove this comment to see the full error message
|
|
27
|
+
const getSettingsPath = (repositoryRoot) => join(repositoryRoot, '.vscode', 'settings.json');
|
|
36
28
|
/**
|
|
37
29
|
* @param {string} repositoryRoot
|
|
38
30
|
*/
|
|
31
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'repositoryRoot' implicitly has an 'any'... Remove this comment to see the full error message
|
|
39
32
|
const hasDenoVSCodeExt = async (repositoryRoot) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
33
|
+
const { stdout: extensions } = await execa('code', ['--list-extensions'], { stderr: 'inherit', cwd: repositoryRoot });
|
|
34
|
+
return extensions.split('\n').includes('denoland.vscode-deno');
|
|
35
|
+
};
|
|
44
36
|
/**
|
|
45
37
|
* @param {string} repositoryRoot
|
|
46
38
|
*/
|
|
39
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'repositoryRoot' implicitly has an 'any'... Remove this comment to see the full error message
|
|
47
40
|
const getDenoVSCodeExt = async (repositoryRoot) => {
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
41
|
+
await execa('code', ['--install-extension', 'denoland.vscode-deno'], { stdio: 'inherit', cwd: repositoryRoot });
|
|
42
|
+
};
|
|
51
43
|
const getDenoExtPrompt = () => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
44
|
+
const message = 'The Deno VS Code extension is recommended. Would you like to install it now?';
|
|
45
|
+
return inquirer.prompt({
|
|
46
|
+
type: 'confirm',
|
|
47
|
+
name: 'confirm',
|
|
48
|
+
message,
|
|
49
|
+
default: true,
|
|
50
|
+
});
|
|
51
|
+
};
|
|
62
52
|
/**
|
|
63
53
|
* @param {object} params
|
|
64
54
|
* @param {*} params.config
|
|
65
55
|
* @param {string} params.repositoryRoot
|
|
66
56
|
* @returns
|
|
67
57
|
*/
|
|
58
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message
|
|
68
59
|
export const run = async ({ config, repositoryRoot }) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (!confirm) {
|
|
81
|
-
return
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
if (!(await hasDenoVSCodeExt(repositoryRoot))) {
|
|
86
|
-
const { confirm: denoExtConfirm } = await getDenoExtPrompt()
|
|
87
|
-
if (denoExtConfirm) {
|
|
88
|
-
getDenoVSCodeExt(repositoryRoot)
|
|
89
|
-
}
|
|
60
|
+
const deno = new DenoBridge({
|
|
61
|
+
onBeforeDownload: () => log(`${NETLIFYDEVWARN} Setting up the Edge Functions environment. This may take a couple of minutes.`),
|
|
62
|
+
});
|
|
63
|
+
const denoBinary = await deno.getBinaryPath();
|
|
64
|
+
const settingsPath = getSettingsPath(repositoryRoot);
|
|
65
|
+
const edgeFunctionsPath = getEdgeFunctionsPath({ config, repositoryRoot });
|
|
66
|
+
const { fileExists, settings: existingSettings } = await getSettings(settingsPath);
|
|
67
|
+
const settings = applySettings(existingSettings, { denoBinary, edgeFunctionsPath, repositoryRoot });
|
|
68
|
+
const { confirm } = await getPrompt({ fileExists, path: settingsPath });
|
|
69
|
+
if (!confirm) {
|
|
70
|
+
return;
|
|
90
71
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
72
|
+
try {
|
|
73
|
+
if (!(await hasDenoVSCodeExt(repositoryRoot))) {
|
|
74
|
+
const { confirm: denoExtConfirm } = await getDenoExtPrompt();
|
|
75
|
+
if (denoExtConfirm) {
|
|
76
|
+
getDenoVSCodeExt(repositoryRoot);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
log(`${NETLIFYDEVWARN} Unable to install Deno VS Code extension. To install it manually, visit ${chalk.blue('https://ntl.fyi/deno-vscode')}.`);
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
await writeSettings({ settings, settingsPath });
|
|
85
|
+
log(`${NETLIFYDEVLOG} VS Code settings file ${fileExists ? 'updated' : 'created'}.`);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
error('Could not write VS Code settings file.');
|
|
89
|
+
}
|
|
90
|
+
};
|
|
@@ -1,65 +1,60 @@
|
|
|
1
|
-
import { mkdir, readFile, stat, writeFile } from 'fs/promises'
|
|
2
|
-
import { dirname, relative } from 'path'
|
|
3
|
-
|
|
1
|
+
import { mkdir, readFile, stat, writeFile } from 'fs/promises';
|
|
2
|
+
import { dirname, relative } from 'path';
|
|
4
3
|
// eslint-disable-next-line import/no-namespace
|
|
5
|
-
import * as JSONC from 'comment-json'
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import * as JSONC from 'comment-json';
|
|
5
|
+
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'unix... Remove this comment to see the full error message
|
|
6
|
+
import unixify from 'unixify';
|
|
7
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'existingSettings' implicitly has an 'an... Remove this comment to see the full error message
|
|
8
8
|
export const applySettings = (existingSettings, { denoBinary, edgeFunctionsPath, repositoryRoot }) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
settings['deno.enablePaths'].push(relativeEdgeFunctionsPath)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// If the Deno CLI binary isn't globally installed, we need to set the path
|
|
24
|
-
// to it in the settings file or the extension won't know where to find it.
|
|
25
|
-
// The only exception is when `deno.path` has already been defined, because
|
|
26
|
-
// we don't want to override that.
|
|
27
|
-
if (!denoBinary.global && settings['deno.path'] === undefined) {
|
|
28
|
-
settings['deno.path'] = denoBinary.path
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return settings
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const getSettings = async (settingsPath) => {
|
|
35
|
-
try {
|
|
36
|
-
const stats = await stat(settingsPath)
|
|
37
|
-
|
|
38
|
-
if (!stats.isFile()) {
|
|
39
|
-
throw new Error(`${settingsPath} is not a valid file.`)
|
|
9
|
+
const relativeEdgeFunctionsPath = unixify(relative(repositoryRoot, edgeFunctionsPath));
|
|
10
|
+
const settings = JSONC.assign(existingSettings, {
|
|
11
|
+
'deno.enable': true,
|
|
12
|
+
'deno.enablePaths': existingSettings['deno.enablePaths'] || [],
|
|
13
|
+
'deno.unstable': true,
|
|
14
|
+
'deno.importMap': '.netlify/edge-functions-import-map.json',
|
|
15
|
+
});
|
|
16
|
+
// If the Edge Functions path isn't already in `deno.enabledPaths`, let's add
|
|
17
|
+
// it.
|
|
18
|
+
if (!settings['deno.enablePaths'].includes(relativeEdgeFunctionsPath)) {
|
|
19
|
+
settings['deno.enablePaths'].push(relativeEdgeFunctionsPath);
|
|
40
20
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
21
|
+
// If the Deno CLI binary isn't globally installed, we need to set the path
|
|
22
|
+
// to it in the settings file or the extension won't know where to find it.
|
|
23
|
+
// The only exception is when `deno.path` has already been defined, because
|
|
24
|
+
// we don't want to override that.
|
|
25
|
+
if (!denoBinary.global && settings['deno.path'] === undefined) {
|
|
26
|
+
settings['deno.path'] = denoBinary.path;
|
|
47
27
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
28
|
+
return settings;
|
|
29
|
+
};
|
|
30
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'settingsPath' implicitly has an 'any' t... Remove this comment to see the full error message
|
|
31
|
+
export const getSettings = async (settingsPath) => {
|
|
32
|
+
try {
|
|
33
|
+
const stats = await stat(settingsPath);
|
|
34
|
+
if (!stats.isFile()) {
|
|
35
|
+
throw new Error(`${settingsPath} is not a valid file.`);
|
|
36
|
+
}
|
|
37
|
+
const file = await readFile(settingsPath, 'utf8');
|
|
38
|
+
return {
|
|
39
|
+
fileExists: true,
|
|
40
|
+
settings: JSONC.parse(file),
|
|
41
|
+
};
|
|
51
42
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
catch (error) {
|
|
44
|
+
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
45
|
+
if (error.code !== 'ENOENT') {
|
|
46
|
+
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
47
|
+
throw new Error(`Could not open VS Code settings file: ${error.message}`);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
fileExists: false,
|
|
51
|
+
settings: {},
|
|
52
|
+
};
|
|
56
53
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
};
|
|
55
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'settings' implicitly has an 'any'... Remove this comment to see the full error message
|
|
60
56
|
export const writeSettings = async ({ settings, settingsPath }) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
57
|
+
const serializedSettings = JSONC.stringify(settings, null, 2);
|
|
58
|
+
await mkdir(dirname(settingsPath), { recursive: true });
|
|
59
|
+
await writeFile(settingsPath, serializedSettings);
|
|
60
|
+
};
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
import isEqual from 'lodash/isEqual.js'
|
|
2
|
-
|
|
1
|
+
import isEqual from 'lodash/isEqual.js';
|
|
2
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'oldValues' implicitly has an 'any' type... Remove this comment to see the full error message
|
|
3
3
|
export default function compare(oldValues, newValues) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}, initialData)
|
|
4
|
+
const initialData = {
|
|
5
|
+
// default everything is equal
|
|
6
|
+
isEqual: true,
|
|
7
|
+
// Keys that are different
|
|
8
|
+
keys: [],
|
|
9
|
+
// Values of the keys that are different
|
|
10
|
+
diffs: {},
|
|
11
|
+
};
|
|
12
|
+
const oldKeys = Object.keys(oldValues);
|
|
13
|
+
const newKeys = Object.keys(newValues);
|
|
14
|
+
const set = new Set([...newKeys, ...oldKeys]);
|
|
15
|
+
// @ts-expect-error TS(2769) FIXME: No overload matches this call.
|
|
16
|
+
return [...set].reduce((acc, current) => {
|
|
17
|
+
// if values not deep equal. There are changes
|
|
18
|
+
if (!isEqual(newValues[current], oldValues[current])) {
|
|
19
|
+
return {
|
|
20
|
+
isEqual: false,
|
|
21
|
+
keys: [...acc.keys, current],
|
|
22
|
+
diffs: {
|
|
23
|
+
...acc.diffs,
|
|
24
|
+
[`${current}`]: {
|
|
25
|
+
newValue: newValues[current],
|
|
26
|
+
oldValue: oldValues[current],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return acc;
|
|
32
|
+
}, initialData);
|
|
34
33
|
}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
// @ts-
|
|
2
|
-
import concordance from 'concordance'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'conc... Remove this comment to see the full error message
|
|
2
|
+
import concordance from 'concordance';
|
|
3
|
+
import { concordanceDiffOptions, concordanceOptions } from './options.mjs';
|
|
4
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'actualDescriptor' implicitly has an 'an... Remove this comment to see the full error message
|
|
6
5
|
const formatDescriptorDiff = function (actualDescriptor, expectedDescriptor, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
6
|
+
const diffOptions = { ...options, ...concordanceDiffOptions };
|
|
7
|
+
return concordance.diffDescriptors(actualDescriptor, expectedDescriptor, diffOptions);
|
|
8
|
+
};
|
|
9
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'actual' implicitly has an 'any' type.
|
|
11
10
|
export default function diffValues(actual, expected) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const result = concordance.compare(actual, expected, concordanceOptions);
|
|
12
|
+
if (result.pass) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const actualDescriptor = result.actual || concordance.describe(actual, concordanceOptions);
|
|
16
|
+
const expectedDescriptor = result.expected || concordance.describe(expected, concordanceOptions);
|
|
17
|
+
// @ts-expect-error TS(2554) FIXME: Expected 3 arguments, but got 2.
|
|
18
|
+
return formatDescriptorDiff(actualDescriptor, expectedDescriptor);
|
|
20
19
|
}
|
|
@@ -1,108 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
import ansiStyles from 'ansi-styles'
|
|
1
|
+
import ansiStyles from 'ansi-styles';
|
|
3
2
|
// eslint-disable-next-line no-restricted-imports
|
|
4
|
-
import { Chalk } from 'chalk'
|
|
5
|
-
|
|
6
|
-
const forceColor = new Chalk({ level: 1 })
|
|
7
|
-
|
|
3
|
+
import { Chalk } from 'chalk';
|
|
4
|
+
const forceColor = new Chalk({ level: 1 });
|
|
8
5
|
const colorTheme = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
diffGutters: {
|
|
16
|
-
actual: `${forceColor.red('-')} `,
|
|
17
|
-
expected: `${forceColor.green('+')} `,
|
|
18
|
-
padding: ' ',
|
|
19
|
-
},
|
|
20
|
-
error: {
|
|
21
|
-
ctor: {
|
|
22
|
-
open: `${ansiStyles.grey.open}(`,
|
|
23
|
-
close: `)${ansiStyles.grey.close}`,
|
|
6
|
+
boolean: ansiStyles.yellow,
|
|
7
|
+
circular: forceColor.grey('[Circular]'),
|
|
8
|
+
date: {
|
|
9
|
+
invalid: forceColor.red('invalid'),
|
|
10
|
+
value: ansiStyles.blue,
|
|
24
11
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
stringTag: ansiStyles.magenta,
|
|
30
|
-
},
|
|
31
|
-
global: ansiStyles.magenta,
|
|
32
|
-
item: {
|
|
33
|
-
after: forceColor.grey(','),
|
|
34
|
-
},
|
|
35
|
-
list: {
|
|
36
|
-
openBracket: forceColor.grey('['),
|
|
37
|
-
closeBracket: forceColor.grey(']'),
|
|
38
|
-
},
|
|
39
|
-
mapEntry: {
|
|
40
|
-
after: forceColor.grey(','),
|
|
41
|
-
},
|
|
42
|
-
maxDepth: forceColor.grey('…'),
|
|
43
|
-
null: ansiStyles.yellow,
|
|
44
|
-
number: ansiStyles.yellow,
|
|
45
|
-
object: {
|
|
46
|
-
openBracket: forceColor.grey('{'),
|
|
47
|
-
closeBracket: forceColor.grey('}'),
|
|
48
|
-
ctor: ansiStyles.magenta,
|
|
49
|
-
stringTag: {
|
|
50
|
-
open: `${ansiStyles.magenta.open}@`,
|
|
51
|
-
close: ansiStyles.magenta.close,
|
|
12
|
+
diffGutters: {
|
|
13
|
+
actual: `${forceColor.red('-')} `,
|
|
14
|
+
expected: `${forceColor.green('+')} `,
|
|
15
|
+
padding: ' ',
|
|
52
16
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
17
|
+
error: {
|
|
18
|
+
ctor: {
|
|
19
|
+
open: `${ansiStyles.grey.open}(`,
|
|
20
|
+
close: `)${ansiStyles.grey.close}`,
|
|
21
|
+
},
|
|
22
|
+
name: ansiStyles.magenta,
|
|
56
23
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
keyBracket: { open: forceColor.grey('['), close: forceColor.grey(']') },
|
|
61
|
-
valueFallback: forceColor.grey('…'),
|
|
62
|
-
},
|
|
63
|
-
regexp: {
|
|
64
|
-
source: {
|
|
65
|
-
open: `${ansiStyles.blue.open}/`,
|
|
66
|
-
close: `/${ansiStyles.blue.close}`,
|
|
24
|
+
function: {
|
|
25
|
+
name: ansiStyles.blue,
|
|
26
|
+
stringTag: ansiStyles.magenta,
|
|
67
27
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
string: {
|
|
72
|
-
open: ansiStyles.white.open,
|
|
73
|
-
close: ansiStyles.white.close,
|
|
74
|
-
line: { open: forceColor.white("'"), close: forceColor.white("'") },
|
|
75
|
-
multiline: { start: forceColor.white('`'), end: forceColor.white('`') },
|
|
76
|
-
controlPicture: ansiStyles.grey,
|
|
77
|
-
diff: {
|
|
78
|
-
insert: {
|
|
79
|
-
open: ansiStyles.bgGreen.open + ansiStyles.black.open,
|
|
80
|
-
close: ansiStyles.black.close + ansiStyles.bgGreen.close,
|
|
81
|
-
},
|
|
82
|
-
delete: {
|
|
83
|
-
open: ansiStyles.bgRed.open + ansiStyles.black.open,
|
|
84
|
-
close: ansiStyles.black.close + ansiStyles.bgRed.close,
|
|
85
|
-
},
|
|
86
|
-
equal: ansiStyles.white,
|
|
87
|
-
insertLine: {
|
|
88
|
-
open: ansiStyles.green.open,
|
|
89
|
-
close: ansiStyles.green.close,
|
|
90
|
-
},
|
|
91
|
-
deleteLine: {
|
|
92
|
-
open: ansiStyles.red.open,
|
|
93
|
-
close: ansiStyles.red.close,
|
|
94
|
-
},
|
|
28
|
+
global: ansiStyles.magenta,
|
|
29
|
+
item: {
|
|
30
|
+
after: forceColor.grey(','),
|
|
95
31
|
},
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
32
|
+
list: {
|
|
33
|
+
openBracket: forceColor.grey('['),
|
|
34
|
+
closeBracket: forceColor.grey(']'),
|
|
35
|
+
},
|
|
36
|
+
mapEntry: {
|
|
37
|
+
after: forceColor.grey(','),
|
|
38
|
+
},
|
|
39
|
+
maxDepth: forceColor.grey('…'),
|
|
40
|
+
null: ansiStyles.yellow,
|
|
41
|
+
number: ansiStyles.yellow,
|
|
42
|
+
object: {
|
|
43
|
+
openBracket: forceColor.grey('{'),
|
|
44
|
+
closeBracket: forceColor.grey('}'),
|
|
45
|
+
ctor: ansiStyles.magenta,
|
|
46
|
+
stringTag: {
|
|
47
|
+
open: `${ansiStyles.magenta.open}@`,
|
|
48
|
+
close: ansiStyles.magenta.close,
|
|
49
|
+
},
|
|
50
|
+
secondaryStringTag: {
|
|
51
|
+
open: `${ansiStyles.grey.open}@`,
|
|
52
|
+
close: ansiStyles.grey.close,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
property: {
|
|
56
|
+
after: forceColor.grey(','),
|
|
57
|
+
keyBracket: { open: forceColor.grey('['), close: forceColor.grey(']') },
|
|
58
|
+
valueFallback: forceColor.grey('…'),
|
|
59
|
+
},
|
|
60
|
+
regexp: {
|
|
61
|
+
source: {
|
|
62
|
+
open: `${ansiStyles.blue.open}/`,
|
|
63
|
+
close: `/${ansiStyles.blue.close}`,
|
|
64
|
+
},
|
|
65
|
+
flags: ansiStyles.yellow,
|
|
66
|
+
},
|
|
67
|
+
stats: { separator: forceColor.grey('---') },
|
|
68
|
+
string: {
|
|
69
|
+
open: ansiStyles.white.open,
|
|
70
|
+
close: ansiStyles.white.close,
|
|
71
|
+
line: { open: forceColor.white("'"), close: forceColor.white("'") },
|
|
72
|
+
multiline: { start: forceColor.white('`'), end: forceColor.white('`') },
|
|
73
|
+
controlPicture: ansiStyles.grey,
|
|
74
|
+
diff: {
|
|
75
|
+
insert: {
|
|
76
|
+
open: ansiStyles.bgGreen.open + ansiStyles.black.open,
|
|
77
|
+
close: ansiStyles.black.close + ansiStyles.bgGreen.close,
|
|
78
|
+
},
|
|
79
|
+
delete: {
|
|
80
|
+
open: ansiStyles.bgRed.open + ansiStyles.black.open,
|
|
81
|
+
close: ansiStyles.black.close + ansiStyles.bgRed.close,
|
|
82
|
+
},
|
|
83
|
+
equal: ansiStyles.white,
|
|
84
|
+
insertLine: {
|
|
85
|
+
open: ansiStyles.green.open,
|
|
86
|
+
close: ansiStyles.green.close,
|
|
87
|
+
},
|
|
88
|
+
deleteLine: {
|
|
89
|
+
open: ansiStyles.red.open,
|
|
90
|
+
close: ansiStyles.red.close,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
symbol: ansiStyles.yellow,
|
|
95
|
+
typedArray: {
|
|
96
|
+
bytes: ansiStyles.yellow,
|
|
97
|
+
},
|
|
98
|
+
undefined: ansiStyles.yellow,
|
|
99
|
+
};
|
|
100
|
+
// @ts-expect-error TS(7034) FIXME: Variable 'plugins' implicitly has type 'any[]' in ... Remove this comment to see the full error message
|
|
101
|
+
const plugins = [];
|
|
102
|
+
const theme = colorTheme;
|
|
103
|
+
// @ts-expect-error TS(7005) FIXME: Variable 'plugins' implicitly has an 'any[]' type.
|
|
104
|
+
export const concordanceOptions = { maxDepth: 3, plugins, theme };
|
|
105
|
+
// @ts-expect-error TS(7005) FIXME: Variable 'plugins' implicitly has an 'any[]' type.
|
|
106
|
+
export const concordanceDiffOptions = { maxDepth: 1, plugins, theme };
|