browserslist 4.4.2 → 4.5.3

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/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
+ ## 4.5.3
5
+ * Fix splitting string to queries.
6
+
7
+ ## 4.5.2
8
+ * Show default browsers in CLI on project without config.
9
+
10
+ ## 4.5.1
11
+ * Improve text for the warning about outdated `caniuse-lite`.
12
+
13
+ ## 4.5
14
+ * Add `>=`, `>`, and `<=` support for Node.js version (by Mathspy Terabithian).
15
+
4
16
  ## 4.4.2
5
17
  * Allow to have string in `package.json` (by @dmarkhas).
6
18
 
package/README.md CHANGED
@@ -169,7 +169,7 @@ You can specify the browser and Node.js versions by queries (case insensitive):
169
169
  `browserslist-config-mycompany` npm package.
170
170
  * `ie 6-8`: selects an inclusive range of versions.
171
171
  * `Firefox > 20`: versions of Firefox newer than 20.
172
- `>=`, `<` and `<=` work too.
172
+ `>=`, `<` and `<=` work too. It also works with Node.js.
173
173
  * `iOS 7`: the iOS browser version 7 directly.
174
174
  * `Firefox ESR`: the latest [Firefox ESR] version.
175
175
  * `unreleased versions` or `unreleased Chrome versions`:
@@ -556,13 +556,9 @@ To disable the caching altogether, set the `BROWSERSLIST_DISABLE_CACHE`
556
556
  environment variable.
557
557
 
558
558
 
559
- ## Contributors
559
+ ## Security Contact
560
+
561
+ To report a security vulnerability, please use the [Tidelift security contact].
562
+ Tidelift will coordinate the fix and disclosure.
560
563
 
561
- <img src="https://sourcerer.io/fame/ai/browserslist/browserslist/images/0" alt="" width="76" height="90" align="left">
562
- <img src="https://sourcerer.io/fame/ai/browserslist/browserslist/images/1" alt="" width="76" height="90" align="left">
563
- <img src="https://sourcerer.io/fame/ai/browserslist/browserslist/images/2" alt="" width="76" height="90" align="left">
564
- <img src="https://sourcerer.io/fame/ai/browserslist/browserslist/images/3" alt="" width="76" height="90" align="left">
565
- <img src="https://sourcerer.io/fame/ai/browserslist/browserslist/images/4" alt="" width="76" height="90" align="left">
566
- <img src="https://sourcerer.io/fame/ai/browserslist/browserslist/images/5" alt="" width="76" height="90" align="left">
567
- <img src="https://sourcerer.io/fame/ai/browserslist/browserslist/images/6" alt="" width="76" height="90" align="left">
568
- <img src="https://sourcerer.io/fame/ai/browserslist/browserslist/images/7" alt="" width="76" height="90" align="left">
564
+ [Tidelift security contact]: https://tidelift.com/security
package/cli.js CHANGED
@@ -72,17 +72,6 @@ if (isArg('--help') || isArg('-h')) {
72
72
 
73
73
  var browsers
74
74
  try {
75
- if (!queries && !opts.config) {
76
- if (browserslist.findConfig(process.cwd())) {
77
- opts.path = process.cwd()
78
- } else {
79
- error(
80
- 'Browserslist config was not found. ' +
81
- 'Define queries or config path.' +
82
- '\n\n' + USAGE
83
- )
84
- }
85
- }
86
75
  browsers = browserslist(queries, opts)
87
76
  } catch (e) {
88
77
  if (e.name === 'BrowserslistError') {
package/index.js CHANGED
@@ -91,12 +91,51 @@ function generateFilter (sign, version) {
91
91
  }
92
92
  }
93
93
 
94
- function compareStrings (a, b) {
94
+ function generateSemverFilter (sign, version) {
95
+ version = version.split('.').map(parseSimpleInt)
96
+ version[1] = version[1] || 0
97
+ version[2] = version[2] || 0
98
+ if (sign === '>') {
99
+ return function (v) {
100
+ v = v.split('.').map(parseSimpleInt)
101
+ return compareSemver(v, version) > 0
102
+ }
103
+ } else if (sign === '>=') {
104
+ return function (v) {
105
+ v = v.split('.').map(parseSimpleInt)
106
+ return compareSemver(v, version) >= 0
107
+ }
108
+ } else if (sign === '<') {
109
+ return function (v) {
110
+ v = v.split('.').map(parseSimpleInt)
111
+ return compareSemver(version, v) > 0
112
+ }
113
+ } else {
114
+ return function (v) {
115
+ v = v.split('.').map(parseSimpleInt)
116
+ return compareSemver(version, v) >= 0
117
+ }
118
+ }
119
+ }
120
+
121
+ function parseSimpleInt (x) {
122
+ return parseInt(x)
123
+ }
124
+
125
+ function compare (a, b) {
95
126
  if (a < b) return -1
96
127
  if (a > b) return +1
97
128
  return 0
98
129
  }
99
130
 
131
+ function compareSemver (a, b) {
132
+ return (
133
+ compare(a[0], b[0]) ||
134
+ compare(a[1], b[1]) ||
135
+ compare(a[2], b[2])
136
+ )
137
+ }
138
+
100
139
  function normalizeVersion (data, version) {
101
140
  if (data.versions.indexOf(version) !== -1) {
102
141
  return version
@@ -282,10 +321,10 @@ function browserslist (queries, opts) {
282
321
  if (FLOAT_RANGE.test(name1[1]) && FLOAT_RANGE.test(name2[1])) {
283
322
  return parseFloat(name2[1]) - parseFloat(name1[1])
284
323
  } else {
285
- return compareStrings(name2[1], name1[1])
324
+ return compare(name2[1], name1[1])
286
325
  }
287
326
  } else {
288
- return compareStrings(name1[0], name2[0])
327
+ return compare(name1[0], name2[0])
289
328
  }
290
329
  })
291
330
 
@@ -325,29 +364,26 @@ function doMatch (string, qs) {
325
364
  var or = /^(?:,\s*|\s+OR\s+)(.*)/i
326
365
  var and = /^\s+AND\s+(.*)/i
327
366
 
328
- return find(
329
- string,
330
- function (parsed, n, max) {
331
- if (and.test(parsed)) {
332
- qs.unshift({ type: QUERY_AND, queryString: parsed.match(and)[1] })
333
- return true
334
- } else if (or.test(parsed)) {
335
- qs.unshift({ type: QUERY_OR, queryString: parsed.match(or)[1] })
336
- return true
337
- } else if (n === max) {
338
- qs.unshift({ type: QUERY_OR, queryString: parsed.trim() })
339
- return true
340
- }
341
- return false
367
+ return find(string, function (parsed, n, max) {
368
+ if (and.test(parsed)) {
369
+ qs.unshift({ type: QUERY_AND, queryString: parsed.match(and)[1] })
370
+ return true
371
+ } else if (or.test(parsed)) {
372
+ qs.unshift({ type: QUERY_OR, queryString: parsed.match(or)[1] })
373
+ return true
374
+ } else if (n === max) {
375
+ qs.unshift({ type: QUERY_OR, queryString: parsed.trim() })
376
+ return true
342
377
  }
343
- )
378
+ return false
379
+ })
344
380
  }
345
381
 
346
382
  function find (string, predicate) {
347
383
  for (var n = 1, max = string.length; n <= max; n++) {
348
384
  var parsed = string.substr(-n, n)
349
385
  if (predicate(parsed, n, max)) {
350
- return string.replace(parsed, '')
386
+ return string.slice(0, -n)
351
387
  }
352
388
  }
353
389
  return ''
@@ -745,6 +781,21 @@ var QUERIES = [
745
781
  })
746
782
  }
747
783
  },
784
+ {
785
+ regexp: /^node\s*(>=?|<=?)\s*([\d.]+)$/,
786
+ select: function (context, sign, version) {
787
+ var nodeVersions = jsReleases.filter(function (i) {
788
+ return i.name === 'nodejs'
789
+ }).map(function (i) {
790
+ return i.version
791
+ })
792
+ return nodeVersions
793
+ .filter(generateSemverFilter(sign, version))
794
+ .map(function (v) {
795
+ return 'node ' + v
796
+ })
797
+ }
798
+ },
748
799
  {
749
800
  regexp: /^(\w+)\s*(>=?|<=?)\s*([\d.]+)$/,
750
801
  select: function (context, name, sign, version) {
package/node.js CHANGED
@@ -306,7 +306,8 @@ module.exports = {
306
306
  })
307
307
  console.warn(
308
308
  'Browserslist: caniuse-lite is outdated. ' +
309
- 'Please run next command `' + command + ' caniuse-lite browserslist`')
309
+ 'Please run next command `' + command + '`'
310
+ )
310
311
  }
311
312
  },
312
313
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserslist",
3
- "version": "4.4.2",
3
+ "version": "4.5.3",
4
4
  "description": "Share target browsers between different front-end tools, like Autoprefixer, Stylelint and babel-env-preset",
5
5
  "keywords": [
6
6
  "caniuse",
@@ -11,9 +11,9 @@
11
11
  "license": "MIT",
12
12
  "repository": "browserslist/browserslist",
13
13
  "dependencies": {
14
- "caniuse-lite": "^1.0.30000939",
15
- "electron-to-chromium": "^1.3.113",
16
- "node-releases": "^1.1.8"
14
+ "caniuse-lite": "^1.0.30000955",
15
+ "electron-to-chromium": "^1.3.122",
16
+ "node-releases": "^1.1.12"
17
17
  },
18
18
  "bin": "./cli.js",
19
19
  "browser": {