Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/builder/src/Builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ export class CompactBuilder {
shell: '/bin/bash',
});

steps.push({
cmd: 'find dist -type d -name "witnesses" -exec rm -rf {} +',
msg: 'Removing witness directories from dist',
shell: '/bin/bash',
});

if (this.options.hierarchical) {
steps.push({
// biome-ignore-start lint/suspicious/noUselessEscapeInString: shell vars must survive JS template-literal interpolation
Expand Down
28 changes: 27 additions & 1 deletion packages/builder/test/Builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ describe('CompactBuilder step pipeline', () => {
expect(steps.map((s) => s.msg)).toEqual([
'Compiling TypeScript',
'Copying artifacts',
'Removing witness directories from dist',
'Copying .compact files',
]);
});
Expand All @@ -131,7 +132,7 @@ describe('CompactBuilder step pipeline', () => {

expect(steps[0].msg).toBe('Cleaning dist directory');
expect(steps[0].cmd).toBe('rm -rf dist && mkdir -p dist');
expect(steps).toHaveLength(4);
expect(steps).toHaveLength(5);
});

it('uses the hierarchical copy step when hierarchical is true', () => {
Expand All @@ -156,6 +157,30 @@ describe('CompactBuilder step pipeline', () => {
expect(lastStep?.cmd).toContain("cp '../README.md' dist/");
});

it('removes witness directories after copying artifacts', () => {
const builder = new CompactBuilder();
const steps = builder.getSteps();
const witnessStep = steps.find(
(s) => s.msg === 'Removing witness directories from dist',
);

expect(witnessStep).toBeDefined();
expect(witnessStep?.cmd).toBe(
'find dist -type d -name "witnesses" -exec rm -rf {} +',
);
});

it('runs witness removal after artifact copy and before .compact copy', () => {
const builder = new CompactBuilder();
const msgs = builder.getSteps().map((s) => s.msg);
const artifactIdx = msgs.indexOf('Copying artifacts');
const witnessIdx = msgs.indexOf('Removing witness directories from dist');
const compactIdx = msgs.indexOf('Copying .compact files');

expect(witnessIdx).toBe(artifactIdx + 1);
expect(witnessIdx).toBeLessThan(compactIdx);
});

it('classifies excludes into -name and -path', () => {
const builder = new CompactBuilder({
hierarchical: true,
Expand Down Expand Up @@ -199,6 +224,7 @@ describe('CompactBuilder step pipeline', () => {
'Cleaning dist directory',
'Compiling TypeScript',
'Copying artifacts',
'Removing witness directories from dist',
'Copying .compact files (preserving structure)',
'Copying additional files to dist',
]);
Expand Down
Loading