Search in sources :

Example 1 with CliImportsListener

use of com.walmartlabs.concord.cli.runner.CliImportsListener in project concord by walmartlabs.

the class Lint method call.

@Override
public Integer call() throws Exception {
    if (!Files.isDirectory(targetDir)) {
        throw new IllegalArgumentException("Not a directory: " + targetDir);
    }
    ProjectLoader loader = new ProjectLoader(new NoopImportManager());
    ProcessDefinition pd = loader.loadProject(targetDir, new DummyImportsNormalizer(), verbose ? new CliImportsListener() : null).projectDefinition();
    List<LintResult> lintResults = new ArrayList<>();
    linters().forEach(l -> lintResults.addAll(l.apply(pd)));
    if (!lintResults.isEmpty()) {
        print(lintResults);
        println();
    }
    println("Found:");
    println("  imports: " + pd.imports().items().size());
    println("  profiles: " + pd.profiles().size());
    println("  flows: " + pd.flows().size());
    println("  forms: " + pd.forms().size());
    println("  triggers: " + pd.triggers().size());
    println("  (not counting dynamically imported resources)");
    println();
    printStats(lintResults);
    println();
    boolean hasErrors = hasErrors(lintResults);
    if (hasErrors) {
        println("@|red,bold INVALID|@");
    } else {
        println("@|green,bold VALID|@");
    }
    return hasErrors ? 10 : 0;
}
Also used : NoopImportManager(com.walmartlabs.concord.imports.NoopImportManager) ArrayList(java.util.ArrayList) ProcessDefinition(com.walmartlabs.concord.process.loader.model.ProcessDefinition) CliImportsListener(com.walmartlabs.concord.cli.runner.CliImportsListener) ProjectLoader(com.walmartlabs.concord.process.loader.ProjectLoader)

Aggregations

CliImportsListener (com.walmartlabs.concord.cli.runner.CliImportsListener)1 NoopImportManager (com.walmartlabs.concord.imports.NoopImportManager)1 ProjectLoader (com.walmartlabs.concord.process.loader.ProjectLoader)1 ProcessDefinition (com.walmartlabs.concord.process.loader.model.ProcessDefinition)1 ArrayList (java.util.ArrayList)1