@intlayer/engine 9.5.12 → 9.7.0

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 (169) hide show
  1. package/dist/assets/installSkills/skills/cli.md +28 -1
  2. package/dist/assets/installSkills/skills/compat.md +1 -1
  3. package/dist/assets/installSkills/skills/dev-tools.md +8 -6
  4. package/dist/cjs/build.cjs +12 -2
  5. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +12 -11
  6. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  7. package/dist/cjs/buildIntlayerDictionary/index.cjs +4 -1
  8. package/dist/cjs/buildIntlayerDictionary/rebuildUnmergedDictionaries.cjs +23 -0
  9. package/dist/cjs/buildIntlayerDictionary/rebuildUnmergedDictionaries.cjs.map +1 -0
  10. package/dist/cjs/cli.cjs +12 -0
  11. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  12. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +1 -1
  13. package/dist/cjs/handleContentDeclarationFileChange.cjs +1 -1
  14. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +1 -1
  15. package/dist/cjs/init/cms.cjs +18 -0
  16. package/dist/cjs/init/cms.cjs.map +1 -1
  17. package/dist/cjs/init/index.cjs +23 -10
  18. package/dist/cjs/init/index.cjs.map +1 -1
  19. package/dist/cjs/init/utils/configManipulation.cjs +28 -0
  20. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
  21. package/dist/cjs/init/utils/contentLayout.cjs +61 -0
  22. package/dist/cjs/init/utils/contentLayout.cjs.map +1 -0
  23. package/dist/cjs/init/utils/index.cjs +1 -0
  24. package/dist/cjs/init/utils/packageManager.cjs +1 -1
  25. package/dist/cjs/init/utils/packageManager.cjs.map +1 -1
  26. package/dist/cjs/installMCP/installMCP.cjs +35 -25
  27. package/dist/cjs/installMCP/installMCP.cjs.map +1 -1
  28. package/dist/cjs/installSkills/index.cjs +26 -1
  29. package/dist/cjs/installSkills/index.cjs.map +1 -1
  30. package/dist/cjs/listDictionariesPath.cjs +2 -5
  31. package/dist/cjs/listDictionariesPath.cjs.map +1 -1
  32. package/dist/cjs/listGitFiles.cjs +3 -5
  33. package/dist/cjs/listGitFiles.cjs.map +1 -1
  34. package/dist/cjs/listProjects.cjs +1 -2
  35. package/dist/cjs/listProjects.cjs.map +1 -1
  36. package/dist/cjs/loadDictionaries/index.cjs +1 -1
  37. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +1 -1
  38. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  39. package/dist/cjs/utils/buildComponentFilesList.cjs +18 -30
  40. package/dist/cjs/utils/buildComponentFilesList.cjs.map +1 -1
  41. package/dist/cjs/utils/chunkJSON.cjs +1 -1
  42. package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
  43. package/dist/cjs/utils/index.cjs +2 -0
  44. package/dist/cjs/utils/isDirectoryExcluded.cjs +36 -0
  45. package/dist/cjs/utils/isDirectoryExcluded.cjs.map +1 -0
  46. package/dist/cjs/watcher.cjs +5 -2
  47. package/dist/cjs/watcher.cjs.map +1 -1
  48. package/dist/cjs/writeConfiguration/index.cjs +23 -0
  49. package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
  50. package/dist/cjs/writeContentDeclaration/index.cjs +6 -0
  51. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +20 -13
  52. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
  53. package/dist/cjs/writeContentDeclaration/renderContentDeclaration.cjs +213 -0
  54. package/dist/cjs/writeContentDeclaration/renderContentDeclaration.cjs.map +1 -0
  55. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +5 -51
  56. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  57. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs +2 -31
  58. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs.map +1 -1
  59. package/dist/cjs/writeContentDeclaration/writeYamlFile.cjs +2 -8
  60. package/dist/cjs/writeContentDeclaration/writeYamlFile.cjs.map +1 -1
  61. package/dist/esm/build.mjs +7 -5
  62. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +12 -12
  63. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  64. package/dist/esm/buildIntlayerDictionary/index.mjs +3 -2
  65. package/dist/esm/buildIntlayerDictionary/rebuildUnmergedDictionaries.mjs +22 -0
  66. package/dist/esm/buildIntlayerDictionary/rebuildUnmergedDictionaries.mjs.map +1 -0
  67. package/dist/esm/cli.mjs +5 -3
  68. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  69. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +1 -1
  70. package/dist/esm/handleContentDeclarationFileChange.mjs +1 -1
  71. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +1 -1
  72. package/dist/esm/init/cms.mjs +19 -2
  73. package/dist/esm/init/cms.mjs.map +1 -1
  74. package/dist/esm/init/index.mjs +24 -11
  75. package/dist/esm/init/index.mjs.map +1 -1
  76. package/dist/esm/init/utils/configManipulation.mjs +28 -1
  77. package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
  78. package/dist/esm/init/utils/contentLayout.mjs +58 -0
  79. package/dist/esm/init/utils/contentLayout.mjs.map +1 -0
  80. package/dist/esm/init/utils/index.mjs +2 -2
  81. package/dist/esm/init/utils/packageManager.mjs +1 -1
  82. package/dist/esm/init/utils/packageManager.mjs.map +1 -1
  83. package/dist/esm/installMCP/installMCP.mjs +35 -25
  84. package/dist/esm/installMCP/installMCP.mjs.map +1 -1
  85. package/dist/esm/installSkills/index.mjs +27 -3
  86. package/dist/esm/installSkills/index.mjs.map +1 -1
  87. package/dist/esm/listDictionariesPath.mjs +2 -5
  88. package/dist/esm/listDictionariesPath.mjs.map +1 -1
  89. package/dist/esm/listGitFiles.mjs +1 -1
  90. package/dist/esm/listGitFiles.mjs.map +1 -1
  91. package/dist/esm/listProjects.mjs +1 -1
  92. package/dist/esm/listProjects.mjs.map +1 -1
  93. package/dist/esm/loadDictionaries/index.mjs +1 -1
  94. package/dist/esm/loadDictionaries/loadDictionaries.mjs +1 -1
  95. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  96. package/dist/esm/utils/buildComponentFilesList.mjs +19 -31
  97. package/dist/esm/utils/buildComponentFilesList.mjs.map +1 -1
  98. package/dist/esm/utils/chunkJSON.mjs +1 -1
  99. package/dist/esm/utils/chunkJSON.mjs.map +1 -1
  100. package/dist/esm/utils/index.mjs +2 -1
  101. package/dist/esm/utils/isDirectoryExcluded.mjs +35 -0
  102. package/dist/esm/utils/isDirectoryExcluded.mjs.map +1 -0
  103. package/dist/esm/utils/runParallel/pidTree.mjs +3 -3
  104. package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
  105. package/dist/esm/utils/runParallel/ps.mjs +2 -2
  106. package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
  107. package/dist/esm/utils/runParallel/wmic.mjs +2 -2
  108. package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
  109. package/dist/esm/watcher.mjs +5 -2
  110. package/dist/esm/watcher.mjs.map +1 -1
  111. package/dist/esm/writeConfiguration/index.mjs +23 -1
  112. package/dist/esm/writeConfiguration/index.mjs.map +1 -1
  113. package/dist/esm/writeContentDeclaration/index.mjs +2 -1
  114. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +20 -13
  115. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
  116. package/dist/esm/writeContentDeclaration/renderContentDeclaration.mjs +208 -0
  117. package/dist/esm/writeContentDeclaration/renderContentDeclaration.mjs.map +1 -0
  118. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +5 -51
  119. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  120. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +2 -31
  121. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs.map +1 -1
  122. package/dist/esm/writeContentDeclaration/writeYamlFile.mjs +2 -8
  123. package/dist/esm/writeContentDeclaration/writeYamlFile.mjs.map +1 -1
  124. package/dist/types/build.d.ts +5 -3
  125. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +6 -0
  126. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  127. package/dist/types/buildIntlayerDictionary/index.d.ts +3 -2
  128. package/dist/types/buildIntlayerDictionary/rebuildUnmergedDictionaries.d.ts +14 -0
  129. package/dist/types/buildIntlayerDictionary/rebuildUnmergedDictionaries.d.ts.map +1 -0
  130. package/dist/types/cli.d.ts +6 -4
  131. package/dist/types/fetchDistantDictionaries.d.ts +1 -1
  132. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
  133. package/dist/types/init/cms.d.ts +6 -0
  134. package/dist/types/init/cms.d.ts.map +1 -1
  135. package/dist/types/init/index.d.ts +15 -14
  136. package/dist/types/init/index.d.ts.map +1 -1
  137. package/dist/types/init/utils/configManipulation.d.ts +8 -0
  138. package/dist/types/init/utils/configManipulation.d.ts.map +1 -1
  139. package/dist/types/init/utils/contentLayout.d.ts +42 -0
  140. package/dist/types/init/utils/contentLayout.d.ts.map +1 -0
  141. package/dist/types/init/utils/index.d.ts +2 -2
  142. package/dist/types/init/utils/packageManager.d.ts +9 -3
  143. package/dist/types/init/utils/packageManager.d.ts.map +1 -1
  144. package/dist/types/installMCP/installMCP.d.ts +4 -0
  145. package/dist/types/installMCP/installMCP.d.ts.map +1 -1
  146. package/dist/types/installSkills/index.d.ts +6 -0
  147. package/dist/types/installSkills/index.d.ts.map +1 -1
  148. package/dist/types/listDictionariesPath.d.ts +1 -1
  149. package/dist/types/listDictionariesPath.d.ts.map +1 -1
  150. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +1 -1
  151. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
  152. package/dist/types/utils/buildComponentFilesList.d.ts +6 -6
  153. package/dist/types/utils/buildComponentFilesList.d.ts.map +1 -1
  154. package/dist/types/utils/chunkJSON.d.ts.map +1 -1
  155. package/dist/types/utils/index.d.ts +2 -1
  156. package/dist/types/utils/isDirectoryExcluded.d.ts +15 -0
  157. package/dist/types/utils/isDirectoryExcluded.d.ts.map +1 -0
  158. package/dist/types/watcher.d.ts.map +1 -1
  159. package/dist/types/writeConfiguration/index.d.ts +13 -0
  160. package/dist/types/writeConfiguration/index.d.ts.map +1 -1
  161. package/dist/types/writeContentDeclaration/index.d.ts +2 -1
  162. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts +8 -2
  163. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -1
  164. package/dist/types/writeContentDeclaration/renderContentDeclaration.d.ts +61 -0
  165. package/dist/types/writeContentDeclaration/renderContentDeclaration.d.ts.map +1 -0
  166. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
  167. package/dist/types/writeContentDeclaration/writeMarkdownFile.d.ts.map +1 -1
  168. package/dist/types/writeContentDeclaration/writeYamlFile.d.ts.map +1 -1
  169. package/package.json +18 -10
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: intlayer-cli
3
- description: Manages Intlayer dictionaries and configuration via the Command Line Interface. Use when the user asks to "audit translations", "build dictionaries", "sync content", or run "intlayer" commands.
3
+ description: Sets up Intlayer and manages its dictionaries and configuration via the Command Line Interface. Use when the user asks to "set up Intlayer", "audit translations", "build dictionaries", "sync content", or run "intlayer" commands.
4
4
  metadata:
5
5
  author: Intlayer
6
6
  url: https://intlayer.org
@@ -22,6 +22,33 @@ The `intlayer-cli` package provides a set of commands to manage Intlayer diction
22
22
  npm install intlayer-cli
23
23
  ```
24
24
 
25
+ ## Set Up Intlayer
26
+
27
+ `npx intlayer init` installs the Intlayer packages and sets up the framework (config file, tsconfig, bundler plugin, middleware/proxy, providers). Every other setup step is opt-in, through its own sub-command:
28
+
29
+ | Command | Sets up |
30
+ | --------------------------------------------------------- | --------------------------------------------------------- |
31
+ | `npx intlayer init packages` | Missing Intlayer packages, and upgrades the outdated ones |
32
+ | `npx intlayer init project --routing <routing>` | The framework only (no install) |
33
+ | `npx intlayer init github-actions` | The `fill` and `test` GitHub Actions workflows |
34
+ | `npx intlayer init vscode-extension` | The VS Code extension recommendation |
35
+ | `npx intlayer init lsp` | The language server settings |
36
+ | `npx intlayer init eslint` | The lint rules, when the project already lints |
37
+ | `npx intlayer init skills --platform <p> --skills <s…>` | The Intlayer skills for an AI agent |
38
+ | `npx intlayer init mcp --platform <p> --transport stdio` | The Intlayer MCP server, inside the project |
39
+ | `npx intlayer init extension --browser chrome` | Opens the browser extension store page |
40
+ | `npx intlayer init cms` | CMS login through the browser (needs a person) |
41
+ | `npx intlayer init infra --mode <desktop/docker/compose>` | Desktop app or self-hosted stack |
42
+
43
+ `--routing` accepts `prefix-no-default` (default), `prefix-all`, `no-prefix`, `search-params` or `none`.
44
+
45
+ ### As an AI agent
46
+
47
+ - Never run `npx intlayer init --interactive`: its checklist needs a terminal. Without one it exits with code 1 and lists the sub-commands above.
48
+ - Run `npx intlayer init`, then only the sub-commands the user asked for.
49
+ - Pass the values as flags so nothing is prompted. When omitted without a terminal: `--skills` defaults to the project stack, `--platform` to the detected agent (e.g. `Claude` for Claude Code), `--transport` to `stdio`; `init infra` requires `--mode`.
50
+ - Leave `init cms` and `init extension` to the user: both finish in their browser.
51
+
25
52
  ## Main CLI Commands
26
53
 
27
54
  | Command | Description |
@@ -18,7 +18,7 @@ Compat adapters expose the **exact same public API** as an existing i18n library
18
18
 
19
19
  ## How it works
20
20
 
21
- 1. Run `npx intlayer init --interactive`: it creates `intlayer.config.ts`, installs the adapter and can keep existing JSON catalogs as the source of truth via a sync plugin.
21
+ 1. Run `npx intlayer init`: it creates `intlayer.config.ts`, installs the adapter and can keep existing JSON catalogs as the source of truth via a sync plugin.
22
22
  2. Register the adapter's bundler plugin (`<adapter>/plugin`). It aliases the original imports to the adapter at build time, so no import is rewritten by hand.
23
23
 
24
24
  ## Adapters
@@ -22,7 +22,7 @@ metadata:
22
22
  npm install --save-dev eslint-plugin-intlayer
23
23
  ```
24
24
 
25
- Then spread `intlayer.configs.recommended` in your `eslint.config.mjs` (oxlint is also supported).
25
+ Then spread `intlayer.configs.recommended` in your `eslint.config.mjs` (oxlint is also supported). `npx intlayer init eslint` installs the plugin and wires the oxlint config for you (for an ESLint flat config, it prints the snippet to add).
26
26
 
27
27
  | Config | `no-raw-text` | `static-dictionary-key` | `no-dynamic-field-access` |
28
28
  | --------------- | ------------- | ----------------------- | ------------------------- |
@@ -38,25 +38,27 @@ Then spread `intlayer.configs.recommended` in your `eslint.config.mjs` (oxlint i
38
38
  npm install --save-dev @intlayer/lsp
39
39
  ```
40
40
 
41
+ `npx intlayer init lsp` writes the language server settings to `.vscode/settings.json`.
42
+
41
43
  ## VS Code Extension
42
44
 
43
- Jump from a dictionary key to its content file, extract content from a component, and run build, fill, test, push and pull from the command palette.
45
+ Jump from a dictionary key to its content file, extract content from a component, and run build, fill, test, push and pull from the command palette. `npx intlayer init vscode-extension` recommends it in `.vscode/extensions.json`.
44
46
 
45
47
  ## MCP Server
46
48
 
47
49
  Gives AI assistants access to the Intlayer documentation and CLI.
48
50
 
49
51
  ```bash
50
- npx intlayer init mcp
52
+ npx intlayer init mcp --platform Claude --transport stdio
51
53
  ```
52
54
 
53
- This writes the MCP configuration for your IDE (local `@intlayer/mcp` over stdio, or the hosted `https://mcp.intlayer.org`).
55
+ This writes the MCP configuration inside the project for your IDE or agent (`.mcp.json` for Claude Code, `.cursor/mcp.json`, `.vscode/mcp.json`, …), using the local `@intlayer/mcp` over stdio or the hosted `https://mcp.intlayer.org` over SSE. Both flags are optional: without them the platform is detected and the transport is prompted for, or defaults to `stdio` when there is no terminal.
54
56
 
55
57
  A WebMCP is also available for the main website and documentation at `https://intlayer.org`.
56
58
 
57
59
  ## CI/CD
58
60
 
59
- Fill missing translations with AI on each change, and fail the build on missing ones:
61
+ Fill missing translations with AI on each change, and fail the build on missing ones. `npx intlayer init github-actions` scaffolds both workflows:
60
62
 
61
63
  ```bash
62
64
  npx intlayer fill --git-diff --mode complete
@@ -65,7 +67,7 @@ npx intlayer test
65
67
 
66
68
  ## Chrome Extension
67
69
 
68
- Inspect the i18n setup of any website: framework, i18n library, locales, hreflang and SEO tags.
70
+ Inspect the i18n setup of any website: framework, i18n library, locales, hreflang and SEO tags. `npx intlayer init extension --browser chrome` opens its store page.
69
71
 
70
72
  ## References
71
73
 
@@ -2,6 +2,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_utils_readDictionariesFromDisk = require('./utils/readDictionariesFromDisk.cjs');
3
3
  const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./buildIntlayerDictionary/buildIntlayerDictionary.cjs');
4
4
  const require_buildIntlayerDictionary_processContentDeclaration = require('./buildIntlayerDictionary/processContentDeclaration.cjs');
5
+ const require_loadDictionaries_loadContentDeclaration = require('./loadDictionaries/loadContentDeclaration.cjs');
6
+ const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
7
+ const require_buildIntlayerDictionary_rebuildUnmergedDictionaries = require('./buildIntlayerDictionary/rebuildUnmergedDictionaries.cjs');
5
8
  const require_cleanOutputDir = require('./cleanOutputDir.cjs');
6
9
  const require_createDictionaryEntryPoint_generateDictionaryListContent = require('./createDictionaryEntryPoint/generateDictionaryListContent.cjs');
7
10
  const require_createDictionaryEntryPoint_getBuiltDictionariesPath = require('./createDictionaryEntryPoint/getBuiltDictionariesPath.cjs');
@@ -13,19 +16,19 @@ const require_createDictionaryEntryPoint_createDictionaryEntryPoint = require('.
13
16
  const require_createType_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
14
17
  const require_createType_createType = require('./createType/createType.cjs');
15
18
  const require_formatDictionary = require('./formatDictionary.cjs');
16
- const require_loadDictionaries_loadContentDeclaration = require('./loadDictionaries/loadContentDeclaration.cjs');
17
19
  const require_loadDictionaries_loadRemoteDictionaries = require('./loadDictionaries/loadRemoteDictionaries.cjs');
18
20
  const require_loadDictionaries_loadDictionaries = require('./loadDictionaries/loadDictionaries.cjs');
19
- const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
20
21
  const require_writeConfiguration_index = require('./writeConfiguration/index.cjs');
21
22
  const require_prepareIntlayer = require('./prepareIntlayer.cjs');
22
23
  const require_prepareIntlayerServer = require('./prepareIntlayerServer.cjs');
23
24
  const require_writeContentDeclaration_detectExportedComponentName = require('./writeContentDeclaration/detectExportedComponentName.cjs');
24
25
  const require_writeContentDeclaration_transformJSFile = require('./writeContentDeclaration/transformJSFile.cjs');
26
+ const require_writeContentDeclaration_renderContentDeclaration = require('./writeContentDeclaration/renderContentDeclaration.cjs');
25
27
  const require_writeContentDeclaration_writeJSFile = require('./writeContentDeclaration/writeJSFile.cjs');
26
28
  const require_writeContentDeclaration_writeContentDeclaration = require('./writeContentDeclaration/writeContentDeclaration.cjs');
27
29
 
28
30
  exports.INTLAYER_WATCH_ENV_VAR = require_prepareIntlayerServer.INTLAYER_WATCH_ENV_VAR;
31
+ exports.addStoredSiblingDictionaries = require_buildIntlayerDictionary_buildIntlayerDictionary.addStoredSiblingDictionaries;
29
32
  exports.buildDictionary = require_buildIntlayerDictionary_buildIntlayerDictionary.buildDictionary;
30
33
  exports.cleanOutputDir = require_cleanOutputDir.cleanOutputDir;
31
34
  exports.createDictionaryEntryPoint = require_createDictionaryEntryPoint_createDictionaryEntryPoint.createDictionaryEntryPoint;
@@ -33,6 +36,7 @@ exports.createModuleAugmentation = require_createType_createModuleAugmentation.c
33
36
  exports.createTypes = require_createType_createType.createTypes;
34
37
  exports.detectExportedComponentName = require_writeContentDeclaration_detectExportedComponentName.detectExportedComponentName;
35
38
  exports.ensureIntlayerBundle = require_loadDictionaries_loadContentDeclaration.ensureIntlayerBundle;
39
+ exports.formatContentDeclaration = require_writeContentDeclaration_renderContentDeclaration.formatContentDeclaration;
36
40
  exports.formatDictionaries = require_formatDictionary.formatDictionaries;
37
41
  exports.formatDictionariesOutput = require_formatDictionary.formatDictionariesOutput;
38
42
  exports.formatDictionary = require_formatDictionary.formatDictionary;
@@ -52,15 +56,21 @@ exports.getIsDevWatcherCommand = require_prepareIntlayerServer.getIsDevWatcherCo
52
56
  exports.getIsServerDevelopment = require_prepareIntlayerServer.getIsServerDevelopment;
53
57
  exports.getTypeName = require_createType_createModuleAugmentation.getTypeName;
54
58
  exports.isCachedConfigurationUpToDate = require_writeConfiguration_index.isCachedConfigurationUpToDate;
59
+ exports.isRenderableContentDeclarationPath = require_writeContentDeclaration_renderContentDeclaration.isRenderableContentDeclarationPath;
55
60
  exports.loadContentDeclaration = require_loadDictionaries_loadContentDeclaration.loadContentDeclaration;
56
61
  exports.loadContentDeclarations = require_loadDictionaries_loadContentDeclaration.loadContentDeclarations;
57
62
  exports.loadDictionaries = require_loadDictionaries_loadDictionaries.loadDictionaries;
58
63
  exports.loadLocalDictionaries = require_loadDictionaries_loadLocalDictionaries.loadLocalDictionaries;
59
64
  exports.loadRemoteDictionaries = require_loadDictionaries_loadRemoteDictionaries.loadRemoteDictionaries;
65
+ exports.overrideBuiltEditorConfiguration = require_writeConfiguration_index.overrideBuiltEditorConfiguration;
60
66
  exports.prepareIntlayer = require_prepareIntlayer.prepareIntlayer;
61
67
  exports.prepareIntlayerServer = require_prepareIntlayerServer.prepareIntlayerServer;
62
68
  exports.processContentDeclaration = require_buildIntlayerDictionary_processContentDeclaration.processContentDeclaration;
63
69
  exports.readDictionariesFromDisk = require_utils_readDictionariesFromDisk.readDictionariesFromDisk;
70
+ exports.rebuildUnmergedDictionaries = require_buildIntlayerDictionary_rebuildUnmergedDictionaries.rebuildUnmergedDictionaries;
71
+ exports.renderContentDeclaration = require_writeContentDeclaration_renderContentDeclaration.renderContentDeclaration;
72
+ exports.renderMarkdownContentDeclaration = require_writeContentDeclaration_renderContentDeclaration.renderMarkdownContentDeclaration;
73
+ exports.renderYamlContentDeclaration = require_writeContentDeclaration_renderContentDeclaration.renderYamlContentDeclaration;
64
74
  exports.transformJSFile = require_writeContentDeclaration_transformJSFile.transformJSFile;
65
75
  exports.writeConfiguration = require_writeConfiguration_index.writeConfiguration;
66
76
  exports.writeContentDeclaration = require_writeContentDeclaration_writeContentDeclaration.writeContentDeclaration;
@@ -16,6 +16,16 @@ const defaultOptions = {
16
16
  env: "dev"
17
17
  };
18
18
  /**
19
+ * Appends the already-built declarations sharing a key with
20
+ * `localDictionaries` (other `localId`), so a partial rebuild does not drop
21
+ * the declarations coming from other content files.
22
+ */
23
+ const addStoredSiblingDictionaries = (localDictionaries, configuration) => {
24
+ const storedUnmergedDictionaries = require_utils_readDictionariesFromDisk.readDictionariesFromDisk(configuration.system.unmergedDictionariesDir);
25
+ const siblingDictionaries = localDictionaries.flatMap((localDictionary) => (storedUnmergedDictionaries[localDictionary.key] ?? []).filter((storedDictionary) => storedDictionary.localId !== localDictionary.localId));
26
+ return [...localDictionaries, ...siblingDictionaries];
27
+ };
28
+ /**
19
29
  * This function transpile the bundled code to to make dictionaries as JSON files
20
30
  */
21
31
  const buildDictionary = async (localDictionariesEntries, configuration, options) => {
@@ -24,17 +34,7 @@ const buildDictionary = async (localDictionariesEntries, configuration, options)
24
34
  ...defaultOptions,
25
35
  ...options
26
36
  };
27
- const unmergedDictionariesToUpdate = [...localDictionariesEntries];
28
- if (importOtherDictionaries) {
29
- const prevUnmergedDictionaries = require_utils_readDictionariesFromDisk.readDictionariesFromDisk(configuration.system.unmergedDictionariesDir);
30
- for (const dictionaryToWrite of localDictionariesEntries) {
31
- const allPrebuiltUnmergedDictionaries = prevUnmergedDictionaries[dictionaryToWrite.key];
32
- if (allPrebuiltUnmergedDictionaries?.length > 0) {
33
- const otherUnmergedDictionaries = allPrebuiltUnmergedDictionaries?.filter((unmergedDictionary) => unmergedDictionary.localId !== dictionaryToWrite.localId);
34
- unmergedDictionariesToUpdate.push(...otherUnmergedDictionaries ?? []);
35
- }
36
- }
37
- }
37
+ const unmergedDictionariesToUpdate = importOtherDictionaries ? addStoredSiblingDictionaries(localDictionariesEntries, configuration) : [...localDictionariesEntries];
38
38
  const unmergedDictionaries = await require_buildIntlayerDictionary_writeUnmergedDictionary.writeUnmergedDictionaries(unmergedDictionariesToUpdate, configuration, env);
39
39
  const mergedDictionaries = await require_buildIntlayerDictionary_writeMergedDictionary.writeMergedDictionaries(unmergedDictionaries, configuration);
40
40
  const nestedDictionaryGraph = (0, _intlayer_core_dictionaryManipulator.getNestedDictionaryGraph)(Object.values(require_utils_readDictionariesFromDisk.readDictionariesFromDisk(configuration.system.dictionariesDir)));
@@ -87,5 +87,6 @@ const buildDictionary = async (localDictionariesEntries, configuration, options)
87
87
  };
88
88
 
89
89
  //#endregion
90
+ exports.addStoredSiblingDictionaries = addStoredSiblingDictionaries;
90
91
  exports.buildDictionary = buildDictionary;
91
92
  //# sourceMappingURL=buildIntlayerDictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildIntlayerDictionary.cjs","names":["OUTPUT_FORMAT","IMPORT_MODE","readDictionariesFromDisk","writeUnmergedDictionaries","writeMergedDictionaries","getNestedDictionaryGraph","writeNestedDictionaries","isQualifiedDictionaryGroup","getAppLogger","colorizeKey","writeDynamicDictionary","writeDynamicQualifiedDictionaries","writeFetchDictionary"],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"sourcesContent":["import { IMPORT_MODE, OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport {\n getNestedDictionaryGraph,\n isQualifiedDictionaryGroup,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { readDictionariesFromDisk } from '../utils/readDictionariesFromDisk';\nimport {\n type LocalizedDictionaryOutput,\n type QualifiedMergedDictionaryOutput,\n writeDynamicDictionary,\n writeDynamicQualifiedDictionaries,\n} from './writeDynamicDictionary';\nimport { writeFetchDictionary } from './writeFetchDictionary';\nimport {\n type PlainMergedDictionaryOutput,\n writeMergedDictionaries,\n} from './writeMergedDictionary';\nimport { writeNestedDictionaries } from './writeNestedDictionary';\nimport { writeUnmergedDictionaries } from './writeUnmergedDictionary';\n\nexport type BuildDictionariesOptions = Partial<{\n formats: typeof OUTPUT_FORMAT;\n importOtherDictionaries: boolean;\n env: 'prod' | 'dev';\n}>;\n\nconst defaultOptions = {\n formats: OUTPUT_FORMAT,\n importOtherDictionaries: true,\n env: 'dev',\n} as const satisfies BuildDictionariesOptions;\n\n/**\n * This function transpile the bundled code to to make dictionaries as JSON files\n */\nexport const buildDictionary = async (\n localDictionariesEntries: Dictionary[],\n configuration: IntlayerConfig,\n options?: BuildDictionariesOptions\n) => {\n const importMode =\n configuration?.build?.importMode ??\n configuration?.dictionary?.importMode ??\n IMPORT_MODE;\n\n const { importOtherDictionaries, env, formats } = {\n ...defaultOptions,\n ...options,\n };\n\n const unmergedDictionariesToUpdate: Dictionary[] = [\n ...localDictionariesEntries,\n ];\n\n if (importOtherDictionaries) {\n const prevUnmergedDictionaries: Record<string, Dictionary[]> =\n readDictionariesFromDisk(configuration.system.unmergedDictionariesDir);\n\n // Reinsert other dictionaries with the same key to avoid merging errors\n for (const dictionaryToWrite of localDictionariesEntries) {\n const allPrebuiltUnmergedDictionaries =\n prevUnmergedDictionaries[dictionaryToWrite.key]!;\n\n if (allPrebuiltUnmergedDictionaries?.length > 0) {\n // Do not add the same dictionary again by filtering out the one with the same localId\n const otherUnmergedDictionaries =\n allPrebuiltUnmergedDictionaries?.filter(\n (unmergedDictionary) =>\n unmergedDictionary.localId !== dictionaryToWrite.localId\n );\n\n unmergedDictionariesToUpdate.push(...(otherUnmergedDictionaries ?? []));\n }\n }\n }\n\n const unmergedDictionaries = await writeUnmergedDictionaries(\n unmergedDictionariesToUpdate,\n configuration,\n env\n );\n\n const mergedDictionaries = await writeMergedDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n // `nest()` dependency graph, read back from disk so it stays complete on\n // incremental rebuilds where only a subset of dictionaries was regenerated.\n // Every artifact kind attaches its dependencies, letting `getNesting` resolve\n // them locally instead of through the registry the optimizer strips.\n const nestedDictionaryGraph = getNestedDictionaryGraph(\n Object.values(\n readDictionariesFromDisk<Record<string, Dictionary>>(\n configuration.system.dictionariesDir\n )\n )\n );\n\n await writeNestedDictionaries(nestedDictionaryGraph, configuration, formats);\n\n const dictionariesToBuildDynamic: PlainMergedDictionaryOutput = {};\n const qualifiedDictionariesToBuildDynamic: QualifiedMergedDictionaryOutput =\n {};\n const keysToBuildFetch = new Set<string>();\n\n for (const [key, mergedResult] of Object.entries(mergedDictionaries)) {\n const dictionary = mergedResult.dictionary;\n\n if (isQualifiedDictionaryGroup(dictionary)) {\n // Collections / variants resolve their qualifier at\n // runtime from a selector. Static mode keeps every entry in one JSON;\n // dynamic mode splits them into one chunk per (locale, qualifierId).\n const entryMode = dictionary.importMode ?? importMode;\n\n if (entryMode === 'dynamic') {\n qualifiedDictionariesToBuildDynamic[key] = {\n dictionaryPath: mergedResult.dictionaryPath,\n dictionary,\n };\n } else if (entryMode === 'fetch') {\n const appLogger = getAppLogger(configuration);\n appLogger(\n `Dictionary ${colorizeKey(key)} uses 'fetch' import mode with (${dictionary.qualifierTypes.join(', ')}) entries — fetch mode is not qualifier-aware yet, falling back to static import.`,\n { level: 'warn' }\n );\n }\n\n continue;\n }\n\n const mode = dictionary.importMode ?? importMode;\n\n if (mode === 'dynamic' || mode === 'fetch') {\n dictionariesToBuildDynamic[key] = {\n dictionaryPath: mergedResult.dictionaryPath,\n dictionary,\n };\n }\n\n if (mode === 'fetch') {\n keysToBuildFetch.add(key);\n }\n }\n\n // A lazily loaded dictionary resolves its `nest()` references from chunks\n // loaded by the same loader, so its nest targets need dynamic artifacts of\n // their own — whatever import mode they declare for their own call sites.\n for (const consumerKey of Object.keys(dictionariesToBuildDynamic)) {\n for (const nestedKey of nestedDictionaryGraph.get(consumerKey) ?? []) {\n if (dictionariesToBuildDynamic[nestedKey]) continue;\n\n const nestedResult = mergedDictionaries[nestedKey];\n if (\n !nestedResult ||\n isQualifiedDictionaryGroup(nestedResult.dictionary)\n ) {\n continue;\n }\n\n dictionariesToBuildDynamic[nestedKey] = {\n dictionaryPath: nestedResult.dictionaryPath,\n dictionary: nestedResult.dictionary,\n };\n }\n }\n\n let dynamicDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (Object.keys(dictionariesToBuildDynamic).length > 0) {\n dynamicDictionaries = await writeDynamicDictionary(\n dictionariesToBuildDynamic,\n configuration,\n formats,\n nestedDictionaryGraph\n );\n }\n\n if (Object.keys(qualifiedDictionariesToBuildDynamic).length > 0) {\n await writeDynamicQualifiedDictionaries(\n qualifiedDictionariesToBuildDynamic,\n configuration,\n formats\n );\n }\n\n let fetchDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (dynamicDictionaries && keysToBuildFetch.size > 0) {\n const dictionariesToBuildFetch: LocalizedDictionaryOutput = {};\n\n for (const key of keysToBuildFetch) {\n if (dynamicDictionaries[key]) {\n dictionariesToBuildFetch[key] = dynamicDictionaries[key];\n }\n }\n\n if (Object.keys(dictionariesToBuildFetch).length > 0) {\n fetchDictionaries = await writeFetchDictionary(\n dictionariesToBuildFetch,\n configuration,\n formats,\n nestedDictionaryGraph\n );\n }\n }\n\n return {\n unmergedDictionaries,\n mergedDictionaries,\n dynamicDictionaries,\n fetchDictionaries,\n };\n};\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAM,iBAAiB;CACrB,SAASA;CACT,yBAAyB;CACzB,KAAK;AACP;;;;AAKA,MAAa,kBAAkB,OAC7B,0BACA,eACA,YACG;CACH,MAAM,aACJ,eAAe,OAAO,cACtB,eAAe,YAAY,cAC3BC;CAEF,MAAM,EAAE,yBAAyB,KAAK,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CAE5B;CAKA,KAAK,MAAM,eAAe,OAAO,KAAK,0BAA0B,GAC9D,KAAK,MAAM,aAAa,sBAAsB,IAAI,WAAW,KAAK,CAAC,GAAG;EACpE,IAAI,2BAA2B,YAAY;EAE3C,MAAM,eAAe,mBAAmB;EACxC,IACE,CAAC,oBACDF,iEAA2B,aAAa,UAAU,GAElD;EAGF,2BAA2B,aAAa;GACtC,gBAAgB,aAAa;GAC7B,YAAY,aAAa;EAC3B;CACF;CAGF,IAAI,sBAAwD;CAE5D,IAAI,OAAO,KAAK,0BAA0B,CAAC,CAAC,SAAS,GACnD,sBAAsB,MAAMG,8EAC1B,4BACA,eACA,SACA,qBACF;CAGF,IAAI,OAAO,KAAK,mCAAmC,CAAC,CAAC,SAAS,GAC5D,MAAMC,yFACJ,qCACA,eACA,OACF;CAGF,IAAI,oBAAsD;CAE1D,IAAI,uBAAuB,iBAAiB,OAAO,GAAG;EACpD,MAAM,2BAAsD,CAAC;EAE7D,KAAK,MAAM,OAAO,kBAChB,IAAI,oBAAoB,MACtB,yBAAyB,OAAO,oBAAoB;EAIxD,IAAI,OAAO,KAAK,wBAAwB,CAAC,CAAC,SAAS,GACjD,oBAAoB,MAAMC,0EACxB,0BACA,eACA,SACA,qBACF;CAEJ;CAEA,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"buildIntlayerDictionary.cjs","names":["OUTPUT_FORMAT","readDictionariesFromDisk","IMPORT_MODE","writeUnmergedDictionaries","writeMergedDictionaries","getNestedDictionaryGraph","writeNestedDictionaries","isQualifiedDictionaryGroup","getAppLogger","colorizeKey","writeDynamicDictionary","writeDynamicQualifiedDictionaries","writeFetchDictionary"],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"sourcesContent":["import { IMPORT_MODE, OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport {\n getNestedDictionaryGraph,\n isQualifiedDictionaryGroup,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { readDictionariesFromDisk } from '../utils/readDictionariesFromDisk';\nimport {\n type LocalizedDictionaryOutput,\n type QualifiedMergedDictionaryOutput,\n writeDynamicDictionary,\n writeDynamicQualifiedDictionaries,\n} from './writeDynamicDictionary';\nimport { writeFetchDictionary } from './writeFetchDictionary';\nimport {\n type PlainMergedDictionaryOutput,\n writeMergedDictionaries,\n} from './writeMergedDictionary';\nimport { writeNestedDictionaries } from './writeNestedDictionary';\nimport { writeUnmergedDictionaries } from './writeUnmergedDictionary';\n\nexport type BuildDictionariesOptions = Partial<{\n formats: typeof OUTPUT_FORMAT;\n importOtherDictionaries: boolean;\n env: 'prod' | 'dev';\n}>;\n\nconst defaultOptions = {\n formats: OUTPUT_FORMAT,\n importOtherDictionaries: true,\n env: 'dev',\n} as const satisfies BuildDictionariesOptions;\n\n/**\n * Appends the already-built declarations sharing a key with\n * `localDictionaries` (other `localId`), so a partial rebuild does not drop\n * the declarations coming from other content files.\n */\nexport const addStoredSiblingDictionaries = (\n localDictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Dictionary[] => {\n const storedUnmergedDictionaries: Record<string, Dictionary[]> =\n readDictionariesFromDisk(configuration.system.unmergedDictionariesDir);\n\n const siblingDictionaries = localDictionaries.flatMap((localDictionary) =>\n (storedUnmergedDictionaries[localDictionary.key] ?? []).filter(\n (storedDictionary) => storedDictionary.localId !== localDictionary.localId\n )\n );\n\n return [...localDictionaries, ...siblingDictionaries];\n};\n\n/**\n * This function transpile the bundled code to to make dictionaries as JSON files\n */\nexport const buildDictionary = async (\n localDictionariesEntries: Dictionary[],\n configuration: IntlayerConfig,\n options?: BuildDictionariesOptions\n) => {\n const importMode =\n configuration?.build?.importMode ??\n configuration?.dictionary?.importMode ??\n IMPORT_MODE;\n\n const { importOtherDictionaries, env, formats } = {\n ...defaultOptions,\n ...options,\n };\n\n // Reinsert other dictionaries with the same key to avoid merging errors\n const unmergedDictionariesToUpdate: Dictionary[] = importOtherDictionaries\n ? addStoredSiblingDictionaries(localDictionariesEntries, configuration)\n : [...localDictionariesEntries];\n\n const unmergedDictionaries = await writeUnmergedDictionaries(\n unmergedDictionariesToUpdate,\n configuration,\n env\n );\n\n const mergedDictionaries = await writeMergedDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n // `nest()` dependency graph, read back from disk so it stays complete on\n // incremental rebuilds where only a subset of dictionaries was regenerated.\n // Every artifact kind attaches its dependencies, letting `getNesting` resolve\n // them locally instead of through the registry the optimizer strips.\n const nestedDictionaryGraph = getNestedDictionaryGraph(\n Object.values(\n readDictionariesFromDisk<Record<string, Dictionary>>(\n configuration.system.dictionariesDir\n )\n )\n );\n\n await writeNestedDictionaries(nestedDictionaryGraph, configuration, formats);\n\n const dictionariesToBuildDynamic: PlainMergedDictionaryOutput = {};\n const qualifiedDictionariesToBuildDynamic: QualifiedMergedDictionaryOutput =\n {};\n const keysToBuildFetch = new Set<string>();\n\n for (const [key, mergedResult] of Object.entries(mergedDictionaries)) {\n const dictionary = mergedResult.dictionary;\n\n if (isQualifiedDictionaryGroup(dictionary)) {\n // Collections / variants resolve their qualifier at\n // runtime from a selector. Static mode keeps every entry in one JSON;\n // dynamic mode splits them into one chunk per (locale, qualifierId).\n const entryMode = dictionary.importMode ?? importMode;\n\n if (entryMode === 'dynamic') {\n qualifiedDictionariesToBuildDynamic[key] = {\n dictionaryPath: mergedResult.dictionaryPath,\n dictionary,\n };\n } else if (entryMode === 'fetch') {\n const appLogger = getAppLogger(configuration);\n appLogger(\n `Dictionary ${colorizeKey(key)} uses 'fetch' import mode with (${dictionary.qualifierTypes.join(', ')}) entries — fetch mode is not qualifier-aware yet, falling back to static import.`,\n { level: 'warn' }\n );\n }\n\n continue;\n }\n\n const mode = dictionary.importMode ?? importMode;\n\n if (mode === 'dynamic' || mode === 'fetch') {\n dictionariesToBuildDynamic[key] = {\n dictionaryPath: mergedResult.dictionaryPath,\n dictionary,\n };\n }\n\n if (mode === 'fetch') {\n keysToBuildFetch.add(key);\n }\n }\n\n // A lazily loaded dictionary resolves its `nest()` references from chunks\n // loaded by the same loader, so its nest targets need dynamic artifacts of\n // their own — whatever import mode they declare for their own call sites.\n for (const consumerKey of Object.keys(dictionariesToBuildDynamic)) {\n for (const nestedKey of nestedDictionaryGraph.get(consumerKey) ?? []) {\n if (dictionariesToBuildDynamic[nestedKey]) continue;\n\n const nestedResult = mergedDictionaries[nestedKey];\n if (\n !nestedResult ||\n isQualifiedDictionaryGroup(nestedResult.dictionary)\n ) {\n continue;\n }\n\n dictionariesToBuildDynamic[nestedKey] = {\n dictionaryPath: nestedResult.dictionaryPath,\n dictionary: nestedResult.dictionary,\n };\n }\n }\n\n let dynamicDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (Object.keys(dictionariesToBuildDynamic).length > 0) {\n dynamicDictionaries = await writeDynamicDictionary(\n dictionariesToBuildDynamic,\n configuration,\n formats,\n nestedDictionaryGraph\n );\n }\n\n if (Object.keys(qualifiedDictionariesToBuildDynamic).length > 0) {\n await writeDynamicQualifiedDictionaries(\n qualifiedDictionariesToBuildDynamic,\n configuration,\n formats\n );\n }\n\n let fetchDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (dynamicDictionaries && keysToBuildFetch.size > 0) {\n const dictionariesToBuildFetch: LocalizedDictionaryOutput = {};\n\n for (const key of keysToBuildFetch) {\n if (dynamicDictionaries[key]) {\n dictionariesToBuildFetch[key] = dynamicDictionaries[key];\n }\n }\n\n if (Object.keys(dictionariesToBuildFetch).length > 0) {\n fetchDictionaries = await writeFetchDictionary(\n dictionariesToBuildFetch,\n configuration,\n formats,\n nestedDictionaryGraph\n );\n }\n }\n\n return {\n unmergedDictionaries,\n mergedDictionaries,\n dynamicDictionaries,\n fetchDictionaries,\n };\n};\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAM,iBAAiB;CACrB,SAASA;CACT,yBAAyB;C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EA,MAAM,OAAO,WAAW,cAAc;EAEtC,IAAI,SAAS,aAAa,SAAS,SACjC,2BAA2B,OAAO;GAChC,gBAAgB,aAAa;GAC7B;EACF;EAGF,IAAI,SAAS,SACX,iBAAiB,IAAI,GAAG;CAE5B;CAKA,KAAK,MAAM,eAAe,OAAO,KAAK,0BAA0B,GAC9D,KAAK,MAAM,aAAa,sBAAsB,IAAI,WAAW,KAAK,CAAC,GAAG;EACpE,IAAI,2BAA2B,YAAY;EAE3C,MAAM,eAAe,mBAAmB;EACxC,IACE,CAAC,oBACDF,iEAA2B,aAAa,UAAU,GAElD;EAGF,2BAA2B,aAAa;GACtC,gBAAgB,aAAa;GAC7B,YAAY,aAAa;EAC3B;CACF;CAGF,IAAI,sBAAwD;CAE5D,IAAI,OAAO,KAAK,0BAA0B,CAAC,CAAC,SAAS,GACnD,sBAAsB,MAAMG,8EAC1B,4BACA,eACA,SACA,qBACF;CAGF,IAAI,OAAO,KAAK,mCAAmC,CAAC,CAAC,SAAS,GAC5D,MAAMC,yFACJ,qCACA,eACA,OACF;CAGF,IAAI,oBAAsD;CAE1D,IAAI,uBAAuB,iBAAiB,OAAO,GAAG;EACpD,MAAM,2BAAsD,CAAC;EAE7D,KAAK,MAAM,OAAO,kBAChB,IAAI,oBAAoB,MACtB,yBAAyB,OAAO,oBAAoB;EAIxD,IAAI,OAAO,KAAK,wBAAwB,CAAC,CAAC,SAAS,GACjD,oBAAoB,MAAMC,0EACxB,0BACA,eACA,SACA,qBACF;CAEJ;CAEA,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
@@ -1,6 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./buildIntlayerDictionary.cjs');
3
3
  const require_buildIntlayerDictionary_processContentDeclaration = require('./processContentDeclaration.cjs');
4
+ const require_buildIntlayerDictionary_rebuildUnmergedDictionaries = require('./rebuildUnmergedDictionaries.cjs');
4
5
 
6
+ exports.addStoredSiblingDictionaries = require_buildIntlayerDictionary_buildIntlayerDictionary.addStoredSiblingDictionaries;
5
7
  exports.buildDictionary = require_buildIntlayerDictionary_buildIntlayerDictionary.buildDictionary;
6
- exports.processContentDeclaration = require_buildIntlayerDictionary_processContentDeclaration.processContentDeclaration;
8
+ exports.processContentDeclaration = require_buildIntlayerDictionary_processContentDeclaration.processContentDeclaration;
9
+ exports.rebuildUnmergedDictionaries = require_buildIntlayerDictionary_rebuildUnmergedDictionaries.rebuildUnmergedDictionaries;
@@ -0,0 +1,23 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_buildIntlayerDictionary_writeUnmergedDictionary = require('./writeUnmergedDictionary.cjs');
3
+ const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./buildIntlayerDictionary.cjs');
4
+ const require_loadDictionaries_loadLocalDictionaries = require('../loadDictionaries/loadLocalDictionaries.cjs');
5
+
6
+ //#region src/buildIntlayerDictionary/rebuildUnmergedDictionaries.ts
7
+ /**
8
+ * Reloads a content declaration file and rewrites only the unmerged
9
+ * dictionaries of its keys. Used by the editor server right after writing a
10
+ * source file, so the next read reflects the write without waiting for the
11
+ * app watcher (which still owns the merged / dynamic / type outputs).
12
+ *
13
+ * @returns The reloaded declarations of the file.
14
+ */
15
+ const rebuildUnmergedDictionaries = async (contentDeclarationPath, configuration) => {
16
+ const localDictionaries = await require_loadDictionaries_loadLocalDictionaries.loadLocalDictionaries(contentDeclarationPath, configuration);
17
+ await require_buildIntlayerDictionary_writeUnmergedDictionary.writeUnmergedDictionaries(require_buildIntlayerDictionary_buildIntlayerDictionary.addStoredSiblingDictionaries(localDictionaries, configuration), configuration, "dev");
18
+ return localDictionaries;
19
+ };
20
+
21
+ //#endregion
22
+ exports.rebuildUnmergedDictionaries = rebuildUnmergedDictionaries;
23
+ //# sourceMappingURL=rebuildUnmergedDictionaries.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rebuildUnmergedDictionaries.cjs","names":["loadLocalDictionaries","writeUnmergedDictionaries","addStoredSiblingDictionaries"],"sources":["../../../src/buildIntlayerDictionary/rebuildUnmergedDictionaries.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { addStoredSiblingDictionaries } from './buildIntlayerDictionary';\nimport { writeUnmergedDictionaries } from './writeUnmergedDictionary';\n\n/**\n * Reloads a content declaration file and rewrites only the unmerged\n * dictionaries of its keys. Used by the editor server right after writing a\n * source file, so the next read reflects the write without waiting for the\n * app watcher (which still owns the merged / dynamic / type outputs).\n *\n * @returns The reloaded declarations of the file.\n */\nexport const rebuildUnmergedDictionaries = async (\n contentDeclarationPath: string,\n configuration: IntlayerConfig\n): Promise<Dictionary[]> => {\n const localDictionaries = await loadLocalDictionaries(\n contentDeclarationPath,\n configuration\n );\n\n await writeUnmergedDictionaries(\n addStoredSiblingDictionaries(localDictionaries, configuration),\n configuration,\n 'dev'\n );\n\n return localDictionaries;\n};\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,8BAA8B,OACzC,wBACA,kBAC0B;CAC1B,MAAM,oBAAoB,MAAMA,qEAC9B,wBACA,aACF;CAEA,MAAMC,kFACJC,qFAA6B,mBAAmB,aAAa,GAC7D,eACA,KACF;CAEA,OAAO;AACT"}
package/dist/cjs/cli.cjs CHANGED
@@ -5,6 +5,7 @@ const require_listDictionariesPath = require('./listDictionariesPath.cjs');
5
5
  const require_prepareIntlayer = require('./prepareIntlayer.cjs');
6
6
  const require_writeContentDeclaration_detectExportedComponentName = require('./writeContentDeclaration/detectExportedComponentName.cjs');
7
7
  const require_writeContentDeclaration_transformJSFile = require('./writeContentDeclaration/transformJSFile.cjs');
8
+ const require_writeContentDeclaration_renderContentDeclaration = require('./writeContentDeclaration/renderContentDeclaration.cjs');
8
9
  const require_getContentDeclarationFileTemplate_getContentDeclarationFileTemplate = require('./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs');
9
10
  const require_writeContentDeclaration_writeJSFile = require('./writeContentDeclaration/writeJSFile.cjs');
10
11
  const require_writeContentDeclaration_writeContentDeclaration = require('./writeContentDeclaration/writeContentDeclaration.cjs');
@@ -15,14 +16,18 @@ const require_init_utils_packageManager = require('./init/utils/packageManager.c
15
16
  const require_init_utils_nextCompilerBabel = require('./init/utils/nextCompilerBabel.cjs');
16
17
  const require_init_utils_urlRoutingFramework = require('./init/utils/urlRoutingFramework.cjs');
17
18
  const require_init_upgradeIntlayerPackages = require('./init/upgradeIntlayerPackages.cjs');
19
+ const require_init_utils_contentLayout = require('./init/utils/contentLayout.cjs');
18
20
  const require_init_index = require('./init/index.cjs');
19
21
  const require_installLSP = require('./installLSP.cjs');
20
22
  const require_installSkills_index = require('./installSkills/index.cjs');
21
23
  const require_installMCP_installMCP = require('./installMCP/installMCP.cjs');
22
24
  const require_listGitFiles = require('./listGitFiles.cjs');
23
25
 
26
+ exports.CATALOG_MESSAGE_FORMATS = require_init_utils_contentLayout.CATALOG_MESSAGE_FORMATS;
24
27
  exports.COMPAT_I18N_LIBRARIES = require_init_utils_packageManager.COMPAT_I18N_LIBRARIES;
28
+ exports.CONTENT_FORMATS_BY_LAYOUT = require_init_utils_contentLayout.CONTENT_FORMATS_BY_LAYOUT;
25
29
  exports.DocumentationRouter = require_init_documentationRouter.DocumentationRouter;
30
+ exports.MCP_TRANSPORTS = require_installMCP_installMCP.MCP_TRANSPORTS;
26
31
  exports.NEXT_INTLAYER_BABEL_CONFIG_CONTENT = require_init_utils_nextCompilerBabel.NEXT_INTLAYER_BABEL_CONFIG_CONTENT;
27
32
  exports.PLATFORMS = require_installSkills_index.PLATFORMS;
28
33
  exports.PLATFORMS_METADATA = require_installSkills_index.PLATFORMS_METADATA;
@@ -32,9 +37,12 @@ exports.detectCompatI18nLibraries = require_init_utils_packageManager.detectComp
32
37
  exports.detectExportedComponentName = require_writeContentDeclaration_detectExportedComponentName.detectExportedComponentName;
33
38
  exports.detectFormatCommand = require_detectFormatCommand.detectFormatCommand;
34
39
  exports.detectPackageManager = require_init_utils_packageManager.detectPackageManager;
40
+ exports.detectPlatform = require_installSkills_index.detectPlatform;
35
41
  exports.enableEditorInConfig = require_init_cms.enableEditorInConfig;
36
42
  exports.findLockFileDir = require_init_utils_packageManager.findLockFileDir;
43
+ exports.formatContentDeclaration = require_writeContentDeclaration_renderContentDeclaration.formatContentDeclaration;
37
44
  exports.getContentDeclarationFileTemplate = require_getContentDeclarationFileTemplate_getContentDeclarationFileTemplate.getContentDeclarationFileTemplate;
45
+ exports.getContentLayoutSetup = require_init_utils_contentLayout.getContentLayoutSetup;
38
46
  exports.getDefaultApplicationURL = require_init_index.getDefaultApplicationURL;
39
47
  exports.getDocumentationUrl = require_init_documentationRouter.getDocumentationUrl;
40
48
  exports.getGitRootDir = require_listProjects.getGitRootDir;
@@ -46,6 +54,7 @@ exports.installLSP = require_installLSP.installLSP;
46
54
  exports.installMCP = require_installMCP_installMCP.installMCP;
47
55
  exports.installPackages = require_init_utils_packageManager.installPackages;
48
56
  exports.installSkills = require_installSkills_index.installSkills;
57
+ exports.isRenderableContentDeclarationPath = require_writeContentDeclaration_renderContentDeclaration.isRenderableContentDeclarationPath;
49
58
  exports.listDictionaries = require_listDictionariesPath.listDictionaries;
50
59
  exports.listDictionariesWithStats = require_listDictionariesPath.listDictionariesWithStats;
51
60
  exports.listGitFiles = require_listGitFiles.listGitFiles;
@@ -54,6 +63,9 @@ exports.listProjects = require_listProjects.listProjects;
54
63
  exports.logConfigDetails = require_logConfigDetails.logConfigDetails;
55
64
  exports.logInitSuccessMessage = require_init_index.logInitSuccessMessage;
56
65
  exports.prepareIntlayer = require_prepareIntlayer.prepareIntlayer;
66
+ exports.renderContentDeclaration = require_writeContentDeclaration_renderContentDeclaration.renderContentDeclaration;
67
+ exports.renderMarkdownContentDeclaration = require_writeContentDeclaration_renderContentDeclaration.renderMarkdownContentDeclaration;
68
+ exports.renderYamlContentDeclaration = require_writeContentDeclaration_renderContentDeclaration.renderYamlContentDeclaration;
57
69
  exports.setupCmsCredentials = require_init_cms.setupCmsCredentials;
58
70
  exports.transformJSFile = require_writeContentDeclaration_transformJSFile.transformJSFile;
59
71
  exports.upgradeIntlayerPackages = require_init_upgradeIntlayerPackages.upgradeIntlayerPackages;
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionaries.cjs","names":["getConfiguration","getAppLogger","dictionaryEndpoint","createIntlayerCMS","chunkArray","parallelize","retryManager","x"],"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { createIntlayerCMS } from '@intlayer/api';\nimport { dictionaryEndpoint } from '@intlayer/api/dictionary';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, x } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { retryManager } from '@intlayer/config/utils';\nimport type { DictionariesStatus } from './loadDictionaries';\nimport { chunkArray } from './utils/chunkArray';\nimport { parallelize } from './utils/parallelize';\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":";;;;;;;;;;;;;;AAeA,MAAM,mCAAmC;;AAGzC,MAAM,4BAA4B;;AAGlC,MAAM,oBAAoB;;AAG1B,MAAM,sBAAsB;;AAG5B,MAAM,kDAAkC,IAAI,IAAI;CAAC;CAAK;CAAK;AAAG,CAAC;;;;;;AAO/D,MAAM,oBAAoB,UAA4B;CACpD,MAAM,SAAU,OAA+B;CAE/C,IAAI,OAAO,WAAW,UAAU,OAAO;CAEvC,IAAI,UAAU,KAAK,OAAO;CAE1B,OAAO,gCAAgC,IAAI,MAAM;AACnD;;;;;;;AAQA,MAAM,8BAA8B,UACjC,OAA+B,WAAW;;;;;;;;;;AAqC7C,MAAa,2BAA2B,OACtC,SACA,mBAC6B;CAC7B,MAAM,aAASA,wCAAiB;CAChC,MAAM,gBAAYC,sCAAa,MAAM;CACrC,IAAI;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AM,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,MANoBD,sCACzB,SACA,cACA,gBACF,EAEmB,CAAC,KAAK;CAC3B,SAAS,QAAQ;EACf,UAAU,GAAGE,0BAAE,wCAAwC,EAAE,OAAO,QAAQ,CAAC;EACzE,OAAO,CAAC;CACV;AACF"}
1
+ {"version":3,"file":"fetchDistantDictionaries.cjs","names":["getConfiguration","getAppLogger","dictionaryEndpoint","createIntlayerCMS","chunkArray","parallelize","retryManager","x"],"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 { retryManager } from '@intlayer/config/utils';\nimport type { DictionariesStatus } from './loadDictionaries';\nimport { chunkArray } from './utils/chunkArray';\nimport { parallelize } from './utils/parallelize';\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":";;;;;;;;;;;;;;AAaA,MAAM,mCAAmC;;AAGzC,MAAM,4BAA4B;;AAGlC,MAAM,oBAAoB;;AAG1B,MAAM,sBAAsB;;AAG5B,MAAM,kDAAkC,IAAI,IAAI;CAAC;CAAK;CAAK;AAAG,CAAC;;;;;;AAO/D,MAAM,oBAAoB,UAA4B;CACpD,MAAM,SAAU,OAA+B;CAE/C,IAAI,O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O,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,MANoBD,sCACzB,SACA,cACA,gBACF,EAEmB,CAAC,KAAK;CAC3B,SAAS,QAAQ;EACf,UAAU,GAAGE,0BAAE,wCAAwC,EAAE,OAAO,QAAQ,CAAC;EACzE,OAAO,CAAC;CACV;AACF"}
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_utils_formatter = require('./utils/formatter.cjs');
3
3
  const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./buildIntlayerDictionary/buildIntlayerDictionary.cjs');
4
+ const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
4
5
  const require_createDictionaryEntryPoint_createDictionaryEntryPoint = require('./createDictionaryEntryPoint/createDictionaryEntryPoint.cjs');
5
6
  const require_createType_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
6
7
  const require_createType_createType = require('./createType/createType.cjs');
7
- const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
8
8
  let _intlayer_config_logger = require("@intlayer/config/logger");
9
9
 
10
10
  //#region src/handleAdditionalContentDeclarationFile.ts
@@ -1,11 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_utils_formatter = require('./utils/formatter.cjs');
3
3
  const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./buildIntlayerDictionary/buildIntlayerDictionary.cjs');
4
+ const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
4
5
  const require_createDictionaryEntryPoint_getBuiltDictionariesPath = require('./createDictionaryEntryPoint/getBuiltDictionariesPath.cjs');
5
6
  const require_createDictionaryEntryPoint_createDictionaryEntryPoint = require('./createDictionaryEntryPoint/createDictionaryEntryPoint.cjs');
6
7
  const require_createType_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
7
8
  const require_createType_createType = require('./createType/createType.cjs');
8
- const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
9
9
  const require_cleanRemovedContentDeclaration = require('./cleanRemovedContentDeclaration.cjs');
10
10
  let node_path = require("node:path");
11
11
  let _intlayer_config_logger = require("@intlayer/config/logger");
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_utils_formatter = require('./utils/formatter.cjs');
3
3
  const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./buildIntlayerDictionary/buildIntlayerDictionary.cjs');
4
+ const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
4
5
  const require_createType_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
5
6
  const require_createType_createType = require('./createType/createType.cjs');
6
- const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
7
7
  const require_listDictionariesPath = require('./listDictionariesPath.cjs');
8
8
  const require_cleanRemovedContentDeclaration = require('./cleanRemovedContentDeclaration.cjs');
9
9
  let node_path = require("node:path");
@@ -171,6 +171,23 @@ const setCompilerOutputInConfig = async (rootDir, outputTemplate) => {
171
171
  return configFile;
172
172
  };
173
173
  /**
174
+ * Sets `dictionary.locale` to the default locale in the project's Intlayer
175
+ * configuration file. Returns the config file that was updated, or `undefined`
176
+ * when none was found.
177
+ */
178
+ const setDictionaryLocaleInConfig = async (rootDir) => {
179
+ const configFile = await findIntlayerConfigFile(rootDir);
180
+ if (!configFile) return void 0;
181
+ const extension = configFile.split(".").pop();
182
+ const content = await require_init_utils_fileSystem.readFileFromRoot(rootDir, configFile);
183
+ const updatedContent = require_init_utils_configManipulation.setIntlayerConfigDictionaryLocale(content, extension);
184
+ if (updatedContent !== content) {
185
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, configFile, updatedContent);
186
+ (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Set ${(0, _intlayer_config_logger.colorize)("dictionary.locale", _intlayer_config_colors.GREY_LIGHT)} to the default locale in ${(0, _intlayer_config_logger.colorizePath)(configFile)}`);
187
+ }
188
+ return configFile;
189
+ };
190
+ /**
174
191
  * Completes the CMS setup once credentials are received from the login flow:
175
192
  * writes them to the environment file and enables the editor in the Intlayer
176
193
  * configuration file.
@@ -185,6 +202,7 @@ exports.INTLAYER_CONFIG_FILE_CANDIDATES = INTLAYER_CONFIG_FILE_CANDIDATES;
185
202
  exports.enableEditorInConfig = enableEditorInConfig;
186
203
  exports.findEnvFile = findEnvFile;
187
204
  exports.setCompilerOutputInConfig = setCompilerOutputInConfig;
205
+ exports.setDictionaryLocaleInConfig = setDictionaryLocaleInConfig;
188
206
  exports.setEnableProxyInConfig = setEnableProxyInConfig;
189
207
  exports.setRoutingModeInConfig = setRoutingModeInConfig;
190
208
  exports.setRoutingStorageOnlyInConfig = setRoutingStorageOnlyInConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"cms.cjs","names":["exists","fg","readFileFromRoot","writeFileToRoot","v","colorizePath","colorize","ANSIColors","x","enableIntlayerEditorConfig","setIntlayerConfigRoutingMode","setIntlayerConfigEnableProxy","setIntlayerConfigRoutingStorageOnly","setIntlayerConfigCompilerOutput"],"sources":["../../../src/init/cms.ts"],"sourcesContent":["import * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, colorizePath, logger, v, x } from '@intlayer/config/logger';\nimport fg from 'fast-glob';\nimport {\n enableIntlayerEditorConfig,\n type RoutingMode,\n setIntlayerConfigCompilerOutput,\n setIntlayerConfigEnableProxy,\n setIntlayerConfigRoutingMode,\n setIntlayerConfigRoutingStorageOnly,\n} from './utils/configManipulation';\nimport { exists, readFileFromRoot, writeFileToRoot } from './utils/fileSystem';\n\n/**\n * Intlayer configuration file candidates, ordered by the precedence used when\n * resolving which file to mutate.\n */\nexport const INTLAYER_CONFIG_FILE_CANDIDATES = [\n 'intlayer.config.ts',\n 'intlayer.config.mjs',\n 'intlayer.config.js',\n 'intlayer.config.cjs',\n 'intlayer.config.json',\n] as const;\n\n/**\n * Environment files searched (most-preferred first) when persisting the CMS\n * credentials. The first existing match is reused; otherwise a `.env` file is\n * created at the project root.\n */\nconst ENV_FILE_CANDIDATES = ['.env', '.env.local', '.env.development'] as const;\n\n/** Credentials returned by the CMS login flow (access key pair). */\nexport type CmsCredentials = {\n clientId: string;\n clientSecret: string;\n};\n\n/**\n * Resolves the first existing Intlayer configuration file at the project root,\n * or `undefined` when none is present.\n */\nconst findIntlayerConfigFile = async (\n rootDir: string\n): Promise<(typeof INTLAYER_CONFIG_FILE_CANDIDATES)[number] | undefined> => {\n for (const candidate of INTLAYER_CONFIG_FILE_CANDIDATES) {\n if (await exists(rootDir, candidate)) {\n return candidate;\n }\n }\n\n return undefined;\n};\n\n/**\n * Locates the environment file the CMS credentials should be written to. Uses\n * `fast-glob` to detect an existing dotenv file at the project root, preferring\n * a plain `.env`; falls back to `.env` (to be created) when none exist.\n */\nexport const findEnvFile = async (rootDir: string): Promise<string> => {\n const matches = await fg([...ENV_FILE_CANDIDATES], {\n cwd: rootDir,\n dot: true,\n deep: 1,\n onlyFiles: true,\n });\n\n return (\n ENV_FILE_CANDIDATES.find((candidate) => matches.includes(candidate)) ??\n '.env'\n );\n};\n\n/**\n * Inserts or updates a `KEY=value` line in dotenv file content. An existing\n * assignment of the same key is replaced in place; otherwise the line is\n * appended with a trailing newline.\n */\nconst upsertEnvVariable = (\n content: string,\n key: string,\n value: string\n): string => {\n const line = `${key}=${value}`;\n const keyMatcher = new RegExp(`^${key}=.*$`, 'm');\n\n if (keyMatcher.test(content)) {\n return content.replace(keyMatcher, line);\n }\n\n const needsLeadingNewline = content.length > 0 && !content.endsWith('\\n');\n\n return `${content}${needsLeadingNewline ? '\\n' : ''}${line}\\n`;\n};\n\n/**\n * Persists the CMS access-key credentials to the project's environment file as\n * `INTLAYER_CLIENT_ID` / `INTLAYER_CLIENT_SECRET`. The target file is detected\n * with {@link findEnvFile} and created when missing. Returns the relative path\n * of the file that was written.\n */\nexport const writeCmsCredentialsToEnv = async (\n rootDir: string,\n { clientId, clientSecret }: CmsCredentials\n): Promise<string> => {\n const envFile = await findEnvFile(rootDir);\n\n let content = '';\n if (await exists(rootDir, envFile)) {\n content = await readFileFromRoot(rootDir, envFile);\n }\n\n let updatedContent = content;\n updatedContent = upsertEnvVariable(\n updatedContent,\n 'INTLAYER_CLIENT_ID',\n clientId\n );\n updatedContent = upsertEnvVariable(\n updatedContent,\n 'INTLAYER_CLIENT_SECRET',\n clientSecret\n );\n\n await writeFileToRoot(rootDir, envFile, updatedContent);\n logger(\n `${v} Saved Intlayer CMS credentials to ${colorizePath(envFile)} (${colorize('INTLAYER_CLIENT_ID', ANSIColors.GREY_LIGHT)}, ${colorize('INTLAYER_CLIENT_SECRET', ANSIColors.GREY_LIGHT)})`\n );\n\n return envFile;\n};\n\n/**\n * Enables the Intlayer visual editor in the project's configuration file:\n * flips `editor.enabled` to `true` and wires `clientId` / `clientSecret` to the\n * matching environment variables. JSON configs cannot reference `process.env`,\n * so they are skipped with a warning. Returns the config file that was updated,\n * or `undefined` when no editable config was found.\n */\nexport const enableEditorInConfig = async (\n rootDir: string\n): Promise<string | undefined> => {\n const configFile = await findIntlayerConfigFile(rootDir);\n\n if (!configFile) {\n logger(\n `${x} Could not find an Intlayer configuration file to enable the editor.`,\n { level: 'warn' }\n );\n return undefined;\n }\n\n const extension = configFile.split('.').pop()!;\n\n if (extension === 'json') {\n logger(\n `${x} ${colorizePath(configFile)} is a JSON config and cannot reference environment variables. Enable the editor and set clientId/clientSecret manually.`,\n { level: 'warn' }\n );\n return undefined;\n }\n\n const content = await readFileFromRoot(rootDir, configFile);\n const updatedContent = enableIntlayerEditorConfig(content);\n\n if (updatedContent !== content) {\n await writeFileToRoot(rootDir, configFile, updatedContent);\n logger(`${v} Enabled the Intlayer editor in ${colorizePath(configFile)}`);\n } else {\n logger(\n `${v} ${colorizePath(configFile)} already has the Intlayer editor enabled`\n );\n }\n\n return configFile;\n};\n\n/**\n * Sets `routing.mode` in the project's Intlayer configuration file. Returns the\n * config file that was updated, or `undefined` when none was found.\n */\nexport const setRoutingModeInConfig = async (\n rootDir: string,\n mode: RoutingMode\n): Promise<string | undefined> => {\n const configFile = await findIntlayerConfigFile(rootDir);\n\n if (!configFile) return undefined;\n\n const extension = configFile.split('.').pop()!;\n const content = await readFileFromRoot(rootDir, configFile);\n const updatedContent = setIntlayerConfigRoutingMode(content, extension, mode);\n\n if (updatedContent !== content) {\n await writeFileToRoot(rootDir, configFile, updatedContent);\n logger(\n `${v} Set ${colorize(`routing.mode = '${mode}'`, ANSIColors.GREY_LIGHT)} in ${colorizePath(configFile)}`\n );\n }\n\n return configFile;\n};\n\n/**\n * Sets `routing.enableProxy` in the project's Intlayer configuration file.\n * Returns the config file that was updated, or `undefined` when none was found.\n */\nexport const setEnableProxyInConfig = async (\n rootDir: string,\n enableProxy: boolean\n): Promise<string | undefined> => {\n const configFile = await findIntlayerConfigFile(rootDir);\n\n if (!configFile) return undefined;\n\n const extension = configFile.split('.').pop()!;\n const content = await readFileFromRoot(rootDir, configFile);\n const updatedContent = setIntlayerConfigEnableProxy(\n content,\n extension,\n enableProxy\n );\n\n if (updatedContent !== content) {\n await writeFileToRoot(rootDir, configFile, updatedContent);\n logger(\n `${v} Set ${colorize(`routing.enableProxy = ${enableProxy}`, ANSIColors.GREY_LIGHT)} in ${colorizePath(configFile)}`\n );\n }\n\n return configFile;\n};\n\n/**\n * Reduces `routing` in the project's Intlayer configuration file to its\n * `storage` entry. Returns the config file that was updated, or `undefined`\n * when none was found.\n */\nexport const setRoutingStorageOnlyInConfig = async (\n rootDir: string\n): Promise<string | undefined> => {\n const configFile = await findIntlayerConfigFile(rootDir);\n\n if (!configFile) return undefined;\n\n const extension = configFile.split('.').pop()!;\n const content = await readFileFromRoot(rootDir, configFile);\n const updatedContent = setIntlayerConfigRoutingStorageOnly(\n content,\n extension\n );\n\n if (updatedContent !== content) {\n await writeFileToRoot(rootDir, configFile, updatedContent);\n logger(\n `${v} Kept only ${colorize('routing.storage', ANSIColors.GREY_LIGHT)} in ${colorizePath(configFile)} (no URL routing in this project)`\n );\n }\n\n return configFile;\n};\n\n/**\n * Sets `compiler.output` in the project's Intlayer configuration file to the\n * given `{{variable}}` path template. Returns the config file that was updated,\n * or `undefined` when none was found.\n */\nexport const setCompilerOutputInConfig = async (\n rootDir: string,\n outputTemplate: string\n): Promise<string | undefined> => {\n const configFile = await findIntlayerConfigFile(rootDir);\n\n if (!configFile) return undefined;\n\n const extension = configFile.split('.').pop()!;\n const content = await readFileFromRoot(rootDir, configFile);\n const updatedContent = setIntlayerConfigCompilerOutput(\n content,\n extension,\n outputTemplate\n );\n\n if (updatedContent !== content) {\n await writeFileToRoot(rootDir, configFile, updatedContent);\n logger(\n `${v} Set ${colorize(`compiler.output = '${outputTemplate}'`, ANSIColors.GREY_LIGHT)} in ${colorizePath(configFile)}`\n );\n }\n\n return configFile;\n};\n\n/**\n * Completes the CMS setup once credentials are received from the login flow:\n * writes them to the environment file and enables the editor in the Intlayer\n * configuration file.\n */\nexport const setupCmsCredentials = async (\n rootDir: string,\n credentials: CmsCredentials\n): Promise<void> => {\n await writeCmsCredentialsToEnv(rootDir, credentials);\n await enableEditorInConfig(rootDir);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAa,kCAAkC;CAC7C;CACA;CACA;CACA;CACA;AACF;;;;;;AAOA,MAAM,sBAAsB;CAAC;CAAQ;CAAc;AAAkB;;;;;AAYrE,MAAM,yBAAyB,OAC7B,YAC0E;CAC1E,KAAK,MAAM,aAAa,iCACtB,IAAI,MAAMA,qCAAO,SAAS,SAAS,GACjC,OAAO;AAKb;;;;;;AAOA,MAAa,cAAc,OAAO,YAAqC;CACrE,MAAM,UAAU,UAAMC,mBAAG,CAAC,GAAG,mBAAmB,GAAG;EACjD,KAAK;EACL,KAAK;EACL,MAAM;EACN,WAAW;CACb,CAAC;CAED,OACE,oBAAoB,MAAM,cAAc,QAAQ,SAAS,SAAS,CAAC,KACnE;AAEJ;;;;;;AAOA,MAAM,qBACJ,SACA,KACA,UACW;CACX,MAAM,OAAO,GAAG,IAAI,GAAG;CACvB,MAAM,aAAa,IAAI,OAAO,IAAI,IAAI,OAAO,GAAG;CAEhD,IAAI,WAAW,KAAK,OAAO,GACzB,OAAO,QAAQ,QAAQ,YAAY,IAAI;CAKzC,OAAO,GAAG,UAFkB,QAAQ,SAAS,KAAK,CAAC,QAAQ,SAAS,IAAI,IAE9B,OAAO,KAAK,KAAK;AAC7D;;;;;;;AAQA,MAAa,2BAA2B,OACtC,SACA,EAAE,UAAU,mBACQ;CACpB,MAAM,UAAU,MAAM,YAAY,OAAO;CAEzC,IAAI,UAAU;CACd,IAAI,MAAMD,qCAAO,SAAS,OAAO,GAC/B,UAAU,MAAME,+CAAiB,SAAS,OAAO;CAGnD,IAAI,iBAAiB;CACrB,iBAAiB,kBACf,gBACA,sBACA,QACF;CACA,iBAAiB,kBACf,gBACA,0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mB,SAAS;EAC9B,MAAMV,8CAAgB,SAAS,YAAY,cAAc;EACzD,oCACE,GAAGC,0BAAE,WAAOE,kCAAS,sBAAsB,eAAe,IAAIC,wBAAW,UAAU,EAAE,UAAMF,sCAAa,UAAU,GACpH;CACF;CAEA,OAAO;AACT;;;;;;AAOA,MAAa,sBAAsB,OACjC,SACA,gBACkB;CAClB,MAAM,yBAAyB,SAAS,WAAW;CACnD,MAAM,qBAAqB,OAAO;AACpC"}
1
+ {"version":3,"file":"cms.cjs","names":["exists","fg","readFileFromRoot","writeFileToRoot","v","colorizePath","colorize","ANSIColors","x","enableIntlayerEditorConfig","setIntlayerConfigRoutingMode","setIntlayerConfigEnableProxy","setIntlayerConfigRoutingStorageOnly","setIntlayerConfigCompilerOutput","setIntlayerConfigDictionaryLocale"],"sources":["../../../src/init/cms.ts"],"sourcesContent":["import * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, colorizePath, logger, v, x } from '@intlayer/config/logger';\nimport fg from 'fast-glob';\nimport {\n enableIntlayerEditorConfig,\n type RoutingMode,\n setIntlayerConfigCompilerOutput,\n setIntlayerConfigDictionaryLocale,\n setIntlayerConfigEnableProxy,\n setIntlayerConfigRoutingMode,\n setIntlayerConfigRoutingStorageOnly,\n} from './utils/configManipulation';\nimport { exists, readFileFromRoot, writeFileToRoot } from './utils/fileSystem';\n\n/**\n * Intlayer configuration file candidates, ordered by the precedence used when\n * resolving which file to mutate.\n */\nexport const INTLAYER_CONFIG_FILE_CANDIDATES = [\n 'intlayer.config.ts',\n 'intlayer.config.mjs',\n 'intlayer.config.js',\n 'intlayer.config.cjs',\n 'intlayer.config.json',\n] as const;\n\n/**\n * Environment files searched (most-preferred first) when persisting the CMS\n * credentials. The first existing match is reused; otherwise a `.env` file is\n * created at the project root.\n */\nconst ENV_FILE_CANDIDATES = ['.env', '.env.local', '.env.development'] as const;\n\n/** Credentials returned by the CMS login flow (access key pair). */\nexport type CmsCredentials = {\n clientId: string;\n clientSecret: string;\n};\n\n/**\n * Resolves the first existing Intlayer configuration file at the project root,\n * or `undefined` when none is present.\n */\nconst findIntlayerConfigFile = async (\n rootDir: string\n): Promise<(typeof INTLAYER_CONFIG_FILE_CANDIDATES)[number] | undefined> => {\n for (const candidate of INTLAYER_CONFIG_FILE_CANDIDATES) {\n if (await exists(rootDir, candidate)) {\n return candidate;\n }\n }\n\n return undefined;\n};\n\n/**\n * Locates the environment file the CMS credentials should be written to. Uses\n * `fast-glob` to detect an existing dotenv file at the project root, preferring\n * a plain `.env`; falls back to `.env` (to be created) when none exist.\n */\nexport const findEnvFile = async (rootDir: string): Promise<string> => {\n const matches = await fg([...ENV_FILE_CANDIDATES], {\n cwd: rootDir,\n dot: true,\n deep: 1,\n onlyFiles: true,\n });\n\n return (\n ENV_FILE_CANDIDATES.find((candidate) => matches.includes(candidate)) ??\n '.env'\n );\n};\n\n/**\n * Inserts or updates a `KEY=value` line in dotenv file content. An existing\n * assignment of the same key is replaced in place; otherwise the line is\n * appended with a trailing newline.\n */\nconst upsertEnvVariable = (\n content: string,\n key: string,\n value: string\n): string => {\n const line = `${key}=${value}`;\n const keyMatcher = new RegExp(`^${key}=.*$`, 'm');\n\n if (keyMatcher.test(content)) {\n return content.replace(keyMatcher, line);\n }\n\n const needsLeadingNewline = content.length > 0 && !content.endsWith('\\n');\n\n return `${content}${needsLeadingNewline ? '\\n' : ''}${line}\\n`;\n};\n\n/**\n * Persists the CMS access-key credentials to the project's environment file as\n * `INTLAYER_CLIENT_ID` / `INTLAYER_CLIENT_SECRET`. The target file is detected\n * with {@link findEnvFile} and created when missing. Returns the relative path\n * of the file that was written.\n */\nexport const writeCmsCredentialsToEnv = async (\n rootDir: string,\n { clientId, clientSecret }: CmsCredentials\n): Promise<string> => {\n const envFile = await findEnvFile(rootDir);\n\n let content = '';\n if (await exists(rootDir, envFile)) {\n content = await readFileFromRoot(rootDir, envFile);\n }\n\n let updatedContent = content;\n updatedContent = upsertEnvVariable(\n updatedContent,\n 'INTLAYER_CLIENT_ID',\n clientId\n );\n updatedContent = upsertEnvVariable(\n updatedContent,\n 'INTLAYER_CLIENT_SECRET',\n clientSecret\n );\n\n await writeFileToRoot(rootDir, envFile, updatedContent);\n logger(\n `${v} Saved Intlayer CMS credentials to ${colorizePath(envFile)} (${colorize('INTLAYER_CLIENT_ID', ANSIColors.GREY_LIGHT)}, ${colorize('INTLAYER_CLIENT_SECRET', ANSIColors.GREY_LIGHT)})`\n );\n\n return envFile;\n};\n\n/**\n * Enables the Intlayer visual editor in the project's configuration file:\n * flips `editor.enabled` to `true` and wires `clientId` / `clientSecret` to the\n * matching environment variables. JSON configs cannot reference `process.env`,\n * so they are skipped with a warning. Returns the config file that was updated,\n * or `undefined` when no editable config was found.\n */\nexport const enableEditorInConfig = async (\n rootDir: string\n): Promise<string | undefined> => {\n const configFile = await findIntlayerConfigFile(rootDir);\n\n if (!configFile) {\n logger(\n `${x} Could not find an Intlayer configuration file to enable the editor.`,\n { level: 'warn' }\n );\n return undefined;\n }\n\n const extension = configFile.split('.').pop()!;\n\n if (extension === 'json') {\n logger(\n `${x} ${colorizePath(configFile)} is a JSON config and cannot reference environment variables. Enable the editor and set clientId/clientSecret manually.`,\n { level: 'warn' }\n );\n return undefined;\n }\n\n const content = await readFileFromRoot(rootDir, configFile);\n const updatedContent = enableIntlayerEditorConfig(content);\n\n if (updatedContent !== content) {\n await writeFileToRoot(rootDir, configFile, updatedContent);\n logger(`${v} Enabled the Intlayer editor in ${colorizePath(configFile)}`);\n } else {\n logger(\n `${v} ${colorizePath(configFile)} already has the Intlayer editor enabled`\n );\n }\n\n return configFile;\n};\n\n/**\n * Sets `routing.mode` in the project's Intlayer configuration file. Returns the\n * config file that was updated, or `undefined` when none was found.\n */\nexport const setRoutingModeInConfig = async (\n rootDir: string,\n mode: RoutingMode\n): Promise<string | undefined> => {\n const configFile = await findIntlayerConfigFile(rootDir);\n\n if (!configFile) return undefined;\n\n const extension = configFile.split('.').pop()!;\n const content = await readFileFromRoot(rootDir, configFile);\n const updatedContent = setIntlayerConfigRoutingMode(content, extension, mode);\n\n if (updatedContent !== content) {\n await writeFileToRoot(rootDir, configFile, updatedContent);\n logger(\n `${v} Set ${colorize(`routing.mode = '${mode}'`, ANSIColors.GREY_LIGHT)} in ${colorizePath(configFile)}`\n );\n }\n\n return configFile;\n};\n\n/**\n * Sets `routing.enableProxy` in the project's Intlayer configuration file.\n * Returns the config file that was updated, or `undefined` when none was found.\n */\nexport const setEnableProxyInConfig = async (\n rootDir: string,\n enableProxy: boolean\n): Promise<string | undefined> => {\n const configFile = await findIntlayerConfigFile(rootDir);\n\n if (!configFile) return undefined;\n\n const extension = configFile.split('.').pop()!;\n const content = await readFileFromRoot(rootDir, configFile);\n const updatedContent = setIntlayerConfigEnableProxy(\n content,\n extension,\n enableProxy\n );\n\n if (updatedContent !== content) {\n await writeFileToRoot(rootDir, configFile, updatedContent);\n logger(\n `${v} Set ${colorize(`routing.enableProxy = ${enableProxy}`, ANSIColors.GREY_LIGHT)} in ${colorizePath(configFile)}`\n );\n }\n\n return configFile;\n};\n\n/**\n * Reduces `routing` in the project's Intlayer configuration file to its\n * `storage` entry. Returns the config file that was updated, or `undefined`\n * when none was found.\n */\nexport const setRoutingStorageOnlyInConfig = async (\n rootDir: string\n): Promise<string | undefined> => {\n const configFile = await findIntlayerConfigFile(rootDir);\n\n if (!configFile) return undefined;\n\n const extension = configFile.split('.').pop()!;\n const content = await readFileFromRoot(rootDir, configFile);\n const updatedContent = setIntlayerConfigRoutingStorageOnly(\n content,\n extension\n );\n\n if (updatedContent !== content) {\n await writeFileToRoot(rootDir, configFile, updatedContent);\n logger(\n `${v} Kept only ${colorize('routing.storage', ANSIColors.GREY_LIGHT)} in ${colorizePath(configFile)} (no URL routing in this project)`\n );\n }\n\n return configFile;\n};\n\n/**\n * Sets `compiler.output` in the project's Intlayer configuration file to the\n * given `{{variable}}` path template. Returns the config file that was updated,\n * or `undefined` when none was found.\n */\nexport const setCompilerOutputInConfig = async (\n rootDir: string,\n outputTemplate: string\n): Promise<string | undefined> => {\n const configFile = await findIntlayerConfigFile(rootDir);\n\n if (!configFile) return undefined;\n\n const extension = configFile.split('.').pop()!;\n const content = await readFileFromRoot(rootDir, configFile);\n const updatedContent = setIntlayerConfigCompilerOutput(\n content,\n extension,\n outputTemplate\n );\n\n if (updatedContent !== content) {\n await writeFileToRoot(rootDir, configFile, updatedContent);\n logger(\n `${v} Set ${colorize(`compiler.output = '${outputTemplate}'`, ANSIColors.GREY_LIGHT)} in ${colorizePath(configFile)}`\n );\n }\n\n return configFile;\n};\n\n/**\n * Sets `dictionary.locale` to the default locale in the project's Intlayer\n * configuration file. Returns the config file that was updated, or `undefined`\n * when none was found.\n */\nexport const setDictionaryLocaleInConfig = async (\n rootDir: string\n): Promise<string | undefined> => {\n const configFile = await findIntlayerConfigFile(rootDir);\n\n if (!configFile) return undefined;\n\n const extension = configFile.split('.').pop()!;\n const content = await readFileFromRoot(rootDir, configFile);\n const updatedContent = setIntlayerConfigDictionaryLocale(content, extension);\n\n if (updatedContent !== content) {\n await writeFileToRoot(rootDir, configFile, updatedContent);\n logger(\n `${v} Set ${colorize('dictionary.locale', ANSIColors.GREY_LIGHT)} to the default locale in ${colorizePath(configFile)}`\n );\n }\n\n return configFile;\n};\n\n/**\n * Completes the CMS setup once credentials are received from the login flow:\n * writes them to the environment file and enables the editor in the Intlayer\n * configuration file.\n */\nexport const setupCmsCredentials = async (\n rootDir: string,\n credentials: CmsCredentials\n): Promise<void> => {\n await writeCmsCredentialsToEnv(rootDir, credentials);\n await enableEditorInConfig(rootDir);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAa,kCAAkC;CAC7C;CACA;CACA;CACA;CACA;AACF;;;;;;AAOA,MAAM,sBAAsB;CAAC;CAAQ;CAAc;AAAkB;;;;;AAYrE,MAAM,yBAAyB,OAC7B,YAC0E;CAC1E,KAAK,MAAM,aAAa,iCACtB,IAAI,MAAMA,qCAAO,SAAS,SAAS,GACjC,OAAO;AAK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