browserslist 4.4.1 → 4.5.2

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.2
5
+ * Show default browsers in CLI on project without config.
6
+
7
+ ## 4.5.1
8
+ * Improve text for the warning about outdated `caniuse-lite`.
9
+
10
+ ## 4.5
11
+ * Add `>=`, `>`, and `<=` support for Node.js version (by Mathspy Terabithian).
12
+
13
+ ## 4.4.2
14
+ * Allow to have string in `package.json` (by @dmarkhas).
15
+
4
16
  ## 4.4.1
5
17
  * Allow to use `.` in scope name of shareable config (by Gustav Nikolaj).
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`:
@@ -219,6 +219,7 @@ samsung 5
219
219
 
220
220
  Browserslist works with separated versions of browsers.
221
221
  You should avoid queries like `Firefox > 0`.
222
+ The list of the specified browsers acts as a white list which means other browsers are ignored.
222
223
 
223
224
  All queries are based on the [Can I Use] support table,
224
225
  e.g. `last 3 iOS versions` might select `8.4, 9.2, 9.3` (mixed major and minor),
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
 
@@ -745,6 +784,21 @@ var QUERIES = [
745
784
  })
746
785
  }
747
786
  },
787
+ {
788
+ regexp: /^node\s*(>=?|<=?)\s*([\d.]+)$/,
789
+ select: function (context, sign, version) {
790
+ var nodeVersions = jsReleases.filter(function (i) {
791
+ return i.name === 'nodejs'
792
+ }).map(function (i) {
793
+ return i.version
794
+ })
795
+ return nodeVersions
796
+ .filter(generateSemverFilter(sign, version))
797
+ .map(function (v) {
798
+ return 'node ' + v
799
+ })
800
+ }
801
+ },
748
802
  {
749
803
  regexp: /^(\w+)\s*(>=?|<=?)\s*([\d.]+)$/,
750
804
  select: function (context, name, sign, version) {
package/node.js CHANGED
@@ -86,10 +86,9 @@ function parsePackage (file) {
86
86
  '`browserlist` key instead of `browserslist` in ' + file)
87
87
  }
88
88
  var list = config.browserslist
89
- if (Array.isArray(list)) {
89
+ if (Array.isArray(list) || typeof list === 'string') {
90
90
  list = { defaults: list }
91
91
  }
92
-
93
92
  for (var i in list) {
94
93
  check(list[i])
95
94
  }
@@ -307,7 +306,8 @@ module.exports = {
307
306
  })
308
307
  console.warn(
309
308
  'Browserslist: caniuse-lite is outdated. ' +
310
- 'Please run next command `' + command + ' caniuse-lite browserslist`')
309
+ 'Please run next command `' + command + '`'
310
+ )
311
311
  }
312
312
  },
313
313
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserslist",
3
- "version": "4.4.1",
3
+ "version": "4.5.2",
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.30000929",
15
- "electron-to-chromium": "^1.3.103",
16
- "node-releases": "^1.1.3"
14
+ "caniuse-lite": "^1.0.30000951",
15
+ "electron-to-chromium": "^1.3.116",
16
+ "node-releases": "^1.1.11"
17
17
  },
18
18
  "bin": "./cli.js",
19
19
  "browser": {