Skip to content

Commit

Permalink
fix(help): fix regression bug or not showing usages from rate-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed May 21, 2022
1 parent d5802cb commit 1aac4df
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions build/dtsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async function prepareBuild(nodes: Node[]) {
async function bundleNodes(nodes: Node[]) {
for (const node of nodes) {
await fs.mkdir(resolve(cwd, node.path, 'lib'), { recursive: true })
console.log('building', node.path)
await spawnAsync(['yarn', 'dtsc'], {
cwd: resolve(cwd, node.path),
})
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/command/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ declare module 'cordis' {
'command/before-execute'(argv: Argv): Awaitable<void | string>
'command/before-attach-channel'(argv: Argv, fields: Set<Channel.Field>): void
'command/before-attach-user'(argv: Argv, fields: Set<User.Field>): void
'help/command'(output: string[], command: Command, session: Session): void
'help/option'(output: string, option: Argv.OptionDeclaration, command: Command, session: Session): string
}
}

Expand Down
1 change: 0 additions & 1 deletion packages/core/src/command/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ export namespace Argv {
/** hide the option by default */
hidden?: boolean | ((session: Session) => boolean)
authority?: number
notUsage?: boolean
descPath?: string
}

Expand Down
4 changes: 2 additions & 2 deletions packages/core/tests/runtime.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ const cmd1 = app.command('cmd1 <arg1>', { authority: 2 })
.shortcut('foo1', { args: ['bar'] })
.shortcut('foo4', { fuzzy: true })
.option('--bar', '', { authority: 3 })
.option('--baz', '', { notUsage: true })
.option('--baz', '')
.action(({}, arg) => 'cmd1:' + arg)

const cmd2 = app.command('cmd2')
.userFields(['id'])
.shortcut('foo2', { options: { text: 'bar' } })
.shortcut('foo3', { prefix: true, fuzzy: true })
.option('--bar', '', { authority: 3 })
.option('--baz', '', { notUsage: true })
.option('--baz', '')
.action(({ session }) => 'cmd2:' + session.userId)

app.middleware((session, next) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@koishijs/segment": "^1.1.1",
"cosmokit": "^1.1.2",
"reggol": "^1.0.3",
"schemastery": "^3.4.0",
"schemastery": "^3.4.1",
"supports-color": "^8.1.1"
}
}
7 changes: 7 additions & 0 deletions plugins/a11y/rate-limit/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Argv, Command, Context, Dict, Schema, Session, Time, User } from 'koishi'
import { adminUser } from '@koishijs/helpers'
import {} from '@koishijs/plugin-help'

declare module 'koishi' {
namespace Command {
Expand All @@ -17,6 +18,12 @@ declare module 'koishi' {
usage: Dict<number>
timers: Dict<number>
}

namespace Argv {
interface OptionConfig {
notUsage?: boolean
}
}
}

export interface Config {}
Expand Down
2 changes: 1 addition & 1 deletion plugins/a11y/switch/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function apply(ctx: Context, config: Config = {}) {

names = deduplicate(names)
const forbidden = names.filter((name) => {
const command = ctx.app._commands.get(name)
const command = ctx.$commander._commands.get(name)
return command && command.config.authority >= session.user.authority
})
if (forbidden.length) return session.text('.forbidden', [forbidden.join(', ')])
Expand Down
2 changes: 1 addition & 1 deletion plugins/adapter/qqguild/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const AdapterConfig: Schema<AdapterConfig> = Schema.intersect([
Schema.object({
sandbox: Schema.boolean().description('是否开启沙箱模式。').default(true),
endpoint: Schema.string().role('url').description('API 入口地址。').default('https://api.sgroup.qq.com/'),
authType: Schema.union(['bot', 'bearer']).description('采用的验证方式。').default('bot'),
authType: Schema.union(['bot', 'bearer'] as const).description('采用的验证方式。').default('bot'),
}),
Adapter.WebSocketClient.Config,
])
Expand Down
2 changes: 1 addition & 1 deletion plugins/adapter/telegram/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const BotConfig: Schema<BotConfig> = Schema.intersect([
Quester.createSchema({
endpoint: 'https://api.telegram.org',
}),
])
] as const)

export class TelegramBot extends Bot<BotConfig> {
static schema = AdapterConfig
Expand Down
6 changes: 5 additions & 1 deletion plugins/common/help/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ declare module 'koishi' {
}
}
}

interface Events {
'help/command'(output: string[], command: Command, session: Session): void
'help/option'(output: string, option: Argv.OptionDeclaration, command: Command, session: Session): string
}
}

interface HelpOptions {
Expand All @@ -25,7 +30,6 @@ export function enableHelp<U extends User.Field, G extends Channel.Field, A exte
return cmd.option('help', '-h', {
hidden: true,
descPath: 'commands.help.options.help',
notUsage: true,
})
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/frontend/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"element-plus": "^2.1.11",
"marked": "^4.0.15",
"sass": "^1.51.0",
"schemastery": "^3.4.0",
"schemastery": "^3.4.1",
"vite": "^2.9.8",
"vue": "^3.2.33",
"vue-router": "^4.0.14"
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es2020",
"target": "es2019",
"module": "commonjs",
"declaration": true,
"emitDeclarationOnly": true,
Expand Down

0 comments on commit 1aac4df

Please sign in to comment.