@intlayer/chokidar 7.5.10 → 7.5.12

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 (46) hide show
  1. package/dist/cjs/index.cjs +2 -0
  2. package/dist/cjs/init/index.cjs +101 -2
  3. package/dist/cjs/init/index.cjs.map +1 -1
  4. package/dist/cjs/listDictionariesPath.cjs +16 -1
  5. package/dist/cjs/listDictionariesPath.cjs.map +1 -1
  6. package/dist/cjs/listProjects.cjs +47 -0
  7. package/dist/cjs/listProjects.cjs.map +1 -0
  8. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +4 -13
  9. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  10. package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
  11. package/dist/cjs/utils/getComponentTransformPattern.cjs +4 -2
  12. package/dist/cjs/utils/getComponentTransformPattern.cjs.map +1 -1
  13. package/dist/esm/index.mjs +2 -1
  14. package/dist/esm/init/index.mjs +101 -2
  15. package/dist/esm/init/index.mjs.map +1 -1
  16. package/dist/esm/listDictionariesPath.mjs +16 -1
  17. package/dist/esm/listDictionariesPath.mjs.map +1 -1
  18. package/dist/esm/listProjects.mjs +44 -0
  19. package/dist/esm/listProjects.mjs.map +1 -0
  20. package/dist/esm/loadDictionaries/loadDictionaries.mjs +4 -13
  21. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  22. package/dist/esm/utils/buildFilesList.mjs.map +1 -1
  23. package/dist/esm/utils/getComponentTransformPattern.mjs +4 -2
  24. package/dist/esm/utils/getComponentTransformPattern.mjs.map +1 -1
  25. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -2
  26. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  27. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
  28. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  29. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +3 -3
  30. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  31. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -2
  32. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
  33. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +2 -2
  34. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
  35. package/dist/types/formatDictionary.d.ts +15 -15
  36. package/dist/types/index.d.ts +2 -1
  37. package/dist/types/init/index.d.ts.map +1 -1
  38. package/dist/types/listDictionariesPath.d.ts.map +1 -1
  39. package/dist/types/listProjects.d.ts +26 -0
  40. package/dist/types/listProjects.d.ts.map +1 -0
  41. package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
  42. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +2 -2
  43. package/dist/types/utils/buildFilesList.d.ts.map +1 -1
  44. package/dist/types/utils/chunkJSON.d.ts.map +1 -1
  45. package/dist/types/utils/getComponentTransformPattern.d.ts.map +1 -1
  46. package/package.json +10 -10
@@ -26,6 +26,7 @@ const require_handleUnlinkedContentDeclarationFile = require('./handleUnlinkedCo
26
26
  const require_getContentDeclarationFileTemplate_getContentDeclarationFileTemplate = require('./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs');
27
27
  const require_init_index = require('./init/index.cjs');
28
28
  const require_listGitFiles = require('./listGitFiles.cjs');
29
+ const require_listProjects = require('./listProjects.cjs');
29
30
  const require_utils_sortAlphabetically = require('./utils/sortAlphabetically.cjs');
30
31
  const require_loadDictionaries_loadRemoteDictionaries = require('./loadDictionaries/loadRemoteDictionaries.cjs');
31
32
  const require_loadDictionaries_loadDictionaries = require('./loadDictionaries/loadDictionaries.cjs');
@@ -97,6 +98,7 @@ exports.listDictionaries = require_listDictionariesPath.listDictionaries;
97
98
  exports.listDictionariesWithStats = require_listDictionariesPath.listDictionariesWithStats;
98
99
  exports.listGitFiles = require_listGitFiles.listGitFiles;
99
100
  exports.listGitLines = require_listGitFiles.listGitLines;
101
+ exports.listProjects = require_listProjects.listProjects;
100
102
  exports.loadContentDeclarations = require_loadDictionaries_loadContentDeclaration.loadContentDeclarations;
101
103
  exports.loadDictionaries = require_loadDictionaries_loadDictionaries.loadDictionaries;
102
104
  exports.loadLocalDictionaries = require_loadDictionaries_loadLocalDictionaries.loadLocalDictionaries;
@@ -7,14 +7,108 @@ let _intlayer_config = require("@intlayer/config");
7
7
 
8
8
  //#region src/init/index.ts
9
9
  /**
10
+ * Documentation URL Constants
11
+ */
12
+ const DocumentationRouter = {
13
+ NextJS: "https://intlayer.org/doc/environment/nextjs.md",
14
+ NextJS_15: "https://intlayer.org/doc/environment/nextjs/15.md",
15
+ NextJS_14: "https://intlayer.org/doc/environment/nextjs/14.md",
16
+ CRA: "https://intlayer.org/doc/environment/create-react-app.md",
17
+ Astro: "https://intlayer.org/doc/environment/astro.md",
18
+ ViteAndReact: "https://intlayer.org/doc/environment/vite-and-react.md",
19
+ ViteAndReact_ReactRouterV7: "https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md",
20
+ ViteAndReact_ReactRouterV7_FSRoutes: "https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md",
21
+ ViteAndVue: "https://intlayer.org/doc/environment/vite-and-vue.md",
22
+ ViteAndSolid: "https://intlayer.org/doc/environment/vite-and-solid.md",
23
+ ViteAndSvelte: "https://intlayer.org/doc/environment/vite-and-svelte.md",
24
+ ViteAndPreact: "https://intlayer.org/doc/environment/vite-and-preact.md",
25
+ TanStackRouter: "https://intlayer.org/doc/environment/tanstack.md",
26
+ NuxtAndVue: "https://intlayer.org/doc/environment/nuxt-and-vue.md",
27
+ Angular: "https://intlayer.org/doc/environment/angular.md",
28
+ SvelteKit: "https://intlayer.org/doc/environment/sveltekit.md",
29
+ ReactNativeAndExpo: "https://intlayer.org/doc/environment/react-native-and-expo.md",
30
+ Lynx: "https://intlayer.org/doc/environment/lynx-and-react.md",
31
+ Express: "https://intlayer.org/doc/environment/express.md",
32
+ NestJS: "https://intlayer.org/doc/environment/nestjs.md",
33
+ Fastify: "https://intlayer.org/doc/environment/fastify.md",
34
+ Default: "https://intlayer.org/doc/get-started",
35
+ NextIntl: "https://intlayer.org/blog/intlayer-with-next-intl.md",
36
+ ReactI18Next: "https://intlayer.org/blog/intlayer-with-react-i18next.md",
37
+ ReactIntl: "https://intlayer.org/blog/intlayer-with-react-intl.md",
38
+ NextI18Next: "https://intlayer.org/blog/intlayer-with-next-i18next.md",
39
+ VueI18n: "https://intlayer.org/blog/intlayer-with-vue-i18n.md"
40
+ };
41
+ /**
42
+ * Helper: Detects the environment and returns the doc URL
43
+ */
44
+ const getDocumentationUrl = (packageJson) => {
45
+ const deps = {
46
+ ...packageJson.dependencies,
47
+ ...packageJson.devDependencies
48
+ };
49
+ /**
50
+ * Helper to check if a version string matches a specific major version
51
+ * Matches: "15", "^15.0.0", "~15.2", "15.0.0-beta"
52
+ */
53
+ const isVersion = (versionString, major) => {
54
+ if (!versionString || typeof versionString !== "string") return false;
55
+ return (/* @__PURE__ */ new RegExp(`^[\\^~]?${major}(?:\\.|$)`)).test(versionString);
56
+ };
57
+ if (deps["@lynx-js/react"] || deps["@lynx-js/core"]) return DocumentationRouter.Lynx;
58
+ if (deps["react-native"] || deps["expo"]) return DocumentationRouter.ReactNativeAndExpo;
59
+ if (deps["next"]) {
60
+ const version = deps["next"];
61
+ if (isVersion(version, 14)) return DocumentationRouter.NextJS_14;
62
+ if (isVersion(version, 15)) return DocumentationRouter.NextJS_15;
63
+ return DocumentationRouter.NextJS;
64
+ }
65
+ if (deps["nuxt"]) return DocumentationRouter.NuxtAndVue;
66
+ if (deps["astro"]) return DocumentationRouter.Astro;
67
+ if (deps["@sveltejs/kit"]) return DocumentationRouter.SvelteKit;
68
+ if (deps["@tanstack/react-router"]) return DocumentationRouter.TanStackRouter;
69
+ const reactRouterVersion = deps["react-router"];
70
+ if (reactRouterVersion && typeof reactRouterVersion === "string") {
71
+ if (deps["@react-router/fs-routes"]) return DocumentationRouter.ViteAndReact_ReactRouterV7_FSRoutes;
72
+ if (isVersion(reactRouterVersion, 7)) return DocumentationRouter.ViteAndReact_ReactRouterV7;
73
+ }
74
+ if (deps["vite"]) {
75
+ if (deps["vue"]) return DocumentationRouter.ViteAndVue;
76
+ if (deps["solid-js"]) return DocumentationRouter.ViteAndSolid;
77
+ if (deps["svelte"]) return DocumentationRouter.ViteAndSvelte;
78
+ if (deps["preact"]) return DocumentationRouter.ViteAndPreact;
79
+ return DocumentationRouter.ViteAndReact;
80
+ }
81
+ if (deps["react-scripts"]) return DocumentationRouter.CRA;
82
+ if (deps["@angular/core"]) return DocumentationRouter.Angular;
83
+ if (deps["@nestjs/core"]) return DocumentationRouter.NestJS;
84
+ if (deps["express"]) return DocumentationRouter.Express;
85
+ if (deps["fastify"]) return DocumentationRouter.Fastify;
86
+ if (deps["next-intl"]) return DocumentationRouter.NextIntl;
87
+ if (deps["react-i18next"] || deps["i18next"]) return DocumentationRouter.ReactI18Next;
88
+ if (deps["react-intl"]) return DocumentationRouter.ReactIntl;
89
+ if (deps["next-i18next"]) return DocumentationRouter.NextI18Next;
90
+ if (deps["vue-i18n"]) return DocumentationRouter.VueI18n;
91
+ return DocumentationRouter.Default;
92
+ };
93
+ /**
10
94
  * MAIN LOGIC
11
95
  */
12
96
  const initIntlayer = async (rootDir) => {
13
97
  (0, _intlayer_config.logger)((0, _intlayer_config.colorize)("Checking Intlayer configuration...", _intlayer_config.ANSIColors.CYAN));
14
- if (!await require_init_utils_fileSystem.exists(rootDir, "package.json")) {
98
+ const packageJsonPath = "package.json";
99
+ if (!await require_init_utils_fileSystem.exists(rootDir, packageJsonPath)) {
15
100
  (0, _intlayer_config.logger)(`${_intlayer_config.x} No ${(0, _intlayer_config.colorizePath)("package.json")} found. Please run this script from the project root.`, { level: "error" });
16
101
  process.exit(1);
17
102
  }
103
+ const packageJsonContent = await require_init_utils_fileSystem.readFileFromRoot(rootDir, packageJsonPath);
104
+ let packageJson;
105
+ try {
106
+ packageJson = JSON.parse(packageJsonContent);
107
+ } catch {
108
+ (0, _intlayer_config.logger)(`${_intlayer_config.x} Could not parse ${(0, _intlayer_config.colorizePath)("package.json")}.`, { level: "error" });
109
+ process.exit(1);
110
+ }
111
+ const guideUrl = getDocumentationUrl(packageJson);
18
112
  const gitignorePath = ".gitignore";
19
113
  if (await require_init_utils_fileSystem.exists(rootDir, gitignorePath)) {
20
114
  const gitignoreContent = await require_init_utils_fileSystem.readFileFromRoot(rootDir, gitignorePath);
@@ -31,7 +125,7 @@ const initIntlayer = async (rootDir) => {
31
125
  const config = require_init_utils_jsonParser.parseJSONWithComments(await require_init_utils_fileSystem.readFileFromRoot(rootDir, fileName));
32
126
  const typeDefinition = ".intlayer/**/*.ts";
33
127
  let updated = false;
34
- if (!config.include) {} else if (Array.isArray(config.include) && !config.include.some((patten) => patten.includes(".intlayer"))) {
128
+ if (!config.include) {} else if (Array.isArray(config.include) && !config.include.some((pattern) => pattern.includes(".intlayer"))) {
35
129
  config.include.push(typeDefinition);
36
130
  updated = true;
37
131
  } else if (config.include.includes(typeDefinition)) (0, _intlayer_config.logger)(`${_intlayer_config.v} ${(0, _intlayer_config.colorizePath)(fileName)} already includes intlayer types`);
@@ -71,6 +165,11 @@ const initIntlayer = async (rootDir) => {
71
165
  break;
72
166
  }
73
167
  (0, _intlayer_config.logger)(`${_intlayer_config.v} ${(0, _intlayer_config.colorize)("Intlayer init setup complete.", _intlayer_config.ANSIColors.GREEN)}`);
168
+ (0, _intlayer_config.logger)([
169
+ (0, _intlayer_config.colorize)("Next →", _intlayer_config.ANSIColors.MAGENTA),
170
+ (0, _intlayer_config.colorize)(`Follow the instructions in the documentation to complete the setup:`, _intlayer_config.ANSIColors.GREY_LIGHT),
171
+ (0, _intlayer_config.colorizePath)(guideUrl)
172
+ ]);
74
173
  };
75
174
 
76
175
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["ANSIColors","exists","x","readFileFromRoot","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 * MAIN LOGIC\n */\n\nexport const initIntlayer = async (rootDir: string) => {\n logger(colorize('Checking Intlayer configuration...', ANSIColors.CYAN));\n\n // Check for package.json to ensure we are in a project root\n if (!(await exists(rootDir, 'package.json'))) {\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 // 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 // Find all tsconfig files (tsconfig.json, tsconfig.*.json)\n const tsConfigFiles = await findTsConfigFiles(rootDir);\n\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 // Check if include array exists - if not, skip (likely a solution-style tsconfig with references)\n let updated = false;\n if (!config.include) {\n // Skip tsconfig files without include array (e.g. solution-style configs with references)\n } else if (\n Array.isArray(config.include) &&\n !(config.include as string[]).some((patten: string) =>\n patten.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 // We write back using standard JSON stringify (comments will be lost, sadly)\n // If preserving comments is critical, a more complex parser/printer is needed.\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 Intlayer configuration 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\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 // Prepend the import\n content = `${viteImport}\\n${content}`;\n await writeFileToRoot(rootDir, file, content);\n logger(`${v} Injected import into ${colorizePath(file)}`);\n }\n break; // Stop after finding one vite config\n }\n }\n\n // Check Next Config\n const nextConfigs = ['next.config.js', 'next.config.mjs', 'next.config.ts'];\n\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 // Prepend the import\n content = `${nextImport}\\n${content}`;\n await writeFileToRoot(rootDir, file, content);\n logger(`${v} Injected import into ${colorizePath(file)}`);\n }\n break; // Stop after finding one next config\n }\n }\n\n logger(`${v} ${col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;AACD,iCACE,GAAGC,mBAAE,8CAAwB,SAAS,CAAC,4BACxC;;UAEG;AACN,gCACE,GAAGH,mBAAE,gEAA0C,SAAS,CAAC,2DAAqC,0BAA0B,CAAC,aACzH,EAAE,OAAO,QAAQ,CAClB;;;AAOP,OAAMM,oCADS,cAAc,uBAAuB,uBAC3B,QAAQ;AAKjC,MAAK,MAAM,QAFS;EAAC;EAAkB;EAAkB;EAAkB,CAGzE,KAAI,MAAMP,qCAAO,SAAS,KAAK,EAAE;EAC/B,IAAI,UAAU,MAAME,+CAAiB,SAAS,KAAK;AAEnD,MAAI,CAAC,QAAQ,SAAS,gBAAgB,EAAE;AAKtC,aAAU,wFAAkB;AAC5B,SAAMC,8CAAgB,SAAS,MAAM,QAAQ;AAC7C,gCAAO,GAAGC,mBAAE,2DAAqC,KAAK,GAAG;;AAE3D;;AAOJ,MAAK,MAAM,QAFS;EAAC;EAAkB;EAAmB;EAAiB,CAGzE,KAAI,MAAMJ,qCAAO,SAAS,KAAK,EAAE;EAC/B,IAAI,UAAU,MAAME,+CAAiB,SAAS,KAAK;AAEnD,MAAI,CAAC,QAAQ,SAAS,gBAAgB,EAAE;AAKtC,aAAU,iGAAkB;AAC5B,SAAMC,8CAAgB,SAAS,MAAM,QAAQ;AAC7C,gCAAO,GAAGC,mBAAE,2DAAqC,KAAK,GAAG;;AAE3D;;AAIJ,8BAAO,GAAGA,mBAAE,kCAAY,iCAAiCL,4BAAW,MAAM,GAAG"}
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,KAAK,Q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listDictionaries = async (configuration) => {
13
- return await (0, fast_glob.default)(configuration.content.watchedFilesPatternWithPath, { ignore: configuration.content.excludedPath });
13
+ const { watchedFilesPatternWithPath, excludedPath } = configuration.content;
14
+ const filePromises = watchedFilesPatternWithPath.map(async (pattern) => {
15
+ const magicIndex = pattern.search(/[*?{}(]/);
16
+ const basePattern = magicIndex > -1 ? pattern.slice(0, magicIndex) : pattern;
17
+ return (0, fast_glob.default)(pattern, {
18
+ ignore: excludedPath.filter((excludePattern) => {
19
+ const cleanName = excludePattern.replace(/\*\*/g, "").replace(/\//g, "");
20
+ if (cleanName && basePattern.includes(`/${cleanName}/`)) return false;
21
+ return true;
22
+ }),
23
+ absolute: true,
24
+ dot: true
25
+ });
26
+ });
27
+ const filesArrays = await Promise.all(filePromises);
28
+ return Array.from(new Set(filesArrays.flat()));
14
29
  };
15
30
  const listDictionariesWithStats = async (configuration) => {
16
31
  const files = await listDictionaries(configuration);
@@ -1 +1 @@
1
- {"version":3,"file":"listDictionariesPath.cjs","names":[],"sources":["../../src/listDictionariesPath.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * List all dictionaries absolute paths in the project\n * @param configuration - The configuration object\n * @returns An array of dictionary paths\n */\nexport const listDictionaries = async (\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const files: string[] = await fg(\n configuration.content.watchedFilesPatternWithPath,\n {\n ignore: configuration.content.excludedPath,\n }\n );\n\n return files;\n};\n\nexport const listDictionariesWithStats = async (\n configuration: IntlayerConfig\n) => {\n const files = await listDictionaries(configuration);\n\n return Promise.all(\n files.map(async (file) => ({ path: file, stats: await stat(file) }))\n );\n};\n"],"mappings":";;;;;;;;;;;AASA,MAAa,mBAAmB,OAC9B,kBACsB;AAQtB,QAPwB,6BACtB,cAAc,QAAQ,6BACtB,EACE,QAAQ,cAAc,QAAQ,cAC/B,CACF;;AAKH,MAAa,4BAA4B,OACvC,kBACG;CACH,MAAM,QAAQ,MAAM,iBAAiB,cAAc;AAEnD,QAAO,QAAQ,IACb,MAAM,IAAI,OAAO,UAAU;EAAE,MAAM;EAAM,OAAO,iCAAW,KAAK;EAAE,EAAE,CACrE"}
1
+ {"version":3,"file":"listDictionariesPath.cjs","names":[],"sources":["../../src/listDictionariesPath.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * List all dictionaries absolute paths in the project\n * @param configuration - The configuration object\n * @returns An array of dictionary paths\n */\nexport const listDictionaries = async (\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const { watchedFilesPatternWithPath, excludedPath } = configuration.content;\n\n const filePromises = watchedFilesPatternWithPath.map(async (pattern) => {\n // Identify the static part of the path (before any wildcards like *)\n // e.g. \"/Users/.../design-system/dist/esm/**/*.content.ts\" -> \"/Users/.../design-system/dist/esm/\"\n const magicIndex = pattern.search(/[*?{}(]/);\n const basePattern =\n magicIndex > -1 ? pattern.slice(0, magicIndex) : pattern;\n\n // Filter the global ignored list for this specific pattern\n const applicableIgnore = excludedPath.filter((excludePattern) => {\n // Heuristic: Extract the key directory name from the glob\n // e.g. \"**/dist/**\" -> \"dist\", \"**/node_modules/**\" -> \"node_modules\"\n const cleanName = excludePattern.replace(/\\*\\*/g, '').replace(/\\//g, '');\n\n // If the explicit base path contains the excluded directory (e.g. \".../dist/...\"),\n // we assume you explicitly want it, so we REMOVE it from the ignore list.\n // We check for `/${cleanName}/` to ensure we match whole folder names.\n if (cleanName && basePattern.includes(`/${cleanName}/`)) {\n return false; // Drop this exclude rule\n }\n\n return true; // Keep this exclude rule\n });\n\n // Run fast-glob with the customized ignore list\n return fg(pattern, {\n ignore: applicableIgnore,\n absolute: true,\n dot: true,\n });\n });\n\n const filesArrays = await Promise.all(filePromises);\n\n // Flatten and deduplicate\n const uniqueFiles = Array.from(new Set(filesArrays.flat()));\n\n return uniqueFiles;\n};\n\nexport const listDictionariesWithStats = async (\n configuration: IntlayerConfig\n) => {\n const files = await listDictionaries(configuration);\n\n return Promise.all(\n files.map(async (file) => ({ path: file, stats: await stat(file) }))\n );\n};\n"],"mappings":";;;;;;;;;;;AASA,MAAa,mBAAmB,OAC9B,kBACsB;CACtB,MAAM,EAAE,6BAA6B,iBAAiB,cAAc;CAEpE,MAAM,eAAe,4BAA4B,IAAI,OAAO,YAAY;EAGtE,MAAM,aAAa,QAAQ,OAAO,UAAU;EAC5C,MAAM,cACJ,aAAa,KAAK,QAAQ,MAAM,GAAG,WAAW,GAAG;AAmBnD,gCAAU,SAAS;GACjB,QAjBuB,aAAa,QAAQ,mBAAmB;IAG/D,MAAM,YAAY,eAAe,QAAQ,SAAS,GAAG,CAAC,QAAQ,OAAO,GAAG;AAKxE,QAAI,aAAa,YAAY,SAAS,IAAI,UAAU,GAAG,CACrD,QAAO;AAGT,WAAO;KACP;GAKA,UAAU;GACV,KAAK;GACN,CAAC;GACF;CAEF,MAAM,cAAc,MAAM,QAAQ,IAAI,aAAa;AAKnD,QAFoB,MAAM,KAAK,IAAI,IAAI,YAAY,MAAM,CAAC,CAAC;;AAK7D,MAAa,4BAA4B,OACvC,kBACG;CACH,MAAM,QAAQ,MAAM,iBAAiB,cAAc;AAEnD,QAAO,QAAQ,IACb,MAAM,IAAI,OAAO,UAAU;EAAE,MAAM;EAAM,OAAO,iCAAW,KAAK;EAAE,EAAE,CACrE"}
@@ -0,0 +1,47 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let node_path = require("node:path");
3
+ let fast_glob = require("fast-glob");
4
+ fast_glob = require_rolldown_runtime.__toESM(fast_glob);
5
+ let _intlayer_config = require("@intlayer/config");
6
+ let simple_git = require("simple-git");
7
+ simple_git = require_rolldown_runtime.__toESM(simple_git);
8
+
9
+ //#region src/listProjects.ts
10
+ /**
11
+ * Get the git root directory
12
+ */
13
+ const getGitRootDir = async (cwd) => {
14
+ try {
15
+ return (await (cwd ? (0, simple_git.default)(cwd) : (0, simple_git.default)()).revparse(["--show-toplevel"])).trim();
16
+ } catch (_error) {
17
+ return null;
18
+ }
19
+ };
20
+ /**
21
+ * List all Intlayer projects by searching for configuration files
22
+ *
23
+ * @param options - Options for listing projects
24
+ * @returns Array of absolute paths to project directories containing Intlayer config
25
+ */
26
+ const listProjects = async (options) => {
27
+ let searchDir = options?.baseDir ?? process.cwd();
28
+ if (options?.gitRoot) {
29
+ const gitRootDir = await getGitRootDir(searchDir);
30
+ if (gitRootDir) searchDir = gitRootDir;
31
+ }
32
+ const configFiles = await (0, fast_glob.default)(_intlayer_config.configurationFilesCandidates.map((fileName) => `**/${fileName}`), {
33
+ cwd: searchDir,
34
+ absolute: true,
35
+ ignore: ["**/node_modules/**", "**/.git/**"],
36
+ dot: true
37
+ });
38
+ const projectDirs = [...new Set(configFiles.map((file) => (0, node_path.dirname)(file)))];
39
+ return {
40
+ searchDir,
41
+ projectsPath: projectDirs.sort()
42
+ };
43
+ };
44
+
45
+ //#endregion
46
+ exports.listProjects = listProjects;
47
+ //# sourceMappingURL=listProjects.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listProjects.cjs","names":["configurationFilesCandidates"],"sources":["../../src/listProjects.ts"],"sourcesContent":["import { dirname } from 'node:path';\nimport { configurationFilesCandidates } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport simpleGit from 'simple-git';\n\nexport type ListProjectsOptions = {\n /**\n * Base directory to search from\n * @default process.cwd()\n */\n baseDir?: string;\n /**\n * If true, search from the git root directory instead of baseDir\n * @default false\n */\n gitRoot?: boolean;\n};\n\n/**\n * Get the git root directory\n */\nconst getGitRootDir = async (cwd?: string): Promise<string | null> => {\n try {\n const git = cwd ? simpleGit(cwd) : simpleGit();\n const rootDir = await git.revparse(['--show-toplevel']);\n return rootDir.trim();\n } catch (_error) {\n return null;\n }\n};\n\n/**\n * List all Intlayer projects by searching for configuration files\n *\n * @param options - Options for listing projects\n * @returns Array of absolute paths to project directories containing Intlayer config\n */\nexport const listProjects = async (\n options?: ListProjectsOptions\n): Promise<{ searchDir: string; projectsPath: string[] }> => {\n let searchDir = options?.baseDir ?? process.cwd();\n\n // If gitRoot option is enabled, try to get the git root directory\n if (options?.gitRoot) {\n const gitRootDir = await getGitRootDir(searchDir);\n if (gitRootDir) {\n searchDir = gitRootDir;\n }\n }\n\n // Build glob patterns for all config file candidates\n const configPatterns = configurationFilesCandidates.map(\n (fileName) => `**/${fileName}`\n );\n\n // Search for all config files\n const configFiles = await fg(configPatterns, {\n cwd: searchDir,\n absolute: true,\n ignore: ['**/node_modules/**', '**/.git/**'],\n dot: true, // Include dot files like .intlayerrc\n });\n\n // Extract unique directory paths from config files\n const projectDirs = [...new Set(configFiles.map((file) => dirname(file)))];\n\n // Sort alphabetically for consistent output\n return { searchDir, projectsPath: projectDirs.sort() };\n};\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAM,gBAAgB,OAAO,QAAyC;AACpE,KAAI;AAGF,UADgB,OADJ,8BAAgB,IAAI,4BAAc,EACpB,SAAS,CAAC,kBAAkB,CAAC,EACxC,MAAM;UACd,QAAQ;AACf,SAAO;;;;;;;;;AAUX,MAAa,eAAe,OAC1B,YAC2D;CAC3D,IAAI,YAAY,SAAS,WAAW,QAAQ,KAAK;AAGjD,KAAI,SAAS,SAAS;EACpB,MAAM,aAAa,MAAM,cAAc,UAAU;AACjD,MAAI,WACF,aAAY;;CAUhB,MAAM,cAAc,6BALGA,8CAA6B,KACjD,aAAa,MAAM,WACrB,EAG4C;EAC3C,KAAK;EACL,UAAU;EACV,QAAQ,CAAC,sBAAsB,aAAa;EAC5C,KAAK;EACN,CAAC;CAGF,MAAM,cAAc,CAAC,GAAG,IAAI,IAAI,YAAY,KAAK,gCAAiB,KAAK,CAAC,CAAC,CAAC;AAG1E,QAAO;EAAE;EAAW,cAAc,YAAY,MAAM;EAAE"}
@@ -78,26 +78,17 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
78
78
  const { plugins } = configuration;
79
79
  const loadDictionariesStartTime = Date.now();
80
80
  (0, _intlayer_config_client.getAppLogger)(configuration)("Dictionaries:", { isVerbose: true });
81
- const pluginsWithLoadDictionaries = (plugins ?? []).filter((plugin) => plugin.loadDictionaries);
82
- logger.setPluginTotal(pluginsWithLoadDictionaries.length);
83
- const completedPluginIndices = /* @__PURE__ */ new Set();
84
- const updatePluginProgress = () => {
85
- logger.setPluginDone(completedPluginIndices.size);
86
- };
87
- const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(async (plugin, index) => {
81
+ const loadPluginDictionariesPromise = (plugins ?? []).filter((plugin) => plugin.loadDictionaries).map(async (plugin, index) => {
88
82
  try {
89
- const res = await plugin.loadDictionaries?.({ configuration });
90
- completedPluginIndices.add(index);
91
- updatePluginProgress();
92
- return res ?? [];
83
+ return await plugin.loadDictionaries?.({ configuration }) ?? [];
93
84
  } catch (error) {
94
85
  logger.setPluginError(error);
95
- completedPluginIndices.add(index);
96
- updatePluginProgress();
97
86
  return [];
98
87
  }
99
88
  });
100
89
  const pluginDictionaries = await Promise.all(loadPluginDictionariesPromise).then((dictionaries) => dictionaries.flat()).then((dictionaries) => require_filterInvalidDictionaries.filterInvalidDictionaries(dictionaries, configuration)).then((dictionaries) => require_formatDictionary.formatDictionaries(dictionaries));
90
+ logger.setPluginTotal(pluginDictionaries.length);
91
+ logger.setPluginDone(pluginDictionaries.length);
101
92
  const pluginDictionariesTime = Date.now();
102
93
  const localDictionaries = await require_loadDictionaries_loadContentDeclaration.loadContentDeclarations(Array.isArray(contentDeclarationsPaths) ? contentDeclarationsPaths : [contentDeclarationsPaths], configuration, setLoadDictionariesStatus).then((dictionaries) => require_filterInvalidDictionaries.filterInvalidDictionaries(dictionaries, configuration)).then((dictionaries) => require_formatDictionary.formatDictionaries(dictionaries));
103
94
  const localDictionariesTime = Date.now();
@@ -1 +1 @@
1
- {"version":3,"file":"loadDictionaries.cjs","names":["loadDictionariesStatus: DictionariesStatus[]","DictionariesLogger","updated: DictionariesStatus[]","ANSIColors","labels: string[]","pluginDictionaries: Dictionary[]","filterInvalidDictionaries","formatDictionaries","localDictionaries: Dictionary[]","loadContentDeclarations","remoteDictionaries: Dictionary[]","loadRemoteDictionaries"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDictionaries } from '../formatDictionary';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const status of loadDictionariesStatus) {\n const rec = byKey.get(status.dictionaryKey) ?? {};\n if (status.type === 'local') rec.local = status.status;\n if (status.type === 'remote') rec.remote = status.status;\n byKey.set(status.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const pluginsWithLoadDictionaries = (plugins ?? []).filter(\n (plugin) => plugin.loadDictionaries\n );\n\n logger.setPluginTotal(pluginsWithLoadDictionaries.length);\n\n const completedPluginIndices = new Set<number>();\n const updatePluginProgress = () => {\n logger.setPluginDone(completedPluginIndices.size);\n };\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin, index) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n completedPluginIndices.add(index);\n updatePluginProgress();\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error);\n completedPluginIndices.add(index);\n updatePluginProgress();\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = await Promise.all(\n loadPluginDictionariesPromise as Promise<Dictionary[]>[]\n )\n .then((dictionaries) => dictionaries.flat())\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const pluginDictionariesTime = Date.now();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const localDictionariesTime = Date.now();\n\n const localDictionariesStatus = localDictionaries.map(\n (dictionary) =>\n ({\n dictionaryKey: dictionary.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n }\n\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - pluginDictionariesTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - loadDictionariesStartTime,\n },\n };\n};\n"],"mappings":";;;;;;;;;AA6BA,IAAIA,yBAA+C,EAAE;AACrD,MAAM,SAAS,IAAIC,iDAAoB;AAEvC,MAAM,6BAA6B,aAAmC;CACpE,MAAMC,UAAgC,CAAC,GAAG,uBAAuB;AAEjE,MAAK,MAAM,YAAY,UAAU;EAC/B,MAAM,QAAQ,QAAQ,WACnB,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS,KACrE;AACD,MAAI,SAAS,EACX,SAAQ,SAAS;MAEjB,SAAQ,KAAK,SAAS;;AAI1B,0BAAyB;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ACjC,yBAAsB;AACtB,UAAO,EAAE;;GAGd;CAED,MAAME,qBAAmC,MAAM,QAAQ,IACrD,8BACD,CACE,MAAM,iBAAiB,aAAa,MAAM,CAAC,CAC3C,MAAM,iBACLC,4DAA0B,cAAc,cAAc,CACvD,CACA,MAAM,iBAAiBC,4CAAmB,aAAa,CAAC;CAE3D,MAAM,yBAAyB,KAAK,KAAK;CAMzC,MAAMC,oBAAkC,MAAMC,wEAJhC,MAAM,QAAQ,yBAAyB,GACjD,2BACA,CAAC,yBAAyB,EAI5B,eACA,0BACD,CACE,MAAM,iBACLH,4DAA0B,cAAc,cAAc,CACvD,CACA,MAAM,iBAAiBC,4CAAmB,aAAa,CAAC;CAE3D,MAAM,wBAAwB,KAAK,KAAK;AAWxC,2BATgC,kBAAkB,KAC/C,gBACE;EACC,eAAe,WAAW;EAC1B,MAAM;EACN,QAAQ;EACT,EACJ,CAEiD;CAElD,MAAM,wBAAwB,QAC5B,cAAc,OAAO,YAAY,cAAc,OAAO,aACvD;AAED,KAAI,sBAEF,QAAO,gBAAgB,KAAK;CAG9B,IAAIG,qBAAmC,EAAE;AAEzC,KAAI,sBACF,sBAAqB,MAAMC,uEACzB,eACA,2BACA;EACE,0BAA0B,OAAO,kBAAkB;EACnD,yBAAyB,OAAO,iBAAiB;EACjD,UAAU,MAAM,OAAO,eAAe,EAAE;EACzC,CACF,CACE,MAAM,iBACLL,4DAA0B,cAAc,cAAc,CACvD,CACA,MAAM,iBAAiBC,4CAAmB,aAAa,CAAC;CAG7D,MAAM,yBAAyB,KAAK,KAAK;AAGzC,QAAO,QAAQ;AAEf,cAAa,cAAc;AAE3B,QAAO;EACL;EACA;EACA;EACA,MAAM;GACJ,mBAAmB,wBAAwB;GAC3C,oBAAoB,yBAAyB;GAC7C,oBAAoB,yBAAyB;GAC9C;EACF"}
1
+ {"version":3,"file":"loadDictionaries.cjs","names":["loadDictionariesStatus: DictionariesStatus[]","DictionariesLogger","updated: DictionariesStatus[]","ANSIColors","labels: string[]","pluginDictionaries: Dictionary[]","filterInvalidDictionaries","formatDictionaries","localDictionaries: Dictionary[]","loadContentDeclarations","remoteDictionaries: Dictionary[]","loadRemoteDictionaries"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDictionaries } from '../formatDictionary';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const status of loadDictionariesStatus) {\n const rec = byKey.get(status.dictionaryKey) ?? {};\n if (status.type === 'local') rec.local = status.status;\n if (status.type === 'remote') rec.remote = status.status;\n byKey.set(status.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const pluginsWithLoadDictionaries = (plugins ?? []).filter(\n (plugin) => plugin.loadDictionaries\n );\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin, index) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error);\n\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = await Promise.all(\n loadPluginDictionariesPromise as Promise<Dictionary[]>[]\n )\n .then((dictionaries) => dictionaries.flat())\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n logger.setPluginTotal(pluginDictionaries.length);\n logger.setPluginDone(pluginDictionaries.length);\n\n const pluginDictionariesTime = Date.now();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const localDictionariesTime = Date.now();\n\n const localDictionariesStatus = localDictionaries.map(\n (dictionary) =>\n ({\n dictionaryKey: dictionary.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n }\n\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - pluginDictionariesTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - loadDictionariesStartTime,\n },\n };\n};\n"],"mappings":";;;;;;;;;AA6BA,IAAIA,yBAA+C,EAAE;AACrD,MAAM,SAAS,IAAIC,iDAAoB;AAEvC,MAAM,6BAA6B,aAAmC;CACpE,MAAMC,UAAgC,CAAC,GAAG,uBAAuB;AAEjE,MAAK,MAAM,YAAY,UAAU;EAC/B,MAAM,QAAQ,QAAQ,WACnB,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS,KACrE;AACD,MAAI,SAAS,EACX,SAAQ,SAAS;MAEjB,SAAQ,KAAK,SAAS;;AAI1B,0BAAyB;AACzB,QAAO,OAAO,SAAS;AAEvB,QAAO;;AAQT,MAAM,WAAW,WAAyC;AACxD,SAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,UACH,QAAO;EACT,KAAK,QAC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,CAAC,yBAAyB,EAI5B,eACA,0BACD,CACE,MAAM,iBACLH,4DAA0B,cAAc,cAAc,CACvD,CACA,MAAM,iBAAiBC,4CAAmB,aAAa,CAAC;CAE3D,MAAM,wBAAwB,KAAK,KAAK;AAWxC,2BATgC,kBAAkB,KAC/C,gBACE;EACC,eAAe,WAAW;EAC1B,MAAM;EACN,QAAQ;EACT,EACJ,CAEiD;CAElD,MAAM,wBAAwB,QAC5B,cAAc,OAAO,YAAY,cAAc,OAAO,aACvD;AAED,KAAI,sBAEF,QAAO,gBAAgB,KAAK;CAG9B,IAAIG,qBAAmC,EAAE;AAEzC,KAAI,sBACF,sBAAqB,MAAMC,uEACzB,eACA,2BACA;EACE,0BAA0B,OAAO,kBAAkB;EACnD,yBAAyB,OAAO,iBAAiB;EACjD,UAAU,MAAM,OAAO,eAAe,EAAE;EACzC,CACF,CACE,MAAM,iBACLL,4DAA0B,cAAc,cAAc,CACvD,CACA,MAAM,iBAAiBC,4CAAmB,aAAa,CAAC;CAG7D,MAAM,yBAAyB,KAAK,KAAK;AAGzC,QAAO,QAAQ;AAEf,cAAa,cAAc;AAE3B,QAAO;EACL;EACA;EACA;EACA,MAAM;GACJ,mBAAmB,wBAAwB;GAC3C,oBAAoB,yBAAyB;GAC7C,oBAAoB,yBAAyB;GAC9C;EACF"}
@@ -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"}
@@ -26,6 +26,7 @@ import { handleUnlinkedContentDeclarationFile } from "./handleUnlinkedContentDec
26
26
  import { getContentDeclarationFileTemplate } from "./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";
27
27
  import { initIntlayer } from "./init/index.mjs";
28
28
  import { listGitFiles, listGitLines } from "./listGitFiles.mjs";
29
+ import { listProjects } from "./listProjects.mjs";
29
30
  import { sortAlphabetically } from "./utils/sortAlphabetically.mjs";
30
31
  import { loadRemoteDictionaries } from "./loadDictionaries/loadRemoteDictionaries.mjs";
31
32
  import { loadDictionaries } from "./loadDictionaries/loadDictionaries.mjs";
@@ -51,4 +52,4 @@ import { runParallel } from "./utils/runParallel/index.mjs";
51
52
  import { verifyIdenticObjectFormat } from "./utils/verifyIdenticObjectFormat.mjs";
52
53
  import { buildAndWatchIntlayer, watch } from "./watcher.mjs";
53
54
 
54
- export { ATTRIBUTES_TO_EXTRACT, assembleJSON, buildAndWatchIntlayer, buildDictionary, buildFilesList, chunkJSON, cleanOutputDir, createDictionaryEntryPoint, createModuleAugmentation, createTypes, detectExportedComponentName, detectFormatCommand, extractDictionaryKey, extractIntlayer, fetchDistantDictionaries, formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput, formatLocale, formatPath, generateDictionaryListContent, generateKey, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath, getChunk, getComponentTransformPattern, getComponentTransformPatternSync, getContentDeclarationFileTemplate, getExtensionFromFormat, getFileHash, getFormatFromExtension, getGlobalLimiter, getTaskLimiter, handleAdditionalContentDeclarationFile, handleContentDeclarationFileChange, handleUnlinkedContentDeclarationFile, initIntlayer, isInvalidDictionary, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, loadContentDeclarations, loadDictionaries, loadLocalDictionaries, loadRemoteDictionaries, pLimit, parallelize, parallelizeGlobal, prepareIntlayer, reconstructFromSingleChunk, reduceDictionaryContent, reduceObjectFormat, resolveObjectPromises, runOnce, runParallel, shouldExtract, sortAlphabetically, splitTextByLines, transformFiles, transformJSFile, verifyIdenticObjectFormat, watch, writeContentDeclaration, writeJSFile };
55
+ export { ATTRIBUTES_TO_EXTRACT, assembleJSON, buildAndWatchIntlayer, buildDictionary, buildFilesList, chunkJSON, cleanOutputDir, createDictionaryEntryPoint, createModuleAugmentation, createTypes, detectExportedComponentName, detectFormatCommand, extractDictionaryKey, extractIntlayer, fetchDistantDictionaries, formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput, formatLocale, formatPath, generateDictionaryListContent, generateKey, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath, getChunk, getComponentTransformPattern, getComponentTransformPatternSync, getContentDeclarationFileTemplate, getExtensionFromFormat, getFileHash, getFormatFromExtension, getGlobalLimiter, getTaskLimiter, handleAdditionalContentDeclarationFile, handleContentDeclarationFileChange, handleUnlinkedContentDeclarationFile, initIntlayer, isInvalidDictionary, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, loadContentDeclarations, loadDictionaries, loadLocalDictionaries, loadRemoteDictionaries, pLimit, parallelize, parallelizeGlobal, prepareIntlayer, reconstructFromSingleChunk, reduceDictionaryContent, reduceObjectFormat, resolveObjectPromises, runOnce, runParallel, shouldExtract, sortAlphabetically, splitTextByLines, transformFiles, transformJSFile, verifyIdenticObjectFormat, watch, writeContentDeclaration, writeJSFile };
@@ -6,14 +6,108 @@ import { ANSIColors, colorize, colorizePath, logger, v, x } from "@intlayer/conf
6
6
 
7
7
  //#region src/init/index.ts
8
8
  /**
9
+ * Documentation URL Constants
10
+ */
11
+ const DocumentationRouter = {
12
+ NextJS: "https://intlayer.org/doc/environment/nextjs.md",
13
+ NextJS_15: "https://intlayer.org/doc/environment/nextjs/15.md",
14
+ NextJS_14: "https://intlayer.org/doc/environment/nextjs/14.md",
15
+ CRA: "https://intlayer.org/doc/environment/create-react-app.md",
16
+ Astro: "https://intlayer.org/doc/environment/astro.md",
17
+ ViteAndReact: "https://intlayer.org/doc/environment/vite-and-react.md",
18
+ ViteAndReact_ReactRouterV7: "https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md",
19
+ ViteAndReact_ReactRouterV7_FSRoutes: "https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md",
20
+ ViteAndVue: "https://intlayer.org/doc/environment/vite-and-vue.md",
21
+ ViteAndSolid: "https://intlayer.org/doc/environment/vite-and-solid.md",
22
+ ViteAndSvelte: "https://intlayer.org/doc/environment/vite-and-svelte.md",
23
+ ViteAndPreact: "https://intlayer.org/doc/environment/vite-and-preact.md",
24
+ TanStackRouter: "https://intlayer.org/doc/environment/tanstack.md",
25
+ NuxtAndVue: "https://intlayer.org/doc/environment/nuxt-and-vue.md",
26
+ Angular: "https://intlayer.org/doc/environment/angular.md",
27
+ SvelteKit: "https://intlayer.org/doc/environment/sveltekit.md",
28
+ ReactNativeAndExpo: "https://intlayer.org/doc/environment/react-native-and-expo.md",
29
+ Lynx: "https://intlayer.org/doc/environment/lynx-and-react.md",
30
+ Express: "https://intlayer.org/doc/environment/express.md",
31
+ NestJS: "https://intlayer.org/doc/environment/nestjs.md",
32
+ Fastify: "https://intlayer.org/doc/environment/fastify.md",
33
+ Default: "https://intlayer.org/doc/get-started",
34
+ NextIntl: "https://intlayer.org/blog/intlayer-with-next-intl.md",
35
+ ReactI18Next: "https://intlayer.org/blog/intlayer-with-react-i18next.md",
36
+ ReactIntl: "https://intlayer.org/blog/intlayer-with-react-intl.md",
37
+ NextI18Next: "https://intlayer.org/blog/intlayer-with-next-i18next.md",
38
+ VueI18n: "https://intlayer.org/blog/intlayer-with-vue-i18n.md"
39
+ };
40
+ /**
41
+ * Helper: Detects the environment and returns the doc URL
42
+ */
43
+ const getDocumentationUrl = (packageJson) => {
44
+ const deps = {
45
+ ...packageJson.dependencies,
46
+ ...packageJson.devDependencies
47
+ };
48
+ /**
49
+ * Helper to check if a version string matches a specific major version
50
+ * Matches: "15", "^15.0.0", "~15.2", "15.0.0-beta"
51
+ */
52
+ const isVersion = (versionString, major) => {
53
+ if (!versionString || typeof versionString !== "string") return false;
54
+ return (/* @__PURE__ */ new RegExp(`^[\\^~]?${major}(?:\\.|$)`)).test(versionString);
55
+ };
56
+ if (deps["@lynx-js/react"] || deps["@lynx-js/core"]) return DocumentationRouter.Lynx;
57
+ if (deps["react-native"] || deps["expo"]) return DocumentationRouter.ReactNativeAndExpo;
58
+ if (deps["next"]) {
59
+ const version = deps["next"];
60
+ if (isVersion(version, 14)) return DocumentationRouter.NextJS_14;
61
+ if (isVersion(version, 15)) return DocumentationRouter.NextJS_15;
62
+ return DocumentationRouter.NextJS;
63
+ }
64
+ if (deps["nuxt"]) return DocumentationRouter.NuxtAndVue;
65
+ if (deps["astro"]) return DocumentationRouter.Astro;
66
+ if (deps["@sveltejs/kit"]) return DocumentationRouter.SvelteKit;
67
+ if (deps["@tanstack/react-router"]) return DocumentationRouter.TanStackRouter;
68
+ const reactRouterVersion = deps["react-router"];
69
+ if (reactRouterVersion && typeof reactRouterVersion === "string") {
70
+ if (deps["@react-router/fs-routes"]) return DocumentationRouter.ViteAndReact_ReactRouterV7_FSRoutes;
71
+ if (isVersion(reactRouterVersion, 7)) return DocumentationRouter.ViteAndReact_ReactRouterV7;
72
+ }
73
+ if (deps["vite"]) {
74
+ if (deps["vue"]) return DocumentationRouter.ViteAndVue;
75
+ if (deps["solid-js"]) return DocumentationRouter.ViteAndSolid;
76
+ if (deps["svelte"]) return DocumentationRouter.ViteAndSvelte;
77
+ if (deps["preact"]) return DocumentationRouter.ViteAndPreact;
78
+ return DocumentationRouter.ViteAndReact;
79
+ }
80
+ if (deps["react-scripts"]) return DocumentationRouter.CRA;
81
+ if (deps["@angular/core"]) return DocumentationRouter.Angular;
82
+ if (deps["@nestjs/core"]) return DocumentationRouter.NestJS;
83
+ if (deps["express"]) return DocumentationRouter.Express;
84
+ if (deps["fastify"]) return DocumentationRouter.Fastify;
85
+ if (deps["next-intl"]) return DocumentationRouter.NextIntl;
86
+ if (deps["react-i18next"] || deps["i18next"]) return DocumentationRouter.ReactI18Next;
87
+ if (deps["react-intl"]) return DocumentationRouter.ReactIntl;
88
+ if (deps["next-i18next"]) return DocumentationRouter.NextI18Next;
89
+ if (deps["vue-i18n"]) return DocumentationRouter.VueI18n;
90
+ return DocumentationRouter.Default;
91
+ };
92
+ /**
9
93
  * MAIN LOGIC
10
94
  */
11
95
  const initIntlayer = async (rootDir) => {
12
96
  logger(colorize("Checking Intlayer configuration...", ANSIColors.CYAN));
13
- if (!await exists(rootDir, "package.json")) {
97
+ const packageJsonPath = "package.json";
98
+ if (!await exists(rootDir, packageJsonPath)) {
14
99
  logger(`${x} No ${colorizePath("package.json")} found. Please run this script from the project root.`, { level: "error" });
15
100
  process.exit(1);
16
101
  }
102
+ const packageJsonContent = await readFileFromRoot(rootDir, packageJsonPath);
103
+ let packageJson;
104
+ try {
105
+ packageJson = JSON.parse(packageJsonContent);
106
+ } catch {
107
+ logger(`${x} Could not parse ${colorizePath("package.json")}.`, { level: "error" });
108
+ process.exit(1);
109
+ }
110
+ const guideUrl = getDocumentationUrl(packageJson);
17
111
  const gitignorePath = ".gitignore";
18
112
  if (await exists(rootDir, gitignorePath)) {
19
113
  const gitignoreContent = await readFileFromRoot(rootDir, gitignorePath);
@@ -30,7 +124,7 @@ const initIntlayer = async (rootDir) => {
30
124
  const config = parseJSONWithComments(await readFileFromRoot(rootDir, fileName));
31
125
  const typeDefinition = ".intlayer/**/*.ts";
32
126
  let updated = false;
33
- if (!config.include) {} else if (Array.isArray(config.include) && !config.include.some((patten) => patten.includes(".intlayer"))) {
127
+ if (!config.include) {} else if (Array.isArray(config.include) && !config.include.some((pattern) => pattern.includes(".intlayer"))) {
34
128
  config.include.push(typeDefinition);
35
129
  updated = true;
36
130
  } else if (config.include.includes(typeDefinition)) logger(`${v} ${colorizePath(fileName)} already includes intlayer types`);
@@ -70,6 +164,11 @@ const initIntlayer = async (rootDir) => {
70
164
  break;
71
165
  }
72
166
  logger(`${v} ${colorize("Intlayer init setup complete.", ANSIColors.GREEN)}`);
167
+ logger([
168
+ colorize("Next →", ANSIColors.MAGENTA),
169
+ colorize(`Follow the instructions in the documentation to complete the setup:`, ANSIColors.GREY_LIGHT),
170
+ colorizePath(guideUrl)
171
+ ]);
73
172
  };
74
173
 
75
174
  //#endregion