-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintainers can not maintain.
- Loading branch information
Showing
5 changed files
with
41 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { readFile } from "node:fs/promises"; | ||
import { reject, startsWith, partition, path, flip } from "ramda"; | ||
|
||
const excludeTypes = reject(startsWith("@types/")); | ||
|
||
/** @todo make it a plugin later */ | ||
export const getDependencies = async (packageJson, unlistedPeers) => { | ||
const manifest = JSON.parse(await readFile(packageJson, "utf-8")); | ||
const lookup = flip(path)(manifest); | ||
const isOptional = (name) => | ||
lookup(["peerDependenciesMeta", name, "optional"]); | ||
|
||
const allPeers = excludeTypes(Object.keys(manifest.peerDependencies)); | ||
const [optPeers, reqPeers] = partition(isOptional, allPeers); | ||
const production = Object.keys(manifest.dependencies); | ||
|
||
return { | ||
allowed: production.concat(reqPeers), | ||
typeOnly: optPeers.concat(unlistedPeers), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters