-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add third-party license management and in-app viewer #4
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,54 @@ | ||
| name: Update Third-Party Licenses | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'package-lock.json' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| update-licenses: | ||
| name: Update Licenses | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: npm | ||
|
|
||
| - run: npm ci | ||
|
|
||
| - name: Generate third-party license file | ||
| run: npx generate-license-file --input package.json --output THIRD_PARTY_LICENSES.txt --overwrite | ||
|
|
||
| - name: Check for changes | ||
| id: check | ||
| run: | | ||
| if git diff --quiet THIRD_PARTY_LICENSES.txt; then | ||
| echo "changed=false" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "changed=true" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Create Pull Request | ||
| if: steps.check.outputs.changed == 'true' | ||
| uses: peter-evans/create-pull-request@v7 | ||
| with: | ||
| commit-message: 'chore: update third-party licenses' | ||
| title: 'chore: update third-party licenses' | ||
| body: | | ||
| This PR updates the THIRD_PARTY_LICENSES.txt file with the latest | ||
| license information from npm dependencies. | ||
|
|
||
| Auto-generated by the licenses workflow. | ||
| branch: chore/update-licenses | ||
| delete-branch: true | ||
| labels: dependencies |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,17 @@ | ||
| import { ipcMain, app } from 'electron'; | ||
| import fs from 'fs'; | ||
| import path from 'path'; | ||
|
|
||
| export function registerLicenseHandlers(): void { | ||
| ipcMain.handle('app:get-licenses', async () => { | ||
| const licensePath = app.isPackaged | ||
| ? path.join(process.resourcesPath, 'THIRD_PARTY_LICENSES.txt') | ||
| : path.join(app.getAppPath(), 'THIRD_PARTY_LICENSES.txt'); | ||
|
|
||
| try { | ||
| return await fs.promises.readFile(licensePath, 'utf-8'); | ||
| } catch { | ||
| return null; | ||
| } | ||
| }); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,68 @@ | ||
| <script lang="ts"> | ||
| import { X, Loader } from '@lucide/svelte'; | ||
| import { getLicenses } from '$lib/utils/ipc'; | ||
| import * as m from '$paraglide/messages'; | ||
|
|
||
| let { | ||
| open = $bindable(), // eslint-disable-line @typescript-eslint/no-useless-default-assignment -- $bindable() required for Svelte bind: | ||
| }: { open: boolean } = $props(); | ||
|
|
||
| let licenseText = $state<string | null>(null); | ||
| let loading = $state(false); | ||
| let error = $state<string | null>(null); | ||
|
|
||
| $effect(() => { | ||
| if (open && licenseText === null) { | ||
| loading = true; | ||
| error = null; | ||
| getLicenses() | ||
| .then((text) => { | ||
| licenseText = text; | ||
| }) | ||
| .catch((e: unknown) => { | ||
| error = (e as Error).message; | ||
| }) | ||
| .finally(() => { | ||
| loading = false; | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| function close() { | ||
| open = false; | ||
| } | ||
| </script> | ||
|
|
||
| {#if open} | ||
| <dialog class="modal modal-open"> | ||
| <div class="modal-box flex h-[80vh] max-w-4xl flex-col"> | ||
| <div class="flex items-center justify-between"> | ||
| <h2 class="text-lg font-semibold">{m.licenses_title()}</h2> | ||
| <button onclick={close} class="btn btn-ghost btn-sm btn-square"> | ||
| <X size={20} /> | ||
| </button> | ||
| </div> | ||
|
|
||
| <div class="mt-4 flex-1 overflow-auto"> | ||
| {#if loading} | ||
| <div class="flex items-center justify-center py-12"> | ||
| <Loader size={24} class="animate-spin" /> | ||
| </div> | ||
| {:else if error} | ||
| <p class="text-error text-sm">{error}</p> | ||
| {:else if licenseText} | ||
| <pre class="text-base-content/70 font-mono text-xs leading-relaxed whitespace-pre-wrap">{licenseText}</pre> | ||
| {:else} | ||
| <p class="text-base-content/50 text-sm">{m.licenses_notFound()}</p> | ||
| {/if} | ||
| </div> | ||
|
|
||
| <div class="modal-action"> | ||
| <button onclick={close} class="btn">{m.common_button_close()}</button> | ||
| </div> | ||
| </div> | ||
| <form method="dialog" class="modal-backdrop"> | ||
| <button onclick={close}>close</button> | ||
| </form> | ||
| </dialog> | ||
| {/if} | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error object
ein acatchblock is of typeunknown. Directly casting it withas Erroris not type-safe and can lead to runtime errors if the caught value is not anErrorobject. It's better to check ifeis an instance ofErrorbefore accessing its properties.