Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 27, 2020
2 parents cb00d8f + 16fd63e commit aefa45a
Show file tree
Hide file tree
Showing 45 changed files with 364 additions and 207 deletions.
14 changes: 9 additions & 5 deletions build/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import { resolve } from 'path'

const args = ['jest', '--coverage']

if (process.argv[2]) {
args.push(process.argv[2])
if (process.argv[3]) {
args.push('--collectCoverageFrom', `**/${process.argv[3]}/**/*.ts`)
const [,, argv2, argv3] = process.argv

if (argv2 && !argv2.startsWith('-')) {
args.push(argv2)
if (argv3 && !argv3.startsWith('-')) {
args.push('--collectCoverageFrom', `**/${argv3}/**/*.ts`, ...process.argv.slice(3))
} else {
args.push(...process.argv.slice(3))
}
} else {
args.push('packages/.+\\.spec\\.ts')
args.push('packages/.+\\.spec\\.ts', ...process.argv.slice(2))
}

const child = spawn('npx', args, { stdio: 'inherit' })
Expand Down
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ module.exports = {
moduleNameMapper: {
"koishi-(test-utils|(database|plugin)-[\\w-]+)(/dist)?": "<rootDir>/packages/$1/src",
"koishi-[\\w-]+": "<rootDir>/packages/$0/src",
"shiki-core": "<rootDir>/bots/shiki/core",
"touhou-words": "<rootDir>/bots/shiki/lib/touhou-words",
"shiki-universe": "<rootDir>/bots/shiki/lib/shiki-universe/src",
"inference-puzzles": "<rootDir>/bots/shiki/lib/inference-puzzles/src",
},
coverageProvider: 'v8',
coverageReporters: ['text', 'lcov'],
coveragePathIgnorePatterns: [
'tests/',
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"version": "1.0.0",
"license": "MIT",
"devDependencies": {
"@octokit/rest": "^16.38.1",
"@octokit/rest": "^16.38.3",
"@types/cross-spawn": "^6.0.1",
"@types/fs-extra": "^8.0.1",
"@types/jest": "^24.9.0",
"@types/node": "^13.1.8",
"@types/jest": "^24.9.1",
"@types/node": "^13.5.0",
"@types/semver": "^6.2.0",
"@typescript-eslint/eslint-plugin": "^2.17.0",
"@typescript-eslint/parser": "^2.17.0",
Expand All @@ -44,15 +44,15 @@
"express": "^4.17.1",
"fs-extra": "^8.1.0",
"globby": "^11.0.0",
"jest": "^24.9.0",
"jest": "^25.1.0",
"kleur": "^3.0.3",
"latest-version": "^5.1.0",
"open": "^7.0.0",
"ora": "^4.0.3",
"p-map": "^3.0.0",
"prompts": "^2.3.0",
"semver": "^7.1.1",
"ts-jest": "^24.3.0",
"ts-jest": "^25.0.0",
"ts-node": "^8.6.2",
"typescript": "^3.7.5"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/database-level/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-database-level",
"description": "Leveldb support for Koishi",
"version": "1.0.8",
"version": "1.0.9",
"main": "dist/index.js",
"files": [
"dist"
Expand Down Expand Up @@ -33,12 +33,12 @@
"leveldb"
],
"devDependencies": {
"koishi-test-utils": "^2.1.0"
"koishi-test-utils": "^3.0.0"
},
"dependencies": {
"@types/leveldown": "^4.0.2",
"@types/levelup": "^4.3.0",
"koishi-core": "^1.6.0",
"koishi-core": "^1.7.0",
"koishi-utils": "^1.0.2",
"leveldown": "^5.4.1",
"levelup": "^4.3.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/database-memory/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-database-memory",
"description": "An in-memory database implementation for Koishi",
"version": "1.0.1",
"version": "1.0.2",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand All @@ -22,7 +22,7 @@
},
"homepage": "https://github.com/koishijs/koishi/tree/master/packages/database-memory#readme",
"dependencies": {
"koishi-core": "^1.6.0",
"koishi-core": "^1.7.0",
"koishi-utils": "^1.0.2"
}
}
6 changes: 3 additions & 3 deletions packages/database-mysql/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-database-mysql",
"description": "MySQL support for Koishi",
"version": "1.0.8",
"version": "1.0.9",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand Down Expand Up @@ -35,8 +35,8 @@
"@types/mysql": "^2.15.8"
},
"dependencies": {
"koishi-core": "^1.6.0",
"koishi-core": "^1.7.0",
"koishi-utils": "^1.0.2",
"mysql": "^2.18.0"
"mysql": "^2.18.1"
}
}
6 changes: 3 additions & 3 deletions packages/database-sqlite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "koishi-database-sqlite",
"version": "1.0.0-alpha.4",
"version": "1.0.0-alpha.5",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand All @@ -22,10 +22,10 @@
"homepage": "https://github.com/koishijs/koishi/tree/master/packages/database-sqlite#readme",
"devDependencies": {
"@types/sqlite3": "^3.1.6",
"koishi-test-utils": "^2.1.0"
"koishi-test-utils": "^3.0.0"
},
"dependencies": {
"koishi-core": "^1.6.0",
"koishi-core": "^1.7.0",
"koishi-utils": "^1.0.2",
"sqlite3": "^4.1.1"
}
Expand Down
10 changes: 5 additions & 5 deletions packages/koishi-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi",
"description": "A QQ bot framework based on CQHTTP",
"version": "1.6.0",
"version": "1.7.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand Down Expand Up @@ -33,16 +33,16 @@
"koishi"
],
"devDependencies": {
"@types/js-yaml": "^3.12.1",
"@types/js-yaml": "^3.12.2",
"@types/prompts": "^2.0.3"
},
"dependencies": {
"cac": "^6.5.5",
"js-yaml": "^3.13.1",
"kleur": "^3.0.3",
"koishi-core": "^1.6.0",
"koishi-plugin-common": "^2.0.1",
"koishi-plugin-schedule": "^1.0.4",
"koishi-core": "^1.7.0",
"koishi-plugin-common": "^2.1.0",
"koishi-plugin-schedule": "^1.0.5",
"koishi-utils": "^1.0.2",
"prompts": "^2.3.0"
}
Expand Down
20 changes: 10 additions & 10 deletions packages/koishi-cli/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import kleur from 'kleur'

export namespace logger {
export function info (message: string, logLevel?: number) {
export function info (message: string, logLevel?: number, scope?: string) {
if (logLevel < 2) return
console.log(`${kleur.blue('info')}`, message)
console.log(`${kleur.blue(scope ? 'info:' + scope : 'info')}`, message)
}

export function error (message: string, logLevel?: number) {
export function error (message: string, logLevel?: number, scope?: string) {
if (logLevel < 1) return
console.log(`${kleur.red('error')}`, message)
console.log(`${kleur.red(scope ? 'error:' + scope : 'error')}`, message)
}

export function warn (message: string, logLevel?: number) {
export function warn (message: string, logLevel?: number, scope?: string) {
if (logLevel < 2) return
console.log(`${kleur.yellow('warning')}`, message)
console.log(`${kleur.yellow(scope ? 'warning:' + scope : 'warning')}`, message)
}

export function success (message: string, logLevel?: number) {
export function success (message: string, logLevel?: number, scope?: string) {
if (logLevel < 1) return
console.log(`${kleur.green('success')}`, message)
console.log(`${kleur.green(scope ? 'success:' + scope : 'success')}`, message)
}

export function debug (message: string, logLevel?: number) {
export function debug (message: string, logLevel?: number, scope?: string) {
if (logLevel < 3) return
console.log(`${kleur.magenta('debug')}`, message)
console.log(`${kleur.magenta(scope ? 'debug:' + scope : 'debug')}`, message)
}
}
2 changes: 1 addition & 1 deletion packages/koishi-cli/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ appList.forEach((app) => {
const { logLevel = 2, logFilter = {} } = app.options as AppConfig

app.receiver.on('logger', (scope, message, type) => {
logger[type](message, Math.min(logFilter[scope] ?? logLevel, baseLogLevel))
logger[type](message, Math.min(logFilter[scope] ?? logLevel, baseLogLevel), scope)
})
})

Expand Down
6 changes: 3 additions & 3 deletions packages/koishi-core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-core",
"description": "Core features for Koishi",
"version": "1.6.0",
"version": "1.7.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand Down Expand Up @@ -35,8 +35,8 @@
"@types/debug": "^4.1.5",
"@types/ws": "^7.2.0",
"get-port": "^5.1.1",
"koishi-database-memory": "^1.0.1",
"koishi-test-utils": "^2.1.0"
"koishi-database-memory": "^1.0.2",
"koishi-test-utils": "^3.0.0"
},
"dependencies": {
"axios": "^0.19.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/koishi-core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export class App extends Context {
if (fuzzy && !nickname && _message.match(/^\S/)) continue
const result: ParsedLine = oneArg
? { rest: '', options: {}, unknown: [], args: [_message.trim()] }
: command.parse(_message)
: command.parse(_message.trim())
result.options = { ...options, ...result.options }
result.args.unshift(...args)
parsedArgv = { meta, command, ...result }
Expand All @@ -328,7 +328,7 @@ export class App extends Context {
if (meta.messageType === 'group') {
// attach group data
const groupFields = new Set<GroupField>(['flag', 'assignee'])
this.receiver.emit('before-group', groupFields, parsedArgv || { meta })
this.emitEvent(meta, 'before-group', groupFields, parsedArgv || { meta })
const group = await this.database.observeGroup(meta.groupId, Array.from(groupFields))
Object.defineProperty(meta, '$group', { value: group, writable: true })

Expand All @@ -344,15 +344,15 @@ export class App extends Context {

// attach user data
const userFields = new Set<UserField>(['flag'])
this.receiver.emit('before-user', userFields, parsedArgv || { meta })
this.emitEvent(meta, 'before-user', userFields, parsedArgv || { meta })
const user = await this.database.observeUser(meta.userId, Array.from(userFields))
Object.defineProperty(meta, '$user', { value: user, writable: true })

// ignore some user calls
if (user.flag & UserFlag.ignore) return

// emit attach event
this.receiver.emit('attach', meta)
this.emitEvent(meta, 'attach', meta)
}

// execute command
Expand Down
2 changes: 1 addition & 1 deletion packages/koishi-core/src/sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class Sender {
if (app.options.token) {
headers.Authorization = `Token ${app.options.token}`
}
const uri = new URL(action, this.app.options.server).href
const uri = new URL(action, app.options.server).href
const { data } = await axios.get(uri, { params, headers })
return data
}
Expand Down
Loading

0 comments on commit aefa45a

Please sign in to comment.