Skip to content

Commit

Permalink
add browserslist-config
Browse files Browse the repository at this point in the history
  • Loading branch information
rellafella committed Sep 17, 2024
1 parent 6e450b2 commit 16f051a
Show file tree
Hide file tree
Showing 12 changed files with 343 additions and 126 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"eslint-config",
"stylelint-config",
"prettier-config",
"browserslist-config",
"github-actions",
"cspell",
"mdat",
Expand All @@ -51,6 +52,7 @@
"release": "pnpm bumpp -r --commit 'release: %s' --tag 'v%s' && pnpm -r publish --otp $(op read 'op://Personal/NPM/one-time password?attribute=otp')"
},
"devDependencies": {
"@envsa/browserslist-config": "workspace:*",
"@envsa/cspell-config": "workspace:*",
"@envsa/eslint-config": "workspace:*",
"@envsa/mdat-config": "workspace:*",
Expand Down
2 changes: 2 additions & 0 deletions packages/browserslist-config/bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
// Placeholder, will be replaced by the actual CLI script during the build process
1 change: 1 addition & 0 deletions packages/browserslist-config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ['> 0.5% in AU', 'last 3 years', 'iOS >= 7', 'ie >= 11'];
23 changes: 23 additions & 0 deletions packages/browserslist-config/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
MIT License

Copyright (c) 2024 Liam Rella

Based on the MIT-licensed "@kitschpatrol/shared-config" project by Eric Mika

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
49 changes: 49 additions & 0 deletions packages/browserslist-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "@envsa/browserslist-config",
"version": "1.0.0-beta.13",
"type": "module",
"description": "Browserslist configuration for @envsa/shared-config.",
"repository": {
"type": "git",
"url": "git@github.com:envsa/shared-config.git",
"directory": "packages/browserslist-config"
},
"bugs": {
"url": "https://github.com/envsa/shared-config/issues",
"email": "DEW.ICTWebServices@sa.gov.au"
},
"author": {
"name": "Liam Rella",
"email": "DEW.ICTWebServices@sa.gov.au",
"url": "https://github.com/rellafella"
},
"license": "MIT",
"engines": {
"node": ">=18.0.0",
"pnpm": ">=8.0.0"
},
"bin": {
"browserslist-config": "bin/cli.js"
},
"main": "./index.js",
"keywords": [
"shared-config",
"browserslist-config",
"browserslist",
"cli"
],
"scripts": {
"build": "../../scripts/build.ts && mdat readme",
"cli": "node ./bin/cli.js",
"prepublishOnly": "pnpm run build"
},
"dependencies": {
"@pinojs/json-colorizer": "^4.0.0",
"cosmiconfig": "^9.0.0",
"execa": "^8.0.1",
"fs-extra": "^11.2.0"
},
"publishConfig": {
"access": "public"
}
}
84 changes: 84 additions & 0 deletions packages/browserslist-config/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!--+ Warning: Content inside HTML comment blocks was generated by mdat and may be overwritten. +-->

<!-- title -->

# @envsa/browserslist-config

<!-- /title -->

<!-- badges -->

[![NPM Package @envsa/browserslist-config](https://img.shields.io/npm/v/@envsa/browserslist-config.svg)](https://npmjs.com/package/@envsa/browserslist-config)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

<!-- /badges -->

<!-- description -->

**Browserslist configuration for @envsa/shared-config.**

<!-- /description -->

## Overview

It's a shared [Browserslist](https://browsersl.ist) config.

**See [`@envsa/shared-config`](https://www.npmjs.com/package/@envsa/shared-config) for the recommended single-package approach.**

## Setup

To use just this browserslist config in isolation:

1. Install the `.npmrc` in your project root. This is required for correct PNPM behavior:

```sh
pnpm dlx @envsa/repo-config --init
```

2. Add the package:

```sh
pnpm add -D @envsa/browserslist-config
```

## Usage

Integrate with your `package.json` scripts as you see fit, for example:

```json
"browserslist": ["extends @envsa/browserslist-config"]
```

or use the cli

### CLI

<!-- cli-help {cliCommand: "browserslist-config"} -->

```txt
Browserslist configuration for @envsa/shared-config.
Usage
$ browserslist-config --init
Options
--init, -i Add browserslist key to `package.json`.
--help, -h Print this help info.
--version, -v Print the package version.
```

<!-- /cli-help -->

## Credits

[Eric Mika](https://github.com/kitschpatrol) is the author of the original [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config) project on which this is based.

<!-- license -->

## License

[MIT](license.txt) © Liam Rella

<!-- /license -->
9 changes: 9 additions & 0 deletions packages/browserslist-config/src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env node
import { buildCommands } from '$root/src/command-builder.ts';

await buildCommands('browserslist-config', '[Browserslist]', 'white', {
init: {
command: 'pnpm',
defaultArguments: ['pkg', 'set', 'browserslist[0]=extends @envsa/browserslist-config'],
},
});
2 changes: 2 additions & 0 deletions packages/shared-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"eslint-config",
"stylelint-config",
"prettier-config",
"browserslist-config",
"github-actions",
"cspell",
"mdat",
Expand All @@ -45,6 +46,7 @@
"prepublishOnly": "pnpm run build"
},
"dependencies": {
"@envsa/browserslist-config": "workspace:*",
"@envsa/cspell-config": "workspace:*",
"@envsa/eslint-config": "workspace:*",
"@envsa/mdat-config": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-config/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ shared-config [<file|glob> ...]

| Option | Argument | Description |
| ------------------------ | -------- | ---------------------------------------------------------------- |
| `--check`<br>`-c` | | Check for and report issues. Same as `shared-config`. |
| `--init`<br>`-i` | | Initialize by copying starter config files to your project root. |
| `--check`<br>`-c` | | Check for and report issues. Same as `shared-config`. |
| `--print-config`<br>`-p` | `<path>` | Print the effective configuration at a certain path. |
| `--fix`<br>`-f` | | Fix all auto-fixable issues, and report the un-fixable. |
| `--help`<br>`-h` | | Print this help info. |
Expand Down
Loading

0 comments on commit 16f051a

Please sign in to comment.