@netlify/build 27.20.4 → 27.20.5
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/lib/core/bin.js +42 -59
- package/lib/core/build.js +333 -536
- package/lib/core/config.js +94 -159
- package/lib/core/constants.js +95 -135
- package/lib/core/dev.js +26 -30
- package/lib/core/dry.js +18 -36
- package/lib/core/feature_flags.js +13 -16
- package/lib/core/flags.js +168 -169
- package/lib/core/lingering.js +44 -61
- package/lib/core/main.js +94 -136
- package/lib/core/missing_side_file.js +12 -24
- package/lib/core/normalize_flags.js +52 -63
- package/lib/core/severity.js +13 -15
- package/lib/core/user_node_version.js +26 -35
- package/lib/env/changes.js +29 -37
- package/lib/env/main.js +10 -15
- package/lib/env/metadata.js +63 -76
- package/lib/error/api.js +31 -40
- package/lib/error/build.js +27 -38
- package/lib/error/cancel.js +5 -6
- package/lib/error/colors.js +7 -9
- package/lib/error/handle.js +38 -49
- package/lib/error/info.js +26 -35
- package/lib/error/monitor/location.js +12 -17
- package/lib/error/monitor/normalize.js +75 -85
- package/lib/error/monitor/print.js +19 -41
- package/lib/error/monitor/report.js +102 -121
- package/lib/error/monitor/start.js +43 -56
- package/lib/error/parse/clean_stack.js +52 -69
- package/lib/error/parse/location.js +40 -52
- package/lib/error/parse/normalize.js +18 -23
- package/lib/error/parse/parse.js +59 -93
- package/lib/error/parse/plugin.js +42 -57
- package/lib/error/parse/properties.js +13 -20
- package/lib/error/parse/serialize_log.js +29 -37
- package/lib/error/parse/serialize_status.js +15 -23
- package/lib/error/parse/stack.js +29 -38
- package/lib/error/type.js +132 -150
- package/lib/install/functions.js +16 -24
- package/lib/install/local.js +31 -48
- package/lib/install/main.js +52 -66
- package/lib/install/missing.js +40 -53
- package/lib/log/colors.js +15 -22
- package/lib/log/description.js +16 -21
- package/lib/log/header.js +11 -13
- package/lib/log/header_func.js +11 -15
- package/lib/log/logger.js +88 -119
- package/lib/log/messages/compatibility.js +100 -158
- package/lib/log/messages/config.js +76 -92
- package/lib/log/messages/core.js +40 -60
- package/lib/log/messages/core_steps.js +63 -92
- package/lib/log/messages/dry.js +31 -53
- package/lib/log/messages/install.js +21 -28
- package/lib/log/messages/ipc.js +21 -30
- package/lib/log/messages/mutations.js +51 -71
- package/lib/log/messages/plugins.js +18 -31
- package/lib/log/messages/status.js +12 -14
- package/lib/log/messages/steps.js +14 -18
- package/lib/log/old_version.js +23 -32
- package/lib/log/serialize.js +7 -10
- package/lib/log/stream.js +48 -65
- package/lib/log/theme.js +22 -23
- package/lib/plugins/child/diff.js +31 -40
- package/lib/plugins/child/error.js +20 -26
- package/lib/plugins/child/lazy.js +11 -14
- package/lib/plugins/child/load.js +15 -22
- package/lib/plugins/child/logic.js +51 -58
- package/lib/plugins/child/main.js +32 -46
- package/lib/plugins/child/run.js +18 -27
- package/lib/plugins/child/status.js +52 -63
- package/lib/plugins/child/typescript.js +19 -36
- package/lib/plugins/child/utils.js +36 -49
- package/lib/plugins/child/validate.js +25 -28
- package/lib/plugins/compatibility.js +64 -92
- package/lib/plugins/error.js +29 -35
- package/lib/plugins/events.js +7 -12
- package/lib/plugins/expected_version.js +61 -99
- package/lib/plugins/ipc.js +79 -102
- package/lib/plugins/list.js +49 -62
- package/lib/plugins/load.js +44 -64
- package/lib/plugins/manifest/check.js +64 -85
- package/lib/plugins/manifest/load.js +34 -37
- package/lib/plugins/manifest/main.js +16 -21
- package/lib/plugins/manifest/path.js +18 -25
- package/lib/plugins/manifest/validate.js +77 -94
- package/lib/plugins/node_version.js +22 -42
- package/lib/plugins/options.js +45 -78
- package/lib/plugins/pinned_version.js +58 -106
- package/lib/plugins/resolve.js +91 -133
- package/lib/plugins/spawn.js +43 -61
- package/lib/plugins_core/add.js +26 -40
- package/lib/plugins_core/build_command.js +47 -72
- package/lib/plugins_core/deploy/buildbot_client.js +61 -87
- package/lib/plugins_core/deploy/index.js +47 -71
- package/lib/plugins_core/edge_functions/index.js +73 -116
- package/lib/plugins_core/edge_functions/lib/error.js +13 -17
- package/lib/plugins_core/edge_functions/lib/internal_manifest.js +45 -55
- package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +65 -80
- package/lib/plugins_core/functions/error.js +88 -128
- package/lib/plugins_core/functions/feature_flags.js +5 -5
- package/lib/plugins_core/functions/index.js +98 -145
- package/lib/plugins_core/functions/utils.js +36 -57
- package/lib/plugins_core/functions/zisi.js +35 -52
- package/lib/plugins_core/functions_install/index.js +8 -11
- package/lib/plugins_core/list.js +15 -22
- package/lib/status/add.js +26 -32
- package/lib/status/colors.js +14 -19
- package/lib/status/load_error.js +8 -9
- package/lib/status/report.js +72 -126
- package/lib/status/success.js +10 -14
- package/lib/steps/core_step.js +54 -89
- package/lib/steps/error.js +50 -87
- package/lib/steps/get.js +33 -41
- package/lib/steps/plugin.js +53 -83
- package/lib/steps/return.js +24 -51
- package/lib/steps/run_core_steps.js +119 -171
- package/lib/steps/run_step.js +154 -270
- package/lib/steps/run_steps.js +91 -174
- package/lib/steps/update_config.js +45 -72
- package/lib/telemetry/main.js +89 -128
- package/lib/time/aggregate.js +84 -110
- package/lib/time/main.js +23 -34
- package/lib/time/measure.js +11 -15
- package/lib/time/report.js +32 -44
- package/lib/utils/errors.js +10 -9
- package/lib/utils/json.js +11 -15
- package/lib/utils/omit.js +3 -4
- package/lib/utils/package.js +19 -22
- package/lib/utils/remove_falsy.js +5 -7
- package/lib/utils/resolve.js +30 -34
- package/lib/utils/runtime.js +4 -4
- package/lib/utils/semver.js +19 -25
- package/package.json +13 -6
package/lib/steps/run_steps.js
CHANGED
|
@@ -1,179 +1,96 @@
|
|
|
1
|
-
import pReduce from 'p-reduce'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { runStep } from './run_step.js'
|
|
7
|
-
|
|
1
|
+
import pReduce from 'p-reduce';
|
|
2
|
+
import { addErrorInfo } from '../error/info.js';
|
|
3
|
+
import { addStatus } from '../status/add.js';
|
|
4
|
+
import { runStep } from './run_step.js';
|
|
8
5
|
// Run all steps.
|
|
9
6
|
// Each step can change some state: last `error`, environment variables changes,
|
|
10
7
|
// list of `failedPlugins` (that ran `utils.build.failPlugin()`).
|
|
11
8
|
// If an error arises, runs `onError` events.
|
|
12
9
|
// Runs `onEnd` events at the end, whether an error was thrown or not.
|
|
13
|
-
export const runSteps = async function ({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
loadedFrom,
|
|
101
|
-
origin,
|
|
102
|
-
condition,
|
|
103
|
-
configPath,
|
|
104
|
-
buildDir,
|
|
105
|
-
repositoryRoot,
|
|
106
|
-
nodePath,
|
|
107
|
-
index,
|
|
108
|
-
childEnv,
|
|
109
|
-
context,
|
|
110
|
-
branch,
|
|
111
|
-
envChanges,
|
|
112
|
-
constants,
|
|
113
|
-
steps,
|
|
114
|
-
buildbotServerSocket,
|
|
115
|
-
events,
|
|
116
|
-
mode,
|
|
117
|
-
api,
|
|
118
|
-
errorMonitor,
|
|
119
|
-
deployId,
|
|
120
|
-
errorParams,
|
|
121
|
-
error,
|
|
122
|
-
failedPlugins,
|
|
123
|
-
configOpts,
|
|
124
|
-
netlifyConfig: netlifyConfigA,
|
|
125
|
-
configMutations,
|
|
126
|
-
headersPath: headersPathA,
|
|
127
|
-
redirectsPath: redirectsPathA,
|
|
128
|
-
logs,
|
|
129
|
-
debug,
|
|
130
|
-
systemLog,
|
|
131
|
-
verbose,
|
|
132
|
-
saveConfig,
|
|
133
|
-
timers: timersA,
|
|
134
|
-
testOpts,
|
|
135
|
-
featureFlags,
|
|
136
|
-
})
|
|
137
|
-
const statusesA = addStatus({ newStatus, statuses, event, packageName, pluginPackageJson })
|
|
138
|
-
return {
|
|
139
|
-
index: newIndex,
|
|
140
|
-
error: newError,
|
|
141
|
-
failedPlugins: [...failedPlugins, ...failedPlugin],
|
|
142
|
-
envChanges: { ...envChanges, ...newEnvChanges },
|
|
143
|
-
netlifyConfig: netlifyConfigB,
|
|
144
|
-
configMutations: configMutationsA,
|
|
145
|
-
headersPath: headersPathB,
|
|
146
|
-
redirectsPath: redirectsPathB,
|
|
147
|
-
statuses: statusesA,
|
|
148
|
-
timers: timersB,
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
index: 0,
|
|
153
|
-
failedPlugins: [],
|
|
154
|
-
envChanges: {},
|
|
155
|
-
netlifyConfig,
|
|
156
|
-
configMutations: [],
|
|
157
|
-
headersPath,
|
|
158
|
-
redirectsPath,
|
|
159
|
-
statuses: [],
|
|
160
|
-
timers,
|
|
161
|
-
},
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
// Instead of throwing any build failure right away, we wait for `onError`,
|
|
165
|
-
// etc. to complete. This is why we are throwing only now.
|
|
166
|
-
if (errorA !== undefined) {
|
|
167
|
-
addErrorInfo(errorA, { statuses: statusesB })
|
|
168
|
-
throw errorA
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
stepsCount,
|
|
173
|
-
netlifyConfig: netlifyConfigC,
|
|
174
|
-
statuses: statusesB,
|
|
175
|
-
failedPlugins: failedPluginsA,
|
|
176
|
-
timers: timersC,
|
|
177
|
-
configMutations: configMutationsB,
|
|
178
|
-
}
|
|
179
|
-
}
|
|
10
|
+
export const runSteps = async function ({ steps, buildbotServerSocket, events, configPath, headersPath, redirectsPath, buildDir, repositoryRoot, nodePath, childEnv, context, branch, constants, mode, api, errorMonitor, deployId, errorParams, netlifyConfig, configOpts, logs, debug, systemLog, verbose, saveConfig, timers, testOpts, featureFlags, }) {
|
|
11
|
+
const { index: stepsCount, error: errorA, netlifyConfig: netlifyConfigC, statuses: statusesB, failedPlugins: failedPluginsA, timers: timersC, configMutations: configMutationsB, } = await pReduce(steps, async ({ index, error, failedPlugins, envChanges, netlifyConfig: netlifyConfigA, configMutations, headersPath: headersPathA, redirectsPath: redirectsPathA, statuses, timers: timersA, }, { event, childProcess, packageName, coreStep, coreStepId, coreStepName, coreStepDescription, pluginPackageJson, loadedFrom, origin, condition, }) => {
|
|
12
|
+
const { newIndex = index, newError = error, failedPlugin = [], newEnvChanges = {}, netlifyConfig: netlifyConfigB = netlifyConfigA, configMutations: configMutationsA = configMutations, headersPath: headersPathB = headersPathA, redirectsPath: redirectsPathB = redirectsPathA, newStatus, timers: timersB = timersA, } = await runStep({
|
|
13
|
+
event,
|
|
14
|
+
childProcess,
|
|
15
|
+
packageName,
|
|
16
|
+
coreStep,
|
|
17
|
+
coreStepId,
|
|
18
|
+
coreStepName,
|
|
19
|
+
coreStepDescription,
|
|
20
|
+
pluginPackageJson,
|
|
21
|
+
loadedFrom,
|
|
22
|
+
origin,
|
|
23
|
+
condition,
|
|
24
|
+
configPath,
|
|
25
|
+
buildDir,
|
|
26
|
+
repositoryRoot,
|
|
27
|
+
nodePath,
|
|
28
|
+
index,
|
|
29
|
+
childEnv,
|
|
30
|
+
context,
|
|
31
|
+
branch,
|
|
32
|
+
envChanges,
|
|
33
|
+
constants,
|
|
34
|
+
steps,
|
|
35
|
+
buildbotServerSocket,
|
|
36
|
+
events,
|
|
37
|
+
mode,
|
|
38
|
+
api,
|
|
39
|
+
errorMonitor,
|
|
40
|
+
deployId,
|
|
41
|
+
errorParams,
|
|
42
|
+
error,
|
|
43
|
+
failedPlugins,
|
|
44
|
+
configOpts,
|
|
45
|
+
netlifyConfig: netlifyConfigA,
|
|
46
|
+
configMutations,
|
|
47
|
+
headersPath: headersPathA,
|
|
48
|
+
redirectsPath: redirectsPathA,
|
|
49
|
+
logs,
|
|
50
|
+
debug,
|
|
51
|
+
systemLog,
|
|
52
|
+
verbose,
|
|
53
|
+
saveConfig,
|
|
54
|
+
timers: timersA,
|
|
55
|
+
testOpts,
|
|
56
|
+
featureFlags,
|
|
57
|
+
});
|
|
58
|
+
const statusesA = addStatus({ newStatus, statuses, event, packageName, pluginPackageJson });
|
|
59
|
+
return {
|
|
60
|
+
index: newIndex,
|
|
61
|
+
error: newError,
|
|
62
|
+
failedPlugins: [...failedPlugins, ...failedPlugin],
|
|
63
|
+
envChanges: { ...envChanges, ...newEnvChanges },
|
|
64
|
+
netlifyConfig: netlifyConfigB,
|
|
65
|
+
configMutations: configMutationsA,
|
|
66
|
+
headersPath: headersPathB,
|
|
67
|
+
redirectsPath: redirectsPathB,
|
|
68
|
+
statuses: statusesA,
|
|
69
|
+
timers: timersB,
|
|
70
|
+
};
|
|
71
|
+
}, {
|
|
72
|
+
index: 0,
|
|
73
|
+
failedPlugins: [],
|
|
74
|
+
envChanges: {},
|
|
75
|
+
netlifyConfig,
|
|
76
|
+
configMutations: [],
|
|
77
|
+
headersPath,
|
|
78
|
+
redirectsPath,
|
|
79
|
+
statuses: [],
|
|
80
|
+
timers,
|
|
81
|
+
});
|
|
82
|
+
// Instead of throwing any build failure right away, we wait for `onError`,
|
|
83
|
+
// etc. to complete. This is why we are throwing only now.
|
|
84
|
+
if (errorA !== undefined) {
|
|
85
|
+
addErrorInfo(errorA, { statuses: statusesB });
|
|
86
|
+
throw errorA;
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
stepsCount,
|
|
90
|
+
netlifyConfig: netlifyConfigC,
|
|
91
|
+
statuses: statusesB,
|
|
92
|
+
failedPlugins: failedPluginsA,
|
|
93
|
+
timers: timersC,
|
|
94
|
+
configMutations: configMutationsB,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
@@ -1,93 +1,66 @@
|
|
|
1
|
-
import { isDeepStrictEqual } from 'util'
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { logConfigOnUpdate } from '../log/messages/config.js'
|
|
9
|
-
import { logConfigMutations } from '../log/messages/mutations.js'
|
|
10
|
-
|
|
1
|
+
import { isDeepStrictEqual } from 'util';
|
|
2
|
+
import pFilter from 'p-filter';
|
|
3
|
+
import { pathExists } from 'path-exists';
|
|
4
|
+
import { resolveUpdatedConfig } from '../core/config.js';
|
|
5
|
+
import { addErrorInfo } from '../error/info.js';
|
|
6
|
+
import { logConfigOnUpdate } from '../log/messages/config.js';
|
|
7
|
+
import { logConfigMutations } from '../log/messages/mutations.js';
|
|
11
8
|
// If `netlifyConfig` was updated or `_redirects` was created, the configuration
|
|
12
9
|
// is updated by calling `@netlify/config` again.
|
|
13
|
-
export const updateNetlifyConfig = async function ({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
logConfigMutations(logs, newConfigMutations, debug)
|
|
31
|
-
const configMutationsA = [...configMutations, ...newConfigMutations]
|
|
32
|
-
const {
|
|
33
|
-
config: netlifyConfigA,
|
|
34
|
-
headersPath: headersPathA,
|
|
35
|
-
redirectsPath: redirectsPathA,
|
|
36
|
-
} = await resolveUpdatedConfig(configOpts, configMutationsA)
|
|
37
|
-
logConfigOnUpdate({ logs, netlifyConfig: netlifyConfigA, debug })
|
|
38
|
-
|
|
39
|
-
errorParams.netlifyConfig = netlifyConfigA
|
|
40
|
-
return {
|
|
41
|
-
netlifyConfig: netlifyConfigA,
|
|
42
|
-
configMutations: configMutationsA,
|
|
43
|
-
headersPath: headersPathA,
|
|
44
|
-
redirectsPath: redirectsPathA,
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
10
|
+
export const updateNetlifyConfig = async function ({ configOpts, netlifyConfig, headersPath, redirectsPath, configMutations, newConfigMutations, configSideFiles, errorParams, logs, debug, }) {
|
|
11
|
+
if (!(await shouldUpdateConfig({ newConfigMutations, configSideFiles, headersPath, redirectsPath }))) {
|
|
12
|
+
return { netlifyConfig, configMutations };
|
|
13
|
+
}
|
|
14
|
+
validateConfigMutations(newConfigMutations);
|
|
15
|
+
logConfigMutations(logs, newConfigMutations, debug);
|
|
16
|
+
const configMutationsA = [...configMutations, ...newConfigMutations];
|
|
17
|
+
const { config: netlifyConfigA, headersPath: headersPathA, redirectsPath: redirectsPathA, } = await resolveUpdatedConfig(configOpts, configMutationsA);
|
|
18
|
+
logConfigOnUpdate({ logs, netlifyConfig: netlifyConfigA, debug });
|
|
19
|
+
errorParams.netlifyConfig = netlifyConfigA;
|
|
20
|
+
return {
|
|
21
|
+
netlifyConfig: netlifyConfigA,
|
|
22
|
+
configMutations: configMutationsA,
|
|
23
|
+
headersPath: headersPathA,
|
|
24
|
+
redirectsPath: redirectsPathA,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
48
27
|
const shouldUpdateConfig = async function ({ newConfigMutations, configSideFiles, headersPath, redirectsPath }) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
28
|
+
return (newConfigMutations.length !== 0 || (await haveConfigSideFilesChanged(configSideFiles, headersPath, redirectsPath)));
|
|
29
|
+
};
|
|
54
30
|
// The configuration mostly depends on `netlify.toml` and UI build settings.
|
|
55
31
|
// However, it also uses some additional optional side files like `_redirects`.
|
|
56
32
|
// Those are often created by the build command. When those are created, we need
|
|
57
33
|
// to update the configuration. We detect this by checking for file existence
|
|
58
34
|
// before and after running plugins and the build command.
|
|
59
35
|
const haveConfigSideFilesChanged = async function (configSideFiles, headersPath, redirectsPath) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
36
|
+
const newSideFiles = await listConfigSideFiles([headersPath, redirectsPath]);
|
|
37
|
+
return !isDeepStrictEqual(newSideFiles, configSideFiles);
|
|
38
|
+
};
|
|
64
39
|
// List all the files used for configuration besides `netlify.toml`.
|
|
65
40
|
// This is useful when applying configuration mutations since those files
|
|
66
41
|
// sometimes have higher priority and should therefore be deleted in order to
|
|
67
42
|
// apply any configuration update on `netlify.toml`.
|
|
68
43
|
export const listConfigSideFiles = async function (sideFiles) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
44
|
+
const configSideFiles = await pFilter(sideFiles, pathExists);
|
|
45
|
+
return configSideFiles.sort();
|
|
46
|
+
};
|
|
74
47
|
// Validate each new configuration change
|
|
75
48
|
const validateConfigMutations = function (newConfigMutations) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
49
|
+
try {
|
|
50
|
+
newConfigMutations.forEach(validateConfigMutation);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
addErrorInfo(error, { type: 'pluginValidation' });
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
84
57
|
// Triggered when calling `netlifyConfig.{key} = undefined | null`
|
|
85
58
|
// We do not allow this because the back-end only receives mutations as a
|
|
86
59
|
// `netlify.toml`, i.e. cannot apply property deletions since `undefined` is
|
|
87
60
|
// not serializable in TOML.
|
|
88
61
|
const validateConfigMutation = function ({ value, keysString }) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
Please set this property to a specific value instead.`)
|
|
92
|
-
|
|
93
|
-
}
|
|
62
|
+
if (value === undefined || value === null) {
|
|
63
|
+
throw new Error(`Setting "netlifyConfig.${keysString}" to ${value} is not allowed.
|
|
64
|
+
Please set this property to a specific value instead.`);
|
|
65
|
+
}
|
|
66
|
+
};
|
package/lib/telemetry/main.js
CHANGED
|
@@ -1,136 +1,97 @@
|
|
|
1
|
-
import { platform } from 'process'
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { ROOT_PACKAGE_JSON } from '../utils/json.js'
|
|
9
|
-
|
|
10
|
-
const DEFAULT_TELEMETRY_TIMEOUT = 1200
|
|
1
|
+
import { platform } from 'process';
|
|
2
|
+
import got from 'got';
|
|
3
|
+
import osName from 'os-name';
|
|
4
|
+
import { addErrorInfo } from '../error/info.js';
|
|
5
|
+
import { roundTimerToMillisecs } from '../time/measure.js';
|
|
6
|
+
import { ROOT_PACKAGE_JSON } from '../utils/json.js';
|
|
7
|
+
const DEFAULT_TELEMETRY_TIMEOUT = 1200;
|
|
11
8
|
const DEFAULT_TELEMETRY_CONFIG = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
9
|
+
origin: 'https://api.segment.io/v1',
|
|
10
|
+
writeKey: 'dWhlM1lYSlpNd1k5Uk9rcjFra2JSOEoybnRjZjl0YTI6',
|
|
11
|
+
timeout: DEFAULT_TELEMETRY_TIMEOUT,
|
|
12
|
+
};
|
|
17
13
|
// Send telemetry request when build completes
|
|
18
|
-
export const trackBuildComplete = async function ({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
userNodeVersion,
|
|
45
|
-
framework,
|
|
46
|
-
})
|
|
47
|
-
await track({
|
|
48
|
-
payload,
|
|
49
|
-
config: { ...DEFAULT_TELEMETRY_CONFIG, origin: telemetryOrigin, timeout: telemetryTimeout },
|
|
50
|
-
})
|
|
51
|
-
} catch (error) {
|
|
52
|
-
addErrorInfo(error, { type: 'telemetry' })
|
|
53
|
-
throw error
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
14
|
+
export const trackBuildComplete = async function ({ deployId, buildId, status, stepsCount, pluginsOptions, durationNs, siteInfo, telemetry, userNodeVersion, framework, testOpts: { telemetryOrigin = DEFAULT_TELEMETRY_CONFIG.origin, telemetryTimeout = DEFAULT_TELEMETRY_CONFIG.timeout }, }) {
|
|
15
|
+
if (!telemetry) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const payload = getPayload({
|
|
20
|
+
deployId,
|
|
21
|
+
buildId,
|
|
22
|
+
status,
|
|
23
|
+
stepsCount,
|
|
24
|
+
pluginsOptions,
|
|
25
|
+
durationNs,
|
|
26
|
+
siteInfo,
|
|
27
|
+
userNodeVersion,
|
|
28
|
+
framework,
|
|
29
|
+
});
|
|
30
|
+
await track({
|
|
31
|
+
payload,
|
|
32
|
+
config: { ...DEFAULT_TELEMETRY_CONFIG, origin: telemetryOrigin, timeout: telemetryTimeout },
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
addErrorInfo(error, { type: 'telemetry' });
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
57
40
|
// Send track HTTP request to telemetry.
|
|
58
41
|
const track = async function ({ payload, config: { origin, writeKey, timeout } }) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
42
|
+
const url = `${origin}/track`;
|
|
43
|
+
await got.post(url, {
|
|
44
|
+
json: payload,
|
|
45
|
+
timeout,
|
|
46
|
+
retry: 0,
|
|
47
|
+
headers: { Authorization: `Basic ${writeKey}` },
|
|
48
|
+
});
|
|
49
|
+
};
|
|
68
50
|
// Retrieve telemetry information
|
|
69
51
|
// siteInfo can be empty if the build fails during the get config step
|
|
70
|
-
const getPayload = function ({
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
framework,
|
|
97
|
-
siteId: siteInfo.id,
|
|
98
|
-
...(pluginsOptions !== undefined && {
|
|
99
|
-
plugins: pluginsOptions.map(getPlugin),
|
|
100
|
-
pluginCount: pluginsOptions.length,
|
|
101
|
-
}),
|
|
102
|
-
...(durationNs !== undefined && { duration: roundTimerToMillisecs(durationNs) }),
|
|
103
|
-
},
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
52
|
+
const getPayload = function ({ deployId, buildId, status, stepsCount, pluginsOptions, durationNs, userNodeVersion, siteInfo = {}, framework, }) {
|
|
53
|
+
return {
|
|
54
|
+
userId: 'buildbot_user',
|
|
55
|
+
event: 'build:ci_build_process_completed',
|
|
56
|
+
timestamp: Date.now(),
|
|
57
|
+
properties: {
|
|
58
|
+
deployId,
|
|
59
|
+
buildId,
|
|
60
|
+
status,
|
|
61
|
+
steps: stepsCount,
|
|
62
|
+
buildVersion: ROOT_PACKAGE_JSON.version,
|
|
63
|
+
// We're passing the node version set by the buildbot/user which will run the `build.command` and
|
|
64
|
+
// the `package.json`/locally defined plugins
|
|
65
|
+
nodeVersion: userNodeVersion,
|
|
66
|
+
osPlatform: OS_TYPES[platform],
|
|
67
|
+
osName: osName(),
|
|
68
|
+
framework,
|
|
69
|
+
siteId: siteInfo.id,
|
|
70
|
+
...(pluginsOptions !== undefined && {
|
|
71
|
+
plugins: pluginsOptions.map(getPlugin),
|
|
72
|
+
pluginCount: pluginsOptions.length,
|
|
73
|
+
}),
|
|
74
|
+
...(durationNs !== undefined && { duration: roundTimerToMillisecs(durationNs) }),
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
};
|
|
107
78
|
const OS_TYPES = {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
loadedFrom,
|
|
122
|
-
nodeVersion,
|
|
123
|
-
pinnedVersion,
|
|
124
|
-
pluginPackageJson: { version } = {},
|
|
125
|
-
}) {
|
|
126
|
-
const installType = getInstallType(origin, loadedFrom)
|
|
127
|
-
return { name: packageName, installType, nodeVersion, pinnedVersion, version }
|
|
128
|
-
}
|
|
129
|
-
|
|
79
|
+
linux: 'Linux',
|
|
80
|
+
darwin: 'MacOS',
|
|
81
|
+
win32: 'Windows',
|
|
82
|
+
android: 'Android',
|
|
83
|
+
sunos: 'SunOS',
|
|
84
|
+
aix: 'AIX',
|
|
85
|
+
freebsd: 'FreeBSD',
|
|
86
|
+
openbsd: 'OpenBSD',
|
|
87
|
+
};
|
|
88
|
+
const getPlugin = function ({ packageName, origin, loadedFrom, nodeVersion, pinnedVersion, pluginPackageJson: { version } = {}, }) {
|
|
89
|
+
const installType = getInstallType(origin, loadedFrom);
|
|
90
|
+
return { name: packageName, installType, nodeVersion, pinnedVersion, version };
|
|
91
|
+
};
|
|
130
92
|
const getInstallType = function (origin, loadedFrom) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
93
|
+
if (loadedFrom === 'auto_install') {
|
|
94
|
+
return origin === 'ui' ? 'ui' : 'netlify_toml';
|
|
95
|
+
}
|
|
96
|
+
return loadedFrom;
|
|
97
|
+
};
|