Skip to content

Commit

Permalink
Merge pull request #92 from mvnpm/fix-more
Browse files Browse the repository at this point in the history
Change .more.tgs extraction failures to warning message instead of blocking
  • Loading branch information
ia3andy authored Feb 5, 2024
2 parents e405e68 + abb1a6d commit a349d85
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/main/java/io/mvnpm/esbuild/install/WebDepsInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ public static boolean install(Path nodeModulesDir, List<WebDependency> dependenc
final Path mvnpmMoreArchive = findMvnpmMoreArchive(extractDir);
if (mvnpmMoreArchive != null) {
logger.log(Level.FINE, "Found more archive ''{0}''", mvnpmMoreArchive);
Archives.unTgz(mvnpmMoreArchive, mvnpmMoreArchive.getParent());
try {
Archives.unTgz(mvnpmMoreArchive, mvnpmMoreArchive.getParent());
} catch (IOException e) {
logger.log(Level.WARNING, "Could not extract .more.tgz archive '" + mvnpmMoreArchive + "'", e);
}
}
}
final Map<String, Path> packageNameAndRoot = JarInspector.findPackageNameAndRoot(dep.id(), extractDir, dep.type());
Expand All @@ -82,10 +86,10 @@ public static boolean install(Path nodeModulesDir, List<WebDependency> dependenc
logger.log(Level.FINE, "installed package ''{0}''", packageName);
}
installed.add(new MvnpmInfo.InstalledDependency(dep.id(), dirs));
logger.log(Level.FINE, "installed dep ''{0}'' (''{1}'')", new Object[] { dep.path(), dep.id() });
logger.log(Level.FINE, "installed dep ''{0}'' (''{1}'')", new Object[]{dep.path(), dep.id()});
} else {
logger.log(Level.WARNING, "package.json not found in dep: ''{0}'' (''{1}'')",
new Object[] { dep.path(), dep.id() });
new Object[]{dep.path(), dep.id()});
}
}
PathUtils.deleteRecursive(tmp);
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/io/mvnpm/esbuild/util/Archives.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void unzip(Path source, Path target) throws IOException {
}
}

public static void unTgz(Path source, Path target) {
public static void unTgz(Path source, Path target) throws IOException {
try (var is = Files.newInputStream(source);
var bis = new BufferedInputStream(is);
var gzis = new GzipCompressorInputStream(bis);
Expand All @@ -36,9 +36,7 @@ public static void unTgz(Path source, Path target) {
while ((entry = tar.getNextTarEntry()) != null) {
extractEntry(target, entry.getName(), entry.isDirectory(), tar);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

}

Expand Down
14 changes: 14 additions & 0 deletions src/test/java/io/mvnpm/esbuild/install/WebDepsInstallerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ void testInstallWithNewDeps() throws IOException {
}
}

@Test
void testVaadinInputError() throws IOException {
Path tempDir = Files.createTempDirectory("testVaadinInputError");
install(tempDir, getWebDependencies(List.of("/mvnpm/vaadin-webcomponents-24.3.5.jar")));
final MvnpmInfo mvnpmInfo = readMvnpmInfo(getMvnpmInfoPath(tempDir));
checkNodeModulesDir(tempDir, mvnpmInfo);
assertEquals(1, mvnpmInfo.installed().size());
final MvnpmInfo.InstalledDependency installedVaadin = mvnpmInfo.installed().stream()
.filter(installedDependency -> installedDependency.id().equals("org.something:vaadin-webcomponents-24.3.5"))
.findFirst()
.get();
assertEquals(55, installedVaadin.dirs().size());
}

@Test
void testNoInfo() throws IOException {
Path tempDir = Files.createTempDirectory("testNoInfo");
Expand Down
Binary file not shown.

0 comments on commit a349d85

Please sign in to comment.