@intlayer/cli 9.7.0 → 9.7.1
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.
- package/dist/cjs/IntlayerEventListener.cjs +1 -2
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -2
- package/dist/cjs/_virtual/_utils_asset.cjs +2 -3
- package/dist/cjs/auth/login.cjs +8 -9
- package/dist/cjs/auth/sessionToken.cjs +1 -2
- package/dist/cjs/auth/setupRepository.cjs +6 -7
- package/dist/cjs/build.cjs +2 -3
- package/dist/cjs/bundle.cjs +1 -2
- package/dist/cjs/ci.cjs +2 -3
- package/dist/cjs/cli.cjs +5 -6
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/config.cjs +2 -3
- package/dist/cjs/editor.cjs +3 -4
- package/dist/cjs/extract.cjs +7 -8
- package/dist/cjs/fill/deepMergeContent.cjs +1 -2
- package/dist/cjs/fill/extractTranslatableContent.cjs +1 -2
- package/dist/cjs/fill/fill.cjs +9 -10
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs +2 -3
- package/dist/cjs/fill/formatFillData.cjs +2 -3
- package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs +1 -2
- package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs +1 -2
- package/dist/cjs/fill/index.cjs +2 -2
- package/dist/cjs/fill/listTranslationsTasks.cjs +4 -5
- package/dist/cjs/fill/translateDictionary.cjs +6 -7
- package/dist/cjs/fill/writeFill.cjs +4 -5
- package/dist/cjs/getTargetDictionary.cjs +2 -3
- package/dist/cjs/index.cjs +27 -27
- package/dist/cjs/init.cjs +12 -13
- package/dist/cjs/initChromeExtension.cjs +5 -6
- package/dist/cjs/initInfra.cjs +3 -4
- package/dist/cjs/initMCP.cjs +6 -7
- package/dist/cjs/initSkills.cjs +6 -7
- package/dist/cjs/listContentDeclaration.cjs +3 -4
- package/dist/cjs/listProjects.cjs +1 -2
- package/dist/cjs/liveSync.cjs +4 -5
- package/dist/cjs/loadPrompts.cjs +1 -2
- package/dist/cjs/pull.cjs +9 -11
- package/dist/cjs/pull.cjs.map +1 -1
- package/dist/cjs/push/pullLog.cjs +2 -3
- package/dist/cjs/push/push.cjs +10 -10
- package/dist/cjs/push/push.cjs.map +1 -1
- package/dist/cjs/pushConfig.cjs +4 -5
- package/dist/cjs/pushLog.cjs +2 -3
- package/dist/cjs/reviewDoc/reviewDoc.cjs +15 -15
- package/dist/cjs/reviewDoc/reviewDoc.cjs.map +1 -1
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +8 -9
- package/dist/cjs/reviewDoc/reviewDocLog.cjs +2 -3
- package/dist/cjs/reviewDoc/reviewDocProgress.cjs +2 -3
- package/dist/cjs/reviewDoc/reviewDocSynthesis.cjs +2 -3
- package/dist/cjs/scan.cjs +2 -3
- package/dist/cjs/searchDoc.cjs +2 -3
- package/dist/cjs/test/index.cjs +2 -2
- package/dist/cjs/test/listMissingTranslations.cjs +2 -3
- package/dist/cjs/test/test.cjs +3 -4
- package/dist/cjs/translateDoc/index.cjs +3 -3
- package/dist/cjs/translateDoc/translateDoc.cjs +12 -13
- package/dist/cjs/translateDoc/translateDoc.cjs.map +1 -1
- package/dist/cjs/translateDoc/translateFile.cjs +8 -9
- package/dist/cjs/translateDoc/validation.cjs +1 -2
- package/dist/cjs/upgrade.cjs +2 -3
- package/dist/cjs/utils/calculateChunks.cjs +1 -2
- package/dist/cjs/utils/checkAccess.cjs +5 -6
- package/dist/cjs/utils/checkConfigConsistency.cjs +1 -2
- package/dist/cjs/utils/checkFileModifiedRange.cjs +3 -4
- package/dist/cjs/utils/checkLastUpdateTime.cjs +1 -2
- package/dist/cjs/utils/chunkInference.cjs +2 -3
- package/dist/cjs/utils/detectGitRepository.cjs +2 -3
- package/dist/cjs/utils/fixChunkStartEndChars.cjs +1 -2
- package/dist/cjs/utils/formatLineRanges.cjs +1 -2
- package/dist/cjs/utils/formatTimeDiff.cjs +1 -2
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +1 -2
- package/dist/cjs/utils/getOutputFilePath.cjs +1 -2
- package/dist/cjs/utils/getParentPackageJSON.cjs +2 -3
- package/dist/cjs/utils/isInteractiveTerminal.cjs +1 -2
- package/dist/cjs/utils/listSpecialChars.cjs +1 -2
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs +2 -3
- package/dist/cjs/utils/openBrowser.cjs +1 -2
- package/dist/cjs/utils/parseChoice.cjs +1 -2
- package/dist/cjs/utils/reorderParagraphs.cjs +2 -3
- package/dist/cjs/utils/selectCmsEnvironment.cjs +2 -3
- package/dist/cjs/utils/setupAI.cjs +3 -4
- package/dist/cjs/watch.cjs +2 -3
- package/dist/esm/IntlayerEventListener.mjs +1 -2
- package/dist/esm/_virtual/_rolldown/runtime.mjs +1 -2
- package/dist/esm/_virtual/_utils_asset.mjs +2 -3
- package/dist/esm/auth/login.mjs +4 -5
- package/dist/esm/auth/sessionToken.mjs +1 -2
- package/dist/esm/auth/setupRepository.mjs +3 -4
- package/dist/esm/build.mjs +2 -3
- package/dist/esm/bundle.mjs +1 -2
- package/dist/esm/ci.mjs +2 -3
- package/dist/esm/cli.mjs +4 -5
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/config.mjs +2 -3
- package/dist/esm/editor.mjs +2 -3
- package/dist/esm/extract.mjs +5 -6
- package/dist/esm/fill/deepMergeContent.mjs +1 -2
- package/dist/esm/fill/extractTranslatableContent.mjs +1 -2
- package/dist/esm/fill/fill.mjs +3 -4
- package/dist/esm/fill/formatAutoFilledFilePath.mjs +2 -3
- package/dist/esm/fill/formatFillData.mjs +1 -2
- package/dist/esm/fill/getAvailableLocalesInDictionary.mjs +1 -2
- package/dist/esm/fill/getFilterMissingContentPerLocale.mjs +1 -2
- package/dist/esm/fill/index.mjs +1 -1
- package/dist/esm/fill/listTranslationsTasks.mjs +2 -3
- package/dist/esm/fill/translateDictionary.mjs +2 -3
- package/dist/esm/fill/writeFill.mjs +2 -3
- package/dist/esm/getTargetDictionary.mjs +2 -3
- package/dist/esm/index.mjs +13 -13
- package/dist/esm/init.mjs +6 -7
- package/dist/esm/initChromeExtension.mjs +2 -3
- package/dist/esm/initInfra.mjs +1 -2
- package/dist/esm/initMCP.mjs +3 -4
- package/dist/esm/initSkills.mjs +2 -3
- package/dist/esm/listContentDeclaration.mjs +3 -4
- package/dist/esm/listProjects.mjs +1 -2
- package/dist/esm/liveSync.mjs +2 -3
- package/dist/esm/loadPrompts.mjs +1 -2
- package/dist/esm/pull.mjs +6 -8
- package/dist/esm/pull.mjs.map +1 -1
- package/dist/esm/push/pullLog.mjs +1 -2
- package/dist/esm/push/push.mjs +6 -6
- package/dist/esm/push/push.mjs.map +1 -1
- package/dist/esm/pushConfig.mjs +2 -3
- package/dist/esm/pushLog.mjs +1 -2
- package/dist/esm/reviewDoc/reviewDoc.mjs +8 -8
- package/dist/esm/reviewDoc/reviewDoc.mjs.map +1 -1
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +3 -4
- package/dist/esm/reviewDoc/reviewDocLog.mjs +2 -3
- package/dist/esm/reviewDoc/reviewDocProgress.mjs +1 -2
- package/dist/esm/reviewDoc/reviewDocSynthesis.mjs +1 -2
- package/dist/esm/scan.mjs +1 -2
- package/dist/esm/searchDoc.mjs +2 -3
- package/dist/esm/test/listMissingTranslations.mjs +2 -3
- package/dist/esm/test/test.mjs +1 -2
- package/dist/esm/translateDoc/index.mjs +2 -2
- package/dist/esm/translateDoc/translateDoc.mjs +7 -8
- package/dist/esm/translateDoc/translateDoc.mjs.map +1 -1
- package/dist/esm/translateDoc/translateFile.mjs +4 -5
- package/dist/esm/translateDoc/validation.mjs +1 -2
- package/dist/esm/upgrade.mjs +1 -2
- package/dist/esm/utils/calculateChunks.mjs +1 -2
- package/dist/esm/utils/checkAccess.mjs +2 -3
- package/dist/esm/utils/checkConfigConsistency.mjs +1 -2
- package/dist/esm/utils/checkFileModifiedRange.mjs +1 -2
- package/dist/esm/utils/checkLastUpdateTime.mjs +1 -2
- package/dist/esm/utils/chunkInference.mjs +1 -2
- package/dist/esm/utils/detectGitRepository.mjs +2 -3
- package/dist/esm/utils/fixChunkStartEndChars.mjs +1 -2
- package/dist/esm/utils/formatLineRanges.mjs +1 -2
- package/dist/esm/utils/formatTimeDiff.mjs +1 -2
- package/dist/esm/utils/getIsFileUpdatedRecently.mjs +1 -2
- package/dist/esm/utils/getOutputFilePath.mjs +1 -2
- package/dist/esm/utils/getParentPackageJSON.mjs +2 -3
- package/dist/esm/utils/isInteractiveTerminal.mjs +1 -2
- package/dist/esm/utils/listSpecialChars.mjs +1 -2
- package/dist/esm/utils/mapChunksBetweenFiles.mjs +1 -2
- package/dist/esm/utils/openBrowser.mjs +1 -2
- package/dist/esm/utils/parseChoice.mjs +1 -2
- package/dist/esm/utils/reorderParagraphs.mjs +1 -2
- package/dist/esm/utils/selectCmsEnvironment.mjs +1 -2
- package/dist/esm/utils/setupAI.mjs +1 -2
- package/dist/esm/watch.mjs +2 -3
- package/dist/types/IntlayerEventListener.d.ts +0 -2
- package/dist/types/IntlayerEventListener.d.ts.map +1 -1
- package/dist/types/auth/login.d.ts +1 -2
- package/dist/types/auth/login.d.ts.map +1 -1
- package/dist/types/auth/sessionToken.d.ts +0 -2
- package/dist/types/auth/sessionToken.d.ts.map +1 -1
- package/dist/types/auth/setupRepository.d.ts +1 -2
- package/dist/types/auth/setupRepository.d.ts.map +1 -1
- package/dist/types/build.d.ts +1 -2
- package/dist/types/build.d.ts.map +1 -1
- package/dist/types/bundle.d.ts +0 -2
- package/dist/types/bundle.d.ts.map +1 -1
- package/dist/types/ci.d.ts +1 -2
- package/dist/types/ci.d.ts.map +1 -1
- package/dist/types/cli.d.ts +1 -2
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/config.d.ts +1 -2
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/editor.d.ts +1 -2
- package/dist/types/editor.d.ts.map +1 -1
- package/dist/types/extract.d.ts +1 -2
- package/dist/types/extract.d.ts.map +1 -1
- package/dist/types/fill/deepMergeContent.d.ts +0 -2
- package/dist/types/fill/deepMergeContent.d.ts.map +1 -1
- package/dist/types/fill/extractTranslatableContent.d.ts +0 -2
- package/dist/types/fill/extractTranslatableContent.d.ts.map +1 -1
- package/dist/types/fill/fill.d.ts +0 -2
- package/dist/types/fill/fill.d.ts.map +1 -1
- package/dist/types/fill/formatAutoFilledFilePath.d.ts +0 -2
- package/dist/types/fill/formatAutoFilledFilePath.d.ts.map +1 -1
- package/dist/types/fill/formatFillData.d.ts +0 -2
- package/dist/types/fill/formatFillData.d.ts.map +1 -1
- package/dist/types/fill/getAvailableLocalesInDictionary.d.ts +0 -2
- package/dist/types/fill/getAvailableLocalesInDictionary.d.ts.map +1 -1
- package/dist/types/fill/getFilterMissingContentPerLocale.d.ts +0 -2
- package/dist/types/fill/getFilterMissingContentPerLocale.d.ts.map +1 -1
- package/dist/types/fill/listTranslationsTasks.d.ts +0 -2
- package/dist/types/fill/listTranslationsTasks.d.ts.map +1 -1
- package/dist/types/fill/translateDictionary.d.ts +2 -3
- package/dist/types/fill/translateDictionary.d.ts.map +1 -1
- package/dist/types/fill/writeFill.d.ts +0 -2
- package/dist/types/fill/writeFill.d.ts.map +1 -1
- package/dist/types/getTargetDictionary.d.ts +0 -2
- package/dist/types/getTargetDictionary.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/init.d.ts +1 -2
- package/dist/types/init.d.ts.map +1 -1
- package/dist/types/initChromeExtension.d.ts +0 -2
- package/dist/types/initChromeExtension.d.ts.map +1 -1
- package/dist/types/initInfra.d.ts +0 -2
- package/dist/types/initInfra.d.ts.map +1 -1
- package/dist/types/initMCP.d.ts +0 -2
- package/dist/types/initMCP.d.ts.map +1 -1
- package/dist/types/initSkills.d.ts +0 -2
- package/dist/types/initSkills.d.ts.map +1 -1
- package/dist/types/listContentDeclaration.d.ts +1 -2
- package/dist/types/listContentDeclaration.d.ts.map +1 -1
- package/dist/types/listProjects.d.ts +0 -2
- package/dist/types/listProjects.d.ts.map +1 -1
- package/dist/types/liveSync.d.ts +1 -2
- package/dist/types/liveSync.d.ts.map +1 -1
- package/dist/types/loadPrompts.d.ts +0 -2
- package/dist/types/loadPrompts.d.ts.map +1 -1
- package/dist/types/pull.d.ts +1 -2
- package/dist/types/pull.d.ts.map +1 -1
- package/dist/types/push/pullLog.d.ts +0 -2
- package/dist/types/push/pullLog.d.ts.map +1 -1
- package/dist/types/push/push.d.ts +1 -2
- package/dist/types/push/push.d.ts.map +1 -1
- package/dist/types/pushConfig.d.ts +1 -2
- package/dist/types/pushConfig.d.ts.map +1 -1
- package/dist/types/pushLog.d.ts +0 -2
- package/dist/types/pushLog.d.ts.map +1 -1
- package/dist/types/reviewDoc/reviewDoc.d.ts +1 -2
- package/dist/types/reviewDoc/reviewDoc.d.ts.map +1 -1
- package/dist/types/reviewDoc/reviewDocBlockAware.d.ts +0 -2
- package/dist/types/reviewDoc/reviewDocBlockAware.d.ts.map +1 -1
- package/dist/types/reviewDoc/reviewDocLog.d.ts +0 -2
- package/dist/types/reviewDoc/reviewDocLog.d.ts.map +1 -1
- package/dist/types/reviewDoc/reviewDocProgress.d.ts +0 -2
- package/dist/types/reviewDoc/reviewDocProgress.d.ts.map +1 -1
- package/dist/types/reviewDoc/reviewDocSynthesis.d.ts +0 -2
- package/dist/types/reviewDoc/reviewDocSynthesis.d.ts.map +1 -1
- package/dist/types/scan.d.ts +0 -2
- package/dist/types/scan.d.ts.map +1 -1
- package/dist/types/searchDoc.d.ts +1 -2
- package/dist/types/searchDoc.d.ts.map +1 -1
- package/dist/types/test/listMissingTranslations.d.ts +0 -2
- package/dist/types/test/listMissingTranslations.d.ts.map +1 -1
- package/dist/types/test/test.d.ts +1 -2
- package/dist/types/test/test.d.ts.map +1 -1
- package/dist/types/translateDoc/index.d.ts +1 -1
- package/dist/types/translateDoc/translateDoc.d.ts +0 -2
- package/dist/types/translateDoc/translateDoc.d.ts.map +1 -1
- package/dist/types/translateDoc/translateFile.d.ts +0 -2
- package/dist/types/translateDoc/translateFile.d.ts.map +1 -1
- package/dist/types/translateDoc/types.d.ts +0 -2
- package/dist/types/translateDoc/types.d.ts.map +1 -1
- package/dist/types/translateDoc/validation.d.ts +0 -2
- package/dist/types/translateDoc/validation.d.ts.map +1 -1
- package/dist/types/upgrade.d.ts +0 -2
- package/dist/types/upgrade.d.ts.map +1 -1
- package/dist/types/utils/calculateChunks.d.ts +0 -2
- package/dist/types/utils/calculateChunks.d.ts.map +1 -1
- package/dist/types/utils/checkAccess.d.ts +0 -2
- package/dist/types/utils/checkAccess.d.ts.map +1 -1
- package/dist/types/utils/checkConfigConsistency.d.ts +0 -2
- package/dist/types/utils/checkConfigConsistency.d.ts.map +1 -1
- package/dist/types/utils/checkFileModifiedRange.d.ts +1 -2
- package/dist/types/utils/checkFileModifiedRange.d.ts.map +1 -1
- package/dist/types/utils/checkLastUpdateTime.d.ts +0 -2
- package/dist/types/utils/checkLastUpdateTime.d.ts.map +1 -1
- package/dist/types/utils/chunkInference.d.ts +1 -2
- package/dist/types/utils/chunkInference.d.ts.map +1 -1
- package/dist/types/utils/detectGitRepository.d.ts +0 -2
- package/dist/types/utils/detectGitRepository.d.ts.map +1 -1
- package/dist/types/utils/fixChunkStartEndChars.d.ts +0 -2
- package/dist/types/utils/fixChunkStartEndChars.d.ts.map +1 -1
- package/dist/types/utils/formatLineRanges.d.ts +0 -2
- package/dist/types/utils/formatLineRanges.d.ts.map +1 -1
- package/dist/types/utils/formatTimeDiff.d.ts +0 -2
- package/dist/types/utils/formatTimeDiff.d.ts.map +1 -1
- package/dist/types/utils/getIsFileUpdatedRecently.d.ts +0 -2
- package/dist/types/utils/getIsFileUpdatedRecently.d.ts.map +1 -1
- package/dist/types/utils/getOutputFilePath.d.ts +0 -2
- package/dist/types/utils/getOutputFilePath.d.ts.map +1 -1
- package/dist/types/utils/getParentPackageJSON.d.ts +1 -2
- package/dist/types/utils/getParentPackageJSON.d.ts.map +1 -1
- package/dist/types/utils/isInteractiveTerminal.d.ts +0 -2
- package/dist/types/utils/isInteractiveTerminal.d.ts.map +1 -1
- package/dist/types/utils/listSpecialChars.d.ts +1 -2
- package/dist/types/utils/listSpecialChars.d.ts.map +1 -1
- package/dist/types/utils/mapChunksBetweenFiles.d.ts +0 -2
- package/dist/types/utils/mapChunksBetweenFiles.d.ts.map +1 -1
- package/dist/types/utils/openBrowser.d.ts +0 -2
- package/dist/types/utils/openBrowser.d.ts.map +1 -1
- package/dist/types/utils/parseChoice.d.ts +0 -2
- package/dist/types/utils/parseChoice.d.ts.map +1 -1
- package/dist/types/utils/reorderParagraphs.d.ts +0 -2
- package/dist/types/utils/reorderParagraphs.d.ts.map +1 -1
- package/dist/types/utils/selectCmsEnvironment.d.ts +0 -2
- package/dist/types/utils/selectCmsEnvironment.d.ts.map +1 -1
- package/dist/types/utils/setupAI.d.ts +1 -2
- package/dist/types/utils/setupAI.d.ts.map +1 -1
- package/dist/types/watch.d.ts +1 -2
- package/dist/types/watch.d.ts.map +1 -1
- package/package.json +13 -13
package/dist/cjs/pull.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.cjs","names":["getConfiguration","getAppLogger","checkCMSAuth","getAuthenticatedAPI","selectCmsEnvironment","getUnmergedDictionaries","join","getProjectRequire","existsSync","PullLogger","writeContentDeclaration","parallelize","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 { getUnmergedDictionaries } from '@intlayer/dictionaries-entry/unmerged';\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 { 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,aAASA,wCAAiB,SAAS,aAAa;CACtD,MAAM,gBAAYC,sCAAa,MAAM;CAErC,IAAI;EACF,2CAAiB,SAAS,aAAa;EAIvC,IAAI,CAAC,MAFoBC,uCAAa,MAAM,GAE3B;EAEjB,MAAM,cAAc,MAAMC,8CAAoB,MAAM;EAEpD,MAAMC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EACf,OAAO,QACT,CAAC;CACH;AACF"}
|
|
1
|
+
{"version":3,"file":"pull.cjs","names":["getConfiguration","getAppLogger","checkCMSAuth","getAuthenticatedAPI","selectCmsEnvironment","getUnmergedDictionaries","join","getProjectRequire","existsSync","PullLogger","writeContentDeclaration","parallelize","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, parallelize } from '@intlayer/config/utils';\nimport { getUnmergedDictionaries } from '@intlayer/dictionaries-entry/unmerged';\nimport {\n type DictionaryStatus,\n writeContentDeclaration,\n} from '@intlayer/engine/build';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport type { Dictionary } from '@intlayer/types/dictionary';\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":";;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,aAASA,wCAAiB,SAAS,aAAa;CACtD,MAAM,gBAAYC,sCAAa,MAAM;CAErC,IAAI;EACF,2CAAiB,SAAS,aAAa;EAIvC,IAAI,CAAC,MAFoBC,uCAAa,MAAM,GAE3B;EAEjB,MAAM,cAAc,MAAMC,8CAAoB,MAAM;EAEpD,MAAMC,wDACJ,SAAS,eAAe,KACxB,aACA,MACF;EAEA,MAAM,iCAA6BC,+DAAwB,MAAM;EAGjE,MAAM,uCACJ,MAAM,YAAY,WAAW,+BAA+B;EAE9D,IAAI,CAAC,qCAAqC,MACxC,MAAM,IAAI,MAAM,+BAA+B;EAGjD,IAAI,qCACF,qCAAqC;EAGvC,IAAI,SAAS,cACX,qCAAqC,OAAO,YAC1C,OAAO,QAAQ,kCAAkC,CAAC,CAAC,QAAQ,CAAC,SAC1D,QAAQ,cAAc,SAAS,GAAG,CACpC,CACF;EAIF,qCAAqC,OAAO,YAC1C,OAAO,QAAQ,kCAAkC,CAAC,CAAC,QAAQ,CAAC,SAAS;GAEnE,MAAM,WADoB,2BAA2B,IAElC,GAAG,EAAE,EAAE,YACxB,OAAO,YAAY,YACnB;GAEF,OAAO,aAAa,YAAY,aAAa;EAC/C,CAAC,CACH;EAGA,MAAM,6BAAyBC,gBAC7B,OAAO,OAAO,SACd,yBACF;EACA,MAAM,kBAAkB,OAAO,OAAO,eAAWC,0CAAkB;EACnE,MAAM,+BAAgDC,oBACpD,sBACF,IACK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QAAQ,QAAR;IACE,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK,cACH,OAAOC,wBAAW;IACpB,KAAK;IACL,KAAK,oBACH,OAAOA,wBAAW;IACpB,KAAK,SACH,OAAOA,wBAAW;IACpB,SACE,OAAOA,wBAAW;GACtB;EACF;EAEA,KAAK,MAAM,KAAK,sBAAsB;GACpC,MAAM,OAAO,QAAQ,EAAE,MAAM;GAC7B,MAAM,QAAQ,SAAS,EAAE,MAAM;GAC/B,UACE,MAAM,EAAE,cAAc,GAAGA,wBAAW,KAAK,GAAG,QAAQ,KAAK,GAAG,EAAE,SAASA,wBAAW,KAAK,GAAGA,wBAAW,OACvG;EACF;EAGA,KAAK,MAAM,aAAa,sBACtB,IAAI,UAAU,cACZ,UAAU,UAAU,cAAc,EAChC,OAAO,QACT,CAAC;CAGP,SAAS,OAAO;EACd,UAAU,OAAO,EACf,OAAO,QACT,CAAC;CACH;AACF"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
4
4
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
5
5
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
6
6
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/push/pullLog.ts
|
|
9
9
|
var PullLogger = class {
|
|
10
10
|
statuses = [];
|
|
11
11
|
spinnerTimer = null;
|
|
@@ -102,6 +102,5 @@ var PullLogger = class {
|
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
//#endregion
|
|
106
105
|
exports.PullLogger = PullLogger;
|
|
107
106
|
//# sourceMappingURL=pullLog.cjs.map
|
package/dist/cjs/push/push.cjs
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
3
|
-
const require_loadPrompts = require(
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
8
|
-
let node_path = require("node:path");
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_loadPrompts = require("../loadPrompts.cjs");
|
|
4
|
+
const require_pushLog = require("../pushLog.cjs");
|
|
5
|
+
const require_utils_checkAccess = require("../utils/checkAccess.cjs");
|
|
6
|
+
const require_utils_selectCmsEnvironment = require("../utils/selectCmsEnvironment.cjs");
|
|
9
7
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
10
8
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
11
9
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
12
10
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
11
|
+
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
12
|
+
let node_path = require("node:path");
|
|
13
13
|
let node_fs_promises = require("node:fs/promises");
|
|
14
14
|
node_fs_promises = require_runtime.__toESM(node_fs_promises);
|
|
15
15
|
let _intlayer_engine_utils = require("@intlayer/engine/utils");
|
|
16
|
+
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
16
17
|
let _intlayer_dictionaries_entry_unmerged = require("@intlayer/dictionaries-entry/unmerged");
|
|
17
18
|
let _intlayer_engine_build = require("@intlayer/engine/build");
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
// src/push/push.ts
|
|
20
21
|
const statusIconsAndColors = {
|
|
21
22
|
pushed: {
|
|
22
23
|
icon: "✔",
|
|
@@ -151,7 +152,7 @@ const push = async (options) => {
|
|
|
151
152
|
}]);
|
|
152
153
|
}
|
|
153
154
|
};
|
|
154
|
-
await (0,
|
|
155
|
+
await (0, _intlayer_config_utils.parallelize)(dictionariesStatuses, processDictionary, 5);
|
|
155
156
|
logger.finish();
|
|
156
157
|
for (const dictionaryStatus of dictionariesStatuses) {
|
|
157
158
|
const { icon, color } = getIconAndColor(dictionaryStatus.status);
|
|
@@ -203,6 +204,5 @@ const deleteLocalDictionaries = async (dictionariesToDelete, options) => {
|
|
|
203
204
|
}
|
|
204
205
|
};
|
|
205
206
|
|
|
206
|
-
//#endregion
|
|
207
207
|
exports.push = push;
|
|
208
208
|
//# sourceMappingURL=push.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.cjs","names":["ANSIColors","getConfiguration","getAppLogger","prepareIntlayer","checkCMSAuth","getAuthenticatedAPI","selectCmsEnvironment","getUnmergedDictionaries","colorize","listGitFiles","join","PushLogger","writeContentDeclaration","parallelize","colorizeKey","loadPrompts","fsPromises","formatPath"],"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 { getUnmergedDictionaries } from '@intlayer/dictionaries-entry/unmerged';\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 { loadPrompts } from '../loadPrompts';\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 loadPrompts();\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":";;;;;;;;;;;;;;;;;;;AAiDA,MAAM,uBAAuB;CAC3B,QAAQ;EAAE,MAAM;EAAK,OAAOA,wBAAW;CAAM;CAC7C,UAAU;EAAE,MAAM;EAAK,OAAOA,wBAAW;CAAM;CAC/C,cAAc;EAAE,MAAM;EAAK,OAAOA,wBAAW;CAAK;CAClD,OAAO;EAAE,MAAM;EAAK,OAAOA,wBAAW;CAAI;CAC1C,SAAS;EAAE,MAAM;EAAK,OAAOA,wBAAW;CAAK;AAC/C;AAEA,MAAM,mBAAmB,WAAyC;CAChE,OACE,qBAAqB,WACrB,qBAAqB;AAEzB;;;;AAKA,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,aAASC,wCAAiB,SAAS,aAAa;CACtD,2CAAiB,SAAS,aAAa;CAEvC,MAAM,gBAAYC,sCAAa,MAAM;CAErC,IAAI,SAAS,UAAU,MACrB,UAAMC,wCAA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,CAAC,CAAC;EACtD,OAAO,IAAI,MAAM,YAAY,GAC3B,UAAU,2BAAuBA,mCAAW,QAAQ,EAAE,cAAc,CAAC,CAAC;OAEtE,UACE,6BAAyBA,mCAAW,QAAQ,EAAE,cAC9C,CAAC,CACH;CAEJ,SAAS,KAAK;EACZ,UAAU,sBAAkBA,mCAAW,QAAQ,EAAE,IAAI,OAAO,EAC1D,OAAO,QACT,CAAC;CACH;AAEJ"}
|
|
1
|
+
{"version":3,"file":"push.cjs","names":["ANSIColors","getConfiguration","getAppLogger","prepareIntlayer","checkCMSAuth","getAuthenticatedAPI","selectCmsEnvironment","getUnmergedDictionaries","colorize","listGitFiles","join","PushLogger","writeContentDeclaration","parallelize","colorizeKey","loadPrompts","fsPromises","formatPath"],"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 { parallelize } from '@intlayer/config/utils';\nimport { getUnmergedDictionaries } from '@intlayer/dictionaries-entry/unmerged';\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 } from '@intlayer/engine/utils';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { loadPrompts } from '../loadPrompts';\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 loadPrompts();\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":";;;;;;;;;;;;;;;;;;;;AAkDA,MAAM,uBAAuB;CAC3B,QAAQ;EAAE,MAAM;EAAK,OAAOA,wBAAW;CAAM;CAC7C,UAAU;EAAE,MAAM;EAAK,OAAOA,wBAAW;CAAM;CAC/C,cAAc;EAAE,MAAM;EAAK,OAAOA,wBAAW;CAAK;CAClD,OAAO;EAAE,MAAM;EAAK,OAAOA,wBAAW;CAAI;CAC1C,SAAS;EAAE,MAAM;EAAK,OAAOA,wBAAW;CAAK;AAC/C;AAEA,MAAM,mBAAmB,WAAyC;CAChE,OACE,qBAAqB,WACrB,qBAAqB;AAEzB;;;;AAKA,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,aAASC,wCAAiB,SAAS,aAAa;CACtD,2CAAiB,SAAS,aAAa;CAEvC,MAAM,gBAAYC,sCAAa,MAAM;CAErC,IAAI,SAAS,UAAU,MACrB,UAAMC,wCAAgB,QAAQ,EAAE,UAAU,KAAK,CAAC;MAC3C,IAAI,OAAO,SAAS,UAA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A,mCAAW,QAAQ,EAAE,cAAc,CAAC,CAAC;OAEtE,UACE,6BAAyBA,mCAAW,QAAQ,EAAE,cAC9C,CAAC,CACH;CAEJ,SAAS,KAAK;EACZ,UAAU,sBAAkBA,mCAAW,QAAQ,EAAE,IAAI,OAAO,EAC1D,OAAO,QACT,CAAC;CACH;AAEJ"}
|
package/dist/cjs/pushConfig.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_utils_checkAccess = require(
|
|
3
|
-
const require_utils_selectCmsEnvironment = require(
|
|
4
|
-
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
2
|
+
const require_utils_checkAccess = require("./utils/checkAccess.cjs");
|
|
3
|
+
const require_utils_selectCmsEnvironment = require("./utils/selectCmsEnvironment.cjs");
|
|
5
4
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
6
5
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
7
6
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
7
|
+
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// src/pushConfig.ts
|
|
10
10
|
const pushConfig = async (options) => {
|
|
11
11
|
const config = (0, _intlayer_config_node.getConfiguration)(options?.configOptions);
|
|
12
12
|
(0, _intlayer_engine_cli.logConfigDetails)(options?.configOptions);
|
|
@@ -25,6 +25,5 @@ const pushConfig = async (options) => {
|
|
|
25
25
|
appLogger((0, _intlayer_config_logger.colorize)("--------------------------------", _intlayer_config_colors.GREY_DARK));
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
//#endregion
|
|
29
28
|
exports.pushConfig = pushConfig;
|
|
30
29
|
//# sourceMappingURL=pushConfig.cjs.map
|
package/dist/cjs/pushLog.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
2
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
4
4
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
5
5
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/pushLog.ts
|
|
8
8
|
var PushLogger = class {
|
|
9
9
|
statuses = [];
|
|
10
10
|
spinnerTimer = null;
|
|
@@ -85,6 +85,5 @@ var PushLogger = class {
|
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
//#endregion
|
|
89
88
|
exports.PushLogger = PushLogger;
|
|
90
89
|
//# sourceMappingURL=pushLog.cjs.map
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const require_reviewDoc_reviewDocBlockAware = require(
|
|
8
|
-
const require_reviewDoc_reviewDocLog = require(
|
|
9
|
-
const require_reviewDoc_reviewDocProgress = require(
|
|
10
|
-
const require_reviewDoc_reviewDocSynthesis = require(
|
|
11
|
-
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
12
|
-
let node_fs = require("node:fs");
|
|
13
|
-
let node_path = require("node:path");
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_utils_checkFileModifiedRange = require("../utils/checkFileModifiedRange.cjs");
|
|
4
|
+
const require_utils_formatLineRanges = require("../utils/formatLineRanges.cjs");
|
|
5
|
+
const require_utils_getOutputFilePath = require("../utils/getOutputFilePath.cjs");
|
|
6
|
+
const require_utils_setupAI = require("../utils/setupAI.cjs");
|
|
7
|
+
const require_reviewDoc_reviewDocBlockAware = require("./reviewDocBlockAware.cjs");
|
|
8
|
+
const require_reviewDoc_reviewDocLog = require("./reviewDocLog.cjs");
|
|
9
|
+
const require_reviewDoc_reviewDocProgress = require("./reviewDocProgress.cjs");
|
|
10
|
+
const require_reviewDoc_reviewDocSynthesis = require("./reviewDocSynthesis.cjs");
|
|
14
11
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
15
12
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
16
13
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
17
14
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
15
|
+
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
16
|
+
let node_path = require("node:path");
|
|
17
|
+
let node_fs = require("node:fs");
|
|
18
18
|
let node_fs_promises = require("node:fs/promises");
|
|
19
19
|
let _intlayer_engine_utils = require("@intlayer/engine/utils");
|
|
20
|
+
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
20
21
|
let _intlayer_engine_docReview = require("@intlayer/engine/docReview");
|
|
21
22
|
let fast_glob = require("fast-glob");
|
|
22
23
|
fast_glob = require_runtime.__toESM(fast_glob);
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
// src/reviewDoc/reviewDoc.ts
|
|
25
26
|
/**
|
|
26
27
|
* Main audit function: scans all .md files in "en/" (unless you specified DOC_LIST),
|
|
27
28
|
* then audits them to each locale in LOCALE_LIST.
|
|
@@ -137,7 +138,7 @@ const reviewDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale,
|
|
|
137
138
|
}));
|
|
138
139
|
const progressLogger = require_reviewDoc_reviewDocProgress.createReviewProgressLogger(allTasks.length);
|
|
139
140
|
if (mode === "synthesis") progressLogger.start();
|
|
140
|
-
await (0,
|
|
141
|
+
await (0, _intlayer_config_utils.parallelize)(allTasks, async (task) => {
|
|
141
142
|
await task();
|
|
142
143
|
progressLogger.increment();
|
|
143
144
|
}, nbSimultaneousFileProcessed ?? 3);
|
|
@@ -147,6 +148,5 @@ const reviewDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale,
|
|
|
147
148
|
return reviewResults;
|
|
148
149
|
};
|
|
149
150
|
|
|
150
|
-
//#endregion
|
|
151
151
|
exports.reviewDoc = reviewDoc;
|
|
152
152
|
//# sourceMappingURL=reviewDoc.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewDoc.cjs","names":["getConfiguration","getAppLogger","setupAI","x","fg","listGitFiles","join","formatLocale","colorizeNumber","formatPath","getOutputFilePath","existsSync","relative","colorize","ANSIColors","checkFileModifiedRange","listGitLines","formatLineRanges","readFile","buildReviewReport","buildFileReviewReport","reviewFileBlockAware","createReviewProgressLogger","parallelize","formatReviewSynthesis"],"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, AIOptions } from '@intlayer/ai';\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 {\n buildReviewReport,\n type ReviewReportSummary,\n} 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 { buildFileReviewReport, logReviewFileBlocks } from './reviewDocLog';\nimport { createReviewProgressLogger } from './reviewDocProgress';\nimport {\n formatReviewSynthesis,\n type ReviewFileResult,\n type ReviewOutcome,\n} from './reviewDocSynthesis';\n\n/**\n * How the review should be run.\n *\n * - `apply`: translate the diverging blocks with AI and write the target files.\n * - `report`: no AI. Log every block that needs attention (line numbers and\n * content, for both locales) so another agent can generate the translations.\n * - `synthesis`: no AI, no per-block output. Only log the final synthesis of the\n * documents that are up to date and the ones that still have blocks to edit.\n */\nexport type ReviewDocMode = 'apply' | 'report' | 'synthesis';\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 /** How the review should be run. Defaults to `apply`. See {@link ReviewDocMode}. */\n mode?: ReviewDocMode;\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 mode = 'apply',\n}: ReviewDocOptions) => {\n const configuration = getConfiguration(configOptions);\n logConfigDetails(configOptions);\n\n const appLogger = getAppLogger({ log: { ...configuration.log, prefix: '' } });\n\n // The `report` and `synthesis` modes never call an AI, so the AI access\n // checks are skipped.\n let aiClient: AIClient | undefined;\n let aiConfig: AIConfig | undefined;\n\n if (mode === 'apply') {\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 // In `synthesis` mode only the final recap is printed, so the per-file\n // progress logs are muted.\n const logProgress: typeof appLogger = (...content) => {\n if (mode === 'synthesis') return;\n appLogger(...content);\n };\n\n // Filled by every task, then rendered as the end-of-run synthesis.\n const reviewResults: ReviewFileResult[] = [];\n\n /** A document is up to date when no block has to be added, reviewed or removed. */\n const getOutcome = (summary: ReviewReportSummary): ReviewOutcome =>\n summary.review + summary.insertNew + summary.delete > 0\n ? 'toEdit'\n : 'upToDate';\n\n // Create all tasks to be processed\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n logProgress(\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 logProgress(\n `${colorize('⊘', ANSIColors.YELLOW)} File ${formatPath(relativePath)} already exists, skipping.`\n );\n reviewResults.push({ docPath, locale, outcome: 'skipped' });\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 logProgress(fileModificationData.message);\n reviewResults.push({ docPath, locale, outcome: 'skipped' });\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 logProgress(\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 logProgress(\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 logProgress(\n `Corresponding block (${formatLocale(locale)}): ${formatLineRanges(correspondingTargetLines)}`\n );\n }\n\n if (mode !== 'apply') {\n const report = await buildFileReviewReport(\n absoluteBaseFilePath,\n outputFilePath,\n changedLines\n );\n\n if (mode === 'report') {\n logReviewFileBlocks(\n report,\n absoluteBaseFilePath,\n locale as Locale,\n baseLocale,\n configOptions\n );\n }\n\n reviewResults.push({\n docPath,\n locale,\n outcome: getOutcome(report.summary),\n summary: report.summary,\n });\n return;\n }\n\n const reviewSummary = 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 reviewResults.push({\n docPath,\n locale,\n outcome: getOutcome(reviewSummary),\n summary: reviewSummary,\n });\n })\n );\n\n // The per-file logs are muted in `synthesis` mode, so a progress line keeps\n // the run readable while every document is compared.\n const progressLogger = createReviewProgressLogger(allTasks.length);\n\n if (mode === 'synthesis') progressLogger.start();\n\n await parallelize(\n allTasks,\n async (task) => {\n await task();\n progressLogger.increment();\n },\n nbSimultaneousFileProcessed ?? 3\n );\n\n progressLogger.stop();\n\n const synthesis = formatReviewSynthesis(reviewResults, {\n hasAppliedChanges: mode === 'apply',\n });\n\n for (const line of synthesis.split('\\n')) {\n appLogger(line);\n }\n\n return reviewResults;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,MAAa,YAAY,OAAO,EAC9B,YACA,SACA,qBACA,YACA,WACA,6BACA,eACA,oBACA,sBACA,qBACA,cACA,YACA,OAAO,cACe;CACtB,MAAM,oBAAgBA,wCAAiB,aAAa;CACpD,2CAAiB,aAAa;CAE9B,MAAM,gBAAYC,sCAAa,EAAE,KAAK;EAAE,GAAG,cAAc;EAAK,QAAQ;CAAG,EAAE,CAAC;CAI5E,IAAI;CACJ,IAAI;CAEJ,IAAI,SAAS,SAAS;EACpB,MAAM,WAAW,MAAMC,8BAAQ,eAAe,SAAS;EAEvD,IAAI,CAAC,UAAU,aAAa,OAAO,CAAC;EAEpC,W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U,gDAAiB,wBAAwB,GAC7F;EACF;EAEA,IAAI,SAAS,SAAS;GACpB,MAAM,SAAS,MAAMG,qDACnB,sBACA,gBACA,YACF;GAEA,IAAI,SAAS,UACX,mDACE,QACA,sBACA,QACA,YACA,aACF;GAGF,cAAc,KAAK;IACjB;IACA;IACA,SAAS,WAAW,OAAO,OAAO;IAClC,SAAS,OAAO;GAClB,CAAC;GACD;EACF;EAEA,MAAM,gBAAgB,MAAMC,2DAC1B,sBACA,gBACA,QACA,YACA,WACA,eACA,oBACA,cACA,UACA,QACF;EAEA,cAAc,KAAK;GACjB;GACA;GACA,SAAS,WAAW,aAAa;GACjC,SAAS;EACX,CAAC;CACH,CAAC,CACH;CAIA,MAAM,iBAAiBC,+DAA2B,SAAS,MAAM;CAEjE,IAAI,SAAS,aAAa,eAAe,MAAM;CAE/C,UAAMC,oCACJ,UACA,OAAO,SAAS;EACd,MAAM,KAAK;EACX,eAAe,UAAU;CAC3B,GACA,+BAA+B,CACjC;CAEA,eAAe,KAAK;CAEpB,MAAM,YAAYC,2DAAsB,eAAe,EACrD,mBAAmB,SAAS,QAC9B,CAAC;CAED,KAAK,MAAM,QAAQ,UAAU,MAAM,IAAI,GACrC,UAAU,IAAI;CAGhB,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"reviewDoc.cjs","names":["getConfiguration","getAppLogger","setupAI","x","fg","listGitFiles","join","formatLocale","colorizeNumber","formatPath","getOutputFilePath","existsSync","relative","colorize","ANSIColors","checkFileModifiedRange","listGitLines","formatLineRanges","readFile","buildReviewReport","buildFileReviewReport","reviewFileBlockAware","createReviewProgressLogger","parallelize","formatReviewSynthesis"],"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, AIOptions } from '@intlayer/ai';\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 { parallelize } from '@intlayer/config/utils';\nimport {\n type ListGitFilesOptions,\n listGitFiles,\n listGitLines,\n logConfigDetails,\n} from '@intlayer/engine/cli';\nimport {\n buildReviewReport,\n type ReviewReportSummary,\n} from '@intlayer/engine/docReview';\nimport { formatLocale, formatPath } 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 { buildFileReviewReport, logReviewFileBlocks } from './reviewDocLog';\nimport { createReviewProgressLogger } from './reviewDocProgress';\nimport {\n formatReviewSynthesis,\n type ReviewFileResult,\n type ReviewOutcome,\n} from './reviewDocSynthesis';\n\n/**\n * How the review should be run.\n *\n * - `apply`: translate the diverging blocks with AI and write the target files.\n * - `report`: no AI. Log every block that needs attention (line numbers and\n * content, for both locales) so another agent can generate the translations.\n * - `synthesis`: no AI, no per-block output. Only log the final synthesis of the\n * documents that are up to date and the ones that still have blocks to edit.\n */\nexport type ReviewDocMode = 'apply' | 'report' | 'synthesis';\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 /** How the review should be run. Defaults to `apply`. See {@link ReviewDocMode}. */\n mode?: ReviewDocMode;\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 mode = 'apply',\n}: ReviewDocOptions) => {\n const configuration = getConfiguration(configOptions);\n logConfigDetails(configOptions);\n\n const appLogger = getAppLogger({ log: { ...configuration.log, prefix: '' } });\n\n // The `report` and `synthesis` modes never call an AI, so the AI access\n // checks are skipped.\n let aiClient: AIClient | undefined;\n let aiConfig: AIConfig | undefined;\n\n if (mode === 'apply') {\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 // In `synthesis` mode only the final recap is printed, so the per-file\n // progress logs are muted.\n const logProgress: typeof appLogger = (...content) => {\n if (mode === 'synthesis') return;\n appLogger(...content);\n };\n\n // Filled by every task, then rendered as the end-of-run synthesis.\n const reviewResults: ReviewFileResult[] = [];\n\n /** A document is up to date when no block has to be added, reviewed or removed. */\n const getOutcome = (summary: ReviewReportSummary): ReviewOutcome =>\n summary.review + summary.insertNew + summary.delete > 0\n ? 'toEdit'\n : 'upToDate';\n\n // Create all tasks to be processed\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n logProgress(\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 logProgress(\n `${colorize('⊘', ANSIColors.YELLOW)} File ${formatPath(relativePath)} already exists, skipping.`\n );\n reviewResults.push({ docPath, locale, outcome: 'skipped' });\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 logProgress(fileModificationData.message);\n reviewResults.push({ docPath, locale, outcome: 'skipped' });\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 logProgress(\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 logProgress(\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 logProgress(\n `Corresponding block (${formatLocale(locale)}): ${formatLineRanges(correspondingTargetLines)}`\n );\n }\n\n if (mode !== 'apply') {\n const report = await buildFileReviewReport(\n absoluteBaseFilePath,\n outputFilePath,\n changedLines\n );\n\n if (mode === 'report') {\n logReviewFileBlocks(\n report,\n absoluteBaseFilePath,\n locale as Locale,\n baseLocale,\n configOptions\n );\n }\n\n reviewResults.push({\n docPath,\n locale,\n outcome: getOutcome(report.summary),\n summary: report.summary,\n });\n return;\n }\n\n const reviewSummary = 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 reviewResults.push({\n docPath,\n locale,\n outcome: getOutcome(reviewSummary),\n summary: reviewSummary,\n });\n })\n );\n\n // The per-file logs are muted in `synthesis` mode, so a progress line keeps\n // the run readable while every document is compared.\n const progressLogger = createReviewProgressLogger(allTasks.length);\n\n if (mode === 'synthesis') progressLogger.start();\n\n await parallelize(\n allTasks,\n async (task) => {\n await task();\n progressLogger.increment();\n },\n nbSimultaneousFileProcessed ?? 3\n );\n\n progressLogger.stop();\n\n const synthesis = formatReviewSynthesis(reviewResults, {\n hasAppliedChanges: mode === 'apply',\n });\n\n for (const line of synthesis.split('\\n')) {\n appLogger(line);\n }\n\n return reviewResults;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,MAAa,YAAY,OAAO,EAC9B,YACA,SACA,qBACA,YACA,WACA,6BACA,eACA,oBACA,sBACA,qBACA,cACA,YACA,OAAO,cACe;CACtB,MAAM,oBAAgBA,wCAAiB,aAAa;CACpD,2CAAiB,aAAa;CAE9B,MAAM,gBAAYC,sCAAa,EAAE,KAAK;EAAE,GAAG,cAAc;EAAK,QAAQ;CAAG,EAAE,CAAC;CAI5E,IAAI;CACJ,IAAI;CAEJ,IAAI,SAAS,SAAS;EACpB,MAAM,WAAW,MAAMC,8BAAQ,eAAe,SAAS;EAEvD,IAAI,CAAC,UAAU,aAAa,OAAO,CAAC;EAEpC,WAAW,SAAS;EACpB,WAAW,SAAS;EAEpB,IAAI,SAAS,cAAc,YAAY,UAAU;GAC/C,MAAM,EAAE,aAAa,UAAU,MAAM,SAAS,iBAAiB,QAAQ;GACvE,IAAI,CAAC,aAAa;IAChB,UAAU,GAAGC,0BAAE,GAAG,OAAO;IACzB,OAAO,CAAC;GACV;EACF;CACF;CAEA,IAAI,+BAA+B,8BAA8B,IAAI;EACnE,UACE,kDAAkD,4BAA4B,8CAChF;EACA,8BAA8B;CAChC;CAEA,IAAI,UAAoB,UAAMC,mBAAG,YAAY,EAC3C,QAAQ,oBACV,CAAC;CAED,IAAI,YAAY;EACd,MAAM,kBAAkB,UAAMC,mCAAa,UAAU;EAErD,IAAI,iBAIF,UAAU,QAAQ,QAAQ,SACxB,gBAAgB,MAAM,gBAAYC,gBAAK,QAAQ,IAAI,GAAG,IAAI,MAAM,OAAO,CACzE;CAEJ;CAIA,UAAU,sBAAkBC,qCAAa,UAAU,GAAG;CACtD,UACE,iBAAaC,wCAAe,QAAQ,MAA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,MAAM,YAAYC,2DAAsB,eAAe,EACrD,mBAAmB,SAAS,QAC9B,CAAC;CAED,KAAK,MAAM,QAAQ,UAAU,MAAM,IAAI,GACrC,UAAU,IAAI;CAGhB,OAAO;AACT"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
3
|
-
const require__utils_asset = require(
|
|
4
|
-
const require_translateDoc_validation = require(
|
|
5
|
-
const require_utils_chunkInference = require(
|
|
6
|
-
const require_utils_fixChunkStartEndChars = require(
|
|
7
|
-
let node_fs = require("node:fs");
|
|
8
|
-
let node_path = require("node:path");
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require__utils_asset = require("../_virtual/_utils_asset.cjs");
|
|
4
|
+
const require_translateDoc_validation = require("../translateDoc/validation.cjs");
|
|
5
|
+
const require_utils_chunkInference = require("../utils/chunkInference.cjs");
|
|
6
|
+
const require_utils_fixChunkStartEndChars = require("../utils/fixChunkStartEndChars.cjs");
|
|
9
7
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
10
8
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
11
9
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
12
10
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
11
|
+
let node_path = require("node:path");
|
|
12
|
+
let node_fs = require("node:fs");
|
|
13
13
|
let node_fs_promises = require("node:fs/promises");
|
|
14
14
|
let _intlayer_engine_utils = require("@intlayer/engine/utils");
|
|
15
15
|
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
@@ -17,7 +17,7 @@ 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
|
|
|
20
|
-
|
|
20
|
+
// src/reviewDoc/reviewDocBlockAware.ts
|
|
21
21
|
/**
|
|
22
22
|
* Review a file using block-aware alignment.
|
|
23
23
|
*
|
|
@@ -123,6 +123,5 @@ const reviewFileBlockAware = async (baseFilePath, outputFilePath, locale, baseLo
|
|
|
123
123
|
return reviewSummary;
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
-
//#endregion
|
|
127
126
|
exports.reviewFileBlockAware = reviewFileBlockAware;
|
|
128
127
|
//# sourceMappingURL=reviewDocBlockAware.cjs.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
let node_fs = require("node:fs");
|
|
3
2
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
4
3
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
5
|
let node_fs_promises = require("node:fs/promises");
|
|
6
6
|
let _intlayer_engine_utils = require("@intlayer/engine/utils");
|
|
7
7
|
let _intlayer_engine_docReview = require("@intlayer/engine/docReview");
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// src/reviewDoc/reviewDocLog.ts
|
|
10
10
|
/**
|
|
11
11
|
* Compare a base document with its translation without calling any AI.
|
|
12
12
|
*
|
|
@@ -49,7 +49,6 @@ const logReviewFileBlocks = (report, baseFilePath, locale, baseLocale, configOpt
|
|
|
49
49
|
for (const line of formatted.split("\n")) appLogger(line);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
//#endregion
|
|
53
52
|
exports.buildFileReviewReport = buildFileReviewReport;
|
|
54
53
|
exports.logReviewFileBlocks = logReviewFileBlocks;
|
|
55
54
|
//# sourceMappingURL=reviewDocLog.cjs.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
4
4
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
5
5
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/reviewDoc/reviewDocProgress.ts
|
|
8
8
|
/** Refresh rate of the spinner, in milliseconds. */
|
|
9
9
|
const SPINNER_INTERVAL_MS = 100;
|
|
10
10
|
/**
|
|
@@ -61,6 +61,5 @@ const createReviewProgressLogger = (totalCount) => {
|
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
//#endregion
|
|
65
64
|
exports.createReviewProgressLogger = createReviewProgressLogger;
|
|
66
65
|
//# sourceMappingURL=reviewDocProgress.cjs.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
4
4
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
5
5
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
6
6
|
let _intlayer_engine_utils = require("@intlayer/engine/utils");
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/reviewDoc/reviewDocSynthesis.ts
|
|
9
9
|
/** Group results by base document path, preserving the first-seen order. */
|
|
10
10
|
const groupResultsByDocPath = (results) => {
|
|
11
11
|
const grouped = /* @__PURE__ */ new Map();
|
|
@@ -75,6 +75,5 @@ const formatReviewSynthesis = (results, options) => {
|
|
|
75
75
|
].join("\n");
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
//#endregion
|
|
79
78
|
exports.formatReviewSynthesis = formatReviewSynthesis;
|
|
80
79
|
//# sourceMappingURL=reviewDocSynthesis.cjs.map
|
package/dist/cjs/scan.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
2
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
4
4
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
5
5
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
6
6
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
7
7
|
let _intlayer_engine_scan = require("@intlayer/engine/scan");
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// src/scan.ts
|
|
10
10
|
/** Human-readable labels for each scorable check type. */
|
|
11
11
|
const checkLabels = {
|
|
12
12
|
robots_robotsPresent: "robots.txt present",
|
|
@@ -107,6 +107,5 @@ const scan = async (url, options = {}) => {
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
//#endregion
|
|
111
110
|
exports.scan = scan;
|
|
112
111
|
//# sourceMappingURL=scan.cjs.map
|
package/dist/cjs/searchDoc.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
3
2
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
4
3
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
4
|
+
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
5
5
|
let _intlayer_api = require("@intlayer/api");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/searchDoc.ts
|
|
8
8
|
const searchDoc = async ({ query, limit = 10, configOptions }) => {
|
|
9
9
|
const config = (0, _intlayer_config_node.getConfiguration)(configOptions);
|
|
10
10
|
(0, _intlayer_engine_cli.logConfigDetails)(configOptions);
|
|
@@ -37,6 +37,5 @@ const searchDoc = async ({ query, limit = 10, configOptions }) => {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
//#endregion
|
|
41
40
|
exports.searchDoc = searchDoc;
|
|
42
41
|
//# sourceMappingURL=searchDoc.cjs.map
|
package/dist/cjs/test/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_test_listMissingTranslations = require(
|
|
3
|
-
const require_test_test = require(
|
|
2
|
+
const require_test_listMissingTranslations = require("./listMissingTranslations.cjs");
|
|
3
|
+
const require_test_test = require("./test.cjs");
|
|
4
4
|
|
|
5
5
|
exports.listMissingTranslations = require_test_listMissingTranslations.listMissingTranslations;
|
|
6
6
|
exports.listMissingTranslationsWithConfig = require_test_listMissingTranslations.listMissingTranslationsWithConfig;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
3
2
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
3
|
+
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
4
4
|
let _intlayer_dictionaries_entry_unmerged = require("@intlayer/dictionaries-entry/unmerged");
|
|
5
5
|
let _intlayer_core_plugins = require("@intlayer/core/plugins");
|
|
6
6
|
let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/test/listMissingTranslations.ts
|
|
9
9
|
const listMissingTranslationsWithConfig = (configuration) => {
|
|
10
10
|
const unmergedDictionariesRecord = (0, _intlayer_dictionaries_entry_unmerged.getUnmergedDictionaries)(configuration);
|
|
11
11
|
const mergedDictionaries = (0, _intlayer_dictionaries_entry.getDictionaries)(configuration);
|
|
@@ -60,7 +60,6 @@ const listMissingTranslations = (configurationOptions) => {
|
|
|
60
60
|
return listMissingTranslationsWithConfig(configuration);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
//#endregion
|
|
64
63
|
exports.listMissingTranslations = listMissingTranslations;
|
|
65
64
|
exports.listMissingTranslationsWithConfig = listMissingTranslationsWithConfig;
|
|
66
65
|
//# sourceMappingURL=listMissingTranslations.cjs.map
|