@intlayer/chokidar 8.1.10 → 8.2.0
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/astro.md +1 -1
- package/dist/assets/installSkills/skills/cli.md +2 -2
- package/dist/cjs/cli.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
- package/dist/cjs/createType/createModuleAugmentation.cjs +3 -3
- package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/init/utils/configManipulation.cjs +1 -1
- package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
- package/dist/cjs/installMCP/installMCP.cjs +2 -0
- package/dist/cjs/installMCP/installMCP.cjs.map +1 -0
- package/dist/cjs/installSkills/index.cjs +1 -1
- package/dist/cjs/installSkills/index.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +1 -1
- package/dist/cjs/loadDictionaries/log.cjs +1 -1
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +1 -1
- package/dist/cjs/utils/getPathHash.cjs +2 -0
- package/dist/cjs/utils/getPathHash.cjs.map +1 -0
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/cjs/watcher.cjs +1 -1
- package/dist/cjs/watcher.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +1 -2
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +1 -1
- package/dist/esm/cli.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
- package/dist/esm/createType/createModuleAugmentation.mjs +9 -9
- package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/init/utils/configManipulation.mjs +1 -1
- package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
- package/dist/esm/installMCP/installMCP.mjs +2 -0
- package/dist/esm/installMCP/installMCP.mjs.map +1 -0
- package/dist/esm/installSkills/index.mjs +1 -1
- package/dist/esm/installSkills/index.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +1 -1
- package/dist/esm/loadDictionaries/log.mjs +2 -2
- package/dist/esm/loadDictionaries/log.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +1 -1
- package/dist/esm/utils/getPathHash.mjs +2 -0
- package/dist/esm/utils/getPathHash.mjs.map +1 -0
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
- package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
- package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
- package/dist/esm/watcher.mjs +1 -1
- package/dist/esm/watcher.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs +1 -2
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +1 -1
- package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs +1 -1
- package/dist/types/build.d.ts +0 -5
- package/dist/types/cli.d.ts +8 -5
- package/dist/types/createType/createModuleAugmentation.d.ts.map +1 -1
- package/dist/types/fetchDistantDictionaries.d.ts +0 -1
- package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/init/utils/configManipulation.d.ts +0 -12
- package/dist/types/init/utils/configManipulation.d.ts.map +1 -1
- package/dist/types/installMCP/installMCP.d.ts +11 -0
- package/dist/types/installMCP/installMCP.d.ts.map +1 -0
- package/dist/types/installSkills/index.d.ts +23 -49
- package/dist/types/installSkills/index.d.ts.map +1 -1
- package/dist/types/loadDictionaries/log.d.ts.map +1 -1
- package/dist/types/utils/getPathHash.d.ts +5 -0
- package/dist/types/utils/getPathHash.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +2 -2
- package/dist/types/watcher.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/transformJSFile.d.ts +1 -26
- package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/transformJSONFile.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
- package/package.json +9 -23
- package/dist/cjs/index.cjs +0 -1
- package/dist/cjs/transformFiles/extractDictionaryKey.cjs +0 -2
- package/dist/cjs/transformFiles/extractDictionaryKey.cjs.map +0 -1
- package/dist/cjs/transformFiles/index.cjs +0 -1
- package/dist/cjs/transformFiles/transformFiles.cjs +0 -2
- package/dist/cjs/transformFiles/transformFiles.cjs.map +0 -1
- package/dist/cjs/utils/getFileHash.cjs +0 -2
- package/dist/cjs/utils/getFileHash.cjs.map +0 -1
- package/dist/esm/index.mjs +0 -1
- package/dist/esm/transformFiles/extractDictionaryKey.mjs +0 -2
- package/dist/esm/transformFiles/extractDictionaryKey.mjs.map +0 -1
- package/dist/esm/transformFiles/index.mjs +0 -1
- package/dist/esm/transformFiles/transformFiles.mjs +0 -2
- package/dist/esm/transformFiles/transformFiles.mjs.map +0 -1
- package/dist/esm/utils/getFileHash.mjs +0 -2
- package/dist/esm/utils/getFileHash.mjs.map +0 -1
- package/dist/types/index.d.ts +0 -57
- package/dist/types/transformFiles/extractDictionaryKey.d.ts +0 -5
- package/dist/types/transformFiles/extractDictionaryKey.d.ts.map +0 -1
- package/dist/types/transformFiles/index.d.ts +0 -3
- package/dist/types/transformFiles/transformFiles.d.ts +0 -24
- package/dist/types/transformFiles/transformFiles.d.ts.map +0 -1
- package/dist/types/utils/getFileHash.d.ts +0 -5
- package/dist/types/utils/getFileHash.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeContentDeclaration.mjs","names":[],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';\nimport { basename, 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 const tempDir = configuration.system?.tempDir;\n if (tempDir) {\n await mkdir(tempDir, { recursive: true });\n }\n\n const tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n const tempPath = tempDir\n ? join(tempDir, tempFileName)\n : `${absoluteFilePath}.${tempFileName}`;\n try {\n await writeFile(tempPath, `${jsonDictionary}\\n`); // Add a new line at the end of the file to avoid formatting issues with VSCode\n await rename(tempPath, absoluteFilePath);\n } catch (error) {\n try {\n await rm(tempPath, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\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 const tempDir = configuration.system?.tempDir;\n if (tempDir) {\n await mkdir(tempDir, { recursive: true });\n }\n\n const tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n const tempPath = tempDir\n ? join(tempDir, tempFileName)\n : `${absoluteFilePath}.${tempFileName}`;\n try {\n await writeFile(tempPath, transformedContent, 'utf-8');\n await rename(tempPath, absoluteFilePath);\n } catch (error) {\n try {\n await rm(tempPath, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\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":"wsBAwBA,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,CAA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AM,EAAE,CAAC,MAClG,EAAW,EACb,EAAK,EAAS,EAAa,CAC3B,GAAG,EAAiB,GAAG,IAC3B,GAAI,CACF,MAAM,EAAU,EAAU,EAAoB,QAAQ,CACtD,MAAM,EAAO,EAAU,EAAiB,OACjC,EAAO,CACd,GAAI,CACF,MAAM,EAAG,EAAU,CAAE,MAAO,GAAM,CAAC,MAC7B,EAGR,MAAM,EAER,OAGF,MAAM,EAAY,EAAkB,EAAY,EAAc,CAI9D,GAAI,CAKF,MAAM,EAJe,EACnB,EAAc,OAAO,SACrB,yBACD,CACsB,CAAE,UAAW,GAAM,CAAC,MACrC"}
|
|
1
|
+
{"version":3,"file":"writeContentDeclaration.mjs","names":[],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';\nimport { basename, 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 { detectFormatCommand } from '../detectFormatCommand';\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 const tempDir = configuration.system?.tempDir;\n if (tempDir) {\n await mkdir(tempDir, { recursive: true });\n }\n\n const tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n const tempPath = tempDir\n ? join(tempDir, tempFileName)\n : `${absoluteFilePath}.${tempFileName}`;\n try {\n await writeFile(tempPath, `${jsonDictionary}\\n`); // Add a new line at the end of the file to avoid formatting issues with VSCode\n await rename(tempPath, absoluteFilePath);\n } catch (error) {\n try {\n await rm(tempPath, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\n\n const formatCommand = detectFormatCommand(configuration);\n\n if (formatCommand) {\n try {\n execSync(formatCommand.replace('{{file}}', absoluteFilePath), {\n stdio: 'inherit',\n cwd: configuration.content.baseDir,\n });\n } catch (error) {\n console.error(error);\n }\n }\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 const tempDir = configuration.system?.tempDir;\n if (tempDir) {\n await mkdir(tempDir, { recursive: true });\n }\n\n const tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n const tempPath = tempDir\n ? join(tempDir, tempFileName)\n : `${absoluteFilePath}.${tempFileName}`;\n try {\n await writeFile(tempPath, transformedContent, 'utf-8');\n await rename(tempPath, absoluteFilePath);\n } catch (error) {\n try {\n await rm(tempPath, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\n\n const formatCommand = detectFormatCommand(configuration);\n\n if (formatCommand) {\n try {\n execSync(formatCommand.replace('{{file}}', absoluteFilePath), {\n stdio: 'inherit',\n cwd: configuration.content.baseDir,\n });\n } catch (error) {\n console.error(error);\n }\n }\n\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":"uzBA0BA,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,MAA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AAC,MACrC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getFormatFromExtension as e}from"../utils/getFormatFromExtension.mjs";import{transformJSFile as t}from"./transformJSFile.mjs";import{detectFormatCommand as n}from"../detectFormatCommand.mjs";import{getContentDeclarationFileTemplate as r}from"../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";import{mkdir as i,readFile as a,rename as o,rm as s,writeFile as c}from"node:fs/promises";import{basename as l,extname as u,join as d}from"node:path";import{getAppLogger as f,logger as p}from"@intlayer/config/logger";import{existsSync as m}from"node:fs";import{execSync as h}from"node:child_process";const g=async(g,_,v)=>{let y={...v.dictionary,..._},b=f(v);if(!m(g)){let t=e(u(g));b(`File does not exist, creating it`,{isVerbose:!0});let n=await r(y.key,t,Object.fromEntries(Object.entries({id:y.id,locale:y.locale,filled:y.filled,fill:y.fill,description:y.description,title:y.title,tags:y.tags,version:y.version,priority:y.priority,importMode:y.importMode}).filter(([,e])=>e!==void 0))),a=v.system?.tempDir;a&&await i(a,{recursive:!0});let f=`${l(g)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`,p=a?d(a,f):`${g}.${f}`;try{await c(p,n,`utf-8`),await o(p,g)}catch(e){try{await s(p,{force:!0})}catch{}throw e}}let x=await a(g,`utf-8`);if(x===``){let t=e(u(g));x=await r(y.key,t)}let S=await t(x,_),C=v.system?.tempDir;C&&await i(C,{recursive:!0});let w=`${l(g)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`,T=C?d(C,w):`${g}.${w}`;try{await c(T,S,`utf-8`),await o(T,g),p(`Successfully updated ${g}`,{level:`info`,isVerbose:!0})}catch(e){try{await s(T,{force:!0})}catch{}let t=e;throw p(`Failed to write updated file: ${g}`,{level:`error`}),Error(`Failed to write updated file ${g}: ${t.message}`)}let E=n(v);if(E)try{h(E.replace(`{{file}}`,g),{stdio:`inherit`,cwd:v.content.baseDir})}catch(e){console.error(e)}};export{g as writeJSFile};
|
|
2
2
|
//# sourceMappingURL=writeJSFile.mjs.map
|
package/dist/types/build.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { buildDictionary } from "./buildIntlayerDictionary/buildIntlayerDictionary.js";
|
|
2
2
|
import { processContentDeclaration } from "./buildIntlayerDictionary/processContentDeclaration.js";
|
|
3
|
-
import "./buildIntlayerDictionary/index.js";
|
|
4
3
|
import { cleanOutputDir } from "./cleanOutputDir.js";
|
|
5
4
|
import { CreateDictionaryEntryPointOptions, createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.js";
|
|
6
5
|
import { generateDictionaryListContent } from "./createDictionaryEntryPoint/generateDictionaryListContent.js";
|
|
@@ -9,16 +8,13 @@ import { getBuiltDynamicDictionariesPath } from "./createDictionaryEntryPoint/ge
|
|
|
9
8
|
import { getBuiltFetchDictionariesPath } from "./createDictionaryEntryPoint/getBuiltFetchDictionariesPath.js";
|
|
10
9
|
import { getBuiltRemoteDictionariesPath } from "./createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.js";
|
|
11
10
|
import { getBuiltUnmergedDictionariesPath } from "./createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.js";
|
|
12
|
-
import "./createDictionaryEntryPoint/index.js";
|
|
13
11
|
import { createModuleAugmentation, getTypeName } from "./createType/createModuleAugmentation.js";
|
|
14
12
|
import { createTypes, generateTypeScriptType } from "./createType/createType.js";
|
|
15
|
-
import "./createType/index.js";
|
|
16
13
|
import { formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput } from "./formatDictionary.js";
|
|
17
14
|
import { DictionariesStatus, loadDictionaries } from "./loadDictionaries/loadDictionaries.js";
|
|
18
15
|
import { formatLocalDictionaries, loadContentDeclarations } from "./loadDictionaries/loadContentDeclaration.js";
|
|
19
16
|
import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.js";
|
|
20
17
|
import { formatDistantDictionaries, loadRemoteDictionaries } from "./loadDictionaries/loadRemoteDictionaries.js";
|
|
21
|
-
import "./loadDictionaries/index.js";
|
|
22
18
|
import { prepareIntlayer } from "./prepareIntlayer.js";
|
|
23
19
|
import { isCachedConfigurationUpToDate, writeConfiguration } from "./writeConfiguration/index.js";
|
|
24
20
|
import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.js";
|
|
@@ -26,5 +22,4 @@ import { DictionaryStatus } from "./writeContentDeclaration/dictionaryStatus.js"
|
|
|
26
22
|
import { transformJSFile } from "./writeContentDeclaration/transformJSFile.js";
|
|
27
23
|
import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.js";
|
|
28
24
|
import { writeJSFile } from "./writeContentDeclaration/writeJSFile.js";
|
|
29
|
-
import "./writeContentDeclaration/index.js";
|
|
30
25
|
export { CreateDictionaryEntryPointOptions, DictionariesStatus, DictionaryStatus, buildDictionary, cleanOutputDir, createDictionaryEntryPoint, createModuleAugmentation, createTypes, detectExportedComponentName, 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 };
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.js";
|
|
2
|
+
import { DictionaryStatus } from "./writeContentDeclaration/dictionaryStatus.js";
|
|
3
|
+
import { transformJSFile } from "./writeContentDeclaration/transformJSFile.js";
|
|
4
|
+
import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.js";
|
|
5
|
+
import { writeJSFile } from "./writeContentDeclaration/writeJSFile.js";
|
|
1
6
|
import { detectFormatCommand } from "./detectFormatCommand.js";
|
|
2
7
|
import { getContentDeclarationFileTemplate } from "./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.js";
|
|
3
8
|
import { initIntlayer } from "./init/index.js";
|
|
4
|
-
import { Platform, SKILLS, SKILLS_METADATA, Skill, installSkills } from "./installSkills/index.js";
|
|
9
|
+
import { PLATFORMS, PLATFORMS_METADATA, Platform, PlatformMetadata, SKILLS, SKILLS_METADATA, Skill, getInitialSkills, installSkills } from "./installSkills/index.js";
|
|
10
|
+
import { MCPTransport, installMCP } from "./installMCP/installMCP.js";
|
|
5
11
|
import { listDictionaries, listDictionariesWithStats } from "./listDictionariesPath.js";
|
|
6
12
|
import { DiffMode, ListGitFilesOptions, ListGitLinesOptions, listGitFiles, listGitLines } from "./listGitFiles.js";
|
|
7
13
|
import { ListProjectsOptions, listProjects } from "./listProjects.js";
|
|
8
|
-
|
|
9
|
-
import { ATTRIBUTES_TO_EXTRACT, ExtractIntlayerOptions, PackageName, extractIntlayer, shouldExtract, transformFiles } from "./transformFiles/transformFiles.js";
|
|
10
|
-
import "./transformFiles/index.js";
|
|
11
|
-
export { ATTRIBUTES_TO_EXTRACT, DiffMode, ExtractIntlayerOptions, ListGitFilesOptions, ListGitLinesOptions, ListProjectsOptions, PackageName, Platform, SKILLS, SKILLS_METADATA, Skill, detectFormatCommand, extractDictionaryKey, extractIntlayer, getContentDeclarationFileTemplate, initIntlayer, installSkills, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, shouldExtract, transformFiles };
|
|
14
|
+
export { DictionaryStatus, DiffMode, ListGitFilesOptions, ListGitLinesOptions, ListProjectsOptions, MCPTransport, PLATFORMS, PLATFORMS_METADATA, Platform, PlatformMetadata, SKILLS, SKILLS_METADATA, Skill, detectExportedComponentName, detectFormatCommand, getContentDeclarationFileTemplate, getInitialSkills, initIntlayer, installMCP, installSkills, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, transformJSFile, writeContentDeclaration, writeJSFile };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createModuleAugmentation.d.ts","names":[],"sources":["../../../src/createType/createModuleAugmentation.ts"],"mappings":";;;cASa,WAAA,GAAe,GAAA;;
|
|
1
|
+
{"version":3,"file":"createModuleAugmentation.d.ts","names":[],"sources":["../../../src/createType/createModuleAugmentation.ts"],"mappings":";;;cASa,WAAA,GAAe,GAAA;;cAyKf,wBAAA,GACX,aAAA,EAAe,cAAA,KAAc,OAAA"}
|
|
@@ -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"}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
//#region src/init/utils/configManipulation.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Updates a Vite configuration file to include the Intlayer plugin.
|
|
4
|
-
* @param content The content of the vite.config file
|
|
5
|
-
* @param extension The file extension (ts, js, mjs, cjs)
|
|
6
|
-
* @returns The updated content
|
|
7
|
-
*/
|
|
8
2
|
declare const updateViteConfig: (content: string, extension: string) => string;
|
|
9
|
-
/**
|
|
10
|
-
* Updates a Next.js configuration file to wrap the export with withIntlayer.
|
|
11
|
-
* @param content The content of the next.config file
|
|
12
|
-
* @param extension The file extension (ts, js, mjs, cjs)
|
|
13
|
-
* @returns The updated content
|
|
14
|
-
*/
|
|
15
3
|
declare const updateNextConfig: (content: string, extension: string) => string;
|
|
16
4
|
//#endregion
|
|
17
5
|
export { updateNextConfig, updateViteConfig };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configManipulation.d.ts","names":[],"sources":["../../../../src/init/utils/configManipulation.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"configManipulation.d.ts","names":[],"sources":["../../../../src/init/utils/configManipulation.ts"],"mappings":";cAmEa,gBAAA,GACX,OAAA,UACA,SAAA;AAAA,cAoHW,gBAAA,GACX,OAAA,UACA,SAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Platform } from "../installSkills/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/installMCP/installMCP.d.ts
|
|
4
|
+
type MCPTransport = 'stdio' | 'sse';
|
|
5
|
+
/**
|
|
6
|
+
* Installs the Intlayer MCP server configuration for a specific platform.
|
|
7
|
+
*/
|
|
8
|
+
declare const installMCP: (projectRoot: string, platform: Platform, transport: MCPTransport) => Promise<string>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { MCPTransport, installMCP };
|
|
11
|
+
//# sourceMappingURL=installMCP.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installMCP.d.ts","names":[],"sources":["../../../src/installMCP/installMCP.ts"],"mappings":";;;KAKY,YAAA;;AAAZ;;cAsBa,UAAA,GACX,WAAA,UACA,QAAA,EAAU,QAAA,EACV,SAAA,EAAW,YAAA,KACV,OAAA"}
|
|
@@ -1,68 +1,42 @@
|
|
|
1
1
|
//#region src/installSkills/index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Metadata for each available documentation skill.
|
|
4
|
+
*/
|
|
2
5
|
declare const SKILLS_METADATA: {
|
|
3
|
-
readonly Usage: "How to use Intlayer in your project";
|
|
4
|
-
readonly RemoteContent: "How to use Intlayer with Remote/CMS/Server-side content";
|
|
5
6
|
readonly Config: "Intlayer configuration documentation";
|
|
6
7
|
readonly Content: "Reference for all Intlayer content node types (t, enu, etc.)";
|
|
7
|
-
readonly
|
|
8
|
-
readonly
|
|
8
|
+
readonly Usage: "How to use Intlayer in your project";
|
|
9
|
+
readonly CLI: "Intlayer CLI commands and usage";
|
|
10
|
+
readonly Compiler: "Intlayer Compiler setup and usage for automatic content extraction without .content files";
|
|
11
|
+
readonly RemoteContent: "How to use Intlayer with Remote/CMS/Server-side content";
|
|
9
12
|
readonly NextJS: "Next.js-specific usage (Server & Client components)";
|
|
13
|
+
readonly React: "React-specific syntax and hooks usage";
|
|
10
14
|
readonly Vue: "Vue-specific composables and syntax";
|
|
15
|
+
readonly Svelte: "Svelte-specific stores and syntax";
|
|
16
|
+
readonly Angular: "Angular-specific syntax and Injectable Function usage";
|
|
11
17
|
readonly Preact: "Preact-specific syntax and hooks usage";
|
|
12
18
|
readonly Solid: "Integrates Intlayer internationalization with SolidJS components. Use when the user asks to \"setup SolidJS i18n\", use the \"useIntlayer\" hook in Solid, or manage locales in a SolidJS application.";
|
|
13
|
-
readonly Svelte: "Svelte-specific stores and syntax";
|
|
14
19
|
readonly Astro: "Astro-specific usage and getIntlayer";
|
|
15
|
-
readonly CLI: "Intlayer CLI commands and usage";
|
|
16
|
-
readonly Compiler: "Intlayer Compiler setup and usage for automatic content extraction without .content files";
|
|
17
20
|
};
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
type Skill = keyof typeof SKILLS_METADATA;
|
|
22
|
+
declare const SKILLS: Skill[];
|
|
23
|
+
declare const getInitialSkills: (deps: Record<string, string>) => (keyof typeof SKILLS_METADATA)[];
|
|
24
|
+
interface PlatformMetadata {
|
|
25
|
+
label: string;
|
|
26
|
+
dir: string;
|
|
27
|
+
check?: () => boolean;
|
|
28
|
+
}
|
|
20
29
|
/**
|
|
21
|
-
*
|
|
30
|
+
* Metadata and configuration for each supported platform.
|
|
22
31
|
*/
|
|
23
|
-
declare const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Trae: string;
|
|
27
|
-
OpenCode: string;
|
|
28
|
-
GitHub: string;
|
|
29
|
-
Claude: string;
|
|
30
|
-
VSCode: string;
|
|
31
|
-
Antigravity: string;
|
|
32
|
-
Augment: string;
|
|
33
|
-
OpenClaw: string;
|
|
34
|
-
Cline: string;
|
|
35
|
-
CodeBuddy: string;
|
|
36
|
-
CommandCode: string;
|
|
37
|
-
Continue: string;
|
|
38
|
-
Crush: string;
|
|
39
|
-
Droid: string;
|
|
40
|
-
Goose: string;
|
|
41
|
-
Junie: string;
|
|
42
|
-
IFlow: string;
|
|
43
|
-
KiloCode: string;
|
|
44
|
-
Kiro: string;
|
|
45
|
-
Kode: string;
|
|
46
|
-
MCPJam: string;
|
|
47
|
-
MistralVibe: string;
|
|
48
|
-
Mux: string;
|
|
49
|
-
OpenHands: string;
|
|
50
|
-
Pi: string;
|
|
51
|
-
Qoder: string;
|
|
52
|
-
Qwen: string;
|
|
53
|
-
RooCode: string;
|
|
54
|
-
TraeCN: string;
|
|
55
|
-
Zencoder: string;
|
|
56
|
-
Neovate: string;
|
|
57
|
-
Pochi: string;
|
|
58
|
-
Other: string;
|
|
59
|
-
};
|
|
60
|
-
type Platform = keyof typeof PLATFORM_DIRS;
|
|
32
|
+
declare const PLATFORMS_METADATA: Record<string, PlatformMetadata>;
|
|
33
|
+
type Platform = keyof typeof PLATFORMS_METADATA;
|
|
34
|
+
declare const PLATFORMS: Platform[];
|
|
61
35
|
/**
|
|
62
36
|
* Installs skills using the "Agent Skills" directory standard.
|
|
63
37
|
* Standard: <PROJECT_ROOT>/<CONFIG_DIR>/skills/<SKILL_NAME>/SKILL.md
|
|
64
38
|
*/
|
|
65
39
|
declare const installSkills: (projectRoot: string, platform: Platform, skills: Skill[]) => Promise<string>;
|
|
66
40
|
//#endregion
|
|
67
|
-
export { Platform, SKILLS, SKILLS_METADATA, Skill, installSkills };
|
|
41
|
+
export { PLATFORMS, PLATFORMS_METADATA, Platform, PlatformMetadata, SKILLS, SKILLS_METADATA, Skill, getInitialSkills, installSkills };
|
|
68
42
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/installSkills/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/installSkills/index.ts"],"mappings":";;AAQA;;cAAa,eAAA;EAAA;;;;;;;;;;;;;;;KAmBD,KAAA,gBAAqB,eAAA;AAAA,cAEpB,MAAA,EAAyC,KAAA;AAAA,cAEzC,gBAAA,GACX,IAAA,EAAM,MAAA,mCACS,eAAA;AAAA,UAoBA,gBAAA;EACf,KAAA;EACA,GAAA;EACA,KAAA;AAAA;;;;cAMW,kBAAA,EAAoB,MAAA,SAAe,gBAAA;AAAA,KA6JpC,QAAA,gBAAwB,kBAAA;AAAA,cAEvB,SAAA,EAA+C,QAAA;;;;;cAyD/C,aAAA,GACX,WAAA,UACA,QAAA,EAAU,QAAA,EACV,MAAA,EAAQ,KAAA,OACP,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","names":[],"sources":["../../../src/loadDictionaries/log.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"log.d.ts","names":[],"sources":["../../../src/loadDictionaries/log.ts"],"mappings":";;;cAYa,kBAAA;EAAA,QACH,QAAA;EAAA,QACA,YAAA;EAAA,QACA,YAAA;EAAA,QACA,aAAA;EAAA,iBACS,aAAA;EAAA,QACT,UAAA;EAAA,iBACS,MAAA;EAAA,QACT,iBAAA;EAAA,QACA,qBAAA;EAAA,QACA,YAAA;EAAA,QACA,WAAA;EAAA,QACA,WAAA;EAAA,QACA,UAAA;EAAA,QACA,WAAA;;EAMR,eAAA,CAAgB,MAAA;EAIhB,gBAAA,CAAA;EAOA,eAAA,CAAA;EAIA,MAAA,CAAO,WAAA,EAAa,kBAAA;EAyBpB,MAAA,CAAA;EAAA,QAOQ,YAAA;EAAA,QAQA,WAAA;EAMD,cAAA,GAAkB,KAAA,GAAQ,KAAA;EAQjC,cAAA,CAAe,KAAA;EASf,aAAA,CAAc,IAAA;EAMd,cAAA,CAAe,KAAA,GAAQ,KAAA;EAAA,QAMf,MAAA;EAAA,QAqGA,eAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPathHash.d.ts","names":[],"sources":["../../../src/utils/getPathHash.ts"],"mappings":";cAEa,WAAA,GAAe,QAAA"}
|
|
@@ -5,7 +5,7 @@ import { JSONObject, JsonChunk, assembleJSON, chunkJSON, reconstructFromSingleCh
|
|
|
5
5
|
import { formatLocale, formatPath } from "./formatter.js";
|
|
6
6
|
import { getChunk } from "./getChunk.js";
|
|
7
7
|
import { getComponentTransformPattern, getComponentTransformPatternSync } from "./getComponentTransformPattern.js";
|
|
8
|
-
import {
|
|
8
|
+
import { getPathHash } from "./getPathHash.js";
|
|
9
9
|
import { mergeChunks } from "./mergeChunks.js";
|
|
10
10
|
import { parallelize } from "./parallelize.js";
|
|
11
11
|
import { Queue, pLimit } from "./pLimit.js";
|
|
@@ -17,4 +17,4 @@ import { ParallelHandle, runParallel } from "./runParallel/index.js";
|
|
|
17
17
|
import { sortAlphabetically } from "./sortAlphabetically.js";
|
|
18
18
|
import { splitTextByLines } from "./splitTextByLine.js";
|
|
19
19
|
import { verifyIdenticObjectFormat } from "./verifyIdenticObjectFormat.js";
|
|
20
|
-
export { BuildFilesListOptions, Extension, Format, JSONObject, JsonChunk, ParallelHandle, Queue, assembleJSON, autoDecorateContent, buildFilesList, chunkJSON, formatLocale, formatPath, getChunk, getComponentTransformPattern, getComponentTransformPatternSync, getExtensionFromFormat,
|
|
20
|
+
export { BuildFilesListOptions, Extension, Format, JSONObject, JsonChunk, ParallelHandle, Queue, assembleJSON, autoDecorateContent, buildFilesList, chunkJSON, formatLocale, formatPath, getChunk, getComponentTransformPattern, getComponentTransformPatternSync, getExtensionFromFormat, getFormatFromExtension, getGlobalLimiter, getPathHash, getTaskLimiter, mergeChunks, pLimit, parallelize, parallelizeGlobal, reconstructFromSingleChunk, reduceObjectFormat, resolveObjectPromises, runOnce, runParallel, sortAlphabetically, splitTextByLines, verifyIdenticObjectFormat };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watcher.d.ts","names":[],"sources":["../../src/watcher.ts"],"mappings":";;;;;;KAqCK,YAAA,GAAe,eAAA;EAClB,aAAA,GAAgB,cAAA;EAChB,aAAA,GAAgB,uBAAA;EAChB,WAAA;AAAA;AAAA,cAIW,KAAA,GAAS,OAAA,GAAU,YAAA,KAAY,QAAA,CAAA,SAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"watcher.d.ts","names":[],"sources":["../../src/watcher.ts"],"mappings":";;;;;;KAqCK,YAAA,GAAe,eAAA;EAClB,aAAA,GAAgB,cAAA;EAChB,aAAA,GAAgB,uBAAA;EAChB,WAAA;AAAA;AAAA,cAIW,KAAA,GAAS,OAAA,GAAU,YAAA,KAAY,QAAA,CAAA,SAAA;AAAA,cAuJ/B,qBAAA,GAA+B,OAAA,GAAU,YAAA,KAAY,OAAA"}
|
|
@@ -2,32 +2,7 @@ import { Dictionary, Locale } from "@intlayer/types";
|
|
|
2
2
|
|
|
3
3
|
//#region src/writeContentDeclaration/transformJSFile.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Updates a
|
|
6
|
-
* It targets a specific dictionary object within the file and updates its
|
|
7
|
-
* metadata (title, description, tags) and content entries.
|
|
8
|
-
*
|
|
9
|
-
* This function now supports inserting translation keys into nested objects
|
|
10
|
-
* within arrays. For example, if you have:
|
|
11
|
-
* ```
|
|
12
|
-
* content: [
|
|
13
|
-
* { question: t({ en: '...', fr: '...' }) }
|
|
14
|
-
* ]
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* You can add a new locale (e.g., 'pl') by providing a dictionary with:
|
|
18
|
-
* ```
|
|
19
|
-
* {
|
|
20
|
-
* content: [
|
|
21
|
-
* { question: { [NodeType.Translation]: { en: '...', fr: '...', pl: '...' } } }
|
|
22
|
-
* ]
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* The function will:
|
|
27
|
-
* 1. Detect the existing array structure
|
|
28
|
-
* 2. Navigate into each array element (if it's an object)
|
|
29
|
-
* 3. Recursively process nested properties
|
|
30
|
-
* 4. Update translation maps while preserving existing locales
|
|
5
|
+
* Updates a JS/TS file seamlessly to map new localization keys, arrays, complex nodes and nested dictionaries gracefully using AST updates via Recast parser.
|
|
31
6
|
*/
|
|
32
7
|
declare const transformJSFile: (fileContent: string, dictionary: Dictionary, fallbackLocale?: Locale) => Promise<string>;
|
|
33
8
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformJSFile.d.ts","names":[],"sources":["../../../src/writeContentDeclaration/transformJSFile.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"transformJSFile.d.ts","names":[],"sources":["../../../src/writeContentDeclaration/transformJSFile.ts"],"mappings":";;;;;AAyhBA;cAAa,eAAA,GACX,WAAA,UACA,UAAA,EAAY,UAAA,EACZ,cAAA,GAAiB,MAAA,KAChB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformJSONFile.d.ts","names":[],"sources":["../../../src/writeContentDeclaration/transformJSONFile.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"transformJSONFile.d.ts","names":[],"sources":["../../../src/writeContentDeclaration/transformJSONFile.ts"],"mappings":";;;cAgGa,iBAAA,GACX,WAAA,UACA,UAAA,EAAY,UAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeContentDeclaration.d.ts","names":[],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"writeContentDeclaration.d.ts","names":[],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"mappings":";;;;KAuHK,8BAAA;EACH,mBAAA;EACA,UAAA,GAAa,aAAA;EACb,cAAA,GAAiB,MAAA;AAAA;AAAA,cAON,uBAAA,GACX,UAAA,EAAY,UAAA,EACZ,aAAA,EAAe,cAAA,EACf,OAAA,GAAU,8BAAA,KACT,OAAA;EAAU,MAAA,EAAQ,gBAAA;EAAkB,IAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.",
|
|
6
6
|
"keywords": [
|
|
@@ -101,23 +101,21 @@
|
|
|
101
101
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@intlayer/api": "8.1.
|
|
105
|
-
"@intlayer/config": "8.1.
|
|
106
|
-
"@intlayer/core": "8.1.
|
|
107
|
-
"@intlayer/dictionaries-entry": "8.1.
|
|
108
|
-
"@intlayer/remote-dictionaries-entry": "8.1.
|
|
109
|
-
"@intlayer/types": "8.
|
|
110
|
-
"@intlayer/unmerged-dictionaries-entry": "8.1.
|
|
104
|
+
"@intlayer/api": "8.1.11",
|
|
105
|
+
"@intlayer/config": "8.1.11",
|
|
106
|
+
"@intlayer/core": "8.1.11",
|
|
107
|
+
"@intlayer/dictionaries-entry": "8.1.11",
|
|
108
|
+
"@intlayer/remote-dictionaries-entry": "8.1.11",
|
|
109
|
+
"@intlayer/types": "8.2.0",
|
|
110
|
+
"@intlayer/unmerged-dictionaries-entry": "8.1.11",
|
|
111
111
|
"chokidar": "3.6.0",
|
|
112
|
-
"crypto-js": "4.2.0",
|
|
113
112
|
"defu": "6.1.4",
|
|
114
113
|
"fast-glob": "3.3.3",
|
|
114
|
+
"recast": "^0.23.11",
|
|
115
115
|
"simple-git": "3.32.3",
|
|
116
|
-
"ts-morph": "27.0.2",
|
|
117
116
|
"zod-to-ts": "2.0.0"
|
|
118
117
|
},
|
|
119
118
|
"devDependencies": {
|
|
120
|
-
"@types/crypto-js": "4.2.2",
|
|
121
119
|
"@types/node": "25.3.3",
|
|
122
120
|
"@utils/ts-config": "1.0.4",
|
|
123
121
|
"@utils/ts-config-types": "1.0.4",
|
|
@@ -128,18 +126,6 @@
|
|
|
128
126
|
"vitest": "4.0.18",
|
|
129
127
|
"zod": "4.3.6"
|
|
130
128
|
},
|
|
131
|
-
"peerDependencies": {
|
|
132
|
-
"@intlayer/svelte-transformer": "8.1.10",
|
|
133
|
-
"@intlayer/vue-transformer": "8.1.10"
|
|
134
|
-
},
|
|
135
|
-
"peerDependenciesMeta": {
|
|
136
|
-
"@intlayer/svelte-transformer": {
|
|
137
|
-
"optional": true
|
|
138
|
-
},
|
|
139
|
-
"@intlayer/vue-transformer": {
|
|
140
|
-
"optional": true
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
129
|
"engines": {
|
|
144
130
|
"node": ">=14.18"
|
|
145
131
|
},
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./utils/pLimit.cjs`),t=require(`./utils/parallelize.cjs`),n=require(`./utils/formatter.cjs`),r=require(`./buildIntlayerDictionary/buildIntlayerDictionary.cjs`),i=require(`./utils/autoDecorateContent.cjs`),a=require(`./utils/resolveObjectPromises.cjs`),o=require(`./buildIntlayerDictionary/processContentDeclaration.cjs`),s=require(`./cleanOutputDir.cjs`),c=require(`./utils/getFileHash.cjs`),l=require(`./createDictionaryEntryPoint/generateDictionaryListContent.cjs`),u=require(`./createDictionaryEntryPoint/getBuiltDictionariesPath.cjs`),d=require(`./createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs`),f=require(`./createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs`),p=require(`./createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs`),m=require(`./createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs`),h=require(`./createDictionaryEntryPoint/createDictionaryEntryPoint.cjs`),g=require(`./createType/createModuleAugmentation.cjs`),_=require(`./createType/createType.cjs`),v=require(`./formatDictionary.cjs`),y=require(`./loadDictionaries/loadContentDeclaration.cjs`),b=require(`./utils/sortAlphabetically.cjs`),x=require(`./loadDictionaries/loadRemoteDictionaries.cjs`),S=require(`./loadDictionaries/loadDictionaries.cjs`),C=require(`./loadDictionaries/loadLocalDictionaries.cjs`),w=require(`./listDictionariesPath.cjs`),T=require(`./utils/runOnce.cjs`),E=require(`./writeConfiguration/index.cjs`),D=require(`./prepareIntlayer.cjs`),O=require(`./writeContentDeclaration/detectExportedComponentName.cjs`),k=require(`./writeContentDeclaration/transformJSFile.cjs`),A=require(`./utils/getFormatFromExtension.cjs`),j=require(`./detectFormatCommand.cjs`),M=require(`./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs`),N=require(`./writeContentDeclaration/writeJSFile.cjs`),P=require(`./writeContentDeclaration/writeContentDeclaration.cjs`),F=require(`./init/index.cjs`),I=require(`./installSkills/index.cjs`),L=require(`./listGitFiles.cjs`),R=require(`./listProjects.cjs`),z=require(`./transformFiles/extractDictionaryKey.cjs`),B=require(`./transformFiles/transformFiles.cjs`),V=require(`./utils/buildFilesList.cjs`),H=require(`./utils/splitTextByLine.cjs`),U=require(`./utils/getChunk.cjs`),W=require(`./utils/chunkJSON.cjs`),G=require(`./utils/getComponentTransformPattern.cjs`),K=require(`./utils/mergeChunks.cjs`),q=require(`./utils/parallelizeGlobal.cjs`),J=require(`./utils/reduceObjectFormat.cjs`),Y=require(`./utils/runParallel/index.cjs`),X=require(`./utils/verifyIdenticObjectFormat.cjs`),Z=require(`./watcher.cjs`);exports.ATTRIBUTES_TO_EXTRACT=B.ATTRIBUTES_TO_EXTRACT,exports.Queue=e.Queue,exports.SKILLS=I.SKILLS,exports.SKILLS_METADATA=I.SKILLS_METADATA,exports.assembleJSON=W.assembleJSON,exports.autoDecorateContent=i.autoDecorateContent,exports.buildAndWatchIntlayer=Z.buildAndWatchIntlayer,exports.buildDictionary=r.buildDictionary,exports.buildFilesList=V.buildFilesList,exports.chunkJSON=W.chunkJSON,exports.cleanOutputDir=s.cleanOutputDir,exports.createDictionaryEntryPoint=h.createDictionaryEntryPoint,exports.createModuleAugmentation=g.createModuleAugmentation,exports.createTypes=_.createTypes,exports.detectExportedComponentName=O.detectExportedComponentName,exports.detectFormatCommand=j.detectFormatCommand,exports.extractDictionaryKey=z.extractDictionaryKey,exports.extractIntlayer=B.extractIntlayer,exports.formatDictionaries=v.formatDictionaries,exports.formatDictionariesOutput=v.formatDictionariesOutput,exports.formatDictionary=v.formatDictionary,exports.formatDictionaryOutput=v.formatDictionaryOutput,exports.formatDistantDictionaries=x.formatDistantDictionaries,exports.formatLocalDictionaries=y.formatLocalDictionaries,exports.formatLocale=n.formatLocale,exports.formatPath=n.formatPath,exports.generateDictionaryListContent=l.generateDictionaryListContent,exports.generateTypeScriptType=_.generateTypeScriptType,exports.getBuiltDictionariesPath=u.getBuiltDictionariesPath,exports.getBuiltDynamicDictionariesPath=d.getBuiltDynamicDictionariesPath,exports.getBuiltFetchDictionariesPath=f.getBuiltFetchDictionariesPath,exports.getBuiltRemoteDictionariesPath=p.getBuiltRemoteDictionariesPath,exports.getBuiltUnmergedDictionariesPath=m.getBuiltUnmergedDictionariesPath,exports.getChunk=U.getChunk,exports.getComponentTransformPattern=G.getComponentTransformPattern,exports.getComponentTransformPatternSync=G.getComponentTransformPatternSync,exports.getContentDeclarationFileTemplate=M.getContentDeclarationFileTemplate,exports.getExtensionFromFormat=A.getExtensionFromFormat,exports.getFileHash=c.getFileHash,exports.getFormatFromExtension=A.getFormatFromExtension,exports.getGlobalLimiter=q.getGlobalLimiter,exports.getTaskLimiter=q.getTaskLimiter,exports.getTypeName=g.getTypeName,exports.initIntlayer=F.initIntlayer,exports.installSkills=I.installSkills,exports.isCachedConfigurationUpToDate=E.isCachedConfigurationUpToDate,exports.listDictionaries=w.listDictionaries,exports.listDictionariesWithStats=w.listDictionariesWithStats,exports.listGitFiles=L.listGitFiles,exports.listGitLines=L.listGitLines,exports.listProjects=R.listProjects,exports.loadContentDeclarations=y.loadContentDeclarations,exports.loadDictionaries=S.loadDictionaries,exports.loadLocalDictionaries=C.loadLocalDictionaries,exports.loadRemoteDictionaries=x.loadRemoteDictionaries,exports.mergeChunks=K.mergeChunks,exports.pLimit=e.pLimit,exports.parallelize=t.parallelize,exports.parallelizeGlobal=q.parallelizeGlobal,exports.prepareIntlayer=D.prepareIntlayer,exports.processContentDeclaration=o.processContentDeclaration,exports.reconstructFromSingleChunk=W.reconstructFromSingleChunk,exports.reduceObjectFormat=J.reduceObjectFormat,exports.resolveObjectPromises=a.resolveObjectPromises,exports.runOnce=T.runOnce,exports.runParallel=Y.runParallel,exports.shouldExtract=B.shouldExtract,exports.sortAlphabetically=b.sortAlphabetically,exports.splitTextByLines=H.splitTextByLines,exports.transformFiles=B.transformFiles,exports.transformJSFile=k.transformJSFile,exports.verifyIdenticObjectFormat=X.verifyIdenticObjectFormat,exports.watch=Z.watch,exports.writeConfiguration=E.writeConfiguration,exports.writeContentDeclaration=P.writeContentDeclaration,exports.writeJSFile=N.writeJSFile;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../writeContentDeclaration/detectExportedComponentName.cjs`);let t=require(`node:path`);const n=(n,r)=>{let i=e.detectExportedComponentName(r);if(i)return i;let a=(0,t.basename)(n,(0,t.extname)(n));return a===`index`&&(a=(0,t.basename)((0,t.dirname)(n))),a};exports.extractDictionaryKey=n;
|
|
2
|
-
//# sourceMappingURL=extractDictionaryKey.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractDictionaryKey.cjs","names":["detectExportedComponentName"],"sources":["../../../src/transformFiles/extractDictionaryKey.ts"],"sourcesContent":["import { basename, dirname, extname } from 'node:path';\nimport { detectExportedComponentName } from '../writeContentDeclaration/detectExportedComponentName';\n\nexport const extractDictionaryKey = (\n filePath: string,\n fileText: string\n): string => {\n const componentName = detectExportedComponentName(fileText);\n if (componentName) {\n return componentName;\n }\n\n const ext = extname(filePath);\n let baseName = basename(filePath, ext);\n\n if (baseName === 'index') {\n baseName = basename(dirname(filePath));\n }\n\n return baseName;\n};\n"],"mappings":"yNAGA,MAAa,GACX,EACA,IACW,CACX,IAAM,EAAgBA,EAAAA,4BAA4B,EAAS,CAC3D,GAAI,EACF,OAAO,EAIT,IAAI,GAAA,EAAA,EAAA,UAAoB,GAAA,EAAA,EAAA,SADJ,EAAS,CACS,CAMtC,OAJI,IAAa,UACf,GAAA,EAAA,EAAA,WAAA,EAAA,EAAA,SAA4B,EAAS,CAAC,EAGjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./extractDictionaryKey.cjs`),t=require(`./transformFiles.cjs`);exports.ATTRIBUTES_TO_EXTRACT=t.ATTRIBUTES_TO_EXTRACT,exports.extractDictionaryKey=e.extractDictionaryKey,exports.extractIntlayer=t.extractIntlayer,exports.shouldExtract=t.shouldExtract,exports.transformFiles=t.transformFiles;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../detectFormatCommand.cjs`),n=require(`../writeContentDeclaration/writeContentDeclaration.cjs`),r=require(`./extractDictionaryKey.cjs`);let i=require(`@intlayer/config/node`),a=require(`node:fs/promises`);a=e.__toESM(a);let o=require(`node:path`),s=require(`@intlayer/config/logger`),c=require(`@intlayer/config/utils`),l=require(`ts-morph`),u=require(`node:child_process`),d=require(`@intlayer/core/utils`);const f=[`title`,`placeholder`,`alt`,`aria-label`,`label`],p=e=>{let t=e.trim();return!(!t||!t.includes(` `)||!/^[A-Z]/.test(t)||t.startsWith(`{`)||t.startsWith(`v-`))},m=async(e,t,r,i,a)=>{let{defaultLocale:s}=i.internationalization,{baseDir:c,fileExtensions:l}=i.content,u=i?.dictionary?.locale,d=a?(0,o.resolve)(a):(0,o.dirname)(r),f=(0,o.basename)(r,(0,o.extname)(r)),p=(0,o.join)(d,`${f.charAt(0).toLowerCase()+f.slice(1)}.${l[0]}`),m=(0,o.relative)(c,p),h;if(u)h={key:t,content:e,locale:s,filePath:m};else{let n={};for(let[t,r]of Object.entries(e))n[t]={nodeType:`translation`,translation:{[s]:r}};h={key:t,content:n,filePath:m}}let g=(0,o.relative)(c,d);return await n.writeContentDeclaration(h,i,{newDictionariesPath:g}),p},h=(e,t)=>{let n={},r=[];return e.forEachDescendant(e=>{if(l.Node.isJsxText(e)){let i=e.getText();if(p(i)){let a=(0,d.generateKey)(i,t);t.add(a),n[a]=i.replace(/\s+/g,` `).trim(),r.push({node:e,key:a,type:`jsx-text`})}}else if(l.Node.isJsxAttribute(e)){let i=e.getNameNode().getText();if(f.includes(i)){let i=e.getInitializer();if(l.Node.isStringLiteral(i)){let a=i.getLiteralValue();if(p(a)){let i=(0,d.generateKey)(a,t);t.add(i),n[i]=a.trim(),r.push({node:e,key:i,type:`jsx-attribute`})}}}}else if(l.Node.isStringLiteral(e)){let i=e.getLiteralValue();if(p(i)){let a=e.getParent();if(a?.getKindName()===`ImportDeclaration`||a?.getKindName()===`ImportSpecifier`||a?.getKindName()===`ModuleSpecifier`||l.Node.isJsxAttribute(a)||l.Node.isCallExpression(a)&&a.getExpression().getText().includes(`console.log`)||l.Node.isPropertyAssignment(a)&&a.getNameNode()===e)return;let o=(0,d.generateKey)(i,t);t.add(o),n[o]=i.trim(),r.push({node:e,key:o,type:`string-literal`})}}}),{extractedContent:n,replacements:r}},g=async(e,t,n,r,i=!0)=>{let a;try{a=r.addSourceFileAtPath(e)}catch{a=r.getSourceFileOrThrow(e)}let o=n===`solid-intlayer`,{extractedContent:s,replacements:c}=h(a,new Set);if(Object.keys(s).length===0)return null;for(let{node:e,key:t,type:n}of c){let r=o?`content().${t}`:`content.${t}`;n===`jsx-text`&&l.Node.isJsxText(e)?e.replaceWithText(`{${r}}`):n===`jsx-attribute`&&l.Node.isJsxAttribute(e)?e.setInitializer(`{${r}.value}`):n===`string-literal`&&l.Node.isStringLiteral(e)&&e.replaceWithText(`${r}.value`)}let u=a.getImportDeclaration(e=>e.getModuleSpecifierValue()===n);return u?u.getNamedImports().some(e=>e.getName()===`useIntlayer`)||u.addNamedImport(`useIntlayer`):a.addImportDeclaration({namedImports:[`useIntlayer`],moduleSpecifier:n}),a.getFunctions().forEach(e=>{e.getBody()?.asKind(l.SyntaxKind.Block)?.insertStatements(0,`const content = useIntlayer("${t}");`)}),a.getVariableDeclarations().forEach(e=>{let n=e.getInitializer();if(l.Node.isArrowFunction(n)||l.Node.isFunctionExpression(n)){let e=n.getBody();l.Node.isBlock(e)&&(e.getText().includes(`return`)||e.getText().includes(`use`))&&e.insertStatements(0,`const content = useIntlayer("${t}");`)}}),i&&await a.save(),s},_=async(e,n,f,_)=>{let v=!f?.declarationOnly,y=!f?.codeOnly,b=(0,i.getConfiguration)(f?.configOptions),x=(0,s.getAppLogger)(b),{baseDir:S}=b.content,C=_||new l.Project({skipAddingFilesFromTsConfig:!0}),w=r.extractDictionaryKey(e,(await a.default.readFile(e)).toString()),T=(0,c.camelCaseToKebabCase)(w),E=(0,o.extname)(e),D=null;if(E===`.vue`)try{let{processVueFile:t}=await import(`@intlayer/vue-transformer`);D=await t(e,T,n,{generateKey:d.generateKey,shouldExtract:p,extractTsContent:h},v)}catch(e){throw e.code===`ERR_MODULE_NOT_FOUND`||e.message?.includes(`Cannot find module`)?Error(`Please install ${(0,s.colorizePath)(`@intlayer/vue-transformer`,s.ANSIColors.YELLOW)} to process Vue files.`):e}else if(E===`.svelte`)try{let{processSvelteFile:t}=await import(`@intlayer/svelte-transformer`);D=await t(e,T,n,{generateKey:d.generateKey,shouldExtract:p,extractTsContent:h},v)}catch(e){throw e.code===`ERR_MODULE_NOT_FOUND`||e.message?.includes(`Cannot find module`)?Error(`Please install ${(0,s.colorizePath)(`@intlayer/svelte-transformer`,s.ANSIColors.YELLOW)} to process Svelte files.`):e}else [`.tsx`,`.jsx`,`.ts`,`.js`].includes(E)&&(D=await g(e,T,n,C,v));if(!D){x(`No extractable text found in ${w}`);return}if(y){let t=await m(D,T,e,b,f?.outputDir);x(`Created content file: ${(0,s.colorizePath)((0,o.relative)(b.content.baseDir,t))}`)}if(v){try{let n=t.detectFormatCommand(b);n&&(0,u.execSync)(n.replace(`{{file}}`,e),{stdio:`ignore`,cwd:S})}catch{}x(`Updated component: ${(0,s.colorizePath)((0,o.relative)(S,e))}`)}},v=async(e,t,n)=>{let r=(0,s.getAppLogger)((0,i.getConfiguration)(n?.configOptions)),a=new l.Project({skipAddingFilesFromTsConfig:!0});for(let i of e)try{await _(i,t,n,a)}catch(e){r(`Failed to transform ${i}: ${e.message}`)}};exports.ATTRIBUTES_TO_EXTRACT=f,exports.extractIntlayer=_,exports.shouldExtract=p,exports.transformFiles=v;
|
|
2
|
-
//# sourceMappingURL=transformFiles.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformFiles.cjs","names":["writeContentDeclaration","Node","SyntaxKind","Project","extractDictionaryKey","fs","ANSIColors","detectFormatCommand"],"sources":["../../../src/transformFiles/transformFiles.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport fs from 'node:fs/promises';\nimport { basename, dirname, extname, join, relative, resolve } from 'node:path';\nimport {\n ANSIColors,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { camelCaseToKebabCase } from '@intlayer/config/utils';\nimport { generateKey } from '@intlayer/core/utils';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { Node, Project, type SourceFile, SyntaxKind } from 'ts-morph';\nimport { detectFormatCommand } from '../detectFormatCommand';\nimport { writeContentDeclaration } from '../writeContentDeclaration';\nimport { extractDictionaryKey } from './extractDictionaryKey';\n\n// ==========================================\n// Shared Utilities (exported for reuse in babel plugin)\n// ==========================================\n\n/**\n * Attributes that should be extracted for localization\n */\nexport const ATTRIBUTES_TO_EXTRACT = [\n 'title',\n 'placeholder',\n 'alt',\n 'aria-label',\n 'label',\n];\n\n/**\n * Default function to determine if a string should be extracted for localization\n */\nexport const shouldExtract = (text: string): boolean => {\n const trimmed = text.trim();\n if (!trimmed) return false;\n if (!trimmed.includes(' ')) return false;\n // Starts with Capital letter\n if (!/^[A-Z]/.test(trimmed)) return false;\n // Filter out template logic identifiers (simple check)\n if (trimmed.startsWith('{') || trimmed.startsWith('v-')) return false;\n return true;\n};\n\n/**\n * Translation node structure used in multilingual dictionaries\n */\ntype TranslationNode = {\n nodeType: 'translation';\n translation: Record<string, string>;\n};\n\nconst writeContentHelper = async (\n extractedContent: Record<string, string>,\n componentKey: string,\n filePath: string,\n configuration: IntlayerConfig,\n outputDir?: string\n) => {\n const { defaultLocale } = configuration.internationalization;\n const { baseDir, fileExtensions } = configuration.content;\n\n const isPerLocaleFile = configuration?.dictionary?.locale;\n\n const dirName = outputDir ? resolve(outputDir) : dirname(filePath);\n const ext = extname(filePath);\n const baseName = basename(filePath, ext);\n const contentBaseName = baseName.charAt(0).toLowerCase() + baseName.slice(1);\n\n const contentFilePath = join(\n dirName,\n `${contentBaseName}.${fileExtensions[0]}`\n );\n const relativeContentFilePath = relative(baseDir, contentFilePath);\n\n let dictionary: Dictionary;\n\n if (isPerLocaleFile) {\n // Per-locale format: simple string content with locale property\n dictionary = {\n key: componentKey,\n content: extractedContent,\n locale: defaultLocale,\n filePath: relativeContentFilePath,\n };\n } else {\n // Multilingual format: content wrapped in translation nodes, no locale property\n const multilingualContent: Record<string, TranslationNode> = {};\n for (const [key, value] of Object.entries(extractedContent)) {\n multilingualContent[key] = {\n nodeType: 'translation',\n translation: {\n [defaultLocale]: value,\n },\n };\n }\n\n dictionary = {\n key: componentKey,\n content: multilingualContent,\n filePath: relativeContentFilePath,\n };\n }\n\n const relativeDir = relative(baseDir, dirName);\n await writeContentDeclaration(dictionary, configuration, {\n newDictionariesPath: relativeDir,\n });\n\n return contentFilePath;\n};\n\ntype TsReplacement = {\n node: Node;\n key: string;\n type: 'jsx-text' | 'jsx-attribute' | 'string-literal';\n};\n\nconst extractTsContent = (\n sourceFile: SourceFile,\n existingKeys: Set<string>\n): {\n extractedContent: Record<string, string>;\n replacements: TsReplacement[];\n} => {\n const extractedContent: Record<string, string> = {};\n const replacements: TsReplacement[] = [];\n\n sourceFile.forEachDescendant((node) => {\n // 1. JSX Text\n if (Node.isJsxText(node)) {\n const text = node.getText();\n if (shouldExtract(text)) {\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[key] = text.replace(/\\s+/g, ' ').trim();\n replacements.push({ node, key, type: 'jsx-text' });\n }\n }\n\n // 2. JSX Attributes\n else if (Node.isJsxAttribute(node)) {\n const name = node.getNameNode().getText();\n if (ATTRIBUTES_TO_EXTRACT.includes(name)) {\n const initializer = node.getInitializer();\n if (Node.isStringLiteral(initializer)) {\n const text = initializer.getLiteralValue();\n if (shouldExtract(text)) {\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[key] = text.trim();\n replacements.push({ node, key, type: 'jsx-attribute' });\n }\n }\n }\n }\n\n // 3. String Literals (Variables, Arrays, etc.)\n else if (Node.isStringLiteral(node)) {\n const text = node.getLiteralValue();\n if (shouldExtract(text)) {\n const parent = node.getParent();\n\n // Skip if inside ImportDeclaration\n if (\n parent?.getKindName() === 'ImportDeclaration' ||\n parent?.getKindName() === 'ImportSpecifier' ||\n parent?.getKindName() === 'ModuleSpecifier'\n ) {\n return;\n }\n\n // Skip if it's a JSX Attribute value (handled above)\n if (Node.isJsxAttribute(parent)) return;\n\n // Skip console.log\n if (Node.isCallExpression(parent)) {\n const expression = parent.getExpression();\n if (expression.getText().includes('console.log')) return;\n }\n\n // Skip Object Keys: { key: \"value\" } -> \"key\" is PropertyAssignment name if not computed\n if (Node.isPropertyAssignment(parent)) {\n if (parent.getNameNode() === node) return; // It's the key\n }\n\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[key] = text.trim();\n replacements.push({ node, key, type: 'string-literal' });\n }\n }\n });\n\n return { extractedContent, replacements };\n};\n\n// ==========================================\n// React (TS-Morph) Strategy\n// ==========================================\n\nconst processTsxFile = async (\n filePath: string,\n componentKey: string,\n packageName: PackageName,\n project: Project,\n save: boolean = true\n) => {\n let sourceFile: SourceFile;\n try {\n sourceFile = project.addSourceFileAtPath(filePath);\n } catch {\n sourceFile = project.getSourceFileOrThrow(filePath);\n }\n\n const isSolid = packageName === 'solid-intlayer';\n\n const existingKeys = new Set<string>();\n const { extractedContent, replacements } = extractTsContent(\n sourceFile,\n existingKeys\n );\n\n if (Object.keys(extractedContent).length === 0) return null;\n\n for (const { node, key, type } of replacements) {\n const contentAccess = isSolid ? `content().${key}` : `content.${key}`;\n\n if (type === 'jsx-text' && Node.isJsxText(node)) {\n node.replaceWithText(`{${contentAccess}}`);\n } else if (type === 'jsx-attribute' && Node.isJsxAttribute(node)) {\n node.setInitializer(`{${contentAccess}.value}`);\n } else if (type === 'string-literal' && Node.isStringLiteral(node)) {\n // For React/JS variables, we usually want the value\n node.replaceWithText(`${contentAccess}.value`);\n }\n }\n\n // Inject hook\n const importDecl = sourceFile.getImportDeclaration(\n (d) => d.getModuleSpecifierValue() === packageName\n );\n if (!importDecl) {\n sourceFile.addImportDeclaration({\n namedImports: ['useIntlayer'],\n moduleSpecifier: packageName,\n });\n } else if (\n !importDecl.getNamedImports().some((n) => n.getName() === 'useIntlayer')\n ) {\n importDecl.addNamedImport('useIntlayer');\n }\n\n // Insert hook at start of component\n sourceFile.getFunctions().forEach((f) => {\n f.getBody()\n ?.asKind(SyntaxKind.Block)\n ?.insertStatements(0, `const content = useIntlayer(\"${componentKey}\");`);\n });\n\n // Also handle const/arrow components\n sourceFile.getVariableDeclarations().forEach((v) => {\n const init = v.getInitializer();\n if (Node.isArrowFunction(init) || Node.isFunctionExpression(init)) {\n const body = init.getBody();\n if (Node.isBlock(body)) {\n // Heuristic: check if it returns JSX or uses hooks\n if (\n body.getText().includes('return') ||\n body.getText().includes('use')\n ) {\n body.insertStatements(\n 0,\n `const content = useIntlayer(\"${componentKey}\");`\n );\n }\n }\n }\n });\n\n if (save) {\n await sourceFile.save();\n }\n return extractedContent;\n};\n\n// ==========================================\n// 5. Main Dispatcher\n// ==========================================\n\nexport type PackageName =\n | 'next-intlayer'\n | 'react-intlayer'\n | 'vue-intlayer'\n | 'svelte-intlayer'\n | 'preact-intlayer'\n | 'solid-intlayer'\n | 'angular-intlayer'\n | 'express-intlayer';\n\nexport type ExtractIntlayerOptions = {\n configOptions?: GetConfigurationOptions;\n outputDir?: string;\n codeOnly?: boolean;\n declarationOnly?: boolean;\n};\n\nexport const extractIntlayer = async (\n filePath: string,\n packageName: PackageName,\n options?: ExtractIntlayerOptions,\n project?: Project\n) => {\n const saveComponent = !options?.declarationOnly;\n const writeContent = !options?.codeOnly;\n\n const configuration = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n const { baseDir } = configuration.content;\n\n // Setup Project for TS/React files if needed\n const _project =\n project || new Project({ skipAddingFilesFromTsConfig: true });\n\n const baseName = extractDictionaryKey(\n filePath,\n (await fs.readFile(filePath)).toString()\n );\n const componentKey = camelCaseToKebabCase(baseName);\n const ext = extname(filePath);\n\n let extractedContent: Record<string, string> | null = null;\n\n if (ext === '.vue') {\n try {\n const { processVueFile } = await import('@intlayer/vue-transformer');\n extractedContent = await processVueFile(\n filePath,\n componentKey,\n packageName,\n {\n generateKey,\n shouldExtract,\n extractTsContent,\n },\n saveComponent\n );\n } catch (error: any) {\n if (\n error.code === 'ERR_MODULE_NOT_FOUND' ||\n error.message?.includes('Cannot find module')\n ) {\n throw new Error(\n `Please install ${colorizePath('@intlayer/vue-transformer', ANSIColors.YELLOW)} to process Vue files.`\n );\n }\n throw error;\n }\n } else if (ext === '.svelte') {\n try {\n const { processSvelteFile } = (await import(\n '@intlayer/svelte-transformer'\n )) as any;\n extractedContent = await processSvelteFile(\n filePath,\n componentKey,\n packageName,\n {\n generateKey,\n shouldExtract,\n extractTsContent,\n },\n saveComponent\n );\n } catch (error: any) {\n if (\n error.code === 'ERR_MODULE_NOT_FOUND' ||\n error.message?.includes('Cannot find module')\n ) {\n throw new Error(\n `Please install ${colorizePath('@intlayer/svelte-transformer', ANSIColors.YELLOW)} to process Svelte files.`\n );\n }\n throw error;\n }\n } else if (['.tsx', '.jsx', '.ts', '.js'].includes(ext)) {\n extractedContent = await processTsxFile(\n filePath,\n componentKey,\n packageName,\n _project,\n saveComponent\n );\n }\n\n if (!extractedContent) {\n appLogger(`No extractable text found in ${baseName}`);\n return;\n }\n\n // Shared Write Logic\n if (writeContent) {\n const contentFilePath = await writeContentHelper(\n extractedContent,\n componentKey,\n filePath,\n configuration,\n options?.outputDir\n );\n\n const relativeContentFilePath = relative(\n configuration.content.baseDir,\n contentFilePath\n );\n appLogger(`Created content file: ${colorizePath(relativeContentFilePath)}`);\n }\n\n // Optional: Format\n if (saveComponent) {\n try {\n const formatCommand = detectFormatCommand(configuration);\n if (formatCommand) {\n execSync(formatCommand.replace('{{file}}', filePath), {\n stdio: 'ignore', // Silent\n cwd: baseDir,\n });\n }\n } catch {\n // Ignore format errors\n }\n\n appLogger(\n `Updated component: ${colorizePath(relative(baseDir, filePath))}`\n );\n }\n};\n\nexport const transformFiles = async (\n filePaths: string[],\n packageName: PackageName,\n options?: ExtractIntlayerOptions\n) => {\n const configuration = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n\n const project = new Project({\n skipAddingFilesFromTsConfig: true,\n });\n\n for (const filePath of filePaths) {\n try {\n await extractIntlayer(filePath, packageName, options, project);\n } catch (error) {\n appLogger(`Failed to transform ${filePath}: ${(error as Error).message}`);\n }\n }\n};\n"],"mappings":"4hBA2BA,MAAa,EAAwB,CACnC,Q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2BACnF,CAEG,OAEC,CAAC,OAAQ,OAAQ,MAAO,MAAM,CAAC,SAAS,EAAI,GACrD,EAAmB,MAAM,EACvB,EACA,EACA,EACA,EACA,EACD,EAGH,GAAI,CAAC,EAAkB,CACrB,EAAU,gCAAgC,IAAW,CACrD,OAIF,GAAI,EAAc,CAChB,IAAM,EAAkB,MAAM,EAC5B,EACA,EACA,EACA,EACA,GAAS,UACV,CAMD,EAAU,0BAAA,EAAA,EAAA,eAAA,EAAA,EAAA,UAHR,EAAc,QAAQ,QACtB,EACD,CACuE,GAAG,CAI7E,GAAI,EAAe,CACjB,GAAI,CACF,IAAM,EAAgBC,EAAAA,oBAAoB,EAAc,CACpD,IACF,EAAA,EAAA,UAAS,EAAc,QAAQ,WAAY,EAAS,CAAE,CACpD,MAAO,SACP,IAAK,EACN,CAAC,MAEE,EAIR,EACE,uBAAA,EAAA,EAAA,eAAA,EAAA,EAAA,UAA4C,EAAS,EAAS,CAAC,GAChE,GAIQ,EAAiB,MAC5B,EACA,EACA,IACG,CAEH,IAAM,GAAA,EAAA,EAAA,eAAA,EAAA,EAAA,kBADiC,GAAS,cAAc,CACjB,CAEvC,EAAU,IAAIJ,EAAAA,QAAQ,CAC1B,4BAA6B,GAC9B,CAAC,CAEF,IAAK,IAAM,KAAY,EACrB,GAAI,CACF,MAAM,EAAgB,EAAU,EAAa,EAAS,EAAQ,OACvD,EAAO,CACd,EAAU,uBAAuB,EAAS,IAAK,EAAgB,UAAU"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`crypto-js`);t=e.__toESM(t);const n=e=>t.default.SHA3(e).toString(t.default.enc.Base64).replace(/[^A-Z\d]/gi,``).substring(0,20);exports.getFileHash=n;
|
|
2
|
-
//# sourceMappingURL=getFileHash.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFileHash.cjs","names":["crypto"],"sources":["../../../src/utils/getFileHash.ts"],"sourcesContent":["import crypto from 'crypto-js';\n\nexport const getFileHash = (filePath: string) => {\n const hash = crypto.SHA3(filePath);\n\n return hash\n .toString(crypto.enc.Base64)\n .replace(/[^A-Z\\d]/gi, '')\n .substring(0, 20);\n};\n"],"mappings":"kKAEA,MAAa,EAAe,GACbA,EAAAA,QAAO,KAAK,EAAS,CAG/B,SAASA,EAAAA,QAAO,IAAI,OAAO,CAC3B,QAAQ,aAAc,GAAG,CACzB,UAAU,EAAG,GAAG"}
|
package/dist/esm/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Queue as e,pLimit as t}from"./utils/pLimit.mjs";import{parallelize as n}from"./utils/parallelize.mjs";import{formatLocale as r,formatPath as i}from"./utils/formatter.mjs";import{buildDictionary as a}from"./buildIntlayerDictionary/buildIntlayerDictionary.mjs";import{autoDecorateContent as o}from"./utils/autoDecorateContent.mjs";import{resolveObjectPromises as s}from"./utils/resolveObjectPromises.mjs";import{processContentDeclaration as c}from"./buildIntlayerDictionary/processContentDeclaration.mjs";import{cleanOutputDir as l}from"./cleanOutputDir.mjs";import{getFileHash as u}from"./utils/getFileHash.mjs";import{generateDictionaryListContent as d}from"./createDictionaryEntryPoint/generateDictionaryListContent.mjs";import{getBuiltDictionariesPath as f}from"./createDictionaryEntryPoint/getBuiltDictionariesPath.mjs";import{getBuiltDynamicDictionariesPath as p}from"./createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs";import{getBuiltFetchDictionariesPath as m}from"./createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs";import{getBuiltRemoteDictionariesPath as h}from"./createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs";import{getBuiltUnmergedDictionariesPath as g}from"./createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs";import{createDictionaryEntryPoint as _}from"./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";import{createModuleAugmentation as v,getTypeName as y}from"./createType/createModuleAugmentation.mjs";import{createTypes as b,generateTypeScriptType as x}from"./createType/createType.mjs";import{formatDictionaries as S,formatDictionariesOutput as C,formatDictionary as w,formatDictionaryOutput as T}from"./formatDictionary.mjs";import{formatLocalDictionaries as E,loadContentDeclarations as D}from"./loadDictionaries/loadContentDeclaration.mjs";import{sortAlphabetically as O}from"./utils/sortAlphabetically.mjs";import{formatDistantDictionaries as k,loadRemoteDictionaries as A}from"./loadDictionaries/loadRemoteDictionaries.mjs";import{loadDictionaries as j}from"./loadDictionaries/loadDictionaries.mjs";import{loadLocalDictionaries as M}from"./loadDictionaries/loadLocalDictionaries.mjs";import{listDictionaries as N,listDictionariesWithStats as P}from"./listDictionariesPath.mjs";import{runOnce as F}from"./utils/runOnce.mjs";import{isCachedConfigurationUpToDate as I,writeConfiguration as L}from"./writeConfiguration/index.mjs";import{prepareIntlayer as R}from"./prepareIntlayer.mjs";import{detectExportedComponentName as z}from"./writeContentDeclaration/detectExportedComponentName.mjs";import{transformJSFile as B}from"./writeContentDeclaration/transformJSFile.mjs";import{getExtensionFromFormat as V,getFormatFromExtension as H}from"./utils/getFormatFromExtension.mjs";import{detectFormatCommand as U}from"./detectFormatCommand.mjs";import{getContentDeclarationFileTemplate as W}from"./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";import{writeJSFile as G}from"./writeContentDeclaration/writeJSFile.mjs";import{writeContentDeclaration as K}from"./writeContentDeclaration/writeContentDeclaration.mjs";import{initIntlayer as q}from"./init/index.mjs";import{SKILLS as J,SKILLS_METADATA as Y,installSkills as X}from"./installSkills/index.mjs";import{listGitFiles as Z,listGitLines as Q}from"./listGitFiles.mjs";import{listProjects as $}from"./listProjects.mjs";import{extractDictionaryKey as ee}from"./transformFiles/extractDictionaryKey.mjs";import{ATTRIBUTES_TO_EXTRACT as te,extractIntlayer as ne,shouldExtract as re,transformFiles as ie}from"./transformFiles/transformFiles.mjs";import{buildFilesList as ae}from"./utils/buildFilesList.mjs";import{splitTextByLines as oe}from"./utils/splitTextByLine.mjs";import{getChunk as se}from"./utils/getChunk.mjs";import{assembleJSON as ce,chunkJSON as le,reconstructFromSingleChunk as ue}from"./utils/chunkJSON.mjs";import{getComponentTransformPattern as de,getComponentTransformPatternSync as fe}from"./utils/getComponentTransformPattern.mjs";import{mergeChunks as pe}from"./utils/mergeChunks.mjs";import{getGlobalLimiter as me,getTaskLimiter as he,parallelizeGlobal as ge}from"./utils/parallelizeGlobal.mjs";import{reduceObjectFormat as _e}from"./utils/reduceObjectFormat.mjs";import{runParallel as ve}from"./utils/runParallel/index.mjs";import{verifyIdenticObjectFormat as ye}from"./utils/verifyIdenticObjectFormat.mjs";import{buildAndWatchIntlayer as be,watch as xe}from"./watcher.mjs";export{te as ATTRIBUTES_TO_EXTRACT,e as Queue,J as SKILLS,Y as SKILLS_METADATA,ce as assembleJSON,o as autoDecorateContent,be as buildAndWatchIntlayer,a as buildDictionary,ae as buildFilesList,le as chunkJSON,l as cleanOutputDir,_ as createDictionaryEntryPoint,v as createModuleAugmentation,b as createTypes,z as detectExportedComponentName,U as detectFormatCommand,ee as extractDictionaryKey,ne as extractIntlayer,S as formatDictionaries,C as formatDictionariesOutput,w as formatDictionary,T as formatDictionaryOutput,k as formatDistantDictionaries,E as formatLocalDictionaries,r as formatLocale,i as formatPath,d as generateDictionaryListContent,x as generateTypeScriptType,f as getBuiltDictionariesPath,p as getBuiltDynamicDictionariesPath,m as getBuiltFetchDictionariesPath,h as getBuiltRemoteDictionariesPath,g as getBuiltUnmergedDictionariesPath,se as getChunk,de as getComponentTransformPattern,fe as getComponentTransformPatternSync,W as getContentDeclarationFileTemplate,V as getExtensionFromFormat,u as getFileHash,H as getFormatFromExtension,me as getGlobalLimiter,he as getTaskLimiter,y as getTypeName,q as initIntlayer,X as installSkills,I as isCachedConfigurationUpToDate,N as listDictionaries,P as listDictionariesWithStats,Z as listGitFiles,Q as listGitLines,$ as listProjects,D as loadContentDeclarations,j as loadDictionaries,M as loadLocalDictionaries,A as loadRemoteDictionaries,pe as mergeChunks,t as pLimit,n as parallelize,ge as parallelizeGlobal,R as prepareIntlayer,c as processContentDeclaration,ue as reconstructFromSingleChunk,_e as reduceObjectFormat,s as resolveObjectPromises,F as runOnce,ve as runParallel,re as shouldExtract,O as sortAlphabetically,oe as splitTextByLines,ie as transformFiles,B as transformJSFile,ye as verifyIdenticObjectFormat,xe as watch,L as writeConfiguration,K as writeContentDeclaration,G as writeJSFile};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{detectExportedComponentName as e}from"../writeContentDeclaration/detectExportedComponentName.mjs";import{basename as t,dirname as n,extname as r}from"node:path";const i=(i,a)=>{let o=e(a);if(o)return o;let s=t(i,r(i));return s===`index`&&(s=t(n(i))),s};export{i as extractDictionaryKey};
|
|
2
|
-
//# sourceMappingURL=extractDictionaryKey.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractDictionaryKey.mjs","names":[],"sources":["../../../src/transformFiles/extractDictionaryKey.ts"],"sourcesContent":["import { basename, dirname, extname } from 'node:path';\nimport { detectExportedComponentName } from '../writeContentDeclaration/detectExportedComponentName';\n\nexport const extractDictionaryKey = (\n filePath: string,\n fileText: string\n): string => {\n const componentName = detectExportedComponentName(fileText);\n if (componentName) {\n return componentName;\n }\n\n const ext = extname(filePath);\n let baseName = basename(filePath, ext);\n\n if (baseName === 'index') {\n baseName = basename(dirname(filePath));\n }\n\n return baseName;\n};\n"],"mappings":"wKAGA,MAAa,GACX,EACA,IACW,CACX,IAAM,EAAgB,EAA4B,EAAS,CAC3D,GAAI,EACF,OAAO,EAIT,IAAI,EAAW,EAAS,EADZ,EAAQ,EAAS,CACS,CAMtC,OAJI,IAAa,UACf,EAAW,EAAS,EAAQ,EAAS,CAAC,EAGjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{extractDictionaryKey as e}from"./extractDictionaryKey.mjs";import{ATTRIBUTES_TO_EXTRACT as t,extractIntlayer as n,shouldExtract as r,transformFiles as i}from"./transformFiles.mjs";export{t as ATTRIBUTES_TO_EXTRACT,e as extractDictionaryKey,n as extractIntlayer,r as shouldExtract,i as transformFiles};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{detectFormatCommand as e}from"../detectFormatCommand.mjs";import{writeContentDeclaration as t}from"../writeContentDeclaration/writeContentDeclaration.mjs";import{extractDictionaryKey as n}from"./extractDictionaryKey.mjs";import{getConfiguration as r}from"@intlayer/config/node";import i from"node:fs/promises";import{basename as a,dirname as o,extname as s,join as c,relative as l,resolve as u}from"node:path";import{ANSIColors as d,colorizePath as f,getAppLogger as p}from"@intlayer/config/logger";import{camelCaseToKebabCase as m}from"@intlayer/config/utils";import{Node as h,Project as g,SyntaxKind as _}from"ts-morph";import{execSync as v}from"node:child_process";import{generateKey as y}from"@intlayer/core/utils";const b=[`title`,`placeholder`,`alt`,`aria-label`,`label`],x=e=>{let t=e.trim();return!(!t||!t.includes(` `)||!/^[A-Z]/.test(t)||t.startsWith(`{`)||t.startsWith(`v-`))},S=async(e,n,r,i,d)=>{let{defaultLocale:f}=i.internationalization,{baseDir:p,fileExtensions:m}=i.content,h=i?.dictionary?.locale,g=d?u(d):o(r),_=a(r,s(r)),v=c(g,`${_.charAt(0).toLowerCase()+_.slice(1)}.${m[0]}`),y=l(p,v),b;if(h)b={key:n,content:e,locale:f,filePath:y};else{let t={};for(let[n,r]of Object.entries(e))t[n]={nodeType:`translation`,translation:{[f]:r}};b={key:n,content:t,filePath:y}}let x=l(p,g);return await t(b,i,{newDictionariesPath:x}),v},C=(e,t)=>{let n={},r=[];return e.forEachDescendant(e=>{if(h.isJsxText(e)){let i=e.getText();if(x(i)){let a=y(i,t);t.add(a),n[a]=i.replace(/\s+/g,` `).trim(),r.push({node:e,key:a,type:`jsx-text`})}}else if(h.isJsxAttribute(e)){let i=e.getNameNode().getText();if(b.includes(i)){let i=e.getInitializer();if(h.isStringLiteral(i)){let a=i.getLiteralValue();if(x(a)){let i=y(a,t);t.add(i),n[i]=a.trim(),r.push({node:e,key:i,type:`jsx-attribute`})}}}}else if(h.isStringLiteral(e)){let i=e.getLiteralValue();if(x(i)){let a=e.getParent();if(a?.getKindName()===`ImportDeclaration`||a?.getKindName()===`ImportSpecifier`||a?.getKindName()===`ModuleSpecifier`||h.isJsxAttribute(a)||h.isCallExpression(a)&&a.getExpression().getText().includes(`console.log`)||h.isPropertyAssignment(a)&&a.getNameNode()===e)return;let o=y(i,t);t.add(o),n[o]=i.trim(),r.push({node:e,key:o,type:`string-literal`})}}}),{extractedContent:n,replacements:r}},w=async(e,t,n,r,i=!0)=>{let a;try{a=r.addSourceFileAtPath(e)}catch{a=r.getSourceFileOrThrow(e)}let o=n===`solid-intlayer`,{extractedContent:s,replacements:c}=C(a,new Set);if(Object.keys(s).length===0)return null;for(let{node:e,key:t,type:n}of c){let r=o?`content().${t}`:`content.${t}`;n===`jsx-text`&&h.isJsxText(e)?e.replaceWithText(`{${r}}`):n===`jsx-attribute`&&h.isJsxAttribute(e)?e.setInitializer(`{${r}.value}`):n===`string-literal`&&h.isStringLiteral(e)&&e.replaceWithText(`${r}.value`)}let l=a.getImportDeclaration(e=>e.getModuleSpecifierValue()===n);return l?l.getNamedImports().some(e=>e.getName()===`useIntlayer`)||l.addNamedImport(`useIntlayer`):a.addImportDeclaration({namedImports:[`useIntlayer`],moduleSpecifier:n}),a.getFunctions().forEach(e=>{e.getBody()?.asKind(_.Block)?.insertStatements(0,`const content = useIntlayer("${t}");`)}),a.getVariableDeclarations().forEach(e=>{let n=e.getInitializer();if(h.isArrowFunction(n)||h.isFunctionExpression(n)){let e=n.getBody();h.isBlock(e)&&(e.getText().includes(`return`)||e.getText().includes(`use`))&&e.insertStatements(0,`const content = useIntlayer("${t}");`)}}),i&&await a.save(),s},T=async(t,a,o,c)=>{let u=!o?.declarationOnly,h=!o?.codeOnly,_=r(o?.configOptions),b=p(_),{baseDir:T}=_.content,E=c||new g({skipAddingFilesFromTsConfig:!0}),D=n(t,(await i.readFile(t)).toString()),O=m(D),k=s(t),A=null;if(k===`.vue`)try{let{processVueFile:e}=await import(`@intlayer/vue-transformer`);A=await e(t,O,a,{generateKey:y,shouldExtract:x,extractTsContent:C},u)}catch(e){throw e.code===`ERR_MODULE_NOT_FOUND`||e.message?.includes(`Cannot find module`)?Error(`Please install ${f(`@intlayer/vue-transformer`,d.YELLOW)} to process Vue files.`):e}else if(k===`.svelte`)try{let{processSvelteFile:e}=await import(`@intlayer/svelte-transformer`);A=await e(t,O,a,{generateKey:y,shouldExtract:x,extractTsContent:C},u)}catch(e){throw e.code===`ERR_MODULE_NOT_FOUND`||e.message?.includes(`Cannot find module`)?Error(`Please install ${f(`@intlayer/svelte-transformer`,d.YELLOW)} to process Svelte files.`):e}else [`.tsx`,`.jsx`,`.ts`,`.js`].includes(k)&&(A=await w(t,O,a,E,u));if(!A){b(`No extractable text found in ${D}`);return}if(h){let e=await S(A,O,t,_,o?.outputDir);b(`Created content file: ${f(l(_.content.baseDir,e))}`)}if(u){try{let n=e(_);n&&v(n.replace(`{{file}}`,t),{stdio:`ignore`,cwd:T})}catch{}b(`Updated component: ${f(l(T,t))}`)}},E=async(e,t,n)=>{let i=p(r(n?.configOptions)),a=new g({skipAddingFilesFromTsConfig:!0});for(let r of e)try{await T(r,t,n,a)}catch(e){i(`Failed to transform ${r}: ${e.message}`)}};export{b as ATTRIBUTES_TO_EXTRACT,T as extractIntlayer,x as shouldExtract,E as transformFiles};
|
|
2
|
-
//# sourceMappingURL=transformFiles.mjs.map
|