免费获取学习方案
ARTICLE DETAIL

资讯详情

深耕编程基础知识与建站技术分享的一线实战洞察。

Authelia 开发工具 authelia-gen github issue-templates 命令详解:自动生成 GitHub Issue 模板

Authelia 开发工具 authelia-gen github issue-templates 命令详解:自动生成 GitHub Issue 模板 Authelia 开发工具 authelia-gen github issue-templates 命令详解自动生成 GitHub Issue 模板【免费下载链接】autheliaThe Single Sign-On Multi-Factor portal for web apps. OpenID Certified™ and Post-Quantum Cryptography Ready.项目地址: https://gitcode.com/GitHub_Trending/au/authelia导读authelia-gen是 Authelia 仓库内置的代码与文档生成器而authelia-gen github issue-templates是其下负责自动生成 GitHub Issue 模板文件的子命令。本文围绕该命令的完整 CLI 参考文档展开先给出用法与全部参数说明再结合 cmd_github.go 与 templates 中的源码实现剖析模板渲染、标签注入与版本列表生成的底层逻辑最后对照生成产物 .github/ISSUE_TEMPLATE 说明实际效果帮助你理解 Authelia 如何以代码生成方式维护高质量的社区反馈渠道。一、命令概览与作用authelia-gen github issue-templates属于authelia-gen的github命令族其职责在命令的 Short 描述中写得很明确Generate GitHub issue templates即生成 GitHub Issue 模板。它不是一个直接输出到终端文本的命令而是把预置的 Go 文本模板渲染为仓库根目录下.github/ISSUE_TEMPLATE/中的 YAML 表单文件供 GitHub 仓库的 Issue 创建流程使用。从源码结构看该命令的完整层级为authelia-gen └── github # Generate GitHub files └── issue-templates # Generate GitHub issue templates本文主题 ├── bug-report # Generate GitHub bug report issue template └── feature-request # Generate GitHub feature request issue template这一层级关系在 cmd_github.go 中通过三次cmd.AddCommand调用构建newGitHubCmd()注册github命令newGitHubIssueTemplatesCmd()注册issue-templates后者再挂载bug-report与feature-request两个叶子子命令同时仓库测试 cmd_root_test.go 断言github命令的子命令列表正是[issue-templates]验证了该命令结构。二、命令用法authelia-gen github issue-templates [flags]与许多只承担命令分组职责的中间命令一样issue-templates自身的选项只有一个帮助选项真正的功能逻辑在它的两个子命令中但所有可用的全局/父级选项同样对本命令生效。命令自身选项选项说明-h, --help显示issue-templates命令的帮助信息子命令子命令功能authelia-gen github issue-templates bug-report生成 GitHub bug report issue 模板默认输出 .github/ISSUE_TEMPLATE/bug-report.ymlauthelia-gen github issue-templates feature-request生成 GitHub feature request issue 模板默认输出 .github/ISSUE_TEMPLATE/feature-request.yml三、从父命令继承的选项作为authelia-gen的子命令issue-templates会自动继承根命令newRootCmd()中注册的全部持久化选项persistent flags这些选项在文档中一一列出。它们按用途可分为四组1. 仓库与目录定位选项默认值说明-C, --cwd string空为 git 命令设置工作目录CWD影响版本标签的获取-d, --dir.root string./仓库根目录--dir.authentication stringinternal/authenticationauthentication 目录相对仓库根--dir.schema stringinternal/configuration/schemaschema 目录相对仓库根--dir.web stringwebweb 目录相对仓库根--dir.locales stringinternal/server/localeslocales 目录相对仓库根2. 文档docs相关目录选项默认值说明--dir.docs stringdocsdocs 目录--dir.docs.adr stringreference/architecture-decision-logADR 数据目录--dir.docs.cli-reference stringreference/cliCLI 参考 markdown 存放目录--dir.docs.content stringcontentdocs 内容目录--dir.docs.data stringdatadocs 数据目录--dir.docs.static stringstaticdocs 静态文件目录--dir.docs.static.json-schemas stringschemasdocs 静态 JSONSchema 文件目录3. 文件路径选项默认值说明--file.bug-report string.github/ISSUE_TEMPLATE/bug-report.ymlbug report issue 模板文件路径--file.feature-request string.github/ISSUE_TEMPLATE/feature-request.ymlfeature request issue 模板文件路径--file.commit-lint-config stringcommitlint.config.mjscommit lint JavaScript 配置文件相对仓库根--file.configuration-keys stringinternal/configuration/schema/keys.go配置键文件路径--file.docs-commit-msg-guidelines stringdocs/content/contributing/guidelines/commit-message.md提交信息规范文档相对仓库根--file.docs.data.keys stringconfigkeys.jsondocs 键数据文件路径--file.docs.data.languages stringlanguages.jsondocs 语言数据文件相对 docs data 目录--file.docs.data.misc stringmisc.jsondocs misc 数据文件相对 docs data 目录--file.docs.static.json-schemas.configuration stringconfiguration配置 JSONSchema 文件路径--file.docs.static.json-schemas.exports.identifiers stringexports.identifiersidentifiers 导出 JSONSchema 路径--file.docs.static.json-schemas.exports.totp stringexports.totpTOTP 导出 JSONSchema 路径--file.docs.static.json-schemas.exports.webauthn stringexports.webauthnWebAuthn 导出 JSONSchema 路径--file.docs.static.json-schemas.user-database stringuser-database用户数据库 JSONSchema 路径--file.scripts.gen stringcmd/authelia-scripts/cmd/gen.goauthelia-scripts gen 文件路径--file.server.generated stringinternal/server/gen.goserver 生成文件路径--file.web.i18n stringsrc/i18n/index.tsweb 目录下 i18n TypeScript 配置文件--file.web.package stringpackage.jsonweb 目录下 node 包配置文件4. 生成行为开关与元数据选项默认值说明-X, --exclude strings空设置被排除的生成器名称--latestfalse启用 latest 功能影响 JSON Schema 等生成器--nextfalse启用 next 功能影响 JSON Schema 等生成器--package.configuration.keys stringschema键文件的包名--package.scripts.gen stringcmdauthelia-scripts gen 文件的包名--version-count int5输出模板中列出的最大 minor 版本数量--versions strings空指定生成器运行的版本特殊值current与next互斥说明上表中的目录类默认值均为相对值实际拼接根目录后构成完整路径。其中与 Issue 模板生成直接相关的核心选项是--file.bug-report、--file.feature-request、--version-count、-C/--cwd与-d/--dir.root其余选项多被authelia-gen的其他生成器如 docs、JSON Schema、i18n复用属于全局共享的持久化参数。四、源码级实现原理1. 命令注册与执行入口两个子命令的执行函数分别是cmdGitHubIssueTemplatesFeatureRunE与cmdGitHubIssueTemplatesBugReportRunE均位于 cmd_github.go。二者的整体流程一致读取--cwd、--dir.root、对应--file.*路径与--version-count等标志调用getGitTags(cwd)执行git tag --sort-creatordate获取按创建时间倒序排列的版本标签用model.NewSemanticVersion解析标签构造语义版本对象组装模板数据tmplIssueTemplateData执行 Gotext/template渲染并把结果写入目标文件。模板文件通过//go:embed templates/*打包进二进制相关注册见 templates.gotmplGitHubIssueTemplateBug template.Must(newTMPL(github_issue_template_bug_report.yml)) tmplIssueTemplateFeature template.Must(newTMPL(github_issue_template_feature.yml))2. 模板数据结构渲染所需数据由 types.go 中的结构体承载type tmplIssueTemplateData struct { Labels []string Versions []string Proxies []string }Labels注入 Issue 模板 front matter 中的标签列表Versions注入版本下拉框的候选版本列表Proxies注入反向代理下拉框的候选代理列表仅 bug-report 模板使用。3. 版本列表的两种计算策略这是整个命令最有意思的部分同一个--version-count标志在两个子命令中含义截然不同。feature-request 生成的是未来版本cmd_github.go以最新 git tag 的Major.Minor为基准依次生成Minor1、Minor2……共versions个未来版本号。例如最新稳定版为v4.39.x且--version-count5时会生成v4.40、v4.41、v4.42、v4.43、v4.44。这样做的意图是提交功能请求的人可以声明该功能期望进入哪个未来版本。bug-report 生成的是最近支持版本cmd_github.go先以最新版本为基准令Patch0、Minor - versions得到一个最低版本阈值minimum随后遍历所有 git tag跳过非稳定版本version.IsStable()为假则忽略只保留version.GreaterThanOrEqual(minimum)的稳定版本并按创建时间倒序填入下拉框。因此--version-count5意味着列出最近 5 个 minor 版本线内的全部稳定补丁版本。这一点在仓库产物中得到验证当前 .github/ISSUE_TEMPLATE/bug-report.yml 中版本选项覆盖了v4.39.24至v4.34.x的数十个稳定版本数量远大于 5因为同一 minor 线内的所有 patch 版本都被保留。4. 标签Labels的注入机制两个模板的 labels 由代码直接拼装cmd_github.go 与 cmd_github.gobug-reporttype/bug/unconfirmedstatus/needs-triagepriority/4/normalfeature-requesttype/featurestatus/needs-designpriority/4/normal这些标签并非硬编码字符串而是通过 types.go 中的枚举类型labelPriority、labelStatus、labelType及其String()方法格式化生成。格式化规则labelFormatString会把: 替换为/、空格替换为-并转小写例如Bug: Unconfirmed→type/bug/unconfirmed、Needs Triage→status/needs-triage、priority 序号 4 Normal→priority/4/normal。这意味着只要调整枚举定义并重新运行生成器所有模板的标签即可一次性同步更新这正是用代码生成维护 Issue 模板的核心价值。相关枚举的完整性由 types_test.go 覆盖。5. 模板渲染细节bug-report 模板github_issue_template_bug_report.yml.tmpl产出一个包含 14 个表单块的完整 YAML开头的 markdown 引导说明、Version / Deployment Method / Reverse Proxy 三个下拉框、Reverse Proxy Version 输入框、Description / Reproduction / Expectations / Configuration / Build Information / Logs 等文本域以及 Generative AI 下拉框和 8 项 Pre-Submission Checklist 复选框。feature-request 模板github_issue_template_feature.yml.tmpl结构更轻量markdown 引导、Description / Use Case / Details / Documentation 四个文本域、Generative AI 下拉框与 2 项 checklist 复选框。反向代理候选列表在代码中以硬编码数组提供cmd_github.goCaddy、Traefik、Envoy、Istio、NGINX、SWAG、NGINX Proxy Manager、HAProxy——这与 Authelia 作为 Web 应用前置 SSO 门户、常部署于各类反向代理之后的典型场景相匹配。两个模板的 checklist 都要求提交者确认遵循 Code of Conduct、已查阅相关 issue 与文档其中 bug-report 额外要求提交者确认已阅读安全策略、提供完整配置文件或说明与配置无关、提供完整 debug/trace 日志或build-info输出等从流程上强制保证 Issue 信息质量。五、实际生成产物运行该命令后仓库根目录下会生成或覆盖以下文件生成文件对应子命令说明.github/ISSUE_TEMPLATE/bug-report.ymlauthelia-gen github issue-templates bug-reportBug 报告表单.github/ISSUE_TEMPLATE/feature-request.ymlauthelia-gen github issue-templates feature-request功能请求表单.github/ISSUE_TEMPLATE/config.yml静态文件Issue 流程辅助配置如链接到讨论区例如执行authelia-gen github issue-templates bug-report --version-count 5即以最近 5 个 minor 版本线内的全部稳定标签生成新版 bug 报告模板产物 front matter 形如name: Bug Report description: Report a bug labels: - type/bug/unconfirmed - status/needs-triage - priority/4/normal由于渲染结果直接覆盖.github/ISSUE_TEMPLATE/下的文件该命令适合在每次发布新版本后由维护流程自动执行从而让版本下拉框始终与仓库真实 git tag 保持同步避免人工编辑 YAML 带来的遗漏与格式错误。六、相关命令authelia-gen github —github父命令Generate GitHub filesauthelia-gen github issue-templates bug-report — 生成 GitHub bug report issue 模板authelia-gen github issue-templates feature-request — 生成 GitHub feature request issue 模板七、小结authelia-gen github issue-templates展示了 Authelia 工程化维护社区流程的一贯思路把模板、标签、版本清单全部沉淀为代码与模板文件用git tag作为版本事实来源用text/template渲染统一格式的 YAML 表单。理解它的参数体系与实现路径不仅能在本地复现.github/ISSUE_TEMPLATE的生成过程也能为自建项目的 Issue 模板自动化提供可借鉴的范本——核心入口在 cmd_github.go模板定义在 templates 目录生成结果可在 .github/ISSUE_TEMPLATE 中直接查看。【免费下载链接】autheliaThe Single Sign-On Multi-Factor portal for web apps. OpenID Certified™ and Post-Quantum Cryptography Ready.项目地址: https://gitcode.com/GitHub_Trending/au/authelia创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表