@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
68 lines (66 loc) • 3.12 kB
JavaScript
;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.PathLengthFileGeneratorTest = void 0;
const ProjectInfoItem_1 = require("./ProjectInfoItem");
const IInfoItemData_1 = require("./IInfoItemData");
var PathLengthFileGeneratorTest;
(function (PathLengthFileGeneratorTest) {
PathLengthFileGeneratorTest[PathLengthFileGeneratorTest["filePathExceeds8DirectorySegments"] = 2] = "filePathExceeds8DirectorySegments";
PathLengthFileGeneratorTest[PathLengthFileGeneratorTest["filePathExceedsCharacterLength"] = 3] = "filePathExceedsCharacterLength";
})(PathLengthFileGeneratorTest = exports.PathLengthFileGeneratorTest || (exports.PathLengthFileGeneratorTest = {}));
class PathLengthFileGenerator {
constructor() {
this.id = "PATHLENGTH";
this.title = "Path Length";
this.canAlwaysProcess = true;
}
getTopicData(topicId) {
return {
title: topicId.toString(),
};
}
summarize(info, infoSet) { }
async generate(project, file, contentIndex) {
const items = [];
let path = file.storageRelativePath;
const packContentFolderHints = [
"bp",
"rp",
"resource pack",
"resource packs",
"content/resource_packs",
"behavior pack",
"behavior packs",
"content/behavior_packs",
"skin pack",
"skin packs",
"content/skin_packs",
"world_template",
];
for (const hint of packContentFolderHints) {
const hintIndex = path.toLowerCase().indexOf("/" + hint + "/");
if (hintIndex >= 0) {
path = path.substring(hintIndex + hint.length + 2);
}
}
const packStarterFolderHints = ["resource_packs", "behavior_packs", "world_templates", "skin_packs"];
for (const hint of packStarterFolderHints) {
if (path.toLowerCase().startsWith(hint + "/")) {
path = path.substring(hint.length + 1);
}
}
const fSlashSegments = path.split("/");
const bSlashSegments = path.split("\\");
if (fSlashSegments.length > 9 || bSlashSegments.length > 9) {
items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.error, this.id, PathLengthFileGeneratorTest.filePathExceeds8DirectorySegments, `File path contains 8 or more directory segments, and may not run on all devices`, project.getItemByExtendedOrProjectPath(file.extendedPath), path));
}
if (path.length > 100) {
items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.error, this.id, PathLengthFileGeneratorTest.filePathExceedsCharacterLength, `File path contains more than 100 characters, and may not run on all devices`, project.getItemByExtendedOrProjectPath(file.extendedPath), path));
}
return items;
}
}
exports.default = PathLengthFileGenerator;
//# sourceMappingURL=../maps/info/PathLengthFileGenerator.js.map