feat: сделать split-клиент режимом по умолчанию

- добавлен operationsTree для сборки полного клиента
- удален режим генерации both
- обновлена документация под npm SDK workflow
- поднята версия пакета до 4.0.0
This commit is contained in:
2026-06-30 10:46:15 +03:00
parent bf340b3dbe
commit fe5d3ae091
9 changed files with 445 additions and 109 deletions

View File

@@ -42,9 +42,10 @@ describe('CLI', () => {
expect(exitCode).toBe(0);
const generatedFile = join(outputPath, 'MinimalAPI.ts');
const exists = await fileExists(generatedFile);
expect(exists).toBe(true);
expect(await fileExists(join(outputPath, 'index.ts'))).toBe(true);
expect(await fileExists(join(outputPath, 'http-client.ts'))).toBe(true);
expect(await fileExists(join(outputPath, 'operations-tree.ts'))).toBe(true);
expect(await fileExists(join(outputPath, 'operations', 'index.ts'))).toBe(true);
}, 30000);
test('должен генерировать монолит с кастомным именем файла', async () => {
@@ -60,6 +61,8 @@ describe('CLI', () => {
outputPath,
'--name',
customName,
'--mode',
'single',
]);
expect(exitCode).toBe(0);
@@ -86,29 +89,30 @@ describe('CLI', () => {
expect(exitCode).toBe(0);
expect(await fileExists(join(outputPath, 'index.ts'))).toBe(true);
expect(await fileExists(join(outputPath, 'http-client.ts'))).toBe(true);
expect(await fileExists(join(outputPath, 'operations-tree.ts'))).toBe(true);
expect(await fileExists(join(outputPath, 'operations', 'index.ts'))).toBe(true);
}, 30000);
test('должен генерировать both режим', async () => {
test('должен отклонять удаленный both режим', async () => {
const outputPath = join(tempDir, 'output');
const { exitCode } = await execa('bun', [
'run',
CLI_PATH,
'--input',
FIXTURES.MINIMAL,
'--output',
outputPath,
'--name',
'CustomApi',
'--mode',
'both',
]);
expect(exitCode).toBe(0);
expect(await fileExists(join(outputPath, 'CustomApi.ts'))).toBe(true);
expect(await fileExists(join(outputPath, 'index.ts'))).toBe(true);
expect(await fileExists(join(outputPath, 'operations', 'index.ts'))).toBe(true);
try {
await execa('bun', [
'run',
CLI_PATH,
'--input',
FIXTURES.MINIMAL,
'--output',
outputPath,
'--mode',
'both',
]);
throw new Error('Should have thrown');
} catch (error: any) {
expect(error.exitCode).not.toBe(0);
expect(error.stderr).toContain('Некорректный режим генерации');
expect(error.stderr).toContain('split, single');
}
}, 30000);
test('должен отображать версию с --version', async () => {