netlify-cli 8.0.7 → 8.1.0-rc
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 +81 -3
- package/npm-shrinkwrap.json +305 -2105
- package/package.json +10 -33
- package/src/commands/addons/addons-auth.js +50 -0
- package/src/commands/addons/addons-config.js +180 -0
- package/src/commands/addons/addons-create.js +129 -0
- package/src/commands/addons/addons-delete.js +59 -0
- package/src/commands/addons/addons-list.js +62 -0
- package/src/commands/addons/addons.js +49 -0
- package/src/commands/addons/index.js +3 -24
- package/src/commands/api/api.js +83 -0
- package/src/commands/api/index.js +5 -0
- package/src/commands/base-command.js +322 -0
- package/src/commands/build/build.js +58 -0
- package/src/commands/build/index.js +3 -61
- package/src/commands/completion/completion.js +18 -0
- package/src/commands/completion/index.js +5 -0
- package/src/commands/{deploy.js → deploy/deploy.js} +306 -278
- package/src/commands/deploy/index.js +5 -0
- package/src/commands/dev/dev-exec.js +39 -0
- package/src/commands/dev/dev-trace.js +50 -0
- package/src/commands/dev/dev.js +349 -0
- package/src/commands/dev/index.js +3 -335
- package/src/commands/env/env-get.js +51 -0
- package/src/commands/env/env-import.js +93 -0
- package/src/commands/env/env-list.js +63 -0
- package/src/commands/env/env-set.js +67 -0
- package/src/commands/env/env-unset.js +66 -0
- package/src/commands/env/env.js +47 -0
- package/src/commands/env/index.js +3 -23
- package/src/commands/functions/functions-build.js +59 -0
- package/src/commands/functions/{create.js → functions-create.js} +133 -94
- package/src/commands/functions/functions-invoke.js +276 -0
- package/src/commands/functions/functions-list.js +107 -0
- package/src/commands/functions/functions-serve.js +63 -0
- package/src/commands/functions/functions.js +53 -0
- package/src/commands/functions/index.js +3 -45
- package/src/commands/index.js +5 -0
- package/src/commands/init/index.js +6 -0
- package/src/commands/{init.js → init/init.js} +79 -68
- package/src/commands/link/index.js +6 -0
- package/src/{utils/link/link-by-prompt.js → commands/link/link.js} +153 -14
- package/src/commands/lm/index.js +3 -19
- package/src/commands/lm/lm-info.js +42 -0
- package/src/commands/lm/lm-install.js +36 -0
- package/src/commands/lm/lm-setup.js +106 -0
- package/src/commands/lm/lm-uninstall.js +25 -0
- package/src/commands/lm/lm.js +39 -0
- package/src/commands/login/index.js +6 -0
- package/src/commands/login/login.js +52 -0
- package/src/commands/logout/index.js +5 -0
- package/src/commands/logout/logout.js +43 -0
- package/src/commands/main.js +117 -0
- package/src/commands/open/index.js +3 -39
- package/src/commands/open/open-admin.js +56 -0
- package/src/commands/open/open-site.js +49 -0
- package/src/commands/open/open.js +42 -0
- package/src/commands/sites/index.js +5 -20
- package/src/commands/sites/sites-create.js +184 -0
- package/src/commands/sites/sites-delete.js +108 -0
- package/src/commands/sites/sites-list.js +89 -0
- package/src/commands/sites/sites.js +36 -0
- package/src/commands/status/index.js +3 -118
- package/src/commands/status/status-hooks.js +73 -0
- package/src/commands/status/status.js +125 -0
- package/src/commands/switch/index.js +5 -0
- package/src/commands/switch/switch.js +50 -0
- package/src/commands/unlink/index.js +5 -0
- package/src/commands/unlink/unlink.js +48 -0
- package/src/commands/watch/index.js +5 -0
- package/src/commands/watch/watch.js +121 -0
- package/src/lib/build.js +21 -7
- package/src/lib/exec-fetcher.js +5 -3
- package/src/lib/fs.js +54 -36
- package/src/lib/functions/background.js +1 -1
- package/src/lib/functions/form-submissions-handler.js +2 -1
- package/src/lib/functions/local-proxy.js +2 -1
- package/src/lib/functions/netlify-function.js +4 -1
- package/src/lib/functions/registry.js +4 -6
- package/src/lib/functions/runtimes/go/index.js +2 -1
- package/src/lib/functions/runtimes/js/builders/netlify-lambda.js +6 -4
- package/src/lib/functions/runtimes/js/builders/zisi.js +3 -3
- package/src/lib/functions/runtimes/rust/index.js +4 -3
- package/src/lib/functions/server.js +2 -3
- package/src/lib/functions/synchronous.js +2 -1
- package/src/lib/functions/utils.js +2 -3
- package/src/lib/functions/watcher.js +1 -0
- package/src/lib/http-agent.js +3 -5
- package/src/lib/log.js +2 -1
- package/src/lib/spinner.js +22 -0
- package/src/utils/addons/diffs/index.js +1 -0
- package/src/utils/addons/diffs/options.js +3 -1
- package/src/utils/addons/prepare.js +13 -6
- package/src/utils/addons/prompts.js +2 -1
- package/src/utils/addons/render.js +3 -1
- package/src/utils/command-helpers.js +156 -43
- package/src/utils/create-stream-promise.js +5 -5
- package/src/utils/deferred.js +1 -0
- package/src/utils/deploy/deploy-site.js +1 -1
- package/src/utils/deploy/index.js +4 -0
- package/src/utils/detect-server-settings.js +10 -12
- package/src/utils/dev.js +18 -10
- package/src/utils/dot-env.js +4 -2
- package/src/utils/{edge-handlers.js → functions/edge-handlers.js} +8 -7
- package/src/utils/functions/functions.js +36 -0
- package/src/utils/{get-functions.js → functions/get-functions.js} +2 -1
- package/src/utils/functions/index.js +8 -26
- package/src/utils/get-global-config.js +3 -2
- package/src/utils/get-repo-data.js +1 -0
- package/src/utils/gh-auth.js +1 -0
- package/src/utils/gitignore.js +7 -5
- package/src/utils/header.js +2 -2
- package/src/utils/headers.js +1 -2
- package/src/utils/index.js +42 -0
- package/src/utils/init/config-github.js +12 -5
- package/src/utils/init/config-manual.js +9 -2
- package/src/utils/init/config.js +13 -7
- package/src/utils/init/frameworks.js +1 -0
- package/src/utils/init/node-version.js +4 -2
- package/src/utils/init/plugins.js +1 -0
- package/src/utils/init/utils.js +10 -6
- package/src/utils/live-tunnel.js +3 -4
- package/src/utils/lm/install.js +10 -15
- package/src/utils/lm/requirements.js +3 -1
- package/src/utils/lm/steps.js +1 -1
- package/src/utils/lm/ui.js +7 -3
- package/src/utils/open-browser.js +8 -2
- package/src/utils/parse-raw-flags.js +4 -4
- package/src/utils/proxy.js +6 -5
- package/src/utils/read-repo-url.js +1 -0
- package/src/utils/redirects.js +2 -2
- package/src/utils/rules-proxy.js +2 -1
- package/src/utils/state-config.js +1 -1
- package/src/utils/telemetry/index.js +2 -113
- package/src/utils/telemetry/request.js +3 -1
- package/src/utils/telemetry/telemetry.js +117 -0
- package/src/utils/telemetry/validation.js +13 -12
- package/src/utils/traffic-mesh.js +3 -3
- package/oclif.manifest.json +0 -1
- package/src/commands/addons/auth.js +0 -42
- package/src/commands/addons/config.js +0 -177
- package/src/commands/addons/create.js +0 -127
- package/src/commands/addons/delete.js +0 -69
- package/src/commands/addons/list.js +0 -54
- package/src/commands/api.js +0 -84
- package/src/commands/dev/exec.js +0 -32
- package/src/commands/dev/trace.js +0 -61
- package/src/commands/env/get.js +0 -44
- package/src/commands/env/import.js +0 -90
- package/src/commands/env/list.js +0 -49
- package/src/commands/env/set.js +0 -64
- package/src/commands/env/unset.js +0 -58
- package/src/commands/functions/build.js +0 -60
- package/src/commands/functions/invoke.js +0 -277
- package/src/commands/functions/list.js +0 -102
- package/src/commands/functions/serve.js +0 -70
- package/src/commands/link.js +0 -133
- package/src/commands/lm/info.js +0 -36
- package/src/commands/lm/install.js +0 -30
- package/src/commands/lm/setup.js +0 -107
- package/src/commands/lm/uninstall.js +0 -17
- package/src/commands/login.js +0 -54
- package/src/commands/logout.js +0 -37
- package/src/commands/open/admin.js +0 -51
- package/src/commands/open/site.js +0 -43
- package/src/commands/sites/create.js +0 -191
- package/src/commands/sites/delete.js +0 -116
- package/src/commands/sites/list.js +0 -84
- package/src/commands/status/hooks.js +0 -60
- package/src/commands/switch.js +0 -44
- package/src/commands/unlink.js +0 -38
- package/src/commands/watch.js +0 -115
- package/src/hooks/init.js +0 -46
- package/src/index.js +0 -25
- package/src/lib/help.js +0 -26
- package/src/utils/chalk.js +0 -16
- package/src/utils/check-command-inputs.js +0 -21
- package/src/utils/command.js +0 -262
- package/src/utils/detect-functions-builder.js +0 -25
- package/src/utils/difference.js +0 -4
- package/src/utils/logo.js +0 -11
- package/src/utils/show-help.js +0 -5
- package/src/utils/telemetry/tracked-command.js +0 -51
package/src/utils/header.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const chalk = require('chalk')
|
|
2
|
-
|
|
3
1
|
const pkg = require('../../package.json')
|
|
4
2
|
|
|
3
|
+
const { chalk } = require('./command-helpers')
|
|
4
|
+
|
|
5
5
|
module.exports = function header(context) {
|
|
6
6
|
const title = `${chalk.bgBlack.cyan('⬥ Netlify CLI')}`
|
|
7
7
|
const docsMsg = `${chalk.greenBright('Read the docs:')} https://www.netlify.com/docs/cli`
|
package/src/utils/headers.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { parseAllHeaders } = require('netlify-headers-parser')
|
|
2
2
|
|
|
3
|
-
const { log } = require('./command-helpers')
|
|
4
|
-
const { NETLIFYDEVERR } = require('./logo')
|
|
3
|
+
const { NETLIFYDEVERR, log } = require('./command-helpers')
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Get the matching headers for `path` given a set of `rules`.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
const commandHelpers = require('./command-helpers')
|
|
3
|
+
const createStreamPromise = require('./create-stream-promise')
|
|
4
|
+
const deploy = require('./deploy')
|
|
5
|
+
const detectServerSettings = require('./detect-server-settings')
|
|
6
|
+
const dev = require('./dev')
|
|
7
|
+
const execa = require('./execa')
|
|
8
|
+
const functions = require('./functions')
|
|
9
|
+
const getGlobalConfig = require('./get-global-config')
|
|
10
|
+
const getRepoData = require('./get-repo-data')
|
|
11
|
+
const ghAuth = require('./gh-auth')
|
|
12
|
+
const gitignore = require('./gitignore')
|
|
13
|
+
const liveTunnel = require('./live-tunnel')
|
|
14
|
+
const openBrowser = require('./open-browser')
|
|
15
|
+
const parseRawFlags = require('./parse-raw-flags')
|
|
16
|
+
const proxy = require('./proxy')
|
|
17
|
+
const readRepoURL = require('./read-repo-url')
|
|
18
|
+
const StateConfig = require('./state-config')
|
|
19
|
+
const telemetry = require('./telemetry')
|
|
20
|
+
const trafficMesh = require('./traffic-mesh')
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
...commandHelpers,
|
|
24
|
+
...createStreamPromise,
|
|
25
|
+
...deploy,
|
|
26
|
+
...detectServerSettings,
|
|
27
|
+
...dev,
|
|
28
|
+
...functions,
|
|
29
|
+
...getRepoData,
|
|
30
|
+
...ghAuth,
|
|
31
|
+
...gitignore,
|
|
32
|
+
...liveTunnel,
|
|
33
|
+
...openBrowser,
|
|
34
|
+
...parseRawFlags,
|
|
35
|
+
...proxy,
|
|
36
|
+
...readRepoURL,
|
|
37
|
+
...StateConfig,
|
|
38
|
+
...telemetry,
|
|
39
|
+
...trafficMesh,
|
|
40
|
+
execa,
|
|
41
|
+
getGlobalConfig,
|
|
42
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
const { Octokit } = require('@octokit/rest')
|
|
2
|
-
const chalk = require('chalk')
|
|
3
3
|
|
|
4
|
-
const { error: failAndExit, log } = require('../command-helpers')
|
|
4
|
+
const { chalk, error: failAndExit, log } = require('../command-helpers')
|
|
5
5
|
const { getGitHubToken: ghauth } = require('../gh-auth')
|
|
6
6
|
|
|
7
7
|
const { createDeployKey, formatErrorMessage, getBuildSettings, saveNetlifyToml, setupSite } = require('./utils')
|
|
@@ -23,7 +23,7 @@ const PAGE_SIZE = 100
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Get a valid github token
|
|
26
|
-
* @returns {string}
|
|
26
|
+
* @returns {Promise<string>}
|
|
27
27
|
*/
|
|
28
28
|
const getGitHubToken = async ({ globalConfig }) => {
|
|
29
29
|
const userId = globalConfig.get('userId')
|
|
@@ -196,8 +196,15 @@ const addNotificationHooks = async ({ api, siteId, token }) => {
|
|
|
196
196
|
log(`Netlify Notification Hooks configured!`)
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
/**
|
|
200
|
+
* @param {object} config
|
|
201
|
+
* @param {import('../../commands/base-command').BaseCommand} config.command
|
|
202
|
+
* @param {string} config.repoName
|
|
203
|
+
* @param {string} config.repoOwner
|
|
204
|
+
* @param {string} config.siteId
|
|
205
|
+
*/
|
|
206
|
+
const configGithub = async ({ command, repoName, repoOwner, siteId }) => {
|
|
207
|
+
const { netlify } = command
|
|
201
208
|
const {
|
|
202
209
|
api,
|
|
203
210
|
cachedConfig: { configPath, env },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
const inquirer = require('inquirer')
|
|
2
3
|
|
|
3
4
|
const { exit, log } = require('../command-helpers')
|
|
@@ -51,8 +52,14 @@ const addDeployHook = async ({ deployHook }) => {
|
|
|
51
52
|
return deployHookAdded
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
/**
|
|
56
|
+
* @param {object} config
|
|
57
|
+
* @param {import('../../commands/base-command').BaseCommand} config.command
|
|
58
|
+
* @param {*} config.repoData
|
|
59
|
+
* @param {string} config.siteId
|
|
60
|
+
*/
|
|
61
|
+
module.exports = async function configManual({ command, repoData, siteId }) {
|
|
62
|
+
const { netlify } = command
|
|
56
63
|
const {
|
|
57
64
|
api,
|
|
58
65
|
cachedConfig: { configPath, env },
|
package/src/utils/init/config.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { log } = require('../command-helpers')
|
|
1
|
+
// @ts-check
|
|
2
|
+
const { chalk, log } = require('../command-helpers')
|
|
4
3
|
|
|
5
4
|
const { configGithub } = require('./config-github')
|
|
6
5
|
const configManual = require('./config-manual')
|
|
@@ -18,14 +17,21 @@ const logSuccess = (repoData) => {
|
|
|
18
17
|
`)
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @param {object} config
|
|
22
|
+
* @param {import('../../commands/base-command').BaseCommand} config.command
|
|
23
|
+
* @param {boolean} config.manual
|
|
24
|
+
* @param {*} config.repoData
|
|
25
|
+
* @param {string} config.siteId
|
|
26
|
+
*/
|
|
27
|
+
const configureRepo = async ({ command, manual, repoData, siteId }) => {
|
|
22
28
|
if (manual) {
|
|
23
|
-
await configManual({
|
|
29
|
+
await configManual({ command, siteId, repoData })
|
|
24
30
|
} else if (repoData.provider === 'github') {
|
|
25
|
-
await configGithub({
|
|
31
|
+
await configGithub({ command, siteId, repoName: repoData.name, repoOwner: repoData.owner })
|
|
26
32
|
} else {
|
|
27
33
|
log(`No configurator found for the provided git remote. Configuring manually...`)
|
|
28
|
-
await configManual({
|
|
34
|
+
await configManual({ command, siteId, repoData })
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
logSuccess(repoData)
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
const { readFile } = require('fs').promises
|
|
3
|
+
|
|
1
4
|
const { get } = require('dot-prop')
|
|
2
5
|
const locatePath = require('locate-path')
|
|
3
6
|
const nodeVersionAlias = require('node-version-alias')
|
|
4
7
|
|
|
5
|
-
const { readFileAsync } = require('../../lib/fs')
|
|
6
8
|
const { warn } = require('../command-helpers')
|
|
7
9
|
|
|
8
10
|
const DEFAULT_NODE_VERSION = '12.18.0'
|
|
@@ -16,7 +18,7 @@ const detectNodeVersion = async ({ baseDirectory, env }) => {
|
|
|
16
18
|
try {
|
|
17
19
|
const nodeVersionFile = await locatePath(['.nvmrc', '.node-version'], { cwd: baseDirectory })
|
|
18
20
|
const configuredVersion =
|
|
19
|
-
nodeVersionFile === undefined ? get(env, 'NODE_VERSION.value') : await
|
|
21
|
+
nodeVersionFile === undefined ? get(env, 'NODE_VERSION.value') : await readFile(nodeVersionFile, 'utf8')
|
|
20
22
|
|
|
21
23
|
const version =
|
|
22
24
|
configuredVersion === undefined
|
package/src/utils/init/utils.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
const { existsSync } = require('fs')
|
|
3
|
+
const { writeFile } = require('fs').promises
|
|
1
4
|
const { EOL } = require('os')
|
|
2
5
|
const path = require('path')
|
|
3
6
|
const process = require('process')
|
|
4
7
|
|
|
5
|
-
const chalk = require('chalk')
|
|
6
8
|
const cleanDeep = require('clean-deep')
|
|
7
9
|
const inquirer = require('inquirer')
|
|
8
10
|
const isEmpty = require('lodash/isEmpty')
|
|
9
11
|
|
|
10
|
-
const { fileExistsAsync, writeFileAsync } = require('../../lib/fs')
|
|
11
12
|
const { normalizeBackslash } = require('../../lib/path')
|
|
12
|
-
const { error: failAndExit, warn } = require('../command-helpers')
|
|
13
|
+
const { chalk, error: failAndExit, warn } = require('../command-helpers')
|
|
13
14
|
|
|
14
15
|
const { getFrameworkInfo } = require('./frameworks')
|
|
15
16
|
const { detectNodeVersion } = require('./node-version')
|
|
@@ -204,8 +205,7 @@ const getNetlifyToml = ({
|
|
|
204
205
|
const saveNetlifyToml = async ({ baseDir, buildCmd, buildDir, config, configPath, functionsDir, repositoryRoot }) => {
|
|
205
206
|
const tomlPathParts = [repositoryRoot, baseDir, 'netlify.toml'].filter(Boolean)
|
|
206
207
|
const tomlPath = path.join(...tomlPathParts)
|
|
207
|
-
|
|
208
|
-
if (exists) {
|
|
208
|
+
if (existsSync(tomlPath)) {
|
|
209
209
|
return
|
|
210
210
|
}
|
|
211
211
|
|
|
@@ -226,7 +226,11 @@ const saveNetlifyToml = async ({ baseDir, buildCmd, buildDir, config, configPath
|
|
|
226
226
|
])
|
|
227
227
|
if (makeNetlifyTOML) {
|
|
228
228
|
try {
|
|
229
|
-
await
|
|
229
|
+
await writeFile(
|
|
230
|
+
tomlPath,
|
|
231
|
+
getNetlifyToml({ command: buildCmd, publish: buildDir, functions: functionsDir }),
|
|
232
|
+
'utf-8',
|
|
233
|
+
)
|
|
230
234
|
} catch (error) {
|
|
231
235
|
warn(`Failed saving Netlify toml file: ${error.message}`)
|
|
232
236
|
}
|
package/src/utils/live-tunnel.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
const process = require('process')
|
|
2
3
|
|
|
3
|
-
const chalk = require('chalk')
|
|
4
|
-
const execa = require('execa')
|
|
5
4
|
const fetch = require('node-fetch')
|
|
6
5
|
const pWaitFor = require('p-wait-for')
|
|
7
6
|
|
|
8
7
|
const { fetchLatestVersion, shouldFetchLatestVersion } = require('../lib/exec-fetcher')
|
|
9
8
|
const { getPathInHome } = require('../lib/settings')
|
|
10
9
|
|
|
11
|
-
const { log } = require('./command-helpers')
|
|
12
|
-
const
|
|
10
|
+
const { NETLIFYDEVERR, NETLIFYDEVLOG, chalk, log } = require('./command-helpers')
|
|
11
|
+
const execa = require('./execa')
|
|
13
12
|
|
|
14
13
|
const PACKAGE_NAME = 'live-tunnel-client'
|
|
15
14
|
const EXEC_NAME = PACKAGE_NAME
|
package/src/utils/lm/install.js
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
const { appendFile, copyFile, readFile, writeFile } = require('fs').promises
|
|
1
3
|
const os = require('os')
|
|
2
4
|
const path = require('path')
|
|
3
5
|
const process = require('process')
|
|
4
6
|
|
|
5
|
-
const chalk = require('chalk')
|
|
6
7
|
const execa = require('execa')
|
|
7
8
|
const hasbin = require('hasbin')
|
|
8
9
|
const Listr = require('listr')
|
|
9
10
|
const pathKey = require('path-key')
|
|
10
11
|
|
|
11
12
|
const { fetchLatestVersion, shouldFetchLatestVersion } = require('../../lib/exec-fetcher')
|
|
12
|
-
const {
|
|
13
|
-
appendFileAsync,
|
|
14
|
-
copyFileAsync,
|
|
15
|
-
fileExistsAsync,
|
|
16
|
-
readFileAsync,
|
|
17
|
-
rmdirRecursiveAsync,
|
|
18
|
-
writeFileAsync,
|
|
19
|
-
} = require('../../lib/fs')
|
|
13
|
+
const { fileExistsAsync, rmdirRecursiveAsync } = require('../../lib/fs')
|
|
20
14
|
const { normalizeBackslash } = require('../../lib/path')
|
|
21
15
|
const { getLegacyPathInHome, getPathInHome } = require('../../lib/settings')
|
|
16
|
+
const { chalk } = require('../command-helpers')
|
|
22
17
|
|
|
23
18
|
const PACKAGE_NAME = 'netlify-credential-helper'
|
|
24
19
|
const EXEC_NAME = 'git-credential-netlify'
|
|
@@ -154,7 +149,7 @@ Set the helper path in your environment PATH: ${getBinPath()}`
|
|
|
154
149
|
}
|
|
155
150
|
|
|
156
151
|
return await Promise.all([
|
|
157
|
-
await
|
|
152
|
+
await copyFile(`${__dirname}/scripts/${shell}.sh`, incFilePath),
|
|
158
153
|
await writeConfig(configFile, getInitContent(incFilePath)),
|
|
159
154
|
])
|
|
160
155
|
}
|
|
@@ -165,12 +160,12 @@ const writeConfig = async function (name, initContent) {
|
|
|
165
160
|
return
|
|
166
161
|
}
|
|
167
162
|
|
|
168
|
-
const content = await
|
|
163
|
+
const content = await readFile(configPath, 'utf8')
|
|
169
164
|
if (content.includes(initContent)) {
|
|
170
165
|
return
|
|
171
166
|
}
|
|
172
167
|
|
|
173
|
-
return await
|
|
168
|
+
return await appendFile(configPath, initContent, 'utf-8')
|
|
174
169
|
}
|
|
175
170
|
|
|
176
171
|
const getCurrentCredentials = async () => {
|
|
@@ -225,7 +220,7 @@ const configureGitConfig = async function () {
|
|
|
225
220
|
}
|
|
226
221
|
|
|
227
222
|
const gitConfigPath = getGitConfigPath()
|
|
228
|
-
await
|
|
223
|
+
await writeFile(gitConfigPath, helperConfig, 'utf-8')
|
|
229
224
|
|
|
230
225
|
return writeConfig(GIT_CONFIG, getGitConfigContent(gitConfigPath))
|
|
231
226
|
}
|
|
@@ -292,8 +287,8 @@ const removeConfig = async function (name, toRemove) {
|
|
|
292
287
|
return
|
|
293
288
|
}
|
|
294
289
|
|
|
295
|
-
const content = await
|
|
296
|
-
return await
|
|
290
|
+
const content = await readFile(configPath, 'utf8')
|
|
291
|
+
return await writeFile(configPath, content.replace(toRemove, ''))
|
|
297
292
|
}
|
|
298
293
|
|
|
299
294
|
module.exports = { installPlatform, isBinInPath, getShellInfo, uninstall }
|
package/src/utils/lm/steps.js
CHANGED
package/src/utils/lm/ui.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
const os = require('os')
|
|
2
2
|
|
|
3
3
|
const boxen = require('boxen')
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
const { chalk, log } = require('../command-helpers')
|
|
5
6
|
|
|
6
7
|
const { getShellInfo, isBinInPath } = require('./install')
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @param {boolean} force
|
|
11
|
+
*/
|
|
12
|
+
const printBanner = function (force) {
|
|
9
13
|
const print = force || !isBinInPath()
|
|
10
14
|
const platform = os.platform()
|
|
11
15
|
|
|
@@ -15,7 +19,7 @@ const printBanner = function (command, force) {
|
|
|
15
19
|
`Run this command to use Netlify Large Media in your current shell\n\nsource ${incFilePath}`,
|
|
16
20
|
)
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
log(boxen(banner, { padding: 1, margin: 1, align: 'center', borderColor: '#00c7b7' }))
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
const process = require('process')
|
|
2
2
|
|
|
3
3
|
const open = require('better-opn')
|
|
4
|
-
const chalk = require('chalk')
|
|
5
4
|
const isDockerContainer = require('is-docker')
|
|
6
5
|
|
|
7
|
-
const { log } = require('./command-helpers')
|
|
6
|
+
const { chalk, log } = require('./command-helpers')
|
|
8
7
|
|
|
9
8
|
const unableToOpenBrowserMessage = function ({ message, url }) {
|
|
10
9
|
log('---------------------------')
|
|
@@ -14,6 +13,13 @@ const unableToOpenBrowserMessage = function ({ message, url }) {
|
|
|
14
13
|
log('---------------------------')
|
|
15
14
|
}
|
|
16
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Opens a browser and logs a message if it is not possible
|
|
18
|
+
* @param {object} config
|
|
19
|
+
* @param {string} config.url The url to open
|
|
20
|
+
* @param {boolean} [config.silentBrowserNoneError]
|
|
21
|
+
* @returns {Promise<void>}
|
|
22
|
+
*/
|
|
17
23
|
const openBrowser = async function ({ silentBrowserNoneError, url }) {
|
|
18
24
|
if (isDockerContainer()) {
|
|
19
25
|
unableToOpenBrowserMessage({ url, message: 'Running inside a docker container' })
|
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
|
|
13
13
|
const parseRawFlags = function (raw) {
|
|
14
14
|
const rawFlags = raw.reduce((acc, curr, index, array) => {
|
|
15
|
-
if (/^-{1,2}/.test(curr
|
|
16
|
-
const key = curr.
|
|
15
|
+
if (/^-{1,2}/.test(curr)) {
|
|
16
|
+
const key = curr.replace(/^-{1,2}/, '')
|
|
17
17
|
const next = array[index + 1]
|
|
18
18
|
if (!next) {
|
|
19
19
|
acc[key] = true
|
|
20
|
-
} else if (next && next
|
|
20
|
+
} else if (next && next && /^-{1,2}/.test(next)) {
|
|
21
21
|
acc[key] = true
|
|
22
22
|
} else {
|
|
23
|
-
acc[key] = next ? aggressiveJSONParse(next
|
|
23
|
+
acc[key] = next ? aggressiveJSONParse(next) : true
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
return acc
|
package/src/utils/proxy.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
const { Buffer } = require('buffer')
|
|
3
|
+
const { readFile } = require('fs').promises
|
|
2
4
|
const http = require('http')
|
|
3
5
|
const https = require('https')
|
|
4
6
|
const path = require('path')
|
|
@@ -16,13 +18,12 @@ const pEvent = require('p-event')
|
|
|
16
18
|
const pFilter = require('p-filter')
|
|
17
19
|
const toReadableStream = require('to-readable-stream')
|
|
18
20
|
|
|
19
|
-
const { fileExistsAsync, isFileAsync
|
|
21
|
+
const { fileExistsAsync, isFileAsync } = require('../lib/fs')
|
|
20
22
|
|
|
23
|
+
const { NETLIFYDEVLOG, NETLIFYDEVWARN } = require('./command-helpers')
|
|
21
24
|
const { createStreamPromise } = require('./create-stream-promise')
|
|
22
25
|
const { headersForPath, parseHeaders } = require('./headers')
|
|
23
|
-
const {
|
|
24
|
-
const { createRewriter } = require('./rules-proxy')
|
|
25
|
-
const { onChanges } = require('./rules-proxy')
|
|
26
|
+
const { createRewriter, onChanges } = require('./rules-proxy')
|
|
26
27
|
|
|
27
28
|
const isInternal = function (url) {
|
|
28
29
|
return url.startsWith('/.netlify/')
|
|
@@ -84,7 +85,7 @@ const render404 = async function (publicFolder) {
|
|
|
84
85
|
const maybe404Page = path.resolve(publicFolder, '404.html')
|
|
85
86
|
try {
|
|
86
87
|
const isFile = await isFileAsync(maybe404Page)
|
|
87
|
-
if (isFile) return await
|
|
88
|
+
if (isFile) return await readFile(maybe404Page, 'utf-8')
|
|
88
89
|
} catch (error) {
|
|
89
90
|
console.warn(NETLIFYDEVWARN, 'Error while serving 404.html file', error.message)
|
|
90
91
|
}
|
package/src/utils/redirects.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
const { parseAllRedirects } = require('netlify-redirect-parser')
|
|
2
3
|
|
|
3
|
-
const { log } = require('./command-helpers')
|
|
4
|
-
const { NETLIFYDEVERR } = require('./logo')
|
|
4
|
+
const { NETLIFYDEVERR, log } = require('./command-helpers')
|
|
5
5
|
|
|
6
6
|
// Parse, normalize and validate all redirects from `_redirects` files
|
|
7
7
|
// and `netlify.toml`
|
package/src/utils/rules-proxy.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
const path = require('path')
|
|
2
3
|
const url = require('url')
|
|
3
4
|
|
|
@@ -8,7 +9,7 @@ const pFilter = require('p-filter')
|
|
|
8
9
|
|
|
9
10
|
const { fileExistsAsync } = require('../lib/fs')
|
|
10
11
|
|
|
11
|
-
const { NETLIFYDEVLOG } = require('./
|
|
12
|
+
const { NETLIFYDEVLOG } = require('./command-helpers')
|
|
12
13
|
const { parseRedirects } = require('./redirects')
|
|
13
14
|
|
|
14
15
|
const onChanges = function (files, listener) {
|
|
@@ -1,116 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
const process = require('process')
|
|
3
|
-
|
|
4
|
-
const { isCI } = require('ci-info')
|
|
5
|
-
const execa = require('execa')
|
|
6
|
-
|
|
7
|
-
const getGlobalConfig = require('../get-global-config')
|
|
8
|
-
|
|
9
|
-
const isValidEventName = require('./validation')
|
|
10
|
-
|
|
11
|
-
const isTelemetryDisabled = function (config) {
|
|
12
|
-
return config.get('telemetryDisabled')
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const send = function (type, payload) {
|
|
16
|
-
const requestFile = path.join(__dirname, 'request.js')
|
|
17
|
-
const options = JSON.stringify({
|
|
18
|
-
data: payload,
|
|
19
|
-
type,
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
const args = [process.execPath, [requestFile, options]]
|
|
23
|
-
if (process.env.NETLIFY_TEST_TELEMETRY_WAIT === 'true') {
|
|
24
|
-
return execa(...args, {
|
|
25
|
-
stdio: 'inherit',
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// spawn detached child process to handle send
|
|
30
|
-
execa(...args, {
|
|
31
|
-
detached: true,
|
|
32
|
-
stdio: 'ignore',
|
|
33
|
-
}).unref()
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const eventConfig = {
|
|
37
|
-
// Namespace of current application
|
|
38
|
-
projectName: 'cli',
|
|
39
|
-
// Allowed objects
|
|
40
|
-
objects: [
|
|
41
|
-
// example cli:sites_created
|
|
42
|
-
'sites',
|
|
43
|
-
// example cli:user_signup
|
|
44
|
-
'user',
|
|
45
|
-
],
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const track = async function (eventName, payload = {}) {
|
|
49
|
-
if (isCI) {
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const globalConfig = await getGlobalConfig()
|
|
54
|
-
if (isTelemetryDisabled(globalConfig)) {
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const [userId, cliId] = [globalConfig.get('userId'), globalConfig.get('cliId')]
|
|
59
|
-
|
|
60
|
-
// automatically add `cli:` prefix if missing
|
|
61
|
-
if (!eventName.includes('cli:')) {
|
|
62
|
-
eventName = `cli:${eventName}`
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// event 'cli:command' bypasses validation
|
|
66
|
-
const isValid = eventName === 'cli:command' ? () => true : isValidEventName
|
|
67
|
-
// to ensure clean data, validate event name
|
|
68
|
-
if (!isValid(eventName, eventConfig)) {
|
|
69
|
-
return false
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const { duration, status, ...properties } = payload
|
|
73
|
-
const defaultData = {
|
|
74
|
-
event: eventName,
|
|
75
|
-
userId,
|
|
76
|
-
anonymousId: cliId,
|
|
77
|
-
duration,
|
|
78
|
-
status,
|
|
79
|
-
properties,
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return send('track', defaultData)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const identify = async function (payload) {
|
|
86
|
-
if (isCI) {
|
|
87
|
-
return
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const globalConfig = await getGlobalConfig()
|
|
91
|
-
if (isTelemetryDisabled(globalConfig, payload)) {
|
|
92
|
-
return
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const cliId = globalConfig.get('cliId')
|
|
96
|
-
const { email, name, userId } = payload
|
|
97
|
-
|
|
98
|
-
const defaultTraits = {
|
|
99
|
-
name,
|
|
100
|
-
email,
|
|
101
|
-
cliId,
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const identifyData = {
|
|
105
|
-
anonymousId: cliId,
|
|
106
|
-
userId,
|
|
107
|
-
traits: { ...defaultTraits, ...payload },
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return send('identify', identifyData)
|
|
111
|
-
}
|
|
1
|
+
const telemetry = require('./telemetry')
|
|
112
2
|
|
|
113
3
|
module.exports = {
|
|
114
|
-
|
|
115
|
-
identify,
|
|
4
|
+
...telemetry,
|
|
116
5
|
}
|