Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

place fsh-index.json in the data folder #1556

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
5 changes: 3 additions & 2 deletions src/utils/Processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,9 @@ export function writeFSHIndex(
// write txt with nice formatting
textIndex.unshift(['Output File', 'Name', 'Type', 'FSH File', 'Lines']);
fs.outputFileSync(path.join(outDir, 'fsh-generated', 'fsh-index.txt'), table(textIndex));
// write json for machine usage
fs.outputJsonSync(path.join(outDir, 'fsh-generated', 'fsh-index.json'), jsonIndex, { spaces: 2 });
// write json for machine usage. Use the fsh-generated/data folder for the template to pick it up. Ensure the folder exists
fs.ensureDirSync(path.join(outDir, 'fsh-generated', 'data'));
fs.outputJsonSync(path.join(outDir, 'fsh-generated', 'data', 'fsh-index.json'), jsonIndex, { spaces: 2 });
}

export function writePreprocessedFSH(outDir: string, inDir: string, tank: FSHTank) {
Expand Down
6 changes: 3 additions & 3 deletions test/utils/Processing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ describe('Processing', () => {
it('should create text and json index files that contain each resource in the package', () => {
writeFSHIndex(tempIGPubRoot, outPackage, fshRoot, []);
const textIndex = path.join(tempIGPubRoot, 'fsh-generated', 'fsh-index.txt');
const jsonIndex = path.join(tempIGPubRoot, 'fsh-generated', 'fsh-index.json');
const jsonIndex = path.join(tempIGPubRoot, 'fsh-generated', 'data', 'fsh-index.json');
expect(fs.existsSync(textIndex)).toBeTrue();
expect(fs.existsSync(jsonIndex)).toBeTrue();

Expand Down Expand Up @@ -1734,7 +1734,7 @@ describe('Processing', () => {
it('should sort the list of resources by output file name', () => {
writeFSHIndex(tempIGPubRoot, outPackage, fshRoot, []);
const textIndex = path.join(tempIGPubRoot, 'fsh-generated', 'fsh-index.txt');
const jsonIndex = path.join(tempIGPubRoot, 'fsh-generated', 'fsh-index.json');
const jsonIndex = path.join(tempIGPubRoot, 'fsh-generated', 'data', 'fsh-index.json');
expect(fs.existsSync(textIndex)).toBeTrue();
expect(fs.existsSync(jsonIndex)).toBeTrue();

Expand All @@ -1757,7 +1757,7 @@ describe('Processing', () => {
it('should not include a resource in the package if it is in the list of resources to skip', () => {
writeFSHIndex(tempIGPubRoot, outPackage, fshRoot, ['StructureDefinition-my-extension.json']);
const textIndex = path.join(tempIGPubRoot, 'fsh-generated', 'fsh-index.txt');
const jsonIndex = path.join(tempIGPubRoot, 'fsh-generated', 'fsh-index.json');
const jsonIndex = path.join(tempIGPubRoot, 'fsh-generated', 'data', 'fsh-index.json');
expect(fs.existsSync(textIndex)).toBeTrue();
expect(fs.existsSync(jsonIndex)).toBeTrue();

Expand Down
Loading