progmaweb
The site and account service of Progmasoft: a Next.js frontend and an ASP.NET Core API.
Clonegit clone https://git.progmasoft.com/progmaweb
Show the Tazel plugins of ViGet, open the Gradle catalog, and route their files
- Commit
3d1c6d52b830d201a68b0440a8a81c13b74c8b92- Author
- Leitwolf11 ·
- Parents
58fa0d19d223
Changes
apps/web/app/viget.css | 65 ++++++ apps/web/app/viget/dslplugins/gradle/page.tsx | 93 ++++++++ .../dslplugins/tazel/[publisher]/[name]/page.tsx | 198 ++++++++++++++++ apps/web/app/viget/dslplugins/tazel/page.tsx | 55 ++++- apps/web/lib/localization.ts | 16 +- apps/web/lib/viget-catalogs.ts | 6 +- apps/web/lib/viget-plugins.ts | 253 +++++++++++++++++++++ apps/web/proxy.ts | 22 ++ apps/web/tests/viget-catalogs.test.mjs | 2 +- apps/web/tests/viget-plugins.test.mjs | 53 +++++ ops/README.md | 56 +++++ ops/nginx/progmaweb.conf | 74 ++++++ 12 files changed, 881 insertions(+), 12 deletions(-) diff --git a/apps/web/app/viget.css b/apps/web/app/viget.css index 9d6b68f..7010440 100644 --- a/apps/web/app/viget.css +++ b/apps/web/app/viget.css @@ -359,3 +359,68 @@ a.viget-catalog-card:hover { .viget-catalog-disabled small { color: var(--ink-500); } + +/* The pages of the Tazel plugins: the usage snippet and the table of versions. */ +.viget-plugin-empty { + margin: 0; + color: var(--ink-650); +} + +.viget-snippet { + overflow-x: auto; + margin: 0; + border-radius: var(--radius-sm); + padding: 18px 20px; + background: var(--surface-blue); + color: var(--blue-700); + font-family: "Cascadia Code", Consolas, monospace; + font-size: 14px; + line-height: 1.6; +} + +.viget-catalog-card .viget-snippet { + margin-top: 20px; +} + +.viget-table-scroll { + overflow-x: auto; +} + +.viget-versions { + width: 100%; + border-collapse: collapse; + font-size: 15px; +} + +.viget-versions th, +.viget-versions td { + border-bottom: 1px solid var(--line); + padding: 12px 14px; + text-align: start; + white-space: nowrap; +} + +.viget-versions th { + color: var(--ink-500); + font-size: 13px; + font-weight: 700; +} + +.viget-versions code { + font-family: "Cascadia Code", Consolas, monospace; + font-size: 13px; +} + +.viget-yanked td { + color: var(--ink-500); +} + +.viget-badge { + margin-inline-start: 10px; + border-radius: 999px; + padding: 2px 9px; + background: var(--line); + color: var(--ink-650); + font-size: 12px; + font-weight: 700; +} diff --git a/apps/web/app/viget/dslplugins/gradle/page.tsx b/apps/web/app/viget/dslplugins/gradle/page.tsx new file mode 100644 index 0000000..494d863 --- /dev/null +++ b/apps/web/app/viget/dslplugins/gradle/page.tsx @@ -0,0 +1,93 @@ +// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com> +// SPDX-License-Identifier: AGPL-3.0-or-later WITH AdditionRef-Progmasoft-Patent-Grant-1.1 + +import type { Metadata } from "next"; +import { ViGetFooter } from "@/components/ViGetFooter"; +import { ViGetHeader } from "@/components/ViGetHeader"; +import { getLocale } from "@/lib/locale.server"; +import { forwardArrow } from "@/lib/localization"; +import { catalogText } from "@/lib/viget-catalogs"; +import { gradlePlugins, pluginText } from "@/lib/viget-plugins"; + +export async function generateMetadata(): Promise<Metadata> { + const locale = await getLocale(); + const text = pluginText(locale); + return { + title: `${text.gradleTitle} · ViGet`, + description: text.gradleDescription, + alternates: { + canonical: "https://viget.progmasoft.com/dslplugins/gradle", + }, + robots: { index: true, follow: true }, + }; +} + +/** The Gradle catalog: a list only; Gradle downloads the plugins from the Gradle Plugin Portal. */ +export default async function GradlePluginsPage() { + const locale = await getLocale(); + const text = pluginText(locale); + const catalogs = catalogText(locale); + return ( + <div className="viget-surface"> + <ViGetHeader locale={locale} /> + <main> + <section className="viget-plugin-hero"> + <div className="shell viget-plugin-grid"> + <div className="viget-hero-copy"> + <p className="eyebrow">ViGet · BUILD SYSTEM DSL PLUGINS</p> + <h1>{text.gradleTitle}</h1> + <p>{text.gradleDescription}</p> + <div className="hero-actions"> + <a + className="button button-secondary" + href="https://viget.progmasoft.com/" + > + {catalogs.backToRegistry} + </a> + <a + className="viget-text-link" + href="https://plugins.gradle.org/" + rel="noopener" + > + {text.gradlePortal} {forwardArrow(locale)} + </a> + </div> + </div> + </div> + </section> + <section className="section" aria-labelledby="gradle-list-title"> + <div className="shell"> + <div className="section-heading"> + <div> + <h2 id="gradle-list-title" className="viget-catalog-heading"> + {text.catalogTitle} + </h2> + </div> + </div> + <div className="viget-catalog-grid"> + {gradlePlugins.map((plugin) => ( + <article key={plugin.id} className="viget-catalog-card"> + <span>Gradle</span> + <h3>{plugin.id}</h3> + <small>{plugin.description[locale]}</small> + <pre className="viget-snippet"> + <code>{plugin.usage}</code> + </pre> + <strong> + <a + href={`https://plugins.gradle.org/plugin/${plugin.id}`} + rel="noopener" + > + {text.gradlePortal} {forwardArrow(locale)} + </a> + </strong> + </article> + ))} + </div> + </div> + </section> + </main> + <ViGetFooter locale={locale} /> + </div> + ); +} diff --git a/apps/web/app/viget/dslplugins/tazel/[publisher]/[name]/page.tsx b/apps/web/app/viget/dslplugins/tazel/[publisher]/[name]/page.tsx new file mode 100644 index 0000000..73a2248 --- /dev/null +++ b/apps/web/app/viget/dslplugins/tazel/[publisher]/[name]/page.tsx @@ -0,0 +1,198 @@ +// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com> +// SPDX-License-Identifier: AGPL-3.0-or-later WITH AdditionRef-Progmasoft-Patent-Grant-1.1 + +import type { Metadata } from "next"; +import { notFound } from "next/navigation"; +import { ViGetFooter } from "@/components/ViGetFooter"; +import { ViGetHeader } from "@/components/ViGetHeader"; +import { getLocale } from "@/lib/locale.server"; +import { forwardArrow } from "@/lib/localization"; +import { + pluginDeclaration, + pluginText, + tazelPlugin, +} from "@/lib/viget-plugins"; + +// A page shows the versions as they are published and yanked. +export const dynamic = "force-dynamic"; + +type Parameters = { params: Promise<{ publisher: string; name: string }> }; + +export async function generateMetadata({ + params, +}: Parameters): Promise<Metadata> { + const { publisher, name } = await params; + const plugin = await tazelPlugin(publisher, name); + if (!plugin) + return { title: "ViGet", robots: { index: false, follow: false } }; + return { + title: `${plugin.publisher}.${plugin.name} · Tazel DSL plugins · ViGet`, + description: plugin.description ?? undefined, + alternates: { + canonical: `https://viget.progmasoft.com/dslplugins/tazel/${plugin.publisher}/${plugin.name}`, + }, + robots: { index: true, follow: true }, + }; +} + +function formatSize(bytes: number): string { + return bytes < 1024 * 1024 + ? `${(bytes / 1024).toFixed(1)} KiB` + : `${(bytes / 1024 / 1024).toFixed(1)} MiB`; +} + +export default async function TazelPluginPage({ params }: Parameters) { + const { publisher, name } = await params; + const plugin = await tazelPlugin(publisher, name); + if (!plugin) notFound(); + const locale = await getLocale(); + const text = pluginText(locale); + const dates = new Intl.DateTimeFormat(locale, { dateStyle: "medium" }); + return ( + <div className="viget-surface"> + <ViGetHeader locale={locale} /> + <main> + <section className="viget-plugin-hero"> + <div className="shell viget-plugin-grid"> + <div className="viget-hero-copy"> + <p className="eyebrow">ViGet · TAZEL DSL PLUGIN</p> + <h1>{plugin.name}</h1> + {plugin.description ? <p>{plugin.description}</p> : null} + <div className="hero-actions"> + <a + className="button button-secondary" + href="https://viget.progmasoft.com/dslplugins/tazel" + > + {text.backToCatalog} + </a> + {plugin.homepage ? ( + <a + className="viget-text-link" + href={plugin.homepage} + rel="noopener" + > + {text.homepage} {forwardArrow(locale)} + </a> + ) : null} + {plugin.repository ? ( + <a + className="viget-text-link" + href={plugin.repository} + rel="noopener" + > + {text.repository} {forwardArrow(locale)} + </a> + ) : null} + </div> + </div> + <aside + className="viget-availability" + aria-labelledby="plugin-facts-title" + > + <h2 id="plugin-facts-title"> + {plugin.publisher}.{plugin.name} + </h2> + <dl> + <div> + <dt>{text.publisherLabel}</dt> + <dd>{plugin.publisher}</dd> + </div> + <div> + <dt>{text.latest}</dt> + <dd>{plugin.latestVersion}</dd> + </div> + {plugin.license ? ( + <div> + <dt>{text.license}</dt> + <dd>{plugin.license}</dd> + </div> + ) : null} + {plugin.authors.length > 0 ? ( + <div> + <dt>{text.authors}</dt> + <dd>{plugin.authors.join(", ")}</dd> + </div> + ) : null} + </dl> + </aside> + </div> + </section> + <section className="section" aria-labelledby="plugin-usage-title"> + <div className="shell"> + <div className="section-heading"> + <div> + <h2 id="plugin-usage-title" className="viget-catalog-heading"> + {text.usage} + </h2> + </div> + <p>{text.usageDescription}</p> + </div> + <pre className="viget-snippet"> + <code>{pluginDeclaration(plugin, plugin.latestVersion)}</code> + </pre> + </div> + </section> + <section + className="section section-muted" + aria-labelledby="plugin-versions-title" + > + <div className="shell"> + <div className="section-heading"> + <div> + <h2 + id="plugin-versions-title" + className="viget-catalog-heading" + > + {text.versions} + </h2> + </div> + </div> + <div className="viget-table-scroll"> + <table className="viget-versions"> + <thead> + <tr> + <th scope="col">{text.version}</th> + <th scope="col">{text.published}</th> + <th scope="col">{text.api}</th> + <th scope="col">{text.size}</th> + <th scope="col">SHA-256</th> + <th scope="col">{text.download}</th> + </tr> + </thead> + <tbody> + {plugin.versions.map((version) => ( + <tr + key={version.version} + className={version.yanked ? "viget-yanked" : undefined} + > + <td> + {version.version} + {version.yanked ? ( + <span className="viget-badge">{text.yanked}</span> + ) : null} + </td> + <td>{dates.format(new Date(version.publishedAt))}</td> + <td>{version.apiVersion}</td> + <td>{formatSize(version.size)}</td> + <td> + <code title={version.sha256}> + {version.sha256.slice(0, 16)}… + </code> + </td> + <td> + <a href={`https://viget.progmasoft.com${version.path}`}> + {plugin.name}-{version.version}.jar + </a> + </td> + </tr> + ))} + </tbody> + </table> + </div> + </div> + </section> + </main> + <ViGetFooter locale={locale} /> + </div> + ); +} diff --git a/apps/web/app/viget/dslplugins/tazel/page.tsx b/apps/web/app/viget/dslplugins/tazel/page.tsx index 5195170..cd7246f 100644 --- a/apps/web/app/viget/dslplugins/tazel/page.tsx +++ b/apps/web/app/viget/dslplugins/tazel/page.tsx @@ -7,6 +7,10 @@ import { ViGetHeader } from "@/components/ViGetHeader"; import { getLocale } from "@/lib/locale.server"; import { forwardArrow, getMessages } from "@/lib/localization"; import { catalogText } from "@/lib/viget-catalogs"; +import { pluginText, tazelPlugins } from "@/lib/viget-plugins"; + +// The catalog changes whenever a plugin is published. +export const dynamic = "force-dynamic"; export async function generateMetadata(): Promise<Metadata> { const locale = await getLocale(); @@ -25,6 +29,8 @@ export default async function TazelPluginsPage() { const locale = await getLocale(); const { viget } = getMessages(locale); const catalogs = catalogText(locale); + const text = pluginText(locale); + const plugins = await tazelPlugins(); return ( <div className="viget-surface"> <ViGetHeader locale={locale} /> @@ -55,12 +61,57 @@ export default async function TazelPluginsPage() { <span aria-hidden="true" /> {viget.pluginAvailable} </div> - <h2 id="plugin-availability-title">{viget.pluginEmptyTitle}</h2> - <p>{viget.pluginEmptyDescription}</p> + <h2 id="plugin-availability-title"> + {plugins.length > 0 + ? text.catalogTitle + : viget.pluginEmptyTitle} + </h2> + <p> + {plugins.length > 0 + ? plugins + .map((plugin) => `${plugin.publisher}.${plugin.name}`) + .join(", ") + : viget.pluginEmptyDescription} + </p> <code>/dslplugins/tazel/<Publisher>/<Name>/</code> </aside> </div> </section> + <section className="section" aria-labelledby="plugin-list-title"> + <div className="shell"> + <div className="section-heading"> + <div> + <h2 id="plugin-list-title" className="viget-catalog-heading"> + {text.catalogTitle} + </h2> + </div> + </div> + {plugins.length === 0 ? ( + <p className="viget-plugin-empty">{text.catalogEmpty}</p> + ) : ( + <div className="viget-catalog-grid"> + {plugins.map((plugin) => ( + <a + key={`${plugin.publisher}/${plugin.name}`} + className="viget-catalog-card viget-catalog-primary" + href={`https://viget.progmasoft.com/dslplugins/tazel/${plugin.publisher}/${plugin.name}`} + > + <span>{plugin.publisher}</span> + <h3>{plugin.name}</h3> + {plugin.description ? ( + <small>{plugin.description}</small> + ) : null} + <strong> + {text.latest} {plugin.latestVersion} + {plugin.license ? ` · ${plugin.license}` : ""}{" "} + {forwardArrow(locale)} + </strong> + </a> + ))} + </div> + )} + </div> + </section> <section className="section section-muted"> <div className="shell viget-guidance-grid"> {viget.guidance.map(([label, title, description]) => ( diff --git a/apps/web/lib/localization.ts b/apps/web/lib/localization.ts index 13b65ec..3213adf 100644 --- a/apps/web/lib/localization.ts +++ b/apps/web/lib/localization.ts @@ -366,8 +366,8 @@ export const messages = { ], [ "Availability", - "Publishing closed", - "Publishing opens only after the signed plugin contract is complete.", + "Progmasoft first", + "Progmasoft publishes the first plugins; publishing opens to every account later.", ], ], footerDescription: @@ -621,8 +621,8 @@ export const messages = { ], [ "Verfügbarkeit", - "Veröffentlichung geschlossen", - "Die Veröffentlichung wird erst nach Fertigstellung des signierten Plugin-Vertrags geöffnet.", + "Zuerst Progmasoft", + "Progmasoft veröffentlicht die ersten Plugins; später öffnet die Veröffentlichung für jedes Konto.", ], ], footerDescription: @@ -876,8 +876,8 @@ export const messages = { ], [ "Доступность", - "Публикация закрыта", - "Публикация откроется только после завершения контракта подписанных плагинов.", + "Сначала Progmasoft", + "Первые плагины публикует Progmasoft; позже публикация откроется для всех учётных записей.", ], ], footerDescription: @@ -1109,8 +1109,8 @@ export const messages = { ], [ "זמינות", - "הפרסום סגור", - "הפרסום ייפתח רק לאחר השלמת חוזה התוספים החתומים.", + "תחילה Progmasoft", + "Progmasoft מפרסמת את התוספים הראשונים; בהמשך הפרסום ייפתח לכל חשבון.", ], ], footerDescription: diff --git a/apps/web/lib/viget-catalogs.ts b/apps/web/lib/viget-catalogs.ts index ae49c51..410d3d1 100644 --- a/apps/web/lib/viget-catalogs.ts +++ b/apps/web/lib/viget-catalogs.ts @@ -21,7 +21,7 @@ export const languageCatalogs: readonly Catalog[] = [ /** The build systems whose DSL plugins ViGet hosts, in the order the page lists them. */ export const buildSystemCatalogs: readonly Catalog[] = [ { name: "Tazel", path: "/dslplugins/tazel" }, - { name: "Gradle" }, + { name: "Gradle", path: "/dslplugins/gradle" }, ]; // The two section names are the ones the registry uses everywhere; they are @@ -56,6 +56,7 @@ const text: Record<Locale, CatalogText> = { holds: { Tala: "Libraries and applications written in Tala.", Tazel: "Kotlin JAR plugins for the project file of Tazel.", + Gradle: "Gradle plugins of Progmasoft, from the Gradle Plugin Portal.", }, notAvailable: "Not available yet", open: "Open catalog", @@ -79,6 +80,7 @@ const text: Record<Locale, CatalogText> = { holds: { Tala: "Bibliotheken und Anwendungen, geschrieben in Tala.", Tazel: "Kotlin-JAR-Plugins für die Projektdatei von Tazel.", + Gradle: "Gradle-Plugins von Progmasoft, vom Gradle Plugin Portal.", }, notAvailable: "Noch nicht verfügbar", open: "Katalog öffnen", @@ -102,6 +104,7 @@ const text: Record<Locale, CatalogText> = { holds: { Tala: "Библиотеки и приложения, написанные на Tala.", Tazel: "Плагины Kotlin JAR для файла проекта Tazel.", + Gradle: "Плагины Gradle от Progmasoft, с Gradle Plugin Portal.", }, notAvailable: "Пока недоступно", open: "Открыть каталог", @@ -123,6 +126,7 @@ const text: Record<Locale, CatalogText> = { holds: { Tala: "ספריות ויישומים שנכתבו ב-Tala.", Tazel: "תוספי Kotlin JAR עבור קובץ הפרויקט של Tazel.", + Gradle: "תוספי Gradle של Progmasoft, מ-Gradle Plugin Portal.", }, notAvailable: "עוד לא זמין", open: "פתיחת הקטלוג", diff --git a/apps/web/lib/viget-plugins.ts b/apps/web/lib/viget-plugins.ts new file mode 100644 index 0000000..1ae4a7d --- /dev/null +++ b/apps/web/lib/viget-plugins.ts @@ -0,0 +1,253 @@ +// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com> +// SPDX-License-Identifier: AGPL-3.0-or-later WITH AdditionRef-Progmasoft-Patent-Grant-1.1 + +import type { Locale } from "./localization"; + +/** A Tazel plugin as the list of the catalog shows it. */ +export type TazelPluginSummary = { + readonly publisher: string; + readonly name: string; + readonly description: string | null; + readonly license: string | null; + readonly latestVersion: string; + readonly updatedAt: string; +}; + +/** One published version of a Tazel plugin. */ +export type TazelPluginVersion = { + readonly version: string; + readonly sha256: string; + readonly apiVersion: number; + readonly size: number; + readonly publishedAt: string; + readonly yanked: boolean; + /** The address of the JAR on the ViGet host. */ + readonly path: string; +}; + +/** A Tazel plugin with everything its page shows. */ +export type TazelPlugin = { + readonly publisher: string; + readonly name: string; + readonly description: string | null; + readonly authors: readonly string[]; + readonly license: string | null; + readonly homepage: string | null; + readonly repository: string | null; + readonly latestVersion: string; + readonly versions: readonly TazelPluginVersion[]; +}; + +/** A Gradle plugin the catalog lists; Gradle downloads it from the Gradle Plugin Portal. */ +export type GradlePlugin = { + readonly id: string; + readonly description: Record<Locale, string>; + readonly usage: string; +}; + +/** The Gradle plugins of Progmasoft. */ +export const gradlePlugins: readonly GradlePlugin[] = [ + { + id: "com.progmasoft.tazel.plugin", + description: { + "en-US": + "Builds plugins of the Tazel project file: adds the Tazel API as tazelApi() and writes the descriptor of the plugin from tazelPlugin { }.", + "de-DE": + "Baut Plugins für die Projektdatei von Tazel: stellt die Tazel-API als tazelApi() bereit und schreibt den Deskriptor des Plugins aus tazelPlugin { }.", + "ru-RU": + "Собирает плагины для файла проекта Tazel: добавляет API Tazel как tazelApi() и записывает дескриптор плагина из tazelPlugin { }.", + "he-IL": + "בונה תוספים לקובץ הפרויקט של Tazel: מוסיף את ה-API של Tazel כ-tazelApi() וכותב את מתאר התוסף מתוך tazelPlugin { }.", + }, + usage: 'plugins {\n id("com.progmasoft.tazel.plugin") version "0.2.0"\n}', + }, +]; + +// The pages run on the server, beside the API on its loopback address. Nginx +// does not pass /api/ of the ViGet host on, so these addresses stay private. +const apiOrigin = process.env.PROGMAWEB_API_ORIGIN ?? "http://127.0.0.1:5085"; + +async function read<T>(path: string): Promise<T | null> { + try { + const response = await fetch( + `${apiOrigin}/api/v1/viget/dslplugins/tazel${path}`, + { + cache: "no-store", + headers: { Accept: "application/json" }, + }, + ); + return response.ok ? ((await response.json()) as T) : null; + } catch { + // An unreachable API shows an empty catalog rather than an error page. + return null; + } +} + +/** Every Tazel plugin of the catalog; empty when the API cannot be reached. */ +export async function tazelPlugins(): Promise<readonly TazelPluginSummary[]> { + const list = await read<{ plugins: TazelPluginSummary[] }>(""); + return list?.plugins ?? []; +} + +/** A Tazel plugin by its exact publisher and name, or null. */ +export async function tazelPlugin( + publisher: string, + name: string, +): Promise<TazelPlugin | null> { + const identifier = /^[A-Za-z_][A-Za-z0-9_]*$/; + if (!identifier.test(publisher) || !identifier.test(name)) return null; + return read<TazelPlugin>(`/${publisher}/${name}`); +} + +/** The declaration a project file writes to use a plugin. */ +export function pluginDeclaration( + plugin: { publisher: string; name: string }, + version: string, +): string { + return `plugins {\n plugin("${plugin.publisher}") {\n name = "${plugin.name}"\n version = "${version}"\n }\n}`; +} + +type PluginText = { + catalogTitle: string; + catalogEmpty: string; + latest: string; + license: string; + authors: string; + homepage: string; + repository: string; + versions: string; + version: string; + published: string; + api: string; + size: string; + yanked: string; + download: string; + usage: string; + usageDescription: string; + publisherLabel: string; + backToCatalog: string; + notFoundTitle: string; + notFoundDescription: string; + gradleTitle: string; + gradleDescription: string; + gradlePortal: string; +}; + +const text: Record<Locale, PluginText> = { + "en-US": { + catalogTitle: "Published plugins", + catalogEmpty: "No plugin is published yet.", + latest: "Latest", + license: "License", + authors: "Authors", + homepage: "Homepage", + repository: "Repository", + versions: "Versions", + version: "Version", + published: "Published", + api: "Plugin API", + size: "Size", + yanked: "Yanked", + download: "JAR", + usage: "Use it", + usageDescription: + "Declare the plugin at the top of BUILD.kts; Tazel downloads it from ViGet and checks its SHA-256.", + publisherLabel: "Publisher", + backToCatalog: "Back to the Tazel catalog", + notFoundTitle: "No such plugin.", + notFoundDescription: + "ViGet has no Tazel plugin with this publisher and name.", + gradleTitle: "Gradle plugins", + gradleDescription: + "Gradle plugins of Progmasoft. ViGet lists them; Gradle downloads them from the Gradle Plugin Portal.", + gradlePortal: "Gradle Plugin Portal", + }, + "de-DE": { + catalogTitle: "Veröffentlichte Plugins", + catalogEmpty: "Noch ist kein Plugin veröffentlicht.", + latest: "Neueste", + license: "Lizenz", + authors: "Autoren", + homepage: "Website", + repository: "Repository", + versions: "Versionen", + version: "Version", + published: "Veröffentlicht", + api: "Plugin-API", + size: "Größe", + yanked: "Zurückgezogen", + download: "JAR", + usage: "Verwenden", + usageDescription: + "Deklarieren Sie das Plugin oben in BUILD.kts; Tazel lädt es von ViGet und prüft seine SHA-256.", + publisherLabel: "Herausgeber", + backToCatalog: "Zurück zum Tazel-Katalog", + notFoundTitle: "Kein solches Plugin.", + notFoundDescription: + "ViGet hat kein Tazel-Plugin mit diesem Herausgeber und Namen.", + gradleTitle: "Gradle-Plugins", + gradleDescription: + "Gradle-Plugins von Progmasoft. ViGet listet sie; Gradle lädt sie vom Gradle Plugin Portal.", + gradlePortal: "Gradle Plugin Portal", + }, + "ru-RU": { + catalogTitle: "Опубликованные плагины", + catalogEmpty: "Пока не опубликовано ни одного плагина.", + latest: "Последняя", + license: "Лицензия", + authors: "Авторы", + homepage: "Сайт", + repository: "Репозиторий", + versions: "Версии", + version: "Версия", + published: "Опубликована", + api: "API плагинов", + size: "Размер", + yanked: "Отозвана", + download: "JAR", + usage: "Использование", + usageDescription: + "Объявите плагин в начале BUILD.kts; Tazel загрузит его из ViGet и проверит SHA-256.", + publisherLabel: "Издатель", + backToCatalog: "Назад к каталогу Tazel", + notFoundTitle: "Такого плагина нет.", + notFoundDescription: + "В ViGet нет плагина Tazel с таким издателем и именем.", + gradleTitle: "Плагины Gradle", + gradleDescription: + "Плагины Gradle от Progmasoft. ViGet перечисляет их; Gradle загружает их с Gradle Plugin Portal.", + gradlePortal: "Gradle Plugin Portal", + }, + "he-IL": { + catalogTitle: "תוספים שפורסמו", + catalogEmpty: "עדיין לא פורסם אף תוסף.", + latest: "אחרונה", + license: "רישיון", + authors: "מחברים", + homepage: "אתר", + repository: "מאגר", + versions: "גרסאות", + version: "גרסה", + published: "פורסמה", + api: "API של תוספים", + size: "גודל", + yanked: "נמשכה", + download: "JAR", + usage: "שימוש", + usageDescription: + "הצהירו על התוסף בראש BUILD.kts; Tazel מוריד אותו מ-ViGet ובודק את ה-SHA-256 שלו.", + publisherLabel: "מפרסם", + backToCatalog: "חזרה לקטלוג של Tazel", + notFoundTitle: "אין תוסף כזה.", + notFoundDescription: "ב-ViGet אין תוסף Tazel עם המפרסם והשם האלה.", + gradleTitle: "תוספי Gradle", + gradleDescription: + "תוספי Gradle של Progmasoft. ViGet מציג אותם; Gradle מוריד אותם מ-Gradle Plugin Portal.", + gradlePortal: "Gradle Plugin Portal", + }, +}; + +/** The text of the plugin pages in [locale]. */ +export function pluginText(locale: Locale): PluginText { + return text[locale]; +} diff --git a/apps/web/proxy.ts b/apps/web/proxy.ts index 2842e4c..99e9cc3 100644 --- a/apps/web/proxy.ts +++ b/apps/web/proxy.ts @@ -149,6 +149,28 @@ export function proxy(request: NextRequest) { internalRoute(request, "/viget/dslplugins/tazel"), ); } + // The page of one plugin. Its index.json and JARs below it are served by + // Nginx, from the API and from the files of ViGet. + const plugin = + /^\/dslplugins\/tazel\/([A-Za-z_][A-Za-z0-9_]*)\/([A-Za-z_][A-Za-z0-9_]*)\/?$/.exec( + pathname, + ); + if (plugin) { + return NextResponse.rewrite( + internalRoute( + request, + `/viget/dslplugins/tazel/${plugin[1]}/${plugin[2]}`, + ), + ); + } + if ( + pathname === "/dslplugins/gradle" || + pathname === "/dslplugins/gradle/" + ) { + return NextResponse.rewrite( + internalRoute(request, "/viget/dslplugins/gradle"), + ); + } if (pathname === "/langs" || pathname === "/langs/") { return NextResponse.redirect( new URL("https://viget.progmasoft.com/langs/tala"), diff --git a/apps/web/tests/viget-catalogs.test.mjs b/apps/web/tests/viget-catalogs.test.mjs index 2238998..ed1ea6d 100644 --- a/apps/web/tests/viget-catalogs.test.mjs +++ b/apps/web/tests/viget-catalogs.test.mjs @@ -23,7 +23,7 @@ test("the registry lists Tala and C++, then Tazel and Gradle, under their own he ]); assert.deepEqual(buildSystemCatalogs, [ { name: "Tazel", path: "/dslplugins/tazel" }, - { name: "Gradle" }, + { name: "Gradle", path: "/dslplugins/gradle" }, ]); }); diff --git a/apps/web/tests/viget-plugins.test.mjs b/apps/web/tests/viget-plugins.test.mjs new file mode 100644 index 0000000..739ac6d --- /dev/null +++ b/apps/web/tests/viget-plugins.test.mjs @@ -0,0 +1,53 @@ +// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com> +// SPDX-License-Identifier: AGPL-3.0-or-later WITH AdditionRef-Progmasoft-Patent-Grant-1.1 + +import assert from "node:assert/strict"; +import { test } from "node:test"; +import { + gradlePlugins, + pluginDeclaration, + pluginText, + tazelPlugin, +} from "../lib/viget-plugins.ts"; + +const locales = ["en-US", "de-DE", "ru-RU", "he-IL"]; + +test("the plugin pages have every text in every language", () => { + for (const locale of locales) { + for (const [key, value] of Object.entries(pluginText(locale))) { + assert.ok(value.trim().length > 0, `${locale} ${key}`); + } + for (const plugin of gradlePlugins) { + assert.ok( + plugin.description[locale].length > 0, + `${locale} ${plugin.id}`, + ); + } + } +}); + +test("the declaration is the plugins block Tazel reads", () => { + assert.equal( + pluginDeclaration({ publisher: "Progmasoft", name: "CMake" }, "0.1.0"), + [ + "plugins {", + ' plugin("Progmasoft") {', + ' name = "CMake"', + ' version = "0.1.0"', + " }", + "}", + ].join("\n"), + ); +}); + +test("the Gradle catalog lists the Tazel plugin builder", () => { + assert.deepEqual( + gradlePlugins.map((plugin) => plugin.id), + ["com.progmasoft.tazel.plugin"], + ); +}); + +test("a plugin page asks the API only for names that are identifiers", async () => { + assert.equal(await tazelPlugin("../etc", "passwd"), null); + assert.equal(await tazelPlugin("Progmasoft", "c-make"), null); +}); diff --git a/ops/README.md b/ops/README.md index 61836d3..dd1ee9d 100644 --- a/ops/README.md +++ b/ops/README.md @@ -152,3 +152,59 @@ The certificate of `progmasoft.com` must name `credentials.progmasoft.com`, `aut `console.progmasoft.com`, `product.progmasoft.com`, `ides.progmasoft.com` and `catch3.progmasoft.com` as well; expand it with certbot's webroot plugin before the vhosts are enabled, then check `/.well-known/openid-configuration`, the sign-in page and the console from outside. + +## ViGet: Tazel plugins + +ViGet opens in stages. Now only the accounts that `ViGet__TazelPublishers` names (Progmasoft by default) publish Tazel +plugins, and they publish on the server; later every account will publish through the API. The catalog lives in the +account database (`viget_*` tables, created by the API at start) and the JARs in `/srv/viget/files`, which Nginx +serves: + +| Address on `viget.progmasoft.com` | Served by | +| --- | --- | +| `/dslplugins/tazel`, `/dslplugins/tazel/<Publisher>/<Name>`, `/dslplugins/gradle` | the Next.js site | +| `/dslplugins/tazel/<Publisher>/<Name>/index.json` | the account API, `/api/v1/viget/dslplugins/tazel/...` | +| `/dslplugins/tazel/<Publisher>/<Name>/<Version>/<Name>-<Version>.jar` | the files below `/srv/viget/files` | + +The directory belongs to the service user, and Nginx reads it: + +```sh +install -d -m 0755 -o progmaweb -g progmaweb /srv/viget /srv/viget/files +semanage fcontext -a -t httpd_sys_content_t '/srv/viget/files(/.*)?' +restorecon -R /srv/viget/files +``` + +A plugin JAR is published with the configuration of the service, as its user: + +```sh +cd /srv/progmaweb/current/api +runuser -u progmaweb -- env $(grep -v '^#' /etc/progmaweb/account.env | xargs) \ + ./Progmaweb.Api viget publish-tazel-plugin /tmp/CMake-0.1.0.jar +restorecon -R /srv/viget/files +``` + +The command checks the descriptor of the JAR, the publisher, its account and the version, which is never replaced. +`viget yank-tazel-plugin <Publisher> <Name> <Version>` yanks a version, and `--undo` takes the yank back. + +## Maven repository + +`maven.progmasoft.com/tazel` is a static Maven repository: it holds `com.progmasoft.tazel:tazel-api`, which plugins of +Tazel compile against. It lives in `/srv/maven/tazel`, labelled like the files of ViGet: + +```sh +install -d -m 0755 /srv/maven /srv/maven/tazel +semanage fcontext -a -t httpd_sys_content_t '/srv/maven(/.*)?' +restorecon -R /srv/maven +``` + +A release of Tazel publishes the API into a local copy of the repository and copies it back, so that +`maven-metadata.xml` keeps the versions published before: + +```sh +scp -r root@91.151.88.130:/srv/maven/tazel/. build/maven/ # in the Tazel checkout +./gradlew :tazel-api:publishAllPublicationsToStagingRepository +scp -r build/maven/. root@91.151.88.130:/srv/maven/tazel/ +ssh root@91.151.88.130 'chown -R root:root /srv/maven && restorecon -R /srv/maven' +``` + +Published versions are never changed. The certificate of `progmasoft.com` must name `maven.progmasoft.com`. diff --git a/ops/nginx/progmaweb.conf b/ops/nginx/progmaweb.conf index 39a2546..3cbb21a 100644 --- a/ops/nginx/progmaweb.conf +++ b/ops/nginx/progmaweb.conf @@ -168,6 +168,32 @@ server { proxy_set_header X-Real-IP $remote_addr; } + # The index of a Tazel plugin, which Tazel reads to choose a version and + # check the JAR it downloads: from the API, under its own path. + location ~ "^/dslplugins/tazel/([A-Za-z_][A-Za-z0-9_]*)/([A-Za-z_][A-Za-z0-9_]*)/index\.json$" { + proxy_http_version 1.1; + proxy_pass http://127.0.0.1:5085/api/v1/viget/dslplugins/tazel/$1/$2/index.json; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header X-Real-IP $remote_addr; + add_header Cache-Control "no-cache" always; + add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always; + add_header X-Content-Type-Options "nosniff" always; + } + + # The JARs of Tazel plugins, from the files of ViGet. A version is never + # replaced, so a JAR is cached for good. + location ~ "^/dslplugins/tazel/[A-Za-z_][A-Za-z0-9_]*/[A-Za-z_][A-Za-z0-9_]*/[0-9A-Za-z.+-]+/[A-Za-z_][A-Za-z0-9_]*-[0-9A-Za-z.+-]+\.jar$" { + root /srv/viget/files; + default_type application/java-archive; + types { } + add_header Cache-Control "public, max-age=31536000, immutable" always; + add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always; + add_header X-Content-Type-Options "nosniff" always; + } + location ^~ /api/ { return 404; } @@ -516,3 +542,51 @@ server { proxy_read_timeout 60s; } } + +# The Maven repository of Progmasoft: /tazel holds com.progmasoft.tazel:tazel-api, +# which plugins of Tazel compile against. Static files only, copied from the +# Gradle staging repository of a release; see ops/README.md. +server { + listen 80; + listen [::]:80; + server_name maven.progmasoft.com; + + location ^~ /.well-known/acme-challenge/ { + root /var/lib/letsencrypt; + default_type text/plain; + } + + location / { + return 308 https://maven.progmasoft.com$request_uri; + } +} + +server { + listen 443 ssl; + listen [::]:443 ssl; + http2 on; + server_name maven.progmasoft.com; + + ssl_certificate /etc/letsencrypt/live/progmasoft.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/progmasoft.com/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + + root /srv/maven; + autoindex on; + + add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-Robots-Tag "noindex" always; + + location = / { + return 302 https://maven.progmasoft.com/tazel/; + } + + location ^~ /tazel/ { + try_files $uri $uri/ =404; + } + + location / { + return 404; + } +}