@netlify/build 27.8.0 → 28.0.0-rc
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 +1 -1
- package/src/core/flags.js +5 -0
- package/src/core/main.js +12 -1
- package/src/error/type.js +1 -1
- package/src/log/logger.js +35 -0
- package/src/plugins_core/edge_functions/index.js +3 -5
- package/src/steps/core_step.js +2 -0
- package/src/steps/run_step.js +6 -0
- package/src/steps/run_steps.js +2 -0
- package/src/log/messages/edge_manifest.js +0 -7
package/package.json
CHANGED
package/src/core/flags.js
CHANGED
|
@@ -145,6 +145,11 @@ Default: false`,
|
|
|
145
145
|
describe: 'Print user-facing debugging information',
|
|
146
146
|
hidden: true,
|
|
147
147
|
},
|
|
148
|
+
systemLogFile: {
|
|
149
|
+
type: 'number',
|
|
150
|
+
describe: 'File descriptor to where system logs should be piped',
|
|
151
|
+
hidden: true,
|
|
152
|
+
},
|
|
148
153
|
verbose: {
|
|
149
154
|
boolean: true,
|
|
150
155
|
describe: 'Print internal debugging information',
|
package/src/core/main.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { handleBuildError } from '../error/handle.js'
|
|
3
3
|
import { getErrorInfo } from '../error/info.js'
|
|
4
4
|
import { startErrorMonitor } from '../error/monitor/start.js'
|
|
5
|
-
import { getBufferLogs } from '../log/logger.js'
|
|
5
|
+
import { getBufferLogs, getSystemLogger } from '../log/logger.js'
|
|
6
6
|
import { logBuildStart, logTimer, logBuildSuccess } from '../log/messages/core.js'
|
|
7
7
|
import { loadPlugins } from '../plugins/load.js'
|
|
8
8
|
import { getPluginsOptions } from '../plugins/options.js'
|
|
@@ -57,6 +57,7 @@ export default async function buildSite(flags = {}) {
|
|
|
57
57
|
mode,
|
|
58
58
|
logs,
|
|
59
59
|
debug,
|
|
60
|
+
systemLogFile,
|
|
60
61
|
testOpts,
|
|
61
62
|
statsdOpts,
|
|
62
63
|
dry,
|
|
@@ -80,6 +81,7 @@ export default async function buildSite(flags = {}) {
|
|
|
80
81
|
} = await execBuild({
|
|
81
82
|
...flagsA,
|
|
82
83
|
buildId,
|
|
84
|
+
systemLogFile,
|
|
83
85
|
deployId,
|
|
84
86
|
dry,
|
|
85
87
|
errorMonitor,
|
|
@@ -163,6 +165,7 @@ const tExecBuild = async function ({
|
|
|
163
165
|
baseRelDir,
|
|
164
166
|
env: envOpt,
|
|
165
167
|
debug,
|
|
168
|
+
systemLogFile,
|
|
166
169
|
verbose,
|
|
167
170
|
nodePath,
|
|
168
171
|
functionsDistDir,
|
|
@@ -241,6 +244,7 @@ const tExecBuild = async function ({
|
|
|
241
244
|
mode,
|
|
242
245
|
testOpts,
|
|
243
246
|
})
|
|
247
|
+
const systemLog = getSystemLogger(logs, debug, systemLogFile)
|
|
244
248
|
const pluginsOptions = addCorePlugins({ netlifyConfig, constants })
|
|
245
249
|
// `errorParams` is purposely stateful
|
|
246
250
|
// eslint-disable-next-line fp/no-mutating-assign
|
|
@@ -276,6 +280,7 @@ const tExecBuild = async function ({
|
|
|
276
280
|
errorParams,
|
|
277
281
|
logs,
|
|
278
282
|
debug,
|
|
283
|
+
systemLog,
|
|
279
284
|
verbose,
|
|
280
285
|
timers: timersA,
|
|
281
286
|
sendStatus,
|
|
@@ -325,6 +330,7 @@ const runAndReportBuild = async function ({
|
|
|
325
330
|
errorParams,
|
|
326
331
|
logs,
|
|
327
332
|
debug,
|
|
333
|
+
systemLog,
|
|
328
334
|
verbose,
|
|
329
335
|
timers,
|
|
330
336
|
sendStatus,
|
|
@@ -365,6 +371,7 @@ const runAndReportBuild = async function ({
|
|
|
365
371
|
errorParams,
|
|
366
372
|
logs,
|
|
367
373
|
debug,
|
|
374
|
+
systemLog,
|
|
368
375
|
verbose,
|
|
369
376
|
timers,
|
|
370
377
|
sendStatus,
|
|
@@ -457,6 +464,7 @@ const initAndRunBuild = async function ({
|
|
|
457
464
|
errorParams,
|
|
458
465
|
logs,
|
|
459
466
|
debug,
|
|
467
|
+
systemLog,
|
|
460
468
|
verbose,
|
|
461
469
|
sendStatus,
|
|
462
470
|
saveConfig,
|
|
@@ -528,6 +536,7 @@ const initAndRunBuild = async function ({
|
|
|
528
536
|
errorParams,
|
|
529
537
|
logs,
|
|
530
538
|
debug,
|
|
539
|
+
systemLog,
|
|
531
540
|
verbose,
|
|
532
541
|
saveConfig,
|
|
533
542
|
timers: timersB,
|
|
@@ -581,6 +590,7 @@ const runBuild = async function ({
|
|
|
581
590
|
errorParams,
|
|
582
591
|
logs,
|
|
583
592
|
debug,
|
|
593
|
+
systemLog,
|
|
584
594
|
verbose,
|
|
585
595
|
saveConfig,
|
|
586
596
|
timers,
|
|
@@ -634,6 +644,7 @@ const runBuild = async function ({
|
|
|
634
644
|
configOpts,
|
|
635
645
|
logs,
|
|
636
646
|
debug,
|
|
647
|
+
systemLog,
|
|
637
648
|
verbose,
|
|
638
649
|
saveConfig,
|
|
639
650
|
timers: timersA,
|
package/src/error/type.js
CHANGED
|
@@ -88,7 +88,7 @@ const TYPES = {
|
|
|
88
88
|
|
|
89
89
|
return `Bundling of function "${functionName}" failed`
|
|
90
90
|
},
|
|
91
|
-
group: ({ location: { functionType = 'serverless' } }) => `
|
|
91
|
+
group: ({ location: { functionType = 'serverless' } }) => `Bundling of ${functionType} function failed`,
|
|
92
92
|
stackType: 'none',
|
|
93
93
|
locationType: 'functionsBundling',
|
|
94
94
|
severity: 'info',
|
package/src/log/logger.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createWriteStream } from 'fs'
|
|
2
|
+
|
|
1
3
|
import figures from 'figures'
|
|
2
4
|
import indentString from 'indent-string'
|
|
3
5
|
|
|
@@ -105,3 +107,36 @@ export const logErrorSubHeader = function (logs, string, opts) {
|
|
|
105
107
|
export const logWarningSubHeader = function (logs, string, opts) {
|
|
106
108
|
logSubHeader(logs, string, { color: THEME.warningSubHeader, ...opts })
|
|
107
109
|
}
|
|
110
|
+
|
|
111
|
+
// Combines an array of elements into a single string, separated by a space,
|
|
112
|
+
// and with basic serialization of non-string types
|
|
113
|
+
const reduceLogLines = function (lines) {
|
|
114
|
+
return lines
|
|
115
|
+
.map((input) => {
|
|
116
|
+
if (typeof input === 'object') {
|
|
117
|
+
return JSON.stringify(input)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return input.toString()
|
|
121
|
+
})
|
|
122
|
+
.join(' ')
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Builds a function for logging data to the system logger (i.e. hidden from
|
|
126
|
+
// the user-facing build logs)
|
|
127
|
+
export const getSystemLogger = function (logs, debug, systemLogFile) {
|
|
128
|
+
// If there's not a file descriptor (or it's set to 0, matching stdout), we
|
|
129
|
+
// send debug lines to the normal logger. The same happens if the `debug`
|
|
130
|
+
// flag is used, since that means we want to print logs to stdout.
|
|
131
|
+
if (!systemLogFile || debug) {
|
|
132
|
+
return (...args) => log(logs, reduceLogLines(args))
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const fileDescriptor = createWriteStream(null, { fd: systemLogFile })
|
|
136
|
+
|
|
137
|
+
fileDescriptor.on('error', () => {
|
|
138
|
+
logError(logs, 'Could not write to system log file')
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
return (...args) => fileDescriptor.write(reduceLogLines(args))
|
|
142
|
+
}
|
|
@@ -5,7 +5,6 @@ import { bundle, find } from '@netlify/edge-bundler'
|
|
|
5
5
|
import { pathExists } from 'path-exists'
|
|
6
6
|
|
|
7
7
|
import { logFunctionsToBundle } from '../../log/messages/core_steps.js'
|
|
8
|
-
import { logEdgeManifest } from '../../log/messages/edge_manifest.js'
|
|
9
8
|
|
|
10
9
|
import { tagBundlingError } from './lib/error.js'
|
|
11
10
|
import { parseManifest } from './lib/internal_manifest.js'
|
|
@@ -15,7 +14,7 @@ import { validateEdgeFunctionsManifest } from './validate_manifest/validate_edge
|
|
|
15
14
|
const DENO_CLI_CACHE_DIRECTORY = '.netlify/plugins/deno-cli'
|
|
16
15
|
const IMPORT_MAP_FILENAME = 'edge-functions-import-map.json'
|
|
17
16
|
|
|
18
|
-
// eslint-disable-next-line
|
|
17
|
+
// eslint-disable-next-line max-statements
|
|
19
18
|
const coreStep = async function ({
|
|
20
19
|
buildDir,
|
|
21
20
|
constants: {
|
|
@@ -25,6 +24,7 @@ const coreStep = async function ({
|
|
|
25
24
|
IS_LOCAL: isRunningLocally,
|
|
26
25
|
},
|
|
27
26
|
debug,
|
|
27
|
+
systemLog,
|
|
28
28
|
featureFlags,
|
|
29
29
|
logs,
|
|
30
30
|
netlifyConfig,
|
|
@@ -59,9 +59,7 @@ const coreStep = async function ({
|
|
|
59
59
|
importMaps: [importMap].filter(Boolean),
|
|
60
60
|
})
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
logEdgeManifest({ manifest, logs, debug })
|
|
64
|
-
}
|
|
62
|
+
systemLog('Edge Functions manifest:', manifest)
|
|
65
63
|
} catch (error) {
|
|
66
64
|
tagBundlingError(error)
|
|
67
65
|
|
package/src/steps/core_step.js
CHANGED
|
@@ -27,6 +27,7 @@ export const fireCoreStep = async function ({
|
|
|
27
27
|
redirectsPath,
|
|
28
28
|
featureFlags,
|
|
29
29
|
debug,
|
|
30
|
+
systemLog,
|
|
30
31
|
saveConfig,
|
|
31
32
|
}) {
|
|
32
33
|
try {
|
|
@@ -54,6 +55,7 @@ export const fireCoreStep = async function ({
|
|
|
54
55
|
redirectsPath,
|
|
55
56
|
featureFlags,
|
|
56
57
|
debug,
|
|
58
|
+
systemLog,
|
|
57
59
|
saveConfig,
|
|
58
60
|
})
|
|
59
61
|
const {
|
package/src/steps/run_step.js
CHANGED
|
@@ -48,6 +48,7 @@ export const runStep = async function ({
|
|
|
48
48
|
redirectsPath,
|
|
49
49
|
logs,
|
|
50
50
|
debug,
|
|
51
|
+
systemLog,
|
|
51
52
|
verbose,
|
|
52
53
|
saveConfig,
|
|
53
54
|
timers,
|
|
@@ -109,6 +110,7 @@ export const runStep = async function ({
|
|
|
109
110
|
error,
|
|
110
111
|
logs,
|
|
111
112
|
debug,
|
|
113
|
+
systemLog,
|
|
112
114
|
verbose,
|
|
113
115
|
saveConfig,
|
|
114
116
|
timers,
|
|
@@ -140,6 +142,7 @@ export const runStep = async function ({
|
|
|
140
142
|
redirectsPath: redirectsPathA,
|
|
141
143
|
logs,
|
|
142
144
|
debug,
|
|
145
|
+
systemLog,
|
|
143
146
|
timers: timersA,
|
|
144
147
|
durationNs,
|
|
145
148
|
testOpts,
|
|
@@ -237,6 +240,7 @@ const tFireStep = function ({
|
|
|
237
240
|
error,
|
|
238
241
|
logs,
|
|
239
242
|
debug,
|
|
243
|
+
systemLog,
|
|
240
244
|
verbose,
|
|
241
245
|
saveConfig,
|
|
242
246
|
errorParams,
|
|
@@ -271,6 +275,7 @@ const tFireStep = function ({
|
|
|
271
275
|
redirectsPath,
|
|
272
276
|
featureFlags,
|
|
273
277
|
debug,
|
|
278
|
+
systemLog,
|
|
274
279
|
saveConfig,
|
|
275
280
|
})
|
|
276
281
|
}
|
|
@@ -294,6 +299,7 @@ const tFireStep = function ({
|
|
|
294
299
|
error,
|
|
295
300
|
logs,
|
|
296
301
|
debug,
|
|
302
|
+
systemLog,
|
|
297
303
|
verbose,
|
|
298
304
|
})
|
|
299
305
|
}
|
package/src/steps/run_steps.js
CHANGED
|
@@ -34,6 +34,7 @@ export const runSteps = async function ({
|
|
|
34
34
|
configOpts,
|
|
35
35
|
logs,
|
|
36
36
|
debug,
|
|
37
|
+
systemLog,
|
|
37
38
|
verbose,
|
|
38
39
|
saveConfig,
|
|
39
40
|
timers,
|
|
@@ -127,6 +128,7 @@ export const runSteps = async function ({
|
|
|
127
128
|
redirectsPath: redirectsPathA,
|
|
128
129
|
logs,
|
|
129
130
|
debug,
|
|
131
|
+
systemLog,
|
|
130
132
|
verbose,
|
|
131
133
|
saveConfig,
|
|
132
134
|
timers: timersA,
|