Skip to content

Commit

Permalink
🩹 fix(patch): set default log preset to none (#2602)
Browse files Browse the repository at this point in the history
Fixes: logging issue in nightly.

## Type of change

**PATCH: backwards compatible change**
  • Loading branch information
kellymears authored Jun 19, 2024
1 parent 3efb83f commit 15037dd
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 79 deletions.
7 changes: 5 additions & 2 deletions sources/@roots/bud-build/src/config/bail.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type {Factory} from '@roots/bud-build/config'

export const bail: Factory<'bail'> = async ({hooks, isProduction}) =>
hooks.filter(`build.bail`, isProduction)
export const bail: Factory<'bail'> = async ({
context,
hooks,
isProduction,
}) => hooks.filter(`build.bail`, isProduction && !context.ignoreErrors)
1 change: 1 addition & 0 deletions sources/@roots/bud-build/src/config/optimization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const optimization: Factory<`optimization`> = async ({
`build.optimization.providedExports`,
isProduction,
),

/**
* Will be new default in webpack 6
* @see {@link https://webpack.js.org/configuration/optimization/#optimizationremoveavailablemodules}
Expand Down
2 changes: 1 addition & 1 deletion sources/@roots/bud-build/src/config/stats.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Factory} from '@roots/bud-build/config'

export const stats: Factory<`stats`> = async app =>
app.hooks.filter(`build.stats`, {preset: `normal`})
app.hooks.filter(`build.stats`, {preset: `none`})
48 changes: 22 additions & 26 deletions sources/@roots/bud-compiler/src/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,27 @@ class Compiler extends Service implements BudCompiler {
*/
@bind
public onStats(stats: MultiStats) {
this.stats = stats.toJson(statsOptions)
this.stats = stats.toJson({
all: false,
children: {
all: false,
assets: true,
cached: true,
cachedAssets: true,
cachedModules: true,
entrypoints: true,
errorDetails: false,
errors: true,
errorsCount: true,
hash: true,
modules: true,
name: true,
outputPath: true,
timings: true,
warnings: true,
warningsCount: true,
},
})
this.app.dashboard.render(stats)

if (stats.hasErrors()) {
Expand Down Expand Up @@ -124,9 +144,7 @@ class Compiler extends Service implements BudCompiler {
this.logger.info(`parallel compilations: ${this.config.parallelism}`)
}

await bud.hooks.fire(`compiler.before`, bud).catch(error => {
throw error
})
await bud.hooks.fire(`compiler.before`, bud)

this.instance = this.implementation(this.config)
this.instance.hooks.done.tap(bud.label, this.onStats)
Expand All @@ -150,26 +168,4 @@ class Compiler extends Service implements BudCompiler {
}
}

const statsOptions = {
all: false,
children: {
all: false,
assets: true,
cached: true,
cachedAssets: true,
cachedModules: true,
entrypoints: true,
errorDetails: false,
errors: true,
errorsCount: true,
hash: true,
modules: true,
name: true,
outputPath: true,
timings: true,
warnings: true,
warningsCount: true,
},
}

export {Compiler as default}
8 changes: 3 additions & 5 deletions sources/@roots/bud-dashboard/src/service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ export class Dashboard extends Service implements BudDashboard {
/**
* Do not render if silent mode is enabled
*/
if (this.app.context.silent) return null
if (this.app.context.silent) return

/**
* Do not render if no stats received
*/
if (!stats) {
return null
}
if (!stats) return

/**
* Render basic output if `--dashboard` flag is false
Expand All @@ -73,7 +71,7 @@ export class Dashboard extends Service implements BudDashboard {
const stringStats = stats.toString({
preset: `minimal`,
})
return <Text>{stringStats}</Text>
return render(<Text>{stringStats}</Text>)
}

const data: StatsCompilation =
Expand Down
9 changes: 9 additions & 0 deletions sources/@roots/bud-framework/test/methods/run/run.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {describe, expect, it} from 'vitest'

import {run} from '../../../src/methods/run/index'

describe(`bud.run`, () => {
it(`is a function`, async () => {
expect(run).toBeInstanceOf(Function)
})
})
1 change: 0 additions & 1 deletion tests/unit/logging.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Bud, factory} from '@repo/test-kit'
import logger from '@roots/bud-support/logger'
import {beforeAll, describe, expect, it, vi} from 'vitest'

describe(`bud`, function () {
Expand Down
32 changes: 0 additions & 32 deletions tests/unit/path.test.ts

This file was deleted.

12 changes: 0 additions & 12 deletions tests/unit/run.test.ts

This file was deleted.

0 comments on commit 15037dd

Please sign in to comment.