feat(manifest): element name, version prefix, platform/language dropdowns #572
@@ -429,7 +429,7 @@ func prepareMigrationTasks() []*migration {
|
||||
newMigration(349, "Add security scanning tables", v1_27.AddSecurityScanningTables),
|
||||
newMigration(350, "Add issue type definitions table", v1_27.AddIssueTypeDefTable),
|
||||
newMigration(351, "Add CDN public flag to attachments", v1_27.AddAttachmentCDNPublic),
|
||||
newMigration(352, "Add version prefix to repo manifest", v1_27.AddManifestVersionPrefix),
|
||||
newMigration(352, "Add version prefix and element name to repo manifest", v1_27.AddManifestVersionPrefixAndElement),
|
||||
}
|
||||
return preparedMigrations
|
||||
}
|
||||
|
||||
@@ -5,10 +5,11 @@ package v1_27
|
||||
|
||||
import "xorm.io/xorm"
|
||||
|
||||
// AddManifestVersionPrefix adds the version_prefix column to the repo_manifest table.
|
||||
func AddManifestVersionPrefix(x *xorm.Engine) error {
|
||||
// AddManifestVersionPrefixAndElement adds version_prefix and element_name columns to repo_manifest.
|
||||
func AddManifestVersionPrefixAndElement(x *xorm.Engine) error {
|
||||
type RepoManifest struct {
|
||||
VersionPrefix string `xorm:"TEXT 'version_prefix'"`
|
||||
ElementName string `xorm:"TEXT 'element_name'"`
|
||||
}
|
||||
return x.Sync(new(RepoManifest))
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ type RepoManifest struct {
|
||||
StandardsSource string `xorm:"TEXT 'standards_source'"` // URL to standards repo
|
||||
|
||||
// versioning
|
||||
VersionPrefix string `xorm:"TEXT 'version_prefix'"` // tag prefix stripped for version display, e.g. "v1.26.1-moko."
|
||||
VersionPrefix string `xorm:"TEXT 'version_prefix'"` // tag prefix stripped for version display, e.g. "v1.26.1-moko."
|
||||
ElementName string `xorm:"TEXT 'element_name'"` // full element name override, e.g. "pkg_mokowaas" (auto-constructed if empty)
|
||||
|
||||
// build section
|
||||
Language string `xorm:"VARCHAR(50) 'language'"` // Go, PHP, TypeScript, etc.
|
||||
@@ -50,6 +51,45 @@ func (RepoManifest) TableName() string {
|
||||
return "repo_manifest"
|
||||
}
|
||||
|
||||
// joomlaTypePrefix maps Joomla extension types to their element name prefixes.
|
||||
var joomlaTypePrefix = map[string]string{
|
||||
"component": "com_",
|
||||
"module": "mod_",
|
||||
"plugin": "plg_",
|
||||
"package": "pkg_",
|
||||
"template": "tpl_",
|
||||
"library": "lib_",
|
||||
"file": "file_",
|
||||
}
|
||||
|
||||
// AutoElementName returns the auto-constructed Joomla element name (e.g. pkg_mokowaas).
|
||||
func (m *RepoManifest) AutoElementName() string {
|
||||
if m.Name == "" || m.PackageType == "" {
|
||||
return ""
|
||||
}
|
||||
if prefix, ok := joomlaTypePrefix[m.PackageType]; ok {
|
||||
return prefix + m.Name
|
||||
}
|
||||
return m.Name
|
||||
}
|
||||
|
||||
// FullElementName returns the effective element name: override if set, otherwise auto-constructed.
|
||||
func (m *RepoManifest) FullElementName() string {
|
||||
if m.ElementName != "" {
|
||||
return m.ElementName
|
||||
}
|
||||
return m.AutoElementName()
|
||||
}
|
||||
|
||||
// ElementNameMismatch returns true if an override is set that differs from the auto-constructed name.
|
||||
func (m *RepoManifest) ElementNameMismatch() bool {
|
||||
if m.ElementName == "" {
|
||||
return false
|
||||
}
|
||||
auto := m.AutoElementName()
|
||||
return auto != "" && m.ElementName != auto
|
||||
}
|
||||
|
||||
// GetRepoManifest returns the manifest for a repo, or nil if none exists.
|
||||
func GetRepoManifest(ctx context.Context, repoID int64) (*RepoManifest, error) {
|
||||
m := new(RepoManifest)
|
||||
|
||||
@@ -2737,6 +2737,12 @@
|
||||
"repo.settings.manifest_desc": "Project identity, governance, and build settings from the MokoPlatform manifest. These are accessible via API for Actions workflows and the MokoPlatform CLI.",
|
||||
"repo.settings.manifest_identity": "Identity",
|
||||
"repo.settings.manifest_name": "Project Name",
|
||||
"repo.settings.manifest_element_name": "Element Name",
|
||||
"repo.settings.manifest_element_name_help": "Base name used to construct the Joomla element identifier (e.g. 'mokowaas'). Combined with the extension type to produce the full element name.",
|
||||
"repo.settings.manifest_element_full": "Full Element Name",
|
||||
"repo.settings.manifest_element_full_help": "Auto-constructed from type + name. Leave blank to use the default, or override for non-standard naming.",
|
||||
"repo.settings.manifest_element_mismatch": "Warning: this overrides the auto-constructed name '%s'. Make sure this matches your Joomla extension's element identifier.",
|
||||
"repo.settings.manifest_package_type_help": "Maps to the Joomla extension type and determines the element prefix (com_, mod_, plg_, pkg_, tpl_, lib_, file_).",
|
||||
"repo.settings.manifest_org": "Organization",
|
||||
"repo.settings.manifest_description": "Description",
|
||||
"repo.settings.manifest_version": "Version",
|
||||
|
||||
@@ -20,6 +20,7 @@ type apiManifest struct {
|
||||
LicenseSPDX string `json:"license_spdx"`
|
||||
LicenseName string `json:"license_name"`
|
||||
VersionPrefix string `json:"version_prefix"`
|
||||
ElementName string `json:"element_name"`
|
||||
Platform string `json:"platform"`
|
||||
StandardsVersion string `json:"standards_version"`
|
||||
StandardsSource string `json:"standards_source"`
|
||||
@@ -62,6 +63,7 @@ func GetRepoManifest(ctx *context.APIContext) {
|
||||
LicenseSPDX: m.LicenseSPDX,
|
||||
LicenseName: m.LicenseName,
|
||||
VersionPrefix: m.VersionPrefix,
|
||||
ElementName: m.FullElementName(),
|
||||
Platform: m.Platform,
|
||||
StandardsVersion: m.StandardsVersion,
|
||||
StandardsSource: m.StandardsSource,
|
||||
@@ -98,6 +100,7 @@ func UpdateRepoManifest(ctx *context.APIContext) {
|
||||
LicenseSPDX: req.LicenseSPDX,
|
||||
LicenseName: req.LicenseName,
|
||||
VersionPrefix: req.VersionPrefix,
|
||||
ElementName: req.ElementName,
|
||||
Platform: req.Platform,
|
||||
StandardsVersion: req.StandardsVersion,
|
||||
StandardsSource: req.StandardsSource,
|
||||
@@ -119,6 +122,7 @@ func UpdateRepoManifest(ctx *context.APIContext) {
|
||||
LicenseSPDX: m.LicenseSPDX,
|
||||
LicenseName: m.LicenseName,
|
||||
VersionPrefix: m.VersionPrefix,
|
||||
ElementName: m.FullElementName(),
|
||||
Platform: m.Platform,
|
||||
StandardsVersion: m.StandardsVersion,
|
||||
StandardsSource: m.StandardsSource,
|
||||
|
||||
@@ -94,6 +94,7 @@ func ManifestSettingsPost(ctx *context.Context) {
|
||||
LicenseSPDX: ctx.FormString("license_spdx"),
|
||||
LicenseName: ctx.FormString("license_name"),
|
||||
VersionPrefix: ctx.FormString("version_prefix"),
|
||||
ElementName: ctx.FormString("element_name"),
|
||||
Platform: ctx.FormString("platform"),
|
||||
StandardsVersion: ctx.FormString("standards_version"),
|
||||
StandardsSource: ctx.FormString("standards_source"),
|
||||
|
||||
@@ -11,8 +11,14 @@
|
||||
<h5 class="ui dividing header">{{ctx.Locale.Tr "repo.settings.manifest_identity"}}</h5>
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<label>{{ctx.Locale.Tr "repo.settings.manifest_name"}}</label>
|
||||
<input name="name" value="{{.Manifest.Name}}" placeholder="Project name">
|
||||
{{if eq .Manifest.Platform "joomla"}}
|
||||
<label>{{ctx.Locale.Tr "repo.settings.manifest_element_name"}}</label>
|
||||
<input name="name" value="{{.Manifest.Name}}" placeholder="e.g. mokowaas">
|
||||
<p class="help">{{ctx.Locale.Tr "repo.settings.manifest_element_name_help"}}</p>
|
||||
{{else}}
|
||||
<label>{{ctx.Locale.Tr "repo.settings.manifest_name"}}</label>
|
||||
<input name="name" value="{{.Manifest.Name}}" placeholder="Project name">
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{ctx.Locale.Tr "repo.settings.manifest_org"}}</label>
|
||||
@@ -45,7 +51,7 @@
|
||||
<select name="platform" class="ui dropdown">
|
||||
<option value="">—</option>
|
||||
{{$platform := .Manifest.Platform}}
|
||||
{{range $val := StringUtils.Split "joomla,dolibarr,go,mcp,platform,generic" ","}}
|
||||
{{range $val := StringUtils.Split "joomla,wordpress,dolibarr,go,mcp,platform,generic" ","}}
|
||||
<option value="{{$val}}" {{if eq $val $platform}}selected{{end}}>{{$val}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
@@ -82,6 +88,17 @@
|
||||
<option value="{{$val}}" {{if eq $val $pkgType}}selected{{end}}>{{$val}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
<p class="help">{{ctx.Locale.Tr "repo.settings.manifest_package_type_help"}}</p>
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="field">
|
||||
<label>{{ctx.Locale.Tr "repo.settings.manifest_element_full"}}</label>
|
||||
<input name="element_name" value="{{.Manifest.ElementName}}" placeholder="{{.Manifest.AutoElementName}}">
|
||||
{{if .Manifest.ElementNameMismatch}}
|
||||
<p class="help tw-text-yellow-600">{{ctx.Locale.Tr "repo.settings.manifest_element_mismatch" .Manifest.AutoElementName}}</p>
|
||||
{{else}}
|
||||
<p class="help">{{ctx.Locale.Tr "repo.settings.manifest_element_full_help"}}</p>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="field">
|
||||
|
||||
Reference in New Issue
Block a user