Skip to content

Commit ecbb660

Browse files
[autofix.ci] apply automated fixes
1 parent 9afe21d commit ecbb660

File tree

2 files changed

+28
-30
lines changed

2 files changed

+28
-30
lines changed

app/components/LicenseDisplay.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const hasAnyValidLicense = computed(() => tokens.value.some(t => t.type === 'lic
5858
class="border border-amber-600/40 bg-amber-500/10 rounded-lg inline-flex justify-start items-center mt-1 gap-x-1 py-[2px] px-[3px]"
5959
>
6060
<p class="text-md text-amber-800 dark:text-amber-400">
61-
{{ $t("package.versions.license_change_warning") }}
61+
{{ $t('package.versions.license_change_warning') }}
6262
</p>
6363
<TooltipApp interactive position="top">
6464
<span
Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,74 @@
1-
import type { MaybeRefOrGetter } from "vue";
2-
import { toValue } from "vue";
1+
import type { MaybeRefOrGetter } from 'vue'
2+
import { toValue } from 'vue'
33

44
export interface LicenseChange {
5-
from: string;
6-
to: string;
7-
version: string;
5+
from: string
6+
to: string
7+
version: string
88
}
99

1010
export interface LicenseChangesResult {
11-
changes: LicenseChange[];
11+
changes: LicenseChange[]
1212
}
1313

1414
// Type definitions for npm registry response
1515
interface NpmRegistryVersion {
16-
version: string;
17-
license?: string;
16+
version: string
17+
license?: string
1818
}
1919

2020
// for registry responses of $fetch function, the type includes the key versions as well as many others too.
2121
interface NpmRegistryResponse {
22-
time: Record<string, string>;
23-
versions: Record<string, NpmRegistryVersion>;
22+
time: Record<string, string>
23+
versions: Record<string, NpmRegistryVersion>
2424
}
2525

2626
/**
2727
* Composable to detect license changes across all versions of a package
2828
*/
29-
export function useLicenseChanges(
30-
packageName: MaybeRefOrGetter<string | null | undefined>,
31-
) {
29+
export function useLicenseChanges(packageName: MaybeRefOrGetter<string | null | undefined>) {
3230
return useAsyncData<LicenseChangesResult>(
3331
() => `license-changes:${toValue(packageName)}`,
3432
async () => {
35-
const name = toValue(packageName);
36-
if (!name) return { changes: [] };
33+
const name = toValue(packageName)
34+
if (!name) return { changes: [] }
3735

3836
// Fetch full package metadata from npm registry
39-
const url = `https://registry.npmjs.org/${name}`;
40-
const data = await $fetch<NpmRegistryResponse>(url);
37+
const url = `https://registry.npmjs.org/${name}`
38+
const data = await $fetch<NpmRegistryResponse>(url)
4139

42-
const changes: LicenseChange[] = [];
43-
let prevLicense: string | undefined = undefined;
40+
const changes: LicenseChange[] = []
41+
let prevLicense: string | undefined = undefined
4442

4543
// `data.versions` is an object with version keys
46-
const versions = Object.values(data.versions) as NpmRegistryVersion[];
44+
const versions = Object.values(data.versions) as NpmRegistryVersion[]
4745

4846
// Sort versions ascending to compare chronologically
4947
versions.sort((a, b) => {
50-
const dateA = new Date(data.time[a.version] as string).getTime();
51-
const dateB = new Date(data.time[b.version] as string).getTime();
48+
const dateA = new Date(data.time[a.version] as string).getTime()
49+
const dateB = new Date(data.time[b.version] as string).getTime()
5250

5351
// Ascending order (oldest to newest)
54-
return dateA - dateB;
55-
});
52+
return dateA - dateB
53+
})
5654

5755
// Detect license changes
5856
for (const version of versions) {
59-
const license = (version.license as string) ?? "UNKNOWN";
57+
const license = (version.license as string) ?? 'UNKNOWN'
6058
if (prevLicense && license !== prevLicense) {
6159
changes.push({
6260
from: prevLicense,
6361
to: license,
6462
version: version.version as string,
65-
});
63+
})
6664
}
67-
prevLicense = license;
65+
prevLicense = license
6866
}
69-
return { changes };
67+
return { changes }
7068
},
7169
{
7270
default: () => ({ changes: [] }),
7371
watch: [() => toValue(packageName)],
7472
},
75-
);
73+
)
7674
}

0 commit comments

Comments
 (0)