@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,76 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/writeContentDeclaration/transformJSONFile.ts
|
|
4
|
-
/**
|
|
5
|
-
* Checks if a value is a plain object (and not null/array)
|
|
6
|
-
*/
|
|
7
|
-
const isPlainObject = (value) => {
|
|
8
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Safely formats a key for use in object literals.
|
|
12
|
-
* Always quotes keys to ensure compatibility with standard JSON files.
|
|
13
|
-
*/
|
|
14
|
-
const stringifyKey = (objectKey) => {
|
|
15
|
-
return JSON.stringify(objectKey);
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Robustly finds a property in an ObjectLiteralExpression.
|
|
19
|
-
* Handles cases where the property name in the source file is quoted ("key") or unquoted (key).
|
|
20
|
-
*/
|
|
21
|
-
const getMatchingProperty = (node, key) => {
|
|
22
|
-
return node.getProperties().find((prop) => {
|
|
23
|
-
if (Node.isPropertyAssignment(prop)) {
|
|
24
|
-
const propName = prop.getName();
|
|
25
|
-
return propName === key || propName === `"${key}"` || propName === `'${key}'`;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Recursively updates the AST object literal with new data.
|
|
32
|
-
*/
|
|
33
|
-
const updateObjectLiteral = (node, data) => {
|
|
34
|
-
for (const [key, val] of Object.entries(data)) {
|
|
35
|
-
if (val === void 0) continue;
|
|
36
|
-
const stringifiedValue = JSON.stringify(val, null, 2);
|
|
37
|
-
if (stringifiedValue === void 0 && !isPlainObject(val)) continue;
|
|
38
|
-
const existingProp = getMatchingProperty(node, key);
|
|
39
|
-
if (isPlainObject(val)) if (existingProp && Node.isPropertyAssignment(existingProp)) {
|
|
40
|
-
const initializer = existingProp.getInitializer();
|
|
41
|
-
if (Node.isObjectLiteralExpression(initializer)) updateObjectLiteral(initializer, val);
|
|
42
|
-
else existingProp.setInitializer(stringifiedValue);
|
|
43
|
-
} else if (existingProp) existingProp.replaceWithText(`${stringifyKey(key)}: ${stringifiedValue}`);
|
|
44
|
-
else node.addPropertyAssignment({
|
|
45
|
-
name: stringifyKey(key),
|
|
46
|
-
initializer: stringifiedValue
|
|
47
|
-
});
|
|
48
|
-
else if (existingProp && Node.isPropertyAssignment(existingProp)) existingProp.setInitializer(stringifiedValue);
|
|
49
|
-
else if (existingProp) existingProp.replaceWithText(`${stringifyKey(key)}: ${stringifiedValue}`);
|
|
50
|
-
else node.addPropertyAssignment({
|
|
51
|
-
name: stringifyKey(key),
|
|
52
|
-
initializer: stringifiedValue
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const transformJSONFile = (fileContent, dictionary) => {
|
|
57
|
-
const project = new Project({
|
|
58
|
-
useInMemoryFileSystem: true,
|
|
59
|
-
manipulationSettings: {
|
|
60
|
-
indentationText: IndentationText.TwoSpaces,
|
|
61
|
-
quoteKind: QuoteKind.Double
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
const dummyFileName = "temp.ts";
|
|
65
|
-
const wrappedContent = `const _config = ${fileContent.trim() || "{}"}`;
|
|
66
|
-
const sourceFile = project.createSourceFile(dummyFileName, wrappedContent);
|
|
67
|
-
const objectLiteral = sourceFile.getVariableDeclaration("_config")?.getInitializerIfKind(SyntaxKind.ObjectLiteralExpression);
|
|
68
|
-
if (!objectLiteral) return JSON.stringify(dictionary, null, 2);
|
|
69
|
-
updateObjectLiteral(objectLiteral, dictionary);
|
|
70
|
-
sourceFile.formatText();
|
|
71
|
-
return objectLiteral.getText();
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
//#endregion
|
|
75
|
-
export { transformJSONFile };
|
|
1
|
+
import{IndentationText as e,Node as t,Project as n,QuoteKind as r,SyntaxKind as i}from"ts-morph";const a=e=>typeof e==`object`&&!!e&&!Array.isArray(e),o=e=>JSON.stringify(e),s=(e,n)=>e.getProperties().find(e=>{if(t.isPropertyAssignment(e)){let t=e.getName();return t===n||t===`"${n}"`||t===`'${n}'`}return!1}),c=(e,n)=>{for(let[r,i]of Object.entries(n)){if(i===void 0)continue;let n=JSON.stringify(i,null,2);if(n===void 0&&!a(i))continue;let l=s(e,r);if(a(i))if(l&&t.isPropertyAssignment(l)){let e=l.getInitializer();t.isObjectLiteralExpression(e)?c(e,i):l.setInitializer(n)}else l?l.replaceWithText(`${o(r)}: ${n}`):e.addPropertyAssignment({name:o(r),initializer:n});else l&&t.isPropertyAssignment(l)?l.setInitializer(n):l?l.replaceWithText(`${o(r)}: ${n}`):e.addPropertyAssignment({name:o(r),initializer:n})}},l=(t,a)=>{let o=new n({useInMemoryFileSystem:!0,manipulationSettings:{indentationText:e.TwoSpaces,quoteKind:r.Double}}),s=`const _config = ${t.trim()||`{}`}`,l=o.createSourceFile(`temp.ts`,s),u=l.getVariableDeclaration(`_config`)?.getInitializerIfKind(i.ObjectLiteralExpression);return u?(c(u,a),l.formatText(),u.getText()):JSON.stringify(a,null,2)};export{l as transformJSONFile};
|
|
76
2
|
//# sourceMappingURL=transformJSONFile.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformJSONFile.mjs","names":[],"sources":["../../../src/writeContentDeclaration/transformJSONFile.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types';\nimport {\n IndentationText,\n Node,\n type ObjectLiteralExpression,\n Project,\n QuoteKind,\n SyntaxKind,\n} from 'ts-morph';\n\n/**\n * Checks if a value is a plain object (and not null/array)\n */\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\n/**\n * Safely formats a key for use in object literals.\n * Always quotes keys to ensure compatibility with standard JSON files.\n */\nconst stringifyKey = (objectKey: string): string => {\n return JSON.stringify(objectKey);\n};\n\n/**\n * Robustly finds a property in an ObjectLiteralExpression.\n * Handles cases where the property name in the source file is quoted (\"key\") or unquoted (key).\n */\nconst getMatchingProperty = (node: ObjectLiteralExpression, key: string) => {\n return node.getProperties().find((prop) => {\n // We only care about property assignments (key: value)\n if (Node.isPropertyAssignment(prop)) {\n const propName = prop.getName();\n // Check for strict match (unquoted identifier) or quoted match (string literal)\n // We check both double and single quotes to handle JSONC/JSON5 variations.\n return (\n propName === key || propName === `\"${key}\"` || propName === `'${key}'`\n );\n }\n return false;\n });\n};\n\n/**\n * Recursively updates the AST object literal with new data.\n */\nconst updateObjectLiteral = (\n node: ObjectLiteralExpression,\n data: Record<string, any>\n) => {\n for (const [key, val] of Object.entries(data)) {\n // Skip undefined values.\n if (val === undefined) continue;\n\n const stringifiedValue = JSON.stringify(val, null, 2);\n\n // Safety check: ensure we have a string unless we are recursing into an object\n if (stringifiedValue === undefined && !isPlainObject(val)) continue;\n\n // Use robust lookup instead of node.getProperty(key)\n const existingProp = getMatchingProperty(node, key);\n\n if (isPlainObject(val)) {\n if (existingProp && Node.isPropertyAssignment(existingProp)) {\n const initializer = existingProp.getInitializer();\n\n if (Node.isObjectLiteralExpression(initializer)) {\n // Recurse into nested object\n updateObjectLiteral(initializer, val);\n } else {\n // Property exists but is not an object (e.g. was null or number), overwrite with new object\n existingProp.setInitializer(stringifiedValue!);\n }\n } else if (existingProp) {\n // Property exists but isn't a simple assignment, overwrite it safely\n existingProp.replaceWithText(\n `${stringifyKey(key)}: ${stringifiedValue}`\n );\n } else {\n // Property doesn't exist, add it\n node.addPropertyAssignment({\n name: stringifyKey(key),\n initializer: stringifiedValue!,\n });\n }\n } else {\n // Handling Primitives / Arrays\n if (existingProp && Node.isPropertyAssignment(existingProp)) {\n existingProp.setInitializer(stringifiedValue!);\n } else if (existingProp) {\n existingProp.replaceWithText(\n `${stringifyKey(key)}: ${stringifiedValue}`\n );\n } else {\n node.addPropertyAssignment({\n name: stringifyKey(key),\n initializer: stringifiedValue!,\n });\n }\n }\n }\n};\n\nexport const transformJSONFile = (\n fileContent: string,\n dictionary: Dictionary\n): string => {\n // Initialize a virtual project\n const project = new Project({\n useInMemoryFileSystem: true,\n manipulationSettings: {\n indentationText: IndentationText.TwoSpaces,\n quoteKind: QuoteKind.Double,\n },\n });\n\n // Wrap content in a variable declaration so it acts as a valid SourceFile\n const dummyFileName = 'temp.ts';\n const wrappedContent = `const _config = ${fileContent.trim() || '{}'}`;\n const sourceFile = project.createSourceFile(dummyFileName, wrappedContent);\n\n // Locate the object literal\n const varDecl = sourceFile.getVariableDeclaration('_config');\n const objectLiteral = varDecl?.getInitializerIfKind(\n SyntaxKind.ObjectLiteralExpression\n );\n\n if (!objectLiteral) {\n // Fallback if parsing failed\n return JSON.stringify(dictionary, null, 2);\n }\n\n // Update the AST\n updateObjectLiteral(objectLiteral, dictionary);\n\n // Format text to ensure new properties are aligned\n sourceFile.formatText();\n\n // Extract the object literal text.\n return objectLiteral.getText();\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"transformJSONFile.mjs","names":[],"sources":["../../../src/writeContentDeclaration/transformJSONFile.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types';\nimport {\n IndentationText,\n Node,\n type ObjectLiteralExpression,\n Project,\n QuoteKind,\n SyntaxKind,\n} from 'ts-morph';\n\n/**\n * Checks if a value is a plain object (and not null/array)\n */\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\n/**\n * Safely formats a key for use in object literals.\n * Always quotes keys to ensure compatibility with standard JSON files.\n */\nconst stringifyKey = (objectKey: string): string => {\n return JSON.stringify(objectKey);\n};\n\n/**\n * Robustly finds a property in an ObjectLiteralExpression.\n * Handles cases where the property name in the source file is quoted (\"key\") or unquoted (key).\n */\nconst getMatchingProperty = (node: ObjectLiteralExpression, key: string) => {\n return node.getProperties().find((prop) => {\n // We only care about property assignments (key: value)\n if (Node.isPropertyAssignment(prop)) {\n const propName = prop.getName();\n // Check for strict match (unquoted identifier) or quoted match (string literal)\n // We check both double and single quotes to handle JSONC/JSON5 variations.\n return (\n propName === key || propName === `\"${key}\"` || propName === `'${key}'`\n );\n }\n return false;\n });\n};\n\n/**\n * Recursively updates the AST object literal with new data.\n */\nconst updateObjectLiteral = (\n node: ObjectLiteralExpression,\n data: Record<string, any>\n) => {\n for (const [key, val] of Object.entries(data)) {\n // Skip undefined values.\n if (val === undefined) continue;\n\n const stringifiedValue = JSON.stringify(val, null, 2);\n\n // Safety check: ensure we have a string unless we are recursing into an object\n if (stringifiedValue === undefined && !isPlainObject(val)) continue;\n\n // Use robust lookup instead of node.getProperty(key)\n const existingProp = getMatchingProperty(node, key);\n\n if (isPlainObject(val)) {\n if (existingProp && Node.isPropertyAssignment(existingProp)) {\n const initializer = existingProp.getInitializer();\n\n if (Node.isObjectLiteralExpression(initializer)) {\n // Recurse into nested object\n updateObjectLiteral(initializer, val);\n } else {\n // Property exists but is not an object (e.g. was null or number), overwrite with new object\n existingProp.setInitializer(stringifiedValue!);\n }\n } else if (existingProp) {\n // Property exists but isn't a simple assignment, overwrite it safely\n existingProp.replaceWithText(\n `${stringifyKey(key)}: ${stringifiedValue}`\n );\n } else {\n // Property doesn't exist, add it\n node.addPropertyAssignment({\n name: stringifyKey(key),\n initializer: stringifiedValue!,\n });\n }\n } else {\n // Handling Primitives / Arrays\n if (existingProp && Node.isPropertyAssignment(existingProp)) {\n existingProp.setInitializer(stringifiedValue!);\n } else if (existingProp) {\n existingProp.replaceWithText(\n `${stringifyKey(key)}: ${stringifiedValue}`\n );\n } else {\n node.addPropertyAssignment({\n name: stringifyKey(key),\n initializer: stringifiedValue!,\n });\n }\n }\n }\n};\n\nexport const transformJSONFile = (\n fileContent: string,\n dictionary: Dictionary\n): string => {\n // Initialize a virtual project\n const project = new Project({\n useInMemoryFileSystem: true,\n manipulationSettings: {\n indentationText: IndentationText.TwoSpaces,\n quoteKind: QuoteKind.Double,\n },\n });\n\n // Wrap content in a variable declaration so it acts as a valid SourceFile\n const dummyFileName = 'temp.ts';\n const wrappedContent = `const _config = ${fileContent.trim() || '{}'}`;\n const sourceFile = project.createSourceFile(dummyFileName, wrappedContent);\n\n // Locate the object literal\n const varDecl = sourceFile.getVariableDeclaration('_config');\n const objectLiteral = varDecl?.getInitializerIfKind(\n SyntaxKind.ObjectLiteralExpression\n );\n\n if (!objectLiteral) {\n // Fallback if parsing failed\n return JSON.stringify(dictionary, null, 2);\n }\n\n // Update the AST\n updateObjectLiteral(objectLiteral, dictionary);\n\n // Format text to ensure new properties are aligned\n sourceFile.formatText();\n\n // Extract the object literal text.\n return objectLiteral.getText();\n};\n"],"mappings":"iGAaA,MAAM,EAAiB,GACd,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,EAAM,CAOvE,EAAgB,GACb,KAAK,UAAU,EAAU,CAO5B,GAAuB,EAA+B,IACnD,EAAK,eAAe,CAAC,KAAM,GAAS,CAEzC,GAAI,EAAK,qBAAqB,EAAK,CAAE,CACnC,IAAM,EAAW,EAAK,SAAS,CAG/B,OACE,IAAa,GAAO,IAAa,IAAI,EAAI,IAAM,IAAa,IAAI,EAAI,GAGxE,MAAO,IACP,CAME,GACJ,EACA,IACG,CACH,IAAK,GAAM,CAAC,EAAK,KAAQ,OAAO,QAAQ,EAAK,CAAE,CAE7C,GAAI,IAAQ,IAAA,GAAW,SAEvB,IAAM,EAAmB,KAAK,UAAU,EAAK,KAAM,EAAE,CAGrD,GAAI,IAAqB,IAAA,IAAa,CAAC,EAAc,EAAI,CAAE,SAG3D,IAAM,EAAe,EAAoB,EAAM,EAAI,CAEnD,GAAI,EAAc,EAAI,CACpB,GAAI,GAAgB,EAAK,qBAAqB,EAAa,CAAE,CAC3D,IAAM,EAAc,EAAa,gBAAgB,CAE7C,EAAK,0BAA0B,EAAY,CAE7C,EAAoB,EAAa,EAAI,CAGrC,EAAa,eAAe,EAAkB,MAEvC,EAET,EAAa,gBACX,GAAG,EAAa,EAAI,CAAC,IAAI,IAC1B,CAGD,EAAK,sBAAsB,CACzB,KAAM,EAAa,EAAI,CACvB,YAAa,EACd,CAAC,MAIA,GAAgB,EAAK,qBAAqB,EAAa,CACzD,EAAa,eAAe,EAAkB,CACrC,EACT,EAAa,gBACX,GAAG,EAAa,EAAI,CAAC,IAAI,IAC1B,CAED,EAAK,sBAAsB,CACzB,KAAM,EAAa,EAAI,CACvB,YAAa,EACd,CAAC,GAMG,GACX,EACA,IACW,CAEX,IAAM,EAAU,IAAI,EAAQ,CAC1B,sBAAuB,GACvB,qBAAsB,CACpB,gBAAiB,EAAgB,UACjC,UAAW,EAAU,OACtB,CACF,CAAC,CAII,EAAiB,mBAAmB,EAAY,MAAM,EAAI,OAC1D,EAAa,EAAQ,iBAAiB,UAAe,EAAe,CAIpE,EADU,EAAW,uBAAuB,UAAU,EAC7B,qBAC7B,EAAW,wBACZ,CAcD,OAZK,GAML,EAAoB,EAAe,EAAW,CAG9C,EAAW,YAAY,CAGhB,EAAc,SAAS,EAVrB,KAAK,UAAU,EAAY,KAAM,EAAE"}
|
|
@@ -1,122 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { processContentDeclarationContent } from "./processContentDeclarationContent.mjs";
|
|
3
|
-
import { transformJSONFile } from "./transformJSONFile.mjs";
|
|
4
|
-
import { writeJSFile } from "./writeJSFile.mjs";
|
|
5
|
-
import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
|
|
6
|
-
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
7
|
-
import { dirname, extname, join, resolve } from "node:path";
|
|
8
|
-
import { getFilteredLocalesDictionary, getPerLocaleDictionary } from "@intlayer/core";
|
|
9
|
-
import { existsSync } from "node:fs";
|
|
10
|
-
import { isDeepStrictEqual } from "node:util";
|
|
11
|
-
|
|
12
|
-
//#region src/writeContentDeclaration/writeContentDeclaration.ts
|
|
13
|
-
const formatContentDeclaration = async (dictionary, configuration, localeList) => {
|
|
14
|
-
/**
|
|
15
|
-
* Clean Markdown, Insertion, File, etc. node metadata
|
|
16
|
-
*/
|
|
17
|
-
const processedDictionary = await processContentDeclarationContent(dictionary);
|
|
18
|
-
let content = processedDictionary.content;
|
|
19
|
-
/**
|
|
20
|
-
* Filter locales content
|
|
21
|
-
*/
|
|
22
|
-
if (dictionary.locale) content = getPerLocaleDictionary(processedDictionary, dictionary.locale).content;
|
|
23
|
-
else if (localeList) content = getFilteredLocalesDictionary(processedDictionary, localeList).content;
|
|
24
|
-
let pluginFormatResult = {
|
|
25
|
-
...dictionary,
|
|
26
|
-
content
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Format the dictionary with the plugins
|
|
30
|
-
*/
|
|
31
|
-
for await (const plugin of configuration.plugins ?? []) if (plugin.formatOutput) {
|
|
32
|
-
const formattedResult = await plugin.formatOutput?.({
|
|
33
|
-
dictionary: pluginFormatResult,
|
|
34
|
-
configuration
|
|
35
|
-
});
|
|
36
|
-
if (formattedResult) pluginFormatResult = formattedResult;
|
|
37
|
-
}
|
|
38
|
-
if (!(pluginFormatResult.content && pluginFormatResult.key)) return pluginFormatResult;
|
|
39
|
-
let result = {
|
|
40
|
-
key: dictionary.key,
|
|
41
|
-
id: dictionary.id,
|
|
42
|
-
title: dictionary.title,
|
|
43
|
-
description: dictionary.description,
|
|
44
|
-
tags: dictionary.tags,
|
|
45
|
-
locale: dictionary.locale,
|
|
46
|
-
fill: dictionary.fill,
|
|
47
|
-
filled: dictionary.filled,
|
|
48
|
-
priority: dictionary.priority,
|
|
49
|
-
importMode: dictionary.importMode,
|
|
50
|
-
version: dictionary.version,
|
|
51
|
-
content
|
|
52
|
-
};
|
|
53
|
-
if (getFormatFromExtension(dictionary.filePath ? extname(dictionary.filePath) : ".json") === "json" && pluginFormatResult.content && pluginFormatResult.key) result = {
|
|
54
|
-
$schema: "https://intlayer.org/schema.json",
|
|
55
|
-
...result
|
|
56
|
-
};
|
|
57
|
-
return result;
|
|
58
|
-
};
|
|
59
|
-
const defaultOptions = { newDictionariesPath: "intlayer-dictionaries" };
|
|
60
|
-
const writeContentDeclaration = async (dictionary, configuration, options) => {
|
|
61
|
-
const { content } = configuration;
|
|
62
|
-
const { baseDir } = content;
|
|
63
|
-
const { newDictionariesPath, localeList } = {
|
|
64
|
-
...defaultOptions,
|
|
65
|
-
...options
|
|
66
|
-
};
|
|
67
|
-
const newDictionaryLocationPath = join(baseDir, newDictionariesPath);
|
|
68
|
-
const existingDictionary = getUnmergedDictionaries(configuration)[dictionary.key]?.find((el) => el.localId === dictionary.localId);
|
|
69
|
-
const formattedContentDeclaration = await formatContentDeclaration(dictionary, configuration, localeList);
|
|
70
|
-
if (existingDictionary?.filePath) {
|
|
71
|
-
const isSameContent = isDeepStrictEqual(existingDictionary, dictionary);
|
|
72
|
-
const filePath = resolve(configuration.content.baseDir, existingDictionary.filePath);
|
|
73
|
-
if (isSameContent) return {
|
|
74
|
-
status: "up-to-date",
|
|
75
|
-
path: filePath
|
|
76
|
-
};
|
|
77
|
-
await writeFileWithDirectories(filePath, formattedContentDeclaration, configuration);
|
|
78
|
-
return {
|
|
79
|
-
status: "updated",
|
|
80
|
-
path: filePath
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
if (dictionary.filePath) {
|
|
84
|
-
const filePath = resolve(configuration.content.baseDir, dictionary.filePath);
|
|
85
|
-
await writeFileWithDirectories(filePath, formattedContentDeclaration, configuration);
|
|
86
|
-
return {
|
|
87
|
-
status: "created",
|
|
88
|
-
path: filePath
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
const contentDeclarationPath = join(newDictionaryLocationPath, `${dictionary.key}.content.json`);
|
|
92
|
-
await writeFileWithDirectories(contentDeclarationPath, formattedContentDeclaration, configuration);
|
|
93
|
-
return {
|
|
94
|
-
status: "imported",
|
|
95
|
-
path: contentDeclarationPath
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
const writeFileWithDirectories = async (absoluteFilePath, dictionary, configuration) => {
|
|
99
|
-
await mkdir(dirname(absoluteFilePath), { recursive: true });
|
|
100
|
-
const extension = extname(absoluteFilePath);
|
|
101
|
-
if (!configuration.content.fileExtensions.map((extension) => extname(extension)).includes(extension)) throw new Error(`Invalid file extension: ${extension}, file: ${absoluteFilePath}`);
|
|
102
|
-
if (extension === ".json") {
|
|
103
|
-
await writeFile(absoluteFilePath, `${JSON.stringify(dictionary, null, 2)}\n`);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if ([".jsonc", ".json5"].includes(extension)) {
|
|
107
|
-
let fileContent = "{}";
|
|
108
|
-
if (existsSync(absoluteFilePath)) try {
|
|
109
|
-
fileContent = await readFile(absoluteFilePath, "utf-8");
|
|
110
|
-
} catch {}
|
|
111
|
-
await writeFile(absoluteFilePath, transformJSONFile(fileContent, dictionary), "utf-8");
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
await writeJSFile(absoluteFilePath, dictionary, configuration);
|
|
115
|
-
try {
|
|
116
|
-
await rm(join(configuration.system.cacheDir, "intlayer-prepared.lock"), { recursive: true });
|
|
117
|
-
} catch {}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
//#endregion
|
|
121
|
-
export { writeContentDeclaration };
|
|
1
|
+
import{getFormatFromExtension as e}from"../utils/getFormatFromExtension.mjs";import{processContentDeclarationContent as t}from"./processContentDeclarationContent.mjs";import{transformJSONFile as n}from"./transformJSONFile.mjs";import{writeJSFile as r}from"./writeJSFile.mjs";import{getUnmergedDictionaries as i}from"@intlayer/unmerged-dictionaries-entry";import{mkdir as a,readFile as o,rm as s,writeFile as c}from"node:fs/promises";import{dirname as l,extname as u,join as d,resolve as f}from"node:path";import{getFilteredLocalesDictionary as p,getPerLocaleDictionary as m}from"@intlayer/core/plugins";import{existsSync as h}from"node:fs";import{isDeepStrictEqual as g}from"node:util";const _=async(n,r,i)=>{let a=await t(n),o=a.content;n.locale?o=m(a,n.locale).content:i&&(o=p(a,i).content);let s={...n,content:o};for await(let e of r.plugins??[])if(e.formatOutput){let t=await e.formatOutput?.({dictionary:s,configuration:r});t&&(s=t)}if(!(s.content&&s.key))return s;let c={key:n.key,id:n.id,title:n.title,description:n.description,tags:n.tags,locale:n.locale,fill:n.fill,filled:n.filled,priority:n.priority,importMode:n.importMode,version:n.version,content:o};return e(n.filePath?u(n.filePath):`.json`)===`json`&&s.content&&s.key&&(c={$schema:`https://intlayer.org/schema.json`,...c}),c},v={newDictionariesPath:`intlayer-dictionaries`},y=async(e,t,n)=>{let{content:r}=t,{baseDir:a}=r,{newDictionariesPath:o,localeList:s}={...v,...n},c=d(a,o),l=i(t)[e.key]?.find(t=>t.localId===e.localId),u=await _(e,t,s);if(l?.filePath){let n=g(l,e),r=f(t.content.baseDir,l.filePath);return n?{status:`up-to-date`,path:r}:(await b(r,u,t),{status:`updated`,path:r})}if(e.filePath){let n=f(t.content.baseDir,e.filePath);return await b(n,u,t),{status:`created`,path:n}}let p=d(c,`${e.key}.content.json`);return await b(p,u,t),{status:`imported`,path:p}},b=async(e,t,i)=>{await a(l(e),{recursive:!0});let f=u(e);if(!i.content.fileExtensions.map(e=>u(e)).includes(f))throw Error(`Invalid file extension: ${f}, file: ${e}`);if(f===`.json`){await c(e,`${JSON.stringify(t,null,2)}\n`);return}if([`.jsonc`,`.json5`].includes(f)){let r=`{}`;if(h(e))try{r=await o(e,`utf-8`)}catch{}await c(e,n(r,t),`utf-8`);return}await r(e,t,i);try{await s(d(i.system.cacheDir,`intlayer-prepared.lock`),{recursive:!0})}catch{}};export{y as writeContentDeclaration};
|
|
122
2
|
//# sourceMappingURL=writeContentDeclaration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeContentDeclaration.mjs","names":[],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir, readFile, rm, writeFile } from 'node:fs/promises';\nimport { dirname, extname, join, resolve } from 'node:path';\nimport { isDeepStrictEqual } from 'node:util';\nimport {\n getFilteredLocalesDictionary,\n getPerLocaleDictionary,\n} from '@intlayer/core';\nimport type {\n Dictionary,\n IntlayerConfig,\n Locale,\n LocalesValues,\n} from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport type { DictionaryStatus } from './dictionaryStatus';\nimport { processContentDeclarationContent } from './processContentDeclarationContent';\nimport { transformJSONFile } from './transformJSONFile';\nimport { writeJSFile } from './writeJSFile';\n\nconst formatContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n localeList?: LocalesValues[]\n) => {\n /**\n * Clean Markdown, Insertion, File, etc. node metadata\n */\n const processedDictionary =\n await processContentDeclarationContent(dictionary);\n\n let content = processedDictionary.content;\n\n /**\n * Filter locales content\n */\n\n if (dictionary.locale) {\n content = getPerLocaleDictionary(\n processedDictionary,\n dictionary.locale\n ).content;\n } else if (localeList) {\n content = getFilteredLocalesDictionary(\n processedDictionary,\n localeList\n ).content;\n }\n\n let pluginFormatResult: any = {\n ...dictionary,\n content,\n } satisfies Dictionary;\n\n /**\n * Format the dictionary with the plugins\n */\n\n for await (const plugin of configuration.plugins ?? []) {\n if (plugin.formatOutput) {\n const formattedResult = await plugin.formatOutput?.({\n dictionary: pluginFormatResult,\n configuration,\n });\n\n if (formattedResult) {\n pluginFormatResult = formattedResult;\n }\n }\n }\n\n const isDictionaryFormat =\n pluginFormatResult.content && pluginFormatResult.key;\n\n if (!isDictionaryFormat) return pluginFormatResult;\n\n let result: Dictionary = {\n key: dictionary.key,\n id: dictionary.id,\n title: dictionary.title,\n description: dictionary.description,\n tags: dictionary.tags,\n locale: dictionary.locale,\n fill: dictionary.fill,\n filled: dictionary.filled,\n priority: dictionary.priority,\n importMode: dictionary.importMode,\n version: dictionary.version,\n content,\n };\n\n /**\n * Add $schema to JSON dictionaries\n */\n const extension = (\n dictionary.filePath ? extname(dictionary.filePath) : '.json'\n ) as Extension;\n const format = getFormatFromExtension(extension);\n\n if (\n format === 'json' &&\n pluginFormatResult.content &&\n pluginFormatResult.key\n ) {\n result = {\n $schema: 'https://intlayer.org/schema.json',\n ...result,\n };\n }\n\n return result;\n};\n\ntype WriteContentDeclarationOptions = {\n newDictionariesPath?: string;\n localeList?: LocalesValues[];\n fallbackLocale?: Locale;\n};\n\nconst defaultOptions = {\n newDictionariesPath: 'intlayer-dictionaries',\n} satisfies WriteContentDeclarationOptions;\n\nexport const writeContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n options?: WriteContentDeclarationOptions\n): Promise<{ status: DictionaryStatus; path: string }> => {\n const { content } = configuration;\n const { baseDir } = content;\n const { newDictionariesPath, localeList } = {\n ...defaultOptions,\n ...options,\n };\n\n const newDictionaryLocationPath = join(baseDir, newDictionariesPath);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n const unmergedDictionaries = unmergedDictionariesRecord[\n dictionary.key\n ] as Dictionary[];\n\n const existingDictionary = unmergedDictionaries?.find(\n (el) => el.localId === dictionary.localId\n );\n\n const formattedContentDeclaration = await formatContentDeclaration(\n dictionary,\n configuration,\n localeList\n );\n\n if (existingDictionary?.filePath) {\n // Compare existing dictionary content with new dictionary content\n const isSameContent = isDeepStrictEqual(existingDictionary, dictionary);\n\n const filePath = resolve(\n configuration.content.baseDir,\n existingDictionary.filePath\n );\n\n // Up to date, nothing to do\n if (isSameContent) {\n return {\n status: 'up-to-date',\n path: filePath,\n };\n }\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\n );\n\n return { status: 'updated', path: filePath };\n }\n\n if (dictionary.filePath) {\n const filePath = resolve(\n configuration.content.baseDir,\n dictionary.filePath\n );\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\n );\n\n return { status: 'created', path: filePath };\n }\n\n // No existing dictionary, write to new location\n const contentDeclarationPath = join(\n newDictionaryLocationPath,\n `${dictionary.key}.content.json`\n );\n\n await writeFileWithDirectories(\n contentDeclarationPath,\n formattedContentDeclaration,\n configuration\n );\n\n return {\n status: 'imported',\n path: contentDeclarationPath,\n };\n};\n\nconst writeFileWithDirectories = async (\n absoluteFilePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Promise<void> => {\n // Extract the directory from the file path\n const dir = dirname(absoluteFilePath);\n\n // Create the directory recursively\n await mkdir(dir, { recursive: true });\n\n const extension = extname(absoluteFilePath);\n const acceptedExtensions = configuration.content.fileExtensions.map(\n (extension) => extname(extension)\n );\n\n if (!acceptedExtensions.includes(extension)) {\n throw new Error(\n `Invalid file extension: ${extension}, file: ${absoluteFilePath}`\n );\n }\n\n if (extension === '.json') {\n const jsonDictionary = JSON.stringify(dictionary, null, 2);\n\n // Write the file\n await writeFile(absoluteFilePath, `${jsonDictionary}\\n`); // Add a new line at the end of the file to avoid formatting issues with VSCode\n\n return;\n }\n\n // Handle JSONC, and JSON5 via the AST transformer\n if (['.jsonc', '.json5'].includes(extension)) {\n let fileContent = '{}';\n\n if (existsSync(absoluteFilePath)) {\n try {\n fileContent = await readFile(absoluteFilePath, 'utf-8');\n } catch {\n // ignore read errors, start with empty object\n }\n }\n\n const transformedContent = transformJSONFile(fileContent, dictionary);\n\n // We use standard writeFile because transformedContent is already a string\n await writeFile(absoluteFilePath, transformedContent, 'utf-8');\n return;\n }\n\n await writeJSFile(absoluteFilePath, dictionary, configuration);\n\n // remove the cache as content has changed\n // Will force a new preparation of the intlayer on next build\n try {\n const sentinelPath = join(\n configuration.system.cacheDir,\n 'intlayer-prepared.lock'\n );\n await rm(sentinelPath, { recursive: true });\n } catch {}\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"writeContentDeclaration.mjs","names":[],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir, readFile, rm, writeFile } from 'node:fs/promises';\nimport { dirname, extname, join, resolve } from 'node:path';\nimport { isDeepStrictEqual } from 'node:util';\nimport {\n getFilteredLocalesDictionary,\n getPerLocaleDictionary,\n} from '@intlayer/core/plugins';\nimport type {\n Dictionary,\n IntlayerConfig,\n Locale,\n LocalesValues,\n} from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport type { DictionaryStatus } from './dictionaryStatus';\nimport { processContentDeclarationContent } from './processContentDeclarationContent';\nimport { transformJSONFile } from './transformJSONFile';\nimport { writeJSFile } from './writeJSFile';\n\nconst formatContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n localeList?: LocalesValues[]\n) => {\n /**\n * Clean Markdown, Insertion, File, etc. node metadata\n */\n const processedDictionary =\n await processContentDeclarationContent(dictionary);\n\n let content = processedDictionary.content;\n\n /**\n * Filter locales content\n */\n\n if (dictionary.locale) {\n content = getPerLocaleDictionary(\n processedDictionary,\n dictionary.locale\n ).content;\n } else if (localeList) {\n content = getFilteredLocalesDictionary(\n processedDictionary,\n localeList\n ).content;\n }\n\n let pluginFormatResult: any = {\n ...dictionary,\n content,\n } satisfies Dictionary;\n\n /**\n * Format the dictionary with the plugins\n */\n\n for await (const plugin of configuration.plugins ?? []) {\n if (plugin.formatOutput) {\n const formattedResult = await plugin.formatOutput?.({\n dictionary: pluginFormatResult,\n configuration,\n });\n\n if (formattedResult) {\n pluginFormatResult = formattedResult;\n }\n }\n }\n\n const isDictionaryFormat =\n pluginFormatResult.content && pluginFormatResult.key;\n\n if (!isDictionaryFormat) return pluginFormatResult;\n\n let result: Dictionary = {\n key: dictionary.key,\n id: dictionary.id,\n title: dictionary.title,\n description: dictionary.description,\n tags: dictionary.tags,\n locale: dictionary.locale,\n fill: dictionary.fill,\n filled: dictionary.filled,\n priority: dictionary.priority,\n importMode: dictionary.importMode,\n version: dictionary.version,\n content,\n };\n\n /**\n * Add $schema to JSON dictionaries\n */\n const extension = (\n dictionary.filePath ? extname(dictionary.filePath) : '.json'\n ) as Extension;\n const format = getFormatFromExtension(extension);\n\n if (\n format === 'json' &&\n pluginFormatResult.content &&\n pluginFormatResult.key\n ) {\n result = {\n $schema: 'https://intlayer.org/schema.json',\n ...result,\n };\n }\n\n return result;\n};\n\ntype WriteContentDeclarationOptions = {\n newDictionariesPath?: string;\n localeList?: LocalesValues[];\n fallbackLocale?: Locale;\n};\n\nconst defaultOptions = {\n newDictionariesPath: 'intlayer-dictionaries',\n} satisfies WriteContentDeclarationOptions;\n\nexport const writeContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n options?: WriteContentDeclarationOptions\n): Promise<{ status: DictionaryStatus; path: string }> => {\n const { content } = configuration;\n const { baseDir } = content;\n const { newDictionariesPath, localeList } = {\n ...defaultOptions,\n ...options,\n };\n\n const newDictionaryLocationPath = join(baseDir, newDictionariesPath);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n const unmergedDictionaries = unmergedDictionariesRecord[\n dictionary.key\n ] as Dictionary[];\n\n const existingDictionary = unmergedDictionaries?.find(\n (el) => el.localId === dictionary.localId\n );\n\n const formattedContentDeclaration = await formatContentDeclaration(\n dictionary,\n configuration,\n localeList\n );\n\n if (existingDictionary?.filePath) {\n // Compare existing dictionary content with new dictionary content\n const isSameContent = isDeepStrictEqual(existingDictionary, dictionary);\n\n const filePath = resolve(\n configuration.content.baseDir,\n existingDictionary.filePath\n );\n\n // Up to date, nothing to do\n if (isSameContent) {\n return {\n status: 'up-to-date',\n path: filePath,\n };\n }\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\n );\n\n return { status: 'updated', path: filePath };\n }\n\n if (dictionary.filePath) {\n const filePath = resolve(\n configuration.content.baseDir,\n dictionary.filePath\n );\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\n );\n\n return { status: 'created', path: filePath };\n }\n\n // No existing dictionary, write to new location\n const contentDeclarationPath = join(\n newDictionaryLocationPath,\n `${dictionary.key}.content.json`\n );\n\n await writeFileWithDirectories(\n contentDeclarationPath,\n formattedContentDeclaration,\n configuration\n );\n\n return {\n status: 'imported',\n path: contentDeclarationPath,\n };\n};\n\nconst writeFileWithDirectories = async (\n absoluteFilePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Promise<void> => {\n // Extract the directory from the file path\n const dir = dirname(absoluteFilePath);\n\n // Create the directory recursively\n await mkdir(dir, { recursive: true });\n\n const extension = extname(absoluteFilePath);\n const acceptedExtensions = configuration.content.fileExtensions.map(\n (extension) => extname(extension)\n );\n\n if (!acceptedExtensions.includes(extension)) {\n throw new Error(\n `Invalid file extension: ${extension}, file: ${absoluteFilePath}`\n );\n }\n\n if (extension === '.json') {\n const jsonDictionary = JSON.stringify(dictionary, null, 2);\n\n // Write the file\n await writeFile(absoluteFilePath, `${jsonDictionary}\\n`); // Add a new line at the end of the file to avoid formatting issues with VSCode\n\n return;\n }\n\n // Handle JSONC, and JSON5 via the AST transformer\n if (['.jsonc', '.json5'].includes(extension)) {\n let fileContent = '{}';\n\n if (existsSync(absoluteFilePath)) {\n try {\n fileContent = await readFile(absoluteFilePath, 'utf-8');\n } catch {\n // ignore read errors, start with empty object\n }\n }\n\n const transformedContent = transformJSONFile(fileContent, dictionary);\n\n // We use standard writeFile because transformedContent is already a string\n await writeFile(absoluteFilePath, transformedContent, 'utf-8');\n return;\n }\n\n await writeJSFile(absoluteFilePath, dictionary, configuration);\n\n // remove the cache as content has changed\n // Will force a new preparation of the intlayer on next build\n try {\n const sentinelPath = join(\n configuration.system.cacheDir,\n 'intlayer-prepared.lock'\n );\n await rm(sentinelPath, { recursive: true });\n } catch {}\n};\n"],"mappings":"8qBAwBA,MAAM,EAA2B,MAC/B,EACA,EACA,IACG,CAIH,IAAM,EACJ,MAAM,EAAiC,EAAW,CAEhD,EAAU,EAAoB,QAM9B,EAAW,OACb,EAAU,EACR,EACA,EAAW,OACZ,CAAC,QACO,IACT,EAAU,EACR,EACA,EACD,CAAC,SAGJ,IAAI,EAA0B,CAC5B,GAAG,EACH,UACD,CAMD,UAAW,IAAM,KAAU,EAAc,SAAW,EAAE,CACpD,GAAI,EAAO,aAAc,CACvB,IAAM,EAAkB,MAAM,EAAO,eAAe,CAClD,WAAY,EACZ,gBACD,CAAC,CAEE,IACF,EAAqB,GAQ3B,GAAI,EAFF,EAAmB,SAAW,EAAmB,KAE1B,OAAO,EAEhC,IAAI,EAAqB,CACvB,IAAK,EAAW,IAChB,GAAI,EAAW,GACf,MAAO,EAAW,MAClB,YAAa,EAAW,YACxB,KAAM,EAAW,KACjB,OAAQ,EAAW,OACnB,KAAM,EAAW,KACjB,OAAQ,EAAW,OACnB,SAAU,EAAW,SACrB,WAAY,EAAW,WACvB,QAAS,EAAW,QACpB,UACD,CAqBD,OAbe,EAFb,EAAW,SAAW,EAAQ,EAAW,SAAS,CAAG,QAEP,GAGnC,QACX,EAAmB,SACnB,EAAmB,MAEnB,EAAS,CACP,QAAS,mCACT,GAAG,EACJ,EAGI,GASH,EAAiB,CACrB,oBAAqB,wBACtB,CAEY,EAA0B,MACrC,EACA,EACA,IACwD,CACxD,GAAM,CAAE,WAAY,EACd,CAAE,WAAY,EACd,CAAE,sBAAqB,cAAe,CAC1C,GAAG,EACH,GAAG,EACJ,CAEK,EAA4B,EAAK,EAAS,EAAoB,CAO9D,EAL6B,EAAwB,EAAc,CAEvE,EAAW,MAGoC,KAC9C,GAAO,EAAG,UAAY,EAAW,QACnC,CAEK,EAA8B,MAAM,EACxC,EACA,EACA,EACD,CAED,GAAI,GAAoB,SAAU,CAEhC,IAAM,EAAgB,EAAkB,EAAoB,EAAW,CAEjE,EAAW,EACf,EAAc,QAAQ,QACtB,EAAmB,SACpB,CAgBD,OAbI,EACK,CACL,OAAQ,aACR,KAAM,EACP,EAGH,MAAM,EACJ,EACA,EACA,EACD,CAEM,CAAE,OAAQ,UAAW,KAAM,EAAU,EAG9C,GAAI,EAAW,SAAU,CACvB,IAAM,EAAW,EACf,EAAc,QAAQ,QACtB,EAAW,SACZ,CAQD,OANA,MAAM,EACJ,EACA,EACA,EACD,CAEM,CAAE,OAAQ,UAAW,KAAM,EAAU,CAI9C,IAAM,EAAyB,EAC7B,EACA,GAAG,EAAW,IAAI,eACnB,CAQD,OANA,MAAM,EACJ,EACA,EACA,EACD,CAEM,CACL,OAAQ,WACR,KAAM,EACP,EAGG,EAA2B,MAC/B,EACA,EACA,IACkB,CAKlB,MAAM,EAHM,EAAQ,EAAiB,CAGpB,CAAE,UAAW,GAAM,CAAC,CAErC,IAAM,EAAY,EAAQ,EAAiB,CAK3C,GAAI,CAJuB,EAAc,QAAQ,eAAe,IAC7D,GAAc,EAAQ,EAAU,CAClC,CAEuB,SAAS,EAAU,CACzC,MAAU,MACR,2BAA2B,EAAU,UAAU,IAChD,CAGH,GAAI,IAAc,QAAS,CAIzB,MAAM,EAAU,EAAkB,GAHX,KAAK,UAAU,EAAY,KAAM,EAAE,CAGN,IAAI,CAExD,OAIF,GAAI,CAAC,SAAU,SAAS,CAAC,SAAS,EAAU,CAAE,CAC5C,IAAI,EAAc,KAElB,GAAI,EAAW,EAAiB,CAC9B,GAAI,CACF,EAAc,MAAM,EAAS,EAAkB,QAAQ,MACjD,EAQV,MAAM,EAAU,EAHW,EAAkB,EAAa,EAAW,CAGf,QAAQ,CAC9D,OAGF,MAAM,EAAY,EAAkB,EAAY,EAAc,CAI9D,GAAI,CAKF,MAAM,EAJe,EACnB,EAAc,OAAO,SACrB,yBACD,CACsB,CAAE,UAAW,GAAM,CAAC,MACrC"}
|
|
@@ -1,70 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { transformJSFile } from "./transformJSFile.mjs";
|
|
3
|
-
import { getFormatFromExtension } from "../utils/getFormatFromExtension.mjs";
|
|
4
|
-
import { getContentDeclarationFileTemplate } from "../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";
|
|
5
|
-
import { getAppLogger, logger } from "@intlayer/config";
|
|
6
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
7
|
-
import { extname } from "node:path";
|
|
8
|
-
import { existsSync } from "node:fs";
|
|
9
|
-
import { execSync } from "node:child_process";
|
|
10
|
-
|
|
11
|
-
//#region src/writeContentDeclaration/writeJSFile.ts
|
|
12
|
-
/**
|
|
13
|
-
* Updates a JavaScript/TypeScript file based on the provided JSON instructions.
|
|
14
|
-
* It targets a specific dictionary object within the file (identified by its 'key' property)
|
|
15
|
-
* and updates its 'content' entries. Currently, it focuses on modifying arguments
|
|
16
|
-
* of 't' (translation) function calls.
|
|
17
|
-
*/
|
|
18
|
-
const writeJSFile = async (filePath, dictionary, configuration) => {
|
|
19
|
-
const mergedDictionary = {
|
|
20
|
-
...configuration.dictionary,
|
|
21
|
-
...dictionary
|
|
22
|
-
};
|
|
23
|
-
const appLogger = getAppLogger(configuration);
|
|
24
|
-
if (!existsSync(filePath)) {
|
|
25
|
-
const format = getFormatFromExtension(extname(filePath));
|
|
26
|
-
appLogger("File does not exist, creating it", { isVerbose: true });
|
|
27
|
-
await writeFile(filePath, await getContentDeclarationFileTemplate(mergedDictionary.key, format, Object.fromEntries(Object.entries({
|
|
28
|
-
id: mergedDictionary.id,
|
|
29
|
-
locale: mergedDictionary.locale,
|
|
30
|
-
filled: mergedDictionary.filled,
|
|
31
|
-
fill: mergedDictionary.fill,
|
|
32
|
-
description: mergedDictionary.description,
|
|
33
|
-
title: mergedDictionary.title,
|
|
34
|
-
tags: mergedDictionary.tags,
|
|
35
|
-
version: mergedDictionary.version,
|
|
36
|
-
priority: mergedDictionary.priority,
|
|
37
|
-
importMode: mergedDictionary.importMode
|
|
38
|
-
}).filter(([, value]) => value !== void 0))), "utf-8");
|
|
39
|
-
}
|
|
40
|
-
let fileContent = await readFile(filePath, "utf-8");
|
|
41
|
-
if (fileContent === "") {
|
|
42
|
-
const format = getFormatFromExtension(extname(filePath));
|
|
43
|
-
fileContent = await getContentDeclarationFileTemplate(mergedDictionary.key, format);
|
|
44
|
-
}
|
|
45
|
-
const finalCode = await transformJSFile(fileContent, dictionary);
|
|
46
|
-
try {
|
|
47
|
-
await writeFile(filePath, finalCode, "utf-8");
|
|
48
|
-
logger(`Successfully updated ${filePath}`, {
|
|
49
|
-
level: "info",
|
|
50
|
-
isVerbose: true
|
|
51
|
-
});
|
|
52
|
-
} catch (error) {
|
|
53
|
-
const err = error;
|
|
54
|
-
logger(`Failed to write updated file: ${filePath}`, { level: "error" });
|
|
55
|
-
throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);
|
|
56
|
-
}
|
|
57
|
-
const formatCommand = detectFormatCommand(configuration);
|
|
58
|
-
if (formatCommand) try {
|
|
59
|
-
execSync(formatCommand.replace("{{file}}", filePath), {
|
|
60
|
-
stdio: "inherit",
|
|
61
|
-
cwd: configuration.content.baseDir
|
|
62
|
-
});
|
|
63
|
-
} catch (error) {
|
|
64
|
-
console.error(error);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
export { writeJSFile };
|
|
1
|
+
import{detectFormatCommand as e}from"./detectFormatCommand.mjs";import{transformJSFile as t}from"./transformJSFile.mjs";import{getFormatFromExtension as n}from"../utils/getFormatFromExtension.mjs";import{getContentDeclarationFileTemplate as r}from"../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";import{readFile as i,writeFile as a}from"node:fs/promises";import{extname as o}from"node:path";import{getAppLogger as s,logger as c}from"@intlayer/config/logger";import{existsSync as l}from"node:fs";import{execSync as u}from"node:child_process";const d=async(d,f,p)=>{let m={...p.dictionary,...f},h=s(p);if(!l(d)){let e=n(o(d));h(`File does not exist, creating it`,{isVerbose:!0}),await a(d,await r(m.key,e,Object.fromEntries(Object.entries({id:m.id,locale:m.locale,filled:m.filled,fill:m.fill,description:m.description,title:m.title,tags:m.tags,version:m.version,priority:m.priority,importMode:m.importMode}).filter(([,e])=>e!==void 0))),`utf-8`)}let g=await i(d,`utf-8`);if(g===``){let e=n(o(d));g=await r(m.key,e)}let _=await t(g,f);try{await a(d,_,`utf-8`),c(`Successfully updated ${d}`,{level:`info`,isVerbose:!0})}catch(e){let t=e;throw c(`Failed to write updated file: ${d}`,{level:`error`}),Error(`Failed to write updated file ${d}: ${t.message}`)}let v=e(p);if(v)try{u(v.replace(`{{file}}`,d),{stdio:`inherit`,cwd:p.content.baseDir})}catch(e){console.error(e)}};export{d as writeJSFile};
|
|
70
2
|
//# sourceMappingURL=writeJSFile.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeJSFile.mjs","names":[],"sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { readFile, writeFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport { getAppLogger, logger } from '@intlayer/config';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { getContentDeclarationFileTemplate } from '../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport { detectFormatCommand } from './detectFormatCommand';\nimport { transformJSFile } from './transformJSFile';\n\n/**\n * Updates a JavaScript/TypeScript file based on the provided JSON instructions.\n * It targets a specific dictionary object within the file (identified by its 'key' property)\n * and updates its 'content' entries. Currently, it focuses on modifying arguments\n * of 't' (translation) function calls.\n */\nexport const writeJSFile = async (\n filePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Promise<void> => {\n const mergedDictionary = {\n ...configuration.dictionary,\n ...dictionary,\n };\n\n const appLogger = getAppLogger(configuration);\n\n // Check if the file exist\n if (!existsSync(filePath)) {\n const fileExtension = extname(filePath) as Extension;\n\n const format = getFormatFromExtension(fileExtension);\n\n appLogger('File does not exist, creating it', {\n isVerbose: true,\n });\n const template = await getContentDeclarationFileTemplate(\n mergedDictionary.key,\n format,\n // Filter out undefined values\n Object.fromEntries(\n Object.entries({\n id: mergedDictionary.id,\n locale: mergedDictionary.locale,\n filled: mergedDictionary.filled,\n fill: mergedDictionary.fill,\n description: mergedDictionary.description,\n title: mergedDictionary.title,\n tags: mergedDictionary.tags,\n version: mergedDictionary.version,\n priority: mergedDictionary.priority,\n importMode: mergedDictionary.importMode,\n }).filter(([, value]) => value !== undefined)\n )\n );\n\n await writeFile(filePath, template, 'utf-8');\n }\n\n let fileContent = await readFile(filePath, 'utf-8');\n\n if (fileContent === '') {\n const format = getFormatFromExtension(extname(filePath) as Extension);\n\n fileContent = await getContentDeclarationFileTemplate(\n mergedDictionary.key,\n format\n );\n }\n\n const finalCode = await transformJSFile(fileContent, dictionary);\n\n // Write the modified code back to the file\n try {\n await writeFile(filePath, finalCode, 'utf-8');\n logger(`Successfully updated ${filePath}`, {\n level: 'info',\n isVerbose: true,\n });\n } catch (error) {\n const err = error as Error;\n logger(`Failed to write updated file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);\n }\n\n const formatCommand = detectFormatCommand(configuration);\n\n if (formatCommand) {\n try {\n execSync(formatCommand.replace('{{file}}', filePath), {\n stdio: 'inherit',\n cwd: configuration.content.baseDir,\n });\n } catch (error) {\n console.error(error);\n }\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"writeJSFile.mjs","names":[],"sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { readFile, writeFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport { getAppLogger, logger } from '@intlayer/config/logger';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { getContentDeclarationFileTemplate } from '../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport { detectFormatCommand } from './detectFormatCommand';\nimport { transformJSFile } from './transformJSFile';\n\n/**\n * Updates a JavaScript/TypeScript file based on the provided JSON instructions.\n * It targets a specific dictionary object within the file (identified by its 'key' property)\n * and updates its 'content' entries. Currently, it focuses on modifying arguments\n * of 't' (translation) function calls.\n */\nexport const writeJSFile = async (\n filePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Promise<void> => {\n const mergedDictionary = {\n ...configuration.dictionary,\n ...dictionary,\n };\n\n const appLogger = getAppLogger(configuration);\n\n // Check if the file exist\n if (!existsSync(filePath)) {\n const fileExtension = extname(filePath) as Extension;\n\n const format = getFormatFromExtension(fileExtension);\n\n appLogger('File does not exist, creating it', {\n isVerbose: true,\n });\n const template = await getContentDeclarationFileTemplate(\n mergedDictionary.key,\n format,\n // Filter out undefined values\n Object.fromEntries(\n Object.entries({\n id: mergedDictionary.id,\n locale: mergedDictionary.locale,\n filled: mergedDictionary.filled,\n fill: mergedDictionary.fill,\n description: mergedDictionary.description,\n title: mergedDictionary.title,\n tags: mergedDictionary.tags,\n version: mergedDictionary.version,\n priority: mergedDictionary.priority,\n importMode: mergedDictionary.importMode,\n }).filter(([, value]) => value !== undefined)\n )\n );\n\n await writeFile(filePath, template, 'utf-8');\n }\n\n let fileContent = await readFile(filePath, 'utf-8');\n\n if (fileContent === '') {\n const format = getFormatFromExtension(extname(filePath) as Extension);\n\n fileContent = await getContentDeclarationFileTemplate(\n mergedDictionary.key,\n format\n );\n }\n\n const finalCode = await transformJSFile(fileContent, dictionary);\n\n // Write the modified code back to the file\n try {\n await writeFile(filePath, finalCode, 'utf-8');\n logger(`Successfully updated ${filePath}`, {\n level: 'info',\n isVerbose: true,\n });\n } catch (error) {\n const err = error as Error;\n logger(`Failed to write updated file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);\n }\n\n const formatCommand = detectFormatCommand(configuration);\n\n if (formatCommand) {\n try {\n execSync(formatCommand.replace('{{file}}', filePath), {\n stdio: 'inherit',\n cwd: configuration.content.baseDir,\n });\n } catch (error) {\n console.error(error);\n }\n }\n};\n"],"mappings":"yjBAoBA,MAAa,EAAc,MACzB,EACA,EACA,IACkB,CAClB,IAAM,EAAmB,CACvB,GAAG,EAAc,WACjB,GAAG,EACJ,CAEK,EAAY,EAAa,EAAc,CAG7C,GAAI,CAAC,EAAW,EAAS,CAAE,CAGzB,IAAM,EAAS,EAFO,EAAQ,EAAS,CAEa,CAEpD,EAAU,mCAAoC,CAC5C,UAAW,GACZ,CAAC,CAqBF,MAAM,EAAU,EApBC,MAAM,EACrB,EAAiB,IACjB,EAEA,OAAO,YACL,OAAO,QAAQ,CACb,GAAI,EAAiB,GACrB,OAAQ,EAAiB,OACzB,OAAQ,EAAiB,OACzB,KAAM,EAAiB,KACvB,YAAa,EAAiB,YAC9B,MAAO,EAAiB,MACxB,KAAM,EAAiB,KACvB,QAAS,EAAiB,QAC1B,SAAU,EAAiB,SAC3B,WAAY,EAAiB,WAC9B,CAAC,CAAC,QAAQ,EAAG,KAAW,IAAU,IAAA,GAAU,CAC9C,CACF,CAEmC,QAAQ,CAG9C,IAAI,EAAc,MAAM,EAAS,EAAU,QAAQ,CAEnD,GAAI,IAAgB,GAAI,CACtB,IAAM,EAAS,EAAuB,EAAQ,EAAS,CAAc,CAErE,EAAc,MAAM,EAClB,EAAiB,IACjB,EACD,CAGH,IAAM,EAAY,MAAM,EAAgB,EAAa,EAAW,CAGhE,GAAI,CACF,MAAM,EAAU,EAAU,EAAW,QAAQ,CAC7C,EAAO,wBAAwB,IAAY,CACzC,MAAO,OACP,UAAW,GACZ,CAAC,OACK,EAAO,CACd,IAAM,EAAM,EAIZ,MAHA,EAAO,iCAAiC,IAAY,CAClD,MAAO,QACR,CAAC,CACQ,MAAM,gCAAgC,EAAS,IAAI,EAAI,UAAU,CAG7E,IAAM,EAAgB,EAAoB,EAAc,CAExD,GAAI,EACF,GAAI,CACF,EAAS,EAAc,QAAQ,WAAY,EAAS,CAAE,CACpD,MAAO,UACP,IAAK,EAAc,QAAQ,QAC5B,CAAC,OACK,EAAO,CACd,QAAQ,MAAM,EAAM"}
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/writeFileIfChanged.ts
|
|
4
|
-
const writeFileIfChanged = async (path, dataOrStream, { encoding = "utf8" } = {}) => {
|
|
5
|
-
await writeFile(path, dataOrStream, { encoding });
|
|
6
|
-
return true;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
export { writeFileIfChanged };
|
|
1
|
+
import{writeFile as e}from"node:fs/promises";const t=async(t,n,{encoding:r=`utf8`}={})=>(await e(t,n,{encoding:r}),!0);export{t as writeFileIfChanged};
|
|
11
2
|
//# sourceMappingURL=writeFileIfChanged.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeFileIfChanged.mjs","names":[],"sources":["../../src/writeFileIfChanged.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\n// import { createHash } from 'node:crypto';\n// import { createReadStream } from 'node:fs';\n// import type { Readable } from 'node:stream';\n\n// const hashFile = async (path: string) => {\n// const h = createHash('sha256');\n// const rs = createReadStream(path);\n// rs.on('data', (chunk) => h.update(chunk));\n// await new Promise<void>((res, rej) => {\n// rs.on('end', () => res());\n// rs.on('error', rej);\n// });\n// return h.digest('hex');\n// };\n\n// const isReadableStream = (value: unknown): value is Readable =>\n// !!value &&\n// typeof value === 'object' &&\n// typeof (value as any).pipe === 'function';\n\nexport const writeFileIfChanged = async (\n path: string,\n dataOrStream: string,\n { encoding = 'utf8' }: { encoding?: BufferEncoding } = {}\n): Promise<boolean> => {\n // Disabled because it's too slow. Build time increases from 3s to 7s.\n await writeFile(path, dataOrStream, { encoding });\n\n // 1) write new content to temporary file (stream-safe)\n // const tmp = `${path}.tmp`;\n\n // if (isReadableStream(dataOrStream)) {\n // await pipeline(dataOrStream, createWriteStream(tmp));\n // } else {\n // // dataOrStream = string | Buffer\n // const buf = Buffer.isBuffer(dataOrStream)\n // ? dataOrStream\n // : Buffer.from(dataOrStream, encoding);\n // await writeFile(tmp, buf);\n // }\n\n // 2) if old file exists, compare hashes (streaming)\n // let same = false;\n // try {\n // const [oldHash, newHash] = await Promise.all([\n // hashFile(path),\n // hashFile(tmp),\n // ]);\n // same = oldHash === newHash;\n // } catch {\n // // old file missing -> will replace\n // }\n\n // if (same) {\n // await rm(tmp);\n // return false; // no change\n // }\n\n // 3) atomic replacement\n // On Unix, rename is atomic. On Windows, if file exists, we can delete it first.\n // try {\n // await rename(tmp, path);\n // } catch {\n // try {\n // await rm(path);\n // } catch {}\n // await rename(tmp, path);\n // }\n\n return true; // changed\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"writeFileIfChanged.mjs","names":[],"sources":["../../src/writeFileIfChanged.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\n// import { createHash } from 'node:crypto';\n// import { createReadStream } from 'node:fs';\n// import type { Readable } from 'node:stream';\n\n// const hashFile = async (path: string) => {\n// const h = createHash('sha256');\n// const rs = createReadStream(path);\n// rs.on('data', (chunk) => h.update(chunk));\n// await new Promise<void>((res, rej) => {\n// rs.on('end', () => res());\n// rs.on('error', rej);\n// });\n// return h.digest('hex');\n// };\n\n// const isReadableStream = (value: unknown): value is Readable =>\n// !!value &&\n// typeof value === 'object' &&\n// typeof (value as any).pipe === 'function';\n\nexport const writeFileIfChanged = async (\n path: string,\n dataOrStream: string,\n { encoding = 'utf8' }: { encoding?: BufferEncoding } = {}\n): Promise<boolean> => {\n // Disabled because it's too slow. Build time increases from 3s to 7s.\n await writeFile(path, dataOrStream, { encoding });\n\n // 1) write new content to temporary file (stream-safe)\n // const tmp = `${path}.tmp`;\n\n // if (isReadableStream(dataOrStream)) {\n // await pipeline(dataOrStream, createWriteStream(tmp));\n // } else {\n // // dataOrStream = string | Buffer\n // const buf = Buffer.isBuffer(dataOrStream)\n // ? dataOrStream\n // : Buffer.from(dataOrStream, encoding);\n // await writeFile(tmp, buf);\n // }\n\n // 2) if old file exists, compare hashes (streaming)\n // let same = false;\n // try {\n // const [oldHash, newHash] = await Promise.all([\n // hashFile(path),\n // hashFile(tmp),\n // ]);\n // same = oldHash === newHash;\n // } catch {\n // // old file missing -> will replace\n // }\n\n // if (same) {\n // await rm(tmp);\n // return false; // no change\n // }\n\n // 3) atomic replacement\n // On Unix, rename is atomic. On Windows, if file exists, we can delete it first.\n // try {\n // await rename(tmp, path);\n // } catch {\n // try {\n // await rm(path);\n // } catch {}\n // await rename(tmp, path);\n // }\n\n return true; // changed\n};\n"],"mappings":"6CAqBA,MAAa,EAAqB,MAChC,EACA,EACA,CAAE,WAAW,QAA0C,EAAE,IAGzD,MAAM,EAAU,EAAM,EAAc,CAAE,WAAU,CAAC,CA2C1C"}
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/writeJsonIfChanged.ts
|
|
4
|
-
const writeJsonIfChanged = async (path, data, { pretty = true } = {}) => {
|
|
5
|
-
const space = pretty ? 2 : void 0;
|
|
6
|
-
let json = "{}";
|
|
7
|
-
try {
|
|
8
|
-
json = JSON.stringify(data, null, space);
|
|
9
|
-
} catch (error) {
|
|
10
|
-
console.error(`Error while parsing data to JSON for ${path}:`, error);
|
|
11
|
-
}
|
|
12
|
-
return await writeFileIfChanged(path, json);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { writeJsonIfChanged };
|
|
1
|
+
import{writeFileIfChanged as e}from"./writeFileIfChanged.mjs";const t=async(t,n,{pretty:r=!1}={})=>{let i=r?2:void 0,a=`{}`;try{a=JSON.stringify(n,null,i)}catch(e){console.error(`Error while parsing data to JSON for ${t}:`,e)}return await e(t,a)};export{t as writeJsonIfChanged};
|
|
17
2
|
//# sourceMappingURL=writeJsonIfChanged.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeJsonIfChanged.mjs","names":[],"sources":["../../src/writeJsonIfChanged.ts"],"sourcesContent":["import { writeFileIfChanged } from './writeFileIfChanged';\n\nexport const writeJsonIfChanged = async <T>(\n path: string,\n data: T,\n { pretty = process.env.NODE_ENV === 'development' } = {}\n): Promise<boolean> => {\n const space = pretty ? 2 : undefined;\n\n let json = '{}';\n\n try {\n json = JSON.stringify(data, null, space);\n } catch (error) {\n console.error(`Error while parsing data to JSON for ${path}:`, error);\n }\n\n return await writeFileIfChanged(path, json);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"writeJsonIfChanged.mjs","names":[],"sources":["../../src/writeJsonIfChanged.ts"],"sourcesContent":["import { writeFileIfChanged } from './writeFileIfChanged';\n\nexport const writeJsonIfChanged = async <T>(\n path: string,\n data: T,\n { pretty = process.env.NODE_ENV === 'development' } = {}\n): Promise<boolean> => {\n const space = pretty ? 2 : undefined;\n\n let json = '{}';\n\n try {\n json = JSON.stringify(data, null, space);\n } catch (error) {\n console.error(`Error while parsing data to JSON for ${path}:`, error);\n }\n\n return await writeFileIfChanged(path, json);\n};\n"],"mappings":"8DAEA,MAAa,EAAqB,MAChC,EACA,EACA,CAAE,SAAS,IAA2C,EAAE,GACnC,CACrB,IAAM,EAAQ,EAAS,EAAI,IAAA,GAEvB,EAAO,KAEX,GAAI,CACF,EAAO,KAAK,UAAU,EAAM,KAAM,EAAM,OACjC,EAAO,CACd,QAAQ,MAAM,wCAAwC,EAAK,GAAI,EAAM,CAGvE,OAAO,MAAM,EAAmB,EAAM,EAAK"}
|
package/dist/types/build.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { buildDictionary } from "./buildIntlayerDictionary/buildIntlayerDictionary.js";
|
|
2
2
|
import { processContentDeclaration } from "./buildIntlayerDictionary/processContentDeclaration.js";
|
|
3
3
|
import "./buildIntlayerDictionary/index.js";
|
|
4
|
+
import { cleanOutputDir } from "./cleanOutputDir.js";
|
|
4
5
|
import { CreateDictionaryEntryPointOptions, createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.js";
|
|
5
6
|
import { generateDictionaryListContent } from "./createDictionaryEntryPoint/generateDictionaryListContent.js";
|
|
6
7
|
import { getBuiltDictionariesPath } from "./createDictionaryEntryPoint/getBuiltDictionariesPath.js";
|
|
@@ -12,6 +13,7 @@ import "./createDictionaryEntryPoint/index.js";
|
|
|
12
13
|
import { createModuleAugmentation, getTypeName } from "./createType/createModuleAugmentation.js";
|
|
13
14
|
import { createTypes, generateTypeScriptType } from "./createType/createType.js";
|
|
14
15
|
import "./createType/index.js";
|
|
16
|
+
import { formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput } from "./formatDictionary.js";
|
|
15
17
|
import { DictionariesStatus, loadDictionaries } from "./loadDictionaries/loadDictionaries.js";
|
|
16
18
|
import { formatLocalDictionaries, loadContentDeclarations } from "./loadDictionaries/loadContentDeclaration.js";
|
|
17
19
|
import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.js";
|
|
@@ -26,4 +28,4 @@ import { transformJSFile } from "./writeContentDeclaration/transformJSFile.js";
|
|
|
26
28
|
import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.js";
|
|
27
29
|
import { writeJSFile } from "./writeContentDeclaration/writeJSFile.js";
|
|
28
30
|
import "./writeContentDeclaration/index.js";
|
|
29
|
-
export { CreateDictionaryEntryPointOptions, DictionariesStatus, DictionaryStatus, buildDictionary, createDictionaryEntryPoint, createModuleAugmentation, createTypes, detectExportedComponentName, detectFormatCommand, formatDistantDictionaries, formatLocalDictionaries, generateDictionaryListContent, generateTypeScriptType, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath, getTypeName, isCachedConfigurationUpToDate, loadContentDeclarations, loadDictionaries, loadLocalDictionaries, loadRemoteDictionaries, prepareIntlayer, processContentDeclaration, transformJSFile, writeConfiguration, writeContentDeclaration, writeJSFile };
|
|
31
|
+
export { CreateDictionaryEntryPointOptions, DictionariesStatus, DictionaryStatus, buildDictionary, cleanOutputDir, createDictionaryEntryPoint, createModuleAugmentation, createTypes, detectExportedComponentName, detectFormatCommand, formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput, formatDistantDictionaries, formatLocalDictionaries, generateDictionaryListContent, generateTypeScriptType, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath, getTypeName, isCachedConfigurationUpToDate, loadContentDeclarations, loadDictionaries, loadLocalDictionaries, loadRemoteDictionaries, prepareIntlayer, processContentDeclaration, transformJSFile, writeConfiguration, writeContentDeclaration, writeJSFile };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildIntlayerDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"buildIntlayerDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"mappings":";;;;;;;;;;cAea,eAAA,GACX,wBAAA,EAA0B,UAAA,IAC1B,aAAA,GADoC,gBAAA,CACpC,cAAA,EACA,OAAA,sBACA,uBAAA,eAA8B,OAAA;wBAFI,wBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeDynamicDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"writeDynamicDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"mappings":";;;;;KAYY,gBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,yBAAA,GAA4B,OAAA,CACtC,MAAA,CAAO,MAAA,EAAQ,gBAAA;AAAA,KAGL,yBAAA,GAA4B,MAAA,SAEtC,yBAAA;;;;cAMW,4BAAA,GACX,gCAAA,EAAkC,yBAAA,EAClC,MAAA,kBACA,aAAA,GAF2D,gBAAA,CAE3D,cAAA;;;AAfF;;;;;;;;;;;;;;cAkEa,sBAAA,GACX,kBAAA,EAAoB,sBAAA,EACpB,aAAA,GAD0C,gBAAA,CAC1C,cAAA,EACA,OAAA,yBACC,OAAA,CAAQ,yBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeFetchDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"writeFetchDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"mappings":";;;;;;;cAea,4BAAA,GACX,8BAAA,EAAgC,yBAAA,EAChC,MAAA,kBACA,aAAA,GAFyD,gBAAA,CAEzD,cAAA;;;;;;;;;;;AA+CF;;;;;;cAAa,oBAAA,GACX,mBAAA,EAAqB,yBAAA,EACrB,aAAA,GAD8C,gBAAA,CAC9C,cAAA,EACA,OAAA,yBACC,OAAA,CAAQ,yBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeMergedDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"writeMergedDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"mappings":";;;;;KAaY,sBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,sBAAA,GAAyB,MAAA,SAAe,sBAAA;;;;;;;;AAApD;;;;;AAkBA;;;;cAAa,uBAAA,GACX,mBAAA,EAAqB,wBAAA,EACrB,aAAA,GAD6C,gBAAA,CAC7C,cAAA,KACC,OAAA,CAAQ,sBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeRemoteDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"writeRemoteDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"mappings":";;;;KAeY,sBAAA;EACV,cAAA;EACA,YAAA,EAAc,UAAA;AAAA;AAAA,KAGJ,sBAAA,GAAyB,MAAA,SAAe,sBAAA;;;;;;;;AAApD;;;;;AAkBA;;;;cAAa,qBAAA,GACX,kBAAA,EAAoB,UAAA,IACpB,aAAA,GAD8B,gBAAA,CAC9B,cAAA,KACC,OAAA,CAAQ,sBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateDictionaryListContent.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"generateDictionaryListContent.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"mappings":";;;;;;cAQa,6BAAA,GACX,YAAA,YACA,YAAA,UACA,UAAA,yBACA,MAAA,kBACA,aAAA,GA2CD,gBAAA,CA3CC,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchDistantDictionaries.d.ts","names":[],"sources":["../../src/fetchDistantDictionaries.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"fetchDistantDictionaries.d.ts","names":[],"sources":["../../src/fetchDistantDictionaries.ts"],"mappings":";;;;;KAQK,+BAAA;EACH,cAAA;EACA,mBAAA;EACA,SAAA;AAAA;;;;cAMW,wBAAA,GACX,OAAA,EAAS,+BAAA,EACT,cAAA,IAAkB,MAAA,EAAQ,kBAAA,gBACzB,OAAA,CAAQ,aAAA"}
|