UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

55 lines (54 loc) 2.11 kB
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Log_1 = __importDefault(require("../core/Log")); const GeneratorRegistrations_1 = __importDefault(require("../info/registration/GeneratorRegistrations")); class ProjectUpdateRunner { project; constructor(project) { this.project = project; } async updateProject(includeUpdaters, excludeUpdaters) { const updaters = GeneratorRegistrations_1.default.updaters; const results = []; if (!this.project) { Log_1.default.throwUnexpectedUndefined("PURUP"); return; } for (let i = 0; i < updaters.length; i++) { const updater = updaters[i]; const updaterIds = updater.getUpdateIds(); for (let j = 0; j < updaterIds.length; j++) { if ((!includeUpdaters || includeUpdaters.includes(updater.id)) && (!excludeUpdaters || !excludeUpdaters.includes(updater.id))) { const localResults = await updater.update(this.project, updaterIds[j]); results.push(...localResults); } } } return results; } async update(updaterId, updaterIndex) { const updaters = GeneratorRegistrations_1.default.updaters; const allResults = []; if (!this.project) { Log_1.default.throwUnexpectedUndefined("PURU"); return []; } for (let i = 0; i < updaters.length; i++) { const updater = updaters[i]; if (updater.id === updaterId) { const results = await updater.update(this.project, updaterIndex); for (const result of results) { allResults.push(result); } } } return allResults; } } exports.default = ProjectUpdateRunner;