@intlayer/engine 9.7.1 → 9.7.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.
Files changed (158) hide show
  1. package/dist/cjs/_virtual/_utils_asset.cjs +1 -1
  2. package/dist/cjs/build.cjs +8 -8
  3. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +3 -3
  4. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +2 -2
  5. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +2 -2
  6. package/dist/cjs/buildIntlayerDictionary/writeNestedDictionary.cjs +2 -2
  7. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +2 -2
  8. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +2 -2
  9. package/dist/cjs/cleanOutputDir.cjs +1 -1
  10. package/dist/cjs/cleanRemovedContentDeclaration.cjs +1 -1
  11. package/dist/cjs/cli.cjs +5 -2
  12. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +1 -1
  13. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +2 -2
  14. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +2 -2
  15. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +2 -2
  16. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +2 -2
  17. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +2 -2
  18. package/dist/cjs/createType/createModuleAugmentation.cjs +1 -1
  19. package/dist/cjs/createType/createType.cjs +1 -1
  20. package/dist/cjs/docReview/pipeline.cjs.map +1 -1
  21. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  22. package/dist/cjs/handleContentDeclarationFileChange.cjs +2 -2
  23. package/dist/cjs/init/documentationRouter.cjs +1 -0
  24. package/dist/cjs/init/documentationRouter.cjs.map +1 -1
  25. package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs +1 -1
  26. package/dist/cjs/init/frameworkSetup/nextAppRouter/restructure.cjs +1 -1
  27. package/dist/cjs/init/frameworkSetup/tanstackStart/index.cjs +1 -1
  28. package/dist/cjs/init/frameworkSetup/tanstackStart/restructure.cjs +1 -1
  29. package/dist/cjs/init/index.cjs +47 -3
  30. package/dist/cjs/init/index.cjs.map +1 -1
  31. package/dist/cjs/init/utils/fileSystem.cjs +2 -2
  32. package/dist/cjs/init/utils/githubActions.cjs +1 -1
  33. package/dist/cjs/init/utils/index.cjs +6 -0
  34. package/dist/cjs/init/utils/intlayerDependencies.cjs +2 -2
  35. package/dist/cjs/init/utils/packageManager.cjs +3 -1
  36. package/dist/cjs/init/utils/packageManager.cjs.map +1 -1
  37. package/dist/cjs/init/utils/prettierConfig.cjs +54 -0
  38. package/dist/cjs/init/utils/prettierConfig.cjs.map +1 -0
  39. package/dist/cjs/initConfig/index.cjs +1 -1
  40. package/dist/cjs/initConfig/index.cjs.map +1 -1
  41. package/dist/cjs/installLSP.cjs +1 -1
  42. package/dist/cjs/installMCP/installMCP.cjs +1 -1
  43. package/dist/cjs/installSkills/index.cjs +1 -1
  44. package/dist/cjs/installSkills/index.cjs.map +1 -1
  45. package/dist/cjs/listGitFiles.cjs +1 -1
  46. package/dist/cjs/listGitFiles.cjs.map +1 -1
  47. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +1 -1
  48. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +1 -1
  49. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +1 -1
  50. package/dist/cjs/loadDictionaries/log.cjs +1 -1
  51. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -1
  52. package/dist/cjs/prepareIntlayer.cjs +2 -2
  53. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  54. package/dist/cjs/scan/index.cjs +1 -1
  55. package/dist/cjs/syncPluginKit/createFileAdapter.cjs +1 -1
  56. package/dist/cjs/utils/buildComponentFilesList.cjs +1 -1
  57. package/dist/cjs/utils/contentWatcherLock.cjs +2 -2
  58. package/dist/cjs/utils/readDictionariesFromDisk.cjs +1 -1
  59. package/dist/cjs/utils/runOnce.cjs +2 -2
  60. package/dist/cjs/utils/withFileLock.cjs +2 -2
  61. package/dist/cjs/watcher.cjs +4 -4
  62. package/dist/cjs/watcher.cjs.map +1 -1
  63. package/dist/cjs/writeConfiguration/index.cjs +2 -2
  64. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +1 -1
  65. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +2 -2
  66. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +2 -2
  67. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs +1 -1
  68. package/dist/cjs/writeContentDeclaration/writeYamlFile.cjs +1 -1
  69. package/dist/cjs/writeFileIfChanged.cjs +2 -2
  70. package/dist/esm/_virtual/_utils_asset.mjs +1 -1
  71. package/dist/esm/build.mjs +8 -8
  72. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +3 -3
  73. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +2 -2
  74. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +2 -2
  75. package/dist/esm/buildIntlayerDictionary/writeNestedDictionary.mjs +2 -2
  76. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +2 -2
  77. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +2 -2
  78. package/dist/esm/cleanOutputDir.mjs +1 -1
  79. package/dist/esm/cleanRemovedContentDeclaration.mjs +1 -1
  80. package/dist/esm/cli.mjs +4 -3
  81. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +1 -1
  82. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +2 -2
  83. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +2 -2
  84. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +2 -2
  85. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +2 -2
  86. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +2 -2
  87. package/dist/esm/createType/createModuleAugmentation.mjs +1 -1
  88. package/dist/esm/createType/createType.mjs +1 -1
  89. package/dist/esm/docReview/pipeline.mjs.map +1 -1
  90. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  91. package/dist/esm/handleContentDeclarationFileChange.mjs +2 -2
  92. package/dist/esm/init/documentationRouter.mjs +1 -0
  93. package/dist/esm/init/documentationRouter.mjs.map +1 -1
  94. package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs +1 -1
  95. package/dist/esm/init/frameworkSetup/nextAppRouter/restructure.mjs +1 -1
  96. package/dist/esm/init/frameworkSetup/tanstackStart/index.mjs +1 -1
  97. package/dist/esm/init/frameworkSetup/tanstackStart/restructure.mjs +1 -1
  98. package/dist/esm/init/index.mjs +47 -3
  99. package/dist/esm/init/index.mjs.map +1 -1
  100. package/dist/esm/init/utils/fileSystem.mjs +2 -2
  101. package/dist/esm/init/utils/githubActions.mjs +1 -1
  102. package/dist/esm/init/utils/index.mjs +2 -1
  103. package/dist/esm/init/utils/intlayerDependencies.mjs +2 -2
  104. package/dist/esm/init/utils/packageManager.mjs +3 -1
  105. package/dist/esm/init/utils/packageManager.mjs.map +1 -1
  106. package/dist/esm/init/utils/prettierConfig.mjs +49 -0
  107. package/dist/esm/init/utils/prettierConfig.mjs.map +1 -0
  108. package/dist/esm/initConfig/index.mjs +1 -1
  109. package/dist/esm/initConfig/index.mjs.map +1 -1
  110. package/dist/esm/installLSP.mjs +1 -1
  111. package/dist/esm/installMCP/installMCP.mjs +1 -1
  112. package/dist/esm/installSkills/index.mjs +1 -1
  113. package/dist/esm/installSkills/index.mjs.map +1 -1
  114. package/dist/esm/listGitFiles.mjs +1 -1
  115. package/dist/esm/listGitFiles.mjs.map +1 -1
  116. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +1 -1
  117. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +1 -1
  118. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +1 -1
  119. package/dist/esm/loadDictionaries/log.mjs +1 -1
  120. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs.map +1 -1
  121. package/dist/esm/prepareIntlayer.mjs +2 -2
  122. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  123. package/dist/esm/scan/index.mjs +1 -1
  124. package/dist/esm/syncPluginKit/createFileAdapter.mjs +1 -1
  125. package/dist/esm/utils/buildComponentFilesList.mjs +1 -1
  126. package/dist/esm/utils/contentWatcherLock.mjs +2 -2
  127. package/dist/esm/utils/readDictionariesFromDisk.mjs +1 -1
  128. package/dist/esm/utils/runOnce.mjs +2 -2
  129. package/dist/esm/utils/withFileLock.mjs +2 -2
  130. package/dist/esm/watcher.mjs +4 -4
  131. package/dist/esm/watcher.mjs.map +1 -1
  132. package/dist/esm/writeConfiguration/index.mjs +2 -2
  133. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +1 -1
  134. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +2 -2
  135. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +2 -2
  136. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +1 -1
  137. package/dist/esm/writeContentDeclaration/writeYamlFile.mjs +1 -1
  138. package/dist/esm/writeFileIfChanged.mjs +2 -2
  139. package/dist/types/build.d.ts +17 -17
  140. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  141. package/dist/types/cli.d.ts +12 -10
  142. package/dist/types/docReview/pipeline.d.ts.map +1 -1
  143. package/dist/types/init/documentationRouter.d.ts +1 -0
  144. package/dist/types/init/documentationRouter.d.ts.map +1 -1
  145. package/dist/types/init/index.d.ts +2 -0
  146. package/dist/types/init/index.d.ts.map +1 -1
  147. package/dist/types/init/utils/index.d.ts +2 -1
  148. package/dist/types/init/utils/packageManager.d.ts +5 -0
  149. package/dist/types/init/utils/packageManager.d.ts.map +1 -1
  150. package/dist/types/init/utils/prettierConfig.d.ts +28 -0
  151. package/dist/types/init/utils/prettierConfig.d.ts.map +1 -0
  152. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +1 -1
  153. package/dist/types/loadDictionaries/logTypeScriptErrors.d.ts.map +1 -1
  154. package/dist/types/scan/detection/index.d.ts +4 -0
  155. package/dist/types/scan/index.d.ts +5 -4
  156. package/dist/types/watcher.d.ts.map +1 -1
  157. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +1 -1
  158. package/package.json +69 -69
@@ -1 +1 @@
1
- {"version":3,"file":"logTypeScriptErrors.mjs","names":[],"sources":["../../../src/loadDictionaries/logTypeScriptErrors.ts"],"sourcesContent":["import { dirname, extname, resolve } from 'node:path';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n API as NativeTypeScriptAPI,\n Diagnostic as NativeTypeScriptDiagnostic,\n} from 'typescript/unstable/async';\n\n/** Diagnostic of the classic (TS <= 6) compiler API. */\ninterface ClassicTypeScriptDiagnostic {\n file?: {\n fileName: string;\n getLineAndCharacterOfPosition: (position: number) => {\n line: number;\n character: number;\n };\n };\n start?: number;\n messageText: string | { messageText: string };\n}\n\n/** Subset of the classic (TS <= 6) compiler API used here. */\ninterface ClassicTypeScriptCompiler {\n findConfigFile: (\n searchPath: string,\n fileExists: (path: string) => boolean,\n configName?: string\n ) => string | undefined;\n sys: {\n fileExists: (path: string) => boolean;\n readFile: (path: string, encoding?: string) => string | undefined;\n };\n parseConfigFileTextToJson: (\n fileName: string,\n jsonText: string\n ) => { config?: Record<string, unknown>; error?: unknown };\n parseJsonConfigFileContent: (\n json: unknown,\n host: unknown,\n basePath: string\n ) => {\n options: Record<string, unknown>;\n };\n createProgram: (\n rootNames: readonly string[],\n options: Record<string, unknown>\n ) => {\n getSourceFile: (fileName: string) => unknown;\n };\n getPreEmitDiagnostics: (\n program: unknown,\n sourceFile?: unknown\n ) => readonly ClassicTypeScriptDiagnostic[];\n flattenDiagnosticMessageText: (\n diagnostic: string | { messageText: string },\n newLine: string\n ) => string;\n}\n\n/** Root module of `typescript`, possibly wrapped in a CJS `default`. */\ntype ClassicTypeScriptModule = Partial<ClassicTypeScriptCompiler> & {\n default?: Partial<ClassicTypeScriptCompiler>;\n};\n\n/** Engine-agnostic diagnostic, with 0-based line and character. */\ninterface TypeScriptError {\n fileName: string;\n line: number;\n character: number;\n message: string;\n}\n\nconst CHECKABLE_EXTENSIONS = [\n '.ts',\n '.tsx',\n '.js',\n '.jsx',\n '.cjs',\n '.mjs',\n '.json',\n];\n\n/**\n * Checks files with the classic compiler API (`typescript` <= 6), which is\n * exposed from the package root.\n */\nconst collectClassicTypeScriptErrors = (\n typescript: ClassicTypeScriptCompiler,\n filePaths: string[],\n baseDir: string\n): TypeScriptError[] => {\n const configFileName = typescript.findConfigFile(\n baseDir,\n typescript.sys.fileExists,\n 'tsconfig.json'\n );\n\n let compilerOptions: Record<string, unknown> = {\n noEmit: true,\n allowJs: true,\n resolveJsonModule: true,\n };\n\n const configFileText = configFileName\n ? typescript.sys.readFile(configFileName)\n : undefined;\n\n if (configFileName && configFileText) {\n const configJson = typescript.parseConfigFileTextToJson(\n configFileName,\n configFileText\n );\n\n if (!configJson.error) {\n const parsedConfig = typescript.parseJsonConfigFileContent(\n configJson.config,\n typescript.sys,\n dirname(configFileName)\n );\n\n const { incremental, tsBuildInfoFile, ...restOptions } =\n parsedConfig.options;\n\n compilerOptions = { ...compilerOptions, ...restOptions, noEmit: true };\n }\n }\n\n const program = typescript.createProgram(filePaths, compilerOptions);\n\n return filePaths.flatMap((filePath) => {\n const sourceFile = program.getSourceFile(filePath);\n\n if (!sourceFile) return [];\n\n return typescript\n .getPreEmitDiagnostics(program, sourceFile)\n .flatMap((diagnostic) => {\n if (!diagnostic.file || diagnostic.start === undefined) return [];\n\n const { line, character } =\n diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);\n\n return {\n fileName: diagnostic.file.fileName,\n line,\n character,\n message: typescript.flattenDiagnosticMessageText(\n diagnostic.messageText,\n '\\n'\n ),\n };\n });\n });\n};\n\n/** Flattens a native diagnostic message chain, indenting nested messages. */\nconst flattenNativeDiagnosticMessage = (\n diagnostic: NativeTypeScriptDiagnostic,\n depth = 0\n): string =>\n [\n `${' '.repeat(depth)}${diagnostic.text}`,\n ...(diagnostic.messageChain ?? []).map((chainedDiagnostic) =>\n flattenNativeDiagnosticMessage(chainedDiagnostic, depth + 1)\n ),\n ].join('\\n');\n\n/**\n * Checks files with the native API (`typescript` >= 7, Go port), whose root\n * export only exposes the version. It spawns the bundled `tsgo` binary, which\n * resolves the closest tsconfig of each file.\n */\nconst collectNativeTypeScriptErrors = async (\n NativeAPI: typeof NativeTypeScriptAPI,\n filePaths: string[],\n baseDir: string\n): Promise<TypeScriptError[]> => {\n const api = new NativeAPI({ cwd: baseDir });\n\n try {\n const snapshot = await api.updateSnapshot({ openFiles: filePaths });\n\n try {\n const results = await Promise.all(\n filePaths.map(async (filePath) => {\n const defaultProject =\n await snapshot.getDefaultProjectForFile(filePath);\n const program = defaultProject?.program;\n\n if (!program) return [];\n\n const sourceFile = await program.getSourceFile(filePath);\n\n if (!sourceFile) return [];\n\n const syntacticDiagnostics =\n await program.getSyntacticDiagnostics(filePath);\n const semanticDiagnostics =\n await program.getSemanticDiagnostics(filePath);\n\n return [...syntacticDiagnostics, ...semanticDiagnostics].map(\n (diagnostic) => {\n const { line, character } =\n sourceFile.getLineAndCharacterOfPosition(diagnostic.pos);\n\n return {\n fileName: diagnostic.fileName ?? filePath,\n line,\n character,\n message: flattenNativeDiagnosticMessage(diagnostic),\n };\n }\n );\n })\n );\n\n return results.flat();\n } finally {\n await snapshot.dispose();\n }\n } finally {\n await api.close();\n }\n};\n\n/**\n * Resolves the installed TypeScript and returns its errors for the given\n * files, or `undefined` if TypeScript is not installed.\n */\nconst collectTypeScriptErrors = async (\n filePaths: string[],\n baseDir: string\n): Promise<TypeScriptError[] | undefined> => {\n let typescriptModule: ClassicTypeScriptModule;\n\n try {\n // Typed against the installed version, whose root may be version-only (>= 7)\n typescriptModule = (await import(\n 'typescript'\n )) as unknown as ClassicTypeScriptModule;\n } catch {\n return undefined;\n }\n\n const classicTypeScript = typescriptModule.createProgram\n ? typescriptModule\n : typescriptModule.default;\n\n if (classicTypeScript?.createProgram) {\n return collectClassicTypeScriptErrors(\n classicTypeScript as ClassicTypeScriptCompiler,\n filePaths,\n baseDir\n );\n }\n\n let nativeModule: { API: typeof NativeTypeScriptAPI };\n\n try {\n nativeModule = await import('typescript/unstable/async');\n } catch {\n try {\n nativeModule = (await import('typescript/unstable/sync')) as unknown as {\n API: typeof NativeTypeScriptAPI;\n };\n } catch {\n // Neither the classic nor the native API is available\n return undefined;\n }\n }\n\n return collectNativeTypeScriptErrors(nativeModule.API, filePaths, baseDir);\n};\n\n/**\n * Type-checks content declaration files and logs errors as warnings.\n * Supports both the classic (`typescript` <= 6) and native (>= 7) compilers.\n */\nexport const logTypeScriptErrors = async (\n filePaths: string[],\n configuration: IntlayerConfig\n): Promise<void> => {\n const appLogger = getAppLogger(configuration);\n const baseDir = configuration.system?.baseDir ?? process.cwd();\n\n const filesToCheck = filePaths\n .filter((filePath) => CHECKABLE_EXTENSIONS.includes(extname(filePath)))\n .map((filePath) => resolve(baseDir, filePath));\n\n if (filesToCheck.length === 0) return;\n\n const typeScriptErrors = await collectTypeScriptErrors(filesToCheck, baseDir);\n\n typeScriptErrors?.forEach(({ fileName, line, character, message }) => {\n appLogger(\n `TS Error in ${fileName} (${line + 1},${character + 1}): ${message}`,\n { level: 'warn' }\n );\n });\n};\n"],"mappings":";;;;AAwEA,MAAM,uBAAuB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAMA,MAAM,kCACJ,YACA,WAC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,aAAa,aAAa;CAC5C,MAAM,UAAU,cAAc,QAAQ,WAAW,QAAQ,IAAI;CAE7D,MAAM,eAAe,UAClB,QAAQ,aAAa,qBAAqB,SAAS,QAAQ,QAAQ,CAAC,CAAC,CAAC,CACtE,KAAK,aAAa,QAAQ,SAAS,QAAQ,CAAC;CAE/C,IAAI,aAAa,WAAW,GAAG;CAI/B,OAF+B,wBAAwB,cAAc,OAAO,EAE5D,EAAE,SAAS,EAAE,UAAU,MAAM,WAAW,cAAc;EACpE,UACE,eAAe,SAAS,IAAI,OAAO,EAAE,GAAG,YAAY,EAAE,KAAK,WAC3D,EAAE,OAAO,OAAO,CAClB;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"logTypeScriptErrors.mjs","names":[],"sources":["../../../src/loadDictionaries/logTypeScriptErrors.ts"],"sourcesContent":["import { dirname, extname, resolve } from 'node:path';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n API as NativeTypeScriptAPI,\n Diagnostic as NativeTypeScriptDiagnostic,\n} from 'typescript/unstable/async';\n\n/** Diagnostic of the classic (TS <= 6) compiler API. */\ninterface ClassicTypeScriptDiagnostic {\n file?: {\n fileName: string;\n getLineAndCharacterOfPosition: (position: number) => {\n line: number;\n character: number;\n };\n };\n start?: number;\n messageText: string | { messageText: string };\n}\n\n/** Subset of the classic (TS <= 6) compiler API used here. */\ninterface ClassicTypeScriptCompiler {\n findConfigFile: (\n searchPath: string,\n fileExists: (path: string) => boolean,\n configName?: string\n ) => string | undefined;\n sys: {\n fileExists: (path: string) => boolean;\n readFile: (path: string, encoding?: string) => string | undefined;\n };\n parseConfigFileTextToJson: (\n fileName: string,\n jsonText: string\n ) => { config?: Record<string, unknown>; error?: unknown };\n parseJsonConfigFileContent: (\n json: unknown,\n host: unknown,\n basePath: string\n ) => {\n options: Record<string, unknown>;\n };\n createProgram: (\n rootNames: readonly string[],\n options: Record<string, unknown>\n ) => {\n getSourceFile: (fileName: string) => unknown;\n };\n getPreEmitDiagnostics: (\n program: unknown,\n sourceFile?: unknown\n ) => readonly ClassicTypeScriptDiagnostic[];\n flattenDiagnosticMessageText: (\n diagnostic: string | { messageText: string },\n newLine: string\n ) => string;\n}\n\n/** Root module of `typescript`, possibly wrapped in a CJS `default`. */\ntype ClassicTypeScriptModule = Partial<ClassicTypeScriptCompiler> & {\n default?: Partial<ClassicTypeScriptCompiler>;\n};\n\n/** Engine-agnostic diagnostic, with 0-based line and character. */\ninterface TypeScriptError {\n fileName: string;\n line: number;\n character: number;\n message: string;\n}\n\nconst CHECKABLE_EXTENSIONS = [\n '.ts',\n '.tsx',\n '.js',\n '.jsx',\n '.cjs',\n '.mjs',\n '.json',\n];\n\n/**\n * Checks files with the classic compiler API (`typescript` <= 6), which is\n * exposed from the package root.\n */\nconst collectClassicTypeScriptErrors = (\n typescript: ClassicTypeScriptCompiler,\n filePaths: string[],\n baseDir: string\n): TypeScriptError[] => {\n const configFileName = typescript.findConfigFile(\n baseDir,\n typescript.sys.fileExists,\n 'tsconfig.json'\n );\n\n let compilerOptions: Record<string, unknown> = {\n noEmit: true,\n allowJs: true,\n resolveJsonModule: true,\n };\n\n const configFileText = configFileName\n ? typescript.sys.readFile(configFileName)\n : undefined;\n\n if (configFileName && configFileText) {\n const configJson = typescript.parseConfigFileTextToJson(\n configFileName,\n configFileText\n );\n\n if (!configJson.error) {\n const parsedConfig = typescript.parseJsonConfigFileContent(\n configJson.config,\n typescript.sys,\n dirname(configFileName)\n );\n\n const { incremental, tsBuildInfoFile, ...restOptions } =\n parsedConfig.options;\n\n compilerOptions = { ...compilerOptions, ...restOptions, noEmit: true };\n }\n }\n\n const program = typescript.createProgram(filePaths, compilerOptions);\n\n return filePaths.flatMap((filePath) => {\n const sourceFile = program.getSourceFile(filePath);\n\n if (!sourceFile) return [];\n\n return typescript\n .getPreEmitDiagnostics(program, sourceFile)\n .flatMap((diagnostic) => {\n if (!diagnostic.file || diagnostic.start === undefined) return [];\n\n const { line, character } =\n diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);\n\n return {\n fileName: diagnostic.file.fileName,\n line,\n character,\n message: typescript.flattenDiagnosticMessageText(\n diagnostic.messageText,\n '\\n'\n ),\n };\n });\n });\n};\n\n/** Flattens a native diagnostic message chain, indenting nested messages. */\nconst flattenNativeDiagnosticMessage = (\n diagnostic: NativeTypeScriptDiagnostic,\n depth = 0\n): string =>\n [\n `${' '.repeat(depth)}${diagnostic.text}`,\n ...(diagnostic.messageChain ?? []).map((chainedDiagnostic) =>\n flattenNativeDiagnosticMessage(chainedDiagnostic, depth + 1)\n ),\n ].join('\\n');\n\n/**\n * Checks files with the native API (`typescript` >= 7, Go port), whose root\n * export only exposes the version. It spawns the bundled `tsgo` binary, which\n * resolves the closest tsconfig of each file.\n */\nconst collectNativeTypeScriptErrors = async (\n NativeAPI: typeof NativeTypeScriptAPI,\n filePaths: string[],\n baseDir: string\n): Promise<TypeScriptError[]> => {\n const api = new NativeAPI({ cwd: baseDir });\n\n try {\n const snapshot = await api.updateSnapshot({ openFiles: filePaths });\n\n try {\n const results = await Promise.all(\n filePaths.map(async (filePath) => {\n const defaultProject =\n await snapshot.getDefaultProjectForFile(filePath);\n const program = defaultProject?.program;\n\n if (!program) return [];\n\n const sourceFile = await program.getSourceFile(filePath);\n\n if (!sourceFile) return [];\n\n const syntacticDiagnostics =\n await program.getSyntacticDiagnostics(filePath);\n const semanticDiagnostics =\n await program.getSemanticDiagnostics(filePath);\n\n return [...syntacticDiagnostics, ...semanticDiagnostics].map(\n (diagnostic) => {\n const { line, character } =\n sourceFile.getLineAndCharacterOfPosition(diagnostic.pos);\n\n return {\n fileName: diagnostic.fileName ?? filePath,\n line,\n character,\n message: flattenNativeDiagnosticMessage(diagnostic),\n };\n }\n );\n })\n );\n\n return results.flat();\n } finally {\n await snapshot.dispose();\n }\n } finally {\n await api.close();\n }\n};\n\n/**\n * Resolves the installed TypeScript and returns its errors for the given\n * files, or `undefined` if TypeScript is not installed.\n */\nconst collectTypeScriptErrors = async (\n filePaths: string[],\n baseDir: string\n): Promise<TypeScriptError[] | undefined> => {\n let typescriptModule: ClassicTypeScriptModule;\n\n try {\n // Typed against the installed version, whose root may be version-only (>= 7)\n typescriptModule =\n (await import('typescript')) as unknown as ClassicTypeScriptModule;\n } catch {\n return undefined;\n }\n\n const classicTypeScript = typescriptModule.createProgram\n ? typescriptModule\n : typescriptModule.default;\n\n if (classicTypeScript?.createProgram) {\n return collectClassicTypeScriptErrors(\n classicTypeScript as ClassicTypeScriptCompiler,\n filePaths,\n baseDir\n );\n }\n\n let nativeModule: { API: typeof NativeTypeScriptAPI };\n\n try {\n nativeModule = await import('typescript/unstable/async');\n } catch {\n try {\n nativeModule = (await import('typescript/unstable/sync')) as unknown as {\n API: typeof NativeTypeScriptAPI;\n };\n } catch {\n // Neither the classic nor the native API is available\n return undefined;\n }\n }\n\n return collectNativeTypeScriptErrors(nativeModule.API, filePaths, baseDir);\n};\n\n/**\n * Type-checks content declaration files and logs errors as warnings.\n * Supports both the classic (`typescript` <= 6) and native (>= 7) compilers.\n */\nexport const logTypeScriptErrors = async (\n filePaths: string[],\n configuration: IntlayerConfig\n): Promise<void> => {\n const appLogger = getAppLogger(configuration);\n const baseDir = configuration.system?.baseDir ?? process.cwd();\n\n const filesToCheck = filePaths\n .filter((filePath) => CHECKABLE_EXTENSIONS.includes(extname(filePath)))\n .map((filePath) => resolve(baseDir, filePath));\n\n if (filesToCheck.length === 0) return;\n\n const typeScriptErrors = await collectTypeScriptErrors(filesToCheck, baseDir);\n\n typeScriptErrors?.forEach(({ fileName, line, character, message }) => {\n appLogger(\n `TS Error in ${fileName} (${line + 1},${character + 1}): ${message}`,\n { level: 'warn' }\n );\n });\n};\n"],"mappings":";;;;AAwEA,MAAM,uBAAuB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAMA,MAAM,kCACJ,YACA,WACA,YACsB;CACtB,MAAM,iBAAiB,WAAW,eAChC,SACA,WA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QAAQ,IAAI;CAE7D,MAAM,eAAe,UAClB,QAAQ,aAAa,qBAAqB,SAAS,QAAQ,QAAQ,CAAC,CAAC,CAAC,CACtE,KAAK,aAAa,QAAQ,SAAS,QAAQ,CAAC;CAE/C,IAAI,aAAa,WAAW,GAAG;CAI/B,OAF+B,wBAAwB,cAAc,OAAO,EAE5D,EAAE,SAAS,EAAE,UAAU,MAAM,WAAW,cAAc;EACpE,UACE,eAAe,SAAS,IAAI,OAAO,EAAE,GAAG,YAAY,EAAE,KAAK,WAC3D,EAAE,OAAO,OAAO,CAClB;CACF,CAAC;AACH"}
@@ -9,11 +9,11 @@ import { loadDictionaries } from "./loadDictionaries/loadDictionaries.mjs";
9
9
  import { runOnce } from "./utils/runOnce.mjs";
10
10
  import { isCachedConfigurationUpToDate, writeConfiguration } from "./writeConfiguration/index.mjs";
11
11
  import { colorize, getAppLogger } from "@intlayer/config/logger";
12
- import { stat } from "node:fs/promises";
13
12
  import { join } from "node:path";
13
+ import { stat } from "node:fs/promises";
14
+ import { cacheDisk } from "@intlayer/config/utils";
14
15
  import * as ANSIColors from "@intlayer/config/colors";
15
16
  import packageJson from "@intlayer/config/package.json" with { type: "json" };
16
- import { cacheDisk } from "@intlayer/config/utils";
17
17
 
18
18
  // src/prepareIntlayer.ts
19
19
  const DEFAULT_PREPARE_INTLAYER_OPTIONS = {
@@ -1 +1 @@
1
- {"version":3,"file":"prepareIntlayer.mjs","names":[],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { cacheDisk } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionariesWithStats } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { runOnce } from './utils/runOnce';\nimport {\n isCachedConfigurationUpToDate,\n writeConfiguration,\n} from './writeConfiguration';\n\ntype PrepareIntlayerOptions = {\n clean?: boolean;\n env?: 'prod' | 'dev';\n format?: ('cjs' | 'esm')[];\n forceRun?: boolean;\n cacheTimeoutMs?: number;\n onIsCached?: () => void | Promise<void>;\n};\n\nconst DEFAULT_PREPARE_INTLAYER_OPTIONS = {\n clean: false,\n env: 'dev',\n format: ['cjs', 'esm'],\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n} satisfies PrepareIntlayerOptions;\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig,\n options?: PrepareIntlayerOptions\n) => {\n const appLogger = getAppLogger(configuration);\n\n const sentinelPath = join(\n configuration.system.cacheDir,\n 'intlayer-prepared.lock'\n );\n // Clean output dir if the intlayer version has changed\n const versionCache = cacheDisk(configuration, ['intlayer-version']);\n const intlayerCacheVersion = await versionCache.get();\n const isCorrectVersion = Boolean(\n intlayerCacheVersion === undefined ||\n intlayerCacheVersion === packageJson.version\n );\n\n const isConfigSimilar = await isCachedConfigurationUpToDate(configuration);\n\n // Check if any dictionary has been changed to force a new rebuild\n const dictionariesWithStats = await listDictionariesWithStats(configuration);\n let isDictionaryChanged = false;\n try {\n // Try catch as sentinel file may not exist yet\n const sentinelStats = await stat(sentinelPath);\n isDictionaryChanged = dictionariesWithStats.some(\n (dictionary) =>\n dictionary.stats.mtime.getTime() > sentinelStats.mtime.getTime()\n );\n } catch {}\n\n const resolvedPlugins = await Promise.all(configuration.plugins ?? []);\n const hasPluginLoadDictionaries = resolvedPlugins.some((plugin) =>\n Boolean(plugin.loadDictionaries)\n ); // Disable cache if any plugin because it can have custom behavior\n\n const { clean, format, forceRun, onIsCached, cacheTimeoutMs, env } = {\n ...DEFAULT_PREPARE_INTLAYER_OPTIONS,\n forceRun:\n !isCorrectVersion ||\n !isConfigSimilar ||\n isDictionaryChanged ||\n hasPluginLoadDictionaries,\n ...(options ?? {}),\n };\n\n // Skip preparation if it has already been done recently\n await runOnce(\n sentinelPath,\n async ({ renewLock }) => {\n // comment because of issue with next and webpack\n // await checkVersionsConsistency(configuration);\n\n // Re-read the cached version now that the lock is held: another process\n // may have upgraded the output directory while this call was queued, in\n // which case cleaning it would throw away a build that just completed.\n const isCorrectVersionUnderLock =\n (await versionCache.get()) === packageJson.version;\n\n if (clean || !isCorrectVersionUnderLock) {\n await cleanOutputDir(configuration);\n // `cleanOutputDir` wipes the cache directory the sentinel lives in.\n // Re-create it immediately, otherwise a concurrent process (e.g. the\n // `intlayer watch` CLI next to a dev server) sees no lock, starts its\n // own run, and cleans the output directory while this one writes.\n await renewLock();\n }\n\n await versionCache.set(packageJson.version);\n\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const contentDeclarationPaths = dictionariesWithStats.map(\n (dictionary) => dictionary.path\n );\n\n const dictionaries = await loadDictionaries(\n contentDeclarationPaths,\n configuration\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length +\n dictionaries.pluginDictionaries.length >\n 0\n ? [\n `(Total: ${dictionariesLoadedTime - configurationWrittenTime}ms`,\n dictionaries.localDictionaries.length > 0\n ? ` - Local: ${dictionaries.time.localDictionaries}ms`\n : '',\n dictionaries.remoteDictionaries.length > 0\n ? ` - Remote: ${dictionaries.time.remoteDictionaries}ms`\n : '',\n dictionaries.pluginDictionaries.length > 0\n ? ` - Plugin: ${dictionaries.time.pluginDictionaries}ms`\n : '',\n `)`,\n ].join('')\n : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [\n ...dictionaries.localDictionaries,\n ...dictionaries.remoteDictionaries,\n ...dictionaries.pluginDictionaries,\n ],\n configuration,\n { formats: format, importOtherDictionaries: false, env }\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(\n dictionaries.remoteDictionaries,\n configuration\n );\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, configuration);\n\n await createDictionaryEntryPoint(configuration, {\n formats: options?.format,\n });\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of configuration.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n try {\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration,\n });\n } catch (error) {\n // A failing write-back (e.g. transient network error on a remote\n // target) must not invalidate the dictionaries already built.\n appLogger(\n [\n `Plugin ${plugin.name} afterBuild failed:`,\n (error as Error).message,\n ],\n { level: 'error' }\n );\n }\n }\n\n const preparationElapsedMs = Date.now() - preparationStartMs;\n appLogger(\n [`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)],\n {\n level: 'info',\n isVerbose: true,\n }\n );\n },\n {\n forceRun,\n onIsCached,\n cacheTimeoutMs,\n }\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,MAAM,mCAAmC;CACvC,OAAO;CACP,KAAK;CACL,QAAQ,CAAC,OAAO,KAAK;CACrB,gBAAgB;AAClB;AAEA,MAAa,kBAAkB,OAC7B,eACA,YACG;CACH,MAAM,YAAY,aAAa,aAAa;CAE5C,MAAM,eAAe,KACnB,cAAc,OAAO,UACrB,wBACF;CAEA,MAAM,eAAe,UAAU,eAAe,CAAC,kBAAkB,CAAC;CAClE,MAAM,uBAAuB,MAAM,aAAa,IAAI;CACpD,MAAM,mBAAmB,QACvB,yBAAyB,UACvB,yBAAyB,YAAY,OACzC;CAEA,MAAM,kBAAkB,MAAM,8BAA8B,aAAa;CAGzE,MAAM,wBAAwB,MAAM,0BAA0B,aAAa;CAC3E,IAAI,sBAAsB;CAC1B,IAAI;EAEF,MAAM,gBAAgB,MAAM,KAAK,YAAY;EAC7C,sBAAsB,sBAAsB,MACzC,eACC,WAAW,MAAM,MAAM,QAAQ,IAAI,cAAc,MAAM,QAAQ,CACnE;CACF,QAAQ,CAAC;CAGT,MAAM,6BAA4B,MADJ,QAAQ,IAAI,cAAc,WAAW,CAAC,CAAC,EACpB,CAAC,MAAM,WACtD,QAAQ,OAAO,gBAAgB,CACjC;CAEA,MAAM,EAAE,OAAO,QAAQ,UAAU,YAAY,gBAAgB,QAAQ;EACnE,GAAG;EACH,UACE,CAAC,oBACD,CAAC,mBACD,uBACA;EACF,GAAI,WAAW,CAAC;CAClB;CAGA,MAAM,QACJ,cACA,OAAO,EAAE,gBAAgB;EAOvB,MAAM,4BACH,MAAM,aAAa,IAAI,MAAO,YAAY;EAE7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,UAAU;EAE3C,MAAM,YAAY,qBAAqB,aAAa;EAEpD,MAAM,2BAA2B,eAAe,EAC9C,SAAS,SAAS,OACpB,CAAC;EAED,MAAM,wBAAwB,KAAK,IAAI;EAEvC,UAAU,CACR,sBACA,SACE,IAAI,wBAAwB,mBAAmB,MAC/C,WAAW,SACb,CACF,CAAC;EAED,MAAM,yBAAyB,aAAa;EAI5C,UACE,CACE,6BACA,SACE,IAN8B,KAAK,IAML,IAAI,sBAAsB,MACxD,WAAW,SACb,CACF,GACA,EACE,WAAW,KACb,CACF;EAIA,WAAW,MAAM,UAAU,cAAc,WAAW,CAAC,GAAG;GACtD,MAAM,EAAE,sBAAsB,uBAAuB;GAErD,IAAI;IACF,MAAM,OAAO,aAAa;KACxB,cAAc;MACZ;MACA;KACF;KACA;IACF,CAAC;GACH,SAAS,OAAO;IAGd,UACE,CACE,UAAU,OAAO,KAAK,sBACrB,MAAgB,OACnB,GACA,EAAE,OAAO,QAAQ,CACnB;GACF;EACF;EAEA,MAAM,uBAAuB,KAAK,IAAI,IAAI;EAC1C,UACE,CAAC,QAAQ,SAAS,GAAG,qBAAqB,KAAK,WAAW,KAAK,CAAC,GAChE;GACE,OAAO;GACP,WAAW;EACb,CACF;CACF,GACA;EACE;EACA;EACA;CACF,CACF;AACF"}
1
+ {"version":3,"file":"prepareIntlayer.mjs","names":[],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { cacheDisk } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionariesWithStats } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { runOnce } from './utils/runOnce';\nimport {\n isCachedConfigurationUpToDate,\n writeConfiguration,\n} from './writeConfiguration';\n\ntype PrepareIntlayerOptions = {\n clean?: boolean;\n env?: 'prod' | 'dev';\n format?: ('cjs' | 'esm')[];\n forceRun?: boolean;\n cacheTimeoutMs?: number;\n onIsCached?: () => void | Promise<void>;\n};\n\nconst DEFAULT_PREPARE_INTLAYER_OPTIONS = {\n clean: false,\n env: 'dev',\n format: ['cjs', 'esm'],\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n} satisfies PrepareIntlayerOptions;\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig,\n options?: PrepareIntlayerOptions\n) => {\n const appLogger = getAppLogger(configuration);\n\n const sentinelPath = join(\n configuration.system.cacheDir,\n 'intlayer-prepared.lock'\n );\n // Clean output dir if the intlayer version has changed\n const versionCache = cacheDisk(configuration, ['intlayer-version']);\n const intlayerCacheVersion = await versionCache.get();\n const isCorrectVersion = Boolean(\n intlayerCacheVersion === undefined ||\n intlayerCacheVersion === packageJson.version\n );\n\n const isConfigSimilar = await isCachedConfigurationUpToDate(configuration);\n\n // Check if any dictionary has been changed to force a new rebuild\n const dictionariesWithStats = await listDictionariesWithStats(configuration);\n let isDictionaryChanged = false;\n try {\n // Try catch as sentinel file may not exist yet\n const sentinelStats = await stat(sentinelPath);\n isDictionaryChanged = dictionariesWithStats.some(\n (dictionary) =>\n dictionary.stats.mtime.getTime() > sentinelStats.mtime.getTime()\n );\n } catch {}\n\n const resolvedPlugins = await Promise.all(configuration.plugins ?? []);\n const hasPluginLoadDictionaries = resolvedPlugins.some((plugin) =>\n Boolean(plugin.loadDictionaries)\n ); // Disable cache if any plugin because it can have custom behavior\n\n const { clean, format, forceRun, onIsCached, cacheTimeoutMs, env } = {\n ...DEFAULT_PREPARE_INTLAYER_OPTIONS,\n forceRun:\n !isCorrectVersion ||\n !isConfigSimilar ||\n isDictionaryChanged ||\n hasPluginLoadDictionaries,\n ...(options ?? {}),\n };\n\n // Skip preparation if it has already been done recently\n await runOnce(\n sentinelPath,\n async ({ renewLock }) => {\n // comment because of issue with next and webpack\n // await checkVersionsConsistency(configuration);\n\n // Re-read the cached version now that the lock is held: another process\n // may have upgraded the output directory while this call was queued, in\n // which case cleaning it would throw away a build that just completed.\n const isCorrectVersionUnderLock =\n (await versionCache.get()) === packageJson.version;\n\n if (clean || !isCorrectVersionUnderLock) {\n await cleanOutputDir(configuration);\n // `cleanOutputDir` wipes the cache directory the sentinel lives in.\n // Re-create it immediately, otherwise a concurrent process (e.g. the\n // `intlayer watch` CLI next to a dev server) sees no lock, starts its\n // own run, and cleans the output directory while this one writes.\n await renewLock();\n }\n\n await versionCache.set(packageJson.version);\n\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const contentDeclarationPaths = dictionariesWithStats.map(\n (dictionary) => dictionary.path\n );\n\n const dictionaries = await loadDictionaries(\n contentDeclarationPaths,\n configuration\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length +\n dictionaries.pluginDictionaries.length >\n 0\n ? [\n `(Total: ${dictionariesLoadedTime - configurationWrittenTime}ms`,\n dictionaries.localDictionaries.length > 0\n ? ` - Local: ${dictionaries.time.localDictionaries}ms`\n : '',\n dictionaries.remoteDictionaries.length > 0\n ? ` - Remote: ${dictionaries.time.remoteDictionaries}ms`\n : '',\n dictionaries.pluginDictionaries.length > 0\n ? ` - Plugin: ${dictionaries.time.pluginDictionaries}ms`\n : '',\n `)`,\n ].join('')\n : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [\n ...dictionaries.localDictionaries,\n ...dictionaries.remoteDictionaries,\n ...dictionaries.pluginDictionaries,\n ],\n configuration,\n { formats: format, importOtherDictionaries: false, env }\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(\n dictionaries.remoteDictionaries,\n configuration\n );\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, configuration);\n\n await createDictionaryEntryPoint(configuration, {\n formats: options?.format,\n });\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of configuration.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n try {\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration,\n });\n } catch (error) {\n // A failing write-back (e.g. transient network error on a remote\n // target) must not invalidate the dictionaries already built.\n appLogger(\n [\n `Plugin ${plugin.name} afterBuild failed:`,\n (error as Error).message,\n ],\n { level: 'error' }\n );\n }\n }\n\n const preparationElapsedMs = Date.now() - preparationStartMs;\n appLogger(\n [`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)],\n {\n level: 'info',\n isVerbose: true,\n }\n );\n },\n {\n forceRun,\n onIsCached,\n cacheTimeoutMs,\n }\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,MAAM,mCAAmC;CACvC,OAAO;CACP,KAAK;CACL,QAAQ,CAAC,OAAO,KAAK;CACrB,gBAAgB;AAClB;AAEA,MAAa,kBAAkB,OAC7B,eACA,YACG;CACH,MAAM,YAAY,aAAa,aAAa;CAE5C,MAAM,eAAe,KACnB,cAAc,OAAO,UACrB,wBACF;CAEA,MAAM,eAAe,UAAU,eAAe,CAAC,kBAAkB,CAAC;CAClE,MAAM,uBAAuB,MAAM,aAAa,IAAI;CACpD,MAAM,mBAAmB,QACvB,yBAAyB,UACzB,yBAAyB,YAAY,OACvC;CAEA,MAAM,kBAAkB,MAAM,8BAA8B,aAAa;CAGzE,MAAM,wBAAwB,MAAM,0BAA0B,aAAa;CAC3E,IAAI,sBAAsB;CAC1B,IAAI;EAEF,MAAM,gBAAgB,MAAM,KAAK,YAAY;EAC7C,sBAAsB,sBAAsB,MACzC,eACC,WAAW,MAAM,MAAM,QAAQ,IAAI,cAAc,MAAM,QAAQ,CACnE;CACF,QAAQ,CAAC;CAGT,MAAM,6BAA4B,MADJ,QAAQ,IAAI,cAAc,WAAW,CAAC,CAAC,EACpB,CAAC,MAAM,WACtD,QAAQ,OAAO,gBAAgB,CACjC;CAEA,MAAM,EAAE,OAAO,QAAQ,UAAU,YAAY,gBAAgB,QAAQ;EACnE,GAAG;EACH,UACE,CAAC,oBACD,CAAC,mBACD,uBACA;EACF,GAAI,WAAW,CAAC;CAClB;CAGA,MAAM,QACJ,cACA,OAAO,EAAE,gBAAgB;EAOvB,MAAM,4BACH,MAAM,aAAa,IAAI,MAAO,YAAY;EAE7C,IAAI,SAAS,CAAC,2BAA2B;GACvC,MAAM,eAAe,aAA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AM,2BAA2B,eAAe,EAC9C,SAAS,SAAS,OACpB,CAAC;EAED,MAAM,wBAAwB,KAAK,IAAI;EAEvC,UAAU,CACR,sBACA,SACE,IAAI,wBAAwB,mBAAmB,MAC/C,WAAW,SACb,CACF,CAAC;EAED,MAAM,yBAAyB,aAAa;EAI5C,UACE,CACE,6BACA,SACE,IAN8B,KAAK,IAML,IAAI,sBAAsB,MACxD,WAAW,SACb,CACF,GACA,EACE,WAAW,KACb,CACF;EAIA,WAAW,MAAM,UAAU,cAAc,WAAW,CAAC,GAAG;GACtD,MAAM,EAAE,sBAAsB,uBAAuB;GAErD,IAAI;IACF,MAAM,OAAO,aAAa;KACxB,cAAc;MACZ;MACA;KACF;KACA;IACF,CAAC;GACH,SAAS,OAAO;IAGd,UACE,CACE,UAAU,OAAO,KAAK,sBACrB,MAAgB,OACnB,GACA,EAAE,OAAO,QAAQ,CACnB;GACF;EACF;EAEA,MAAM,uBAAuB,KAAK,IAAI,IAAI;EAC1C,UACE,CAAC,QAAQ,SAAS,GAAG,qBAAqB,KAAK,WAAW,KAAK,CAAC,GAChE;GACE,OAAO;GACP,WAAW;EACb,CACF;CACF,GACA;EACE;EACA;EACA;CACF,CACF;AACF"}
@@ -1,10 +1,10 @@
1
1
  import { analyzeBundleContent } from "./analyzeBundleContent.mjs";
2
2
  import { mutateScore, scoreRecord, toScorePercent } from "./calculateScore.mjs";
3
- import { checkBundleContent, checkCanonical, checkHreflang, checkHreflangReciprocity, checkHtmlDir, checkHtmlLang, checkInternalLinks, checkLocaleConsistency, checkOgLocale, checkRobots, checkSitemap, checkXDefault, formatBundleAnalysis, formatSize } from "./checks.mjs";
4
3
  import { findMatchingLocale, getLanguageCode, isRightToLeftLocale, isSameLanguage, isSameLocale, isValidLocaleCode, isValidOpenGraphLocale, looksLikeLocaleCode, normalizeLocaleCode, toOpenGraphLocale } from "./detection/localeCode.mjs";
5
4
  import { getFirstPathSegment, getSiteDomain, isAbsoluteUrl, normalizeHostname, normalizeUrl, parseUrl, toAbsoluteScanUrl } from "./detection/url.mjs";
6
5
  import { detectRoutingStrategy, getUrlLocale } from "./detection/detectRoutingStrategy.mjs";
7
6
  import { classifyInternalLinks } from "./detection/classifyInternalLinks.mjs";
7
+ import { checkBundleContent, checkCanonical, checkHreflang, checkHreflangReciprocity, checkHtmlDir, checkHtmlLang, checkInternalLinks, checkLocaleConsistency, checkOgLocale, checkRobots, checkSitemap, checkXDefault, formatBundleAnalysis, formatSize } from "./checks.mjs";
8
8
  import { fetchText } from "./fetchText.mjs";
9
9
  import { byteLength, extractAnchors, extractCanonicalHref, extractHreflangs, extractHtmlDir, extractHtmlLang, extractMetaDescription, extractOgImage, extractOgLocale, extractOgLocaleAlternates, extractResourceUrls, extractScriptUrls, extractTitle, extractVisibleTextStrings, hasCanonical } from "./parseHtml.mjs";
10
10
  import { isPathAllowedByRobots, parseRobots } from "./robots.mjs";
@@ -1,8 +1,8 @@
1
1
  import { writeFileIfChanged } from "../writeFileIfChanged.mjs";
2
2
  import { extractKeyAndLocaleFromPath } from "./extractKeyAndLocaleFromPath.mjs";
3
3
  import { buildFilePathPatternContext } from "./filePathPatternHelpers.mjs";
4
- import { mkdir, readFile } from "node:fs/promises";
5
4
  import { dirname, isAbsolute, resolve } from "node:path";
5
+ import { mkdir, readFile } from "node:fs/promises";
6
6
  import { parseFilePathPattern } from "@intlayer/config/utils";
7
7
  import fg from "fast-glob";
8
8
 
@@ -1,7 +1,7 @@
1
1
  import { isDirectoryExcluded } from "./isDirectoryExcluded.mjs";
2
+ import { TRAVERSE_PATTERN } from "@intlayer/config/defaultValues";
2
3
  import { isAbsolute, relative, resolve } from "node:path";
3
4
  import { normalizePath } from "@intlayer/config/utils";
4
- import { TRAVERSE_PATTERN } from "@intlayer/config/defaultValues";
5
5
  import fg from "fast-glob";
6
6
 
7
7
  // src/utils/buildComponentFilesList.ts
@@ -1,8 +1,8 @@
1
1
  import { colorize, getAppLogger } from "@intlayer/config/logger";
2
- import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
2
+ import { rmSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
+ import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
4
5
  import * as ANSIColors from "@intlayer/config/colors";
5
- import { rmSync } from "node:fs";
6
6
 
7
7
  // src/utils/contentWatcherLock.ts
8
8
  /**
@@ -1,5 +1,5 @@
1
- import { basename, extname, join } from "node:path";
2
1
  import { existsSync, readFileSync, readdirSync } from "node:fs";
2
+ import { basename, extname, join } from "node:path";
3
3
 
4
4
  // src/utils/readDictionariesFromDisk.ts
5
5
  /**
@@ -1,6 +1,6 @@
1
- import { mkdir, readFile, rmdir, stat, unlink, writeFile } from "node:fs/promises";
2
- import { dirname } from "node:path";
3
1
  import { rmSync } from "node:fs";
2
+ import { dirname } from "node:path";
3
+ import { mkdir, readFile, rmdir, stat, unlink, writeFile } from "node:fs/promises";
4
4
  import packageJson from "@intlayer/core/package.json" with { type: "json" };
5
5
 
6
6
  // src/utils/runOnce.ts
@@ -1,6 +1,6 @@
1
- import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
2
- import { dirname } from "node:path";
3
1
  import { rmSync } from "node:fs";
2
+ import { dirname } from "node:path";
3
+ import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
4
4
 
5
5
  // src/utils/withFileLock.ts
6
6
  const DEFAULT_OPTIONS = {
@@ -9,13 +9,13 @@ import { isDirectoryExcluded } from "./utils/isDirectoryExcluded.mjs";
9
9
  import { parseContentDeclarationFileName } from "./utils/parseContentDeclarationFileName.mjs";
10
10
  import { createBatchDebounce } from "./utils/createBatchDebounce.mjs";
11
11
  import { colorize, getAppLogger } from "@intlayer/config/logger";
12
- import { readFile } from "node:fs/promises";
12
+ import { existsSync, watch as watch$1 } from "node:fs";
13
13
  import { basename, dirname, extname, resolve } from "node:path";
14
- import * as ANSIColor from "@intlayer/config/colors";
14
+ import { readFile } from "node:fs/promises";
15
15
  import { clearAllCache, clearDiskCacheMemory, clearModuleCache, normalizePath } from "@intlayer/config/utils";
16
- import { existsSync, watch as watch$1 } from "node:fs";
17
- import { transpileTSToCJS } from "@intlayer/config/file";
16
+ import * as ANSIColor from "@intlayer/config/colors";
18
17
  import { getConfiguration, getConfigurationAndFilePath } from "@intlayer/config/node";
18
+ import { transpileTSToCJS } from "@intlayer/config/file";
19
19
 
20
20
  // src/watcher.ts
21
21
  const pendingUnlinks = /* @__PURE__ */ new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.mjs","names":["fsWatch"],"sources":["../../src/watcher.ts"],"sourcesContent":["import { existsSync, watch as fsWatch } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { basename, dirname, extname, resolve } from 'node:path';\nimport * as ANSIColor from '@intlayer/config/colors';\nimport { transpileTSToCJS } from '@intlayer/config/file';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n getConfigurationAndFilePath,\n} from '@intlayer/config/node';\nimport {\n clearAllCache,\n clearDiskCacheMemory,\n clearModuleCache,\n normalizePath,\n} from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { handleAdditionalContentDeclarationFile } from './handleAdditionalContentDeclarationFile';\nimport { handleContentDeclarationFilesChange } from './handleContentDeclarationFileChange';\nimport { handleContentDeclarationFileMoved } from './handleContentDeclarationFileMoved';\nimport { handleUnlinkedContentDeclarationFile } from './handleUnlinkedContentDeclarationFile';\nimport { prepareIntlayer } from './prepareIntlayer';\nimport {\n formatPath,\n getFormatFromExtension,\n isDirectoryExcluded,\n parseContentDeclarationFileName,\n} from './utils';\nimport { createBatchDebounce } from './utils/createBatchDebounce';\n\n// Map to track files that were recently unlinked: oldPath -> { timer, timestamp }\nconst pendingUnlinks = new Map<\n string,\n { timer: NodeJS.Timeout; oldPath: string }\n>();\n\n// Array-based sequential task queue — no Promise chain accumulation, no race conditions\nconst taskQueue: (() => Promise<void>)[] = [];\nlet isProcessing = false;\n\nconst processQueue = async () => {\n if (isProcessing) return;\n isProcessing = true;\n while (taskQueue.length > 0) {\n const task = taskQueue.shift()!;\n try {\n await task();\n } catch (error) {\n console.error(error);\n }\n }\n isProcessing = false;\n};\n\nconst processEvent = (task: () => Promise<void>) => {\n taskQueue.push(task);\n processQueue();\n};\n\ntype WatchOptions = {\n configuration?: IntlayerConfig;\n configOptions?: GetConfigurationOptions;\n skipPrepare?: boolean;\n persistent?: boolean;\n};\n\n// awaitWriteFinish equivalent: debounce per path until the file is stable\nconst STABILITY_THRESHOLD = 1000;\n\nconst createStabilityDebounce = () => {\n const pending = new Map<string, NodeJS.Timeout>();\n return (path: string, handler: () => void) => {\n const existing = pending.get(path);\n if (existing) clearTimeout(existing);\n pending.set(\n path,\n setTimeout(() => {\n pending.delete(path);\n handler();\n }, STABILITY_THRESHOLD)\n );\n };\n};\n\n// Initialize @parcel/watcher (non-persistent until subscribed)\nexport const watch = async (options?: WatchOptions) => {\n const { subscribe } = await import('@parcel/watcher');\n\n const configResult = getConfigurationAndFilePath(options?.configOptions);\n const configurationFilePath = configResult.configurationFilePath;\n let configuration: IntlayerConfig =\n options?.configuration ?? configResult.configuration;\n const appLogger = getAppLogger(configuration);\n\n const {\n watch: isWatchMode,\n fileExtensions,\n contentDir,\n excludedPath,\n } = configuration.content;\n\n if (!configuration.content.watch) return;\n\n appLogger('Watching Intlayer content declarations');\n\n if (configuration.build.optimize === true) {\n appLogger(\n [\n `Build optimization is forced to ${colorize('true', ANSIColor.GREY)}, but watching is enabled too.`,\n 'It may lead to dev mode performance degradation as well as import errors.',\n 'Its recommended to keep the',\n colorize('`build.optimized`', ANSIColor.BLUE),\n 'option',\n colorize('undefined', ANSIColor.GREY),\n 'to get the best dev mode experience',\n ],\n {\n level: 'warn',\n }\n );\n }\n\n // Strip glob markers from excludedPath entries to get plain segments (e.g. 'node_modules')\n const excludedSegments = excludedPath.map((segment) =>\n segment.replace(/^\\*\\*\\//, '').replace(/\\/\\*\\*$/, '')\n );\n\n const normalizedConfigPath = configurationFilePath\n ? normalizePath(configurationFilePath)\n : null;\n\n const { mainDir, baseDir } = configuration.system;\n const normalizedMainDir = normalizePath(mainDir);\n const normalizedIntlayerDir = normalizePath(dirname(mainDir));\n\n const subscriptions: { unsubscribe: () => Promise<void> }[] = [];\n\n const scheduleStable = createStabilityDebounce();\n\n const scheduleContentChange = createBatchDebounce<string>(\n (filePaths) =>\n processEvent(async () => {\n for (const filePath of filePaths) {\n // Clear module cache for the changed file to avoid stale require() results\n clearModuleCache(filePath);\n }\n // Evict in-memory caches so loadContentDeclaration picks up fresh content\n clearAllCache();\n clearDiskCacheMemory();\n await handleContentDeclarationFilesChange(filePaths, configuration);\n }),\n STABILITY_THRESHOLD\n );\n\n // ── mainDir watcher (depth 0) ──────────────────────────────────────────────\n // Detects broken or missing entry-point files inside .intlayer/main\n if (existsSync(mainDir)) {\n const mainDirSub = await subscribe(normalizedMainDir, (err, events) => {\n if (err || isProcessing) return;\n\n for (const event of events) {\n const eventPath = normalizePath(event.path);\n // depth-0 filter: only files directly inside mainDir\n const rel = eventPath.slice(normalizedMainDir.length + 1);\n if (!rel || rel.includes('/')) continue;\n // Temp files written by the bundler (write-then-rename) are build-internal;\n // their deletion must not trigger a clean rebuild.\n if (rel.endsWith('.tmp')) continue;\n\n if (event.type === 'update') {\n processEvent(async () => {\n try {\n // Validate that the regenerated entry point — and the relative\n // dictionary graph it imports — still resolves, by bundling it\n // in-memory with esbuild (via the shared, freshness-checked\n // transpile cache). This replaces a cache-busting dynamic\n // `import()`, which leaked a permanent record into Node's ESM\n // registry on every rebuild since that registry is never evicted.\n const entryCode = await readFile(event.path, 'utf-8');\n await transpileTSToCJS(entryCode, event.path);\n } catch {\n appLogger(\n `Entry point ${basename(event.path)} failed to load, running clean rebuild...`,\n { level: 'warn' }\n );\n await prepareIntlayer(configuration, {\n clean: true,\n forceRun: true,\n });\n }\n });\n } else if (event.type === 'delete') {\n processEvent(async () => {\n appLogger(\n [\n 'Entry point',\n formatPath(basename(event.path)),\n 'was removed, running clean rebuild...',\n ],\n { level: 'warn' }\n );\n await prepareIntlayer(configuration, {\n clean: true,\n forceRun: true,\n });\n });\n }\n }\n });\n subscriptions.push(mainDirSub);\n }\n\n // ── baseDir watcher (depth 0) — detect .intlayer directory removal ─────────\n // Native fs.watch is non-recursive and ideal for single-directory depth-0 detection.\n const intlayerDirName = basename(normalizedIntlayerDir);\n const fsDirWatcher = fsWatch(\n baseDir,\n { persistent: isWatchMode },\n (eventType, filename) => {\n if (isProcessing || !filename) return;\n if (filename !== intlayerDirName) return;\n\n const fullPath = normalizePath(resolve(baseDir, filename));\n if (fullPath !== normalizedIntlayerDir) return;\n\n if (eventType === 'rename' && !existsSync(normalizedIntlayerDir)) {\n appLogger([\n formatPath('.intlayer'),\n 'directory removed, running clean rebuild...',\n ]);\n processEvent(() =>\n prepareIntlayer(configuration, { clean: true, forceRun: true })\n );\n }\n }\n );\n subscriptions.push({\n unsubscribe: async () => {\n fsDirWatcher.close();\n },\n });\n\n // ── main content watcher ───────────────────────────────────────────────────\n // Ignore patterns for @parcel/watcher (micromatch globs)\n const ignorePatterns = excludedSegments.map((s) => `**/${s}/**`);\n\n // Strip trailing slashes so directory matching stays exact. A user-supplied\n const contentDirs = contentDir\n .map((dir) => normalizePath(dir).replace(/\\/+$/, ''))\n .filter(existsSync);\n\n // Collect unique directories to subscribe to (dirs only, not file paths)\n const dirsToWatch = new Set<string>(contentDirs);\n if (normalizedConfigPath) {\n dirsToWatch.add(normalizePath(dirname(normalizedConfigPath)));\n }\n\n const contentHandler = (\n err: Error | null,\n events: Array<{ type: string; path: string }>\n ) => {\n if (err) {\n appLogger(`Watcher error: ${err}`, { level: 'error' });\n appLogger('Restarting watcher');\n prepareIntlayer(configuration);\n return;\n }\n\n for (const event of events) {\n const filePath = event.path;\n const path = normalizePath(filePath);\n\n const isConfigFile =\n normalizedConfigPath && path === normalizedConfigPath;\n\n if (!isConfigFile) {\n // Must originate from a watched content directory (the most specific)\n const matchingContentDir = contentDirs\n .filter(\n (dictionary) =>\n path.startsWith(`${dictionary}/`) || path === dictionary\n )\n .reduce<string | undefined>(\n (longest, dictionary) =>\n longest === undefined || dictionary.length > longest.length\n ? dictionary\n : longest,\n undefined\n );\n if (matchingContentDir === undefined) continue;\n\n // Exclusions apply below the content directory only, so an explicit\n // `contentDir` inside e.g. a `dist` folder is still watched\n const relativeDirectory = dirname(\n path.slice(matchingContentDir.length)\n );\n if (isDirectoryExcluded(relativeDirectory, excludedPath)) continue;\n\n if (!fileExtensions.some((extension) => path.endsWith(extension)))\n continue;\n }\n\n if (event.type === 'create') {\n const fileName = basename(filePath);\n\n // Move detection must happen synchronously before any debounce\n let isMove = false;\n let matchedOldPath: string | undefined;\n\n for (const [oldPath] of pendingUnlinks) {\n if (basename(oldPath) === fileName) {\n matchedOldPath = oldPath;\n break;\n }\n }\n\n if (!matchedOldPath && pendingUnlinks.size === 1) {\n matchedOldPath = pendingUnlinks.keys().next().value;\n }\n\n if (matchedOldPath) {\n const pending = pendingUnlinks.get(matchedOldPath);\n if (pending) {\n clearTimeout(pending.timer);\n pendingUnlinks.delete(matchedOldPath);\n }\n isMove = true;\n appLogger(`File moved from ${matchedOldPath} to ${filePath}`);\n }\n\n if (isMove && matchedOldPath) {\n processEvent(async () => {\n await handleContentDeclarationFileMoved(\n matchedOldPath!,\n filePath,\n configuration\n );\n });\n } else {\n // Debounce: wait for write to finish before reading the file\n scheduleStable(path, () => {\n processEvent(async () => {\n const fileContent = await readFile(filePath, 'utf-8');\n const isEmpty = fileContent === '';\n\n if (isEmpty) {\n const { key, locale } = parseContentDeclarationFileName(\n filePath,\n configuration\n );\n\n // A markdown declaration carries a single locale body, so it\n // must always state which locale it holds.\n const isMarkdown =\n getFormatFromExtension(extname(filePath)) === 'md';\n const declaredLocale =\n locale ??\n (isMarkdown\n ? configuration.internationalization.defaultLocale\n : undefined);\n\n // Lazy: pulls recast/ast-types, only needed for new empty files\n const { writeContentDeclaration } = await import(\n './writeContentDeclaration'\n );\n\n await writeContentDeclaration(\n {\n key,\n ...(declaredLocale && { locale: declaredLocale }),\n content: {},\n filePath,\n },\n configuration\n );\n }\n\n await handleAdditionalContentDeclarationFile(\n filePath,\n configuration\n );\n });\n });\n }\n } else if (event.type === 'update') {\n if (!isConfigFile) {\n scheduleContentChange(filePath);\n continue;\n }\n\n scheduleStable(path, () => {\n processEvent(async () => {\n appLogger('Configuration file changed, repreparing Intlayer');\n\n clearModuleCache(filePath);\n clearAllCache();\n\n const { configuration: newConfiguration } =\n getConfigurationAndFilePath(options?.configOptions);\n\n configuration = options?.configuration ?? newConfiguration;\n\n await prepareIntlayer(configuration, { clean: false });\n });\n });\n } else if (event.type === 'delete') {\n // Delay unlink processing to see if an 'add' event occurs (indicating a move)\n const timer = setTimeout(async () => {\n // If timer fires, the file was genuinely removed\n pendingUnlinks.delete(filePath);\n processEvent(async () =>\n handleUnlinkedContentDeclarationFile(filePath, configuration)\n );\n }, 200); // 200ms window to catch the 'create' event\n\n pendingUnlinks.set(filePath, { timer, oldPath: filePath });\n }\n }\n };\n\n for (const dir of dirsToWatch) {\n const sub = await subscribe(dir, contentHandler, {\n ignore: ignorePatterns,\n });\n\n subscriptions.push(sub);\n }\n\n return subscriptions;\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const { skipPrepare, ...rest } = options ?? {};\n const configuration =\n options?.configuration ?? getConfiguration(options?.configOptions);\n\n if (!skipPrepare) {\n await prepareIntlayer(configuration, { forceRun: true });\n }\n\n // Only enter watch mode when the caller explicitly opts in via `persistent`.\n // `configuration.content.watch` is the dev-mode signal consumed by bundler\n // plugins (e.g. vite-intlayer's `configureServer`); it must not coerce\n // `intlayer build` (which passes `persistent: false`) into a persistent\n // watcher, since that prevents the build command from ever exiting.\n if (options?.persistent) {\n await watch({ ...rest, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,iCAAiB,IAAI,IAGzB;AAGF,MAAM,YAAqC,CAAC;AAC5C,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Ae,YAAY;KACzB,aAAa,YAAY;MACvB,UAAU,kDAAkD;MAE5D,iBAAiB,QAAQ;MACzB,cAAc;MAEd,MAAM,EAAE,eAAe,qBACrB,4BAA4B,SAAS,aAAa;MAEpD,gBAAgB,SAAS,iBAAiB;MAE1C,MAAM,gBAAgB,eAAe,EAAE,OAAO,MAAM,CAAC;KACvD,CAAC;IACH,CAAC;GACH,OAAO,IAAI,MAAM,SAAS,UAAU;IAElC,MAAM,QAAQ,WAAW,YAAY;KAEnC,eAAe,OAAO,QAAQ;KAC9B,aAAa,YACX,qCAAqC,UAAU,aAAa,CAC9D;IACF,GAAG,GAAG;IAEN,eAAe,IAAI,UAAU;KAAE;KAAO,SAAS;IAAS,CAAC;GAC3D;EACF;CACF;CAEA,KAAK,MAAM,OAAO,aAAa;EAC7B,MAAM,MAAM,MAAM,UAAU,KAAK,gBAAgB,EAC/C,QAAQ,eACV,CAAC;EAED,cAAc,KAAK,GAAG;CACxB;CAEA,OAAO;AACT;AAEA,MAAa,wBAAwB,OAAO,YAA2B;CACrE,MAAM,EAAE,aAAa,GAAG,SAAS,WAAW,CAAC;CAC7C,MAAM,gBACJ,SAAS,iBAAiB,iBAAiB,SAAS,aAAa;CAEnE,IAAI,CAAC,aACH,MAAM,gBAAgB,eAAe,EAAE,UAAU,KAAK,CAAC;CAQzD,IAAI,SAAS,YACX,MAAM,MAAM;EAAE,GAAG;EAAM;CAAc,CAAC;AAE1C"}
1
+ {"version":3,"file":"watcher.mjs","names":["fsWatch"],"sources":["../../src/watcher.ts"],"sourcesContent":["import { existsSync, watch as fsWatch } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { basename, dirname, extname, resolve } from 'node:path';\nimport * as ANSIColor from '@intlayer/config/colors';\nimport { transpileTSToCJS } from '@intlayer/config/file';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n getConfigurationAndFilePath,\n} from '@intlayer/config/node';\nimport {\n clearAllCache,\n clearDiskCacheMemory,\n clearModuleCache,\n normalizePath,\n} from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { handleAdditionalContentDeclarationFile } from './handleAdditionalContentDeclarationFile';\nimport { handleContentDeclarationFilesChange } from './handleContentDeclarationFileChange';\nimport { handleContentDeclarationFileMoved } from './handleContentDeclarationFileMoved';\nimport { handleUnlinkedContentDeclarationFile } from './handleUnlinkedContentDeclarationFile';\nimport { prepareIntlayer } from './prepareIntlayer';\nimport {\n formatPath,\n getFormatFromExtension,\n isDirectoryExcluded,\n parseContentDeclarationFileName,\n} from './utils';\nimport { createBatchDebounce } from './utils/createBatchDebounce';\n\n// Map to track files that were recently unlinked: oldPath -> { timer, timestamp }\nconst pendingUnlinks = new Map<\n string,\n { timer: NodeJS.Timeout; oldPath: string }\n>();\n\n// Array-based sequential task queue — no Promise chain accumulation, no race conditions\nconst taskQueue: (() => Promise<void>)[] = [];\nlet isProcessing = false;\n\nconst processQueue = async () => {\n if (isProcessing) return;\n isProcessing = true;\n while (taskQueue.length > 0) {\n const task = taskQueue.shift()!;\n try {\n await task();\n } catch (error) {\n console.error(error);\n }\n }\n isProcessing = false;\n};\n\nconst processEvent = (task: () => Promise<void>) => {\n taskQueue.push(task);\n processQueue();\n};\n\ntype WatchOptions = {\n configuration?: IntlayerConfig;\n configOptions?: GetConfigurationOptions;\n skipPrepare?: boolean;\n persistent?: boolean;\n};\n\n// awaitWriteFinish equivalent: debounce per path until the file is stable\nconst STABILITY_THRESHOLD = 1000;\n\nconst createStabilityDebounce = () => {\n const pending = new Map<string, NodeJS.Timeout>();\n return (path: string, handler: () => void) => {\n const existing = pending.get(path);\n if (existing) clearTimeout(existing);\n pending.set(\n path,\n setTimeout(() => {\n pending.delete(path);\n handler();\n }, STABILITY_THRESHOLD)\n );\n };\n};\n\n// Initialize @parcel/watcher (non-persistent until subscribed)\nexport const watch = async (options?: WatchOptions) => {\n const { subscribe } = await import('@parcel/watcher');\n\n const configResult = getConfigurationAndFilePath(options?.configOptions);\n const configurationFilePath = configResult.configurationFilePath;\n let configuration: IntlayerConfig =\n options?.configuration ?? configResult.configuration;\n const appLogger = getAppLogger(configuration);\n\n const {\n watch: isWatchMode,\n fileExtensions,\n contentDir,\n excludedPath,\n } = configuration.content;\n\n if (!configuration.content.watch) return;\n\n appLogger('Watching Intlayer content declarations');\n\n if (configuration.build.optimize === true) {\n appLogger(\n [\n `Build optimization is forced to ${colorize('true', ANSIColor.GREY)}, but watching is enabled too.`,\n 'It may lead to dev mode performance degradation as well as import errors.',\n 'Its recommended to keep the',\n colorize('`build.optimized`', ANSIColor.BLUE),\n 'option',\n colorize('undefined', ANSIColor.GREY),\n 'to get the best dev mode experience',\n ],\n {\n level: 'warn',\n }\n );\n }\n\n // Strip glob markers from excludedPath entries to get plain segments (e.g. 'node_modules')\n const excludedSegments = excludedPath.map((segment) =>\n segment.replace(/^\\*\\*\\//, '').replace(/\\/\\*\\*$/, '')\n );\n\n const normalizedConfigPath = configurationFilePath\n ? normalizePath(configurationFilePath)\n : null;\n\n const { mainDir, baseDir } = configuration.system;\n const normalizedMainDir = normalizePath(mainDir);\n const normalizedIntlayerDir = normalizePath(dirname(mainDir));\n\n const subscriptions: { unsubscribe: () => Promise<void> }[] = [];\n\n const scheduleStable = createStabilityDebounce();\n\n const scheduleContentChange = createBatchDebounce<string>(\n (filePaths) =>\n processEvent(async () => {\n for (const filePath of filePaths) {\n // Clear module cache for the changed file to avoid stale require() results\n clearModuleCache(filePath);\n }\n // Evict in-memory caches so loadContentDeclaration picks up fresh content\n clearAllCache();\n clearDiskCacheMemory();\n await handleContentDeclarationFilesChange(filePaths, configuration);\n }),\n STABILITY_THRESHOLD\n );\n\n // ── mainDir watcher (depth 0) ──────────────────────────────────────────────\n // Detects broken or missing entry-point files inside .intlayer/main\n if (existsSync(mainDir)) {\n const mainDirSub = await subscribe(normalizedMainDir, (err, events) => {\n if (err || isProcessing) return;\n\n for (const event of events) {\n const eventPath = normalizePath(event.path);\n // depth-0 filter: only files directly inside mainDir\n const rel = eventPath.slice(normalizedMainDir.length + 1);\n if (!rel || rel.includes('/')) continue;\n // Temp files written by the bundler (write-then-rename) are build-internal;\n // their deletion must not trigger a clean rebuild.\n if (rel.endsWith('.tmp')) continue;\n\n if (event.type === 'update') {\n processEvent(async () => {\n try {\n // Validate that the regenerated entry point — and the relative\n // dictionary graph it imports — still resolves, by bundling it\n // in-memory with esbuild (via the shared, freshness-checked\n // transpile cache). This replaces a cache-busting dynamic\n // `import()`, which leaked a permanent record into Node's ESM\n // registry on every rebuild since that registry is never evicted.\n const entryCode = await readFile(event.path, 'utf-8');\n await transpileTSToCJS(entryCode, event.path);\n } catch {\n appLogger(\n `Entry point ${basename(event.path)} failed to load, running clean rebuild...`,\n { level: 'warn' }\n );\n await prepareIntlayer(configuration, {\n clean: true,\n forceRun: true,\n });\n }\n });\n } else if (event.type === 'delete') {\n processEvent(async () => {\n appLogger(\n [\n 'Entry point',\n formatPath(basename(event.path)),\n 'was removed, running clean rebuild...',\n ],\n { level: 'warn' }\n );\n await prepareIntlayer(configuration, {\n clean: true,\n forceRun: true,\n });\n });\n }\n }\n });\n subscriptions.push(mainDirSub);\n }\n\n // ── baseDir watcher (depth 0) — detect .intlayer directory removal ─────────\n // Native fs.watch is non-recursive and ideal for single-directory depth-0 detection.\n const intlayerDirName = basename(normalizedIntlayerDir);\n const fsDirWatcher = fsWatch(\n baseDir,\n { persistent: isWatchMode },\n (eventType, filename) => {\n if (isProcessing || !filename) return;\n if (filename !== intlayerDirName) return;\n\n const fullPath = normalizePath(resolve(baseDir, filename));\n if (fullPath !== normalizedIntlayerDir) return;\n\n if (eventType === 'rename' && !existsSync(normalizedIntlayerDir)) {\n appLogger([\n formatPath('.intlayer'),\n 'directory removed, running clean rebuild...',\n ]);\n processEvent(() =>\n prepareIntlayer(configuration, { clean: true, forceRun: true })\n );\n }\n }\n );\n subscriptions.push({\n unsubscribe: async () => {\n fsDirWatcher.close();\n },\n });\n\n // ── main content watcher ───────────────────────────────────────────────────\n // Ignore patterns for @parcel/watcher (micromatch globs)\n const ignorePatterns = excludedSegments.map((s) => `**/${s}/**`);\n\n // Strip trailing slashes so directory matching stays exact. A user-supplied\n const contentDirs = contentDir\n .map((dir) => normalizePath(dir).replace(/\\/+$/, ''))\n .filter(existsSync);\n\n // Collect unique directories to subscribe to (dirs only, not file paths)\n const dirsToWatch = new Set<string>(contentDirs);\n if (normalizedConfigPath) {\n dirsToWatch.add(normalizePath(dirname(normalizedConfigPath)));\n }\n\n const contentHandler = (\n err: Error | null,\n events: Array<{ type: string; path: string }>\n ) => {\n if (err) {\n appLogger(`Watcher error: ${err}`, { level: 'error' });\n appLogger('Restarting watcher');\n prepareIntlayer(configuration);\n return;\n }\n\n for (const event of events) {\n const filePath = event.path;\n const path = normalizePath(filePath);\n\n const isConfigFile =\n normalizedConfigPath && path === normalizedConfigPath;\n\n if (!isConfigFile) {\n // Must originate from a watched content directory (the most specific)\n const matchingContentDir = contentDirs\n .filter(\n (dictionary) =>\n path.startsWith(`${dictionary}/`) || path === dictionary\n )\n .reduce<string | undefined>(\n (longest, dictionary) =>\n longest === undefined || dictionary.length > longest.length\n ? dictionary\n : longest,\n undefined\n );\n if (matchingContentDir === undefined) continue;\n\n // Exclusions apply below the content directory only, so an explicit\n // `contentDir` inside e.g. a `dist` folder is still watched\n const relativeDirectory = dirname(\n path.slice(matchingContentDir.length)\n );\n if (isDirectoryExcluded(relativeDirectory, excludedPath)) continue;\n\n if (!fileExtensions.some((extension) => path.endsWith(extension)))\n continue;\n }\n\n if (event.type === 'create') {\n const fileName = basename(filePath);\n\n // Move detection must happen synchronously before any debounce\n let isMove = false;\n let matchedOldPath: string | undefined;\n\n for (const [oldPath] of pendingUnlinks) {\n if (basename(oldPath) === fileName) {\n matchedOldPath = oldPath;\n break;\n }\n }\n\n if (!matchedOldPath && pendingUnlinks.size === 1) {\n matchedOldPath = pendingUnlinks.keys().next().value;\n }\n\n if (matchedOldPath) {\n const pending = pendingUnlinks.get(matchedOldPath);\n if (pending) {\n clearTimeout(pending.timer);\n pendingUnlinks.delete(matchedOldPath);\n }\n isMove = true;\n appLogger(`File moved from ${matchedOldPath} to ${filePath}`);\n }\n\n if (isMove && matchedOldPath) {\n processEvent(async () => {\n await handleContentDeclarationFileMoved(\n matchedOldPath!,\n filePath,\n configuration\n );\n });\n } else {\n // Debounce: wait for write to finish before reading the file\n scheduleStable(path, () => {\n processEvent(async () => {\n const fileContent = await readFile(filePath, 'utf-8');\n const isEmpty = fileContent === '';\n\n if (isEmpty) {\n const { key, locale } = parseContentDeclarationFileName(\n filePath,\n configuration\n );\n\n // A markdown declaration carries a single locale body, so it\n // must always state which locale it holds.\n const isMarkdown =\n getFormatFromExtension(extname(filePath)) === 'md';\n const declaredLocale =\n locale ??\n (isMarkdown\n ? configuration.internationalization.defaultLocale\n : undefined);\n\n // Lazy: pulls recast/ast-types, only needed for new empty files\n const { writeContentDeclaration } =\n await import('./writeContentDeclaration');\n\n await writeContentDeclaration(\n {\n key,\n ...(declaredLocale && { locale: declaredLocale }),\n content: {},\n filePath,\n },\n configuration\n );\n }\n\n await handleAdditionalContentDeclarationFile(\n filePath,\n configuration\n );\n });\n });\n }\n } else if (event.type === 'update') {\n if (!isConfigFile) {\n scheduleContentChange(filePath);\n continue;\n }\n\n scheduleStable(path, () => {\n processEvent(async () => {\n appLogger('Configuration file changed, repreparing Intlayer');\n\n clearModuleCache(filePath);\n clearAllCache();\n\n const { configuration: newConfiguration } =\n getConfigurationAndFilePath(options?.configOptions);\n\n configuration = options?.configuration ?? newConfiguration;\n\n await prepareIntlayer(configuration, { clean: false });\n });\n });\n } else if (event.type === 'delete') {\n // Delay unlink processing to see if an 'add' event occurs (indicating a move)\n const timer = setTimeout(async () => {\n // If timer fires, the file was genuinely removed\n pendingUnlinks.delete(filePath);\n processEvent(async () =>\n handleUnlinkedContentDeclarationFile(filePath, configuration)\n );\n }, 200); // 200ms window to catch the 'create' event\n\n pendingUnlinks.set(filePath, { timer, oldPath: filePath });\n }\n }\n };\n\n for (const dir of dirsToWatch) {\n const sub = await subscribe(dir, contentHandler, {\n ignore: ignorePatterns,\n });\n\n subscriptions.push(sub);\n }\n\n return subscriptions;\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const { skipPrepare, ...rest } = options ?? {};\n const configuration =\n options?.configuration ?? getConfiguration(options?.configOptions);\n\n if (!skipPrepare) {\n await prepareIntlayer(configuration, { forceRun: true });\n }\n\n // Only enter watch mode when the caller explicitly opts in via `persistent`.\n // `configuration.content.watch` is the dev-mode signal consumed by bundler\n // plugins (e.g. vite-intlayer's `configureServer`); it must not coerce\n // `intlayer build` (which passes `persistent: false`) into a persistent\n // watcher, since that prevents the build command from ever exiting.\n if (options?.persistent) {\n await watch({ ...rest, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,iCAAiB,IAAI,IAGzB;AAGF,MAAM,YAAqC,CAAC;AAC5C,IAAI,eAAe;AAEnB,MAAM,eAAe,YAAY;CAC/B,IAAI,cAAc;CAClB,eAAe;CACf,OAAO,UAAU,SAAS,GAAG;EAC3B,MAAM,OAAO,UAAU,MAAM;EAC7B,IAAI;GACF,MAAM,KAAK;EACb,SAAS,OAAO;GACd,QAAQ,MAAM,KAAK;EACrB;CACF;CACA,eAAe;AACjB;AAEA,MAAM,gBAAgB,SAA8B;CAClD,UAAU,KAAK,IAAI;CACnB,aAAa;AACf;AAUA,MAAM,sBAAsB;AAE5B,MAAM,gCAAgC;CACpC,MAAM,0BAAU,IAAI,IAA4B;CAChD,QAAQ,MAAc,YAAwB;EAC5C,MAAM,WAAW,QAAQ,IAAI,IAAI;EACjC,IAAI,UAAU,aAAa,QAAQ;EACnC,QAAQ,IACN,MACA,iBAAiB;GACf,QAAQ,OAAO,IAAI;GACnB,QAAQ;EACV,GAAG,mBAAmB,CACxB;CACF;AACF;AAGA,MAAa,QAAQ,OAAO,YAA2B;CACrD,MAAM,EA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AAa,wBAAwB,OAAO,YAA2B;CACrE,MAAM,EAAE,aAAa,GAAG,SAAS,WAAW,CAAC;CAC7C,MAAM,gBACJ,SAAS,iBAAiB,iBAAiB,SAAS,aAAa;CAEnE,IAAI,CAAC,aACH,MAAM,gBAAgB,eAAe,EAAE,UAAU,KAAK,CAAC;CAQzD,IAAI,SAAS,YACX,MAAM,MAAM;EAAE,GAAG;EAAM;CAAc,CAAC;AAE1C"}
@@ -1,8 +1,8 @@
1
1
  import { writeFileIfChanged } from "../writeFileIfChanged.mjs";
2
2
  import { generateConfigurationContent } from "./generateConfigurationContent.mjs";
3
- import { mkdir, readFile } from "node:fs/promises";
4
- import { join } from "node:path";
5
3
  import { mkdirSync, watch } from "node:fs";
4
+ import { join } from "node:path";
5
+ import { mkdir, readFile } from "node:fs/promises";
6
6
 
7
7
  // src/writeConfiguration/index.ts
8
8
  const isCachedConfigurationUpToDate = async (configuration) => {
@@ -1,6 +1,6 @@
1
1
  import { colorizePath, x } from "@intlayer/config/logger";
2
- import { dirname, join } from "node:path";
3
2
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
4
  import { deepTransformNode } from "@intlayer/core/interpreter";
5
5
  import * as NodeTypes from "@intlayer/types/nodeType";
6
6
 
@@ -5,10 +5,10 @@ import { transformJSONFile } from "./transformJSONFile.mjs";
5
5
  import { writeJSFile } from "./writeJSFile.mjs";
6
6
  import { writeMarkdownFile } from "./writeMarkdownFile.mjs";
7
7
  import { writeYamlFile } from "./writeYamlFile.mjs";
8
- import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
9
- import { basename, dirname, extname, join, resolve } from "node:path";
10
8
  import { COMPILER_NO_METADATA } from "@intlayer/config/defaultValues";
11
9
  import { existsSync } from "node:fs";
10
+ import { basename, dirname, extname, join, resolve } from "node:path";
11
+ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
12
12
  import { execSync } from "node:child_process";
13
13
  import { isDeepStrictEqual } from "node:util";
14
14
 
@@ -3,9 +3,9 @@ import { getContentDeclarationFileTemplate } from "../getContentDeclarationFileT
3
3
  import { getFormatFromExtension } from "../utils/getFormatFromExtension.mjs";
4
4
  import { transformJSFile } from "./transformJSFile.mjs";
5
5
  import { getAppLogger, logger } from "@intlayer/config/logger";
6
- import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
7
- import { basename, extname, join } from "node:path";
8
6
  import { existsSync } from "node:fs";
7
+ import { basename, extname, join } from "node:path";
8
+ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
9
9
  import { execSync } from "node:child_process";
10
10
 
11
11
  // src/writeContentDeclaration/writeJSFile.ts
@@ -1,7 +1,7 @@
1
1
  import { detectFormatCommand } from "../detectFormatCommand.mjs";
2
2
  import { renderMarkdownContentDeclaration } from "./renderContentDeclaration.mjs";
3
- import { mkdir, rename, rm, writeFile } from "node:fs/promises";
4
3
  import { basename, dirname, join } from "node:path";
4
+ import { mkdir, rename, rm, writeFile } from "node:fs/promises";
5
5
  import { execSync } from "node:child_process";
6
6
 
7
7
  // src/writeContentDeclaration/writeMarkdownFile.ts
@@ -1,7 +1,7 @@
1
1
  import { detectFormatCommand } from "../detectFormatCommand.mjs";
2
2
  import { renderYamlContentDeclaration } from "./renderContentDeclaration.mjs";
3
- import { mkdir, rename, rm, writeFile } from "node:fs/promises";
4
3
  import { basename, dirname, join } from "node:path";
4
+ import { mkdir, rename, rm, writeFile } from "node:fs/promises";
5
5
  import { execSync } from "node:child_process";
6
6
 
7
7
  // src/writeContentDeclaration/writeYamlFile.ts
@@ -1,6 +1,6 @@
1
- import { chmod, mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
2
- import { basename, dirname, join } from "node:path";
3
1
  import { rmSync } from "node:fs";
2
+ import { basename, dirname, join } from "node:path";
3
+ import { chmod, mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
4
4
  import { randomBytes } from "node:crypto";
5
5
 
6
6
  // src/writeFileIfChanged.ts
@@ -1,8 +1,22 @@
1
+ import "./buildIntlayerDictionary/index.js";
2
+ import { DictionariesStatus, loadDictionaries } from "./loadDictionaries/loadDictionaries.js";
3
+ import { ensureIntlayerBundle, formatLocalDictionaries, loadContentDeclaration, loadContentDeclarations } from "./loadDictionaries/loadContentDeclaration.js";
4
+ import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.js";
5
+ import { formatDistantDictionaries, loadRemoteDictionaries } from "./loadDictionaries/loadRemoteDictionaries.js";
6
+ import { cleanOutputDir } from "./cleanOutputDir.js";
7
+ import "./createDictionaryEntryPoint/index.js";
8
+ import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.js";
9
+ import { DictionaryStatus } from "./writeContentDeclaration/dictionaryStatus.js";
10
+ import { RenderContentDeclarationOptions, RenderedContentDeclaration, formatContentDeclaration, isRenderableContentDeclarationPath, renderContentDeclaration, renderMarkdownContentDeclaration, renderYamlContentDeclaration } from "./writeContentDeclaration/renderContentDeclaration.js";
11
+ import { transformJSFile } from "./writeContentDeclaration/transformJSFile.js";
12
+ import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.js";
13
+ import { writeJSFile } from "./writeContentDeclaration/writeJSFile.js";
14
+ import "./createType/index.js";
15
+ import { formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput } from "./formatDictionary.js";
1
16
  import { BuildDictionariesOptions, addStoredSiblingDictionaries, buildDictionary } from "./buildIntlayerDictionary/buildIntlayerDictionary.js";
2
17
  import { processContentDeclaration } from "./buildIntlayerDictionary/processContentDeclaration.js";
3
18
  import { rebuildUnmergedDictionaries } from "./buildIntlayerDictionary/rebuildUnmergedDictionaries.js";
4
- import "./buildIntlayerDictionary/index.js";
5
- import { cleanOutputDir } from "./cleanOutputDir.js";
19
+ import "./loadDictionaries/index.js";
6
20
  import { CreateDictionaryEntryPointOptions, createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.js";
7
21
  import { generateDictionaryListContent } from "./createDictionaryEntryPoint/generateDictionaryListContent.js";
8
22
  import { getBuiltDictionariesPath } from "./createDictionaryEntryPoint/getBuiltDictionariesPath.js";
@@ -10,25 +24,11 @@ import { getBuiltDynamicDictionariesPath } from "./createDictionaryEntryPoint/ge
10
24
  import { getBuiltFetchDictionariesPath } from "./createDictionaryEntryPoint/getBuiltFetchDictionariesPath.js";
11
25
  import { getBuiltRemoteDictionariesPath } from "./createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.js";
12
26
  import { getBuiltUnmergedDictionariesPath } from "./createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.js";
13
- import "./createDictionaryEntryPoint/index.js";
27
+ import { prepareIntlayer } from "./prepareIntlayer.js";
14
28
  import { createModuleAugmentation, formatDomains, formatRewriteRules, getTypeName } from "./createType/createModuleAugmentation.js";
15
29
  import { createTypes, generateTypeScriptType } from "./createType/createType.js";
16
- import "./createType/index.js";
17
- import { formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput } from "./formatDictionary.js";
18
- import { DictionariesStatus, loadDictionaries } from "./loadDictionaries/loadDictionaries.js";
19
- import { ensureIntlayerBundle, formatLocalDictionaries, loadContentDeclaration, loadContentDeclarations } from "./loadDictionaries/loadContentDeclaration.js";
20
- import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.js";
21
- import { formatDistantDictionaries, loadRemoteDictionaries } from "./loadDictionaries/loadRemoteDictionaries.js";
22
- import "./loadDictionaries/index.js";
23
- import { prepareIntlayer } from "./prepareIntlayer.js";
24
30
  import { INTLAYER_WATCH_ENV_VAR, PrepareIntlayerServerOptions, getIsDevWatcherCommand, getIsServerDevelopment, prepareIntlayerServer } from "./prepareIntlayerServer.js";
25
31
  import { readDictionariesFromDisk } from "./utils/readDictionariesFromDisk.js";
26
32
  import { BuiltEditorOverride, WatchBuiltEditorConfigurationOptions, isCachedConfigurationUpToDate, overrideBuiltEditorConfiguration, watchBuiltEditorConfiguration, writeConfiguration } from "./writeConfiguration/index.js";
27
- import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.js";
28
- import { DictionaryStatus } from "./writeContentDeclaration/dictionaryStatus.js";
29
- import { RenderContentDeclarationOptions, RenderedContentDeclaration, formatContentDeclaration, isRenderableContentDeclarationPath, renderContentDeclaration, renderMarkdownContentDeclaration, renderYamlContentDeclaration } from "./writeContentDeclaration/renderContentDeclaration.js";
30
- import { transformJSFile } from "./writeContentDeclaration/transformJSFile.js";
31
- import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.js";
32
- import { writeJSFile } from "./writeContentDeclaration/writeJSFile.js";
33
33
  import "./writeContentDeclaration/index.js";
34
34
  export { BuildDictionariesOptions, BuiltEditorOverride, CreateDictionaryEntryPointOptions, DictionariesStatus, DictionaryStatus, INTLAYER_WATCH_ENV_VAR, PrepareIntlayerServerOptions, RenderContentDeclarationOptions, RenderedContentDeclaration, WatchBuiltEditorConfigurationOptions, addStoredSiblingDictionaries, buildDictionary, cleanOutputDir, createDictionaryEntryPoint, createModuleAugmentation, createTypes, detectExportedComponentName, ensureIntlayerBundle, formatContentDeclaration, formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput, formatDistantDictionaries, formatDomains, formatLocalDictionaries, formatRewriteRules, generateDictionaryListContent, generateTypeScriptType, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath, getIsDevWatcherCommand, getIsServerDevelopment, getTypeName, isCachedConfigurationUpToDate, isRenderableContentDeclarationPath, loadContentDeclaration, loadContentDeclarations, loadDictionaries, loadLocalDictionaries, loadRemoteDictionaries, overrideBuiltEditorConfiguration, prepareIntlayer, prepareIntlayerServer, processContentDeclaration, readDictionariesFromDisk, rebuildUnmergedDictionaries, renderContentDeclaration, renderMarkdownContentDeclaration, renderYamlContentDeclaration, transformJSFile, watchBuiltEditorConfiguration, writeConfiguration, writeContentDeclaration, writeJSFile };
@@ -1 +1 @@
1
- {"version":3,"file":"buildIntlayerDictionary.d.ts","names":["_$__writeUnmergedDictionary0.UnmergedDictionaryOutput","_$__writeMergedDictionary0.MergedDictionaryOutput"],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"mappings":";;;;;;YAuBY,2BAA2B;EACrC,gBAAgB;EAChB;EACA;;;;;;;qBAcW,+BAA4B,mBACpB,cAAY,eAChB,mBACd;;;;qBAgBU,kBAAe,0BACA,cAAY,eACvB,gBAAc,UACnB,6BAAwB;E,sBAAxBA"}
1
+ {"version":3,"file":"buildIntlayerDictionary.d.ts","names":["_$__writeUnmergedDictionary0.UnmergedDictionaryOutput"],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"mappings":";;;;;;YAuBY,2BAA2B;EACrC,gBAAgB;EAChB;EACA;;;;;;;qBAcW,+BAA4B,mBACpB,cAAY,eAChB,mBACd;;;;qBAgBU,kBAAe,0BACA,cAAY,eACvB,gBAAc,UACnB,6BAAwB;E,sBAAxBA"}
@@ -1,20 +1,16 @@
1
1
  import { detectFormatCommand } from "./detectFormatCommand.js";
2
- import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.js";
3
- import { DictionaryStatus } from "./writeContentDeclaration/dictionaryStatus.js";
4
- import { RenderContentDeclarationOptions, RenderedContentDeclaration, formatContentDeclaration, isRenderableContentDeclarationPath, renderContentDeclaration, renderMarkdownContentDeclaration, renderYamlContentDeclaration } from "./writeContentDeclaration/renderContentDeclaration.js";
5
- import { transformJSFile } from "./writeContentDeclaration/transformJSFile.js";
6
- import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.js";
7
- import { writeJSFile } from "./writeContentDeclaration/writeJSFile.js";
2
+ import "./getContentDeclarationFileTemplate/index.js";
3
+ import { getContentDeclarationFileTemplate } from "./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.js";
8
4
  import { CmsCredentials, enableEditorInConfig, setupCmsCredentials, writeCmsCredentialsToEnv } from "./init/cms.js";
9
5
  import { InitOptions, getDefaultApplicationURL, initIntlayer, logInitSuccessMessage } from "./init/index.js";
10
- import { getContentDeclarationFileTemplate } from "./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.js";
11
- import { UpgradeIntlayerPackagesOptions, UpgradeIntlayerPackagesResult, upgradeIntlayerPackages } from "./init/upgradeIntlayerPackages.js";
12
6
  import { RoutingMode } from "./init/utils/configManipulation.js";
13
- import "./init/utils/index.js";
7
+ import { UpgradeIntlayerPackagesOptions, UpgradeIntlayerPackagesResult, upgradeIntlayerPackages } from "./init/upgradeIntlayerPackages.js";
14
8
  import { DocumentationRouter, DocumentationRouterType, getDocumentationUrl } from "./init/documentationRouter.js";
9
+ import "./init/utils/index.js";
15
10
  import { CATALOG_MESSAGE_FORMATS, CONTENT_FORMATS_BY_LAYOUT, CatalogMessageFormat, ContentFormat, ContentLayout, ContentLayoutSetup, getContentLayoutSetup } from "./init/utils/contentLayout.js";
16
11
  import { NEXT_INTLAYER_BABEL_CONFIG_CONTENT } from "./init/utils/nextCompilerBabel.js";
17
12
  import { COMPAT_I18N_LIBRARIES, CompatI18nLibrary, PackageManager, detectCompatI18nLibraries, detectPackageManager, findLockFileDir, hasLintTooling, installPackages } from "./init/utils/packageManager.js";
13
+ import { PRETTIER_CONFIG_FILES, hasPrettier } from "./init/utils/prettierConfig.js";
18
14
  import { hasUrlRoutingFramework } from "./init/utils/urlRoutingFramework.js";
19
15
  import { installLSP } from "./installLSP.js";
20
16
  import { MCPTransport, MCP_TRANSPORTS, installMCP } from "./installMCP/installMCP.js";
@@ -24,5 +20,11 @@ import { DiffMode, ListGitFilesOptions, ListGitLinesOptions, listGitFiles, listG
24
20
  import { ListProjectsOptions, getGitRootDir, listProjects } from "./listProjects.js";
25
21
  import { logConfigDetails } from "./logConfigDetails.js";
26
22
  import { prepareIntlayer } from "./prepareIntlayer.js";
23
+ import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.js";
24
+ import { DictionaryStatus } from "./writeContentDeclaration/dictionaryStatus.js";
25
+ import { RenderContentDeclarationOptions, RenderedContentDeclaration, formatContentDeclaration, isRenderableContentDeclarationPath, renderContentDeclaration, renderMarkdownContentDeclaration, renderYamlContentDeclaration } from "./writeContentDeclaration/renderContentDeclaration.js";
26
+ import { transformJSFile } from "./writeContentDeclaration/transformJSFile.js";
27
+ import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.js";
28
+ import { writeJSFile } from "./writeContentDeclaration/writeJSFile.js";
27
29
  import "./writeContentDeclaration/index.js";
28
- export { CATALOG_MESSAGE_FORMATS, COMPAT_I18N_LIBRARIES, CONTENT_FORMATS_BY_LAYOUT, CatalogMessageFormat, type CmsCredentials, type CompatI18nLibrary, ContentFormat, ContentLayout, ContentLayoutSetup, DictionaryStatus, DiffMode, DocumentationRouter, type DocumentationRouterType, InitOptions, ListGitFilesOptions, ListGitLinesOptions, ListProjectsOptions, MCPTransport, MCP_TRANSPORTS, NEXT_INTLAYER_BABEL_CONFIG_CONTENT, PLATFORMS, PLATFORMS_METADATA, type PackageManager, Platform, PlatformMetadata, RenderContentDeclarationOptions, RenderedContentDeclaration, type RoutingMode, SKILLS, SKILLS_METADATA, Skill, UpgradeIntlayerPackagesOptions, UpgradeIntlayerPackagesResult, detectCompatI18nLibraries, detectExportedComponentName, detectFormatCommand, detectPackageManager, detectPlatform, enableEditorInConfig, findLockFileDir, formatContentDeclaration, getContentDeclarationFileTemplate, getContentLayoutSetup, getDefaultApplicationURL, getDocumentationUrl, getGitRootDir, getInitialSkills, hasLintTooling, hasUrlRoutingFramework, initIntlayer, installLSP, installMCP, installPackages, installSkills, isRenderableContentDeclarationPath, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, logConfigDetails, logInitSuccessMessage, prepareIntlayer, renderContentDeclaration, renderMarkdownContentDeclaration, renderYamlContentDeclaration, setupCmsCredentials, transformJSFile, upgradeIntlayerPackages, writeCmsCredentialsToEnv, writeContentDeclaration, writeJSFile };
30
+ export { CATALOG_MESSAGE_FORMATS, COMPAT_I18N_LIBRARIES, CONTENT_FORMATS_BY_LAYOUT, CatalogMessageFormat, type CmsCredentials, type CompatI18nLibrary, ContentFormat, ContentLayout, ContentLayoutSetup, DictionaryStatus, DiffMode, DocumentationRouter, type DocumentationRouterType, InitOptions, ListGitFilesOptions, ListGitLinesOptions, ListProjectsOptions, MCPTransport, MCP_TRANSPORTS, NEXT_INTLAYER_BABEL_CONFIG_CONTENT, PLATFORMS, PLATFORMS_METADATA, PRETTIER_CONFIG_FILES, type PackageManager, Platform, PlatformMetadata, RenderContentDeclarationOptions, RenderedContentDeclaration, type RoutingMode, SKILLS, SKILLS_METADATA, Skill, UpgradeIntlayerPackagesOptions, UpgradeIntlayerPackagesResult, detectCompatI18nLibraries, detectExportedComponentName, detectFormatCommand, detectPackageManager, detectPlatform, enableEditorInConfig, findLockFileDir, formatContentDeclaration, getContentDeclarationFileTemplate, getContentLayoutSetup, getDefaultApplicationURL, getDocumentationUrl, getGitRootDir, getInitialSkills, hasLintTooling, hasPrettier, hasUrlRoutingFramework, initIntlayer, installLSP, installMCP, installPackages, installSkills, isRenderableContentDeclarationPath, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, logConfigDetails, logInitSuccessMessage, prepareIntlayer, renderContentDeclaration, renderMarkdownContentDeclaration, renderYamlContentDeclaration, setupCmsCredentials, transformJSFile, upgradeIntlayerPackages, writeCmsCredentialsToEnv, writeContentDeclaration, writeJSFile };
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.d.ts","names":[],"sources":["../../../src/docReview/pipeline.ts"],"mappings":";;YAiBY;;EAEV;;EAEA;;;;;;;;EAQA;;YAGU;EACV,YAAY;EACZ,cAAc;EACd,MAAM;EACN,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA4DP,uBAAkB,UAAA,YAAA,gBAI5B,4BAA0B"}
1
+ {"version":3,"file":"pipeline.d.ts","names":[],"sources":["../../../src/docReview/pipeline.ts"],"mappings":";;YAiBY;;EAEV;;EAEA;;;;;;;;EAQA;;YAGU;EACV,YAAY;EACZ,cAAc;EACd,MAAM;EACN,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA0DP,uBAAkB,UAAA,YAAA,gBAI5B,4BAA0B"}
@@ -46,6 +46,7 @@ export declare const DocumentationRouter: {
46
46
  Default: string;
47
47
  LSP: string;
48
48
  ESLint: string;
49
+ Prettier: string;
49
50
  NextIntl: string;
50
51
  NextI18Next: string;
51
52
  ReactI18Next: string;
@@ -1 +1 @@
1
- {"version":3,"file":"documentationRouter.d.ts","names":[],"sources":["../../../src/init/documentationRouter.ts"],"mappings":";;;qBAGa;EACX;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EAGA;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU,iCAAiC;;;;qBAKhC,sBAAmB"}
1
+ {"version":3,"file":"documentationRouter.d.ts","names":[],"sources":["../../../src/init/documentationRouter.ts"],"mappings":";;;qBAGa;EACX;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EAGA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU,iCAAiC;;;;qBAKhC,sBAAmB"}
@@ -27,6 +27,8 @@ export type InitOptions = {
27
27
  noLsp?: boolean;
28
28
  /** Skip enabling the Intlayer lint rules (ESLint / oxlint). */
29
29
  noEslint?: boolean;
30
+ /** Skip adding the Intlayer Prettier plugin (sorts translation keys). */
31
+ noPrettier?: boolean;
30
32
  /**
31
33
  * Skip the project setup: tsconfig types/aliases, the Intlayer config file,
32
34
  * bundler/framework configs and framework-specific
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/init/index.ts"],"mappings":";;;;;;;;;;qBAmFa,2BAAwB,cACrB;;;;YAgBJ;EACV;;EAEA;;;;;EAKA;;EAEA;;EAEA;;EAEA;;;;;;;EAOA;;EAEA;;;;;;EAMA;;;;;;EAMA,cAAc;;;;;;;EAOd;;;;;;;EAOA,gBAAgB;;;;;EAKhB,gBAAgB;;;;;EAKhB,uBAAuB;;;;;qBAMZ,eAAY,iBAAyB,UAAY,gBAAW;;;qBAylC5D,wBAAqB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/init/index.ts"],"mappings":";;;;;;;;;;qBAyFa,2BAAwB,cACrB;;;;YAgBJ;EACV;;EAEA;;;;;EAKA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;EAOA;;EAEA;;;;;;EAMA;;;;;;EAMA,cAAc;;;;;;;EAOd;;;;;;;EAOA,gBAAgB;;;;;EAKhB,gBAAgB;;;;;EAKhB,uBAAuB;;;;;qBA4GZ,eAAY,iBAAyB,UAAY,gBAAW;;;qBAmmC5D,wBAAqB"}
@@ -8,7 +8,8 @@ import { parseJSONWithComments } from "./jsonParser.js";
8
8
  import { LINT_PLUGIN_PACKAGE_NAME, OxlintConfig, addIntlayerRulesToOxlintConfig } from "./lintConfig.js";
9
9
  import { NEXT_INTLAYER_BABEL_CONFIG_CONTENT, setupNextCompilerBabelConfig } from "./nextCompilerBabel.js";
10
10
  import { COMPAT_I18N_LIBRARIES, COMPAT_PACKAGE_REPLACEMENTS, CompatI18nLibrary, CompatSyncConfig, CompatVitePluginConfig, DetectMissingPackagesOptions, IntlayerPackageAnalysis, MINIMUM_ESLINT_MAJOR, PENDING_COMPAT_ADAPTERS, PackageManager, detectCompatI18nLibraries, detectMissingIntlayerPackages, detectPackageManager, findLockFileDir, hasLegacyEslint, hasLintTooling, installPackages, isIntlayerPackageName, moveCompatPackagesToDevDependencies, normalizeVersion, runPackageInstall } from "./packageManager.js";
11
+ import { JSON_PRETTIER_CONFIG_FILES, PRETTIER_CONFIG_FILES, PRETTIER_PLUGIN_PACKAGE_NAME, PrettierConfig, addIntlayerPluginToPrettierConfig, hasPrettier } from "./prettierConfig.js";
11
12
  import { findTsConfigFiles } from "./tsConfig.js";
12
13
  import { hasUrlRoutingFramework } from "./urlRoutingFramework.js";
13
14
  import { isVersionAtLeast } from "./version.js";
14
- export { BACKEND_INTLAYER_PACKAGES, COMPAT_I18N_LIBRARIES, COMPAT_PACKAGE_REPLACEMENTS, CompatI18nLibrary, CompatSyncConfig, CompatVitePluginConfig, DetectMissingPackagesOptions, GITHUB_FILL_WORKFLOW_PATH, GITHUB_TEST_WORKFLOW_PATH, GithubWorkflowFile, GithubWorkflowsContext, GithubWorkflowsOptions, IntlayerDependency, IntlayerDependencyUpgrade, IntlayerPackageAnalysis, JsonLocalePattern, JsonLocalePatternType, LINT_PLUGIN_PACKAGE_NAME, LinguiCatalogPattern, MINIMUM_ESLINT_MAJOR, NEXT_INTLAYER_BABEL_CONFIG_CONTENT, NextIntlMessagesPattern, OxlintConfig, PENDING_COMPAT_ADAPTERS, PackageJsonIntlayerDependencies, PackageManager, RoutingMode, addIntlayerRulesToOxlintConfig, detectCompatI18nLibraries, detectJsonLocalePattern, detectLinguiCatalogPattern, detectMissingIntlayerPackages, detectNextIntlMessagesPattern, detectPackageManager, enableIntlayerEditorConfig, ensureDirectory, ensureNamedImport, exists, fetchLatestPackageVersion, findLockFileDir, findPackageJsonFiles, findTsConfigFiles, firstInsertIndex, getGithubWorkflows, getIntlayerDependencies, getIntlayerDependencyUpgrades, getMetroConfigTemplate, hasIntlayerVitePlugin, hasLegacyEslint, hasLintTooling, hasUrlRoutingFramework, installPackages, isIntlayerPackageName, isModuleScopeBinding, isVersionAtLeast, listIntlayerDependencies, moveCompatPackagesToDevDependencies, normalizeVersion, parseJSONWithComments, readFileFromRoot, replaceViteConfigPluginImportSource, resolveGithubWorkflowsContext, runPackageInstall, setIntlayerConfigCompilerOutput, setIntlayerConfigDictionaryLocale, setIntlayerConfigEnableProxy, setIntlayerConfigRoutingMode, setIntlayerConfigRoutingStorageOnly, setupNextCompilerBabelConfig, toRange, updateAstroConfig, updateIntlayerConfigWithSyncPlugin, updateMetroConfig, updateNextConfig, updateNextConfigForNextI18next, updateNextConfigForNextIntl, updateNextConfigForNextTranslate, updateNuxtConfig, updateNuxtConfigForNuxtjsI18n, updateViteConfig, updateViteConfigForCompatPlugin, updateViteConfigForVueI18n, writeFileToRoot, writeIntlayerDependencyUpgrades };
15
+ export { BACKEND_INTLAYER_PACKAGES, COMPAT_I18N_LIBRARIES, COMPAT_PACKAGE_REPLACEMENTS, CompatI18nLibrary, CompatSyncConfig, CompatVitePluginConfig, DetectMissingPackagesOptions, GITHUB_FILL_WORKFLOW_PATH, GITHUB_TEST_WORKFLOW_PATH, GithubWorkflowFile, GithubWorkflowsContext, GithubWorkflowsOptions, IntlayerDependency, IntlayerDependencyUpgrade, IntlayerPackageAnalysis, JSON_PRETTIER_CONFIG_FILES, JsonLocalePattern, JsonLocalePatternType, LINT_PLUGIN_PACKAGE_NAME, LinguiCatalogPattern, MINIMUM_ESLINT_MAJOR, NEXT_INTLAYER_BABEL_CONFIG_CONTENT, NextIntlMessagesPattern, OxlintConfig, PENDING_COMPAT_ADAPTERS, PRETTIER_CONFIG_FILES, PRETTIER_PLUGIN_PACKAGE_NAME, PackageJsonIntlayerDependencies, PackageManager, PrettierConfig, RoutingMode, addIntlayerPluginToPrettierConfig, addIntlayerRulesToOxlintConfig, detectCompatI18nLibraries, detectJsonLocalePattern, detectLinguiCatalogPattern, detectMissingIntlayerPackages, detectNextIntlMessagesPattern, detectPackageManager, enableIntlayerEditorConfig, ensureDirectory, ensureNamedImport, exists, fetchLatestPackageVersion, findLockFileDir, findPackageJsonFiles, findTsConfigFiles, firstInsertIndex, getGithubWorkflows, getIntlayerDependencies, getIntlayerDependencyUpgrades, getMetroConfigTemplate, hasIntlayerVitePlugin, hasLegacyEslint, hasLintTooling, hasPrettier, hasUrlRoutingFramework, installPackages, isIntlayerPackageName, isModuleScopeBinding, isVersionAtLeast, listIntlayerDependencies, moveCompatPackagesToDevDependencies, normalizeVersion, parseJSONWithComments, readFileFromRoot, replaceViteConfigPluginImportSource, resolveGithubWorkflowsContext, runPackageInstall, setIntlayerConfigCompilerOutput, setIntlayerConfigDictionaryLocale, setIntlayerConfigEnableProxy, setIntlayerConfigRoutingMode, setIntlayerConfigRoutingStorageOnly, setupNextCompilerBabelConfig, toRange, updateAstroConfig, updateIntlayerConfigWithSyncPlugin, updateMetroConfig, updateNextConfig, updateNextConfigForNextI18next, updateNextConfigForNextIntl, updateNextConfigForNextTranslate, updateNuxtConfig, updateNuxtConfigForNuxtjsI18n, updateViteConfig, updateViteConfigForCompatPlugin, updateViteConfigForVueI18n, writeFileToRoot, writeIntlayerDependencyUpgrades };