@netlify/build 25.0.1 → 26.0.1
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/package.json +5 -3
- package/src/core/bin.js +7 -8
- package/src/core/config.js +18 -35
- package/src/core/constants.js +8 -14
- package/src/core/dry.js +4 -8
- package/src/core/feature_flags.js +2 -6
- package/src/core/flags.js +2 -6
- package/src/core/lingering.js +7 -7
- package/src/core/main.js +25 -29
- package/src/core/missing_side_file.js +4 -8
- package/src/core/normalize_flags.js +5 -9
- package/src/core/severity.js +2 -6
- package/src/core/user_node_version.js +7 -11
- package/src/env/changes.js +5 -9
- package/src/env/main.js +4 -8
- package/src/env/metadata.js +3 -7
- package/src/error/api.js +4 -8
- package/src/error/build.js +4 -8
- package/src/error/cancel.js +1 -5
- package/src/error/colors.js +2 -6
- package/src/error/handle.js +10 -14
- package/src/error/info.js +6 -10
- package/src/error/monitor/location.js +1 -5
- package/src/error/monitor/normalize.js +2 -6
- package/src/error/monitor/print.js +2 -8
- package/src/error/monitor/report.js +11 -15
- package/src/error/monitor/start.js +9 -11
- package/src/error/parse/clean_stack.js +4 -8
- package/src/error/parse/location.js +2 -6
- package/src/error/parse/normalize.js +1 -5
- package/src/error/parse/parse.js +10 -14
- package/src/error/parse/plugin.js +2 -6
- package/src/error/parse/properties.js +3 -7
- package/src/error/parse/serialize_log.js +2 -6
- package/src/error/parse/serialize_status.js +1 -5
- package/src/error/parse/stack.js +2 -6
- package/src/error/type.js +1 -5
- package/src/install/functions.js +5 -9
- package/src/install/local.js +5 -9
- package/src/install/main.js +6 -10
- package/src/install/missing.js +9 -13
- package/src/log/colors.js +5 -11
- package/src/log/description.js +2 -6
- package/src/log/header.js +2 -6
- package/src/log/header_func.js +3 -7
- package/src/log/logger.js +20 -40
- package/src/log/messages/compatibility.js +9 -18
- package/src/log/messages/config.js +12 -27
- package/src/log/messages/core.js +20 -31
- package/src/log/messages/core_steps.js +7 -15
- package/src/log/messages/dry.js +7 -15
- package/src/log/messages/install.js +4 -12
- package/src/log/messages/ipc.js +8 -20
- package/src/log/messages/mutations.js +8 -17
- package/src/log/messages/plugins.js +5 -14
- package/src/log/messages/status.js +3 -9
- package/src/log/messages/steps.js +6 -14
- package/src/log/old_version.js +6 -10
- package/src/log/serialize.js +3 -7
- package/src/log/stream.js +6 -15
- package/src/log/theme.js +14 -29
- package/src/plugins/child/diff.js +5 -9
- package/src/plugins/child/error.js +7 -11
- package/src/plugins/child/lazy.js +2 -6
- package/src/plugins/child/load.js +6 -10
- package/src/plugins/child/logic.js +6 -7
- package/src/plugins/child/main.js +5 -7
- package/src/plugins/child/run.js +6 -10
- package/src/plugins/child/status.js +4 -8
- package/src/plugins/child/typescript.js +5 -9
- package/src/plugins/child/utils.js +21 -27
- package/src/plugins/child/validate.js +6 -11
- package/src/plugins/compatibility.js +13 -16
- package/src/plugins/error.js +6 -15
- package/src/plugins/events.js +5 -20
- package/src/plugins/expected_version.js +9 -13
- package/src/plugins/ipc.js +12 -21
- package/src/plugins/list.js +6 -15
- package/src/plugins/load.js +13 -9
- package/src/plugins/manifest/check.js +4 -8
- package/src/plugins/manifest/load.js +6 -10
- package/src/plugins/manifest/main.js +5 -9
- package/src/plugins/manifest/path.js +3 -7
- package/src/plugins/manifest/validate.js +3 -7
- package/src/plugins/node_version.js +9 -15
- package/src/plugins/options.js +12 -17
- package/src/plugins/pinned_version.js +4 -8
- package/src/plugins/resolve.js +7 -11
- package/src/plugins/spawn.js +10 -12
- package/src/plugins_core/add.js +2 -6
- package/src/plugins_core/build_command.js +7 -11
- package/src/plugins_core/deploy/buildbot_client.js +11 -20
- package/src/plugins_core/deploy/index.js +5 -9
- package/src/plugins_core/functions/error.js +4 -8
- package/src/plugins_core/functions/feature_flags.js +1 -5
- package/src/plugins_core/functions/index.js +20 -14
- package/src/plugins_core/functions/utils.js +9 -13
- package/src/plugins_core/functions_install/index.js +3 -7
- package/src/plugins_core/list.js +10 -7
- package/src/status/add.js +1 -5
- package/src/status/colors.js +2 -6
- package/src/status/load_error.js +4 -8
- package/src/status/report.js +4 -8
- package/src/status/success.js +2 -6
- package/src/steps/core_step.js +4 -8
- package/src/steps/error.js +7 -11
- package/src/steps/get.js +7 -12
- package/src/steps/plugin.js +8 -12
- package/src/steps/return.js +4 -8
- package/src/steps/run_step.js +8 -12
- package/src/steps/run_steps.js +5 -9
- package/src/steps/update_config.js +10 -14
- package/src/telemetry/main.js +8 -12
- package/src/time/aggregate.js +2 -6
- package/src/time/main.js +8 -12
- package/src/time/measure.js +4 -8
- package/src/time/report.js +5 -9
- package/src/utils/errors.js +1 -5
- package/src/utils/json.js +19 -0
- package/src/utils/omit.js +2 -6
- package/src/utils/package.js +3 -7
- package/src/utils/remove_falsy.js +2 -6
- package/src/utils/resolve.js +8 -6
- package/src/utils/semver.js +9 -13
- package/types/config/functions.d.ts +1 -1
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { version as currentVersion, execPath } from 'process'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import semver from 'semver'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
engines: { node: nodeVersionSupportedRange },
|
|
9
|
-
} = require('../../package.json')
|
|
10
|
-
const { addErrorInfo } = require('../error/info')
|
|
5
|
+
import { addErrorInfo } from '../error/info.js'
|
|
6
|
+
import { ROOT_PACKAGE_JSON } from '../utils/json.js'
|
|
11
7
|
|
|
12
8
|
// Local plugins and `package.json`-installed plugins use user's preferred Node.js version if higher than our minimum
|
|
13
9
|
// supported version. Else default to the system Node version.
|
|
14
10
|
// Local and programmatic builds use `@netlify/build` Node.js version, which is
|
|
15
11
|
// usually the system's Node.js version.
|
|
16
12
|
// If the user Node version does not satisfy our supported engine range use our own system Node version
|
|
17
|
-
const addPluginsNodeVersion = function ({ pluginsOptions, nodePath, userNodeVersion }) {
|
|
18
|
-
const currentNodeVersion =
|
|
13
|
+
export const addPluginsNodeVersion = function ({ pluginsOptions, nodePath, userNodeVersion }) {
|
|
14
|
+
const currentNodeVersion = semver.clean(currentVersion)
|
|
19
15
|
return pluginsOptions.map((pluginOptions) =>
|
|
20
16
|
addPluginNodeVersion({ pluginOptions, currentNodeVersion, userNodeVersion, nodePath }),
|
|
21
17
|
)
|
|
@@ -29,18 +25,18 @@ const addPluginNodeVersion = function ({
|
|
|
29
25
|
nodePath,
|
|
30
26
|
}) {
|
|
31
27
|
return (loadedFrom === 'local' || loadedFrom === 'package.json') &&
|
|
32
|
-
satisfies(userNodeVersion,
|
|
28
|
+
semver.satisfies(userNodeVersion, ROOT_PACKAGE_JSON.engines.node)
|
|
33
29
|
? { ...pluginOptions, nodePath, nodeVersion: userNodeVersion }
|
|
34
30
|
: { ...pluginOptions, nodePath: execPath, nodeVersion: currentNodeVersion }
|
|
35
31
|
}
|
|
36
32
|
|
|
37
33
|
// Ensure Node.js version is compatible with plugin's `engines.node`
|
|
38
|
-
const checkNodeVersion = function ({
|
|
34
|
+
export const checkNodeVersion = function ({
|
|
39
35
|
nodeVersion,
|
|
40
36
|
packageName,
|
|
41
37
|
pluginPackageJson: { engines: { node: pluginNodeVersionRange } = {} } = {},
|
|
42
38
|
}) {
|
|
43
|
-
if (pluginNodeVersionRange && !satisfies(nodeVersion, pluginNodeVersionRange)) {
|
|
39
|
+
if (pluginNodeVersionRange && !semver.satisfies(nodeVersion, pluginNodeVersionRange)) {
|
|
44
40
|
throwUserError(
|
|
45
41
|
`The Node.js version is ${nodeVersion} but the plugin "${packageName}" requires ${pluginNodeVersionRange}`,
|
|
46
42
|
)
|
|
@@ -52,5 +48,3 @@ const throwUserError = function (message) {
|
|
|
52
48
|
addErrorInfo(error, { type: 'resolveConfig' })
|
|
53
49
|
throw error
|
|
54
50
|
}
|
|
55
|
-
|
|
56
|
-
module.exports = { addPluginsNodeVersion, checkNodeVersion }
|
package/src/plugins/options.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { dirname } from 'path'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { installLocalPluginsDependencies } from '../install/local.js'
|
|
4
|
+
import { measureDuration } from '../time/main.js'
|
|
5
|
+
import { ROOT_PACKAGE_JSON } from '../utils/json.js'
|
|
6
|
+
import { getPackageJson } from '../utils/package.js'
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { getPackageJson } = require('../utils/package')
|
|
9
|
-
|
|
10
|
-
const { useManifest } = require('./manifest/main')
|
|
11
|
-
const { checkNodeVersion } = require('./node_version')
|
|
12
|
-
const { resolvePluginsPath } = require('./resolve')
|
|
8
|
+
import { useManifest } from './manifest/main.js'
|
|
9
|
+
import { checkNodeVersion } from './node_version.js'
|
|
10
|
+
import { resolvePluginsPath } from './resolve.js'
|
|
13
11
|
|
|
14
12
|
// Load core plugins and user plugins
|
|
15
13
|
const tGetPluginsOptions = async function ({
|
|
@@ -51,7 +49,7 @@ const tGetPluginsOptions = async function ({
|
|
|
51
49
|
return { pluginsOptions: pluginsOptionsC }
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
const getPluginsOptions = measureDuration(tGetPluginsOptions, 'get_plugins_options')
|
|
52
|
+
export const getPluginsOptions = measureDuration(tGetPluginsOptions, 'get_plugins_options')
|
|
55
53
|
|
|
56
54
|
// Retrieve plugin's main file path.
|
|
57
55
|
// Then load plugin's `package.json` and `manifest.yml`.
|
|
@@ -82,12 +80,9 @@ const isNotRedundantCorePlugin = function (pluginOptionsA, index, pluginsOptions
|
|
|
82
80
|
|
|
83
81
|
// Retrieve information about @netlify/build when an error happens there and not
|
|
84
82
|
// in a plugin
|
|
85
|
-
const getSpawnInfo = function () {
|
|
86
|
-
const { name } = corePackageJson
|
|
83
|
+
export const getSpawnInfo = function () {
|
|
87
84
|
return {
|
|
88
|
-
plugin: { packageName: name, pluginPackageJson:
|
|
89
|
-
location: { event: 'load', packageName: name, loadedFrom: 'core', origin: 'core' },
|
|
85
|
+
plugin: { packageName: ROOT_PACKAGE_JSON.name, pluginPackageJson: ROOT_PACKAGE_JSON },
|
|
86
|
+
location: { event: 'load', packageName: ROOT_PACKAGE_JSON.name, loadedFrom: 'core', origin: 'core' },
|
|
90
87
|
}
|
|
91
88
|
}
|
|
92
|
-
|
|
93
|
-
module.exports = { getPluginsOptions, getSpawnInfo }
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { handleBuildError } = require('../error/handle')
|
|
4
|
-
const { getMajorVersion } = require('../utils/semver')
|
|
1
|
+
import { handleBuildError } from '../error/handle.js'
|
|
2
|
+
import { getMajorVersion } from '../utils/semver.js'
|
|
5
3
|
|
|
6
4
|
// Retrieve plugin's pinned major versions by fetching the latest `PluginRun`
|
|
7
5
|
// Only applies to `netlify.toml`-only installed plugins.
|
|
8
|
-
const addPinnedVersions = async function ({ pluginsOptions, api, siteInfo: { id: siteId }, sendStatus }) {
|
|
6
|
+
export const addPinnedVersions = async function ({ pluginsOptions, api, siteInfo: { id: siteId }, sendStatus }) {
|
|
9
7
|
if (!sendStatus || api === undefined || !siteId) {
|
|
10
8
|
return pluginsOptions
|
|
11
9
|
}
|
|
@@ -40,7 +38,7 @@ const addPinnedVersion = function (pluginOptions, pluginRuns) {
|
|
|
40
38
|
|
|
41
39
|
// Send an API request to pin plugins' major versions.
|
|
42
40
|
// Only applies to UI-installed plugins.
|
|
43
|
-
const pinPlugins = async function ({
|
|
41
|
+
export const pinPlugins = async function ({
|
|
44
42
|
pluginsOptions,
|
|
45
43
|
failedPlugins,
|
|
46
44
|
api,
|
|
@@ -131,5 +129,3 @@ const pinPlugin = async function ({
|
|
|
131
129
|
const shouldIgnoreError = function ({ status }) {
|
|
132
130
|
return status === 404
|
|
133
131
|
}
|
|
134
|
-
|
|
135
|
-
module.exports = { addPinnedVersions, pinPlugins }
|
package/src/plugins/resolve.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { addErrorInfo } from '../error/info.js'
|
|
2
|
+
import { installMissingPlugins } from '../install/missing.js'
|
|
3
|
+
import { resolvePath, tryResolvePath } from '../utils/resolve.js'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { addExpectedVersions } = require('./expected_version')
|
|
8
|
-
const { addPluginsNodeVersion } = require('./node_version')
|
|
9
|
-
const { addPinnedVersions } = require('./pinned_version')
|
|
5
|
+
import { addExpectedVersions } from './expected_version.js'
|
|
6
|
+
import { addPluginsNodeVersion } from './node_version.js'
|
|
7
|
+
import { addPinnedVersions } from './pinned_version.js'
|
|
10
8
|
|
|
11
9
|
// Try to find plugins in four places, by priority order:
|
|
12
10
|
// - already loaded (core plugins)
|
|
13
11
|
// - local plugin
|
|
14
12
|
// - external plugin already installed in `node_modules`, most likely through `package.json`
|
|
15
13
|
// - automatically installed by us, to `.netlify/plugins/`
|
|
16
|
-
const resolvePluginsPath = async function ({
|
|
14
|
+
export const resolvePluginsPath = async function ({
|
|
17
15
|
pluginsOptions,
|
|
18
16
|
siteInfo,
|
|
19
17
|
buildDir,
|
|
@@ -152,5 +150,3 @@ const resolveMissingPluginPath = async function ({ pluginOptions, pluginOptions:
|
|
|
152
150
|
const isMissingPlugin = function ({ isMissing }) {
|
|
153
151
|
return isMissing
|
|
154
152
|
}
|
|
155
|
-
|
|
156
|
-
module.exports = { resolvePluginsPath }
|
package/src/plugins/spawn.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { fileURLToPath } from 'url'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import execa from 'execa'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { addErrorInfo } from '../error/info.js'
|
|
6
|
+
import { logLoadingPlugins, logOutdatedPlugins, logIncompatiblePlugins } from '../log/messages/compatibility.js'
|
|
7
|
+
import { measureDuration } from '../time/main.js'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
import { getEventFromChild } from './ipc.js'
|
|
10
|
+
import { getSpawnInfo } from './options.js'
|
|
11
11
|
|
|
12
|
-
const CHILD_MAIN_FILE =
|
|
12
|
+
const CHILD_MAIN_FILE = fileURLToPath(new URL('child/main.js', import.meta.url))
|
|
13
13
|
|
|
14
14
|
// Start child processes used by all plugins
|
|
15
15
|
// We fire plugins through child processes so that:
|
|
@@ -28,7 +28,7 @@ const tStartPlugins = async function ({ pluginsOptions, buildDir, childEnv, logs
|
|
|
28
28
|
return { childProcesses }
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const startPlugins = measureDuration(tStartPlugins, 'start_plugins')
|
|
31
|
+
export const startPlugins = measureDuration(tStartPlugins, 'start_plugins')
|
|
32
32
|
|
|
33
33
|
const startPlugin = async function ({ pluginDir, nodePath, buildDir, childEnv }) {
|
|
34
34
|
const childProcess = execa.node(CHILD_MAIN_FILE, {
|
|
@@ -53,7 +53,7 @@ const startPlugin = async function ({ pluginDir, nodePath, buildDir, childEnv })
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// Stop all plugins child processes
|
|
56
|
-
const stopPlugins = function (childProcesses) {
|
|
56
|
+
export const stopPlugins = function (childProcesses) {
|
|
57
57
|
childProcesses.forEach(stopPlugin)
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -64,5 +64,3 @@ const stopPlugin = function ({ childProcess }) {
|
|
|
64
64
|
|
|
65
65
|
childProcess.kill()
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
module.exports = { startPlugins, stopPlugins }
|
package/src/plugins_core/add.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { listCorePlugins, isCorePlugin } = require('./list')
|
|
1
|
+
import { listCorePlugins, isCorePlugin } from './list.js'
|
|
4
2
|
|
|
5
3
|
// Add core plugins and user plugins together.
|
|
6
4
|
// Do not allow user override of core plugins.
|
|
7
|
-
const addCorePlugins = function ({ netlifyConfig: { plugins }, constants }) {
|
|
5
|
+
export const addCorePlugins = function ({ netlifyConfig: { plugins }, constants }) {
|
|
8
6
|
const corePlugins = listCorePlugins(constants)
|
|
9
7
|
const allCorePlugins = corePlugins
|
|
10
8
|
.map((corePlugin) => addCoreProperties(corePlugin, plugins))
|
|
@@ -49,5 +47,3 @@ const normalizePluginOptions = function ({
|
|
|
49
47
|
}) {
|
|
50
48
|
return { packageName, pluginPath, pinnedVersion, loadedFrom, origin, inputs }
|
|
51
49
|
}
|
|
52
|
-
|
|
53
|
-
module.exports = { addCorePlugins }
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { platform } from 'process'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import execa from 'execa'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const { logBuildCommandStart } = require('../log/messages/steps')
|
|
10
|
-
const { getBuildCommandStdio, handleBuildCommandOutput } = require('../log/stream')
|
|
5
|
+
import { addErrorInfo } from '../error/info.js'
|
|
6
|
+
import { getBuildCommandDescription } from '../log/description.js'
|
|
7
|
+
import { logBuildCommandStart } from '../log/messages/steps.js'
|
|
8
|
+
import { getBuildCommandStdio, handleBuildCommandOutput } from '../log/stream.js'
|
|
11
9
|
|
|
12
10
|
// Fire `build.command`
|
|
13
11
|
const coreStep = async function ({
|
|
@@ -67,7 +65,7 @@ const hasBuildCommand = function ({
|
|
|
67
65
|
return buildCommand !== undefined && buildCommand !== ''
|
|
68
66
|
}
|
|
69
67
|
|
|
70
|
-
const buildCommandCore = {
|
|
68
|
+
export const buildCommandCore = {
|
|
71
69
|
event: 'onBuild',
|
|
72
70
|
coreStep,
|
|
73
71
|
coreStepId: 'build_command',
|
|
@@ -75,5 +73,3 @@ const buildCommandCore = {
|
|
|
75
73
|
coreStepDescription,
|
|
76
74
|
condition: hasBuildCommand,
|
|
77
75
|
}
|
|
78
|
-
|
|
79
|
-
module.exports = { buildCommandCore }
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import net from 'net'
|
|
2
|
+
import { normalize, resolve, relative } from 'path'
|
|
3
|
+
import { promisify } from 'util'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
const { normalize, resolve, relative } = require('path')
|
|
5
|
-
const { promisify } = require('util')
|
|
5
|
+
import pEvent from 'p-event'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { addErrorInfo } from '../../error/info.js'
|
|
8
|
+
import { runsAfterDeploy } from '../../plugins/events.js'
|
|
9
|
+
import { addAsyncErrorMessage } from '../../utils/errors.js'
|
|
8
10
|
|
|
9
|
-
const
|
|
10
|
-
const { runsAfterDeploy } = require('../../plugins/events')
|
|
11
|
-
const { addAsyncErrorMessage } = require('../../utils/errors')
|
|
12
|
-
|
|
13
|
-
const createBuildbotClient = function (buildbotServerSocket) {
|
|
11
|
+
export const createBuildbotClient = function (buildbotServerSocket) {
|
|
14
12
|
const connectionOpts = getConnectionOpts(buildbotServerSocket)
|
|
15
13
|
const client = net.createConnection(connectionOpts)
|
|
16
14
|
return client
|
|
@@ -30,9 +28,9 @@ const eConnectBuildbotClient = async function (client) {
|
|
|
30
28
|
await pEvent(client, 'connect')
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
const connectBuildbotClient = addAsyncErrorMessage(eConnectBuildbotClient, 'Could not connect to buildbot')
|
|
31
|
+
export const connectBuildbotClient = addAsyncErrorMessage(eConnectBuildbotClient, 'Could not connect to buildbot')
|
|
34
32
|
|
|
35
|
-
const closeBuildbotClient = async function (client) {
|
|
33
|
+
export const closeBuildbotClient = async function (client) {
|
|
36
34
|
if (client.destroyed) {
|
|
37
35
|
return
|
|
38
36
|
}
|
|
@@ -56,7 +54,7 @@ const getNextParsedResponsePromise = addAsyncErrorMessage(
|
|
|
56
54
|
'Invalid response from buildbot',
|
|
57
55
|
)
|
|
58
56
|
|
|
59
|
-
const deploySiteWithBuildbotClient = async function ({ client, events, buildDir, repositoryRoot, constants }) {
|
|
57
|
+
export const deploySiteWithBuildbotClient = async function ({ client, events, buildDir, repositoryRoot, constants }) {
|
|
60
58
|
const action = shouldWaitForPostProcessing(events) ? 'deploySiteAndAwaitLive' : 'deploySite'
|
|
61
59
|
const deployDir = getDeployDir({ buildDir, repositoryRoot, constants })
|
|
62
60
|
const payload = { action, deployDir }
|
|
@@ -102,10 +100,3 @@ const shouldWaitForPostProcessing = function (events) {
|
|
|
102
100
|
const hasPostDeployLogic = function (event) {
|
|
103
101
|
return runsAfterDeploy(event)
|
|
104
102
|
}
|
|
105
|
-
|
|
106
|
-
module.exports = {
|
|
107
|
-
createBuildbotClient,
|
|
108
|
-
connectBuildbotClient,
|
|
109
|
-
closeBuildbotClient,
|
|
110
|
-
deploySiteWithBuildbotClient,
|
|
111
|
-
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { saveUpdatedConfig, restoreUpdatedConfig } from '../../core/config.js'
|
|
2
|
+
import { logDeploySuccess } from '../../log/messages/plugins.js'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const { logDeploySuccess } = require('../../log/messages/plugins')
|
|
5
|
-
|
|
6
|
-
const {
|
|
4
|
+
import {
|
|
7
5
|
createBuildbotClient,
|
|
8
6
|
connectBuildbotClient,
|
|
9
7
|
closeBuildbotClient,
|
|
10
8
|
deploySiteWithBuildbotClient,
|
|
11
|
-
}
|
|
9
|
+
} from './buildbot_client.js'
|
|
12
10
|
|
|
13
11
|
const coreStep = async function ({
|
|
14
12
|
buildDir,
|
|
@@ -63,7 +61,7 @@ const shouldDeploy = function ({ buildbotServerSocket }) {
|
|
|
63
61
|
return buildbotServerSocket !== undefined
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
const deploySite = {
|
|
64
|
+
export const deploySite = {
|
|
67
65
|
event: 'onPostBuild',
|
|
68
66
|
coreStep,
|
|
69
67
|
coreStepId: 'deploy_site',
|
|
@@ -71,5 +69,3 @@ const deploySite = {
|
|
|
71
69
|
coreStepDescription: () => 'Deploy site',
|
|
72
70
|
condition: shouldDeploy,
|
|
73
71
|
}
|
|
74
|
-
|
|
75
|
-
module.exports = { deploySite }
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import readdirp from 'readdirp'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { addErrorInfo } = require('../../error/info')
|
|
3
|
+
import { addErrorInfo } from '../../error/info.js'
|
|
6
4
|
|
|
7
5
|
const MODULE_NOT_FOUND_CODE = 'MODULE_NOT_FOUND'
|
|
8
6
|
const MODULE_NOT_FOUND_ESBUILD_REGEXP = /^Could not resolve ['"]([^'"]+)/
|
|
9
7
|
const MODULE_NOT_FOUND_REGEXP = /Cannot find module ['"]([^'"]+)/
|
|
10
8
|
|
|
11
9
|
// Handle errors coming from zip-it-and-ship-it
|
|
12
|
-
const getZipError = async function (error, functionsSrc) {
|
|
10
|
+
export const getZipError = async function (error, functionsSrc) {
|
|
13
11
|
const moduleNotFoundError = await getModuleNotFoundError(error, functionsSrc)
|
|
14
12
|
|
|
15
13
|
if (moduleNotFoundError) {
|
|
@@ -151,7 +149,7 @@ package = "@netlify/plugin-functions-install-core"
|
|
|
151
149
|
}
|
|
152
150
|
|
|
153
151
|
// We need to load the site's `package.json` when bundling Functions. This is
|
|
154
|
-
// because `optionalDependencies` can make `
|
|
152
|
+
// because `optionalDependencies` can make `import()` fail, but we don't want
|
|
155
153
|
// to error then. However, if the `package.json` is invalid, we fail the build.
|
|
156
154
|
const isPackageJsonError = function (error) {
|
|
157
155
|
return error.message.includes(PACKAGE_JSON_ORIGINAL_MESSAGE)
|
|
@@ -163,5 +161,3 @@ const getPackageJsonError = function (error) {
|
|
|
163
161
|
addErrorInfo(error, { type: 'resolveConfig' })
|
|
164
162
|
return error
|
|
165
163
|
}
|
|
166
|
-
|
|
167
|
-
module.exports = { getZipError }
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const getZisiFeatureFlags = (featureFlags) => ({
|
|
1
|
+
export const getZisiFeatureFlags = (featureFlags) => ({
|
|
4
2
|
...featureFlags,
|
|
5
3
|
buildGoSource: featureFlags.buildbot_build_go_functions,
|
|
6
4
|
defaultEsModulesToEsbuild: featureFlags.buildbot_es_modules_esbuild,
|
|
@@ -9,5 +7,3 @@ const getZisiFeatureFlags = (featureFlags) => ({
|
|
|
9
7
|
parseWithEsbuild: featureFlags.buildbot_zisi_esbuild_parser,
|
|
10
8
|
traceWithNft: featureFlags.buildbot_zisi_trace_nft,
|
|
11
9
|
})
|
|
12
|
-
|
|
13
|
-
module.exports = { getZisiFeatureFlags }
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { join, resolve } from 'path'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { zipFunctions } from '@netlify/zip-it-and-ship-it'
|
|
4
|
+
import mapObject from 'map-obj'
|
|
5
|
+
import pathExists from 'path-exists'
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const mapObject = require('map-obj')
|
|
8
|
-
const pathExists = require('path-exists')
|
|
7
|
+
import { log } from '../../log/logger.js'
|
|
8
|
+
import { logBundleResults, logFunctionsNonExistingDir, logFunctionsToBundle } from '../../log/messages/core_steps.js'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const { getZipError } = require('./error')
|
|
14
|
-
const { getZisiFeatureFlags } = require('./feature_flags')
|
|
15
|
-
const { getUserAndInternalFunctions, validateFunctionsSrc } = require('./utils')
|
|
10
|
+
import { getZipError } from './error.js'
|
|
11
|
+
import { getZisiFeatureFlags } from './feature_flags.js'
|
|
12
|
+
import { getUserAndInternalFunctions, validateFunctionsSrc } from './utils.js'
|
|
16
13
|
|
|
17
14
|
// Returns `true` if at least one of the functions has been configured to use
|
|
18
15
|
// esbuild.
|
|
@@ -182,7 +179,7 @@ const hasFunctionsDirectories = async function ({ buildDir, constants: { INTERNA
|
|
|
182
179
|
return await pathExists(internalFunctionsSrc)
|
|
183
180
|
}
|
|
184
181
|
|
|
185
|
-
const bundleFunctions = {
|
|
182
|
+
export const bundleFunctions = {
|
|
186
183
|
event: 'onBuild',
|
|
187
184
|
coreStep,
|
|
188
185
|
coreStepId: 'functions_bundling',
|
|
@@ -191,4 +188,13 @@ const bundleFunctions = {
|
|
|
191
188
|
condition: hasFunctionsDirectories,
|
|
192
189
|
}
|
|
193
190
|
|
|
194
|
-
|
|
191
|
+
// Named imports with ES modules cannot be mocked (unlike CommonJS) because
|
|
192
|
+
// they are bound at load time.
|
|
193
|
+
// However, some of our tests are asserting which arguments are passed to
|
|
194
|
+
// `zip-it-and-ship-it` methods. Therefore, we need to use an intermediary
|
|
195
|
+
// function and export them so tests can use it.
|
|
196
|
+
export const zipItAndShipIt = {
|
|
197
|
+
async zipFunctions(...args) {
|
|
198
|
+
return await zipFunctions(...args)
|
|
199
|
+
},
|
|
200
|
+
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { stat } from 'fs'
|
|
2
|
+
import { relative } from 'path'
|
|
3
|
+
import { promisify } from 'util'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
const { relative } = require('path')
|
|
5
|
-
const { promisify } = require('util')
|
|
5
|
+
import { listFunctions } from '@netlify/zip-it-and-ship-it'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { addErrorInfo } from '../../error/info.js'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const { addErrorInfo } = require('../../error/info')
|
|
9
|
+
import { getZisiFeatureFlags } from './feature_flags.js'
|
|
12
10
|
|
|
13
|
-
const
|
|
11
|
+
const pStat = promisify(stat)
|
|
14
12
|
|
|
15
13
|
// Returns the `mainFile` of each function found in `functionsSrc`, relative to
|
|
16
14
|
// `functionsSrc`.
|
|
@@ -24,7 +22,7 @@ const getRelativeFunctionMainFiles = async function ({ featureFlags, functionsSr
|
|
|
24
22
|
return functions.map(({ mainFile }) => relative(functionsSrc, mainFile))
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
const getUserAndInternalFunctions = ({
|
|
25
|
+
export const getUserAndInternalFunctions = ({
|
|
28
26
|
featureFlags,
|
|
29
27
|
functionsSrc,
|
|
30
28
|
functionsSrcExists,
|
|
@@ -42,7 +40,7 @@ const getUserAndInternalFunctions = ({
|
|
|
42
40
|
// Returns `true` if the functions directory exists and is valid. Returns
|
|
43
41
|
// `false` if it doesn't exist. Throws an error if it's invalid or can't
|
|
44
42
|
// be accessed.
|
|
45
|
-
const validateFunctionsSrc = async function ({ functionsSrc, relativeFunctionsSrc }) {
|
|
43
|
+
export const validateFunctionsSrc = async function ({ functionsSrc, relativeFunctionsSrc }) {
|
|
46
44
|
if (functionsSrc === undefined) {
|
|
47
45
|
return false
|
|
48
46
|
}
|
|
@@ -69,5 +67,3 @@ const validateFunctionsSrc = async function ({ functionsSrc, relativeFunctionsSr
|
|
|
69
67
|
throw error
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
|
-
|
|
73
|
-
module.exports = { getUserAndInternalFunctions, validateFunctionsSrc }
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import pathExists from 'path-exists'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { installFunctionDependencies } = require('../../install/functions')
|
|
3
|
+
import { installFunctionDependencies } from '../../install/functions.js'
|
|
6
4
|
|
|
7
5
|
// Plugin to package Netlify functions with @netlify/zip-it-and-ship-it
|
|
8
|
-
const onPreBuild = async function ({ constants: { FUNCTIONS_SRC, IS_LOCAL } }) {
|
|
6
|
+
export const onPreBuild = async function ({ constants: { FUNCTIONS_SRC, IS_LOCAL } }) {
|
|
9
7
|
if (!(await pathExists(FUNCTIONS_SRC))) {
|
|
10
8
|
return {}
|
|
11
9
|
}
|
|
@@ -13,5 +11,3 @@ const onPreBuild = async function ({ constants: { FUNCTIONS_SRC, IS_LOCAL } }) {
|
|
|
13
11
|
await installFunctionDependencies(FUNCTIONS_SRC, IS_LOCAL)
|
|
14
12
|
return {}
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
module.exports = { onPreBuild }
|
package/src/plugins_core/list.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { createRequire } from 'module'
|
|
2
|
+
import { fileURLToPath } from 'url'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
import { LOCAL_INSTALL_PLUGIN_NAME } from '../install/local.js'
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
// TODO: use `import.resolve()` once it is available without any experimental
|
|
7
|
+
// flags
|
|
8
|
+
const require = createRequire(import.meta.url)
|
|
9
|
+
|
|
10
|
+
const FUNCTIONS_INSTALL_PLUGIN = fileURLToPath(new URL('functions_install/index.js', import.meta.url))
|
|
6
11
|
|
|
7
12
|
// List of core plugin names
|
|
8
13
|
const FUNCTIONS_INSTALL_PLUGIN_NAME = '@netlify/plugin-functions-install-core'
|
|
@@ -12,7 +17,7 @@ const CORE_PLUGINS = new Set([FUNCTIONS_INSTALL_PLUGIN_NAME, LOCAL_INSTALL_PLUGI
|
|
|
12
17
|
const EDGE_HANDLERS_PLUGIN_PATH = require.resolve(EDGE_HANDLERS_PLUGIN_NAME)
|
|
13
18
|
|
|
14
19
|
// Plugins that are installed and enabled by default
|
|
15
|
-
const listCorePlugins = function ({ FUNCTIONS_SRC, EDGE_HANDLERS_SRC }) {
|
|
20
|
+
export const listCorePlugins = function ({ FUNCTIONS_SRC, EDGE_HANDLERS_SRC }) {
|
|
16
21
|
const functionsInstallPlugin = getFunctionsInstallPlugin(FUNCTIONS_SRC)
|
|
17
22
|
const edgeHandlersPlugin = getEdgeHandlersPlugin(EDGE_HANDLERS_SRC)
|
|
18
23
|
return [functionsInstallPlugin, edgeHandlersPlugin].filter(Boolean)
|
|
@@ -38,8 +43,6 @@ const getEdgeHandlersPlugin = function (EDGE_HANDLERS_SRC) {
|
|
|
38
43
|
return { package: EDGE_HANDLERS_PLUGIN_NAME, pluginPath: EDGE_HANDLERS_PLUGIN_PATH }
|
|
39
44
|
}
|
|
40
45
|
|
|
41
|
-
const isCorePlugin = function (packageName) {
|
|
46
|
+
export const isCorePlugin = function (packageName) {
|
|
42
47
|
return CORE_PLUGINS.has(packageName)
|
|
43
48
|
}
|
|
44
|
-
|
|
45
|
-
module.exports = { listCorePlugins, isCorePlugin }
|
package/src/status/add.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
// Merge plugin status to the list of plugin statuses.
|
|
4
|
-
const addStatus = function ({ newStatus, statuses, event, packageName, pluginPackageJson: { version } = {} }) {
|
|
2
|
+
export const addStatus = function ({ newStatus, statuses, event, packageName, pluginPackageJson: { version } = {} }) {
|
|
5
3
|
// Either:
|
|
6
4
|
// - `build.command`
|
|
7
5
|
// - no status was set
|
|
@@ -36,5 +34,3 @@ const canOverrideStatus = function (formerStatus, newStatus) {
|
|
|
36
34
|
|
|
37
35
|
// Possible status states, ordered by severity.
|
|
38
36
|
const STATES = ['success', 'canceled_plugin', 'failed_plugin', 'failed_build']
|
|
39
|
-
|
|
40
|
-
module.exports = { addStatus }
|
package/src/status/colors.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const stripAnsi = require('strip-ansi')
|
|
1
|
+
import stripAnsi from 'strip-ansi'
|
|
4
2
|
|
|
5
3
|
// Remove colors from statuses
|
|
6
|
-
const removeStatusesColors = function (statuses) {
|
|
4
|
+
export const removeStatusesColors = function (statuses) {
|
|
7
5
|
return statuses.map(removeStatusColors)
|
|
8
6
|
}
|
|
9
7
|
|
|
@@ -23,5 +21,3 @@ const removeAttrColor = function (status, attribute) {
|
|
|
23
21
|
const valueA = stripAnsi(value)
|
|
24
22
|
return { [attribute]: valueA }
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
module.exports = { removeStatusesColors }
|
package/src/status/load_error.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const { getFullErrorInfo } = require('../error/parse/parse')
|
|
5
|
-
const { serializeErrorStatus } = require('../error/parse/serialize_status')
|
|
1
|
+
import { addErrorInfo } from '../error/info.js'
|
|
2
|
+
import { getFullErrorInfo } from '../error/parse/parse.js'
|
|
3
|
+
import { serializeErrorStatus } from '../error/parse/serialize_status.js'
|
|
6
4
|
|
|
7
5
|
// Errors that happen during plugin loads should be reported as error statuses
|
|
8
|
-
const addPluginLoadErrorStatus = function ({ error, packageName, version, debug }) {
|
|
6
|
+
export const addPluginLoadErrorStatus = function ({ error, packageName, version, debug }) {
|
|
9
7
|
const fullErrorInfo = getFullErrorInfo({ error, colors: false, debug })
|
|
10
8
|
const errorStatus = serializeErrorStatus({ fullErrorInfo, state: 'failed_build' })
|
|
11
9
|
const statuses = [{ ...errorStatus, event: 'load', packageName, version }]
|
|
12
10
|
addErrorInfo(error, { statuses })
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
module.exports = { addPluginLoadErrorStatus }
|
package/src/status/report.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { handleBuildError } from '../error/handle.js'
|
|
2
|
+
import { logStatuses } from '../log/messages/status.js'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const { logStatuses } = require('../log/messages/status')
|
|
5
|
-
|
|
6
|
-
const { removeStatusesColors } = require('./colors')
|
|
4
|
+
import { removeStatusesColors } from './colors.js'
|
|
7
5
|
|
|
8
6
|
// Report plugin statuses to the console and API
|
|
9
|
-
const reportStatuses = async function ({
|
|
7
|
+
export const reportStatuses = async function ({
|
|
10
8
|
statuses,
|
|
11
9
|
childEnv,
|
|
12
10
|
api,
|
|
@@ -128,5 +126,3 @@ const sendApiStatus = async function ({
|
|
|
128
126
|
await handleBuildError(error, { errorMonitor, netlifyConfig, childEnv, mode, logs, debug, testOpts })
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
|
-
|
|
132
|
-
module.exports = { reportStatuses }
|