netlify-cli 6.14.0 → 6.14.4
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/npm-shrinkwrap.json +1132 -947
- package/oclif.manifest.json +1 -1
- package/package.json +8 -7
- package/src/commands/addons/auth.js +2 -2
- package/src/commands/addons/config.js +5 -5
- package/src/commands/addons/create.js +4 -4
- package/src/commands/addons/delete.js +2 -2
- package/src/commands/addons/index.js +1 -1
- package/src/commands/addons/list.js +1 -1
- package/src/commands/api.js +1 -1
- package/src/commands/deploy.js +17 -17
- package/src/commands/dev/index.js +6 -6
- package/src/commands/env/import.js +1 -1
- package/src/commands/env/index.js +1 -1
- package/src/commands/env/list.js +1 -1
- package/src/commands/functions/build.js +2 -2
- package/src/commands/functions/create.js +8 -8
- package/src/commands/functions/index.js +1 -1
- package/src/commands/functions/invoke.js +2 -2
- package/src/commands/functions/list.js +3 -3
- package/src/commands/functions/serve.js +3 -3
- package/src/commands/init.js +3 -3
- package/src/commands/link.js +1 -1
- package/src/commands/lm/index.js +1 -1
- package/src/commands/lm/info.js +2 -2
- package/src/commands/login.js +1 -1
- package/src/commands/logout.js +1 -1
- package/src/commands/open/admin.js +1 -1
- package/src/commands/open/index.js +1 -1
- package/src/commands/open/site.js +1 -1
- package/src/commands/sites/create.js +1 -1
- package/src/commands/sites/delete.js +1 -1
- package/src/commands/sites/index.js +1 -1
- package/src/commands/status/hooks.js +2 -2
- package/src/commands/status/index.js +2 -2
- package/src/commands/switch.js +1 -1
- package/src/commands/unlink.js +1 -1
- package/src/commands/watch.js +1 -1
- package/src/functions-templates/javascript/apollo-graphql-rest/{{name}}.js +1 -1
- package/src/functions-templates/javascript/create-user/{{name}}.js +1 -1
- package/src/functions-templates/javascript/fauna-crud/create-schema.js +1 -1
- package/src/functions-templates/javascript/fauna-crud/create.js +1 -1
- package/src/functions-templates/javascript/fauna-crud/delete.js +1 -1
- package/src/functions-templates/javascript/fauna-crud/read-all.js +1 -1
- package/src/functions-templates/javascript/fauna-crud/read.js +1 -1
- package/src/functions-templates/javascript/fauna-crud/update.js +1 -1
- package/src/functions-templates/javascript/stripe-charge/package-lock.json +12 -12
- package/src/functions-templates/javascript/stripe-subscription/package-lock.json +12 -12
- package/src/functions-templates/javascript/stripe-subscription/{{name}}.js +1 -1
- package/src/functions-templates/javascript/token-hider/{{name}}.js +1 -1
- package/src/functions-templates/javascript/using-middleware/{{name}}.js +1 -1
- 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/api.js +2 -2
- package/src/lib/build.js +2 -2
- package/src/lib/exec-fetcher.js +4 -4
- package/src/lib/functions/registry.js +1 -1
- package/src/lib/functions/runtimes/js/builders/zisi.js +1 -1
- package/src/lib/functions/server.js +5 -5
- package/src/lib/http-agent.js +4 -4
- package/src/lib/spinner.js +1 -1
- package/src/utils/addons/diffs/index.js +1 -1
- package/src/utils/addons/prepare.js +5 -5
- package/src/utils/addons/render.js +1 -1
- package/src/utils/command-helpers.js +2 -2
- package/src/utils/command.js +4 -4
- package/src/utils/deploy/deploy-site.js +4 -4
- package/src/utils/deploy/hash-files.js +2 -2
- package/src/utils/deploy/hash-fns.js +4 -4
- package/src/utils/deploy/hasher-segments.js +1 -1
- package/src/utils/deploy/upload-files.js +3 -3
- package/src/utils/detect-server-settings.js +5 -5
- package/src/utils/dev.js +4 -4
- package/src/utils/edge-handlers.js +4 -4
- package/src/utils/functions/index.js +1 -1
- package/src/utils/get-global-config.js +1 -1
- package/src/utils/get-repo-data.js +1 -1
- package/src/utils/gitignore.js +1 -1
- package/src/utils/headers.js +2 -2
- package/src/utils/init/config-github.js +12 -12
- package/src/utils/init/config-manual.js +4 -4
- package/src/utils/init/config.js +1 -1
- package/src/utils/init/frameworks.js +1 -1
- package/src/utils/init/plugins.js +1 -1
- package/src/utils/init/utils.js +15 -15
- package/src/utils/link/link-by-prompt.js +1 -1
- package/src/utils/live-tunnel.js +5 -5
- package/src/utils/lm/install.js +7 -7
- package/src/utils/lm/steps.js +1 -1
- package/src/utils/open-browser.js +2 -2
- package/src/utils/proxy.js +8 -8
- package/src/utils/redirects.js +3 -3
- package/src/utils/rules-proxy.js +1 -1
- package/src/utils/telemetry/index.js +1 -1
- package/src/utils/telemetry/tracked-command.js +1 -1
- package/src/utils/traffic-mesh.js +6 -6
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const { Octokit } = require('@octokit/rest')
|
|
2
2
|
const chalk = require('chalk')
|
|
3
3
|
|
|
4
|
-
const {
|
|
4
|
+
const { error: failAndExit, log } = require('../command-helpers')
|
|
5
5
|
const ghauth = require('../gh-auth')
|
|
6
6
|
|
|
7
|
-
const {
|
|
7
|
+
const { createDeployKey, formatErrorMessage, getBuildSettings, saveNetlifyToml, setupSite } = require('./utils')
|
|
8
8
|
|
|
9
|
-
const formatRepoAndOwner = ({
|
|
9
|
+
const formatRepoAndOwner = ({ repoName, repoOwner }) => ({
|
|
10
10
|
name: chalk.magenta(repoName),
|
|
11
11
|
owner: chalk.magenta(repoOwner),
|
|
12
12
|
})
|
|
@@ -35,7 +35,7 @@ const getGitHubClient = ({ token }) => {
|
|
|
35
35
|
return octokit
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const addDeployKey = async ({ api, octokit,
|
|
38
|
+
const addDeployKey = async ({ api, octokit, repoName, repoOwner }) => {
|
|
39
39
|
log('Adding deploy key to repository...')
|
|
40
40
|
const key = await createDeployKey({ api })
|
|
41
41
|
try {
|
|
@@ -58,7 +58,7 @@ const addDeployKey = async ({ api, octokit, repoOwner, repoName }) => {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const getGitHubRepo = async ({ octokit,
|
|
61
|
+
const getGitHubRepo = async ({ octokit, repoName, repoOwner }) => {
|
|
62
62
|
try {
|
|
63
63
|
const { data } = await octokit.repos.get({
|
|
64
64
|
owner: repoOwner,
|
|
@@ -75,7 +75,7 @@ const getGitHubRepo = async ({ octokit, repoOwner, repoName }) => {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
const hookExists = async ({ deployHook, octokit,
|
|
78
|
+
const hookExists = async ({ deployHook, octokit, repoName, repoOwner }) => {
|
|
79
79
|
try {
|
|
80
80
|
const { data: hooks } = await octokit.repos.listWebhooks({
|
|
81
81
|
owner: repoOwner,
|
|
@@ -90,7 +90,7 @@ const hookExists = async ({ deployHook, octokit, repoOwner, repoName }) => {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
const addDeployHook = async ({ deployHook, octokit,
|
|
93
|
+
const addDeployHook = async ({ deployHook, octokit, repoName, repoOwner }) => {
|
|
94
94
|
const exists = await hookExists({ deployHook, octokit, repoOwner, repoName })
|
|
95
95
|
if (!exists) {
|
|
96
96
|
try {
|
|
@@ -122,7 +122,7 @@ const addDeployHook = async ({ deployHook, octokit, repoOwner, repoName }) => {
|
|
|
122
122
|
const GITHUB_HOOK_EVENTS = ['deploy_created', 'deploy_failed', 'deploy_building']
|
|
123
123
|
const GITHUB_HOOK_TYPE = 'github_commit_status'
|
|
124
124
|
|
|
125
|
-
const upsertHook = async ({
|
|
125
|
+
const upsertHook = async ({ api, event, ntlHooks, siteId, token }) => {
|
|
126
126
|
const ntlHook = ntlHooks.find((hook) => hook.type === GITHUB_HOOK_TYPE && hook.event === event)
|
|
127
127
|
|
|
128
128
|
if (!ntlHook || ntlHook.disabled) {
|
|
@@ -148,7 +148,7 @@ const upsertHook = async ({ ntlHooks, event, api, siteId, token }) => {
|
|
|
148
148
|
})
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
const addNotificationHooks = async ({
|
|
151
|
+
const addNotificationHooks = async ({ api, siteId, token }) => {
|
|
152
152
|
log(`Creating Netlify GitHub Notification Hooks...`)
|
|
153
153
|
|
|
154
154
|
let ntlHooks
|
|
@@ -172,15 +172,15 @@ const addNotificationHooks = async ({ siteId, api, token }) => {
|
|
|
172
172
|
log(`Netlify Notification Hooks configured!`)
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
module.exports = async function configGithub({ context,
|
|
175
|
+
module.exports = async function configGithub({ context, repoName, repoOwner, siteId }) {
|
|
176
176
|
const { netlify } = context
|
|
177
177
|
const {
|
|
178
178
|
api,
|
|
179
|
-
|
|
179
|
+
cachedConfig: { configPath, env },
|
|
180
180
|
config,
|
|
181
|
+
globalConfig,
|
|
181
182
|
repositoryRoot,
|
|
182
183
|
site: { root: siteRoot },
|
|
183
|
-
cachedConfig: { env, configPath },
|
|
184
184
|
} = netlify
|
|
185
185
|
|
|
186
186
|
const token = await getGitHubToken({ globalConfig })
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const inquirer = require('inquirer')
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { exit, log } = require('../command-helpers')
|
|
4
4
|
|
|
5
|
-
const { getBuildSettings, saveNetlifyToml,
|
|
5
|
+
const { createDeployKey, getBuildSettings, saveNetlifyToml, setupSite } = require('./utils')
|
|
6
6
|
|
|
7
7
|
const addDeployKey = async ({ deployKey }) => {
|
|
8
8
|
log('\nGive this Netlify SSH public key access to your repository:\n')
|
|
@@ -51,14 +51,14 @@ const addDeployHook = async ({ deployHook }) => {
|
|
|
51
51
|
return deployHookAdded
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
module.exports = async function configManual({ context,
|
|
54
|
+
module.exports = async function configManual({ context, repoData, siteId }) {
|
|
55
55
|
const { netlify } = context
|
|
56
56
|
const {
|
|
57
57
|
api,
|
|
58
|
+
cachedConfig: { configPath, env },
|
|
58
59
|
config,
|
|
59
60
|
repositoryRoot,
|
|
60
61
|
site: { root: siteRoot },
|
|
61
|
-
cachedConfig: { env, configPath },
|
|
62
62
|
} = netlify
|
|
63
63
|
|
|
64
64
|
const { baseDir, buildCmd, buildDir, functionsDir, pluginsToInstall } = await getBuildSettings({
|
package/src/utils/init/config.js
CHANGED
|
@@ -18,7 +18,7 @@ const logSuccess = (repoData) => {
|
|
|
18
18
|
`)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const configureRepo = async ({ context,
|
|
21
|
+
const configureRepo = async ({ context, manual, repoData, siteId }) => {
|
|
22
22
|
if (manual) {
|
|
23
23
|
await configManual({ context, siteId, repoData })
|
|
24
24
|
} else if (repoData.provider === 'github') {
|
|
@@ -21,7 +21,7 @@ const isPluginInstalled = (configPlugins, plugin) =>
|
|
|
21
21
|
const getRecommendPlugins = (frameworkPlugins, config) =>
|
|
22
22
|
frameworkPlugins.filter((plugin) => !isPluginInstalled(config.plugins, plugin))
|
|
23
23
|
|
|
24
|
-
const getPluginsToInstall = ({
|
|
24
|
+
const getPluginsToInstall = ({ installSinglePlugin, plugins, recommendedPlugins }) => {
|
|
25
25
|
if (Array.isArray(plugins)) {
|
|
26
26
|
return plugins.map((plugin) => ({ package: plugin }))
|
|
27
27
|
}
|
package/src/utils/init/utils.js
CHANGED
|
@@ -13,9 +13,9 @@ const { error: failAndExit, warn } = require('../command-helpers')
|
|
|
13
13
|
|
|
14
14
|
const { getFrameworkInfo } = require('./frameworks')
|
|
15
15
|
const { detectNodeVersion } = require('./node-version')
|
|
16
|
-
const { getPluginsList,
|
|
16
|
+
const { getPluginInfo, getPluginsList, getPluginsToInstall, getRecommendPlugins, getUIPlugins } = require('./plugins')
|
|
17
17
|
|
|
18
|
-
const normalizeDir = ({ baseDirectory,
|
|
18
|
+
const normalizeDir = ({ baseDirectory, defaultValue, dir }) => {
|
|
19
19
|
if (dir === undefined) {
|
|
20
20
|
return defaultValue
|
|
21
21
|
}
|
|
@@ -24,19 +24,19 @@ const normalizeDir = ({ baseDirectory, dir, defaultValue }) => {
|
|
|
24
24
|
return relativeDir || defaultValue
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const getDefaultBase = ({
|
|
27
|
+
const getDefaultBase = ({ baseDirectory, repositoryRoot }) => {
|
|
28
28
|
if (baseDirectory !== repositoryRoot && baseDirectory.startsWith(repositoryRoot)) {
|
|
29
29
|
return path.relative(repositoryRoot, baseDirectory)
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const getDefaultSettings = ({
|
|
34
|
-
repositoryRoot,
|
|
35
|
-
config,
|
|
36
34
|
baseDirectory,
|
|
37
|
-
|
|
35
|
+
config,
|
|
38
36
|
frameworkBuildCommand,
|
|
39
37
|
frameworkBuildDir,
|
|
38
|
+
frameworkPlugins,
|
|
39
|
+
repositoryRoot,
|
|
40
40
|
}) => {
|
|
41
41
|
const recommendedPlugins = getRecommendPlugins(frameworkPlugins, config)
|
|
42
42
|
const {
|
|
@@ -55,12 +55,12 @@ const getDefaultSettings = ({
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
const getPromptInputs = async ({
|
|
58
|
+
defaultBaseDir,
|
|
58
59
|
defaultBuildCmd,
|
|
59
60
|
defaultBuildDir,
|
|
60
61
|
defaultFunctionsDir,
|
|
61
|
-
defaultBaseDir,
|
|
62
|
-
recommendedPlugins,
|
|
63
62
|
frameworkName,
|
|
63
|
+
recommendedPlugins,
|
|
64
64
|
}) => {
|
|
65
65
|
const inputs = [
|
|
66
66
|
defaultBaseDir !== undefined && {
|
|
@@ -132,7 +132,7 @@ const getPromptInputs = async ({
|
|
|
132
132
|
const getBaseDirectory = ({ repositoryRoot, siteRoot }) =>
|
|
133
133
|
path.normalize(repositoryRoot) === path.normalize(siteRoot) ? process.cwd() : siteRoot
|
|
134
134
|
|
|
135
|
-
const getBuildSettings = async ({
|
|
135
|
+
const getBuildSettings = async ({ config, env, repositoryRoot, siteRoot }) => {
|
|
136
136
|
const baseDirectory = getBaseDirectory({ repositoryRoot, siteRoot })
|
|
137
137
|
const nodeVersion = await detectNodeVersion({ baseDirectory, env })
|
|
138
138
|
const {
|
|
@@ -153,7 +153,7 @@ const getBuildSettings = async ({ repositoryRoot, siteRoot, config, env }) => {
|
|
|
153
153
|
frameworkBuildDir,
|
|
154
154
|
frameworkPlugins,
|
|
155
155
|
})
|
|
156
|
-
const { baseDir, buildCmd, buildDir, functionsDir,
|
|
156
|
+
const { baseDir, buildCmd, buildDir, functionsDir, installSinglePlugin, plugins } = await inquirer.prompt(
|
|
157
157
|
await getPromptInputs({
|
|
158
158
|
defaultBuildCmd,
|
|
159
159
|
defaultBuildDir,
|
|
@@ -176,8 +176,8 @@ const getBuildSettings = async ({ repositoryRoot, siteRoot, config, env }) => {
|
|
|
176
176
|
|
|
177
177
|
const getNetlifyToml = ({
|
|
178
178
|
command = '# no build command',
|
|
179
|
-
publish = '.',
|
|
180
179
|
functions = 'functions',
|
|
180
|
+
publish = '.',
|
|
181
181
|
}) => `# example netlify.toml
|
|
182
182
|
[build]
|
|
183
183
|
command = "${command}"
|
|
@@ -201,7 +201,7 @@ const getNetlifyToml = ({
|
|
|
201
201
|
## more info on configuring this file: https://www.netlify.com/docs/netlify-toml-reference/
|
|
202
202
|
`
|
|
203
203
|
|
|
204
|
-
const saveNetlifyToml = async ({
|
|
204
|
+
const saveNetlifyToml = async ({ baseDir, buildCmd, buildDir, config, configPath, functionsDir, repositoryRoot }) => {
|
|
205
205
|
const tomlPathParts = [repositoryRoot, baseDir, 'netlify.toml'].filter(Boolean)
|
|
206
206
|
const tomlPath = path.join(...tomlPathParts)
|
|
207
207
|
const exists = await fileExistsAsync(tomlPath)
|
|
@@ -233,7 +233,7 @@ const saveNetlifyToml = async ({ repositoryRoot, config, configPath, baseDir, bu
|
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
const formatErrorMessage = ({
|
|
236
|
+
const formatErrorMessage = ({ error, message }) => {
|
|
237
237
|
const errorMessage = error.json ? `${error.message} - ${JSON.stringify(error.json)}` : error.message
|
|
238
238
|
return `${message} with error: ${chalk.red(errorMessage)}`
|
|
239
239
|
}
|
|
@@ -250,7 +250,7 @@ const createDeployKey = async ({ api }) => {
|
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
const updateSite = async ({
|
|
253
|
+
const updateSite = async ({ api, options, siteId }) => {
|
|
254
254
|
try {
|
|
255
255
|
const updatedSite = await api.updateSite({ siteId, body: options })
|
|
256
256
|
return updatedSite
|
|
@@ -260,7 +260,7 @@ const updateSite = async ({ siteId, api, options }) => {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
const setupSite = async ({ api,
|
|
263
|
+
const setupSite = async ({ api, configPlugins, pluginsToInstall, repo, siteId }) => {
|
|
264
264
|
const updatedSite = await updateSite({
|
|
265
265
|
siteId,
|
|
266
266
|
api,
|
|
@@ -5,7 +5,7 @@ const inquirer = require('inquirer')
|
|
|
5
5
|
const isEmpty = require('lodash/isEmpty')
|
|
6
6
|
|
|
7
7
|
const { listSites } = require('../../lib/api')
|
|
8
|
-
const {
|
|
8
|
+
const { error, exit, log } = require('../command-helpers')
|
|
9
9
|
const { getRepoData } = require('../get-repo-data')
|
|
10
10
|
const { track } = require('../telemetry')
|
|
11
11
|
|
package/src/utils/live-tunnel.js
CHANGED
|
@@ -5,11 +5,11 @@ const execa = require('execa')
|
|
|
5
5
|
const fetch = require('node-fetch')
|
|
6
6
|
const pWaitFor = require('p-wait-for')
|
|
7
7
|
|
|
8
|
-
const {
|
|
8
|
+
const { fetchLatestVersion, shouldFetchLatestVersion } = require('../lib/exec-fetcher')
|
|
9
9
|
const { getPathInHome } = require('../lib/settings')
|
|
10
10
|
|
|
11
11
|
const { log } = require('./command-helpers')
|
|
12
|
-
const {
|
|
12
|
+
const { NETLIFYDEVERR, NETLIFYDEVLOG } = require('./logo')
|
|
13
13
|
|
|
14
14
|
const PACKAGE_NAME = 'live-tunnel-client'
|
|
15
15
|
const EXEC_NAME = PACKAGE_NAME
|
|
@@ -19,7 +19,7 @@ const TUNNEL_POLL_INTERVAL = 1e3
|
|
|
19
19
|
// 5 minutes
|
|
20
20
|
const TUNNEL_POLL_TIMEOUT = 3e5
|
|
21
21
|
|
|
22
|
-
const createTunnel = async function ({
|
|
22
|
+
const createTunnel = async function ({ netlifyApiToken, siteId }) {
|
|
23
23
|
await installTunnelClient()
|
|
24
24
|
|
|
25
25
|
if (!siteId) {
|
|
@@ -51,7 +51,7 @@ const createTunnel = async function ({ siteId, netlifyApiToken }) {
|
|
|
51
51
|
return data
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const connectTunnel = function ({
|
|
54
|
+
const connectTunnel = function ({ localPort, netlifyApiToken, session }) {
|
|
55
55
|
const execPath = getPathInHome(['tunnel', 'bin', EXEC_NAME])
|
|
56
56
|
const args = ['connect', '-s', session.id, '-t', netlifyApiToken, '-l', localPort]
|
|
57
57
|
if (process.env.DEBUG) {
|
|
@@ -88,7 +88,7 @@ const installTunnelClient = async function () {
|
|
|
88
88
|
})
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
const startLiveTunnel = async ({
|
|
91
|
+
const startLiveTunnel = async ({ localPort, netlifyApiToken, siteId }) => {
|
|
92
92
|
const session = await createTunnel({
|
|
93
93
|
siteId,
|
|
94
94
|
netlifyApiToken,
|
package/src/utils/lm/install.js
CHANGED
|
@@ -8,24 +8,24 @@ const hasbin = require('hasbin')
|
|
|
8
8
|
const Listr = require('listr')
|
|
9
9
|
const pathKey = require('path-key')
|
|
10
10
|
|
|
11
|
-
const {
|
|
11
|
+
const { fetchLatestVersion, shouldFetchLatestVersion } = require('../../lib/exec-fetcher')
|
|
12
12
|
const {
|
|
13
|
-
fileExistsAsync,
|
|
14
|
-
writeFileAsync,
|
|
15
|
-
readFileAsync,
|
|
16
13
|
appendFileAsync,
|
|
17
14
|
copyFileAsync,
|
|
15
|
+
fileExistsAsync,
|
|
16
|
+
readFileAsync,
|
|
18
17
|
rmdirRecursiveAsync,
|
|
18
|
+
writeFileAsync,
|
|
19
19
|
} = require('../../lib/fs')
|
|
20
20
|
const { normalizeBackslash } = require('../../lib/path')
|
|
21
|
-
const {
|
|
21
|
+
const { getLegacyPathInHome, getPathInHome } = require('../../lib/settings')
|
|
22
22
|
|
|
23
23
|
const PACKAGE_NAME = 'netlify-credential-helper'
|
|
24
24
|
const EXEC_NAME = 'git-credential-netlify'
|
|
25
25
|
|
|
26
26
|
const GIT_CONFIG = '.gitconfig'
|
|
27
27
|
|
|
28
|
-
const {
|
|
28
|
+
const { checkGitLFSVersionStep, checkGitVersionStep, checkLFSFiltersStep } = require('./steps')
|
|
29
29
|
|
|
30
30
|
const SUPPORTED_PLATFORMS = {
|
|
31
31
|
linux: 'Linux',
|
|
@@ -145,7 +145,7 @@ const setupUnixPath = async () => {
|
|
|
145
145
|
return true
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
const {
|
|
148
|
+
const { configFile, incFilePath, shell } = getShellInfo()
|
|
149
149
|
|
|
150
150
|
if (configFile === undefined) {
|
|
151
151
|
const error = `Unable to set credential helper in PATH. We don't how to set the path for ${shell} shell.
|
package/src/utils/lm/steps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const chalk = require('chalk')
|
|
2
2
|
|
|
3
|
-
const { checkGitVersion,
|
|
3
|
+
const { checkGitVersion, checkHelperVersion, checkLFSFilters, checkLFSVersion } = require('./requirements')
|
|
4
4
|
|
|
5
5
|
const checkGitVersionStep = {
|
|
6
6
|
title: 'Checking Git version',
|
|
@@ -6,7 +6,7 @@ const isDockerContainer = require('is-docker')
|
|
|
6
6
|
|
|
7
7
|
const { log } = require('./command-helpers')
|
|
8
8
|
|
|
9
|
-
const unableToOpenBrowserMessage = function ({
|
|
9
|
+
const unableToOpenBrowserMessage = function ({ message, url }) {
|
|
10
10
|
log('---------------------------')
|
|
11
11
|
log(chalk.redBright(`Error: Unable to open browser automatically: ${message}`))
|
|
12
12
|
log(chalk.cyan('Please open your browser and open the URL below:'))
|
|
@@ -14,7 +14,7 @@ const unableToOpenBrowserMessage = function ({ url, message }) {
|
|
|
14
14
|
log('---------------------------')
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const openBrowser = async function ({
|
|
17
|
+
const openBrowser = async function ({ silentBrowserNoneError, url }) {
|
|
18
18
|
if (isDockerContainer()) {
|
|
19
19
|
unableToOpenBrowserMessage({ url, message: 'Running inside a docker container' })
|
|
20
20
|
return
|
package/src/utils/proxy.js
CHANGED
|
@@ -16,10 +16,10 @@ const pEvent = require('p-event')
|
|
|
16
16
|
const pFilter = require('p-filter')
|
|
17
17
|
const toReadableStream = require('to-readable-stream')
|
|
18
18
|
|
|
19
|
-
const {
|
|
19
|
+
const { fileExistsAsync, isFileAsync, readFileAsync } = require('../lib/fs')
|
|
20
20
|
|
|
21
21
|
const { createStreamPromise } = require('./create-stream-promise')
|
|
22
|
-
const {
|
|
22
|
+
const { headersForPath, parseHeaders } = require('./headers')
|
|
23
23
|
const { NETLIFYDEVLOG, NETLIFYDEVWARN } = require('./logo')
|
|
24
24
|
const { createRewriter } = require('./rules-proxy')
|
|
25
25
|
const { onChanges } = require('./rules-proxy')
|
|
@@ -54,11 +54,11 @@ const isExternal = function (match) {
|
|
|
54
54
|
return match.to && match.to.match(/^https?:\/\//)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
const stripOrigin = function ({ pathname, search
|
|
57
|
+
const stripOrigin = function ({ hash, pathname, search }) {
|
|
58
58
|
return `${pathname}${search}${hash}`
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const proxyToExternalUrl = function ({
|
|
61
|
+
const proxyToExternalUrl = function ({ dest, destURL, req, res }) {
|
|
62
62
|
console.log(`${NETLIFYDEVLOG} Proxying to ${dest}`)
|
|
63
63
|
const handler = createProxyMiddleware({
|
|
64
64
|
target: dest.origin,
|
|
@@ -69,7 +69,7 @@ const proxyToExternalUrl = function ({ req, res, dest, destURL }) {
|
|
|
69
69
|
return handler(req, res, {})
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const handleAddonUrl = function ({ req, res
|
|
72
|
+
const handleAddonUrl = function ({ addonUrl, req, res }) {
|
|
73
73
|
const dest = new URL(addonUrl)
|
|
74
74
|
const destURL = stripOrigin(dest)
|
|
75
75
|
|
|
@@ -114,7 +114,7 @@ const alternativePathsFor = function (url) {
|
|
|
114
114
|
return paths
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
const serveRedirect = async function ({
|
|
117
|
+
const serveRedirect = async function ({ match, options, proxy, req, res }) {
|
|
118
118
|
if (!match) return proxy.web(req, res, options)
|
|
119
119
|
|
|
120
120
|
options = options || req.proxyOptions || {}
|
|
@@ -271,7 +271,7 @@ const reqToURL = function (req, pathname) {
|
|
|
271
271
|
|
|
272
272
|
const MILLISEC_TO_SEC = 1e3
|
|
273
273
|
|
|
274
|
-
const initializeProxy = async function ({
|
|
274
|
+
const initializeProxy = async function ({ configPath, distDir, port, projectDir }) {
|
|
275
275
|
const proxy = httpProxy.createProxyServer({
|
|
276
276
|
selfHandleResponse: true,
|
|
277
277
|
target: {
|
|
@@ -358,7 +358,7 @@ const initializeProxy = async function ({ port, distDir, projectDir, configPath
|
|
|
358
358
|
return handlers
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
-
const onRequest = async ({
|
|
361
|
+
const onRequest = async ({ addonsUrls, functionsServer, proxy, rewriter, settings }, req, res) => {
|
|
362
362
|
req.originalBody = ['GET', 'OPTIONS', 'HEAD'].includes(req.method)
|
|
363
363
|
? null
|
|
364
364
|
: await createStreamPromise(req, BYTES_LIMIT)
|
package/src/utils/redirects.js
CHANGED
|
@@ -5,8 +5,8 @@ const { NETLIFYDEVERR } = require('./logo')
|
|
|
5
5
|
|
|
6
6
|
// Parse, normalize and validate all redirects from `_redirects` files
|
|
7
7
|
// and `netlify.toml`
|
|
8
|
-
const parseRedirects = async function ({
|
|
9
|
-
const {
|
|
8
|
+
const parseRedirects = async function ({ configPath, redirectsFiles }) {
|
|
9
|
+
const { errors, redirects } = await parseAllRedirects({
|
|
10
10
|
redirectsFiles,
|
|
11
11
|
netlifyConfigPath: configPath,
|
|
12
12
|
minimal: false,
|
|
@@ -33,9 +33,9 @@ const getErrorMessage = function ({ message }) {
|
|
|
33
33
|
// - `query` is called `params`
|
|
34
34
|
// - `conditions.role|country|language` are capitalized
|
|
35
35
|
const normalizeRedirect = function ({
|
|
36
|
+
conditions: { country, language, role, ...conditions },
|
|
36
37
|
from,
|
|
37
38
|
query,
|
|
38
|
-
conditions: { role, country, language, ...conditions },
|
|
39
39
|
...redirect
|
|
40
40
|
}) {
|
|
41
41
|
return {
|
package/src/utils/rules-proxy.js
CHANGED
|
@@ -30,7 +30,7 @@ const getCountry = function () {
|
|
|
30
30
|
return 'us'
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const createRewriter = async function ({ distDir,
|
|
33
|
+
const createRewriter = async function ({ configPath, distDir, jwtRoleClaim, jwtSecret, projectDir }) {
|
|
34
34
|
let matcher = null
|
|
35
35
|
const redirectsFiles = [...new Set([path.resolve(distDir, '_redirects'), path.resolve(projectDir, '_redirects')])]
|
|
36
36
|
let redirects = await parseRedirects({ redirectsFiles, configPath })
|
|
@@ -36,7 +36,7 @@ class TrackedCommand extends Command {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
async finally(error) {
|
|
39
|
-
const {
|
|
39
|
+
const { payload, startTime } = this.analytics
|
|
40
40
|
const duration = getDuration(startTime)
|
|
41
41
|
const status = getStatus(error)
|
|
42
42
|
await track('command', {
|
|
@@ -12,19 +12,19 @@ const { clearSpinner, startSpinner, stopSpinner } = require('../lib/spinner')
|
|
|
12
12
|
|
|
13
13
|
const { log } = require('./command-helpers')
|
|
14
14
|
const { createDeferred } = require('./deferred')
|
|
15
|
-
const {
|
|
15
|
+
const { NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN } = require('./logo')
|
|
16
16
|
|
|
17
17
|
const EDGE_HANDLERS_BUNDLER_CLI_PATH = path.resolve(require.resolve('@netlify/plugin-edge-handlers'), '..', 'cli.js')
|
|
18
18
|
|
|
19
19
|
const startForwardProxy = async ({
|
|
20
|
-
|
|
20
|
+
debug,
|
|
21
21
|
frameworkPort,
|
|
22
22
|
functionsPort,
|
|
23
|
-
publishDir,
|
|
24
|
-
debug,
|
|
25
|
-
locationDb,
|
|
26
23
|
jwtRolesPath,
|
|
27
24
|
jwtSecret,
|
|
25
|
+
locationDb,
|
|
26
|
+
port,
|
|
27
|
+
publishDir,
|
|
28
28
|
}) => {
|
|
29
29
|
const args = [
|
|
30
30
|
'run',
|
|
@@ -62,7 +62,7 @@ const startForwardProxy = async ({
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
const { subprocess } = runProcess({ args })
|
|
65
|
-
const {
|
|
65
|
+
const { firstBundleReady, forwarder } = forwardMessagesToLog({ subprocess })
|
|
66
66
|
|
|
67
67
|
subprocess.on('close', process.exit)
|
|
68
68
|
subprocess.on('SIGINT', process.exit)
|