use of org.eclipse.n4js.workspace.utils.N4JSPackageName in project n4js by eclipse.
the class N4jsLibsAccess method loadDepenencies.
private static Set<N4JSPackageName> loadDepenencies(Path projectPath, boolean includeDevDependencies, boolean excludeNestedProjects, boolean includeDepsOfNestedProjects) throws IOException {
Set<N4JSPackageName> result = new LinkedHashSet<>();
Map<N4JSPackageName, Path> nodeModuleProjects = getNodeModuleProjects(projectPath);
// add dependencies of project at 'projectPath'
List<N4JSPackageName> dependencyNames = loadDepenencies(projectPath, includeDevDependencies);
result.addAll(dependencyNames);
// add dependencies of nested projects (if requested)
if (includeDepsOfNestedProjects) {
for (Path nestedProjectPath : nodeModuleProjects.values()) {
Set<N4JSPackageName> nestedDependencyNames = loadDepenencies(nestedProjectPath, // never include devDependencies of nested projects!
false, excludeNestedProjects, includeDepsOfNestedProjects);
result.addAll(nestedDependencyNames);
}
}
// remove nested projects (if requested)
if (excludeNestedProjects) {
result.removeAll(nodeModuleProjects.keySet());
}
return result;
}
use of org.eclipse.n4js.workspace.utils.N4JSPackageName in project n4js by eclipse.
the class N4jsLibsAccess method getNodeModuleProjects.
/**
* Returns name/path of all projects nested inside the node_modules folder of the project at the given location.
*/
private static Map<N4JSPackageName, Path> getNodeModuleProjects(Path projectPath) {
Map<N4JSPackageName, Path> result = new HashMap<>();
Path nodeModulesPath = projectPath.resolve(N4JSGlobals.NODE_MODULES);
if (Files.exists(nodeModulesPath)) {
for (File childDir : nodeModulesPath.toFile().listFiles(File::isDirectory)) {
if (childDir.getName().startsWith("@")) {
for (File grandChildDir : childDir.listFiles(File::isDirectory)) {
if (isNpmPackage(grandChildDir.toPath())) {
result.put(new N4JSPackageName(childDir.getName() + '/' + grandChildDir.getName()), grandChildDir.toPath());
}
}
} else if (isNpmPackage(childDir.toPath())) {
result.put(new N4JSPackageName(childDir.getName()), childDir.toPath());
}
}
}
return result;
}
use of org.eclipse.n4js.workspace.utils.N4JSPackageName in project n4js by eclipse.
the class AbstractIdeTest method installN4JSRuntime.
/**
* Installs the given libsToInstall into the given target project. Respects yarn setups.
*
* @see N4jsLibsAccess#installN4jsLibs
*/
protected void installN4JSRuntime() {
File root = getProjectRoot();
N4JSPackageName projectName = new N4JSPackageName(root);
installN4jsLibs(projectName, new N4JSPackageName[] { N4JSGlobals.N4JS_RUNTIME });
}
Aggregations