netlify-cli 12.2.7 → 12.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/run.mjs +2 -3
- package/npm-shrinkwrap.json +1543 -179
- package/package.json +10 -5
- package/scripts/postinstall.mjs +2 -2
- package/src/commands/base-command.mjs +8 -12
- package/src/commands/build/build.mjs +2 -2
- package/src/commands/completion/completion.mjs +3 -3
- package/src/commands/deploy/deploy.mjs +4 -5
- package/src/commands/dev/{dev-exec.cjs → dev-exec.mjs} +5 -5
- package/src/commands/dev/{dev.cjs → dev.mjs} +33 -33
- package/src/commands/dev/index.mjs +1 -0
- package/src/commands/env/{env-clone.cjs → env-clone.mjs} +7 -16
- package/src/commands/env/{env-get.cjs → env-get.mjs} +5 -13
- package/src/commands/env/{env-import.cjs → env-import.mjs} +8 -15
- package/src/commands/env/{env-list.cjs → env-list.mjs} +13 -25
- package/src/commands/env/{env-set.cjs → env-set.mjs} +5 -5
- package/src/commands/env/{env-unset.cjs → env-unset.mjs} +4 -12
- package/src/commands/env/{env.cjs → env.mjs} +7 -9
- package/src/commands/env/index.mjs +1 -0
- package/src/commands/functions/functions-build.mjs +2 -1
- package/src/commands/functions/functions-create.mjs +2 -12
- package/src/commands/functions/functions-invoke.mjs +2 -1
- package/src/commands/functions/functions-list.mjs +2 -1
- package/src/commands/functions/functions-serve.mjs +3 -2
- package/src/commands/graph/{graph-config-write.cjs → graph-config-write.mjs} +8 -8
- package/src/commands/graph/{graph-edit.cjs → graph-edit.mjs} +9 -14
- package/src/commands/graph/{graph-handler.cjs → graph-handler.mjs} +6 -6
- package/src/commands/graph/{graph-init.cjs → graph-init.mjs} +12 -20
- package/src/commands/graph/{graph-library.cjs → graph-library.mjs} +8 -8
- package/src/commands/graph/{graph-operations.cjs → graph-operations.mjs} +7 -7
- package/src/commands/graph/{graph-pull.cjs → graph-pull.mjs} +8 -12
- package/src/commands/graph/{graph.cjs → graph.mjs} +8 -10
- package/src/commands/graph/index.mjs +1 -0
- package/src/commands/init/init.mjs +5 -2
- package/src/commands/link/index.mjs +1 -0
- package/src/commands/link/{link.cjs → link.mjs} +15 -13
- package/src/commands/lm/index.mjs +1 -0
- package/src/commands/lm/{lm-info.cjs → lm-info.mjs} +4 -6
- package/src/commands/lm/{lm-install.cjs → lm-install.mjs} +3 -5
- package/src/commands/lm/{lm-setup.cjs → lm-setup.mjs} +8 -8
- package/src/commands/lm/{lm-uninstall.cjs → lm-uninstall.mjs} +2 -4
- package/src/commands/lm/{lm.cjs → lm.mjs} +5 -7
- package/src/commands/logout/logout.mjs +2 -1
- package/src/commands/main.mjs +10 -12
- package/src/commands/recipes/common.mjs +36 -0
- package/src/commands/recipes/index.mjs +1 -0
- package/src/commands/recipes/{recipes-list.cjs → recipes-list.mjs} +3 -5
- package/src/commands/recipes/{recipes.cjs → recipes.mjs} +12 -10
- package/src/commands/sites/sites-create-template.mjs +3 -1
- package/src/commands/sites/sites-create.mjs +4 -2
- package/src/commands/sites/sites-list.mjs +1 -1
- package/src/commands/unlink/unlink.mjs +2 -1
- package/src/functions-templates/go/hello-world/go.mod +1 -1
- package/src/functions-templates/javascript/graphql-gateway/example-sibling-function-graphql-1.js +0 -2
- package/src/functions-templates/javascript/graphql-gateway/example-sibling-function-graphql-2.js +0 -2
- package/src/functions-templates/javascript/stripe-charge/package-lock.json +6 -6
- package/src/functions-templates/javascript/stripe-subscription/package-lock.json +6 -6
- package/src/functions-templates/javascript/token-hider/package-lock.json +6 -6
- package/src/functions-templates/rust/hello-world/Cargo.toml +1 -1
- package/src/functions-templates/typescript/hello-world/package-lock.json +12 -12
- package/src/lib/account.cjs +0 -3
- package/src/lib/{api.cjs → api.mjs} +3 -5
- package/src/lib/{build.cjs → build.mjs} +9 -9
- package/src/lib/completion/constants.mjs +4 -0
- package/src/lib/completion/{generate-autocompletion.cjs → generate-autocompletion.mjs} +6 -6
- package/src/lib/completion/{script.cjs → get-autocompletion.mjs} +1 -25
- package/src/lib/completion/index.mjs +1 -0
- package/src/lib/completion/script.mjs +35 -0
- package/src/lib/edge-functions/consts.cjs +0 -10
- package/src/lib/edge-functions/{editor-helper.cjs → editor-helper.mjs} +4 -6
- package/src/lib/edge-functions/index.cjs +1 -2
- package/src/lib/exec-fetcher.cjs +0 -2
- package/src/lib/functions/{form-submissions-handler.cjs → form-submissions-handler.mjs} +26 -28
- package/src/lib/functions/{scheduled.cjs → scheduled.mjs} +6 -8
- package/src/lib/functions/{server.cjs → server.mjs} +36 -34
- package/src/lib/geo-location.cjs +1 -1
- package/src/lib/{http-agent.cjs → http-agent.mjs} +7 -8
- package/src/lib/one-graph/{cli-client.cjs → cli-client.mjs} +46 -74
- package/src/lib/one-graph/{cli-netlify-graph.cjs → cli-netlify-graph.mjs} +35 -43
- package/src/recipes/vscode/{index.cjs → index.mjs} +7 -9
- package/src/recipes/vscode/{settings.cjs → settings.mjs} +10 -12
- package/src/utils/command-helpers.cjs +0 -1
- package/src/utils/{create-stream-promise.cjs → create-stream-promise.mjs} +2 -2
- package/src/utils/{detect-server-settings.cjs → detect-server-settings.mjs} +14 -20
- package/src/utils/functions/constants.mjs +1 -0
- package/src/utils/functions/{functions.cjs → functions.mjs} +6 -8
- package/src/utils/functions/{get-functions.cjs → get-functions.mjs} +4 -25
- package/src/utils/functions/index.mjs +3 -0
- package/src/utils/get-package-json.mjs +16 -0
- package/src/utils/{get-repo-data.cjs → get-repo-data.mjs} +15 -12
- package/src/utils/{gitignore.cjs → gitignore.mjs} +6 -8
- package/src/utils/index.cjs +0 -20
- package/src/utils/{live-tunnel.cjs → live-tunnel.mjs} +8 -10
- package/src/utils/lm/{install.cjs → install.mjs} +26 -25
- package/src/utils/lm/{requirements.cjs → requirements.mjs} +6 -13
- package/src/utils/lm/{steps.cjs → steps.mjs} +6 -8
- package/src/utils/lm/{ui.cjs → ui.mjs} +5 -7
- package/src/utils/{proxy.cjs → proxy.mjs} +31 -34
- package/src/utils/{read-repo-url.cjs → read-repo-url.mjs} +6 -11
- package/src/utils/{state-config.cjs → state-config.mjs} +8 -10
- package/src/utils/telemetry/index.mjs +1 -0
- package/src/utils/telemetry/{request.cjs → request.mjs} +5 -3
- package/src/utils/telemetry/{telemetry.cjs → telemetry.mjs} +12 -14
- package/src/utils/telemetry/{validation.cjs → validation.mjs} +2 -2
- package/src/commands/dev/index.cjs +0 -5
- package/src/commands/env/index.cjs +0 -5
- package/src/commands/graph/index.cjs +0 -5
- package/src/commands/link/index.cjs +0 -6
- package/src/commands/lm/index.cjs +0 -5
- package/src/commands/recipes/common.cjs +0 -33
- package/src/commands/recipes/index.cjs +0 -8
- package/src/lib/completion/constants.cjs +0 -6
- package/src/lib/completion/index.cjs +0 -5
- package/src/utils/functions/constants.cjs +0 -5
- package/src/utils/functions/index.cjs +0 -12
- package/src/utils/telemetry/index.cjs +0 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
3
|
"description": "Netlify command line tool",
|
|
4
|
-
"version": "12.2.
|
|
4
|
+
"version": "12.2.9",
|
|
5
5
|
"author": "Netlify Inc.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"contributors": [
|
|
@@ -211,8 +211,11 @@
|
|
|
211
211
|
"test:init:eleventy-deps": "npm ci --prefix tests/integration/eleventy-site --no-audit",
|
|
212
212
|
"test:init:hugo-deps": "npm ci --prefix tests/integration/hugo-site --no-audit",
|
|
213
213
|
"test:dev:ava": "ava --verbose",
|
|
214
|
+
"test:dev:vitest": "vitest run",
|
|
214
215
|
"test:ci:ava:unit": "c8 -r json ava --no-worker-threads tests/unit/ tools/",
|
|
215
216
|
"test:ci:ava:integration": "c8 -r json ava --concurrency 1 --no-worker-threads tests/integration/",
|
|
217
|
+
"test:ci:vitest:unit": "vitest run --coverage tests/unit/",
|
|
218
|
+
"test:ci:vitest:integration": "vitest run --coverage --no-threads tests/integration/",
|
|
216
219
|
"test:affected": "node ./tools/affected-test.mjs",
|
|
217
220
|
"e2e": "node ./tools/e2e/run.mjs",
|
|
218
221
|
"docs": "node ./site/scripts/docs.mjs",
|
|
@@ -228,9 +231,9 @@
|
|
|
228
231
|
"prettier": "--ignore-path .gitignore --loglevel=warn \"{src,tools,scripts,site,tests,.github}/**/*.{mjs,cjs,js,md,yml,json,html}\" \"*.{mjs,cjs,js,yml,json,html}\" \".*.{mjs,cjs,js,yml,json,html}\" \"!CHANGELOG.md\" \"!npm-shrinkwrap.json\" \"!**/*/package-lock.json\" \"!.github/**/*.md\""
|
|
229
232
|
},
|
|
230
233
|
"dependencies": {
|
|
231
|
-
"@netlify/build": "^28.4.
|
|
234
|
+
"@netlify/build": "^28.4.5",
|
|
232
235
|
"@netlify/config": "^20.0.2",
|
|
233
|
-
"@netlify/edge-bundler": "^
|
|
236
|
+
"@netlify/edge-bundler": "^5.3.1",
|
|
234
237
|
"@netlify/framework-info": "^9.5.2",
|
|
235
238
|
"@netlify/local-functions-proxy": "^1.1.1",
|
|
236
239
|
"@netlify/zip-it-and-ship-it": "^8.1.0",
|
|
@@ -337,6 +340,7 @@
|
|
|
337
340
|
"devDependencies": {
|
|
338
341
|
"@babel/preset-react": "^7.12.13",
|
|
339
342
|
"@netlify/eslint-config-node": "^7.0.0",
|
|
343
|
+
"@vitest/coverage-c8": "^0.25.3",
|
|
340
344
|
"ava": "^4.0.0",
|
|
341
345
|
"c8": "^7.11.0",
|
|
342
346
|
"eslint-plugin-sort-destructure-keys": "^1.3.5",
|
|
@@ -352,14 +356,15 @@
|
|
|
352
356
|
"rewiremock": "^3.14.3",
|
|
353
357
|
"serialize-javascript": "^6.0.0",
|
|
354
358
|
"sinon": "^14.0.0",
|
|
355
|
-
"sort-on": "^4.1.0",
|
|
356
359
|
"strip-ansi": "^6.0.0",
|
|
357
360
|
"supertest": "^6.1.6",
|
|
358
361
|
"temp-dir": "^2.0.0",
|
|
359
362
|
"tomlify-j0.4": "^3.0.0",
|
|
360
363
|
"tree-kill": "^1.2.2",
|
|
361
364
|
"typescript": "^4.4.4",
|
|
362
|
-
"verdaccio": "^5.10.2"
|
|
365
|
+
"verdaccio": "^5.10.2",
|
|
366
|
+
"vite": "^3.2.4",
|
|
367
|
+
"vitest": "^0.25.3"
|
|
363
368
|
},
|
|
364
369
|
"ava": {
|
|
365
370
|
"files": [
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -28,11 +28,11 @@ const postInstall = async () => {
|
|
|
28
28
|
if (!process.argv[1].includes('.yarn')) {
|
|
29
29
|
const { createMainCommand } = await import('../src/commands/index.mjs')
|
|
30
30
|
// TODO: use destructuring again once the imported file is esm
|
|
31
|
-
const
|
|
31
|
+
const { generateAutocompletion } = await import('../src/lib/completion/index.mjs')
|
|
32
32
|
|
|
33
33
|
// create or update the autocompletion definition
|
|
34
34
|
const program = createMainCommand()
|
|
35
|
-
|
|
35
|
+
generateAutocompletion(program)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
console.log('')
|
|
@@ -8,29 +8,25 @@ import debug from 'debug'
|
|
|
8
8
|
import merge from 'lodash/merge.js'
|
|
9
9
|
import { NetlifyAPI } from 'netlify'
|
|
10
10
|
|
|
11
|
-
import { getAgent } from '../lib/http-agent.
|
|
12
|
-
|
|
13
|
-
import utils from '../utils/index.cjs'
|
|
14
|
-
|
|
15
|
-
const {
|
|
11
|
+
import { getAgent } from '../lib/http-agent.mjs'
|
|
12
|
+
import {
|
|
16
13
|
NETLIFY_CYAN,
|
|
17
|
-
StateConfig,
|
|
18
14
|
USER_AGENT,
|
|
19
15
|
chalk,
|
|
20
16
|
error,
|
|
21
17
|
exit,
|
|
22
|
-
getGlobalConfig,
|
|
23
18
|
getToken,
|
|
24
|
-
identify,
|
|
25
19
|
log,
|
|
26
20
|
normalizeConfig,
|
|
27
|
-
openBrowser,
|
|
28
21
|
padLeft,
|
|
29
22
|
pollForToken,
|
|
30
23
|
sortOptions,
|
|
31
|
-
track,
|
|
32
24
|
warn,
|
|
33
|
-
}
|
|
25
|
+
} from '../utils/command-helpers.cjs'
|
|
26
|
+
import getGlobalConfig from '../utils/get-global-config.cjs'
|
|
27
|
+
import { openBrowser } from '../utils/open-browser.cjs'
|
|
28
|
+
import StateConfig from '../utils/state-config.mjs'
|
|
29
|
+
import { identify, track } from '../utils/telemetry/index.mjs'
|
|
34
30
|
|
|
35
31
|
// Netlify CLI client id. Lives in bot@netlify.com
|
|
36
32
|
// TODO: setup client for multiple environments
|
|
@@ -77,7 +73,7 @@ const getDuration = function (startTime) {
|
|
|
77
73
|
* @property {*} config
|
|
78
74
|
* @property {*} cachedConfig
|
|
79
75
|
* @property {*} globalConfig
|
|
80
|
-
* @property {
|
|
76
|
+
* @property {import('../../utils/state-config.mjs').default} state,
|
|
81
77
|
*/
|
|
82
78
|
|
|
83
79
|
/** Base command class that provides tracking and config initialization */
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import process from 'process'
|
|
3
3
|
|
|
4
|
-
import { getBuildOptions, runBuild } from '../../lib/build.
|
|
4
|
+
import { getBuildOptions, runBuild } from '../../lib/build.mjs'
|
|
5
5
|
import utils from '../../utils/index.cjs'
|
|
6
6
|
|
|
7
7
|
const { error, exit, generateNetlifyGraphJWT, getEnvelopeEnv, getToken, normalizeContext } = utils
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @param {import('../../lib/build.
|
|
10
|
+
* @param {import('../../lib/build.mjs').BuildConfig} options
|
|
11
11
|
*/
|
|
12
12
|
const checkOptions = ({ cachedConfig: { siteInfo = {} }, token }) => {
|
|
13
13
|
if (!siteInfo.id) {
|
|
@@ -3,9 +3,9 @@ import { fileURLToPath } from 'url'
|
|
|
3
3
|
|
|
4
4
|
import { install, uninstall } from 'tabtab'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { generateAutocompletion } from '../../lib/completion/index.mjs'
|
|
7
7
|
|
|
8
|
-
const completer = join(dirname(fileURLToPath(import.meta.url)), '../../lib/completion/script.
|
|
8
|
+
const completer = join(dirname(fileURLToPath(import.meta.url)), '../../lib/completion/script.mjs')
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* The completion:generate command
|
|
@@ -15,7 +15,7 @@ const completer = join(dirname(fileURLToPath(import.meta.url)), '../../lib/compl
|
|
|
15
15
|
const completionGenerate = async (options, command) => {
|
|
16
16
|
const { parent } = command
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
generateAutocompletion(parent)
|
|
19
19
|
|
|
20
20
|
await install({
|
|
21
21
|
name: parent.name(),
|
|
@@ -10,13 +10,14 @@ import inquirer from 'inquirer'
|
|
|
10
10
|
import isObject from 'lodash/isObject.js'
|
|
11
11
|
import prettyjson from 'prettyjson'
|
|
12
12
|
|
|
13
|
-
import { cancelDeploy } from '../../lib/api.
|
|
14
|
-
import { getBuildOptions, runBuild } from '../../lib/build.
|
|
13
|
+
import { cancelDeploy } from '../../lib/api.mjs'
|
|
14
|
+
import { getBuildOptions, runBuild } from '../../lib/build.mjs'
|
|
15
15
|
import { normalizeFunctionsConfig } from '../../lib/functions/config.cjs'
|
|
16
16
|
import { getLogMessage } from '../../lib/log.cjs'
|
|
17
17
|
import { startSpinner, stopSpinner } from '../../lib/spinner.cjs'
|
|
18
|
+
import { getFunctionsManifestPath, getInternalFunctionsDir } from '../../utils/functions/index.mjs'
|
|
18
19
|
import utils from '../../utils/index.cjs'
|
|
19
|
-
import { link } from '../link/index.
|
|
20
|
+
import { link } from '../link/index.mjs'
|
|
20
21
|
import { sitesCreate } from '../sites/index.mjs'
|
|
21
22
|
|
|
22
23
|
const {
|
|
@@ -27,8 +28,6 @@ const {
|
|
|
27
28
|
deploySite,
|
|
28
29
|
error,
|
|
29
30
|
exit,
|
|
30
|
-
getFunctionsManifestPath,
|
|
31
|
-
getInternalFunctionsDir,
|
|
32
31
|
getToken,
|
|
33
32
|
log,
|
|
34
33
|
logJson,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import execa from 'execa'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import utils from '../../utils/index.cjs'
|
|
4
|
+
|
|
5
|
+
const { getEnvelopeEnv, injectEnvVariables, normalizeContext } = utils
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* The dev:exec command
|
|
@@ -27,7 +29,7 @@ const devExec = async (cmd, options, command) => {
|
|
|
27
29
|
* @param {import('../base-command.mjs').default} program
|
|
28
30
|
* @returns
|
|
29
31
|
*/
|
|
30
|
-
const createDevExecCommand = (program) =>
|
|
32
|
+
export const createDevExecCommand = (program) =>
|
|
31
33
|
program
|
|
32
34
|
.command('dev:exec')
|
|
33
35
|
.argument('<...cmd>', `the command that should be executed`)
|
|
@@ -43,5 +45,3 @@ const createDevExecCommand = (program) =>
|
|
|
43
45
|
.allowExcessArguments(true)
|
|
44
46
|
.addExamples(['netlify dev:exec npm run bootstrap'])
|
|
45
47
|
.action(devExec)
|
|
46
|
-
|
|
47
|
-
module.exports = { createDevExecCommand }
|
|
@@ -1,32 +1,40 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
import events from 'events'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import process from 'process'
|
|
5
|
+
import { promisify } from 'util'
|
|
6
|
+
|
|
7
|
+
import boxen from 'boxen'
|
|
8
|
+
import { Option } from 'commander'
|
|
9
|
+
import execa from 'execa'
|
|
10
|
+
import StaticServer from 'static-server'
|
|
11
|
+
import stripAnsiCc from 'strip-ansi-control-characters'
|
|
12
|
+
import waitPort from 'wait-port'
|
|
13
|
+
|
|
14
|
+
import { promptEditorHelper } from '../../lib/edge-functions/editor-helper.mjs'
|
|
15
|
+
import { startFunctionsServer } from '../../lib/functions/server.mjs'
|
|
16
|
+
import {
|
|
17
17
|
OneGraphCliClient,
|
|
18
18
|
loadCLISession,
|
|
19
19
|
markCliSessionInactive,
|
|
20
20
|
persistNewOperationsDocForSession,
|
|
21
21
|
startOneGraphCLISession,
|
|
22
|
-
}
|
|
23
|
-
|
|
22
|
+
} from '../../lib/one-graph/cli-client.mjs'
|
|
23
|
+
import {
|
|
24
24
|
defaultExampleOperationsDoc,
|
|
25
25
|
getGraphEditUrlBySiteId,
|
|
26
26
|
getNetlifyGraphConfig,
|
|
27
27
|
readGraphQLOperationsSourceFile,
|
|
28
|
-
}
|
|
29
|
-
|
|
28
|
+
} from '../../lib/one-graph/cli-netlify-graph.mjs'
|
|
29
|
+
import { startSpinner, stopSpinner } from '../../lib/spinner.cjs'
|
|
30
|
+
import detectServerSettings from '../../utils/detect-server-settings.mjs'
|
|
31
|
+
import { ensureNetlifyIgnore } from '../../utils/gitignore.mjs'
|
|
32
|
+
import utils from '../../utils/index.cjs'
|
|
33
|
+
import { startLiveTunnel } from '../../utils/live-tunnel.mjs'
|
|
34
|
+
import { startProxy } from '../../utils/proxy.mjs'
|
|
35
|
+
|
|
36
|
+
import { createDevExecCommand } from './dev-exec.mjs'
|
|
37
|
+
|
|
30
38
|
const {
|
|
31
39
|
BANG,
|
|
32
40
|
NETLIFYDEV,
|
|
@@ -34,8 +42,6 @@ const {
|
|
|
34
42
|
NETLIFYDEVLOG,
|
|
35
43
|
NETLIFYDEVWARN,
|
|
36
44
|
chalk,
|
|
37
|
-
detectServerSettings,
|
|
38
|
-
ensureNetlifyIgnore,
|
|
39
45
|
error,
|
|
40
46
|
exit,
|
|
41
47
|
generateNetlifyGraphJWT,
|
|
@@ -48,13 +54,9 @@ const {
|
|
|
48
54
|
normalizeContext,
|
|
49
55
|
openBrowser,
|
|
50
56
|
processOnExit,
|
|
51
|
-
startLiveTunnel,
|
|
52
|
-
startProxy,
|
|
53
57
|
warn,
|
|
54
58
|
watchDebounced,
|
|
55
|
-
} =
|
|
56
|
-
|
|
57
|
-
const { createDevExecCommand } = require('./dev-exec.cjs')
|
|
59
|
+
} = utils
|
|
58
60
|
|
|
59
61
|
const netlifyBuildPromise = import('@netlify/build')
|
|
60
62
|
|
|
@@ -247,8 +249,8 @@ const FRAMEWORK_PORT_TIMEOUT = 6e5
|
|
|
247
249
|
*
|
|
248
250
|
* @param {object} params
|
|
249
251
|
* @param {*} params.addonsUrls
|
|
250
|
-
* @param {import('../base-command').NetlifyOptions["config"]} params.config
|
|
251
|
-
* @param {import('../base-command').NetlifyOptions["cachedConfig"]['env']} params.env
|
|
252
|
+
* @param {import('../base-command.mjs').NetlifyOptions["config"]} params.config
|
|
253
|
+
* @param {import('../base-command.mjs').NetlifyOptions["cachedConfig"]['env']} params.env
|
|
252
254
|
* @param {InspectSettings} params.inspectSettings
|
|
253
255
|
* @param {() => Promise<object>} params.getUpdatedConfig
|
|
254
256
|
* @param {string} params.geolocationMode
|
|
@@ -257,7 +259,7 @@ const FRAMEWORK_PORT_TIMEOUT = 6e5
|
|
|
257
259
|
* @param {boolean} params.offline
|
|
258
260
|
* @param {*} params.site
|
|
259
261
|
* @param {*} params.siteInfo
|
|
260
|
-
* @param {import('../../utils/state-config').
|
|
262
|
+
* @param {import('../../utils/state-config.mjs').default} params.state
|
|
261
263
|
* @returns
|
|
262
264
|
*/
|
|
263
265
|
const startProxyServer = async ({
|
|
@@ -514,7 +516,7 @@ const dev = async (options, command) => {
|
|
|
514
516
|
|
|
515
517
|
const devCommand = async () => {
|
|
516
518
|
const { ipVersion } = await startFrameworkServer({ settings })
|
|
517
|
-
|
|
519
|
+
|
|
518
520
|
settings.frameworkHost = ipVersion === 6 ? '::1' : '127.0.0.1'
|
|
519
521
|
}
|
|
520
522
|
const startDevOptions = getBuildOptions({
|
|
@@ -690,7 +692,7 @@ const getBuildOptions = ({ cachedConfig, options: { context, cwd = process.cwd()
|
|
|
690
692
|
* @param {import('../base-command.mjs').default} program
|
|
691
693
|
* @returns
|
|
692
694
|
*/
|
|
693
|
-
const createDevCommand = (program) => {
|
|
695
|
+
export const createDevCommand = (program) => {
|
|
694
696
|
createDevExecCommand(program)
|
|
695
697
|
|
|
696
698
|
return program
|
|
@@ -765,5 +767,3 @@ const createDevCommand = (program) => {
|
|
|
765
767
|
])
|
|
766
768
|
.action(dev)
|
|
767
769
|
}
|
|
768
|
-
|
|
769
|
-
module.exports = { createDevCommand }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createDevCommand } from './dev.mjs'
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
import utils from '../../utils/index.cjs'
|
|
2
3
|
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
chalk,
|
|
7
|
-
error: logError,
|
|
8
|
-
log,
|
|
9
|
-
translateFromEnvelopeToMongo,
|
|
10
|
-
translateFromMongoToEnvelope,
|
|
11
|
-
} = require('../../utils/index.cjs')
|
|
4
|
+
const { chalk, error: logError, log, translateFromEnvelopeToMongo, translateFromMongoToEnvelope } = utils
|
|
12
5
|
|
|
13
6
|
const safeGetSite = async (api, siteId) => {
|
|
14
7
|
try {
|
|
@@ -93,7 +86,7 @@ const mongoToMongo = async ({ api, siteFrom, siteTo }) => {
|
|
|
93
86
|
},
|
|
94
87
|
] = [siteFrom, siteTo]
|
|
95
88
|
|
|
96
|
-
if (
|
|
89
|
+
if (Object.keys(envFrom).length === 0) {
|
|
97
90
|
log(`${chalk.green(siteFrom.name)} has no environment variables, nothing to clone`)
|
|
98
91
|
return false
|
|
99
92
|
}
|
|
@@ -125,7 +118,7 @@ const mongoToEnvelope = async ({ api, siteFrom, siteTo }) => {
|
|
|
125
118
|
const envFrom = siteFrom.build_settings.env || {}
|
|
126
119
|
const keysFrom = Object.keys(envFrom)
|
|
127
120
|
|
|
128
|
-
if (
|
|
121
|
+
if (Object.keys(envFrom).length === 0) {
|
|
129
122
|
log(`${chalk.green(siteFrom.name)} has no environment variables, nothing to clone`)
|
|
130
123
|
return false
|
|
131
124
|
}
|
|
@@ -158,7 +151,7 @@ const envelopeToMongo = async ({ api, siteFrom, siteTo }) => {
|
|
|
158
151
|
const envelopeVariables = await api.getEnvVars({ accountId: siteFrom.account_slug, siteId: siteFrom.id })
|
|
159
152
|
const envFrom = translateFromEnvelopeToMongo(envelopeVariables)
|
|
160
153
|
|
|
161
|
-
if (
|
|
154
|
+
if (Object.keys(envFrom).length === 0) {
|
|
162
155
|
log(`${chalk.green(siteFrom.name)} has no environment variables, nothing to clone`)
|
|
163
156
|
return false
|
|
164
157
|
}
|
|
@@ -196,7 +189,7 @@ const envelopeToEnvelope = async ({ api, siteFrom, siteTo }) => {
|
|
|
196
189
|
|
|
197
190
|
const keysFrom = envelopeFrom.map(({ key }) => key)
|
|
198
191
|
|
|
199
|
-
if (
|
|
192
|
+
if (keysFrom.length === 0) {
|
|
200
193
|
log(`${chalk.green(siteFrom.name)} has no environment variables, nothing to clone`)
|
|
201
194
|
return false
|
|
202
195
|
}
|
|
@@ -222,7 +215,7 @@ const envelopeToEnvelope = async ({ api, siteFrom, siteTo }) => {
|
|
|
222
215
|
* @param {import('../base-command.mjs').default} program
|
|
223
216
|
* @returns
|
|
224
217
|
*/
|
|
225
|
-
const createEnvCloneCommand = (program) =>
|
|
218
|
+
export const createEnvCloneCommand = (program) =>
|
|
226
219
|
program
|
|
227
220
|
.command('env:clone')
|
|
228
221
|
.alias('env:migrate')
|
|
@@ -231,5 +224,3 @@ const createEnvCloneCommand = (program) =>
|
|
|
231
224
|
.description(`Clone environment variables from one site to another`)
|
|
232
225
|
.addExamples(['netlify env:clone --to <to-site-id>', 'netlify env:clone --to <to-site-id> --from <from-site-id>'])
|
|
233
226
|
.action(envClone)
|
|
234
|
-
|
|
235
|
-
module.exports = { createEnvCloneCommand }
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
import { Option } from 'commander'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
error,
|
|
8
|
-
getEnvelopeEnv,
|
|
9
|
-
log,
|
|
10
|
-
logJson,
|
|
11
|
-
normalizeContext,
|
|
12
|
-
} = require('../../utils/index.cjs')
|
|
4
|
+
import utils from '../../utils/index.cjs'
|
|
5
|
+
|
|
6
|
+
const { AVAILABLE_CONTEXTS, chalk, error, getEnvelopeEnv, log, logJson, normalizeContext } = utils
|
|
13
7
|
|
|
14
8
|
/**
|
|
15
9
|
* The env:get command
|
|
@@ -65,7 +59,7 @@ const envGet = async (name, options, command) => {
|
|
|
65
59
|
* @param {import('../base-command.mjs').default} program
|
|
66
60
|
* @returns
|
|
67
61
|
*/
|
|
68
|
-
const createEnvGetCommand = (program) =>
|
|
62
|
+
export const createEnvGetCommand = (program) =>
|
|
69
63
|
program
|
|
70
64
|
.command('env:get')
|
|
71
65
|
.argument('<name>', 'Environment variable name')
|
|
@@ -90,5 +84,3 @@ const createEnvGetCommand = (program) =>
|
|
|
90
84
|
.action(async (name, options, command) => {
|
|
91
85
|
await envGet(name, options, command)
|
|
92
86
|
})
|
|
93
|
-
|
|
94
|
-
module.exports = { createEnvGetCommand }
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
import { readFile } from 'fs/promises'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const isEmpty = require('lodash/isEmpty')
|
|
4
|
+
import AsciiTable from 'ascii-table'
|
|
5
|
+
import dotenv from 'dotenv'
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
logJson,
|
|
12
|
-
translateFromEnvelopeToMongo,
|
|
13
|
-
translateFromMongoToEnvelope,
|
|
14
|
-
} = require('../../utils/index.cjs')
|
|
7
|
+
import utils from '../../utils/index.cjs'
|
|
8
|
+
|
|
9
|
+
const { exit, log, logJson, translateFromEnvelopeToMongo, translateFromMongoToEnvelope } = utils
|
|
15
10
|
|
|
16
11
|
/**
|
|
17
12
|
* The env:import command
|
|
@@ -38,7 +33,7 @@ const envImport = async (fileName, options, command) => {
|
|
|
38
33
|
exit(1)
|
|
39
34
|
}
|
|
40
35
|
|
|
41
|
-
if (
|
|
36
|
+
if (Object.keys(importedEnv).length === 0) {
|
|
42
37
|
log(`No environment variables found in file ${fileName} to import`)
|
|
43
38
|
return false
|
|
44
39
|
}
|
|
@@ -128,7 +123,7 @@ const importIntoEnvelope = async ({ api, importedEnv, options, siteInfo }) => {
|
|
|
128
123
|
* @param {import('../base-command.mjs').default} program
|
|
129
124
|
* @returns
|
|
130
125
|
*/
|
|
131
|
-
const createEnvImportCommand = (program) =>
|
|
126
|
+
export const createEnvImportCommand = (program) =>
|
|
132
127
|
program
|
|
133
128
|
.command('env:import')
|
|
134
129
|
.argument('<fileName>', '.env file to import')
|
|
@@ -141,5 +136,3 @@ const createEnvImportCommand = (program) =>
|
|
|
141
136
|
.action(async (fileName, options, command) => {
|
|
142
137
|
await envImport(fileName, options, command)
|
|
143
138
|
})
|
|
144
|
-
|
|
145
|
-
module.exports = { createEnvImportCommand }
|
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
getHumanReadableScopes,
|
|
14
|
-
log,
|
|
15
|
-
logJson,
|
|
16
|
-
normalizeContext,
|
|
17
|
-
} = require('../../utils/index.cjs')
|
|
18
|
-
|
|
19
|
-
const [logUpdatePromise, ansiEscapesPromise] = [import('log-update'), import('ansi-escapes')]
|
|
2
|
+
import ansiEscapes from 'ansi-escapes'
|
|
3
|
+
import AsciiTable from 'ascii-table'
|
|
4
|
+
import { isCI } from 'ci-info'
|
|
5
|
+
import { Option } from 'commander'
|
|
6
|
+
import inquirer from 'inquirer'
|
|
7
|
+
import logUpdate from 'log-update'
|
|
8
|
+
|
|
9
|
+
import utils from '../../utils/index.cjs'
|
|
10
|
+
|
|
11
|
+
const { AVAILABLE_CONTEXTS, chalk, error, getEnvelopeEnv, getHumanReadableScopes, log, logJson, normalizeContext } =
|
|
12
|
+
utils
|
|
20
13
|
|
|
21
14
|
const MASK_LENGTH = 50
|
|
22
15
|
const MASK = '*'.repeat(MASK_LENGTH)
|
|
@@ -89,7 +82,7 @@ const envList = async (options, command) => {
|
|
|
89
82
|
const contextType = AVAILABLE_CONTEXTS.includes(context) ? 'context' : 'branch'
|
|
90
83
|
const withContext = isUsingEnvelope ? `in the ${chalk.magenta(options.context)} ${contextType}` : ''
|
|
91
84
|
const withScope = isUsingEnvelope && scope !== 'any' ? `and ${chalk.yellow(options.scope)} scope` : ''
|
|
92
|
-
if (
|
|
85
|
+
if (Object.keys(environment).length === 0) {
|
|
93
86
|
log(`No environment variables set ${forSite} ${withContext} ${withScope}`)
|
|
94
87
|
return false
|
|
95
88
|
}
|
|
@@ -103,8 +96,6 @@ const envList = async (options, command) => {
|
|
|
103
96
|
return false
|
|
104
97
|
}
|
|
105
98
|
|
|
106
|
-
const { default: logUpdate } = await logUpdatePromise
|
|
107
|
-
|
|
108
99
|
logUpdate(getTable({ environment, hideValues: true, scopesColumn: isUsingEnvelope }))
|
|
109
100
|
const { showValues } = await inquirer.prompt([
|
|
110
101
|
{
|
|
@@ -116,7 +107,6 @@ const envList = async (options, command) => {
|
|
|
116
107
|
])
|
|
117
108
|
|
|
118
109
|
if (showValues) {
|
|
119
|
-
const { default: ansiEscapes } = await ansiEscapesPromise
|
|
120
110
|
// since inquirer adds a prompt, we need to account for it when printing the table again
|
|
121
111
|
log(ansiEscapes.eraseLines(3))
|
|
122
112
|
logUpdate(getTable({ environment, hideValues: false, scopesColumn: isUsingEnvelope }))
|
|
@@ -129,7 +119,7 @@ const envList = async (options, command) => {
|
|
|
129
119
|
* @param {import('../base-command.mjs').default} program
|
|
130
120
|
* @returns
|
|
131
121
|
*/
|
|
132
|
-
const createEnvListCommand = (program) =>
|
|
122
|
+
export const createEnvListCommand = (program) =>
|
|
133
123
|
program
|
|
134
124
|
.command('env:list')
|
|
135
125
|
.option(
|
|
@@ -153,5 +143,3 @@ const createEnvListCommand = (program) =>
|
|
|
153
143
|
.action(async (options, command) => {
|
|
154
144
|
await envList(options, command)
|
|
155
145
|
})
|
|
156
|
-
|
|
157
|
-
module.exports = { createEnvListCommand }
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
import { Option } from 'commander'
|
|
3
|
+
|
|
4
|
+
import utils from '../../utils/index.cjs'
|
|
3
5
|
|
|
4
6
|
const {
|
|
5
7
|
AVAILABLE_CONTEXTS,
|
|
@@ -10,7 +12,7 @@ const {
|
|
|
10
12
|
logJson,
|
|
11
13
|
normalizeContext,
|
|
12
14
|
translateFromEnvelopeToMongo,
|
|
13
|
-
} =
|
|
15
|
+
} = utils
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* The env:set command
|
|
@@ -150,7 +152,7 @@ const setInEnvelope = async ({ api, context, key, scope, siteInfo, value }) => {
|
|
|
150
152
|
* @param {import('../base-command.mjs').default} program
|
|
151
153
|
* @returns
|
|
152
154
|
*/
|
|
153
|
-
const createEnvSetCommand = (program) =>
|
|
155
|
+
export const createEnvSetCommand = (program) =>
|
|
154
156
|
program
|
|
155
157
|
.command('env:set')
|
|
156
158
|
.argument('<key>', 'Environment variable key')
|
|
@@ -180,5 +182,3 @@ const createEnvSetCommand = (program) =>
|
|
|
180
182
|
.action(async (key, value, options, command) => {
|
|
181
183
|
await envSet(key, value, options, command)
|
|
182
184
|
})
|
|
183
|
-
|
|
184
|
-
module.exports = { createEnvSetCommand }
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
error,
|
|
6
|
-
log,
|
|
7
|
-
logJson,
|
|
8
|
-
normalizeContext,
|
|
9
|
-
translateFromEnvelopeToMongo,
|
|
10
|
-
} = require('../../utils/index.cjs')
|
|
2
|
+
import utils from '../../utils/index.cjs'
|
|
3
|
+
|
|
4
|
+
const { AVAILABLE_CONTEXTS, chalk, error, log, logJson, normalizeContext, translateFromEnvelopeToMongo } = utils
|
|
11
5
|
|
|
12
6
|
/**
|
|
13
7
|
* The env:unset command
|
|
@@ -138,7 +132,7 @@ const unsetInEnvelope = async ({ api, context, key, siteInfo }) => {
|
|
|
138
132
|
* @param {import('../base-command.mjs').default} program
|
|
139
133
|
* @returns
|
|
140
134
|
*/
|
|
141
|
-
const createEnvUnsetCommand = (program) =>
|
|
135
|
+
export const createEnvUnsetCommand = (program) =>
|
|
142
136
|
program
|
|
143
137
|
.command('env:unset')
|
|
144
138
|
.aliases(['env:delete', 'env:remove'])
|
|
@@ -158,5 +152,3 @@ const createEnvUnsetCommand = (program) =>
|
|
|
158
152
|
.action(async (key, options, command) => {
|
|
159
153
|
await envUnset(key, options, command)
|
|
160
154
|
})
|
|
161
|
-
|
|
162
|
-
module.exports = { createEnvUnsetCommand }
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { createEnvCloneCommand } from './env-clone.mjs'
|
|
3
|
+
import { createEnvGetCommand } from './env-get.mjs'
|
|
4
|
+
import { createEnvImportCommand } from './env-import.mjs'
|
|
5
|
+
import { createEnvListCommand } from './env-list.mjs'
|
|
6
|
+
import { createEnvSetCommand } from './env-set.mjs'
|
|
7
|
+
import { createEnvUnsetCommand } from './env-unset.mjs'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The env command
|
|
@@ -20,7 +20,7 @@ const env = (options, command) => {
|
|
|
20
20
|
* @param {import('../base-command.mjs').default} program
|
|
21
21
|
* @returns
|
|
22
22
|
*/
|
|
23
|
-
const createEnvCommand = (program) => {
|
|
23
|
+
export const createEnvCommand = (program) => {
|
|
24
24
|
createEnvGetCommand(program)
|
|
25
25
|
createEnvImportCommand(program)
|
|
26
26
|
createEnvListCommand(program)
|
|
@@ -41,5 +41,3 @@ const createEnvCommand = (program) => {
|
|
|
41
41
|
])
|
|
42
42
|
.action(env)
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
module.exports = { createEnvCommand }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createEnvCommand } from './env.mjs'
|