Skip to main content
The ProjectInfoSet class is the central container for project validation. It coordinates generator execution, collects validation items, and provides methods to query and export results.

Constructor

const infoSet = new ProjectInfoSet(
  project?,                  // Project to validate
  suite?,                    // Validation suite to run
  excludeTests?,             // Tests to skip
  info?,                     // Pre-existing info data
  items?,                    // Pre-existing items
  index?,                    // Content index
  performAggressiveCleanup?  // Memory management flag
);
Parameters:
  • project - The project to analyze
  • suite - Which validation suite to run (see Validation Suites)
  • excludeTests - Array of generator IDs to exclude (e.g., ["STRICT", "ESLINT"])
  • info - Existing project info metadata
  • items - Existing validation items to load
  • index - Content index for cross-reference tracking
  • performAggressiveCleanup - If true, generators can aggressively free memory (for CLI usage)

Properties

project

project?: Project
The project being validated.

suite

suite: ProjectInfoSuite
The validation suite being executed.

info

info: IProjectInfo
Aggregated project metadata and statistics.

items

items: ProjectInfoItem[]
All validation items generated during analysis.

contentIndex

contentIndex: ContentIndex
Tracks content usage and references across the project.

completedGeneration

get completedGeneration(): boolean
Whether validation has finished running.

Validation Suites

enum ProjectInfoSuite {
  defaultInDevelopment = 0,      // All tests except cooperative add-on and sharing
  currentPlatformVersions = 1,   // Version-related tests only
  cooperativeAddOn = 2,          // Marketplace cooperative add-on tests
  sharing = 3,                   // Tests for sharing/publishing
  sharingStrict = 4             // Strict sharing tests with language files
}
Suite selection:
const suite = ProjectInfoSet.getSuiteFromString("addon");
// Returns: ProjectInfoSuite.cooperativeAddOn

const name = ProjectInfoSet.getSuiteString(ProjectInfoSuite.sharing);
// Returns: "sharing"

Core Methods

generateForProject()

Runs all validation generators for the project.
await infoSet.generateForProject(force?: boolean)
Parameters:
  • force - If true, re-runs validation even if already completed
Example:
const project = new Project();
await project.loadFromFolder(folder);

const infoSet = new ProjectInfoSet(
  project,
  ProjectInfoSuite.defaultInDevelopment
);

await infoSet.generateForProject();

console.log(`Found ${infoSet.errorAndFailCount} issues`);
Process:
  1. Loads project structure and resources
  2. Runs project-level generators
  3. Runs item-level generators on each ProjectItem
  4. Runs file-level generators
  5. Aggregates results and generates summary

getItems()

Retrieve items from a specific generator and topic.
getItems(generatorId: string, itemIndex: number): ProjectInfoItem[]
Example:
// Get all items from the JSONTAGS generator, topic 101
const items = infoSet.getItems("JSONTAGS", 101);

for (const item of items) {
  console.log(item.message);
}

getItemsByType()

Retrieve items of a specific type from a generator.
getItemsByType(
  generatorId: string,
  itemType: InfoItemType
): ProjectInfoItem[]
Example:
// Get all errors from the STRICT generator
const errors = infoSet.getItemsByType("STRICT", InfoItemType.error);
console.log(`Found ${errors.length} strict mode errors`);

getItemsByStoragePath()

Get all validation items for a specific file.
getItemsByStoragePath(path: string): ProjectInfoItem[] | undefined
Example:
// Get all issues in a specific entity file
const items = infoSet.getItemsByStoragePath(
  "BP/entities/custom_entity.json"
);

if (items) {
  console.log(`File has ${items.length} issues`);
}

getCountByType()

Count items of a specific type.
getCountByType(itemType: InfoItemType): number
Example:
const errorCount = infoSet.getCountByType(InfoItemType.error);
const warningCount = infoSet.getCountByType(InfoItemType.warning);

console.log(`${errorCount} errors, ${warningCount} warnings`);

Statistics Properties

errorAndFailCount

get errorAndFailCount(): number
Total count of errors, internal errors, and test failures.

errorFailWarnCount

get errorFailWarnCount(): number
Total count of errors, warnings, internal errors, and test failures.

errorFailWarnString

get errorFailWarnString(): string
Formatted string of all errors, warnings, and failures. Example:
if (infoSet.errorAndFailCount > 0) {
  console.error("Validation failed:");
  console.error(infoSet.errorFailWarnString);
  process.exit(1);
}

Export Methods

getDataObject()

Export validation results as a data object.
getDataObject(
  sourceName?: string,
  sourcePath?: string,
  sourceHash?: string,
  isIndexOnly?: boolean,
  subsetReports?: IProjectMetaState[]
): IProjectInfoData
Returns: Complete validation data structure
interface IProjectInfoData {
  info?: IProjectInfo;              // Aggregate statistics
  items?: IInfoItemData[];          // Individual validation items
  sourcePath?: string;              // Project source path
  sourceHash?: string;              // Content hash
  sourceName?: string;              // Project name
  suite?: number;                   // Validation suite used
  subsetReports?: IProjectMetaState[]; // Nested reports
  index?: IContextIndexData;        // Content index data
  generatorName?: string;           // Tool name
  generatorVersion?: string;        // Tool version
}

getReportHtml()

Generate a standalone HTML report.
getReportHtml(
  sourceName?: string,
  sourcePath?: string,
  sourceHash?: string
): string
Returns: Complete HTML document with embedded validation results Example:
const html = infoSet.getReportHtml(
  project.name,
  project.projectFolder?.storageRelativePath,
  await project.getHash()
);

await fs.writeFile("validation-report.html", html);

getItemCsvLines()

Export validation items as CSV lines.
getItemCsvLines(): string[]
Example:
const lines = [
  ProjectInfoSet.CommonCsvHeader,  // Header row
  ...infoSet.getItemCsvLines()     // Data rows
];

await fs.writeFile("validation.csv", lines.join("\n"));

getSummaryCsvLine()

Export summary statistics as a CSV line.
getSummaryCsvLine(
  containerName: string,
  title: string,
  allFeatures?: { [setName: string]: { [measureName: string]: number | undefined } | undefined }
): string

Generator Options

interface IGeneratorOptions {
  /**
   * When true, generators may perform aggressive memory cleanup operations
   * after processing (e.g., clearing LevelDB data, chunk caches).
   * This is appropriate for fire-and-forget contexts like CLI validation,
   * but should be false when the data may be needed by other components
   * (e.g., world map rendering in the browser).
   */
  performAggressiveCleanup?: boolean;
}
Usage:
// For CLI tools
const infoSet = new ProjectInfoSet(
  project,
  ProjectInfoSuite.defaultInDevelopment,
  undefined,  // excludeTests
  undefined,  // info
  undefined,  // items
  undefined,  // index
  true        // performAggressiveCleanup
);

// For UI/interactive tools
const infoSet = new ProjectInfoSet(
  project,
  ProjectInfoSuite.defaultInDevelopment,
  undefined,
  undefined,
  undefined,
  undefined,
  false  // Keep data in memory
);

Complete Example

import {
  Project,
  ProjectInfoSet,
  ProjectInfoSuite,
  InfoItemType
} from "@minecraft/creator-tools";

async function validateProject(projectPath: string) {
  // Create and load project
  const project = new Project();
  const folder = await getFolder(projectPath);
  await project.loadFromFolder(folder);

  // Create validation set
  const infoSet = new ProjectInfoSet(
    project,
    ProjectInfoSuite.defaultInDevelopment,
    ["ESLINT"],  // Skip ESLint
    undefined,
    undefined,
    undefined,
    true  // CLI mode - aggressive cleanup
  );

  // Run validation
  console.log("Validating project...");
  await infoSet.generateForProject();

  // Check results
  const errorCount = infoSet.getCountByType(InfoItemType.error);
  const warningCount = infoSet.getCountByType(InfoItemType.warning);

  console.log(`\nValidation complete:`);
  console.log(`  Errors: ${errorCount}`);
  console.log(`  Warnings: ${warningCount}`);

  // Show errors
  if (errorCount > 0) {
    console.log("\nErrors found:");
    const errors = infoSet.items.filter(
      item => item.itemType === InfoItemType.error
    );

    for (const error of errors) {
      console.log(`  [${error.generatorId}] ${error.message}`);
      if (error.projectItemPath) {
        console.log(`    in ${error.projectItemPath}`);
      }
    }
  }

  // Export report
  const html = infoSet.getReportHtml(
    project.name || "Unknown Project",
    projectPath
  );
  await fs.writeFile("validation-report.html", html);

  return errorCount === 0;
}

// Usage
const success = await validateProject("/path/to/project");
process.exit(success ? 0 : 1);

Feature Aggregation

ProjectInfoSet aggregates feature usage across all items:
// Access aggregated features
const featureSets = infoSet.info.featureSets;

if (featureSets) {
  const entityCount = featureSets["entityType.size"]?.count;
  const scriptSize = featureSets["javaScript.size"]?.total;

  console.log(`Project has ${entityCount} entity types`);
  console.log(`Total script size: ${scriptSize} bytes`);
}

Best Practices

  1. Choose the right suite: Use specific suites for targeted validation
  2. Exclude unnecessary tests: Skip generators that don’t apply
  3. Handle completion: Check completedGeneration before accessing results
  4. Export reports: Generate HTML/CSV for stakeholders
  5. Use aggressive cleanup for CLI: Enable for one-shot validation
  6. Cache when possible: Reuse ProjectInfoSet for multiple queries
  7. Check error counts first: Quick validation pass/fail check
  8. Group by file: Use getItemsByStoragePath() for file-specific feedback

Build docs developers (and LLMs) love