update-browserslist-db 1.3.0 → 1.3.1
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/index.js +51 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
let { execSync } = require('child_process')
|
|
2
2
|
let escalade = require('escalade/sync')
|
|
3
3
|
let { existsSync, readFileSync, writeFileSync } = require('fs')
|
|
4
|
-
let { join } = require('path')
|
|
4
|
+
let { dirname, join } = require('path')
|
|
5
5
|
let pico = require('picocolors')
|
|
6
6
|
|
|
7
7
|
let { detectEOL, detectIndent } = require('./utils')
|
|
@@ -264,6 +264,55 @@ function updatePackageManually(print, lock, latest) {
|
|
|
264
264
|
execSync(del + ' caniuse-lite baseline-browser-mapping')
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
+
/**
|
|
268
|
+
* Bun cannot update a transitive dependency by name: `bun update caniuse-lite`
|
|
269
|
+
* adds caniuse-lite to package.json as a new direct dependency at the latest
|
|
270
|
+
* version and leaves every nested copy - the ones that actually get resolved at
|
|
271
|
+
* runtime - on the old version. A temporary `overrides` entry reaches those,
|
|
272
|
+
* and the resolutions survive once it is taken back out.
|
|
273
|
+
*/
|
|
274
|
+
function updateBun(print, lock, latest) {
|
|
275
|
+
let pkgFile = join(dirname(lock.file), 'package.json')
|
|
276
|
+
let original = readFileSync(pkgFile)
|
|
277
|
+
let pkg = JSON.parse(original.toString())
|
|
278
|
+
let withOverride = {
|
|
279
|
+
...pkg,
|
|
280
|
+
overrides: {
|
|
281
|
+
...pkg.overrides,
|
|
282
|
+
'baseline-browser-mapping': 'latest',
|
|
283
|
+
'caniuse-lite': latest.version
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// The file is restored byte for byte below, so its formatting does not matter.
|
|
288
|
+
writeFileSync(pkgFile, JSON.stringify(withOverride, null, 2) + '\n')
|
|
289
|
+
|
|
290
|
+
print(
|
|
291
|
+
'Updating caniuse-lite version\n' +
|
|
292
|
+
pico.yellow('$ bun install') +
|
|
293
|
+
' (with a temporary caniuse-lite override)\n'
|
|
294
|
+
)
|
|
295
|
+
try {
|
|
296
|
+
execSync('bun install')
|
|
297
|
+
} catch (e) /* c8 ignore start */ {
|
|
298
|
+
writeFileSync(pkgFile, original)
|
|
299
|
+
print(pico.red(e.stdout.toString()))
|
|
300
|
+
print(
|
|
301
|
+
pico.red(
|
|
302
|
+
'\n' +
|
|
303
|
+
e.stack +
|
|
304
|
+
'\n\n' +
|
|
305
|
+
'Problem with `bun install` call. ' +
|
|
306
|
+
'Run it manually.\n'
|
|
307
|
+
)
|
|
308
|
+
)
|
|
309
|
+
process.exit(1)
|
|
310
|
+
} /* c8 ignore end */
|
|
311
|
+
|
|
312
|
+
writeFileSync(pkgFile, original)
|
|
313
|
+
updateWith(print, 'bun install', 'Removing the temporary override')
|
|
314
|
+
}
|
|
315
|
+
|
|
267
316
|
function updateWith(print, cmd, message = 'Updating caniuse-lite version') {
|
|
268
317
|
print(message + '\n' + pico.yellow('$ ' + cmd) + '\n')
|
|
269
318
|
try {
|
|
@@ -308,7 +357,7 @@ module.exports = function updateDB(print = defaultPrint) {
|
|
|
308
357
|
: 'caniuse-lite'
|
|
309
358
|
updateWith(print, 'pnpm up --depth=Infinity --no-save ' + packages)
|
|
310
359
|
} else if (lock.mode === 'bun') {
|
|
311
|
-
|
|
360
|
+
updateBun(print, lock, latest)
|
|
312
361
|
} else if (lock.mode === 'deno') {
|
|
313
362
|
updateWith(print, 'deno add npm:caniuse-lite npm:baseline-browser-mapping')
|
|
314
363
|
updateWith(
|