@intlayer/chokidar 8.4.4 → 8.4.6
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/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/cjs/_virtual/_utils_asset.cjs +98 -0
- package/dist/cjs/build.cjs +58 -1
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +62 -1
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/index.cjs +6 -1
- package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +26 -1
- package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +107 -5
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +80 -3
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +46 -1
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +50 -1
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +59 -1
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
- package/dist/cjs/cleanOutputDir.cjs +30 -1
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/cleanRemovedContentDeclaration.cjs +97 -1
- package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
- package/dist/cjs/cli.cjs +35 -1
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +70 -1
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +42 -7
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +23 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +24 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +24 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +23 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +23 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/index.cjs +16 -1
- package/dist/cjs/createType/createModuleAugmentation.cjs +112 -9
- package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/createType/createType.cjs +29 -1
- package/dist/cjs/createType/createType.cjs.map +1 -1
- package/dist/cjs/createType/index.cjs +8 -1
- package/dist/cjs/detectFormatCommand.cjs +32 -1
- package/dist/cjs/detectFormatCommand.cjs.map +1 -1
- package/dist/cjs/fetchDistantDictionaries.cjs +51 -1
- package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/filterInvalidDictionaries.cjs +52 -1
- package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
- package/dist/cjs/formatDictionary.cjs +49 -1
- package/dist/cjs/formatDictionary.cjs.map +1 -1
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +61 -7
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
- package/dist/cjs/getContentDeclarationFileTemplate/index.cjs +4 -1
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +34 -1
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileChange.cjs +49 -1
- package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileMoved.cjs +24 -1
- package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +37 -1
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
- package/dist/cjs/init/index.cjs +284 -1
- package/dist/cjs/init/index.cjs.map +1 -1
- package/dist/cjs/init/utils/configManipulation.cjs +111 -1
- package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
- package/dist/cjs/init/utils/fileSystem.cjs +39 -1
- package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
- package/dist/cjs/init/utils/index.cjs +14 -1
- package/dist/cjs/init/utils/jsonParser.cjs +42 -3
- package/dist/cjs/init/utils/jsonParser.cjs.map +1 -1
- package/dist/cjs/init/utils/tsConfig.cjs +18 -1
- package/dist/cjs/init/utils/tsConfig.cjs.map +1 -1
- package/dist/cjs/initConfig/index.cjs +39 -1
- package/dist/cjs/initConfig/index.cjs.map +1 -1
- package/dist/cjs/installMCP/installMCP.cjs +50 -1
- package/dist/cjs/installMCP/installMCP.cjs.map +1 -1
- package/dist/cjs/installSkills/index.cjs +303 -1
- package/dist/cjs/installSkills/index.cjs.map +1 -1
- package/dist/cjs/listDictionariesPath.cjs +42 -1
- package/dist/cjs/listDictionariesPath.cjs.map +1 -1
- package/dist/cjs/listGitFiles.cjs +105 -5
- package/dist/cjs/listGitFiles.cjs.map +1 -1
- package/dist/cjs/listProjects.cjs +47 -1
- package/dist/cjs/listProjects.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +68 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/index.cjs +14 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +93 -2
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +127 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +27 -1
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +61 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/log.cjs +138 -3
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs +63 -2
- package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -1
- package/dist/cjs/logConfigDetails.cjs +39 -2
- package/dist/cjs/logConfigDetails.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +103 -1
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs +30 -1
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +12 -1
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
- package/dist/cjs/utils/autoDecorateContent.cjs +89 -1
- package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
- package/dist/cjs/utils/buildComponentFilesList.cjs +67 -1
- package/dist/cjs/utils/buildComponentFilesList.cjs.map +1 -1
- package/dist/cjs/utils/buildFilesList.cjs +83 -1
- package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
- package/dist/cjs/utils/chunkJSON.cjs +336 -1
- package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
- package/dist/cjs/utils/formatter.cjs +18 -1
- package/dist/cjs/utils/formatter.cjs.map +1 -1
- package/dist/cjs/utils/getChunk.cjs +34 -1
- package/dist/cjs/utils/getChunk.cjs.map +1 -1
- package/dist/cjs/utils/getContentExtension.cjs +29 -1
- package/dist/cjs/utils/getContentExtension.cjs.map +1 -1
- package/dist/cjs/utils/getFormatFromExtension.cjs +34 -1
- package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
- package/dist/cjs/utils/getPathHash.cjs +10 -1
- package/dist/cjs/utils/getPathHash.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +49 -1
- package/dist/cjs/utils/mergeChunks.cjs +28 -1
- package/dist/cjs/utils/mergeChunks.cjs.map +1 -1
- package/dist/cjs/utils/pLimit.cjs +128 -1
- package/dist/cjs/utils/pLimit.cjs.map +1 -1
- package/dist/cjs/utils/parallelize.cjs +11 -1
- package/dist/cjs/utils/parallelize.cjs.map +1 -1
- package/dist/cjs/utils/parallelizeGlobal.cjs +29 -1
- package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -1
- package/dist/cjs/utils/reduceObjectFormat.cjs +31 -1
- package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
- package/dist/cjs/utils/resolveObjectPromises.cjs +21 -1
- package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
- package/dist/cjs/utils/resolveRelativePath.cjs +21 -1
- package/dist/cjs/utils/resolveRelativePath.cjs.map +1 -1
- package/dist/cjs/utils/runOnce.cjs +95 -1
- package/dist/cjs/utils/runOnce.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/bin.cjs +54 -1
- package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/bootstrap.cjs +24 -1
- package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/index.cjs +115 -1
- package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/pidTree.cjs +145 -1
- package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/ps.cjs +49 -1
- package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/runTask.cjs +154 -1
- package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/spawnPosix.cjs +59 -1
- package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/spawnWin32.cjs +43 -1
- package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/wmic.cjs +52 -1
- package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
- package/dist/cjs/utils/sortAlphabetically.cjs +7 -1
- package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
- package/dist/cjs/utils/splitTextByLine.cjs +11 -1
- package/dist/cjs/utils/splitTextByLine.cjs.map +1 -1
- package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +60 -1
- package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
- package/dist/cjs/watcher.cjs +120 -1
- package/dist/cjs/watcher.cjs.map +1 -1
- package/dist/cjs/writeConfiguration/index.cjs +42 -1
- package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +28 -1
- package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/index.cjs +10 -1
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +94 -1
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +412 -3
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +127 -2
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +148 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +92 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
- package/dist/cjs/writeFileIfChanged.cjs +50 -1
- package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
- package/dist/cjs/writeJsonIfChanged.cjs +17 -1
- package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
- package/dist/esm/_virtual/_utils_asset.mjs +97 -0
- package/dist/esm/build.mjs +25 -1
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +60 -1
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/index.mjs +4 -1
- package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs +24 -1
- package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +102 -5
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +76 -3
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +44 -1
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +48 -1
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +56 -1
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
- package/dist/esm/cleanOutputDir.mjs +28 -1
- package/dist/esm/cleanOutputDir.mjs.map +1 -1
- package/dist/esm/cleanRemovedContentDeclaration.mjs +94 -1
- package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
- package/dist/esm/cli.mjs +15 -1
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +68 -1
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +40 -7
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +20 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +21 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +21 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +20 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +20 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/index.mjs +9 -1
- package/dist/esm/createType/createModuleAugmentation.mjs +108 -9
- package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/createType/createType.mjs +26 -1
- package/dist/esm/createType/createType.mjs.map +1 -1
- package/dist/esm/createType/index.mjs +4 -1
- package/dist/esm/detectFormatCommand.mjs +30 -1
- package/dist/esm/detectFormatCommand.mjs.map +1 -1
- package/dist/esm/fetchDistantDictionaries.mjs +49 -1
- package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/filterInvalidDictionaries.mjs +48 -1
- package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
- package/dist/esm/formatDictionary.mjs +44 -1
- package/dist/esm/formatDictionary.mjs.map +1 -1
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +59 -7
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
- package/dist/esm/getContentDeclarationFileTemplate/index.mjs +3 -1
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs +32 -1
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileChange.mjs +47 -1
- package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileMoved.mjs +22 -1
- package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -1
- package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +35 -1
- package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
- package/dist/esm/init/index.mjs +281 -1
- package/dist/esm/init/index.mjs.map +1 -1
- package/dist/esm/init/utils/configManipulation.mjs +108 -1
- package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
- package/dist/esm/init/utils/fileSystem.mjs +34 -1
- package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
- package/dist/esm/init/utils/index.mjs +6 -1
- package/dist/esm/init/utils/jsonParser.mjs +40 -3
- package/dist/esm/init/utils/jsonParser.mjs.map +1 -1
- package/dist/esm/init/utils/tsConfig.mjs +16 -1
- package/dist/esm/init/utils/tsConfig.mjs.map +1 -1
- package/dist/esm/initConfig/index.mjs +37 -1
- package/dist/esm/initConfig/index.mjs.map +1 -1
- package/dist/esm/installMCP/installMCP.mjs +46 -1
- package/dist/esm/installMCP/installMCP.mjs.map +1 -1
- package/dist/esm/installSkills/index.mjs +295 -1
- package/dist/esm/installSkills/index.mjs.map +1 -1
- package/dist/esm/listDictionariesPath.mjs +38 -1
- package/dist/esm/listDictionariesPath.mjs.map +1 -1
- package/dist/esm/listGitFiles.mjs +100 -5
- package/dist/esm/listGitFiles.mjs.map +1 -1
- package/dist/esm/listProjects.mjs +43 -1
- package/dist/esm/listProjects.mjs.map +1 -1
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +67 -1
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
- package/dist/esm/loadDictionaries/index.mjs +6 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +88 -2
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +124 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +25 -1
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +58 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/log.mjs +134 -3
- package/dist/esm/loadDictionaries/log.mjs.map +1 -1
- package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs +61 -2
- package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs.map +1 -1
- package/dist/esm/logConfigDetails.mjs +36 -2
- package/dist/esm/logConfigDetails.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +99 -1
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/reduceDictionaryContent/applyMask.mjs +28 -1
- package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
- package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +10 -1
- package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
- package/dist/esm/utils/autoDecorateContent.mjs +86 -1
- package/dist/esm/utils/autoDecorateContent.mjs.map +1 -1
- package/dist/esm/utils/buildComponentFilesList.mjs +64 -1
- package/dist/esm/utils/buildComponentFilesList.mjs.map +1 -1
- package/dist/esm/utils/buildFilesList.mjs +79 -1
- package/dist/esm/utils/buildFilesList.mjs.map +1 -1
- package/dist/esm/utils/chunkJSON.mjs +333 -1
- package/dist/esm/utils/chunkJSON.mjs.map +1 -1
- package/dist/esm/utils/formatter.mjs +13 -1
- package/dist/esm/utils/formatter.mjs.map +1 -1
- package/dist/esm/utils/getChunk.mjs +33 -1
- package/dist/esm/utils/getChunk.mjs.map +1 -1
- package/dist/esm/utils/getContentExtension.mjs +27 -1
- package/dist/esm/utils/getContentExtension.mjs.map +1 -1
- package/dist/esm/utils/getFormatFromExtension.mjs +31 -1
- package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
- package/dist/esm/utils/getPathHash.mjs +7 -1
- package/dist/esm/utils/getPathHash.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +22 -1
- package/dist/esm/utils/mergeChunks.mjs +26 -1
- package/dist/esm/utils/mergeChunks.mjs.map +1 -1
- package/dist/esm/utils/pLimit.mjs +125 -1
- package/dist/esm/utils/pLimit.mjs.map +1 -1
- package/dist/esm/utils/parallelize.mjs +10 -1
- package/dist/esm/utils/parallelize.mjs.map +1 -1
- package/dist/esm/utils/parallelizeGlobal.mjs +26 -1
- package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -1
- package/dist/esm/utils/reduceObjectFormat.mjs +29 -1
- package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -1
- package/dist/esm/utils/resolveObjectPromises.mjs +19 -1
- package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
- package/dist/esm/utils/resolveRelativePath.mjs +19 -1
- package/dist/esm/utils/resolveRelativePath.mjs.map +1 -1
- package/dist/esm/utils/runOnce.mjs +92 -1
- package/dist/esm/utils/runOnce.mjs.map +1 -1
- package/dist/esm/utils/runParallel/bin.mjs +52 -1
- package/dist/esm/utils/runParallel/bin.mjs.map +1 -1
- package/dist/esm/utils/runParallel/bootstrap.mjs +22 -1
- package/dist/esm/utils/runParallel/bootstrap.mjs.map +1 -1
- package/dist/esm/utils/runParallel/index.mjs +113 -1
- package/dist/esm/utils/runParallel/index.mjs.map +1 -1
- package/dist/esm/utils/runParallel/pidTree.mjs +142 -1
- package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
- package/dist/esm/utils/runParallel/ps.mjs +46 -1
- package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
- package/dist/esm/utils/runParallel/runTask.mjs +152 -1
- package/dist/esm/utils/runParallel/runTask.mjs.map +1 -1
- package/dist/esm/utils/runParallel/spawnPosix.mjs +57 -1
- package/dist/esm/utils/runParallel/spawnPosix.mjs.map +1 -1
- package/dist/esm/utils/runParallel/spawnWin32.mjs +41 -1
- package/dist/esm/utils/runParallel/spawnWin32.mjs.map +1 -1
- package/dist/esm/utils/runParallel/wmic.mjs +49 -1
- package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
- package/dist/esm/utils/sortAlphabetically.mjs +5 -1
- package/dist/esm/utils/sortAlphabetically.mjs.map +1 -1
- package/dist/esm/utils/splitTextByLine.mjs +9 -1
- package/dist/esm/utils/splitTextByLine.mjs.map +1 -1
- package/dist/esm/utils/verifyIdenticObjectFormat.mjs +58 -1
- package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -1
- package/dist/esm/watcher.mjs +117 -1
- package/dist/esm/watcher.mjs.map +1 -1
- package/dist/esm/writeConfiguration/index.mjs +39 -1
- package/dist/esm/writeConfiguration/index.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +26 -1
- package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/index.mjs +6 -1
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +91 -1
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs +407 -3
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +124 -2
- package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +146 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs +90 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
- package/dist/esm/writeFileIfChanged.mjs +48 -1
- package/dist/esm/writeFileIfChanged.mjs.map +1 -1
- package/dist/esm/writeJsonIfChanged.mjs +16 -1
- package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
- package/dist/types/build.d.ts +20 -20
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +25 -2
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -0
- package/dist/types/buildIntlayerDictionary/index.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +11 -2
- package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts.map +1 -0
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +49 -2
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -0
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +1 -1
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +30 -2
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -0
- package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +34 -2
- package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts.map +1 -0
- package/dist/types/cli.d.ts +6 -6
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +14 -2
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +10 -2
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +10 -2
- package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +10 -2
- package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +10 -2
- package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +10 -2
- package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +10 -2
- package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/index.d.ts +7 -7
- package/dist/types/createType/createModuleAugmentation.d.ts +9 -2
- package/dist/types/createType/createModuleAugmentation.d.ts.map +1 -0
- package/dist/types/createType/createType.d.ts +12 -2
- package/dist/types/createType/createType.d.ts.map +1 -0
- package/dist/types/createType/index.d.ts +2 -2
- package/dist/types/fetchDistantDictionaries.d.ts +1 -1
- package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts +7 -2
- package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map +1 -0
- package/dist/types/getContentDeclarationFileTemplate/index.d.ts +1 -1
- package/dist/types/loadDictionaries/index.d.ts +4 -4
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +12 -2
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -0
- package/dist/types/loadDictionaries/loadDictionaries.d.ts +23 -2
- package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -0
- package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +8 -2
- package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts.map +1 -0
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +15 -2
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -0
- package/dist/types/loadDictionaries/log.d.ts +1 -1
- package/dist/types/utils/getFormatFromExtension.d.ts +8 -2
- package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/writeConfiguration/index.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts +12 -2
- package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts.map +1 -0
- package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +5 -2
- package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts.map +1 -0
- package/dist/types/writeContentDeclaration/index.d.ts +5 -5
- package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/transformJSFile.d.ts +11 -2
- package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -0
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +19 -2
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -0
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts +14 -2
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -0
- package/package.json +8 -8
- package/dist/cjs/_utils_asset-SJVy1xMD.cjs +0 -2
- package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
- package/dist/esm/_utils_asset-4w8dPH9r.mjs +0 -2
- package/dist/esm/chunk-DDgYwkfe.mjs +0 -1
- package/dist/types/buildIntlayerDictionary-C-LWgPIL.d.ts +0 -25
- package/dist/types/buildIntlayerDictionary-C-LWgPIL.d.ts.map +0 -1
- package/dist/types/createDictionaryEntryPoint-Bc5lHSiY.d.ts +0 -14
- package/dist/types/createDictionaryEntryPoint-Bc5lHSiY.d.ts.map +0 -1
- package/dist/types/createModuleAugmentation-D1eIVnjg.d.ts +0 -9
- package/dist/types/createModuleAugmentation-D1eIVnjg.d.ts.map +0 -1
- package/dist/types/createType--rDwdg2t.d.ts +0 -12
- package/dist/types/createType--rDwdg2t.d.ts.map +0 -1
- package/dist/types/detectExportedComponentName-DVXsp_FG.d.ts +0 -12
- package/dist/types/detectExportedComponentName-DVXsp_FG.d.ts.map +0 -1
- package/dist/types/dictionaryStatus-DPVO37qe.d.ts +0 -5
- package/dist/types/dictionaryStatus-DPVO37qe.d.ts.map +0 -1
- package/dist/types/generateDictionaryListContent-DAtHG6SR.d.ts +0 -10
- package/dist/types/generateDictionaryListContent-DAtHG6SR.d.ts.map +0 -1
- package/dist/types/getBuiltDictionariesPath-C4it65a1.d.ts +0 -10
- package/dist/types/getBuiltDictionariesPath-C4it65a1.d.ts.map +0 -1
- package/dist/types/getBuiltDynamicDictionariesPath-Cj9EWnjT.d.ts +0 -10
- package/dist/types/getBuiltDynamicDictionariesPath-Cj9EWnjT.d.ts.map +0 -1
- package/dist/types/getBuiltFetchDictionariesPath-1JleRhT3.d.ts +0 -10
- package/dist/types/getBuiltFetchDictionariesPath-1JleRhT3.d.ts.map +0 -1
- package/dist/types/getBuiltRemoteDictionariesPath-DHOmqNCr.d.ts +0 -10
- package/dist/types/getBuiltRemoteDictionariesPath-DHOmqNCr.d.ts.map +0 -1
- package/dist/types/getBuiltUnmergedDictionariesPath-GUmmLxTB.d.ts +0 -10
- package/dist/types/getBuiltUnmergedDictionariesPath-GUmmLxTB.d.ts.map +0 -1
- package/dist/types/getContentDeclarationFileTemplate-Dz3rnFy9.d.ts +0 -7
- package/dist/types/getContentDeclarationFileTemplate-Dz3rnFy9.d.ts.map +0 -1
- package/dist/types/getFormatFromExtension-SdXYWfPx.d.ts +0 -8
- package/dist/types/getFormatFromExtension-SdXYWfPx.d.ts.map +0 -1
- package/dist/types/loadContentDeclaration-CBMS4vkA.d.ts +0 -12
- package/dist/types/loadContentDeclaration-CBMS4vkA.d.ts.map +0 -1
- package/dist/types/loadDictionaries-BIqHwtYE.d.ts +0 -23
- package/dist/types/loadDictionaries-BIqHwtYE.d.ts.map +0 -1
- package/dist/types/loadLocalDictionaries-CNmVaw0c.d.ts +0 -8
- package/dist/types/loadLocalDictionaries-CNmVaw0c.d.ts.map +0 -1
- package/dist/types/loadRemoteDictionaries-MoITTb7W.d.ts +0 -15
- package/dist/types/loadRemoteDictionaries-MoITTb7W.d.ts.map +0 -1
- package/dist/types/processContentDeclaration-CAvrHaIT.d.ts +0 -11
- package/dist/types/processContentDeclaration-CAvrHaIT.d.ts.map +0 -1
- package/dist/types/transformJSFile-Cg0LkeLb.d.ts +0 -11
- package/dist/types/transformJSFile-Cg0LkeLb.d.ts.map +0 -1
- package/dist/types/writeContentDeclaration-XdGxj0KP.d.ts +0 -19
- package/dist/types/writeContentDeclaration-XdGxj0KP.d.ts.map +0 -1
- package/dist/types/writeDynamicDictionary-BE0mF2zZ.d.ts +0 -49
- package/dist/types/writeDynamicDictionary-BE0mF2zZ.d.ts.map +0 -1
- package/dist/types/writeJSFile-kK95jzg_.d.ts +0 -14
- package/dist/types/writeJSFile-kK95jzg_.d.ts.map +0 -1
- package/dist/types/writeMergedDictionary-CMeghcRI.d.ts +0 -30
- package/dist/types/writeMergedDictionary-CMeghcRI.d.ts.map +0 -1
- package/dist/types/writeUnmergedDictionary-Cxx51isz.d.ts +0 -34
- package/dist/types/writeUnmergedDictionary-Cxx51isz.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeFetchDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type { LocalizedDictionaryOutput } from './writeDynamicDictionary';\n\nconst LOAD_CONTENT_MODULE = '_loadjson';\n\n/**\n * Generates the content of the shared `loadContent` module for fetch dictionaries.\n * - `configuration` is imported at runtime from \"intlayer\" (liveSyncURL not baked in).\n * - Fallback delegates to the dynamic dictionary's `_loadjson` module.\n * - Locales are baked in so each entry is a static function referencing one locale.\n */\nexport const generateFetchLoadContentModule = (\n format: 'cjs' | 'esm',\n relativePrefix: string,\n locales: string[]\n): string => {\n const sortedLocales = [...locales].sort((a, b) =>\n String(a).localeCompare(String(b))\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const localeEntries = sortedLocales\n .map(\n (locale) =>\n ` '${locale}': async () => {\\n` +\n ` try {\\n` +\n ` const res = await fetch(\\`\\${configuration.editor.liveSyncURL}/dictionaries/\\${key}/${locale}\\`);\\n` +\n ` return await res.json();\\n` +\n ` } catch {\\n` +\n ` return dynContent['${locale}']();\\n` +\n ` }\\n` +\n ` }`\n )\n .join(',\\n');\n\n const body =\n `const loadContent = (key) => {\\n` +\n ` const dynContent = loadContentDyn(key);\\n` +\n ` return {\\n${localeEntries}\\n };\\n` +\n `};\\n`;\n\n if (format === 'esm') {\n return (\n `import { configuration } from 'intlayer';\\n` +\n `import { loadContent as loadContentDyn } from '${relativePrefix}/${LOAD_CONTENT_MODULE}.${extension}';\\n\\n` +\n `${body}\\nexport { loadContent };\\n`\n );\n }\n return (\n `const { configuration } = require('intlayer');\\n` +\n `const { loadContent: loadContentDyn } = require('${relativePrefix}/${LOAD_CONTENT_MODULE}.${extension}');\\n\\n` +\n `${body}\\nmodule.exports = { loadContent };\\n`\n );\n};\n\n/**\n * Generates the content of a fetch dictionary entry point file.\n */\nexport const generateDictionaryEntryPoint = (\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n if (format === 'esm') {\n return (\n `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\\n\\n` +\n `const content = loadContent('${key}');\\n\\n` +\n `export default content;\\n`\n );\n }\n return (\n `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\\n\\n` +\n `module.exports = loadContent('${key}');\\n`\n );\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionary/home.mjs\n * // .intlayer/fetch_dictionary/home.cjs\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir, dynamicDictionariesDir } = configuration.system;\n const { locales } = configuration.internationalization;\n\n // Compute relative path from fetch dir (where _loadjson lives) to dynamic dir\n let relativePrefix = normalizePath(\n relative(fetchDictionariesDir, dynamicDictionariesDir)\n );\n if (!relativePrefix.startsWith('.')) {\n relativePrefix = `./${relativePrefix}`;\n }\n\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n // Write the shared loadContent module once per format\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateFetchLoadContentModule(format, relativePrefix, locales)\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(Object.entries(dynamicDictionaries), async ([key]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(key, format);\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n });\n\n return resultDictionariesPaths;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"writeFetchDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type { LocalizedDictionaryOutput } from './writeDynamicDictionary';\n\nconst LOAD_CONTENT_MODULE = '_loadjson';\n\n/**\n * Generates the content of the shared `loadContent` module for fetch dictionaries.\n * - `configuration` is imported at runtime from \"intlayer\" (liveSyncURL not baked in).\n * - Fallback delegates to the dynamic dictionary's `_loadjson` module.\n * - Locales are baked in so each entry is a static function referencing one locale.\n */\nexport const generateFetchLoadContentModule = (\n format: 'cjs' | 'esm',\n relativePrefix: string,\n locales: string[]\n): string => {\n const sortedLocales = [...locales].sort((a, b) =>\n String(a).localeCompare(String(b))\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const localeEntries = sortedLocales\n .map(\n (locale) =>\n ` '${locale}': async () => {\\n` +\n ` try {\\n` +\n ` const res = await fetch(\\`\\${configuration.editor.liveSyncURL}/dictionaries/\\${key}/${locale}\\`);\\n` +\n ` return await res.json();\\n` +\n ` } catch {\\n` +\n ` return dynContent['${locale}']();\\n` +\n ` }\\n` +\n ` }`\n )\n .join(',\\n');\n\n const body =\n `const loadContent = (key) => {\\n` +\n ` const dynContent = loadContentDyn(key);\\n` +\n ` return {\\n${localeEntries}\\n };\\n` +\n `};\\n`;\n\n if (format === 'esm') {\n return (\n `import { configuration } from 'intlayer';\\n` +\n `import { loadContent as loadContentDyn } from '${relativePrefix}/${LOAD_CONTENT_MODULE}.${extension}';\\n\\n` +\n `${body}\\nexport { loadContent };\\n`\n );\n }\n return (\n `const { configuration } = require('intlayer');\\n` +\n `const { loadContent: loadContentDyn } = require('${relativePrefix}/${LOAD_CONTENT_MODULE}.${extension}');\\n\\n` +\n `${body}\\nmodule.exports = { loadContent };\\n`\n );\n};\n\n/**\n * Generates the content of a fetch dictionary entry point file.\n */\nexport const generateDictionaryEntryPoint = (\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n if (format === 'esm') {\n return (\n `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\\n\\n` +\n `const content = loadContent('${key}');\\n\\n` +\n `export default content;\\n`\n );\n }\n return (\n `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\\n\\n` +\n `module.exports = loadContent('${key}');\\n`\n );\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionary/home.mjs\n * // .intlayer/fetch_dictionary/home.cjs\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir, dynamicDictionariesDir } = configuration.system;\n const { locales } = configuration.internationalization;\n\n // Compute relative path from fetch dir (where _loadjson lives) to dynamic dir\n let relativePrefix = normalizePath(\n relative(fetchDictionariesDir, dynamicDictionariesDir)\n );\n if (!relativePrefix.startsWith('.')) {\n relativePrefix = `./${relativePrefix}`;\n }\n\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n // Write the shared loadContent module once per format\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateFetchLoadContentModule(format, relativePrefix, locales)\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(Object.entries(dynamicDictionaries), async ([key]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(key, format);\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n });\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;AAUA,MAAM,sBAAsB;;;;;;;AAQ5B,MAAa,kCACX,QACA,gBACA,YACW;CACX,MAAM,gBAAgB,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,MAC1C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC;CACD,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAgB7C,MAAM,OACJ;;cAfoB,cACnB,KACE,WACC,MAAM,OAAO,yHAEgF,OAAO,gFAGxE,OAAO,mBAGtC,CACA,KAAK,MAAM,CAKiB;AAG/B,KAAI,WAAW,MACb,QACE,6FACkD,eAAe,GAAG,oBAAoB,GAAG,UAAU,QAClG,KAAK;AAGZ,QACE,oGACoD,eAAe,GAAG,oBAAoB,GAAG,UAAU,SACpG,KAAK;;;;;AAOZ,MAAa,gCACX,KACA,SAAwB,UACb;CACX,MAAM,YAAY,WAAW,QAAQ,QAAQ;AAC7C,KAAI,WAAW,MACb,QACE,kCAAkC,oBAAoB,GAAG,UAAU,qCACnC,IAAI;AAIxC,QACE,sCAAsC,oBAAoB,GAAG,UAAU,uCACtC,IAAI;;;;;;;;;;;;;;;;;;AAoBzC,MAAa,uBAAuB,OAClC,qBACA,eACA,UAA6B,kBACU;CACvC,MAAM,EAAE,sBAAsB,2BAA2B,cAAc;CACvE,MAAM,EAAE,YAAY,cAAc;CAGlC,IAAI,iBAAiB,cACnB,SAAS,sBAAsB,uBAAuB,CACvD;AACD,KAAI,CAAC,eAAe,WAAW,IAAI,CACjC,kBAAiB,KAAK;AAGxB,OAAM,MAAM,QAAQ,qBAAqB,EAAE,EAAE,WAAW,MAAM,CAAC;AAG/D,OAAM,YAAY,SAAS,OAAO,WAAW;EAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;AAC7C,QAAM,mBACJ,QAAQ,sBAAsB,GAAG,oBAAoB,GAAG,YAAY,EACpE,+BAA+B,QAAQ,gBAAgB,QAAQ,CAChE,CAAC,OAAO,QAAQ;AACf,WAAQ,MACN,wBAAwB,aAAa,QAAQ,sBAAsB,GAAG,oBAAoB,GAAG,YAAY,CAAC,CAAC,IAC3G,IACD;IACD;GACF;CAEF,MAAM,0BAAqD,EAAE;AAG7D,OAAM,YAAY,OAAO,QAAQ,oBAAoB,EAAE,OAAO,CAAC,SAAS;AACtE,MAAI,QAAQ,YAAa;AAEzB,QAAM,YAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;GAC7C,MAAM,UAAU,6BAA6B,KAAK,OAAO;AAEzD,SAAM,mBACJ,QAAQ,sBAAsB,GAAG,IAAI,GAAG,YAAY,EACpD,QACD,CAAC,OAAO,QAAQ;AACf,YAAQ,MACN,wBAAwB,aAAa,QAAQ,sBAAsB,GAAG,IAAI,GAAG,YAAY,CAAC,CAAC,IAC3F,IACD;KACD;IACF;GACF;AAEF,QAAO"}
|
|
@@ -1,2 +1,45 @@
|
|
|
1
|
-
import{parallelize
|
|
1
|
+
import { parallelize } from "../utils/parallelize.mjs";
|
|
2
|
+
import { writeJsonIfChanged } from "../writeJsonIfChanged.mjs";
|
|
3
|
+
import { mkdir } from "node:fs/promises";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import { colorizePath } from "@intlayer/config/logger";
|
|
6
|
+
import { mergeDictionaries, normalizeDictionaries } from "@intlayer/core/dictionaryManipulator";
|
|
7
|
+
|
|
8
|
+
//#region src/buildIntlayerDictionary/writeMergedDictionary.ts
|
|
9
|
+
/**
|
|
10
|
+
* Write the merged dictionaries to the dictionariesDir
|
|
11
|
+
* @param groupedDictionaries - The grouped dictionaries
|
|
12
|
+
* @param configuration - The configuration
|
|
13
|
+
* @returns The merged dictionaries
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
18
|
+
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
19
|
+
* console.log(finalDictionaries);
|
|
20
|
+
*
|
|
21
|
+
* // .intlayer/dictionary/home.json
|
|
22
|
+
* // { key: 'home', content: { ... } },
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
const writeMergedDictionaries = async (groupedDictionaries, configuration) => {
|
|
26
|
+
const { dictionariesDir } = configuration.system;
|
|
27
|
+
await mkdir(resolve(dictionariesDir), { recursive: true });
|
|
28
|
+
const results = await parallelize(Object.entries(groupedDictionaries), async ([key, dictionariesEntry]) => {
|
|
29
|
+
if (key === "undefined") return;
|
|
30
|
+
const mergedDictionary = mergeDictionaries(normalizeDictionaries(dictionariesEntry.dictionaries, configuration));
|
|
31
|
+
const resultFilePath = resolve(dictionariesDir, `${key}.json`);
|
|
32
|
+
await writeJsonIfChanged(resultFilePath, mergedDictionary).catch((err) => {
|
|
33
|
+
console.error(`Error creating merged ${colorizePath(resultFilePath)}:`, err);
|
|
34
|
+
});
|
|
35
|
+
return [key, {
|
|
36
|
+
dictionaryPath: resultFilePath,
|
|
37
|
+
dictionary: mergedDictionary
|
|
38
|
+
}];
|
|
39
|
+
});
|
|
40
|
+
return Object.fromEntries(results.filter(Boolean));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { writeMergedDictionaries };
|
|
2
45
|
//# sourceMappingURL=writeMergedDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeMergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport {\n mergeDictionaries,\n normalizeDictionaries,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionary/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration: IntlayerConfig\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionariesEntry]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n MergedDictionaryResult,\n ];\n }\n\n const normalizedDictionaries = normalizeDictionaries(\n dictionariesEntry.dictionaries,\n configuration\n );\n\n const mergedDictionary = mergeDictionaries(normalizedDictionaries);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"writeMergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport {\n mergeDictionaries,\n normalizeDictionaries,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionary/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration: IntlayerConfig\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionariesEntry]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n MergedDictionaryResult,\n ];\n }\n\n const normalizedDictionaries = normalizeDictionaries(\n dictionariesEntry.dictionaries,\n configuration\n );\n\n const mergedDictionary = mergeDictionaries(normalizedDictionaries);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,0BAA0B,OACrC,qBACA,kBACoC;CACpC,MAAM,EAAE,oBAAoB,cAAc;AAG1C,OAAM,MAAM,QAAQ,gBAAgB,EAAE,EAAE,WAAW,MAAM,CAAC;CAE1D,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,uBAAuB;AAClC,MAAI,QAAQ,YACV;EAWF,MAAM,mBAAmB,kBALM,sBAC7B,kBAAkB,cAClB,cACD,CAEiE;EAGlE,MAAM,iBAAiB,QAAQ,iBADR,GAAG,IAAI,OACiC;AAG/D,QAAM,mBAAmB,gBAAgB,iBAAiB,CAAC,OACxD,QAAQ;AACP,WAAQ,MACN,yBAAyB,aAAa,eAAe,CAAC,IACtD,IACD;IAEJ;AAED,SAAO,CACL,KACA;GACE,gBAAgB;GAChB,YAAY;GACb,CACF;GAEJ;AAED,QAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CACxB"}
|
|
@@ -1,2 +1,49 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { parallelize } from "../utils/parallelize.mjs";
|
|
2
|
+
import { writeJsonIfChanged } from "../writeJsonIfChanged.mjs";
|
|
3
|
+
import { filterInvalidDictionaries } from "../filterInvalidDictionaries.mjs";
|
|
4
|
+
import { groupDictionariesByKey } from "./writeUnmergedDictionary.mjs";
|
|
5
|
+
import { formatDistantDictionaries } from "../loadDictionaries/loadRemoteDictionaries.mjs";
|
|
6
|
+
import { mkdir } from "node:fs/promises";
|
|
7
|
+
import { resolve } from "node:path";
|
|
8
|
+
import { colorizePath, x } from "@intlayer/config/logger";
|
|
9
|
+
import { orderDictionaries } from "@intlayer/core/dictionaryManipulator";
|
|
10
|
+
|
|
11
|
+
//#region src/buildIntlayerDictionary/writeRemoteDictionary.ts
|
|
12
|
+
/**
|
|
13
|
+
* Write the localized dictionaries to the dictionariesDir
|
|
14
|
+
* @param mergedDictionaries - The merged dictionaries
|
|
15
|
+
* @param configuration - The configuration
|
|
16
|
+
* @returns The final dictionaries
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
21
|
+
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
22
|
+
* console.log(finalDictionaries);
|
|
23
|
+
*
|
|
24
|
+
* // .intlayer/fetch_dictionaries/home.json
|
|
25
|
+
* // { key: 'home', content: { ... } },
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
const writeRemoteDictionary = async (remoteDictionaries, configuration) => {
|
|
29
|
+
const { remoteDictionariesDir } = configuration.system;
|
|
30
|
+
await mkdir(resolve(remoteDictionariesDir), { recursive: true });
|
|
31
|
+
const groupedDictionaries = groupDictionariesByKey(filterInvalidDictionaries(remoteDictionaries, configuration));
|
|
32
|
+
const results = await parallelize(Object.entries(groupedDictionaries), async ([key, dictionaries]) => {
|
|
33
|
+
if (key === "undefined") return;
|
|
34
|
+
const orderedDictionaries = orderDictionaries(formatDistantDictionaries(dictionaries), configuration);
|
|
35
|
+
const unmergedFilePath = resolve(remoteDictionariesDir, `${key}.json`);
|
|
36
|
+
await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch((err) => {
|
|
37
|
+
console.error(`${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`, err);
|
|
38
|
+
});
|
|
39
|
+
return [key, {
|
|
40
|
+
dictionaryPath: unmergedFilePath,
|
|
41
|
+
dictionaries
|
|
42
|
+
}];
|
|
43
|
+
});
|
|
44
|
+
return Object.fromEntries(results.filter(Boolean));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { writeRemoteDictionary };
|
|
2
49
|
//# sourceMappingURL=writeRemoteDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeRemoteDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDistantDictionaries } from '../loadDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport {\n groupDictionariesByKey,\n type UnmergedDictionaryResult,\n} from './writeUnmergedDictionary';\n\nexport type RemoteDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type RemoteDictionaryOutput = Record<string, RemoteDictionaryResult>;\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeRemoteDictionary = async (\n remoteDictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Promise<RemoteDictionaryOutput> => {\n const { remoteDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(remoteDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(\n remoteDictionaries,\n configuration\n );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n // Merge dictionaries with the same key and write to dictionariesDir\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const formattedDictionaries = formatDistantDictionaries(dictionaries);\n\n const orderedDictionaries = orderDictionaries(\n formattedDictionaries,\n configuration\n );\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(remoteDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"writeRemoteDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDistantDictionaries } from '../loadDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport {\n groupDictionariesByKey,\n type UnmergedDictionaryResult,\n} from './writeUnmergedDictionary';\n\nexport type RemoteDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type RemoteDictionaryOutput = Record<string, RemoteDictionaryResult>;\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeRemoteDictionary = async (\n remoteDictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Promise<RemoteDictionaryOutput> => {\n const { remoteDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(remoteDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(\n remoteDictionaries,\n configuration\n );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n // Merge dictionaries with the same key and write to dictionariesDir\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const formattedDictionaries = formatDistantDictionaries(dictionaries);\n\n const orderedDictionaries = orderDictionaries(\n formattedDictionaries,\n configuration\n );\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(remoteDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,wBAAwB,OACnC,oBACA,kBACoC;CACpC,MAAM,EAAE,0BAA0B,cAAc;AAGhD,OAAM,MAAM,QAAQ,sBAAsB,EAAE,EAAE,WAAW,MAAM,CAAC;CAQhE,MAAM,sBAAsB,uBANC,0BAC3B,oBACA,cACD,CAGuE;CAGxE,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,kBAAkB;AAC7B,MAAI,QAAQ,YACV;EAQF,MAAM,sBAAsB,kBAFE,0BAA0B,aAAa,EAInE,cACD;EAGD,MAAM,mBAAmB,QAAQ,uBADV,GAAG,IAAI,OACyC;AAGvE,QAAM,mBAAmB,kBAAkB,oBAAoB,CAAC,OAC7D,QAAQ;AACP,WAAQ,MACN,GAAG,EAAE,2BAA2B,aAAa,iBAAiB,CAAC,IAC/D,IACD;IAEJ;AAED,SAAO,CACL,KACA;GACE,gBAAgB;GAChB;GACD,CACF;GAEJ;AAED,QAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CAGxB"}
|
|
@@ -1,2 +1,57 @@
|
|
|
1
|
-
import{parallelize
|
|
1
|
+
import { parallelize } from "../utils/parallelize.mjs";
|
|
2
|
+
import { writeJsonIfChanged } from "../writeJsonIfChanged.mjs";
|
|
3
|
+
import { filterInvalidDictionaries } from "../filterInvalidDictionaries.mjs";
|
|
4
|
+
import { mkdir } from "node:fs/promises";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
import { colorizePath, x } from "@intlayer/config/logger";
|
|
7
|
+
import { orderDictionaries } from "@intlayer/core/dictionaryManipulator";
|
|
8
|
+
|
|
9
|
+
//#region src/buildIntlayerDictionary/writeUnmergedDictionary.ts
|
|
10
|
+
const groupDictionariesByKey = (dictionaries) => dictionaries.reduce((acc, dictionary) => {
|
|
11
|
+
const key = dictionary.key;
|
|
12
|
+
if (!acc[key]) acc[key] = [];
|
|
13
|
+
acc[key].push(dictionary);
|
|
14
|
+
return acc;
|
|
15
|
+
}, {});
|
|
16
|
+
/**
|
|
17
|
+
* Write the unmerged dictionaries to the unmergedDictionariesDir
|
|
18
|
+
* @param dictionaries - The dictionaries to write
|
|
19
|
+
* @param configuration - The configuration
|
|
20
|
+
* @returns The grouped dictionaries
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
25
|
+
* console.log(unmergedDictionaries);
|
|
26
|
+
*
|
|
27
|
+
* // .intlayer/unmerged_dictionaries/home.json
|
|
28
|
+
* // {
|
|
29
|
+
* // [
|
|
30
|
+
* // { key: 'home', content: { ... } },
|
|
31
|
+
* // { key: 'home', content: { ... } },
|
|
32
|
+
* // ],
|
|
33
|
+
* // }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
const writeUnmergedDictionaries = async (dictionaries, configuration, env) => {
|
|
37
|
+
const { unmergedDictionariesDir } = configuration.system;
|
|
38
|
+
await mkdir(resolve(unmergedDictionariesDir), { recursive: true });
|
|
39
|
+
const groupedDictionaries = groupDictionariesByKey(filterInvalidDictionaries(dictionaries, configuration, { checkSchema: true }));
|
|
40
|
+
const results = await parallelize(Object.entries(groupedDictionaries), async ([key, dictionaries]) => {
|
|
41
|
+
if (key === "undefined") return;
|
|
42
|
+
const orderedDictionaries = orderDictionaries(dictionaries, configuration);
|
|
43
|
+
const unmergedFilePath = resolve(unmergedDictionariesDir, `${key}.json`);
|
|
44
|
+
if (configuration.editor.enabled || env === "dev") await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch((err) => {
|
|
45
|
+
console.error(`${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`, err);
|
|
46
|
+
});
|
|
47
|
+
return [key, {
|
|
48
|
+
dictionaryPath: unmergedFilePath,
|
|
49
|
+
dictionaries
|
|
50
|
+
}];
|
|
51
|
+
});
|
|
52
|
+
return Object.fromEntries(results.filter(Boolean));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { groupDictionariesByKey, writeUnmergedDictionaries };
|
|
2
57
|
//# sourceMappingURL=writeUnmergedDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeUnmergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeUnmergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary, DictionaryKey } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\nexport const groupDictionariesByKey = (\n dictionaries: Dictionary[]\n): Record<string, Dictionary[]> =>\n dictionaries.reduce(\n (acc, dictionary) => {\n const key = dictionary.key;\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(dictionary);\n return acc;\n },\n {} as Record<string, Dictionary[]>\n );\n\nexport type UnmergedDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type UnmergedDictionaryOutput = Record<\n DictionaryKey,\n UnmergedDictionaryResult\n>;\n\n/**\n * Write the unmerged dictionaries to the unmergedDictionariesDir\n * @param dictionaries - The dictionaries to write\n * @param configuration - The configuration\n * @returns The grouped dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * console.log(unmergedDictionaries);\n *\n * // .intlayer/unmerged_dictionaries/home.json\n * // {\n * // [\n * // { key: 'home', content: { ... } },\n * // { key: 'home', content: { ... } },\n * // ],\n * // }\n * ```\n */\nexport const writeUnmergedDictionaries = async (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig,\n env: 'prod' | 'dev'\n): Promise<UnmergedDictionaryOutput> => {\n const { unmergedDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(unmergedDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(\n dictionaries,\n configuration,\n { checkSchema: true }\n );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const orderedDictionaries = orderDictionaries(\n dictionaries,\n configuration\n );\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries in disk if the editor is enabled\n // To make work the visual editor on the server\n // No need them if the editor is disabled\n // But in local env (env: 'dev') we write them for the vscode extension\n if (configuration.editor.enabled || env === 'dev') {\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n }\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries: dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"writeUnmergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeUnmergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary, DictionaryKey } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\nexport const groupDictionariesByKey = (\n dictionaries: Dictionary[]\n): Record<string, Dictionary[]> =>\n dictionaries.reduce(\n (acc, dictionary) => {\n const key = dictionary.key;\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(dictionary);\n return acc;\n },\n {} as Record<string, Dictionary[]>\n );\n\nexport type UnmergedDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type UnmergedDictionaryOutput = Record<\n DictionaryKey,\n UnmergedDictionaryResult\n>;\n\n/**\n * Write the unmerged dictionaries to the unmergedDictionariesDir\n * @param dictionaries - The dictionaries to write\n * @param configuration - The configuration\n * @returns The grouped dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * console.log(unmergedDictionaries);\n *\n * // .intlayer/unmerged_dictionaries/home.json\n * // {\n * // [\n * // { key: 'home', content: { ... } },\n * // { key: 'home', content: { ... } },\n * // ],\n * // }\n * ```\n */\nexport const writeUnmergedDictionaries = async (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig,\n env: 'prod' | 'dev'\n): Promise<UnmergedDictionaryOutput> => {\n const { unmergedDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(unmergedDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(\n dictionaries,\n configuration,\n { checkSchema: true }\n );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const orderedDictionaries = orderDictionaries(\n dictionaries,\n configuration\n );\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries in disk if the editor is enabled\n // To make work the visual editor on the server\n // No need them if the editor is disabled\n // But in local env (env: 'dev') we write them for the vscode extension\n if (configuration.editor.enabled || env === 'dev') {\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n }\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries: dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":";;;;;;;;;AAUA,MAAa,0BACX,iBAEA,aAAa,QACV,KAAK,eAAe;CACnB,MAAM,MAAM,WAAW;AACvB,KAAI,CAAC,IAAI,KACP,KAAI,OAAO,EAAE;AAEf,KAAI,KAAK,KAAK,WAAW;AACzB,QAAO;GAET,EAAE,CACH;;;;;;;;;;;;;;;;;;;;;AAgCH,MAAa,4BAA4B,OACvC,cACA,eACA,QACsC;CACtC,MAAM,EAAE,4BAA4B,cAAc;AAGlD,OAAM,MAAM,QAAQ,wBAAwB,EAAE,EAAE,WAAW,MAAM,CAAC;CASlE,MAAM,sBAAsB,uBAPC,0BAC3B,cACA,eACA,EAAE,aAAa,MAAM,CACtB,CAGuE;CAExE,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,kBAAkB;AAC7B,MAAI,QAAQ,YACV;EAMF,MAAM,sBAAsB,kBAC1B,cACA,cACD;EAGD,MAAM,mBAAmB,QAAQ,yBADV,GAAG,IAAI,OAC2C;AAMzE,MAAI,cAAc,OAAO,WAAW,QAAQ,MAC1C,OAAM,mBAAmB,kBAAkB,oBAAoB,CAAC,OAC7D,QAAQ;AACP,WAAQ,MACN,GAAG,EAAE,2BAA2B,aAAa,iBAAiB,CAAC,IAC/D,IACD;IAEJ;AAGH,SAAO,CACL,KACA;GACE,gBAAgB;GACF;GACf,CACF;GAEJ;AAED,QAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CAGxB"}
|
|
@@ -1,2 +1,29 @@
|
|
|
1
|
-
import{rm
|
|
1
|
+
import { rm } from "node:fs/promises";
|
|
2
|
+
import { getAppLogger } from "@intlayer/config/logger";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
|
|
5
|
+
//#region src/cleanOutputDir.ts
|
|
6
|
+
const cleanOutputDir = async (configuration) => {
|
|
7
|
+
const { dictionariesDir, unmergedDictionariesDir, dynamicDictionariesDir, remoteDictionariesDir, fetchDictionariesDir, mainDir, typesDir, configDir, cacheDir } = configuration.system;
|
|
8
|
+
const appLogger = getAppLogger(configuration);
|
|
9
|
+
const directoriesToClean = [
|
|
10
|
+
dictionariesDir,
|
|
11
|
+
unmergedDictionariesDir,
|
|
12
|
+
dynamicDictionariesDir,
|
|
13
|
+
remoteDictionariesDir,
|
|
14
|
+
fetchDictionariesDir,
|
|
15
|
+
mainDir,
|
|
16
|
+
typesDir,
|
|
17
|
+
configDir,
|
|
18
|
+
cacheDir
|
|
19
|
+
];
|
|
20
|
+
await Promise.all(directoriesToClean.filter((dir) => existsSync(dir)).map((dir) => rm(dir, {
|
|
21
|
+
recursive: true,
|
|
22
|
+
force: true
|
|
23
|
+
})));
|
|
24
|
+
appLogger("Output directory cleaned", { isVerbose: true });
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { cleanOutputDir };
|
|
2
29
|
//# sourceMappingURL=cleanOutputDir.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanOutputDir.mjs","names":[],"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\nexport const cleanOutputDir = async (configuration: IntlayerConfig) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n remoteDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n cacheDir,\n } = configuration.system;\n\n const appLogger = getAppLogger(configuration);\n\n const directoriesToClean: string[] = [\n dictionariesDir, // Merged dictionaries\n unmergedDictionariesDir, // Unmerged dictionaries\n dynamicDictionariesDir, // Dynamic dictionaries\n remoteDictionariesDir, // Remote dictionaries\n fetchDictionariesDir, // Fetch dictionaries\n mainDir, // Main files\n typesDir, // Types\n configDir, // Configuration\n cacheDir, // Cache\n ];\n\n // Execute all deletions in parallel\n await Promise.all(\n directoriesToClean\n .filter((dir) => existsSync(dir))\n .map((dir) => rm(dir, { recursive: true, force: true }))\n );\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"cleanOutputDir.mjs","names":[],"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\nexport const cleanOutputDir = async (configuration: IntlayerConfig) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n remoteDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n cacheDir,\n } = configuration.system;\n\n const appLogger = getAppLogger(configuration);\n\n const directoriesToClean: string[] = [\n dictionariesDir, // Merged dictionaries\n unmergedDictionariesDir, // Unmerged dictionaries\n dynamicDictionariesDir, // Dynamic dictionaries\n remoteDictionariesDir, // Remote dictionaries\n fetchDictionariesDir, // Fetch dictionaries\n mainDir, // Main files\n typesDir, // Types\n configDir, // Configuration\n cacheDir, // Cache\n ];\n\n // Execute all deletions in parallel\n await Promise.all(\n directoriesToClean\n .filter((dir) => existsSync(dir))\n .map((dir) => rm(dir, { recursive: true, force: true }))\n );\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;AAKA,MAAa,iBAAiB,OAAO,kBAAkC;CACrE,MAAM,EACJ,iBACA,yBACA,wBACA,uBACA,sBACA,SACA,UACA,WACA,aACE,cAAc;CAElB,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,qBAA+B;EACnC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;AAGD,OAAM,QAAQ,IACZ,mBACG,QAAQ,QAAQ,WAAW,IAAI,CAAC,CAChC,KAAK,QAAQ,GAAG,KAAK;EAAE,WAAW;EAAM,OAAO;EAAM,CAAC,CAAC,CAC3D;AAED,WAAU,4BAA4B,EACpC,WAAW,MACZ,CAAC"}
|
|
@@ -1,2 +1,95 @@
|
|
|
1
|
-
import{createDictionaryEntryPoint
|
|
1
|
+
import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";
|
|
2
|
+
import { writeJsonIfChanged } from "./writeJsonIfChanged.mjs";
|
|
3
|
+
import { readFile, rm } from "node:fs/promises";
|
|
4
|
+
import { join, normalize, relative } from "node:path";
|
|
5
|
+
import { normalizePath } from "@intlayer/config/client";
|
|
6
|
+
import { colorizeKey, colorizePath, getAppLogger } from "@intlayer/config/logger";
|
|
7
|
+
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
8
|
+
import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
|
|
9
|
+
import fg from "fast-glob";
|
|
10
|
+
|
|
11
|
+
//#region src/cleanRemovedContentDeclaration.ts
|
|
12
|
+
const cleanRemovedContentDeclaration = async (filePath, keysToKeep, configuration) => {
|
|
13
|
+
const appLogger = getAppLogger(configuration);
|
|
14
|
+
const unmergedDictionaries = getUnmergedDictionaries(configuration);
|
|
15
|
+
const baseDir = configuration.system.baseDir;
|
|
16
|
+
const relativeFilePath = relative(baseDir, filePath);
|
|
17
|
+
const uniqueUnmergedDictionaries = Object.values(unmergedDictionaries).flat().filter((dictionary) => dictionary.filePath === relativeFilePath && !keysToKeep.includes(dictionary.key)).filter((dictionary, index, self) => index === self.findIndex((t) => t.key === dictionary.key));
|
|
18
|
+
const changedDictionariesLocalIds = [];
|
|
19
|
+
const filesToRemove = [];
|
|
20
|
+
const excludeKeys = [];
|
|
21
|
+
await Promise.all(uniqueUnmergedDictionaries.map(async (dictionary) => {
|
|
22
|
+
const unmergedFilePath = normalize(join(configuration.system.unmergedDictionariesDir, `${dictionary.key}.json`));
|
|
23
|
+
try {
|
|
24
|
+
const jsonContent = await readFile(unmergedFilePath, "utf8");
|
|
25
|
+
const parsedContent = JSON.parse(jsonContent);
|
|
26
|
+
if (parsedContent.length === 1) {
|
|
27
|
+
if (parsedContent[0].filePath === relativeFilePath) {
|
|
28
|
+
appLogger(`Removing outdated dictionary ${colorizeKey(dictionary.key)}`, { isVerbose: true });
|
|
29
|
+
filesToRemove.push(unmergedFilePath);
|
|
30
|
+
excludeKeys.push(dictionary.key);
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
await writeJsonIfChanged(unmergedFilePath, parsedContent.filter((content) => content.filePath !== relativeFilePath));
|
|
34
|
+
changedDictionariesLocalIds.push(dictionary.localId);
|
|
35
|
+
}
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (error.code === "ENOENT") {
|
|
38
|
+
if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
42
|
+
const dictionaries = getDictionaries(configuration);
|
|
43
|
+
const uniqueMergedDictionaries = (Object.values(dictionaries)?.filter((dictionary) => !keysToKeep.includes(dictionary.key) && dictionary.localIds?.length === 1 && dictionary.localIds[0].endsWith(`::local::${relativeFilePath}`))).filter((dictionary, index, self) => index === self.findIndex((t) => t.key === dictionary.key));
|
|
44
|
+
await Promise.all(uniqueMergedDictionaries.map(async (dictionary) => {
|
|
45
|
+
const mergedFilePath = normalize(join(configuration.system.dictionariesDir, `${dictionary.key}.json`));
|
|
46
|
+
try {
|
|
47
|
+
const fileContent = await readFile(mergedFilePath, "utf8");
|
|
48
|
+
const parsedContent = JSON.parse(fileContent);
|
|
49
|
+
if (parsedContent.localIds?.length === 1) {
|
|
50
|
+
if (parsedContent.localIds[0].endsWith(`::local::${relativeFilePath}`)) {
|
|
51
|
+
appLogger(`Removing outdated unmerged dictionary ${colorizeKey(dictionary.key)}`, { isVerbose: true });
|
|
52
|
+
filesToRemove.push(mergedFilePath);
|
|
53
|
+
const typesFilePath = normalize(join(configuration.system.typesDir, `${dictionary.key}.ts`));
|
|
54
|
+
filesToRemove.push(typesFilePath);
|
|
55
|
+
const dynamicFiles = await fg(normalizePath(join(configuration.system.dynamicDictionariesDir, `${dictionary.key}.*`)), { absolute: true });
|
|
56
|
+
filesToRemove.push(...dynamicFiles);
|
|
57
|
+
if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
const localIds = parsedContent.localIds?.filter((localeId) => !localeId.endsWith(`::local::${relativeFilePath}`));
|
|
61
|
+
await writeJsonIfChanged(mergedFilePath, {
|
|
62
|
+
...parsedContent,
|
|
63
|
+
localIds
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (error.code === "ENOENT") {
|
|
68
|
+
if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
|
|
69
|
+
const typesFilePath = normalize(join(configuration.system.typesDir, `${dictionary.key}.ts`));
|
|
70
|
+
filesToRemove.push(typesFilePath);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
if (filesToRemove.length > 0 || excludeKeys.length > 0) {
|
|
75
|
+
await createDictionaryEntryPoint(configuration, { excludeKeys });
|
|
76
|
+
if (filesToRemove.length > 0) await Promise.all(filesToRemove.map(async (path) => {
|
|
77
|
+
const relativePath = relative(baseDir, path);
|
|
78
|
+
try {
|
|
79
|
+
await rm(path, { force: true });
|
|
80
|
+
appLogger(`Deleted artifact: ${colorizePath(relativePath)}`, { isVerbose: true });
|
|
81
|
+
} catch {
|
|
82
|
+
appLogger(`Error while removing file ${colorizePath(relativePath)}`, { isVerbose: true });
|
|
83
|
+
}
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
changedDictionariesLocalIds,
|
|
88
|
+
excludeKeys,
|
|
89
|
+
hasRebuilt: filesToRemove.length > 0 || excludeKeys.length > 0
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { cleanRemovedContentDeclaration };
|
|
2
95
|
//# sourceMappingURL=cleanRemovedContentDeclaration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanRemovedContentDeclaration.mjs","names":[],"sources":["../../src/cleanRemovedContentDeclaration.ts"],"sourcesContent":["import { readFile, rm } from 'node:fs/promises';\nimport { join, normalize, relative } from 'node:path';\nimport { normalizePath } from '@intlayer/config/client';\nimport {\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport fg from 'fast-glob';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint';\nimport { writeJsonIfChanged } from './writeJsonIfChanged';\n\nexport const cleanRemovedContentDeclaration = async (\n filePath: string,\n keysToKeep: string[],\n configuration: IntlayerConfig\n): Promise<{\n changedDictionariesLocalIds: string[];\n excludeKeys: string[];\n hasRebuilt: boolean;\n}> => {\n const appLogger = getAppLogger(configuration);\n\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n const baseDir = configuration.system.baseDir;\n\n const relativeFilePath = relative(baseDir, filePath);\n const flatUnmergedDictionaries = Object.values(unmergedDictionaries).flat();\n\n const filteredUnmergedDictionaries = flatUnmergedDictionaries.filter(\n (dictionary) =>\n dictionary.filePath === relativeFilePath &&\n !keysToKeep.includes(dictionary.key)\n );\n\n // Deduplicate dictionaries by key\n const uniqueUnmergedDictionaries = filteredUnmergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n const changedDictionariesLocalIds: string[] = [];\n const filesToRemove: string[] = [];\n const excludeKeys: string[] = [];\n\n // Identify Unmerged Dictionaries to remove or clean\n await Promise.all(\n uniqueUnmergedDictionaries.map(async (dictionary) => {\n const unmergedFilePath = normalize(\n join(\n configuration.system.unmergedDictionariesDir,\n `${dictionary.key}.json`\n )\n );\n\n try {\n const jsonContent = await readFile(unmergedFilePath, 'utf8');\n const parsedContent = JSON.parse(jsonContent);\n\n if (parsedContent.length === 1) {\n if (parsedContent[0].filePath === relativeFilePath) {\n appLogger(\n `Removing outdated dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n filesToRemove.push(unmergedFilePath);\n excludeKeys.push(dictionary.key);\n }\n } else {\n const filteredContent = parsedContent.filter(\n (content: any) => content.filePath !== relativeFilePath\n );\n await writeJsonIfChanged(unmergedFilePath, filteredContent);\n changedDictionariesLocalIds.push(dictionary.localId!);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n }\n })\n );\n\n const dictionaries = getDictionaries(configuration);\n const flatDictionaries = Object.values(dictionaries) as Dictionary[];\n\n const filteredMergedDictionaries = flatDictionaries?.filter(\n (dictionary) =>\n !keysToKeep.includes(dictionary.key) &&\n dictionary.localIds?.length === 1 &&\n (dictionary.localIds[0] as string).endsWith(\n `::local::${relativeFilePath}`\n )\n );\n\n const uniqueMergedDictionaries = filteredMergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n // Identify Merged Dictionaries, Types, and Dynamic Dictionaries to remove\n await Promise.all(\n uniqueMergedDictionaries.map(async (dictionary) => {\n const mergedFilePath = normalize(\n join(configuration.system.dictionariesDir, `${dictionary.key}.json`)\n );\n\n try {\n const fileContent = await readFile(mergedFilePath, 'utf8');\n const parsedContent = JSON.parse(fileContent) as Dictionary;\n\n if (parsedContent.localIds?.length === 1) {\n if (\n parsedContent.localIds[0].endsWith(`::local::${relativeFilePath}`)\n ) {\n appLogger(\n `Removing outdated unmerged dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n\n // Mark JSON for removal\n filesToRemove.push(mergedFilePath);\n\n // Mark TS Types for removal\n const typesFilePath = normalize(\n join(configuration.system.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n\n // Mark Dynamic Dictionaries for removal\n // We use glob to catch the loader files (.cjs, .mjs) AND the split locale files (.en.json, etc.)\n const dynamicFilesGlob = join(\n configuration.system.dynamicDictionariesDir,\n `${dictionary.key}.*`\n );\n const dynamicFiles = await fg(normalizePath(dynamicFilesGlob), {\n absolute: true,\n });\n filesToRemove.push(...dynamicFiles);\n\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n } else {\n const localIds = parsedContent.localIds?.filter(\n (localeId) => !localeId.endsWith(`::local::${relativeFilePath}`)\n ) as string[];\n const newContent = { ...parsedContent, localIds };\n await writeJsonIfChanged(mergedFilePath, newContent);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n const typesFilePath = normalize(\n join(configuration.system.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n }\n }\n })\n );\n\n // Execute Cleanup\n if (filesToRemove.length > 0 || excludeKeys.length > 0) {\n // Update entry points (indexes) first so the app doesn't import dead files\n await createDictionaryEntryPoint(configuration, { excludeKeys });\n\n // Remove the files synchronously (awaited) immediately after.\n if (filesToRemove.length > 0) {\n await Promise.all(\n filesToRemove.map(async (path) => {\n const relativePath = relative(baseDir, path);\n try {\n await rm(path, { force: true });\n\n appLogger(`Deleted artifact: ${colorizePath(relativePath)}`, {\n isVerbose: true,\n });\n } catch {\n appLogger(\n `Error while removing file ${colorizePath(relativePath)}`,\n {\n isVerbose: true,\n }\n );\n }\n })\n );\n }\n }\n\n return {\n changedDictionariesLocalIds,\n excludeKeys,\n hasRebuilt: filesToRemove.length > 0 || excludeKeys.length > 0,\n };\n};\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"cleanRemovedContentDeclaration.mjs","names":[],"sources":["../../src/cleanRemovedContentDeclaration.ts"],"sourcesContent":["import { readFile, rm } from 'node:fs/promises';\nimport { join, normalize, relative } from 'node:path';\nimport { normalizePath } from '@intlayer/config/client';\nimport {\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport fg from 'fast-glob';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint';\nimport { writeJsonIfChanged } from './writeJsonIfChanged';\n\nexport const cleanRemovedContentDeclaration = async (\n filePath: string,\n keysToKeep: string[],\n configuration: IntlayerConfig\n): Promise<{\n changedDictionariesLocalIds: string[];\n excludeKeys: string[];\n hasRebuilt: boolean;\n}> => {\n const appLogger = getAppLogger(configuration);\n\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n const baseDir = configuration.system.baseDir;\n\n const relativeFilePath = relative(baseDir, filePath);\n const flatUnmergedDictionaries = Object.values(unmergedDictionaries).flat();\n\n const filteredUnmergedDictionaries = flatUnmergedDictionaries.filter(\n (dictionary) =>\n dictionary.filePath === relativeFilePath &&\n !keysToKeep.includes(dictionary.key)\n );\n\n // Deduplicate dictionaries by key\n const uniqueUnmergedDictionaries = filteredUnmergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n const changedDictionariesLocalIds: string[] = [];\n const filesToRemove: string[] = [];\n const excludeKeys: string[] = [];\n\n // Identify Unmerged Dictionaries to remove or clean\n await Promise.all(\n uniqueUnmergedDictionaries.map(async (dictionary) => {\n const unmergedFilePath = normalize(\n join(\n configuration.system.unmergedDictionariesDir,\n `${dictionary.key}.json`\n )\n );\n\n try {\n const jsonContent = await readFile(unmergedFilePath, 'utf8');\n const parsedContent = JSON.parse(jsonContent);\n\n if (parsedContent.length === 1) {\n if (parsedContent[0].filePath === relativeFilePath) {\n appLogger(\n `Removing outdated dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n filesToRemove.push(unmergedFilePath);\n excludeKeys.push(dictionary.key);\n }\n } else {\n const filteredContent = parsedContent.filter(\n (content: any) => content.filePath !== relativeFilePath\n );\n await writeJsonIfChanged(unmergedFilePath, filteredContent);\n changedDictionariesLocalIds.push(dictionary.localId!);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n }\n })\n );\n\n const dictionaries = getDictionaries(configuration);\n const flatDictionaries = Object.values(dictionaries) as Dictionary[];\n\n const filteredMergedDictionaries = flatDictionaries?.filter(\n (dictionary) =>\n !keysToKeep.includes(dictionary.key) &&\n dictionary.localIds?.length === 1 &&\n (dictionary.localIds[0] as string).endsWith(\n `::local::${relativeFilePath}`\n )\n );\n\n const uniqueMergedDictionaries = filteredMergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n // Identify Merged Dictionaries, Types, and Dynamic Dictionaries to remove\n await Promise.all(\n uniqueMergedDictionaries.map(async (dictionary) => {\n const mergedFilePath = normalize(\n join(configuration.system.dictionariesDir, `${dictionary.key}.json`)\n );\n\n try {\n const fileContent = await readFile(mergedFilePath, 'utf8');\n const parsedContent = JSON.parse(fileContent) as Dictionary;\n\n if (parsedContent.localIds?.length === 1) {\n if (\n parsedContent.localIds[0].endsWith(`::local::${relativeFilePath}`)\n ) {\n appLogger(\n `Removing outdated unmerged dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n\n // Mark JSON for removal\n filesToRemove.push(mergedFilePath);\n\n // Mark TS Types for removal\n const typesFilePath = normalize(\n join(configuration.system.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n\n // Mark Dynamic Dictionaries for removal\n // We use glob to catch the loader files (.cjs, .mjs) AND the split locale files (.en.json, etc.)\n const dynamicFilesGlob = join(\n configuration.system.dynamicDictionariesDir,\n `${dictionary.key}.*`\n );\n const dynamicFiles = await fg(normalizePath(dynamicFilesGlob), {\n absolute: true,\n });\n filesToRemove.push(...dynamicFiles);\n\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n } else {\n const localIds = parsedContent.localIds?.filter(\n (localeId) => !localeId.endsWith(`::local::${relativeFilePath}`)\n ) as string[];\n const newContent = { ...parsedContent, localIds };\n await writeJsonIfChanged(mergedFilePath, newContent);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n const typesFilePath = normalize(\n join(configuration.system.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n }\n }\n })\n );\n\n // Execute Cleanup\n if (filesToRemove.length > 0 || excludeKeys.length > 0) {\n // Update entry points (indexes) first so the app doesn't import dead files\n await createDictionaryEntryPoint(configuration, { excludeKeys });\n\n // Remove the files synchronously (awaited) immediately after.\n if (filesToRemove.length > 0) {\n await Promise.all(\n filesToRemove.map(async (path) => {\n const relativePath = relative(baseDir, path);\n try {\n await rm(path, { force: true });\n\n appLogger(`Deleted artifact: ${colorizePath(relativePath)}`, {\n isVerbose: true,\n });\n } catch {\n appLogger(\n `Error while removing file ${colorizePath(relativePath)}`,\n {\n isVerbose: true,\n }\n );\n }\n })\n );\n }\n }\n\n return {\n changedDictionariesLocalIds,\n excludeKeys,\n hasRebuilt: filesToRemove.length > 0 || excludeKeys.length > 0,\n };\n};\n"],"mappings":"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"}
|
package/dist/esm/cli.mjs
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { listProjects } from "./listProjects.mjs";
|
|
2
|
+
import { listDictionaries, listDictionariesWithStats } from "./listDictionariesPath.mjs";
|
|
3
|
+
import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.mjs";
|
|
4
|
+
import { transformJSFile } from "./writeContentDeclaration/transformJSFile.mjs";
|
|
5
|
+
import { detectFormatCommand } from "./detectFormatCommand.mjs";
|
|
6
|
+
import { getContentDeclarationFileTemplate } from "./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";
|
|
7
|
+
import { writeJSFile } from "./writeContentDeclaration/writeJSFile.mjs";
|
|
8
|
+
import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.mjs";
|
|
9
|
+
import { initIntlayer } from "./init/index.mjs";
|
|
10
|
+
import { PLATFORMS, PLATFORMS_METADATA, SKILLS, SKILLS_METADATA, getInitialSkills, installSkills } from "./installSkills/index.mjs";
|
|
11
|
+
import { installMCP } from "./installMCP/installMCP.mjs";
|
|
12
|
+
import { listGitFiles, listGitLines } from "./listGitFiles.mjs";
|
|
13
|
+
import { logConfigDetails } from "./logConfigDetails.mjs";
|
|
14
|
+
|
|
15
|
+
export { PLATFORMS, PLATFORMS_METADATA, SKILLS, SKILLS_METADATA, detectExportedComponentName, detectFormatCommand, getContentDeclarationFileTemplate, getInitialSkills, initIntlayer, installMCP, installSkills, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, logConfigDetails, transformJSFile, writeContentDeclaration, writeJSFile };
|
|
@@ -1,2 +1,69 @@
|
|
|
1
|
-
import{parallelize
|
|
1
|
+
import { parallelize } from "../utils/parallelize.mjs";
|
|
2
|
+
import { writeFileIfChanged } from "../writeFileIfChanged.mjs";
|
|
3
|
+
import { generateDictionaryListContent } from "./generateDictionaryListContent.mjs";
|
|
4
|
+
import { getBuiltDictionariesPath } from "./getBuiltDictionariesPath.mjs";
|
|
5
|
+
import { getBuiltDynamicDictionariesPath } from "./getBuiltDynamicDictionariesPath.mjs";
|
|
6
|
+
import { getBuiltFetchDictionariesPath } from "./getBuiltFetchDictionariesPath.mjs";
|
|
7
|
+
import { getBuiltRemoteDictionariesPath } from "./getBuiltRemoteDictionariesPath.mjs";
|
|
8
|
+
import { getBuiltUnmergedDictionariesPath } from "./getBuiltUnmergedDictionariesPath.mjs";
|
|
9
|
+
import { mkdir } from "node:fs/promises";
|
|
10
|
+
import { resolve } from "node:path";
|
|
11
|
+
import { getConfiguration } from "@intlayer/config/node";
|
|
12
|
+
|
|
13
|
+
//#region src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts
|
|
14
|
+
const writeDictionaryFiles = async (paths, fileName, importType, functionName, format, configuration = getConfiguration()) => {
|
|
15
|
+
const content = generateDictionaryListContent(await paths, functionName, importType, format, configuration);
|
|
16
|
+
const extension = format === "cjs" ? "cjs" : "mjs";
|
|
17
|
+
const { mainDir } = configuration.system;
|
|
18
|
+
await writeFileIfChanged(resolve(mainDir, `${fileName}.${extension}`), content);
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* This function generates a list of dictionaries in the main directory
|
|
22
|
+
*/
|
|
23
|
+
const createDictionaryEntryPoint = async (configuration = getConfiguration(), options = {}) => {
|
|
24
|
+
const { formats, excludeKeys = [] } = options;
|
|
25
|
+
const outputFormats = formats ?? configuration.build.outputFormat;
|
|
26
|
+
const { mainDir } = configuration.system;
|
|
27
|
+
await mkdir(mainDir, { recursive: true });
|
|
28
|
+
await parallelize([
|
|
29
|
+
...outputFormats.map((format) => ({
|
|
30
|
+
paths: getBuiltDictionariesPath(configuration, excludeKeys),
|
|
31
|
+
importType: "json",
|
|
32
|
+
functionName: "getDictionaries",
|
|
33
|
+
fileName: "dictionaries",
|
|
34
|
+
format
|
|
35
|
+
})),
|
|
36
|
+
...outputFormats.map((format) => ({
|
|
37
|
+
paths: getBuiltUnmergedDictionariesPath(configuration, excludeKeys),
|
|
38
|
+
importType: "json",
|
|
39
|
+
functionName: "getUnmergedDictionaries",
|
|
40
|
+
fileName: "unmerged_dictionaries",
|
|
41
|
+
format
|
|
42
|
+
})),
|
|
43
|
+
...outputFormats.map((format) => ({
|
|
44
|
+
paths: getBuiltDynamicDictionariesPath(configuration, format, excludeKeys),
|
|
45
|
+
importType: "javascript",
|
|
46
|
+
functionName: "getDynamicDictionaries",
|
|
47
|
+
fileName: "dynamic_dictionaries",
|
|
48
|
+
format
|
|
49
|
+
})),
|
|
50
|
+
...outputFormats.map((format) => ({
|
|
51
|
+
paths: getBuiltFetchDictionariesPath(configuration, format, excludeKeys),
|
|
52
|
+
importType: "javascript",
|
|
53
|
+
functionName: "getFetchDictionaries",
|
|
54
|
+
fileName: "fetch_dictionaries",
|
|
55
|
+
format
|
|
56
|
+
})),
|
|
57
|
+
...outputFormats.map((format) => ({
|
|
58
|
+
paths: getBuiltRemoteDictionariesPath(configuration, excludeKeys),
|
|
59
|
+
importType: "json",
|
|
60
|
+
functionName: "getRemoteDictionaries",
|
|
61
|
+
fileName: "remote_dictionaries",
|
|
62
|
+
format
|
|
63
|
+
}))
|
|
64
|
+
], async ({ paths, fileName, format, functionName, importType }) => writeDictionaryFiles(paths, fileName, importType, functionName, format, configuration));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
export { createDictionaryEntryPoint };
|
|
2
69
|
//# sourceMappingURL=createDictionaryEntryPoint.mjs.map
|