Skip to content

Commit

Permalink
chore(fmt): run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
mxdvl committed Jan 20, 2023
1 parent 2b8d276 commit 51050b1
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (parsed.success) {
"✅ Valid package.json",
Object.keys(parsed.data)
.map((dep) => cyan(dep))
.join(" and ")
.join(" and "),
);
} else {
console.error("🚨 Invalid dependencies fields in your package.json");
Expand All @@ -50,9 +50,11 @@ if (parsed.success) {
const dependencies_map = new Map<string, SemVer>();

for (const [type, dependencies] of Object.entries(parsed.data)) {
for (const [dep, ver] of Object.entries(dependencies).map(
([dep, ver]) => [dep, coerce(ver)] as const
)) {
for (
const [dep, ver] of Object.entries(dependencies).map(
([dep, ver]) => [dep, coerce(ver)] as const,
)
) {
if (dependencies_map.has(dep)) {
console.error("🚨 Duplicate dependency:", dep);
Deno.exit(1);
Expand Down Expand Up @@ -82,8 +84,8 @@ const fetched_peers = await Promise.all(
fetch(
new URL(
`${dependency}@${version.version}/package.json`,
"https://esm.sh/"
)
"https://esm.sh/",
),
)
.then((res) => res.json())
.then(parse_peers)
Expand All @@ -92,16 +94,18 @@ const fetched_peers = await Promise.all(
console.error("🚨 Failed to parse package.json for", dependency);
Deno.exit(2);
})
)
),
);

let missing_peer_dependencies = 0;

for (const {
dependency,
peerDependencies,
peerDependenciesMeta,
} of fetched_peers) {
for (
const {
dependency,
peerDependencies,
peerDependenciesMeta,
} of fetched_peers
) {
if (peerDependencies) {
const mismatched = Object.entries(peerDependencies).filter(([dep, ver]) => {
const specified_version = dependencies_map.get(dep);
Expand All @@ -114,13 +118,15 @@ for (const {

if (mismatched.length === 0) {
console.info(
`✅ All ${cyan("peerDependencies")} satisfied for ${blue(dependency)}`
`✅ All ${cyan("peerDependencies")} satisfied for ${blue(dependency)}`,
);
} else {
console.error(
`🚨 The following ${cyan("peerDependencies")} from ${blue(
dependency
)} are unsatisfied:`
`🚨 The following ${cyan("peerDependencies")} from ${
blue(
dependency,
)
} are unsatisfied:`,
);
for (const [dep, ver] of mismatched) {
console.error(` - ${[blue(dep), gray("@"), yellow(ver)].join("")}`);
Expand Down

0 comments on commit 51050b1

Please sign in to comment.