docs: add version to the docs data misc generator (#4827)
parent
b42a84340d
commit
a1517f18e5
|
@ -110,7 +110,7 @@ func commitLintRunE(cmd *cobra.Command, args []string) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
if pathCommitLintConfig, err = cmd.Flags().GetString(cmdFlagFileConfigCommitLint); err != nil {
|
||||
if pathCommitLintConfig, err = getPFlagPath(cmd.Flags(), cmdFlagRoot, cmdFlagWeb, cmdFlagFileConfigCommitLint); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,26 @@ func docsDataMiscRunE(cmd *cobra.Command, args []string) (err error) {
|
|||
data.CSP.TemplateDefault = strings.ReplaceAll(data.CSP.TemplateDefault, "%s", codeCSPNonce)
|
||||
data.CSP.TemplateDevelopment = strings.ReplaceAll(data.CSP.TemplateDevelopment, "%s", codeCSPNonce)
|
||||
|
||||
var (
|
||||
pathPackageJSON string
|
||||
dataPackageJSON []byte
|
||||
packageJSON PackageJSON
|
||||
)
|
||||
|
||||
if pathPackageJSON, err = getPFlagPath(cmd.Flags(), cmdFlagRoot, cmdFlagWeb, cmdFlagFileWebPackage); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if dataPackageJSON, err = os.ReadFile(pathPackageJSON); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = json.Unmarshal(dataPackageJSON, &packageJSON); err != nil {
|
||||
return fmt.Errorf("failed to unmarshall package.json: %w", err)
|
||||
}
|
||||
|
||||
data.Latest = packageJSON.Version
|
||||
|
||||
var (
|
||||
outputPath string
|
||||
dataJSON []byte
|
||||
|
|
|
@ -42,7 +42,7 @@ func localesRunE(cmd *cobra.Command, args []string) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
if pathWebI18NIndex, err = cmd.Flags().GetString(cmdFlagFileWebI18N); err != nil {
|
||||
if pathWebI18NIndex, err = getPFlagPath(cmd.Flags(), cmdFlagRoot, cmdFlagWeb, cmdFlagFileWebI18N); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -26,12 +26,14 @@ func newRootCmd() *cobra.Command {
|
|||
|
||||
cmd.PersistentFlags().StringP(cmdFlagCwd, "C", "", "Sets the CWD for git commands")
|
||||
cmd.PersistentFlags().StringP(cmdFlagRoot, "d", dirCurrent, "The repository root")
|
||||
cmd.PersistentFlags().String(cmdFlagWeb, dirWeb, "The repository web directory in relation to the root directory")
|
||||
cmd.PersistentFlags().StringSliceP(cmdFlagExclude, "X", nil, "Sets the names of excluded generators")
|
||||
cmd.PersistentFlags().String(cmdFlagFeatureRequest, fileGitHubIssueTemplateFR, "Sets the path of the feature request issue template file")
|
||||
cmd.PersistentFlags().String(cmdFlagBugReport, fileGitHubIssueTemplateBR, "Sets the path of the bug report issue template file")
|
||||
cmd.PersistentFlags().Int(cmdFlagVersions, 5, "the maximum number of minor versions to list in output templates")
|
||||
cmd.PersistentFlags().String(cmdFlagDirLocales, dirLocales, "The locales directory in relation to the root")
|
||||
cmd.PersistentFlags().String(cmdFlagFileWebI18N, fileWebI18NIndex, "The i18n typescript configuration file in relation to the root")
|
||||
cmd.PersistentFlags().String(cmdFlagFileWebI18N, fileWebI18NIndex, "The i18n typescript configuration file in relation to the web directory")
|
||||
cmd.PersistentFlags().String(cmdFlagFileWebPackage, fileWebPackage, "The node package configuration file in relation to the web directory")
|
||||
cmd.PersistentFlags().String(cmdFlagDocsDataLanguages, fileDocsDataLanguages, "The languages docs data file in relation to the docs data folder")
|
||||
cmd.PersistentFlags().String(cmdFlagDocsDataMisc, fileDocsDataMisc, "The misc docs data file in relation to the docs data folder")
|
||||
cmd.PersistentFlags().String(cmdFlagDocsCLIReference, dirDocsCLIReference, "The directory to store the markdown in")
|
||||
|
|
|
@ -3,12 +3,14 @@ package main
|
|||
const (
|
||||
dirCurrent = "./"
|
||||
dirLocales = "internal/server/locales"
|
||||
dirWeb = "web"
|
||||
|
||||
subPathCmd = "cmd"
|
||||
subPathInternal = "internal"
|
||||
|
||||
fileCICommitLintConfig = "web/.commitlintrc.js"
|
||||
fileWebI18NIndex = "web/src/i18n/index.ts"
|
||||
fileCICommitLintConfig = ".commitlintrc.js"
|
||||
fileWebI18NIndex = "src/i18n/index.ts"
|
||||
fileWebPackage = "package.json"
|
||||
|
||||
fileDocsCommitMessageGuidelines = "docs/content/en/contributing/guidelines/commit-message.md"
|
||||
|
||||
|
@ -68,27 +70,30 @@ const (
|
|||
|
||||
const (
|
||||
cmdFlagRoot = "dir.root"
|
||||
cmdFlagExclude = "exclude"
|
||||
cmdFlagVersions = "versions"
|
||||
cmdFlagWeb = "dir.web"
|
||||
cmdFlagFileWebI18N = "file.web.i18n"
|
||||
cmdFlagFileWebPackage = "file.web.package"
|
||||
cmdFlagDocs = "dir.docs"
|
||||
cmdFlagDirLocales = "dir.locales"
|
||||
cmdFlagDocsCLIReference = "dir.docs.cli-reference"
|
||||
cmdFlagDocsContent = "dir.docs.content"
|
||||
cmdFlagDocsData = "dir.docs.data"
|
||||
cmdFlagDocs = "dir.docs"
|
||||
cmdFlagDocsDataLanguages = "file.docs.data.languages"
|
||||
cmdFlagDocsDataMisc = "file.docs.data.misc"
|
||||
cmdFlagDocsDataKeys = "file.docs.data.keys"
|
||||
cmdFlagCwd = "cwd"
|
||||
cmdFlagDocsDataLanguages = "file.docs.data.languages"
|
||||
cmdFlagFileConfigKeys = "file.configuration-keys"
|
||||
cmdFlagFileScriptsGen = "file.scripts.gen"
|
||||
cmdFlagFileServerGenerated = "file.server.generated"
|
||||
cmdFlagFileConfigCommitLint = "file.commit-lint-config"
|
||||
cmdFlagFileDocsCommitMsgGuidelines = "file.docs-commit-msg-guidelines"
|
||||
cmdFlagFileWebI18N = "file.web-i18n"
|
||||
cmdFlagFeatureRequest = "file.feature-request"
|
||||
cmdFlagBugReport = "file.bug-report"
|
||||
cmdFlagPackageConfigKeys = "package.configuration.keys"
|
||||
cmdFlagPackageScriptsGen = "package.scripts.gen"
|
||||
|
||||
cmdFlagExclude = "exclude"
|
||||
cmdFlagVersions = "versions"
|
||||
cmdFlagCwd = "cwd"
|
||||
cmdFlagPackageConfigKeys = "package.configuration.keys"
|
||||
cmdFlagPackageScriptsGen = "package.scripts.gen"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -32,7 +32,8 @@ type GitHubTagsJSON struct {
|
|||
|
||||
// DocsDataMisc represents the docs misc data schema.
|
||||
type DocsDataMisc struct {
|
||||
CSP TemplateCSP `json:"csp"`
|
||||
CSP TemplateCSP `json:"csp"`
|
||||
Latest string `json:"latest"`
|
||||
}
|
||||
|
||||
// TemplateCSP represents the CSP template vars.
|
||||
|
@ -139,7 +140,13 @@ func (t labelType) String() string {
|
|||
return fmt.Sprintf("%s/%s", labelAreaPrefixType, labelTypeDescriptions[t])
|
||||
}
|
||||
|
||||
// CSPValue represents individual CSP values.
|
||||
type CSPValue struct {
|
||||
Name string
|
||||
Value string
|
||||
}
|
||||
|
||||
// PackageJSON represents a NPM package.json file.
|
||||
type PackageJSON struct {
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"csp":{"default":"default-src 'self'; frame-src 'none'; object-src 'none'; style-src 'self' 'nonce-${NONCE}'; frame-ancestors 'none'; base-uri 'self'","development":"default-src 'self' 'unsafe-eval'; frame-src 'none'; object-src 'none'; style-src 'self' 'nonce-${NONCE}'; frame-ancestors 'none'; base-uri 'self'","nonce":"${NONCE}"}}
|
||||
{"csp":{"default":"default-src 'self'; frame-src 'none'; object-src 'none'; style-src 'self' 'nonce-${NONCE}'; frame-ancestors 'none'; base-uri 'self'","development":"default-src 'self' 'unsafe-eval'; frame-src 'none'; object-src 'none'; style-src 'self' 'nonce-${NONCE}'; frame-ancestors 'none'; base-uri 'self'","nonce":"${NONCE}"},"latest":"4.37.5"}
|
|
@ -7,7 +7,7 @@
|
|||
<div class="col-lg-9 col-xl-8 text-center">
|
||||
<p class="lead">{{ .Params.lead | safeHTML }}</p>
|
||||
<a class="btn btn-primary btn-lg px-4 mb-2" href="/integration/prologue/get-started/" role="button">Get Started</a>
|
||||
<p class="meta">Open-source Apache 2.0 Licensed. <a href="https://github.com/authelia/authelia">GitHub v{{ $data := getJSON "https://raw.githubusercontent.com/authelia/authelia/master/web/package.json" }}{{ $data.version }}</a></p>
|
||||
<p class="meta">Open-source Apache 2.0 Licensed. <a href="https://github.com/authelia/authelia">GitHub v{{ $.Site.Data.misc.latest }}</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
|
Loading…
Reference in New Issue