fix(core): avoid reading empty .config.json, upgrade cosmiconfig@v9.0.0 #4062
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The credit should go to @ghiscoding - I'm just back-porting his fix to the same bug in lerna-lite to lerna here.
Description
The newer version of cosmicconfig does not suffer from the issue that
it defaults to looking for .config.json the way 8.x does.
This upgrade implicitly fixes the underlying issue that lerna has for the
same reason.
Motivation and Context
Fixes #4061
lerna-lite used to have the same bug, you can read the full context here:
.configcosmiconfig/cosmiconfig#313How Has This Been Tested?
npm test && npm run integrationThe tests all passed, but for the integratin tests 2 of them failed with the logs pasted below. They were failing the same way on
mainprior to my changes so I'm assuming this to be a false positive but you tell me.Summary of all failing tests FAIL __tests__/lerna-publish-validation.spec.ts ● lerna publish exits with EBEHIND when behind upstream remote Command failed with exit code 128: git commit -m upstream change Author identity unknown *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: empty ident name (for <peter@C11-73JFIMZA8J6.dir.svc.accenture.com>) not allowed 26 | await fs.outputFile(path.join(cloneDir, "README.md"), "upstream change"); 27 | await gitAdd(cloneDir, "-A"); > 28 | await gitCommit(cloneDir, "upstream change"); | ^ 29 | await execa("git", ["push", "origin", "main"], { cwd: cloneDir }); 30 | 31 | // throws during interactive publish (local) at makeError (../node_modules/execa/lib/error.js:59:11) at handlePromise (../node_modules/execa/index.js:114:26) at Object.<anonymous> (__tests__/lerna-publish-validation.spec.ts:28:3) FAIL __tests__/lerna-bootstrap-yarn.spec.ts ● lerna bootstrap --npm-client yarn Command failed with exit code 1: node /home/peter/a/lerna/packages/lerna/dist/cli.js bootstrap --npm-client yarn lerna notice cli v8.1.8 lerna info ci enabled lerna info Bootstrapping 4 packages lerna info lifecycle package-4@1.0.0~preinstall: package-4@1.0.0 lerna info Installing external dependencies lerna ERR! yarn install --mutex network:42424 --non-interactive exited 1 in '@integration/package-2' lerna ERR! yarn install --mutex network:42424 --non-interactive stdout: Unknown Syntax Error: Unsupported option name ("--mutex"). $ yarn install [--json] [--immutable] [--immutable-cache] [--refresh-lockfile] [--check-cache] [--check-resolutions] [--inline-builds] [--mode #0] lerna ERR! yarn install --mutex network:42424 --non-interactive exited 1 in '@integration/package-2' lerna WARN complete Waiting for 2 child processes to exit. CTRL-C to exit immediately. > package-4@1.0.0 preinstall /tmp/dd16a3ecb8e9a0c03b35291c2f37dd47/package-4 > exit 0 9 | const lerna = cliRunner(cwd); 10 | > 11 | const { stderr } = await lerna("bootstrap", "--npm-client", "yarn"); | ^ 12 | expect(stderr).toMatchInlineSnapshot(` 13 | lerna notice cli __TEST_VERSION__ 14 | lerna info ci enabled at makeError (../node_modules/execa/lib/error.js:59:11) at handlePromise (../node_modules/execa/index.js:114:26) at Object.<anonymous> (__tests__/lerna-bootstrap-yarn.spec.ts:11:22) Test Suites: 2 failed, 31 passed, 33 total Tests: 2 failed, 83 passed, 85 total Snapshots: 93 passed, 93 total Time: 68.037 s, estimated 83 s Ran all test suites. —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— NX Ran target integration for project integration and 6 task(s) they depend on (1m) With additional flags: --maxWorkers=2 ✖ 1/7 failed ✔ 6/7 succeeded [4 read from cache] View structured, searchable error logs at https://nx.app/runs/8xAbKEIHdjTypes of changes
Checklist: