update-browserslist-db 1.2.2 → 1.3.0
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/LICENSE +1 -1
- package/README.md +17 -6
- package/check-npm-version.js +15 -13
- package/cli.js +1 -1
- package/index.js +27 -16
- package/package.json +7 -7
- package/utils.js +1 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright 2022 Andrey Sitnik <andrey@sitnik.
|
|
3
|
+
Copyright 2022 Andrey Sitnik <andrey@sitnik.es> and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
6
|
this software and associated documentation files (the "Software"), to deal in
|
package/README.md
CHANGED
|
@@ -12,19 +12,30 @@ from `caniuse-lite`.
|
|
|
12
12
|
```sh
|
|
13
13
|
npx update-browserslist-db@latest
|
|
14
14
|
```
|
|
15
|
+
|
|
15
16
|
Or if using `pnpm`:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
pnpm dlx update-browserslist-db latest
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or if using `bun`:
|
|
23
|
+
|
|
16
24
|
```sh
|
|
17
|
-
|
|
25
|
+
bunx update-browserslist-db@latest
|
|
18
26
|
```
|
|
19
|
-
|
|
27
|
+
|
|
28
|
+
Or if using `yarn` 2+:
|
|
29
|
+
|
|
20
30
|
```sh
|
|
21
31
|
yarn dlx update-browserslist-db@latest
|
|
22
32
|
```
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
<img src="https://cdn.evilmartians.com/badges/logo-no-label.svg" alt="" width="22" height="16" /> Update Browserslist DB is built by <b><a href="https://evilmartians.com/">Evil Martians</a></b>, an American design and engineering consultancy for <b>developer tools, AI, and cybersecurity startups</b>.
|
|
37
|
+
|
|
38
|
+
---
|
|
28
39
|
|
|
29
40
|
## Docs
|
|
30
41
|
Read full docs **[here](https://github.com/browserslist/update-db#readme)**.
|
package/check-npm-version.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
let { execSync } = require('child_process')
|
|
2
|
+
let { existsSync } = require('fs')
|
|
2
3
|
let pico = require('picocolors')
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
if (!existsSync('deno.lock')) {
|
|
6
|
+
try {
|
|
7
|
+
let version = parseInt(execSync('npm -v'))
|
|
8
|
+
if (version <= 6) {
|
|
9
|
+
process.stderr.write(
|
|
10
|
+
pico.red(
|
|
11
|
+
'Update npm or call ' +
|
|
12
|
+
pico.yellow('npx browserslist@latest --update-db') +
|
|
13
|
+
'\n'
|
|
14
|
+
)
|
|
12
15
|
)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
} catch (e) {}
|
|
16
|
+
process.exit(1)
|
|
17
|
+
}
|
|
18
|
+
} catch {}
|
|
19
|
+
}
|
package/cli.js
CHANGED
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ let { existsSync, readFileSync, writeFileSync } = require('fs')
|
|
|
4
4
|
let { join } = require('path')
|
|
5
5
|
let pico = require('picocolors')
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
let { detectEOL, detectIndent } = require('./utils')
|
|
8
8
|
|
|
9
9
|
function BrowserslistUpdateError(message) {
|
|
10
10
|
this.name = 'BrowserslistUpdateError'
|
|
@@ -18,8 +18,7 @@ function BrowserslistUpdateError(message) {
|
|
|
18
18
|
BrowserslistUpdateError.prototype = Error.prototype
|
|
19
19
|
|
|
20
20
|
// Check if HADOOP_HOME is set to determine if this is running in a Hadoop environment
|
|
21
|
-
const
|
|
22
|
-
const yarnCommand = IsHadoopExists ? 'yarnpkg' : 'yarn'
|
|
21
|
+
const YARN_CMD = process.env.HADOOP_HOME ? 'yarnpkg' : 'yarn'
|
|
23
22
|
|
|
24
23
|
/* c8 ignore next 3 */
|
|
25
24
|
function defaultPrint(str) {
|
|
@@ -44,6 +43,7 @@ function detectLockfile() {
|
|
|
44
43
|
let lockfilePnpm = join(packageDir, 'pnpm-lock.yaml')
|
|
45
44
|
let lockfileBun = join(packageDir, 'bun.lock')
|
|
46
45
|
let lockfileBunBinary = join(packageDir, 'bun.lockb')
|
|
46
|
+
let lockfileDeno = join(packageDir, 'deno.lock')
|
|
47
47
|
|
|
48
48
|
if (existsSync(lockfilePnpm)) {
|
|
49
49
|
return { file: lockfilePnpm, mode: 'pnpm' }
|
|
@@ -58,9 +58,11 @@ function detectLockfile() {
|
|
|
58
58
|
return lock
|
|
59
59
|
} else if (existsSync(lockfileShrinkwrap)) {
|
|
60
60
|
return { file: lockfileShrinkwrap, mode: 'npm' }
|
|
61
|
+
} else if (existsSync(lockfileDeno)) {
|
|
62
|
+
return { file: lockfileDeno, mode: 'deno' }
|
|
61
63
|
}
|
|
62
64
|
throw new BrowserslistUpdateError(
|
|
63
|
-
'No lockfile found. Run "npm install", "yarn install" or "
|
|
65
|
+
'No lockfile found. Run "npm install", "yarn install", "pnpm install", "bun install" or "deno install"'
|
|
64
66
|
)
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -68,11 +70,11 @@ function getLatestInfo(lock) {
|
|
|
68
70
|
if (lock.mode === 'yarn') {
|
|
69
71
|
if (lock.version === 1) {
|
|
70
72
|
return JSON.parse(
|
|
71
|
-
execSync(
|
|
73
|
+
execSync(YARN_CMD + ' info caniuse-lite --json').toString()
|
|
72
74
|
).data
|
|
73
75
|
} else {
|
|
74
76
|
return JSON.parse(
|
|
75
|
-
execSync(
|
|
77
|
+
execSync(YARN_CMD + ' npm info caniuse-lite --json').toString()
|
|
76
78
|
)
|
|
77
79
|
}
|
|
78
80
|
}
|
|
@@ -80,8 +82,13 @@ function getLatestInfo(lock) {
|
|
|
80
82
|
return JSON.parse(execSync('pnpm info caniuse-lite --json').toString())
|
|
81
83
|
}
|
|
82
84
|
if (lock.mode === 'bun') {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
return JSON.parse(execSync(' bun info caniuse-lite --json').toString())
|
|
86
|
+
}
|
|
87
|
+
if (lock.mode === 'deno') {
|
|
88
|
+
let result = JSON.parse(
|
|
89
|
+
execSync('deno x -y npm:npm show caniuse-lite version --json').toString()
|
|
90
|
+
)
|
|
91
|
+
return { version: Array.isArray(result) ? result[0] : result }
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
return JSON.parse(execSync('npm show caniuse-lite --json').toString())
|
|
@@ -224,7 +231,7 @@ function updatePackageManually(print, lock, latest) {
|
|
|
224
231
|
writeFileSync(lock.file, lockfileData.content)
|
|
225
232
|
|
|
226
233
|
let install =
|
|
227
|
-
lock.mode === 'yarn' ?
|
|
234
|
+
lock.mode === 'yarn' ? YARN_CMD + ' add -W' : lock.mode + ' install'
|
|
228
235
|
print(
|
|
229
236
|
'Installing new caniuse-lite version\n' +
|
|
230
237
|
pico.yellow('$ ' + install + ' caniuse-lite baseline-browser-mapping') +
|
|
@@ -248,7 +255,7 @@ function updatePackageManually(print, lock, latest) {
|
|
|
248
255
|
} /* c8 ignore end */
|
|
249
256
|
|
|
250
257
|
let del =
|
|
251
|
-
lock.mode === 'yarn' ?
|
|
258
|
+
lock.mode === 'yarn' ? YARN_CMD + ' remove -W' : lock.mode + ' uninstall'
|
|
252
259
|
print(
|
|
253
260
|
'Cleaning package.json dependencies from caniuse-lite\n' +
|
|
254
261
|
pico.yellow('$ ' + del + ' caniuse-lite baseline-browser-mapping') +
|
|
@@ -257,8 +264,8 @@ function updatePackageManually(print, lock, latest) {
|
|
|
257
264
|
execSync(del + ' caniuse-lite baseline-browser-mapping')
|
|
258
265
|
}
|
|
259
266
|
|
|
260
|
-
function updateWith(print, cmd) {
|
|
261
|
-
print(
|
|
267
|
+
function updateWith(print, cmd, message = 'Updating caniuse-lite version') {
|
|
268
|
+
print(message + '\n' + pico.yellow('$ ' + cmd) + '\n')
|
|
262
269
|
try {
|
|
263
270
|
execSync(cmd)
|
|
264
271
|
} catch (e) /* c8 ignore start */ {
|
|
@@ -293,10 +300,7 @@ module.exports = function updateDB(print = defaultPrint) {
|
|
|
293
300
|
print('Latest version: ' + pico.bold(pico.green(latest.version)) + '\n')
|
|
294
301
|
|
|
295
302
|
if (lock.mode === 'yarn' && lock.version !== 1) {
|
|
296
|
-
updateWith(
|
|
297
|
-
print,
|
|
298
|
-
yarnCommand + ' up -R caniuse-lite baseline-browser-mapping'
|
|
299
|
-
)
|
|
303
|
+
updateWith(print, YARN_CMD + ' up -R caniuse-lite baseline-browser-mapping')
|
|
300
304
|
} else if (lock.mode === 'pnpm') {
|
|
301
305
|
let lockContent = readFileSync(lock.file).toString()
|
|
302
306
|
let packages = lockContent.includes('baseline-browser-mapping')
|
|
@@ -305,6 +309,13 @@ module.exports = function updateDB(print = defaultPrint) {
|
|
|
305
309
|
updateWith(print, 'pnpm up --depth=Infinity --no-save ' + packages)
|
|
306
310
|
} else if (lock.mode === 'bun') {
|
|
307
311
|
updateWith(print, 'bun update caniuse-lite baseline-browser-mapping')
|
|
312
|
+
} else if (lock.mode === 'deno') {
|
|
313
|
+
updateWith(print, 'deno add npm:caniuse-lite npm:baseline-browser-mapping')
|
|
314
|
+
updateWith(
|
|
315
|
+
print,
|
|
316
|
+
'deno remove caniuse-lite baseline-browser-mapping',
|
|
317
|
+
'Cleaning package.json dependencies from caniuse-lite'
|
|
318
|
+
)
|
|
308
319
|
} else {
|
|
309
320
|
updatePackageManually(print, lock, latest)
|
|
310
321
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "update-browserslist-db",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "CLI tool to update caniuse-lite to refresh target browsers from Browserslist config",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"caniuse",
|
|
7
6
|
"browsers",
|
|
7
|
+
"caniuse",
|
|
8
8
|
"target"
|
|
9
9
|
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"author": "Andrey Sitnik <andrey@sitnik.es>",
|
|
12
|
+
"repository": "browserslist/update-db",
|
|
10
13
|
"funding": [
|
|
11
14
|
{
|
|
12
15
|
"type": "opencollective",
|
|
@@ -21,9 +24,7 @@
|
|
|
21
24
|
"url": "https://github.com/sponsors/ai"
|
|
22
25
|
}
|
|
23
26
|
],
|
|
24
|
-
"
|
|
25
|
-
"license": "MIT",
|
|
26
|
-
"repository": "browserslist/update-db",
|
|
27
|
+
"bin": "cli.js",
|
|
27
28
|
"types": "./index.d.ts",
|
|
28
29
|
"exports": {
|
|
29
30
|
".": "./index.js",
|
|
@@ -35,6 +36,5 @@
|
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
38
|
"browserslist": ">= 4.21.0"
|
|
38
|
-
}
|
|
39
|
-
"bin": "cli.js"
|
|
39
|
+
}
|
|
40
40
|
}
|
package/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { EOL } = require('os')
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function getFirstRegexpMatchOrDefault(text, regexp, defaultValue) {
|
|
4
4
|
regexp.lastIndex = 0 // https://stackoverflow.com/a/11477448/4536543
|
|
5
5
|
let match = regexp.exec(text)
|
|
6
6
|
if (match !== null) {
|