diff --git a/packages/docs/src/components/ErrorScope.tsx b/packages/docs/src/components/ErrorScope.tsx index c880fc3..327b22b 100644 --- a/packages/docs/src/components/ErrorScope.tsx +++ b/packages/docs/src/components/ErrorScope.tsx @@ -3,7 +3,6 @@ import Link from '@docusaurus/Link' // eslint-disable-next-line import/no-unresolved import Admonition from '@theme/Admonition' -import { clsx } from 'clsx' const errorScopeMap = { user: { diff --git a/packages/iife/pack.cts b/packages/iife/pack.cts index 85d2edb..046b3a4 100644 --- a/packages/iife/pack.cts +++ b/packages/iife/pack.cts @@ -2,10 +2,7 @@ import { cp, mkdir } from 'node:fs/promises' import { join, resolve } from 'node:path' void (async () => { - const distPath = resolve( - __dirname, - '../../build/dist/iife/', - ) + const distPath = resolve(__dirname, '../../build/dist/iife/') await mkdir(distPath, { recursive: true }) await cp(join(__dirname, 'lib/index.js'), join(distPath, 'chronocat.js')) })() diff --git a/packages/llqqnt/src/index.ts b/packages/llqqnt/src/index.ts index 7f247dd..ca1ae05 100644 --- a/packages/llqqnt/src/index.ts +++ b/packages/llqqnt/src/index.ts @@ -4,16 +4,16 @@ import { version as ccApiVersion } from '@chronocat/engine-chronocat-api/package import { version as ccEventVersion } from '@chronocat/engine-chronocat-event/package.json' import { apply as ccEvent } from '@chronocat/engine-chronocat-event' -void chronocat().then(x => { +void chronocat().then((x) => { x?.load({ name: 'engine-chronocat-api', version: ccApiVersion, - apply: ccApi + apply: ccApi, }) x?.load({ name: 'engine-chronocat-event', version: ccEventVersion, - apply: ccEvent + apply: ccEvent, }) }) diff --git a/packages/shell/src/services/logger/index.ts b/packages/shell/src/services/logger/index.ts index 5dbcbdf..ea48505 100644 --- a/packages/shell/src/services/logger/index.ts +++ b/packages/shell/src/services/logger/index.ts @@ -12,7 +12,8 @@ import { getAuthData } from '../authData' import { baseDir } from '../baseDir' import { getConfig } from '../config' import { logiriMessageCreated } from './logiri' -import { ColorFormatter, grey, red, yellow } from '../../utils/colors' +import type { ColorFormatter } from '../../utils/colors' +import { grey, red, yellow } from '../../utils/colors' interface LogOptions { code?: number diff --git a/packages/shell/src/services/logger/logiri.ts b/packages/shell/src/services/logger/logiri.ts index 20f7050..801ec90 100644 --- a/packages/shell/src/services/logger/logiri.ts +++ b/packages/shell/src/services/logger/logiri.ts @@ -9,14 +9,18 @@ export const logiriMessageCreated = async (data: object) => { const messages = await new LogiriMessager().send(d.message?.content) return messages.map( (x) => - `${blue(link( - d.channel?.id === d.guild?.id - ? `${d.channel?.name}(${d.channel?.id})` - : `${d.guild?.name}(${d.guild?.id})/${d.channel?.name}(${d.channel?.id})`, - d.guild?.avatar, - ))}${grey('-')}${cyan(link( - `${d.user?.name || d.member?.nick}(${d.user?.id})`, - d.user?.avatar, - ))}${grey(':')} ${x}`, + `${blue( + link( + d.channel?.id === d.guild?.id + ? `${d.channel?.name}(${d.channel?.id})` + : `${d.guild?.name}(${d.guild?.id})/${d.channel?.name}(${d.channel?.id})`, + d.guild?.avatar, + ), + )}${grey('-')}${cyan( + link( + `${d.user?.name || d.member?.nick}(${d.user?.id})`, + d.user?.avatar, + ), + )}${grey(':')} ${x}`, ) } diff --git a/packages/shell/src/services/logger/messager.ts b/packages/shell/src/services/logger/messager.ts index c59e5a2..e87f27b 100644 --- a/packages/shell/src/services/logger/messager.ts +++ b/packages/shell/src/services/logger/messager.ts @@ -6,7 +6,7 @@ export class LogiriMessager { private children: string[] = [] private results: string[] = [] - prepare = async () => { } + prepare = async () => {} render = async (elements: h[], flush?: boolean) => { for (const element of elements) await this.visit(element) @@ -68,13 +68,14 @@ export class LogiriMessager { const id = author?.attrs['user-id'] as string | undefined this.children.push( - grey(id - ? `${link( - `[回复${id}]`, - `http://thirdqq.qlogo.cn/headimg_dl?dst_uin=${id}&spec=640`, - )} ` - : `[回复] `) - , + grey( + id + ? `${link( + `[回复${id}]`, + `http://thirdqq.qlogo.cn/headimg_dl?dst_uin=${id}&spec=640`, + )} ` + : `[回复] `, + ), ) return } diff --git a/scripts/runOnChanged.cts b/scripts/runOnChanged.cts index ba5e81f..3cc9006 100644 --- a/scripts/runOnChanged.cts +++ b/scripts/runOnChanged.cts @@ -1,10 +1,12 @@ -import * as fs from 'node:fs' +import * as cp from 'node:child_process' import * as crypto from 'node:crypto' - +import * as fs from 'node:fs' const watchFolder = process.argv[2] if (!watchFolder) { - console.error('Usage: node -r esbuild-register runOnChanged ') + console.error( + 'Usage: node -r esbuild-register runOnChanged ', + ) process.exit(1) } const command = process.argv.slice(3).join(' ') @@ -12,10 +14,10 @@ const command = process.argv.slice(3).join(' ') // create or compare hash of files in the folder let hasChanged = false -let hashes = new Map() - -const sha1 = (data: string) => crypto.createHash('sha1').update(data).digest('hex') +let hashes = new Map() +const sha1 = (data: string) => + crypto.createHash('sha1').update(data).digest('hex') const hashFile = (file: string) => { const hash = sha1(fs.readFileSync(file, 'utf8')) @@ -28,7 +30,7 @@ const hashFile = (file: string) => { const hashFilepath = `${watchFolder}/.runOnChanged.hashes.json` const hashFolder = (folder: string) => { const files = fs.readdirSync(folder) - files.forEach((file: any) => { + files.forEach((file) => { const path = `${folder}/${file}` if (file.endsWith('.runOnChanged.hashes.json')) return @@ -42,7 +44,10 @@ const hashFolder = (folder: string) => { } if (fs.existsSync(hashFilepath)) { - const oldHashes = JSON.parse(fs.readFileSync(hashFilepath, 'utf8')) + const oldHashes = JSON.parse(fs.readFileSync(hashFilepath, 'utf8')) as Record< + string, + string + > hashes = new Map(Object.entries(oldHashes)) } @@ -51,8 +56,7 @@ hashFolder(watchFolder) if (hasChanged) { console.log('[+] Files have changed, rebuilding...') fs.writeFileSync(hashFilepath, JSON.stringify(Object.fromEntries(hashes))) - require('child_process').execSync(command, { stdio: 'inherit' }) + cp.execSync(command, { stdio: 'inherit' }) } else { console.log('[-] Files not changed :)') } -