@storm-software/eslint
Version:
A package containing the base ESLint configuration used by Storm Software across many projects.
63 lines (55 loc) • 3.9 kB
JavaScript
import { ACRONYMS_LIST } from './chunk-WHUEAYCR.js';
import { init_esm_shims } from './chunk-QO5ZXGIE.js';
// src/utils/get-file-banner.ts
init_esm_shims();
var getFileBanner = (name = "", workspaceConfig) => {
if (!name) {
name = process.env.STORM_NAME || "";
}
let padding = " ";
for (let i = 0; i < name.length + 2 && padding.length > 4; i++) {
padding = padding.slice(0, -1);
}
let titleName = name || workspaceConfig?.name;
if (titleName) {
if (titleName?.startsWith("@")) {
titleName = titleName.slice(1);
}
titleName = (titleName.charAt(0).toUpperCase() + titleName.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
if (ACRONYMS_LIST.includes(word.toUpperCase())) {
return word.toUpperCase();
}
return word.charAt(0).toUpperCase() + word.slice(1);
}).join(" ");
}
const license = (process.env.STORM_LICENSE || workspaceConfig?.license || "Apache-2.0").split(" ").filter((word) => word && word.toLowerCase() !== "license").join(" ");
const organization = process.env.STORM_ORG_NAME || process.env.STORM_ORGANIZATION_NAME || process.env.STORM_ORG || process.env.STORM_ORGANIZATION || (workspaceConfig?.organization && (typeof workspaceConfig.organization === "string" || typeof workspaceConfig.organization.name === "string") ? typeof workspaceConfig.organization === "string" ? workspaceConfig.organization : workspaceConfig.organization.name : void 0) || "storm-software";
return ` -------------------------------------------------------------------
${padding}\u26A1 ${(organization.charAt(0).toUpperCase() + organization.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
if (ACRONYMS_LIST.includes(word.toUpperCase())) {
return word.toUpperCase();
}
return word.charAt(0).toUpperCase() + word.slice(1);
}).join(" ")} ${titleName ? `- ${titleName}` : ""}
This code was released as part of ${titleName ? `the ${titleName}` : `a ${(organization.charAt(0).toUpperCase() + organization.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
if (ACRONYMS_LIST.includes(word.toUpperCase())) {
return word.toUpperCase();
}
return word.charAt(0).toUpperCase() + word.slice(1);
}).join(" ")}`} project. ${titleName ? titleName : "The project"}
is maintained by ${(organization.charAt(0).toUpperCase() + organization.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
if (ACRONYMS_LIST.includes(word.toUpperCase())) {
return word.toUpperCase();
}
return word.charAt(0).toUpperCase() + word.slice(1);
}).join(" ")} under the ${license} license, and is
free for commercial and private use. For more information, please visit
our licensing page at ${process.env.STORM_LICENSING?.replace(/\/$/, "") || workspaceConfig?.licensing?.replace(/\/$/, "") || "https://stormsoftware.com/licenses"}/${name ? `projects/${name}` : ""}.
Website: ${process.env.STORM_HOMEPAGE || workspaceConfig?.homepage || "https://stormsoftware.com"}
Repository: ${process.env.STORM_REPOSITORY || workspaceConfig?.repository || `https://github.com/${organization}${name ? `/${name}` : ""}`}
Documentation: ${process.env.STORM_DOCS || workspaceConfig?.docs || `https://docs.stormsoftware.com${name ? `/projects/${name}` : ""}`}
Contact: ${(process.env.STORM_HOMEPAGE || workspaceConfig?.homepage || "https://stormsoftware.com").endsWith("/") ? (process.env.STORM_HOMEPAGE || workspaceConfig?.homepage || "https://stormsoftware.com").slice(-1) : process.env.STORM_HOMEPAGE || workspaceConfig?.homepage || "https://stormsoftware.com"}/contact
SPDX-License-Identifier: ${license}
------------------------------------------------------------------- `;
};
export { getFileBanner };