fix: 修复API发布CI阻断

This commit is contained in:
sunlei 2026-06-16 01:09:20 +08:00
parent 7edbb97e70
commit 2064fdf014
3 changed files with 46 additions and 1 deletions

View File

@ -119,7 +119,8 @@ const getControlledRoots = (options: Required<QqbotPluginCliOptions>) => {
if (fs.existsSync(path.join(cwd, 'package.json'))) {
const workspaceRoot = findWorkspaceRoot(cwd);
if (workspaceRoot) roots.push(path.join(workspaceRoot, '.kt-workspace'));
const artifactRoot = workspaceRoot || path.resolve(cwd, '..', '..');
roots.push(path.join(artifactRoot, '.kt-workspace'));
}
return roots;

View File

@ -151,6 +151,40 @@ describe('QQBot plugin CLI', () => {
expect(path.dirname(packed.packagePath || '')).toBe(packageRoot);
});
it('allows Jenkins single-repo checkout artifact roots without root AGENTS.md', async () => {
const ciProjectRoot = path.join(
sandbox,
'agent',
'workspace',
'KT-Template_KT-Template-API_main',
);
fs.mkdirSync(ciProjectRoot, { recursive: true });
fs.writeFileSync(
path.join(ciProjectRoot, 'package.json'),
JSON.stringify({ name: 'kt-template-online-api' }),
);
const pluginRoot = path.resolve(
ciProjectRoot,
'..',
'..',
'.kt-workspace',
'tmp',
'smoke-plugin',
);
const created = await runQqbotPluginCli(
['create', 'smoke-plugin', '--out', pluginRoot],
silentCliOptions(ciProjectRoot),
);
expect(created).toMatchObject({
command: 'create',
exitCode: 0,
pluginRoot,
});
expect(fs.existsSync(path.join(pluginRoot, 'plugin.json'))).toBe(true);
});
it('rejects unsafe create output paths before writing files', async () => {
const outsideRoot = path.resolve(sandbox, '..', 'outside-plugin');

View File

@ -1,3 +1,5 @@
import * as fs from 'fs';
import {
checkRelationList,
fuzzySearch,
@ -9,6 +11,14 @@ import {
} from '@/modules/qqbot/plugins/bangdream/src/domain/search/fuzzy-search-rule.registry';
import type { FuzzySearchResult } from '@/modules/qqbot/plugins/bangdream/src/domain/search/fuzzy-search.types';
import { createBangDreamEntityMatcher } from '@/modules/qqbot/plugins/bangdream/src/domain/search/entity-list-matcher';
import { configureBangDreamRuntimeIo } from '@/modules/qqbot/plugins/bangdream/src/infrastructure/integration/runtime-io';
beforeAll(() => {
configureBangDreamRuntimeIo({
readJsonFileSync: (filePath) =>
JSON.parse(fs.readFileSync(filePath, 'utf8')),
});
});
describe('BangDream fuzzy search helpers', () => {
it('parses number, level, relation and quoted fallback keywords', () => {