chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
60158935f4
commit
6519682885
15831 files changed
+3063428
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import type { TestWorld } from '@test/fixtures/kernel'
|
||||
import { testContext } from '@test/fixtures/kernel'
|
||||
import { afterEach, expect, it } from 'vite-plus/test'
|
||||
import { commands } from '@/plugins/commands'
|
||||
import { config } from '@/plugins/config'
|
||||
|
||||
const worlds: TestWorld[] = []
|
||||
afterEach(async () => {
|
||||
for (const w of worlds.splice(0)) await w.stop()
|
||||
})
|
||||
|
||||
it('writes a value that the config service can read back', async () => {
|
||||
const w = await testContext({ login: false, argv: ['set', 'config', 'http.timeout', '5000'] })
|
||||
worlds.push(w)
|
||||
expect(await (await w.ctx.get(commands)).run()).toBe(0)
|
||||
expect(await (await w.ctx.get(config)).get('http.timeout')).toBe(5000)
|
||||
})
|
||||
|
||||
it('rejects an unknown key with exit 2', async () => {
|
||||
const w = await testContext({ login: false, argv: ['set', 'config', 'nope', '1'] })
|
||||
worlds.push(w)
|
||||
await expect((await w.ctx.get(commands)).run()).rejects.toMatchObject({
|
||||
code: 'config_invalid_key',
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { CommandContext } from '@/plugins/base'
|
||||
import { z } from 'zod'
|
||||
import { Command } from '@/plugins/commands/command'
|
||||
import { config } from '@/plugins/config'
|
||||
|
||||
const INPUT = z.object({ key: z.string(), value: z.string() })
|
||||
|
||||
export default class ConfigSet extends Command<typeof INPUT> {
|
||||
static override summary = 'Set a local config value'
|
||||
static override effect = 'write' as const
|
||||
static override input = INPUT
|
||||
static override positional = ['key', 'value'] as const
|
||||
|
||||
async run(input: z.infer<typeof INPUT>, ctx: CommandContext) {
|
||||
const configService = await ctx.get(config)
|
||||
await configService.set(input.key, input.value)
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user