@intlayer/chokidar 8.1.2 → 8.1.3
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/assets/installSkills/skills/angular.md +3 -0
- package/dist/assets/installSkills/skills/astro.md +3 -0
- package/dist/assets/installSkills/skills/cli.md +7 -4
- package/dist/assets/installSkills/skills/config.md +3 -0
- package/dist/assets/installSkills/skills/content.md +3 -0
- package/dist/assets/installSkills/skills/next_js.md +3 -0
- package/dist/assets/installSkills/skills/preact.md +3 -2
- package/dist/assets/installSkills/skills/react.md +3 -0
- package/dist/assets/installSkills/skills/solid.md +3 -0
- package/dist/assets/installSkills/skills/svelte.md +3 -0
- package/dist/assets/installSkills/skills/usage.md +2 -0
- package/dist/assets/installSkills/skills/vue.md +3 -0
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/cjs/_virtual/_utils_asset.cjs +2 -98
- package/dist/cjs/build.cjs +1 -51
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +1 -53
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/index.cjs +1 -6
- package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +1 -26
- package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +4 -78
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +4 -62
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +1 -46
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +1 -50
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +1 -59
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
- package/dist/cjs/cleanOutputDir.cjs +1 -30
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/cleanRemovedContentDeclaration.cjs +1 -96
- package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
- package/dist/cjs/cli.cjs +1 -21
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +1 -70
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +7 -41
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +1 -23
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +1 -24
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +1 -24
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +1 -23
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +1 -23
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/index.cjs +1 -16
- package/dist/cjs/createType/createModuleAugmentation.cjs +9 -110
- package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/createType/createType.cjs +1 -29
- package/dist/cjs/createType/createType.cjs.map +1 -1
- package/dist/cjs/createType/index.cjs +1 -8
- package/dist/cjs/fetchDistantDictionaries.cjs +1 -50
- package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/filterInvalidDictionaries.cjs +1 -49
- package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
- package/dist/cjs/formatDictionary.cjs +1 -49
- package/dist/cjs/formatDictionary.cjs.map +1 -1
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +1 -39
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +1 -34
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileChange.cjs +1 -49
- package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileMoved.cjs +1 -24
- package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +1 -37
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -131
- package/dist/cjs/init/index.cjs +1 -242
- package/dist/cjs/init/index.cjs.map +1 -1
- package/dist/cjs/init/utils/configManipulation.cjs +1 -164
- package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
- package/dist/cjs/init/utils/fileSystem.cjs +1 -30
- package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
- package/dist/cjs/init/utils/index.cjs +1 -13
- package/dist/cjs/init/utils/jsonParser.cjs +3 -42
- package/dist/cjs/init/utils/jsonParser.cjs.map +1 -1
- package/dist/cjs/init/utils/tsConfig.cjs +1 -18
- package/dist/cjs/init/utils/tsConfig.cjs.map +1 -1
- package/dist/cjs/initConfig/index.cjs +1 -38
- package/dist/cjs/initConfig/index.cjs.map +1 -1
- package/dist/cjs/installSkills/index.cjs +1 -172
- package/dist/cjs/installSkills/index.cjs.map +1 -1
- package/dist/cjs/listDictionariesPath.cjs +1 -41
- package/dist/cjs/listDictionariesPath.cjs.map +1 -1
- package/dist/cjs/listGitFiles.cjs +5 -95
- package/dist/cjs/listGitFiles.cjs.map +1 -1
- package/dist/cjs/listProjects.cjs +1 -47
- package/dist/cjs/listProjects.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +1 -66
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/index.cjs +1 -12
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +2 -72
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +1 -125
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +1 -28
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +1 -61
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/log.cjs +3 -135
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +1 -95
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs +1 -30
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +1 -12
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
- package/dist/cjs/transformFiles/extractDictionaryKey.cjs +1 -16
- package/dist/cjs/transformFiles/extractDictionaryKey.cjs.map +1 -1
- package/dist/cjs/transformFiles/index.cjs +1 -10
- package/dist/cjs/transformFiles/transformFiles.cjs +1 -251
- package/dist/cjs/transformFiles/transformFiles.cjs.map +1 -1
- package/dist/cjs/utils/autoDecorateContent.cjs +1 -87
- package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
- package/dist/cjs/utils/buildFilesList.cjs +1 -50
- package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
- package/dist/cjs/utils/chunkJSON.cjs +1 -336
- package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
- package/dist/cjs/utils/formatter.cjs +1 -16
- package/dist/cjs/utils/formatter.cjs.map +1 -1
- package/dist/cjs/utils/getChunk.cjs +1 -34
- package/dist/cjs/utils/getChunk.cjs.map +1 -1
- package/dist/cjs/utils/getComponentTransformPattern.cjs +1 -48
- package/dist/cjs/utils/getComponentTransformPattern.cjs.map +1 -1
- package/dist/cjs/utils/getFileHash.cjs +1 -12
- package/dist/cjs/utils/getFileHash.cjs.map +1 -1
- package/dist/cjs/utils/getFormatFromExtension.cjs +1 -31
- package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +1 -46
- package/dist/cjs/utils/pLimit.cjs +1 -128
- package/dist/cjs/utils/pLimit.cjs.map +1 -1
- package/dist/cjs/utils/parallelize.cjs +1 -11
- package/dist/cjs/utils/parallelize.cjs.map +1 -1
- package/dist/cjs/utils/parallelizeGlobal.cjs +1 -29
- package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -1
- package/dist/cjs/utils/reduceObjectFormat.cjs +1 -31
- package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
- package/dist/cjs/utils/resolveObjectPromises.cjs +1 -21
- package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
- package/dist/cjs/utils/runOnce.cjs +1 -95
- package/dist/cjs/utils/runOnce.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/bin.cjs +1 -54
- package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/bootstrap.cjs +1 -24
- package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/index.cjs +1 -110
- package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/pidTree.cjs +1 -145
- package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/ps.cjs +1 -49
- package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/runTask.cjs +1 -154
- package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/spawnPosix.cjs +1 -59
- package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/spawnWin32.cjs +1 -43
- package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/wmic.cjs +1 -52
- package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
- package/dist/cjs/utils/sortAlphabetically.cjs +1 -7
- package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
- package/dist/cjs/utils/splitTextByLine.cjs +1 -11
- package/dist/cjs/utils/splitTextByLine.cjs.map +1 -1
- package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +1 -60
- package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
- package/dist/cjs/watcher.cjs +1 -95
- package/dist/cjs/watcher.cjs.map +1 -1
- package/dist/cjs/writeConfiguration/index.cjs +1 -34
- package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +1 -28
- package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs +1 -31
- package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/index.cjs +1 -12
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +1 -93
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +2 -1775
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +1 -77
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +1 -123
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +1 -71
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
- package/dist/cjs/writeFileIfChanged.cjs +1 -12
- package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
- package/dist/cjs/writeJsonIfChanged.cjs +1 -17
- package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.mjs +1 -8
- package/dist/esm/_virtual/_utils_asset.mjs +2 -97
- package/dist/esm/build.mjs +1 -24
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +1 -51
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/index.mjs +1 -4
- package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs +1 -24
- package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +4 -75
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +4 -59
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +1 -44
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +1 -48
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +1 -56
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
- package/dist/esm/cleanOutputDir.mjs +1 -28
- package/dist/esm/cleanOutputDir.mjs.map +1 -1
- package/dist/esm/cleanRemovedContentDeclaration.mjs +1 -93
- package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
- package/dist/esm/cli.mjs +1 -8
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +1 -68
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +7 -39
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +1 -20
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +1 -21
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +1 -21
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +1 -20
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +1 -20
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/index.mjs +1 -9
- package/dist/esm/createType/createModuleAugmentation.mjs +9 -106
- package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/createType/createType.mjs +1 -26
- package/dist/esm/createType/createType.mjs.map +1 -1
- package/dist/esm/createType/index.mjs +1 -4
- package/dist/esm/fetchDistantDictionaries.mjs +1 -48
- package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/filterInvalidDictionaries.mjs +1 -46
- package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
- package/dist/esm/formatDictionary.mjs +1 -44
- package/dist/esm/formatDictionary.mjs.map +1 -1
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +1 -37
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs +1 -32
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileChange.mjs +1 -47
- package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileMoved.mjs +1 -22
- package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -1
- package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +1 -35
- package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -57
- package/dist/esm/init/index.mjs +1 -240
- package/dist/esm/init/index.mjs.map +1 -1
- package/dist/esm/init/utils/configManipulation.mjs +1 -161
- package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
- package/dist/esm/init/utils/fileSystem.mjs +1 -26
- package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
- package/dist/esm/init/utils/index.mjs +1 -6
- package/dist/esm/init/utils/jsonParser.mjs +3 -40
- package/dist/esm/init/utils/jsonParser.mjs.map +1 -1
- package/dist/esm/init/utils/tsConfig.mjs +1 -16
- package/dist/esm/init/utils/tsConfig.mjs.map +1 -1
- package/dist/esm/initConfig/index.mjs +1 -36
- package/dist/esm/initConfig/index.mjs.map +1 -1
- package/dist/esm/installSkills/index.mjs +1 -167
- package/dist/esm/installSkills/index.mjs.map +1 -1
- package/dist/esm/listDictionariesPath.mjs +1 -37
- package/dist/esm/listDictionariesPath.mjs.map +1 -1
- package/dist/esm/listGitFiles.mjs +5 -90
- package/dist/esm/listGitFiles.mjs.map +1 -1
- package/dist/esm/listProjects.mjs +1 -43
- package/dist/esm/listProjects.mjs.map +1 -1
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +1 -65
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
- package/dist/esm/loadDictionaries/index.mjs +1 -6
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +2 -69
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +1 -123
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +1 -26
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +1 -58
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/log.mjs +3 -132
- package/dist/esm/loadDictionaries/log.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +1 -92
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/reduceDictionaryContent/applyMask.mjs +1 -28
- package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
- package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +1 -10
- package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
- package/dist/esm/transformFiles/extractDictionaryKey.mjs +1 -14
- package/dist/esm/transformFiles/extractDictionaryKey.mjs.map +1 -1
- package/dist/esm/transformFiles/index.mjs +1 -4
- package/dist/esm/transformFiles/transformFiles.mjs +1 -244
- package/dist/esm/transformFiles/transformFiles.mjs.map +1 -1
- package/dist/esm/utils/autoDecorateContent.mjs +1 -85
- package/dist/esm/utils/autoDecorateContent.mjs.map +1 -1
- package/dist/esm/utils/buildFilesList.mjs +1 -47
- package/dist/esm/utils/buildFilesList.mjs.map +1 -1
- package/dist/esm/utils/chunkJSON.mjs +1 -333
- package/dist/esm/utils/chunkJSON.mjs.map +1 -1
- package/dist/esm/utils/formatter.mjs +1 -12
- package/dist/esm/utils/formatter.mjs.map +1 -1
- package/dist/esm/utils/getChunk.mjs +1 -33
- package/dist/esm/utils/getChunk.mjs.map +1 -1
- package/dist/esm/utils/getComponentTransformPattern.mjs +1 -44
- package/dist/esm/utils/getComponentTransformPattern.mjs.map +1 -1
- package/dist/esm/utils/getFileHash.mjs +1 -9
- package/dist/esm/utils/getFileHash.mjs.map +1 -1
- package/dist/esm/utils/getFormatFromExtension.mjs +1 -28
- package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +1 -20
- package/dist/esm/utils/pLimit.mjs +1 -125
- package/dist/esm/utils/pLimit.mjs.map +1 -1
- package/dist/esm/utils/parallelize.mjs +1 -10
- package/dist/esm/utils/parallelize.mjs.map +1 -1
- package/dist/esm/utils/parallelizeGlobal.mjs +1 -26
- package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -1
- package/dist/esm/utils/reduceObjectFormat.mjs +1 -29
- package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -1
- package/dist/esm/utils/resolveObjectPromises.mjs +1 -19
- package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
- package/dist/esm/utils/runOnce.mjs +1 -92
- package/dist/esm/utils/runOnce.mjs.map +1 -1
- package/dist/esm/utils/runParallel/bin.mjs +1 -52
- package/dist/esm/utils/runParallel/bin.mjs.map +1 -1
- package/dist/esm/utils/runParallel/bootstrap.mjs +1 -22
- package/dist/esm/utils/runParallel/bootstrap.mjs.map +1 -1
- package/dist/esm/utils/runParallel/index.mjs +1 -108
- package/dist/esm/utils/runParallel/index.mjs.map +1 -1
- package/dist/esm/utils/runParallel/pidTree.mjs +1 -142
- package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
- package/dist/esm/utils/runParallel/ps.mjs +1 -46
- package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
- package/dist/esm/utils/runParallel/runTask.mjs +1 -152
- package/dist/esm/utils/runParallel/runTask.mjs.map +1 -1
- package/dist/esm/utils/runParallel/spawnPosix.mjs +1 -57
- package/dist/esm/utils/runParallel/spawnPosix.mjs.map +1 -1
- package/dist/esm/utils/runParallel/spawnWin32.mjs +1 -41
- package/dist/esm/utils/runParallel/spawnWin32.mjs.map +1 -1
- package/dist/esm/utils/runParallel/wmic.mjs +1 -49
- package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
- package/dist/esm/utils/sortAlphabetically.mjs +1 -5
- package/dist/esm/utils/sortAlphabetically.mjs.map +1 -1
- package/dist/esm/utils/splitTextByLine.mjs +1 -9
- package/dist/esm/utils/splitTextByLine.mjs.map +1 -1
- package/dist/esm/utils/verifyIdenticObjectFormat.mjs +1 -58
- package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -1
- package/dist/esm/watcher.mjs +1 -92
- package/dist/esm/watcher.mjs.map +1 -1
- package/dist/esm/writeConfiguration/index.mjs +1 -31
- package/dist/esm/writeConfiguration/index.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +1 -26
- package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/detectFormatCommand.mjs +1 -29
- package/dist/esm/writeContentDeclaration/detectFormatCommand.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/index.mjs +1 -7
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +1 -91
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs +2 -1773
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +1 -75
- package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +1 -121
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs +1 -69
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
- package/dist/esm/writeFileIfChanged.mjs +1 -10
- package/dist/esm/writeFileIfChanged.mjs.map +1 -1
- package/dist/esm/writeJsonIfChanged.mjs +1 -16
- package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
- package/dist/types/build.d.ts +3 -1
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
- package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/index.d.ts +16 -24
- package/dist/types/initConfig/index.d.ts +1 -1
- package/dist/types/initConfig/index.d.ts.map +1 -1
- package/dist/types/listGitFiles.d.ts.map +1 -1
- package/dist/types/loadDictionaries/getIntlayerBundle.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts.map +1 -1
- package/dist/types/transformFiles/transformFiles.d.ts +1 -1
- package/dist/types/transformFiles/transformFiles.d.ts.map +1 -1
- package/dist/types/utils/formatter.d.ts +1 -1
- package/dist/types/watcher.d.ts +1 -1
- package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -1
- package/package.json +10 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeDynamicDictionary.cjs","names":["parallelize","writeJsonIfChanged","writeFileIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport {
|
|
1
|
+
{"version":3,"file":"writeDynamicDictionary.cjs","names":["parallelize","writeJsonIfChanged","writeFileIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { normalizePath } from '@intlayer/config/utils';\nimport { getPerLocaleDictionary } from '@intlayer/core/plugins';\nimport type { Dictionary, Locale } from '@intlayer/types';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { MergedDictionaryOutput } from './writeMergedDictionary';\n\nexport type DictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type LocalizedDictionaryResult = Partial<\n Record<Locale, DictionaryResult>\n>;\n\nexport type LocalizedDictionaryOutput = Record<\n string,\n LocalizedDictionaryResult\n>;\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryEntryPoint = (\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { dynamicDictionariesDir } = configuration.system;\n\n let content = '';\n\n // Format Dictionary Map - map locales to functions\n const formattedDictionaryMap: string = Object.entries(\n localizedDictionariesPathsRecord\n )\n // The following filter/sort preserve determinism of the generated map\n // when files are built in parallel or across different Node versions.\n .filter((entry): entry is [string, DictionaryResult] => Boolean(entry[1]))\n .sort(([a], [b]) => String(a).localeCompare(String(b)))\n .map(([locale, dictionary]) => {\n const relativePath = normalizePath(\n relative(dynamicDictionariesDir, dictionary.dictionaryPath)\n );\n\n if (format === 'esm') {\n return ` '${locale}': () => import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)`;\n }\n\n return ` '${locale}': () => Promise.resolve(require('./${relativePath}'))`;\n })\n .join(',\\n');\n\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dynamic_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeDynamicDictionary = async (\n mergedDictionaries: MergedDictionaryOutput,\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n): Promise<LocalizedDictionaryOutput> => {\n const { locales, defaultLocale } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dynamicDictionariesDir), { recursive: true });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Merge dictionaries with the same key and write to dictionariesDir\n await parallelize(\n Object.entries(mergedDictionaries).sort(([a], [b]) =>\n String(a).localeCompare(String(b))\n ),\n async ([key, dictionaryEntry]) => {\n if (key === 'undefined') return;\n\n const localizedDictionariesPathsRecord: LocalizedDictionaryResult = {};\n\n await parallelize(locales, async (locale) => {\n const localizedDictionary = getPerLocaleDictionary(\n dictionaryEntry.dictionary,\n locale,\n defaultLocale\n );\n\n const outputFileName = `${key}.${locale}.json`;\n const resultFilePath = resolve(dynamicDictionariesDir, outputFileName);\n\n // Write the localized dictionary\n await writeJsonIfChanged(resultFilePath, localizedDictionary).catch(\n (err) => {\n console.error(`Error creating localized ${outputFileName}:`, err);\n }\n );\n\n localizedDictionariesPathsRecord[locale] = {\n dictionaryPath: resultFilePath,\n dictionary: localizedDictionary,\n };\n });\n\n resultDictionariesPaths[key] = localizedDictionariesPathsRecord;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localizedDictionariesPathsRecord,\n format,\n configuration\n );\n\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":"mbA6BA,MAAa,GACX,EACA,EAAwB,MACxB,GAAA,EAAA,EAAA,mBAAkC,GACvB,CACX,GAAM,CAAE,0BAA2B,EAAc,OAE7C,EAAU,GAGR,EAAiC,OAAO,QAC5C,EACD,CAGE,OAAQ,GAA+C,EAAQ,EAAM,GAAI,CACzE,MAAM,CAAC,GAAI,CAAC,KAAO,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC,CACtD,KAAK,CAAC,EAAQ,KAAgB,CAC7B,IAAM,GAAA,EAAA,EAAA,gBAAA,EAAA,EAAA,UACK,EAAwB,EAAW,eAAe,CAC5D,CAMD,OAJI,IAAW,MACN,MAAM,EAAO,qBAAqB,EAAa,0DAGjD,MAAM,EAAO,sCAAsC,EAAa,MACvE,CACD,KAAK;EAAM,CAOd,MALA,IAAW,sBAAsB,EAAuB,QAEpD,IAAW,QAAO,GAAW;GAC7B,IAAW,QAAO,GAAW;GAE1B,GAmBI,EAAyB,MACpC,EACA,GAAA,EAAA,EAAA,mBAAkC,CAClC,EAA6B,CAAC,MAAO,MAAM,GACJ,CACvC,GAAM,CAAE,UAAS,iBAAkB,EAAc,qBAC3C,CAAE,0BAA2B,EAAc,OAGjD,MAAA,EAAA,EAAA,QAAA,EAAA,EAAA,SAAoB,EAAuB,CAAE,CAAE,UAAW,GAAM,CAAC,CAEjE,IAAM,EAAqD,EAAE,CA0D7D,OAvDA,MAAMA,EAAAA,YACJ,OAAO,QAAQ,EAAmB,CAAC,MAAM,CAAC,GAAI,CAAC,KAC7C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC,CACD,MAAO,CAAC,EAAK,KAAqB,CAChC,GAAI,IAAQ,YAAa,OAEzB,IAAM,EAA8D,EAAE,CAEtE,MAAMA,EAAAA,YAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,GAAA,EAAA,EAAA,wBACJ,EAAgB,WAChB,EACA,EACD,CAEK,EAAiB,GAAG,EAAI,GAAG,EAAO,OAClC,GAAA,EAAA,EAAA,SAAyB,EAAwB,EAAe,CAGtE,MAAMC,EAAAA,mBAAmB,EAAgB,EAAoB,CAAC,MAC3D,GAAQ,CACP,QAAQ,MAAM,4BAA4B,EAAe,GAAI,EAAI,EAEpE,CAED,EAAiC,GAAU,CACzC,eAAgB,EAChB,WAAY,EACb,EACD,CAEF,EAAwB,GAAO,EAE/B,MAAMD,EAAAA,YAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MACvC,EAAU,EACd,EACA,EACA,EACD,CAED,MAAME,EAAAA,oBAAAA,EAAAA,EAAAA,SACI,EAAwB,GAAG,EAAI,GAAG,IAAY,CACtD,EACD,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,2BAAA,EAAA,EAAA,eAAA,EAAA,EAAA,SAA+C,EAAwB,GAAG,EAAI,GAAG,IAAY,CAAC,CAAC,GAC/F,EACD,EACD,EACF,EAEL,CAEM"}
|
|
@@ -1,63 +1,5 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let _intlayer_config = require("@intlayer/config");
|
|
6
|
-
let node_fs_promises = require("node:fs/promises");
|
|
7
|
-
let node_path = require("node:path");
|
|
8
|
-
|
|
9
|
-
//#region src/buildIntlayerDictionary/writeFetchDictionary.ts
|
|
10
|
-
/**
|
|
11
|
-
* This function generates the content of the dictionary list file
|
|
12
|
-
*/
|
|
13
|
-
const generateDictionaryEntryPoint = (localedDictionariesPathsRecord, format = "esm", configuration = (0, _intlayer_config.getConfiguration)()) => {
|
|
14
|
-
const { fetchDictionariesDir } = configuration.system;
|
|
15
|
-
const { liveSyncURL } = configuration.editor;
|
|
16
|
-
let content = "";
|
|
17
|
-
const formattedDictionaryMap = Object.entries(localedDictionariesPathsRecord).map(([locale, dictionary]) => {
|
|
18
|
-
const relativePath = (0, _intlayer_config.normalizePath)((0, node_path.relative)(fetchDictionariesDir, dictionary.dictionaryPath));
|
|
19
|
-
if (format === "esm") return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return await import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)}})()`;
|
|
20
|
-
return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return Promise.resolve(require('./${relativePath}'))}})()`;
|
|
21
|
-
}).join(",\n");
|
|
22
|
-
content += `const content = {\n${formattedDictionaryMap}\n};\n`;
|
|
23
|
-
if (format === "esm") content += `export default content;\n`;
|
|
24
|
-
if (format === "cjs") content += `module.exports = content;\n`;
|
|
25
|
-
return content;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Write the localized dictionaries to the dictionariesDir
|
|
29
|
-
* @param mergedDictionaries - The merged dictionaries
|
|
30
|
-
* @param configuration - The configuration
|
|
31
|
-
* @returns The final dictionaries
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
36
|
-
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
37
|
-
* console.log(finalDictionaries);
|
|
38
|
-
*
|
|
39
|
-
* // .intlayer/fetch_dictionaries/home.json
|
|
40
|
-
* // { key: 'home', content: { ... } },
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
const writeFetchDictionary = async (dynamicDictionaries, configuration = (0, _intlayer_config.getConfiguration)(), formats = ["cjs", "esm"]) => {
|
|
44
|
-
const { fetchDictionariesDir } = configuration.system;
|
|
45
|
-
await (0, node_fs_promises.mkdir)((0, node_path.resolve)(fetchDictionariesDir), { recursive: true });
|
|
46
|
-
const resultDictionariesPaths = {};
|
|
47
|
-
await require_utils_parallelize.parallelize(Object.entries(dynamicDictionaries), async ([key, localedDictionariesPathsRecord]) => {
|
|
48
|
-
if (key === "undefined") return;
|
|
49
|
-
await require_utils_parallelize.parallelize(formats, async (format) => {
|
|
50
|
-
const extension = format === "cjs" ? "cjs" : "mjs";
|
|
51
|
-
const content = generateDictionaryEntryPoint(localedDictionariesPathsRecord, format, configuration);
|
|
52
|
-
await require_writeFileIfChanged.writeFileIfChanged((0, node_path.resolve)(fetchDictionariesDir, `${key}.${extension}`), content).catch((err) => {
|
|
53
|
-
console.error(`Error creating fetch ${(0, _intlayer_config.colorizePath)((0, node_path.resolve)(fetchDictionariesDir, `${key}.${extension}`))}:`, err);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
return resultDictionariesPaths;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
//#endregion
|
|
61
|
-
exports.generateDictionaryEntryPoint = generateDictionaryEntryPoint;
|
|
62
|
-
exports.writeFetchDictionary = writeFetchDictionary;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../utils/parallelize.cjs`),t=require(`../writeFileIfChanged.cjs`);let n=require(`@intlayer/config/node`),r=require(`node:fs/promises`),i=require(`node:path`),a=require(`@intlayer/config/logger`),o=require(`@intlayer/config/utils`);const s=(e,t=`esm`,r=(0,n.getConfiguration)())=>{let{fetchDictionariesDir:a}=r.system,{liveSyncURL:s}=r.editor,c=``,l=Object.entries(e).map(([e,n])=>{let r=(0,o.normalizePath)((0,i.relative)(a,n.dictionaryPath));return t===`esm`?` '${e}': () => (async () => { try {return await fetch('${s}/dictionaries/${n.dictionary.key}/${e}').then(res => res.json())} catch (_error) {return await import('./${r}', { assert: { type: 'json' }}).then(mod => mod.default)}})()`:` '${e}': () => (async () => { try {return await fetch('${s}/dictionaries/${n.dictionary.key}/${e}').then(res => res.json())} catch (_error) {return Promise.resolve(require('./${r}'))}})()`}).join(`,
|
|
2
|
+
`);return c+=`const content = {\n${l}\n};\n`,t===`esm`&&(c+=`export default content;
|
|
3
|
+
`),t===`cjs`&&(c+=`module.exports = content;
|
|
4
|
+
`),c},c=async(o,c=(0,n.getConfiguration)(),l=[`cjs`,`esm`])=>{let{fetchDictionariesDir:u}=c.system;return await(0,r.mkdir)((0,i.resolve)(u),{recursive:!0}),await e.parallelize(Object.entries(o),async([n,r])=>{n!==`undefined`&&await e.parallelize(l,async e=>{let o=e===`cjs`?`cjs`:`mjs`,l=s(r,e,c);await t.writeFileIfChanged((0,i.resolve)(u,`${n}.${o}`),l).catch(e=>{console.error(`Error creating fetch ${(0,a.colorizePath)((0,i.resolve)(u,`${n}.${o}`))}:`,e)})})}),{}};exports.generateDictionaryEntryPoint=s,exports.writeFetchDictionary=c;
|
|
63
5
|
//# sourceMappingURL=writeFetchDictionary.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeFetchDictionary.cjs","names":["parallelize","writeFileIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport {
|
|
1
|
+
{"version":3,"file":"writeFetchDictionary.cjs","names":["parallelize","writeFileIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { normalizePath } from '@intlayer/config/utils';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type {\n LocalizedDictionaryOutput,\n LocalizedDictionaryResult,\n} from './writeDynamicDictionary';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryEntryPoint = (\n localedDictionariesPathsRecord: LocalizedDictionaryResult,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { fetchDictionariesDir } = configuration.system;\n const { liveSyncURL } = configuration.editor;\n\n let content = '';\n\n const formattedDictionaryMap: string = Object.entries(\n localedDictionariesPathsRecord\n )\n .map(([locale, dictionary]) => {\n const relativePath = normalizePath(\n relative(fetchDictionariesDir, dictionary.dictionaryPath)\n );\n\n if (format === 'esm') {\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return await import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)}})()`;\n }\n\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return Promise.resolve(require('./${relativePath}'))}})()`;\n })\n .join(',\\n');\n\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\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_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(\n Object.entries(dynamicDictionaries),\n async ([key, localedDictionariesPathsRecord]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localedDictionariesPathsRecord,\n format,\n configuration\n );\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\n return resultDictionariesPaths;\n};\n"],"mappings":"wWAeA,MAAa,GACX,EACA,EAAwB,MACxB,GAAA,EAAA,EAAA,mBAAkC,GACvB,CACX,GAAM,CAAE,wBAAyB,EAAc,OACzC,CAAE,eAAgB,EAAc,OAElC,EAAU,GAER,EAAiC,OAAO,QAC5C,EACD,CACE,KAAK,CAAC,EAAQ,KAAgB,CAC7B,IAAM,GAAA,EAAA,EAAA,gBAAA,EAAA,EAAA,UACK,EAAsB,EAAW,eAAe,CAC1D,CAMD,OAJI,IAAW,MACN,MAAM,EAAO,mDAAmD,EAAY,gBAAgB,EAAW,WAAW,IAAI,GAAG,EAAO,qEAAqE,EAAa,+DAGpN,MAAM,EAAO,mDAAmD,EAAY,gBAAgB,EAAW,WAAW,IAAI,GAAG,EAAO,gFAAgF,EAAa,WACpO,CACD,KAAK;EAAM,CAOd,MALA,IAAW,sBAAsB,EAAuB,QAEpD,IAAW,QAAO,GAAW;GAC7B,IAAW,QAAO,GAAW;GAE1B,GAmBI,EAAuB,MAClC,EACA,GAAA,EAAA,EAAA,mBAAkC,CAClC,EAA6B,CAAC,MAAO,MAAM,GACJ,CACvC,GAAM,CAAE,wBAAyB,EAAc,OAkC/C,OA/BA,MAAA,EAAA,EAAA,QAAA,EAAA,EAAA,SAAoB,EAAqB,CAAE,CAAE,UAAW,GAAM,CAAC,CAK/D,MAAMA,EAAAA,YACJ,OAAO,QAAQ,EAAoB,CACnC,MAAO,CAAC,EAAK,KAAoC,CAC3C,IAAQ,aAEZ,MAAMA,EAAAA,YAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MACvC,EAAU,EACd,EACA,EACA,EACD,CAED,MAAMC,EAAAA,oBAAAA,EAAAA,EAAAA,SACI,EAAsB,GAAG,EAAI,GAAG,IAAY,CACpD,EACD,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,yBAAA,EAAA,EAAA,eAAA,EAAA,EAAA,SAA6C,EAAsB,GAAG,EAAI,GAAG,IAAY,CAAC,CAAC,GAC3F,EACD,EACD,EACF,EAEL,CA3B0D,EAAE"}
|
|
@@ -1,47 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_utils_parallelize = require('../utils/parallelize.cjs');
|
|
4
|
-
const require_writeJsonIfChanged = require('../writeJsonIfChanged.cjs');
|
|
5
|
-
let _intlayer_config = require("@intlayer/config");
|
|
6
|
-
let node_fs_promises = require("node:fs/promises");
|
|
7
|
-
let node_path = require("node:path");
|
|
8
|
-
let _intlayer_core = require("@intlayer/core");
|
|
9
|
-
|
|
10
|
-
//#region src/buildIntlayerDictionary/writeMergedDictionary.ts
|
|
11
|
-
/**
|
|
12
|
-
* Write the merged dictionaries to the dictionariesDir
|
|
13
|
-
* @param groupedDictionaries - The grouped dictionaries
|
|
14
|
-
* @param configuration - The configuration
|
|
15
|
-
* @returns The merged dictionaries
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
20
|
-
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
21
|
-
* console.log(finalDictionaries);
|
|
22
|
-
*
|
|
23
|
-
* // .intlayer/dictionary/home.json
|
|
24
|
-
* // { key: 'home', content: { ... } },
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
const writeMergedDictionaries = async (groupedDictionaries, configuration = (0, _intlayer_config.getConfiguration)()) => {
|
|
28
|
-
const { dictionariesDir } = configuration.system;
|
|
29
|
-
await (0, node_fs_promises.mkdir)((0, node_path.resolve)(dictionariesDir), { recursive: true });
|
|
30
|
-
const results = await require_utils_parallelize.parallelize(Object.entries(groupedDictionaries), async ([key, dictionariesEntry]) => {
|
|
31
|
-
if (key === "undefined") return;
|
|
32
|
-
const mergedDictionary = (0, _intlayer_core.mergeDictionaries)((0, _intlayer_core.normalizeDictionaries)(dictionariesEntry.dictionaries, configuration));
|
|
33
|
-
const resultFilePath = (0, node_path.resolve)(dictionariesDir, `${key}.json`);
|
|
34
|
-
await require_writeJsonIfChanged.writeJsonIfChanged(resultFilePath, mergedDictionary).catch((err) => {
|
|
35
|
-
console.error(`Error creating merged ${(0, _intlayer_config.colorizePath)(resultFilePath)}:`, err);
|
|
36
|
-
});
|
|
37
|
-
return [key, {
|
|
38
|
-
dictionaryPath: resultFilePath,
|
|
39
|
-
dictionary: mergedDictionary
|
|
40
|
-
}];
|
|
41
|
-
});
|
|
42
|
-
return Object.fromEntries(results.filter(Boolean));
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
exports.writeMergedDictionaries = writeMergedDictionaries;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../utils/parallelize.cjs`),t=require(`../writeJsonIfChanged.cjs`);let n=require(`@intlayer/config/node`),r=require(`node:fs/promises`),i=require(`node:path`),a=require(`@intlayer/config/logger`),o=require(`@intlayer/core/dictionaryManipulator`);const s=async(s,c=(0,n.getConfiguration)())=>{let{dictionariesDir:l}=c.system;await(0,r.mkdir)((0,i.resolve)(l),{recursive:!0});let u=await e.parallelize(Object.entries(s),async([e,n])=>{if(e===`undefined`)return;let r=(0,o.mergeDictionaries)((0,o.normalizeDictionaries)(n.dictionaries,c)),s=(0,i.resolve)(l,`${e}.json`);return await t.writeJsonIfChanged(s,r).catch(e=>{console.error(`Error creating merged ${(0,a.colorizePath)(s)}:`,e)}),[e,{dictionaryPath:s,dictionary:r}]});return Object.fromEntries(u.filter(Boolean))};exports.writeMergedDictionaries=s;
|
|
47
2
|
//# sourceMappingURL=writeMergedDictionary.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeMergedDictionary.cjs","names":["parallelize","writeJsonIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath
|
|
1
|
+
{"version":3,"file":"writeMergedDictionary.cjs","names":["parallelize","writeJsonIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {\n mergeDictionaries,\n normalizeDictionaries,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types';\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 = getConfiguration()\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":"sXAoCA,MAAa,EAA0B,MACrC,EACA,GAAA,EAAA,EAAA,mBAAkC,GACE,CACpC,GAAM,CAAE,mBAAoB,EAAc,OAG1C,MAAA,EAAA,EAAA,QAAA,EAAA,EAAA,SAAoB,EAAgB,CAAE,CAAE,UAAW,GAAM,CAAC,CAE1D,IAAM,EAAU,MAAMA,EAAAA,YACpB,OAAO,QAAQ,EAAoB,CACnC,MAAO,CAAC,EAAK,KAAuB,CAClC,GAAI,IAAQ,YACV,OAWF,IAAM,GAAA,EAAA,EAAA,oBAAA,EAAA,EAAA,uBAJJ,EAAkB,aAClB,EACD,CAEiE,CAG5D,GAAA,EAAA,EAAA,SAAyB,EADR,GAAG,EAAI,OACiC,CAY/D,OATA,MAAMC,EAAAA,mBAAmB,EAAgB,EAAiB,CAAC,MACxD,GAAQ,CACP,QAAQ,MACN,0BAAA,EAAA,EAAA,cAAsC,EAAe,CAAC,GACtD,EACD,EAEJ,CAEM,CACL,EACA,CACE,eAAgB,EAChB,WAAY,EACb,CACF,EAEJ,CAED,OAAO,OAAO,YACZ,EAAQ,OAAO,QAAQ,CACxB"}
|
|
@@ -1,51 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_utils_parallelize = require('../utils/parallelize.cjs');
|
|
4
|
-
const require_writeJsonIfChanged = require('../writeJsonIfChanged.cjs');
|
|
5
|
-
const require_filterInvalidDictionaries = require('../filterInvalidDictionaries.cjs');
|
|
6
|
-
const require_buildIntlayerDictionary_writeUnmergedDictionary = require('./writeUnmergedDictionary.cjs');
|
|
7
|
-
const require_loadDictionaries_loadRemoteDictionaries = require('../loadDictionaries/loadRemoteDictionaries.cjs');
|
|
8
|
-
let _intlayer_config = require("@intlayer/config");
|
|
9
|
-
let node_fs_promises = require("node:fs/promises");
|
|
10
|
-
let node_path = require("node:path");
|
|
11
|
-
let _intlayer_core = require("@intlayer/core");
|
|
12
|
-
|
|
13
|
-
//#region src/buildIntlayerDictionary/writeRemoteDictionary.ts
|
|
14
|
-
/**
|
|
15
|
-
* Write the localized dictionaries to the dictionariesDir
|
|
16
|
-
* @param mergedDictionaries - The merged dictionaries
|
|
17
|
-
* @param configuration - The configuration
|
|
18
|
-
* @returns The final dictionaries
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
23
|
-
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
24
|
-
* console.log(finalDictionaries);
|
|
25
|
-
*
|
|
26
|
-
* // .intlayer/fetch_dictionaries/home.json
|
|
27
|
-
* // { key: 'home', content: { ... } },
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
const writeRemoteDictionary = async (remoteDictionaries, configuration = (0, _intlayer_config.getConfiguration)()) => {
|
|
31
|
-
const { remoteDictionariesDir } = configuration.system;
|
|
32
|
-
await (0, node_fs_promises.mkdir)((0, node_path.resolve)(remoteDictionariesDir), { recursive: true });
|
|
33
|
-
const groupedDictionaries = require_buildIntlayerDictionary_writeUnmergedDictionary.groupDictionariesByKey(require_filterInvalidDictionaries.filterInvalidDictionaries(remoteDictionaries, configuration));
|
|
34
|
-
const results = await require_utils_parallelize.parallelize(Object.entries(groupedDictionaries), async ([key, dictionaries]) => {
|
|
35
|
-
if (key === "undefined") return;
|
|
36
|
-
const orderedDictionaries = (0, _intlayer_core.orderDictionaries)(require_loadDictionaries_loadRemoteDictionaries.formatDistantDictionaries(dictionaries), configuration);
|
|
37
|
-
const unmergedFilePath = (0, node_path.resolve)(remoteDictionariesDir, `${key}.json`);
|
|
38
|
-
await require_writeJsonIfChanged.writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch((err) => {
|
|
39
|
-
console.error(`${_intlayer_config.x} Error creating unmerged ${(0, _intlayer_config.colorizePath)(unmergedFilePath)}:`, err);
|
|
40
|
-
});
|
|
41
|
-
return [key, {
|
|
42
|
-
dictionaryPath: unmergedFilePath,
|
|
43
|
-
dictionaries
|
|
44
|
-
}];
|
|
45
|
-
});
|
|
46
|
-
return Object.fromEntries(results.filter(Boolean));
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
//#endregion
|
|
50
|
-
exports.writeRemoteDictionary = writeRemoteDictionary;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../utils/parallelize.cjs`),t=require(`../writeJsonIfChanged.cjs`),n=require(`../filterInvalidDictionaries.cjs`),r=require(`./writeUnmergedDictionary.cjs`),i=require(`../loadDictionaries/loadRemoteDictionaries.cjs`);let a=require(`@intlayer/config/node`),o=require(`node:fs/promises`),s=require(`node:path`),c=require(`@intlayer/config/logger`),l=require(`@intlayer/core/dictionaryManipulator`);const u=async(u,d=(0,a.getConfiguration)())=>{let{remoteDictionariesDir:f}=d.system;await(0,o.mkdir)((0,s.resolve)(f),{recursive:!0});let p=r.groupDictionariesByKey(n.filterInvalidDictionaries(u,d)),m=await e.parallelize(Object.entries(p),async([e,n])=>{if(e===`undefined`)return;let r=(0,l.orderDictionaries)(i.formatDistantDictionaries(n),d),a=(0,s.resolve)(f,`${e}.json`);return await t.writeJsonIfChanged(a,r).catch(e=>{console.error(`${c.x} Error creating unmerged ${(0,c.colorizePath)(a)}:`,e)}),[e,{dictionaryPath:a,dictionaries:n}]});return Object.fromEntries(m.filter(Boolean))};exports.writeRemoteDictionary=u;
|
|
51
2
|
//# sourceMappingURL=writeRemoteDictionary.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeRemoteDictionary.cjs","names":["groupDictionariesByKey","filterInvalidDictionaries","parallelize","formatDistantDictionaries","writeJsonIfChanged","x"],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath,
|
|
1
|
+
{"version":3,"file":"writeRemoteDictionary.cjs","names":["groupDictionariesByKey","filterInvalidDictionaries","parallelize","formatDistantDictionaries","writeJsonIfChanged","x"],"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 { getConfiguration } from '@intlayer/config/node';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types';\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 = getConfiguration()\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":"2gBAsCA,MAAa,EAAwB,MACnC,EACA,GAAA,EAAA,EAAA,mBAAkC,GACE,CACpC,GAAM,CAAE,yBAA0B,EAAc,OAGhD,MAAA,EAAA,EAAA,QAAA,EAAA,EAAA,SAAoB,EAAsB,CAAE,CAAE,UAAW,GAAM,CAAC,CAQhE,IAAM,EAAsBA,EAAAA,uBANCC,EAAAA,0BAC3B,EACA,EACD,CAGuE,CAGlE,EAAU,MAAMC,EAAAA,YACpB,OAAO,QAAQ,EAAoB,CACnC,MAAO,CAAC,EAAK,KAAkB,CAC7B,GAAI,IAAQ,YACV,OAQF,IAAM,GAAA,EAAA,EAAA,mBAFwBC,EAAAA,0BAA0B,EAAa,CAInE,EACD,CAGK,GAAA,EAAA,EAAA,SAA2B,EADV,GAAG,EAAI,OACyC,CAYvE,OATA,MAAMC,EAAAA,mBAAmB,EAAkB,EAAoB,CAAC,MAC7D,GAAQ,CACP,QAAQ,MACN,GAAGC,EAAAA,EAAE,4BAAA,EAAA,EAAA,cAAwC,EAAiB,CAAC,GAC/D,EACD,EAEJ,CAEM,CACL,EACA,CACE,eAAgB,EAChB,eACD,CACF,EAEJ,CAED,OAAO,OAAO,YACZ,EAAQ,OAAO,QAAQ,CAGxB"}
|
|
@@ -1,60 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_utils_parallelize = require('../utils/parallelize.cjs');
|
|
4
|
-
const require_writeJsonIfChanged = require('../writeJsonIfChanged.cjs');
|
|
5
|
-
const require_filterInvalidDictionaries = require('../filterInvalidDictionaries.cjs');
|
|
6
|
-
let _intlayer_config = require("@intlayer/config");
|
|
7
|
-
let node_fs_promises = require("node:fs/promises");
|
|
8
|
-
let node_path = require("node:path");
|
|
9
|
-
let _intlayer_core = require("@intlayer/core");
|
|
10
|
-
|
|
11
|
-
//#region src/buildIntlayerDictionary/writeUnmergedDictionary.ts
|
|
12
|
-
const groupDictionariesByKey = (dictionaries) => dictionaries.reduce((acc, dictionary) => {
|
|
13
|
-
const key = dictionary.key;
|
|
14
|
-
if (!acc[key]) acc[key] = [];
|
|
15
|
-
acc[key].push(dictionary);
|
|
16
|
-
return acc;
|
|
17
|
-
}, {});
|
|
18
|
-
/**
|
|
19
|
-
* Write the unmerged dictionaries to the unmergedDictionariesDir
|
|
20
|
-
* @param dictionaries - The dictionaries to write
|
|
21
|
-
* @param configuration - The configuration
|
|
22
|
-
* @returns The grouped dictionaries
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
27
|
-
* console.log(unmergedDictionaries);
|
|
28
|
-
*
|
|
29
|
-
* // .intlayer/unmerged_dictionaries/home.json
|
|
30
|
-
* // {
|
|
31
|
-
* // [
|
|
32
|
-
* // { key: 'home', content: { ... } },
|
|
33
|
-
* // { key: 'home', content: { ... } },
|
|
34
|
-
* // ],
|
|
35
|
-
* // }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
const writeUnmergedDictionaries = async (dictionaries, configuration) => {
|
|
39
|
-
const { unmergedDictionariesDir } = configuration.system;
|
|
40
|
-
await (0, node_fs_promises.mkdir)((0, node_path.resolve)(unmergedDictionariesDir), { recursive: true });
|
|
41
|
-
const groupedDictionaries = groupDictionariesByKey(require_filterInvalidDictionaries.filterInvalidDictionaries(dictionaries, configuration, { checkSchema: true }));
|
|
42
|
-
const results = await require_utils_parallelize.parallelize(Object.entries(groupedDictionaries), async ([key, dictionaries]) => {
|
|
43
|
-
if (key === "undefined") return;
|
|
44
|
-
const orderedDictionaries = (0, _intlayer_core.orderDictionaries)(dictionaries, configuration);
|
|
45
|
-
const unmergedFilePath = (0, node_path.resolve)(unmergedDictionariesDir, `${key}.json`);
|
|
46
|
-
if (configuration.editor.enabled) await require_writeJsonIfChanged.writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch((err) => {
|
|
47
|
-
console.error(`${_intlayer_config.x} Error creating unmerged ${(0, _intlayer_config.colorizePath)(unmergedFilePath)}:`, err);
|
|
48
|
-
});
|
|
49
|
-
return [key, {
|
|
50
|
-
dictionaryPath: unmergedFilePath,
|
|
51
|
-
dictionaries
|
|
52
|
-
}];
|
|
53
|
-
});
|
|
54
|
-
return Object.fromEntries(results.filter(Boolean));
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
exports.groupDictionariesByKey = groupDictionariesByKey;
|
|
59
|
-
exports.writeUnmergedDictionaries = writeUnmergedDictionaries;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../utils/parallelize.cjs`),t=require(`../writeJsonIfChanged.cjs`),n=require(`../filterInvalidDictionaries.cjs`);let r=require(`node:fs/promises`),i=require(`node:path`),a=require(`@intlayer/config/logger`),o=require(`@intlayer/core/dictionaryManipulator`);const s=e=>e.reduce((e,t)=>{let n=t.key;return e[n]||(e[n]=[]),e[n].push(t),e},{}),c=async(c,l)=>{let{unmergedDictionariesDir:u}=l.system;await(0,r.mkdir)((0,i.resolve)(u),{recursive:!0});let d=s(n.filterInvalidDictionaries(c,l,{checkSchema:!0})),f=await e.parallelize(Object.entries(d),async([e,n])=>{if(e===`undefined`)return;let r=(0,o.orderDictionaries)(n,l),s=(0,i.resolve)(u,`${e}.json`);return l.editor.enabled&&await t.writeJsonIfChanged(s,r).catch(e=>{console.error(`${a.x} Error creating unmerged ${(0,a.colorizePath)(s)}:`,e)}),[e,{dictionaryPath:s,dictionaries:n}]});return Object.fromEntries(f.filter(Boolean))};exports.groupDictionariesByKey=s,exports.writeUnmergedDictionaries=c;
|
|
60
2
|
//# sourceMappingURL=writeUnmergedDictionary.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeUnmergedDictionary.cjs","names":["filterInvalidDictionaries","parallelize","writeJsonIfChanged","x"],"sources":["../../../src/buildIntlayerDictionary/writeUnmergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config';\nimport { orderDictionaries } from '@intlayer/core';\nimport type {\n Dictionary,\n DictionaryKey,\n IntlayerConfig,\n} from '@intlayer/types';\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): 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 // No need them if the editor is disabled\n if (configuration.editor.enabled) {\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.cjs","names":["filterInvalidDictionaries","parallelize","writeJsonIfChanged","x"],"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 {\n Dictionary,\n DictionaryKey,\n IntlayerConfig,\n} from '@intlayer/types';\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): 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 // No need them if the editor is disabled\n if (configuration.editor.enabled) {\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":"iYAaA,MAAa,EACX,GAEA,EAAa,QACV,EAAK,IAAe,CACnB,IAAM,EAAM,EAAW,IAKvB,OAJK,EAAI,KACP,EAAI,GAAO,EAAE,EAEf,EAAI,GAAK,KAAK,EAAW,CAClB,GAET,EAAE,CACH,CAgCU,EAA4B,MACvC,EACA,IACsC,CACtC,GAAM,CAAE,2BAA4B,EAAc,OAGlD,MAAA,EAAA,EAAA,QAAA,EAAA,EAAA,SAAoB,EAAwB,CAAE,CAAE,UAAW,GAAM,CAAC,CASlE,IAAM,EAAsB,EAPCA,EAAAA,0BAC3B,EACA,EACA,CAAE,YAAa,GAAM,CACtB,CAGuE,CAElE,EAAU,MAAMC,EAAAA,YACpB,OAAO,QAAQ,EAAoB,CACnC,MAAO,CAAC,EAAK,KAAkB,CAC7B,GAAI,IAAQ,YACV,OAMF,IAAM,GAAA,EAAA,EAAA,mBACJ,EACA,EACD,CAGK,GAAA,EAAA,EAAA,SAA2B,EADV,GAAG,EAAI,OAC2C,CAezE,OAXI,EAAc,OAAO,SACvB,MAAMC,EAAAA,mBAAmB,EAAkB,EAAoB,CAAC,MAC7D,GAAQ,CACP,QAAQ,MACN,GAAGC,EAAAA,EAAE,4BAAA,EAAA,EAAA,cAAwC,EAAiB,CAAC,GAC/D,EACD,EAEJ,CAGI,CACL,EACA,CACE,eAAgB,EACF,eACf,CACF,EAEJ,CAED,OAAO,OAAO,YACZ,EAAQ,OAAO,QAAQ,CAGxB"}
|
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let node_fs_promises = require("node:fs/promises");
|
|
4
|
-
let _intlayer_config_client = require("@intlayer/config/client");
|
|
5
|
-
let node_fs = require("node:fs");
|
|
6
|
-
|
|
7
|
-
//#region src/cleanOutputDir.ts
|
|
8
|
-
const cleanOutputDir = async (configuration) => {
|
|
9
|
-
const { dictionariesDir, unmergedDictionariesDir, dynamicDictionariesDir, remoteDictionariesDir, fetchDictionariesDir, mainDir, typesDir, configDir, cacheDir } = configuration.system;
|
|
10
|
-
const appLogger = (0, _intlayer_config_client.getAppLogger)(configuration);
|
|
11
|
-
const directoriesToClean = [
|
|
12
|
-
dictionariesDir,
|
|
13
|
-
unmergedDictionariesDir,
|
|
14
|
-
dynamicDictionariesDir,
|
|
15
|
-
remoteDictionariesDir,
|
|
16
|
-
fetchDictionariesDir,
|
|
17
|
-
mainDir,
|
|
18
|
-
typesDir,
|
|
19
|
-
configDir,
|
|
20
|
-
cacheDir
|
|
21
|
-
];
|
|
22
|
-
await Promise.all(directoriesToClean.filter((dir) => (0, node_fs.existsSync)(dir)).map((dir) => (0, node_fs_promises.rm)(dir, {
|
|
23
|
-
recursive: true,
|
|
24
|
-
force: true
|
|
25
|
-
})));
|
|
26
|
-
appLogger("Output directory cleaned", { isVerbose: true });
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
exports.cleanOutputDir = cleanOutputDir;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/config/client`),t=require(`node:fs/promises`),n=require(`node:fs`);const r=async r=>{let{dictionariesDir:i,unmergedDictionariesDir:a,dynamicDictionariesDir:o,remoteDictionariesDir:s,fetchDictionariesDir:c,mainDir:l,typesDir:u,configDir:d,cacheDir:f}=r.system,p=(0,e.getAppLogger)(r),m=[i,a,o,s,c,l,u,d,f];await Promise.all(m.filter(e=>(0,n.existsSync)(e)).map(e=>(0,t.rm)(e,{recursive:!0,force:!0}))),p(`Output directory cleaned`,{isVerbose:!0})};exports.cleanOutputDir=r;
|
|
31
2
|
//# sourceMappingURL=cleanOutputDir.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanOutputDir.cjs","names":[],"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { getAppLogger } from '@intlayer/config/client';\nimport type { IntlayerConfig } from '@intlayer/types';\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.cjs","names":[],"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { getAppLogger } from '@intlayer/config/client';\nimport type { IntlayerConfig } from '@intlayer/types';\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":"2MAKA,MAAa,EAAiB,KAAO,IAAkC,CACrE,GAAM,CACJ,kBACA,0BACA,yBACA,wBACA,uBACA,UACA,WACA,YACA,YACE,EAAc,OAEZ,GAAA,EAAA,EAAA,cAAyB,EAAc,CAEvC,EAA+B,CACnC,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACD,CAGD,MAAM,QAAQ,IACZ,EACG,OAAQ,IAAA,EAAA,EAAA,YAAmB,EAAI,CAAC,CAChC,IAAK,IAAA,EAAA,EAAA,IAAW,EAAK,CAAE,UAAW,GAAM,MAAO,GAAM,CAAC,CAAC,CAC3D,CAED,EAAU,2BAA4B,CACpC,UAAW,GACZ,CAAC"}
|
|
@@ -1,97 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_writeJsonIfChanged = require('./writeJsonIfChanged.cjs');
|
|
4
|
-
const require_createDictionaryEntryPoint_createDictionaryEntryPoint = require('./createDictionaryEntryPoint/createDictionaryEntryPoint.cjs');
|
|
5
|
-
let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
|
|
6
|
-
let node_fs_promises = require("node:fs/promises");
|
|
7
|
-
let node_path = require("node:path");
|
|
8
|
-
let _intlayer_config_client = require("@intlayer/config/client");
|
|
9
|
-
let fast_glob = require("fast-glob");
|
|
10
|
-
fast_glob = require_runtime.__toESM(fast_glob);
|
|
11
|
-
let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
|
|
12
|
-
|
|
13
|
-
//#region src/cleanRemovedContentDeclaration.ts
|
|
14
|
-
const cleanRemovedContentDeclaration = async (filePath, keysToKeep, configuration) => {
|
|
15
|
-
const appLogger = (0, _intlayer_config_client.getAppLogger)(configuration);
|
|
16
|
-
const unmergedDictionaries = (0, _intlayer_unmerged_dictionaries_entry.getUnmergedDictionaries)(configuration);
|
|
17
|
-
const baseDir = configuration.content.baseDir;
|
|
18
|
-
const relativeFilePath = (0, node_path.relative)(baseDir, filePath);
|
|
19
|
-
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));
|
|
20
|
-
const changedDictionariesLocalIds = [];
|
|
21
|
-
const filesToRemove = [];
|
|
22
|
-
const excludeKeys = [];
|
|
23
|
-
await Promise.all(uniqueUnmergedDictionaries.map(async (dictionary) => {
|
|
24
|
-
const unmergedFilePath = (0, node_path.normalize)((0, node_path.join)(configuration.system.unmergedDictionariesDir, `${dictionary.key}.json`));
|
|
25
|
-
try {
|
|
26
|
-
const jsonContent = await (0, node_fs_promises.readFile)(unmergedFilePath, "utf8");
|
|
27
|
-
const parsedContent = JSON.parse(jsonContent);
|
|
28
|
-
if (parsedContent.length === 1) {
|
|
29
|
-
if (parsedContent[0].filePath === relativeFilePath) {
|
|
30
|
-
appLogger(`Removing outdated dictionary ${(0, _intlayer_config_client.colorizeKey)(dictionary.key)}`, { isVerbose: true });
|
|
31
|
-
filesToRemove.push(unmergedFilePath);
|
|
32
|
-
excludeKeys.push(dictionary.key);
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
await require_writeJsonIfChanged.writeJsonIfChanged(unmergedFilePath, parsedContent.filter((content) => content.filePath !== relativeFilePath));
|
|
36
|
-
changedDictionariesLocalIds.push(dictionary.localId);
|
|
37
|
-
}
|
|
38
|
-
} catch (error) {
|
|
39
|
-
if (error.code === "ENOENT") {
|
|
40
|
-
if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}));
|
|
44
|
-
const dictionaries = (0, _intlayer_dictionaries_entry.getDictionaries)(configuration);
|
|
45
|
-
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));
|
|
46
|
-
await Promise.all(uniqueMergedDictionaries.map(async (dictionary) => {
|
|
47
|
-
const mergedFilePath = (0, node_path.normalize)((0, node_path.join)(configuration.system.dictionariesDir, `${dictionary.key}.json`));
|
|
48
|
-
try {
|
|
49
|
-
const fileContent = await (0, node_fs_promises.readFile)(mergedFilePath, "utf8");
|
|
50
|
-
const parsedContent = JSON.parse(fileContent);
|
|
51
|
-
if (parsedContent.localIds?.length === 1) {
|
|
52
|
-
if (parsedContent.localIds[0].endsWith(`::local::${relativeFilePath}`)) {
|
|
53
|
-
appLogger(`Removing outdated unmerged dictionary ${(0, _intlayer_config_client.colorizeKey)(dictionary.key)}`, { isVerbose: true });
|
|
54
|
-
filesToRemove.push(mergedFilePath);
|
|
55
|
-
const typesFilePath = (0, node_path.normalize)((0, node_path.join)(configuration.system.typesDir, `${dictionary.key}.ts`));
|
|
56
|
-
filesToRemove.push(typesFilePath);
|
|
57
|
-
const dynamicFiles = await (0, fast_glob.default)((0, _intlayer_config_client.normalizePath)((0, node_path.join)(configuration.system.dynamicDictionariesDir, `${dictionary.key}.*`)), { absolute: true });
|
|
58
|
-
filesToRemove.push(...dynamicFiles);
|
|
59
|
-
if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
const localIds = parsedContent.localIds?.filter((localeId) => !localeId.endsWith(`::local::${relativeFilePath}`));
|
|
63
|
-
await require_writeJsonIfChanged.writeJsonIfChanged(mergedFilePath, {
|
|
64
|
-
...parsedContent,
|
|
65
|
-
localIds
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
} catch (error) {
|
|
69
|
-
if (error.code === "ENOENT") {
|
|
70
|
-
if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
|
|
71
|
-
const typesFilePath = (0, node_path.normalize)((0, node_path.join)(configuration.system.typesDir, `${dictionary.key}.ts`));
|
|
72
|
-
filesToRemove.push(typesFilePath);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}));
|
|
76
|
-
if (filesToRemove.length > 0 || excludeKeys.length > 0) {
|
|
77
|
-
await require_createDictionaryEntryPoint_createDictionaryEntryPoint.createDictionaryEntryPoint(configuration, { excludeKeys });
|
|
78
|
-
if (filesToRemove.length > 0) await Promise.all(filesToRemove.map(async (path) => {
|
|
79
|
-
const relativePath = (0, node_path.relative)(baseDir, path);
|
|
80
|
-
try {
|
|
81
|
-
await (0, node_fs_promises.rm)(path, { force: true });
|
|
82
|
-
appLogger(`Deleted artifact: ${(0, _intlayer_config_client.colorizePath)(relativePath)}`, { isVerbose: true });
|
|
83
|
-
} catch {
|
|
84
|
-
appLogger(`Error while removing file ${(0, _intlayer_config_client.colorizePath)(relativePath)}`, { isVerbose: true });
|
|
85
|
-
}
|
|
86
|
-
}));
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
changedDictionariesLocalIds,
|
|
90
|
-
excludeKeys,
|
|
91
|
-
hasRebuilt: filesToRemove.length > 0 || excludeKeys.length > 0
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
//#endregion
|
|
96
|
-
exports.cleanRemovedContentDeclaration = cleanRemovedContentDeclaration;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./writeJsonIfChanged.cjs`),n=require(`./createDictionaryEntryPoint/createDictionaryEntryPoint.cjs`);let r=require(`@intlayer/config/client`),i=require(`@intlayer/unmerged-dictionaries-entry`),a=require(`node:fs/promises`),o=require(`node:path`),s=require(`fast-glob`);s=e.__toESM(s);let c=require(`@intlayer/dictionaries-entry`);const l=async(e,l,u)=>{let d=(0,r.getAppLogger)(u),f=(0,i.getUnmergedDictionaries)(u),p=u.content.baseDir,m=(0,o.relative)(p,e),h=Object.values(f).flat().filter(e=>e.filePath===m&&!l.includes(e.key)).filter((e,t,n)=>t===n.findIndex(t=>t.key===e.key)),g=[],_=[],v=[];await Promise.all(h.map(async e=>{let n=(0,o.normalize)((0,o.join)(u.system.unmergedDictionariesDir,`${e.key}.json`));try{let i=await(0,a.readFile)(n,`utf8`),o=JSON.parse(i);o.length===1?o[0].filePath===m&&(d(`Removing outdated dictionary ${(0,r.colorizeKey)(e.key)}`,{isVerbose:!0}),_.push(n),v.push(e.key)):(await t.writeJsonIfChanged(n,o.filter(e=>e.filePath!==m)),g.push(e.localId))}catch(t){t.code===`ENOENT`&&(v.includes(e.key)||v.push(e.key))}}));let y=(0,c.getDictionaries)(u),b=(Object.values(y)?.filter(e=>!l.includes(e.key)&&e.localIds?.length===1&&e.localIds[0].endsWith(`::local::${m}`))).filter((e,t,n)=>t===n.findIndex(t=>t.key===e.key));return await Promise.all(b.map(async e=>{let n=(0,o.normalize)((0,o.join)(u.system.dictionariesDir,`${e.key}.json`));try{let i=await(0,a.readFile)(n,`utf8`),c=JSON.parse(i);if(c.localIds?.length===1){if(c.localIds[0].endsWith(`::local::${m}`)){d(`Removing outdated unmerged dictionary ${(0,r.colorizeKey)(e.key)}`,{isVerbose:!0}),_.push(n);let t=(0,o.normalize)((0,o.join)(u.system.typesDir,`${e.key}.ts`));_.push(t);let i=await(0,s.default)((0,r.normalizePath)((0,o.join)(u.system.dynamicDictionariesDir,`${e.key}.*`)),{absolute:!0});_.push(...i),v.includes(e.key)||v.push(e.key)}}else{let e=c.localIds?.filter(e=>!e.endsWith(`::local::${m}`));await t.writeJsonIfChanged(n,{...c,localIds:e})}}catch(t){if(t.code===`ENOENT`){v.includes(e.key)||v.push(e.key);let t=(0,o.normalize)((0,o.join)(u.system.typesDir,`${e.key}.ts`));_.push(t)}}})),(_.length>0||v.length>0)&&(await n.createDictionaryEntryPoint(u,{excludeKeys:v}),_.length>0&&await Promise.all(_.map(async e=>{let t=(0,o.relative)(p,e);try{await(0,a.rm)(e,{force:!0}),d(`Deleted artifact: ${(0,r.colorizePath)(t)}`,{isVerbose:!0})}catch{d(`Error while removing file ${(0,r.colorizePath)(t)}`,{isVerbose:!0})}}))),{changedDictionariesLocalIds:g,excludeKeys:v,hasRebuilt:_.length>0||v.length>0}};exports.cleanRemovedContentDeclaration=l;
|
|
97
2
|
//# sourceMappingURL=cleanRemovedContentDeclaration.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanRemovedContentDeclaration.cjs","names":["writeJsonIfChanged","createDictionaryEntryPoint"],"sources":["../../src/cleanRemovedContentDeclaration.ts"],"sourcesContent":["import { readFile, rm } from 'node:fs/promises';\nimport { join, normalize, relative } from 'node:path';\nimport {\n colorizeKey,\n colorizePath,\n getAppLogger,\n normalizePath,\n} from '@intlayer/config/client';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\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.content.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.cjs","names":["writeJsonIfChanged","createDictionaryEntryPoint"],"sources":["../../src/cleanRemovedContentDeclaration.ts"],"sourcesContent":["import { readFile, rm } from 'node:fs/promises';\nimport { join, normalize, relative } from 'node:path';\nimport {\n colorizeKey,\n colorizePath,\n getAppLogger,\n normalizePath,\n} from '@intlayer/config/client';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\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.content.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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"}
|