use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class NpmPackage method fromFolder.
public static NpmPackage fromFolder(String folder, PackageType defType, String... exemptions) throws IOException {
NpmPackage res = new NpmPackage();
res.loadFiles(folder, new File(folder), exemptions);
if (!res.folders.containsKey("package")) {
res.folders.put("package", res.new NpmPackageFolder("package"));
}
if (!res.folders.get("package").hasFile("package.json") && defType != null) {
TextFile.stringToFile("{ \"type\" : \"" + defType.getCode() + "\"}", Utilities.path(res.folders.get("package").folder.getAbsolutePath(), "package.json"));
}
res.npm = (JsonObject) new com.google.gson.JsonParser().parse(new String(res.folders.get("package").fetchFile("package.json")));
return res;
}
use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class NpmPackage method fromUrl.
public static NpmPackage fromUrl(String source) throws IOException {
SimpleHTTPClient fetcher = new SimpleHTTPClient();
HTTPResult res = fetcher.get(source + "?nocache=" + System.currentTimeMillis());
res.checkThrowException();
return fromPackage(new ByteArrayInputStream(res.getContent()));
}
use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class CorePackageTools method buildPackage.
private void buildPackage(String path, String output) throws IOException {
NpmPackage npm = NpmPackage.fromFolder(path);
npm.loadAllFiles();
npm.save(new FileOutputStream(output));
}
use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class NpmPackageTests method testOldTgz.
@Test
public void testOldTgz() throws IOException {
NpmPackage npm = NpmPackage.fromPackage(TestingUtilities.loadTestResourceStream("npm", "test.format.old.tgz"));
checkNpm(npm);
}
use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class NpmPackageTests method testNewFolder.
@Test
public void testNewFolder() throws IOException {
// extract the test
String dst = Utilities.path("[tmp]", "npm", "test.format.new");
Utilities.clearDirectory(dst);
unzip(TestingUtilities.loadTestResourceStream("npm", "test.format.new.zip"), new File(dst));
dst = Utilities.path(dst, "test.format.new");
NpmPackage npm = NpmPackage.fromFolder(dst);
checkNpm(npm);
}
Aggregations