@intlayer/chokidar 7.5.8 → 7.5.10

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 (54) hide show
  1. package/README.md +9 -2
  2. package/dist/assets/initConfig/templates/cjs.txt +5 -12
  3. package/dist/assets/initConfig/templates/mjs.txt +5 -12
  4. package/dist/assets/initConfig/templates/ts.txt +5 -11
  5. package/dist/cjs/init/index.cjs +18 -71
  6. package/dist/cjs/init/index.cjs.map +1 -1
  7. package/dist/cjs/init/utils/fileSystem.cjs +30 -0
  8. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -0
  9. package/dist/cjs/init/utils/index.cjs +9 -0
  10. package/dist/cjs/init/utils/jsonParser.cjs +42 -0
  11. package/dist/cjs/init/utils/jsonParser.cjs.map +1 -0
  12. package/dist/cjs/init/utils/tsConfig.cjs +18 -0
  13. package/dist/cjs/init/utils/tsConfig.cjs.map +1 -0
  14. package/dist/cjs/initConfig/index.cjs +8 -12
  15. package/dist/cjs/initConfig/index.cjs.map +1 -1
  16. package/dist/cjs/watcher.cjs +1 -1
  17. package/dist/cjs/watcher.cjs.map +1 -1
  18. package/dist/esm/init/index.mjs +18 -71
  19. package/dist/esm/init/index.mjs.map +1 -1
  20. package/dist/esm/init/utils/fileSystem.mjs +27 -0
  21. package/dist/esm/init/utils/fileSystem.mjs.map +1 -0
  22. package/dist/esm/init/utils/index.mjs +5 -0
  23. package/dist/esm/init/utils/jsonParser.mjs +41 -0
  24. package/dist/esm/init/utils/jsonParser.mjs.map +1 -0
  25. package/dist/esm/init/utils/tsConfig.mjs +17 -0
  26. package/dist/esm/init/utils/tsConfig.mjs.map +1 -0
  27. package/dist/esm/initConfig/index.mjs +11 -14
  28. package/dist/esm/initConfig/index.mjs.map +1 -1
  29. package/dist/esm/watcher.mjs +1 -1
  30. package/dist/esm/watcher.mjs.map +1 -1
  31. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -2
  32. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -2
  33. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
  34. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
  35. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
  36. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +2 -2
  37. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
  38. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
  39. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
  40. package/dist/types/formatDictionary.d.ts +15 -15
  41. package/dist/types/init/index.d.ts +1 -1
  42. package/dist/types/init/index.d.ts.map +1 -1
  43. package/dist/types/init/utils/fileSystem.d.ts +16 -0
  44. package/dist/types/init/utils/fileSystem.d.ts.map +1 -0
  45. package/dist/types/init/utils/index.d.ts +4 -0
  46. package/dist/types/init/utils/jsonParser.d.ts +8 -0
  47. package/dist/types/init/utils/jsonParser.d.ts.map +1 -0
  48. package/dist/types/init/utils/tsConfig.d.ts +8 -0
  49. package/dist/types/init/utils/tsConfig.d.ts.map +1 -0
  50. package/dist/types/initConfig/index.d.ts +2 -2
  51. package/dist/types/initConfig/index.d.ts.map +1 -1
  52. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +2 -2
  53. package/package.json +10 -10
  54. package/dist/assets/initConfig/templates/js.txt +0 -18
@@ -1,86 +1,33 @@
1
1
  import { initConfig } from "../initConfig/index.mjs";
2
- import { access, readFile, readdir, writeFile } from "node:fs/promises";
3
- import { join } from "node:path";
2
+ import { exists, readFileFromRoot, writeFileToRoot } from "./utils/fileSystem.mjs";
3
+ import { parseJSONWithComments } from "./utils/jsonParser.mjs";
4
+ import { findTsConfigFiles } from "./utils/tsConfig.mjs";
4
5
  import { ANSIColors, colorize, colorizePath, logger, v, x } from "@intlayer/config";
5
6
 
6
7
  //#region src/init/index.ts
7
8
  /**
8
- * UTILITIES
9
- */
10
- const rootDir = process.cwd();
11
- const exists = async (filePath) => {
12
- try {
13
- await access(join(rootDir, filePath));
14
- return true;
15
- } catch {
16
- return false;
17
- }
18
- };
19
- const readFileFromRoot = async (filePath) => await readFile(join(rootDir, filePath), "utf8");
20
- const writeFileToRoot = async (filePath, content) => await writeFile(join(rootDir, filePath), content, "utf8");
21
- const parseJSONWithComments = (jsonString) => {
22
- try {
23
- return JSON.parse(jsonString);
24
- } catch {}
25
- const cleanedLines = jsonString.split("\n").map((line) => {
26
- let inString = false;
27
- let result = "";
28
- for (let i = 0; i < line.length; i++) {
29
- const char = line[i];
30
- const nextChar = line[i + 1];
31
- if (char === "\"" && (i === 0 || line[i - 1] !== "\\")) {
32
- inString = !inString;
33
- result += char;
34
- continue;
35
- }
36
- if (inString) {
37
- result += char;
38
- continue;
39
- }
40
- if (char === "/" && nextChar === "/") break;
41
- if (char === "/" && nextChar === "*") {
42
- const endIndex = line.indexOf("*/", i + 2);
43
- if (endIndex !== -1) {
44
- i = endIndex + 1;
45
- continue;
46
- }
47
- }
48
- result += char;
49
- }
50
- return result;
51
- });
52
- return JSON.parse(cleanedLines.join("\n"));
53
- };
54
- const findTsConfigFiles = async () => {
55
- try {
56
- return (await readdir(rootDir)).filter((file) => file === "tsconfig.json" || /^tsconfig\..+\.json$/.test(file));
57
- } catch {
58
- return [];
59
- }
60
- };
61
- /**
62
9
  * MAIN LOGIC
63
10
  */
64
- const initIntlayer = async () => {
11
+ const initIntlayer = async (rootDir) => {
65
12
  logger(colorize("Checking Intlayer configuration...", ANSIColors.CYAN));
66
- if (!await exists("package.json")) {
13
+ if (!await exists(rootDir, "package.json")) {
67
14
  logger(`${x} No ${colorizePath("package.json")} found. Please run this script from the project root.`, { level: "error" });
68
15
  process.exit(1);
69
16
  }
70
17
  const gitignorePath = ".gitignore";
71
- if (await exists(gitignorePath)) {
72
- const gitignoreContent = await readFileFromRoot(gitignorePath);
18
+ if (await exists(rootDir, gitignorePath)) {
19
+ const gitignoreContent = await readFileFromRoot(rootDir, gitignorePath);
73
20
  if (!gitignoreContent.includes("intlayer")) {
74
- await writeFileToRoot(gitignorePath, `${gitignoreContent}\n\n# Intlayer\n.intlayer\n`);
21
+ await writeFileToRoot(rootDir, gitignorePath, `${gitignoreContent}\n# Intlayer\n.intlayer\n`);
75
22
  logger(`${v} Added ${colorizePath(".intlayer")} to ${colorizePath(gitignorePath)}`);
76
23
  } else logger(`${v} ${colorizePath(gitignorePath)} already includes .intlayer`);
77
24
  }
78
- const tsConfigFiles = await findTsConfigFiles();
25
+ const tsConfigFiles = await findTsConfigFiles(rootDir);
79
26
  let hasTsConfig = false;
80
- for (const fileName of tsConfigFiles) if (await exists(fileName)) {
27
+ for (const fileName of tsConfigFiles) if (await exists(rootDir, fileName)) {
81
28
  hasTsConfig = true;
82
29
  try {
83
- const config = parseJSONWithComments(await readFileFromRoot(fileName));
30
+ const config = parseJSONWithComments(await readFileFromRoot(rootDir, fileName));
84
31
  const typeDefinition = ".intlayer/**/*.ts";
85
32
  let updated = false;
86
33
  if (!config.include) {} else if (Array.isArray(config.include) && !config.include.some((patten) => patten.includes(".intlayer"))) {
@@ -88,7 +35,7 @@ const initIntlayer = async () => {
88
35
  updated = true;
89
36
  } else if (config.include.includes(typeDefinition)) logger(`${v} ${colorizePath(fileName)} already includes intlayer types`);
90
37
  if (updated) {
91
- await writeFileToRoot(fileName, JSON.stringify(config, null, 2));
38
+ await writeFileToRoot(rootDir, fileName, JSON.stringify(config, null, 2));
92
39
  logger(`${v} Updated ${colorizePath(fileName)} to include intlayer types`);
93
40
  }
94
41
  } catch {
@@ -100,11 +47,11 @@ const initIntlayer = async () => {
100
47
  "vite.config.ts",
101
48
  "vite.config.js",
102
49
  "vite.config.mjs"
103
- ]) if (await exists(file)) {
104
- let content = await readFileFromRoot(file);
50
+ ]) if (await exists(rootDir, file)) {
51
+ let content = await readFileFromRoot(rootDir, file);
105
52
  if (!content.includes("vite-intlayer")) {
106
53
  content = `import { intlayer } from 'vite-intlayer'; // Add the plugin to the Vite plugin list\n${content}`;
107
- await writeFileToRoot(file, content);
54
+ await writeFileToRoot(rootDir, file, content);
108
55
  logger(`${v} Injected import into ${colorizePath(file)}`);
109
56
  }
110
57
  break;
@@ -113,11 +60,11 @@ const initIntlayer = async () => {
113
60
  "next.config.js",
114
61
  "next.config.mjs",
115
62
  "next.config.ts"
116
- ]) if (await exists(file)) {
117
- let content = await readFileFromRoot(file);
63
+ ]) if (await exists(rootDir, file)) {
64
+ let content = await readFileFromRoot(rootDir, file);
118
65
  if (!content.includes("next-intlayer")) {
119
66
  content = `import { withIntlayer } from 'next-intlayer'; // Add the plugin to the Next.js configuration\n${content}`;
120
- await writeFileToRoot(file, content);
67
+ await writeFileToRoot(rootDir, file, content);
121
68
  logger(`${v} Injected import into ${colorizePath(file)}`);
122
69
  }
123
70
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/init/index.ts"],"sourcesContent":["import { access, readdir, readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n logger,\n v,\n x,\n} from '@intlayer/config';\nimport { initConfig } from '../initConfig';\n\n/**\n * UTILITIES\n */\nconst rootDir = process.cwd();\n\n// Helper to check if a file exists\nconst exists = async (filePath: string) => {\n try {\n await access(join(rootDir, filePath));\n return true;\n } catch {\n return false;\n }\n};\n\n// Helper to read a file\nconst readFileFromRoot = async (filePath: string) =>\n await readFile(join(rootDir, filePath), 'utf8');\n\n// Helper to write a file\nconst writeFileToRoot = async (filePath: string, content: string) =>\n await writeFile(join(rootDir, filePath), content, 'utf8');\n\n// Helper to parse JSON that may contain comments (tsconfig allows comments)\nconst parseJSONWithComments = (jsonString: string) => {\n // First, try parsing as-is (most tsconfig files don't have comments)\n try {\n return JSON.parse(jsonString);\n } catch {\n // If that fails, try stripping comments\n // Note: This simple approach removes comments line by line to avoid\n // matching glob patterns like /* and */ that appear in paths\n }\n\n // Process line by line to safely remove comments\n const lines = jsonString.split('\\n');\n const cleanedLines = lines.map((line) => {\n // Track if we're inside a string\n let inString = false;\n let result = '';\n\n for (let i = 0; i < line.length; i++) {\n const char = line[i];\n const nextChar = line[i + 1];\n\n // Handle string boundaries (accounting for escaped quotes)\n if (char === '\"' && (i === 0 || line[i - 1] !== '\\\\')) {\n inString = !inString;\n result += char;\n continue;\n }\n\n // If we're inside a string, keep the character\n if (inString) {\n result += char;\n continue;\n }\n\n // Check for single-line comment outside of strings\n if (char === '/' && nextChar === '/') {\n // Rest of line is a comment, stop here\n break;\n }\n\n // Check for multi-line comment start (/* ... */)\n // For simplicity, we only handle single-line /* */ comments here\n if (char === '/' && nextChar === '*') {\n const endIndex = line.indexOf('*/', i + 2);\n if (endIndex !== -1) {\n // Skip the comment\n i = endIndex + 1;\n continue;\n }\n }\n\n result += char;\n }\n\n return result;\n });\n\n return JSON.parse(cleanedLines.join('\\n'));\n};\n\n// Helper to find all tsconfig files (tsconfig.json, tsconfig.*.json)\nconst findTsConfigFiles = async (): Promise<string[]> => {\n try {\n const files = await readdir(rootDir);\n\n return files.filter(\n (file) => file === 'tsconfig.json' || /^tsconfig\\..+\\.json$/.test(file)\n );\n } catch {\n return [];\n }\n};\n\n/**\n * MAIN LOGIC\n */\n\nexport const initIntlayer = async () => {\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('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(gitignorePath)) {\n const gitignoreContent = await readFileFromRoot(gitignorePath);\n\n if (!gitignoreContent.includes('intlayer')) {\n const newContent = `${gitignoreContent}\\n\\n# Intlayer\\n.intlayer\\n`;\n await writeFileToRoot(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();\n\n let hasTsConfig = false;\n\n for (const fileName of tsConfigFiles) {\n if (await exists(fileName)) {\n hasTsConfig = true;\n try {\n const fileContent = await readFileFromRoot(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(fileName, JSON.stringify(config, null, 2));\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(file)) {\n let content = await readFileFromRoot(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(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(file)) {\n let content = await readFileFromRoot(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(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} ${colorize('Intlayer init setup complete.', ANSIColors.GREEN)}`);\n};\n"],"mappings":";;;;;;;;;AAeA,MAAM,UAAU,QAAQ,KAAK;AAG7B,MAAM,SAAS,OAAO,aAAqB;AACzC,KAAI;AACF,QAAM,OAAO,KAAK,SAAS,SAAS,CAAC;AACrC,SAAO;SACD;AACN,SAAO;;;AAKX,MAAM,mBAAmB,OAAO,aAC9B,MAAM,SAAS,KAAK,SAAS,SAAS,EAAE,OAAO;AAGjD,MAAM,kBAAkB,OAAO,UAAkB,YAC/C,MAAM,UAAU,KAAK,SAAS,SAAS,EAAE,SAAS,OAAO;AAG3D,MAAM,yBAAyB,eAAuB;AAEpD,KAAI;AACF,SAAO,KAAK,MAAM,WAAW;SACvB;CAQR,MAAM,eADQ,WAAW,MAAM,KAAK,CACT,KAAK,SAAS;EAEvC,IAAI,WAAW;EACf,IAAI,SAAS;AAEb,OAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;GACpC,MAAM,OAAO,KAAK;GAClB,MAAM,WAAW,KAAK,IAAI;AAG1B,OAAI,SAAS,SAAQ,MAAM,KAAK,KAAK,IAAI,OAAO,OAAO;AACrD,eAAW,CAAC;AACZ,cAAU;AACV;;AAIF,OAAI,UAAU;AACZ,cAAU;AACV;;AAIF,OAAI,SAAS,OAAO,aAAa,IAE/B;AAKF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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} ${colorize('Intlayer init setup complete.', ANSIColors.GREEN)}`);\n};\n"],"mappings":";;;;;;;;;;AAqBA,MAAa,eAAe,OAAO,YAAoB;AACrD,QAAO,SAAS,sCAAsC,WAAW,KAAK,CAAC;AAGvE,KAAI,CAAE,MAAM,OAAO,SAAS,eAAe,EAAG;AAC5C,SACE,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B,QAAQ;AAKjC,MAAK,MAAM,QAFS;EAAC;EAAkB;EAAkB;EAAkB,CAGzE,KAAI,MAAM,OAAO,SAAS,KAAK,EAAE;EAC/B,IAAI,UAAU,MAAM,iBAAiB,SAAS,KAAK;AAEnD,MAAI,CAAC,QAAQ,SAAS,gBAAgB,EAAE;AAKtC,aAAU,wFAAkB;AAC5B,SAAM,gBAAgB,SAAS,MAAM,QAAQ;AAC7C,UAAO,GAAG,EAAE,wBAAwB,aAAa,KAAK,GAAG;;AAE3D;;AAOJ,MAAK,MAAM,QAFS;EAAC;EAAkB;EAAmB;EAAiB,CAGzE,KAAI,MAAM,OAAO,SAAS,KAAK,EAAE;EAC/B,IAAI,UAAU,MAAM,iBAAiB,SAAS,KAAK;AAEnD,MAAI,CAAC,QAAQ,SAAS,gBAAgB,EAAE;AAKtC,aAAU,iGAAkB;AAC5B,SAAM,gBAAgB,SAAS,MAAM,QAAQ;AAC7C,UAAO,GAAG,EAAE,wBAAwB,aAAa,KAAK,GAAG;;AAE3D;;AAIJ,QAAO,GAAG,EAAE,GAAG,SAAS,iCAAiC,WAAW,MAAM,GAAG"}
@@ -0,0 +1,27 @@
1
+ import { access, readFile, writeFile } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+
4
+ //#region src/init/utils/fileSystem.ts
5
+ /**
6
+ * Helper to check if a file exists
7
+ */
8
+ const exists = async (rootDir, filePath) => {
9
+ try {
10
+ await access(join(rootDir, filePath));
11
+ return true;
12
+ } catch {
13
+ return false;
14
+ }
15
+ };
16
+ /**
17
+ * Helper to read a file
18
+ */
19
+ const readFileFromRoot = async (rootDir, filePath) => await readFile(join(rootDir, filePath), "utf8");
20
+ /**
21
+ * Helper to write a file
22
+ */
23
+ const writeFileToRoot = async (rootDir, filePath, content) => await writeFile(join(rootDir, filePath), content, "utf8");
24
+
25
+ //#endregion
26
+ export { exists, readFileFromRoot, writeFileToRoot };
27
+ //# sourceMappingURL=fileSystem.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileSystem.mjs","names":[],"sources":["../../../../src/init/utils/fileSystem.ts"],"sourcesContent":["import { access, readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n * Helper to check if a file exists\n */\nexport const exists = async (rootDir: string, filePath: string) => {\n try {\n await access(join(rootDir, filePath));\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Helper to read a file\n */\nexport const readFileFromRoot = async (rootDir: string, filePath: string) =>\n await readFile(join(rootDir, filePath), 'utf8');\n\n/**\n * Helper to write a file\n */\nexport const writeFileToRoot = async (\n rootDir: string,\n filePath: string,\n content: string\n) => await writeFile(join(rootDir, filePath), content, 'utf8');\n"],"mappings":";;;;;;;AAMA,MAAa,SAAS,OAAO,SAAiB,aAAqB;AACjE,KAAI;AACF,QAAM,OAAO,KAAK,SAAS,SAAS,CAAC;AACrC,SAAO;SACD;AACN,SAAO;;;;;;AAOX,MAAa,mBAAmB,OAAO,SAAiB,aACtD,MAAM,SAAS,KAAK,SAAS,SAAS,EAAE,OAAO;;;;AAKjD,MAAa,kBAAkB,OAC7B,SACA,UACA,YACG,MAAM,UAAU,KAAK,SAAS,SAAS,EAAE,SAAS,OAAO"}
@@ -0,0 +1,5 @@
1
+ import { exists, readFileFromRoot, writeFileToRoot } from "./fileSystem.mjs";
2
+ import { parseJSONWithComments } from "./jsonParser.mjs";
3
+ import { findTsConfigFiles } from "./tsConfig.mjs";
4
+
5
+ export { exists, findTsConfigFiles, parseJSONWithComments, readFileFromRoot, writeFileToRoot };
@@ -0,0 +1,41 @@
1
+ //#region src/init/utils/jsonParser.ts
2
+ /**
3
+ * Helper to parse JSON that may contain comments (tsconfig allows comments)
4
+ */
5
+ const parseJSONWithComments = (jsonString) => {
6
+ try {
7
+ return JSON.parse(jsonString);
8
+ } catch {}
9
+ const cleanedLines = jsonString.split("\n").map((line) => {
10
+ let inString = false;
11
+ let result = "";
12
+ for (let i = 0; i < line.length; i++) {
13
+ const char = line[i];
14
+ const nextChar = line[i + 1];
15
+ if (char === "\"" && (i === 0 || line[i - 1] !== "\\")) {
16
+ inString = !inString;
17
+ result += char;
18
+ continue;
19
+ }
20
+ if (inString) {
21
+ result += char;
22
+ continue;
23
+ }
24
+ if (char === "/" && nextChar === "/") break;
25
+ if (char === "/" && nextChar === "*") {
26
+ const endIndex = line.indexOf("*/", i + 2);
27
+ if (endIndex !== -1) {
28
+ i = endIndex + 1;
29
+ continue;
30
+ }
31
+ }
32
+ result += char;
33
+ }
34
+ return result;
35
+ });
36
+ return JSON.parse(cleanedLines.join("\n"));
37
+ };
38
+
39
+ //#endregion
40
+ export { parseJSONWithComments };
41
+ //# sourceMappingURL=jsonParser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonParser.mjs","names":[],"sources":["../../../../src/init/utils/jsonParser.ts"],"sourcesContent":["/**\n * Helper to parse JSON that may contain comments (tsconfig allows comments)\n */\nexport const parseJSONWithComments = (jsonString: string) => {\n // First, try parsing as-is (most tsconfig files don't have comments)\n try {\n return JSON.parse(jsonString);\n } catch {\n // If that fails, try stripping comments\n // Note: This simple approach removes comments line by line to avoid\n // matching glob patterns like /* and */ that appear in paths\n }\n\n // Process line by line to safely remove comments\n const lines = jsonString.split('\\n');\n const cleanedLines = lines.map((line) => {\n // Track if we're inside a string\n let inString = false;\n let result = '';\n\n for (let i = 0; i < line.length; i++) {\n const char = line[i];\n const nextChar = line[i + 1];\n\n // Handle string boundaries (accounting for escaped quotes)\n if (char === '\"' && (i === 0 || line[i - 1] !== '\\\\')) {\n inString = !inString;\n result += char;\n continue;\n }\n\n // If we're inside a string, keep the character\n if (inString) {\n result += char;\n continue;\n }\n\n // Check for single-line comment outside of strings\n if (char === '/' && nextChar === '/') {\n // Rest of line is a comment, stop here\n break;\n }\n\n // Check for multi-line comment start (/* ... */)\n // For simplicity, we only handle single-line /* */ comments here\n if (char === '/' && nextChar === '*') {\n const endIndex = line.indexOf('*/', i + 2);\n if (endIndex !== -1) {\n // Skip the comment\n i = endIndex + 1;\n continue;\n }\n }\n\n result += char;\n }\n\n return result;\n });\n\n return JSON.parse(cleanedLines.join('\\n'));\n};\n"],"mappings":";;;;AAGA,MAAa,yBAAyB,eAAuB;AAE3D,KAAI;AACF,SAAO,KAAK,MAAM,WAAW;SACvB;CAQR,MAAM,eADQ,WAAW,MAAM,KAAK,CACT,KAAK,SAAS;EAEvC,IAAI,WAAW;EACf,IAAI,SAAS;AAEb,OAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;GACpC,MAAM,OAAO,KAAK;GAClB,MAAM,WAAW,KAAK,IAAI;AAG1B,OAAI,SAAS,SAAQ,MAAM,KAAK,KAAK,IAAI,OAAO,OAAO;AACrD,eAAW,CAAC;AACZ,cAAU;AACV;;AAIF,OAAI,UAAU;AACZ,cAAU;AACV;;AAIF,OAAI,SAAS,OAAO,aAAa,IAE/B;AAKF,OAAI,SAAS,OAAO,aAAa,KAAK;IACpC,MAAM,WAAW,KAAK,QAAQ,MAAM,IAAI,EAAE;AAC1C,QAAI,aAAa,IAAI;AAEnB,SAAI,WAAW;AACf;;;AAIJ,aAAU;;AAGZ,SAAO;GACP;AAEF,QAAO,KAAK,MAAM,aAAa,KAAK,KAAK,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { readdir } from "node:fs/promises";
2
+
3
+ //#region src/init/utils/tsConfig.ts
4
+ /**
5
+ * Helper to find all tsconfig files (tsconfig.json, tsconfig.*.json)
6
+ */
7
+ const findTsConfigFiles = async (rootDir) => {
8
+ try {
9
+ return (await readdir(rootDir)).filter((file) => file === "tsconfig.json" || /^tsconfig\..+\.json$/.test(file));
10
+ } catch {
11
+ return [];
12
+ }
13
+ };
14
+
15
+ //#endregion
16
+ export { findTsConfigFiles };
17
+ //# sourceMappingURL=tsConfig.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsConfig.mjs","names":[],"sources":["../../../../src/init/utils/tsConfig.ts"],"sourcesContent":["import { readdir } from 'node:fs/promises';\n\n/**\n * Helper to find all tsconfig files (tsconfig.json, tsconfig.*.json)\n */\nexport const findTsConfigFiles = async (rootDir: string): Promise<string[]> => {\n try {\n const files = await readdir(rootDir);\n\n return files.filter(\n (file) => file === 'tsconfig.json' || /^tsconfig\\..+\\.json$/.test(file)\n );\n } catch {\n return [];\n }\n};\n"],"mappings":";;;;;;AAKA,MAAa,oBAAoB,OAAO,YAAuC;AAC7E,KAAI;AAGF,UAFc,MAAM,QAAQ,QAAQ,EAEvB,QACV,SAAS,SAAS,mBAAmB,uBAAuB,KAAK,KAAK,CACxE;SACK;AACN,SAAO,EAAE"}
@@ -1,25 +1,22 @@
1
- import { readFile, writeFile } from "node:fs/promises";
2
- import { dirname, join, relative } from "node:path";
1
+ import { readAsset } from "../_virtual/_utils_asset.mjs";
2
+ import { writeFile } from "node:fs/promises";
3
+ import { join, relative } from "node:path";
3
4
  import { colorizePath, logger, searchConfigurationFile, v } from "@intlayer/config";
4
- import { fileURLToPath } from "node:url";
5
5
 
6
6
  //#region src/initConfig/index.ts
7
7
  /**
8
8
  * UTILITIES
9
9
  */
10
10
  const rootDir = process.cwd();
11
- const isESModule = typeof import.meta.url === "string";
12
- const currentFileDir = isESModule ? dirname(fileURLToPath(import.meta.url)) : __dirname;
13
11
  const writeFileToRoot = async (filePath, content) => await writeFile(join(rootDir, filePath), content, "utf8");
14
- const readTemplate = async (templatePath) => await readFile(join(currentFileDir, "templates", templatePath), "utf8");
15
12
  const getTemplatePath = (format) => {
16
13
  switch (format) {
17
- case "ts": return "ts.txt";
18
- case "cjs": return "cjs.txt";
19
- case "mjs": return "mjs.txt";
20
- case "js": return "js.txt";
21
- case "json": return "json.txt";
22
- default: return "ts.txt";
14
+ case "ts": return "./templates/ts.txt";
15
+ case "cjs": return "./templates/cjs.txt";
16
+ case "mjs": return "./templates/mjs.txt";
17
+ case "js": return "./templates/mjs.txt";
18
+ case "json": return "./templates/json.txt";
19
+ default: return "./templates/ts.txt";
23
20
  }
24
21
  };
25
22
  /**
@@ -31,10 +28,10 @@ const initConfig = async (format, baseDir) => {
31
28
  logger(`${v} ${colorizePath(relative(baseDir, configurationFilePath))} already exists`);
32
29
  return;
33
30
  }
34
- await writeFileToRoot(format, await readTemplate(getTemplatePath(format.split(".").pop())));
31
+ await writeFileToRoot(format, readAsset(getTemplatePath(format.split(".").pop())));
35
32
  logger(`Created ${format}`);
36
33
  };
37
34
 
38
35
  //#endregion
39
- export { initConfig, isESModule };
36
+ export { initConfig };
40
37
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/initConfig/index.ts"],"sourcesContent":["import { readFile, writeFile } from 'node:fs/promises';\nimport { dirname, join, relative } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n colorizePath,\n type configurationFilesCandidates,\n logger,\n searchConfigurationFile,\n v,\n} from '@intlayer/config';\n\n/**\n * UTILITIES\n */\nconst rootDir = process.cwd();\nexport const isESModule = typeof import.meta.url === 'string';\n\nconst currentFileDir = isESModule\n ? dirname(fileURLToPath(import.meta.url))\n : __dirname;\n\n// Helper to write a file\nconst writeFileToRoot = async (filePath: string, content: string) =>\n await writeFile(join(rootDir, filePath), content, 'utf8');\n\n// Helper to read a template file\nconst readTemplate = async (templatePath: string) =>\n await readFile(join(currentFileDir, 'templates', templatePath), 'utf8');\n\ntype ConfigFormat = 'ts' | 'cjs' | 'mjs' | 'js' | 'json';\n\nconst getTemplatePath = (format: ConfigFormat) => {\n switch (format) {\n case 'ts':\n return 'ts.txt';\n case 'cjs':\n return 'cjs.txt';\n case 'mjs':\n return 'mjs.txt';\n case 'js':\n return 'js.txt';\n case 'json':\n return 'json.txt';\n default:\n return 'ts.txt';\n }\n};\n\n/**\n * Initialize the Intlayer configuration file\n */\nexport const initConfig = async (\n format: (typeof configurationFilesCandidates)[number],\n baseDir: string\n) => {\n // Search for configuration file\n const { configurationFilePath } = searchConfigurationFile(baseDir);\n\n // return if the configuration file is found\n if (configurationFilePath) {\n const relativePath = relative(baseDir, configurationFilePath);\n logger(`${v} ${colorizePath(relativePath)} already exists`);\n return;\n }\n\n // Extract the format from the filename (e.g. 'intlayer.config.ts' -> 'ts')\n const extension = format.split('.').pop() as ConfigFormat;\n\n const templatePath = getTemplatePath(extension);\n const configContent = await readTemplate(templatePath);\n\n await writeFileToRoot(format, configContent);\n logger(`Created ${format}`);\n};\n"],"mappings":";;;;;;;;;AAcA,MAAM,UAAU,QAAQ,KAAK;AAC7B,MAAa,aAAa,OAAO,OAAO,KAAK,QAAQ;AAErD,MAAM,iBAAiB,aACnB,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC,GACvC;AAGJ,MAAM,kBAAkB,OAAO,UAAkB,YAC/C,MAAM,UAAU,KAAK,SAAS,SAAS,EAAE,SAAS,OAAO;AAG3D,MAAM,eAAe,OAAO,iBAC1B,MAAM,SAAS,KAAK,gBAAgB,aAAa,aAAa,EAAE,OAAO;AAIzE,MAAM,mBAAmB,WAAyB;AAChD,SAAQ,QAAR;EACE,KAAK,KACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,KACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,QACE,QAAO;;;;;;AAOb,MAAa,aAAa,OACxB,QACA,YACG;CAEH,MAAM,EAAE,0BAA0B,wBAAwB,QAAQ;AAGlE,KAAI,uBAAuB;AAEzB,SAAO,GAAG,EAAE,GAAG,aADM,SAAS,SAAS,sBAAsB,CACpB,CAAC,iBAAiB;AAC3D;;AASF,OAAM,gBAAgB,QAFA,MAAM,aADP,gBAFH,OAAO,MAAM,IAAI,CAAC,KAAK,CAEM,CACO,CAEV;AAC5C,QAAO,WAAW,SAAS"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/initConfig/index.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport {\n colorizePath,\n type configurationFilesCandidates,\n logger,\n searchConfigurationFile,\n v,\n} from '@intlayer/config';\n\n/**\n * UTILITIES\n */\nconst rootDir = process.cwd();\n\n// Helper to write a file\nconst writeFileToRoot = async (filePath: string, content: string) =>\n await writeFile(join(rootDir, filePath), content, 'utf8');\n\ntype ConfigFormat = 'ts' | 'cjs' | 'mjs' | 'js' | 'json';\n\nconst getTemplatePath = (format: ConfigFormat) => {\n switch (format) {\n case 'ts':\n return './templates/ts.txt';\n case 'cjs':\n return './templates/cjs.txt';\n case 'mjs':\n return './templates/mjs.txt';\n case 'js':\n return './templates/mjs.txt';\n case 'json':\n return './templates/json.txt';\n default:\n return './templates/ts.txt';\n }\n};\n\n/**\n * Initialize the Intlayer configuration file\n */\nexport const initConfig = async (\n format: (typeof configurationFilesCandidates)[number],\n baseDir: string\n) => {\n // Search for configuration file\n const { configurationFilePath } = searchConfigurationFile(baseDir);\n\n // return if the configuration file is found\n if (configurationFilePath) {\n const relativePath = relative(baseDir, configurationFilePath);\n logger(`${v} ${colorizePath(relativePath)} already exists`);\n return;\n }\n\n // Extract the format from the filename (e.g. 'intlayer.config.ts' -> 'ts')\n const extension = format.split('.').pop() as ConfigFormat;\n\n const templatePath = getTemplatePath(extension);\n const configContent = readAsset(templatePath);\n\n await writeFileToRoot(format, configContent);\n logger(`Created ${format}`);\n};\n"],"mappings":";;;;;;;;;AAcA,MAAM,UAAU,QAAQ,KAAK;AAG7B,MAAM,kBAAkB,OAAO,UAAkB,YAC/C,MAAM,UAAU,KAAK,SAAS,SAAS,EAAE,SAAS,OAAO;AAI3D,MAAM,mBAAmB,WAAyB;AAChD,SAAQ,QAAR;EACE,KAAK,KACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,KACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,QACE,QAAO;;;;;;AAOb,MAAa,aAAa,OACxB,QACA,YACG;CAEH,MAAM,EAAE,0BAA0B,wBAAwB,QAAQ;AAGlE,KAAI,uBAAuB;AAEzB,SAAO,GAAG,EAAE,GAAG,aADM,SAAS,SAAS,sBAAsB,CACpB,CAAC,iBAAiB;AAC3D;;AASF,OAAM,gBAAgB,QAFA,UADD,gBAFH,OAAO,MAAM,IAAI,CAAC,KAAK,CAEM,CACF,CAED;AAC5C,QAAO,WAAW,SAAS"}
@@ -10,7 +10,7 @@ import { getAppLogger, getConfiguration } from "@intlayer/config";
10
10
  import { watch as watch$1 } from "chokidar";
11
11
 
12
12
  //#region src/watcher.ts
13
- /** @ts-ignore remove error Module '"chokidar"' has no exported member 'ChokidarOptions'. */
13
+ /** @ts-ignore remove error Module '"chokidar"' has no exported member 'ChokidarOptions' */
14
14
  const pendingUnlinks = /* @__PURE__ */ new Map();
15
15
  const watch = (options) => {
16
16
  const configuration = options?.configuration ?? getConfiguration(options?.configOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.mjs","names":["configuration: IntlayerConfig","chokidarWatch","matchedOldPath: string | undefined"],"sources":["../../src/watcher.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport {\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions'. */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { handleAdditionalContentDeclarationFile } from './handleAdditionalContentDeclarationFile';\nimport { handleContentDeclarationFileChange } from './handleContentDeclarationFileChange';\nimport { handleContentDeclarationFileMoved } from './handleContentDeclarationFileMoved';\nimport { handleUnlinkedContentDeclarationFile } from './handleUnlinkedContentDeclarationFile';\nimport { prepareIntlayer } from './prepareIntlayer';\nimport { writeContentDeclaration } from './writeContentDeclaration';\n\n// Map to track files that were recently unlinked: oldPath -> { timer, timestamp }\nconst pendingUnlinks = new Map<\n string,\n { timer: NodeJS.Timeout; oldPath: string }\n>();\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n configOptions?: GetConfigurationOptions;\n skipPrepare?: boolean;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration: IntlayerConfig =\n options?.configuration ?? getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n\n const {\n watch: isWatchMode,\n watchedFilesPatternWithPath,\n fileExtensions,\n } = configuration.content;\n\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n awaitWriteFinish: {\n stabilityThreshold: 1000,\n pollInterval: 100,\n },\n ignored: [\n '**/node_modules/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n ],\n ...options,\n })\n .on('add', async (filePath) => {\n const fileName = basename(filePath);\n let isMove = false;\n\n // 1. Check if this Add corresponds to a pending Unlink (Move/Rename detection)\n // Heuristic:\n // - Priority A: Exact basename match (Moved to different folder)\n // - Priority B: Single entry in pendingUnlinks (Renamed file)\n let matchedOldPath: string | undefined;\n\n // Search for basename match\n for (const [oldPath] of pendingUnlinks) {\n if (basename(oldPath) === fileName) {\n matchedOldPath = oldPath;\n break;\n }\n }\n\n // If no basename match, but exactly one file was recently unlinked, assume it's a rename\n if (!matchedOldPath && pendingUnlinks.size === 1) {\n matchedOldPath = pendingUnlinks.keys().next().value;\n }\n\n if (matchedOldPath) {\n // It is a move! Cancel the unlink handler\n const pending = pendingUnlinks.get(matchedOldPath);\n if (pending) {\n clearTimeout(pending.timer);\n pendingUnlinks.delete(matchedOldPath);\n }\n\n isMove = true;\n appLogger(`File moved from ${matchedOldPath} to ${filePath}`);\n\n await handleContentDeclarationFileMoved(\n matchedOldPath,\n filePath,\n configuration\n );\n }\n\n // 2. If it's NOT a move, perform standard \"New File\" logic\n if (!isMove) {\n const fileContent = await readFile(filePath, 'utf-8');\n const isEmpty = fileContent === '';\n\n // Fill template content declaration file if it is empty\n if (isEmpty) {\n const extensionPattern = fileExtensions\n .map((ext) => ext.replace(/\\./g, '\\\\.'))\n .join('|');\n const name = fileName.replace(\n new RegExp(`(${extensionPattern})$`),\n ''\n );\n\n await writeContentDeclaration(\n {\n key: name,\n content: {},\n filePath,\n },\n configuration\n );\n }\n }\n\n // 3. Always ensure the file is processed (both for moves and adds)\n await handleAdditionalContentDeclarationFile(filePath, configuration);\n })\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('unlink', async (filePath) => {\n // Delay unlink processing to see if an 'add' event occurs (indicating a move)\n const timer = setTimeout(async () => {\n // If timer fires, the file was genuinely removed\n pendingUnlinks.delete(filePath);\n await handleUnlinkedContentDeclarationFile(filePath, configuration);\n }, 200); // 200ms window to catch the 'add' event\n\n pendingUnlinks.set(filePath, { timer, oldPath: filePath });\n })\n .on('error', async (error) => {\n appLogger(`Watcher error: ${error}`, {\n level: 'error',\n });\n\n appLogger('Restarting watcher');\n\n await prepareIntlayer(configuration);\n });\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const { skipPrepare, ...rest } = options ?? {};\n const configuration =\n options?.configuration ?? getConfiguration(options?.configOptions);\n\n if (!skipPrepare) {\n await prepareIntlayer(configuration, { forceRun: true });\n }\n\n if (configuration.content.watch || options?.persistent) {\n const appLogger = getAppLogger(configuration);\n\n appLogger('Watching Intlayer content declarations');\n watch({ ...rest, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAM,iCAAiB,IAAI,KAGxB;AASH,MAAa,SAAS,YAA2B;CAC/C,MAAMA,gBACJ,SAAS,iBAAiB,iBAAiB,SAAS,cAAc;CACpE,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,EACJ,OAAO,aACP,6BACA,mBACE,cAAc;AAElB,QAAOC,QAAc,6BAA6B;EAChD,YAAY;EACZ,eAAe;EACf,kBAAkB;GAChB,oBAAoB;GACpB,cAAc;GACf;EACD,SAAS;GACP;GACA;GACA;GACA;GACD;EACD,GAAG;EACJ,CAAC,CACC,GAAG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EAAE,aAAa,GAAG,SAAS,WAAW,EAAE;CAC9C,MAAM,gBACJ,SAAS,iBAAiB,iBAAiB,SAAS,cAAc;AAEpE,KAAI,CAAC,YACH,OAAM,gBAAgB,eAAe,EAAE,UAAU,MAAM,CAAC;AAG1D,KAAI,cAAc,QAAQ,SAAS,SAAS,YAAY;AAGtD,EAFkB,aAAa,cAAc,CAEnC,yCAAyC;AACnD,QAAM;GAAE,GAAG;GAAM;GAAe,CAAC"}
1
+ {"version":3,"file":"watcher.mjs","names":["configuration: IntlayerConfig","chokidarWatch","matchedOldPath: string | undefined"],"sources":["../../src/watcher.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport {\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { handleAdditionalContentDeclarationFile } from './handleAdditionalContentDeclarationFile';\nimport { handleContentDeclarationFileChange } from './handleContentDeclarationFileChange';\nimport { handleContentDeclarationFileMoved } from './handleContentDeclarationFileMoved';\nimport { handleUnlinkedContentDeclarationFile } from './handleUnlinkedContentDeclarationFile';\nimport { prepareIntlayer } from './prepareIntlayer';\nimport { writeContentDeclaration } from './writeContentDeclaration';\n\n// Map to track files that were recently unlinked: oldPath -> { timer, timestamp }\nconst pendingUnlinks = new Map<\n string,\n { timer: NodeJS.Timeout; oldPath: string }\n>();\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n configOptions?: GetConfigurationOptions;\n skipPrepare?: boolean;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration: IntlayerConfig =\n options?.configuration ?? getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n\n const {\n watch: isWatchMode,\n watchedFilesPatternWithPath,\n fileExtensions,\n } = configuration.content;\n\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n awaitWriteFinish: {\n stabilityThreshold: 1000,\n pollInterval: 100,\n },\n ignored: [\n '**/node_modules/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n ],\n ...options,\n })\n .on('add', async (filePath) => {\n const fileName = basename(filePath);\n let isMove = false;\n\n // Check if this Add corresponds to a pending Unlink (Move/Rename detection)\n // Heuristic:\n // - Priority A: Exact basename match (Moved to different folder)\n // - Priority B: Single entry in pendingUnlinks (Renamed file)\n let matchedOldPath: string | undefined;\n\n // Search for basename match\n for (const [oldPath] of pendingUnlinks) {\n if (basename(oldPath) === fileName) {\n matchedOldPath = oldPath;\n break;\n }\n }\n\n // If no basename match, but exactly one file was recently unlinked, assume it's a rename\n if (!matchedOldPath && pendingUnlinks.size === 1) {\n matchedOldPath = pendingUnlinks.keys().next().value;\n }\n\n if (matchedOldPath) {\n // It is a move! Cancel the unlink handler\n const pending = pendingUnlinks.get(matchedOldPath);\n if (pending) {\n clearTimeout(pending.timer);\n pendingUnlinks.delete(matchedOldPath);\n }\n\n isMove = true;\n appLogger(`File moved from ${matchedOldPath} to ${filePath}`);\n\n await handleContentDeclarationFileMoved(\n matchedOldPath,\n filePath,\n configuration\n );\n }\n\n // If it's NOT a move, perform standard \"New File\" logic\n if (!isMove) {\n const fileContent = await readFile(filePath, 'utf-8');\n const isEmpty = fileContent === '';\n\n // Fill template content declaration file if it is empty\n if (isEmpty) {\n const extensionPattern = fileExtensions\n .map((ext) => ext.replace(/\\./g, '\\\\.'))\n .join('|');\n const name = fileName.replace(\n new RegExp(`(${extensionPattern})$`),\n ''\n );\n\n await writeContentDeclaration(\n {\n key: name,\n content: {},\n filePath,\n },\n configuration\n );\n }\n }\n\n // Always ensure the file is processed (both for moves and adds)\n await handleAdditionalContentDeclarationFile(filePath, configuration);\n })\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('unlink', async (filePath) => {\n // Delay unlink processing to see if an 'add' event occurs (indicating a move)\n const timer = setTimeout(async () => {\n // If timer fires, the file was genuinely removed\n pendingUnlinks.delete(filePath);\n await handleUnlinkedContentDeclarationFile(filePath, configuration);\n }, 200); // 200ms window to catch the 'add' event\n\n pendingUnlinks.set(filePath, { timer, oldPath: filePath });\n })\n .on('error', async (error) => {\n appLogger(`Watcher error: ${error}`, {\n level: 'error',\n });\n\n appLogger('Restarting watcher');\n\n await prepareIntlayer(configuration);\n });\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const { skipPrepare, ...rest } = options ?? {};\n const configuration =\n options?.configuration ?? getConfiguration(options?.configOptions);\n\n if (!skipPrepare) {\n await prepareIntlayer(configuration, { forceRun: true });\n }\n\n if (configuration.content.watch || options?.persistent) {\n const appLogger = getAppLogger(configuration);\n\n appLogger('Watching Intlayer content declarations');\n watch({ ...rest, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAM,iCAAiB,IAAI,KAGxB;AASH,MAAa,SAAS,YAA2B;CAC/C,MAAMA,gBACJ,SAAS,iBAAiB,iBAAiB,SAAS,cAAc;CACpE,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,EACJ,OAAO,aACP,6BACA,mBACE,cAAc;AAElB,QAAOC,QAAc,6BAA6B;EAChD,YAAY;EACZ,eAAe;EACf,kBAAkB;GAChB,oBAAoB;GACpB,cAAc;GACf;EACD,SAAS;GACP;GACA;GACA;GACA;GACD;EACD,GAAG;EACJ,CAAC,CACC,GAAG,OAAO,OAAO,aAAa;EAC7B,MAAM,WAAW,SAAS,SAAS;EACnC,IAAI,SAAS;EAMb,IAAIC;AAGJ,OAAK,MAAM,CAAC,YAAY,eACtB,KAAI,SAAS,QAAQ,KAAK,UAAU;AAClC,oBAAiB;AACjB;;AAKJ,MAAI,CAAC,kBAAkB,eAAe,SAAS,EAC7C,kBAAiB,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Ac,CAEnC,yCAAyC;AACnD,QAAM;GAAE,GAAG;GAAM;GAAe,CAAC"}
@@ -1,14 +1,14 @@
1
1
  import { UnmergedDictionaryOutput } from "./writeUnmergedDictionary.js";
2
2
  import { MergedDictionaryOutput } from "./writeMergedDictionary.js";
3
3
  import { LocalizedDictionaryOutput } from "./writeDynamicDictionary.js";
4
- import * as _intlayer_types0 from "@intlayer/types";
4
+ import * as _intlayer_types1 from "@intlayer/types";
5
5
  import { Dictionary } from "@intlayer/types";
6
6
 
7
7
  //#region src/buildIntlayerDictionary/buildIntlayerDictionary.d.ts
8
8
  /**
9
9
  * This function transpile the bundled code to to make dictionaries as JSON files
10
10
  */
11
- declare const buildDictionary: (localDictionariesEntries: Dictionary[], configuration?: _intlayer_types0.IntlayerConfig, formats?: ("cjs" | "esm")[], importOtherDictionaries?: boolean) => Promise<{
11
+ declare const buildDictionary: (localDictionariesEntries: Dictionary[], configuration?: _intlayer_types1.IntlayerConfig, formats?: ("cjs" | "esm")[], importOtherDictionaries?: boolean) => Promise<{
12
12
  unmergedDictionaries: UnmergedDictionaryOutput;
13
13
  mergedDictionaries: MergedDictionaryOutput;
14
14
  dynamicDictionaries: LocalizedDictionaryOutput;
@@ -1,5 +1,5 @@
1
1
  import { UnmergedDictionaryOutput } from "./writeUnmergedDictionary.js";
2
- import * as _intlayer_types5 from "@intlayer/types";
2
+ import * as _intlayer_types22 from "@intlayer/types";
3
3
  import { Dictionary } from "@intlayer/types";
4
4
 
5
5
  //#region src/buildIntlayerDictionary/writeMergedDictionary.d.ts
@@ -24,7 +24,7 @@ type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;
24
24
  * // { key: 'home', content: { ... } },
25
25
  * ```
26
26
  */
27
- declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration?: _intlayer_types5.IntlayerConfig) => Promise<MergedDictionaryOutput>;
27
+ declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration?: _intlayer_types22.IntlayerConfig) => Promise<MergedDictionaryOutput>;
28
28
  //#endregion
29
29
  export { MergedDictionaryOutput, MergedDictionaryResult, writeMergedDictionaries };
30
30
  //# sourceMappingURL=writeMergedDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeMergedDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":[],"mappings":";;;;;KASY,sBAAA;;cAEE;AAFd,CAAA;AAKY,KAAA,sBAAA,GAAyB,MAAe,CAAA,MAAA,EAAA,sBAAT,CAAA;AAkB3C;;;;;;;;;;;;;;;;cAAa,+CACU,0CAAwB,gBAAA,CAC7C,mBACC,QAAQ"}
1
+ {"version":3,"file":"writeMergedDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":[],"mappings":";;;;;KASY,sBAAA;;cAEE;AAFd,CAAA;AAKY,KAAA,sBAAA,GAAyB,MAAe,CAAA,MAAA,EAAA,sBAAT,CAAA;AAkB3C;;;;;;;;;;;;;;;;cAAa,+CACU,0CAAwB,iBAAA,CAC7C,mBACC,QAAQ"}
@@ -1,4 +1,4 @@
1
- import * as _intlayer_types4 from "@intlayer/types";
1
+ import * as _intlayer_types18 from "@intlayer/types";
2
2
  import { Dictionary } from "@intlayer/types";
3
3
 
4
4
  //#region src/buildIntlayerDictionary/writeRemoteDictionary.d.ts
@@ -23,7 +23,7 @@ type RemoteDictionaryOutput = Record<string, RemoteDictionaryResult>;
23
23
  * // { key: 'home', content: { ... } },
24
24
  * ```
25
25
  */
26
- declare const writeRemoteDictionary: (remoteDictionaries: Dictionary[], configuration?: _intlayer_types4.IntlayerConfig) => Promise<RemoteDictionaryOutput>;
26
+ declare const writeRemoteDictionary: (remoteDictionaries: Dictionary[], configuration?: _intlayer_types18.IntlayerConfig) => Promise<RemoteDictionaryOutput>;
27
27
  //#endregion
28
28
  export { RemoteDictionaryOutput, RemoteDictionaryResult, writeRemoteDictionary };
29
29
  //# sourceMappingURL=writeRemoteDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeRemoteDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":[],"mappings":";;;;KAcY,sBAAA;;gBAEI;AAFhB,CAAA;AAKY,KAAA,sBAAA,GAAyB,MAAe,CAAA,MAAA,EAAA,sBAAT,CAAA;AAkB3C;;;;;;;;;;;;;;;;cAAa,4CACS,8BAAU,gBAAA,CAC9B,mBACC,QAAQ"}
1
+ {"version":3,"file":"writeRemoteDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":[],"mappings":";;;;KAcY,sBAAA;;gBAEI;AAFhB,CAAA;AAKY,KAAA,sBAAA,GAAyB,MAAe,CAAA,MAAA,EAAA,sBAAT,CAAA;AAkB3C;;;;;;;;;;;;;;;;cAAa,4CACS,8BAAU,iBAAA,CAC9B,mBACC,QAAQ"}
@@ -1,4 +1,4 @@
1
- import * as _intlayer_types6 from "@intlayer/types";
1
+ import * as _intlayer_types20 from "@intlayer/types";
2
2
 
3
3
  //#region src/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts
4
4
  type CreateDictionaryEntryPointOptions = {
@@ -8,7 +8,7 @@ type CreateDictionaryEntryPointOptions = {
8
8
  /**
9
9
  * This function generates a list of dictionaries in the main directory
10
10
  */
11
- declare const createDictionaryEntryPoint: (configuration?: _intlayer_types6.IntlayerConfig, options?: CreateDictionaryEntryPointOptions) => Promise<void>;
11
+ declare const createDictionaryEntryPoint: (configuration?: _intlayer_types20.IntlayerConfig, options?: CreateDictionaryEntryPointOptions) => Promise<void>;
12
12
  //#endregion
13
13
  export { CreateDictionaryEntryPointOptions, createDictionaryEntryPoint };
14
14
  //# sourceMappingURL=createDictionaryEntryPoint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createDictionaryEntryPoint.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"sourcesContent":[],"mappings":";;;KAqCY,iCAAA;;;AAAZ,CAAA;AAQA;;;AAEiD,cAFpC,0BAEoC,EAAA,CAAA,aAAA,CAAA,EAiFhD,gBAAA,CAlFC,cAC+C,EAAA,OAAA,CAAA,EAAtC,iCAAsC,EAAA,GAAA,OAAA,CAAA,IAAA,CAAA"}
1
+ {"version":3,"file":"createDictionaryEntryPoint.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"sourcesContent":[],"mappings":";;;KAqCY,iCAAA;;;AAAZ,CAAA;AAQA;;;AAEiD,cAFpC,0BAEoC,EAAA,CAAA,aAAA,CAAA,EAiFhD,iBAAA,CAlFC,cAC+C,EAAA,OAAA,CAAA,EAAtC,iCAAsC,EAAA,GAAA,OAAA,CAAA,IAAA,CAAA"}
@@ -1,10 +1,10 @@
1
- import * as _intlayer_types7 from "@intlayer/types";
1
+ import * as _intlayer_types21 from "@intlayer/types";
2
2
 
3
3
  //#region src/createDictionaryEntryPoint/generateDictionaryListContent.d.ts
4
4
  /**
5
5
  * This function generates the content of the dictionary list file
6
6
  */
7
- declare const generateDictionaryListContent: (dictionaries: string[], functionName: string, importType: "json" | "javascript", format?: "cjs" | "esm", configuration?: _intlayer_types7.IntlayerConfig) => string;
7
+ declare const generateDictionaryListContent: (dictionaries: string[], functionName: string, importType: "json" | "javascript", format?: "cjs" | "esm", configuration?: _intlayer_types21.IntlayerConfig) => string;
8
8
  //#endregion
9
9
  export { generateDictionaryListContent };
10
10
  //# sourceMappingURL=generateDictionaryListContent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateDictionaryListContent.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"sourcesContent":[],"mappings":";;;;;;AAOa,cAAA,6BAgDZ,EAAA,CAAA,YA3CC,EAAA,MAAA,EAAA,EAAA,YAAkC,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,GAAA,YAAA,EAAA,MAAA,CAAA,EAAA,KAAA,GAAA,KAAA,EAAA,aAAA,CAAA,EA2CnC,gBAAA,CA3CC,cAAkC,EAAA,GAAA,MAAA"}
1
+ {"version":3,"file":"generateDictionaryListContent.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"sourcesContent":[],"mappings":";;;;;;AAOa,cAAA,6BAgDZ,EAAA,CAAA,YAAA,EA3CC,MAAA,EAAA,EAAA,YAAkC,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,GAAA,YAAA,EAAA,MAAA,CAAA,EAAA,KAAA,GAAA,KAAA,EAAA,aAAA,CAAA,EA2CnC,iBAAA,CA3CC,cAAkC,EAAA,GAAA,MAAA"}
@@ -1,4 +1,4 @@
1
- import * as _intlayer_types8 from "@intlayer/types";
1
+ import * as _intlayer_types4 from "@intlayer/types";
2
2
  import { Dictionary } from "@intlayer/types";
3
3
  import * as _intlayer_core_messageFormat0 from "@intlayer/core/messageFormat";
4
4
 
@@ -9,45 +9,45 @@ declare const formatDictionaryOutput: (dictionary: Dictionary) => Dictionary | {
9
9
  format: string;
10
10
  content: _intlayer_core_messageFormat0.JsonValue;
11
11
  $schema?: string;
12
- id?: _intlayer_types8.DictionaryId;
12
+ id?: _intlayer_types4.DictionaryId;
13
13
  projectIds?: string[];
14
- localId?: _intlayer_types8.LocalDictionaryId;
15
- localIds?: _intlayer_types8.LocalDictionaryId[];
16
- key: _intlayer_types8.DictionaryKey;
14
+ localId?: _intlayer_types4.LocalDictionaryId;
15
+ localIds?: _intlayer_types4.LocalDictionaryId[];
16
+ key: _intlayer_types4.DictionaryKey;
17
17
  title?: string;
18
18
  description?: string;
19
19
  versions?: string[];
20
20
  version?: string;
21
21
  filePath?: string;
22
22
  tags?: string[];
23
- locale?: _intlayer_types8.LocalesValues;
24
- fill?: _intlayer_types8.Fill;
23
+ locale?: _intlayer_types4.LocalesValues;
24
+ fill?: _intlayer_types4.Fill;
25
25
  filled?: true;
26
26
  priority?: number;
27
27
  live?: boolean;
28
- location?: _intlayer_types8.DictionaryLocation;
28
+ location?: _intlayer_types4.DictionaryLocation;
29
29
  };
30
30
  declare const formatDictionariesOutput: (dictionaries: Dictionary[]) => (Dictionary | {
31
31
  format: string;
32
32
  content: _intlayer_core_messageFormat0.JsonValue;
33
33
  $schema?: string;
34
- id?: _intlayer_types8.DictionaryId;
34
+ id?: _intlayer_types4.DictionaryId;
35
35
  projectIds?: string[];
36
- localId?: _intlayer_types8.LocalDictionaryId;
37
- localIds?: _intlayer_types8.LocalDictionaryId[];
38
- key: _intlayer_types8.DictionaryKey;
36
+ localId?: _intlayer_types4.LocalDictionaryId;
37
+ localIds?: _intlayer_types4.LocalDictionaryId[];
38
+ key: _intlayer_types4.DictionaryKey;
39
39
  title?: string;
40
40
  description?: string;
41
41
  versions?: string[];
42
42
  version?: string;
43
43
  filePath?: string;
44
44
  tags?: string[];
45
- locale?: _intlayer_types8.LocalesValues;
46
- fill?: _intlayer_types8.Fill;
45
+ locale?: _intlayer_types4.LocalesValues;
46
+ fill?: _intlayer_types4.Fill;
47
47
  filled?: true;
48
48
  priority?: number;
49
49
  live?: boolean;
50
- location?: _intlayer_types8.DictionaryLocation;
50
+ location?: _intlayer_types4.DictionaryLocation;
51
51
  })[];
52
52
  //#endregion
53
53
  export { formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput };
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * MAIN LOGIC
4
4
  */
5
- declare const initIntlayer: () => Promise<void>;
5
+ declare const initIntlayer: (rootDir: string) => Promise<void>;
6
6
  //#endregion
7
7
  export { initIntlayer };
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/init/index.ts"],"sourcesContent":[],"mappings":";;AAiHA;;cAAa,oBAAY"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/init/index.ts"],"sourcesContent":[],"mappings":";;AAqBA;;cAAa,mCAAqC"}
@@ -0,0 +1,16 @@
1
+ //#region src/init/utils/fileSystem.d.ts
2
+ /**
3
+ * Helper to check if a file exists
4
+ */
5
+ declare const exists: (rootDir: string, filePath: string) => Promise<boolean>;
6
+ /**
7
+ * Helper to read a file
8
+ */
9
+ declare const readFileFromRoot: (rootDir: string, filePath: string) => Promise<string>;
10
+ /**
11
+ * Helper to write a file
12
+ */
13
+ declare const writeFileToRoot: (rootDir: string, filePath: string, content: string) => Promise<void>;
14
+ //#endregion
15
+ export { exists, readFileFromRoot, writeFileToRoot };
16
+ //# sourceMappingURL=fileSystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileSystem.d.ts","names":[],"sources":["../../../../src/init/utils/fileSystem.ts"],"sourcesContent":[],"mappings":";;AAMA;AAYA;AAMa,cAlBA,MAsBiD,EAAA,CAAA,OAD7C,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,GArB6C,OAqB7C,CAAA,OAAA,CAAA;;;;cATJ,yDAA2D;;;;cAM3D,yEAGI"}
@@ -0,0 +1,4 @@
1
+ import { exists, readFileFromRoot, writeFileToRoot } from "./fileSystem.js";
2
+ import { parseJSONWithComments } from "./jsonParser.js";
3
+ import { findTsConfigFiles } from "./tsConfig.js";
4
+ export { exists, findTsConfigFiles, parseJSONWithComments, readFileFromRoot, writeFileToRoot };