chore(root): migrate to biome

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-09-16 12:20:40 +02:00
parent 1f6e198336
commit 32e91959f6
383 changed files with 1943 additions and 3085 deletions

View File

@@ -1,5 +1,5 @@
import fs from 'fs';
import path from 'path';
import fs from 'node:fs';
import path from 'node:path';
function transform(data: any) {
const obj: Record<string, unknown> = {};
@@ -22,7 +22,7 @@ async function main() {
// Get document, or throw exception on error
try {
const data = await fetch(
'https://s3-eu-west-1.amazonaws.com/snowplow-hosted-assets/third-party/referer-parser/referers-latest.json'
'https://s3-eu-west-1.amazonaws.com/snowplow-hosted-assets/third-party/referer-parser/referers-latest.json',
).then((res) => res.json());
fs.writeFileSync(
@@ -34,11 +34,11 @@ async function main() {
`// The orginal referers.yml is based on Piwik's SearchEngines.php and Socials.php, copyright 2012 Matthieu Aubry and available under the GNU General Public License v3.`,
'',
`const referrers: Record<string, { type: string, name: string }> = ${JSON.stringify(
transform(data)
transform(data),
)} as const;`,
'export default referrers;',
].join('\n'),
'utf-8'
'utf-8',
);
} catch (e) {
console.log(e);

View File

@@ -1,8 +1,8 @@
import { ch, chQuery, TABLE_NAMES } from '@openpanel/db';
import { TABLE_NAMES, ch, chQuery } from '@openpanel/db';
async function main() {
const projects = await chQuery(
`SELECT distinct project_id FROM ${TABLE_NAMES.events} ORDER BY project_id`
`SELECT distinct project_id FROM ${TABLE_NAMES.events} ORDER BY project_id`,
);
const withOrigin = [];
@@ -10,10 +10,10 @@ async function main() {
try {
const [eventWithOrigin, eventWithoutOrigin] = await Promise.all([
await chQuery(
`SELECT * FROM ${TABLE_NAMES.events} WHERE origin != '' AND project_id = '${project.project_id}' ORDER BY created_at DESC LIMIT 1`
`SELECT * FROM ${TABLE_NAMES.events} WHERE origin != '' AND project_id = '${project.project_id}' ORDER BY created_at DESC LIMIT 1`,
),
await chQuery(
`SELECT * FROM ${TABLE_NAMES.events} WHERE origin = '' AND project_id = '${project.project_id}' AND path != '' ORDER BY created_at DESC LIMIT 1`
`SELECT * FROM ${TABLE_NAMES.events} WHERE origin = '' AND project_id = '${project.project_id}' AND path != '' ORDER BY created_at DESC LIMIT 1`,
),
]);
@@ -22,7 +22,7 @@ async function main() {
console.log(`- Origin: ${eventWithOrigin[0].origin}`);
withOrigin.push(project.project_id);
const events = await chQuery(
`SELECT count(*) as count FROM ${TABLE_NAMES.events} WHERE project_id = '${project.project_id}' AND path != '' AND origin = ''`
`SELECT count(*) as count FROM ${TABLE_NAMES.events} WHERE project_id = '${project.project_id}' AND path != '' AND origin = ''`,
);
console.log(`🤠🤠🤠🤠 Will update ${events[0]?.count} events`);
await ch.command({
@@ -35,20 +35,20 @@ async function main() {
if (!eventWithOrigin[0] && eventWithoutOrigin[0]) {
console.log(
`😧 Project ${project.project_id} has no events with origin (last event ${eventWithoutOrigin[0].created_at})`
`😧 Project ${project.project_id} has no events with origin (last event ${eventWithoutOrigin[0].created_at})`,
);
console.log('- NO ORIGIN');
}
if (!eventWithOrigin[0] && !eventWithoutOrigin[0]) {
console.log(
`🔥 WARNING: Project ${project.project_id} has no events at all?!?!?!`
`🔥 WARNING: Project ${project.project_id} has no events at all?!?!?!`,
);
}
if (eventWithOrigin[0] && !eventWithoutOrigin[0]) {
console.log(
`✅ Project ${project.project_id} has all events with origin!!!`
`✅ Project ${project.project_id} has all events with origin!!!`,
);
}
console.log('');