feat: add git always namespace option

This commit is contained in:
Nicolas Giard 2025-02-02 16:16:52 -05:00
parent abc8dce9cc
commit 403e98dced
No known key found for this signature in database
GPG Key ID: B755FB6870B30F63
2 changed files with 13 additions and 7 deletions

View File

@ -87,6 +87,12 @@ props:
default: './data/repo'
hint: 'Path where the local git repository will be created.'
order: 30
alwaysNamespace:
type: Boolean
title: Always Locale Namespace
default: false
hint: 'Whether to put content from the primary language into a subfolder.'
order: 40
gitBinaryPath:
type: String
title: Git Binary Path

View File

@ -298,7 +298,7 @@ module.exports = {
async created(page) {
WIKI.logger.info(`(STORAGE/GIT) Committing new file [${page.localeCode}] ${page.path}...`)
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
if (this.config.alwaysNamespace || (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode)) {
fileName = `${page.localeCode}/${fileName}`
}
const filePath = path.join(this.repoPath, fileName)
@ -320,7 +320,7 @@ module.exports = {
async updated(page) {
WIKI.logger.info(`(STORAGE/GIT) Committing updated file [${page.localeCode}] ${page.path}...`)
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
if (this.config.alwaysNamespace || (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode)) {
fileName = `${page.localeCode}/${fileName}`
}
const filePath = path.join(this.repoPath, fileName)
@ -342,7 +342,7 @@ module.exports = {
async deleted(page) {
WIKI.logger.info(`(STORAGE/GIT) Committing removed file [${page.localeCode}] ${page.path}...`)
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
if (this.config.alwaysNamespace || (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode)) {
fileName = `${page.localeCode}/${fileName}`
}
@ -364,11 +364,11 @@ module.exports = {
let sourceFileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
let destinationFileName = `${page.destinationPath}.${pageHelper.getFileExtension(page.contentType)}`
if (WIKI.config.lang.namespacing) {
if (WIKI.config.lang.code !== page.localeCode) {
if (this.config.alwaysNamespace || WIKI.config.lang.namespacing) {
if (this.config.alwaysNamespace || WIKI.config.lang.code !== page.localeCode) {
sourceFileName = `${page.localeCode}/${sourceFileName}`
}
if (WIKI.config.lang.code !== page.destinationLocaleCode) {
if (this.config.alwaysNamespace || WIKI.config.lang.code !== page.destinationLocaleCode) {
destinationFileName = `${page.destinationLocaleCode}/${destinationFileName}`
}
}
@ -483,7 +483,7 @@ module.exports = {
page.tags = await pageObject.$relatedQuery('tags')
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
if (this.config.alwaysNamespace || (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode)) {
fileName = `${page.localeCode}/${fileName}`
}
WIKI.logger.info(`(STORAGE/GIT) Adding page ${fileName}...`)