netlify-cli 15.10.0-rc.1 → 15.11.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/bin/run.mjs +5 -6
- package/npm-shrinkwrap.json +3 -6
- package/package.json +2 -1
- package/src/commands/base-command.mjs +116 -295
- package/src/commands/build/build.mjs +1 -9
- package/src/commands/deploy/deploy.mjs +9 -23
- package/src/commands/dev/dev.mjs +17 -22
- package/src/commands/functions/functions-create.mjs +89 -118
- package/src/commands/functions/functions-invoke.mjs +7 -10
- package/src/commands/functions/functions-list.mjs +2 -2
- package/src/commands/init/init.mjs +1 -1
- package/src/commands/link/link.mjs +5 -5
- package/src/commands/serve/serve.mjs +6 -10
- package/src/commands/sites/sites-create-template.mjs +1 -1
- package/src/commands/sites/sites-create.mjs +1 -1
- package/src/lib/edge-functions/internal.mjs +3 -5
- package/src/lib/edge-functions/proxy.mjs +3 -27
- package/src/lib/functions/netlify-function.mjs +26 -1
- package/src/lib/functions/registry.mjs +14 -26
- package/src/lib/functions/runtimes/js/worker.mjs +1 -1
- package/src/lib/spinner.mjs +1 -1
- package/src/recipes/vscode/index.mjs +6 -24
- package/src/utils/command-helpers.mjs +7 -16
- package/src/utils/detect-server-settings.mjs +245 -133
- package/src/utils/framework-server.mjs +5 -6
- package/src/utils/functions/functions.mjs +5 -8
- 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 +3 -4
- package/src/utils/read-repo-url.mjs +0 -4
- package/src/utils/run-build.mjs +32 -58
- package/src/utils/shell.mjs +7 -24
- package/src/utils/state-config.mjs +1 -5
- package/src/utils/static-server.mjs +0 -4
- package/src/utils/build-info.mjs +0 -100
package/src/utils/build-info.mjs
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import fuzzy from 'fuzzy'
|
|
4
|
-
import inquirer from 'inquirer'
|
|
5
|
-
|
|
6
|
-
import { chalk, log } from './command-helpers.mjs'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Filters the inquirer settings based on the input
|
|
10
|
-
* @param {ReturnType<typeof formatSettingsArrForInquirer>} scriptInquirerOptions
|
|
11
|
-
* @param {string} input
|
|
12
|
-
*/
|
|
13
|
-
const filterSettings = function (scriptInquirerOptions, input) {
|
|
14
|
-
const filterOptions = scriptInquirerOptions.map((scriptInquirerOption) => scriptInquirerOption.name)
|
|
15
|
-
// TODO: remove once https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1394 is fixed
|
|
16
|
-
// eslint-disable-next-line unicorn/no-array-method-this-argument
|
|
17
|
-
const filteredSettings = fuzzy.filter(input, filterOptions)
|
|
18
|
-
const filteredSettingNames = new Set(
|
|
19
|
-
filteredSettings.map((filteredSetting) => (input ? filteredSetting.string : filteredSetting)),
|
|
20
|
-
)
|
|
21
|
-
return scriptInquirerOptions.filter((t) => filteredSettingNames.has(t.name))
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** @typedef {import('@netlify/build-info').Settings} Settings */
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @param {Settings[]} settings
|
|
28
|
-
* @param {'dev' | 'build'} type The type of command (dev or build)
|
|
29
|
-
*/
|
|
30
|
-
const formatSettingsArrForInquirer = function (settings, type = 'dev') {
|
|
31
|
-
return settings.map((setting) => {
|
|
32
|
-
const cmd = type === 'dev' ? setting.devCommand : setting.buildCommand
|
|
33
|
-
return {
|
|
34
|
-
name: `[${chalk.yellow(setting.framework.name)}] '${cmd}'`,
|
|
35
|
-
value: { ...setting, commands: [cmd] },
|
|
36
|
-
short: `${setting.name}-${cmd}`,
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Uses @netlify/build-info to detect the dev settings and port based on the framework
|
|
43
|
-
* and the build system that is used.
|
|
44
|
-
* @param {import('../commands/base-command.mjs').default} command
|
|
45
|
-
* @param {'dev' | 'build'} type The type of command (dev or build)
|
|
46
|
-
* @returns {Promise<Settings | undefined>}
|
|
47
|
-
*/
|
|
48
|
-
export const detectFrameworkSettings = async (command, type = 'dev') => {
|
|
49
|
-
const { relConfigFilePath } = command.netlify
|
|
50
|
-
const settings = await detectBuildSettings(command)
|
|
51
|
-
if (settings.length === 1) {
|
|
52
|
-
return settings[0]
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (settings.length > 1) {
|
|
56
|
-
/** multiple matching detectors, make the user choose */
|
|
57
|
-
const scriptInquirerOptions = formatSettingsArrForInquirer(settings, type)
|
|
58
|
-
/** @type {{chosenSettings: Settings}} */
|
|
59
|
-
const { chosenSettings } = await inquirer.prompt({
|
|
60
|
-
name: 'chosenSettings',
|
|
61
|
-
message: `Multiple possible ${type} commands found`,
|
|
62
|
-
type: 'autocomplete',
|
|
63
|
-
source(/** @type {string} */ _, input = '') {
|
|
64
|
-
if (!input) return scriptInquirerOptions
|
|
65
|
-
// only show filtered results
|
|
66
|
-
return filterSettings(scriptInquirerOptions, input)
|
|
67
|
-
},
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
log(`
|
|
71
|
-
Update your ${relConfigFilePath} to avoid this selection prompt next time:
|
|
72
|
-
|
|
73
|
-
[build]
|
|
74
|
-
command = "${chosenSettings.buildCommand}"
|
|
75
|
-
publish = "${chosenSettings.dist}"
|
|
76
|
-
|
|
77
|
-
[dev]
|
|
78
|
-
command = "${chosenSettings.devCommand}"
|
|
79
|
-
`)
|
|
80
|
-
return chosenSettings
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Detects and filters the build setting for a project and a command
|
|
86
|
-
* @param {import('../commands/base-command.mjs').default} command
|
|
87
|
-
*/
|
|
88
|
-
export const detectBuildSettings = async (command) => {
|
|
89
|
-
const { project, workspacePackage } = command
|
|
90
|
-
const buildSettings = await project.getBuildSettings(project.workspace ? workspacePackage : '')
|
|
91
|
-
return buildSettings
|
|
92
|
-
.filter((setting) => {
|
|
93
|
-
if (project.workspace && project.relativeBaseDirectory && setting.packagePath) {
|
|
94
|
-
return project.relativeBaseDirectory.startsWith(setting.packagePath)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return true
|
|
98
|
-
})
|
|
99
|
-
.filter((setting) => setting.devCommand)
|
|
100
|
-
}
|