Skip to content

Commit c58f966

Browse files
feat: add quiet flag (#4788)
* feat: add `quiet` flag * chore: update snapshot
1 parent bf4f74f commit c58f966

File tree

14 files changed

+197
-10
lines changed

14 files changed

+197
-10
lines changed

packages/build/src/core/build.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ export const startBuild = function (flags: Partial<BuildCLIFlags>) {
2727
const timers = initTimers()
2828

2929
const logs = getBufferLogs(flags)
30-
logBuildStart(logs)
30+
31+
if (!flags.quiet) {
32+
logBuildStart(logs)
33+
}
3134

3235
const { bugsnagKey, ...flagsA } = normalizeFlags(flags, logs)
3336
const errorMonitor = startErrorMonitor({ flags: flagsA, logs, bugsnagKey })
@@ -72,6 +75,7 @@ const tExecBuild = async function ({
7275
featureFlags,
7376
timeline,
7477
devCommand,
78+
quiet,
7579
}) {
7680
const configOpts = getConfigOpts({
7781
config,
@@ -117,6 +121,7 @@ const tExecBuild = async function ({
117121
logs,
118122
nodePath,
119123
timers,
124+
quiet,
120125
})
121126
const constants = await getConstants({
122127
configPath,
@@ -177,6 +182,7 @@ const tExecBuild = async function ({
177182
featureFlags,
178183
timeline,
179184
devCommand,
185+
quiet,
180186
})
181187
return {
182188
pluginsOptions: pluginsOptionsA,
@@ -227,6 +233,7 @@ export const runAndReportBuild = async function ({
227233
featureFlags,
228234
timeline,
229235
devCommand,
236+
quiet,
230237
}) {
231238
try {
232239
const {
@@ -272,6 +279,7 @@ export const runAndReportBuild = async function ({
272279
featureFlags,
273280
timeline,
274281
devCommand,
282+
quiet,
275283
})
276284
await Promise.all([
277285
reportStatuses({
@@ -367,6 +375,7 @@ const initAndRunBuild = async function ({
367375
featureFlags,
368376
timeline,
369377
devCommand,
378+
quiet,
370379
}) {
371380
const { pluginsOptions: pluginsOptionsA, timers: timersA } = await getPluginsOptions({
372381
pluginsOptions,
@@ -396,6 +405,7 @@ const initAndRunBuild = async function ({
396405
debug,
397406
timers: timersA,
398407
featureFlags,
408+
quiet,
399409
})
400410

401411
try {
@@ -439,6 +449,7 @@ const initAndRunBuild = async function ({
439449
featureFlags,
440450
timeline,
441451
devCommand,
452+
quiet,
442453
})
443454

444455
await Promise.all([
@@ -500,6 +511,7 @@ const runBuild = async function ({
500511
featureFlags,
501512
timeline,
502513
devCommand,
514+
quiet,
503515
}) {
504516
const { pluginsSteps, timers: timersA } = await loadPlugins({
505517
pluginsOptions,
@@ -554,6 +566,7 @@ const runBuild = async function ({
554566
timers: timersA,
555567
testOpts,
556568
featureFlags,
569+
quiet,
557570
})
558571

559572
return { stepsCount, netlifyConfig: netlifyConfigA, statuses, failedPlugins, timers: timersB, configMutations }

packages/build/src/core/config.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,16 @@ export const getConfigOpts = function ({
5959
}
6060

6161
// Retrieve configuration object
62-
const tLoadConfig = async function ({ configOpts, cachedConfig, cachedConfigPath, envOpt, debug, logs, nodePath }) {
62+
const tLoadConfig = async function ({
63+
configOpts,
64+
cachedConfig,
65+
cachedConfigPath,
66+
envOpt,
67+
debug,
68+
logs,
69+
nodePath,
70+
quiet,
71+
}) {
6372
const {
6473
configPath,
6574
headersPath,
@@ -74,7 +83,10 @@ const tLoadConfig = async function ({ configOpts, cachedConfig, cachedConfigPath
7483
siteInfo,
7584
env,
7685
} = await resolveInitialConfig(configOpts, cachedConfig, cachedConfigPath)
77-
logConfigInfo({ logs, configPath, buildDir, netlifyConfig, context: contextA, debug })
86+
87+
if (!quiet) {
88+
logConfigInfo({ logs, configPath, buildDir, netlifyConfig, context: contextA, debug })
89+
}
7890

7991
const apiA = addApiErrorHandlers(api)
8092
const envValues = mapObj(env, (key, { value }) => [key, value])

packages/build/src/core/normalize_flags.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ export const normalizeFlags = function (flags: Partial<BuildCLIFlags>, logs): Re
6161
}
6262
const normalizedFlags = removeFalsy(mergedFlags) as any
6363

64-
logFlags(logs, rawFlags, normalizedFlags)
64+
if (!flags.quiet) {
65+
logFlags(logs, rawFlags, normalizedFlags)
66+
}
6567

6668
return normalizedFlags
6769
}
@@ -90,6 +92,7 @@ const getDefaultFlags = function ({ env: envOpt = {} }, combinedEnv) {
9092
featureFlags: DEFAULT_FEATURE_FLAGS,
9193
statsd: { port: DEFAULT_STATSD_PORT },
9294
timeline: 'build',
95+
quiet: false,
9396
}
9497
}
9598

packages/build/src/core/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export type BuildCLIFlags = {
2828
cwd?: string
2929
/** A list of all the feature flags passed to netlify/build */
3030
featureFlags: Record<string, boolean>
31+
/**
32+
* Print only essential/error output
33+
* @default false
34+
*/
35+
quiet?: boolean
3136
}
3237

3338
export type BuildResult = {

packages/build/src/plugins/spawn.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ const CHILD_MAIN_FILE = fileURLToPath(new URL('child/main.js', import.meta.url))
2222
// (for both security and safety reasons)
2323
// - logs can be buffered which allows manipulating them for log shipping,
2424
// transforming and parallel plugins
25-
const tStartPlugins = async function ({ pluginsOptions, buildDir, childEnv, logs, debug, featureFlags }) {
26-
logRuntime(logs, pluginsOptions)
27-
logLoadingPlugins(logs, pluginsOptions, debug)
25+
const tStartPlugins = async function ({ pluginsOptions, buildDir, childEnv, logs, debug, featureFlags, quiet }) {
26+
if (!quiet) {
27+
logRuntime(logs, pluginsOptions)
28+
logLoadingPlugins(logs, pluginsOptions, debug)
29+
}
30+
2831
logOutdatedPlugins(logs, pluginsOptions)
2932
logIncompatiblePlugins(logs, pluginsOptions)
3033

packages/build/src/steps/return.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const getStepReturn = function ({
2727
durationNs,
2828
testOpts,
2929
systemLog,
30+
quiet,
3031
}) {
3132
if (newError !== undefined) {
3233
return handleStepError({
@@ -45,9 +46,11 @@ export const getStepReturn = function ({
4546
})
4647
}
4748

48-
logStepSuccess(logs)
49+
if (!quiet) {
50+
logStepSuccess(logs)
4951

50-
logTimer(logs, durationNs, timerName, systemLog)
52+
logTimer(logs, durationNs, timerName, systemLog)
53+
}
5154

5255
return { newEnvChanges, netlifyConfig, configMutations, headersPath, redirectsPath, newStatus, timers }
5356
}

packages/build/src/steps/run_step.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const runStep = async function ({
5454
timers,
5555
testOpts,
5656
featureFlags,
57+
quiet,
5758
}) {
5859
const constantsA = await addMutableConstants({ constants, buildDir, netlifyConfig })
5960

@@ -73,7 +74,9 @@ export const runStep = async function ({
7374
return {}
7475
}
7576

76-
logStepStart({ logs, event, packageName, coreStepDescription, index, error, netlifyConfig })
77+
if (!quiet) {
78+
logStepStart({ logs, event, packageName, coreStepDescription, index, error, netlifyConfig })
79+
}
7780

7881
const fireStep = getFireStep(packageName, coreStepId, event)
7982
const {
@@ -147,6 +150,7 @@ export const runStep = async function ({
147150
durationNs,
148151
testOpts,
149152
systemLog,
153+
quiet,
150154
})
151155
return { ...newValues, newIndex: index + 1 }
152156
}

packages/build/src/steps/run_steps.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const runSteps = async function ({
3939
timers,
4040
testOpts,
4141
featureFlags,
42+
quiet,
4243
}) {
4344
const {
4445
index: stepsCount,
@@ -133,6 +134,7 @@ export const runSteps = async function ({
133134
timers: timersA,
134135
testOpts,
135136
featureFlags,
137+
quiet,
136138
})
137139
const statusesA = addStatus({ newStatus, statuses, event, packageName, pluginPackageJson })
138140
return {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name: test
2+
inputs: []
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[[plugins]]
2+
package = "./plugin.js"

0 commit comments

Comments
 (0)