Skip to content

Commit

Permalink
feat: change global package cache file path
Browse files Browse the repository at this point in the history
  • Loading branch information
mechanik-daniel committed Dec 6, 2024
1 parent 7c53817 commit 74e4ebb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
27 changes: 19 additions & 8 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
/**
* © Copyright Outburn Ltd. 2022-2024 All Rights Reserved
* Project name: FUME-COMMUNITY
*/
/**
* © Copyright Outburn Ltd. 2022-2024 All Rights Reserved
* Project name: FUME-COMMUNITY
*/

import { fhirCorePackages } from './constants';
import { fhirVersionToMinor } from './helpers/fhirFunctions/fhirVersionToMinor';
import defaultConfig from './serverConfig';
import { fhirCorePackages } from './constants';
import { fhirVersionToMinor } from './helpers/fhirFunctions/fhirVersionToMinor';
import defaultConfig from './serverConfig';
import type { IAppBinding, IConfig } from './types';

const additionalBindings: Record<string, IAppBinding> = {}; // additional functions to bind when running transformations
let serverConfig: IConfig = { ...defaultConfig };
let fhirPackages: Record<string, string> = {};

const setFhirPackages = (packages: Record<string, string>) => {
fhirPackages = packages;
};

const getFhirPackages = () => {
return fhirPackages;
};

const setServerConfig = <ConfigType extends IConfig>(config: Partial<ConfigType>) => {
let fhirServerBase: string | undefined = config.FHIR_SERVER_BASE ? config.FHIR_SERVER_BASE.trim() : undefined;
Expand Down Expand Up @@ -60,5 +69,7 @@ export default {
getServerConfig,
setServerConfig,
setBinding,
getBindings
getBindings,
setFhirPackages,
getFhirPackages
};
2 changes: 1 addition & 1 deletion src/helpers/conformance/getCachePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ export const getCachedPackageDirs = () => {
};

export const getFumeIndexFilePath = () => {
return path.join(getCachePath(), 'fume.index.json');
return path.join('.', 'fhirPackageIndex.json');
};
6 changes: 3 additions & 3 deletions src/helpers/conformance/loadFhirPackageIndex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('loadFhirPackageIndex', () => {
test('Creates the cache folder if it does not exist', async () => {
let counter = 0;
(fs.existsSync as jest.Mock).mockImplementation((name: string) => {
if (name.includes('fume.index.json')) {
if (name.includes('fhirPackageIndex.json')) {
return false;
}
if (counter === 0) {
Expand All @@ -32,12 +32,12 @@ describe('loadFhirPackageIndex', () => {
(fs.readdirSync as jest.Mock).mockReturnValue([]);
await loadFhirPackageIndex();
expect(fs.mkdirSync).toHaveBeenCalledTimes(1);
expect(fs.mkdirSync).toHaveBeenCalledWith(path.join(os.homedir(), '.fhir'), { recursive: true });
expect(fs.mkdirSync).toHaveBeenCalledWith(path.join(os.homedir(), '.fhir', 'packages'), { recursive: true });
});

test('Doesnt create the cache folder if it exists', async () => {
(fs.existsSync as jest.Mock).mockImplementation((name: string) => {
if (name.includes('fume.index.json')) {
if (name.includes('fhirPackageIndex.json')) {
return false;
}
return true;
Expand Down

0 comments on commit 74e4ebb

Please sign in to comment.