Skip to content

Commit d80cf63

Browse files
committed
Fix missing type in manifest and mkdir call in manifest builder
1 parent 0d54296 commit d80cf63

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

lib/buildtools/src/build/modules/__tests__/building.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import fs from 'fs/promises';
2+
import { outDir } from '@sourceacademy/modules-repotools/getGitRoot';
3+
import type { ResolvedBundle } from '@sourceacademy/modules-repotools/types';
24
import { beforeEach, expect, test, vi } from 'vitest';
35
import { testMocksDir } from '../../../__tests__/fixtures.js';
46
import { buildBundle, buildTab } from '../index.js';
7+
import { buildManifest } from '../manifest.js';
58

69
const written: string[] = [];
710
vi.spyOn(fs, 'open').mockResolvedValue({
@@ -98,3 +101,39 @@ test('build tab', async () => {
98101
expect(tab.body(0)).toEqual(0);
99102
expect(tab.toSpawn()).toEqual(true);
100103
});
104+
105+
test('build manifest', async () => {
106+
const sampleManifests: Record<string, ResolvedBundle> = {
107+
bundle0: {
108+
type: 'bundle',
109+
name: 'bundle0',
110+
directory: './bundle0',
111+
manifest: {
112+
requires: 1
113+
}
114+
},
115+
bundle1: {
116+
type: 'bundle',
117+
name: 'bundle1',
118+
directory: './bundle1',
119+
manifest: {
120+
version: '1.0.0'
121+
}
122+
}
123+
};
124+
125+
await buildManifest(sampleManifests, outDir);
126+
127+
expect(fs.mkdir).toHaveBeenCalledExactlyOnceWith(outDir);
128+
expect(fs.writeFile).toHaveBeenCalledExactlyOnceWith(
129+
`${outDir}/modules.json`,
130+
JSON.stringify({
131+
bundle0: {
132+
requires: 1
133+
},
134+
bundle1: {
135+
version: '1.0.0'
136+
}
137+
})
138+
);
139+
});

lib/buildtools/src/build/modules/manifest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export async function buildManifest(bundles: Record<string, ResolvedBundle>, out
1111
[name]: manifest
1212
}), {});
1313

14+
await fs.mkdir(outDir);
15+
1416
const outpath = `${outDir}/modules.json`;
1517
await fs.writeFile(outpath, JSON.stringify(finalManifest, null, 2));
1618

lib/repotools/src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export const severity = {
77
export type Severity = (typeof severity)[keyof typeof severity];
88

99
export interface BundleManifest {
10-
version?: string;
10+
requires?: number;
11+
version?: string
1112
tabs?: string[];
1213
}
1314

0 commit comments

Comments
 (0)