netlify-cli 15.9.1-rc.0 → 15.10.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/npm-shrinkwrap.json +236 -738
- package/package.json +6 -5
- package/src/commands/base-command.mjs +59 -195
- package/src/commands/deploy/deploy.mjs +9 -21
- package/src/commands/dev/dev.mjs +15 -21
- package/src/commands/functions/functions-create.mjs +3 -0
- package/src/commands/functions/functions-invoke.mjs +5 -8
- package/src/commands/init/init.mjs +1 -1
- package/src/commands/link/link.mjs +5 -5
- package/src/commands/serve/serve.mjs +5 -11
- package/src/commands/sites/sites-create-template.mjs +1 -1
- package/src/commands/sites/sites-create.mjs +1 -1
- package/src/functions-templates/typescript/hello-world/package-lock.json +6 -6
- package/src/lib/edge-functions/bootstrap.mjs +1 -1
- package/src/lib/edge-functions/headers.mjs +1 -0
- package/src/lib/edge-functions/internal.mjs +3 -5
- package/src/lib/edge-functions/proxy.mjs +4 -27
- package/src/lib/functions/runtimes/js/index.mjs +1 -1
- package/src/lib/functions/runtimes/js/worker.mjs +1 -1
- package/src/lib/spinner.mjs +1 -1
- package/src/utils/command-helpers.mjs +7 -16
- package/src/utils/detect-server-settings.mjs +198 -147
- package/src/utils/framework-server.mjs +2 -2
- package/src/utils/functions/functions.mjs +0 -7
- package/src/utils/get-repo-data.mjs +6 -5
- package/src/utils/init/config-github.mjs +2 -2
- package/src/utils/init/config-manual.mjs +7 -24
- package/src/utils/init/frameworks.mjs +23 -0
- package/src/utils/init/utils.mjs +63 -62
- package/src/utils/proxy-server.mjs +4 -7
- package/src/utils/proxy.mjs +0 -4
- package/src/utils/run-build.mjs +7 -58
- package/src/utils/shell.mjs +3 -14
- package/src/utils/state-config.mjs +1 -5
- package/src/utils/static-server.mjs +0 -4
- package/src/utils/build-info.mjs +0 -19
|
@@ -5,12 +5,7 @@ import { exit, log } from '../command-helpers.mjs'
|
|
|
5
5
|
|
|
6
6
|
import { createDeployKey, getBuildSettings, saveNetlifyToml, setupSite } from './utils.mjs'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* Prompts for granting the netlify ssh public key access to your repo
|
|
10
|
-
* @param {object} deployKey
|
|
11
|
-
* @param {string} deployKey.public_key
|
|
12
|
-
*/
|
|
13
|
-
const addDeployKey = async (deployKey) => {
|
|
8
|
+
const addDeployKey = async ({ deployKey }) => {
|
|
14
9
|
log('\nGive this Netlify SSH public key access to your repository:\n')
|
|
15
10
|
log(`\n${deployKey.public_key}\n\n`)
|
|
16
11
|
|
|
@@ -28,11 +23,6 @@ const addDeployKey = async (deployKey) => {
|
|
|
28
23
|
}
|
|
29
24
|
}
|
|
30
25
|
|
|
31
|
-
/**
|
|
32
|
-
* @param {object} config
|
|
33
|
-
* @param {Awaited<ReturnType<import('../../utils/get-repo-data.mjs').default>>} config.repoData
|
|
34
|
-
* @returns {Promise<string>}
|
|
35
|
-
*/
|
|
36
26
|
const getRepoPath = async ({ repoData }) => {
|
|
37
27
|
const { repoPath } = await inquirer.prompt([
|
|
38
28
|
{
|
|
@@ -40,9 +30,6 @@ const getRepoPath = async ({ repoData }) => {
|
|
|
40
30
|
name: 'repoPath',
|
|
41
31
|
message: 'The SSH URL of the remote git repo:',
|
|
42
32
|
default: repoData.url,
|
|
43
|
-
/**
|
|
44
|
-
* @param {string} url
|
|
45
|
-
*/
|
|
46
33
|
validate: (url) => SSH_URL_REGEXP.test(url) || 'The URL provided does not use the SSH protocol',
|
|
47
34
|
},
|
|
48
35
|
])
|
|
@@ -50,11 +37,7 @@ const getRepoPath = async ({ repoData }) => {
|
|
|
50
37
|
return repoPath
|
|
51
38
|
}
|
|
52
39
|
|
|
53
|
-
|
|
54
|
-
* @param {string} deployHook
|
|
55
|
-
* @returns
|
|
56
|
-
*/
|
|
57
|
-
const addDeployHook = async (deployHook) => {
|
|
40
|
+
const addDeployHook = async ({ deployHook }) => {
|
|
58
41
|
log('\nConfigure the following webhook for your repository:\n')
|
|
59
42
|
log(`\n${deployHook}\n\n`)
|
|
60
43
|
const { deployHookAdded } = await inquirer.prompt([
|
|
@@ -72,14 +55,14 @@ const addDeployHook = async (deployHook) => {
|
|
|
72
55
|
/**
|
|
73
56
|
* @param {object} config
|
|
74
57
|
* @param {import('../../commands/base-command.mjs').default} config.command
|
|
75
|
-
* @param {
|
|
58
|
+
* @param {*} config.repoData
|
|
76
59
|
* @param {string} config.siteId
|
|
77
60
|
*/
|
|
78
61
|
export default async function configManual({ command, repoData, siteId }) {
|
|
79
62
|
const { netlify } = command
|
|
80
63
|
const {
|
|
81
64
|
api,
|
|
82
|
-
cachedConfig: { configPath },
|
|
65
|
+
cachedConfig: { configPath, env },
|
|
83
66
|
config,
|
|
84
67
|
repositoryRoot,
|
|
85
68
|
site: { root: siteRoot },
|
|
@@ -89,12 +72,12 @@ export default async function configManual({ command, repoData, siteId }) {
|
|
|
89
72
|
repositoryRoot,
|
|
90
73
|
siteRoot,
|
|
91
74
|
config,
|
|
92
|
-
|
|
75
|
+
env,
|
|
93
76
|
})
|
|
94
77
|
await saveNetlifyToml({ repositoryRoot, config, configPath, baseDir, buildCmd, buildDir, functionsDir })
|
|
95
78
|
|
|
96
79
|
const deployKey = await createDeployKey({ api })
|
|
97
|
-
await addDeployKey(deployKey)
|
|
80
|
+
await addDeployKey({ deployKey })
|
|
98
81
|
|
|
99
82
|
const repoPath = await getRepoPath({ repoData })
|
|
100
83
|
const repo = {
|
|
@@ -116,7 +99,7 @@ export default async function configManual({ command, repoData, siteId }) {
|
|
|
116
99
|
configPlugins: config.plugins,
|
|
117
100
|
pluginsToInstall,
|
|
118
101
|
})
|
|
119
|
-
const deployHookAdded = await addDeployHook(updatedSite.deploy_hook)
|
|
102
|
+
const deployHookAdded = await addDeployHook({ deployHook: updatedSite.deploy_hook })
|
|
120
103
|
if (!deployHookAdded) {
|
|
121
104
|
exit()
|
|
122
105
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { listFrameworks } from '@netlify/framework-info'
|
|
3
|
+
|
|
4
|
+
export const getFrameworkInfo = async ({ baseDirectory, nodeVersion }) => {
|
|
5
|
+
const frameworks = await listFrameworks({ projectDir: baseDirectory, nodeVersion })
|
|
6
|
+
// several frameworks can be detected - first one has highest priority
|
|
7
|
+
if (frameworks.length !== 0) {
|
|
8
|
+
const [
|
|
9
|
+
{
|
|
10
|
+
build: { commands, directory },
|
|
11
|
+
name,
|
|
12
|
+
plugins,
|
|
13
|
+
},
|
|
14
|
+
] = frameworks
|
|
15
|
+
return {
|
|
16
|
+
frameworkName: name,
|
|
17
|
+
frameworkBuildCommand: commands[0],
|
|
18
|
+
frameworkBuildDir: directory,
|
|
19
|
+
frameworkPlugins: plugins,
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return {}
|
|
23
|
+
}
|
package/src/utils/init/utils.mjs
CHANGED
|
@@ -1,72 +1,64 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import { writeFile } from 'fs/promises'
|
|
3
3
|
import path from 'path'
|
|
4
|
+
import process from 'process'
|
|
4
5
|
|
|
5
6
|
import cleanDeep from 'clean-deep'
|
|
6
7
|
import inquirer from 'inquirer'
|
|
7
8
|
|
|
8
9
|
import { fileExistsAsync } from '../../lib/fs.mjs'
|
|
9
10
|
import { normalizeBackslash } from '../../lib/path.mjs'
|
|
10
|
-
import { detectBuildSettings } from '../build-info.mjs'
|
|
11
11
|
import { chalk, error as failAndExit, log, warn } from '../command-helpers.mjs'
|
|
12
12
|
|
|
13
|
+
import { getFrameworkInfo } from './frameworks.mjs'
|
|
14
|
+
import { detectNodeVersion } from './node-version.mjs'
|
|
13
15
|
import { getRecommendPlugins, getUIPlugins } from './plugins.mjs'
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export const getPluginsToAutoInstall = (pluginsInstalled = [], pluginsRecommended = []) =>
|
|
30
|
-
pluginsRecommended.reduce(
|
|
31
|
-
(acc, plugin) =>
|
|
32
|
-
pluginsInstalled.includes(plugin) && !pluginsToAlwaysInstall.has(plugin) ? acc : [...acc, plugin],
|
|
33
|
-
|
|
34
|
-
/** @type {string[]} */ ([]),
|
|
35
|
-
)
|
|
17
|
+
const normalizeDir = ({ baseDirectory, defaultValue, dir }) => {
|
|
18
|
+
if (dir === undefined) {
|
|
19
|
+
return defaultValue
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const relativeDir = path.relative(baseDirectory, dir)
|
|
23
|
+
return relativeDir || defaultValue
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const getDefaultBase = ({ baseDirectory, repositoryRoot }) => {
|
|
27
|
+
if (baseDirectory !== repositoryRoot && baseDirectory.startsWith(repositoryRoot)) {
|
|
28
|
+
return path.relative(repositoryRoot, baseDirectory)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const recommendedPlugins = getRecommendPlugins(
|
|
32
|
+
const getDefaultSettings = ({
|
|
33
|
+
baseDirectory,
|
|
34
|
+
config,
|
|
35
|
+
frameworkBuildCommand,
|
|
36
|
+
frameworkBuildDir,
|
|
37
|
+
frameworkPlugins,
|
|
38
|
+
repositoryRoot,
|
|
39
|
+
}) => {
|
|
40
|
+
const recommendedPlugins = getRecommendPlugins(frameworkPlugins, config)
|
|
41
|
+
const {
|
|
42
|
+
command: defaultBuildCmd = frameworkBuildCommand,
|
|
43
|
+
functions: defaultFunctionsDir,
|
|
44
|
+
publish: defaultBuildDir = frameworkBuildDir,
|
|
45
|
+
} = config.build
|
|
46
46
|
|
|
47
47
|
return {
|
|
48
|
-
defaultBaseDir:
|
|
49
|
-
defaultBuildCmd
|
|
50
|
-
defaultBuildDir:
|
|
51
|
-
defaultFunctionsDir:
|
|
48
|
+
defaultBaseDir: getDefaultBase({ repositoryRoot, baseDirectory }),
|
|
49
|
+
defaultBuildCmd,
|
|
50
|
+
defaultBuildDir: normalizeDir({ baseDirectory, dir: defaultBuildDir, defaultValue: '.' }),
|
|
51
|
+
defaultFunctionsDir: normalizeDir({ baseDirectory, dir: defaultFunctionsDir, defaultValue: 'netlify/functions' }),
|
|
52
52
|
recommendedPlugins,
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
* @param {object} param0
|
|
59
|
-
* @param {string} param0.defaultBaseDir
|
|
60
|
-
* @param {string} param0.defaultBuildCmd
|
|
61
|
-
* @param {string=} param0.defaultBuildDir
|
|
62
|
-
* @returns
|
|
63
|
-
*/
|
|
64
56
|
const getPromptInputs = ({ defaultBaseDir, defaultBuildCmd, defaultBuildDir }) => {
|
|
65
57
|
const inputs = [
|
|
66
58
|
defaultBaseDir !== undefined && {
|
|
67
59
|
type: 'input',
|
|
68
60
|
name: 'baseDir',
|
|
69
|
-
message: 'Base directory
|
|
61
|
+
message: 'Base directory (e.g. projects/frontend):',
|
|
70
62
|
default: defaultBaseDir,
|
|
71
63
|
},
|
|
72
64
|
{
|
|
@@ -87,22 +79,34 @@ const getPromptInputs = ({ defaultBaseDir, defaultBuildCmd, defaultBuildDir }) =
|
|
|
87
79
|
return inputs.filter(Boolean)
|
|
88
80
|
}
|
|
89
81
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
82
|
+
// `repositoryRoot === siteRoot` means the base directory wasn't detected by @netlify/config, so we use cwd()
|
|
83
|
+
const getBaseDirectory = ({ repositoryRoot, siteRoot }) =>
|
|
84
|
+
path.normalize(repositoryRoot) === path.normalize(siteRoot) ? process.cwd() : siteRoot
|
|
85
|
+
|
|
86
|
+
export const getBuildSettings = async ({ config, env, repositoryRoot, siteRoot }) => {
|
|
87
|
+
const baseDirectory = getBaseDirectory({ repositoryRoot, siteRoot })
|
|
88
|
+
const nodeVersion = await detectNodeVersion({ baseDirectory, env })
|
|
89
|
+
const {
|
|
90
|
+
frameworkBuildCommand,
|
|
91
|
+
frameworkBuildDir,
|
|
92
|
+
frameworkName,
|
|
93
|
+
frameworkPlugins = [],
|
|
94
|
+
} = await getFrameworkInfo({
|
|
95
|
+
baseDirectory,
|
|
96
|
+
nodeVersion,
|
|
97
|
+
})
|
|
101
98
|
const { defaultBaseDir, defaultBuildCmd, defaultBuildDir, defaultFunctionsDir, recommendedPlugins } =
|
|
102
|
-
await
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
await getDefaultSettings({
|
|
100
|
+
repositoryRoot,
|
|
101
|
+
config,
|
|
102
|
+
baseDirectory,
|
|
103
|
+
frameworkBuildCommand,
|
|
104
|
+
frameworkBuildDir,
|
|
105
|
+
frameworkPlugins,
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
if (recommendedPlugins.length !== 0) {
|
|
109
|
+
log(`Configuring ${formatTitle(frameworkName)} runtime...`)
|
|
106
110
|
log()
|
|
107
111
|
}
|
|
108
112
|
|
|
@@ -195,9 +199,6 @@ export const formatErrorMessage = ({ error, message }) => {
|
|
|
195
199
|
return `${message} with error: ${chalk.red(errorMessage)}`
|
|
196
200
|
}
|
|
197
201
|
|
|
198
|
-
/**
|
|
199
|
-
* @param {string} title
|
|
200
|
-
*/
|
|
201
202
|
const formatTitle = (title) => chalk.cyan(title)
|
|
202
203
|
|
|
203
204
|
export const createDeployKey = async ({ api }) => {
|
|
@@ -36,21 +36,19 @@ export const generateInspectSettings = (edgeInspect, edgeInspectBrk) => {
|
|
|
36
36
|
/**
|
|
37
37
|
*
|
|
38
38
|
* @param {object} params
|
|
39
|
-
* @param {string=} params.accountId
|
|
40
39
|
* @param {*} params.addonsUrls
|
|
41
|
-
* @param {import('../commands/
|
|
40
|
+
* @param {import('../commands/base-command.mjs').NetlifyOptions["config"]} params.config
|
|
42
41
|
* @param {string} [params.configPath] An override for the Netlify config path
|
|
43
42
|
* @param {boolean} params.debug
|
|
44
|
-
* @param {import('../commands/
|
|
43
|
+
* @param {import('../commands/base-command.mjs').NetlifyOptions["cachedConfig"]['env']} params.env
|
|
45
44
|
* @param {InspectSettings} params.inspectSettings
|
|
46
45
|
* @param {() => Promise<object>} params.getUpdatedConfig
|
|
47
46
|
* @param {string} params.geolocationMode
|
|
48
47
|
* @param {string} params.geoCountry
|
|
49
48
|
* @param {*} params.settings
|
|
50
49
|
* @param {boolean} params.offline
|
|
51
|
-
* @param {
|
|
50
|
+
* @param {*} params.site
|
|
52
51
|
* @param {*} params.siteInfo
|
|
53
|
-
* @param {string} params.projectDir
|
|
54
52
|
* @param {import('./state-config.mjs').default} params.state
|
|
55
53
|
* @returns
|
|
56
54
|
*/
|
|
@@ -66,7 +64,6 @@ export const startProxyServer = async ({
|
|
|
66
64
|
getUpdatedConfig,
|
|
67
65
|
inspectSettings,
|
|
68
66
|
offline,
|
|
69
|
-
projectDir,
|
|
70
67
|
settings,
|
|
71
68
|
site,
|
|
72
69
|
siteInfo,
|
|
@@ -83,7 +80,7 @@ export const startProxyServer = async ({
|
|
|
83
80
|
getUpdatedConfig,
|
|
84
81
|
inspectSettings,
|
|
85
82
|
offline,
|
|
86
|
-
projectDir,
|
|
83
|
+
projectDir: site.root,
|
|
87
84
|
settings,
|
|
88
85
|
state,
|
|
89
86
|
siteInfo,
|
package/src/utils/proxy.mjs
CHANGED
|
@@ -599,10 +599,6 @@ const onRequest = async (
|
|
|
599
599
|
proxy.web(req, res, options)
|
|
600
600
|
}
|
|
601
601
|
|
|
602
|
-
/**
|
|
603
|
-
* @param {import('./types.js').ServerSettings} settings
|
|
604
|
-
* @returns
|
|
605
|
-
*/
|
|
606
602
|
export const getProxyUrl = function (settings) {
|
|
607
603
|
const scheme = settings.https ? 'https' : 'http'
|
|
608
604
|
return `${scheme}://localhost:${settings.port}`
|
package/src/utils/run-build.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import { promises as fs } from 'fs'
|
|
3
3
|
import path from 'path'
|
|
4
|
+
import process from 'process'
|
|
4
5
|
|
|
5
6
|
import { INTERNAL_EDGE_FUNCTIONS_FOLDER } from '../lib/edge-functions/consts.mjs'
|
|
6
7
|
import { getPathInProject } from '../lib/settings.mjs'
|
|
@@ -11,13 +12,8 @@ import { INTERNAL_FUNCTIONS_FOLDER } from './functions/index.mjs'
|
|
|
11
12
|
|
|
12
13
|
const netlifyBuildPromise = import('@netlify/build')
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* directory and returns the path to its new location.
|
|
17
|
-
* @param {object} config
|
|
18
|
-
* @param {string} config.configPath
|
|
19
|
-
* @param {string} config.siteRoot
|
|
20
|
-
*/
|
|
15
|
+
// Copies `netlify.toml`, if one is defined, into the `.netlify` internal
|
|
16
|
+
// directory and returns the path to its new location.
|
|
21
17
|
const copyConfig = async ({ configPath, siteRoot }) => {
|
|
22
18
|
const newConfigPath = path.resolve(siteRoot, getPathInProject(['netlify.toml']))
|
|
23
19
|
|
|
@@ -30,9 +26,6 @@ const copyConfig = async ({ configPath, siteRoot }) => {
|
|
|
30
26
|
return newConfigPath
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
/**
|
|
34
|
-
* @param {string} basePath
|
|
35
|
-
*/
|
|
36
29
|
const cleanInternalDirectory = async (basePath) => {
|
|
37
30
|
const ops = [INTERNAL_FUNCTIONS_FOLDER, INTERNAL_EDGE_FUNCTIONS_FOLDER, 'netlify.toml'].map((name) => {
|
|
38
31
|
const fullPath = path.resolve(basePath, getPathInProject([name]))
|
|
@@ -43,26 +36,9 @@ const cleanInternalDirectory = async (basePath) => {
|
|
|
43
36
|
await Promise.all(ops)
|
|
44
37
|
}
|
|
45
38
|
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* @param {object} config
|
|
49
|
-
* @param {string} config.projectDir
|
|
50
|
-
* @param {*} config.cachedConfig
|
|
51
|
-
* @param {object} config.options
|
|
52
|
-
* @param {string} config.options.configPath
|
|
53
|
-
* @param {*} config.options.context
|
|
54
|
-
* @param {string=} config.options.cwd
|
|
55
|
-
* @param {boolean} config.options.debug
|
|
56
|
-
* @param {boolean} config.options.dry
|
|
57
|
-
* @param {boolean} config.options.offline
|
|
58
|
-
* @param {boolean} config.options.quiet
|
|
59
|
-
* @param {boolean} config.options.saveConfig
|
|
60
|
-
* @returns
|
|
61
|
-
*/
|
|
62
39
|
const getBuildOptions = ({
|
|
63
40
|
cachedConfig,
|
|
64
|
-
options: { configPath, context, debug, dry, offline, quiet, saveConfig },
|
|
65
|
-
projectDir,
|
|
41
|
+
options: { configPath, context, cwd = process.cwd(), debug, dry, offline, quiet, saveConfig },
|
|
66
42
|
}) => ({
|
|
67
43
|
cachedConfig,
|
|
68
44
|
configPath,
|
|
@@ -75,35 +51,14 @@ const getBuildOptions = ({
|
|
|
75
51
|
telemetry: false,
|
|
76
52
|
buffer: false,
|
|
77
53
|
offline,
|
|
78
|
-
cwd
|
|
54
|
+
cwd,
|
|
79
55
|
quiet,
|
|
80
56
|
saveConfig,
|
|
81
57
|
})
|
|
82
58
|
|
|
83
|
-
|
|
84
|
-
*
|
|
85
|
-
* @param {object} config
|
|
86
|
-
* @param {*} config.cachedConfig
|
|
87
|
-
* @param {NodeJS.ProcessEnv} config.env
|
|
88
|
-
* @param {*} config.options The flags of the command
|
|
89
|
-
* @param {string} config.projectDir
|
|
90
|
-
* @param {import('./types.js').ServerSettings} config.settings
|
|
91
|
-
* @param {*} config.site
|
|
92
|
-
* @param {'build' | 'dev'} config.timeline
|
|
93
|
-
* @returns
|
|
94
|
-
*/
|
|
95
|
-
export const runNetlifyBuild = async ({
|
|
96
|
-
cachedConfig,
|
|
97
|
-
env,
|
|
98
|
-
options,
|
|
99
|
-
projectDir,
|
|
100
|
-
settings,
|
|
101
|
-
site,
|
|
102
|
-
timeline = 'build',
|
|
103
|
-
}) => {
|
|
59
|
+
const runNetlifyBuild = async ({ cachedConfig, env, options, settings, site, timeline = 'build' }) => {
|
|
104
60
|
const { default: buildSite, startDev } = await netlifyBuildPromise
|
|
105
61
|
const sharedOptions = getBuildOptions({
|
|
106
|
-
projectDir,
|
|
107
62
|
cachedConfig,
|
|
108
63
|
options,
|
|
109
64
|
})
|
|
@@ -163,19 +118,13 @@ export const runNetlifyBuild = async ({
|
|
|
163
118
|
// Run Netlify Build using the `startDev` entry point.
|
|
164
119
|
const { error: startDevError, success } = await startDev(devCommand, startDevOptions)
|
|
165
120
|
|
|
166
|
-
if (!success
|
|
121
|
+
if (!success) {
|
|
167
122
|
error(`Could not start local development server\n\n${startDevError.message}\n\n${startDevError.stack}`)
|
|
168
123
|
}
|
|
169
124
|
|
|
170
125
|
return {}
|
|
171
126
|
}
|
|
172
127
|
|
|
173
|
-
/**
|
|
174
|
-
* @param {Omit<Parameters<typeof runNetlifyBuild>[0], 'timeline'>} options
|
|
175
|
-
*/
|
|
176
128
|
export const runDevTimeline = (options) => runNetlifyBuild({ ...options, timeline: 'dev' })
|
|
177
129
|
|
|
178
|
-
/**
|
|
179
|
-
* @param {Omit<Parameters<typeof runNetlifyBuild>[0], 'timeline'>} options
|
|
180
|
-
*/
|
|
181
130
|
export const runBuildTimeline = (options) => runNetlifyBuild({ ...options, timeline: 'build' })
|
package/src/utils/shell.mjs
CHANGED
|
@@ -48,11 +48,7 @@ export const runCommand = (command, env = {}, spinner = null) => {
|
|
|
48
48
|
preferLocal: true,
|
|
49
49
|
// we use reject=false to avoid rejecting synchronously when the command doesn't exist
|
|
50
50
|
reject: false,
|
|
51
|
-
env
|
|
52
|
-
// we want always colorful terminal outputs
|
|
53
|
-
FORCE_COLOR: 'true',
|
|
54
|
-
...env,
|
|
55
|
-
},
|
|
51
|
+
env,
|
|
56
52
|
// windowsHide needs to be false for child process to terminate properly on Windows
|
|
57
53
|
windowsHide: false,
|
|
58
54
|
})
|
|
@@ -94,7 +90,7 @@ export const runCommand = (command, env = {}, spinner = null) => {
|
|
|
94
90
|
? `${NETLIFYDEVERR} ${result.shortMessage}`
|
|
95
91
|
: `${NETLIFYDEVWARN} "${command}" exited with code ${result.exitCode}`
|
|
96
92
|
|
|
97
|
-
log(
|
|
93
|
+
log(`${errorMessage}. Shutting down Netlify Dev server`)
|
|
98
94
|
}
|
|
99
95
|
|
|
100
96
|
return await cleanupBeforeExit({ exitCode: 1 })
|
|
@@ -104,13 +100,6 @@ export const runCommand = (command, env = {}, spinner = null) => {
|
|
|
104
100
|
return commandProcess
|
|
105
101
|
}
|
|
106
102
|
|
|
107
|
-
/**
|
|
108
|
-
*
|
|
109
|
-
* @param {object} config
|
|
110
|
-
* @param {string} config.command
|
|
111
|
-
* @param {*} config.error
|
|
112
|
-
* @returns
|
|
113
|
-
*/
|
|
114
103
|
const isNonExistingCommandError = ({ command, error: commandError }) => {
|
|
115
104
|
// `ENOENT` is only returned for non Windows systems
|
|
116
105
|
// See https://github.com/sindresorhus/execa/pull/447
|
|
@@ -119,7 +108,7 @@ const isNonExistingCommandError = ({ command, error: commandError }) => {
|
|
|
119
108
|
}
|
|
120
109
|
|
|
121
110
|
// if the command is a package manager we let it report the error
|
|
122
|
-
if (['yarn', 'npm'
|
|
111
|
+
if (['yarn', 'npm'].includes(command)) {
|
|
123
112
|
return false
|
|
124
113
|
}
|
|
125
114
|
|
|
@@ -11,11 +11,7 @@ import { getPathInProject } from '../lib/settings.mjs'
|
|
|
11
11
|
const STATE_PATH = getPathInProject(['state.json'])
|
|
12
12
|
const permissionError = "You don't have access to this file."
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
* Finds location of `.netlify/state.json`
|
|
16
|
-
* @param {string} cwd
|
|
17
|
-
* @returns {string}
|
|
18
|
-
*/
|
|
14
|
+
// Finds location of `.netlify/state.json`
|
|
19
15
|
const findStatePath = (cwd) => {
|
|
20
16
|
const statePath = findUpSync([STATE_PATH], { cwd })
|
|
21
17
|
|
|
@@ -6,10 +6,6 @@ import Fastify from 'fastify'
|
|
|
6
6
|
|
|
7
7
|
import { log, NETLIFYDEVLOG } from './command-helpers.mjs'
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* @param {object} config
|
|
11
|
-
* @param {import('./types.js').ServerSettings} config.settings
|
|
12
|
-
*/
|
|
13
9
|
export const startStaticServer = async ({ settings }) => {
|
|
14
10
|
const server = Fastify()
|
|
15
11
|
const rootPath = path.resolve(settings.dist)
|
package/src/utils/build-info.mjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Detects and filters the build setting for a project and a command
|
|
5
|
-
* @param {import('../commands/base-command.mjs').default} command
|
|
6
|
-
*/
|
|
7
|
-
export const detectBuildSettings = async (command) => {
|
|
8
|
-
const { project, workspacePackage } = command
|
|
9
|
-
const buildSettings = await project.getBuildSettings(project.workspace ? workspacePackage : '')
|
|
10
|
-
return buildSettings
|
|
11
|
-
.filter((setting) => {
|
|
12
|
-
if (project.workspace && project.relativeBaseDirectory && setting.packagePath) {
|
|
13
|
-
return project.relativeBaseDirectory.startsWith(setting.packagePath)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return true
|
|
17
|
-
})
|
|
18
|
-
.filter((setting) => setting.devCommand)
|
|
19
|
-
}
|