nav tabs on admin dashboard
This commit is contained in:
127
node_modules/browserslist/node.js
generated
vendored
127
node_modules/browserslist/node.js
generated
vendored
@@ -1,3 +1,4 @@
|
||||
var region = require('caniuse-lite/dist/unpacker/region').default
|
||||
var path = require('path')
|
||||
var fs = require('fs')
|
||||
|
||||
@@ -5,18 +6,21 @@ var BrowserslistError = require('./error')
|
||||
|
||||
var IS_SECTION = /^\s*\[(.+)\]\s*$/
|
||||
var CONFIG_PATTERN = /^browserslist-config-/
|
||||
var SCOPED_CONFIG__PATTERN = /@[^./]+\/browserslist-config(-|$)/
|
||||
var SCOPED_CONFIG__PATTERN = /@[^/]+\/browserslist-config(-|$|\/)/
|
||||
var TIME_TO_UPDATE_CANIUSE = 6 * 30 * 24 * 60 * 60 * 1000
|
||||
var FORMAT = 'Browserslist config should be a string or an array ' +
|
||||
'of strings with browser queries'
|
||||
|
||||
var dataTimeChecked = false
|
||||
var filenessCache = { }
|
||||
var configCache = { }
|
||||
|
||||
function checkExtend (name) {
|
||||
var use = ' Use `dangerousExtend` option to disable.'
|
||||
if (!CONFIG_PATTERN.test(name) && !SCOPED_CONFIG__PATTERN.test(name)) {
|
||||
throw new BrowserslistError(
|
||||
'Browserslist config needs `browserslist-config-` prefix. ' + use)
|
||||
}
|
||||
if (name.indexOf('.') !== -1) {
|
||||
if (name.replace(/^@[^/]+\//, '').indexOf('.') !== -1) {
|
||||
throw new BrowserslistError(
|
||||
'`.` not allowed in Browserslist config name. ' + use)
|
||||
}
|
||||
@@ -46,6 +50,18 @@ function eachParent (file, callback) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
function check (section) {
|
||||
if (Array.isArray(section)) {
|
||||
for (var i = 0; i < section.length; i++) {
|
||||
if (typeof section[i] !== 'string') {
|
||||
throw new BrowserslistError(FORMAT)
|
||||
}
|
||||
}
|
||||
} else if (typeof section !== 'string') {
|
||||
throw new BrowserslistError(FORMAT)
|
||||
}
|
||||
}
|
||||
|
||||
function pickEnv (config, opts) {
|
||||
if (typeof config !== 'object') return config
|
||||
|
||||
@@ -57,7 +73,7 @@ function pickEnv (config, opts) {
|
||||
} else if (process.env.NODE_ENV) {
|
||||
name = process.env.NODE_ENV
|
||||
} else {
|
||||
name = 'development'
|
||||
name = 'production'
|
||||
}
|
||||
|
||||
return config[name] || config.defaults
|
||||
@@ -70,17 +86,34 @@ function parsePackage (file) {
|
||||
'`browserlist` key instead of `browserslist` in ' + file)
|
||||
}
|
||||
var list = config.browserslist
|
||||
if (typeof list === 'object' && list.length) {
|
||||
if (Array.isArray(list) || typeof list === 'string') {
|
||||
list = { defaults: list }
|
||||
}
|
||||
for (var i in list) {
|
||||
check(list[i])
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
function latestReleaseTime (agents) {
|
||||
var latest = 0
|
||||
for (var name in agents) {
|
||||
var dates = agents[name].releaseDate || { }
|
||||
for (var key in dates) {
|
||||
if (latest < dates[key]) {
|
||||
latest = dates[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
return latest * 1000
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
loadQueries: function loadQueries (context, name) {
|
||||
if (!context.dangerousExtend) checkExtend(name)
|
||||
// eslint-disable-next-line security/detect-non-literal-require
|
||||
var queries = require(name)
|
||||
var queries = require(require.resolve(name, { paths: ['.'] }))
|
||||
if (!Array.isArray(queries)) {
|
||||
throw new BrowserslistError(
|
||||
'`' + name + '` config exports not an array of queries')
|
||||
@@ -88,7 +121,7 @@ module.exports = {
|
||||
return queries
|
||||
},
|
||||
|
||||
getStat: function getStat (opts) {
|
||||
getStat: function getStat (opts, data) {
|
||||
var stats
|
||||
if (opts.stats) {
|
||||
stats = opts.stats
|
||||
@@ -109,7 +142,25 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
return stats
|
||||
if (stats && 'dataByBrowser' in stats) {
|
||||
stats = stats.dataByBrowser
|
||||
}
|
||||
|
||||
if (typeof stats !== 'object') return undefined
|
||||
|
||||
var normalized = { }
|
||||
for (var i in stats) {
|
||||
var versions = Object.keys(stats[i])
|
||||
if (versions.length === 1 && data[i] && data[i].versions.length === 1) {
|
||||
var normal = Object.keys(data[i].versions)[0]
|
||||
normalized[i] = { }
|
||||
normalized[i][normal] = stats[i][versions[0]]
|
||||
} else {
|
||||
normalized[i] = stats[i]
|
||||
}
|
||||
}
|
||||
|
||||
return normalized
|
||||
},
|
||||
|
||||
loadConfig: function loadConfig (opts) {
|
||||
@@ -129,13 +180,28 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
loadCountry: function loadCountry (usage, country) {
|
||||
var code = country.replace(/[^\w-]/g, '')
|
||||
if (!usage[code]) {
|
||||
// eslint-disable-next-line security/detect-non-literal-require
|
||||
var compressed = require('caniuse-lite/data/regions/' + code + '.js')
|
||||
var data = region(compressed)
|
||||
usage[country] = { }
|
||||
for (var i in data) {
|
||||
for (var j in data[i]) {
|
||||
usage[country][i + ' ' + j] = data[i][j]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
parseConfig: function parseConfig (string) {
|
||||
var result = { defaults: [] }
|
||||
var section = 'defaults'
|
||||
var sections = ['defaults']
|
||||
|
||||
string.toString()
|
||||
.replace(/#[^\n]*/g, '')
|
||||
.split(/\n/)
|
||||
.split(/\n|,/)
|
||||
.map(function (line) {
|
||||
return line.trim()
|
||||
})
|
||||
@@ -144,10 +210,18 @@ module.exports = {
|
||||
})
|
||||
.forEach(function (line) {
|
||||
if (IS_SECTION.test(line)) {
|
||||
section = line.match(IS_SECTION)[1].trim()
|
||||
result[section] = result[section] || []
|
||||
sections = line.match(IS_SECTION)[1].trim().split(' ')
|
||||
sections.forEach(function (section) {
|
||||
if (result[section]) {
|
||||
throw new BrowserslistError(
|
||||
'Duplicate section ' + section + ' in Browserslist config')
|
||||
}
|
||||
result[section] = []
|
||||
})
|
||||
} else {
|
||||
result[section].push(line)
|
||||
sections.forEach(function (section) {
|
||||
result[section].push(line)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -209,7 +283,34 @@ module.exports = {
|
||||
},
|
||||
|
||||
clearCaches: function clearCaches () {
|
||||
dataTimeChecked = false
|
||||
filenessCache = { }
|
||||
configCache = { }
|
||||
},
|
||||
|
||||
oldDataWarning: function oldDataWarning (agentsObj) {
|
||||
if (dataTimeChecked) return
|
||||
dataTimeChecked = true
|
||||
|
||||
var latest = latestReleaseTime(agentsObj)
|
||||
var halfYearAgo = Date.now() - TIME_TO_UPDATE_CANIUSE
|
||||
|
||||
if (latest !== 0 && latest < halfYearAgo) {
|
||||
var command = 'npm update'
|
||||
eachParent(__filename, function (dir) {
|
||||
var pckg = path.join(dir, 'package.json')
|
||||
var yarnLock = path.join(dir, 'yarn.lock')
|
||||
if (isFile(pckg) && isFile(yarnLock)) {
|
||||
command = 'yarn upgrade'
|
||||
}
|
||||
})
|
||||
console.warn(
|
||||
'Browserslist: caniuse-lite is outdated. ' +
|
||||
'Please run next command `' + command + ' caniuse-lite browserslist`')
|
||||
}
|
||||
},
|
||||
|
||||
currentNode: function currentNode () {
|
||||
return 'node ' + process.versions.node
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user