mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-28 01:10:54 +01:00
feat: add everyone group (#1322)
* feat: add everyone group through seed * feat: add reserved group name check in group router actions * feat: improve user interface for everyone group * fix: reserved group alert is a server component * feat: add all users to everyone group * chore: update lockfile * fix: format issues * fix: lint issues * fix: lint format issues * test: add unit tests for everyone group * refactor: add codegen for documentation urls by sitemap * refactor: change group query to count * chore: remove migrations temporarily * chore: add migrations again * chore: add lint rule to prevent usage of raw documentation links * fix: format issues
This commit is contained in:
75
packages/definitions/src/docs/codegen.ts
Normal file
75
packages/definitions/src/docs/codegen.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import fs from "fs/promises";
|
||||
import path, { dirname } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { XMLParser } from "fast-xml-parser";
|
||||
import { z } from "zod";
|
||||
|
||||
import { createDocumentationLink } from "./index";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const removeCommonUrl = (url: string) => {
|
||||
return url.replace("https://homarr.dev", "");
|
||||
};
|
||||
|
||||
const sitemapSchema = z.object({
|
||||
urlset: z.object({
|
||||
url: z.array(
|
||||
z.object({
|
||||
loc: z.string(),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
});
|
||||
|
||||
const fetchSitemapAsync = async () => {
|
||||
const response = await fetch(createDocumentationLink("/sitemap.xml"));
|
||||
return await response.text();
|
||||
};
|
||||
|
||||
const parseXml = (sitemapXml: string) => {
|
||||
const parser = new XMLParser();
|
||||
const data: unknown = parser.parse(sitemapXml);
|
||||
const result = sitemapSchema.safeParse(data);
|
||||
if (!result.success) {
|
||||
throw new Error("Invalid sitemap schema");
|
||||
}
|
||||
|
||||
return result.data;
|
||||
};
|
||||
|
||||
const mapSitemapXmlToPaths = (sitemapData: z.infer<typeof sitemapSchema>) => {
|
||||
return sitemapData.urlset.url.map((url) => removeCommonUrl(url.loc));
|
||||
};
|
||||
|
||||
const createSitemapPathType = (paths: string[]) => {
|
||||
return "export type HomarrDocumentationPath =\n" + paths.map((path) => ` | "${path.replace(/\/$/, "")}"`).join("\n");
|
||||
};
|
||||
|
||||
const updateSitemapTypeFileAsync = async (sitemapPathType: string) => {
|
||||
const content =
|
||||
"// This file is auto-generated by the codegen script\n" +
|
||||
"// it uses the sitemap.xml to generate the HomarrDocumentationPath type\n" +
|
||||
sitemapPathType +
|
||||
";\n";
|
||||
|
||||
await fs.writeFile(path.join(__dirname, "homarr-docs-sitemap.ts"), content);
|
||||
};
|
||||
|
||||
/**
|
||||
* This script fetches the sitemap.xml and generates the HomarrDocumentationPath type
|
||||
* which is used for typesafe documentation links
|
||||
*/
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
const main = async () => {
|
||||
const sitemapXml = await fetchSitemapAsync();
|
||||
const sitemapData = parseXml(sitemapXml);
|
||||
const paths = mapSitemapXmlToPaths(sitemapData);
|
||||
// Adding sitemap as it's not in the sitemap.xml and we need it for this file
|
||||
paths.push("/sitemap.xml");
|
||||
const sitemapPathType = createSitemapPathType(paths);
|
||||
await updateSitemapTypeFileAsync(sitemapPathType);
|
||||
};
|
||||
|
||||
void main();
|
||||
191
packages/definitions/src/docs/homarr-docs-sitemap.ts
Normal file
191
packages/definitions/src/docs/homarr-docs-sitemap.ts
Normal file
@@ -0,0 +1,191 @@
|
||||
// This file is auto-generated by the codegen script
|
||||
// it uses the sitemap.xml to generate the HomarrDocumentationPath type
|
||||
export type HomarrDocumentationPath =
|
||||
| "/about-us"
|
||||
| "/blog"
|
||||
| "/blog/2023/01/11/version0.11"
|
||||
| "/blog/2023/04/16/version0.12-more-widgets"
|
||||
| "/blog/2023/11/10/authentication"
|
||||
| "/blog/2023/12/22/updated-documentation"
|
||||
| "/blog/2024/09/23/version-1.0"
|
||||
| "/blog/archive"
|
||||
| "/blog/authors"
|
||||
| "/blog/authors/ajnart"
|
||||
| "/blog/authors/manuel-rw"
|
||||
| "/blog/authors/meierschlumpf"
|
||||
| "/blog/authors/tagashi"
|
||||
| "/blog/authors/walkx"
|
||||
| "/blog/documentation-migration"
|
||||
| "/blog/tags"
|
||||
| "/blog/tags/authentication"
|
||||
| "/blog/tags/breaking-changes"
|
||||
| "/blog/tags/contributions"
|
||||
| "/blog/tags/design"
|
||||
| "/blog/tags/dnd"
|
||||
| "/blog/tags/docs"
|
||||
| "/blog/tags/documentation"
|
||||
| "/blog/tags/gridstack"
|
||||
| "/blog/tags/homarr"
|
||||
| "/blog/tags/migration"
|
||||
| "/blog/tags/notepad"
|
||||
| "/blog/tags/security"
|
||||
| "/blog/tags/translations"
|
||||
| "/blog/tags/update"
|
||||
| "/blog/tags/version"
|
||||
| "/blog/translations"
|
||||
| "/docs/tags"
|
||||
| "/docs/tags/active-directory"
|
||||
| "/docs/tags/ad-guard"
|
||||
| "/docs/tags/ad-guard-home"
|
||||
| "/docs/tags/administration"
|
||||
| "/docs/tags/advanced"
|
||||
| "/docs/tags/analytics"
|
||||
| "/docs/tags/api"
|
||||
| "/docs/tags/banner"
|
||||
| "/docs/tags/blocking"
|
||||
| "/docs/tags/board"
|
||||
| "/docs/tags/boards"
|
||||
| "/docs/tags/bookmark"
|
||||
| "/docs/tags/caddy"
|
||||
| "/docs/tags/checklist"
|
||||
| "/docs/tags/code"
|
||||
| "/docs/tags/community"
|
||||
| "/docs/tags/configuration"
|
||||
| "/docs/tags/connections"
|
||||
| "/docs/tags/customization"
|
||||
| "/docs/tags/data-sources"
|
||||
| "/docs/tags/developer"
|
||||
| "/docs/tags/development"
|
||||
| "/docs/tags/dns"
|
||||
| "/docs/tags/docker"
|
||||
| "/docs/tags/edit-mode"
|
||||
| "/docs/tags/env"
|
||||
| "/docs/tags/environment-variables"
|
||||
| "/docs/tags/feeds"
|
||||
| "/docs/tags/getting-started"
|
||||
| "/docs/tags/google"
|
||||
| "/docs/tags/grafana"
|
||||
| "/docs/tags/groups"
|
||||
| "/docs/tags/hardware"
|
||||
| "/docs/tags/health"
|
||||
| "/docs/tags/help"
|
||||
| "/docs/tags/icons"
|
||||
| "/docs/tags/iframe"
|
||||
| "/docs/tags/images"
|
||||
| "/docs/tags/installation"
|
||||
| "/docs/tags/integrade"
|
||||
| "/docs/tags/integration"
|
||||
| "/docs/tags/integrations"
|
||||
| "/docs/tags/interface"
|
||||
| "/docs/tags/jellyserr"
|
||||
| "/docs/tags/ldap"
|
||||
| "/docs/tags/links"
|
||||
| "/docs/tags/lists"
|
||||
| "/docs/tags/management"
|
||||
| "/docs/tags/monitoring"
|
||||
| "/docs/tags/news"
|
||||
| "/docs/tags/notebook"
|
||||
| "/docs/tags/notes"
|
||||
| "/docs/tags/oidc"
|
||||
| "/docs/tags/open-media-vault"
|
||||
| "/docs/tags/overseerr"
|
||||
| "/docs/tags/permissions"
|
||||
| "/docs/tags/pi-hole"
|
||||
| "/docs/tags/preferences"
|
||||
| "/docs/tags/programming"
|
||||
| "/docs/tags/proxmox"
|
||||
| "/docs/tags/proxy"
|
||||
| "/docs/tags/roles"
|
||||
| "/docs/tags/rss"
|
||||
| "/docs/tags/search"
|
||||
| "/docs/tags/search-engines"
|
||||
| "/docs/tags/security"
|
||||
| "/docs/tags/seo"
|
||||
| "/docs/tags/server"
|
||||
| "/docs/tags/settings"
|
||||
| "/docs/tags/sinkhole"
|
||||
| "/docs/tags/sso"
|
||||
| "/docs/tags/system"
|
||||
| "/docs/tags/table"
|
||||
| "/docs/tags/technical-documentation"
|
||||
| "/docs/tags/text"
|
||||
| "/docs/tags/theming"
|
||||
| "/docs/tags/traefik"
|
||||
| "/docs/tags/translations"
|
||||
| "/docs/tags/unraid"
|
||||
| "/docs/tags/user"
|
||||
| "/docs/tags/users"
|
||||
| "/docs/tags/variables"
|
||||
| "/docs/tags/widgets"
|
||||
| "/docs/advanced/command-line"
|
||||
| "/docs/advanced/command-line/password-recovery"
|
||||
| "/docs/advanced/configuration/environment-variables"
|
||||
| "/docs/advanced/configuration/keyboard-shortcuts"
|
||||
| "/docs/advanced/configuration/proxies-and-certificates"
|
||||
| "/docs/advanced/customizations/board-customization"
|
||||
| "/docs/advanced/customizations/dark-mode"
|
||||
| "/docs/advanced/customizations/icons"
|
||||
| "/docs/advanced/customizations/user-preferences"
|
||||
| "/docs/advanced/sso"
|
||||
| "/docs/category/advanced"
|
||||
| "/docs/category/getting-started"
|
||||
| "/docs/category/installation"
|
||||
| "/docs/category/installation-1"
|
||||
| "/docs/category/integrations"
|
||||
| "/docs/category/management"
|
||||
| "/docs/category/more"
|
||||
| "/docs/category/widgets"
|
||||
| "/docs/community/developer-guides"
|
||||
| "/docs/community/donate"
|
||||
| "/docs/community/faq"
|
||||
| "/docs/community/get-in-touch"
|
||||
| "/docs/community/license"
|
||||
| "/docs/community/translations"
|
||||
| "/docs/getting-started"
|
||||
| "/docs/getting-started/after-the-installation"
|
||||
| "/docs/getting-started/glossary"
|
||||
| "/docs/getting-started/installation/docker"
|
||||
| "/docs/getting-started/installation/easy-panel"
|
||||
| "/docs/getting-started/installation/home-assistant"
|
||||
| "/docs/getting-started/installation/kubernetes"
|
||||
| "/docs/getting-started/installation/portainer"
|
||||
| "/docs/getting-started/installation/qnap"
|
||||
| "/docs/getting-started/installation/saltbox"
|
||||
| "/docs/getting-started/installation/source"
|
||||
| "/docs/getting-started/installation/synology"
|
||||
| "/docs/getting-started/installation/truenas"
|
||||
| "/docs/getting-started/installation/unraid"
|
||||
| "/docs/integrations/containers"
|
||||
| "/docs/integrations/dns"
|
||||
| "/docs/integrations/hardware"
|
||||
| "/docs/integrations/media-requester"
|
||||
| "/docs/integrations/media-server"
|
||||
| "/docs/integrations/servarr"
|
||||
| "/docs/integrations/torrent"
|
||||
| "/docs/integrations/usenet"
|
||||
| "/docs/management/api"
|
||||
| "/docs/management/boards"
|
||||
| "/docs/management/integrations"
|
||||
| "/docs/management/search-engines"
|
||||
| "/docs/management/settings"
|
||||
| "/docs/management/users"
|
||||
| "/docs/widgets/bookmarks"
|
||||
| "/docs/widgets/calendar-widget"
|
||||
| "/docs/widgets/clock-widget"
|
||||
| "/docs/widgets/dashdot-widget"
|
||||
| "/docs/widgets/dns-hole"
|
||||
| "/docs/widgets/download-speed-widget"
|
||||
| "/docs/widgets/health-monitoring"
|
||||
| "/docs/widgets/home-assistant"
|
||||
| "/docs/widgets/iframe"
|
||||
| "/docs/widgets/indexer-manager"
|
||||
| "/docs/widgets/media-requests"
|
||||
| "/docs/widgets/media-server"
|
||||
| "/docs/widgets/notebook"
|
||||
| "/docs/widgets/rss-widget"
|
||||
| "/docs/widgets/torrent-widget"
|
||||
| "/docs/widgets/usenet-widget"
|
||||
| "/docs/widgets/video"
|
||||
| "/docs/widgets/weather-widget"
|
||||
| ""
|
||||
| "/sitemap.xml";
|
||||
7
packages/definitions/src/docs/index.ts
Normal file
7
packages/definitions/src/docs/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { HomarrDocumentationPath } from "./homarr-docs-sitemap";
|
||||
|
||||
const documentationBaseUrl = "https://deploy-preview-113--homarr-docs.netlify.app";
|
||||
|
||||
// Please use the method so the path can be checked!
|
||||
export const createDocumentationLink = (path: HomarrDocumentationPath, hashTag?: `#${string}`) =>
|
||||
`${documentationBaseUrl}${path}${hashTag ?? ""}`;
|
||||
Reference in New Issue
Block a user