@intlayer/chokidar 9.0.0-canary.1 → 9.0.0-canary.11

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 (152) hide show
  1. package/dist/assets/initConfig/templates/cjs.txt +10 -3
  2. package/dist/assets/initConfig/templates/json.txt +8 -2
  3. package/dist/assets/initConfig/templates/mjs.txt +10 -3
  4. package/dist/assets/initConfig/templates/ts.txt +10 -3
  5. package/dist/assets/installSkills/skills/cli.md +0 -1
  6. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  7. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +3 -3
  8. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  9. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  10. package/dist/cjs/cli.cjs +9 -0
  11. package/dist/cjs/fetchDistantDictionaries.cjs +3 -2
  12. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  13. package/dist/cjs/init/cms.cjs +140 -0
  14. package/dist/cjs/init/cms.cjs.map +1 -0
  15. package/dist/cjs/init/frameworkSetup/index.cjs +27 -0
  16. package/dist/cjs/init/frameworkSetup/index.cjs.map +1 -0
  17. package/dist/cjs/init/frameworkSetup/nextAppRouter/detect.cjs +56 -0
  18. package/dist/cjs/init/frameworkSetup/nextAppRouter/detect.cjs.map +1 -0
  19. package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs +107 -0
  20. package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs.map +1 -0
  21. package/dist/cjs/init/frameworkSetup/nextAppRouter/restructure.cjs +163 -0
  22. package/dist/cjs/init/frameworkSetup/nextAppRouter/restructure.cjs.map +1 -0
  23. package/dist/cjs/init/frameworkSetup/nextAppRouter/templates.cjs +122 -0
  24. package/dist/cjs/init/frameworkSetup/nextAppRouter/templates.cjs.map +1 -0
  25. package/dist/cjs/init/frameworkSetup/nextAppRouter/transforms.cjs +196 -0
  26. package/dist/cjs/init/frameworkSetup/nextAppRouter/transforms.cjs.map +1 -0
  27. package/dist/cjs/init/frameworkSetup/tanstackStart/detect.cjs +31 -0
  28. package/dist/cjs/init/frameworkSetup/tanstackStart/detect.cjs.map +1 -0
  29. package/dist/cjs/init/frameworkSetup/tanstackStart/index.cjs +76 -0
  30. package/dist/cjs/init/frameworkSetup/tanstackStart/index.cjs.map +1 -0
  31. package/dist/cjs/init/frameworkSetup/tanstackStart/restructure.cjs +116 -0
  32. package/dist/cjs/init/frameworkSetup/tanstackStart/restructure.cjs.map +1 -0
  33. package/dist/cjs/init/frameworkSetup/tanstackStart/templates.cjs +106 -0
  34. package/dist/cjs/init/frameworkSetup/tanstackStart/templates.cjs.map +1 -0
  35. package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs +141 -0
  36. package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs.map +1 -0
  37. package/dist/cjs/init/frameworkSetup/types.cjs +0 -0
  38. package/dist/cjs/init/index.cjs +138 -39
  39. package/dist/cjs/init/index.cjs.map +1 -1
  40. package/dist/cjs/init/utils/astImports.cjs +56 -0
  41. package/dist/cjs/init/utils/astImports.cjs.map +1 -0
  42. package/dist/cjs/init/utils/configManipulation.cjs +221 -24
  43. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
  44. package/dist/cjs/init/utils/fileSystem.cjs +111 -4
  45. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
  46. package/dist/cjs/init/utils/index.cjs +19 -0
  47. package/dist/cjs/init/utils/nextCompilerBabel.cjs +119 -0
  48. package/dist/cjs/init/utils/nextCompilerBabel.cjs.map +1 -0
  49. package/dist/cjs/init/utils/packageManager.cjs +148 -32
  50. package/dist/cjs/init/utils/packageManager.cjs.map +1 -1
  51. package/dist/cjs/initConfig/index.cjs +11 -2
  52. package/dist/cjs/initConfig/index.cjs.map +1 -1
  53. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +2 -1
  54. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  55. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  56. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +3 -3
  57. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  58. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
  59. package/dist/esm/cli.mjs +4 -1
  60. package/dist/esm/fetchDistantDictionaries.mjs +4 -3
  61. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  62. package/dist/esm/init/cms.mjs +131 -0
  63. package/dist/esm/init/cms.mjs.map +1 -0
  64. package/dist/esm/init/frameworkSetup/index.mjs +26 -0
  65. package/dist/esm/init/frameworkSetup/index.mjs.map +1 -0
  66. package/dist/esm/init/frameworkSetup/nextAppRouter/detect.mjs +52 -0
  67. package/dist/esm/init/frameworkSetup/nextAppRouter/detect.mjs.map +1 -0
  68. package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs +104 -0
  69. package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs.map +1 -0
  70. package/dist/esm/init/frameworkSetup/nextAppRouter/restructure.mjs +157 -0
  71. package/dist/esm/init/frameworkSetup/nextAppRouter/restructure.mjs.map +1 -0
  72. package/dist/esm/init/frameworkSetup/nextAppRouter/templates.mjs +113 -0
  73. package/dist/esm/init/frameworkSetup/nextAppRouter/templates.mjs.map +1 -0
  74. package/dist/esm/init/frameworkSetup/nextAppRouter/transforms.mjs +193 -0
  75. package/dist/esm/init/frameworkSetup/nextAppRouter/transforms.mjs.map +1 -0
  76. package/dist/esm/init/frameworkSetup/tanstackStart/detect.mjs +28 -0
  77. package/dist/esm/init/frameworkSetup/tanstackStart/detect.mjs.map +1 -0
  78. package/dist/esm/init/frameworkSetup/tanstackStart/index.mjs +73 -0
  79. package/dist/esm/init/frameworkSetup/tanstackStart/index.mjs.map +1 -0
  80. package/dist/esm/init/frameworkSetup/tanstackStart/restructure.mjs +108 -0
  81. package/dist/esm/init/frameworkSetup/tanstackStart/restructure.mjs.map +1 -0
  82. package/dist/esm/init/frameworkSetup/tanstackStart/templates.mjs +102 -0
  83. package/dist/esm/init/frameworkSetup/tanstackStart/templates.mjs.map +1 -0
  84. package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs +139 -0
  85. package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs.map +1 -0
  86. package/dist/esm/init/frameworkSetup/types.mjs +0 -0
  87. package/dist/esm/init/index.mjs +140 -41
  88. package/dist/esm/init/index.mjs.map +1 -1
  89. package/dist/esm/init/utils/astImports.mjs +51 -0
  90. package/dist/esm/init/utils/astImports.mjs.map +1 -0
  91. package/dist/esm/init/utils/configManipulation.mjs +217 -25
  92. package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
  93. package/dist/esm/init/utils/fileSystem.mjs +111 -6
  94. package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
  95. package/dist/esm/init/utils/index.mjs +6 -4
  96. package/dist/esm/init/utils/nextCompilerBabel.mjs +115 -0
  97. package/dist/esm/init/utils/nextCompilerBabel.mjs.map +1 -0
  98. package/dist/esm/init/utils/packageManager.mjs +145 -34
  99. package/dist/esm/init/utils/packageManager.mjs.map +1 -1
  100. package/dist/esm/initConfig/index.mjs +11 -2
  101. package/dist/esm/initConfig/index.mjs.map +1 -1
  102. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +3 -2
  103. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  104. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
  105. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +1 -1
  106. package/dist/types/cli.d.ts +5 -1
  107. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
  108. package/dist/types/formatDictionary.d.ts +2 -4
  109. package/dist/types/formatDictionary.d.ts.map +1 -1
  110. package/dist/types/init/cms.d.ts +51 -0
  111. package/dist/types/init/cms.d.ts.map +1 -0
  112. package/dist/types/init/frameworkSetup/index.d.ts +13 -0
  113. package/dist/types/init/frameworkSetup/index.d.ts.map +1 -0
  114. package/dist/types/init/frameworkSetup/nextAppRouter/detect.d.ts +25 -0
  115. package/dist/types/init/frameworkSetup/nextAppRouter/detect.d.ts.map +1 -0
  116. package/dist/types/init/frameworkSetup/nextAppRouter/index.d.ts +12 -0
  117. package/dist/types/init/frameworkSetup/nextAppRouter/index.d.ts.map +1 -0
  118. package/dist/types/init/frameworkSetup/nextAppRouter/restructure.d.ts +56 -0
  119. package/dist/types/init/frameworkSetup/nextAppRouter/restructure.d.ts.map +1 -0
  120. package/dist/types/init/frameworkSetup/nextAppRouter/templates.d.ts +26 -0
  121. package/dist/types/init/frameworkSetup/nextAppRouter/templates.d.ts.map +1 -0
  122. package/dist/types/init/frameworkSetup/nextAppRouter/transforms.d.ts +23 -0
  123. package/dist/types/init/frameworkSetup/nextAppRouter/transforms.d.ts.map +1 -0
  124. package/dist/types/init/frameworkSetup/tanstackStart/detect.d.ts +19 -0
  125. package/dist/types/init/frameworkSetup/tanstackStart/detect.d.ts.map +1 -0
  126. package/dist/types/init/frameworkSetup/tanstackStart/index.d.ts +13 -0
  127. package/dist/types/init/frameworkSetup/tanstackStart/index.d.ts.map +1 -0
  128. package/dist/types/init/frameworkSetup/tanstackStart/restructure.d.ts +68 -0
  129. package/dist/types/init/frameworkSetup/tanstackStart/restructure.d.ts.map +1 -0
  130. package/dist/types/init/frameworkSetup/tanstackStart/templates.d.ts +22 -0
  131. package/dist/types/init/frameworkSetup/tanstackStart/templates.d.ts.map +1 -0
  132. package/dist/types/init/frameworkSetup/tanstackStart/transforms.d.ts +17 -0
  133. package/dist/types/init/frameworkSetup/tanstackStart/transforms.d.ts.map +1 -0
  134. package/dist/types/init/frameworkSetup/types.d.ts +43 -0
  135. package/dist/types/init/frameworkSetup/types.d.ts.map +1 -0
  136. package/dist/types/init/index.d.ts +31 -0
  137. package/dist/types/init/index.d.ts.map +1 -1
  138. package/dist/types/init/utils/astImports.d.ts +29 -0
  139. package/dist/types/init/utils/astImports.d.ts.map +1 -0
  140. package/dist/types/init/utils/configManipulation.d.ts +54 -4
  141. package/dist/types/init/utils/configManipulation.d.ts.map +1 -1
  142. package/dist/types/init/utils/fileSystem.d.ts +62 -1
  143. package/dist/types/init/utils/fileSystem.d.ts.map +1 -1
  144. package/dist/types/init/utils/index.d.ts +6 -4
  145. package/dist/types/init/utils/nextCompilerBabel.d.ts +53 -0
  146. package/dist/types/init/utils/nextCompilerBabel.d.ts.map +1 -0
  147. package/dist/types/init/utils/packageManager.d.ts +95 -5
  148. package/dist/types/init/utils/packageManager.d.ts.map +1 -1
  149. package/dist/types/initConfig/index.d.ts +1 -1
  150. package/dist/types/initConfig/index.d.ts.map +1 -1
  151. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
  152. package/package.json +9 -9
@@ -1,10 +1,10 @@
1
+ const { Locales } = require('intlayer');
2
+
1
3
  /**
2
4
  * Intlayer configuration file documentation
3
5
  * @see https://intlayer.org/doc/concept/configuration
4
6
  */
5
7
 
6
- const { Locales } = require('intlayer');
7
-
8
8
  /** @type {import('intlayer').IntlayerConfig} */
9
9
  const config = {
10
10
  internationalization: {
@@ -24,6 +24,13 @@ const config = {
24
24
  * Default: "prefix-no-default"
25
25
  */
26
26
  mode: 'prefix-no-default',
27
+
28
+ /**
29
+ * Enables the Intlayer locale-routing proxy (middleware).
30
+ * Handles locale detection, redirects and rewrites in dev, preview and SSR.
31
+ * Default: true
32
+ */
33
+ enableProxy: false,
27
34
  },
28
35
  editor: {
29
36
  /**
@@ -52,7 +59,7 @@ const config = {
52
59
  applicationContext: [''].join('\n'),
53
60
  },
54
61
  compiler: {
55
- enabled: true,
62
+ enabled: false,
56
63
 
57
64
  /**
58
65
  * Defines the output files path for autogenerated content (compiler / autofill / extract)
@@ -19,7 +19,13 @@
19
19
  * - "search-params": Use search params to define the locale (e.g., /dashboard/?locale=en, /dashboard/?locale=fr)
20
20
  * Default: "prefix-no-default"
21
21
  */
22
- "mode": "prefix-no-default"
22
+ "mode": "prefix-no-default",
23
+ /**
24
+ * Enables the Intlayer locale-routing proxy (middleware).
25
+ * Handles locale detection, redirects and rewrites in dev, preview and SSR.
26
+ * Default: true
27
+ */
28
+ "enableProxy": false
23
29
  },
24
30
  "editor": {
25
31
  /**
@@ -49,7 +55,7 @@
49
55
  "applicationContext": ""
50
56
  },
51
57
  "compiler": {
52
- "enabled": true,
58
+ "enabled": false,
53
59
  /**
54
60
  * Defines the output files path for autogenerated content.
55
61
  * Example: "./{{fileName}}.content.ts"
@@ -1,10 +1,10 @@
1
+ import { Locales } from 'intlayer';
2
+
1
3
  /**
2
4
  * Intlayer configuration file documentation
3
5
  * @see https://intlayer.org/doc/concept/configuration
4
6
  */
5
7
 
6
- import { Locales } from 'intlayer';
7
-
8
8
  /** @type {import('intlayer').IntlayerConfig} */
9
9
  const config = {
10
10
  internationalization: {
@@ -24,6 +24,13 @@ const config = {
24
24
  * Default: "prefix-no-default"
25
25
  */
26
26
  mode: 'prefix-no-default',
27
+
28
+ /**
29
+ * Enables the Intlayer locale-routing proxy (middleware).
30
+ * Handles locale detection, redirects and rewrites in dev, preview and SSR.
31
+ * Default: true
32
+ */
33
+ enableProxy: false,
27
34
  },
28
35
  editor: {
29
36
  /**
@@ -52,7 +59,7 @@ const config = {
52
59
  applicationContext: [''].join('\n'),
53
60
  },
54
61
  compiler: {
55
- enabled: true,
62
+ enabled: false,
56
63
 
57
64
  /**
58
65
  * Defines the output files path for autogenerated content (compiler / autofill / extract)
@@ -1,10 +1,10 @@
1
+ import { type IntlayerConfig, Locales } from 'intlayer';
2
+
1
3
  /**
2
4
  * Intlayer configuration file documentation
3
5
  * @see https://intlayer.org/doc/concept/configuration
4
6
  */
5
7
 
6
- import { type IntlayerConfig, Locales } from 'intlayer';
7
-
8
8
  const config: IntlayerConfig = {
9
9
  internationalization: {
10
10
  locales: [Locales.ENGLISH],
@@ -23,6 +23,13 @@ const config: IntlayerConfig = {
23
23
  * Default: "prefix-no-default"
24
24
  */
25
25
  mode: 'prefix-no-default',
26
+
27
+ /**
28
+ * Enables the Intlayer locale-routing proxy (middleware).
29
+ * Handles locale detection, redirects and rewrites in dev, preview and SSR.
30
+ * Default: true
31
+ */
32
+ enableProxy: false,
26
33
  },
27
34
  editor: {
28
35
  /**
@@ -51,7 +58,7 @@ const config: IntlayerConfig = {
51
58
  applicationContext: [''].join('\n'),
52
59
  },
53
60
  compiler: {
54
- enabled: true,
61
+ enabled: false,
55
62
 
56
63
  /**
57
64
  * Defines the output files path for autogenerated content (compiler / autofill / extract)
@@ -40,7 +40,6 @@ npm install intlayer-cli
40
40
 
41
41
  - [Build](https://intlayer.org/doc/concept/cli/build.md)
42
42
  - [CI](https://intlayer.org/doc/concept/cli.md)
43
- - [CLI Overview](https://intlayer.org/doc/concept/cli/export.md)
44
43
  - [Configuration](https://intlayer.org/doc/concept/cli/configuration.md)
45
44
  - [Debug](https://intlayer.org/doc/concept/cli/debug.md)
46
45
  - [Doc Review](https://intlayer.org/doc/concept/cli/doc-review.md)
@@ -1 +1 @@
1
- {"version":3,"file":"buildIntlayerDictionary.cjs","names":["OUTPUT_FORMAT","IMPORT_MODE","readDictionariesFromDisk","writeUnmergedDictionaries","writeMergedDictionaries","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 { isQualifiedDictionaryGroup } 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 { 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 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 / meta records 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 let dynamicDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (Object.keys(dictionariesToBuildDynamic).length > 0) {\n dynamicDictionaries = await writeDynamicDictionary(\n dictionariesToBuildDynamic,\n configuration,\n formats\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 );\n }\n }\n\n return {\n unmergedDictionaries,\n mergedDictionaries,\n dynamicDictionaries,\n fetchDictionaries,\n };\n};\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,iBAAiB;CACrB,SAASA;CACT,yBAAyB;CACzB,KAAK;CACN;;;;AAKD,MAAa,kBAAkB,OAC7B,0BACA,eACA,YACG;CACH,MAAM,aACJ,eAAe,OAAO,cACtB,eAAe,YAAY,cAC3BC;CAEF,MAAM,EAAE,yBAAyB,KAAK,YAAY;EAChD,GAAG;EACH,GAAG;EACJ;CAED,MAAM,+BAA6C,CACjD,GAAG,yBACJ;AAED,KAAI,yBAAyB;EAC3B,MAAM,2BACJC,gEAAyB,cAAc,OAAO,wBAAwB;AAGxE,OAAK,MAAM,qBAAqB,0BAA0B;GACxD,MAAM,kCACJ,yBAAyB,kBAAkB;AAE7C,OAAI,iCAAiC,SAAS,GAAG;IAE/C,MAAM,4BACJ,iCAAiC,QAC9B,uBACC,mBAAmB,YAAY,kBAAkB,QACpD;AAEH,iCAA6B,KAAK,GAAI,6BAA6B,EAAE,CAAE;;;;CAK7E,MAAM,uBAAuB,MAAMC,kFACjC,8BACA,eACA,IACD;CAED,MAAM,qBAAqB,MAAMC,8EAC/B,sBACA,cACD;CAED,MAAM,6BAA0D,EAAE;CAClE,MAAM,sCACJ,EAAE;CACJ,MAAM,mCAAmB,IAAI,KAAa;AAE1C,MAAK,MAAM,CAAC,KAAK,iBAAiB,OAAO,QAAQ,mBAAmB,EAAE;EACpE,MAAM,aAAa,aAAa;AAEhC,2EAA+B,WAAW,EAAE;GAI1C,MAAM,YAAY,WAAW,cAAc;AAE3C,OAAI,cAAc,UAChB,qCAAoC,OAAO;IACzC,gBAAgB,aAAa;IAC7B;IACD;YACQ,cAAc,QAEvB,2CAD+B,cACtB,CACP,uDAA0B,IAAI,CAAC,kCAAkC,WAAW,eAAe,KAAK,KAAK,CAAC,oFACtG,EAAE,OAAO,QAAQ,CAClB;AAGH;;EAGF,MAAM,OAAO,WAAW,cAAc;AAEtC,MAAI,SAAS,aAAa,SAAS,QACjC,4BAA2B,OAAO;GAChC,gBAAgB,aAAa;GAC7B;GACD;AAGH,MAAI,SAAS,QACX,kBAAiB,IAAI,IAAI;;CAI7B,IAAI,sBAAwD;AAE5D,KAAI,OAAO,KAAK,2BAA2B,CAAC,SAAS,EACnD,uBAAsB,MAAMC,8EAC1B,4BACA,eACA,QACD;AAGH,KAAI,OAAO,KAAK,oCAAoC,CAAC,SAAS,EAC5D,OAAMC,yFACJ,qCACA,eACA,QACD;CAGH,IAAI,oBAAsD;AAE1D,KAAI,uBAAuB,iBAAiB,OAAO,GAAG;EACpD,MAAM,2BAAsD,EAAE;AAE9D,OAAK,MAAM,OAAO,iBAChB,KAAI,oBAAoB,KACtB,0BAAyB,OAAO,oBAAoB;AAIxD,MAAI,OAAO,KAAK,yBAAyB,CAAC,SAAS,EACjD,qBAAoB,MAAMC,0EACxB,0BACA,eACA,QACD;;AAIL,QAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"buildIntlayerDictionary.cjs","names":["OUTPUT_FORMAT","IMPORT_MODE","readDictionariesFromDisk","writeUnmergedDictionaries","writeMergedDictionaries","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 { isQualifiedDictionaryGroup } 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 { 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 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 let dynamicDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (Object.keys(dictionariesToBuildDynamic).length > 0) {\n dynamicDictionaries = await writeDynamicDictionary(\n dictionariesToBuildDynamic,\n configuration,\n formats\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 );\n }\n }\n\n return {\n unmergedDictionaries,\n mergedDictionaries,\n dynamicDictionaries,\n fetchDictionaries,\n };\n};\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,iBAAiB;CACrB,SAASA;CACT,yBAAyB;CACzB,KAAK;CACN;;;;AAKD,MAAa,kBAAkB,OAC7B,0BACA,eACA,YACG;CACH,MAAM,aACJ,eAAe,OAAO,cACtB,eAAe,YAAY,cAC3BC;CAEF,MAAM,EAAE,yBAAyB,KAAK,YAAY;EAChD,GAAG;EACH,GAAG;EACJ;CAED,MAAM,+BAA6C,CACjD,GAAG,yBACJ;AAED,KAAI,yBAAyB;EAC3B,MAAM,2BACJC,gEAAyB,cAAc,OAAO,wBAAwB;AAGxE,OAAK,MAAM,qBAAqB,0BAA0B;GACxD,MAAM,kCACJ,yBAAyB,kBAAkB;AAE7C,OAAI,iCAAiC,SAAS,GAAG;IAE/C,MAAM,4BACJ,iCAAiC,QAC9B,uBACC,mBAAmB,YAAY,kBAAkB,QACpD;AAEH,iCAA6B,KAAK,GAAI,6BAA6B,EAAE,CAAE;;;;CAK7E,MAAM,uBAAuB,MAAMC,kFACjC,8BACA,eACA,IACD;CAED,MAAM,qBAAqB,MAAMC,8EAC/B,sBACA,cACD;CAED,MAAM,6BAA0D,EAAE;CAClE,MAAM,sCACJ,EAAE;CACJ,MAAM,mCAAmB,IAAI,KAAa;AAE1C,MAAK,MAAM,CAAC,KAAK,iBAAiB,OAAO,QAAQ,mBAAmB,EAAE;EACpE,MAAM,aAAa,aAAa;AAEhC,2EAA+B,WAAW,EAAE;GAI1C,MAAM,YAAY,WAAW,cAAc;AAE3C,OAAI,cAAc,UAChB,qCAAoC,OAAO;IACzC,gBAAgB,aAAa;IAC7B;IACD;YACQ,cAAc,QAEvB,2CAD+B,cACtB,CACP,uDAA0B,IAAI,CAAC,kCAAkC,WAAW,eAAe,KAAK,KAAK,CAAC,oFACtG,EAAE,OAAO,QAAQ,CAClB;AAGH;;EAGF,MAAM,OAAO,WAAW,cAAc;AAEtC,MAAI,SAAS,aAAa,SAAS,QACjC,4BAA2B,OAAO;GAChC,gBAAgB,aAAa;GAC7B;GACD;AAGH,MAAI,SAAS,QACX,kBAAiB,IAAI,IAAI;;CAI7B,IAAI,sBAAwD;AAE5D,KAAI,OAAO,KAAK,2BAA2B,CAAC,SAAS,EACnD,uBAAsB,MAAMC,8EAC1B,4BACA,eACA,QACD;AAGH,KAAI,OAAO,KAAK,oCAAoC,CAAC,SAAS,EAC5D,OAAMC,yFACJ,qCACA,eACA,QACD;CAGH,IAAI,oBAAsD;AAE1D,KAAI,uBAAuB,iBAAiB,OAAO,GAAG;EACpD,MAAM,2BAAsD,EAAE;AAE9D,OAAK,MAAM,OAAO,iBAChB,KAAI,oBAAoB,KACtB,0BAAyB,OAAO,oBAAoB;AAIxD,MAAI,OAAO,KAAK,yBAAyB,CAAC,SAAS,EACjD,qBAAoB,MAAMC,0EACxB,0BACA,eACA,QACD;;AAIL,QAAO;EACL;EACA;EACA;EACA;EACD"}
@@ -49,8 +49,8 @@ const serializeLoaderTree = (tree, indentLevel) => {
49
49
  }).join(",\n")}\n${pad}}`;
50
50
  };
51
51
  /**
52
- * Generates the entry point of a qualified dictionary (collection / variant /
53
- * meta record, possibly combined). Under each locale the loader map nests one
52
+ * Generates the entry point of a qualified dictionary (collection / variant,
53
+ * possibly combined). Under each locale the loader map nests one
54
54
  * level per declared dimension (canonical order) and carries a marker listing
55
55
  * those dimensions so the runtime can walk the tree.
56
56
  *
@@ -120,7 +120,7 @@ const writeDynamicDictionary = async (mergedDictionaries, configuration, formats
120
120
  };
121
121
  /**
122
122
  * Writes the dynamic chunks and entry points of qualified dictionaries
123
- * (collections, variants, meta records — possibly combined) in
123
+ * (collections, variants — possibly combined) in
124
124
  * `importMode: 'dynamic'`.
125
125
  *
126
126
  * Each entry is reduced to one per-locale chunk written to a path nested by
@@ -1 +1 @@
1
- {"version":3,"file":"writeDynamicDictionary.cjs","names":["QUALIFIER_DYNAMIC_TYPES_KEY","OUTPUT_FORMAT","parallelize","writeJsonIfChanged","writeFileIfChanged","COMPOSITE_ID_SEPARATOR"],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { assertPathWithin } from '@intlayer/config/utils';\nimport {\n COMPOSITE_ID_SEPARATOR,\n QUALIFIER_DYNAMIC_TYPES_KEY,\n reconstructQualifiedEntry,\n} from '@intlayer/core/dictionaryManipulator';\nimport { getPerLocaleDictionary } from '@intlayer/core/plugins';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n Dictionary,\n DictionaryQualifierType,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { PlainMergedDictionaryOutput } from './writeMergedDictionary';\n\nexport type DictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type LocalizedDictionaryResult = Partial<\n Record<Locale, DictionaryResult>\n>;\n\nexport type LocalizedDictionaryOutput = Record<\n string,\n LocalizedDictionaryResult\n>;\n\nconst DICTIONARIES_SUBDIR = 'json'; // Necessary to add a static first dir for Turbopack\n\n/**\n * Generates the content of a dictionary entry point file.\n */\nexport const generateDictionaryEntryPoint = (\n key: string,\n locales: string[],\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const sortedLocales = [...locales].sort((a, b) =>\n String(a).localeCompare(String(b))\n );\n\n const localeEntries = sortedLocales\n .map((locale) =>\n format === 'esm'\n ? ` '${locale}': () => import('./${DICTIONARIES_SUBDIR}/${key}/${locale}.json').then(m => m.default)`\n : ` '${locale}': () => Promise.resolve(require('./${DICTIONARIES_SUBDIR}/${key}/${locale}.json'))`\n )\n .join(',\\n');\n\n if (format === 'esm') {\n return (\n `const content = {\\n${localeEntries}\\n};\\n\\n` +\n `export default content;\\n`\n );\n }\n return `module.exports = {\\n${localeEntries}\\n};\\n`;\n};\n\n/**\n * A nested loader tree: one level per declared dimension, leaves are loader\n * expression strings.\n */\ntype LoaderTree = { [segment: string]: LoaderTree | string };\n\nconst buildLoaderExpression = (\n key: string,\n segments: string[],\n locale: string,\n format: 'cjs' | 'esm'\n): string => {\n const path = `./${DICTIONARIES_SUBDIR}/${key}/${segments.join('/')}/${locale}.json`;\n\n return format === 'esm'\n ? `() => import('${path}').then(m => m.default)`\n : `() => Promise.resolve(require('${path}'))`;\n};\n\nconst buildLoaderTree = (\n key: string,\n entriesSegments: string[][],\n locale: string,\n format: 'cjs' | 'esm'\n): LoaderTree => {\n const root: LoaderTree = {};\n\n for (const segments of entriesSegments) {\n let node = root;\n\n segments.forEach((segment, index) => {\n if (index === segments.length - 1) {\n node[segment] = buildLoaderExpression(key, segments, locale, format);\n return;\n }\n\n node[segment] = (node[segment] as LoaderTree | undefined) ?? {};\n node = node[segment] as LoaderTree;\n });\n }\n\n return root;\n};\n\nconst serializeLoaderTree = (tree: LoaderTree, indentLevel: number): string => {\n const pad = ' '.repeat(indentLevel);\n const innerPad = ' '.repeat(indentLevel + 1);\n\n const lines = Object.keys(tree)\n .sort((a, b) => a.localeCompare(b))\n .map((segment) => {\n const value = tree[segment]!;\n const serialized =\n typeof value === 'string'\n ? value\n : serializeLoaderTree(value, indentLevel + 1);\n\n return `${innerPad}'${segment}': ${serialized}`;\n });\n\n return `{\\n${lines.join(',\\n')}\\n${pad}}`;\n};\n\n/**\n * Generates the entry point of a qualified dictionary (collection / variant /\n * meta record, possibly combined). Under each locale the loader map nests one\n * level per declared dimension (canonical order) and carries a marker listing\n * those dimensions so the runtime can walk the tree.\n *\n * One static `import()` is emitted per leaf `(locale, …segments)` chunk, which\n * keeps the output compatible with bundlers that reject template-literal\n * dynamic imports (Turbopack).\n */\nexport const generateQualifiedDictionaryEntryPoint = (\n key: string,\n qualifierTypes: DictionaryQualifierType[],\n entriesSegments: string[][],\n locales: string[],\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const sortedLocales = [...locales].sort((a, b) =>\n String(a).localeCompare(String(b))\n );\n\n const localeEntries = sortedLocales\n .map((locale) => {\n const tree = buildLoaderTree(key, entriesSegments, locale, format);\n return ` '${locale}': ${serializeLoaderTree(tree, 1)}`;\n })\n .join(',\\n');\n\n const marker = ` '${QUALIFIER_DYNAMIC_TYPES_KEY}': ${JSON.stringify(qualifierTypes)}`;\n\n if (format === 'esm') {\n return (\n `const content = {\\n${marker},\\n${localeEntries}\\n};\\n\\n` +\n `export default content;\\n`\n );\n }\n return `module.exports = {\\n${marker},\\n${localeEntries}\\n};\\n`;\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dynamic_dictionary/dictionaries/en_home.json\n * // .intlayer/dynamic_dictionary/dictionaries/fr_home.json\n * ```\n */\nexport const writeDynamicDictionary = async (\n mergedDictionaries: PlainMergedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { locales, defaultLocale } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.system;\n\n const dictDir = resolve(dynamicDictionariesDir, DICTIONARIES_SUBDIR);\n await mkdir(dictDir, { recursive: true });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Merge dictionaries with the same key and write to dictionariesDir\n await parallelize(\n Object.entries(mergedDictionaries).sort(([a], [b]) =>\n String(a).localeCompare(String(b))\n ),\n async ([key, dictionaryEntry]) => {\n if (key === 'undefined') return;\n\n const localizedDictionariesPathsRecord: LocalizedDictionaryResult = {};\n\n const keyDir = resolve(dictDir, key);\n assertPathWithin(keyDir, dictDir);\n await mkdir(keyDir, { recursive: true });\n\n await parallelize(locales, async (locale) => {\n const localizedDictionary = getPerLocaleDictionary(\n dictionaryEntry.dictionary,\n locale,\n defaultLocale\n );\n\n // Directory structure: json/key/locale.json\n const resultFilePath = resolve(keyDir, `${locale}.json`);\n\n await writeJsonIfChanged(resultFilePath, localizedDictionary).catch(\n (err) => {\n console.error(\n `Error creating localized ${key}/${locale}.json:`,\n err\n );\n }\n );\n\n localizedDictionariesPathsRecord[locale] = {\n dictionaryPath: resultFilePath,\n dictionary: localizedDictionary,\n };\n });\n\n resultDictionariesPaths[key] = localizedDictionariesPathsRecord;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(key, locales, format);\n\n const dynEntryPath = resolve(\n dynamicDictionariesDir,\n `${key}.${extension}`\n );\n assertPathWithin(dynEntryPath, dynamicDictionariesDir);\n\n await writeFileIfChanged(dynEntryPath, content).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(dynEntryPath)}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n\nexport type QualifiedMergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: QualifiedDictionaryGroup;\n};\n\nexport type QualifiedMergedDictionaryOutput = Record<\n string,\n QualifiedMergedDictionaryResult\n>;\n\n/**\n * Writes the dynamic chunks and entry points of qualified dictionaries\n * (collections, variants, meta records — possibly combined) in\n * `importMode: 'dynamic'`.\n *\n * Each entry is reduced to one per-locale chunk written to a path nested by\n * dimension — `json/{key}/{seg1}/{seg2}/{locale}.json` — and a single\n * `{key}.{ext}` entry point exposes the matching nested loader tree, so the\n * entry point is discovered and aggregated exactly like a plain dynamic one.\n */\nexport const writeDynamicQualifiedDictionaries = async (\n qualifiedDictionaries: QualifiedMergedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<void> => {\n const { locales, defaultLocale } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.system;\n\n const dictDir = resolve(dynamicDictionariesDir, DICTIONARIES_SUBDIR);\n await mkdir(dictDir, { recursive: true });\n\n await parallelize(\n Object.entries(qualifiedDictionaries).sort(([a], [b]) =>\n String(a).localeCompare(String(b))\n ),\n async ([key, { dictionary: group }]) => {\n if (key === 'undefined') return;\n\n const entryIds = Object.keys(group.content);\n\n const keyDir = resolve(dictDir, key);\n assertPathWithin(keyDir, dictDir);\n\n // Per-entry segment lists (one segment per declared dimension), reused for\n // both the chunk paths and the generated loader tree.\n const entriesSegments: string[][] = [];\n\n await parallelize(entryIds, async (entryId) => {\n // Rebuild a resolvable dictionary from the content node + composite id\n // so per-locale extraction sees the same `{ key, content, meta? }` shape.\n const entry = reconstructQualifiedEntry(group, entryId);\n\n const segments = entryId.split(COMPOSITE_ID_SEPARATOR);\n entriesSegments.push(segments);\n\n const entryDir = resolve(keyDir, ...segments);\n assertPathWithin(entryDir, keyDir);\n await mkdir(entryDir, { recursive: true });\n\n await parallelize(locales, async (locale) => {\n const localizedDictionary = getPerLocaleDictionary(\n entry,\n locale,\n defaultLocale\n );\n\n // Directory structure: json/key/<…segments>/locale.json\n const resultFilePath = resolve(entryDir, `${locale}.json`);\n\n await writeJsonIfChanged(resultFilePath, localizedDictionary).catch(\n (err) => {\n console.error(\n `Error creating localized ${key}/${segments.join('/')}/${locale}.json:`,\n err\n );\n }\n );\n });\n });\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateQualifiedDictionaryEntryPoint(\n key,\n group.qualifierTypes,\n entriesSegments,\n locales,\n format\n );\n\n const dynEntryPath = resolve(\n dynamicDictionariesDir,\n `${key}.${extension}`\n );\n assertPathWithin(dynEntryPath, dynamicDictionariesDir);\n\n await writeFileIfChanged(dynEntryPath, content).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(dynEntryPath)}:`,\n err\n );\n });\n });\n }\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAqCA,MAAM,sBAAsB;;;;AAK5B,MAAa,gCACX,KACA,SACA,SAAwB,UACb;CAKX,MAAM,gBAJgB,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,MAC1C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CAGD,CAChC,KAAK,WACJ,WAAW,QACP,MAAM,OAAO,qBAAqB,oBAAoB,GAAG,IAAI,GAAG,OAAO,gCACvE,MAAM,OAAO,sCAAsC,oBAAoB,GAAG,IAAI,GAAG,OAAO,UAC7F,CACA,KAAK,MAAM;AAEd,KAAI,WAAW,MACb,QACE,sBAAsB,cAAc;AAIxC,QAAO,uBAAuB,cAAc;;AAS9C,MAAM,yBACJ,KACA,UACA,QACA,WACW;CACX,MAAM,OAAO,KAAK,oBAAoB,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC,GAAG,OAAO;AAE7E,QAAO,WAAW,QACd,iBAAiB,KAAK,2BACtB,kCAAkC,KAAK;;AAG7C,MAAM,mBACJ,KACA,iBACA,QACA,WACe;CACf,MAAM,OAAmB,EAAE;AAE3B,MAAK,MAAM,YAAY,iBAAiB;EACtC,IAAI,OAAO;AAEX,WAAS,SAAS,SAAS,UAAU;AACnC,OAAI,UAAU,SAAS,SAAS,GAAG;AACjC,SAAK,WAAW,sBAAsB,KAAK,UAAU,QAAQ,OAAO;AACpE;;AAGF,QAAK,WAAY,KAAK,YAAuC,EAAE;AAC/D,UAAO,KAAK;IACZ;;AAGJ,QAAO;;A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C,MAAI,QAAQ,YAAa;EAEzB,MAAM,WAAW,OAAO,KAAK,MAAM,QAAQ;EAE3C,MAAM,gCAAiB,SAAS,IAAI;AACpC,+CAAiB,QAAQ,QAAQ;EAIjC,MAAM,kBAA8B,EAAE;AAEtC,QAAMA,sCAAY,UAAU,OAAO,YAAY;GAG7C,MAAM,4EAAkC,OAAO,QAAQ;GAEvD,MAAM,WAAW,QAAQ,MAAMG,4DAAuB;AACtD,mBAAgB,KAAK,SAAS;GAE9B,MAAM,kCAAmB,QAAQ,GAAG,SAAS;AAC7C,gDAAiB,UAAU,OAAO;AAClC,qCAAY,UAAU,EAAE,WAAW,MAAM,CAAC;AAE1C,SAAMH,sCAAY,SAAS,OAAO,WAAW;IAC3C,MAAM,yEACJ,OACA,QACA,cACD;AAKD,UAAMC,qEAFyB,UAAU,GAAG,OAAO,OAEZ,EAAE,oBAAoB,CAAC,OAC3D,QAAQ;AACP,aAAQ,MACN,4BAA4B,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC,GAAG,OAAO,SAChE,IACD;MAEJ;KACD;IACF;AAEF,QAAMD,sCAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;GAC7C,MAAM,UAAU,sCACd,KACA,MAAM,gBACN,iBACA,SACA,OACD;GAED,MAAM,sCACJ,wBACA,GAAG,IAAI,GAAG,YACX;AACD,gDAAiB,cAAc,uBAAuB;AAEtD,SAAME,8CAAmB,cAAc,QAAQ,CAAC,OAAO,QAAQ;AAC7D,YAAQ,MACN,oEAAuC,aAAa,CAAC,IACrD,IACD;KACD;IACF;GAEL"}
1
+ {"version":3,"file":"writeDynamicDictionary.cjs","names":["QUALIFIER_DYNAMIC_TYPES_KEY","OUTPUT_FORMAT","parallelize","writeJsonIfChanged","writeFileIfChanged","COMPOSITE_ID_SEPARATOR"],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { assertPathWithin } from '@intlayer/config/utils';\nimport {\n COMPOSITE_ID_SEPARATOR,\n QUALIFIER_DYNAMIC_TYPES_KEY,\n reconstructQualifiedEntry,\n} from '@intlayer/core/dictionaryManipulator';\nimport { getPerLocaleDictionary } from '@intlayer/core/plugins';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n Dictionary,\n DictionaryQualifierType,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { PlainMergedDictionaryOutput } from './writeMergedDictionary';\n\nexport type DictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type LocalizedDictionaryResult = Partial<\n Record<Locale, DictionaryResult>\n>;\n\nexport type LocalizedDictionaryOutput = Record<\n string,\n LocalizedDictionaryResult\n>;\n\nconst DICTIONARIES_SUBDIR = 'json'; // Necessary to add a static first dir for Turbopack\n\n/**\n * Generates the content of a dictionary entry point file.\n */\nexport const generateDictionaryEntryPoint = (\n key: string,\n locales: string[],\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const sortedLocales = [...locales].sort((a, b) =>\n String(a).localeCompare(String(b))\n );\n\n const localeEntries = sortedLocales\n .map((locale) =>\n format === 'esm'\n ? ` '${locale}': () => import('./${DICTIONARIES_SUBDIR}/${key}/${locale}.json').then(m => m.default)`\n : ` '${locale}': () => Promise.resolve(require('./${DICTIONARIES_SUBDIR}/${key}/${locale}.json'))`\n )\n .join(',\\n');\n\n if (format === 'esm') {\n return (\n `const content = {\\n${localeEntries}\\n};\\n\\n` +\n `export default content;\\n`\n );\n }\n return `module.exports = {\\n${localeEntries}\\n};\\n`;\n};\n\n/**\n * A nested loader tree: one level per declared dimension, leaves are loader\n * expression strings.\n */\ntype LoaderTree = { [segment: string]: LoaderTree | string };\n\nconst buildLoaderExpression = (\n key: string,\n segments: string[],\n locale: string,\n format: 'cjs' | 'esm'\n): string => {\n const path = `./${DICTIONARIES_SUBDIR}/${key}/${segments.join('/')}/${locale}.json`;\n\n return format === 'esm'\n ? `() => import('${path}').then(m => m.default)`\n : `() => Promise.resolve(require('${path}'))`;\n};\n\nconst buildLoaderTree = (\n key: string,\n entriesSegments: string[][],\n locale: string,\n format: 'cjs' | 'esm'\n): LoaderTree => {\n const root: LoaderTree = {};\n\n for (const segments of entriesSegments) {\n let node = root;\n\n segments.forEach((segment, index) => {\n if (index === segments.length - 1) {\n node[segment] = buildLoaderExpression(key, segments, locale, format);\n return;\n }\n\n node[segment] = (node[segment] as LoaderTree | undefined) ?? {};\n node = node[segment] as LoaderTree;\n });\n }\n\n return root;\n};\n\nconst serializeLoaderTree = (tree: LoaderTree, indentLevel: number): string => {\n const pad = ' '.repeat(indentLevel);\n const innerPad = ' '.repeat(indentLevel + 1);\n\n const lines = Object.keys(tree)\n .sort((a, b) => a.localeCompare(b))\n .map((segment) => {\n const value = tree[segment]!;\n const serialized =\n typeof value === 'string'\n ? value\n : serializeLoaderTree(value, indentLevel + 1);\n\n return `${innerPad}'${segment}': ${serialized}`;\n });\n\n return `{\\n${lines.join(',\\n')}\\n${pad}}`;\n};\n\n/**\n * Generates the entry point of a qualified dictionary (collection / variant,\n * possibly combined). Under each locale the loader map nests one\n * level per declared dimension (canonical order) and carries a marker listing\n * those dimensions so the runtime can walk the tree.\n *\n * One static `import()` is emitted per leaf `(locale, …segments)` chunk, which\n * keeps the output compatible with bundlers that reject template-literal\n * dynamic imports (Turbopack).\n */\nexport const generateQualifiedDictionaryEntryPoint = (\n key: string,\n qualifierTypes: DictionaryQualifierType[],\n entriesSegments: string[][],\n locales: string[],\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const sortedLocales = [...locales].sort((a, b) =>\n String(a).localeCompare(String(b))\n );\n\n const localeEntries = sortedLocales\n .map((locale) => {\n const tree = buildLoaderTree(key, entriesSegments, locale, format);\n return ` '${locale}': ${serializeLoaderTree(tree, 1)}`;\n })\n .join(',\\n');\n\n const marker = ` '${QUALIFIER_DYNAMIC_TYPES_KEY}': ${JSON.stringify(qualifierTypes)}`;\n\n if (format === 'esm') {\n return (\n `const content = {\\n${marker},\\n${localeEntries}\\n};\\n\\n` +\n `export default content;\\n`\n );\n }\n return `module.exports = {\\n${marker},\\n${localeEntries}\\n};\\n`;\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dynamic_dictionary/dictionaries/en_home.json\n * // .intlayer/dynamic_dictionary/dictionaries/fr_home.json\n * ```\n */\nexport const writeDynamicDictionary = async (\n mergedDictionaries: PlainMergedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { locales, defaultLocale } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.system;\n\n const dictDir = resolve(dynamicDictionariesDir, DICTIONARIES_SUBDIR);\n await mkdir(dictDir, { recursive: true });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Merge dictionaries with the same key and write to dictionariesDir\n await parallelize(\n Object.entries(mergedDictionaries).sort(([a], [b]) =>\n String(a).localeCompare(String(b))\n ),\n async ([key, dictionaryEntry]) => {\n if (key === 'undefined') return;\n\n const localizedDictionariesPathsRecord: LocalizedDictionaryResult = {};\n\n const keyDir = resolve(dictDir, key);\n assertPathWithin(keyDir, dictDir);\n await mkdir(keyDir, { recursive: true });\n\n await parallelize(locales, async (locale) => {\n const localizedDictionary = getPerLocaleDictionary(\n dictionaryEntry.dictionary,\n locale,\n defaultLocale\n );\n\n // Directory structure: json/key/locale.json\n const resultFilePath = resolve(keyDir, `${locale}.json`);\n\n await writeJsonIfChanged(resultFilePath, localizedDictionary).catch(\n (err) => {\n console.error(\n `Error creating localized ${key}/${locale}.json:`,\n err\n );\n }\n );\n\n localizedDictionariesPathsRecord[locale] = {\n dictionaryPath: resultFilePath,\n dictionary: localizedDictionary,\n };\n });\n\n resultDictionariesPaths[key] = localizedDictionariesPathsRecord;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(key, locales, format);\n\n const dynEntryPath = resolve(\n dynamicDictionariesDir,\n `${key}.${extension}`\n );\n assertPathWithin(dynEntryPath, dynamicDictionariesDir);\n\n await writeFileIfChanged(dynEntryPath, content).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(dynEntryPath)}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n\nexport type QualifiedMergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: QualifiedDictionaryGroup;\n};\n\nexport type QualifiedMergedDictionaryOutput = Record<\n string,\n QualifiedMergedDictionaryResult\n>;\n\n/**\n * Writes the dynamic chunks and entry points of qualified dictionaries\n * (collections, variants — possibly combined) in\n * `importMode: 'dynamic'`.\n *\n * Each entry is reduced to one per-locale chunk written to a path nested by\n * dimension — `json/{key}/{seg1}/{seg2}/{locale}.json` — and a single\n * `{key}.{ext}` entry point exposes the matching nested loader tree, so the\n * entry point is discovered and aggregated exactly like a plain dynamic one.\n */\nexport const writeDynamicQualifiedDictionaries = async (\n qualifiedDictionaries: QualifiedMergedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<void> => {\n const { locales, defaultLocale } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.system;\n\n const dictDir = resolve(dynamicDictionariesDir, DICTIONARIES_SUBDIR);\n await mkdir(dictDir, { recursive: true });\n\n await parallelize(\n Object.entries(qualifiedDictionaries).sort(([a], [b]) =>\n String(a).localeCompare(String(b))\n ),\n async ([key, { dictionary: group }]) => {\n if (key === 'undefined') return;\n\n const entryIds = Object.keys(group.content);\n\n const keyDir = resolve(dictDir, key);\n assertPathWithin(keyDir, dictDir);\n\n // Per-entry segment lists (one segment per declared dimension), reused for\n // both the chunk paths and the generated loader tree.\n const entriesSegments: string[][] = [];\n\n await parallelize(entryIds, async (entryId) => {\n // Rebuild a resolvable dictionary from the content node + composite id\n // so per-locale extraction sees the same `{ key, content, meta? }` shape.\n const entry = reconstructQualifiedEntry(group, entryId);\n\n const segments = entryId.split(COMPOSITE_ID_SEPARATOR);\n entriesSegments.push(segments);\n\n const entryDir = resolve(keyDir, ...segments);\n assertPathWithin(entryDir, keyDir);\n await mkdir(entryDir, { recursive: true });\n\n await parallelize(locales, async (locale) => {\n const localizedDictionary = getPerLocaleDictionary(\n entry,\n locale,\n defaultLocale\n );\n\n // Directory structure: json/key/<…segments>/locale.json\n const resultFilePath = resolve(entryDir, `${locale}.json`);\n\n await writeJsonIfChanged(resultFilePath, localizedDictionary).catch(\n (err) => {\n console.error(\n `Error creating localized ${key}/${segments.join('/')}/${locale}.json:`,\n err\n );\n }\n );\n });\n });\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateQualifiedDictionaryEntryPoint(\n key,\n group.qualifierTypes,\n entriesSegments,\n locales,\n format\n );\n\n const dynEntryPath = resolve(\n dynamicDictionariesDir,\n `${key}.${extension}`\n );\n assertPathWithin(dynEntryPath, dynamicDictionariesDir);\n\n await writeFileIfChanged(dynEntryPath, content).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(dynEntryPath)}:`,\n err\n );\n });\n });\n }\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAqCA,MAAM,sBAAsB;;;;AAK5B,MAAa,gCACX,KACA,SACA,SA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AO;AAClC,qCAAY,UAAU,EAAE,WAAW,MAAM,CAAC;AAE1C,SAAMH,sCAAY,SAAS,OAAO,WAAW;IAC3C,MAAM,yEACJ,OACA,QACA,cACD;AAKD,UAAMC,qEAFyB,UAAU,GAAG,OAAO,OAEZ,EAAE,oBAAoB,CAAC,OAC3D,QAAQ;AACP,aAAQ,MACN,4BAA4B,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC,GAAG,OAAO,SAChE,IACD;MAEJ;KACD;IACF;AAEF,QAAMD,sCAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;GAC7C,MAAM,UAAU,sCACd,KACA,MAAM,gBACN,iBACA,SACA,OACD;GAED,MAAM,sCACJ,wBACA,GAAG,IAAI,GAAG,YACX;AACD,gDAAiB,cAAc,uBAAuB;AAEtD,SAAME,8CAAmB,cAAc,QAAQ,CAAC,OAAO,QAAQ;AAC7D,YAAQ,MACN,oEAAuC,aAAa,CAAC,IACrD,IACD;KACD;IACF;GAEL"}
@@ -1 +1 @@
1
- {"version":3,"file":"writeMergedDictionary.cjs","names":["parallelize","writeJsonIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { assertPathWithin } from '@intlayer/config/utils';\nimport {\n mergeQualifiedDictionaries,\n normalizeDictionaries,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n Dictionary,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary | QualifiedDictionaryGroup;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Merged output restricted to plain (unqualified) dictionaries — qualified\n * groups (collections, variants, meta records) are static-only and filtered\n * out before the dynamic/fetch build steps.\n */\nexport type PlainMergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type PlainMergedDictionaryOutput = Record<\n string,\n PlainMergedDictionaryResult\n>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionary/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration: IntlayerConfig\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionariesEntry]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n MergedDictionaryResult,\n ];\n }\n\n const normalizedDictionaries = normalizeDictionaries(\n dictionariesEntry.dictionaries,\n configuration\n );\n\n const mergedDictionary = mergeQualifiedDictionaries(\n normalizedDictionaries\n );\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n assertPathWithin(resultFilePath, dictionariesDir);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAa,0BAA0B,OACrC,qBACA,kBACoC;CACpC,MAAM,EAAE,oBAAoB,cAAc;AAG1C,0DAAoB,gBAAgB,EAAE,EAAE,WAAW,MAAM,CAAC;CAE1D,MAAM,UAAU,MAAMA,sCACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,uBAAuB;AAClC,MAAI,QAAQ,YACV;EAWF,MAAM,wJAJJ,kBAAkB,cAClB,cAIsB,CACvB;EAGD,MAAM,wCAAyB,iBAAiB,GADtB,IAAI,OACiC;AAE/D,+CAAiB,gBAAgB,gBAAgB;AAGjD,QAAMC,8CAAmB,gBAAgB,iBAAiB,CAAC,OACxD,QAAQ;AACP,WAAQ,MACN,mEAAsC,eAAe,CAAC,IACtD,IACD;IAEJ;AAED,SAAO,CACL,KACA;GACE,gBAAgB;GAChB,YAAY;GACb,CACF;GAEJ;AAED,QAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CACxB"}
1
+ {"version":3,"file":"writeMergedDictionary.cjs","names":["parallelize","writeJsonIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { assertPathWithin } from '@intlayer/config/utils';\nimport {\n mergeQualifiedDictionaries,\n normalizeDictionaries,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n Dictionary,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary | QualifiedDictionaryGroup;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Merged output restricted to plain (unqualified) dictionaries — qualified\n * groups (collections, variants) are static-only and filtered\n * out before the dynamic/fetch build steps.\n */\nexport type PlainMergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type PlainMergedDictionaryOutput = Record<\n string,\n PlainMergedDictionaryResult\n>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionary/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration: IntlayerConfig\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionariesEntry]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n MergedDictionaryResult,\n ];\n }\n\n const normalizedDictionaries = normalizeDictionaries(\n dictionariesEntry.dictionaries,\n configuration\n );\n\n const mergedDictionary = mergeQualifiedDictionaries(\n normalizedDictionaries\n );\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n assertPathWithin(resultFilePath, dictionariesDir);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAa,0BAA0B,OACrC,qBACA,kBACoC;CACpC,MAAM,EAAE,oBAAoB,cAAc;AAG1C,0DAAoB,gBAAgB,EAAE,EAAE,WAAW,MAAM,CAAC;CAE1D,MAAM,UAAU,MAAMA,sCACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,uBAAuB;AAClC,MAAI,QAAQ,YACV;EAWF,MAAM,wJAJJ,kBAAkB,cAClB,cAIsB,CACvB;EAGD,MAAM,wCAAyB,iBAAiB,GADtB,IAAI,OACiC;AAE/D,+CAAiB,gBAAgB,gBAAgB;AAGjD,QAAMC,8CAAmB,gBAAgB,iBAAiB,CAAC,OACxD,QAAQ;AACP,WAAQ,MACN,mEAAsC,eAAe,CAAC,IACtD,IACD;IAEJ;AAED,SAAO,CACL,KACA;GACE,gBAAgB;GAChB,YAAY;GACb,CACF;GAEJ;AAED,QAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CACxB"}
package/dist/cjs/cli.cjs CHANGED
@@ -9,23 +9,30 @@ const require_detectFormatCommand = require('./detectFormatCommand.cjs');
9
9
  const require_getContentDeclarationFileTemplate_getContentDeclarationFileTemplate = require('./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs');
10
10
  const require_writeContentDeclaration_writeJSFile = require('./writeContentDeclaration/writeJSFile.cjs');
11
11
  const require_writeContentDeclaration_writeContentDeclaration = require('./writeContentDeclaration/writeContentDeclaration.cjs');
12
+ const require_init_cms = require('./init/cms.cjs');
13
+ const require_init_utils_packageManager = require('./init/utils/packageManager.cjs');
14
+ const require_init_utils_nextCompilerBabel = require('./init/utils/nextCompilerBabel.cjs');
12
15
  const require_init_index = require('./init/index.cjs');
13
16
  const require_installSkills_index = require('./installSkills/index.cjs');
14
17
  const require_installMCP_installMCP = require('./installMCP/installMCP.cjs');
15
18
  const require_listGitFiles = require('./listGitFiles.cjs');
16
19
  const require_logConfigDetails = require('./logConfigDetails.cjs');
17
20
 
21
+ exports.NEXT_INTLAYER_BABEL_CONFIG_CONTENT = require_init_utils_nextCompilerBabel.NEXT_INTLAYER_BABEL_CONFIG_CONTENT;
18
22
  exports.PLATFORMS = require_installSkills_index.PLATFORMS;
19
23
  exports.PLATFORMS_METADATA = require_installSkills_index.PLATFORMS_METADATA;
20
24
  exports.SKILLS = require_installSkills_index.SKILLS;
21
25
  exports.SKILLS_METADATA = require_installSkills_index.SKILLS_METADATA;
22
26
  exports.detectExportedComponentName = require_writeContentDeclaration_detectExportedComponentName.detectExportedComponentName;
23
27
  exports.detectFormatCommand = require_detectFormatCommand.detectFormatCommand;
28
+ exports.detectPackageManager = require_init_utils_packageManager.detectPackageManager;
29
+ exports.enableEditorInConfig = require_init_cms.enableEditorInConfig;
24
30
  exports.getContentDeclarationFileTemplate = require_getContentDeclarationFileTemplate_getContentDeclarationFileTemplate.getContentDeclarationFileTemplate;
25
31
  exports.getInitialSkills = require_installSkills_index.getInitialSkills;
26
32
  exports.initIntlayer = require_init_index.initIntlayer;
27
33
  exports.installLSP = require_installLSP.installLSP;
28
34
  exports.installMCP = require_installMCP_installMCP.installMCP;
35
+ exports.installPackages = require_init_utils_packageManager.installPackages;
29
36
  exports.installSkills = require_installSkills_index.installSkills;
30
37
  exports.listDictionaries = require_listDictionariesPath.listDictionaries;
31
38
  exports.listDictionariesWithStats = require_listDictionariesPath.listDictionariesWithStats;
@@ -34,6 +41,8 @@ exports.listGitLines = require_listGitFiles.listGitLines;
34
41
  exports.listProjects = require_listProjects.listProjects;
35
42
  exports.logConfigDetails = require_logConfigDetails.logConfigDetails;
36
43
  exports.prepareIntlayer = require_prepareIntlayer.prepareIntlayer;
44
+ exports.setupCmsCredentials = require_init_cms.setupCmsCredentials;
37
45
  exports.transformJSFile = require_writeContentDeclaration_transformJSFile.transformJSFile;
46
+ exports.writeCmsCredentialsToEnv = require_init_cms.writeCmsCredentialsToEnv;
38
47
  exports.writeContentDeclaration = require_writeContentDeclaration_writeContentDeclaration.writeContentDeclaration;
39
48
  exports.writeJSFile = require_writeContentDeclaration_writeJSFile.writeJSFile;
@@ -4,6 +4,7 @@ const require_utils_parallelize = require('./utils/parallelize.cjs');
4
4
  let _intlayer_config_logger = require("@intlayer/config/logger");
5
5
  let _intlayer_config_node = require("@intlayer/config/node");
6
6
  let _intlayer_api = require("@intlayer/api");
7
+ let _intlayer_api_dictionary = require("@intlayer/api/dictionary");
7
8
 
8
9
  //#region src/fetchDistantDictionaries.ts
9
10
  /**
@@ -13,7 +14,7 @@ const fetchDistantDictionaries = async (options, onStatusUpdate) => {
13
14
  const config = (0, _intlayer_config_node.getConfiguration)();
14
15
  const appLogger = (0, _intlayer_config_logger.getAppLogger)(config);
15
16
  try {
16
- const intlayerAPI = (0, _intlayer_api.getIntlayerAPIProxy)(void 0, config);
17
+ const dictionary = (0, _intlayer_api_dictionary.dictionaryEndpoint)((0, _intlayer_api.createIntlayerCMS)(config));
17
18
  const distantDictionariesKeys = options.dictionaryKeys;
18
19
  const processDictionary = async (dictionaryKey) => {
19
20
  onStatusUpdate?.([{
@@ -22,7 +23,7 @@ const fetchDistantDictionaries = async (options, onStatusUpdate) => {
22
23
  status: "fetching"
23
24
  }]);
24
25
  try {
25
- const distantDictionary = (await intlayerAPI.dictionary.getDictionary(dictionaryKey)).data;
26
+ const distantDictionary = (await dictionary.getDictionary(dictionaryKey)).data;
26
27
  if (!distantDictionary) throw new Error(`Dictionary ${dictionaryKey} not found on remote`);
27
28
  onStatusUpdate?.([{
28
29
  dictionaryKey,
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionaries.cjs","names":["parallelize","x"],"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\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 type { DictionariesStatus } from './loadDictionaries';\nimport { parallelize } from './utils/parallelize';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\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 intlayerAPI = getIntlayerAPIProxy(undefined, config);\n\n const distantDictionariesKeys = options.dictionaryKeys;\n // Process dictionaries in parallel with a concurrency limit\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'fetching',\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult =\n await intlayerAPI.dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n onStatusUpdate?.([\n { dictionaryKey, type: 'remote', status: 'fetched' },\n ]);\n\n return distantDictionary;\n } catch (error) {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'error',\n error: `Error fetching dictionary ${dictionaryKey}: ${error}`,\n },\n ]);\n return undefined;\n }\n };\n\n const result = await parallelize(\n distantDictionariesKeys,\n async (dictionaryKey) => await processDictionary(dictionaryKey)\n );\n\n // Remove undefined values\n const filteredResult = result.filter(\n (dict: DictionaryAPI | undefined): dict is DictionaryAPI =>\n dict !== undefined\n );\n\n return filteredResult;\n } catch (_error) {\n appLogger(`${x} Failed to fetch distant dictionaries`, { level: 'error' });\n return [];\n }\n};\n"],"mappings":";;;;;;;;;;;AAiBA,MAAa,2BAA2B,OACtC,SACA,mBAC6B;CAC7B,MAAM,sDAA2B;CACjC,MAAM,sDAAyB,OAAO;AACtC,KAAI;EACF,MAAM,qDAAkC,QAAW,OAAO;EAE1D,MAAM,0BAA0B,QAAQ;EAExC,MAAM,oBAAoB,OACxB,kBACuC;AACvC,oBAAiB,CACf;IACE;IACA,MAAM;IACN,QAAQ;IACT,CACF,CAAC;AAEF,OAAI;IAKF,MAAM,qBAAoB,MAFlB,YAAY,WAAW,cAAc,cAAc,EAEb;AAE9C,QAAI,CAAC,kBACH,OAAM,IAAI,MAAM,cAAc,cAAc,sBAAsB;AAGpE,qBAAiB,CACf;KAAE;KAAe,MAAM;KAAU,QAAQ;KAAW,CACrD,CAAC;AAEF,WAAO;YACA,OAAO;AACd,qBAAiB,CACf;KACE;KACA,MAAM;KACN,QAAQ;KACR,OAAO,6BAA6B,cAAc,IAAI;KACvD,CACF,CAAC;AACF;;;AAeJ,UALuB,MANFA,sCACnB,yBACA,OAAO,kBAAkB,MAAM,kBAAkB,cAAc,CAChE,EAG6B,QAC3B,SACC,SAAS,OAGQ;UACd,QAAQ;AACf,YAAU,GAAGC,0BAAE,wCAAwC,EAAE,OAAO,SAAS,CAAC;AAC1E,SAAO,EAAE"}
1
+ {"version":3,"file":"fetchDistantDictionaries.cjs","names":["parallelize","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 type { DictionariesStatus } from './loadDictionaries';\nimport { parallelize } from './utils/parallelize';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\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 distantDictionariesKeys = options.dictionaryKeys;\n // Process dictionaries in parallel with a concurrency limit\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'fetching',\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult =\n await dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n onStatusUpdate?.([\n { dictionaryKey, type: 'remote', status: 'fetched' },\n ]);\n\n return distantDictionary;\n } catch (error) {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'error',\n error: `Error fetching dictionary ${dictionaryKey}: ${error}`,\n },\n ]);\n return undefined;\n }\n };\n\n const result = await parallelize(\n distantDictionariesKeys,\n async (dictionaryKey) => await processDictionary(dictionaryKey)\n );\n\n // Remove undefined values\n const filteredResult = result.filter(\n (dict: DictionaryAPI | undefined): dict is DictionaryAPI =>\n dict !== undefined\n );\n\n return filteredResult;\n } catch (_error) {\n appLogger(`${x} Failed to fetch distant dictionaries`, { level: 'error' });\n return [];\n }\n};\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAa,2BAA2B,OACtC,SACA,mBAC6B;CAC7B,MAAM,sDAA2B;CACjC,MAAM,sDAAyB,OAAO;AACtC,KAAI;EACF,MAAM,mGAAkD,OAAO,CAAC;EAEhE,MAAM,0BAA0B,QAAQ;EAExC,MAAM,oBAAoB,OACxB,kBACuC;AACvC,oBAAiB,CACf;IACE;IACA,MAAM;IACN,QAAQ;IACT,CACF,CAAC;AAEF,OAAI;IAKF,MAAM,qBAAoB,MAFlB,WAAW,cAAc,cAAc,EAED;AAE9C,QAAI,CAAC,kBACH,OAAM,IAAI,MAAM,cAAc,cAAc,sBAAsB;AAGpE,qBAAiB,CACf;KAAE;KAAe,MAAM;KAAU,QAAQ;KAAW,CACrD,CAAC;AAEF,WAAO;YACA,OAAO;AACd,qBAAiB,CACf;KACE;KACA,MAAM;KACN,QAAQ;KACR,OAAO,6BAA6B,cAAc,IAAI;KACvD,CACF,CAAC;AACF;;;AAeJ,UALuB,MANFA,sCACnB,yBACA,OAAO,kBAAkB,MAAM,kBAAkB,cAAc,CAChE,EAG6B,QAC3B,SACC,SAAS,OAGQ;UACd,QAAQ;AACf,YAAU,GAAGC,0BAAE,wCAAwC,EAAE,OAAO,SAAS,CAAC;AAC1E,SAAO,EAAE"}
@@ -0,0 +1,140 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_init_utils_configManipulation = require('./utils/configManipulation.cjs');
4
+ const require_init_utils_fileSystem = require('./utils/fileSystem.cjs');
5
+ let _intlayer_config_logger = require("@intlayer/config/logger");
6
+ let fast_glob = require("fast-glob");
7
+ fast_glob = require_runtime.__toESM(fast_glob);
8
+ let _intlayer_config_colors = require("@intlayer/config/colors");
9
+ _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
10
+
11
+ //#region src/init/cms.ts
12
+ /**
13
+ * Intlayer configuration file candidates, ordered by the precedence used when
14
+ * resolving which file to mutate.
15
+ */
16
+ const INTLAYER_CONFIG_FILE_CANDIDATES = [
17
+ "intlayer.config.ts",
18
+ "intlayer.config.mjs",
19
+ "intlayer.config.js",
20
+ "intlayer.config.cjs",
21
+ "intlayer.config.json"
22
+ ];
23
+ /**
24
+ * Environment files searched (most-preferred first) when persisting the CMS
25
+ * credentials. The first existing match is reused; otherwise a `.env` file is
26
+ * created at the project root.
27
+ */
28
+ const ENV_FILE_CANDIDATES = [
29
+ ".env",
30
+ ".env.local",
31
+ ".env.development"
32
+ ];
33
+ /**
34
+ * Resolves the first existing Intlayer configuration file at the project root,
35
+ * or `undefined` when none is present.
36
+ */
37
+ const findIntlayerConfigFile = async (rootDir) => {
38
+ for (const candidate of INTLAYER_CONFIG_FILE_CANDIDATES) if (await require_init_utils_fileSystem.exists(rootDir, candidate)) return candidate;
39
+ };
40
+ /**
41
+ * Locates the environment file the CMS credentials should be written to. Uses
42
+ * `fast-glob` to detect an existing dotenv file at the project root, preferring
43
+ * a plain `.env`; falls back to `.env` (to be created) when none exist.
44
+ */
45
+ const findEnvFile = async (rootDir) => {
46
+ const matches = await (0, fast_glob.default)([...ENV_FILE_CANDIDATES], {
47
+ cwd: rootDir,
48
+ dot: true,
49
+ deep: 1,
50
+ onlyFiles: true
51
+ });
52
+ return ENV_FILE_CANDIDATES.find((candidate) => matches.includes(candidate)) ?? ".env";
53
+ };
54
+ /**
55
+ * Inserts or updates a `KEY=value` line in dotenv file content. An existing
56
+ * assignment of the same key is replaced in place; otherwise the line is
57
+ * appended with a trailing newline.
58
+ */
59
+ const upsertEnvVariable = (content, key, value) => {
60
+ const line = `${key}=${value}`;
61
+ const keyMatcher = new RegExp(`^${key}=.*$`, "m");
62
+ if (keyMatcher.test(content)) return content.replace(keyMatcher, line);
63
+ return `${content}${content.length > 0 && !content.endsWith("\n") ? "\n" : ""}${line}\n`;
64
+ };
65
+ /**
66
+ * Persists the CMS access-key credentials to the project's environment file as
67
+ * `INTLAYER_CLIENT_ID` / `INTLAYER_CLIENT_SECRET`. The target file is detected
68
+ * with {@link findEnvFile} and created when missing. Returns the relative path
69
+ * of the file that was written.
70
+ */
71
+ const writeCmsCredentialsToEnv = async (rootDir, { clientId, clientSecret }) => {
72
+ const envFile = await findEnvFile(rootDir);
73
+ let content = "";
74
+ if (await require_init_utils_fileSystem.exists(rootDir, envFile)) content = await require_init_utils_fileSystem.readFileFromRoot(rootDir, envFile);
75
+ let updatedContent = content;
76
+ updatedContent = upsertEnvVariable(updatedContent, "INTLAYER_CLIENT_ID", clientId);
77
+ updatedContent = upsertEnvVariable(updatedContent, "INTLAYER_CLIENT_SECRET", clientSecret);
78
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, envFile, updatedContent);
79
+ (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Saved Intlayer CMS credentials to ${(0, _intlayer_config_logger.colorizePath)(envFile)} (${(0, _intlayer_config_logger.colorize)("INTLAYER_CLIENT_ID", _intlayer_config_colors.GREY_LIGHT)}, ${(0, _intlayer_config_logger.colorize)("INTLAYER_CLIENT_SECRET", _intlayer_config_colors.GREY_LIGHT)})`);
80
+ return envFile;
81
+ };
82
+ /**
83
+ * Enables the Intlayer visual editor in the project's configuration file:
84
+ * flips `editor.enabled` to `true` and wires `clientId` / `clientSecret` to the
85
+ * matching environment variables. JSON configs cannot reference `process.env`,
86
+ * so they are skipped with a warning. Returns the config file that was updated,
87
+ * or `undefined` when no editable config was found.
88
+ */
89
+ const enableEditorInConfig = async (rootDir) => {
90
+ const configFile = await findIntlayerConfigFile(rootDir);
91
+ if (!configFile) {
92
+ (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.x} Could not find an Intlayer configuration file to enable the editor.`, { level: "warn" });
93
+ return;
94
+ }
95
+ if (configFile.split(".").pop() === "json") {
96
+ (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.x} ${(0, _intlayer_config_logger.colorizePath)(configFile)} is a JSON config and cannot reference environment variables. Enable the editor and set clientId/clientSecret manually.`, { level: "warn" });
97
+ return;
98
+ }
99
+ const content = await require_init_utils_fileSystem.readFileFromRoot(rootDir, configFile);
100
+ const updatedContent = require_init_utils_configManipulation.enableIntlayerEditorConfig(content);
101
+ if (updatedContent !== content) {
102
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, configFile, updatedContent);
103
+ (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Enabled the Intlayer editor in ${(0, _intlayer_config_logger.colorizePath)(configFile)}`);
104
+ } else (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(configFile)} already has the Intlayer editor enabled`);
105
+ return configFile;
106
+ };
107
+ /**
108
+ * Sets `routing.mode` in the project's Intlayer configuration file. Returns the
109
+ * config file that was updated, or `undefined` when none was found.
110
+ */
111
+ const setRoutingModeInConfig = async (rootDir, mode) => {
112
+ const configFile = await findIntlayerConfigFile(rootDir);
113
+ if (!configFile) return void 0;
114
+ const extension = configFile.split(".").pop();
115
+ const content = await require_init_utils_fileSystem.readFileFromRoot(rootDir, configFile);
116
+ const updatedContent = require_init_utils_configManipulation.setIntlayerConfigRoutingMode(content, extension, mode);
117
+ if (updatedContent !== content) {
118
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, configFile, updatedContent);
119
+ (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Set ${(0, _intlayer_config_logger.colorize)(`routing.mode = '${mode}'`, _intlayer_config_colors.GREY_LIGHT)} in ${(0, _intlayer_config_logger.colorizePath)(configFile)}`);
120
+ }
121
+ return configFile;
122
+ };
123
+ /**
124
+ * Completes the CMS setup once credentials are received from the login flow:
125
+ * writes them to the environment file and enables the editor in the Intlayer
126
+ * configuration file.
127
+ */
128
+ const setupCmsCredentials = async (rootDir, credentials) => {
129
+ await writeCmsCredentialsToEnv(rootDir, credentials);
130
+ await enableEditorInConfig(rootDir);
131
+ };
132
+
133
+ //#endregion
134
+ exports.INTLAYER_CONFIG_FILE_CANDIDATES = INTLAYER_CONFIG_FILE_CANDIDATES;
135
+ exports.enableEditorInConfig = enableEditorInConfig;
136
+ exports.findEnvFile = findEnvFile;
137
+ exports.setRoutingModeInConfig = setRoutingModeInConfig;
138
+ exports.setupCmsCredentials = setupCmsCredentials;
139
+ exports.writeCmsCredentialsToEnv = writeCmsCredentialsToEnv;
140
+ //# sourceMappingURL=cms.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cms.cjs","names":["exists","readFileFromRoot","writeFileToRoot","v","ANSIColors","x","enableIntlayerEditorConfig","setIntlayerConfigRoutingMode"],"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 setIntlayerConfigRoutingMode,\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 * 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":";;;;;;;;;;;;;;;AAcA,MAAa,kCAAkC;CAC7C;CACA;CACA;CACA;CACA;CACD;;;;;;AAOD,MAAM,sBAAsB;CAAC;CAAQ;CAAc;CAAmB;;;;;AAYtE,MAAM,yBAAyB,OAC7B,YAC0E;AAC1E,MAAK,MAAM,aAAa,gCACtB,KAAI,MAA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Q;AACxB,sCACE,GAAGA,0BAAE,6CAAgB,WAAW,CAAC,0HACjC,EAAE,OAAO,QAAQ,CAClB;AACD;;CAGF,MAAM,UAAU,MAAMJ,+CAAiB,SAAS,WAAW;CAC3D,MAAM,iBAAiBK,iEAA2B,QAAQ;AAE1D,KAAI,mBAAmB,SAAS;AAC9B,QAAMJ,8CAAgB,SAAS,YAAY,eAAe;AAC1D,sCAAO,GAAGC,0BAAE,4EAA+C,WAAW,GAAG;OAEzE,qCACE,GAAGA,0BAAE,6CAAgB,WAAW,CAAC,0CAClC;AAGH,QAAO;;;;;;AAOT,MAAa,yBAAyB,OACpC,SACA,SACgC;CAChC,MAAM,aAAa,MAAM,uBAAuB,QAAQ;AAExD,KAAI,CAAC,WAAY,QAAO;CAExB,MAAM,YAAY,WAAW,MAAM,IAAI,CAAC,KAAK;CAC7C,MAAM,UAAU,MAAMF,+CAAiB,SAAS,WAAW;CAC3D,MAAM,iBAAiBM,mEAA6B,SAAS,WAAW,KAAK;AAE7E,KAAI,mBAAmB,SAAS;AAC9B,QAAML,8CAAgB,SAAS,YAAY,eAAe;AAC1D,sCACE,GAAGC,0BAAE,6CAAgB,mBAAmB,KAAK,IAAIC,wBAAW,WAAW,CAAC,gDAAmB,WAAW,GACvG;;AAGH,QAAO;;;;;;;AAQT,MAAa,sBAAsB,OACjC,SACA,gBACkB;AAClB,OAAM,yBAAyB,SAAS,YAAY;AACpD,OAAM,qBAAqB,QAAQ"}
@@ -0,0 +1,27 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_init_frameworkSetup_nextAppRouter_index = require('./nextAppRouter/index.cjs');
3
+ const require_init_frameworkSetup_tanstackStart_index = require('./tanstackStart/index.cjs');
4
+
5
+ //#region src/init/frameworkSetup/index.ts
6
+ /**
7
+ * Registered framework adapters, tried in order. The first one whose `detect`
8
+ * returns true handles the project. Add new adapters (Nuxt, Vite + React, …)
9
+ * here as they are implemented.
10
+ */
11
+ const adapters = [require_init_frameworkSetup_nextAppRouter_index.nextAppRouterAdapter, require_init_frameworkSetup_tanstackStart_index.tanStackStartAdapter];
12
+ /**
13
+ * Runs framework-specific scaffolding (middleware/proxy, providers in
14
+ * layout/page, example content) for the first adapter that matches the project.
15
+ * No-ops when no adapter recognizes the project. Each adapter is idempotent and
16
+ * non-destructive, so this is safe to run on existing applications.
17
+ */
18
+ const setupFramework = async (context) => {
19
+ for (const adapter of adapters) if (await adapter.detect(context)) {
20
+ await adapter.setup(context);
21
+ return;
22
+ }
23
+ };
24
+
25
+ //#endregion
26
+ exports.setupFramework = setupFramework;
27
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["nextAppRouterAdapter","tanStackStartAdapter"],"sources":["../../../../src/init/frameworkSetup/index.ts"],"sourcesContent":["import { nextAppRouterAdapter } from './nextAppRouter';\nimport { tanStackStartAdapter } from './tanstackStart';\nimport type { FrameworkAdapter, FrameworkSetupContext } from './types';\n\nexport type { FrameworkAdapter, FrameworkSetupContext } from './types';\n\n/**\n * Registered framework adapters, tried in order. The first one whose `detect`\n * returns true handles the project. Add new adapters (Nuxt, Vite + React, …)\n * here as they are implemented.\n */\nconst adapters: FrameworkAdapter[] = [\n nextAppRouterAdapter,\n tanStackStartAdapter,\n];\n\n/**\n * Runs framework-specific scaffolding (middleware/proxy, providers in\n * layout/page, example content) for the first adapter that matches the project.\n * No-ops when no adapter recognizes the project. Each adapter is idempotent and\n * non-destructive, so this is safe to run on existing applications.\n */\nexport const setupFramework = async (\n context: FrameworkSetupContext\n): Promise<void> => {\n for (const adapter of adapters) {\n if (await adapter.detect(context)) {\n await adapter.setup(context);\n return;\n }\n }\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAM,WAA+B,CACnCA,sEACAC,qEACD;;;;;;;AAQD,MAAa,iBAAiB,OAC5B,YACkB;AAClB,MAAK,MAAM,WAAW,SACpB,KAAI,MAAM,QAAQ,OAAO,QAAQ,EAAE;AACjC,QAAM,QAAQ,MAAM,QAAQ;AAC5B"}