@intlayer/cli 9.0.0-canary.10 → 9.0.0-canary.12

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 (166) hide show
  1. package/dist/cjs/auth/login.cjs +2 -2
  2. package/dist/cjs/auth/login.cjs.map +1 -1
  3. package/dist/cjs/build.cjs +6 -6
  4. package/dist/cjs/build.cjs.map +1 -1
  5. package/dist/cjs/ci.cjs +2 -2
  6. package/dist/cjs/ci.cjs.map +1 -1
  7. package/dist/cjs/cli.cjs.map +1 -1
  8. package/dist/cjs/config.cjs +2 -2
  9. package/dist/cjs/config.cjs.map +1 -1
  10. package/dist/cjs/extract.cjs +7 -7
  11. package/dist/cjs/extract.cjs.map +1 -1
  12. package/dist/cjs/fill/fill.cjs +11 -11
  13. package/dist/cjs/fill/fill.cjs.map +1 -1
  14. package/dist/cjs/fill/formatAutoFilledFilePath.cjs +2 -2
  15. package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -1
  16. package/dist/cjs/fill/formatFillData.cjs +3 -3
  17. package/dist/cjs/fill/formatFillData.cjs.map +1 -1
  18. package/dist/cjs/fill/listTranslationsTasks.cjs +2 -2
  19. package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -1
  20. package/dist/cjs/fill/translateDictionary.cjs +7 -7
  21. package/dist/cjs/fill/translateDictionary.cjs.map +1 -1
  22. package/dist/cjs/fill/writeFill.cjs +5 -5
  23. package/dist/cjs/fill/writeFill.cjs.map +1 -1
  24. package/dist/cjs/getTargetDictionary.cjs +2 -2
  25. package/dist/cjs/getTargetDictionary.cjs.map +1 -1
  26. package/dist/cjs/init.cjs +5 -5
  27. package/dist/cjs/init.cjs.map +1 -1
  28. package/dist/cjs/initBuildOptimization.cjs +6 -6
  29. package/dist/cjs/initBuildOptimization.cjs.map +1 -1
  30. package/dist/cjs/initCompiler.cjs +3 -3
  31. package/dist/cjs/initCompiler.cjs.map +1 -1
  32. package/dist/cjs/initMCP.cjs +3 -3
  33. package/dist/cjs/initMCP.cjs.map +1 -1
  34. package/dist/cjs/initSkills.cjs +11 -11
  35. package/dist/cjs/initSkills.cjs.map +1 -1
  36. package/dist/cjs/listContentDeclaration.cjs +4 -4
  37. package/dist/cjs/listContentDeclaration.cjs.map +1 -1
  38. package/dist/cjs/listProjects.cjs +2 -2
  39. package/dist/cjs/listProjects.cjs.map +1 -1
  40. package/dist/cjs/liveSync.cjs +4 -4
  41. package/dist/cjs/liveSync.cjs.map +1 -1
  42. package/dist/cjs/pull.cjs +6 -6
  43. package/dist/cjs/pull.cjs.map +1 -1
  44. package/dist/cjs/push/pullLog.cjs.map +1 -1
  45. package/dist/cjs/push/push.cjs +13 -13
  46. package/dist/cjs/push/push.cjs.map +1 -1
  47. package/dist/cjs/pushConfig.cjs +2 -2
  48. package/dist/cjs/pushConfig.cjs.map +1 -1
  49. package/dist/cjs/reviewDoc/reviewDoc.cjs +16 -16
  50. package/dist/cjs/reviewDoc/reviewDoc.cjs.map +1 -1
  51. package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +11 -11
  52. package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs.map +1 -1
  53. package/dist/cjs/reviewDoc/reviewDocLog.cjs +7 -7
  54. package/dist/cjs/reviewDoc/reviewDocLog.cjs.map +1 -1
  55. package/dist/cjs/scan.cjs +5 -5
  56. package/dist/cjs/scan.cjs.map +1 -1
  57. package/dist/cjs/searchDoc.cjs +2 -2
  58. package/dist/cjs/searchDoc.cjs.map +1 -1
  59. package/dist/cjs/test/listMissingTranslations.cjs +2 -2
  60. package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
  61. package/dist/cjs/test/test.cjs +11 -11
  62. package/dist/cjs/test/test.cjs.map +1 -1
  63. package/dist/cjs/translateDoc/translateDoc.cjs +6 -6
  64. package/dist/cjs/translateDoc/translateDoc.cjs.map +1 -1
  65. package/dist/cjs/translateDoc/translateFile.cjs +5 -5
  66. package/dist/cjs/translateDoc/translateFile.cjs.map +1 -1
  67. package/dist/cjs/utils/calculateChunks.cjs +4 -4
  68. package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
  69. package/dist/cjs/utils/getOutputFilePath.cjs +2 -2
  70. package/dist/cjs/utils/getOutputFilePath.cjs.map +1 -1
  71. package/dist/cjs/utils/mapChunksBetweenFiles.cjs +4 -4
  72. package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
  73. package/dist/cjs/watch.cjs +6 -6
  74. package/dist/cjs/watch.cjs.map +1 -1
  75. package/dist/esm/auth/login.mjs +1 -1
  76. package/dist/esm/auth/login.mjs.map +1 -1
  77. package/dist/esm/build.mjs +3 -3
  78. package/dist/esm/build.mjs.map +1 -1
  79. package/dist/esm/ci.mjs +1 -1
  80. package/dist/esm/ci.mjs.map +1 -1
  81. package/dist/esm/cli.mjs.map +1 -1
  82. package/dist/esm/config.mjs +1 -1
  83. package/dist/esm/config.mjs.map +1 -1
  84. package/dist/esm/extract.mjs +3 -3
  85. package/dist/esm/extract.mjs.map +1 -1
  86. package/dist/esm/fill/fill.mjs +3 -3
  87. package/dist/esm/fill/fill.mjs.map +1 -1
  88. package/dist/esm/fill/formatAutoFilledFilePath.mjs +1 -1
  89. package/dist/esm/fill/formatAutoFilledFilePath.mjs.map +1 -1
  90. package/dist/esm/fill/formatFillData.mjs +1 -1
  91. package/dist/esm/fill/formatFillData.mjs.map +1 -1
  92. package/dist/esm/fill/listTranslationsTasks.mjs +1 -1
  93. package/dist/esm/fill/listTranslationsTasks.mjs.map +1 -1
  94. package/dist/esm/fill/translateDictionary.mjs +1 -1
  95. package/dist/esm/fill/translateDictionary.mjs.map +1 -1
  96. package/dist/esm/fill/writeFill.mjs +2 -2
  97. package/dist/esm/fill/writeFill.mjs.map +1 -1
  98. package/dist/esm/getTargetDictionary.mjs +1 -1
  99. package/dist/esm/getTargetDictionary.mjs.map +1 -1
  100. package/dist/esm/init.mjs +1 -1
  101. package/dist/esm/init.mjs.map +1 -1
  102. package/dist/esm/initBuildOptimization.mjs +1 -1
  103. package/dist/esm/initBuildOptimization.mjs.map +1 -1
  104. package/dist/esm/initCompiler.mjs +1 -1
  105. package/dist/esm/initCompiler.mjs.map +1 -1
  106. package/dist/esm/initMCP.mjs +1 -1
  107. package/dist/esm/initMCP.mjs.map +1 -1
  108. package/dist/esm/initSkills.mjs +1 -1
  109. package/dist/esm/initSkills.mjs.map +1 -1
  110. package/dist/esm/listContentDeclaration.mjs +2 -2
  111. package/dist/esm/listContentDeclaration.mjs.map +1 -1
  112. package/dist/esm/listProjects.mjs +1 -1
  113. package/dist/esm/listProjects.mjs.map +1 -1
  114. package/dist/esm/liveSync.mjs +2 -2
  115. package/dist/esm/liveSync.mjs.map +1 -1
  116. package/dist/esm/pull.mjs +3 -3
  117. package/dist/esm/pull.mjs.map +1 -1
  118. package/dist/esm/push/pullLog.mjs.map +1 -1
  119. package/dist/esm/push/push.mjs +3 -3
  120. package/dist/esm/push/push.mjs.map +1 -1
  121. package/dist/esm/pushConfig.mjs +1 -1
  122. package/dist/esm/pushConfig.mjs.map +1 -1
  123. package/dist/esm/reviewDoc/reviewDoc.mjs +3 -3
  124. package/dist/esm/reviewDoc/reviewDoc.mjs.map +1 -1
  125. package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +2 -2
  126. package/dist/esm/reviewDoc/reviewDocBlockAware.mjs.map +1 -1
  127. package/dist/esm/reviewDoc/reviewDocLog.mjs +2 -2
  128. package/dist/esm/reviewDoc/reviewDocLog.mjs.map +1 -1
  129. package/dist/esm/scan.mjs +1 -1
  130. package/dist/esm/scan.mjs.map +1 -1
  131. package/dist/esm/searchDoc.mjs +1 -1
  132. package/dist/esm/searchDoc.mjs.map +1 -1
  133. package/dist/esm/test/listMissingTranslations.mjs +1 -1
  134. package/dist/esm/test/listMissingTranslations.mjs.map +1 -1
  135. package/dist/esm/test/test.mjs +2 -2
  136. package/dist/esm/test/test.mjs.map +1 -1
  137. package/dist/esm/translateDoc/translateDoc.mjs +2 -2
  138. package/dist/esm/translateDoc/translateDoc.mjs.map +1 -1
  139. package/dist/esm/translateDoc/translateFile.mjs +1 -1
  140. package/dist/esm/translateDoc/translateFile.mjs.map +1 -1
  141. package/dist/esm/utils/calculateChunks.mjs +1 -1
  142. package/dist/esm/utils/calculateChunks.mjs.map +1 -1
  143. package/dist/esm/utils/getOutputFilePath.mjs +1 -1
  144. package/dist/esm/utils/getOutputFilePath.mjs.map +1 -1
  145. package/dist/esm/utils/mapChunksBetweenFiles.mjs +1 -1
  146. package/dist/esm/utils/mapChunksBetweenFiles.mjs.map +1 -1
  147. package/dist/esm/watch.mjs +3 -3
  148. package/dist/esm/watch.mjs.map +1 -1
  149. package/dist/types/fill/fill.d.ts +1 -1
  150. package/dist/types/fill/translateDictionary.d.ts +2 -2
  151. package/dist/types/fill/translateDictionary.d.ts.map +1 -1
  152. package/dist/types/getTargetDictionary.d.ts +1 -1
  153. package/dist/types/index.d.ts +4 -4
  154. package/dist/types/init.d.ts +1 -1
  155. package/dist/types/initMCP.d.ts +1 -1
  156. package/dist/types/initSkills.d.ts +1 -1
  157. package/dist/types/listProjects.d.ts +1 -1
  158. package/dist/types/push/pullLog.d.ts +1 -1
  159. package/dist/types/push/push.d.ts +1 -1
  160. package/dist/types/reviewDoc/reviewDoc.d.ts +1 -1
  161. package/dist/types/reviewDoc/reviewDoc.d.ts.map +1 -1
  162. package/dist/types/reviewDoc/reviewDocLog.d.ts +1 -1
  163. package/dist/types/scan.d.ts.map +1 -1
  164. package/dist/types/translateDoc/translateDoc.d.ts.map +1 -1
  165. package/dist/types/translateDoc/types.d.ts +1 -1
  166. package/package.json +12 -12
package/dist/cjs/pull.cjs CHANGED
@@ -5,13 +5,13 @@ const require_push_pullLog = require('./push/pullLog.cjs');
5
5
  const require_utils_selectCmsEnvironment = require('./utils/selectCmsEnvironment.cjs');
6
6
  let node_fs = require("node:fs");
7
7
  let node_path = require("node:path");
8
- let _intlayer_chokidar_build = require("@intlayer/chokidar/build");
9
- let _intlayer_chokidar_cli = require("@intlayer/chokidar/cli");
10
- let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
11
8
  let _intlayer_config_colors = require("@intlayer/config/colors");
12
9
  _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
13
10
  let _intlayer_config_logger = require("@intlayer/config/logger");
14
11
  let _intlayer_config_node = require("@intlayer/config/node");
12
+ let _intlayer_engine_build = require("@intlayer/engine/build");
13
+ let _intlayer_engine_cli = require("@intlayer/engine/cli");
14
+ let _intlayer_engine_utils = require("@intlayer/engine/utils");
15
15
  let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
16
16
  let _intlayer_config_utils = require("@intlayer/config/utils");
17
17
 
@@ -24,7 +24,7 @@ const pull = async (options) => {
24
24
  const config = (0, _intlayer_config_node.getConfiguration)(options?.configOptions);
25
25
  const appLogger = (0, _intlayer_config_logger.getAppLogger)(config);
26
26
  try {
27
- (0, _intlayer_chokidar_cli.logConfigDetails)(options?.configOptions);
27
+ (0, _intlayer_engine_cli.logConfigDetails)(options?.configOptions);
28
28
  if (!await require_utils_checkAccess.checkCMSAuth(config)) return;
29
29
  const intlayerAPI = await require_utils_checkAccess.getAuthenticatedAPI(config);
30
30
  await require_utils_selectCmsEnvironment.selectCmsEnvironment(options?.configOptions?.env, intlayerAPI, config);
@@ -96,7 +96,7 @@ const pull = async (options) => {
96
96
  filePath: localAndRemoteDictionary.filePath,
97
97
  localId: localAndRemoteDictionary.localId
98
98
  };
99
- const { status } = await (0, _intlayer_chokidar_build.writeContentDeclaration)(sourceDictionary, config, options);
99
+ const { status } = await (0, _intlayer_engine_build.writeContentDeclaration)(sourceDictionary, config, options);
100
100
  statusObj.status = status;
101
101
  logger.update([{
102
102
  dictionaryKey: statusObj.dictionaryKey,
@@ -113,7 +113,7 @@ const pull = async (options) => {
113
113
  }]);
114
114
  }
115
115
  };
116
- await (0, _intlayer_chokidar_utils.parallelize)(dictionariesStatuses, processDictionary, 5);
116
+ await (0, _intlayer_engine_utils.parallelize)(dictionariesStatuses, processDictionary, 5);
117
117
  logger.finish();
118
118
  const iconFor = (status) => {
119
119
  switch (status) {
@@ -1 +1 @@
1
- {"version":3,"file":"pull.cjs","names":["checkCMSAuth","getAuthenticatedAPI","selectCmsEnvironment","PullLogger","ANSIColors"],"sources":["../../src/pull.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport {\n type DictionaryStatus,\n writeContentDeclaration,\n} from '@intlayer/chokidar/build';\nimport { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { parallelize } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getProjectRequire } from '@intlayer/config/utils';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { PullLogger, type PullStatus } from './push/pullLog';\nimport { checkCMSAuth, getAuthenticatedAPI } from './utils/checkAccess';\nimport { selectCmsEnvironment } from './utils/selectCmsEnvironment';\n\ntype PullOptions = {\n dictionaries?: string[];\n newDictionariesPath?: string;\n configOptions?: GetConfigurationOptions;\n};\n\ntype DictionariesStatus = {\n dictionaryKey: string;\n status: DictionaryStatus | 'pending' | 'fetching' | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n/**\n * Fetch distant dictionaries and write them locally,\n * with progress indicators and concurrency control.\n */\nexport const pull = async (options?: PullOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\n\n try {\n logConfigDetails(options?.configOptions);\n\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = await getAuthenticatedAPI(config);\n\n await selectCmsEnvironment(\n options?.configOptions?.env,\n intlayerAPI,\n config\n );\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n\n // Get remote update timestamps map\n const getDictionariesUpdateTimestampResult =\n await intlayerAPI.dictionary.getDictionariesUpdateTimestamp();\n\n if (!getDictionariesUpdateTimestampResult.data) {\n throw new Error('No distant dictionaries found');\n }\n\n let distantDictionariesUpdateTimeStamp: Record<string, any> =\n getDictionariesUpdateTimestampResult.data;\n\n // Optional filtering by requested dictionaries\n if (options?.dictionaries) {\n distantDictionariesUpdateTimeStamp = Object.fromEntries(\n Object.entries(distantDictionariesUpdateTimeStamp).filter(([key]) =>\n options.dictionaries?.includes(key)\n )\n );\n }\n\n // Filter by location\n distantDictionariesUpdateTimeStamp = Object.fromEntries(\n Object.entries(distantDictionariesUpdateTimeStamp).filter(([key]) => {\n const localDictionaries = unmergedDictionariesRecord[key];\n const location =\n localDictionaries?.[0]?.location ??\n config.dictionary?.location ??\n 'remote';\n\n return location === 'remote' || location === 'hybrid';\n })\n );\n\n // Load local cached remote dictionaries (if any)\n const remoteDictionariesPath = join(\n config.system.mainDir,\n 'remote_dictionaries.cjs'\n );\n const requireFunction = config.build?.require ?? getProjectRequire();\n const remoteDictionariesRecord: Record<string, any> = existsSync(\n remoteDictionariesPath\n )\n ? (requireFunction(remoteDictionariesPath) as any)\n : {};\n\n // Determine which keys need fetching by comparing updatedAt with local cache\n const entries = Object.entries(distantDictionariesUpdateTimeStamp);\n const keysToFetch = entries\n .filter(([key, remoteUpdatedAtValue]) => {\n if (!remoteUpdatedAtValue) return true;\n\n const remoteUpdatedAt =\n typeof remoteUpdatedAtValue === 'object'\n ? (remoteUpdatedAtValue as any).updatedAt\n : remoteUpdatedAtValue;\n\n const local = (remoteDictionariesRecord as any)[key];\n if (!local) return true;\n const localUpdatedAtRaw = (local as any)?.updatedAt as\n | number\n | string\n | undefined;\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n if (typeof localUpdatedAt !== 'number') return true;\n return remoteUpdatedAt > localUpdatedAt;\n })\n .map(([key]) => key);\n\n const cachedKeys = entries\n .filter(([key, remoteUpdatedAtValue]) => {\n const remoteUpdatedAt =\n typeof remoteUpdatedAtValue === 'object'\n ? (remoteUpdatedAtValue as any).updatedAt\n : remoteUpdatedAtValue;\n\n const local = (remoteDictionariesRecord as any)[key];\n const localUpdatedAtRaw = (local as any)?.updatedAt as\n | number\n | string\n | undefined;\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n return (\n typeof localUpdatedAt === 'number' &&\n typeof remoteUpdatedAt === 'number' &&\n localUpdatedAt >= remoteUpdatedAt\n );\n })\n .map(([key]) => key);\n\n // Check if dictionaries list is empty\n if (entries.length === 0) {\n appLogger('No dictionaries to fetch', {\n level: 'error',\n });\n return;\n }\n\n appLogger('Fetching dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = [\n ...cachedKeys.map((dictionaryKey) => ({\n dictionaryKey,\n status: 'imported' as DictionaryStatus,\n })),\n ...keysToFetch.map((dictionaryKey) => ({\n dictionaryKey,\n status: 'pending' as const,\n })),\n ];\n\n // Initialize aggregated logger\n const logger = new PullLogger();\n logger.update(\n dictionariesStatuses.map<PullStatus>((s) => ({\n dictionaryKey: s.dictionaryKey,\n status: s.status,\n }))\n );\n\n const successfullyFetchedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n const isCached =\n statusObj.status === 'imported' || statusObj.status === 'up-to-date';\n\n if (!isCached) {\n statusObj.status = 'fetching';\n logger.update([\n { dictionaryKey: statusObj.dictionaryKey, status: 'fetching' },\n ]);\n }\n\n try {\n let sourceDictionary: Dictionary | undefined;\n\n if (isCached) {\n sourceDictionary = remoteDictionariesRecord[\n statusObj.dictionaryKey\n ] as Dictionary | undefined;\n }\n\n if (!sourceDictionary) {\n // Fetch the dictionary\n const getDictionaryResult =\n await intlayerAPI.dictionary.getDictionary(statusObj.dictionaryKey);\n\n sourceDictionary = getDictionaryResult.data as Dictionary | undefined;\n }\n\n if (!sourceDictionary) {\n throw new Error(\n `Dictionary ${statusObj.dictionaryKey} not found on remote`\n );\n }\n\n // Check if there is a local version of this dictionary that is hybrid\n const localDictionaries =\n unmergedDictionariesRecord[statusObj.dictionaryKey];\n const localAndRemoteDictionary = localDictionaries?.find(\n (d) => d.location === 'hybrid'\n );\n\n if (localAndRemoteDictionary) {\n // We want to preserve the local properties but use the remote content\n sourceDictionary = {\n ...sourceDictionary,\n location: 'hybrid',\n filePath: localAndRemoteDictionary.filePath,\n localId: localAndRemoteDictionary.localId,\n };\n }\n\n // Now, write the dictionary to local file\n const { status } = await writeContentDeclaration(\n sourceDictionary,\n config,\n options\n );\n\n statusObj.status = status;\n logger.update([{ dictionaryKey: statusObj.dictionaryKey, status }]);\n\n successfullyFetchedDictionaries.push(sourceDictionary);\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error fetching dictionary ${statusObj.dictionaryKey}: ${error}`;\n logger.update([\n { dictionaryKey: statusObj.dictionaryKey, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with concurrency limit\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n // Per-dictionary summary\n const iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'fetched':\n case 'imported':\n case 'updated':\n case 'up-to-date':\n case 'reimported in JSON':\n case 'new content file':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n };\n\n const colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'fetched':\n case 'imported':\n case 'updated':\n case 'up-to-date':\n return ANSIColors.GREEN;\n case 'reimported in JSON':\n case 'new content file':\n return ANSIColors.YELLOW;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n };\n\n for (const s of dictionariesStatuses) {\n const icon = iconFor(s.status);\n const color = colorFor(s.status);\n appLogger(\n ` - ${s.dictionaryKey} ${ANSIColors.GREY}[${color}${icon} ${s.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n appLogger(statusObj.errorMessage, {\n level: 'error',\n });\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,qDAA0B,SAAS,cAAc;CACvD,MAAM,sDAAyB,OAAO;AAEtC,KAAI;AACF,+CAAiB,SAAS,cAAc;AAIxC,MAAI,CAAC,MAFoBA,uCAAa,OAAO,CAE5B;EAEjB,MAAM,cAAc,MAAMC,8CAAoB,OAAO;AAErD,QAAMC,wDACJ,SAAS,eAAe,KACxB,aACA,OACD;EAED,MAAM,gGAAqD,OAAO;EAGlE,MAAM,uCACJ,MAAM,YAAY,WAAW,gCAAgC;AAE/D,MAAI,CAAC,qCAAqC,KACxC,OAAM,IAAI,MAAM,gCAAgC;EAGlD,IAAI,qCACF,qCAAqC;AAGvC,MAAI,SAAS,aACX,sCAAqC,OAAO,YAC1C,OAAO,QAAQ,mCAAmC,CAAC,QAAQ,CAAC,SAC1D,QAAQ,cAAc,SAAS,IAAI,CACpC,CACF;AAIH,uCAAqC,OAAO,YAC1C,OAAO,QAAQ,mCAAmC,CAAC,QAAQ,CAAC,SAAS;GAEnE,MAAM,WADoB,2BAA2B,OAE/B,IAAI,YACxB,OAAO,YAAY,YACnB;AAEF,UAAO,aAAa,YAAY,aAAa;IAC7C,CACH;EAGD,MAAM,6CACJ,OAAO,OAAO,SACd,0BACD;EACD,MAAM,kBAAkB,OAAO,OAAO,0DAA8B;EACpE,MAAM,mDACJ,uBACD,GACI,gBAAgB,uBAAuB,GACxC,EAAE;EAGN,MAAM,UAAU,OAAO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ACpB,QACE,QAAOA,wBAAW;;;AAIxB,OAAK,MAAM,KAAK,sBAAsB;GACpC,MAAM,OAAO,QAAQ,EAAE,OAAO;GAC9B,MAAM,QAAQ,SAAS,EAAE,OAAO;AAChC,aACE,MAAM,EAAE,cAAc,GAAGA,wBAAW,KAAK,GAAG,QAAQ,KAAK,GAAG,EAAE,SAASA,wBAAW,KAAK,GAAGA,wBAAW,QACtG;;AAIH,OAAK,MAAM,aAAa,qBACtB,KAAI,UAAU,aACZ,WAAU,UAAU,cAAc,EAChC,OAAO,SACR,CAAC;UAGC,OAAO;AACd,YAAU,OAAO,EACf,OAAO,SACR,CAAC"}
1
+ {"version":3,"file":"pull.cjs","names":["checkCMSAuth","getAuthenticatedAPI","selectCmsEnvironment","PullLogger","ANSIColors"],"sources":["../../src/pull.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getProjectRequire } from '@intlayer/config/utils';\nimport {\n type DictionaryStatus,\n writeContentDeclaration,\n} from '@intlayer/engine/build';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport { parallelize } from '@intlayer/engine/utils';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { PullLogger, type PullStatus } from './push/pullLog';\nimport { checkCMSAuth, getAuthenticatedAPI } from './utils/checkAccess';\nimport { selectCmsEnvironment } from './utils/selectCmsEnvironment';\n\ntype PullOptions = {\n dictionaries?: string[];\n newDictionariesPath?: string;\n configOptions?: GetConfigurationOptions;\n};\n\ntype DictionariesStatus = {\n dictionaryKey: string;\n status: DictionaryStatus | 'pending' | 'fetching' | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n/**\n * Fetch distant dictionaries and write them locally,\n * with progress indicators and concurrency control.\n */\nexport const pull = async (options?: PullOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\n\n try {\n logConfigDetails(options?.configOptions);\n\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = await getAuthenticatedAPI(config);\n\n await selectCmsEnvironment(\n options?.configOptions?.env,\n intlayerAPI,\n config\n );\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n\n // Get remote update timestamps map\n const getDictionariesUpdateTimestampResult =\n await intlayerAPI.dictionary.getDictionariesUpdateTimestamp();\n\n if (!getDictionariesUpdateTimestampResult.data) {\n throw new Error('No distant dictionaries found');\n }\n\n let distantDictionariesUpdateTimeStamp: Record<string, any> =\n getDictionariesUpdateTimestampResult.data;\n\n // Optional filtering by requested dictionaries\n if (options?.dictionaries) {\n distantDictionariesUpdateTimeStamp = Object.fromEntries(\n Object.entries(distantDictionariesUpdateTimeStamp).filter(([key]) =>\n options.dictionaries?.includes(key)\n )\n );\n }\n\n // Filter by location\n distantDictionariesUpdateTimeStamp = Object.fromEntries(\n Object.entries(distantDictionariesUpdateTimeStamp).filter(([key]) => {\n const localDictionaries = unmergedDictionariesRecord[key];\n const location =\n localDictionaries?.[0]?.location ??\n config.dictionary?.location ??\n 'remote';\n\n return location === 'remote' || location === 'hybrid';\n })\n );\n\n // Load local cached remote dictionaries (if any)\n const remoteDictionariesPath = join(\n config.system.mainDir,\n 'remote_dictionaries.cjs'\n );\n const requireFunction = config.build?.require ?? getProjectRequire();\n const remoteDictionariesRecord: Record<string, any> = existsSync(\n remoteDictionariesPath\n )\n ? (requireFunction(remoteDictionariesPath) as any)\n : {};\n\n // Determine which keys need fetching by comparing updatedAt with local cache\n const entries = Object.entries(distantDictionariesUpdateTimeStamp);\n const keysToFetch = entries\n .filter(([key, remoteUpdatedAtValue]) => {\n if (!remoteUpdatedAtValue) return true;\n\n const remoteUpdatedAt =\n typeof remoteUpdatedAtValue === 'object'\n ? (remoteUpdatedAtValue as any).updatedAt\n : remoteUpdatedAtValue;\n\n const local = (remoteDictionariesRecord as any)[key];\n if (!local) return true;\n const localUpdatedAtRaw = (local as any)?.updatedAt as\n | number\n | string\n | undefined;\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n if (typeof localUpdatedAt !== 'number') return true;\n return remoteUpdatedAt > localUpdatedAt;\n })\n .map(([key]) => key);\n\n const cachedKeys = entries\n .filter(([key, remoteUpdatedAtValue]) => {\n const remoteUpdatedAt =\n typeof remoteUpdatedAtValue === 'object'\n ? (remoteUpdatedAtValue as any).updatedAt\n : remoteUpdatedAtValue;\n\n const local = (remoteDictionariesRecord as any)[key];\n const localUpdatedAtRaw = (local as any)?.updatedAt as\n | number\n | string\n | undefined;\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n return (\n typeof localUpdatedAt === 'number' &&\n typeof remoteUpdatedAt === 'number' &&\n localUpdatedAt >= remoteUpdatedAt\n );\n })\n .map(([key]) => key);\n\n // Check if dictionaries list is empty\n if (entries.length === 0) {\n appLogger('No dictionaries to fetch', {\n level: 'error',\n });\n return;\n }\n\n appLogger('Fetching dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = [\n ...cachedKeys.map((dictionaryKey) => ({\n dictionaryKey,\n status: 'imported' as DictionaryStatus,\n })),\n ...keysToFetch.map((dictionaryKey) => ({\n dictionaryKey,\n status: 'pending' as const,\n })),\n ];\n\n // Initialize aggregated logger\n const logger = new PullLogger();\n logger.update(\n dictionariesStatuses.map<PullStatus>((s) => ({\n dictionaryKey: s.dictionaryKey,\n status: s.status,\n }))\n );\n\n const successfullyFetchedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n const isCached =\n statusObj.status === 'imported' || statusObj.status === 'up-to-date';\n\n if (!isCached) {\n statusObj.status = 'fetching';\n logger.update([\n { dictionaryKey: statusObj.dictionaryKey, status: 'fetching' },\n ]);\n }\n\n try {\n let sourceDictionary: Dictionary | undefined;\n\n if (isCached) {\n sourceDictionary = remoteDictionariesRecord[\n statusObj.dictionaryKey\n ] as Dictionary | undefined;\n }\n\n if (!sourceDictionary) {\n // Fetch the dictionary\n const getDictionaryResult =\n await intlayerAPI.dictionary.getDictionary(statusObj.dictionaryKey);\n\n sourceDictionary = getDictionaryResult.data as Dictionary | undefined;\n }\n\n if (!sourceDictionary) {\n throw new Error(\n `Dictionary ${statusObj.dictionaryKey} not found on remote`\n );\n }\n\n // Check if there is a local version of this dictionary that is hybrid\n const localDictionaries =\n unmergedDictionariesRecord[statusObj.dictionaryKey];\n const localAndRemoteDictionary = localDictionaries?.find(\n (d) => d.location === 'hybrid'\n );\n\n if (localAndRemoteDictionary) {\n // We want to preserve the local properties but use the remote content\n sourceDictionary = {\n ...sourceDictionary,\n location: 'hybrid',\n filePath: localAndRemoteDictionary.filePath,\n localId: localAndRemoteDictionary.localId,\n };\n }\n\n // Now, write the dictionary to local file\n const { status } = await writeContentDeclaration(\n sourceDictionary,\n config,\n options\n );\n\n statusObj.status = status;\n logger.update([{ dictionaryKey: statusObj.dictionaryKey, status }]);\n\n successfullyFetchedDictionaries.push(sourceDictionary);\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error fetching dictionary ${statusObj.dictionaryKey}: ${error}`;\n logger.update([\n { dictionaryKey: statusObj.dictionaryKey, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with concurrency limit\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n // Per-dictionary summary\n const iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'fetched':\n case 'imported':\n case 'updated':\n case 'up-to-date':\n case 'reimported in JSON':\n case 'new content file':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n };\n\n const colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'fetched':\n case 'imported':\n case 'updated':\n case 'up-to-date':\n return ANSIColors.GREEN;\n case 'reimported in JSON':\n case 'new content file':\n return ANSIColors.YELLOW;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n };\n\n for (const s of dictionariesStatuses) {\n const icon = iconFor(s.status);\n const color = colorFor(s.status);\n appLogger(\n ` - ${s.dictionaryKey} ${ANSIColors.GREY}[${color}${icon} ${s.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n appLogger(statusObj.errorMessage, {\n level: 'error',\n });\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,qDAA0B,SAAS,cAAc;CACvD,MAAM,sDAAyB,OAAO;AAEtC,KAAI;AACF,6CAAiB,SAAS,cAAc;AAIxC,MAAI,CAAC,MAFoBA,uCAAa,OAAO,CAE5B;EAEjB,MAAM,cAAc,MAAMC,8CAAoB,OAAO;AAErD,QAAMC,wDACJ,SAAS,eAAe,KACxB,aACA,OACD;EAED,MAAM,gGAAqD,OAAO;EAGlE,MAAM,uCACJ,MAAM,YAAY,WAAW,gCAAgC;AAE/D,MAAI,CAAC,qCAAqC,KACxC,OAAM,IAAI,MAAM,gCAAgC;EAGlD,IAAI,qCACF,qCAAqC;AAGvC,MAAI,SAAS,aACX,sCAAqC,OAAO,YAC1C,OAAO,QAAQ,mCAAmC,CAAC,QAAQ,CAAC,SAC1D,QAAQ,cAAc,SAAS,IAAI,CACpC,CACF;AAIH,uCAAqC,OAAO,YAC1C,OAAO,QAAQ,mCAAmC,CAAC,Q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IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK,mBACH,QAAO;IACT,KAAK,QACH,QAAO;IACT,QACE,QAAO;;;EAIb,MAAM,YAAY,WAAyC;AACzD,WAAQ,QAAR;IACE,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK,aACH,QAAOC,wBAAW;IACpB,KAAK;IACL,KAAK,mBACH,QAAOA,wBAAW;IACpB,KAAK,QACH,QAAOA,wBAAW;IACpB,QACE,QAAOA,wBAAW;;;AAIxB,OAAK,MAAM,KAAK,sBAAsB;GACpC,MAAM,OAAO,QAAQ,EAAE,OAAO;GAC9B,MAAM,QAAQ,SAAS,EAAE,OAAO;AAChC,aACE,MAAM,EAAE,cAAc,GAAGA,wBAAW,KAAK,GAAG,QAAQ,KAAK,GAAG,EAAE,SAASA,wBAAW,KAAK,GAAGA,wBAAW,QACtG;;AAIH,OAAK,MAAM,aAAa,qBACtB,KAAI,UAAU,aACZ,WAAU,UAAU,cAAc,EAChC,OAAO,SACR,CAAC;UAGC,OAAO;AACd,YAAU,OAAO,EACf,OAAO,SACR,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"pullLog.cjs","names":["spinnerFrames","ANSIColors"],"sources":["../../../src/push/pullLog.ts"],"sourcesContent":["import type { DictionaryStatus } from '@intlayer/chokidar/build';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, spinnerFrames } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\n\nexport type PullStatus = {\n dictionaryKey: string;\n status: DictionaryStatus | 'pending' | 'fetching';\n errorMessage?: string;\n};\n\nexport class PullLogger {\n private statuses: PullStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n\n constructor() {\n const configuration = getConfiguration();\n this.prefix = configuration.log.prefix;\n }\n\n update(newStatuses: PullStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) => s.dictionaryKey === status.dictionaryKey\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n private render() {\n const { total, done, success, errors } = this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const lines: string[] = [];\n\n const isDone = done === total;\n const progressLabel = `dictionaries: ${done}/${total}`;\n const details: string[] = [];\n if (success > 0) details.push(`ok: ${success}`);\n if (errors > 0) details.push(colorize(`errors: ${errors}`, ANSIColors.RED));\n\n const suffix = details.length > 0 ? ` (${details.join(', ')})` : '';\n\n if (isDone) {\n lines.push(\n `${this.prefix} ${colorize('✔', ANSIColors.GREEN)} fetched ${progressLabel}${suffix}`\n );\n } else {\n lines.push(\n `${this.prefix} ${colorize(frame, ANSIColors.BLUE)} fetching ${progressLabel}${suffix}`\n );\n }\n\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const keys = new Set(this.statuses.map((s) => s.dictionaryKey));\n\n const doneSet = new Set<DictionaryStatus | 'error'>([\n 'fetched',\n 'imported',\n 'updated',\n 'up-to-date',\n 'reimported in JSON',\n 'new content file',\n 'error',\n ] as const);\n\n const successesSet = new Set<DictionaryStatus>([\n 'fetched',\n 'imported',\n 'updated',\n 'up-to-date',\n 'reimported in JSON',\n 'new content file',\n ] as const);\n\n const done = this.statuses.filter((s) =>\n doneSet.has(s.status as any)\n ).length;\n const success = this.statuses.filter((s) =>\n successesSet.has(s.status as any)\n ).length;\n const errors = this.statuses.filter((s) => s.status === 'error').length;\n\n return {\n total: keys.size,\n done,\n success,\n errors,\n } as const;\n }\n}\n"],"mappings":";;;;;;;;AAWA,IAAa,aAAb,MAAwB;CACtB,AAAQ,WAAyB,EAAE;CACnC,AAAQ,eAAsC;CAC9C,AAAQ,eAAe;CACvB,AAAQ,gBAAgB;CACxB,AAAiB,gBAAgBA;CACjC,AAAQ,aAAa;CACrB,AAAiB;CACjB,AAAQ,oBAA4B;CAEpC,cAAc;EACZ,MAAM,6DAAkC;AACxC,OAAK,SAAS,cAAc,IAAI;;CAGlC,OAAO,aAA2B;AAChC,MAAI,KAAK,WAAY;AACrB,OAAK,MAAM,UAAU,aAAa;GAChC,MAAM,QAAQ,KAAK,SAAS,WACzB,MAAM,EAAE,kBAAkB,OAAO,cACnC;AACD,OAAI,SAAS,EACX,MAAK,SAAS,SAAS;OAEvB,MAAK,SAAS,KAAK,OAAO;;AAI9B,OAAK,cAAc;AACnB,OAAK,QAAQ;;CAGf,SAAS;AACP,OAAK,aAAa;AAClB,OAAK,aAAa;AAClB,OAAK,QAAQ;;CAGf,AAAQ,eAAe;AACrB,MAAI,KAAK,gBAAgB,KAAK,WAAY;AAC1C,OAAK,eAAe,kBAAkB;AACpC,QAAK,gBAAgB,KAAK,eAAe,KAAK,KAAK,cAAc;AACjE,QAAK,QAAQ;KACZ,IAAI;;CAGT,AAAQ,cAAc;AACpB,MAAI,CAAC,KAAK,aAAc;AACxB,gBAAc,KAAK,aAAa;AAChC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ACA;GACA;GACA;GACD,CAAU;EAEX,MAAM,eAAe,IAAI,IAAsB;GAC7C;GACA;GACA;GACA;GACA;GACA;GACD,CAAU;EAEX,MAAM,OAAO,KAAK,SAAS,QAAQ,MACjC,QAAQ,IAAI,EAAE,OAAc,CAC7B,CAAC;EACF,MAAM,UAAU,KAAK,SAAS,QAAQ,MACpC,aAAa,IAAI,EAAE,OAAc,CAClC,CAAC;EACF,MAAM,SAAS,KAAK,SAAS,QAAQ,MAAM,EAAE,WAAW,QAAQ,CAAC;AAEjE,SAAO;GACL,OAAO,KAAK;GACZ;GACA;GACA;GACD"}
1
+ {"version":3,"file":"pullLog.cjs","names":["spinnerFrames","ANSIColors"],"sources":["../../../src/push/pullLog.ts"],"sourcesContent":["import * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, spinnerFrames } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { DictionaryStatus } from '@intlayer/engine/build';\n\nexport type PullStatus = {\n dictionaryKey: string;\n status: DictionaryStatus | 'pending' | 'fetching';\n errorMessage?: string;\n};\n\nexport class PullLogger {\n private statuses: PullStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n\n constructor() {\n const configuration = getConfiguration();\n this.prefix = configuration.log.prefix;\n }\n\n update(newStatuses: PullStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) => s.dictionaryKey === status.dictionaryKey\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n private render() {\n const { total, done, success, errors } = this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const lines: string[] = [];\n\n const isDone = done === total;\n const progressLabel = `dictionaries: ${done}/${total}`;\n const details: string[] = [];\n if (success > 0) details.push(`ok: ${success}`);\n if (errors > 0) details.push(colorize(`errors: ${errors}`, ANSIColors.RED));\n\n const suffix = details.length > 0 ? ` (${details.join(', ')})` : '';\n\n if (isDone) {\n lines.push(\n `${this.prefix} ${colorize('✔', ANSIColors.GREEN)} fetched ${progressLabel}${suffix}`\n );\n } else {\n lines.push(\n `${this.prefix} ${colorize(frame, ANSIColors.BLUE)} fetching ${progressLabel}${suffix}`\n );\n }\n\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const keys = new Set(this.statuses.map((s) => s.dictionaryKey));\n\n const doneSet = new Set<DictionaryStatus | 'error'>([\n 'fetched',\n 'imported',\n 'updated',\n 'up-to-date',\n 'reimported in JSON',\n 'new content file',\n 'error',\n ] as const);\n\n const successesSet = new Set<DictionaryStatus>([\n 'fetched',\n 'imported',\n 'updated',\n 'up-to-date',\n 'reimported in JSON',\n 'new content file',\n ] as const);\n\n const done = this.statuses.filter((s) =>\n doneSet.has(s.status as any)\n ).length;\n const success = this.statuses.filter((s) =>\n successesSet.has(s.status as any)\n ).length;\n const errors = this.statuses.filter((s) => s.status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EjE,SAAO;GACL,OAAO,KAAK;GACZ;GACA;GACA;GACD"}
@@ -4,13 +4,13 @@ const require_utils_checkAccess = require('../utils/checkAccess.cjs');
4
4
  const require_utils_selectCmsEnvironment = require('../utils/selectCmsEnvironment.cjs');
5
5
  const require_pushLog = require('../pushLog.cjs');
6
6
  let node_path = require("node:path");
7
- let _intlayer_chokidar_build = require("@intlayer/chokidar/build");
8
- let _intlayer_chokidar_cli = require("@intlayer/chokidar/cli");
9
- let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
10
7
  let _intlayer_config_colors = require("@intlayer/config/colors");
11
8
  _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
12
9
  let _intlayer_config_logger = require("@intlayer/config/logger");
13
10
  let _intlayer_config_node = require("@intlayer/config/node");
11
+ let _intlayer_engine_build = require("@intlayer/engine/build");
12
+ let _intlayer_engine_cli = require("@intlayer/engine/cli");
13
+ let _intlayer_engine_utils = require("@intlayer/engine/utils");
14
14
  let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
15
15
  let node_fs_promises = require("node:fs/promises");
16
16
  node_fs_promises = require_runtime.__toESM(node_fs_promises);
@@ -46,10 +46,10 @@ const getIconAndColor = (status) => {
46
46
  */
47
47
  const push = async (options) => {
48
48
  const config = (0, _intlayer_config_node.getConfiguration)(options?.configOptions);
49
- (0, _intlayer_chokidar_cli.logConfigDetails)(options?.configOptions);
49
+ (0, _intlayer_engine_cli.logConfigDetails)(options?.configOptions);
50
50
  const appLogger = (0, _intlayer_config_logger.getAppLogger)(config);
51
- if (options?.build === true) await (0, _intlayer_chokidar_build.prepareIntlayer)(config, { forceRun: true });
52
- else if (typeof options?.build === "undefined") await (0, _intlayer_chokidar_build.prepareIntlayer)(config);
51
+ if (options?.build === true) await (0, _intlayer_engine_build.prepareIntlayer)(config, { forceRun: true });
52
+ else if (typeof options?.build === "undefined") await (0, _intlayer_engine_build.prepareIntlayer)(config);
53
53
  try {
54
54
  if (!await require_utils_checkAccess.checkCMSAuth(config)) return;
55
55
  const intlayerAPI = await require_utils_checkAccess.getAuthenticatedAPI(config);
@@ -77,7 +77,7 @@ const push = async (options) => {
77
77
  dictionaries = dictionaries.filter((dictionary) => options.dictionaries?.includes(dictionary.key));
78
78
  }
79
79
  if (options?.gitOptions) {
80
- const gitFiles = await (0, _intlayer_chokidar_cli.listGitFiles)(options.gitOptions);
80
+ const gitFiles = await (0, _intlayer_engine_cli.listGitFiles)(options.gitOptions);
81
81
  dictionaries = dictionaries.filter((dictionary) => gitFiles.includes((0, node_path.join)(config.system.baseDir, dictionary.filePath ?? "")));
82
82
  }
83
83
  if (dictionaries.length === 0) {
@@ -114,7 +114,7 @@ const push = async (options) => {
114
114
  for (const remoteDictionaryData of allDictionaries) {
115
115
  const localDictionary = unmergedDictionariesRecord[remoteDictionaryData.key]?.find((dictionary) => dictionary.localId === remoteDictionaryData.localId);
116
116
  if (!localDictionary) continue;
117
- await (0, _intlayer_chokidar_build.writeContentDeclaration)({
117
+ await (0, _intlayer_engine_build.writeContentDeclaration)({
118
118
  ...localDictionary,
119
119
  id: remoteDictionaryData.id
120
120
  }, config);
@@ -150,7 +150,7 @@ const push = async (options) => {
150
150
  }]);
151
151
  }
152
152
  };
153
- await (0, _intlayer_chokidar_utils.parallelize)(dictionariesStatuses, processDictionary, 5);
153
+ await (0, _intlayer_engine_utils.parallelize)(dictionariesStatuses, processDictionary, 5);
154
154
  logger.finish();
155
155
  for (const dictionaryStatus of dictionariesStatuses) {
156
156
  const { icon, color } = getIconAndColor(dictionaryStatus.status);
@@ -193,11 +193,11 @@ const deleteLocalDictionaries = async (dictionariesToDelete, options) => {
193
193
  const stats = await node_fs_promises.lstat(filePath);
194
194
  if (stats.isFile()) {
195
195
  await node_fs_promises.unlink(filePath);
196
- appLogger(`Deleted file ${(0, _intlayer_chokidar_utils.formatPath)(filePath)}`, {});
197
- } else if (stats.isDirectory()) appLogger(`Path is a directory ${(0, _intlayer_chokidar_utils.formatPath)(filePath)}, skipping.`, {});
198
- else appLogger(`Unknown file type for ${(0, _intlayer_chokidar_utils.formatPath)(filePath)}, skipping.`, {});
196
+ appLogger(`Deleted file ${(0, _intlayer_engine_utils.formatPath)(filePath)}`, {});
197
+ } else if (stats.isDirectory()) appLogger(`Path is a directory ${(0, _intlayer_engine_utils.formatPath)(filePath)}, skipping.`, {});
198
+ else appLogger(`Unknown file type for ${(0, _intlayer_engine_utils.formatPath)(filePath)}, skipping.`, {});
199
199
  } catch (err) {
200
- appLogger(`Error deleting ${(0, _intlayer_chokidar_utils.formatPath)(filePath)}: ${err}`, { level: "error" });
200
+ appLogger(`Error deleting ${(0, _intlayer_engine_utils.formatPath)(filePath)}: ${err}`, { level: "error" });
201
201
  }
202
202
  };
203
203
 
@@ -1 +1 @@
1
- {"version":3,"file":"push.cjs","names":["ANSIColors","checkCMSAuth","getAuthenticatedAPI","selectCmsEnvironment","PushLogger","fsPromises"],"sources":["../../../src/push/push.ts"],"sourcesContent":["import * as fsPromises from 'node:fs/promises';\nimport { join } from 'node:path';\nimport {\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/chokidar/build';\nimport {\n type ListGitFilesOptions,\n listGitFiles,\n logConfigDetails,\n} from '@intlayer/chokidar/cli';\nimport { formatPath, parallelize } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { PushLogger, type PushStatus } from '../pushLog';\nimport { checkCMSAuth, getAuthenticatedAPI } from '../utils/checkAccess';\nimport { selectCmsEnvironment } from '../utils/selectCmsEnvironment';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status:\n | 'pending'\n | 'pushing'\n | 'modified'\n | 'pushed'\n | 'up-to-date'\n | 'unknown'\n | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n// Print per-dictionary summary similar to loadDictionaries\nconst statusIconsAndColors = {\n pushed: { icon: '✔', color: ANSIColors.GREEN },\n modified: { icon: '✔', color: ANSIColors.GREEN },\n 'up-to-date': { icon: '=', color: ANSIColors.GREY },\n error: { icon: '✖', color: ANSIColors.RED },\n default: { icon: '⏲', color: ANSIColors.BLUE },\n};\n\nconst getIconAndColor = (status: DictionariesStatus['status']) => {\n return (\n statusIconsAndColors[status as keyof typeof statusIconsAndColors] ??\n statusIconsAndColors.default\n );\n};\n\n/**\n * Get all local dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n try {\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = await getAuthenticatedAPI(config);\n\n await selectCmsEnvironment(\n options?.configOptions?.env,\n intlayerAPI,\n config\n );\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n const allDictionaries = Object.values(unmergedDictionariesRecord).flat();\n\n const customLocations = Array.from(\n new Set(\n allDictionaries\n .map((dictionary) => dictionary.location)\n .filter(\n (location) =>\n location && !['remote', 'local', 'hybrid'].includes(location)\n )\n )\n ) as string[];\n\n // Include all custom locations automatically — no interactive prompt needed.\n const selectedCustomLocations: string[] = customLocations;\n\n let dictionaries: Dictionary[] = allDictionaries.filter((dictionary) => {\n const location =\n dictionary.location ?? config.dictionary?.location ?? 'local';\n\n return (\n location === 'remote' ||\n location === 'hybrid' ||\n selectedCustomLocations.includes(location)\n );\n });\n\n // Check if the dictionaries list is empty after filtering by location\n if (dictionaries.length === 0) {\n appLogger(\n `No dictionaries found to push. Only dictionaries with location ${colorize('remote', ANSIColors.BLUE, ANSIColors.RESET)}, ${colorize('hybrid', ANSIColors.BLUE, ANSIColors.RESET)} or selected custom locations are pushed.`,\n { level: 'warn' }\n );\n appLogger(\n `You can set the location in your dictionary file (e.g. ${colorize(\"{ key: 'my-key', location: 'hybrid', ... }\", ANSIColors.BLUE, ANSIColors.RESET)} or globally in your intlayer.config.ts file (e.g. ${colorize(\"{ dictionary: { location: 'hybrid' } }\", ANSIColors.BLUE, ANSIColors.RESET)}).`,\n { level: 'info' }\n );\n return;\n }\n\n const existingDictionariesKeys: string[] = Object.keys(\n unmergedDictionariesRecord\n );\n\n if (options?.dictionaries) {\n // Check if the provided dictionaries exist\n const noneExistingDictionariesOption = options.dictionaries.filter(\n (dictionaryId) => !existingDictionariesKeys.includes(dictionaryId)\n );\n\n if (noneExistingDictionariesOption.length > 0) {\n appLogger(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`,\n {\n level: 'error',\n }\n );\n }\n\n // Filter the dictionaries from the provided list of IDs\n dictionaries = dictionaries.filter((dictionary) =>\n options.dictionaries?.includes(dictionary.key)\n );\n }\n\n if (options?.gitOptions) {\n const gitFiles = await listGitFiles(options.gitOptions);\n\n dictionaries = dictionaries.filter((dictionary) =>\n gitFiles.includes(\n join(config.system.baseDir, dictionary.filePath ?? '')\n )\n );\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n appLogger('No local dictionaries found', {\n level: 'error',\n });\n return;\n }\n\n appLogger('Pushing dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary) => ({\n dictionary,\n status: 'pending',\n })\n );\n\n // Initialize aggregated logger similar to loadDictionaries\n const logger = new PushLogger();\n logger.update(\n dictionariesStatuses.map<PushStatus>((s) => ({\n dictionaryKey: s.dictionary.key,\n status: 'pending',\n }))\n );\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushing' },\n ]);\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries([\n statusObj.dictionary,\n ]);\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries ?? [];\n const newDictionaries = pushResult.data?.newDictionaries ?? [];\n const upToDateDictionaries =\n pushResult.data?.upToDateDictionaries ?? [];\n\n const allDictionaries = [\n ...updatedDictionaries,\n ...newDictionaries,\n ...upToDateDictionaries,\n ];\n\n for (const remoteDictionaryData of allDictionaries) {\n const localDictionary = unmergedDictionariesRecord[\n remoteDictionaryData.key\n ]?.find(\n (dictionary) => dictionary.localId === remoteDictionaryData.localId\n );\n\n if (!localDictionary) continue;\n\n await writeContentDeclaration(\n { ...localDictionary, id: remoteDictionaryData.id },\n config\n );\n }\n\n if (\n updatedDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'modified' },\n ]);\n } else if (\n newDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushed' },\n ]);\n } else if (\n upToDateDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'up-to-date';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'up-to-date' },\n ]);\n } else {\n statusObj.status = 'unknown';\n }\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error pushing dictionary ${statusObj.dictionary.key}: ${error}`;\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit (reuse parallelize)\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n for (const dictionaryStatus of dictionariesStatuses) {\n const { icon, color } = getIconAndColor(dictionaryStatus.status);\n appLogger(\n ` - ${colorizeKey(dictionaryStatus.dictionary.key)} ${ANSIColors.GREY}[${color}${icon} ${dictionaryStatus.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n appLogger(statusObj.errorMessage, {\n level: 'error',\n });\n }\n }\n\n // Handle delete or keep options\n const deleteOption = options?.deleteLocaleDictionary;\n const keepOption = options?.keepLocaleDictionary;\n\n if (deleteOption && keepOption) {\n throw new Error(\n 'Cannot specify both --deleteLocaleDictionary and --keepLocaleDictionary options.'\n );\n }\n\n if (deleteOption) {\n // Delete only the successfully pushed dictionaries\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const remoteDictionaries = successfullyPushedDictionaries.filter(\n (dictionary) => dictionary.location === 'remote'\n );\n const remoteDictionariesKeys = remoteDictionaries.map(\n (dictionary) => dictionary.key\n );\n\n if (remoteDictionaries.length > 0) {\n const { confirm, isCancel } = await import('@clack/prompts');\n\n const shouldDelete = await confirm({\n message: `Do you want to delete the local dictionaries that were successfully pushed? ${colorize('(Dictionaries:', ANSIColors.GREY, ANSIColors.RESET)} ${colorizeKey(remoteDictionariesKeys)}${colorize(')', ANSIColors.GREY, ANSIColors.RESET)}`,\n initialValue: false,\n });\n\n if (isCancel(shouldDelete)) {\n return;\n }\n\n if (shouldDelete) {\n await deleteLocalDictionaries(remoteDictionaries, options);\n }\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\n\n // Use a Set to collect all unique file paths\n const filePathsSet: Set<string> = new Set();\n\n for (const dictionary of dictionariesToDelete) {\n const { filePath } = dictionary;\n\n if (!filePath) {\n appLogger(\n `Dictionary ${colorizeKey(dictionary.key)} does not have a file path`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n appLogger(`Deleted file ${formatPath(filePath)}`, {});\n } else if (stats.isDirectory()) {\n appLogger(`Path is a directory ${formatPath(filePath)}, skipping.`, {});\n } else {\n appLogger(\n `Unknown file type for ${formatPath(filePath)}, skipping.`,\n {}\n );\n }\n } catch (err) {\n appLogger(`Error deleting ${formatPath(filePath)}: ${err}`, {\n level: 'error',\n });\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgDA,MAAM,uBAAuB;CAC3B,QAAQ;EAAE,MAAM;EAAK,OAAOA,wBAAW;EAAO;CAC9C,UAAU;EAAE,MAAM;EAAK,OAAOA,wBAAW;EAAO;CAChD,cAAc;EAAE,MAAM;EAAK,OAAOA,wBAAW;EAAM;CACnD,OAAO;EAAE,MAAM;EAAK,OAAOA,wBAAW;EAAK;CAC3C,SAAS;EAAE,MAAM;EAAK,OAAOA,wBAAW;EAAM;CAC/C;AAED,MAAM,mBAAmB,WAAyC;AAChE,QACE,qBAAqB,WACrB,qBAAqB;;;;;AAOzB,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,qDAA0B,SAAS,cAAc;AACvD,8CAAiB,SAAS,cAAc;CAExC,MAAM,sDAAyB,OAAO;AAEtC,KAAI,SAAS,UAAU,KACrB,qDAAsB,QAAQ,EAAE,UAAU,MA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yBAAyB,mBAAmB,KAC/C,eAAe,WAAW,IAC5B;AAED,OAAI,mBAAmB,SAAS,GAAG;IACjC,MAAM,EAAE,SAAS,aAAa,MAAM,OAAO;IAE3C,MAAM,eAAe,MAAM,QAAQ;KACjC,SAAS,qHAAwF,kBAAkBA,wBAAW,MAAMA,wBAAW,MAAM,CAAC,4CAAe,uBAAuB,yCAAY,KAAKA,wBAAW,MAAMA,wBAAW,MAAM;KAC/O,cAAc;KACf,CAAC;AAEF,QAAI,SAAS,aAAa,CACxB;AAGF,QAAI,aACF,OAAM,wBAAwB,oBAAoB,QAAQ;;;UAIzD,OAAO;AACd,YAAU,OAAO,EACf,OAAO,SACR,CAAC;;;AAIN,MAAM,0BAA0B,OAC9B,sBACA,YACkB;CAElB,MAAM,kGAD0B,SAAS,cACJ,CAAC;CAGtC,MAAM,+BAA4B,IAAI,KAAK;AAE3C,MAAK,MAAM,cAAc,sBAAsB;EAC7C,MAAM,EAAE,aAAa;AAErB,MAAI,CAAC,UAAU;AACb,aACE,uDAA0B,WAAW,IAAI,CAAC,6BAC1C,EACE,OAAO,SACR,CACF;AACD;;AAGF,eAAa,IAAI,SAAS;;AAG5B,MAAK,MAAM,YAAY,aACrB,KAAI;EACF,MAAM,QAAQ,MAAMK,iBAAW,MAAM,SAAS;AAE9C,MAAI,MAAM,QAAQ,EAAE;AAClB,SAAMA,iBAAW,OAAO,SAAS;AACjC,aAAU,yDAA2B,SAAS,IAAI,EAAE,CAAC;aAC5C,MAAM,aAAa,CAC5B,WAAU,gEAAkC,SAAS,CAAC,cAAc,EAAE,CAAC;MAEvE,WACE,kEAAoC,SAAS,CAAC,cAC9C,EAAE,CACH;UAEI,KAAK;AACZ,YAAU,2DAA6B,SAAS,CAAC,IAAI,OAAO,EAC1D,OAAO,SACR,CAAC"}
1
+ {"version":3,"file":"push.cjs","names":["ANSIColors","checkCMSAuth","getAuthenticatedAPI","selectCmsEnvironment","PushLogger","fsPromises"],"sources":["../../../src/push/push.ts"],"sourcesContent":["import * as fsPromises from 'node:fs/promises';\nimport { join } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/engine/build';\nimport {\n type ListGitFilesOptions,\n listGitFiles,\n logConfigDetails,\n} from '@intlayer/engine/cli';\nimport { formatPath, parallelize } from '@intlayer/engine/utils';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { PushLogger, type PushStatus } from '../pushLog';\nimport { checkCMSAuth, getAuthenticatedAPI } from '../utils/checkAccess';\nimport { selectCmsEnvironment } from '../utils/selectCmsEnvironment';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status:\n | 'pending'\n | 'pushing'\n | 'modified'\n | 'pushed'\n | 'up-to-date'\n | 'unknown'\n | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n// Print per-dictionary summary similar to loadDictionaries\nconst statusIconsAndColors = {\n pushed: { icon: '✔', color: ANSIColors.GREEN },\n modified: { icon: '✔', color: ANSIColors.GREEN },\n 'up-to-date': { icon: '=', color: ANSIColors.GREY },\n error: { icon: '✖', color: ANSIColors.RED },\n default: { icon: '⏲', color: ANSIColors.BLUE },\n};\n\nconst getIconAndColor = (status: DictionariesStatus['status']) => {\n return (\n statusIconsAndColors[status as keyof typeof statusIconsAndColors] ??\n statusIconsAndColors.default\n );\n};\n\n/**\n * Get all local dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n try {\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = await getAuthenticatedAPI(config);\n\n await selectCmsEnvironment(\n options?.configOptions?.env,\n intlayerAPI,\n config\n );\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n const allDictionaries = Object.values(unmergedDictionariesRecord).flat();\n\n const customLocations = Array.from(\n new Set(\n allDictionaries\n .map((dictionary) => dictionary.location)\n .filter(\n (location) =>\n location && !['remote', 'local', 'hybrid'].includes(location)\n )\n )\n ) as string[];\n\n // Include all custom locations automatically — no interactive prompt needed.\n const selectedCustomLocations: string[] = customLocations;\n\n let dictionaries: Dictionary[] = allDictionaries.filter((dictionary) => {\n const location =\n dictionary.location ?? config.dictionary?.location ?? 'local';\n\n return (\n location === 'remote' ||\n location === 'hybrid' ||\n selectedCustomLocations.includes(location)\n );\n });\n\n // Check if the dictionaries list is empty after filtering by location\n if (dictionaries.length === 0) {\n appLogger(\n `No dictionaries found to push. Only dictionaries with location ${colorize('remote', ANSIColors.BLUE, ANSIColors.RESET)}, ${colorize('hybrid', ANSIColors.BLUE, ANSIColors.RESET)} or selected custom locations are pushed.`,\n { level: 'warn' }\n );\n appLogger(\n `You can set the location in your dictionary file (e.g. ${colorize(\"{ key: 'my-key', location: 'hybrid', ... }\", ANSIColors.BLUE, ANSIColors.RESET)} or globally in your intlayer.config.ts file (e.g. ${colorize(\"{ dictionary: { location: 'hybrid' } }\", ANSIColors.BLUE, ANSIColors.RESET)}).`,\n { level: 'info' }\n );\n return;\n }\n\n const existingDictionariesKeys: string[] = Object.keys(\n unmergedDictionariesRecord\n );\n\n if (options?.dictionaries) {\n // Check if the provided dictionaries exist\n const noneExistingDictionariesOption = options.dictionaries.filter(\n (dictionaryId) => !existingDictionariesKeys.includes(dictionaryId)\n );\n\n if (noneExistingDictionariesOption.length > 0) {\n appLogger(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`,\n {\n level: 'error',\n }\n );\n }\n\n // Filter the dictionaries from the provided list of IDs\n dictionaries = dictionaries.filter((dictionary) =>\n options.dictionaries?.includes(dictionary.key)\n );\n }\n\n if (options?.gitOptions) {\n const gitFiles = await listGitFiles(options.gitOptions);\n\n dictionaries = dictionaries.filter((dictionary) =>\n gitFiles.includes(\n join(config.system.baseDir, dictionary.filePath ?? '')\n )\n );\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n appLogger('No local dictionaries found', {\n level: 'error',\n });\n return;\n }\n\n appLogger('Pushing dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary) => ({\n dictionary,\n status: 'pending',\n })\n );\n\n // Initialize aggregated logger similar to loadDictionaries\n const logger = new PushLogger();\n logger.update(\n dictionariesStatuses.map<PushStatus>((s) => ({\n dictionaryKey: s.dictionary.key,\n status: 'pending',\n }))\n );\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushing' },\n ]);\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries([\n statusObj.dictionary,\n ]);\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries ?? [];\n const newDictionaries = pushResult.data?.newDictionaries ?? [];\n const upToDateDictionaries =\n pushResult.data?.upToDateDictionaries ?? [];\n\n const allDictionaries = [\n ...updatedDictionaries,\n ...newDictionaries,\n ...upToDateDictionaries,\n ];\n\n for (const remoteDictionaryData of allDictionaries) {\n const localDictionary = unmergedDictionariesRecord[\n remoteDictionaryData.key\n ]?.find(\n (dictionary) => dictionary.localId === remoteDictionaryData.localId\n );\n\n if (!localDictionary) continue;\n\n await writeContentDeclaration(\n { ...localDictionary, id: remoteDictionaryData.id },\n config\n );\n }\n\n if (\n updatedDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'modified' },\n ]);\n } else if (\n newDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushed' },\n ]);\n } else if (\n upToDateDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'up-to-date';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'up-to-date' },\n ]);\n } else {\n statusObj.status = 'unknown';\n }\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error pushing dictionary ${statusObj.dictionary.key}: ${error}`;\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit (reuse parallelize)\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n for (const dictionaryStatus of dictionariesStatuses) {\n const { icon, color } = getIconAndColor(dictionaryStatus.status);\n appLogger(\n ` - ${colorizeKey(dictionaryStatus.dictionary.key)} ${ANSIColors.GREY}[${color}${icon} ${dictionaryStatus.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n appLogger(statusObj.errorMessage, {\n level: 'error',\n });\n }\n }\n\n // Handle delete or keep options\n const deleteOption = options?.deleteLocaleDictionary;\n const keepOption = options?.keepLocaleDictionary;\n\n if (deleteOption && keepOption) {\n throw new Error(\n 'Cannot specify both --deleteLocaleDictionary and --keepLocaleDictionary options.'\n );\n }\n\n if (deleteOption) {\n // Delete only the successfully pushed dictionaries\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const remoteDictionaries = successfullyPushedDictionaries.filter(\n (dictionary) => dictionary.location === 'remote'\n );\n const remoteDictionariesKeys = remoteDictionaries.map(\n (dictionary) => dictionary.key\n );\n\n if (remoteDictionaries.length > 0) {\n const { confirm, isCancel } = await import('@clack/prompts');\n\n const shouldDelete = await confirm({\n message: `Do you want to delete the local dictionaries that were successfully pushed? ${colorize('(Dictionaries:', ANSIColors.GREY, ANSIColors.RESET)} ${colorizeKey(remoteDictionariesKeys)}${colorize(')', ANSIColors.GREY, ANSIColors.RESET)}`,\n initialValue: false,\n });\n\n if (isCancel(shouldDelete)) {\n return;\n }\n\n if (shouldDelete) {\n await deleteLocalDictionaries(remoteDictionaries, options);\n }\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\n\n // Use a Set to collect all unique file paths\n const filePathsSet: Set<string> = new Set();\n\n for (const dictionary of dictionariesToDelete) {\n const { filePath } = dictionary;\n\n if (!filePath) {\n appLogger(\n `Dictionary ${colorizeKey(dictionary.key)} does not have a file path`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n appLogger(`Deleted file ${formatPath(filePath)}`, {});\n } else if (stats.isDirectory()) {\n appLogger(`Path is a directory ${formatPath(filePath)}, skipping.`, {});\n } else {\n appLogger(\n `Unknown file type for ${formatPath(filePath)}, skipping.`,\n {}\n );\n }\n } catch (err) {\n appLogger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AAC,UAAU;AACb,aACE,uDAA0B,WAAW,IAAI,CAAC,6BAC1C,EACE,OAAO,SACR,CACF;AACD;;AAGF,eAAa,IAAI,SAAS;;AAG5B,MAAK,MAAM,YAAY,aACrB,KAAI;EACF,MAAM,QAAQ,MAAMK,iBAAW,MAAM,SAAS;AAE9C,MAAI,MAAM,QAAQ,EAAE;AAClB,SAAMA,iBAAW,OAAO,SAAS;AACjC,aAAU,uDAA2B,SAAS,IAAI,EAAE,CAAC;aAC5C,MAAM,aAAa,CAC5B,WAAU,8DAAkC,SAAS,CAAC,cAAc,EAAE,CAAC;MAEvE,WACE,gEAAoC,SAAS,CAAC,cAC9C,EAAE,CACH;UAEI,KAAK;AACZ,YAAU,yDAA6B,SAAS,CAAC,IAAI,OAAO,EAC1D,OAAO,SACR,CAAC"}
@@ -2,15 +2,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  const require_utils_checkAccess = require('./utils/checkAccess.cjs');
4
4
  const require_utils_selectCmsEnvironment = require('./utils/selectCmsEnvironment.cjs');
5
- let _intlayer_chokidar_cli = require("@intlayer/chokidar/cli");
6
5
  let _intlayer_config_colors = require("@intlayer/config/colors");
7
6
  let _intlayer_config_logger = require("@intlayer/config/logger");
8
7
  let _intlayer_config_node = require("@intlayer/config/node");
8
+ let _intlayer_engine_cli = require("@intlayer/engine/cli");
9
9
 
10
10
  //#region src/pushConfig.ts
11
11
  const pushConfig = async (options) => {
12
12
  const config = (0, _intlayer_config_node.getConfiguration)(options?.configOptions);
13
- (0, _intlayer_chokidar_cli.logConfigDetails)(options?.configOptions);
13
+ (0, _intlayer_engine_cli.logConfigDetails)(options?.configOptions);
14
14
  const appLogger = (0, _intlayer_config_logger.getAppLogger)(config);
15
15
  if (!await require_utils_checkAccess.checkCMSAuth(config, false)) return;
16
16
  const intlayerAPI = await require_utils_checkAccess.getAuthenticatedAPI(config);
@@ -1 +1 @@
1
- {"version":3,"file":"pushConfig.cjs","names":["checkCMSAuth","getAuthenticatedAPI","selectCmsEnvironment","CYAN","GREY_DARK"],"sources":["../../src/pushConfig.ts"],"sourcesContent":["import { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { CYAN, GREY_DARK } from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeObject,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { checkCMSAuth, getAuthenticatedAPI } from './utils/checkAccess';\nimport { selectCmsEnvironment } from './utils/selectCmsEnvironment';\n\ntype PushOptions = {\n configOptions?: GetConfigurationOptions;\n};\n\nexport const pushConfig = async (options?: PushOptions) => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n const hasCMSAuth = await checkCMSAuth(config, false);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = await getAuthenticatedAPI(config);\n\n await selectCmsEnvironment(options?.configOptions?.env, intlayerAPI, config);\n\n // Push the project configuration\n const getDictionariesKeysResult =\n await intlayerAPI.project.pushProjectConfiguration(config);\n\n if (!getDictionariesKeysResult.data) {\n appLogger(\n `Error pushing project configuration. Run ${colorize('npx intlayer login', CYAN)} command to authenticate.`,\n {\n level: 'error',\n }\n );\n throw new Error('Error pushing project configuration');\n }\n\n appLogger('Project configuration pushed successfully');\n\n appLogger(colorize('--------------------------------', GREY_DARK));\n appLogger(colorizeObject(getDictionariesKeysResult.data.configuration));\n appLogger(colorize('--------------------------------', GREY_DARK));\n};\n"],"mappings":";;;;;;;;;;AAkBA,MAAa,aAAa,OAAO,YAA0B;CACzD,MAAM,qDAA0B,SAAS,cAAc;AACvD,8CAAiB,SAAS,cAAc;CAExC,MAAM,sDAAyB,OAAO;AAItC,KAAI,CAAC,MAFoBA,uCAAa,QAAQ,MAAM,CAEnC;CAEjB,MAAM,cAAc,MAAMC,8CAAoB,OAAO;AAErD,OAAMC,wDAAqB,SAAS,eAAe,KAAK,aAAa,OAAO;CAG5E,MAAM,4BACJ,MAAM,YAAY,QAAQ,yBAAyB,OAAO;AAE5D,KAAI,CAAC,0BAA0B,MAAM;AACnC,YACE,kFAAqD,sBAAsBC,6BAAK,CAAC,4BACjF,EACE,OAAO,SACR,CACF;AACD,QAAM,IAAI,MAAM,sCAAsC;;AAGxD,WAAU,4CAA4C;AAEtD,iDAAmB,oCAAoCC,kCAAU,CAAC;AAClE,uDAAyB,0BAA0B,KAAK,cAAc,CAAC;AACvE,iDAAmB,oCAAoCA,kCAAU,CAAC"}
1
+ {"version":3,"file":"pushConfig.cjs","names":["checkCMSAuth","getAuthenticatedAPI","selectCmsEnvironment","CYAN","GREY_DARK"],"sources":["../../src/pushConfig.ts"],"sourcesContent":["import { CYAN, GREY_DARK } from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeObject,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport { checkCMSAuth, getAuthenticatedAPI } from './utils/checkAccess';\nimport { selectCmsEnvironment } from './utils/selectCmsEnvironment';\n\ntype PushOptions = {\n configOptions?: GetConfigurationOptions;\n};\n\nexport const pushConfig = async (options?: PushOptions) => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n const hasCMSAuth = await checkCMSAuth(config, false);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = await getAuthenticatedAPI(config);\n\n await selectCmsEnvironment(options?.configOptions?.env, intlayerAPI, config);\n\n // Push the project configuration\n const getDictionariesKeysResult =\n await intlayerAPI.project.pushProjectConfiguration(config);\n\n if (!getDictionariesKeysResult.data) {\n appLogger(\n `Error pushing project configuration. Run ${colorize('npx intlayer login', CYAN)} command to authenticate.`,\n {\n level: 'error',\n }\n );\n throw new Error('Error pushing project configuration');\n }\n\n appLogger('Project configuration pushed successfully');\n\n appLogger(colorize('--------------------------------', GREY_DARK));\n appLogger(colorizeObject(getDictionariesKeysResult.data.configuration));\n appLogger(colorize('--------------------------------', GREY_DARK));\n};\n"],"mappings":";;;;;;;;;;AAkBA,MAAa,aAAa,OAAO,YAA0B;CACzD,MAAM,qDAA0B,SAAS,cAAc;AACvD,4CAAiB,SAAS,cAAc;CAExC,MAAM,sDAAyB,OAAO;AAItC,KAAI,CAAC,MAFoBA,uCAAa,QAAQ,MAAM,CAEnC;CAEjB,MAAM,cAAc,MAAMC,8CAAoB,OAAO;AAErD,OAAMC,wDAAqB,SAAS,eAAe,KAAK,aAAa,OAAO;CAG5E,MAAM,4BACJ,MAAM,YAAY,QAAQ,yBAAyB,OAAO;AAE5D,KAAI,CAAC,0BAA0B,MAAM;AACnC,YACE,kFAAqD,sBAAsBC,6BAAK,CAAC,4BACjF,EACE,OAAO,SACR,CACF;AACD,QAAM,IAAI,MAAM,sCAAsC;;AAGxD,WAAU,4CAA4C;AAEtD,iDAAmB,oCAAoCC,kCAAU,CAAC;AAClE,uDAAyB,0BAA0B,KAAK,cAAc,CAAC;AACvE,iDAAmB,oCAAoCA,kCAAU,CAAC"}
@@ -8,14 +8,14 @@ const require_reviewDoc_reviewDocBlockAware = require('./reviewDocBlockAware.cjs
8
8
  const require_reviewDoc_reviewDocLog = require('./reviewDocLog.cjs');
9
9
  let node_fs = require("node:fs");
10
10
  let node_path = require("node:path");
11
- let _intlayer_chokidar_cli = require("@intlayer/chokidar/cli");
12
- let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
13
11
  let _intlayer_config_colors = require("@intlayer/config/colors");
14
12
  _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
15
13
  let _intlayer_config_logger = require("@intlayer/config/logger");
16
14
  let _intlayer_config_node = require("@intlayer/config/node");
15
+ let _intlayer_engine_cli = require("@intlayer/engine/cli");
16
+ let _intlayer_engine_utils = require("@intlayer/engine/utils");
17
17
  let node_fs_promises = require("node:fs/promises");
18
- let _intlayer_chokidar_docReview = require("@intlayer/chokidar/docReview");
18
+ let _intlayer_engine_docReview = require("@intlayer/engine/docReview");
19
19
  let fast_glob = require("fast-glob");
20
20
  fast_glob = require_runtime.__toESM(fast_glob);
21
21
 
@@ -26,7 +26,7 @@ fast_glob = require_runtime.__toESM(fast_glob);
26
26
  */
27
27
  const reviewDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale, aiOptions, nbSimultaneousFileProcessed, configOptions, customInstructions, skipIfModifiedBefore, skipIfModifiedAfter, skipIfExists, gitOptions, log }) => {
28
28
  const configuration = (0, _intlayer_config_node.getConfiguration)(configOptions);
29
- (0, _intlayer_chokidar_cli.logConfigDetails)(configOptions);
29
+ (0, _intlayer_engine_cli.logConfigDetails)(configOptions);
30
30
  const appLogger = (0, _intlayer_config_logger.getAppLogger)({ log: {
31
31
  ...configuration.log,
32
32
  prefix: ""
@@ -52,20 +52,20 @@ const reviewDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale,
52
52
  }
53
53
  let docList = await (0, fast_glob.default)(docPattern, { ignore: excludedGlobPattern });
54
54
  if (gitOptions) {
55
- const gitChangedFiles = await (0, _intlayer_chokidar_cli.listGitFiles)(gitOptions);
55
+ const gitChangedFiles = await (0, _intlayer_engine_cli.listGitFiles)(gitOptions);
56
56
  if (gitChangedFiles) docList = docList.filter((path) => gitChangedFiles.some((gitFile) => (0, node_path.join)(process.cwd(), path) === gitFile));
57
57
  }
58
- appLogger(`Base locale is ${(0, _intlayer_chokidar_utils.formatLocale)(baseLocale)}`);
59
- appLogger(`Reviewing ${(0, _intlayer_config_logger.colorizeNumber)(locales.length)} locales: [ ${(0, _intlayer_chokidar_utils.formatLocale)(locales)} ]`);
58
+ appLogger(`Base locale is ${(0, _intlayer_engine_utils.formatLocale)(baseLocale)}`);
59
+ appLogger(`Reviewing ${(0, _intlayer_config_logger.colorizeNumber)(locales.length)} locales: [ ${(0, _intlayer_engine_utils.formatLocale)(locales)} ]`);
60
60
  appLogger(`Reviewing ${(0, _intlayer_config_logger.colorizeNumber)(docList.length)} files:`);
61
- appLogger(docList.map((path) => ` - ${(0, _intlayer_chokidar_utils.formatPath)(path)}\n`));
62
- await (0, _intlayer_chokidar_utils.parallelize)(docList.flatMap((docPath) => locales.map((locale) => async () => {
63
- appLogger(`Reviewing file: ${(0, _intlayer_chokidar_utils.formatPath)(docPath)} to ${(0, _intlayer_chokidar_utils.formatLocale)(locale)}`);
61
+ appLogger(docList.map((path) => ` - ${(0, _intlayer_engine_utils.formatPath)(path)}\n`));
62
+ await (0, _intlayer_engine_utils.parallelize)(docList.flatMap((docPath) => locales.map((locale) => async () => {
63
+ appLogger(`Reviewing file: ${(0, _intlayer_engine_utils.formatPath)(docPath)} to ${(0, _intlayer_engine_utils.formatLocale)(locale)}`);
64
64
  const absoluteBaseFilePath = (0, node_path.join)(configuration.system.baseDir, docPath);
65
65
  const outputFilePath = require_utils_getOutputFilePath.getOutputFilePath(absoluteBaseFilePath, locale, baseLocale);
66
66
  if (skipIfExists && (0, node_fs.existsSync)(outputFilePath)) {
67
67
  const relativePath = (0, node_path.relative)(configuration.system.baseDir, outputFilePath);
68
- appLogger(`${(0, _intlayer_config_logger.colorize)("⊘", _intlayer_config_colors.YELLOW)} File ${(0, _intlayer_chokidar_utils.formatPath)(relativePath)} already exists, skipping.`);
68
+ appLogger(`${(0, _intlayer_config_logger.colorize)("⊘", _intlayer_config_colors.YELLOW)} File ${(0, _intlayer_engine_utils.formatPath)(relativePath)} already exists, skipping.`);
69
69
  return;
70
70
  }
71
71
  if ((0, node_fs.existsSync)(outputFilePath)) {
@@ -77,13 +77,13 @@ const reviewDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale,
77
77
  appLogger(fileModificationData.message);
78
78
  return;
79
79
  }
80
- } else if (skipIfModifiedBefore || skipIfModifiedAfter) appLogger(`${(0, _intlayer_config_logger.colorize)("!", _intlayer_config_colors.YELLOW)} File ${(0, _intlayer_chokidar_utils.formatPath)(outputFilePath)} does not exist, skipping modification date check.`);
80
+ } else if (skipIfModifiedBefore || skipIfModifiedAfter) appLogger(`${(0, _intlayer_config_logger.colorize)("!", _intlayer_config_colors.YELLOW)} File ${(0, _intlayer_engine_utils.formatPath)(outputFilePath)} does not exist, skipping modification date check.`);
81
81
  let changedLines;
82
82
  if (gitOptions) {
83
- const gitChangedLines = await (0, _intlayer_chokidar_cli.listGitLines)(absoluteBaseFilePath, gitOptions);
83
+ const gitChangedLines = await (0, _intlayer_engine_cli.listGitLines)(absoluteBaseFilePath, gitOptions);
84
84
  changedLines = gitChangedLines;
85
- appLogger(`Changed lines (${(0, _intlayer_chokidar_utils.formatLocale)(baseLocale)}): ${require_utils_formatLineRanges.formatLineRanges(gitChangedLines)}`);
86
- const { blocks } = (0, _intlayer_chokidar_docReview.buildReviewReport)({
85
+ appLogger(`Changed lines (${(0, _intlayer_engine_utils.formatLocale)(baseLocale)}): ${require_utils_formatLineRanges.formatLineRanges(gitChangedLines)}`);
86
+ const { blocks } = (0, _intlayer_engine_docReview.buildReviewReport)({
87
87
  baseText: await (0, node_fs_promises.readFile)(absoluteBaseFilePath, "utf-8").catch(() => ""),
88
88
  targetText: (0, node_fs.existsSync)(outputFilePath) ? await (0, node_fs_promises.readFile)(outputFilePath, "utf-8").catch(() => "") : "",
89
89
  changedLines: gitChangedLines
@@ -93,7 +93,7 @@ const reviewDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale,
93
93
  const { start, end } = block.targetLineRange;
94
94
  return Array.from({ length: end - start + 1 }, (_unused, offset) => start + offset);
95
95
  });
96
- appLogger(`Corresponding block (${(0, _intlayer_chokidar_utils.formatLocale)(locale)}): ${require_utils_formatLineRanges.formatLineRanges(correspondingTargetLines)}`);
96
+ appLogger(`Corresponding block (${(0, _intlayer_engine_utils.formatLocale)(locale)}): ${require_utils_formatLineRanges.formatLineRanges(correspondingTargetLines)}`);
97
97
  }
98
98
  if (log) {
99
99
  await require_reviewDoc_reviewDocLog.logReviewFileBlocks(absoluteBaseFilePath, outputFilePath, locale, baseLocale, configOptions, changedLines);
@@ -1 +1 @@
1
- {"version":3,"file":"reviewDoc.cjs","names":["setupAI","x","getOutputFilePath","ANSIColors","checkFileModifiedRange","formatLineRanges","logReviewFileBlocks","reviewFileBlockAware"],"sources":["../../../src/reviewDoc/reviewDoc.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport type { AIConfig } from '@intlayer/ai';\nimport type { AIOptions } from '@intlayer/api';\nimport {\n type ListGitFilesOptions,\n listGitFiles,\n listGitLines,\n logConfigDetails,\n} from '@intlayer/chokidar/cli';\nimport { buildReviewReport } from '@intlayer/chokidar/docReview';\nimport {\n formatLocale,\n formatPath,\n parallelize,\n} from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeNumber,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport fg from 'fast-glob';\nimport { checkFileModifiedRange } from '../utils/checkFileModifiedRange';\nimport { formatLineRanges } from '../utils/formatLineRanges';\nimport { getOutputFilePath } from '../utils/getOutputFilePath';\nimport { type AIClient, setupAI } from '../utils/setupAI';\nimport { reviewFileBlockAware } from './reviewDocBlockAware';\nimport { logReviewFileBlocks } from './reviewDocLog';\n\ntype ReviewDocOptions = {\n docPattern: string[];\n locales: Locale[];\n excludedGlobPattern: string[];\n baseLocale: Locale;\n aiOptions?: AIOptions;\n nbSimultaneousFileProcessed?: number;\n configOptions?: GetConfigurationOptions;\n customInstructions?: string;\n skipIfModifiedBefore?: number | string | Date;\n skipIfModifiedAfter?: number | string | Date;\n skipIfExists?: boolean;\n gitOptions?: ListGitFilesOptions;\n /**\n * Log-only mode. Instead of translating the changed blocks with AI, log the\n * blocks that need attention (with line numbers and content) for the base and\n * target locales, so another agent can generate the translations.\n */\n log?: boolean;\n};\n\n/**\n * Main audit function: scans all .md files in \"en/\" (unless you specified DOC_LIST),\n * then audits them to each locale in LOCALE_LIST.\n */\nexport const reviewDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed,\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n log,\n}: ReviewDocOptions) => {\n const configuration = getConfiguration(configOptions);\n logConfigDetails(configOptions);\n\n const appLogger = getAppLogger({ log: { ...configuration.log, prefix: '' } });\n\n // Log-only mode does not call any AI, so the AI access checks are skipped.\n let aiClient: AIClient | undefined;\n let aiConfig: AIConfig | undefined;\n\n if (!log) {\n const aiResult = await setupAI(configuration, aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n aiClient = aiResult.aiClient;\n aiConfig = aiResult.aiConfig;\n\n if (aiResult.isCustomAI && aiClient && aiConfig) {\n const { hasAIAccess, error } = await aiClient.checkAISDKAccess(aiConfig);\n if (!hasAIAccess) {\n appLogger(`${x} ${error}`);\n return;\n }\n }\n }\n\n if (nbSimultaneousFileProcessed && nbSimultaneousFileProcessed > 10) {\n appLogger(\n `Warning: nbSimultaneousFileProcessed is set to ${nbSimultaneousFileProcessed}, which is greater than 10. Setting it to 10.`\n );\n nbSimultaneousFileProcessed = 10; // Limit the number of simultaneous file processed to 10\n }\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n // OAuth handled by API proxy internally\n\n appLogger(`Base locale is ${formatLocale(baseLocale)}`);\n appLogger(\n `Reviewing ${colorizeNumber(locales.length)} locales: [ ${formatLocale(locales)} ]`\n );\n\n appLogger(`Reviewing ${colorizeNumber(docList.length)} files:`);\n appLogger(docList.map((path) => ` - ${formatPath(path)}\\n`));\n\n // Create all tasks to be processed\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n appLogger(\n `Reviewing file: ${formatPath(docPath)} to ${formatLocale(locale)}`\n );\n\n const absoluteBaseFilePath = join(configuration.system.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip if file exists and skipIfExists option is enabled\n if (skipIfExists && existsSync(outputFilePath)) {\n const relativePath = relative(\n configuration.system.baseDir,\n outputFilePath\n );\n appLogger(\n `${colorize('⊘', ANSIColors.YELLOW)} File ${formatPath(relativePath)} already exists, skipping.`\n );\n return;\n }\n\n // Check modification range only if the file exists\n if (existsSync(outputFilePath)) {\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n } else if (skipIfModifiedBefore || skipIfModifiedAfter) {\n // Log if we intended to check modification time but couldn't because the file doesn't exist\n appLogger(\n `${colorize('!', ANSIColors.YELLOW)} File ${formatPath(outputFilePath)} does not exist, skipping modification date check.`\n );\n }\n\n let changedLines: number[] | undefined;\n // FIXED: Enable git optimization that was previously commented out\n if (gitOptions) {\n const gitChangedLines = await listGitLines(\n absoluteBaseFilePath,\n gitOptions\n );\n changedLines = gitChangedLines;\n\n // Report the base lines that changed, then the corresponding line span\n // in the target document — i.e. the blocks the alignment will actually\n // re-translate. `review` blocks are exactly the aligned base blocks the\n // changed lines touched, so their `targetLineRange` is the matching span\n // in the existing translation.\n appLogger(\n `Changed lines (${formatLocale(baseLocale)}): ${formatLineRanges(gitChangedLines)}`\n );\n\n const baseText = await readFile(absoluteBaseFilePath, 'utf-8').catch(\n () => ''\n );\n const targetText = existsSync(outputFilePath)\n ? await readFile(outputFilePath, 'utf-8').catch(() => '')\n : '';\n\n const { blocks } = buildReviewReport({\n baseText,\n targetText,\n changedLines: gitChangedLines,\n });\n\n const correspondingTargetLines = blocks.flatMap((block) => {\n if (block.action !== 'review' || !block.targetLineRange) return [];\n\n const { start, end } = block.targetLineRange;\n return Array.from(\n { length: end - start + 1 },\n (_unused, offset) => start + offset\n );\n });\n\n appLogger(\n `Corresponding block (${formatLocale(locale)}): ${formatLineRanges(correspondingTargetLines)}`\n );\n }\n\n if (log) {\n await logReviewFileBlocks(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locale,\n baseLocale,\n configOptions,\n changedLines\n );\n return;\n }\n\n await reviewFileBlockAware(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locale,\n baseLocale,\n aiOptions,\n configOptions,\n customInstructions,\n changedLines,\n aiClient,\n aiConfig\n );\n })\n );\n\n await parallelize(\n allTasks,\n (task) => task(),\n nbSimultaneousFileProcessed ?? 3\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,MAAa,YAAY,OAAO,EAC9B,YACA,SACA,qBACA,YACA,WACA,6BACA,eACA,oBACA,sBACA,qBACA,cACA,YACA,UACsB;CACtB,MAAM,4DAAiC,cAAc;AACrD,8CAAiB,cAAc;CAE/B,MAAM,sDAAyB,EAAE,KAAK;EAAE,GAAG,cAAc;EAAK,QAAQ;EAAI,EAAE,CAAC;CAG7E,IAAI;CACJ,IAAI;AAEJ,KAAI,CAAC,KAAK;EACR,MAAM,WAAW,MAAMA,8BAAQ,eAAe,UAAU;AAExD,MAAI,CAAC,UAAU,YAAa;AAE5B,aAAW,SAAS;AACpB,aAAW,SAAS;AAEpB,MAAI,SAAS,cAAc,YAAY,UAAU;GAC/C,MAAM,EAAE,aAAa,UAAU,MAAM,SAAS,iBAAiB,SAAS;AACxE,OAAI,CAAC,aAAa;AAChB,cAAU,GAAGC,0BAAE,GAAG,QAAQ;AAC1B;;;;AAKN,KAAI,+BAA+B,8BAA8B,IAAI;AACn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,+DAA6B;IACnC,+CAR8B,sBAAsB,QAAQ,CAAC,YACvD,GACP;IAOC,oCAN4B,eAAe,GACzC,qCAAe,gBAAgB,QAAQ,CAAC,YAAY,GAAG,GACvD;IAKF,cAAc;IACf,CAAC;GAEF,MAAM,2BAA2B,OAAO,SAAS,UAAU;AACzD,QAAI,MAAM,WAAW,YAAY,CAAC,MAAM,gBAAiB,QAAO,EAAE;IAElE,MAAM,EAAE,OAAO,QAAQ,MAAM;AAC7B,WAAO,MAAM,KACX,EAAE,QAAQ,MAAM,QAAQ,GAAG,GAC1B,SAAS,WAAW,QAAQ,OAC9B;KACD;AAEF,aACE,mEAAqC,OAAO,CAAC,KAAKA,gDAAiB,yBAAyB,GAC7F;;AAGH,MAAI,KAAK;AACP,SAAMC,mDACJ,sBACA,gBACA,QACA,YACA,eACA,aACD;AACD;;AAGF,QAAMC,2DACJ,sBACA,gBACA,QACA,YACA,WACA,eACA,oBACA,cACA,UACA,SACD;GACD,CAIM,GACP,SAAS,MAAM,EAChB,+BAA+B,EAChC"}
1
+ {"version":3,"file":"reviewDoc.cjs","names":["setupAI","x","getOutputFilePath","ANSIColors","checkFileModifiedRange","formatLineRanges","logReviewFileBlocks","reviewFileBlockAware"],"sources":["../../../src/reviewDoc/reviewDoc.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport type { AIConfig } from '@intlayer/ai';\nimport type { AIOptions } from '@intlayer/api';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeNumber,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n type ListGitFilesOptions,\n listGitFiles,\n listGitLines,\n logConfigDetails,\n} from '@intlayer/engine/cli';\nimport { buildReviewReport } from '@intlayer/engine/docReview';\nimport { formatLocale, formatPath, parallelize } from '@intlayer/engine/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport fg from 'fast-glob';\nimport { checkFileModifiedRange } from '../utils/checkFileModifiedRange';\nimport { formatLineRanges } from '../utils/formatLineRanges';\nimport { getOutputFilePath } from '../utils/getOutputFilePath';\nimport { type AIClient, setupAI } from '../utils/setupAI';\nimport { reviewFileBlockAware } from './reviewDocBlockAware';\nimport { logReviewFileBlocks } from './reviewDocLog';\n\ntype ReviewDocOptions = {\n docPattern: string[];\n locales: Locale[];\n excludedGlobPattern: string[];\n baseLocale: Locale;\n aiOptions?: AIOptions;\n nbSimultaneousFileProcessed?: number;\n configOptions?: GetConfigurationOptions;\n customInstructions?: string;\n skipIfModifiedBefore?: number | string | Date;\n skipIfModifiedAfter?: number | string | Date;\n skipIfExists?: boolean;\n gitOptions?: ListGitFilesOptions;\n /**\n * Log-only mode. Instead of translating the changed blocks with AI, log the\n * blocks that need attention (with line numbers and content) for the base and\n * target locales, so another agent can generate the translations.\n */\n log?: boolean;\n};\n\n/**\n * Main audit function: scans all .md files in \"en/\" (unless you specified DOC_LIST),\n * then audits them to each locale in LOCALE_LIST.\n */\nexport const reviewDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed,\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n log,\n}: ReviewDocOptions) => {\n const configuration = getConfiguration(configOptions);\n logConfigDetails(configOptions);\n\n const appLogger = getAppLogger({ log: { ...configuration.log, prefix: '' } });\n\n // Log-only mode does not call any AI, so the AI access checks are skipped.\n let aiClient: AIClient | undefined;\n let aiConfig: AIConfig | undefined;\n\n if (!log) {\n const aiResult = await setupAI(configuration, aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n aiClient = aiResult.aiClient;\n aiConfig = aiResult.aiConfig;\n\n if (aiResult.isCustomAI && aiClient && aiConfig) {\n const { hasAIAccess, error } = await aiClient.checkAISDKAccess(aiConfig);\n if (!hasAIAccess) {\n appLogger(`${x} ${error}`);\n return;\n }\n }\n }\n\n if (nbSimultaneousFileProcessed && nbSimultaneousFileProcessed > 10) {\n appLogger(\n `Warning: nbSimultaneousFileProcessed is set to ${nbSimultaneousFileProcessed}, which is greater than 10. Setting it to 10.`\n );\n nbSimultaneousFileProcessed = 10; // Limit the number of simultaneous file processed to 10\n }\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n // OAuth handled by API proxy internally\n\n appLogger(`Base locale is ${formatLocale(baseLocale)}`);\n appLogger(\n `Reviewing ${colorizeNumber(locales.length)} locales: [ ${formatLocale(locales)} ]`\n );\n\n appLogger(`Reviewing ${colorizeNumber(docList.length)} files:`);\n appLogger(docList.map((path) => ` - ${formatPath(path)}\\n`));\n\n // Create all tasks to be processed\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n appLogger(\n `Reviewing file: ${formatPath(docPath)} to ${formatLocale(locale)}`\n );\n\n const absoluteBaseFilePath = join(configuration.system.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip if file exists and skipIfExists option is enabled\n if (skipIfExists && existsSync(outputFilePath)) {\n const relativePath = relative(\n configuration.system.baseDir,\n outputFilePath\n );\n appLogger(\n `${colorize('⊘', ANSIColors.YELLOW)} File ${formatPath(relativePath)} already exists, skipping.`\n );\n return;\n }\n\n // Check modification range only if the file exists\n if (existsSync(outputFilePath)) {\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n } else if (skipIfModifiedBefore || skipIfModifiedAfter) {\n // Log if we intended to check modification time but couldn't because the file doesn't exist\n appLogger(\n `${colorize('!', ANSIColors.YELLOW)} File ${formatPath(outputFilePath)} does not exist, skipping modification date check.`\n );\n }\n\n let changedLines: number[] | undefined;\n // FIXED: Enable git optimization that was previously commented out\n if (gitOptions) {\n const gitChangedLines = await listGitLines(\n absoluteBaseFilePath,\n gitOptions\n );\n changedLines = gitChangedLines;\n\n // Report the base lines that changed, then the corresponding line span\n // in the target document — i.e. the blocks the alignment will actually\n // re-translate. `review` blocks are exactly the aligned base blocks the\n // changed lines touched, so their `targetLineRange` is the matching span\n // in the existing translation.\n appLogger(\n `Changed lines (${formatLocale(baseLocale)}): ${formatLineRanges(gitChangedLines)}`\n );\n\n const baseText = await readFile(absoluteBaseFilePath, 'utf-8').catch(\n () => ''\n );\n const targetText = existsSync(outputFilePath)\n ? await readFile(outputFilePath, 'utf-8').catch(() => '')\n : '';\n\n const { blocks } = buildReviewReport({\n baseText,\n targetText,\n changedLines: gitChangedLines,\n });\n\n const correspondingTargetLines = blocks.flatMap((block) => {\n if (block.action !== 'review' || !block.targetLineRange) return [];\n\n const { start, end } = block.targetLineRange;\n return Array.from(\n { length: end - start + 1 },\n (_unused, offset) => start + offset\n );\n });\n\n appLogger(\n `Corresponding block (${formatLocale(locale)}): ${formatLineRanges(correspondingTargetLines)}`\n );\n }\n\n if (log) {\n await logReviewFileBlocks(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locale,\n baseLocale,\n configOptions,\n changedLines\n );\n return;\n }\n\n await reviewFileBlockAware(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locale,\n baseLocale,\n aiOptions,\n configOptions,\n customInstructions,\n changedLines,\n aiClient,\n aiConfig\n );\n })\n );\n\n await parallelize(\n allTasks,\n (task) => task(),\n nbSimultaneousFileProcessed ?? 3\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAa,YAAY,OAAO,EAC9B,Y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@@ const require_utils_chunkInference = require('../utils/chunkInference.cjs');
6
6
  const require_utils_fixChunkStartEndChars = require('../utils/fixChunkStartEndChars.cjs');
7
7
  let node_fs = require("node:fs");
8
8
  let node_path = require("node:path");
9
- let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
10
9
  let _intlayer_config_colors = require("@intlayer/config/colors");
11
10
  _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
12
11
  let _intlayer_config_logger = require("@intlayer/config/logger");
13
12
  let _intlayer_config_node = require("@intlayer/config/node");
13
+ let _intlayer_engine_utils = require("@intlayer/engine/utils");
14
14
  let node_fs_promises = require("node:fs/promises");
15
15
  let _intlayer_config_utils = require("@intlayer/config/utils");
16
- let _intlayer_chokidar_docReview = require("@intlayer/chokidar/docReview");
16
+ let _intlayer_engine_docReview = require("@intlayer/engine/docReview");
17
17
  let _intlayer_core_localization = require("@intlayer/core/localization");
18
18
  let _intlayer_types_locales = require("@intlayer/types/locales");
19
19
 
@@ -37,10 +37,10 @@ const reviewFileBlockAware = async (baseFilePath, outputFilePath, locale, baseLo
37
37
  } });
38
38
  const baseText = await (0, node_fs_promises.readFile)(baseFilePath, "utf-8");
39
39
  const targetText = await (0, node_fs_promises.readFile)(outputFilePath, "utf-8").catch(() => "");
40
- const basePrompt = require__utils_asset.readAsset("./prompts/REVIEW_PROMPT.md", "utf-8").replaceAll("{{localeName}}", `${(0, _intlayer_chokidar_utils.formatLocale)(locale, false)}`).replaceAll("{{baseLocaleName}}", `${(0, _intlayer_chokidar_utils.formatLocale)(baseLocale, false)}`).replace("{{applicationContext}}", aiOptions?.applicationContext ?? "-").replace("{{customInstructions}}", customInstructions ?? "-");
41
- const filePrefix = [(0, _intlayer_config_logger.colon)(`${_intlayer_config_colors.GREY_DARK}[${(0, _intlayer_chokidar_utils.formatPath)(baseFilePath)}${_intlayer_config_colors.GREY_DARK}] `, { colSize: 40 }), `→ ${_intlayer_config_colors.RESET}`].join("");
42
- const prefix = [(0, _intlayer_config_logger.colon)(`${_intlayer_config_colors.GREY_DARK}[${(0, _intlayer_chokidar_utils.formatPath)(baseFilePath)}${_intlayer_config_colors.GREY_DARK}][${(0, _intlayer_chokidar_utils.formatLocale)(locale)}${_intlayer_config_colors.GREY_DARK}] `, { colSize: 40 }), `→ ${_intlayer_config_colors.RESET}`].join("");
43
- const { baseBlocks, targetBlocks, plan, segmentsToReview } = (0, _intlayer_chokidar_docReview.buildAlignmentPlan)({
40
+ const basePrompt = require__utils_asset.readAsset("./prompts/REVIEW_PROMPT.md", "utf-8").replaceAll("{{localeName}}", `${(0, _intlayer_engine_utils.formatLocale)(locale, false)}`).replaceAll("{{baseLocaleName}}", `${(0, _intlayer_engine_utils.formatLocale)(baseLocale, false)}`).replace("{{applicationContext}}", aiOptions?.applicationContext ?? "-").replace("{{customInstructions}}", customInstructions ?? "-");
41
+ const filePrefix = [(0, _intlayer_config_logger.colon)(`${_intlayer_config_colors.GREY_DARK}[${(0, _intlayer_engine_utils.formatPath)(baseFilePath)}${_intlayer_config_colors.GREY_DARK}] `, { colSize: 40 }), `→ ${_intlayer_config_colors.RESET}`].join("");
42
+ const prefix = [(0, _intlayer_config_logger.colon)(`${_intlayer_config_colors.GREY_DARK}[${(0, _intlayer_engine_utils.formatPath)(baseFilePath)}${_intlayer_config_colors.GREY_DARK}][${(0, _intlayer_engine_utils.formatLocale)(locale)}${_intlayer_config_colors.GREY_DARK}] `, { colSize: 40 }), `→ ${_intlayer_config_colors.RESET}`].join("");
43
+ const { baseBlocks, targetBlocks, plan, segmentsToReview } = (0, _intlayer_engine_docReview.buildAlignmentPlan)({
44
44
  baseText,
45
45
  targetText,
46
46
  changedLines
@@ -51,7 +51,7 @@ const reviewFileBlockAware = async (baseFilePath, outputFilePath, locale, baseLo
51
51
  const reviewedSegmentsMap = /* @__PURE__ */ new Map();
52
52
  for (const [actionIndex, action] of plan.actions.entries()) if (action.kind === "delete") reviewedSegmentsMap.set(actionIndex, "");
53
53
  const writeCurrentState = () => {
54
- const output = (0, _intlayer_chokidar_docReview.mergeReviewedSegments)(plan, targetBlocks, reviewedSegmentsMap);
54
+ const output = (0, _intlayer_engine_docReview.mergeReviewedSegments)(plan, targetBlocks, reviewedSegmentsMap);
55
55
  (0, node_fs.mkdirSync)((0, node_path.dirname)(outputFilePath), { recursive: true });
56
56
  (0, node_fs.writeFileSync)(outputFilePath, output);
57
57
  };
@@ -64,7 +64,7 @@ const reviewFileBlockAware = async (baseFilePath, outputFilePath, locale, baseLo
64
64
  applicationLogger(`${filePrefix}No segments need review, reusing existing translation`);
65
65
  writeCurrentState();
66
66
  }
67
- applicationLogger(`${(0, _intlayer_config_logger.colorize)("✔", _intlayer_config_colors.GREEN)} File ${(0, _intlayer_chokidar_utils.formatPath)(outputFilePath)} updated successfully (no AI changes needed).`);
67
+ applicationLogger(`${(0, _intlayer_config_logger.colorize)("✔", _intlayer_config_colors.GREEN)} File ${(0, _intlayer_engine_utils.formatPath)(outputFilePath)} updated successfully (no AI changes needed).`);
68
68
  return;
69
69
  }
70
70
  applicationLogger(`${filePrefix}Segments to review: ${(0, _intlayer_config_logger.colorizeNumber)(segmentsToReview.length)} (processing bottom-up)`);
@@ -74,8 +74,8 @@ const reviewFileBlockAware = async (baseFilePath, outputFilePath, locale, baseLo
74
74
  })).reverse();
75
75
  for (const { segment, displayNumber } of segmentsBottomUp) {
76
76
  const baseBlock = segment.baseBlock;
77
- const getBaseChunkContextPrompt = () => `**BLOCK ${displayNumber} of ${segmentsToReview.length}** is the base block in ${(0, _intlayer_chokidar_utils.formatLocale)(baseLocale, false)} as reference.\n///chunksStart///\n` + baseBlock.content + `///chunksEnd///`;
78
- const getTargetChunkPrompt = () => `**BLOCK ${displayNumber} of ${segmentsToReview.length}** is the current block to review in ${(0, _intlayer_chokidar_utils.formatLocale)(locale, false)}.\n///chunksStart///\n` + (segment.targetBlockText ?? "") + `///chunksEnd///`;
77
+ const getBaseChunkContextPrompt = () => `**BLOCK ${displayNumber} of ${segmentsToReview.length}** is the base block in ${(0, _intlayer_engine_utils.formatLocale)(baseLocale, false)} as reference.\n///chunksStart///\n` + baseBlock.content + `///chunksEnd///`;
78
+ const getTargetChunkPrompt = () => `**BLOCK ${displayNumber} of ${segmentsToReview.length}** is the current block to review in ${(0, _intlayer_engine_utils.formatLocale)(locale, false)}.\n///chunksStart///\n` + (segment.targetBlockText ?? "") + `///chunksEnd///`;
79
79
  const reviewedChunkResult = await (0, _intlayer_config_utils.retryManager)(async () => {
80
80
  const result = await require_utils_chunkInference.chunkInference([
81
81
  {
@@ -107,7 +107,7 @@ const reviewFileBlockAware = async (baseFilePath, outputFilePath, locale, baseLo
107
107
  reviewedSegmentsMap.set(segment.actionIndex, reviewedChunkResult);
108
108
  writeCurrentState();
109
109
  }
110
- applicationLogger(`${(0, _intlayer_config_logger.colorize)("✔", _intlayer_config_colors.GREEN)} File ${(0, _intlayer_chokidar_utils.formatPath)(outputFilePath)} created/updated successfully.`);
110
+ applicationLogger(`${(0, _intlayer_config_logger.colorize)("✔", _intlayer_config_colors.GREEN)} File ${(0, _intlayer_engine_utils.formatPath)(outputFilePath)} created/updated successfully.`);
111
111
  };
112
112
 
113
113
  //#endregion