browserslist 4.14.6 → 4.14.7

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,8 +1,14 @@
1
1
  # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
+ ## 4.14.7
5
+ * Fixed Yarn Workspaces support to `--update-db` (by Fausto Núñez Alberro).
6
+ * Added browser changes to `--update-db` (by @AleksandrSl).
7
+ * Added color output to `--update-db`.
8
+ * Updated `package.funding` to have link to our Open Collective.
9
+
4
10
  ## 4.14.6
5
- * Fixed Yarn support n `--update-db` (by Ivan Storck).
11
+ * Fixed Yarn support in `--update-db` (by Ivan Storck).
6
12
  * Fixed npm 7 support in `--update-db`.
7
13
 
8
14
  ## 4.14.5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserslist",
3
- "version": "4.14.6",
3
+ "version": "4.14.7",
4
4
  "description": "Share target browsers between different front-end tools, like Autoprefixer, Stylelint and babel-env-preset",
5
5
  "keywords": [
6
6
  "caniuse",
@@ -8,17 +8,18 @@
8
8
  "target"
9
9
  ],
10
10
  "funding": {
11
- "type": "tidelift",
12
- "url": "https://tidelift.com/funding/github/npm/browserslist"
11
+ "type": "opencollective",
12
+ "url": "https://opencollective.com/browserslist"
13
13
  },
14
14
  "author": "Andrey Sitnik <andrey@sitnik.ru>",
15
15
  "license": "MIT",
16
16
  "repository": "browserslist/browserslist",
17
17
  "dependencies": {
18
- "caniuse-lite": "^1.0.30001154",
19
- "electron-to-chromium": "^1.3.585",
18
+ "caniuse-lite": "^1.0.30001157",
19
+ "colorette": "^1.2.1",
20
+ "electron-to-chromium": "^1.3.591",
20
21
  "escalade": "^3.1.1",
21
- "node-releases": "^1.1.65"
22
+ "node-releases": "^1.1.66"
22
23
  },
23
24
  "engines": {
24
25
  "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
package/update-db.js CHANGED
@@ -1,10 +1,16 @@
1
1
  var childProcess = require('child_process')
2
+ var colorette = require('colorette')
2
3
  var escalade = require('escalade/sync')
3
4
  var path = require('path')
4
5
  var fs = require('fs')
5
6
 
6
7
  var BrowserslistError = require('./error')
7
8
 
9
+ var red = colorette.red
10
+ var bold = colorette.bold
11
+ var green = colorette.green
12
+ var yellow = colorette.yellow
13
+
8
14
  function detectLockfile () {
9
15
  var packageDir = escalade('.', function (dir, names) {
10
16
  return names.indexOf('package.json') !== -1 ? dir : ''
@@ -65,6 +71,52 @@ function getLatestInfo (lock) {
65
71
  }
66
72
  }
67
73
 
74
+ function getBrowsersList () {
75
+ return childProcess.execSync('npx browserslist').toString()
76
+ .trim()
77
+ .split('\n')
78
+ .map(function (line) {
79
+ return line.trim().split(' ')
80
+ })
81
+ .reduce(function (result, entry) {
82
+ if (!result[entry[0]]) {
83
+ result[entry[0]] = []
84
+ }
85
+ result[entry[0]].push(entry[1])
86
+ return result
87
+ }, {})
88
+ }
89
+
90
+ function diffBrowsersLists (old, current) {
91
+ var browsers = Object.keys(old).concat(
92
+ Object.keys(current).filter(function (browser) {
93
+ return old[browser] === undefined
94
+ })
95
+ )
96
+ return browsers.map(function (browser) {
97
+ var oldVersions = old[browser] || []
98
+ var currentVersions = current[browser] || []
99
+ var intersection = oldVersions.filter(function (version) {
100
+ return currentVersions.indexOf(version) !== -1
101
+ })
102
+ var addedVersions = currentVersions.filter(function (version) {
103
+ return intersection.indexOf(version) === -1
104
+ })
105
+ var removedVersions = oldVersions.filter(function (version) {
106
+ return intersection.indexOf(version) === -1
107
+ })
108
+ return removedVersions.map(function (version) {
109
+ return red('- ' + browser + ' ' + version)
110
+ }).concat(addedVersions.map(function (version) {
111
+ return green('+ ' + browser + ' ' + version)
112
+ }))
113
+ })
114
+ .reduce(function (result, array) {
115
+ return result.concat(array)
116
+ }, [])
117
+ .join('\n')
118
+ }
119
+
68
120
  function updateLockfile (lock, latest) {
69
121
  if (lock.mode === 'npm') {
70
122
  var fixed = deletePackage(JSON.parse(lock.content))
@@ -126,36 +178,80 @@ module.exports = function updateDB (print) {
126
178
 
127
179
  var current = getCurrentVersion(lock)
128
180
  var latest = getLatestInfo(lock)
181
+ var browsersListRetrievalError
182
+ var oldBrowsersList
183
+ try {
184
+ oldBrowsersList = getBrowsersList()
185
+ } catch (e) {
186
+ browsersListRetrievalError = e
187
+ }
129
188
 
130
189
  if (typeof current === 'string') {
131
- print('Current version: ' + current + '\n')
190
+ print('Current version: ' + bold(red(current)) + '\n')
132
191
  }
133
192
  print(
134
- 'New version: ' + latest.version + '\n' +
193
+ 'New version: ' + bold(green(latest.version)) + '\n' +
135
194
  'Removing old caniuse-lite from lock file\n'
136
195
  )
137
196
 
138
197
  fs.writeFileSync(lock.file, updateLockfile(lock, latest))
139
198
 
140
- var install = lock.mode === 'yarn' ? 'yarn add' : lock.mode + ' install'
199
+ var install = lock.mode === 'yarn' ? 'yarn add -W' : lock.mode + ' install'
141
200
  print(
142
201
  'Installing new caniuse-lite version\n' +
143
- '$ ' + install + ' caniuse-lite\n'
202
+ yellow('$ ' + install + ' caniuse-lite') + '\n'
144
203
  )
145
204
  try {
146
205
  childProcess.execSync(install + ' caniuse-lite')
147
206
  } catch (e) /* istanbul ignore next */ {
148
- print(e.stack)
149
- print('\nProblem with `' + lock.mode + ' install` call. Run it manually.\n')
207
+ print(
208
+ red(
209
+ '\n' +
210
+ e.stack + '\n\n' +
211
+ 'Problem with `' + install + ' caniuse-lite` call. ' +
212
+ 'Run it manually.\n'
213
+ )
214
+ )
150
215
  process.exit(1)
151
216
  }
152
217
 
153
- var del = lock.mode === 'yarn' ? 'yarn remove' : lock.mode + ' uninstall'
218
+ var del = lock.mode === 'yarn' ? 'yarn remove -W' : lock.mode + ' uninstall'
154
219
  print(
155
220
  'Cleaning package.json dependencies from caniuse-lite\n' +
156
- '$ ' + del + ' caniuse-lite\n'
221
+ yellow('$ ' + del + ' caniuse-lite') + '\n'
157
222
  )
158
223
  childProcess.execSync(del + ' caniuse-lite')
159
224
 
160
225
  print('caniuse-lite has been successfully updated\n')
226
+
227
+ var currentBrowsersList
228
+ if (!browsersListRetrievalError) {
229
+ try {
230
+ currentBrowsersList = getBrowsersList()
231
+ } catch (e) /* istanbul ignore next */ {
232
+ browsersListRetrievalError = e
233
+ }
234
+ }
235
+
236
+ if (browsersListRetrievalError) {
237
+ print(
238
+ red(
239
+ '\n' +
240
+ browsersListRetrievalError.stack + '\n\n' +
241
+ 'Problem with browsers list retrieval.\n' +
242
+ 'Target browser changes won’t be shown.\n'
243
+ )
244
+ )
245
+ } else {
246
+ var targetBrowserChanges = diffBrowsersLists(
247
+ oldBrowsersList,
248
+ currentBrowsersList
249
+ )
250
+ if (targetBrowserChanges) {
251
+ print('\nTarget browser changes:\n')
252
+ print(targetBrowserChanges + '\n')
253
+ } else {
254
+ print('\n' + green('No target browser changes') + '\n')
255
+ }
256
+ }
161
257
  }