mirror of
https://github.com/ivuorinen/base-configs.git
synced 2026-03-10 04:57:41 +00:00
chore(docs): better readme
This commit is contained in:
@@ -6,7 +6,7 @@ Check for existence of common configuration files in usually used locations.
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Install `this package` as a _`dependencies`_:
|
Install `this package` as a _`dependency`_:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# npm
|
# npm
|
||||||
@@ -18,20 +18,100 @@ yarn add @ivuorinen/config-checker
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
This package is intended to be used in lifecycle events of other packages.
|
||||||
|
|
||||||
|
Configuration packages located in this repository use this tool to check for existence of configuration files, and if they exist, they will not create new ones.
|
||||||
|
|
||||||
|
### Real world example
|
||||||
|
|
||||||
|
For commitlint-config you can find the usage in the [commitlint-config postinstall.js][commitlint-postinstall-link] file.
|
||||||
|
|
||||||
|
Here's a snippet from the file:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const configChecker = require('@ivuorinen/config-checker')
|
const process = require('process')
|
||||||
|
const checkConfig = require('@ivuorinen/config-checker')
|
||||||
|
const foundConfig = checkConfig('commitlint')
|
||||||
|
|
||||||
// Check for existance of configuration files.
|
if (foundConfig.length > 0) {
|
||||||
// Module name for Eslint would be 'eslint' for example.
|
console.log('commitlint-config: Found existing commitlint config file, skipping creation.')
|
||||||
const configFiles = configChecker('module-name')
|
console.log('commitlint-config: If you want to create a new config file, please remove the existing one.')
|
||||||
|
console.log(`commitlint-config: Found config files at: ${foundConfig.join(', ')}`)
|
||||||
if (configFiles.length > 0) {
|
process.exit(0)
|
||||||
console.log('Found configuration files', configFiles)
|
|
||||||
} else {
|
|
||||||
console.log('No configuration files found')
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Locations scanned
|
||||||
|
|
||||||
|
| Searched configuration files |
|
||||||
|
| ----------------------------------- |
|
||||||
|
| `[module name]` |
|
||||||
|
| `[module name]`rc |
|
||||||
|
| `[module name]`rc.json |
|
||||||
|
| `[module name]`rc.yaml |
|
||||||
|
| `[module name]`rc.yml |
|
||||||
|
| `[module name]`rc.js |
|
||||||
|
| `[module name]`rc.ts |
|
||||||
|
| `[module name]`rc.mjs |
|
||||||
|
| `[module name]`rc.cjs |
|
||||||
|
| `[module name]`.jsonc |
|
||||||
|
| `[module name]`.yaml |
|
||||||
|
| `[module name]`.json |
|
||||||
|
| `[module name]`.config.js |
|
||||||
|
| `[module name]`.config.ts |
|
||||||
|
| `[module name]`.config.mjs |
|
||||||
|
| `[module name]`.config.cjs |
|
||||||
|
| .`[module name]` |
|
||||||
|
| .`[module name]`rc |
|
||||||
|
| .`[module name]`rc.json |
|
||||||
|
| .`[module name]`rc.yaml |
|
||||||
|
| .`[module name]`rc.yml |
|
||||||
|
| .`[module name]`rc.js |
|
||||||
|
| .`[module name]`rc.ts |
|
||||||
|
| .`[module name]`rc.mjs |
|
||||||
|
| .`[module name]`rc.cjs |
|
||||||
|
| .`[module name]`.jsonc |
|
||||||
|
| .`[module name]`.yaml |
|
||||||
|
| .`[module name]`.json |
|
||||||
|
| .`[module name]`.config.js |
|
||||||
|
| .`[module name]`.config.ts |
|
||||||
|
| .`[module name]`.config.mjs |
|
||||||
|
| .`[module name]`.config.cjs |
|
||||||
|
| .config/`[module name]` |
|
||||||
|
| .config/`[module name]`rc |
|
||||||
|
| .config/`[module name]`rc.json |
|
||||||
|
| .config/`[module name]`rc.yaml |
|
||||||
|
| .config/`[module name]`rc.yml |
|
||||||
|
| .config/`[module name]`rc.js |
|
||||||
|
| .config/`[module name]`rc.ts |
|
||||||
|
| .config/`[module name]`rc.mjs |
|
||||||
|
| .config/`[module name]`rc.cjs |
|
||||||
|
| .config/`[module name]`.jsonc |
|
||||||
|
| .config/`[module name]`.yaml |
|
||||||
|
| .config/`[module name]`.json |
|
||||||
|
| .config/`[module name]`.config.js |
|
||||||
|
| .config/`[module name]`.config.ts |
|
||||||
|
| .config/`[module name]`.config.mjs |
|
||||||
|
| .config/`[module name]`.config.cjs |
|
||||||
|
| .config/.`[module name]` |
|
||||||
|
| .config/.`[module name]`rc |
|
||||||
|
| .config/.`[module name]`rc.json |
|
||||||
|
| .config/.`[module name]`rc.yaml |
|
||||||
|
| .config/.`[module name]`rc.yml |
|
||||||
|
| .config/.`[module name]`rc.js |
|
||||||
|
| .config/.`[module name]`rc.ts |
|
||||||
|
| .config/.`[module name]`rc.mjs |
|
||||||
|
| .config/.`[module name]`rc.cjs |
|
||||||
|
| .config/.`[module name]`.jsonc |
|
||||||
|
| .config/.`[module name]`.yaml |
|
||||||
|
| .config/.`[module name]`.json |
|
||||||
|
| .config/.`[module name]`.config.js |
|
||||||
|
| .config/.`[module name]`.config.ts |
|
||||||
|
| .config/.`[module name]`.config.mjs |
|
||||||
|
| .config/.`[module name]`.config.cjs |
|
||||||
|
|
||||||
|
This list has been generated using `npm run generate-table`.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
If you are interested in helping contribute, please take a look at our [contribution guidelines][contributing-link] and open an [issue][issue-link] or [pull request][pull-request-link].
|
If you are interested in helping contribute, please take a look at our [contribution guidelines][contributing-link] and open an [issue][issue-link] or [pull request][pull-request-link].
|
||||||
@@ -54,3 +134,4 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md
|
|||||||
[pull-request-link]: https://github.com/ivuorinen/base-configs/pulls
|
[pull-request-link]: https://github.com/ivuorinen/base-configs/pulls
|
||||||
[style-badge]: https://img.shields.io/badge/code_style-ivuorinen%E2%80%99s-663399.svg?labelColor=292a44&style=flat-square
|
[style-badge]: https://img.shields.io/badge/code_style-ivuorinen%E2%80%99s-663399.svg?labelColor=292a44&style=flat-square
|
||||||
[style-link]: https://github.com/ivuorinen/base-configs
|
[style-link]: https://github.com/ivuorinen/base-configs
|
||||||
|
[commitlint-postinstall-link]: https://github.com/ivuorinen/base-configs/blob/main/packages/commitlint-config/scripts/postinstall.js
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
const configurationPaths = require('../lib/configuration-paths')
|
const configurationPaths = require('../lib/configuration-paths')
|
||||||
|
|
||||||
const configItems = configurationPaths('[module name]')
|
const configItems = configurationPaths('`[module name]`')
|
||||||
const longestLine = configItems.reduce((a, b) => (a.length > b.length ? a : b)).length
|
const longestLine = configItems.reduce((a, b) => (a.length > b.length ? a : b)).length
|
||||||
|
|
||||||
const mdTable = configItems.map(file => {
|
const mdTable = configItems.map(file => {
|
||||||
@@ -10,6 +10,8 @@ const mdTable = configItems.map(file => {
|
|||||||
return `| ${file}${' '.repeat(diff)} |`
|
return `| ${file}${' '.repeat(diff)} |`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log('# Configuration files\n')
|
||||||
|
|
||||||
const header = 'Searched configuration files'
|
const header = 'Searched configuration files'
|
||||||
console.log('| ' + header + ' '.repeat(longestLine - header.length) + ' |')
|
console.log('| ' + header + ' '.repeat(longestLine - header.length) + ' |')
|
||||||
console.log('| ' + '-'.repeat(longestLine) + ' |')
|
console.log('| ' + '-'.repeat(longestLine) + ' |')
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node ./__tests__/config-checker.test.js",
|
"test": "node ./__tests__/config-checker.test.js",
|
||||||
"files": "node ./helpers/files.js"
|
"generate-table": "node ./helpers/generate-md-table.js"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/ivuorinen/base-configs/issues"
|
"url": "https://github.com/ivuorinen/base-configs/issues"
|
||||||
|
|||||||
Reference in New Issue
Block a user