Merge branch 'check-all' into 'main'

Type check scripts/

See merge request soapbox-pub/ditto!595
This commit is contained in:
Alex Gleason 2024-11-21 16:28:22 +00:00
commit 1d803b3f32
5 changed files with 8 additions and 5 deletions

View file

@ -10,7 +10,7 @@
"nostr:pull": "deno run -A --env-file --deny-read=.env scripts/nostr-pull.ts", "nostr:pull": "deno run -A --env-file --deny-read=.env scripts/nostr-pull.ts",
"debug": "deno run -A --env-file --deny-read=.env --inspect src/server.ts", "debug": "deno run -A --env-file --deny-read=.env --inspect src/server.ts",
"test": "deno test -A --env-file=.env.test --deny-read=.env --junit-path=./deno-test.xml", "test": "deno test -A --env-file=.env.test --deny-read=.env --junit-path=./deno-test.xml",
"check": "deno check --allow-import src/server.ts", "check": "deno check --allow-import .",
"nsec": "deno run scripts/nsec.ts", "nsec": "deno run scripts/nsec.ts",
"admin:event": "deno run -A --env-file --deny-read=.env scripts/admin-event.ts", "admin:event": "deno run -A --env-file --deny-read=.env scripts/admin-event.ts",
"admin:role": "deno run -A --env-file --deny-read=.env scripts/admin-role.ts", "admin:role": "deno run -A --env-file --deny-read=.env scripts/admin-role.ts",

View file

@ -30,7 +30,7 @@ for await (const line of readable) {
await store.event(event); await store.event(event);
console.warn(`(${count}) Event<${event.kind}> ${event.id}`); console.warn(`(${count}) Event<${event.kind}> ${event.id}`);
} catch (error) { } catch (error) {
if (error.message.includes('violates unique constraint')) { if (error instanceof Error && error.message.includes('violates unique constraint')) {
console.warn(`(${count}) Skipping existing event... ${event.id}`); console.warn(`(${count}) Skipping existing event... ${event.id}`);
} else { } else {
console.error(error); console.error(error);

View file

@ -12,9 +12,12 @@ for await (const msg of store.req([{ kinds: [0] }])) {
const search = [name, nip05].filter(Boolean).join(' ').trim(); const search = [name, nip05].filter(Boolean).join(' ').trim();
try { try {
await kysely.insertInto('author_search').values({ await kysely.insertInto('author_stats').values({
pubkey, pubkey,
search, search,
followers_count: 0,
following_count: 0,
notes_count: 0,
}).onConflict( }).onConflict(
(oc) => (oc) =>
oc.column('pubkey') oc.column('pubkey')

View file

@ -31,7 +31,7 @@ const importUsers = async (
try { try {
await doEvent(event); await doEvent(event);
} catch (error) { } catch (error) {
if (error.message.includes('violates unique constraint')) { if (error instanceof Error && error.message.includes('violates unique constraint')) {
console.warn(`Skipping existing event ${event.id}...`); console.warn(`Skipping existing event ${event.id}...`);
} else { } else {
console.error(error); console.error(error);

View file

@ -56,7 +56,7 @@ if (import.meta.main) {
}) })
.then(async (blob) => .then(async (blob) =>
await pngToIco(Buffer.from(await blob.arrayBuffer())) await pngToIco(Buffer.from(await blob.arrayBuffer()))
.then(async (buf) => await Deno.writeFile('./public/favicon.ico', buf)) .then(async (buf) => await Deno.writeFile('./public/favicon.ico', new Uint8Array(buf)))
); );
} catch (e) { } catch (e) {
die(1, `Error generating favicon from url ${image}: "${e}". Please check this or try again without --image.`); die(1, `Error generating favicon from url ${image}: "${e}". Please check this or try again without --image.`);