Skip to content

Commit

Permalink
🩹 fix(patch): fix --silent and --no-dashboard output (#2485)
Browse files Browse the repository at this point in the history
## Type of change

**PATCH: backwards compatible change**
  • Loading branch information
kellymears authored Oct 23, 2023
1 parent 742b388 commit 783d9df
Show file tree
Hide file tree
Showing 12 changed files with 244 additions and 104 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@vitest/coverage-v8": "0.34.6",
"@vitest/ui": "0.34.6",
"browserslist": "4.22.1",
"caniuse-lite": "1.0.30001546",
"caniuse-lite": "latest",
"esbuild": "0.19.4",
"eslint": "8.51.0",
"eslint-plugin-n": "16.1.0",
Expand Down
55 changes: 35 additions & 20 deletions sources/@repo/yarn-plugin-bud/bundles/@yarnpkg/plugin-bud.js

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions sources/@repo/yarn-plugin-bud/sources/command/_browserslist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {CommandClass, Option} from 'clipanion'

import {Command} from './base.command'

export class Browserslist extends Command {
public static paths: CommandClass['paths'] = [[`@bud`, `browserslist`]]

public static usage: CommandClass['usage'] = {
category: `@bud`,
description: `run browserslist`,
examples: [
[`browserslist usage info`, `yarn @bud browserslist --help`],
],
}

public passthrough = Option.Proxy({name: `browserslist options`})

public async execute() {
return await this.cli
.run([`browserslist`, ...(this.passthrough ?? [])])
.then(this.throwIfError)
.catch(this.catch)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import {path} from '@repo/constants'
import {CommandClass} from 'clipanion'
import {execa} from 'execa'
import * as fs from 'fs-jetpack'
import {kebabCase} from 'lodash'

import {Command} from './base.command'

export class BrowserslistUpdate extends Command {
public static paths: CommandClass['paths'] = [
[`@bud`, `browserslist`, `update`],
[`@bud`, `browserslist`, `upgrade`],
]

public static usage: CommandClass['usage'] = {
category: `@bud`,
description: `update browserslist`,
examples: [
[`browserslist usage info`, `yarn @bud browserslist --help`],
],
}

public static queries: Array<[string, Array<string>]> = [
[`Default`, []],
[`Last 2 versions`, [`last 2 versions`]],
[`Last 3 versions`, [`last 3 versions`]],
[
`WordPress`,
[
`> 1%`,
`last 1 Android versions`,
`last 1 ChromeAndroid versions`,
`last 2 Chrome versions`,
`last 2 Firefox versions`,
`last 2 Safari versions`,
`last 2 iOS versions`,
`last 2 Edge versions`,
`last 2 Opera versions`,
],
],
]

public async execute() {
this.context.stdout.write(`Updating browserslist...\n`)

await execa(`yarn`, [`browserslist`, `--update-db`]).catch(this.catch)

this.context.stdout.write(`Updating queries...\n`)

await Promise.all(
BrowserslistUpdate.queries.map(
async ([name, query]) => await this.updateQuery(name, query),
),
).catch(this.catch)
}

public async updateQuery(name: string, query: Array<string>) {
const list = await execa(`yarn`, [`browserslist`, query.join(`, `)])
.then(({stdout}) => stdout)
.catch(this.catch)

if (!list) return

const parts = []

// banner
parts.push(`/**\n * ${name}\n */\n`)
// opening module.exports statement
parts.push(`module.exports = [\n`)
// each line from stdout
list.split(`\n`).map(item => parts.push(` \`${item}\`,\n`))
// closing bracket
parts.push(`]`)

// file name
const filename = `${kebabCase(name.toLowerCase())}.cjs`
// file path
const writePath = path(
`sources`,
`@roots`,
`browserslist-config`,
filename,
)
// file contents
const contents = parts.join(``)

// write output
await fs.writeAsync(writePath, contents).catch(this.catch)

// log
this.context.stdout.write(`Updated ${filename}\n`)
}
}
2 changes: 2 additions & 0 deletions sources/@repo/yarn-plugin-bud/sources/command/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export {Browserslist} from './_browserslist.js'
export {Docusaurus} from './_docusaurus.js'
export {Eslint} from './_eslint.js'
export {Netlify} from './_netlify.js'
Expand All @@ -7,6 +8,7 @@ export {Prettier} from './_prettier.js'
export {Syncpack} from './_syncpack.js'
export {Tsc} from './_tsc.js'
export {Vitest} from './_vitest.js'
export {BrowserslistUpdate} from './browserslist-update.js'
export {Bud} from './bud.js'
export {Build} from './build.js'
export {Clean} from './clean.js'
Expand Down
18 changes: 10 additions & 8 deletions sources/@roots/browserslist-config/default.cjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
/**
* Browserslist defaults
*/
* Default
**/
module.exports = [
`and_chr 117`,
`and_ff 117`,
`and_chr 118`,
`and_ff 118`,
`and_qq 13.1`,
`and_uc 15.5`,
`android 117`,
`android 118`,
`chrome 118`,
`chrome 117`,
`chrome 116`,
`chrome 115`,
`chrome 114`,
`chrome 109`,
`edge 118`,
`edge 117`,
`edge 116`,
`firefox 118`,
`firefox 117`,
`firefox 116`,
`firefox 115`,
`firefox 102`,
`ios_saf 17.0`,
`ios_saf 16.6`,
`ios_saf 16.3`,
Expand All @@ -27,11 +28,12 @@ module.exports = [
`kaios 2.5`,
`op_mini all`,
`op_mob 73`,
`opera 103`,
`opera 102`,
`opera 101`,
`safari 17.0`,
`safari 16.6`,
`safari 15.6`,
`samsung 22`,
`samsung 21`,
]
]
23 changes: 15 additions & 8 deletions sources/@roots/browserslist-config/last-2-versions.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,34 @@
* Last 2 versions
*/
module.exports = [
`and_chr 117`,
`and_ff 117`,
`and_chr 118`,
`and_ff 118`,
`and_qq 13.1`,
`and_uc 15.5`,
`android 117`,
`android 118`,
`baidu 13.18`,
`bb 10`,
`bb 7`,
`chrome 118`,
`chrome 117`,
`chrome 116`,
`edge 118`,
`edge 117`,
`edge 116`,
`firefox 118`,
`firefox 117`,
`firefox 116`,
`ie 11`,
`ie 10`,
`ie_mob 11`,
`ie_mob 10`,
`ios_saf 17.0`,
`ios_saf 16.6`,
`kaios 3.0-3.1`,
`kaios 2.5`,
`op_mini all`,
`op_mob 73`,
`opera 103`,
`opera 102`,
`opera 101`,
`safari 17.0`,
`safari 16.6`,
`samsung 22`,
`samsung 21`,
]
]
26 changes: 17 additions & 9 deletions sources/@roots/browserslist-config/last-3-versions.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,42 @@
* Last 3 versions
*/
module.exports = [
`and_chr 117`,
`and_ff 117`,
`and_chr 118`,
`and_ff 118`,
`and_qq 13.1`,
`and_uc 15.5`,
`android 117`,
`android 118`,
`baidu 13.18`,
`bb 10`,
`bb 7`,
`chrome 118`,
`chrome 117`,
`chrome 116`,
`chrome 115`,
`edge 118`,
`edge 117`,
`edge 116`,
`edge 115`,
`firefox 118`,
`firefox 117`,
`firefox 116`,
`firefox 115`,
`ie 11`,
`ie 10`,
`ie 9`,
`ie_mob 11`,
`ie_mob 10`,
`ios_saf 17.0`,
`ios_saf 16.6`,
`ios_saf 16.5`,
`kaios 3.0-3.1`,
`kaios 2.5`,
`op_mini all`,
`op_mob 73`,
`opera 103`,
`opera 102`,
`opera 101`,
`opera 100`,
`safari 17.0`,
`safari 16.6`,
`safari 16.5`,
`samsung 22`,
`samsung 21`,
`samsung 20`
]
`samsung 20`,
]
14 changes: 11 additions & 3 deletions sources/@roots/browserslist-config/wordpress.cjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
/**
* WordPress defaults
* WordPress
*/
module.exports = [
`and_chr 117`,
`and_chr 118`,
`android 118`,
`chrome 118`,
`chrome 117`,
`chrome 116`,
`chrome 115`,
`chrome 109`,
`edge 118`,
`edge 117`,
`edge 116`,
`firefox 118`,
`firefox 117`,
`ios_saf 17.0`,
`ios_saf 16.6`,
`ios_saf 15.6-15.7`,
`op_mini all`,
`opera 103`,
`opera 102`,
`safari 17.0`,
`safari 16.6`,
`samsung 22`,
]
]
Loading

0 comments on commit 783d9df

Please sign in to comment.