Allow NPM package versions to have the form {id}#{url} for direct access to packages

This commit is contained in:
Grahame Grieve 2023-05-10 07:32:49 -05:00
parent 3da96f8c02
commit 576be235d7
3 changed files with 15 additions and 8 deletions

View File

@ -6,6 +6,7 @@
* Slight improvement in performance
* Fix FHIRPath split function (parameter is not regex)
* Stop warning that Markdown autolinks need to be escaped
* Allow NPM package versions to have the form {id}#{url} for direct access to packages
## Other code changes

View File

@ -262,7 +262,6 @@ public class MarkDownProcessor {
}
}
public static String makeMarkdownForString(String content) {
StringBuilder b = new StringBuilder();
for (int i = 0; i < content.length(); i++) {

View File

@ -402,10 +402,6 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
@Override
public NpmPackage addPackageToCache(String id, String version, InputStream packageTgzInputStream, String sourceDesc) throws IOException {
checkValidVersionString(version, id);
if (progress) {
log("Installing " + id + "#" + (version == null ? "?" : version) + " to the package cache");
log(" Fetching:");
}
NpmPackage npm = NpmPackage.fromPackage(packageTgzInputStream, sourceDesc, true);
@ -414,8 +410,8 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
logn(" Installing: ");
}
if (!suppressErrors && npm.name() == null || id == null || !id.equalsIgnoreCase(npm.name())) {
if (!id.equals("hl7.fhir.r5.core") && !id.equals("hl7.fhir.us.immds")) {// temporary work around
if ((npm.name() != null && id != null && !id.equals(npm.name()))) {
if (!suppressErrors && (!id.equals("hl7.fhir.r5.core") && !id.equals("hl7.fhir.us.immds"))) {// temporary work around
throw new IOException("Attempt to import a mis-identified package. Expected " + id + ", got " + npm.name());
}
}
@ -569,10 +565,17 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
version = "current";
}
if (progress) {
log("Installing " + id + "#" + (version == null ? "?" : version) + " to the package cache");
log(" Fetching:");
}
// nup, don't have it locally (or it's expired)
FilesystemPackageCacheManager.InputStreamWithSrc source;
if (false && packageProvider != null && packageProvider.handlesPackage(id, version)) {
source = packageProvider.provide(id, version);
} else if (Utilities.isAbsoluteUrl(version)) {
source = fetchSourceFromUrlSpecific(version);
} else if ("current".equals(version) || (version!= null && version.startsWith("current$"))) {
// special case - fetch from ci-build server
source = loadFromCIBuild(id, version.startsWith("current$") ? version.substring(8) : null);
@ -585,6 +588,10 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
return addPackageToCache(id, source.version, source.stream, source.url);
}
private InputStreamWithSrc fetchSourceFromUrlSpecific(String url) {
return new InputStreamWithSrc(fetchFromUrlSpecific(url, false), url, "current");
}
private InputStream fetchFromUrlSpecific(String source, boolean optional) throws FHIRException {
try {
SimpleHTTPClient http = new SimpleHTTPClient();