-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added errorResults handling in cli (#140)
fix: added errorResults handling in cli, fixed issue with duplicated license names in results in cli, renamed describe-license-count to more generic pluralize
- Loading branch information
1 parent
869d917
commit ce13c9f
Showing
12 changed files
with
93 additions
and
53 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
46 changes: 46 additions & 0 deletions
46
packages/cli/src/components/audit-licenses/results-list.tsx
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,46 @@ | ||
import figures from "figures"; | ||
import { Box, Text } from "ink"; | ||
import { pluralize } from "../../utils/pluralize.js"; | ||
|
||
type ResultsListProps = { | ||
message: [string, string]; | ||
results: { packageName: string; licenses: string[]; message: string }[]; | ||
type: "ok" | "warning" | "error"; | ||
renderMessages: boolean; | ||
}; | ||
|
||
const ICONS = { | ||
ok: <Text color="green">{figures.tick}</Text>, | ||
warning: <Text color="yellow">{figures.warning}</Text>, | ||
error: <Text color="red">{figures.cross}</Text>, | ||
}; | ||
|
||
export default function ResultsList({ | ||
message, | ||
results, | ||
type, | ||
renderMessages, | ||
}: ResultsListProps) { | ||
const pluralizedMessage = pluralize(results.length, message[0], message[1]); | ||
|
||
return ( | ||
<Box flexDirection="column"> | ||
<Box> | ||
{ICONS[type]} | ||
<Text>{` ${pluralizedMessage}`}:</Text> | ||
</Box> | ||
<Box flexDirection="column" marginLeft={2}> | ||
{results.map(({ packageName, message }) => ( | ||
<Box key={packageName} marginBottom={renderMessages ? 1 : 0}> | ||
<Text color="gray">{figures.pointerSmall}</Text> | ||
{renderMessages ? ( | ||
<Text> {message} </Text> | ||
) : ( | ||
<Text> {packageName} </Text> | ||
)} | ||
</Box> | ||
))} | ||
</Box> | ||
</Box> | ||
); | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...s/cli/src/utils/describe-license-count.ts → packages/cli/src/utils/pluralize.ts
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
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