@intlayer/engine 9.7.1 → 9.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dist/cjs/_virtual/_utils_asset.cjs +1 -1
  2. package/dist/cjs/build.cjs +8 -8
  3. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +3 -3
  4. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +2 -2
  5. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +2 -2
  6. package/dist/cjs/buildIntlayerDictionary/writeNestedDictionary.cjs +2 -2
  7. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +2 -2
  8. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +2 -2
  9. package/dist/cjs/cleanOutputDir.cjs +1 -1
  10. package/dist/cjs/cleanRemovedContentDeclaration.cjs +1 -1
  11. package/dist/cjs/cli.cjs +5 -2
  12. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +1 -1
  13. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +2 -2
  14. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +2 -2
  15. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +2 -2
  16. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +2 -2
  17. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +2 -2
  18. package/dist/cjs/createType/createModuleAugmentation.cjs +1 -1
  19. package/dist/cjs/createType/createType.cjs +1 -1
  20. package/dist/cjs/docReview/pipeline.cjs.map +1 -1
  21. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  22. package/dist/cjs/handleContentDeclarationFileChange.cjs +2 -2
  23. package/dist/cjs/init/documentationRouter.cjs +1 -0
  24. package/dist/cjs/init/documentationRouter.cjs.map +1 -1
  25. package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs +1 -1
  26. package/dist/cjs/init/frameworkSetup/nextAppRouter/restructure.cjs +1 -1
  27. package/dist/cjs/init/frameworkSetup/tanstackStart/index.cjs +1 -1
  28. package/dist/cjs/init/frameworkSetup/tanstackStart/restructure.cjs +1 -1
  29. package/dist/cjs/init/index.cjs +47 -3
  30. package/dist/cjs/init/index.cjs.map +1 -1
  31. package/dist/cjs/init/utils/fileSystem.cjs +2 -2
  32. package/dist/cjs/init/utils/githubActions.cjs +1 -1
  33. package/dist/cjs/init/utils/index.cjs +6 -0
  34. package/dist/cjs/init/utils/intlayerDependencies.cjs +2 -2
  35. package/dist/cjs/init/utils/packageManager.cjs +3 -1
  36. package/dist/cjs/init/utils/packageManager.cjs.map +1 -1
  37. package/dist/cjs/init/utils/prettierConfig.cjs +54 -0
  38. package/dist/cjs/init/utils/prettierConfig.cjs.map +1 -0
  39. package/dist/cjs/initConfig/index.cjs +1 -1
  40. package/dist/cjs/initConfig/index.cjs.map +1 -1
  41. package/dist/cjs/installLSP.cjs +1 -1
  42. package/dist/cjs/installMCP/installMCP.cjs +1 -1
  43. package/dist/cjs/installSkills/index.cjs +1 -1
  44. package/dist/cjs/installSkills/index.cjs.map +1 -1
  45. package/dist/cjs/listGitFiles.cjs +1 -1
  46. package/dist/cjs/listGitFiles.cjs.map +1 -1
  47. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +1 -1
  48. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +1 -1
  49. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +1 -1
  50. package/dist/cjs/loadDictionaries/log.cjs +1 -1
  51. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -1
  52. package/dist/cjs/prepareIntlayer.cjs +2 -2
  53. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  54. package/dist/cjs/scan/index.cjs +1 -1
  55. package/dist/cjs/syncPluginKit/createFileAdapter.cjs +1 -1
  56. package/dist/cjs/utils/buildComponentFilesList.cjs +1 -1
  57. package/dist/cjs/utils/contentWatcherLock.cjs +2 -2
  58. package/dist/cjs/utils/readDictionariesFromDisk.cjs +1 -1
  59. package/dist/cjs/utils/runOnce.cjs +2 -2
  60. package/dist/cjs/utils/withFileLock.cjs +2 -2
  61. package/dist/cjs/watcher.cjs +4 -4
  62. package/dist/cjs/watcher.cjs.map +1 -1
  63. package/dist/cjs/writeConfiguration/index.cjs +2 -2
  64. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +1 -1
  65. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +2 -2
  66. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +2 -2
  67. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs +1 -1
  68. package/dist/cjs/writeContentDeclaration/writeYamlFile.cjs +1 -1
  69. package/dist/cjs/writeFileIfChanged.cjs +2 -2
  70. package/dist/esm/_virtual/_utils_asset.mjs +1 -1
  71. package/dist/esm/build.mjs +8 -8
  72. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +3 -3
  73. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +2 -2
  74. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +2 -2
  75. package/dist/esm/buildIntlayerDictionary/writeNestedDictionary.mjs +2 -2
  76. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +2 -2
  77. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +2 -2
  78. package/dist/esm/cleanOutputDir.mjs +1 -1
  79. package/dist/esm/cleanRemovedContentDeclaration.mjs +1 -1
  80. package/dist/esm/cli.mjs +4 -3
  81. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +1 -1
  82. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +2 -2
  83. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +2 -2
  84. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +2 -2
  85. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +2 -2
  86. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +2 -2
  87. package/dist/esm/createType/createModuleAugmentation.mjs +1 -1
  88. package/dist/esm/createType/createType.mjs +1 -1
  89. package/dist/esm/docReview/pipeline.mjs.map +1 -1
  90. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  91. package/dist/esm/handleContentDeclarationFileChange.mjs +2 -2
  92. package/dist/esm/init/documentationRouter.mjs +1 -0
  93. package/dist/esm/init/documentationRouter.mjs.map +1 -1
  94. package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs +1 -1
  95. package/dist/esm/init/frameworkSetup/nextAppRouter/restructure.mjs +1 -1
  96. package/dist/esm/init/frameworkSetup/tanstackStart/index.mjs +1 -1
  97. package/dist/esm/init/frameworkSetup/tanstackStart/restructure.mjs +1 -1
  98. package/dist/esm/init/index.mjs +47 -3
  99. package/dist/esm/init/index.mjs.map +1 -1
  100. package/dist/esm/init/utils/fileSystem.mjs +2 -2
  101. package/dist/esm/init/utils/githubActions.mjs +1 -1
  102. package/dist/esm/init/utils/index.mjs +2 -1
  103. package/dist/esm/init/utils/intlayerDependencies.mjs +2 -2
  104. package/dist/esm/init/utils/packageManager.mjs +3 -1
  105. package/dist/esm/init/utils/packageManager.mjs.map +1 -1
  106. package/dist/esm/init/utils/prettierConfig.mjs +49 -0
  107. package/dist/esm/init/utils/prettierConfig.mjs.map +1 -0
  108. package/dist/esm/initConfig/index.mjs +1 -1
  109. package/dist/esm/initConfig/index.mjs.map +1 -1
  110. package/dist/esm/installLSP.mjs +1 -1
  111. package/dist/esm/installMCP/installMCP.mjs +1 -1
  112. package/dist/esm/installSkills/index.mjs +1 -1
  113. package/dist/esm/installSkills/index.mjs.map +1 -1
  114. package/dist/esm/listGitFiles.mjs +1 -1
  115. package/dist/esm/listGitFiles.mjs.map +1 -1
  116. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +1 -1
  117. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +1 -1
  118. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +1 -1
  119. package/dist/esm/loadDictionaries/log.mjs +1 -1
  120. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs.map +1 -1
  121. package/dist/esm/prepareIntlayer.mjs +2 -2
  122. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  123. package/dist/esm/scan/index.mjs +1 -1
  124. package/dist/esm/syncPluginKit/createFileAdapter.mjs +1 -1
  125. package/dist/esm/utils/buildComponentFilesList.mjs +1 -1
  126. package/dist/esm/utils/contentWatcherLock.mjs +2 -2
  127. package/dist/esm/utils/readDictionariesFromDisk.mjs +1 -1
  128. package/dist/esm/utils/runOnce.mjs +2 -2
  129. package/dist/esm/utils/withFileLock.mjs +2 -2
  130. package/dist/esm/watcher.mjs +4 -4
  131. package/dist/esm/watcher.mjs.map +1 -1
  132. package/dist/esm/writeConfiguration/index.mjs +2 -2
  133. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +1 -1
  134. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +2 -2
  135. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +2 -2
  136. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +1 -1
  137. package/dist/esm/writeContentDeclaration/writeYamlFile.mjs +1 -1
  138. package/dist/esm/writeFileIfChanged.mjs +2 -2
  139. package/dist/types/build.d.ts +17 -17
  140. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  141. package/dist/types/cli.d.ts +12 -10
  142. package/dist/types/docReview/pipeline.d.ts.map +1 -1
  143. package/dist/types/init/documentationRouter.d.ts +1 -0
  144. package/dist/types/init/documentationRouter.d.ts.map +1 -1
  145. package/dist/types/init/index.d.ts +2 -0
  146. package/dist/types/init/index.d.ts.map +1 -1
  147. package/dist/types/init/utils/index.d.ts +2 -1
  148. package/dist/types/init/utils/packageManager.d.ts +5 -0
  149. package/dist/types/init/utils/packageManager.d.ts.map +1 -1
  150. package/dist/types/init/utils/prettierConfig.d.ts +28 -0
  151. package/dist/types/init/utils/prettierConfig.d.ts.map +1 -0
  152. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +1 -1
  153. package/dist/types/loadDictionaries/logTypeScriptErrors.d.ts.map +1 -1
  154. package/dist/types/scan/detection/index.d.ts +4 -0
  155. package/dist/types/scan/index.d.ts +5 -4
  156. package/dist/types/watcher.d.ts.map +1 -1
  157. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +1 -1
  158. package/package.json +69 -69
package/dist/esm/cli.mjs CHANGED
@@ -1,12 +1,13 @@
1
1
  import { detectFormatCommand } from "./detectFormatCommand.mjs";
2
2
  import { enableEditorInConfig, setupCmsCredentials, writeCmsCredentialsToEnv } from "./init/cms.mjs";
3
3
  import { getDefaultApplicationURL, initIntlayer, logInitSuccessMessage } from "./init/index.mjs";
4
- import { getContentDeclarationFileTemplate } from "./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";
5
4
  import { upgradeIntlayerPackages } from "./init/upgradeIntlayerPackages.mjs";
6
- import { DocumentationRouter, getDocumentationUrl } from "./init/documentationRouter.mjs";
5
+ import { getContentDeclarationFileTemplate } from "./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";
7
6
  import { CATALOG_MESSAGE_FORMATS, CONTENT_FORMATS_BY_LAYOUT, getContentLayoutSetup } from "./init/utils/contentLayout.mjs";
7
+ import { DocumentationRouter, getDocumentationUrl } from "./init/documentationRouter.mjs";
8
8
  import { NEXT_INTLAYER_BABEL_CONFIG_CONTENT } from "./init/utils/nextCompilerBabel.mjs";
9
9
  import { COMPAT_I18N_LIBRARIES, detectCompatI18nLibraries, detectPackageManager, findLockFileDir, hasLintTooling, installPackages } from "./init/utils/packageManager.mjs";
10
+ import { PRETTIER_CONFIG_FILES, hasPrettier } from "./init/utils/prettierConfig.mjs";
10
11
  import { hasUrlRoutingFramework } from "./init/utils/urlRoutingFramework.mjs";
11
12
  import { installLSP } from "./installLSP.mjs";
12
13
  import { MCP_TRANSPORTS, installMCP } from "./installMCP/installMCP.mjs";
@@ -22,4 +23,4 @@ import { formatContentDeclaration, isRenderableContentDeclarationPath, renderCon
22
23
  import { writeJSFile } from "./writeContentDeclaration/writeJSFile.mjs";
23
24
  import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.mjs";
24
25
 
25
- export { CATALOG_MESSAGE_FORMATS, COMPAT_I18N_LIBRARIES, CONTENT_FORMATS_BY_LAYOUT, DocumentationRouter, MCP_TRANSPORTS, NEXT_INTLAYER_BABEL_CONFIG_CONTENT, PLATFORMS, PLATFORMS_METADATA, SKILLS, SKILLS_METADATA, detectCompatI18nLibraries, detectExportedComponentName, detectFormatCommand, detectPackageManager, detectPlatform, enableEditorInConfig, findLockFileDir, formatContentDeclaration, getContentDeclarationFileTemplate, getContentLayoutSetup, getDefaultApplicationURL, getDocumentationUrl, getGitRootDir, getInitialSkills, hasLintTooling, hasUrlRoutingFramework, initIntlayer, installLSP, installMCP, installPackages, installSkills, isRenderableContentDeclarationPath, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, logConfigDetails, logInitSuccessMessage, prepareIntlayer, renderContentDeclaration, renderMarkdownContentDeclaration, renderYamlContentDeclaration, setupCmsCredentials, transformJSFile, upgradeIntlayerPackages, writeCmsCredentialsToEnv, writeContentDeclaration, writeJSFile };
26
+ export { CATALOG_MESSAGE_FORMATS, COMPAT_I18N_LIBRARIES, CONTENT_FORMATS_BY_LAYOUT, DocumentationRouter, MCP_TRANSPORTS, NEXT_INTLAYER_BABEL_CONFIG_CONTENT, PLATFORMS, PLATFORMS_METADATA, PRETTIER_CONFIG_FILES, SKILLS, SKILLS_METADATA, detectCompatI18nLibraries, detectExportedComponentName, detectFormatCommand, detectPackageManager, detectPlatform, enableEditorInConfig, findLockFileDir, formatContentDeclaration, getContentDeclarationFileTemplate, getContentLayoutSetup, getDefaultApplicationURL, getDocumentationUrl, getGitRootDir, getInitialSkills, hasLintTooling, hasPrettier, hasUrlRoutingFramework, initIntlayer, installLSP, installMCP, installPackages, installSkills, isRenderableContentDeclarationPath, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, logConfigDetails, logInitSuccessMessage, prepareIntlayer, renderContentDeclaration, renderMarkdownContentDeclaration, renderYamlContentDeclaration, setupCmsCredentials, transformJSFile, upgradeIntlayerPackages, writeCmsCredentialsToEnv, writeContentDeclaration, writeJSFile };
@@ -5,8 +5,8 @@ import { getBuiltDynamicDictionariesPath } from "./getBuiltDynamicDictionariesPa
5
5
  import { getBuiltFetchDictionariesPath } from "./getBuiltFetchDictionariesPath.mjs";
6
6
  import { getBuiltRemoteDictionariesPath } from "./getBuiltRemoteDictionariesPath.mjs";
7
7
  import { getBuiltUnmergedDictionariesPath } from "./getBuiltUnmergedDictionariesPath.mjs";
8
- import { mkdir } from "node:fs/promises";
9
8
  import { resolve } from "node:path";
9
+ import { mkdir } from "node:fs/promises";
10
10
  import { parallelize } from "@intlayer/config/utils";
11
11
  import { getConfiguration } from "@intlayer/config/node";
12
12
 
@@ -1,7 +1,7 @@
1
- import { mkdir } from "node:fs/promises";
1
+ import { existsSync } from "node:fs";
2
2
  import { basename } from "node:path";
3
+ import { mkdir } from "node:fs/promises";
3
4
  import { normalizePath } from "@intlayer/config/utils";
4
- import { existsSync } from "node:fs";
5
5
  import fg from "fast-glob";
6
6
 
7
7
  // src/createDictionaryEntryPoint/getBuiltDictionariesPath.ts
@@ -1,7 +1,7 @@
1
- import { mkdir } from "node:fs/promises";
1
+ import { existsSync } from "node:fs";
2
2
  import { basename } from "node:path";
3
+ import { mkdir } from "node:fs/promises";
3
4
  import { normalizePath } from "@intlayer/config/utils";
4
- import { existsSync } from "node:fs";
5
5
  import fg from "fast-glob";
6
6
 
7
7
  // src/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.ts
@@ -1,7 +1,7 @@
1
- import { mkdir } from "node:fs/promises";
1
+ import { existsSync } from "node:fs";
2
2
  import { basename } from "node:path";
3
+ import { mkdir } from "node:fs/promises";
3
4
  import { normalizePath } from "@intlayer/config/utils";
4
- import { existsSync } from "node:fs";
5
5
  import fg from "fast-glob";
6
6
 
7
7
  // src/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.ts
@@ -1,7 +1,7 @@
1
- import { mkdir } from "node:fs/promises";
1
+ import { existsSync } from "node:fs";
2
2
  import { basename } from "node:path";
3
+ import { mkdir } from "node:fs/promises";
3
4
  import { normalizePath } from "@intlayer/config/utils";
4
- import { existsSync } from "node:fs";
5
5
  import fg from "fast-glob";
6
6
 
7
7
  // src/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.ts
@@ -1,7 +1,7 @@
1
- import { mkdir } from "node:fs/promises";
1
+ import { existsSync } from "node:fs";
2
2
  import { basename } from "node:path";
3
+ import { mkdir } from "node:fs/promises";
3
4
  import { normalizePath } from "@intlayer/config/utils";
4
- import { existsSync } from "node:fs";
5
5
  import fg from "fast-glob";
6
6
 
7
7
  // src/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.ts
@@ -1,7 +1,7 @@
1
1
  import { getPathHash } from "../utils/getPathHash.mjs";
2
2
  import { writeFileIfChanged } from "../writeFileIfChanged.mjs";
3
- import { mkdir } from "node:fs/promises";
4
3
  import { basename, extname, join, relative } from "node:path";
4
+ import { mkdir } from "node:fs/promises";
5
5
  import { kebabCaseToCamelCase, normalizePath } from "@intlayer/config/utils";
6
6
  import { getDomainOrigin, getRewriteRules, isLocaleExclusiveOnDomain } from "@intlayer/core/localization";
7
7
  import fg from "fast-glob";
@@ -1,6 +1,6 @@
1
1
  import { writeFileIfChanged } from "../writeFileIfChanged.mjs";
2
- import { mkdir } from "node:fs/promises";
3
2
  import { resolve } from "node:path";
3
+ import { mkdir } from "node:fs/promises";
4
4
  import { parallelize } from "@intlayer/config/utils";
5
5
 
6
6
  // src/createType/createType.ts
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.mjs","names":[],"sources":["../../../src/docReview/pipeline.ts"],"sourcesContent":["import { alignBaseAndTargetBlocks } from './alignBlocks';\nimport { fingerprintBlock } from './fingerprintBlock';\nimport { mapChangedLinesToBlocks } from './mapChangedLinesToBlocks';\nimport { normalizeBlock } from './normalizeBlock';\nimport {\n identifySegmentsToReview,\n mergeReviewedSegments,\n type SegmentToReview,\n} from './rebuildDocument';\nimport { segmentDocument, segmentSections } from './segmentDocument';\nimport type {\n AlignmentPlan,\n Block,\n FingerprintedBlock,\n PlannedAction,\n} from './types';\n\nexport type BuildAlignmentPlanInput = {\n /** The base (source) document, used as the translation reference. */\n baseText: string;\n /** The existing target (translated) document, possibly empty. */\n targetText: string;\n /**\n * 1-based line numbers that changed in the base document.\n *\n * `undefined` means the changed lines are unknown (no git history available):\n * every section is then compared block by block. An empty array means nothing\n * changed, and every aligned block is reused.\n */\n changedLines: number[] | undefined;\n};\n\nexport type BuildAlignmentPlanOutput = {\n baseBlocks: FingerprintedBlock[];\n targetBlocks: FingerprintedBlock[];\n plan: AlignmentPlan;\n segmentsToReview: SegmentToReview[];\n};\n\n/** Fingerprint a list of already-segmented blocks (context = neighbours). */\nconst fingerprintBlockList = (blocks: Block[]): FingerprintedBlock[] => {\n const normalized = blocks.map(normalizeBlock);\n\n return normalized.map((block, index, array) =>\n fingerprintBlock(block, array[index - 1] ?? null, array[index + 1] ?? null)\n );\n};\n\n/**\n * Re-segment a section's own text into fine blocks, shifting their relative line\n * numbers back to absolute document positions so changed-line mapping and the\n * review report keep reporting real file coordinates.\n */\nconst fingerprintSectionFineBlocks = (section: Block): FingerprintedBlock[] => {\n const lineOffset = section.lineStart - 1;\n\n const fineBlocks = segmentDocument(section.content).map(\n (block): Block => ({\n ...block,\n lineStart: block.lineStart + lineOffset,\n lineEnd: block.lineEnd + lineOffset,\n })\n );\n\n return fingerprintBlockList(fineBlocks);\n};\n\n/**\n * Build the block-aware alignment plan between a base document and its\n * translation, in two levels.\n *\n * 1. **Sections** (heading-anchored) are aligned first. Because a document and\n * its translation share the same heading structure, this alignment is robust\n * and never drops a section just because the prose was split into a different\n * number of paragraphs.\n * 2. Only the sections **touched by a changed line** are then re-segmented into\n * fine blocks (paragraphs, code fences) and aligned within the section, so a\n * small edit re-translates only the affected paragraph(s) instead of the\n * whole section. Within a changed section a target block with no base\n * counterpart is **kept as-is** (reused) rather than deleted, so a translation\n * that has extra paragraphs never loses content.\n * When `changedLines` is `undefined` the changed lines are simply unknown, so\n * **every** section is inspected instead of none: aligned blocks are still\n * reused (there is no way to tell which translation went stale), but blocks\n * living on one side only are reported as `insert_new` / `delete`. This is\n * what makes a plain \"compare this document with its translation\" run — one\n * with no git history behind it — report anything at all.\n *\n * Section-level insertions and deletions stay whole: a brand-new section is\n * translated as one unit, and a target section with no base counterpart is\n * reported as `delete` for visibility but never dropped by the merge (see\n * {@link mergeReviewedSegments}), so a review can never lose translated content.\n *\n * @param input - The base/target texts and optional changed lines.\n * @returns The (flattened) blocks, the plan, and the segments that need translation.\n */\nexport const buildAlignmentPlan = ({\n baseText,\n targetText,\n changedLines,\n}: BuildAlignmentPlanInput): BuildAlignmentPlanOutput => {\n // `undefined` means \"which lines changed is unknown\" (no git history to read),\n // which is not the same as \"no line changed\": the former must still compare the\n // two documents, the latter must reuse everything.\n const hasChangedLineInformation = Array.isArray(changedLines);\n const changedLineNumbers = changedLines ?? [];\n\n const baseSections = fingerprintBlockList(segmentSections(baseText));\n const targetSections = fingerprintBlockList(segmentSections(targetText));\n\n const sectionAlignment = alignBaseAndTargetBlocks(\n baseSections,\n targetSections\n );\n const changedSectionIndexes = mapChangedLinesToBlocks(\n baseSections,\n changedLineNumbers\n );\n\n /**\n * Whether a section must be opened and inspected block by block.\n *\n * Without changed-line information every section is inspected, so comparing a\n * document with its translation from scratch still reports the blocks that\n * exist on one side only. With changed lines, only the touched sections are.\n */\n const isSectionToInspect = (sectionIndex: number): boolean =>\n !hasChangedLineInformation || changedSectionIndexes.has(sectionIndex);\n\n // Flattened blocks the plan refers to by index. Reused/deleted/inserted\n // sections contribute their whole-section block; changed sections contribute\n // their fine sub-blocks.\n const baseBlocks: FingerprintedBlock[] = [];\n const targetBlocks: FingerprintedBlock[] = [];\n const actions: PlannedAction[] = [];\n\n const pushBaseBlock = (block: FingerprintedBlock): number =>\n baseBlocks.push(block) - 1;\n const pushTargetBlock = (block: FingerprintedBlock): number =>\n targetBlocks.push(block) - 1;\n\n for (const pair of sectionAlignment) {\n // Section present only in the target → reported as `delete` for visibility,\n // but kept verbatim by the merge (the aligner may simply have failed to\n // follow a reordered section), never silently dropped.\n if (pair.baseIndex === -1 && pair.targetIndex !== null) {\n const targetIndex = pushTargetBlock(targetSections[pair.targetIndex]!);\n actions.push({ kind: 'delete', targetIndex });\n continue;\n }\n\n // Section present only in the base → brand new, translate as one unit.\n if (pair.baseIndex >= 0 && pair.targetIndex === null) {\n const baseIndex = pushBaseBlock(baseSections[pair.baseIndex]!);\n actions.push({ kind: 'insert_new', baseIndex });\n continue;\n }\n\n if (pair.baseIndex < 0 || pair.targetIndex === null) continue;\n\n const baseSection = baseSections[pair.baseIndex]!;\n const targetSection = targetSections[pair.targetIndex]!;\n\n // Unchanged section → reuse the existing translation verbatim.\n if (!isSectionToInspect(pair.baseIndex)) {\n const baseIndex = pushBaseBlock(baseSection);\n const targetIndex = pushTargetBlock(targetSection);\n actions.push({ kind: 'reuse', baseIndex, targetIndex });\n continue;\n }\n\n // Inspected section → align its fine blocks and review only what changed.\n const baseFineBlocks = fingerprintSectionFineBlocks(baseSection);\n const targetFineBlocks = fingerprintSectionFineBlocks(targetSection);\n const fineAlignment = alignBaseAndTargetBlocks(\n baseFineBlocks,\n targetFineBlocks\n );\n const changedFineIndexes = mapChangedLinesToBlocks(\n baseFineBlocks,\n changedLineNumbers\n );\n\n for (const finePair of fineAlignment) {\n // Target-only fine block. Its content is kept either way — `delete` is\n // reported for visibility only and the merge keeps it verbatim (see\n // {@link mergeReviewedSegments}).\n // With changed lines the author's edit is known precisely, so an unmatched\n // target block is most likely the translator's own prose split and stays\n // silent. Without them the whole document is being compared, and such a\n // block is exactly the divergence the report exists to surface.\n if (finePair.baseIndex === -1 && finePair.targetIndex !== null) {\n const targetIndex = pushTargetBlock(\n targetFineBlocks[finePair.targetIndex]!\n );\n actions.push(\n hasChangedLineInformation\n ? { kind: 'reuse', baseIndex: -1, targetIndex }\n : { kind: 'delete', targetIndex }\n );\n continue;\n }\n\n // Base-only fine block: a new paragraph inside the section, translate it.\n if (finePair.baseIndex >= 0 && finePair.targetIndex === null) {\n const baseIndex = pushBaseBlock(baseFineBlocks[finePair.baseIndex]!);\n actions.push({ kind: 'insert_new', baseIndex });\n continue;\n }\n\n if (finePair.baseIndex < 0 || finePair.targetIndex === null) continue;\n\n const baseIndex = pushBaseBlock(baseFineBlocks[finePair.baseIndex]!);\n const targetIndex = pushTargetBlock(\n targetFineBlocks[finePair.targetIndex]!\n );\n\n actions.push(\n changedFineIndexes.has(finePair.baseIndex)\n ? { kind: 'review', baseIndex, targetIndex }\n : { kind: 'reuse', baseIndex, targetIndex }\n );\n }\n }\n\n const plan = { actions };\n\n const { segmentsToReview } = identifySegmentsToReview({\n baseBlocks,\n targetBlocks,\n plan,\n });\n\n return { baseBlocks, targetBlocks, plan, segmentsToReview };\n};\n\nexport type { SegmentToReview };\nexport { mergeReviewedSegments };\n"],"mappings":";;;;;;;;;AAwCA,MAAM,wBAAwB,WAA0C;CAGtE,OAFmB,OAAO,IAAI,cAEd,CAAC,CAAC,KAAK,OAAO,OAAO,UACnC,iBAAiB,OAAO,MAAM,QAAQ,MAAM,MAAM,MAAM,QAAQ,MAAM,IAAI,CAC5E;AACF;;;;;;AAOA,MAAM,gCAAgC,YAAyC;CAC7E,MAAM,aAAa,QAAQ,YAAY;CAEvC,MAAM,aAAa,gBAAgB,QAAQ,OAAO,CAAC,CAAC,KACj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W;GAC3C,MAAM,cAAc,gBAAgB,aAAa;GACjD,QAAQ,KAAK;IAAE,MAAM;IAAS;IAAW;GAAY,CAAC;GACtD;EACF;EAGA,MAAM,iBAAiB,6BAA6B,WAAW;EAC/D,MAAM,mBAAmB,6BAA6B,aAAa;EACnE,MAAM,gBAAgB,yBACpB,gBACA,gBACF;EACA,MAAM,qBAAqB,wBACzB,gBACA,kBACF;EAEA,KAAK,MAAM,YAAY,eAAe;GAQpC,IAAI,SAAS,cAAc,MAAM,SAAS,gBAAgB,MAAM;IAC9D,MAAM,cAAc,gBAClB,iBAAiB,SAAS,YAC5B;IACA,QAAQ,KACN,4BACI;KAAE,MAAM;KAAS,WAAW;KAAI;IAAY,IAC5C;KAAE,MAAM;KAAU;IAAY,CACpC;IACA;GACF;GAGA,IAAI,SAAS,aAAa,KAAK,SAAS,gBAAgB,MAAM;IAC5D,MAAM,YAAY,cAAc,eAAe,SAAS,UAAW;IACnE,QAAQ,KAAK;KAAE,MAAM;KAAc;IAAU,CAAC;IAC9C;GACF;GAEA,IAAI,SAAS,YAAY,KAAK,SAAS,gBAAgB,MAAM;GAE7D,MAAM,YAAY,cAAc,eAAe,SAAS,UAAW;GACnE,MAAM,cAAc,gBAClB,iBAAiB,SAAS,YAC5B;GAEA,QAAQ,KACN,mBAAmB,IAAI,SAAS,SAAS,IACrC;IAAE,MAAM;IAAU;IAAW;GAAY,IACzC;IAAE,MAAM;IAAS;IAAW;GAAY,CAC9C;EACF;CACF;CAEA,MAAM,OAAO,EAAE,QAAQ;CAEvB,MAAM,EAAE,qBAAqB,yBAAyB;EACpD;EACA;EACA;CACF,CAAC;CAED,OAAO;EAAE;EAAY;EAAc;EAAM;CAAiB;AAC5D"}
1
+ {"version":3,"file":"pipeline.mjs","names":[],"sources":["../../../src/docReview/pipeline.ts"],"sourcesContent":["import { alignBaseAndTargetBlocks } from './alignBlocks';\nimport { fingerprintBlock } from './fingerprintBlock';\nimport { mapChangedLinesToBlocks } from './mapChangedLinesToBlocks';\nimport { normalizeBlock } from './normalizeBlock';\nimport {\n identifySegmentsToReview,\n mergeReviewedSegments,\n type SegmentToReview,\n} from './rebuildDocument';\nimport { segmentDocument, segmentSections } from './segmentDocument';\nimport type {\n AlignmentPlan,\n Block,\n FingerprintedBlock,\n PlannedAction,\n} from './types';\n\nexport type BuildAlignmentPlanInput = {\n /** The base (source) document, used as the translation reference. */\n baseText: string;\n /** The existing target (translated) document, possibly empty. */\n targetText: string;\n /**\n * 1-based line numbers that changed in the base document.\n *\n * `undefined` means the changed lines are unknown (no git history available):\n * every section is then compared block by block. An empty array means nothing\n * changed, and every aligned block is reused.\n */\n changedLines: number[] | undefined;\n};\n\nexport type BuildAlignmentPlanOutput = {\n baseBlocks: FingerprintedBlock[];\n targetBlocks: FingerprintedBlock[];\n plan: AlignmentPlan;\n segmentsToReview: SegmentToReview[];\n};\n\n/** Fingerprint a list of already-segmented blocks (context = neighbours). */\nconst fingerprintBlockList = (blocks: Block[]): FingerprintedBlock[] => {\n const normalized = blocks.map(normalizeBlock);\n\n return normalized.map((block, index, array) =>\n fingerprintBlock(block, array[index - 1] ?? null, array[index + 1] ?? null)\n );\n};\n\n/**\n * Re-segment a section's own text into fine blocks, shifting their relative line\n * numbers back to absolute document positions so changed-line mapping and the\n * review report keep reporting real file coordinates.\n */\nconst fingerprintSectionFineBlocks = (section: Block): FingerprintedBlock[] => {\n const lineOffset = section.lineStart - 1;\n\n const fineBlocks = segmentDocument(section.content).map((block): Block => ({\n ...block,\n lineStart: block.lineStart + lineOffset,\n lineEnd: block.lineEnd + lineOffset,\n }));\n\n return fingerprintBlockList(fineBlocks);\n};\n\n/**\n * Build the block-aware alignment plan between a base document and its\n * translation, in two levels.\n *\n * 1. **Sections** (heading-anchored) are aligned first. Because a document and\n * its translation share the same heading structure, this alignment is robust\n * and never drops a section just because the prose was split into a different\n * number of paragraphs.\n * 2. Only the sections **touched by a changed line** are then re-segmented into\n * fine blocks (paragraphs, code fences) and aligned within the section, so a\n * small edit re-translates only the affected paragraph(s) instead of the\n * whole section. Within a changed section a target block with no base\n * counterpart is **kept as-is** (reused) rather than deleted, so a translation\n * that has extra paragraphs never loses content.\n * When `changedLines` is `undefined` the changed lines are simply unknown, so\n * **every** section is inspected instead of none: aligned blocks are still\n * reused (there is no way to tell which translation went stale), but blocks\n * living on one side only are reported as `insert_new` / `delete`. This is\n * what makes a plain \"compare this document with its translation\" run — one\n * with no git history behind it — report anything at all.\n *\n * Section-level insertions and deletions stay whole: a brand-new section is\n * translated as one unit, and a target section with no base counterpart is\n * reported as `delete` for visibility but never dropped by the merge (see\n * {@link mergeReviewedSegments}), so a review can never lose translated content.\n *\n * @param input - The base/target texts and optional changed lines.\n * @returns The (flattened) blocks, the plan, and the segments that need translation.\n */\nexport const buildAlignmentPlan = ({\n baseText,\n targetText,\n changedLines,\n}: BuildAlignmentPlanInput): BuildAlignmentPlanOutput => {\n // `undefined` means \"which lines changed is unknown\" (no git history to read),\n // which is not the same as \"no line changed\": the former must still compare the\n // two documents, the latter must reuse everything.\n const hasChangedLineInformation = Array.isArray(changedLines);\n const changedLineNumbers = changedLines ?? [];\n\n const baseSections = fingerprintBlockList(segmentSections(baseText));\n const targetSections = fingerprintBlockList(segmentSections(targetText));\n\n const sectionAlignment = alignBaseAndTargetBlocks(\n baseSections,\n targetSections\n );\n const changedSectionIndexes = mapChangedLinesToBlocks(\n baseSections,\n changedLineNumbers\n );\n\n /**\n * Whether a section must be opened and inspected block by block.\n *\n * Without changed-line information every section is inspected, so comparing a\n * document with its translation from scratch still reports the blocks that\n * exist on one side only. With changed lines, only the touched sections are.\n */\n const isSectionToInspect = (sectionIndex: number): boolean =>\n !hasChangedLineInformation || changedSectionIndexes.has(sectionIndex);\n\n // Flattened blocks the plan refers to by index. Reused/deleted/inserted\n // sections contribute their whole-section block; changed sections contribute\n // their fine sub-blocks.\n const baseBlocks: FingerprintedBlock[] = [];\n const targetBlocks: FingerprintedBlock[] = [];\n const actions: PlannedAction[] = [];\n\n const pushBaseBlock = (block: FingerprintedBlock): number =>\n baseBlocks.push(block) - 1;\n const pushTargetBlock = (block: FingerprintedBlock): number =>\n targetBlocks.push(block) - 1;\n\n for (const pair of sectionAlignment) {\n // Section present only in the target → reported as `delete` for visibility,\n // but kept verbatim by the merge (the aligner may simply have failed to\n // follow a reordered section), never silently dropped.\n if (pair.baseIndex === -1 && pair.targetIndex !== null) {\n const targetIndex = pushTargetBlock(targetSections[pair.targetIndex]!);\n actions.push({ kind: 'delete', targetIndex });\n continue;\n }\n\n // Section present only in the base → brand new, translate as one unit.\n if (pair.baseIndex >= 0 && pair.targetIndex === null) {\n const baseIndex = pushBaseBlock(baseSections[pair.baseIndex]!);\n actions.push({ kind: 'insert_new', baseIndex });\n continue;\n }\n\n if (pair.baseIndex < 0 || pair.targetIndex === null) continue;\n\n const baseSection = baseSections[pair.baseIndex]!;\n const targetSection = targetSections[pair.targetIndex]!;\n\n // Unchanged section → reuse the existing translation verbatim.\n if (!isSectionToInspect(pair.baseIndex)) {\n const baseIndex = pushBaseBlock(baseSection);\n const targetIndex = pushTargetBlock(targetSection);\n actions.push({ kind: 'reuse', baseIndex, targetIndex });\n continue;\n }\n\n // Inspected section → align its fine blocks and review only what changed.\n const baseFineBlocks = fingerprintSectionFineBlocks(baseSection);\n const targetFineBlocks = fingerprintSectionFineBlocks(targetSection);\n const fineAlignment = alignBaseAndTargetBlocks(\n baseFineBlocks,\n targetFineBlocks\n );\n const changedFineIndexes = mapChangedLinesToBlocks(\n baseFineBlocks,\n changedLineNumbers\n );\n\n for (const finePair of fineAlignment) {\n // Target-only fine block. Its content is kept either way — `delete` is\n // reported for visibility only and the merge keeps it verbatim (see\n // {@link mergeReviewedSegments}).\n // With changed lines the author's edit is known precisely, so an unmatched\n // target block is most likely the translator's own prose split and stays\n // silent. Without them the whole document is being compared, and such a\n // block is exactly the divergence the report exists to surface.\n if (finePair.baseIndex === -1 && finePair.targetIndex !== null) {\n const targetIndex = pushTargetBlock(\n targetFineBlocks[finePair.targetIndex]!\n );\n actions.push(\n hasChangedLineInformation\n ? { kind: 'reuse', baseIndex: -1, targetIndex }\n : { kind: 'delete', targetIndex }\n );\n continue;\n }\n\n // Base-only fine block: a new paragraph inside the section, translate it.\n if (finePair.baseIndex >= 0 && finePair.targetIndex === null) {\n const baseIndex = pushBaseBlock(baseFineBlocks[finePair.baseIndex]!);\n actions.push({ kind: 'insert_new', baseIndex });\n continue;\n }\n\n if (finePair.baseIndex < 0 || finePair.targetIndex === null) continue;\n\n const baseIndex = pushBaseBlock(baseFineBlocks[finePair.baseIndex]!);\n const targetIndex = pushTargetBlock(\n targetFineBlocks[finePair.targetIndex]!\n );\n\n actions.push(\n changedFineIndexes.has(finePair.baseIndex)\n ? { kind: 'review', baseIndex, targetIndex }\n : { kind: 'reuse', baseIndex, targetIndex }\n );\n }\n }\n\n const plan = { actions };\n\n const { segmentsToReview } = identifySegmentsToReview({\n baseBlocks,\n targetBlocks,\n plan,\n });\n\n return { baseBlocks, targetBlocks, plan, segmentsToReview };\n};\n\nexport type { SegmentToReview };\nexport { mergeReviewedSegments };\n"],"mappings":";;;;;;;;;AAwCA,MAAM,wBAAwB,WAA0C;CAGtE,OAFmB,OAAO,IAAI,cAEd,CAAC,CAAC,KAAK,OAAO,OAAO,UACnC,iBAAiB,OAAO,MAAM,QAAQ,MAAM,MAAM,MAAM,QAAQ,MAAM,IAAI,CAC5E;AACF;;;;;;AAOA,MAAM,gCAAgC,YAAyC;CAC7E,MAAM,aAAa,QAAQ,YAAY;CAEvC,MAAM,aAAa,gBAAgB,QAAQ,OAAO,CAAC,CAAC,KAAK,WAAkB;EACzE,GAAG;EACH,WAAW,MAAM,YAAY;EAC7B,SAAS,MAAM,UAAU;CAC3B,EAAE;CAEF,OAAO,qBAAqB,UAAU;AACxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,sBAAsB,EACjC,UACA,YACA,mBACuD;CAIvD,MAAM,4BAA4B,MAAM,QAAQ,YAAY;CAC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,gBACA,kBACF;EAEA,KAAK,MAAM,YAAY,eAAe;GAQpC,IAAI,SAAS,cAAc,MAAM,SAAS,gBAAgB,MAAM;IAC9D,MAAM,cAAc,gBAClB,iBAAiB,SAAS,YAC5B;IACA,QAAQ,KACN,4BACI;KAAE,MAAM;KAAS,WAAW;KAAI;IAAY,IAC5C;KAAE,MAAM;KAAU;IAAY,CACpC;IACA;GACF;GAGA,IAAI,SAAS,aAAa,KAAK,SAAS,gBAAgB,MAAM;IAC5D,MAAM,YAAY,cAAc,eAAe,SAAS,UAAW;IACnE,QAAQ,KAAK;KAAE,MAAM;KAAc;IAAU,CAAC;IAC9C;GACF;GAEA,IAAI,SAAS,YAAY,KAAK,SAAS,gBAAgB,MAAM;GAE7D,MAAM,YAAY,cAAc,eAAe,SAAS,UAAW;GACnE,MAAM,cAAc,gBAClB,iBAAiB,SAAS,YAC5B;GAEA,QAAQ,KACN,mBAAmB,IAAI,SAAS,SAAS,IACrC;IAAE,MAAM;IAAU;IAAW;GAAY,IACzC;IAAE,MAAM;IAAS;IAAW;GAAY,CAC9C;EACF;CACF;CAEA,MAAM,OAAO,EAAE,QAAQ;CAEvB,MAAM,EAAE,qBAAqB,yBAAyB;EACpD;EACA;EACA;CACF,CAAC;CAED,OAAO;EAAE;EAAY;EAAc;EAAM;CAAiB;AAC5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionaries.mjs","names":[],"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { createIntlayerCMS, type DictionaryAPI } from '@intlayer/api';\nimport { dictionaryEndpoint } from '@intlayer/api/dictionary';\nimport { getAppLogger, x } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { chunkArray, parallelize, retryManager } from '@intlayer/config/utils';\nimport type { DictionariesStatus } from './loadDictionaries';\n\n/**\n * Number of dictionaries requested per HTTP call. Must stay under the batch\n * limit enforced by the backend (`MAX_DICTIONARY_KEYS_PER_REQUEST`).\n */\nconst DEFAULT_DICTIONARIES_PER_REQUEST = 3;\n\n/** Number of batch requests kept in flight at the same time. */\nconst DEFAULT_PARALLEL_REQUESTS = 5;\n\n/** Number of retries performed on a failing batch request. */\nconst DEFAULT_MAX_RETRY = 2;\n\n/** Delay between two attempts of a failing batch request, in milliseconds. */\nconst DEFAULT_RETRY_DELAY = 250;\n\n/** HTTP statuses worth another attempt despite being client errors. */\nconst RETRYABLE_CLIENT_ERROR_STATUSES = new Set([408, 425, 429]);\n\n/**\n * A request is worth retrying when it failed for a reason another attempt could\n * fix: a network error (no status at all) or a server-side / throttling status.\n * Replaying a `404` or a `401` only multiplies the noise.\n */\nconst isRetryableError = (error: unknown): boolean => {\n const status = (error as { status?: number })?.status;\n\n if (typeof status !== 'number') return true;\n\n if (status >= 500) return true;\n\n return RETRYABLE_CLIENT_ERROR_STATUSES.has(status);\n};\n\n/**\n * A backend that predates the batch endpoint routes `/dictionary/by-keys` to\n * its `/dictionary/:dictionaryKey` handler, which answers `404` - either as an\n * unknown dictionary or as an unknown route. Both mean the same thing here:\n * this backend cannot serve batches, so fall back to one request per key.\n */\nconst isBatchEndpointUnsupported = (error: unknown): boolean =>\n (error as { status?: number })?.status === 404;\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n /**\n * Number of dictionaries fetched by a single request.\n * @default 3\n */\n dictionariesPerRequest?: number;\n /**\n * Number of requests kept in flight at the same time.\n * @default 5\n */\n parallelRequests?: number;\n /**\n * Number of retries performed when a batch request fails.\n * @default 2\n */\n maxRetry?: number;\n /**\n * Delay between two attempts of a failing batch request, in milliseconds.\n * @default 250\n */\n retryDelay?: number;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n *\n * Keys are grouped into batches fetched by a single request each, and those\n * requests are kept in flight together — by default 5 concurrent requests of 3\n * dictionaries, so 15 dictionaries travel at any given time. A slot is refilled\n * as soon as its request settles, so no batch waits for the whole wave.\n * Failing requests are retried before their keys are reported as errors.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const dictionary = dictionaryEndpoint(createIntlayerCMS(config));\n\n const {\n dictionariesPerRequest = DEFAULT_DICTIONARIES_PER_REQUEST,\n parallelRequests = DEFAULT_PARALLEL_REQUESTS,\n maxRetry = DEFAULT_MAX_RETRY,\n retryDelay = DEFAULT_RETRY_DELAY,\n } = options;\n\n // A same key can be listed twice when several qualified dictionaries share\n // it - one request per key is enough to retrieve all of its siblings.\n const distantDictionariesKeys = [...new Set(options.dictionaryKeys)];\n\n if (distantDictionariesKeys.length === 0) return [];\n\n const batches = chunkArray(distantDictionariesKeys, dictionariesPerRequest);\n\n // Flipped once for the whole run as soon as a backend proves unable to\n // serve batches, so the remaining batches skip the doomed request.\n let isBatchEndpointSupported = true;\n let hasLoggedBatchFallback = false;\n\n /**\n * Fetch each key of a batch with its own request. Used against backends\n * without the batch endpoint. A key missing on the remote only discards\n * itself, never its neighbours.\n */\n const requestDictionariesOneByOne = async (\n batchKeys: string[]\n ): Promise<DictionaryAPI[]> => {\n const results = await parallelize(\n batchKeys,\n async (dictionaryKey) => {\n try {\n const getDictionaryResult =\n await dictionary.getDictionary(dictionaryKey);\n\n return getDictionaryResult.data;\n } catch (_error) {\n return undefined;\n }\n },\n batchKeys.length\n );\n\n return results.filter(\n (distantDictionary): distantDictionary is DictionaryAPI =>\n distantDictionary !== undefined\n );\n };\n\n /**\n * Request one batch of dictionaries, retrying the whole request when it\n * fails for a transient reason - a batch carries several dictionaries, so\n * a network hiccup would otherwise discard all of them at once.\n */\n const requestBatch = retryManager(\n async (batchKeys: string[]): Promise<DictionaryAPI[]> => {\n if (isBatchEndpointSupported) {\n try {\n const getDictionariesResult =\n await dictionary.getDictionariesByKeys(batchKeys);\n\n return getDictionariesResult.data ?? [];\n } catch (error) {\n if (!isBatchEndpointUnsupported(error)) throw error;\n\n isBatchEndpointSupported = false;\n\n if (!hasLoggedBatchFallback) {\n hasLoggedBatchFallback = true;\n appLogger(\n 'This backend does not provide the batch dictionary endpoint - falling back to one request per dictionary.',\n { level: 'warn' }\n );\n }\n }\n }\n\n return await requestDictionariesOneByOne(batchKeys);\n },\n {\n maxRetry,\n delay: retryDelay,\n shouldRetry: isRetryableError,\n onError: ({ error, attempt }) =>\n appLogger(\n `Retrying distant dictionaries request (attempt ${attempt + 1}/${maxRetry}): ${error}`,\n { level: 'warn' }\n ),\n }\n );\n\n /**\n * Fetch one batch of dictionaries within a single request, and report the\n * resulting status of every key it contains.\n */\n const processBatch = async (\n batchKeys: string[]\n ): Promise<DictionaryAPI[]> => {\n onStatusUpdate?.(\n batchKeys.map((dictionaryKey) => ({\n dictionaryKey,\n type: 'remote',\n status: 'fetching',\n }))\n );\n\n try {\n const distantDictionaries = await requestBatch(batchKeys);\n\n const fetchedKeys = new Set(\n distantDictionaries.map(\n (distantDictionary: DictionaryAPI) => distantDictionary.key\n )\n );\n\n onStatusUpdate?.(\n batchKeys.map(\n (dictionaryKey): DictionariesStatus =>\n fetchedKeys.has(dictionaryKey)\n ? {\n dictionaryKey,\n type: 'remote',\n status: 'fetched',\n }\n : {\n dictionaryKey,\n type: 'remote',\n status: 'error',\n error: `Dictionary ${dictionaryKey} not found on remote`,\n }\n )\n );\n\n return distantDictionaries;\n } catch (error) {\n onStatusUpdate?.(\n batchKeys.map((dictionaryKey) => ({\n dictionaryKey,\n type: 'remote',\n status: 'error',\n error: `Error fetching dictionary ${dictionaryKey}: ${error}`,\n }))\n );\n return [];\n }\n };\n\n const batchResults = await parallelize(\n batches,\n processBatch,\n parallelRequests\n );\n\n return batchResults.flat();\n } catch (_error) {\n appLogger(`${x} Failed to fetch distant dictionaries`, { level: 'error' });\n return [];\n }\n};\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,mCAAmC;;AAGzC,MAAM,4BAA4B;;AAGlC,M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wB;KAC3B,yBAAyB;KACzB,UACE,6GACA,EAAE,OAAO,OAAO,CAClB;IACF;GACF;GAGF,OAAO,MAAM,4BAA4B,SAAS;EACpD,GACA;GACE;GACA,OAAO;GACP,aAAa;GACb,UAAU,EAAE,OAAO,cACjB,UACE,kDAAkD,UAAU,EAAE,GAAG,SAAS,KAAK,SAC/E,EAAE,OAAO,OAAO,CAClB;EACJ,CACF;;;;;EAMA,MAAM,eAAe,OACnB,cAC6B;GAC7B,iBACE,UAAU,KAAK,mBAAmB;IAChC;IACA,MAAM;IACN,QAAQ;GACV,EAAE,CACJ;GAEA,IAAI;IACF,MAAM,sBAAsB,MAAM,aAAa,SAAS;IAExD,MAAM,cAAc,IAAI,IACtB,oBAAoB,KACjB,sBAAqC,kBAAkB,GAC1D,CACF;IAEA,iBACE,UAAU,KACP,kBACC,YAAY,IAAI,aAAa,IACzB;KACE;KACA,MAAM;KACN,QAAQ;IACV,IACA;KACE;KACA,MAAM;KACN,QAAQ;KACR,OAAO,cAAc,cAAc;IACrC,CACR,CACF;IAEA,OAAO;GACT,SAAS,OAAO;IACd,iBACE,UAAU,KAAK,mBAAmB;KAChC;KACA,MAAM;KACN,QAAQ;KACR,OAAO,6BAA6B,cAAc,IAAI;IACxD,EAAE,CACJ;IACA,OAAO,CAAC;GACV;EACF;EAQA,QAAO,MANoB,YACzB,SACA,cACA,gBACF,EAEmB,CAAC,KAAK;CAC3B,SAAS,QAAQ;EACf,UAAU,GAAG,EAAE,wCAAwC,EAAE,OAAO,QAAQ,CAAC;EACzE,OAAO,CAAC;CACV;AACF"}
1
+ {"version":3,"file":"fetchDistantDictionaries.mjs","names":[],"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { createIntlayerCMS, type DictionaryAPI } from '@intlayer/api';\nimport { dictionaryEndpoint } from '@intlayer/api/dictionary';\nimport { getAppLogger, x } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { chunkArray, parallelize, retryManager } from '@intlayer/config/utils';\nimport type { DictionariesStatus } from './loadDictionaries';\n\n/**\n * Number of dictionaries requested per HTTP call. Must stay under the batch\n * limit enforced by the backend (`MAX_DICTIONARY_KEYS_PER_REQUEST`).\n */\nconst DEFAULT_DICTIONARIES_PER_REQUEST = 3;\n\n/** Number of batch requests kept in flight at the same time. */\nconst DEFAULT_PARALLEL_REQUESTS = 5;\n\n/** Number of retries performed on a failing batch request. */\nconst DEFAULT_MAX_RETRY = 2;\n\n/** Delay between two attempts of a failing batch request, in milliseconds. */\nconst DEFAULT_RETRY_DELAY = 250;\n\n/** HTTP statuses worth another attempt despite being client errors. */\nconst RETRYABLE_CLIENT_ERROR_STATUSES = new Set([408, 425, 429]);\n\n/**\n * A request is worth retrying when it failed for a reason another attempt could\n * fix: a network error (no status at all) or a server-side / throttling status.\n * Replaying a `404` or a `401` only multiplies the noise.\n */\nconst isRetryableError = (error: unknown): boolean => {\n const status = (error as { status?: number })?.status;\n\n if (typeof status !== 'number') return true;\n\n if (status >= 500) return true;\n\n return RETRYABLE_CLIENT_ERROR_STATUSES.has(status);\n};\n\n/**\n * A backend that predates the batch endpoint routes `/dictionary/by-keys` to\n * its `/dictionary/:dictionaryKey` handler, which answers `404` - either as an\n * unknown dictionary or as an unknown route. Both mean the same thing here:\n * this backend cannot serve batches, so fall back to one request per key.\n */\nconst isBatchEndpointUnsupported = (error: unknown): boolean =>\n (error as { status?: number })?.status === 404;\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n /**\n * Number of dictionaries fetched by a single request.\n * @default 3\n */\n dictionariesPerRequest?: number;\n /**\n * Number of requests kept in flight at the same time.\n * @default 5\n */\n parallelRequests?: number;\n /**\n * Number of retries performed when a batch request fails.\n * @default 2\n */\n maxRetry?: number;\n /**\n * Delay between two attempts of a failing batch request, in milliseconds.\n * @default 250\n */\n retryDelay?: number;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n *\n * Keys are grouped into batches fetched by a single request each, and those\n * requests are kept in flight together — by default 5 concurrent requests of 3\n * dictionaries, so 15 dictionaries travel at any given time. A slot is refilled\n * as soon as its request settles, so no batch waits for the whole wave.\n * Failing requests are retried before their keys are reported as errors.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const dictionary = dictionaryEndpoint(createIntlayerCMS(config));\n\n const {\n dictionariesPerRequest = DEFAULT_DICTIONARIES_PER_REQUEST,\n parallelRequests = DEFAULT_PARALLEL_REQUESTS,\n maxRetry = DEFAULT_MAX_RETRY,\n retryDelay = DEFAULT_RETRY_DELAY,\n } = options;\n\n // A same key can be listed twice when several qualified dictionaries share\n // it - one request per key is enough to retrieve all of its siblings.\n const distantDictionariesKeys = [...new Set(options.dictionaryKeys)];\n\n if (distantDictionariesKeys.length === 0) return [];\n\n const batches = chunkArray(distantDictionariesKeys, dictionariesPerRequest);\n\n // Flipped once for the whole run as soon as a backend proves unable to\n // serve batches, so the remaining batches skip the doomed request.\n let isBatchEndpointSupported = true;\n let hasLoggedBatchFallback = false;\n\n /**\n * Fetch each key of a batch with its own request. Used against backends\n * without the batch endpoint. A key missing on the remote only discards\n * itself, never its neighbours.\n */\n const requestDictionariesOneByOne = async (\n batchKeys: string[]\n ): Promise<DictionaryAPI[]> => {\n const results = await parallelize(\n batchKeys,\n async (dictionaryKey) => {\n try {\n const getDictionaryResult =\n await dictionary.getDictionary(dictionaryKey);\n\n return getDictionaryResult.data;\n } catch (_error) {\n return undefined;\n }\n },\n batchKeys.length\n );\n\n return results.filter(\n (distantDictionary): distantDictionary is DictionaryAPI =>\n distantDictionary !== undefined\n );\n };\n\n /**\n * Request one batch of dictionaries, retrying the whole request when it\n * fails for a transient reason - a batch carries several dictionaries, so\n * a network hiccup would otherwise discard all of them at once.\n */\n const requestBatch = retryManager(\n async (batchKeys: string[]): Promise<DictionaryAPI[]> => {\n if (isBatchEndpointSupported) {\n try {\n const getDictionariesResult =\n await dictionary.getDictionariesByKeys(batchKeys);\n\n return getDictionariesResult.data ?? [];\n } catch (error) {\n if (!isBatchEndpointUnsupported(error)) throw error;\n\n isBatchEndpointSupported = false;\n\n if (!hasLoggedBatchFallback) {\n hasLoggedBatchFallback = true;\n appLogger(\n 'This backend does not provide the batch dictionary endpoint - falling back to one request per dictionary.',\n { level: 'warn' }\n );\n }\n }\n }\n\n return await requestDictionariesOneByOne(batchKeys);\n },\n {\n maxRetry,\n delay: retryDelay,\n shouldRetry: isRetryableError,\n onError: ({ error, attempt }) =>\n appLogger(\n `Retrying distant dictionaries request (attempt ${attempt + 1}/${maxRetry}): ${error}`,\n { level: 'warn' }\n ),\n }\n );\n\n /**\n * Fetch one batch of dictionaries within a single request, and report the\n * resulting status of every key it contains.\n */\n const processBatch = async (\n batchKeys: string[]\n ): Promise<DictionaryAPI[]> => {\n onStatusUpdate?.(\n batchKeys.map((dictionaryKey) => ({\n dictionaryKey,\n type: 'remote',\n status: 'fetching',\n }))\n );\n\n try {\n const distantDictionaries = await requestBatch(batchKeys);\n\n const fetchedKeys = new Set(\n distantDictionaries.map(\n (distantDictionary: DictionaryAPI) => distantDictionary.key\n )\n );\n\n onStatusUpdate?.(\n batchKeys.map((dictionaryKey): DictionariesStatus =>\n fetchedKeys.has(dictionaryKey)\n ? {\n dictionaryKey,\n type: 'remote',\n status: 'fetched',\n }\n : {\n dictionaryKey,\n type: 'remote',\n status: 'error',\n error: `Dictionary ${dictionaryKey} not found on remote`,\n }\n )\n );\n\n return distantDictionaries;\n } catch (error) {\n onStatusUpdate?.(\n batchKeys.map((dictionaryKey) => ({\n dictionaryKey,\n type: 'remote',\n status: 'error',\n error: `Error fetching dictionary ${dictionaryKey}: ${error}`,\n }))\n );\n return [];\n }\n };\n\n const batchResults = await parallelize(\n batches,\n processBatch,\n parallelRequests\n );\n\n return batchResults.flat();\n } catch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AsB,SAAS,EAEtB,CAAC,QAAQ,CAAC;GACxC,SAAS,OAAO;IACd,IAAI,CAAC,2BAA2B,KAAK,GAAG,MAAM;IAE9C,2BAA2B;IAE3B,IAAI,CAAC,wBAAwB;KAC3B,yBAAyB;KACzB,UACE,6GACA,EAAE,OAAO,OAAO,CAClB;IACF;GACF;GAGF,OAAO,MAAM,4BAA4B,SAAS;EACpD,GACA;GACE;GACA,OAAO;GACP,aAAa;GACb,UAAU,EAAE,OAAO,cACjB,UACE,kDAAkD,UAAU,EAAE,GAAG,SAAS,KAAK,SAC/E,EAAE,OAAO,OAAO,CAClB;EACJ,CACF;;;;;EAMA,MAAM,eAAe,OACnB,cAC6B;GAC7B,iBACE,UAAU,KAAK,mBAAmB;IAChC;IACA,MAAM;IACN,QAAQ;GACV,EAAE,CACJ;GAEA,IAAI;IACF,MAAM,sBAAsB,MAAM,aAAa,SAAS;IAExD,MAAM,cAAc,IAAI,IACtB,oBAAoB,KACjB,sBAAqC,kBAAkB,GAC1D,CACF;IAEA,iBACE,UAAU,KAAK,kBACb,YAAY,IAAI,aAAa,IACzB;KACE;KACA,MAAM;KACN,QAAQ;IACV,IACA;KACE;KACA,MAAM;KACN,QAAQ;KACR,OAAO,cAAc,cAAc;IACrC,CACN,CACF;IAEA,OAAO;GACT,SAAS,OAAO;IACd,iBACE,UAAU,KAAK,mBAAmB;KAChC;KACA,MAAM;KACN,QAAQ;KACR,OAAO,6BAA6B,cAAc,IAAI;IACxD,EAAE,CACJ;IACA,OAAO,CAAC;GACV;EACF;EAQA,QAAO,MANoB,YACzB,SACA,cACA,gBACF,EAEmB,CAAC,KAAK;CAC3B,SAAS,QAAQ;EACf,UAAU,GAAG,EAAE,wCAAwC,EAAE,OAAO,QAAQ,CAAC;EACzE,OAAO,CAAC;CACV;AACF"}
@@ -7,9 +7,9 @@ import { createModuleAugmentation } from "./createType/createModuleAugmentation.
7
7
  import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.mjs";
8
8
  import { formatPath } from "./utils/formatter.mjs";
9
9
  import { getAppLogger } from "@intlayer/config/logger";
10
- import { readFile, writeFile } from "node:fs/promises";
11
- import { join, relative } from "node:path";
12
10
  import { existsSync } from "node:fs";
11
+ import { join, relative } from "node:path";
12
+ import { readFile, writeFile } from "node:fs/promises";
13
13
 
14
14
  // src/handleContentDeclarationFileChange.ts
15
15
  /**
@@ -47,6 +47,7 @@ const DocumentationRouter = {
47
47
  Default: "https://intlayer.org/doc/get-started",
48
48
  LSP: "https://intlayer.org/doc/lsp",
49
49
  ESLint: "https://intlayer.org/doc/eslint",
50
+ Prettier: "https://intlayer.org/doc/prettier",
50
51
  NextIntl: "https://intlayer.org/doc/next-intl",
51
52
  NextI18Next: "https://intlayer.org/doc/next-i18next",
52
53
  ReactI18Next: "https://intlayer.org/doc/compatibility/react-i18next",
@@ -1 +1 @@
1
- {"version":3,"file":"documentationRouter.mjs","names":[],"sources":["../../../src/init/documentationRouter.ts"],"sourcesContent":["/**\n * Documentation URL Constants\n */\nexport const DocumentationRouter = {\n NextJS: 'https://intlayer.org/doc/environment/nextjs',\n NextJS_16: 'https://intlayer.org/doc/environment/nextjs',\n NextJS_15: 'https://intlayer.org/doc/environment/nextjs/15',\n NextJS_14: 'https://intlayer.org/doc/environment/nextjs/14',\n NextJS_PageRouter:\n 'https://intlayer.org/doc/environment/nextjs/next-with-page-router',\n CRA: 'https://intlayer.org/doc/environment/create-react-app',\n Astro: 'https://intlayer.org/doc/environment/astro',\n Astro_Lit: 'https://intlayer.org/doc/environment/astro/lit',\n Astro_Preact: 'https://intlayer.org/doc/environment/astro/preact',\n Astro_React: 'https://intlayer.org/doc/environment/astro/react',\n Astro_Solid: 'https://intlayer.org/doc/environment/astro/solid',\n Astro_Svelte: 'https://intlayer.org/doc/environment/astro/svelte',\n Astro_Vue: 'https://intlayer.org/doc/environment/astro/vue',\n ViteAndReact: 'https://intlayer.org/doc/environment/vite-and-react',\n ViteAndReact_ReactRouterV7:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7',\n ViteAndVue: 'https://intlayer.org/doc/environment/vite-and-vue',\n ViteAndSolid: 'https://intlayer.org/doc/environment/vite-and-solid',\n ViteAndSvelte: 'https://intlayer.org/doc/environment/vite-and-svelte',\n ViteAndPreact: 'https://intlayer.org/doc/environment/vite-and-preact',\n ViteAndLit: 'https://intlayer.org/doc/environment/vite-and-lit',\n ViteAndVanilla: 'https://intlayer.org/doc/environment/vite-and-vanilla',\n Vanilla: 'https://intlayer.org/doc/environment/vanilla',\n TanStackRouter: 'https://intlayer.org/doc/environment/tanstack-start',\n TanStackRouterAndSolid:\n 'https://intlayer.org/doc/environment/tanstack-start/solid',\n SolidStart: 'https://intlayer.org/doc/environment/solid-start',\n Analog: 'https://intlayer.org/doc/environment/analog',\n Remix: 'https://intlayer.org/doc/environment/remix-3',\n NuxtAndVue: 'https://intlayer.org/doc/environment/nuxt-and-vue',\n Angular: 'https://intlayer.org/doc/environment/angular',\n Angular_19: 'https://intlayer.org/doc/environment/angular/19',\n SvelteKit: 'https://intlayer.org/doc/environment/sveltekit',\n ReactNativeAndExpo:\n 'https://intlayer.org/doc/environment/react-native-and-expo',\n Lynx: 'https://intlayer.org/doc/environment/lynx-and-react',\n HTMX: 'https://intlayer.org/doc/environment/htmx',\n Storybook: 'https://intlayer.org/doc/storybook',\n Express: 'https://intlayer.org/doc/environment/express',\n NestJS: 'https://intlayer.org/doc/environment/nest',\n Fastify: 'https://intlayer.org/doc/environment/fastify',\n Hono: 'https://intlayer.org/doc/environment/hono',\n AdonisJS: 'https://intlayer.org/doc/environment/adonisjs',\n Elysia: 'https://intlayer.org/doc/environment/elysia',\n Default: 'https://intlayer.org/doc/get-started',\n\n // Intlayer Language Server (Go-to-Definition from getter keys to .content files)\n LSP: 'https://intlayer.org/doc/lsp',\n\n // Lint rules for hardcoded text and non-optimizable dynamic calls\n ESLint: 'https://intlayer.org/doc/eslint',\n\n // Competitor / Compat libs\n NextIntl: 'https://intlayer.org/doc/next-intl',\n NextI18Next: 'https://intlayer.org/doc/next-i18next',\n ReactI18Next: 'https://intlayer.org/doc/compatibility/react-i18next',\n ReactIntl: 'https://intlayer.org/doc/compatibility/react-intl',\n VueI18n: 'https://intlayer.org/doc/compatibility/vue-i18n',\n NuxtI18n: 'https://intlayer.org/doc/compatibility/nuxtjs-i18n',\n I18next: 'https://intlayer.org/doc/compatibility/i18next',\n};\n\nexport type DocumentationRouterType = typeof DocumentationRouter;\n\n/**\n * Helper: Detects the environment and returns the doc URL\n */\nexport const getDocumentationUrl = (packageJson: any): string => {\n const deps = {\n ...packageJson?.dependencies,\n ...packageJson?.devDependencies,\n };\n\n /**\n * Helper to check if a version string matches a specific major version\n * Matches: \"15\", \"^15.0.0\", \"~15.2\", \"15.0.0-beta\"\n */\n const isVersion = (versionString: string, major: number): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const regex = new RegExp(`^[\\\\^~]?${major}(?:\\\\.|$)`);\n return regex.test(versionString);\n };\n\n // Mobile / Cross-platform\n if (deps['@lynx-js/react'] || deps['@lynx-js/core']) {\n return DocumentationRouter.Lynx;\n }\n if (deps['react-native'] || deps.expo) {\n return DocumentationRouter.ReactNativeAndExpo;\n }\n\n // Meta-frameworks (Next, Nuxt, Astro, SvelteKit)\n if (deps.next) {\n const version = deps.next;\n\n if (isVersion(version, 14)) {\n return DocumentationRouter.NextJS_14;\n }\n\n if (isVersion(version, 15)) {\n return DocumentationRouter.NextJS_15;\n }\n\n return DocumentationRouter.NextJS;\n }\n\n if (deps.nuxt) return DocumentationRouter.NuxtAndVue;\n\n if (deps.astro) {\n if (deps['@astrojs/react'] || deps.react)\n return DocumentationRouter.Astro_React;\n if (deps['@astrojs/vue'] || deps.vue) return DocumentationRouter.Astro_Vue;\n if (deps['@astrojs/svelte'] || deps.svelte)\n return DocumentationRouter.Astro_Svelte;\n if (deps['@astrojs/solid-js'] || deps['solid-js'])\n return DocumentationRouter.Astro_Solid;\n if (deps['@astrojs/preact'] || deps.preact)\n return DocumentationRouter.Astro_Preact;\n if (deps['@astrojs/lit'] || deps.lit) return DocumentationRouter.Astro_Lit;\n\n return DocumentationRouter.Astro;\n }\n\n if (deps['@sveltejs/kit']) return DocumentationRouter.SvelteKit;\n if (deps['@analogjs/platform']) return DocumentationRouter.Analog;\n if (deps['@solidjs/start']) return DocumentationRouter.SolidStart;\n if (deps.remix || deps['remix-intlayer']) return DocumentationRouter.Remix;\n\n // Routers (TanStack & React Router v7)\n if (deps['@tanstack/react-router']) {\n return DocumentationRouter.TanStackRouter;\n }\n if (deps['@tanstack/solid-router']) {\n return DocumentationRouter.TanStackRouterAndSolid;\n }\n if (deps['@tanstack/start']) {\n if (deps['solid-js'] || deps['@tanstack/solid-router']) {\n return DocumentationRouter.TanStackRouterAndSolid;\n }\n return DocumentationRouter.TanStackRouter;\n }\n\n // Check for React Router v7 (the guide covers both config and FS routes)\n const reactRouterVersion = deps['react-router'];\n if (\n typeof reactRouterVersion === 'string' &&\n (deps['@react-router/fs-routes'] || isVersion(reactRouterVersion, 7))\n ) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7;\n }\n\n // Vite Ecosystem (General)\n if (deps.vite) {\n if (deps.vue) return DocumentationRouter.ViteAndVue;\n if (deps['solid-js']) return DocumentationRouter.ViteAndSolid;\n if (deps.svelte) return DocumentationRouter.ViteAndSvelte;\n if (deps.preact) return DocumentationRouter.ViteAndPreact;\n if (deps.lit) return DocumentationRouter.ViteAndLit;\n if (deps['vanilla-intlayer']) return DocumentationRouter.ViteAndVanilla;\n\n // Default to React if Vite is present but specific other frameworks aren't found\n return DocumentationRouter.ViteAndReact;\n }\n\n // Other Web Frameworks\n if (deps['react-scripts']) return DocumentationRouter.CRA;\n if (deps['@angular/core']) {\n const version = deps['@angular/core'];\n if (isVersion(version, 19)) {\n return DocumentationRouter.Angular_19;\n }\n return DocumentationRouter.Angular;\n }\n if (deps.lit) return DocumentationRouter.ViteAndLit;\n if (deps['vanilla-intlayer']) return DocumentationRouter.Vanilla;\n if (deps.htmx || deps['htmx.org']) return DocumentationRouter.HTMX;\n if (deps.storybook || deps['@storybook/react'] || deps['@storybook/vue3'])\n return DocumentationRouter.Storybook;\n\n // Backend\n // NestJS first: it runs on top of Express (or Fastify), so both dependencies\n // are present and the more specific one has to win.\n if (deps['@nestjs/core']) return DocumentationRouter.NestJS;\n if (deps['@adonisjs/core']) return DocumentationRouter.AdonisJS;\n if (deps.elysia) return DocumentationRouter.Elysia;\n if (deps.hono) return DocumentationRouter.Hono;\n if (deps.express) return DocumentationRouter.Express;\n if (deps.fastify) return DocumentationRouter.Fastify;\n\n // Competitor Libs (Migration Guides)\n // We check these last as specific environment setup is usually higher priority,\n // but if no specific framework logic matched (or as a fallback), we guide to migration.\n if (deps['next-intl']) return DocumentationRouter.NextIntl;\n if (deps['react-i18next'] || deps.i18next)\n return DocumentationRouter.ReactI18Next;\n if (deps['react-intl']) return DocumentationRouter.ReactIntl;\n if (deps['next-i18next']) return DocumentationRouter.NextI18Next;\n if (deps['vue-i18n']) return DocumentationRouter.VueI18n;\n\n return DocumentationRouter.Default;\n};\n"],"mappings":";;;;AAGA,MAAa,sBAAsB;CACjC,QAAQ;CACR,WAAW;CACX,WAAW;CACX,WAAW;CACX,mBACE;CACF,KAAK;CACL,OAAO;CACP,WAAW;CACX,cAAc;CACd,aAAa;CACb,aAAa;CACb,cAAc;CACd,WAAW;CACX,cAAc;CACd,4BACE;CACF,YAAY;CACZ,cAAc;CACd,eAAe;CACf,eAAe;CACf,YAAY;CACZ,gBAAgB;CAChB,SAAS;CACT,gBAAgB;CAChB,wBACE;CACF,YAAY;CACZ,QAAQ;CACR,OAAO;CACP,YAAY;CACZ,SAAS;CACT,YAAY;CACZ,WAAW;CACX,oBACE;CACF,MAAM;CACN,MAAM;CACN,WAAW;CACX,SAAS;CACT,QAAQ;CACR,SAAS;CACT,MAAM;CACN,UAAU;CACV,QAAQ;CACR,SAAS;CAGT,KAAK;CAGL,QAAQ;CAGR,UAAU;CACV,aAAa;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oB,KAAK,SAChC,OAAO,oBAAoB;CAC7B,IAAI,KAAK,eAAe,OAAO,oBAAoB;CACnD,IAAI,KAAK,iBAAiB,OAAO,oBAAoB;CACrD,IAAI,KAAK,aAAa,OAAO,oBAAoB;CAEjD,OAAO,oBAAoB;AAC7B"}
1
+ {"version":3,"file":"documentationRouter.mjs","names":[],"sources":["../../../src/init/documentationRouter.ts"],"sourcesContent":["/**\n * Documentation URL Constants\n */\nexport const DocumentationRouter = {\n NextJS: 'https://intlayer.org/doc/environment/nextjs',\n NextJS_16: 'https://intlayer.org/doc/environment/nextjs',\n NextJS_15: 'https://intlayer.org/doc/environment/nextjs/15',\n NextJS_14: 'https://intlayer.org/doc/environment/nextjs/14',\n NextJS_PageRouter:\n 'https://intlayer.org/doc/environment/nextjs/next-with-page-router',\n CRA: 'https://intlayer.org/doc/environment/create-react-app',\n Astro: 'https://intlayer.org/doc/environment/astro',\n Astro_Lit: 'https://intlayer.org/doc/environment/astro/lit',\n Astro_Preact: 'https://intlayer.org/doc/environment/astro/preact',\n Astro_React: 'https://intlayer.org/doc/environment/astro/react',\n Astro_Solid: 'https://intlayer.org/doc/environment/astro/solid',\n Astro_Svelte: 'https://intlayer.org/doc/environment/astro/svelte',\n Astro_Vue: 'https://intlayer.org/doc/environment/astro/vue',\n ViteAndReact: 'https://intlayer.org/doc/environment/vite-and-react',\n ViteAndReact_ReactRouterV7:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7',\n ViteAndVue: 'https://intlayer.org/doc/environment/vite-and-vue',\n ViteAndSolid: 'https://intlayer.org/doc/environment/vite-and-solid',\n ViteAndSvelte: 'https://intlayer.org/doc/environment/vite-and-svelte',\n ViteAndPreact: 'https://intlayer.org/doc/environment/vite-and-preact',\n ViteAndLit: 'https://intlayer.org/doc/environment/vite-and-lit',\n ViteAndVanilla: 'https://intlayer.org/doc/environment/vite-and-vanilla',\n Vanilla: 'https://intlayer.org/doc/environment/vanilla',\n TanStackRouter: 'https://intlayer.org/doc/environment/tanstack-start',\n TanStackRouterAndSolid:\n 'https://intlayer.org/doc/environment/tanstack-start/solid',\n SolidStart: 'https://intlayer.org/doc/environment/solid-start',\n Analog: 'https://intlayer.org/doc/environment/analog',\n Remix: 'https://intlayer.org/doc/environment/remix-3',\n NuxtAndVue: 'https://intlayer.org/doc/environment/nuxt-and-vue',\n Angular: 'https://intlayer.org/doc/environment/angular',\n Angular_19: 'https://intlayer.org/doc/environment/angular/19',\n SvelteKit: 'https://intlayer.org/doc/environment/sveltekit',\n ReactNativeAndExpo:\n 'https://intlayer.org/doc/environment/react-native-and-expo',\n Lynx: 'https://intlayer.org/doc/environment/lynx-and-react',\n HTMX: 'https://intlayer.org/doc/environment/htmx',\n Storybook: 'https://intlayer.org/doc/storybook',\n Express: 'https://intlayer.org/doc/environment/express',\n NestJS: 'https://intlayer.org/doc/environment/nest',\n Fastify: 'https://intlayer.org/doc/environment/fastify',\n Hono: 'https://intlayer.org/doc/environment/hono',\n AdonisJS: 'https://intlayer.org/doc/environment/adonisjs',\n Elysia: 'https://intlayer.org/doc/environment/elysia',\n Default: 'https://intlayer.org/doc/get-started',\n\n // Intlayer Language Server (Go-to-Definition from getter keys to .content files)\n LSP: 'https://intlayer.org/doc/lsp',\n\n // Lint rules for hardcoded text and non-optimizable dynamic calls\n ESLint: 'https://intlayer.org/doc/eslint',\n Prettier: 'https://intlayer.org/doc/prettier',\n\n // Competitor / Compat libs\n NextIntl: 'https://intlayer.org/doc/next-intl',\n NextI18Next: 'https://intlayer.org/doc/next-i18next',\n ReactI18Next: 'https://intlayer.org/doc/compatibility/react-i18next',\n ReactIntl: 'https://intlayer.org/doc/compatibility/react-intl',\n VueI18n: 'https://intlayer.org/doc/compatibility/vue-i18n',\n NuxtI18n: 'https://intlayer.org/doc/compatibility/nuxtjs-i18n',\n I18next: 'https://intlayer.org/doc/compatibility/i18next',\n};\n\nexport type DocumentationRouterType = typeof DocumentationRouter;\n\n/**\n * Helper: Detects the environment and returns the doc URL\n */\nexport const getDocumentationUrl = (packageJson: any): string => {\n const deps = {\n ...packageJson?.dependencies,\n ...packageJson?.devDependencies,\n };\n\n /**\n * Helper to check if a version string matches a specific major version\n * Matches: \"15\", \"^15.0.0\", \"~15.2\", \"15.0.0-beta\"\n */\n const isVersion = (versionString: string, major: number): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const regex = new RegExp(`^[\\\\^~]?${major}(?:\\\\.|$)`);\n return regex.test(versionString);\n };\n\n // Mobile / Cross-platform\n if (deps['@lynx-js/react'] || deps['@lynx-js/core']) {\n return DocumentationRouter.Lynx;\n }\n if (deps['react-native'] || deps.expo) {\n return DocumentationRouter.ReactNativeAndExpo;\n }\n\n // Meta-frameworks (Next, Nuxt, Astro, SvelteKit)\n if (deps.next) {\n const version = deps.next;\n\n if (isVersion(version, 14)) {\n return DocumentationRouter.NextJS_14;\n }\n\n if (isVersion(version, 15)) {\n return DocumentationRouter.NextJS_15;\n }\n\n return DocumentationRouter.NextJS;\n }\n\n if (deps.nuxt) return DocumentationRouter.NuxtAndVue;\n\n if (deps.astro) {\n if (deps['@astrojs/react'] || deps.react)\n return DocumentationRouter.Astro_React;\n if (deps['@astrojs/vue'] || deps.vue) return DocumentationRouter.Astro_Vue;\n if (deps['@astrojs/svelte'] || deps.svelte)\n return DocumentationRouter.Astro_Svelte;\n if (deps['@astrojs/solid-js'] || deps['solid-js'])\n return DocumentationRouter.Astro_Solid;\n if (deps['@astrojs/preact'] || deps.preact)\n return DocumentationRouter.Astro_Preact;\n if (deps['@astrojs/lit'] || deps.lit) return DocumentationRouter.Astro_Lit;\n\n return DocumentationRouter.Astro;\n }\n\n if (deps['@sveltejs/kit']) return DocumentationRouter.SvelteKit;\n if (deps['@analogjs/platform']) return DocumentationRouter.Analog;\n if (deps['@solidjs/start']) return DocumentationRouter.SolidStart;\n if (deps.remix || deps['remix-intlayer']) return DocumentationRouter.Remix;\n\n // Routers (TanStack & React Router v7)\n if (deps['@tanstack/react-router']) {\n return DocumentationRouter.TanStackRouter;\n }\n if (deps['@tanstack/solid-router']) {\n return DocumentationRouter.TanStackRouterAndSolid;\n }\n if (deps['@tanstack/start']) {\n if (deps['solid-js'] || deps['@tanstack/solid-router']) {\n return DocumentationRouter.TanStackRouterAndSolid;\n }\n return DocumentationRouter.TanStackRouter;\n }\n\n // Check for React Router v7 (the guide covers both config and FS routes)\n const reactRouterVersion = deps['react-router'];\n if (\n typeof reactRouterVersion === 'string' &&\n (deps['@react-router/fs-routes'] || isVersion(reactRouterVersion, 7))\n ) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7;\n }\n\n // Vite Ecosystem (General)\n if (deps.vite) {\n if (deps.vue) return DocumentationRouter.ViteAndVue;\n if (deps['solid-js']) return DocumentationRouter.ViteAndSolid;\n if (deps.svelte) return DocumentationRouter.ViteAndSvelte;\n if (deps.preact) return DocumentationRouter.ViteAndPreact;\n if (deps.lit) return DocumentationRouter.ViteAndLit;\n if (deps['vanilla-intlayer']) return DocumentationRouter.ViteAndVanilla;\n\n // Default to React if Vite is present but specific other frameworks aren't found\n return DocumentationRouter.ViteAndReact;\n }\n\n // Other Web Frameworks\n if (deps['react-scripts']) return DocumentationRouter.CRA;\n if (deps['@angular/core']) {\n const version = deps['@angular/core'];\n if (isVersion(version, 19)) {\n return DocumentationRouter.Angular_19;\n }\n return DocumentationRouter.Angular;\n }\n if (deps.lit) return DocumentationRouter.ViteAndLit;\n if (deps['vanilla-intlayer']) return DocumentationRouter.Vanilla;\n if (deps.htmx || deps['htmx.org']) return DocumentationRouter.HTMX;\n if (deps.storybook || deps['@storybook/react'] || deps['@storybook/vue3'])\n return DocumentationRouter.Storybook;\n\n // Backend\n // NestJS first: it runs on top of Express (or Fastify), so both dependencies\n // are present and the more specific one has to win.\n if (deps['@nestjs/core']) return DocumentationRouter.NestJS;\n if (deps['@adonisjs/core']) return DocumentationRouter.AdonisJS;\n if (deps.elysia) return DocumentationRouter.Elysia;\n if (deps.hono) return DocumentationRouter.Hono;\n if (deps.express) return DocumentationRouter.Express;\n if (deps.fastify) return DocumentationRouter.Fastify;\n\n // Competitor Libs (Migration Guides)\n // We check these last as specific environment setup is usually higher priority,\n // but if no specific framework logic matched (or as a fallback), we guide to migration.\n if (deps['next-intl']) return DocumentationRouter.NextIntl;\n if (deps['react-i18next'] || deps.i18next)\n return DocumentationRouter.ReactI18Next;\n if (deps['react-intl']) return DocumentationRouter.ReactIntl;\n if (deps['next-i18next']) return DocumentationRouter.NextI18Next;\n if (deps['vue-i18n']) return DocumentationRouter.VueI18n;\n\n return DocumentationRouter.Default;\n};\n"],"mappings":";;;;AAGA,MAAa,sBAAsB;CACjC,QAAQ;CACR,WAAW;CACX,WAAW;CACX,WAAW;CACX,mBACE;CACF,KAAK;CACL,OAAO;CACP,WAAW;CACX,cAAc;CACd,aAAa;CACb,aAAa;CACb,cAAc;CACd,WAAW;CACX,cAAc;CACd,4BACE;CACF,YAAY;CACZ,cAAc;CACd,eAAe;CACf,eAAe;CACf,YAAY;CACZ,gBAAgB;CAChB,SAAS;CACT,gBAAgB;CAChB,wBACE;CACF,YAAY;CACZ,QAAQ;CACR,OAAO;CACP,YAAY;CACZ,SAAS;CACT,YAAY;CACZ,WAAW;CACX,oBACE;CACF,MAAM;CACN,MAAM;CACN,WAAW;CACX,SAAS;CACT,QAAQ;CACR,SAAS;CACT,MAAM;CACN,UAAU;CACV,QAAQ;CACR,SAAS;CAGT,KAAK;CAGL,QAAQ;CACR,UAAU;CAGV,UAAU;CACV,aAAa;CACb,cAAc;CACd,WAAW;CACX,SAAS;CACT,UAAU;CACV,SAAS;AACX;;;;AAOA,MAAa,uBAAuB,gBAA6B;CAC/D,MAAM,OAAO;EACX,GAAG,aAAa;EAChB,GAAG,aAAa;CAClB;;;;;CAMA,MAAM,aAAa,eAAuB,UAA2B;EACnE,IAAI,CAAC,iBAAiB,OAAO,kBAAkB,UAAU,OAAO;EAEhE,OAAO,IADW,OAAO,WAAW,MAAM,UAC/B,CAAC,CAAC,KAAK,aAAa;CAC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ALE_PAGE_TEMPLATE_JS, LOCALE_PAGE_TEMPLATE_TS, MIDDLEWARE_TEMPLATE, PROXY_TEMPLATE, ROOT_LAYOUT_TEMPLATE_JS, ROOT_LAYOUT_TEMPLATE_TS, UNPREFIXED_PAGE_TEMPLATE, UNPREFIXED_ROOT_LAYOUT_TEMPLATE_JS, UNPREFIXED_ROOT_LAYOUT_TEMPLATE_TS } from "./templates.mjs";
7
7
  import { wrapLayoutWithProvider } from "./transforms.mjs";
8
8
  import { colorize, colorizePath, logger, v, x } from "@intlayer/config/logger";
9
- import { readdir } from "node:fs/promises";
10
9
  import { join } from "node:path";
10
+ import { readdir } from "node:fs/promises";
11
11
  import * as ANSIColors from "@intlayer/config/colors";
12
12
 
13
13
  // src/init/frameworkSetup/nextAppRouter/index.ts
@@ -1,6 +1,6 @@
1
1
  import { babelTsParser } from "../../../utils/babelParser.mjs";
2
- import { mkdir, readFile, readdir, rename, writeFile } from "node:fs/promises";
3
2
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
3
+ import { mkdir, readFile, readdir, rename, writeFile } from "node:fs/promises";
4
4
  import fg from "fast-glob";
5
5
  import * as recast from "recast";
6
6
 
@@ -6,8 +6,8 @@ import { getLocaleSegment, isLocaleSegment, restructureRoutesIntoLocale } from "
6
6
  import { UNPREFIXED_ROOT_TEMPLATE_JS, UNPREFIXED_ROOT_TEMPLATE_TS, buildLocaleRouteTemplate, buildRootTemplateJs, buildRootTemplateTs } from "./templates.mjs";
7
7
  import { wrapRootWithProvider, wrapRootWithRequestLocaleProvider } from "./transforms.mjs";
8
8
  import { colorize, colorizePath, logger, v, x } from "@intlayer/config/logger";
9
- import { readdir } from "node:fs/promises";
10
9
  import { join } from "node:path";
10
+ import { readdir } from "node:fs/promises";
11
11
  import * as ANSIColors from "@intlayer/config/colors";
12
12
 
13
13
  // src/init/frameworkSetup/tanstackStart/index.ts
@@ -1,6 +1,6 @@
1
1
  import { rewriteRelativeImports } from "../nextAppRouter/restructure.mjs";
2
- import { mkdir, readFile, readdir, rename, writeFile } from "node:fs/promises";
3
2
  import { join, relative } from "node:path";
3
+ import { mkdir, readFile, readdir, rename, writeFile } from "node:fs/promises";
4
4
  import fg from "fast-glob";
5
5
 
6
6
  // src/init/frameworkSetup/tanstackStart/restructure.ts
@@ -3,6 +3,7 @@ import { setCompilerOutputInConfig, setDictionaryLocaleInConfig, setEnableProxyI
3
3
  import { DocumentationRouter, getDocumentationUrl } from "./documentationRouter.mjs";
4
4
  import { setupFramework } from "./frameworkSetup/index.mjs";
5
5
  import { upgradeIntlayerPackages } from "./upgradeIntlayerPackages.mjs";
6
+ import { JSON_PRETTIER_CONFIG_FILES, PRETTIER_PLUGIN_PACKAGE_NAME, addIntlayerPluginToPrettierConfig, hasPrettier } from "./utils/prettierConfig.mjs";
6
7
  import { LINT_PLUGIN_PACKAGE_NAME, addIntlayerRulesToOxlintConfig } from "./utils/lintConfig.mjs";
7
8
  import { BACKEND_INTLAYER_PACKAGES } from "./utils/backendPackages.mjs";
8
9
  import { MINIMUM_ESLINT_MAJOR, detectCompatI18nLibraries, detectMissingIntlayerPackages, detectPackageManager, hasLegacyEslint, hasLintTooling, installPackages, isIntlayerPackageName, moveCompatPackagesToDevDependencies } from "./utils/packageManager.mjs";
@@ -15,10 +16,10 @@ import { parseJSONWithComments } from "./utils/jsonParser.mjs";
15
16
  import { setupNextCompilerBabelConfig } from "./utils/nextCompilerBabel.mjs";
16
17
  import { getContentLayoutSetup } from "./utils/contentLayout.mjs";
17
18
  import { colorize, colorizePath, logger, v, x } from "@intlayer/config/logger";
19
+ import { ROUTING_MODE } from "@intlayer/config/defaultValues";
18
20
  import { join } from "node:path";
19
- import * as ANSIColors from "@intlayer/config/colors";
20
21
  import { getAlias } from "@intlayer/config/utils";
21
- import { ROUTING_MODE } from "@intlayer/config/defaultValues";
22
+ import * as ANSIColors from "@intlayer/config/colors";
22
23
  import { getConfiguration } from "@intlayer/config/node";
23
24
 
24
25
  // src/init/index.ts
@@ -39,6 +40,47 @@ const getDefaultApplicationURL = (dependencies) => {
39
40
  return "http://localhost:3000";
40
41
  };
41
42
  /**
43
+ * Installs `prettier-plugin-intlayer` (when the package step is skipped) and
44
+ * registers it in the first JSON Prettier config found: `.prettierrc.json`, a
45
+ * JSON `.prettierrc`, or the `prettier` field of `package.json`. Any other
46
+ * config format gets the snippet printed instead.
47
+ */
48
+ const setupPrettierPlugin = async (rootDir, allDependencies, packageManager, options) => {
49
+ const pluginName = colorize(PRETTIER_PLUGIN_PACKAGE_NAME, ANSIColors.MAGENTA);
50
+ if (options?.noInstallPackages && !allDependencies["prettier-plugin-intlayer"]) {
51
+ const pluginSpecifier = options.upgradeToVersion ? `${PRETTIER_PLUGIN_PACKAGE_NAME}@${options.upgradeToVersion}` : PRETTIER_PLUGIN_PACKAGE_NAME;
52
+ try {
53
+ installPackages(rootDir, [pluginSpecifier], packageManager, true);
54
+ logger(`${v} Installed: ${pluginName}`);
55
+ } catch {
56
+ logger(`${x} Failed to install ${PRETTIER_PLUGIN_PACKAGE_NAME}. Please install it manually.`, { level: "warn" });
57
+ }
58
+ }
59
+ /** Patches one JSON config; `undefined` when it is missing or not JSON. */
60
+ const patchJsonConfig = async (configPath, selectConfig) => {
61
+ if (!await exists(rootDir, configPath)) return void 0;
62
+ try {
63
+ const fileContent = parseJSONWithComments(await readFileFromRoot(rootDir, configPath));
64
+ const prettierConfig = selectConfig(fileContent);
65
+ if (typeof prettierConfig !== "object" || prettierConfig === null) return;
66
+ const isUpdated = addIntlayerPluginToPrettierConfig(prettierConfig);
67
+ if (isUpdated) await writeFileToRoot(rootDir, configPath, `${JSON.stringify(fileContent, null, 2)}\n`);
68
+ logger(isUpdated ? `${v} Added ${pluginName} to ${colorizePath(configPath)}` : `${v} ${colorizePath(configPath)} already includes ${pluginName}`);
69
+ return isUpdated;
70
+ } catch {
71
+ return;
72
+ }
73
+ };
74
+ for (const configPath of JSON_PRETTIER_CONFIG_FILES) if (await patchJsonConfig(configPath, (config) => config) !== void 0) return;
75
+ if (await patchJsonConfig("package.json", (packageJson) => packageJson.prettier) !== void 0) return;
76
+ logger([
77
+ colorize("Intlayer Prettier plugin →", ANSIColors.MAGENTA),
78
+ colorize(`Add ${PRETTIER_PLUGIN_PACKAGE_NAME} to the plugins of your Prettier config, to sort the keys of t(), plural(), enu() and select():`, ANSIColors.GREY_LIGHT),
79
+ colorize(` { "plugins": ["${PRETTIER_PLUGIN_PACKAGE_NAME}"] }`, ANSIColors.GREY_LIGHT),
80
+ colorizePath(DocumentationRouter.Prettier)
81
+ ]);
82
+ };
83
+ /**
42
84
  * MAIN LOGIC
43
85
  */
44
86
  const initIntlayer = async (rootDir, options) => {
@@ -76,7 +118,8 @@ const initIntlayer = async (rootDir, options) => {
76
118
  linguiCatalogFormat,
77
119
  dependencies: packageJson.dependencies,
78
120
  devDependencies: packageJson.devDependencies,
79
- skipLintPlugin: options?.noEslint
121
+ skipLintPlugin: options?.noEslint,
122
+ skipPrettierPlugin: options?.noPrettier
80
123
  });
81
124
  /** Whether the compat adapter for a library is not released yet. */
82
125
  const isCompatAdapterPending = (adapterPackage) => pendingCompatAdapters.includes(adapterPackage);
@@ -206,6 +249,7 @@ const initIntlayer = async (rootDir, options) => {
206
249
  colorizePath(DocumentationRouter.ESLint)
207
250
  ]);
208
251
  }
252
+ if (!options?.noPrettier && hasPrettier(allDeps)) await setupPrettierPlugin(rootDir, allDeps, packageManager, options);
209
253
  if (!options?.noFrameworkSetup) {
210
254
  const tsConfigFiles = await findTsConfigFiles(rootDir);
211
255
  let hasTsConfig = false;