@intlayer/chokidar 7.5.11 → 7.5.13

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 (64) hide show
  1. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +2 -0
  2. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
  3. package/dist/cjs/index.cjs +1 -1
  4. package/dist/cjs/init/index.cjs +1 -1
  5. package/dist/cjs/init/index.cjs.map +1 -1
  6. package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
  7. package/dist/cjs/utils/getComponentTransformPattern.cjs +4 -2
  8. package/dist/cjs/utils/getComponentTransformPattern.cjs.map +1 -1
  9. package/dist/cjs/utils/getFormatFromExtension.cjs +3 -0
  10. package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
  11. package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs +21 -17
  12. package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs.map +1 -1
  13. package/dist/cjs/writeContentDeclaration/index.cjs +2 -0
  14. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +77 -0
  15. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -0
  16. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +10 -0
  17. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  18. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +1 -1
  19. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +2 -0
  20. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
  21. package/dist/esm/index.mjs +1 -1
  22. package/dist/esm/init/index.mjs +1 -1
  23. package/dist/esm/init/index.mjs.map +1 -1
  24. package/dist/esm/utils/buildFilesList.mjs.map +1 -1
  25. package/dist/esm/utils/getComponentTransformPattern.mjs +4 -2
  26. package/dist/esm/utils/getComponentTransformPattern.mjs.map +1 -1
  27. package/dist/esm/utils/getFormatFromExtension.mjs +3 -0
  28. package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
  29. package/dist/esm/writeContentDeclaration/detectFormatCommand.mjs +21 -17
  30. package/dist/esm/writeContentDeclaration/detectFormatCommand.mjs.map +1 -1
  31. package/dist/esm/writeContentDeclaration/index.mjs +2 -1
  32. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +76 -0
  33. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -0
  34. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +11 -1
  35. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  36. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +1 -1
  37. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -2
  38. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
  39. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  40. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +3 -3
  41. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  42. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -2
  43. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
  44. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
  45. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
  46. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +2 -2
  47. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
  48. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
  49. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
  50. package/dist/types/formatDictionary.d.ts +15 -15
  51. package/dist/types/index.d.ts +1 -1
  52. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +2 -2
  53. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
  54. package/dist/types/utils/buildFilesList.d.ts.map +1 -1
  55. package/dist/types/utils/getComponentTransformPattern.d.ts.map +1 -1
  56. package/dist/types/utils/getFormatFromExtension.d.ts +2 -2
  57. package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -1
  58. package/dist/types/writeContentDeclaration/detectFormatCommand.d.ts +1 -1
  59. package/dist/types/writeContentDeclaration/detectFormatCommand.d.ts.map +1 -1
  60. package/dist/types/writeContentDeclaration/index.d.ts +2 -1
  61. package/dist/types/writeContentDeclaration/transformJSONFile.d.ts +7 -0
  62. package/dist/types/writeContentDeclaration/transformJSONFile.d.ts.map +1 -0
  63. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
  64. package/package.json +10 -10
@@ -13,6 +13,8 @@ const getContentDeclarationFileTemplate = async (key, format, fileParams = {}) =
13
13
  fileTemplate = "./cjsTemplate.txt";
14
14
  break;
15
15
  case "json":
16
+ case "jsonc":
17
+ case "json5":
16
18
  fileTemplate = "./jsonTemplate.txt";
17
19
  break;
18
20
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"getContentDeclarationFileTemplate.cjs","names":["fileTemplate: string","readAsset","key"],"sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"sourcesContent":["import { readAsset } from 'utils:asset';\nimport { kebabCaseToCamelCase } from '@intlayer/config';\nimport type { Format } from '../utils/getFormatFromExtension';\n\nexport const getContentDeclarationFileTemplate = async (\n key: string,\n format: Format,\n fileParams: Record<string, any> = {}\n) => {\n let fileTemplate: string;\n\n switch (format) {\n case 'ts':\n fileTemplate = './tsTemplate.txt';\n break;\n case 'cjs':\n fileTemplate = './cjsTemplate.txt';\n break;\n case 'json':\n fileTemplate = './jsonTemplate.txt';\n break;\n default:\n fileTemplate = './esmTemplate.txt';\n break;\n }\n\n const fileContent = readAsset(fileTemplate);\n const camelCaseKey = kebabCaseToCamelCase(key);\n const nonCapitalizedCamelCaseKey =\n camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);\n\n const fileParamsString = Object.entries(fileParams)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => {\n const formattedKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key)\n ? key\n : JSON.stringify(key);\n\n if (typeof value === 'object') {\n return `\\n ${formattedKey}: ${JSON.stringify(value)},`;\n }\n\n if (typeof value === 'boolean' || typeof value === 'number') {\n return `\\n ${formattedKey}: ${value},`;\n }\n\n if (typeof value === 'string') {\n return `\\n ${formattedKey}: ${JSON.stringify(value)},`;\n }\n\n return `\\n ${formattedKey}: ${value},`;\n })\n .join('');\n\n return fileContent\n .replace('{{key}}', key)\n .replaceAll('{{name}}', nonCapitalizedCamelCaseKey)\n .replace('{{fileParams}}', fileParamsString);\n};\n"],"mappings":";;;;;AAIA,MAAa,oCAAoC,OAC/C,KACA,QACA,aAAkC,EAAE,KACjC;CACH,IAAIA;AAEJ,SAAQ,QAAR;EACE,KAAK;AACH,kBAAe;AACf;EACF,KAAK;AACH,kBAAe;AACf;EACF,KAAK;AACH,kBAAe;AACf;EACF;AACE,kBAAe;AACf;;CAGJ,MAAM,cAAcC,+BAAU,aAAa;CAC3C,MAAM,0DAAoC,IAAI;CAC9C,MAAM,6BACJ,aAAa,OAAO,EAAE,CAAC,aAAa,GAAG,aAAa,MAAM,EAAE;CAE9D,MAAM,mBAAmB,OAAO,QAAQ,WAAW,CAChD,QAAQ,GAAG,WAAW,UAAU,OAAU,CAC1C,KAAK,CAACC,OAAK,WAAW;EACrB,MAAM,eAAe,6BAA6B,KAAKA,MAAI,GACvDA,QACA,KAAK,UAAUA,MAAI;AAEvB,MAAI,OAAO,UAAU,SACnB,QAAO,OAAO,aAAa,IAAI,KAAK,UAAU,MAAM,CAAC;AAGvD,MAAI,OAAO,UAAU,aAAa,OAAO,UAAU,SACjD,QAAO,OAAO,aAAa,IAAI,MAAM;AAGvC,MAAI,OAAO,UAAU,SACnB,QAAO,OAAO,aAAa,IAAI,KAAK,UAAU,MAAM,CAAC;AAGvD,SAAO,OAAO,aAAa,IAAI,MAAM;GACrC,CACD,KAAK,GAAG;AAEX,QAAO,YACJ,QAAQ,WAAW,IAAI,CACvB,WAAW,YAAY,2BAA2B,CAClD,QAAQ,kBAAkB,iBAAiB"}
1
+ {"version":3,"file":"getContentDeclarationFileTemplate.cjs","names":["fileTemplate: string","readAsset","key"],"sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"sourcesContent":["import { readAsset } from 'utils:asset';\nimport { kebabCaseToCamelCase } from '@intlayer/config';\nimport type { Format } from '../utils/getFormatFromExtension';\n\nexport const getContentDeclarationFileTemplate = async (\n key: string,\n format: Format,\n fileParams: Record<string, any> = {}\n) => {\n let fileTemplate: string;\n\n switch (format) {\n case 'ts':\n fileTemplate = './tsTemplate.txt';\n break;\n case 'cjs':\n fileTemplate = './cjsTemplate.txt';\n break;\n case 'json':\n case 'jsonc':\n case 'json5':\n fileTemplate = './jsonTemplate.txt';\n break;\n default:\n fileTemplate = './esmTemplate.txt';\n break;\n }\n\n const fileContent = readAsset(fileTemplate);\n const camelCaseKey = kebabCaseToCamelCase(key);\n const nonCapitalizedCamelCaseKey =\n camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);\n\n const fileParamsString = Object.entries(fileParams)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => {\n const formattedKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key)\n ? key\n : JSON.stringify(key);\n\n if (typeof value === 'object') {\n return `\\n ${formattedKey}: ${JSON.stringify(value)},`;\n }\n\n if (typeof value === 'boolean' || typeof value === 'number') {\n return `\\n ${formattedKey}: ${value},`;\n }\n\n if (typeof value === 'string') {\n return `\\n ${formattedKey}: ${JSON.stringify(value)},`;\n }\n\n return `\\n ${formattedKey}: ${value},`;\n })\n .join('');\n\n return fileContent\n .replace('{{key}}', key)\n .replaceAll('{{name}}', nonCapitalizedCamelCaseKey)\n .replace('{{fileParams}}', fileParamsString);\n};\n"],"mappings":";;;;;AAIA,MAAa,oCAAoC,OAC/C,KACA,QACA,aAAkC,EAAE,KACjC;CACH,IAAIA;AAEJ,SAAQ,QAAR;EACE,KAAK;AACH,kBAAe;AACf;EACF,KAAK;AACH,kBAAe;AACf;EACF,KAAK;EACL,KAAK;EACL,KAAK;AACH,kBAAe;AACf;EACF;AACE,kBAAe;AACf;;CAGJ,MAAM,cAAcC,+BAAU,aAAa;CAC3C,MAAM,0DAAoC,IAAI;CAC9C,MAAM,6BACJ,aAAa,OAAO,EAAE,CAAC,aAAa,GAAG,aAAa,MAAM,EAAE;CAE9D,MAAM,mBAAmB,OAAO,QAAQ,WAAW,CAChD,QAAQ,GAAG,WAAW,UAAU,OAAU,CAC1C,KAAK,CAACC,OAAK,WAAW;EACrB,MAAM,eAAe,6BAA6B,KAAKA,MAAI,GACvDA,QACA,KAAK,UAAUA,MAAI;AAEvB,MAAI,OAAO,UAAU,SACnB,QAAO,OAAO,aAAa,IAAI,KAAK,UAAU,MAAM,CAAC;AAGvD,MAAI,OAAO,UAAU,aAAa,OAAO,UAAU,SACjD,QAAO,OAAO,aAAa,IAAI,MAAM;AAGvC,MAAI,OAAO,UAAU,SACnB,QAAO,OAAO,aAAa,IAAI,KAAK,UAAU,MAAM,CAAC;AAGvD,SAAO,OAAO,aAAa,IAAI,MAAM;GACrC,CACD,KAAK,GAAG;AAEX,QAAO,YACJ,QAAQ,WAAW,IAAI,CACvB,WAAW,YAAY,2BAA2B,CAClD,QAAQ,kBAAkB,iBAAiB"}
@@ -35,9 +35,9 @@ const require_prepareIntlayer = require('./prepareIntlayer.cjs');
35
35
  const require_reduceDictionaryContent_reduceDictionaryContent = require('./reduceDictionaryContent/reduceDictionaryContent.cjs');
36
36
  const require_writeContentDeclaration_detectExportedComponentName = require('./writeContentDeclaration/detectExportedComponentName.cjs');
37
37
  const require_transformFiles_extractDictionaryKey = require('./transformFiles/extractDictionaryKey.cjs');
38
+ const require_writeContentDeclaration_detectFormatCommand = require('./writeContentDeclaration/detectFormatCommand.cjs');
38
39
  const require_writeContentDeclaration_transformJSFile = require('./writeContentDeclaration/transformJSFile.cjs');
39
40
  const require_utils_getFormatFromExtension = require('./utils/getFormatFromExtension.cjs');
40
- const require_writeContentDeclaration_detectFormatCommand = require('./writeContentDeclaration/detectFormatCommand.cjs');
41
41
  const require_writeContentDeclaration_writeJSFile = require('./writeContentDeclaration/writeJSFile.cjs');
42
42
  const require_writeContentDeclaration_writeContentDeclaration = require('./writeContentDeclaration/writeContentDeclaration.cjs');
43
43
  const require_transformFiles_transformFiles = require('./transformFiles/transformFiles.cjs');
@@ -158,7 +158,7 @@ const initIntlayer = async (rootDir) => {
158
158
  ]) if (await require_init_utils_fileSystem.exists(rootDir, file)) {
159
159
  let content = await require_init_utils_fileSystem.readFileFromRoot(rootDir, file);
160
160
  if (!content.includes("next-intlayer")) {
161
- content = `import { withIntlayer } from 'next-intlayer'; // Add the plugin to the Next.js configuration\n${content}`;
161
+ content = `import { withIntlayer } from 'next-intlayer/server'; // Add the plugin to the Next.js configuration\n${content}`;
162
162
  await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, content);
163
163
  (0, _intlayer_config.logger)(`${_intlayer_config.v} Injected import into ${(0, _intlayer_config.colorizePath)(file)}`);
164
164
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["ANSIColors","exists","x","readFileFromRoot","packageJson: Record<string, any>","writeFileToRoot","v","findTsConfigFiles","parseJSONWithComments","initConfig"],"sources":["../../../src/init/index.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n colorizePath,\n logger,\n v,\n x,\n} from '@intlayer/config';\nimport { initConfig } from '../initConfig';\nimport {\n exists,\n findTsConfigFiles,\n parseJSONWithComments,\n readFileFromRoot,\n writeFileToRoot,\n} from './utils';\n\n/**\n * Documentation URL Constants\n */\nconst DocumentationRouter = {\n NextJS: 'https://intlayer.org/doc/environment/nextjs.md',\n NextJS_15: 'https://intlayer.org/doc/environment/nextjs/15.md',\n NextJS_14: 'https://intlayer.org/doc/environment/nextjs/14.md',\n CRA: 'https://intlayer.org/doc/environment/create-react-app.md',\n Astro: 'https://intlayer.org/doc/environment/astro.md',\n ViteAndReact: 'https://intlayer.org/doc/environment/vite-and-react.md',\n ViteAndReact_ReactRouterV7:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md',\n ViteAndReact_ReactRouterV7_FSRoutes:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md',\n ViteAndVue: 'https://intlayer.org/doc/environment/vite-and-vue.md',\n ViteAndSolid: 'https://intlayer.org/doc/environment/vite-and-solid.md',\n ViteAndSvelte: 'https://intlayer.org/doc/environment/vite-and-svelte.md',\n ViteAndPreact: 'https://intlayer.org/doc/environment/vite-and-preact.md',\n TanStackRouter: 'https://intlayer.org/doc/environment/tanstack.md',\n NuxtAndVue: 'https://intlayer.org/doc/environment/nuxt-and-vue.md',\n Angular: 'https://intlayer.org/doc/environment/angular.md',\n SvelteKit: 'https://intlayer.org/doc/environment/sveltekit.md',\n ReactNativeAndExpo:\n 'https://intlayer.org/doc/environment/react-native-and-expo.md',\n Lynx: 'https://intlayer.org/doc/environment/lynx-and-react.md',\n Express: 'https://intlayer.org/doc/environment/express.md',\n NestJS: 'https://intlayer.org/doc/environment/nestjs.md',\n Fastify: 'https://intlayer.org/doc/environment/fastify.md',\n Default: 'https://intlayer.org/doc/get-started',\n\n // Check for competitors libs\n NextIntl: 'https://intlayer.org/blog/intlayer-with-next-intl.md',\n ReactI18Next: 'https://intlayer.org/blog/intlayer-with-react-i18next.md',\n ReactIntl: 'https://intlayer.org/blog/intlayer-with-react-intl.md',\n NextI18Next: 'https://intlayer.org/blog/intlayer-with-next-i18next.md',\n VueI18n: 'https://intlayer.org/blog/intlayer-with-vue-i18n.md',\n};\n\n/**\n * Helper: Detects the environment and returns the doc URL\n */\nconst getDocumentationUrl = (packageJson: any): string => {\n const deps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n /**\n * Helper to check if a version string matches a specific major version\n * Matches: \"15\", \"^15.0.0\", \"~15.2\", \"15.0.0-beta\"\n */\n const isVersion = (versionString: string, major: number): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const regex = new RegExp(`^[\\\\^~]?${major}(?:\\\\.|$)`);\n return regex.test(versionString);\n };\n\n // Mobile / Cross-platform\n if (deps['@lynx-js/react'] || deps['@lynx-js/core']) {\n return DocumentationRouter.Lynx;\n }\n if (deps['react-native'] || deps['expo']) {\n return DocumentationRouter.ReactNativeAndExpo;\n }\n\n // Meta-frameworks (Next, Nuxt, Astro, SvelteKit)\n if (deps['next']) {\n const version = deps['next'];\n\n if (isVersion(version, 14)) {\n return DocumentationRouter.NextJS_14;\n }\n\n if (isVersion(version, 15)) {\n return DocumentationRouter.NextJS_15;\n }\n\n return DocumentationRouter.NextJS;\n }\n\n if (deps['nuxt']) return DocumentationRouter.NuxtAndVue;\n if (deps['astro']) return DocumentationRouter.Astro;\n if (deps['@sveltejs/kit']) return DocumentationRouter.SvelteKit;\n\n // Routers (TanStack & React Router v7)\n if (deps['@tanstack/react-router']) {\n return DocumentationRouter.TanStackRouter;\n }\n\n // Check for React Router v7\n const reactRouterVersion = deps['react-router'];\n if (reactRouterVersion && typeof reactRouterVersion === 'string') {\n // Distinguish between standard v7 and v7 with FS routes\n if (deps['@react-router/fs-routes']) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7_FSRoutes;\n }\n\n // Use Regex to ensure it is v7\n if (isVersion(reactRouterVersion, 7)) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7;\n }\n }\n\n // Vite Ecosystem (General)\n if (deps['vite']) {\n if (deps['vue']) return DocumentationRouter.ViteAndVue;\n if (deps['solid-js']) return DocumentationRouter.ViteAndSolid;\n if (deps['svelte']) return DocumentationRouter.ViteAndSvelte;\n if (deps['preact']) return DocumentationRouter.ViteAndPreact;\n\n // Default to React if Vite is present but specific other frameworks aren't found\n return DocumentationRouter.ViteAndReact;\n }\n\n // Other Web Frameworks\n if (deps['react-scripts']) return DocumentationRouter.CRA;\n if (deps['@angular/core']) return DocumentationRouter.Angular;\n\n // Backend\n if (deps['@nestjs/core']) return DocumentationRouter.NestJS;\n if (deps['express']) return DocumentationRouter.Express;\n if (deps['fastify']) return DocumentationRouter.Fastify;\n\n // Competitor Libs (Migration Guides)\n // We check these last as specific environment setup is usually higher priority,\n // but if no specific framework logic matched (or as a fallback), we guide to migration.\n if (deps['next-intl']) return DocumentationRouter.NextIntl;\n if (deps['react-i18next'] || deps['i18next'])\n return DocumentationRouter.ReactI18Next;\n if (deps['react-intl']) return DocumentationRouter.ReactIntl;\n if (deps['next-i18next']) return DocumentationRouter.NextI18Next;\n if (deps['vue-i18n']) return DocumentationRouter.VueI18n;\n\n return DocumentationRouter.Default;\n};\n\n/**\n * MAIN LOGIC\n */\nexport const initIntlayer = async (rootDir: string) => {\n logger(colorize('Checking Intlayer configuration...', ANSIColors.CYAN));\n\n // READ PACKAGE.JSON\n const packageJsonPath = 'package.json';\n if (!(await exists(rootDir, packageJsonPath))) {\n logger(\n `${x} No ${colorizePath('package.json')} found. Please run this script from the project root.`,\n { level: 'error' }\n );\n process.exit(1);\n }\n\n const packageJsonContent = await readFileFromRoot(rootDir, packageJsonPath);\n let packageJson: Record<string, any>;\n try {\n packageJson = JSON.parse(packageJsonContent);\n } catch {\n logger(`${x} Could not parse ${colorizePath('package.json')}.`, {\n level: 'error',\n });\n process.exit(1);\n }\n\n // Determine the correct documentation URL based on dependencies\n const guideUrl = getDocumentationUrl(packageJson);\n\n // 2. CHECK .GITIGNORE\n const gitignorePath = '.gitignore';\n if (await exists(rootDir, gitignorePath)) {\n const gitignoreContent = await readFileFromRoot(rootDir, gitignorePath);\n\n if (!gitignoreContent.includes('intlayer')) {\n const newContent = `${gitignoreContent}\\n# Intlayer\\n.intlayer\\n`;\n await writeFileToRoot(rootDir, gitignorePath, newContent);\n logger(\n `${v} Added ${colorizePath('.intlayer')} to ${colorizePath(gitignorePath)}`\n );\n } else {\n logger(`${v} ${colorizePath(gitignorePath)} already includes .intlayer`);\n }\n }\n\n // CHECK TSCONFIGS\n const tsConfigFiles = await findTsConfigFiles(rootDir);\n let hasTsConfig = false;\n\n for (const fileName of tsConfigFiles) {\n if (await exists(rootDir, fileName)) {\n hasTsConfig = true;\n try {\n const fileContent = await readFileFromRoot(rootDir, fileName);\n const config = parseJSONWithComments(fileContent);\n const typeDefinition = '.intlayer/**/*.ts';\n\n let updated = false;\n\n if (!config.include) {\n // Skip if no include array (solution-style)\n } else if (\n Array.isArray(config.include) &&\n !(config.include as string[]).some((pattern: string) =>\n pattern.includes('.intlayer')\n )\n ) {\n config.include.push(typeDefinition);\n updated = true;\n } else if (config.include.includes(typeDefinition)) {\n logger(\n `${v} ${colorizePath(fileName)} already includes intlayer types`\n );\n }\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n fileName,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(fileName)} to include intlayer types`\n );\n }\n } catch {\n logger(\n `${x} Could not parse or update ${colorizePath(fileName)}. You may need to add ${colorizePath('.intlayer/types/**/*.ts')} manually.`,\n { level: 'warn' }\n );\n }\n }\n }\n\n // INITIALIZE CONFIG FILE\n const format = hasTsConfig ? 'intlayer.config.ts' : 'intlayer.config.mjs';\n await initConfig(format, rootDir);\n\n // CHECK VITE CONFIG\n const viteConfigs = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];\n for (const file of viteConfigs) {\n if (await exists(rootDir, file)) {\n let content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('vite-intlayer')) {\n const viteImport =\n \"import { intlayer } from 'vite-intlayer'; // Add the plugin to the Vite plugin list\";\n\n content = `${viteImport}\\n${content}`;\n await writeFileToRoot(rootDir, file, content);\n logger(`${v} Injected import into ${colorizePath(file)}`);\n }\n break;\n }\n }\n\n // CHECK NEXT CONFIG\n const nextConfigs = ['next.config.js', 'next.config.mjs', 'next.config.ts'];\n for (const file of nextConfigs) {\n if (await exists(rootDir, file)) {\n let content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('next-intlayer')) {\n const nextImport =\n \"import { withIntlayer } from 'next-intlayer'; // Add the plugin to the Next.js configuration\";\n\n content = `${nextImport}\\n${content}`;\n await writeFileToRoot(rootDir, file, content);\n logger(`${v} Injected import into ${colorizePath(file)}`);\n }\n break;\n }\n }\n\n // FINAL SUCCESS MESSAGE\n logger(`${v} ${colorize('Intlayer init setup complete.', ANSIColors.GREEN)}`);\n logger([\n colorize('Next →', ANSIColors.MAGENTA),\n colorize(\n `Follow the instructions in the documentation to complete the setup:`,\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(guideUrl),\n ]);\n};\n"],"mappings":";;;;;;;;;;;AAoBA,MAAM,sBAAsB;CAC1B,QAAQ;CACR,WAAW;CACX,WAAW;CACX,KAAK;CACL,OAAO;CACP,cAAc;CACd,4BACE;CACF,qCACE;CACF,YAAY;CACZ,cAAc;CACd,eAAe;CACf,eAAe;CACf,gBAAgB;CAChB,YAAY;CACZ,SAAS;CACT,WAAW;CACX,oBACE;CACF,MAAM;CACN,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CAGT,UAAU;CACV,cAAc;CACd,WAAW;CACX,aAAa;CACb,SAAS;CACV;;;;AAKD,MAAM,uBAAuB,gBAA6B;CACxD,MAAM,OAAO;EACX,GAAG,YAAY;EACf,GAAG,YAAY;EAChB;;;;;CAMD,MAAM,aAAa,eAAuB,UAA2B;AACnE,MAAI,CAAC,iBAAiB,OAAO,kBAAkB,SAAU,QAAO;AAEhE,0BADc,IAAI,OAAO,WAAW,MAAM,WAAW,EACxC,KAAK,cAAc;;AAIlC,KAAI,KAAK,qBAAqB,KAAK,iBACjC,QAAO,oBAAoB;AAE7B,KAAI,KAAK,mBAAmB,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ConfigFiles","parseJSONWithComments","initConfig"],"sources":["../../../src/init/index.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n colorizePath,\n logger,\n v,\n x,\n} from '@intlayer/config';\nimport { initConfig } from '../initConfig';\nimport {\n exists,\n findTsConfigFiles,\n parseJSONWithComments,\n readFileFromRoot,\n writeFileToRoot,\n} from './utils';\n\n/**\n * Documentation URL Constants\n */\nconst DocumentationRouter = {\n NextJS: 'https://intlayer.org/doc/environment/nextjs.md',\n NextJS_15: 'https://intlayer.org/doc/environment/nextjs/15.md',\n NextJS_14: 'https://intlayer.org/doc/environment/nextjs/14.md',\n CRA: 'https://intlayer.org/doc/environment/create-react-app.md',\n Astro: 'https://intlayer.org/doc/environment/astro.md',\n ViteAndReact: 'https://intlayer.org/doc/environment/vite-and-react.md',\n ViteAndReact_ReactRouterV7:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md',\n ViteAndReact_ReactRouterV7_FSRoutes:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md',\n ViteAndVue: 'https://intlayer.org/doc/environment/vite-and-vue.md',\n ViteAndSolid: 'https://intlayer.org/doc/environment/vite-and-solid.md',\n ViteAndSvelte: 'https://intlayer.org/doc/environment/vite-and-svelte.md',\n ViteAndPreact: 'https://intlayer.org/doc/environment/vite-and-preact.md',\n TanStackRouter: 'https://intlayer.org/doc/environment/tanstack.md',\n NuxtAndVue: 'https://intlayer.org/doc/environment/nuxt-and-vue.md',\n Angular: 'https://intlayer.org/doc/environment/angular.md',\n SvelteKit: 'https://intlayer.org/doc/environment/sveltekit.md',\n ReactNativeAndExpo:\n 'https://intlayer.org/doc/environment/react-native-and-expo.md',\n Lynx: 'https://intlayer.org/doc/environment/lynx-and-react.md',\n Express: 'https://intlayer.org/doc/environment/express.md',\n NestJS: 'https://intlayer.org/doc/environment/nestjs.md',\n Fastify: 'https://intlayer.org/doc/environment/fastify.md',\n Default: 'https://intlayer.org/doc/get-started',\n\n // Check for competitors libs\n NextIntl: 'https://intlayer.org/blog/intlayer-with-next-intl.md',\n ReactI18Next: 'https://intlayer.org/blog/intlayer-with-react-i18next.md',\n ReactIntl: 'https://intlayer.org/blog/intlayer-with-react-intl.md',\n NextI18Next: 'https://intlayer.org/blog/intlayer-with-next-i18next.md',\n VueI18n: 'https://intlayer.org/blog/intlayer-with-vue-i18n.md',\n};\n\n/**\n * Helper: Detects the environment and returns the doc URL\n */\nconst getDocumentationUrl = (packageJson: any): string => {\n const deps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n /**\n * Helper to check if a version string matches a specific major version\n * Matches: \"15\", \"^15.0.0\", \"~15.2\", \"15.0.0-beta\"\n */\n const isVersion = (versionString: string, major: number): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const regex = new RegExp(`^[\\\\^~]?${major}(?:\\\\.|$)`);\n return regex.test(versionString);\n };\n\n // Mobile / Cross-platform\n if (deps['@lynx-js/react'] || deps['@lynx-js/core']) {\n return DocumentationRouter.Lynx;\n }\n if (deps['react-native'] || deps['expo']) {\n return DocumentationRouter.ReactNativeAndExpo;\n }\n\n // Meta-frameworks (Next, Nuxt, Astro, SvelteKit)\n if (deps['next']) {\n const version = deps['next'];\n\n if (isVersion(version, 14)) {\n return DocumentationRouter.NextJS_14;\n }\n\n if (isVersion(version, 15)) {\n return DocumentationRouter.NextJS_15;\n }\n\n return DocumentationRouter.NextJS;\n }\n\n if (deps['nuxt']) return DocumentationRouter.NuxtAndVue;\n if (deps['astro']) return DocumentationRouter.Astro;\n if (deps['@sveltejs/kit']) return DocumentationRouter.SvelteKit;\n\n // Routers (TanStack & React Router v7)\n if (deps['@tanstack/react-router']) {\n return DocumentationRouter.TanStackRouter;\n }\n\n // Check for React Router v7\n const reactRouterVersion = deps['react-router'];\n if (reactRouterVersion && typeof reactRouterVersion === 'string') {\n // Distinguish between standard v7 and v7 with FS routes\n if (deps['@react-router/fs-routes']) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7_FSRoutes;\n }\n\n // Use Regex to ensure it is v7\n if (isVersion(reactRouterVersion, 7)) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7;\n }\n }\n\n // Vite Ecosystem (General)\n if (deps['vite']) {\n if (deps['vue']) return DocumentationRouter.ViteAndVue;\n if (deps['solid-js']) return DocumentationRouter.ViteAndSolid;\n if (deps['svelte']) return DocumentationRouter.ViteAndSvelte;\n if (deps['preact']) return DocumentationRouter.ViteAndPreact;\n\n // Default to React if Vite is present but specific other frameworks aren't found\n return DocumentationRouter.ViteAndReact;\n }\n\n // Other Web Frameworks\n if (deps['react-scripts']) return DocumentationRouter.CRA;\n if (deps['@angular/core']) return DocumentationRouter.Angular;\n\n // Backend\n if (deps['@nestjs/core']) return DocumentationRouter.NestJS;\n if (deps['express']) return DocumentationRouter.Express;\n if (deps['fastify']) return DocumentationRouter.Fastify;\n\n // Competitor Libs (Migration Guides)\n // We check these last as specific environment setup is usually higher priority,\n // but if no specific framework logic matched (or as a fallback), we guide to migration.\n if (deps['next-intl']) return DocumentationRouter.NextIntl;\n if (deps['react-i18next'] || deps['i18next'])\n return DocumentationRouter.ReactI18Next;\n if (deps['react-intl']) return DocumentationRouter.ReactIntl;\n if (deps['next-i18next']) return DocumentationRouter.NextI18Next;\n if (deps['vue-i18n']) return DocumentationRouter.VueI18n;\n\n return DocumentationRouter.Default;\n};\n\n/**\n * MAIN LOGIC\n */\nexport const initIntlayer = async (rootDir: string) => {\n logger(colorize('Checking Intlayer configuration...', ANSIColors.CYAN));\n\n // READ PACKAGE.JSON\n const packageJsonPath = 'package.json';\n if (!(await exists(rootDir, packageJsonPath))) {\n logger(\n `${x} No ${colorizePath('package.json')} found. Please run this script from the project root.`,\n { level: 'error' }\n );\n process.exit(1);\n }\n\n const packageJsonContent = await readFileFromRoot(rootDir, packageJsonPath);\n let packageJson: Record<string, any>;\n try {\n packageJson = JSON.parse(packageJsonContent);\n } catch {\n logger(`${x} Could not parse ${colorizePath('package.json')}.`, {\n level: 'error',\n });\n process.exit(1);\n }\n\n // Determine the correct documentation URL based on dependencies\n const guideUrl = getDocumentationUrl(packageJson);\n\n // 2. CHECK .GITIGNORE\n const gitignorePath = '.gitignore';\n if (await exists(rootDir, gitignorePath)) {\n const gitignoreContent = await readFileFromRoot(rootDir, gitignorePath);\n\n if (!gitignoreContent.includes('intlayer')) {\n const newContent = `${gitignoreContent}\\n# Intlayer\\n.intlayer\\n`;\n await writeFileToRoot(rootDir, gitignorePath, newContent);\n logger(\n `${v} Added ${colorizePath('.intlayer')} to ${colorizePath(gitignorePath)}`\n );\n } else {\n logger(`${v} ${colorizePath(gitignorePath)} already includes .intlayer`);\n }\n }\n\n // CHECK TSCONFIGS\n const tsConfigFiles = await findTsConfigFiles(rootDir);\n let hasTsConfig = false;\n\n for (const fileName of tsConfigFiles) {\n if (await exists(rootDir, fileName)) {\n hasTsConfig = true;\n try {\n const fileContent = await readFileFromRoot(rootDir, fileName);\n const config = parseJSONWithComments(fileContent);\n const typeDefinition = '.intlayer/**/*.ts';\n\n let updated = false;\n\n if (!config.include) {\n // Skip if no include array (solution-style)\n } else if (\n Array.isArray(config.include) &&\n !(config.include as string[]).some((pattern: string) =>\n pattern.includes('.intlayer')\n )\n ) {\n config.include.push(typeDefinition);\n updated = true;\n } else if (config.include.includes(typeDefinition)) {\n logger(\n `${v} ${colorizePath(fileName)} already includes intlayer types`\n );\n }\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n fileName,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(fileName)} to include intlayer types`\n );\n }\n } catch {\n logger(\n `${x} Could not parse or update ${colorizePath(fileName)}. You may need to add ${colorizePath('.intlayer/types/**/*.ts')} manually.`,\n { level: 'warn' }\n );\n }\n }\n }\n\n // INITIALIZE CONFIG FILE\n const format = hasTsConfig ? 'intlayer.config.ts' : 'intlayer.config.mjs';\n await initConfig(format, rootDir);\n\n // CHECK VITE CONFIG\n const viteConfigs = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];\n for (const file of viteConfigs) {\n if (await exists(rootDir, file)) {\n let content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('vite-intlayer')) {\n const viteImport =\n \"import { intlayer } from 'vite-intlayer'; // Add the plugin to the Vite plugin list\";\n\n content = `${viteImport}\\n${content}`;\n await writeFileToRoot(rootDir, file, content);\n logger(`${v} Injected import into ${colorizePath(file)}`);\n }\n break;\n }\n }\n\n // CHECK NEXT CONFIG\n const nextConfigs = ['next.config.js', 'next.config.mjs', 'next.config.ts'];\n for (const file of nextConfigs) {\n if (await exists(rootDir, file)) {\n let content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('next-intlayer')) {\n const nextImport =\n \"import { withIntlayer } from 'next-intlayer/server'; // Add the plugin to the Next.js configuration\";\n\n content = `${nextImport}\\n${content}`;\n await writeFileToRoot(rootDir, file, content);\n logger(`${v} Injected import into ${colorizePath(file)}`);\n }\n break;\n }\n }\n\n // FINAL SUCCESS MESSAGE\n logger(`${v} ${colorize('Intlayer init setup complete.', ANSIColors.GREEN)}`);\n logger([\n colorize('Next →', ANSIColors.MAGENTA),\n colorize(\n `Follow the instructions in the documentation to complete the setup:`,\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(guideUrl),\n ]);\n};\n"],"mappings":";;;;;;;;;;;AAoBA,MAAM,sBAAsB;CAC1B,QAAQ;CACR,WAAW;CACX,WAAW;CACX,KAAK;CACL,OAAO;CACP,cAAc;CACd,4BACE;CACF,qCACE;CACF,YAAY;CACZ,cAAc;CACd,eAAe;CACf,eAAe;CACf,gBAAgB;CAChB,YAAY;CACZ,SAAS;CACT,WAAW;CACX,oBACE;CACF,MAAM;CACN,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CAGT,UAAU;CACV,cAAc;CACd,WAAW;CACX,aAAa;CACb,SAAS;CACV;;;;AAKD,MAAM,uBAAuB,gBAA6B;CACxD,MAAM,OAAO;EACX,GAAG,YAAY;EACf,GAAG,YAAY;EAChB;;;;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AAGA,mBAAE,kCAAY,iCAAiCN,4BAAW,MAAM,GAAG;AAC7E,8BAAO;iCACI,UAAUA,4BAAW,QAAQ;iCAEpC,uEACAA,4BAAW,WACZ;qCACY,SAAS;EACvB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildFilesList.cjs","names":["fg"],"sources":["../../../src/utils/buildFilesList.ts"],"sourcesContent":["import { join } from 'node:path';\nimport fg from 'fast-glob';\n\n/**\n * Options for building the files list\n */\nexport type BuildFilesListOptions = {\n /**\n * Glob patterns to match files\n */\n transformPattern: string | string[];\n /**\n * Glob patterns to exclude files\n */\n excludePattern: string | string[];\n /**\n * Base directory for file resolution\n */\n baseDir: string;\n};\n\n/**\n * Adds framework-specific patterns to the existing patterns.\n * If a pattern already includes the framework extension or has a brace expression,\n * it's kept as-is. Otherwise, the extension is added to any existing brace expression.\n *\n * @example\n * addFrameworkPatterns(['src/**\\/*.{ts,tsx}'], 'vue')\n * // Returns: ['src/**\\/*.{ts,tsx,vue}']\n *\n * @example\n * addFrameworkPatterns(['src/**\\/*.vue'], 'vue')\n * // Returns: ['src/**\\/*.vue'] (unchanged, already has .vue)\n */\nconst addFrameworkPatterns = (\n patterns: string[],\n frameworkExtension: string\n): string[] => {\n return patterns.map((pattern) => {\n // If already includes the framework extension, keep as-is\n if (pattern.includes(`.${frameworkExtension}`)) {\n return pattern;\n }\n // If has brace expression, add the extension to it\n if (pattern.includes('{')) {\n return pattern.replace(\n /\\{([^}]+)\\}/,\n (_, exts) => `{${exts},${frameworkExtension}}`\n );\n }\n // No modification needed for patterns without brace expressions\n return pattern;\n });\n};\n\n/**\n * Normalizes a pattern value to an array\n */\nconst normalizeToArray = <T>(value: T | T[]): T[] => {\n return Array.isArray(value) ? value : [value];\n};\n\n/**\n * Builds a list of files matching the given patterns.\n *\n * This utility consolidates the file listing logic used across multiple compilers\n * (Vue, Svelte, Vite) to avoid code duplication.\n *\n * @param options - Configuration options for building the file list\n * @returns Array of absolute file paths matching the patterns\n *\n * @example\n * // Basic usage\n * const files = buildFilesList({\n * transformPattern: 'src/**\\/*.{ts,tsx}',\n * excludePattern: ['**\\/node_modules;\\/**'],\n * baseDir: '/path/to/project',\n * });\n *\n * @example\n * // With framework extension (Vue)\n * const files = buildFilesList({\n * transformPattern: 'src/**\\/*.{ts,tsx}',\n * excludePattern: ['**\\/node_modules\\/**'],\n * baseDir: '/path/to/project',\n * });\n */\nexport const buildFilesList = (options: BuildFilesListOptions): string[] => {\n const { transformPattern, excludePattern, baseDir } = options;\n\n const patterns = normalizeToArray(transformPattern);\n const excludePatterns = normalizeToArray(excludePattern);\n\n const files = fg\n .sync(patterns, {\n cwd: baseDir,\n ignore: excludePatterns,\n })\n .map((file) => join(baseDir, file));\n\n return files;\n};\n"],"mappings":";;;;;;;;;AA0DA,MAAM,oBAAuB,UAAwB;AACnD,QAAO,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/C,MAAa,kBAAkB,YAA6C;CAC1E,MAAM,EAAE,kBAAkB,gBAAgB,YAAY;CAEtD,MAAM,WAAW,iBAAiB,iBAAiB;CACnD,MAAM,kBAAkB,iBAAiB,eAAe;AASxD,QAPcA,kBACX,KAAK,UAAU;EACd,KAAK;EACL,QAAQ;EACT,CAAC,CACD,KAAK,6BAAc,SAAS,KAAK,CAAC"}
1
+ {"version":3,"file":"buildFilesList.cjs","names":["fg"],"sources":["../../../src/utils/buildFilesList.ts"],"sourcesContent":["import { join } from 'node:path';\nimport fg from 'fast-glob';\n\n/**\n * Options for building the files list\n */\nexport type BuildFilesListOptions = {\n /**\n * Glob patterns to match files\n */\n transformPattern: string | string[];\n /**\n * Glob patterns to exclude files\n */\n excludePattern: string | string[];\n /**\n * Base directory for file resolution\n */\n baseDir: string;\n};\n\n/**\n * Normalizes a pattern value to an array\n */\nconst normalizeToArray = <T>(value: T | T[]): T[] => {\n return Array.isArray(value) ? value : [value];\n};\n\n/**\n * Builds a list of files matching the given patterns.\n *\n * This utility consolidates the file listing logic used across multiple compilers\n * (Vue, Svelte, Vite) to avoid code duplication.\n *\n * @param options - Configuration options for building the file list\n * @returns Array of absolute file paths matching the patterns\n *\n * @example\n * // Basic usage\n * const files = buildFilesList({\n * transformPattern: 'src/**\\/*.{ts,tsx}',\n * excludePattern: ['**\\/node_modules;\\/**'],\n * baseDir: '/path/to/project',\n * });\n *\n * @example\n * // With framework extension (Vue)\n * const files = buildFilesList({\n * transformPattern: 'src/**\\/*.{ts,tsx}',\n * excludePattern: ['**\\/node_modules\\/**'],\n * baseDir: '/path/to/project',\n * });\n */\nexport const buildFilesList = (options: BuildFilesListOptions): string[] => {\n const { transformPattern, excludePattern, baseDir } = options;\n\n const patterns = normalizeToArray(transformPattern);\n const excludePatterns = normalizeToArray(excludePattern);\n\n const files = fg\n .sync(patterns, {\n cwd: baseDir,\n ignore: excludePatterns,\n })\n .map((file) => join(baseDir, file));\n\n return files;\n};\n"],"mappings":";;;;;;;;;AAwBA,MAAM,oBAAuB,UAAwB;AACnD,QAAO,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/C,MAAa,kBAAkB,YAA6C;CAC1E,MAAM,EAAE,kBAAkB,gBAAgB,YAAY;CAEtD,MAAM,WAAW,iBAAiB,iBAAiB;CACnD,MAAM,kBAAkB,iBAAiB,eAAe;AASxD,QAPcA,kBACX,KAAK,UAAU;EACd,KAAK;EACL,QAAQ;EACT,CAAC,CACD,KAAK,6BAAc,SAAS,KAAK,CAAC"}
@@ -26,7 +26,8 @@ const getComponentTransformPattern = async (intlayerConfig) => {
26
26
  const { traversePattern } = intlayerConfig.build;
27
27
  const filesListPatternPromises = getDistinctRootDirs([baseDir, ...contentDir]).map((cwd) => (0, fast_glob.default)(traversePattern, {
28
28
  cwd,
29
- absolute: true
29
+ absolute: true,
30
+ dot: true
30
31
  }));
31
32
  const filesList = (await Promise.all(filesListPatternPromises)).flat();
32
33
  return Array.from(new Set(filesList));
@@ -36,7 +37,8 @@ const getComponentTransformPatternSync = (intlayerConfig) => {
36
37
  const { traversePattern } = intlayerConfig.build;
37
38
  const filesList = getDistinctRootDirs([baseDir, ...contentDir]).flatMap((cwd) => fast_glob.default.sync(traversePattern, {
38
39
  cwd,
39
- absolute: true
40
+ absolute: true,
41
+ dot: true
40
42
  }));
41
43
  return Array.from(new Set(filesList));
42
44
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getComponentTransformPattern.cjs","names":["path","fg"],"sources":["../../../src/utils/getComponentTransformPattern.ts"],"sourcesContent":["import path from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * Helper to remove directories that are subdirectories of others in the list.\n * Example: ['/root', '/root/src'] -> ['/root']\n * This prevents scanning the same files twice.\n */\nconst getDistinctRootDirs = (dirs: string[]): string[] => {\n // 1. Resolve to absolute paths and remove exact duplicates\n const uniqueDirs = Array.from(new Set(dirs.map((d) => path.resolve(d))));\n\n // 2. Sort by length (shortest paths first) so parents appear before children\n uniqueDirs.sort((a, b) => a.length - b.length);\n\n // 3. Filter out any directory that is inside a parent already in the accepted list\n return uniqueDirs.reduce((acc: string[], dir) => {\n const isNested = acc.some((parent) => {\n const relative = path.relative(parent, dir);\n return (\n !relative.startsWith('..') && // It is inside the parent\n !path.isAbsolute(relative) && // It is not a different drive/root\n relative !== '' // It is not the parent itself (already handled by Set, but good for safety)\n );\n });\n\n if (!isNested) {\n acc.push(dir);\n }\n return acc;\n }, []);\n};\n\nexport const getComponentTransformPattern = async (\n intlayerConfig: IntlayerConfig\n): Promise<string[]> => {\n const { baseDir, contentDir } = intlayerConfig.content;\n const { traversePattern } = intlayerConfig.build;\n\n // Optimize: Filter out contentDir paths if they are already covered by baseDir\n const distinctRoots = getDistinctRootDirs([baseDir, ...contentDir]);\n\n const filesListPatternPromises = distinctRoots.map((cwd) =>\n fg(traversePattern, {\n cwd,\n absolute: true,\n })\n );\n\n const filesList = (await Promise.all(filesListPatternPromises)).flat();\n\n // Deduplicate files just in case of overlapping patterns or symlinks\n return Array.from(new Set(filesList));\n};\n\nexport const getComponentTransformPatternSync = (\n intlayerConfig: IntlayerConfig\n): string[] => {\n const { baseDir, contentDir } = intlayerConfig.content;\n const { traversePattern } = intlayerConfig.build;\n\n // Optimize: Filter out contentDir paths if they are already covered by baseDir\n const distinctRoots = getDistinctRootDirs([baseDir, ...contentDir]);\n\n const filesList = distinctRoots.flatMap((cwd) =>\n fg.sync(traversePattern, {\n cwd,\n absolute: true,\n })\n );\n\n return Array.from(new Set(filesList));\n};\n"],"mappings":";;;;;;;;;;;;AASA,MAAM,uBAAuB,SAA6B;CAExD,MAAM,aAAa,MAAM,KAAK,IAAI,IAAI,KAAK,KAAK,MAAMA,kBAAK,QAAQ,EAAE,CAAC,CAAC,CAAC;AAGxE,YAAW,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,OAAO;AAG9C,QAAO,WAAW,QAAQ,KAAe,QAAQ;AAU/C,MAAI,CATa,IAAI,MAAM,WAAW;GACpC,MAAM,WAAWA,kBAAK,SAAS,QAAQ,IAAI;AAC3C,UACE,CAAC,SAAS,WAAW,KAAK,IAC1B,CAACA,kBAAK,WAAW,SAAS,IAC1B,aAAa;IAEf,CAGA,KAAI,KAAK,IAAI;AAEf,SAAO;IACN,EAAE,CAAC;;AAGR,MAAa,+BAA+B,OAC1C,mBACsB;CACtB,MAAM,EAAE,SAAS,eAAe,eAAe;CAC/C,MAAM,EAAE,oBAAoB,eAAe;CAK3C,MAAM,2BAFgB,oBAAoB,CAAC,SAAS,GAAG,WAAW,CAAC,CAEpB,KAAK,+BAC/C,iBAAiB;EAClB;EACA,UAAU;EACX,CAAC,CACH;CAED,MAAM,aAAa,MAAM,QAAQ,IAAI,yBAAyB,EAAE,MAAM;AAGtE,QAAO,MAAM,KAAK,IAAI,IAAI,UAAU,CAAC;;AAGvC,MAAa,oCACX,mBACa;CACb,MAAM,EAAE,SAAS,eAAe,eAAe;CAC/C,MAAM,EAAE,oBAAoB,eAAe;CAK3C,MAAM,YAFgB,oBAAoB,CAAC,SAAS,GAAG,WAAW,CAAC,CAEnC,SAAS,QACvCC,kBAAG,KAAK,iBAAiB;EACvB;EACA,UAAU;EACX,CAAC,CACH;AAED,QAAO,MAAM,KAAK,IAAI,IAAI,UAAU,CAAC"}
1
+ {"version":3,"file":"getComponentTransformPattern.cjs","names":["path","fg"],"sources":["../../../src/utils/getComponentTransformPattern.ts"],"sourcesContent":["import path from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * Helper to remove directories that are subdirectories of others in the list.\n * Example: ['/root', '/root/src'] -> ['/root']\n * This prevents scanning the same files twice.\n */\nconst getDistinctRootDirs = (dirs: string[]): string[] => {\n // 1. Resolve to absolute paths and remove exact duplicates\n const uniqueDirs = Array.from(new Set(dirs.map((d) => path.resolve(d))));\n\n // 2. Sort by length (shortest paths first) so parents appear before children\n uniqueDirs.sort((a, b) => a.length - b.length);\n\n // 3. Filter out any directory that is inside a parent already in the accepted list\n return uniqueDirs.reduce((acc: string[], dir) => {\n const isNested = acc.some((parent) => {\n const relative = path.relative(parent, dir);\n return (\n !relative.startsWith('..') && // It is inside the parent\n !path.isAbsolute(relative) && // It is not a different drive/root\n relative !== '' // It is not the parent itself (already handled by Set, but good for safety)\n );\n });\n\n if (!isNested) {\n acc.push(dir);\n }\n return acc;\n }, []);\n};\n\nexport const getComponentTransformPattern = async (\n intlayerConfig: IntlayerConfig\n): Promise<string[]> => {\n const { baseDir, contentDir } = intlayerConfig.content;\n const { traversePattern } = intlayerConfig.build;\n\n // Optimize: Filter out contentDir paths if they are already covered by baseDir\n const distinctRoots = getDistinctRootDirs([baseDir, ...contentDir]);\n\n const filesListPatternPromises = distinctRoots.map((cwd) =>\n fg(traversePattern, {\n cwd,\n absolute: true,\n dot: true,\n })\n );\n\n const filesList = (await Promise.all(filesListPatternPromises)).flat();\n\n // Deduplicate files just in case of overlapping patterns or symlinks\n return Array.from(new Set(filesList));\n};\n\nexport const getComponentTransformPatternSync = (\n intlayerConfig: IntlayerConfig\n): string[] => {\n const { baseDir, contentDir } = intlayerConfig.content;\n const { traversePattern } = intlayerConfig.build;\n\n // Optimize: Filter out contentDir paths if they are already covered by baseDir\n const distinctRoots = getDistinctRootDirs([baseDir, ...contentDir]);\n\n const filesList = distinctRoots.flatMap((cwd) =>\n fg.sync(traversePattern, {\n cwd,\n absolute: true,\n dot: true,\n })\n );\n\n return Array.from(new Set(filesList));\n};\n"],"mappings":";;;;;;;;;;;;AASA,MAAM,uBAAuB,SAA6B;CAExD,MAAM,aAAa,MAAM,KAAK,IAAI,IAAI,KAAK,KAAK,MAAMA,kBAAK,QAAQ,EAAE,CAAC,CAAC,CAAC;AAGxE,YAAW,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,OAAO;AAG9C,QAAO,WAAW,QAAQ,KAAe,QAAQ;AAU/C,MAAI,CATa,IAAI,MAAM,WAAW;GACpC,MAAM,WAAWA,kBAAK,SAAS,QAAQ,IAAI;AAC3C,UACE,CAAC,SAAS,WAAW,KAAK,IAC1B,CAACA,kBAAK,WAAW,SAAS,IAC1B,aAAa;IAEf,CAGA,KAAI,KAAK,IAAI;AAEf,SAAO;IACN,EAAE,CAAC;;AAGR,MAAa,+BAA+B,OAC1C,mBACsB;CACtB,MAAM,EAAE,SAAS,eAAe,eAAe;CAC/C,MAAM,EAAE,oBAAoB,eAAe;CAK3C,MAAM,2BAFgB,oBAAoB,CAAC,SAAS,GAAG,WAAW,CAAC,CAEpB,KAAK,+BAC/C,iBAAiB;EAClB;EACA,UAAU;EACV,KAAK;EACN,CAAC,CACH;CAED,MAAM,aAAa,MAAM,QAAQ,IAAI,yBAAyB,EAAE,MAAM;AAGtE,QAAO,MAAM,KAAK,IAAI,IAAI,UAAU,CAAC;;AAGvC,MAAa,oCACX,mBACa;CACb,MAAM,EAAE,SAAS,eAAe,eAAe;CAC/C,MAAM,EAAE,oBAAoB,eAAe;CAK3C,MAAM,YAFgB,oBAAoB,CAAC,SAAS,GAAG,WAAW,CAAC,CAEnC,SAAS,QACvCC,kBAAG,KAAK,iBAAiB;EACvB;EACA,UAAU;EACV,KAAK;EACN,CAAC,CACH;AAED,QAAO,MAAM,KAAK,IAAI,IAAI,UAAU,CAAC"}
@@ -8,6 +8,7 @@ const getFormatFromExtension = (extension) => {
8
8
  case ".cjsx": return "cjs";
9
9
  case ".mjs": return "esm";
10
10
  case ".json":
11
+ case ".jsonc":
11
12
  case ".json5": return "json";
12
13
  }
13
14
  return "ts";
@@ -17,6 +18,8 @@ const getExtensionFromFormat = (format) => {
17
18
  case "ts": return ".ts";
18
19
  case "cjs": return ".cjs";
19
20
  case "json": return ".json";
21
+ case "jsonc": return ".jsonc";
22
+ case "json5": return ".json5";
20
23
  case "esm": return ".mjs";
21
24
  }
22
25
  return ".ts";
@@ -1 +1 @@
1
- {"version":3,"file":"getFormatFromExtension.cjs","names":[],"sources":["../../../src/utils/getFormatFromExtension.ts"],"sourcesContent":["export type Format = 'ts' | 'cjs' | 'esm' | 'json';\nexport type Extension =\n | '.ts'\n | '.tsx'\n | '.js'\n | '.jsx'\n | '.cjs'\n | '.cjsx'\n | '.mjs'\n | '.mjsx'\n | '.json'\n | '.json5';\n\nexport const getFormatFromExtension = (extension: Extension): Format => {\n switch (extension) {\n case '.ts':\n case '.tsx':\n return 'ts';\n case '.cjs':\n case '.cjsx':\n return 'cjs';\n case '.mjs':\n return 'esm';\n case '.json':\n case '.json5':\n return 'json';\n }\n\n return 'ts';\n};\n\nexport const getExtensionFromFormat = (format: Format): Extension => {\n switch (format) {\n case 'ts':\n return '.ts';\n case 'cjs':\n return '.cjs';\n case 'json':\n return '.json';\n case 'esm':\n return '.mjs';\n }\n\n return '.ts';\n};\n"],"mappings":";;AAaA,MAAa,0BAA0B,cAAiC;AACtE,SAAQ,WAAR;EACE,KAAK;EACL,KAAK,OACH,QAAO;EACT,KAAK;EACL,KAAK,QACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK;EACL,KAAK,SACH,QAAO;;AAGX,QAAO;;AAGT,MAAa,0BAA0B,WAA8B;AACnE,SAAQ,QAAR;EACE,KAAK,KACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,MACH,QAAO;;AAGX,QAAO"}
1
+ {"version":3,"file":"getFormatFromExtension.cjs","names":[],"sources":["../../../src/utils/getFormatFromExtension.ts"],"sourcesContent":["export type Format = 'ts' | 'cjs' | 'esm' | 'json' | 'jsonc' | 'json5';\nexport type Extension =\n | '.ts'\n | '.tsx'\n | '.js'\n | '.jsx'\n | '.cjs'\n | '.cjsx'\n | '.mjs'\n | '.mjsx'\n | '.json'\n | '.jsonc'\n | '.json5';\n\nexport const getFormatFromExtension = (extension: Extension): Format => {\n switch (extension) {\n case '.ts':\n case '.tsx':\n return 'ts';\n case '.cjs':\n case '.cjsx':\n return 'cjs';\n case '.mjs':\n return 'esm';\n case '.json':\n case '.jsonc':\n case '.json5':\n return 'json';\n }\n\n return 'ts';\n};\n\nexport const getExtensionFromFormat = (format: Format): Extension => {\n switch (format) {\n case 'ts':\n return '.ts';\n case 'cjs':\n return '.cjs';\n case 'json':\n return '.json';\n case 'jsonc':\n return '.jsonc';\n case 'json5':\n return '.json5';\n case 'esm':\n return '.mjs';\n }\n\n return '.ts';\n};\n"],"mappings":";;AAcA,MAAa,0BAA0B,cAAiC;AACtE,SAAQ,WAAR;EACE,KAAK;EACL,KAAK,OACH,QAAO;EACT,KAAK;EACL,KAAK,QACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK,SACH,QAAO;;AAGX,QAAO;;AAGT,MAAa,0BAA0B,WAA8B;AACnE,SAAQ,QAAR;EACE,KAAK,KACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,KAAK,MACH,QAAO;;AAGX,QAAO"}
@@ -2,24 +2,28 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  let _intlayer_config = require("@intlayer/config");
3
3
 
4
4
  //#region src/writeContentDeclaration/detectFormatCommand.ts
5
- const detectFormatCommand = (configuration) => {
5
+ let cachedFormatCommand = null;
6
+ const detectFormatCommand = (configuration, projectRequireProp) => {
7
+ const { formatCommand, baseDir } = configuration.content;
8
+ const projectRequire = projectRequireProp ?? (0, _intlayer_config.getProjectRequire)(baseDir);
9
+ if (formatCommand) return formatCommand;
10
+ if (cachedFormatCommand !== null) return cachedFormatCommand;
6
11
  try {
7
- const { formatCommand, baseDir } = configuration.content;
8
- const projectRequire = (0, _intlayer_config.getProjectRequire)(baseDir);
9
- if (formatCommand) return formatCommand;
10
- try {
11
- projectRequire.resolve("prettier");
12
- return "prettier --write \"{{file}}\" --log-level silent";
13
- } catch (_error) {}
14
- try {
15
- projectRequire.resolve("biome");
16
- return "biome format \"{{file}}\" --write --log-level none";
17
- } catch (_error) {}
18
- try {
19
- projectRequire.resolve("eslint");
20
- return "eslint --fix \"{{file}}\" --quiet";
21
- } catch (_error) {}
22
- } catch {}
12
+ projectRequire.resolve("prettier");
13
+ cachedFormatCommand = "prettier --write \"{{file}}\" --log-level silent";
14
+ return cachedFormatCommand;
15
+ } catch (_error) {}
16
+ try {
17
+ projectRequire.resolve("biome");
18
+ cachedFormatCommand = "biome format \"{{file}}\" --write --log-level none";
19
+ return cachedFormatCommand;
20
+ } catch (_error) {}
21
+ try {
22
+ projectRequire.resolve("eslint");
23
+ cachedFormatCommand = "eslint --fix \"{{file}}\" --quiet";
24
+ return cachedFormatCommand;
25
+ } catch (_error) {}
26
+ cachedFormatCommand = void 0;
23
27
  };
24
28
 
25
29
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"detectFormatCommand.cjs","names":[],"sources":["../../../src/writeContentDeclaration/detectFormatCommand.ts"],"sourcesContent":["import { getProjectRequire } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n\nexport const detectFormatCommand = (configuration: IntlayerConfig) => {\n try {\n const { formatCommand, baseDir } = configuration.content;\n const projectRequire = getProjectRequire(baseDir);\n\n if (formatCommand) {\n return formatCommand;\n }\n\n // Try Prettier\n try {\n projectRequire.resolve('prettier');\n\n return 'prettier --write \"{{file}}\" --log-level silent';\n } catch (_error) {\n // Prettier not found, continue to next option\n }\n\n // Try Biome\n try {\n projectRequire.resolve('biome');\n\n return 'biome format \"{{file}}\" --write --log-level none';\n } catch (_error) {\n // Biome not found, continue to next option\n }\n\n // Try ESLint\n try {\n projectRequire.resolve('eslint');\n\n return 'eslint --fix \"{{file}}\" --quiet';\n } catch (_error) {\n // ESLint not found, no formatter available\n }\n } catch {}\n\n // No formatter found\n return undefined;\n};\n"],"mappings":";;;;AAGA,MAAa,uBAAuB,kBAAkC;AACpE,KAAI;EACF,MAAM,EAAE,eAAe,YAAY,cAAc;EACjD,MAAM,yDAAmC,QAAQ;AAEjD,MAAI,cACF,QAAO;AAIT,MAAI;AACF,kBAAe,QAAQ,WAAW;AAElC,UAAO;WACA,QAAQ;AAKjB,MAAI;AACF,kBAAe,QAAQ,QAAQ;AAE/B,UAAO;WACA,QAAQ;AAKjB,MAAI;AACF,kBAAe,QAAQ,SAAS;AAEhC,UAAO;WACA,QAAQ;SAGX"}
1
+ {"version":3,"file":"detectFormatCommand.cjs","names":["cachedFormatCommand: string | undefined | null"],"sources":["../../../src/writeContentDeclaration/detectFormatCommand.ts"],"sourcesContent":["import { getProjectRequire } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n\nlet cachedFormatCommand: string | undefined | null = null;\n\nexport const detectFormatCommand = (\n configuration: IntlayerConfig,\n projectRequireProp?: NodeJS.Require\n) => {\n const { formatCommand, baseDir } = configuration.content;\n const projectRequire = projectRequireProp ?? getProjectRequire(baseDir);\n\n // Priority: Explicit configuration\n // We do not cache this because the user might change their config file active-session.\n if (formatCommand) {\n return formatCommand;\n }\n\n // Priority: Cached detection\n // If not null, we have already performed the expensive checks.\n if (cachedFormatCommand !== null) {\n return cachedFormatCommand;\n }\n\n // Perform Detection\n\n // Try Prettier\n try {\n projectRequire.resolve('prettier');\n cachedFormatCommand = 'prettier --write \"{{file}}\" --log-level silent';\n return cachedFormatCommand;\n } catch (_error) {\n // Prettier not found, continue\n }\n\n // Try Biome\n try {\n projectRequire.resolve('biome');\n cachedFormatCommand = 'biome format \"{{file}}\" --write --log-level none';\n return cachedFormatCommand;\n } catch (_error) {\n // Biome not found, continue\n }\n\n // Try ESLint\n try {\n projectRequire.resolve('eslint');\n cachedFormatCommand = 'eslint --fix \"{{file}}\" --quiet';\n return cachedFormatCommand;\n } catch (_error) {\n // ESLint not found\n }\n\n // No formatter found\n // Set to undefined (not null) so we know we checked and found nothing.\n cachedFormatCommand = undefined;\n return undefined;\n};\n"],"mappings":";;;;AAGA,IAAIA,sBAAiD;AAErD,MAAa,uBACX,eACA,uBACG;CACH,MAAM,EAAE,eAAe,YAAY,cAAc;CACjD,MAAM,iBAAiB,8DAAwC,QAAQ;AAIvE,KAAI,cACF,QAAO;AAKT,KAAI,wBAAwB,KAC1B,QAAO;AAMT,KAAI;AACF,iBAAe,QAAQ,WAAW;AAClC,wBAAsB;AACtB,SAAO;UACA,QAAQ;AAKjB,KAAI;AACF,iBAAe,QAAQ,QAAQ;AAC/B,wBAAsB;AACtB,SAAO;UACA,QAAQ;AAKjB,KAAI;AACF,iBAAe,QAAQ,SAAS;AAChC,wBAAsB;AACtB,SAAO;UACA,QAAQ;AAMjB,uBAAsB"}
@@ -1,9 +1,11 @@
1
1
  const require_writeContentDeclaration_detectExportedComponentName = require('./detectExportedComponentName.cjs');
2
+ const require_writeContentDeclaration_detectFormatCommand = require('./detectFormatCommand.cjs');
2
3
  const require_writeContentDeclaration_transformJSFile = require('./transformJSFile.cjs');
3
4
  const require_writeContentDeclaration_writeJSFile = require('./writeJSFile.cjs');
4
5
  const require_writeContentDeclaration_writeContentDeclaration = require('./writeContentDeclaration.cjs');
5
6
 
6
7
  exports.detectExportedComponentName = require_writeContentDeclaration_detectExportedComponentName.detectExportedComponentName;
8
+ exports.detectFormatCommand = require_writeContentDeclaration_detectFormatCommand.detectFormatCommand;
7
9
  exports.transformJSFile = require_writeContentDeclaration_transformJSFile.transformJSFile;
8
10
  exports.writeContentDeclaration = require_writeContentDeclaration_writeContentDeclaration.writeContentDeclaration;
9
11
  exports.writeJSFile = require_writeContentDeclaration_writeJSFile.writeJSFile;
@@ -0,0 +1,77 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let ts_morph = require("ts-morph");
3
+
4
+ //#region src/writeContentDeclaration/transformJSONFile.ts
5
+ /**
6
+ * Checks if a value is a plain object (and not null/array)
7
+ */
8
+ const isPlainObject = (value) => {
9
+ return typeof value === "object" && value !== null && !Array.isArray(value);
10
+ };
11
+ /**
12
+ * Safely formats a key for use in object literals.
13
+ * Always quotes keys to ensure compatibility with standard JSON files.
14
+ */
15
+ const stringifyKey = (objectKey) => {
16
+ return JSON.stringify(objectKey);
17
+ };
18
+ /**
19
+ * Robustly finds a property in an ObjectLiteralExpression.
20
+ * Handles cases where the property name in the source file is quoted ("key") or unquoted (key).
21
+ */
22
+ const getMatchingProperty = (node, key) => {
23
+ return node.getProperties().find((prop) => {
24
+ if (ts_morph.Node.isPropertyAssignment(prop)) {
25
+ const propName = prop.getName();
26
+ return propName === key || propName === `"${key}"` || propName === `'${key}'`;
27
+ }
28
+ return false;
29
+ });
30
+ };
31
+ /**
32
+ * Recursively updates the AST object literal with new data.
33
+ */
34
+ const updateObjectLiteral = (node, data) => {
35
+ for (const [key, val] of Object.entries(data)) {
36
+ if (val === void 0) continue;
37
+ const stringifiedValue = JSON.stringify(val, null, 2);
38
+ if (stringifiedValue === void 0 && !isPlainObject(val)) continue;
39
+ const existingProp = getMatchingProperty(node, key);
40
+ if (isPlainObject(val)) if (existingProp && ts_morph.Node.isPropertyAssignment(existingProp)) {
41
+ const initializer = existingProp.getInitializer();
42
+ if (ts_morph.Node.isObjectLiteralExpression(initializer)) updateObjectLiteral(initializer, val);
43
+ else existingProp.setInitializer(stringifiedValue);
44
+ } else if (existingProp) existingProp.replaceWithText(`${stringifyKey(key)}: ${stringifiedValue}`);
45
+ else node.addPropertyAssignment({
46
+ name: stringifyKey(key),
47
+ initializer: stringifiedValue
48
+ });
49
+ else if (existingProp && ts_morph.Node.isPropertyAssignment(existingProp)) existingProp.setInitializer(stringifiedValue);
50
+ else if (existingProp) existingProp.replaceWithText(`${stringifyKey(key)}: ${stringifiedValue}`);
51
+ else node.addPropertyAssignment({
52
+ name: stringifyKey(key),
53
+ initializer: stringifiedValue
54
+ });
55
+ }
56
+ };
57
+ const transformJSONFile = (fileContent, dictionary) => {
58
+ const project = new ts_morph.Project({
59
+ useInMemoryFileSystem: true,
60
+ manipulationSettings: {
61
+ indentationText: ts_morph.IndentationText.TwoSpaces,
62
+ quoteKind: ts_morph.QuoteKind.Double
63
+ }
64
+ });
65
+ const dummyFileName = "temp.ts";
66
+ const wrappedContent = `const _config = ${fileContent.trim() || "{}"}`;
67
+ const sourceFile = project.createSourceFile(dummyFileName, wrappedContent);
68
+ const objectLiteral = sourceFile.getVariableDeclaration("_config")?.getInitializerIfKind(ts_morph.SyntaxKind.ObjectLiteralExpression);
69
+ if (!objectLiteral) return JSON.stringify(dictionary, null, 2);
70
+ updateObjectLiteral(objectLiteral, dictionary);
71
+ sourceFile.formatText();
72
+ return objectLiteral.getText();
73
+ };
74
+
75
+ //#endregion
76
+ exports.transformJSONFile = transformJSONFile;
77
+ //# sourceMappingURL=transformJSONFile.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformJSONFile.cjs","names":["Node","Project","IndentationText","QuoteKind","SyntaxKind"],"sources":["../../../src/writeContentDeclaration/transformJSONFile.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types';\nimport {\n IndentationText,\n Node,\n type ObjectLiteralExpression,\n Project,\n QuoteKind,\n SyntaxKind,\n} from 'ts-morph';\n\n/**\n * Checks if a value is a plain object (and not null/array)\n */\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\n/**\n * Safely formats a key for use in object literals.\n * Always quotes keys to ensure compatibility with standard JSON files.\n */\nconst stringifyKey = (objectKey: string): string => {\n return JSON.stringify(objectKey);\n};\n\n/**\n * Robustly finds a property in an ObjectLiteralExpression.\n * Handles cases where the property name in the source file is quoted (\"key\") or unquoted (key).\n */\nconst getMatchingProperty = (node: ObjectLiteralExpression, key: string) => {\n return node.getProperties().find((prop) => {\n // We only care about property assignments (key: value)\n if (Node.isPropertyAssignment(prop)) {\n const propName = prop.getName();\n // Check for strict match (unquoted identifier) or quoted match (string literal)\n // We check both double and single quotes to handle JSONC/JSON5 variations.\n return (\n propName === key || propName === `\"${key}\"` || propName === `'${key}'`\n );\n }\n return false;\n });\n};\n\n/**\n * Recursively updates the AST object literal with new data.\n */\nconst updateObjectLiteral = (\n node: ObjectLiteralExpression,\n data: Record<string, any>\n) => {\n for (const [key, val] of Object.entries(data)) {\n // Skip undefined values.\n if (val === undefined) continue;\n\n const stringifiedValue = JSON.stringify(val, null, 2);\n\n // Safety check: ensure we have a string unless we are recursing into an object\n if (stringifiedValue === undefined && !isPlainObject(val)) continue;\n\n // Use robust lookup instead of node.getProperty(key)\n const existingProp = getMatchingProperty(node, key);\n\n if (isPlainObject(val)) {\n if (existingProp && Node.isPropertyAssignment(existingProp)) {\n const initializer = existingProp.getInitializer();\n\n if (Node.isObjectLiteralExpression(initializer)) {\n // Recurse into nested object\n updateObjectLiteral(initializer, val);\n } else {\n // Property exists but is not an object (e.g. was null or number), overwrite with new object\n existingProp.setInitializer(stringifiedValue!);\n }\n } else if (existingProp) {\n // Property exists but isn't a simple assignment, overwrite it safely\n existingProp.replaceWithText(\n `${stringifyKey(key)}: ${stringifiedValue}`\n );\n } else {\n // Property doesn't exist, add it\n node.addPropertyAssignment({\n name: stringifyKey(key),\n initializer: stringifiedValue!,\n });\n }\n } else {\n // Handling Primitives / Arrays\n if (existingProp && Node.isPropertyAssignment(existingProp)) {\n existingProp.setInitializer(stringifiedValue!);\n } else if (existingProp) {\n existingProp.replaceWithText(\n `${stringifyKey(key)}: ${stringifiedValue}`\n );\n } else {\n node.addPropertyAssignment({\n name: stringifyKey(key),\n initializer: stringifiedValue!,\n });\n }\n }\n }\n};\n\nexport const transformJSONFile = (\n fileContent: string,\n dictionary: Dictionary\n): string => {\n // Initialize a virtual project\n const project = new Project({\n useInMemoryFileSystem: true,\n manipulationSettings: {\n indentationText: IndentationText.TwoSpaces,\n quoteKind: QuoteKind.Double,\n },\n });\n\n // Wrap content in a variable declaration so it acts as a valid SourceFile\n const dummyFileName = 'temp.ts';\n const wrappedContent = `const _config = ${fileContent.trim() || '{}'}`;\n const sourceFile = project.createSourceFile(dummyFileName, wrappedContent);\n\n // Locate the object literal\n const varDecl = sourceFile.getVariableDeclaration('_config');\n const objectLiteral = varDecl?.getInitializerIfKind(\n SyntaxKind.ObjectLiteralExpression\n );\n\n if (!objectLiteral) {\n // Fallback if parsing failed\n return JSON.stringify(dictionary, null, 2);\n }\n\n // Update the AST\n updateObjectLiteral(objectLiteral, dictionary);\n\n // Format text to ensure new properties are aligned\n sourceFile.formatText();\n\n // Extract the object literal text.\n return objectLiteral.getText();\n};\n"],"mappings":";;;;;;;AAaA,MAAM,iBAAiB,UAAqD;AAC1E,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;;;;;AAO7E,MAAM,gBAAgB,cAA8B;AAClD,QAAO,KAAK,UAAU,UAAU;;;;;;AAOlC,MAAM,uBAAuB,MAA+B,QAAgB;AAC1E,QAAO,KAAK,eAAe,CAAC,MAAM,SAAS;AAEzC,MAAIA,cAAK,qBAAqB,KAAK,EAAE;GACnC,MAAM,WAAW,KAAK,SAAS;AAG/B,UACE,aAAa,OAA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,MAAM,EAAE;AAI5C,qBAAoB,eAAe,WAAW;AAG9C,YAAW,YAAY;AAGvB,QAAO,cAAc,SAAS"}
@@ -1,7 +1,9 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_utils_getFormatFromExtension = require('../utils/getFormatFromExtension.cjs');
3
3
  const require_writeContentDeclaration_processContentDeclarationContent = require('./processContentDeclarationContent.cjs');
4
+ const require_writeContentDeclaration_transformJSONFile = require('./transformJSONFile.cjs');
4
5
  const require_writeContentDeclaration_writeJSFile = require('./writeJSFile.cjs');
6
+ let node_fs = require("node:fs");
5
7
  let node_fs_promises = require("node:fs/promises");
6
8
  let node_path = require("node:path");
7
9
  let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
@@ -102,6 +104,14 @@ const writeFileWithDirectories = async (absoluteFilePath, dictionary, configurat
102
104
  await (0, node_fs_promises.writeFile)(absoluteFilePath, `${JSON.stringify(dictionary, null, 2)}\n`);
103
105
  return;
104
106
  }
107
+ if ([".jsonc", ".json5"].includes(extension)) {
108
+ let fileContent = "{}";
109
+ if ((0, node_fs.existsSync)(absoluteFilePath)) try {
110
+ fileContent = await (0, node_fs_promises.readFile)(absoluteFilePath, "utf-8");
111
+ } catch {}
112
+ await (0, node_fs_promises.writeFile)(absoluteFilePath, require_writeContentDeclaration_transformJSONFile.transformJSONFile(fileContent, dictionary), "utf-8");
113
+ return;
114
+ }
105
115
  await require_writeContentDeclaration_writeJSFile.writeJSFile(absoluteFilePath, dictionary, configuration);
106
116
  try {
107
117
  await (0, node_fs_promises.rm)((0, node_path.join)(configuration.content.cacheDir, "intlayer-prepared.lock"), { recursive: true });
@@ -1 +1 @@
1
- {"version":3,"file":"writeContentDeclaration.cjs","names":["processContentDeclarationContent","pluginFormatResult: any","result: Dictionary","getFormatFromExtension","extension","writeJSFile"],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import { mkdir, rm, writeFile } from 'node:fs/promises';\nimport { dirname, extname, join, resolve } from 'node:path';\nimport { isDeepStrictEqual } from 'node:util';\nimport {\n getFilteredLocalesDictionary,\n getPerLocaleDictionary,\n} from '@intlayer/core';\nimport type {\n Dictionary,\n IntlayerConfig,\n Locale,\n LocalesValues,\n} from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport type { DictionaryStatus } from './dictionaryStatus';\nimport { processContentDeclarationContent } from './processContentDeclarationContent';\nimport { writeJSFile } from './writeJSFile';\n\nconst formatContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n localeList?: LocalesValues[]\n) => {\n /**\n * Clean Markdown, Insertion, File, etc. node metadata\n */\n const processedDictionary =\n await processContentDeclarationContent(dictionary);\n\n let content = processedDictionary.content;\n\n /**\n * Filter locales content\n */\n\n if (dictionary.locale) {\n content = getPerLocaleDictionary(\n processedDictionary,\n dictionary.locale\n ).content;\n } else if (localeList) {\n content = getFilteredLocalesDictionary(\n processedDictionary,\n localeList\n ).content;\n }\n\n let pluginFormatResult: any = {\n ...dictionary,\n content,\n } satisfies Dictionary;\n\n /**\n * Format the dictionary with the plugins\n */\n\n for await (const plugin of configuration.plugins ?? []) {\n if (plugin.formatOutput) {\n const formattedResult = await plugin.formatOutput?.({\n dictionary: pluginFormatResult,\n configuration,\n });\n\n if (formattedResult) {\n pluginFormatResult = formattedResult;\n }\n }\n }\n\n const isDictionaryFormat =\n pluginFormatResult.content && pluginFormatResult.key;\n\n if (!isDictionaryFormat) return pluginFormatResult;\n\n let result: Dictionary = {\n key: dictionary.key,\n id: dictionary.id,\n title: dictionary.title,\n description: dictionary.description,\n tags: dictionary.tags,\n locale: dictionary.locale,\n fill: dictionary.fill,\n filled: dictionary.filled,\n priority: dictionary.priority,\n live: dictionary.live,\n version: dictionary.version,\n content,\n };\n\n /**\n * Add $schema to JSON dictionaries\n */\n const extension = (\n dictionary.filePath ? extname(dictionary.filePath) : '.json'\n ) as Extension;\n const format = getFormatFromExtension(extension);\n\n if (\n format === 'json' &&\n pluginFormatResult.content &&\n pluginFormatResult.key\n ) {\n result = {\n $schema: 'https://intlayer.org/schema.json',\n ...result,\n };\n }\n\n return result;\n};\n\ntype WriteContentDeclarationOptions = {\n newDictionariesPath?: string;\n localeList?: LocalesValues[];\n fallbackLocale?: Locale;\n};\n\nconst defaultOptions = {\n newDictionariesPath: 'intlayer-dictionaries',\n} satisfies WriteContentDeclarationOptions;\n\nexport const writeContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n options?: WriteContentDeclarationOptions\n): Promise<{ status: DictionaryStatus; path: string }> => {\n const { content } = configuration;\n const { baseDir } = content;\n const { newDictionariesPath, localeList } = {\n ...defaultOptions,\n ...options,\n };\n\n const newDictionaryLocationPath = join(baseDir, newDictionariesPath);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n const unmergedDictionaries = unmergedDictionariesRecord[\n dictionary.key\n ] as Dictionary[];\n\n const existingDictionary = unmergedDictionaries?.find(\n (el) => el.localId === dictionary.localId\n );\n\n const formattedContentDeclaration = await formatContentDeclaration(\n dictionary,\n configuration,\n localeList\n );\n\n if (existingDictionary?.filePath) {\n // Compare existing dictionary content with new dictionary content\n const isSameContent = isDeepStrictEqual(existingDictionary, dictionary);\n\n const filePath = resolve(\n configuration.content.baseDir,\n existingDictionary.filePath\n );\n\n // Up to date, nothing to do\n if (isSameContent) {\n return {\n status: 'up-to-date',\n path: filePath,\n };\n }\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\n );\n\n return { status: 'updated', path: filePath };\n }\n\n if (dictionary.filePath) {\n const filePath = resolve(\n configuration.content.baseDir,\n dictionary.filePath\n );\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\n );\n\n return { status: 'created', path: filePath };\n }\n\n // No existing dictionary, write to new location\n const contentDeclarationPath = join(\n newDictionaryLocationPath,\n `${dictionary.key}.content.json`\n );\n\n await writeFileWithDirectories(\n contentDeclarationPath,\n formattedContentDeclaration,\n configuration\n );\n\n return {\n status: 'imported',\n path: contentDeclarationPath,\n };\n};\n\nconst writeFileWithDirectories = async (\n absoluteFilePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Promise<void> => {\n // Extract the directory from the file path\n const dir = dirname(absoluteFilePath);\n\n // Create the directory recursively\n await mkdir(dir, { recursive: true });\n\n const extension = extname(absoluteFilePath);\n const acceptedExtensions = configuration.content.fileExtensions.map(\n (extension) => extname(extension)\n );\n\n if (!acceptedExtensions.includes(extension)) {\n throw new Error(\n `Invalid file extension: ${extension}, file: ${absoluteFilePath}`\n );\n }\n\n if (extension === '.json') {\n const jsonDictionary = JSON.stringify(dictionary, null, 2);\n\n // Write the file\n await writeFile(absoluteFilePath, `${jsonDictionary}\\n`); // Add a new line at the end of the file to avoid formatting issues with VSCode\n\n return;\n }\n\n await writeJSFile(absoluteFilePath, dictionary, configuration);\n\n // remove the cache as content has changed\n // Will force a new preparation of the intlayer on next build\n try {\n const sentinelPath = join(\n configuration.content.cacheDir,\n 'intlayer-prepared.lock'\n );\n await rm(sentinelPath, { recursive: true });\n } catch {}\n};\n"],"mappings":";;;;;;;;;;;AAsBA,MAAM,2BAA2B,OAC/B,YACA,eACA,eACG;;;;CAIH,MAAM,sBACJ,MAAMA,kGAAiC,WAAW;CAEpD,IAAI,UAAU,oBAAoB;;;;AAMlC,KAAI,WAAW,OACb,sDACE,qBACA,WAAW,OACZ,CAAC;UACO,WACT,4DACE,qBACA,WACD,CAAC;CAGJ,IAAIC,qBAA0B;EAC5B,GAAG;EACH;EACD;;;;AAMD,YAAW,MAAM,UAAU,cAAc,WAAW,EAAE,CACpD,KAAI,OAAO,cAAc;EACvB,MAAM,kBAAkB,MAAM,OAAO,eAAe;GAClD,YAAY;GACZ;GACD,CAAC;AAEF,MAAI,gBACF,sBAAqB;;AAQ3B,KAAI,E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AAM,yBACJ,wBACA,6BACA,cACD;AAED,QAAO;EACL,QAAQ;EACR,MAAM;EACP;;AAGH,MAAM,2BAA2B,OAC/B,kBACA,YACA,kBACkB;AAKlB,0DAHoB,iBAAiB,EAGpB,EAAE,WAAW,MAAM,CAAC;CAErC,MAAM,mCAAoB,iBAAiB;AAK3C,KAAI,CAJuB,cAAc,QAAQ,eAAe,KAC7D,uCAAsBC,YAAU,CAClC,CAEuB,SAAS,UAAU,CACzC,OAAM,IAAI,MACR,2BAA2B,UAAU,UAAU,mBAChD;AAGH,KAAI,cAAc,SAAS;AAIzB,wCAAgB,kBAAkB,GAHX,KAAK,UAAU,YAAY,MAAM,EAAE,CAGN,IAAI;AAExD;;AAGF,OAAMC,wDAAY,kBAAkB,YAAY,cAAc;AAI9D,KAAI;AAKF,qDAHE,cAAc,QAAQ,UACtB,yBACD,EACsB,EAAE,WAAW,MAAM,CAAC;SACrC"}
1
+ {"version":3,"file":"writeContentDeclaration.cjs","names":["processContentDeclarationContent","pluginFormatResult: any","result: Dictionary","getFormatFromExtension","extension","transformJSONFile","writeJSFile"],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir, readFile, rm, writeFile } from 'node:fs/promises';\nimport { dirname, extname, join, resolve } from 'node:path';\nimport { isDeepStrictEqual } from 'node:util';\nimport {\n getFilteredLocalesDictionary,\n getPerLocaleDictionary,\n} from '@intlayer/core';\nimport type {\n Dictionary,\n IntlayerConfig,\n Locale,\n LocalesValues,\n} from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport type { DictionaryStatus } from './dictionaryStatus';\nimport { processContentDeclarationContent } from './processContentDeclarationContent';\nimport { transformJSONFile } from './transformJSONFile';\nimport { writeJSFile } from './writeJSFile';\n\nconst formatContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n localeList?: LocalesValues[]\n) => {\n /**\n * Clean Markdown, Insertion, File, etc. node metadata\n */\n const processedDictionary =\n await processContentDeclarationContent(dictionary);\n\n let content = processedDictionary.content;\n\n /**\n * Filter locales content\n */\n\n if (dictionary.locale) {\n content = getPerLocaleDictionary(\n processedDictionary,\n dictionary.locale\n ).content;\n } else if (localeList) {\n content = getFilteredLocalesDictionary(\n processedDictionary,\n localeList\n ).content;\n }\n\n let pluginFormatResult: any = {\n ...dictionary,\n content,\n } satisfies Dictionary;\n\n /**\n * Format the dictionary with the plugins\n */\n\n for await (const plugin of configuration.plugins ?? []) {\n if (plugin.formatOutput) {\n const formattedResult = await plugin.formatOutput?.({\n dictionary: pluginFormatResult,\n configuration,\n });\n\n if (formattedResult) {\n pluginFormatResult = formattedResult;\n }\n }\n }\n\n const isDictionaryFormat =\n pluginFormatResult.content && pluginFormatResult.key;\n\n if (!isDictionaryFormat) return pluginFormatResult;\n\n let result: Dictionary = {\n key: dictionary.key,\n id: dictionary.id,\n title: dictionary.title,\n description: dictionary.description,\n tags: dictionary.tags,\n locale: dictionary.locale,\n fill: dictionary.fill,\n filled: dictionary.filled,\n priority: dictionary.priority,\n live: dictionary.live,\n version: dictionary.version,\n content,\n };\n\n /**\n * Add $schema to JSON dictionaries\n */\n const extension = (\n dictionary.filePath ? extname(dictionary.filePath) : '.json'\n ) as Extension;\n const format = getFormatFromExtension(extension);\n\n if (\n format === 'json' &&\n pluginFormatResult.content &&\n pluginFormatResult.key\n ) {\n result = {\n $schema: 'https://intlayer.org/schema.json',\n ...result,\n };\n }\n\n return result;\n};\n\ntype WriteContentDeclarationOptions = {\n newDictionariesPath?: string;\n localeList?: LocalesValues[];\n fallbackLocale?: Locale;\n};\n\nconst defaultOptions = {\n newDictionariesPath: 'intlayer-dictionaries',\n} satisfies WriteContentDeclarationOptions;\n\nexport const writeContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n options?: WriteContentDeclarationOptions\n): Promise<{ status: DictionaryStatus; path: string }> => {\n const { content } = configuration;\n const { baseDir } = content;\n const { newDictionariesPath, localeList } = {\n ...defaultOptions,\n ...options,\n };\n\n const newDictionaryLocationPath = join(baseDir, newDictionariesPath);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n const unmergedDictionaries = unmergedDictionariesRecord[\n dictionary.key\n ] as Dictionary[];\n\n const existingDictionary = unmergedDictionaries?.find(\n (el) => el.localId === dictionary.localId\n );\n\n const formattedContentDeclaration = await formatContentDeclaration(\n dictionary,\n configuration,\n localeList\n );\n\n if (existingDictionary?.filePath) {\n // Compare existing dictionary content with new dictionary content\n const isSameContent = isDeepStrictEqual(existingDictionary, dictionary);\n\n const filePath = resolve(\n configuration.content.baseDir,\n existingDictionary.filePath\n );\n\n // Up to date, nothing to do\n if (isSameContent) {\n return {\n status: 'up-to-date',\n path: filePath,\n };\n }\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\n );\n\n return { status: 'updated', path: filePath };\n }\n\n if (dictionary.filePath) {\n const filePath = resolve(\n configuration.content.baseDir,\n dictionary.filePath\n );\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\n );\n\n return { status: 'created', path: filePath };\n }\n\n // No existing dictionary, write to new location\n const contentDeclarationPath = join(\n newDictionaryLocationPath,\n `${dictionary.key}.content.json`\n );\n\n await writeFileWithDirectories(\n contentDeclarationPath,\n formattedContentDeclaration,\n configuration\n );\n\n return {\n status: 'imported',\n path: contentDeclarationPath,\n };\n};\n\nconst writeFileWithDirectories = async (\n absoluteFilePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Promise<void> => {\n // Extract the directory from the file path\n const dir = dirname(absoluteFilePath);\n\n // Create the directory recursively\n await mkdir(dir, { recursive: true });\n\n const extension = extname(absoluteFilePath);\n const acceptedExtensions = configuration.content.fileExtensions.map(\n (extension) => extname(extension)\n );\n\n if (!acceptedExtensions.includes(extension)) {\n throw new Error(\n `Invalid file extension: ${extension}, file: ${absoluteFilePath}`\n );\n }\n\n if (extension === '.json') {\n const jsonDictionary = JSON.stringify(dictionary, null, 2);\n\n // Write the file\n await writeFile(absoluteFilePath, `${jsonDictionary}\\n`); // Add a new line at the end of the file to avoid formatting issues with VSCode\n\n return;\n }\n\n // Handle JSONC, and JSON5 via the AST transformer\n if (['.jsonc', '.json5'].includes(extension)) {\n let fileContent = '{}';\n\n if (existsSync(absoluteFilePath)) {\n try {\n fileContent = await readFile(absoluteFilePath, 'utf-8');\n } catch {\n // ignore read errors, start with empty object\n }\n }\n\n const transformedContent = transformJSONFile(fileContent, dictionary);\n\n // We use standard writeFile because transformedContent is already a string\n await writeFile(absoluteFilePath, transformedContent, 'utf-8');\n return;\n }\n\n await writeJSFile(absoluteFilePath, dictionary, configuration);\n\n // remove the cache as content has changed\n // Will force a new preparation of the intlayer on next build\n try {\n const sentinelPath = join(\n configuration.content.cacheDir,\n 'intlayer-prepared.lock'\n );\n await rm(sentinelPath, { recursive: true });\n } catch {}\n};\n"],"mappings":";;;;;;;;;;;;;AAwBA,MAAM,2BAA2B,OAC/B,YACA,eACA,eACG;;;;CAIH,MAAM,sBACJ,MAAMA,kGAAiC,WAAW;CAEpD,IAAI,UAAU,oBAAoB;;;;AAMlC,KAAI,WAAW,OACb,sDACE,qBACA,WAAW,OACZ,CAAC;UACO,WACT,4DACE,qBACA,WACD,CAAC;CAGJ,IAAIC,qBAA0B;EAC5B,GAAG;EACH;EACD;;;;AAMD,YAAW,MAAM,UAAU,cAAc,WAAW,EAAE,CACpD,KAAI,OAAO,cAAc;EACvB,MAAM,kBAAkB,MAAM,OAAO,eAAe;GAClD,YAAY;GACZ;GACD,CAAC;AAEF,MAAI,gBACF,sBAAqB;;AAQ3B,KAAI,EAFF,mBAAmB,WAAW,mBAAmB,KAE1B,QAAO;CAEhC,IAAIC,SAAqB;EACvB,KAAK,WAAW;EAChB,IAAI,WAAW;EACf,OAAO,WAAW;EAClB,aAAa,WAAW;EACxB,M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GpB,EAAE,WAAW,MAAM,CAAC;CAErC,MAAM,mCAAoB,iBAAiB;AAK3C,KAAI,CAJuB,cAAc,QAAQ,eAAe,KAC7D,uCAAsBC,YAAU,CAClC,CAEuB,SAAS,UAAU,CACzC,OAAM,IAAI,MACR,2BAA2B,UAAU,UAAU,mBAChD;AAGH,KAAI,cAAc,SAAS;AAIzB,wCAAgB,kBAAkB,GAHX,KAAK,UAAU,YAAY,MAAM,EAAE,CAGN,IAAI;AAExD;;AAIF,KAAI,CAAC,UAAU,SAAS,CAAC,SAAS,UAAU,EAAE;EAC5C,IAAI,cAAc;AAElB,8BAAe,iBAAiB,CAC9B,KAAI;AACF,iBAAc,qCAAe,kBAAkB,QAAQ;UACjD;AAQV,wCAAgB,kBAHWC,oEAAkB,aAAa,WAAW,EAGf,QAAQ;AAC9D;;AAGF,OAAMC,wDAAY,kBAAkB,YAAY,cAAc;AAI9D,KAAI;AAKF,qDAHE,cAAc,QAAQ,UACtB,yBACD,EACsB,EAAE,WAAW,MAAM,CAAC;SACrC"}
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_getContentDeclarationFileTemplate_getContentDeclarationFileTemplate = require('../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs');
3
+ const require_writeContentDeclaration_detectFormatCommand = require('./detectFormatCommand.cjs');
3
4
  const require_writeContentDeclaration_transformJSFile = require('./transformJSFile.cjs');
4
5
  const require_utils_getFormatFromExtension = require('../utils/getFormatFromExtension.cjs');
5
- const require_writeContentDeclaration_detectFormatCommand = require('./detectFormatCommand.cjs');
6
6
  let node_fs = require("node:fs");
7
7
  let node_fs_promises = require("node:fs/promises");
8
8
  let node_path = require("node:path");
@@ -12,6 +12,8 @@ const getContentDeclarationFileTemplate = async (key, format, fileParams = {}) =
12
12
  fileTemplate = "./cjsTemplate.txt";
13
13
  break;
14
14
  case "json":
15
+ case "jsonc":
16
+ case "json5":
15
17
  fileTemplate = "./jsonTemplate.txt";
16
18
  break;
17
19
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"getContentDeclarationFileTemplate.mjs","names":["fileTemplate: string","key"],"sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"sourcesContent":["import { readAsset } from 'utils:asset';\nimport { kebabCaseToCamelCase } from '@intlayer/config';\nimport type { Format } from '../utils/getFormatFromExtension';\n\nexport const getContentDeclarationFileTemplate = async (\n key: string,\n format: Format,\n fileParams: Record<string, any> = {}\n) => {\n let fileTemplate: string;\n\n switch (format) {\n case 'ts':\n fileTemplate = './tsTemplate.txt';\n break;\n case 'cjs':\n fileTemplate = './cjsTemplate.txt';\n break;\n case 'json':\n fileTemplate = './jsonTemplate.txt';\n break;\n default:\n fileTemplate = './esmTemplate.txt';\n break;\n }\n\n const fileContent = readAsset(fileTemplate);\n const camelCaseKey = kebabCaseToCamelCase(key);\n const nonCapitalizedCamelCaseKey =\n camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);\n\n const fileParamsString = Object.entries(fileParams)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => {\n const formattedKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key)\n ? key\n : JSON.stringify(key);\n\n if (typeof value === 'object') {\n return `\\n ${formattedKey}: ${JSON.stringify(value)},`;\n }\n\n if (typeof value === 'boolean' || typeof value === 'number') {\n return `\\n ${formattedKey}: ${value},`;\n }\n\n if (typeof value === 'string') {\n return `\\n ${formattedKey}: ${JSON.stringify(value)},`;\n }\n\n return `\\n ${formattedKey}: ${value},`;\n })\n .join('');\n\n return fileContent\n .replace('{{key}}', key)\n .replaceAll('{{name}}', nonCapitalizedCamelCaseKey)\n .replace('{{fileParams}}', fileParamsString);\n};\n"],"mappings":";;;;AAIA,MAAa,oCAAoC,OAC/C,KACA,QACA,aAAkC,EAAE,KACjC;CACH,IAAIA;AAEJ,SAAQ,QAAR;EACE,KAAK;AACH,kBAAe;AACf;EACF,KAAK;AACH,kBAAe;AACf;EACF,KAAK;AACH,kBAAe;AACf;EACF;AACE,kBAAe;AACf;;CAGJ,MAAM,cAAc,UAAU,aAAa;CAC3C,MAAM,eAAe,qBAAqB,IAAI;CAC9C,MAAM,6BACJ,aAAa,OAAO,EAAE,CAAC,aAAa,GAAG,aAAa,MAAM,EAAE;CAE9D,MAAM,mBAAmB,OAAO,QAAQ,WAAW,CAChD,QAAQ,GAAG,WAAW,UAAU,OAAU,CAC1C,KAAK,CAACC,OAAK,WAAW;EACrB,MAAM,eAAe,6BAA6B,KAAKA,MAAI,GACvDA,QACA,KAAK,UAAUA,MAAI;AAEvB,MAAI,OAAO,UAAU,SACnB,QAAO,OAAO,aAAa,IAAI,KAAK,UAAU,MAAM,CAAC;AAGvD,MAAI,OAAO,UAAU,aAAa,OAAO,UAAU,SACjD,QAAO,OAAO,aAAa,IAAI,MAAM;AAGvC,MAAI,OAAO,UAAU,SACnB,QAAO,OAAO,aAAa,IAAI,KAAK,UAAU,MAAM,CAAC;AAGvD,SAAO,OAAO,aAAa,IAAI,MAAM;GACrC,CACD,KAAK,GAAG;AAEX,QAAO,YACJ,QAAQ,WAAW,IAAI,CACvB,WAAW,YAAY,2BAA2B,CAClD,QAAQ,kBAAkB,iBAAiB"}
1
+ {"version":3,"file":"getContentDeclarationFileTemplate.mjs","names":["fileTemplate: string","key"],"sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"sourcesContent":["import { readAsset } from 'utils:asset';\nimport { kebabCaseToCamelCase } from '@intlayer/config';\nimport type { Format } from '../utils/getFormatFromExtension';\n\nexport const getContentDeclarationFileTemplate = async (\n key: string,\n format: Format,\n fileParams: Record<string, any> = {}\n) => {\n let fileTemplate: string;\n\n switch (format) {\n case 'ts':\n fileTemplate = './tsTemplate.txt';\n break;\n case 'cjs':\n fileTemplate = './cjsTemplate.txt';\n break;\n case 'json':\n case 'jsonc':\n case 'json5':\n fileTemplate = './jsonTemplate.txt';\n break;\n default:\n fileTemplate = './esmTemplate.txt';\n break;\n }\n\n const fileContent = readAsset(fileTemplate);\n const camelCaseKey = kebabCaseToCamelCase(key);\n const nonCapitalizedCamelCaseKey =\n camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);\n\n const fileParamsString = Object.entries(fileParams)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => {\n const formattedKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key)\n ? key\n : JSON.stringify(key);\n\n if (typeof value === 'object') {\n return `\\n ${formattedKey}: ${JSON.stringify(value)},`;\n }\n\n if (typeof value === 'boolean' || typeof value === 'number') {\n return `\\n ${formattedKey}: ${value},`;\n }\n\n if (typeof value === 'string') {\n return `\\n ${formattedKey}: ${JSON.stringify(value)},`;\n }\n\n return `\\n ${formattedKey}: ${value},`;\n })\n .join('');\n\n return fileContent\n .replace('{{key}}', key)\n .replaceAll('{{name}}', nonCapitalizedCamelCaseKey)\n .replace('{{fileParams}}', fileParamsString);\n};\n"],"mappings":";;;;AAIA,MAAa,oCAAoC,OAC/C,KACA,QACA,aAAkC,EAAE,KACjC;CACH,IAAIA;AAEJ,SAAQ,QAAR;EACE,KAAK;AACH,kBAAe;AACf;EACF,KAAK;AACH,kBAAe;AACf;EACF,KAAK;EACL,KAAK;EACL,KAAK;AACH,kBAAe;AACf;EACF;AACE,kBAAe;AACf;;CAGJ,MAAM,cAAc,UAAU,aAAa;CAC3C,MAAM,eAAe,qBAAqB,IAAI;CAC9C,MAAM,6BACJ,aAAa,OAAO,EAAE,CAAC,aAAa,GAAG,aAAa,MAAM,EAAE;CAE9D,MAAM,mBAAmB,OAAO,QAAQ,WAAW,CAChD,QAAQ,GAAG,WAAW,UAAU,OAAU,CAC1C,KAAK,CAACC,OAAK,WAAW;EACrB,MAAM,eAAe,6BAA6B,KAAKA,MAAI,GACvDA,QACA,KAAK,UAAUA,MAAI;AAEvB,MAAI,OAAO,UAAU,SACnB,QAAO,OAAO,aAAa,IAAI,KAAK,UAAU,MAAM,CAAC;AAGvD,MAAI,OAAO,UAAU,aAAa,OAAO,UAAU,SACjD,QAAO,OAAO,aAAa,IAAI,MAAM;AAGvC,MAAI,OAAO,UAAU,SACnB,QAAO,OAAO,aAAa,IAAI,KAAK,UAAU,MAAM,CAAC;AAGvD,SAAO,OAAO,aAAa,IAAI,MAAM;GACrC,CACD,KAAK,GAAG;AAEX,QAAO,YACJ,QAAQ,WAAW,IAAI,CACvB,WAAW,YAAY,2BAA2B,CAClD,QAAQ,kBAAkB,iBAAiB"}
@@ -35,9 +35,9 @@ import { prepareIntlayer } from "./prepareIntlayer.mjs";
35
35
  import { reduceDictionaryContent } from "./reduceDictionaryContent/reduceDictionaryContent.mjs";
36
36
  import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.mjs";
37
37
  import { extractDictionaryKey } from "./transformFiles/extractDictionaryKey.mjs";
38
+ import { detectFormatCommand } from "./writeContentDeclaration/detectFormatCommand.mjs";
38
39
  import { transformJSFile } from "./writeContentDeclaration/transformJSFile.mjs";
39
40
  import { getExtensionFromFormat, getFormatFromExtension } from "./utils/getFormatFromExtension.mjs";
40
- import { detectFormatCommand } from "./writeContentDeclaration/detectFormatCommand.mjs";
41
41
  import { writeJSFile } from "./writeContentDeclaration/writeJSFile.mjs";
42
42
  import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.mjs";
43
43
  import { ATTRIBUTES_TO_EXTRACT, extractIntlayer, generateKey, shouldExtract, transformFiles } from "./transformFiles/transformFiles.mjs";
@@ -157,7 +157,7 @@ const initIntlayer = async (rootDir) => {
157
157
  ]) if (await exists(rootDir, file)) {
158
158
  let content = await readFileFromRoot(rootDir, file);
159
159
  if (!content.includes("next-intlayer")) {
160
- content = `import { withIntlayer } from 'next-intlayer'; // Add the plugin to the Next.js configuration\n${content}`;
160
+ content = `import { withIntlayer } from 'next-intlayer/server'; // Add the plugin to the Next.js configuration\n${content}`;
161
161
  await writeFileToRoot(rootDir, file, content);
162
162
  logger(`${v} Injected import into ${colorizePath(file)}`);
163
163
  }