feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -44,6 +44,8 @@ module.exports = {
findConfig: noop,
findConfigFile: noop,
clearCaches: noop,
oldDataWarning: noop,

2
node_modules/browserslist/cli.js generated vendored
View File

@@ -1,7 +1,7 @@
#!/usr/bin/env node
var updateDb = require('update-browserslist-db')
var fs = require('fs')
var updateDb = require('update-browserslist-db')
var browserslist = require('./')
var pkg = require('./package.json')

27
node_modules/browserslist/index.d.ts generated vendored
View File

@@ -166,6 +166,17 @@ declare namespace browserslist {
opts?: browserslist.Options
): Query[]
/**
* Return queries for specific file inside the project.
*
* ```js
* browserslist.loadConfig({
* file: process.cwd()
* }) ?? browserslist.defaults
* ```
*/
function loadConfig(options: LoadConfigOptions): string[] | undefined
function clearCaches(): void
function parseConfig(string: string): Config
@@ -174,13 +185,25 @@ declare namespace browserslist {
function findConfig(...pathSegments: string[]): Config | undefined
function findConfigFile(...pathSegments: string[]): string | undefined
interface LoadConfigOptions {
/**
* Path to config file
* */
config?: string
/**
* Path to file inside the project to find Browserslist config
* in closest folder
*/
path?: string
/**
* Environment to choose part of config.
*/
env?: string
}
function loadConfig(options: LoadConfigOptions): string[] | undefined
}
declare global {

7
node_modules/browserslist/index.js generated vendored
View File

@@ -1,12 +1,12 @@
var jsReleases = require('node-releases/data/processed/envs.json')
var agents = require('caniuse-lite/dist/unpacker/agents').agents
var e2c = require('electron-to-chromium/versions')
var jsEOL = require('node-releases/data/release-schedule/release-schedule.json')
var path = require('path')
var e2c = require('electron-to-chromium/versions')
var BrowserslistError = require('./error')
var parse = require('./parse')
var env = require('./node') // Will load browser.js in webpack
var env = require('./node')
var parse = require('./parse') // Will load browser.js in webpack
var YEAR = 365.259641 * 24 * 60 * 60 * 1000
var ANDROID_EVERGREEN_FIRST = '37'
@@ -491,6 +491,7 @@ browserslist.versionAliases = {}
browserslist.clearCaches = env.clearCaches
browserslist.parseConfig = env.parseConfig
browserslist.readConfig = env.readConfig
browserslist.findConfigFile = env.findConfigFile
browserslist.findConfig = env.findConfig
browserslist.loadConfig = env.loadConfig

79
node_modules/browserslist/node.js generated vendored
View File

@@ -1,14 +1,13 @@
var feature = require('caniuse-lite/dist/unpacker/feature').default
var region = require('caniuse-lite/dist/unpacker/region').default
var path = require('path')
var fs = require('fs')
var path = require('path')
var BrowserslistError = require('./error')
var IS_SECTION = /^\s*\[(.+)]\s*$/
var 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'
@@ -126,6 +125,14 @@ function parsePackage(file) {
return list
}
function parsePackageOrReadConfig(file) {
if (path.basename(file) === 'package.json') {
return parsePackage(file)
} else {
return module.exports.readConfig(file)
}
}
function latestReleaseTime(agents) {
var latest = 0
for (var name in agents) {
@@ -139,6 +146,16 @@ function latestReleaseTime(agents) {
return latest * 1000
}
function getMonthsPassed(date) {
var now = new Date()
var past = new Date(date)
var years = now.getFullYear() - past.getFullYear()
var months = now.getMonth() - past.getMonth()
return years * 12 + months
}
function normalizeStats(data, stats) {
if (!data) {
data = {}
@@ -237,11 +254,7 @@ module.exports = {
return process.env.BROWSERSLIST
} else if (opts.config || process.env.BROWSERSLIST_CONFIG) {
var file = opts.config || process.env.BROWSERSLIST_CONFIG
if (path.basename(file) === 'package.json') {
return pickEnv(parsePackage(file), opts)
} else {
return pickEnv(module.exports.readConfig(file), opts)
}
return pickEnv(parsePackageOrReadConfig(file), opts)
} else if (opts.path) {
return pickEnv(module.exports.findConfig(opts.path), opts)
} else {
@@ -330,17 +343,8 @@ module.exports = {
return module.exports.parseConfig(fs.readFileSync(file))
},
findConfig: function findConfig(from) {
from = path.resolve(from)
var passed = []
findConfigFile: function findConfigFile(from) {
var resolved = eachParent(from, function (dir) {
if (dir in configCache) {
return configCache[dir]
}
passed.push(dir)
var config = path.join(dir, 'browserslist')
var pkg = path.join(dir, 'package.json')
var rc = path.join(dir, '.browserslistrc')
@@ -370,16 +374,38 @@ module.exports = {
dir + ' contains both .browserslistrc and browserslist'
)
} else if (isFile(config)) {
return module.exports.readConfig(config)
return config
} else if (isFile(rc)) {
return module.exports.readConfig(rc)
} else {
return pkgBrowserslist
return rc
} else if (pkgBrowserslist) {
return pkg
}
})
return resolved
},
findConfig: function findConfig(from) {
from = path.resolve(from)
var fromDir = isFile(from) ? path.dirname(from) : from
if (fromDir in configCache) {
return configCache[fromDir]
}
var resolved
var configFile = this.findConfigFile(from)
if (configFile) {
resolved = parsePackageOrReadConfig(configFile)
}
if (!process.env.BROWSERSLIST_DISABLE_CACHE) {
passed.forEach(function (dir) {
var configDir = configFile && path.dirname(configFile)
eachParent(from, function (dir) {
configCache[dir] = resolved
if (dir === configDir) {
return null
}
})
}
return resolved
@@ -399,11 +425,14 @@ module.exports = {
if (process.env.BROWSERSLIST_IGNORE_OLD_DATA) return
var latest = latestReleaseTime(agentsObj)
var halfYearAgo = Date.now() - TIME_TO_UPDATE_CANIUSE
var monthsPassed = getMonthsPassed(latest)
if (latest !== 0 && latest < halfYearAgo) {
if (latest !== 0 && monthsPassed >= 6) {
var months = monthsPassed + ' ' + (monthsPassed > 1 ? 'months' : 'month')
console.warn(
'Browserslist: caniuse-lite is outdated. Please run:\n' +
'Browserslist: browsers data (caniuse-lite) is ' +
months +
' old. Please run:\n' +
' npx update-browserslist-db@latest\n' +
' Why you should do it regularly: ' +
'https://github.com/browserslist/update-db#readme'

View File

@@ -1,6 +1,6 @@
{
"name": "browserslist",
"version": "4.23.3",
"version": "4.24.2",
"description": "Share target browsers between different front-end tools, like Autoprefixer, Stylelint and babel-env-preset",
"keywords": [
"caniuse",
@@ -25,10 +25,10 @@
"license": "MIT",
"repository": "browserslist/browserslist",
"dependencies": {
"caniuse-lite": "^1.0.30001646",
"electron-to-chromium": "^1.5.4",
"caniuse-lite": "^1.0.30001669",
"electron-to-chromium": "^1.5.41",
"node-releases": "^2.0.18",
"update-browserslist-db": "^1.1.0"
"update-browserslist-db": "^1.1.1"
},
"engines": {
"node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"

2
node_modules/browserslist/parse.js generated vendored
View File

@@ -9,7 +9,7 @@ function flatten(array) {
}
function find(string, predicate) {
for (var n = 1, max = string.length; n <= max; n++) {
for (var max = string.length, n = 1; n <= max; n++) {
var parsed = string.substr(-n, n)
if (predicate(parsed, n, max)) {
return string.slice(0, -n)