feat: skip config creation if one already found (#110)

This commit introduces mechanism that'll check for common configuration file locations and respects the original file.
This commit is contained in:
Ismo Vuorinen
2023-10-25 23:09:15 +03:00
committed by GitHub
parent 56362dad96
commit 9beafec486
22 changed files with 114 additions and 8 deletions

View File

@@ -10,6 +10,7 @@ indent_size = 2
indent_style = space indent_style = space
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
max_line_length = 120
[*.md] [*.md]
max_line_length = off max_line_length = off

View File

@@ -36,6 +36,7 @@
"postinstall": "node scripts/postinstall.js" "postinstall": "node scripts/postinstall.js"
}, },
"dependencies": { "dependencies": {
"@ivuorinen/config-checker": "^1.1.0",
"browserslist": "4.22.1" "browserslist": "4.22.1"
}, },
"gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230" "gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230"

View File

@@ -2,9 +2,18 @@
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const process = require('process')
const checkConfig = require('@ivuorinen/config-checker')
const foundConfig = checkConfig('browserslist')
if (foundConfig.length > 0) {
console.log('browserslist-config: Found existing browserslist config file, skipping creation.')
console.log('browserslist-config: If you want to create a new config file, please remove the existing one.')
console.log(`browserslist-config: Found config files at: ${foundConfig.join(', ')}`)
process.exit(0)
}
const filePath = path.join(process.env.INIT_CWD, '.browserslistrc') const filePath = path.join(process.env.INIT_CWD, '.browserslistrc')
const fileConfigObject = 'extends @ivuorinen/browserslist-config' const fileConfigObject = 'extends @ivuorinen/browserslist-config'
if (!fs.existsSync(filePath)) { if (!fs.existsSync(filePath)) {

View File

@@ -2,6 +2,11 @@
# yarn lockfile v1 # yarn lockfile v1
"@ivuorinen/config-checker@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@ivuorinen/config-checker/-/config-checker-1.1.0.tgz#73a996445a917627cb558ea69f616978ff97da9d"
integrity sha512-YHQSF2yt4YZM0W9jdFXdPUB4X1AicweDJWSJtFw58GVI4+wI8+CJtoKL/Dmbn8F3B6H6gngQHwzENqw80Zsskg==
browserslist@4.22.1: browserslist@4.22.1:
version "4.22.1" version "4.22.1"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.22.1.tgz#ba91958d1a59b87dab6fed8dfbcb3da5e2e9c619" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.22.1.tgz#ba91958d1a59b87dab6fed8dfbcb3da5e2e9c619"

View File

@@ -36,7 +36,8 @@
}, },
"dependencies": { "dependencies": {
"@commitlint/cli": "18.0.0", "@commitlint/cli": "18.0.0",
"@commitlint/config-conventional": "18.0.0" "@commitlint/config-conventional": "18.0.0",
"@ivuorinen/config-checker": "^1.1.0"
}, },
"gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230" "gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230"
} }

View File

@@ -2,9 +2,18 @@
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const process = require('process')
const checkConfig = require('@ivuorinen/config-checker')
const foundConfig = checkConfig('commitlint')
if (foundConfig.length > 0) {
console.log('commitlint-config: Found existing commitlint config file, skipping creation.')
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(', ')}`)
process.exit(0)
}
const filePath = path.join(process.env.INIT_CWD, '.commitlintrc.json') const filePath = path.join(process.env.INIT_CWD, '.commitlintrc.json')
const fileConfigObject = { const fileConfigObject = {
extends: ['@ivuorinen/commitlint-config'] extends: ['@ivuorinen/commitlint-config']
} }

View File

@@ -192,6 +192,11 @@
dependencies: dependencies:
"@jridgewell/trace-mapping" "0.3.9" "@jridgewell/trace-mapping" "0.3.9"
"@ivuorinen/config-checker@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@ivuorinen/config-checker/-/config-checker-1.1.0.tgz#73a996445a917627cb558ea69f616978ff97da9d"
integrity sha512-YHQSF2yt4YZM0W9jdFXdPUB4X1AicweDJWSJtFw58GVI4+wI8+CJtoKL/Dmbn8F3B6H6gngQHwzENqw80Zsskg==
"@jridgewell/resolve-uri@^3.0.3": "@jridgewell/resolve-uri@^3.0.3":
version "3.1.1" version "3.1.1"
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721" resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721"

View File

@@ -36,6 +36,7 @@
"postinstall": "node scripts/postinstall.js" "postinstall": "node scripts/postinstall.js"
}, },
"dependencies": { "dependencies": {
"@ivuorinen/config-checker": "^1.1.0",
"eslint": "8.52.0", "eslint": "8.52.0",
"eslint-config-standard": "17.1.0", "eslint-config-standard": "17.1.0",
"eslint-plugin-import": "2.28.1", "eslint-plugin-import": "2.28.1",

View File

@@ -2,9 +2,18 @@
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const process = require('process')
const checkConfig = require('@ivuorinen/config-checker')
const foundConfig = checkConfig('eslint')
if (foundConfig.length > 0) {
console.log('eslint-config: Found existing eslint config file, skipping creation.')
console.log('eslint-config: If you want to create a new config file, please remove the existing one.')
console.log(`eslint-config: Found config files at: ${foundConfig.join(', ')}`)
process.exit(0)
}
const filePath = path.join(process.env.INIT_CWD, '.eslintrc.json') const filePath = path.join(process.env.INIT_CWD, '.eslintrc.json')
const fileConfigObject = { const fileConfigObject = {
extends: ['@ivuorinen'] extends: ['@ivuorinen']
} }

View File

@@ -58,6 +58,11 @@
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz#e5211452df060fa8522b55c7b3c0c4d1981cb044" resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz#e5211452df060fa8522b55c7b3c0c4d1981cb044"
integrity sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw== integrity sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==
"@ivuorinen/config-checker@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@ivuorinen/config-checker/-/config-checker-1.1.0.tgz#73a996445a917627cb558ea69f616978ff97da9d"
integrity sha512-YHQSF2yt4YZM0W9jdFXdPUB4X1AicweDJWSJtFw58GVI4+wI8+CJtoKL/Dmbn8F3B6H6gngQHwzENqw80Zsskg==
"@nodelib/fs.scandir@2.1.5": "@nodelib/fs.scandir@2.1.5":
version "2.1.5" version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"

View File

@@ -36,6 +36,7 @@
"postinstall": "node scripts/postinstall.js" "postinstall": "node scripts/postinstall.js"
}, },
"dependencies": { "dependencies": {
"@ivuorinen/config-checker": "^1.1.0",
"markdownlint-cli": "0.37.0" "markdownlint-cli": "0.37.0"
}, },
"gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230" "gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230"

View File

@@ -2,9 +2,18 @@
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const process = require('process')
const checkConfig = require('@ivuorinen/config-checker')
const foundConfig = checkConfig('markdownlint')
if (foundConfig.length > 0) {
console.log('markdownlint-config: Found existing markdownlint config file, skipping creation.')
console.log('markdownlint-config: If you want to create a new config file, please remove the existing one.')
console.log(`markdownlint-config: Found config files at: ${foundConfig.join(', ')}`)
process.exit(0)
}
const filePath = path.join(process.env.INIT_CWD, '.markdownlint.json') const filePath = path.join(process.env.INIT_CWD, '.markdownlint.json')
const fileConfigObject = { const fileConfigObject = {
extends: '@ivuorinen/markdownlint-config' extends: '@ivuorinen/markdownlint-config'
} }

View File

@@ -14,6 +14,11 @@
wrap-ansi "^8.1.0" wrap-ansi "^8.1.0"
wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" wrap-ansi-cjs "npm:wrap-ansi@^7.0.0"
"@ivuorinen/config-checker@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@ivuorinen/config-checker/-/config-checker-1.1.0.tgz#73a996445a917627cb558ea69f616978ff97da9d"
integrity sha512-YHQSF2yt4YZM0W9jdFXdPUB4X1AicweDJWSJtFw58GVI4+wI8+CJtoKL/Dmbn8F3B6H6gngQHwzENqw80Zsskg==
"@pkgjs/parseargs@^0.11.0": "@pkgjs/parseargs@^0.11.0":
version "0.11.0" version "0.11.0"
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"

View File

@@ -36,6 +36,7 @@
"postinstall": "node scripts/postinstall.js" "postinstall": "node scripts/postinstall.js"
}, },
"dependencies": { "dependencies": {
"@ivuorinen/config-checker": "^1.1.0",
"prettier": "2.8.8" "prettier": "2.8.8"
}, },
"gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230" "gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230"

View File

@@ -2,9 +2,18 @@
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const process = require('process')
const checkConfig = require('@ivuorinen/config-checker')
const foundConfig = checkConfig('prettier')
if (foundConfig.length > 0) {
console.log('prettier-config: Found existing prettier config file, skipping creation.')
console.log('prettier-config: If you want to create a new config file, please remove the existing one.')
console.log(`prettier-config: Found config files at: ${foundConfig.join(', ')}`)
process.exit(0)
}
const filePath = path.join(process.env.INIT_CWD, '.prettierrc.json') const filePath = path.join(process.env.INIT_CWD, '.prettierrc.json')
const fileConfigObject = '@ivuorinen/prettier-config' const fileConfigObject = '@ivuorinen/prettier-config'
if (!fs.existsSync(filePath)) { if (!fs.existsSync(filePath)) {

View File

@@ -2,6 +2,11 @@
# yarn lockfile v1 # yarn lockfile v1
"@ivuorinen/config-checker@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@ivuorinen/config-checker/-/config-checker-1.1.0.tgz#73a996445a917627cb558ea69f616978ff97da9d"
integrity sha512-YHQSF2yt4YZM0W9jdFXdPUB4X1AicweDJWSJtFw58GVI4+wI8+CJtoKL/Dmbn8F3B6H6gngQHwzENqw80Zsskg==
prettier@2.8.8: prettier@2.8.8:
version "2.8.8" version "2.8.8"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"

View File

@@ -36,6 +36,7 @@
"postinstall": "node scripts/postinstall.js" "postinstall": "node scripts/postinstall.js"
}, },
"dependencies": { "dependencies": {
"@ivuorinen/config-checker": "^1.1.0",
"@semantic-release/changelog": "6.0.3", "@semantic-release/changelog": "6.0.3",
"@semantic-release/git": "10.0.1", "@semantic-release/git": "10.0.1",
"semantic-release": "22.0.5" "semantic-release": "22.0.5"

View File

@@ -2,9 +2,18 @@
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const process = require('process')
const checkConfig = require('@ivuorinen/config-checker')
const foundConfig = checkConfig('release')
if (foundConfig.length > 0) {
console.log('semantic-release-config: Found existing semantic-release config file, skipping creation.')
console.log('semantic-release-config: If you want to create a new config file, please remove the existing one.')
console.log(`semantic-release-config: Found config files at: ${foundConfig.join(', ')}`)
process.exit(0)
}
const filePath = path.join(process.env.INIT_CWD, '.releaserc.json') const filePath = path.join(process.env.INIT_CWD, '.releaserc.json')
const fileConfigObject = { const fileConfigObject = {
extends: ['@ivuorinen/semantic-release-config'] extends: ['@ivuorinen/semantic-release-config']
} }

View File

@@ -46,6 +46,11 @@
resolved "https://registry.yarnpkg.com/@isaacs/string-locale-compare/-/string-locale-compare-1.1.0.tgz#291c227e93fd407a96ecd59879a35809120e432b" resolved "https://registry.yarnpkg.com/@isaacs/string-locale-compare/-/string-locale-compare-1.1.0.tgz#291c227e93fd407a96ecd59879a35809120e432b"
integrity sha512-SQ7Kzhh9+D+ZW9MA0zkYv3VXhIDNx+LzM6EJ+/65I3QY+enU6Itte7E5XX7EWrqLW2FN4n06GWzBnPoC3th2aQ== integrity sha512-SQ7Kzhh9+D+ZW9MA0zkYv3VXhIDNx+LzM6EJ+/65I3QY+enU6Itte7E5XX7EWrqLW2FN4n06GWzBnPoC3th2aQ==
"@ivuorinen/config-checker@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@ivuorinen/config-checker/-/config-checker-1.1.0.tgz#73a996445a917627cb558ea69f616978ff97da9d"
integrity sha512-YHQSF2yt4YZM0W9jdFXdPUB4X1AicweDJWSJtFw58GVI4+wI8+CJtoKL/Dmbn8F3B6H6gngQHwzENqw80Zsskg==
"@nodelib/fs.scandir@2.1.5": "@nodelib/fs.scandir@2.1.5":
version "2.1.5" version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"

View File

@@ -37,6 +37,7 @@
"postinstall": "node scripts/postinstall.js" "postinstall": "node scripts/postinstall.js"
}, },
"dependencies": { "dependencies": {
"@ivuorinen/config-checker": "^1.1.0",
"postcss": "^8.4.2", "postcss": "^8.4.2",
"stylelint": "15.11.0", "stylelint": "15.11.0",
"stylelint-config-recommended-scss": "13.0.0", "stylelint-config-recommended-scss": "13.0.0",

View File

@@ -2,9 +2,18 @@
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const process = require('process')
const checkConfig = require('@ivuorinen/config-checker')
const foundConfig = checkConfig('stylelint')
if (foundConfig.length > 0) {
console.log('stylelint-config: Found existing stylelint config file, skipping creation.')
console.log('stylelint-config: If you want to create a new config file, please remove the existing one.')
console.log(`stylelint-config: Found config files at: ${foundConfig.join(', ')}`)
process.exit(0)
}
const filePath = path.join(process.env.INIT_CWD, '.stylelintrc.json') const filePath = path.join(process.env.INIT_CWD, '.stylelintrc.json')
const fileConfigObject = { const fileConfigObject = {
extends: ['@ivuorinen/stylelint-config/css'] extends: ['@ivuorinen/stylelint-config/css']
} }

View File

@@ -44,6 +44,11 @@
resolved "https://registry.yarnpkg.com/@csstools/selector-specificity/-/selector-specificity-3.0.0.tgz#798622546b63847e82389e473fd67f2707d82247" resolved "https://registry.yarnpkg.com/@csstools/selector-specificity/-/selector-specificity-3.0.0.tgz#798622546b63847e82389e473fd67f2707d82247"
integrity sha512-hBI9tfBtuPIi885ZsZ32IMEU/5nlZH/KOVYJCOh7gyMxaVLGmLedYqFN6Ui1LXkI8JlC8IsuC0rF0btcRZKd5g== integrity sha512-hBI9tfBtuPIi885ZsZ32IMEU/5nlZH/KOVYJCOh7gyMxaVLGmLedYqFN6Ui1LXkI8JlC8IsuC0rF0btcRZKd5g==
"@ivuorinen/config-checker@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@ivuorinen/config-checker/-/config-checker-1.1.0.tgz#73a996445a917627cb558ea69f616978ff97da9d"
integrity sha512-YHQSF2yt4YZM0W9jdFXdPUB4X1AicweDJWSJtFw58GVI4+wI8+CJtoKL/Dmbn8F3B6H6gngQHwzENqw80Zsskg==
"@nodelib/fs.scandir@2.1.5": "@nodelib/fs.scandir@2.1.5":
version "2.1.5" version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"