mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-21 14:48:23 +00:00
chore: lint
This commit is contained in:
parent
71d8628e96
commit
461c8b5e25
@ -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: {
|
||||
|
@ -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'))
|
||||
})()
|
||||
|
@ -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,
|
||||
})
|
||||
})
|
||||
|
@ -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
|
||||
|
@ -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}`,
|
||||
)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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 <folder> <command>')
|
||||
console.error(
|
||||
'Usage: node -r esbuild-register runOnChanged <folder> <command>',
|
||||
)
|
||||
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<string, string>()
|
||||
|
||||
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 :)')
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user