Skip to content

Commit

Permalink
fix: use lilconfig (#1108)
Browse files Browse the repository at this point in the history
* fix: use lilconfig

* fix: remove cosmiconfig
  • Loading branch information
mdonnalley committed Jun 11, 2024
1 parent cb21403 commit 804db9b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 39 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"ansis": "^3.1.1",
"clean-stack": "^3.0.1",
"cli-spinners": "^2.9.2",
"cosmiconfig": "^9.0.0",
"debug": "^4.3.5",
"ejs": "^3.1.10",
"get-package-type": "^0.1.0",
"globby": "^11.1.0",
"indent-string": "^4.0.0",
"is-wsl": "^2.2.0",
"lilconfig": "^3.1.2",
"minimatch": "^9.0.4",
"string-width": "^4.2.3",
"supports-color": "^8",
Expand Down
14 changes: 5 additions & 9 deletions src/util/read-pjson.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {cosmiconfig} from 'cosmiconfig'
import {lilconfig} from 'lilconfig'
import {join} from 'node:path'

import {PJSON} from '../interfaces'
Expand All @@ -8,7 +8,7 @@ import {readJson} from './fs'
const debug = makeDebug('read-pjson')

/**
* Read the package.json file from a given path and add the oclif config (found by cosmiconfig) if it exists.
* Read the package.json file from a given path and add the oclif config (found by lilconfig) if it exists.
*
* We can assume that the package.json file exists because the plugin root has already been loaded at this point.
*/
Expand All @@ -21,14 +21,14 @@ export async function readPjson(path: string): Promise<PJSON> {

const pjson = await readJson<PJSON>(pjsonPath)

// don't bother with cosmiconfig if the plugin's package.json already has an oclif config
// don't bother with lilconfig if the plugin's package.json already has an oclif config
if (pjson.oclif) {
debug(`found oclif config in ${pjsonPath}`)
return pjson
}

debug(`searching for oclif config in ${path}`)
const explorer = cosmiconfig('oclif', {
const explorer = lilconfig('oclif', {
/**
* Remove the following from the defaults:
* - package.json
Expand All @@ -37,18 +37,14 @@ export async function readPjson(path: string): Promise<PJSON> {
searchPlaces: [
'.oclifrc',
'.oclifrc.json',
'.oclifrc.yaml',
'.oclifrc.yml',
'.oclifrc.js',
'.oclifrc.ts',
'.oclifrc.mjs',
'.oclifrc.cjs',
'oclif.config.js',
'oclif.config.ts',
'oclif.config.mjs',
'oclif.config.cjs',
],
searchStrategy: 'none',
stopDir: path,
})
const result = await explorer.search(path)
if (!result?.config) {
Expand Down
33 changes: 4 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4360,7 +4360,7 @@ libnpmversion@^5.0.1:
proc-log "^3.0.0"
semver "^7.3.7"

lilconfig@~3.1.1:
lilconfig@^3.1.2, lilconfig@~3.1.1:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-3.1.2.tgz#e4a7c3cb549e3a606c8dcc32e5ae1005e62c05cb"
integrity sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow==
Expand Down Expand Up @@ -6272,16 +6272,7 @@ string-argv@~0.3.2:
resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.2.tgz#2b6d0ef24b656274d957d54e0a4bbf6153dc02b6"
integrity sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -6351,14 +6342,7 @@ stringify-object@^3.2.1:
is-obj "^1.0.1"
is-regexp "^1.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -6885,7 +6869,7 @@ workerpool@6.2.1:
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343"
integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -6903,15 +6887,6 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit 804db9b

Please sign in to comment.