diff --git a/.schemas/craft.schema.json b/.schemas/craft.schema.json index 6076227a..68c4e932 100644 --- a/.schemas/craft.schema.json +++ b/.schemas/craft.schema.json @@ -6,28 +6,6 @@ "type": "object", "additionalProperties": false, "$defs": { - "maintainer": { - "description": "Maintainer definition", - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "description": "Maintainer name (can be any entity, person name, group name, etc.).", - "type": "string" - }, - "email": { - "description": "Maintainer email.", - "type": "string" - }, - "url": { - "description": "Maintainer URL.", - "type": "string" - } - }, - "required": [ - "name" - ] - }, "ci": { "description": "CI definition to help generate specific files.", "type": "object", @@ -90,6 +68,10 @@ "description": "Static deployment configuration.", "type": "object", "properties": { + "auto": { + "description": "Whether to automatically deploy static builds or not on main branches for github and on protected branches for gitlab.", + "type": "boolean" + }, "name": { "description": "Static deployment name.", "type": "string", @@ -97,10 +79,6 @@ "netlify", "pages" ] - }, - "auto": { - "description": "Whether to automatically deploy static builds or not on main branches for github and on protected branches for gitlab.", - "type": "boolean" } } } @@ -114,30 +92,42 @@ "type": "object", "additionalProperties": false, "properties": { - "registry": { - "description": "Docker registry associated to project. It will be used for CI docker build & push alongside chart image pull.", - "type": "string", - "default": "ghcr.io" - }, "port": { "description": "Container port to override the default one, 3000.", "type": "integer", "default": 3000 + }, + "registry": { + "description": "Docker registry associated to project. It will be used for CI docker build & push alongside chart image pull.", + "type": "string", + "default": "ghcr.io" } } + }, + "maintainer": { + "description": "Maintainer definition", + "type": "object", + "additionalProperties": false, + "properties": { + "email": { + "description": "Maintainer email.", + "type": "string" + }, + "name": { + "description": "Maintainer name (can be any entity, person name, group name, etc.).", + "type": "string" + }, + "url": { + "description": "Maintainer URL.", + "type": "string" + } + }, + "required": [ + "name" + ] } }, "properties": { - "description": { - "description": "Description, only useful when working with docker option and helm generations.", - "type": "string" - }, - "maintainers": { - "description": "List of maintainers.", - "type": "array", - "$ref": "#/$defs/maintainer", - "minItems": 1 - }, "bot": { "description": "Bot in charge of keeping dependencies up to date.", "type": "string", @@ -146,6 +136,20 @@ "renovate" ] }, + "ci": { + "description": "CI definition to help generate specific files.", + "type": "object", + "$ref": "#/$defs/ci" + }, + "description": { + "description": "Description, only useful when working with docker option and helm generations.", + "type": "string" + }, + "docker": { + "description": "Docker definition.", + "type": "object", + "$ref": "#/$defs/docker" + }, "license": { "description": "License name.", "type": "string", @@ -166,19 +170,11 @@ "unlicense" ] }, - "ci": { - "description": "CI definition to help generate specific files.", - "type": "object", - "$ref": "#/$defs/ci" - }, - "platform": { - "description": "Platform for README.md badges (automatically parsed with git origin URL by default).", - "type": "string" - }, - "docker": { - "description": "Docker definition.", - "type": "object", - "$ref": "#/$defs/docker" + "maintainers": { + "description": "List of maintainers.", + "type": "array", + "$ref": "#/$defs/maintainer", + "minItems": 1 }, "no_chart": { "description": "Disable and remove chart generation.", @@ -194,6 +190,15 @@ "description": "Disable and remove makefile generation.", "type": "boolean", "default": false + }, + "no_readme": { + "description": "Disable and remove README.md generation.", + "type": "boolean", + "default": false + }, + "platform": { + "description": "Platform for README.md badges (automatically parsed with git origin URL by default).", + "type": "string" } }, "required": [ diff --git a/README.md b/README.md index dfe086ec..261bc540 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,9 @@ no_goreleaser: true | false # this option is automatically disabled when working with nodejs generation no_makefile: true | false +# whether to generate a README.md with initial badges and informations (optional) +no_readme: true | false + # platform override in case of gitlab on premise, bitbucket on premise, etc. # by default, an on premise gitlab will be matched if the host contains "gitlab" # by default, an on premise bitbucket will be matched if the host contains "bitbucket" or "stash" diff --git a/pkg/craft/configuration.go b/pkg/craft/configuration.go index a8501983..30f64fb3 100644 --- a/pkg/craft/configuration.go +++ b/pkg/craft/configuration.go @@ -13,6 +13,7 @@ type Configuration struct { NoChart bool `json:"-" yaml:"no_chart,omitempty"` NoGoreleaser bool `json:"-" yaml:"no_goreleaser,omitempty"` NoMakefile bool `json:"-" yaml:"no_makefile,omitempty"` + NoReadme bool `json:"-" yaml:"no_readme,omitempty"` Platform string `json:"-" yaml:"platform,omitempty" validate:"omitempty,oneof=bitbucket gitea github gitlab"` } diff --git a/pkg/generate/filehandler.go b/pkg/generate/filehandler.go index d8b2a708..eeab5f71 100644 --- a/pkg/generate/filehandler.go +++ b/pkg/generate/filehandler.go @@ -30,6 +30,7 @@ func MetaHandlers() []MetaHandler { Gitlab, Goreleaser, Makefile, + Readme, Releaserc, Renovate, Sonar, @@ -140,13 +141,13 @@ func githubWorkflows(metadata Metadata) FileHandler { //nolint:cyclop } } -var _actionRegexp = regexp.MustCompile(`\.github/actions/[\w]+/action\.yml\.tmpl$`) +var githubActionFileRegexp = regexp.MustCompile(`\.github/actions/[\w]+/action\.yml\.tmpl$`) // githubActions returns the handler for all files related to .github/actions directory. func githubActions(metadata Metadata) FileHandler { return func(src, _, _ string) (_ bool, _ bool) { // files related to dir .github/actions - if !_actionRegexp.MatchString(src) { + if !githubActionFileRegexp.MatchString(src) { return false, false } @@ -198,6 +199,16 @@ func Makefile(metadata Metadata) FileHandler { } } +// Readme returns the handler for README.md option generation matching. +func Readme(metadata Metadata) FileHandler { + return func(src, dest, name string) (ok bool, apply bool) { + if name != "README.md" { + return false, false + } + return true, !metadata.NoReadme + } +} + // Releaserc returns the handler for releaserc option generation matching. func Releaserc(metadata Metadata) FileHandler { return func(_, _, name string) (_ bool, _ bool) {