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
83 lines
3.7 KiB
TypeScript
83 lines
3.7 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { processFiles } from '../../../src/core/file/fileProcess.js';
|
|
import type { RawFile } from '../../../src/core/file/fileTypes.js';
|
|
import { generateOutput } from '../../../src/core/output/outputGenerate.js';
|
|
import { createMockConfig } from '../../testing/testUtils.js';
|
|
|
|
// End-to-end coverage for the output.patterns "directory-only" inclusion level
|
|
// (issue #608). This composes the two halves the packager wires together:
|
|
// - processFiles produces the per-file content blocks
|
|
// - generateOutput renders the directory tree from the search path list
|
|
// The directory tree is built from `allFilePaths` (the search results, passed
|
|
// through unchanged), while content blocks come from `processedFiles`. A
|
|
// directory-only file must therefore still appear in the tree even though its
|
|
// content is dropped from processedFiles.
|
|
|
|
describe('output.patterns directory-only inclusion level (end-to-end)', () => {
|
|
const rootDir = '/repo';
|
|
|
|
it('lists a directory-only file in the directory structure but omits its content block', async () => {
|
|
const rawFiles: RawFile[] = [
|
|
{ path: 'src/index.ts', content: 'export const greeting = "hello";' },
|
|
{ path: 'website/index.html', content: '<html>OMITTED_WEBSITE_BODY</html>' },
|
|
];
|
|
// Mirrors the packager: allFilePaths comes from the file search and is NOT
|
|
// filtered by inclusion level, so the directory-only path still feeds the tree.
|
|
const allFilePaths = ['src/index.ts', 'website/index.html'];
|
|
const config = createMockConfig({
|
|
cwd: rootDir,
|
|
output: {
|
|
style: 'markdown',
|
|
git: { sortByChanges: false },
|
|
patterns: [{ pattern: 'website/**/*', directoryStructureOnly: true }],
|
|
},
|
|
});
|
|
|
|
const processedFiles = await processFiles(rawFiles, config, () => {});
|
|
|
|
// The directory-only file is dropped from the content output.
|
|
expect(processedFiles.map((f) => f.path)).toEqual(['src/index.ts']);
|
|
|
|
const output = await generateOutput([rootDir], config, processedFiles, allFilePaths);
|
|
|
|
// The directory structure still lists the directory-only file's path...
|
|
expect(output).toContain('website/');
|
|
expect(output).toContain('index.html');
|
|
// ...but its content block is omitted entirely.
|
|
expect(output).not.toContain('OMITTED_WEBSITE_BODY');
|
|
// The full-content file is rendered as usual.
|
|
expect(output).toContain('export const greeting = "hello";');
|
|
});
|
|
|
|
it('keeps a directory-only directory in the tree even when all its files are excluded', async () => {
|
|
const rawFiles: RawFile[] = [
|
|
{ path: 'src/index.ts', content: 'export const a = 1;' },
|
|
{ path: 'website/css/site.css', content: 'body { color: OMITTED; }' },
|
|
{ path: 'website/index.html', content: '<html>OMITTED</html>' },
|
|
];
|
|
const allFilePaths = ['src/index.ts', 'website/css/site.css', 'website/index.html'];
|
|
const config = createMockConfig({
|
|
cwd: rootDir,
|
|
output: {
|
|
style: 'markdown',
|
|
git: { sortByChanges: false },
|
|
patterns: [{ pattern: 'website/**/*', directoryStructureOnly: true }],
|
|
},
|
|
});
|
|
|
|
const processedFiles = await processFiles(rawFiles, config, () => {});
|
|
|
|
// Every website file is excluded from content; only src remains.
|
|
expect(processedFiles.map((f) => f.path)).toEqual(['src/index.ts']);
|
|
|
|
const output = await generateOutput([rootDir], config, processedFiles, allFilePaths);
|
|
|
|
// The website directory and its files are still represented in the tree.
|
|
expect(output).toContain('website/');
|
|
expect(output).toContain('site.css');
|
|
expect(output).toContain('index.html');
|
|
// None of the excluded files leak their content.
|
|
expect(output).not.toContain('OMITTED');
|
|
});
|
|
});
|