Skip to content

Commit

Permalink
🩹 fix(patch): fix browserslist db errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kellymears committed Oct 25, 2023
1 parent 04aa5bb commit 224a285
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 242 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"ts-node": "10.9.1",
"tslib": "2.6.2",
"typescript": "5.2.2",
"update-browserslist-db": "latest",
"verdaccio": "5.27.0",
"vitest": "0.34.6",
"vitest-github-actions-reporter": "0.10.0",
Expand Down
55 changes: 20 additions & 35 deletions sources/@repo/yarn-plugin-bud/bundles/@yarnpkg/plugin-bud.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
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'

Expand All @@ -16,78 +12,11 @@ export class BrowserslistUpdate extends Command {
category: `@bud`,
description: `update browserslist`,
examples: [
[`browserslist usage info`, `yarn @bud browserslist --help`],
[`update browserslist db`, `yarn @bud browserslist update`],
],
}

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`)
await this.cli.run([`update-browserslist-db`])
}
}
37 changes: 2 additions & 35 deletions sources/@roots/browserslist-config/default.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,5 @@
* Default
**/
module.exports = [
`and_chr 118`,
`and_ff 118`,
`and_qq 13.1`,
`and_uc 15.5`,
`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 115`,
`ios_saf 17.0`,
`ios_saf 16.6`,
`ios_saf 16.3`,
`ios_saf 16.1`,
`ios_saf 15.6-15.7`,
`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`,
`safari 15.6`,
`samsung 22`,
`samsung 21`,
]
`defaults`,
]
33 changes: 1 addition & 32 deletions sources/@roots/browserslist-config/last-2-versions.cjs
Original file line number Diff line number Diff line change
@@ -1,35 +1,4 @@
/**
* Last 2 versions
*/
module.exports = [
`and_chr 118`,
`and_ff 118`,
`and_qq 13.1`,
`and_uc 15.5`,
`android 118`,
`baidu 13.18`,
`bb 10`,
`bb 7`,
`chrome 118`,
`chrome 117`,
`edge 118`,
`edge 117`,
`firefox 118`,
`firefox 117`,
`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`,
`safari 17.0`,
`safari 16.6`,
`samsung 22`,
`samsung 21`,
]
module.exports = [`last 2 versions`]
41 changes: 1 addition & 40 deletions sources/@roots/browserslist-config/last-3-versions.cjs
Original file line number Diff line number Diff line change
@@ -1,43 +1,4 @@
/**
* Last 3 versions
*/
module.exports = [
`and_chr 118`,
`and_ff 118`,
`and_qq 13.1`,
`and_uc 15.5`,
`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 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`,
`safari 17.0`,
`safari 16.6`,
`safari 16.5`,
`samsung 22`,
`samsung 21`,
`samsung 20`,
]
module.exports = [`last 3 versions`]
2 changes: 1 addition & 1 deletion sources/@roots/browserslist-config/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/**
* null
* No types for this package
*/
32 changes: 10 additions & 22 deletions sources/@roots/browserslist-config/wordpress.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,13 @@
* WordPress
*/
module.exports = [
`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`,
]
`> 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`,
]
3 changes: 2 additions & 1 deletion sources/@roots/bud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@
"@roots/bud-minify": "workspace:*",
"@roots/bud-server": "workspace:*",
"@roots/bud-support": "workspace:*",
"caniuse-lite": "1.0.30001553",
"browserslist": "4.22.1",
"caniuse-lite": "latest",
"tslib": "2.6.2"
},
"volta": {
Expand Down
15 changes: 12 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9582,7 +9582,8 @@ __metadata:
"@roots/bud-support": "workspace:*"
"@skypack/package-check": 0.2.2
"@types/node": 20.8.8
caniuse-lite: 1.0.30001553
browserslist: 4.22.1
caniuse-lite: latest
tslib: 2.6.2
bin:
bud: ./bin/bud.mjs
Expand Down Expand Up @@ -17273,6 +17274,7 @@ __metadata:
ts-node: 10.9.1
tslib: 2.6.2
typescript: 5.2.2
update-browserslist-db: latest
verdaccio: 5.27.0
vitest: 0.34.6
vitest-github-actions-reporter: 0.10.0
Expand Down Expand Up @@ -17621,13 +17623,20 @@ __metadata:
languageName: node
linkType: hard

"caniuse-lite@npm:1.0.30001553, caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001464, caniuse-lite@npm:^1.0.30001503, caniuse-lite@npm:^1.0.30001517, caniuse-lite@npm:^1.0.30001538, caniuse-lite@npm:^1.0.30001541":
"caniuse-lite@npm:1.0.30001553":
version: 1.0.30001553
resolution: "caniuse-lite@npm:1.0.30001553"
checksum: 45d6a2a3c3a098c8093a4c8883fceafb4bbf59d96f6fd5bb381ba4581d07eecbe0ede4f55383f0d49374154ff6a808bd90fbe32b17ccd1738034d2579787b33c
languageName: node
linkType: hard

"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001464, caniuse-lite@npm:^1.0.30001503, caniuse-lite@npm:^1.0.30001517, caniuse-lite@npm:^1.0.30001538, caniuse-lite@npm:^1.0.30001541, caniuse-lite@npm:latest":
version: 1.0.30001554
resolution: "caniuse-lite@npm:1.0.30001554"
checksum: ccb557daa716b474a15f3a0a3a0e33f59393024a9fd1ccef6d8ee6f35c195fb5cca7f99f1ac88e3db5926b4f1bcd4ad6d7380a27e1d45d68468a837dd7e60106
languageName: node
linkType: hard

"capital-case@npm:^1.0.4":
version: 1.0.4
resolution: "capital-case@npm:1.0.4"
Expand Down Expand Up @@ -40436,7 +40445,7 @@ __metadata:
languageName: node
linkType: hard

"update-browserslist-db@npm:^1.0.13":
"update-browserslist-db@npm:^1.0.13, update-browserslist-db@npm:latest":
version: 1.0.13
resolution: "update-browserslist-db@npm:1.0.13"
dependencies:
Expand Down

0 comments on commit 224a285

Please sign in to comment.