Rename variables
This commit is contained in:
parent
45c126ce80
commit
d078baa6af
1 changed files with 54 additions and 42 deletions
|
@ -23,16 +23,19 @@ type Action = "CREATE" | "DELETE"
|
||||||
|
|
||||||
interface Context {
|
interface Context {
|
||||||
articleById: Record<string, JorfArticle | LegiArticle>
|
articleById: Record<string, JorfArticle | LegiArticle>
|
||||||
currentInternalIds: Set<string>
|
articleModificateurIdByActionById: Record<
|
||||||
infosArticleModificateurById: Record<
|
|
||||||
string,
|
string,
|
||||||
Record<Action, string | undefined>
|
Record<Action, string | undefined>
|
||||||
>
|
>
|
||||||
infosTexteModificateurById: Record<string, Record<Action, string | undefined>>
|
currentInternalIds: Set<string>
|
||||||
legiTexteInternalIds: Set<string>
|
legiTexteInternalIds: Set<string>
|
||||||
sectionTaById: Record<string, LegiSectionTa>
|
sectionTaById: Record<string, LegiSectionTa>
|
||||||
targetDir: string
|
targetDir: string
|
||||||
texteManquantById: Record<string, TexteManquant>
|
texteManquantById: Record<string, TexteManquant>
|
||||||
|
texteModificateurIdByActionById: Record<
|
||||||
|
string,
|
||||||
|
Record<Action, string | undefined>
|
||||||
|
>
|
||||||
texteVersionById: Record<string, JorfTexteVersion | LegiTexteVersion | null>
|
texteVersionById: Record<string, JorfTexteVersion | LegiTexteVersion | null>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,16 +81,16 @@ async function addArticleModificateurId(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let infosArticleModificateur =
|
let articleModificateurIdByAction =
|
||||||
context.infosArticleModificateurById[modifiedId]
|
context.articleModificateurIdByActionById[modifiedId]
|
||||||
if (infosArticleModificateur === undefined) {
|
if (articleModificateurIdByAction === undefined) {
|
||||||
infosArticleModificateur = context.infosArticleModificateurById[
|
articleModificateurIdByAction = context.articleModificateurIdByActionById[
|
||||||
modifiedId
|
modifiedId
|
||||||
] = { CREATE: undefined, DELETE: undefined }
|
] = { CREATE: undefined, DELETE: undefined }
|
||||||
}
|
}
|
||||||
const existingArticleModificateurId = infosArticleModificateur[action]
|
const existingArticleModificateurId = articleModificateurIdByAction[action]
|
||||||
if (existingArticleModificateurId === undefined) {
|
if (existingArticleModificateurId === undefined) {
|
||||||
infosArticleModificateur[action] = articleModificateurId
|
articleModificateurIdByAction[action] = articleModificateurId
|
||||||
} else if (existingArticleModificateurId !== articleModificateurId) {
|
} else if (existingArticleModificateurId !== articleModificateurId) {
|
||||||
const existingArticleModificateur = await getOrLoadArticle(
|
const existingArticleModificateur = await getOrLoadArticle(
|
||||||
context,
|
context,
|
||||||
|
@ -97,7 +100,7 @@ async function addArticleModificateurId(
|
||||||
existingArticleModificateur.CONTEXTE.TEXTE["@date_signature"]! <
|
existingArticleModificateur.CONTEXTE.TEXTE["@date_signature"]! <
|
||||||
articleModificateurDateSignature
|
articleModificateurDateSignature
|
||||||
) {
|
) {
|
||||||
infosArticleModificateur[action] = articleModificateurId
|
articleModificateurIdByAction[action] = articleModificateurId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,16 +155,19 @@ async function addTexteModificateurId(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let infosTexteModificateur = context.infosTexteModificateurById[modifiedId]
|
let texteModificateurIdByAction =
|
||||||
if (infosTexteModificateur === undefined) {
|
context.texteModificateurIdByActionById[modifiedId]
|
||||||
infosTexteModificateur = context.infosTexteModificateurById[modifiedId] = {
|
if (texteModificateurIdByAction === undefined) {
|
||||||
|
texteModificateurIdByAction = context.texteModificateurIdByActionById[
|
||||||
|
modifiedId
|
||||||
|
] = {
|
||||||
CREATE: undefined,
|
CREATE: undefined,
|
||||||
DELETE: undefined,
|
DELETE: undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const existingTexteModificateurId = infosTexteModificateur[action]
|
const existingTexteModificateurId = texteModificateurIdByAction[action]
|
||||||
if (existingTexteModificateurId === undefined) {
|
if (existingTexteModificateurId === undefined) {
|
||||||
infosTexteModificateur[action] = texteModificateurId
|
texteModificateurIdByAction[action] = texteModificateurId
|
||||||
} else if (existingTexteModificateurId !== texteModificateurId) {
|
} else if (existingTexteModificateurId !== texteModificateurId) {
|
||||||
const existingTexteVersionModificateur = (await getOrLoadTexteVersion(
|
const existingTexteVersionModificateur = (await getOrLoadTexteVersion(
|
||||||
context,
|
context,
|
||||||
|
@ -171,7 +177,7 @@ async function addTexteModificateurId(
|
||||||
existingTexteVersionModificateur.META.META_SPEC.META_TEXTE_CHRONICLE
|
existingTexteVersionModificateur.META.META_SPEC.META_TEXTE_CHRONICLE
|
||||||
.DATE_TEXTE! < texteModificateurDateSignature
|
.DATE_TEXTE! < texteModificateurDateSignature
|
||||||
) {
|
) {
|
||||||
infosTexteModificateur[action] = texteModificateurId
|
texteModificateurIdByAction[action] = texteModificateurId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,13 +188,13 @@ async function exportLegiTexteToMarkdown(
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const context: Context = {
|
const context: Context = {
|
||||||
articleById: {},
|
articleById: {},
|
||||||
|
articleModificateurIdByActionById: {},
|
||||||
currentInternalIds: new Set(),
|
currentInternalIds: new Set(),
|
||||||
infosArticleModificateurById: {},
|
|
||||||
infosTexteModificateurById: {},
|
|
||||||
legiTexteInternalIds: new Set(),
|
legiTexteInternalIds: new Set(),
|
||||||
sectionTaById: {},
|
sectionTaById: {},
|
||||||
targetDir,
|
targetDir,
|
||||||
texteManquantById: {},
|
texteManquantById: {},
|
||||||
|
texteModificateurIdByActionById: {},
|
||||||
texteVersionById: {},
|
texteVersionById: {},
|
||||||
}
|
}
|
||||||
context.legiTexteInternalIds.add(legiTexteId)
|
context.legiTexteInternalIds.add(legiTexteId)
|
||||||
|
@ -285,14 +291,14 @@ async function exportLegiTexteToMarkdown(
|
||||||
// Sort of textes modificateurs by date
|
// Sort of textes modificateurs by date
|
||||||
|
|
||||||
const textesModificateursIds = new Set<string>()
|
const textesModificateursIds = new Set<string>()
|
||||||
for (const infosTexteModificateur of Object.values(
|
for (const texteModificateurIdByAction of Object.values(
|
||||||
context.infosTexteModificateurById,
|
context.texteModificateurIdByActionById,
|
||||||
)) {
|
)) {
|
||||||
if (infosTexteModificateur.CREATE !== undefined) {
|
if (texteModificateurIdByAction.CREATE !== undefined) {
|
||||||
textesModificateursIds.add(infosTexteModificateur.CREATE)
|
textesModificateursIds.add(texteModificateurIdByAction.CREATE)
|
||||||
}
|
}
|
||||||
if (infosTexteModificateur.DELETE !== undefined) {
|
if (texteModificateurIdByAction.DELETE !== undefined) {
|
||||||
textesModificateursIds.add(infosTexteModificateur.DELETE)
|
textesModificateursIds.add(texteModificateurIdByAction.DELETE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,10 +449,10 @@ async function generateGitDirectory(
|
||||||
repositoryRelativeDir,
|
repositoryRelativeDir,
|
||||||
articleFilename,
|
articleFilename,
|
||||||
)
|
)
|
||||||
const infosTextModificateur =
|
const texteModificateurIdByAction =
|
||||||
context.infosTexteModificateurById[articleId]
|
context.texteModificateurIdByActionById[articleId]
|
||||||
if (context.currentInternalIds.has(articleId)) {
|
if (context.currentInternalIds.has(articleId)) {
|
||||||
if (infosTextModificateur.DELETE === texteModificateurId) {
|
if (texteModificateurIdByAction.DELETE === texteModificateurId) {
|
||||||
await fs.remove(
|
await fs.remove(
|
||||||
path.join(context.targetDir, articleRepositoryRelativeFilePath),
|
path.join(context.targetDir, articleRepositoryRelativeFilePath),
|
||||||
)
|
)
|
||||||
|
@ -454,7 +460,7 @@ async function generateGitDirectory(
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (infosTextModificateur.CREATE === texteModificateurId) {
|
if (texteModificateurIdByAction.CREATE === texteModificateurId) {
|
||||||
context.currentInternalIds.add(articleId)
|
context.currentInternalIds.add(articleId)
|
||||||
} else {
|
} else {
|
||||||
continue
|
continue
|
||||||
|
@ -501,10 +507,10 @@ async function generateGitDirectory(
|
||||||
repositoryRelativeDir,
|
repositoryRelativeDir,
|
||||||
sectionTaDirName,
|
sectionTaDirName,
|
||||||
)
|
)
|
||||||
const infosTextModificateur =
|
const texteModificateurIdByAction =
|
||||||
context.infosTexteModificateurById[sectionTaId]
|
context.texteModificateurIdByActionById[sectionTaId]
|
||||||
if (context.currentInternalIds.has(sectionTaId)) {
|
if (context.currentInternalIds.has(sectionTaId)) {
|
||||||
if (infosTextModificateur.DELETE === texteModificateurId) {
|
if (texteModificateurIdByAction.DELETE === texteModificateurId) {
|
||||||
await fs.remove(
|
await fs.remove(
|
||||||
path.join(context.targetDir, sectionTaRepositoryRelativeDir),
|
path.join(context.targetDir, sectionTaRepositoryRelativeDir),
|
||||||
)
|
)
|
||||||
|
@ -512,7 +518,7 @@ async function generateGitDirectory(
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (infosTextModificateur.CREATE === texteModificateurId) {
|
if (texteModificateurIdByAction.CREATE === texteModificateurId) {
|
||||||
context.currentInternalIds.add(sectionTaId)
|
context.currentInternalIds.add(sectionTaId)
|
||||||
} else {
|
} else {
|
||||||
continue
|
continue
|
||||||
|
@ -889,14 +895,17 @@ async function registerLegiArticleModifiers(
|
||||||
}
|
}
|
||||||
|
|
||||||
// If article has no texte créateur at all, then create a fake one.
|
// If article has no texte créateur at all, then create a fake one.
|
||||||
let infosTexteModificateur = context.infosTexteModificateurById[articleId]
|
let texteModificateurIdByAction =
|
||||||
if (infosTexteModificateur === undefined) {
|
context.texteModificateurIdByActionById[articleId]
|
||||||
infosTexteModificateur = context.infosTexteModificateurById[articleId] = {
|
if (texteModificateurIdByAction === undefined) {
|
||||||
|
texteModificateurIdByAction = context.texteModificateurIdByActionById[
|
||||||
|
articleId
|
||||||
|
] = {
|
||||||
CREATE: undefined,
|
CREATE: undefined,
|
||||||
DELETE: undefined,
|
DELETE: undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (infosTexteModificateur.CREATE === undefined) {
|
if (texteModificateurIdByAction.CREATE === undefined) {
|
||||||
const texteManquantId = `ZZZZ TEXTE MANQUANT ${articleDateDebut}`
|
const texteManquantId = `ZZZZ TEXTE MANQUANT ${articleDateDebut}`
|
||||||
let texteManquant = context.texteManquantById[texteManquantId]
|
let texteManquant = context.texteManquantById[texteManquantId]
|
||||||
if (texteManquant === undefined) {
|
if (texteManquant === undefined) {
|
||||||
|
@ -904,7 +913,7 @@ async function registerLegiArticleModifiers(
|
||||||
date: articleDateDebut,
|
date: articleDateDebut,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
infosTexteModificateur.CREATE = texteManquantId
|
texteModificateurIdByAction.CREATE = texteManquantId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1020,14 +1029,17 @@ async function registerLegiSectionTaModifiers(
|
||||||
}
|
}
|
||||||
|
|
||||||
// If article has no texte créateur at all, then create a fake one.
|
// If article has no texte créateur at all, then create a fake one.
|
||||||
let infosTexteModificateur = context.infosTexteModificateurById[sectionTaId]
|
let texteModificateurIdByAction =
|
||||||
if (infosTexteModificateur === undefined) {
|
context.texteModificateurIdByActionById[sectionTaId]
|
||||||
infosTexteModificateur = context.infosTexteModificateurById[sectionTaId] = {
|
if (texteModificateurIdByAction === undefined) {
|
||||||
|
texteModificateurIdByAction = context.texteModificateurIdByActionById[
|
||||||
|
sectionTaId
|
||||||
|
] = {
|
||||||
CREATE: undefined,
|
CREATE: undefined,
|
||||||
DELETE: undefined,
|
DELETE: undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (infosTexteModificateur.CREATE === undefined) {
|
if (texteModificateurIdByAction.CREATE === undefined) {
|
||||||
const texteManquantId = `ZZZZ TEXTE MANQUANT ${sectionTaDateDebut}`
|
const texteManquantId = `ZZZZ TEXTE MANQUANT ${sectionTaDateDebut}`
|
||||||
let texteManquant = context.texteManquantById[texteManquantId]
|
let texteManquant = context.texteManquantById[texteManquantId]
|
||||||
if (texteManquant === undefined) {
|
if (texteManquant === undefined) {
|
||||||
|
@ -1035,7 +1047,7 @@ async function registerLegiSectionTaModifiers(
|
||||||
date: sectionTaDateDebut,
|
date: sectionTaDateDebut,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
infosTexteModificateur.CREATE = texteManquantId
|
texteModificateurIdByAction.CREATE = texteManquantId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue