-
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.
feat(cli, core): add option to download/update/clear full license texts
- Loading branch information
Showing
12 changed files
with
170 additions
and
41 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,39 @@ | ||
import { deleteLicenses, updateLicenses } from "@license-auditor/data"; | ||
import { Text, useApp } from "ink"; | ||
import { useEffect, useState } from "react"; | ||
import { z } from "zod"; | ||
import { SpinnerWithLabel } from "../components/spinner-with-label.js"; | ||
|
||
export const options = z.object({ | ||
clearCache: z.boolean().describe("Compress output"), | ||
}); | ||
|
||
type Props = { | ||
options: z.infer<typeof options>; | ||
}; | ||
|
||
export default function UpdateLicenses({ options }: Props) { | ||
const { exit } = useApp(); | ||
const [working, setWorking] = useState(false); | ||
useEffect(() => { | ||
setWorking(true); | ||
|
||
const runUpdate = async () => { | ||
if (options.clearCache) { | ||
deleteLicenses(); | ||
} else { | ||
await updateLicenses({ fetchAllLicenseTexts: true }); | ||
} | ||
setWorking(false); | ||
exit(); | ||
}; | ||
|
||
void runUpdate(); | ||
}, [options, exit]); | ||
|
||
if (working) { | ||
return <SpinnerWithLabel label="Updating licenses..." />; | ||
} | ||
|
||
return <Text>Licenses updated!</Text>; | ||
} |
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./schemas.js"; | ||
export * from "./types.js"; | ||
export * from "./constants.js"; | ||
export * from "./update-licenses.js"; |
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