719032b19f
Update Schema / Update configuration json schema (push) Has been cancelled
Memory Benchmark / Memory Test (Full Analysis) (push) Has been cancelled
CI Quality / Lint GitHub Actions (actionlint) (push) Has been cancelled
CI Quality / Lint GitHub Actions (zizmor) (push) Has been cancelled
CI Quality / Check typos (push) Has been cancelled
CI / Test coverage (push) Has been cancelled
CI / Test (22.x, windows-latest) (push) Has been cancelled
CI / Test (24.x, macos-latest) (push) Has been cancelled
CI / Test (24.x, ubuntu-latest) (push) Has been cancelled
CI / Test (24.x, windows-latest) (push) Has been cancelled
CI / Test (26.x, macos-latest) (push) Has been cancelled
CI / Test (26.x, ubuntu-latest) (push) Has been cancelled
CI / Test (26.x, windows-latest) (push) Has been cancelled
CI / Test with Bun (latest, macos-latest) (push) Has been cancelled
CI / Test with Bun (latest, ubuntu-latest) (push) Has been cancelled
CI / Test with Bun (latest, windows-latest) (push) Has been cancelled
CI / Build and run (22.x, macos-latest) (push) Has been cancelled
CI / Build and run (22.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (22.x, windows-latest) (push) Has been cancelled
autofix.ci / autofix (push) Has been cancelled
CI Browser Extension / Lint Browser Extension (push) Has been cancelled
CI Browser Extension / Test Browser Extension (push) Has been cancelled
Memory Benchmark / Memory Test (push) Has been cancelled
CI Website / Lint Website Client (push) Has been cancelled
CI Website / Lint Website Server (push) Has been cancelled
CI Website / Test Website Server (push) Has been cancelled
CI Website / Bundle Website Server (push) Has been cancelled
CI / Lint Biome (push) Has been cancelled
CI / Lint oxlint (push) Has been cancelled
CI / Lint TypeScript (push) Has been cancelled
CI / Lint Secretlint (push) Has been cancelled
CI / Test (22.x, macos-latest) (push) Has been cancelled
CI / Test (22.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (24.x, macos-latest) (push) Has been cancelled
CI / Build and run (24.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (24.x, windows-latest) (push) Has been cancelled
CI / Build and run (26.x, macos-latest) (push) Has been cancelled
CI / Build and run (26.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (26.x, windows-latest) (push) Has been cancelled
CI / Build and run with Bun (latest, macos-latest) (push) Has been cancelled
CI / Build and run with Bun (latest, ubuntu-latest) (push) Has been cancelled
CI / Build and run with Bun (latest, windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Docker / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Docker / build (linux/arm/v7, ubuntu-24.04-arm) (push) Has been cancelled
Docker / build (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Docker / merge (push) Has been cancelled
Pack repository with Repomix / pack-repo (push) Has been cancelled
Performance Benchmark History / Benchmark (macos-latest) (push) Has been cancelled
Performance Benchmark History / Benchmark (ubuntu-latest) (push) Has been cancelled
Performance Benchmark History / Benchmark (windows-latest) (push) Has been cancelled
Performance Benchmark History / Store Results (push) Has been cancelled
Test Repomix Action / Test Node.js 22 (push) Has been cancelled
Test Repomix Action / Test Node.js 24 (push) Has been cancelled
Test Repomix Action / Test Node.js 26 (push) Has been cancelled
118 lines
3.7 KiB
TypeScript
118 lines
3.7 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
import { type CliCommandPackOptions, generateCliCommand } from '../../website/client/components/utils/cliCommand.js';
|
|
|
|
const createOptions = (overrides: Partial<CliCommandPackOptions> = {}): CliCommandPackOptions => ({
|
|
format: 'xml',
|
|
removeComments: false,
|
|
removeEmptyLines: false,
|
|
showLineNumbers: false,
|
|
fileSummary: true,
|
|
directoryStructure: true,
|
|
includePatterns: '',
|
|
ignorePatterns: '',
|
|
outputParsable: false,
|
|
compress: false,
|
|
...overrides,
|
|
});
|
|
|
|
describe('generateCliCommand', () => {
|
|
test('should generate basic command without options', () => {
|
|
expect(generateCliCommand(undefined)).toBe('npx repomix');
|
|
});
|
|
|
|
test('should add --remote for valid GitHub shorthand', () => {
|
|
const result = generateCliCommand('yamadashy/repomix');
|
|
expect(result).toBe("npx repomix --remote 'yamadashy/repomix'");
|
|
});
|
|
|
|
test('should add --remote for valid URL', () => {
|
|
const result = generateCliCommand('https://github.com/yamadashy/repomix');
|
|
expect(result).toBe("npx repomix --remote 'https://github.com/yamadashy/repomix'");
|
|
});
|
|
|
|
test('should not add --remote for uploaded file names', () => {
|
|
const result = generateCliCommand('project.zip');
|
|
expect(result).toBe('npx repomix');
|
|
});
|
|
|
|
test('should add format option when not default xml', () => {
|
|
const result = generateCliCommand(undefined, createOptions({ format: 'markdown' }));
|
|
expect(result).toBe('npx repomix --style markdown');
|
|
});
|
|
|
|
test('should not add format option when xml (default)', () => {
|
|
const result = generateCliCommand(undefined, createOptions({ format: 'xml' }));
|
|
expect(result).toBe('npx repomix');
|
|
});
|
|
|
|
test('should add boolean flags', () => {
|
|
const result = generateCliCommand(
|
|
undefined,
|
|
createOptions({
|
|
removeComments: true,
|
|
removeEmptyLines: true,
|
|
showLineNumbers: true,
|
|
outputParsable: true,
|
|
compress: true,
|
|
}),
|
|
);
|
|
expect(result).toBe(
|
|
'npx repomix --remove-comments --remove-empty-lines --output-show-line-numbers --parsable-style --compress',
|
|
);
|
|
});
|
|
|
|
test('should add no- flags for disabled defaults', () => {
|
|
const result = generateCliCommand(
|
|
undefined,
|
|
createOptions({
|
|
fileSummary: false,
|
|
directoryStructure: false,
|
|
}),
|
|
);
|
|
expect(result).toBe('npx repomix --no-file-summary --no-directory-structure');
|
|
});
|
|
|
|
test('should shell-escape include and ignore patterns', () => {
|
|
const result = generateCliCommand(
|
|
undefined,
|
|
createOptions({
|
|
includePatterns: '**/*.ts',
|
|
ignorePatterns: "test's dir",
|
|
}),
|
|
);
|
|
expect(result).toBe("npx repomix --include '**/*.ts' --ignore 'test'\\''s dir'");
|
|
});
|
|
|
|
test('should skip empty patterns', () => {
|
|
const result = generateCliCommand(
|
|
undefined,
|
|
createOptions({
|
|
includePatterns: ' ',
|
|
ignorePatterns: '',
|
|
}),
|
|
);
|
|
expect(result).toBe('npx repomix');
|
|
});
|
|
|
|
test('should combine all options', () => {
|
|
const result = generateCliCommand(
|
|
'yamadashy/repomix',
|
|
createOptions({
|
|
format: 'markdown',
|
|
removeComments: true,
|
|
compress: true,
|
|
fileSummary: false,
|
|
includePatterns: 'src/**',
|
|
}),
|
|
);
|
|
expect(result).toBe(
|
|
"npx repomix --remote 'yamadashy/repomix' --style markdown --remove-comments --compress --no-file-summary --include 'src/**'",
|
|
);
|
|
});
|
|
|
|
test('should escape shell metacharacters in repository URL', () => {
|
|
const result = generateCliCommand('https://example.com/repo;rm -rf /', undefined);
|
|
expect(result).toBe("npx repomix --remote 'https://example.com/repo;rm -rf /'");
|
|
});
|
|
});
|