Skip to content

Commit

Permalink
Update Automatic Dependencies
Browse files Browse the repository at this point in the history
- Add hl7.fhir.uv.extensions.r4 for R4 IGs
- Change hl7.fhir.uv.extensions to hl7.fhir.uv.extensions.r5 for R5 IGs
- Change hl7.terminology.r4 to hl7.terminology.r5 for R5 IGs
- Improve regex matchers for automatic dependencies to better support pre-releases and current
  • Loading branch information
cmoesel committed Sep 13, 2023
1 parent db43835 commit a09623e
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 66 deletions.
28 changes: 18 additions & 10 deletions src/utils/Processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,40 @@ const CERTIFICATE_MESSAGE =
' 2. Set NODE_EXTRA_CA_CERTS as described at https://bit.ly/3ghJqJZ (RECOMMENDED).\n' +
' 3. Disable certificate validation as described at https://bit.ly/3syjzm7 (NOT RECOMMENDED).\n';

const R4_OR_4B_REGEX = /^4\.[013]\./;
const R5_OR_CURRENT_REGEX = /^(4\.[2456]\.\d+)|(5\.\d+\.\d+)|(current)/;

type AutomaticDependency = {
packageId: string;
version: string;
fhirVersion?: RegExp;
};

// For some context on implicit packages, see: https://chat.fhir.org/#narrow/stream/179239-tooling/topic/New.20Implicit.20Package/near/325318949
export const AUTOMATIC_DEPENDENCIES: AutomaticDependency[] = [
{
packageId: 'hl7.fhir.uv.tools',
version: 'current'
},
{
// Terminology dependencies are only used in SUSHI to validate existence of VS/CS and to look up by id/name/url. As
// such, the particular version that we load does not matter much, so always load the R4 version. In the future,
// we can consider loading R5 for R5 IGs, but right now, hl7.terminology.r5 is stale and broken -- so let's not.
// See: https://chat.fhir.org/#narrow/stream/179239-tooling/topic/New.20Implicit.20Package/near/325488084
packageId: 'hl7.terminology.r4',
version: 'latest'
version: 'latest',
fhirVersion: R4_OR_4B_REGEX
},
{
packageId: 'hl7.terminology.r5',
version: 'latest',
fhirVersion: R5_OR_CURRENT_REGEX
},
{
packageId: 'hl7.fhir.uv.extensions.r4',
version: 'latest',
fhirVersion: R4_OR_4B_REGEX
},
{
// Right now, auto-load the extensions package for R5 only. In the future, we'll do this for R4 as well, but as
// of 3/27/2023, the rules for resolution in R4 have not yet been determined.
// See: https://chat.fhir.org/#narrow/stream/179239-tooling/topic/New.20Implicit.20Package/near/344938535
packageId: 'hl7.fhir.uv.extensions',
packageId: 'hl7.fhir.uv.extensions.r5',
version: 'latest',
fhirVersion: /^5\.0\.0(-draft-final)?$/
fhirVersion: R5_OR_CURRENT_REGEX
}
];

Expand Down
16 changes: 15 additions & 1 deletion test/testhelpers/asserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,21 @@ export function assertAutomaticR4Dependencies(packages: string[]) {
AUTOMATIC_DEPENDENCIES.forEach(dep => {
if (dep.packageId === 'hl7.terminology.r4' && dep.version === 'latest') {
expect(packages).toContain('hl7.terminology.r4#1.2.3-test');
} else if (dep.packageId !== 'hl7.fhir.uv.extensions') {
} else if (dep.packageId === 'hl7.fhir.uv.extensions.r4' && dep.version === 'latest') {
expect(packages).toContain('hl7.fhir.uv.extensions.r4#4.5.6-test');
} else if (!dep.packageId.endsWith('.r5')) {
expect(packages).toContain(`${dep.packageId}#${dep.version}`);
}
});
}

export function assertAutomaticR5Dependencies(packages: string[]) {
AUTOMATIC_DEPENDENCIES.forEach(dep => {
if (dep.packageId === 'hl7.terminology.r5' && dep.version === 'latest') {
expect(packages).toContain('hl7.terminology.r5#1.2.3-test');
} else if (dep.packageId === 'hl7.fhir.uv.extensions.r5' && dep.version === 'latest') {
expect(packages).toContain('hl7.fhir.uv.extensions.r5#4.5.6-test');
} else if (!dep.packageId.endsWith('.r4')) {
expect(packages).toContain(`${dep.packageId}#${dep.version}`);
}
});
Expand Down
Loading

0 comments on commit a09623e

Please sign in to comment.