-
-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Externals packaging prioritises yarn.lock lookup #485
Comments
I thought of 2 possible solutions:
Instead of: const findUpIO = (name: string, directory = process.cwd()): IOO.IOOption<string> =>
pipe(path.resolve(directory), (dir) =>
pipe(
safeFileExistsIO(path.join(dir, name)),
IO.chain((exists: boolean) => {
if (exists) return IOO.some(dir);
if (isPathRoot(dir)) return IOO.none;
return findUpIO(name, path.dirname(dir));
})
)
);
/**
* Forwards `rootDir` or finds project root folder.
*/
export const findProjectRoot = (rootDir?: string) =>
pipe(
IOO.fromNullable(rootDir),
IOO.fold(() => findUpIO('yarn.lock'), IOO.of),
IOO.fold(() => findUpIO('pnpm-lock.yaml'), IOO.of),
IOO.fold(() => findUpIO('package-lock.json'), IOO.of),
IOO.toUndefined
)(); Have something like: const findUpIO = (**names: string[]**, directory = process.cwd()): IOO.IOOption<string> =>
pipe(path.resolve(directory), (dir) =>
pipe(
**array.some(names.map((name) => safeFileExistsIO(path.join(dir, name))))**,
IO.chain((exists: boolean) => {
if (exists) return IOO.some(dir);
if (isPathRoot(dir)) return IOO.none;
return findUpIO(name, path.dirname(dir));
})
)
);
/**
* Forwards `rootDir` or finds project root folder.
*/
export const findProjectRoot = (rootDir?: string) =>
pipe(
IOO.fromNullable(rootDir),
IOO.fold(() => findUpIO(['yarn.lock', 'pnpm-lock.yaml', 'package-lock.json'), IOO.of),
IOO.toUndefined
)(); I know this is a crude solution, and I haven't given much thought and effort into how it would fit into the overall code, but perhaps it will help speed things up and shorten the time it takes to fix this. |
I can confirm this issue. We spent some time debugging it, and the cause was looking up the directory tree and finding a package-lock.json outside of the repo. |
🎉 This issue has been resolved in version 1.48.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Describe the bug
When packing externals, the Utils/findUpIO willl recursively search up the directory structure for a given file and the function findProjectRoot calls this function sequentially looking for yarn.lock, pnpm-lock.yaml and package-lock.json.
In case you are using pnpm or npm instead of yarn BUT you have a yarn.lock somewhere up the directory structure, it will cause a fail-ure.
To Reproduce
Expected behavior
The build should work....
Screenshots or Logs
Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: