baseline-browser-mapping
Advanced tools
| #!/usr/bin/env node | ||
| "use strict";const{getCompatibleVersions:e}=require("./index.cjs"),a=process.argv.slice(2),s={};for(let e=0;e<a.length;e++){const r=a[e];r&&("-h"===r||"--help"===r?s.help=!0:"--include-downstream-browsers"===r?s["include-downstream-browsers"]=!0:"--list-all-compatible-versions"===r?s["list-all-compatible-versions"]=!0:"--include-kaios"===r?s["include-kaios"]=!0:"--suppress-warnings"===r?s["suppress-warnings"]=!0:r.startsWith("--target-year=")?s["target-year"]=r.substring(14):"--target-year"===r?s["target-year"]=a[++e]:r.startsWith("--widely-available-on-date=")?s["widely-available-on-date"]=r.substring(27):"--widely-available-on-date"===r?s["widely-available-on-date"]=a[++e]:r.startsWith("--override-last-updated=")?s["override-last-updated"]=r.substring(24):"--override-last-updated"===r?s["override-last-updated"]=a[++e]:(console.error(`Unknown argument: ${r}`),process.exit(1)))}s.help&&(console.log("\nGet Baseline Widely available browser versions or Baseline year browser versions.\n\nUsage: baseline-browser-mapping [options]\n\nOptions:\n --target-year Pass a year between 2015 and the current year to get browser versions compatible \n with all Newly Available features as of the end of the year specified.\n --widely-available-on-date Pass a date in the format 'YYYY-MM-DD' to get versions compatible with Widely \n available on the specified date.\n --include-downstream-browsers Whether to include browsers that use the same engines as a core Baseline browser.\n --include-kaios Whether to include KaiOS in downstream browsers. Requires --include-downstream-browsers.\n --list-all-compatible-versions Whether to include only the minimum compatible browser versions or all compatible versions.\n --suppress-warnings Supress potential warnings about data staleness when using a very recent feature cut off date.\n --override-last-updated Override the last updated date for the baseline data for debugging purposes.\n -h, --help Show help\n\nExamples:\n npx baseline-browser-mapping --target-year 2020\n npx baseline-browser-mapping --widely-available-on-date 2023-04-05\n npx baseline-browser-mapping --include-downstream-browsers\n npx baseline-browser-mapping --list-all-compatible-versions\n".trim()),process.exit(0)),console.log(e({targetYear:s["target-year"]?Number.parseInt(s["target-year"]):void 0,widelyAvailableOnDate:s["widely-available-on-date"],includeDownstreamBrowsers:s["include-downstream-browsers"],listAllCompatibleVersions:s["list-all-compatible-versions"],includeKaiOS:s["include-kaios"],suppressWarnings:s["suppress-warnings"],overrideLastUpdated:s["override-last-updated"]?Number.parseInt(s["override-last-updated"]):void 0})); |
+5
-3
@@ -60,6 +60,7 @@ export declare function _resetHasWarned(): void; | ||
| * Takes an optional configuration `Object` with four optional properties: | ||
| * - `listAllCompatibleVersions`: `false` (default) or `false` | ||
| * - `includeDownstreamBrowsers`: `false` (default) or `false` | ||
| * - `listAllCompatibleVersions`: `false` (default) or `true` | ||
| * - `includeDownstreamBrowsers`: `false` (default) or `true` | ||
| * - `widelyAvailableOnDate`: date in format `YYYY-MM-DD` | ||
| * - `targetYear`: year in format `YYYY` | ||
| * - `supressWarnings`: `false` (default) or `true` | ||
| */ | ||
@@ -98,7 +99,8 @@ export declare function getCompatibleVersions(userOptions?: Options): BrowserVersion[]; | ||
| * Takes an optional configuration `Object` with three optional properties: | ||
| * - `includeDownstreamBrowsers`: `true` (default) or `false` | ||
| * - `includeDownstreamBrowsers`: `false` (default) or `true` | ||
| * - `outputFormat`: `"array"` (default), `"object"` or `"csv"` | ||
| * - `useSupports`: `false` (default) or `true`, replaces `wa_compatible` property with optional `supports` property which returns `widely` or `newly` available when present. | ||
| * - `supressWarnings`: `false` (default) or `true` | ||
| */ | ||
| export declare function getAllVersions(userOptions?: AllVersionsOptions): AllBrowsersBrowserVersion[] | NestedBrowserVersions | string; | ||
| export {}; |
+9
-5
| { | ||
| "name": "baseline-browser-mapping", | ||
| "main": "./dist/index.cjs", | ||
| "version": "2.9.19", | ||
| "version": "2.10.0-beta", | ||
| "description": "A library for obtaining browser versions with their maximum supported Baseline feature set and Widely Available status.", | ||
@@ -27,4 +27,7 @@ "exports": { | ||
| "bin": { | ||
| "baseline-browser-mapping": "dist/cli.js" | ||
| "baseline-browser-mapping": "dist/cli.cjs" | ||
| }, | ||
| "engines": { | ||
| "node": ">=6.0.0" | ||
| }, | ||
| "scripts": { | ||
@@ -34,2 +37,3 @@ "fix-cli-permissions": "output=$(npx baseline-browser-mapping 2>&1); path=$(printf '%s\n' \"$output\" | sed -n 's/^.*: \\(.*\\): Permission denied$/\\1/p; t; s/^\\(.*\\): Permission denied$/\\1/p'); if [ -n \"$path\" ]; then echo \"Permission denied for: $path\"; echo \"Removing $path ...\"; rm -rf \"$path\"; else echo \"$output\"; fi", | ||
| "test:lint": "npx eslint .", | ||
| "test:legacy-test": "node spec/legacy-tests/legacy-test.cjs; node dist/cli.cjs", | ||
| "test:jasmine": "npx jasmine", | ||
@@ -47,3 +51,3 @@ "test:jasmine-browser": "npx jasmine-browser-runner runSpecs --config ./spec/support/jasmine-browser.js", | ||
| "devDependencies": { | ||
| "@mdn/browser-compat-data": "^7.2.5", | ||
| "@mdn/browser-compat-data": "^7.3.2", | ||
| "@rollup/plugin-terser": "^0.4.4", | ||
@@ -61,3 +65,3 @@ "@rollup/plugin-typescript": "^12.1.3", | ||
| "typescript-eslint": "^8.35.0", | ||
| "web-features": "^3.14.0" | ||
| "web-features": "^3.17.0" | ||
| }, | ||
@@ -68,2 +72,2 @@ "repository": { | ||
| } | ||
| } | ||
| } |
+13
-9
@@ -18,10 +18,2 @@ # [`baseline-browser-mapping`](https://github.com/web-platform-dx/web-features/packages/baseline-browser-mapping) | ||
| `baseline-browser-mapping` depends on `web-features` and `@mdn/browser-compat-data` for core browser version selection, but the data is pre-packaged and minified. This package checks for updates to those modules and the supported [downstream browsers](#downstream-browsers) on a daily basis and is updated frequently. Consider adding a script to your `package.json` to update `baseline-browser-mapping` and using it as part of your build process to ensure your data is as up to date as possible: | ||
| ```javascript | ||
| "scripts": [ | ||
| "refresh-baseline-browser-mapping": "npm i --save-dev baseline-browser-mapping@latest" | ||
| ] | ||
| ``` | ||
| The minimum supported NodeJS version for `baseline-browser-mapping` is v8 in alignment with `browserslist`. For NodeJS versions earlier than v13.2, the [`require('baseline-browser-mapping')`](https://nodejs.org/api/modules.html#requireid) syntax should be used to import the module. | ||
@@ -31,2 +23,4 @@ | ||
| `baseline-browser-mapping` depends on `web-features` and `@mdn/browser-compat-data` for core browser version selection, but the data is pre-packaged and minified. This package checks for updates to those modules and the supported [downstream browsers](#downstream-browsers) on a daily basis and is updated frequently. | ||
| If you are only using this module to generate minimum browser versions for Baseline Widely available or Baseline year feature sets, you don't need to update this module frequently, as the backward looking data is reasonably stable. | ||
@@ -36,4 +30,14 @@ | ||
| If you want to suppress these warnings you can use the `suppressWarnings: true` option in the configuration object passed to `getCompatibleVersions()` or `getAllVersions()`. Alternatively, you can use the `BASELINE_BROWSER_MAPPING_IGNORE_OLD_DATA=true` environment variable when running your build process. This module also respects the `BROWSERSLIST_IGNORE_OLD_DATA=true` environment variable. Environment variables can also be provided in a `.env` file from Node 20 onwards; however, this module does not load .env files automatically to avoid conflicts with other libraries with different requirements. You will need to use `process.loadEnvFile()` or a library like `dotenv` to load .env files before `baseline-browser-mapping` is called. | ||
| If you want to suppress the console warnings mentioned above you can use the `suppressWarnings: true` option in the configuration object passed to `getCompatibleVersions()` or `getAllVersions()`. Alternatively, you can use the `BASELINE_BROWSER_MAPPING_IGNORE_OLD_DATA=true` environment variable when running your build process. This module also respects the `BROWSERSLIST_IGNORE_OLD_DATA=true` environment variable. Environment variables can also be provided in a `.env` file from Node 20 onwards; however, this module does not load .env files automatically to avoid conflicts with other libraries with different requirements. You will need to use `process.loadEnvFile()` or a library like `dotenv` to load .env files before `baseline-browser-mapping` is called. | ||
| If you're building a tool that uses this module, consider suppressing the warnings but building a process into your tool that automatically updates this module. See, for example, [`browserslist`](https://github.com/browserslist/browserslist/blob/main/node.js#L471) and its [`update-browserslist-db`](https://github.com/browserslist/update-db) package. | ||
| If you're implementing `baseline-browser-mapping` directly, you should add a script to your `package.json` to update `baseline-browser-mapping` and use it as part of your build process to ensure your data is as up to date as possible. For example, if you are using NPM for package management: | ||
| ```javascript | ||
| "scripts": [ | ||
| "refresh-baseline-browser-mapping": "npm i baseline-browser-mapping@latest -D" | ||
| ] | ||
| ``` | ||
| If you want to ensure [reproducible builds](https://www.wikiwand.com/en/articles/Reproducible_builds), we strongly recommend using the `widelyAvailableOnDate` option to fix the Widely available date on a per build basis to ensure dependent tools provide the same output and you do not produce data staleness warnings. If you are using [`browserslist`](https://github.com/browserslist/browserslist) to target Baseline Widely available, consider automatically updating your `browserslist` configuration in `package.json` or `.browserslistrc` to `baseline widely available on {YYYY-MM-DD}` as part of your build process to ensure the same or sufficiently similar list of minimum browsers is reproduced for historical builds. | ||
@@ -40,0 +44,0 @@ |
| #!/usr/bin/env node | ||
| import{parseArgs as e}from"node:util";import{exit as s}from"node:process";import{getCompatibleVersions as a}from"./index.js";const r=process.argv.slice(2),{values:n}=e({args:r,options:{"target-year":{type:"string"},"widely-available-on-date":{type:"string"},"include-downstream-browsers":{type:"boolean"},"list-all-compatible-versions":{type:"boolean"},"include-kaios":{type:"boolean"},"suppress-warnings":{type:"boolean"},"override-last-updated":{type:"string"},help:{type:"boolean",short:"h"}},strict:!0});n.help&&(console.log("\nGet Baseline Widely available browser versions or Baseline year browser versions.\n\nUsage: baseline-browser-mapping [options]\n\nOptions:\n --target-year Pass a year between 2015 and the current year to get browser versions compatible \n with all Newly Available features as of the end of the year specified.\n --widely-available-on-date Pass a date in the format 'YYYY-MM-DD' to get versions compatible with Widely \n available on the specified date.\n --include-downstream-browsers Whether to include browsers that use the same engines as a core Baseline browser.\n --include-kaios Whether to include KaiOS in downstream browsers. Requires --include-downstream-browsers.\n --list-all-compatible-versions Whether to include only the minimum compatible browser versions or all compatible versions.\n --suppress-warnings Supress potential warnings about data staleness when using a very recent feature cut off date.\n --override-last-updated Override the last updated date for the baseline data for debugging purposes.\n -h, --help Show help\n\nExamples:\n npx baseline-browser-mapping --target-year 2020\n npx baseline-browser-mapping --widely-available-on-date 2023-04-05\n npx baseline-browser-mapping --include-downstream-browsers\n npx baseline-browser-mapping --list-all-compatible-versions\n".trim()),s(0)),console.log(a({targetYear:n["target-year"]?Number.parseInt(n["target-year"]):void 0,widelyAvailableOnDate:n["widely-available-on-date"],includeDownstreamBrowsers:n["include-downstream-browsers"],listAllCompatibleVersions:n["list-all-compatible-versions"],includeKaiOS:n["include-kaios"],suppressWarnings:n["suppress-warnings"],overrideLastUpdated:n["override-last-updated"]?Number.parseInt(n["override-last-updated"]):void 0})); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
280218
0.38%1039
0.29%468
0.86%5
25%