@intlayer/chokidar 7.5.3 → 7.5.5

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 (78) hide show
  1. package/dist/cjs/cleanRemovedContentDeclaration.cjs +54 -25
  2. package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
  3. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +7 -6
  4. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
  5. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +7 -3
  6. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
  7. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +7 -3
  8. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
  9. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +7 -3
  10. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
  11. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +7 -3
  12. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
  13. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +7 -3
  14. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
  15. package/dist/cjs/createType/createModuleAugmentation.cjs +1 -1
  16. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +2 -2
  17. package/dist/cjs/handleContentDeclarationFileChange.cjs +14 -13
  18. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  19. package/dist/cjs/handleContentDeclarationFileMoved.cjs +24 -0
  20. package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -0
  21. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +5 -8
  22. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
  23. package/dist/cjs/index.cjs +2 -2
  24. package/dist/cjs/prepareIntlayer.cjs +1 -1
  25. package/dist/cjs/watcher.cjs +36 -15
  26. package/dist/cjs/watcher.cjs.map +1 -1
  27. package/dist/esm/cleanRemovedContentDeclaration.mjs +54 -26
  28. package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
  29. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +7 -6
  30. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
  31. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +7 -3
  32. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
  33. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +7 -3
  34. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
  35. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +7 -3
  36. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
  37. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +7 -3
  38. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
  39. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +7 -3
  40. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
  41. package/dist/esm/createType/createModuleAugmentation.mjs +1 -1
  42. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +2 -2
  43. package/dist/esm/handleContentDeclarationFileChange.mjs +14 -13
  44. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
  45. package/dist/esm/handleContentDeclarationFileMoved.mjs +23 -0
  46. package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -0
  47. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +5 -8
  48. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
  49. package/dist/esm/index.mjs +2 -2
  50. package/dist/esm/prepareIntlayer.mjs +1 -1
  51. package/dist/esm/watcher.mjs +36 -15
  52. package/dist/esm/watcher.mjs.map +1 -1
  53. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -2
  54. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
  55. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +3 -3
  56. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -2
  57. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
  58. package/dist/types/cleanRemovedContentDeclaration.d.ts +5 -1
  59. package/dist/types/cleanRemovedContentDeclaration.d.ts.map +1 -1
  60. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +7 -3
  61. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
  62. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
  63. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +1 -1
  64. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts.map +1 -1
  65. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +1 -1
  66. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts.map +1 -1
  67. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +1 -1
  68. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts.map +1 -1
  69. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +1 -1
  70. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts.map +1 -1
  71. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +1 -1
  72. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts.map +1 -1
  73. package/dist/types/createDictionaryEntryPoint/index.d.ts +2 -2
  74. package/dist/types/handleContentDeclarationFileMoved.d.ts +7 -0
  75. package/dist/types/handleContentDeclarationFileMoved.d.ts.map +1 -0
  76. package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -1
  77. package/dist/types/watcher.d.ts.map +1 -1
  78. package/package.json +10 -10
@@ -1,25 +1,22 @@
1
1
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- const require_createDictionaryEntryPoint_createDictionaryEntryPoint = require('./createDictionaryEntryPoint/createDictionaryEntryPoint.cjs');
3
- const require_createType_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
4
- const require_createType_createType = require('./createType/createType.cjs');
5
2
  const require_cleanRemovedContentDeclaration = require('./cleanRemovedContentDeclaration.cjs');
6
3
  const require_utils_formatter = require('./utils/formatter.cjs');
7
4
  const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./buildIntlayerDictionary/buildIntlayerDictionary.cjs');
5
+ const require_createType_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
6
+ const require_createType_createType = require('./createType/createType.cjs');
8
7
  const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
9
8
  const require_listDictionariesPath = require('./listDictionariesPath.cjs');
9
+ let node_path = require("node:path");
10
10
  let _intlayer_config = require("@intlayer/config");
11
11
 
12
12
  //#region src/handleUnlinkedContentDeclarationFile.ts
13
13
  const handleUnlinkedContentDeclarationFile = async (filePath, config) => {
14
14
  const appLogger = (0, _intlayer_config.getAppLogger)(config);
15
15
  appLogger(`Unlinked detected: ${require_utils_formatter.formatPath(filePath)}`, { isVerbose: true });
16
- const localeDictionaries = await require_loadDictionaries_loadLocalDictionaries.loadLocalDictionaries(await require_listDictionariesPath.listDictionaries(config), config);
17
- localeDictionaries.forEach(async (dictionary) => {
18
- await require_cleanRemovedContentDeclaration.cleanRemovedContentDeclaration(filePath, dictionary.key, config);
19
- });
16
+ const localeDictionaries = await require_loadDictionaries_loadLocalDictionaries.loadLocalDictionaries((await require_listDictionariesPath.listDictionaries(config)).filter((file) => (0, node_path.normalize)(file) !== (0, node_path.normalize)(filePath)), config);
17
+ await require_cleanRemovedContentDeclaration.cleanRemovedContentDeclaration(filePath, [], config);
20
18
  const dictionariesOutput = await require_buildIntlayerDictionary_buildIntlayerDictionary.buildDictionary(localeDictionaries, config);
21
19
  await require_createType_createType.createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionaryPath), config);
22
- await require_createDictionaryEntryPoint_createDictionaryEntryPoint.createDictionaryEntryPoint();
23
20
  appLogger("Dictionaries rebuilt", { isVerbose: true });
24
21
  await require_createType_createModuleAugmentation.createModuleAugmentation(config);
25
22
  appLogger("Module augmentation built", { isVerbose: true });
@@ -1 +1 @@
1
- {"version":3,"file":"handleUnlinkedContentDeclarationFile.cjs","names":["formatPath","loadLocalDictionaries","listDictionaries","cleanRemovedContentDeclaration","buildDictionary","createTypes","createDictionaryEntryPoint","createModuleAugmentation"],"sources":["../../src/handleUnlinkedContentDeclarationFile.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { cleanRemovedContentDeclaration } from './cleanRemovedContentDeclaration';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createTypes } from './createType';\nimport { createModuleAugmentation } from './createType/createModuleAugmentation';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleUnlinkedContentDeclarationFile = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Unlinked detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const files: string[] = await listDictionaries(config);\n\n const localeDictionaries = await loadLocalDictionaries(files, config);\n\n localeDictionaries.forEach(async (dictionary) => {\n await cleanRemovedContentDeclaration(filePath, dictionary.key, config);\n });\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths, config);\n\n await createDictionaryEntryPoint();\n\n appLogger('Dictionaries rebuilt', {\n isVerbose: true,\n });\n\n await createModuleAugmentation(config);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,uCAAuC,OAClD,UACA,WACG;CACH,MAAM,+CAAyB,OAAO;AAGtC,WAAU,sBAAsBA,mCAAW,SAAS,IAAI,EACtD,WAAW,MACZ,CAAC;CAIF,MAAM,qBAAqB,MAAMC,qEAFT,MAAMC,8CAAiB,OAAO,EAEQ,OAAO;AAErE,oBAAmB,QAAQ,OAAO,eAAe;AAC/C,QAAMC,sEAA+B,UAAU,WAAW,KAAK,OAAO;GACtE;CAEF,MAAM,qBAAqB,MAAMC,wEAAgB,oBAAoB,OAAO;AAM5E,OAAMC,0CAJoB,OAAO,OAC/B,oBAAoB,sBAAsB,EAAE,CAC7C,CAAC,KAAK,eAAe,WAAW,eAAe,EAEX,OAAO;AAE5C,OAAMC,0FAA4B;AAElC,WAAU,wBAAwB,EAChC,WAAW,MACZ,CAAC;AAEF,OAAMC,qEAAyB,OAAO;AAEtC,WAAU,6BAA6B,EACrC,WAAW,MACZ,CAAC;AAIF,YAAW,MAAM,UAAU,OAAO,WAAW,EAAE,EAAE;EAC/C,MAAM,EAAE,sBAAsB,uBAAuB;AAErD,QAAM,OAAO,aAAa;GACxB,cAAc;IACZ;IACA;IACD;GACD,eAAe;GAChB,CAAC"}
1
+ {"version":3,"file":"handleUnlinkedContentDeclarationFile.cjs","names":["formatPath","loadLocalDictionaries","listDictionaries","cleanRemovedContentDeclaration","buildDictionary","createTypes","createModuleAugmentation"],"sources":["../../src/handleUnlinkedContentDeclarationFile.ts"],"sourcesContent":["import { normalize } from 'node:path';\nimport { getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { cleanRemovedContentDeclaration } from './cleanRemovedContentDeclaration';\nimport { createTypes } from './createType';\nimport { createModuleAugmentation } from './createType/createModuleAugmentation';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleUnlinkedContentDeclarationFile = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Unlinked detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const files: string[] = await listDictionaries(config);\n\n const existingFiles = files.filter(\n (file) => normalize(file) !== normalize(filePath)\n );\n\n const localeDictionaries = await loadLocalDictionaries(existingFiles, config);\n\n await cleanRemovedContentDeclaration(filePath, [], config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths, config);\n\n appLogger('Dictionaries rebuilt', {\n isVerbose: true,\n });\n\n await createModuleAugmentation(config);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,uCAAuC,OAClD,UACA,WACG;CACH,MAAM,+CAAyB,OAAO;AAGtC,WAAU,sBAAsBA,mCAAW,SAAS,IAAI,EACtD,WAAW,MACZ,CAAC;CAQF,MAAM,qBAAqB,MAAMC,sEANT,MAAMC,8CAAiB,OAAO,EAE1B,QACzB,kCAAmB,KAAK,8BAAe,SAAS,CAClD,EAEqE,OAAO;AAE7E,OAAMC,sEAA+B,UAAU,EAAE,EAAE,OAAO;CAE1D,MAAM,qBAAqB,MAAMC,wEAAgB,oBAAoB,OAAO;AAM5E,OAAMC,0CAJoB,OAAO,OAC/B,oBAAoB,sBAAsB,EAAE,CAC7C,CAAC,KAAK,eAAe,WAAW,eAAe,EAEX,OAAO;AAE5C,WAAU,wBAAwB,EAChC,WAAW,MACZ,CAAC;AAEF,OAAMC,qEAAyB,OAAO;AAEtC,WAAU,6BAA6B,EACrC,WAAW,MACZ,CAAC;AAIF,YAAW,MAAM,UAAU,OAAO,WAAW,EAAE,EAAE;EAC/C,MAAM,EAAE,sBAAsB,uBAAuB;AAErD,QAAM,OAAO,aAAa;GACxB,cAAc;IACZ;IACA;IACD;GACD,eAAe;GAChB,CAAC"}
@@ -9,13 +9,13 @@ const require_createDictionaryEntryPoint_getBuiltFetchDictionariesPath = require
9
9
  const require_createDictionaryEntryPoint_getBuiltRemoteDictionariesPath = require('./createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs');
10
10
  const require_createDictionaryEntryPoint_getBuiltUnmergedDictionariesPath = require('./createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs');
11
11
  const require_createDictionaryEntryPoint_createDictionaryEntryPoint = require('./createDictionaryEntryPoint/createDictionaryEntryPoint.cjs');
12
- const require_createType_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
13
- const require_createType_createType = require('./createType/createType.cjs');
14
12
  const require_fetchDistantDictionaries = require('./fetchDistantDictionaries.cjs');
15
13
  const require_utils_formatter = require('./utils/formatter.cjs');
16
14
  const require_filterInvalidDictionaries = require('./filterInvalidDictionaries.cjs');
17
15
  const require_formatDictionary = require('./formatDictionary.cjs');
18
16
  const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./buildIntlayerDictionary/buildIntlayerDictionary.cjs');
17
+ const require_createType_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
18
+ const require_createType_createType = require('./createType/createType.cjs');
19
19
  const require_utils_resolveObjectPromises = require('./utils/resolveObjectPromises.cjs');
20
20
  const require_loadDictionaries_loadContentDeclaration = require('./loadDictionaries/loadContentDeclaration.cjs');
21
21
  const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
@@ -1,9 +1,9 @@
1
1
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
2
  const require_cleanOutputDir = require('./cleanOutputDir.cjs');
3
3
  const require_createDictionaryEntryPoint_createDictionaryEntryPoint = require('./createDictionaryEntryPoint/createDictionaryEntryPoint.cjs');
4
+ const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./buildIntlayerDictionary/buildIntlayerDictionary.cjs');
4
5
  const require_createType_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
5
6
  const require_createType_createType = require('./createType/createType.cjs');
6
- const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./buildIntlayerDictionary/buildIntlayerDictionary.cjs');
7
7
  const require_listDictionariesPath = require('./listDictionariesPath.cjs');
8
8
  const require_loadDictionaries_loadDictionaries = require('./loadDictionaries/loadDictionaries.cjs');
9
9
  const require_buildIntlayerDictionary_writeRemoteDictionary = require('./buildIntlayerDictionary/writeRemoteDictionary.cjs');
@@ -1,6 +1,7 @@
1
1
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
2
  const require_handleAdditionalContentDeclarationFile = require('./handleAdditionalContentDeclarationFile.cjs');
3
3
  const require_handleContentDeclarationFileChange = require('./handleContentDeclarationFileChange.cjs');
4
+ const require_handleContentDeclarationFileMoved = require('./handleContentDeclarationFileMoved.cjs');
4
5
  const require_handleUnlinkedContentDeclarationFile = require('./handleUnlinkedContentDeclarationFile.cjs');
5
6
  const require_prepareIntlayer = require('./prepareIntlayer.cjs');
6
7
  const require_writeContentDeclaration_writeContentDeclaration = require('./writeContentDeclaration/writeContentDeclaration.cjs');
@@ -11,7 +12,7 @@ let chokidar = require("chokidar");
11
12
 
12
13
  //#region src/watcher.ts
13
14
  /** @ts-ignore remove error Module '"chokidar"' has no exported member 'ChokidarOptions'. */
14
- const recentlyAddedFiles = /* @__PURE__ */ new Set();
15
+ const pendingUnlinks = /* @__PURE__ */ new Map();
15
16
  const watch = (options) => {
16
17
  const configuration = options?.configuration ?? (0, _intlayer_config.getConfiguration)(options?.configOptions);
17
18
  const appLogger = (0, _intlayer_config.getAppLogger)(configuration);
@@ -32,23 +33,43 @@ const watch = (options) => {
32
33
  ...options
33
34
  }).on("add", async (filePath) => {
34
35
  const fileName = (0, node_path.basename)(filePath);
35
- recentlyAddedFiles.add(fileName);
36
- if (await (0, node_fs_promises.readFile)(filePath, "utf-8") === "") {
37
- const extensionPattern = fileExtensions.map((ext) => ext.replace(/\./g, "\\.")).join("|");
38
- await require_writeContentDeclaration_writeContentDeclaration.writeContentDeclaration({
39
- key: fileName.replace(/* @__PURE__ */ new RegExp(`(${extensionPattern})$`), ""),
40
- content: {},
41
- filePath
42
- }, configuration);
36
+ let isMove = false;
37
+ let matchedOldPath;
38
+ for (const [oldPath] of pendingUnlinks) if ((0, node_path.basename)(oldPath) === fileName) {
39
+ matchedOldPath = oldPath;
40
+ break;
41
+ }
42
+ if (!matchedOldPath && pendingUnlinks.size === 1) matchedOldPath = pendingUnlinks.keys().next().value;
43
+ if (matchedOldPath) {
44
+ const pending = pendingUnlinks.get(matchedOldPath);
45
+ if (pending) {
46
+ clearTimeout(pending.timer);
47
+ pendingUnlinks.delete(matchedOldPath);
48
+ }
49
+ isMove = true;
50
+ appLogger(`File moved from ${matchedOldPath} to ${filePath}`);
51
+ await require_handleContentDeclarationFileMoved.handleContentDeclarationFileMoved(matchedOldPath, filePath, configuration);
52
+ }
53
+ if (!isMove) {
54
+ if (await (0, node_fs_promises.readFile)(filePath, "utf-8") === "") {
55
+ const extensionPattern = fileExtensions.map((ext) => ext.replace(/\./g, "\\.")).join("|");
56
+ await require_writeContentDeclaration_writeContentDeclaration.writeContentDeclaration({
57
+ key: fileName.replace(/* @__PURE__ */ new RegExp(`(${extensionPattern})$`), ""),
58
+ content: {},
59
+ filePath
60
+ }, configuration);
61
+ }
43
62
  }
44
63
  await require_handleAdditionalContentDeclarationFile.handleAdditionalContentDeclarationFile(filePath, configuration);
45
- setTimeout(() => recentlyAddedFiles.delete(fileName), 1e3);
46
64
  }).on("change", async (filePath) => await require_handleContentDeclarationFileChange.handleContentDeclarationFileChange(filePath, configuration)).on("unlink", async (filePath) => {
47
- setTimeout(async () => {
48
- const fileName = (0, node_path.basename)(filePath);
49
- if (recentlyAddedFiles.has(fileName)) return;
65
+ const timer = setTimeout(async () => {
66
+ pendingUnlinks.delete(filePath);
50
67
  await require_handleUnlinkedContentDeclarationFile.handleUnlinkedContentDeclarationFile(filePath, configuration);
51
- }, 300);
68
+ }, 200);
69
+ pendingUnlinks.set(filePath, {
70
+ timer,
71
+ oldPath: filePath
72
+ });
52
73
  }).on("error", async (error) => {
53
74
  appLogger(`Watcher error: ${error}`, { level: "error" });
54
75
  appLogger("Restarting watcher");
@@ -58,7 +79,7 @@ const watch = (options) => {
58
79
  const buildAndWatchIntlayer = async (options) => {
59
80
  const { skipPrepare, ...rest } = options ?? {};
60
81
  const configuration = options?.configuration ?? (0, _intlayer_config.getConfiguration)(options?.configOptions);
61
- if (!options?.skipPrepare) await require_prepareIntlayer.prepareIntlayer(configuration, { forceRun: true });
82
+ if (!skipPrepare) await require_prepareIntlayer.prepareIntlayer(configuration, { forceRun: true });
62
83
  if (configuration.content.watch || options?.persistent) {
63
84
  (0, _intlayer_config.getAppLogger)(configuration)("Watching Intlayer content declarations");
64
85
  watch({
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.cjs","names":["writeContentDeclaration","handleAdditionalContentDeclarationFile","handleContentDeclarationFileChange","handleUnlinkedContentDeclarationFile","prepareIntlayer"],"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 { handleUnlinkedContentDeclarationFile } from './handleUnlinkedContentDeclarationFile';\nimport { prepareIntlayer } from './prepareIntlayer';\nimport { writeContentDeclaration } from './writeContentDeclaration';\n\nconst recentlyAddedFiles = new Set<string>();\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 =\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 recentlyAddedFiles.add(fileName);\n\n const fileContent = await readFile(filePath, 'utf-8');\n\n const isEmpty = fileContent === '';\n\n // Fill template content declaration file if it is empty\n if (isEmpty) {\n // Extract name from filename by removing any configured extension\n // e.g., \"example.content.ts\" -> \"example\" or \"example.i18n.json\" -> \"example\"\n const extensionPattern = fileExtensions\n .map((ext) => ext.replace(/\\./g, '\\\\.'))\n .join('|');\n const name = fileName.replace(new RegExp(`(${extensionPattern})$`), '');\n\n await writeContentDeclaration(\n {\n key: name,\n content: {},\n filePath,\n },\n configuration\n );\n }\n\n await handleAdditionalContentDeclarationFile(filePath, configuration);\n\n setTimeout(() => recentlyAddedFiles.delete(fileName), 1000); // Allow time for unlink to trigger if it's a move\n })\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('unlink', async (filePath) => {\n setTimeout(async () => {\n const fileName = basename(filePath);\n\n if (recentlyAddedFiles.has(fileName)) {\n // The file was moved, so ignore unlink\n return;\n }\n\n await handleUnlinkedContentDeclarationFile(filePath, configuration);\n }, 300); // Allow time for unlink to trigger if it's a move\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 (!options?.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 // Start watching (assuming watch is also async)\n watch({ ...rest, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,qCAAqB,IAAI,KAAa;AAS5C,MAAa,SAAS,YAA2B;CAC/C,MAAM,gBACJ,SAAS,wDAAkC,SAAS,cAAc;CACpE,MAAM,+CAAyB,cAAc;CAE7C,MAAM,EACJ,OAAO,aACP,6BACA,mBACE,cAAc;AAElB,4BAAqB,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,mCAAoB,SAAS;AACnC,qBAAmB,IAAI,SAAS;AAOhC,MALoB,qCAAe,UAAU,QAAQ,KAErB,IAGnB;GAGX,MAAM,mBAAmB,eACtB,KAAK,QAAQ,IAAI,QAAQ,OAAO,MAAM,CAAC,CACvC,KAAK,IAAI;AAGZ,SAAMA,gFACJ;IACE,KAJS,SAAS,wBAAQ,IAAI,OAAO,IAAI,iBAAiB,IAAI,EAAE,GAAG;IAKnE,SAAS,EAAE;IACX;IACD,EACD,cACD;;AAGH,QAAMC,sFAAuC,UAAU,cAAc;AAErE,mBAAiB,mBAAmB,OAAO,SAAS,EAAE,IAAK;GAC3D,CACD,GACC,UACA,OAAO,aACL,MAAMC,8EAAmC,UAAU,cAAc,CACpE,CACA,GAAG,UAAU,OAAO,aAAa;AAChC,aAAW,YAAY;GACrB,MAAM,mCAAoB,SAAS;AAEnC,OAAI,mBAAmB,IAAI,SAAS,CAElC;AAGF,SAAMC,kFAAqC,UAAU,cAAc;KAClE,IAAI;GACP,CACD,GAAG,SAAS,OAAO,UAAU;AAC5B,YAAU,kBAAkB,SAAS,EACnC,OAAO,SACR,CAAC;AAEF,YAAU,qBAAqB;AAE/B,QAAMC,wCAAgB,cAAc;GACpC;;AAGN,MAAa,wBAAwB,OAAO,YAA2B;CACrE,MAAM,EAAE,aAAa,GAAG,SAAS,WAAW,EAAE;CAC9C,MAAM,gBACJ,SAAS,wDAAkC,SAAS,cAAc;AAEpE,KAAI,CAAC,SAAS,YACZ,OAAMA,wCAAgB,eAAe,EAAE,UAAU,MAAM,CAAC;AAG1D,KAAI,cAAc,QAAQ,SAAS,SAAS,YAAY;AAGtD,qCAF+B,cAAc,CAEnC,yCAAyC;AAEnD,QAAM;GAAE,GAAG;GAAM;GAAe,CAAC"}
1
+ {"version":3,"file":"watcher.cjs","names":["configuration: IntlayerConfig","matchedOldPath: string | undefined","handleContentDeclarationFileMoved","writeContentDeclaration","handleAdditionalContentDeclarationFile","handleContentDeclarationFileChange","handleUnlinkedContentDeclarationFile","prepareIntlayer"],"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,wDAAkC,SAAS,cAAc;CACpE,MAAM,+CAAyB,cAAc;CAE7C,MAAM,EACJ,OAAO,aACP,6BACA,mBACE,cAAc;AAElB,4BAAqB,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,mCAAoB,SAAS;EACnC,IAAI,SAAS;EAMb,IAAIC;AAGJ,OAAK,MAAM,CAAC,YAAY,eACtB,6BAAa,QAAQ,KAAK,UAAU;AAClC,oBAAiB;AACjB;;AAKJ,MAAI,CAAC,kBAAkB,eAAe,SAAS,EAC7C,kBAAiB,eAAe,MAAM,CAAC,MAAM,CAAC;AAGhD,MAAI,gBAAgB;GAElB,MAAM,UAAU,eAAe,IAAI,eAAe;AAClD,OAAI,SAAS;AACX,iBAAa,QAAQ,MAAM;AAC3B,mBAAe,OAAO,eAAe;;AAGvC,YAAS;AACT,aAAU,mBAAmB,eAAe,MAAM,WAAW;AAE7D,SAAMC,4EACJ,gBACA,UACA,cACD;;AAIH,MAAI,CAAC,QAKH;OAJoB,qCAAe,UAAU,QAAQ,KACrB,IAGnB;IACX,MAAM,mBAAmB,eACtB,KAAK,QAAQ,IAAI,QAAQ,OAAO,MAAM,CAAC,CACvC,KAAK,IAAI;AAMZ,UAAMC,gFACJ;KACE,KAPS,SAAS,wBACpB,IAAI,OAAO,IAAI,iBAAiB,IAAI,EACpC,GACD;KAKG,SAAS,EAAE;KACX;KACD,EACD,cACD;;;AAKL,QAAMC,sFAAuC,UAAU,cAAc;GACrE,CACD,GACC,UACA,OAAO,aACL,MAAMC,8EAAmC,UAAU,cAAc,CACpE,CACA,GAAG,UAAU,OAAO,aAAa;EAEhC,MAAM,QAAQ,WAAW,YAAY;AAEnC,kBAAe,OAAO,SAAS;AAC/B,SAAMC,kFAAqC,UAAU,cAAc;KAClE,IAAI;AAEP,iBAAe,IAAI,UAAU;GAAE;GAAO,SAAS;GAAU,CAAC;GAC1D,CACD,GAAG,SAAS,OAAO,UAAU;AAC5B,YAAU,kBAAkB,SAAS,EACnC,OAAO,SACR,CAAC;AAEF,YAAU,qBAAqB;AAE/B,QAAMC,wCAAgB,cAAc;GACpC;;AAGN,MAAa,wBAAwB,OAAO,YAA2B;CACrE,MAAM,EAAE,aAAa,GAAG,SAAS,WAAW,EAAE;CAC9C,MAAM,gBACJ,SAAS,wDAAkC,SAAS,cAAc;AAEpE,KAAI,CAAC,YACH,OAAMA,wCAAgB,eAAe,EAAE,UAAU,MAAM,CAAC;AAG1D,KAAI,cAAc,QAAQ,SAAS,SAAS,YAAY;AAGtD,qCAF+B,cAAc,CAEnC,yCAAyC;AACnD,QAAM;GAAE,GAAG;GAAM;GAAe,CAAC"}
@@ -1,64 +1,92 @@
1
1
  import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";
2
- import { createTypes } from "./createType/createType.mjs";
3
2
  import { writeJsonIfChanged } from "./writeJsonIfChanged.mjs";
4
3
  import { readFile, rm } from "node:fs/promises";
5
- import { colorizeKey, getAppLogger } from "@intlayer/config/client";
4
+ import { colorizeKey, colorizePath, getAppLogger, normalizePath } from "@intlayer/config/client";
6
5
  import { join, normalize, relative } from "node:path";
7
6
  import { getDictionaries } from "@intlayer/dictionaries-entry";
8
7
  import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
8
+ import fg from "fast-glob";
9
9
 
10
10
  //#region src/cleanRemovedContentDeclaration.ts
11
- const cleanRemovedContentDeclaration = async (filePath, key, configuration) => {
11
+ const cleanRemovedContentDeclaration = async (filePath, keysToKeep, configuration) => {
12
12
  const appLogger = getAppLogger(configuration);
13
13
  const unmergedDictionaries = getUnmergedDictionaries(configuration);
14
- const relativeFilePath = relative(configuration.content.baseDir, filePath);
15
- const filteredUnmergedDictionaries = Object.values(unmergedDictionaries).flat().filter((dictionary) => dictionary.filePath === relativeFilePath && dictionary.key !== key);
14
+ const baseDir = configuration.content.baseDir;
15
+ const relativeFilePath = relative(baseDir, filePath);
16
+ const uniqueUnmergedDictionaries = Object.values(unmergedDictionaries).flat().filter((dictionary) => dictionary.filePath === relativeFilePath && !keysToKeep.includes(dictionary.key)).filter((dictionary, index, self) => index === self.findIndex((t) => t.key === dictionary.key));
16
17
  const changedDictionariesLocalIds = [];
17
- const removedDictionariesLocalIds = [];
18
- const removedDictionariesKeys = [];
19
- filteredUnmergedDictionaries.forEach(async (dictionary) => {
18
+ const filesToRemove = [];
19
+ const excludeKeys = [];
20
+ await Promise.all(uniqueUnmergedDictionaries.map(async (dictionary) => {
20
21
  const unmergedFilePath = normalize(join(configuration.content.unmergedDictionariesDir, `${dictionary.key}.json`));
21
22
  try {
22
23
  const jsonContent = await readFile(unmergedFilePath, "utf8");
23
24
  const parsedContent = JSON.parse(jsonContent);
24
25
  if (parsedContent.length === 1) {
25
- appLogger(`Removing outdated dictionary ${colorizeKey(dictionary.key)}`, { isVerbose: true });
26
- await rm(unmergedFilePath);
27
- removedDictionariesLocalIds.push(dictionary.localId);
26
+ if (parsedContent[0].filePath === relativeFilePath) {
27
+ appLogger(`Removing outdated dictionary ${colorizeKey(dictionary.key)}`, { isVerbose: true });
28
+ filesToRemove.push(unmergedFilePath);
29
+ excludeKeys.push(dictionary.key);
30
+ }
28
31
  } else {
29
32
  await writeJsonIfChanged(unmergedFilePath, parsedContent.filter((content) => content.filePath !== relativeFilePath));
30
33
  changedDictionariesLocalIds.push(dictionary.localId);
31
34
  }
32
- } catch {
33
- appLogger(`Error while processing unmerged dictionary file ${colorizeKey(dictionary.key)}`, { isVerbose: true });
35
+ } catch (error) {
36
+ if (error.code === "ENOENT") {
37
+ if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
38
+ }
34
39
  }
35
- });
40
+ }));
36
41
  const dictionaries = getDictionaries(configuration);
37
- const flatDictionaries = Object.values(dictionaries);
38
- (flatDictionaries?.filter((dictionary) => dictionary.key !== key && dictionary.localIds?.length === 1 && dictionary.localIds[0].endsWith(`::local::${relativeFilePath}`))).forEach(async (dictionary) => {
42
+ const uniqueMergedDictionaries = (Object.values(dictionaries)?.filter((dictionary) => !keysToKeep.includes(dictionary.key) && dictionary.localIds?.length === 1 && dictionary.localIds[0].endsWith(`::local::${relativeFilePath}`))).filter((dictionary, index, self) => index === self.findIndex((t) => t.key === dictionary.key));
43
+ await Promise.all(uniqueMergedDictionaries.map(async (dictionary) => {
39
44
  const mergedFilePath = normalize(join(configuration.content.dictionariesDir, `${dictionary.key}.json`));
40
45
  try {
41
46
  const fileContent = await readFile(mergedFilePath, "utf8");
42
47
  const parsedContent = JSON.parse(fileContent);
43
48
  if (parsedContent.localIds?.length === 1) {
44
- appLogger(`Removing outdated dictionary ${colorizeKey(dictionary.key)}`, { isVerbose: true });
45
- rm(mergedFilePath);
46
- rm(normalize(join(configuration.content.typesDir, `${dictionary.key}.ts`)));
47
- removedDictionariesKeys.push(dictionary.key);
49
+ if (parsedContent.localIds[0].endsWith(`::local::${relativeFilePath}`)) {
50
+ appLogger(`Removing outdated unmerged dictionary ${colorizeKey(dictionary.key)}`, { isVerbose: true });
51
+ filesToRemove.push(mergedFilePath);
52
+ const typesFilePath = normalize(join(configuration.content.typesDir, `${dictionary.key}.ts`));
53
+ filesToRemove.push(typesFilePath);
54
+ const dynamicFiles = await fg(normalizePath(join(configuration.content.dynamicDictionariesDir, `${dictionary.key}.*`)), { absolute: true });
55
+ filesToRemove.push(...dynamicFiles);
56
+ if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
57
+ }
48
58
  } else {
49
- const localIds = parsedContent.localIds?.filter((localeId) => localeId !== relativeFilePath);
59
+ const localIds = parsedContent.localIds?.filter((localeId) => !localeId.endsWith(`::local::${relativeFilePath}`));
50
60
  await writeJsonIfChanged(mergedFilePath, {
51
61
  ...parsedContent,
52
62
  localIds
53
63
  });
54
64
  }
55
65
  } catch (error) {
56
- appLogger([`Error while processing merged dictionary file ${colorizeKey(dictionary.key)}`, error], { isVerbose: true });
66
+ if (error.code === "ENOENT") {
67
+ if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
68
+ const typesFilePath = normalize(join(configuration.content.typesDir, `${dictionary.key}.ts`));
69
+ filesToRemove.push(typesFilePath);
70
+ }
57
71
  }
58
- });
59
- await createTypes(flatDictionaries.filter((dictionary) => !removedDictionariesKeys.includes(dictionary.key)).map((dictionary) => join(configuration.content.dictionariesDir, `${dictionary.key}.json`)), configuration);
60
- await createDictionaryEntryPoint(configuration);
61
- return changedDictionariesLocalIds;
72
+ }));
73
+ if (filesToRemove.length > 0 || excludeKeys.length > 0) {
74
+ await createDictionaryEntryPoint(configuration, { excludeKeys });
75
+ if (filesToRemove.length > 0) await Promise.all(filesToRemove.map(async (path$1) => {
76
+ const relativePath = relative(baseDir, path$1);
77
+ try {
78
+ await rm(path$1, { force: true });
79
+ appLogger(`Deleted artifact: ${colorizePath(relativePath)}`, { isVerbose: true });
80
+ } catch {
81
+ appLogger(`Error while removing file ${colorizePath(relativePath)}`, { isVerbose: true });
82
+ }
83
+ }));
84
+ }
85
+ return {
86
+ changedDictionariesLocalIds,
87
+ excludeKeys,
88
+ hasRebuilt: filesToRemove.length > 0 || excludeKeys.length > 0
89
+ };
62
90
  };
63
91
 
64
92
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"cleanRemovedContentDeclaration.mjs","names":["changedDictionariesLocalIds: string[]","removedDictionariesLocalIds: string[]","removedDictionariesKeys: string[]"],"sources":["../../src/cleanRemovedContentDeclaration.ts"],"sourcesContent":["import { readFile, rm } from 'node:fs/promises';\nimport { join, normalize, relative } from 'node:path';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/client';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint';\nimport { createTypes } from './createType';\nimport { writeJsonIfChanged } from './writeJsonIfChanged';\n\nexport const cleanRemovedContentDeclaration = async (\n filePath: string,\n key: string,\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const appLogger = getAppLogger(configuration);\n\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n const relativeFilePath = relative(configuration.content.baseDir, filePath);\n const flatUnmergedDictionaries = Object.values(unmergedDictionaries).flat();\n\n const filteredUnmergedDictionaries = flatUnmergedDictionaries.filter(\n (dictionary) =>\n dictionary.filePath === relativeFilePath && dictionary.key !== key\n );\n\n const changedDictionariesLocalIds: string[] = [];\n const removedDictionariesLocalIds: string[] = [];\n const removedDictionariesKeys: string[] = [];\n\n filteredUnmergedDictionaries.forEach(async (dictionary) => {\n const unmergedFilePath = normalize(\n join(\n configuration.content.unmergedDictionariesDir,\n `${dictionary.key}.json`\n )\n );\n\n try {\n const jsonContent = await readFile(unmergedFilePath, 'utf8');\n const parsedContent = JSON.parse(jsonContent);\n\n if (parsedContent.length === 1) {\n appLogger(\n `Removing outdated dictionary ${colorizeKey(dictionary.key)}`,\n {\n isVerbose: true,\n }\n );\n\n await rm(unmergedFilePath);\n\n removedDictionariesLocalIds.push(dictionary.localId!);\n } else {\n const filteredContent = parsedContent.filter(\n (content: any) => content.filePath !== relativeFilePath\n );\n\n await writeJsonIfChanged(unmergedFilePath, filteredContent);\n\n changedDictionariesLocalIds.push(dictionary.localId!);\n }\n } catch {\n appLogger(\n `Error while processing unmerged dictionary file ${colorizeKey(dictionary.key)}`,\n {\n isVerbose: true,\n }\n );\n }\n });\n\n const dictionaries = getDictionaries(configuration);\n const flatDictionaries = Object.values(dictionaries);\n\n const filteredMergedDictionaries = flatDictionaries?.filter(\n (dictionary) =>\n dictionary.key !== key &&\n dictionary.localIds?.length === 1 &&\n (dictionary.localIds[0] as string).endsWith(\n `::local::${relativeFilePath}`\n )\n );\n\n filteredMergedDictionaries.forEach(async (dictionary) => {\n const mergedFilePath = normalize(\n join(configuration.content.dictionariesDir, `${dictionary.key}.json`)\n );\n\n try {\n const fileContent = await readFile(mergedFilePath, 'utf8');\n const parsedContent = JSON.parse(fileContent) as Dictionary;\n\n if (parsedContent.localIds?.length === 1) {\n appLogger(\n `Removing outdated dictionary ${colorizeKey(dictionary.key)}`,\n {\n isVerbose: true,\n }\n );\n\n rm(mergedFilePath);\n\n const typesFilePath = normalize(\n join(configuration.content.typesDir, `${dictionary.key}.ts`)\n );\n\n rm(typesFilePath);\n\n removedDictionariesKeys.push(dictionary.key);\n } else {\n const localIds = parsedContent.localIds?.filter(\n (localeId) => localeId !== relativeFilePath\n );\n\n const newContent = { ...parsedContent, localIds };\n\n await writeJsonIfChanged(mergedFilePath, newContent);\n }\n } catch (error) {\n appLogger(\n [\n `Error while processing merged dictionary file ${colorizeKey(dictionary.key)}`,\n error,\n ],\n {\n isVerbose: true,\n }\n );\n }\n });\n\n const dictionariesPaths = flatDictionaries\n .filter((dictionary) => !removedDictionariesKeys.includes(dictionary.key))\n .map((dictionary) =>\n join(configuration.content.dictionariesDir, `${dictionary.key}.json`)\n );\n\n await createTypes(dictionariesPaths, configuration);\n\n await createDictionaryEntryPoint(configuration);\n\n return changedDictionariesLocalIds;\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,iCAAiC,OAC5C,UACA,KACA,kBACsB;CACtB,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,uBAAuB,wBAAwB,cAAc;CAEnE,MAAM,mBAAmB,SAAS,cAAc,QAAQ,SAAS,SAAS;CAG1E,MAAM,+BAF2B,OAAO,OAAO,qBAAqB,CAAC,MAAM,CAEb,QAC3D,eACC,WAAW,aAAa,oBAAoB,WAAW,QAAQ,IAClE;CAED,MAAMA,8BAAwC,EAAE;CAChD,MAAMC,8BAAwC,EAAE;CAChD,MAAMC,0BAAoC,EAAE;AAE5C,8BAA6B,QAAQ,OAAO,eAAe;EACzD,MAAM,mBAAmB,UACvB,KACE,cAAc,QAAQ,yBACtB,GAAG,WAAW,IAAI,OACnB,CACF;AAED,MAAI;GACF,MAAM,cAAc,MAAM,SAAS,kBAAkB,OAAO;GAC5D,MAAM,gBAAgB,KAAK,MAAM,YAAY;AAE7C,OAAI,cAAc,WAAW,GAAG;AAC9B,cACE,gCAAgC,YAAY,WAAW,IAAI,IAC3D,EACE,WAAW,MACZ,CACF;AAED,UAAM,GAAG,iBAAiB;AAE1B,gCAA4B,KAAK,WAAW,QAAS;UAChD;AAKL,UAAM,mBAAmB,kBAJD,cAAc,QACnC,YAAiB,QAAQ,aAAa,iBACxC,CAE0D;AAE3D,gCAA4B,KAAK,WAAW,QAAS;;UAEjD;AACN,aACE,mDAAmD,YAAY,WAAW,IAAI,IAC9E,EACE,WAAW,MACZ,CACF;;GAEH;CAEF,MAAM,eAAe,gBAAgB,cAAc;CACnD,MAAM,mBAAmB,OAAO,OAAO,aAAa;AAWpD,EATmC,kBAAkB,QAClD,eACC,WAAW,QAAQ,OACnB,WAAW,UAAU,WAAW,KAC/B,WAAW,SAAS,GAAc,SACjC,YAAY,mBACb,CACJ,EAE0B,QAAQ,OAAO,eAAe;EACvD,MAAM,iBAAiB,UACrB,KAAK,cAAc,QAAQ,iBAAiB,GAAG,WAAW,IAAI,OAAO,CACtE;AAED,MAAI;GACF,MAAM,cAAc,MAAM,SAAS,gBAAgB,OAAO;GAC1D,MAAM,gBAAgB,KAAK,MAAM,YAAY;AAE7C,OAAI,cAAc,UAAU,WAAW,GAAG;AACxC,cACE,gCAAgC,YAAY,WAAW,IAAI,IAC3D,EACE,WAAW,MACZ,CACF;AAED,OAAG,eAAe;AAMlB,OAJsB,UACpB,KAAK,cAAc,QAAQ,UAAU,GAAG,WAAW,IAAI,KAAK,CAC7D,CAEgB;AAEjB,4BAAwB,KAAK,WAAW,IAAI;UACvC;IACL,MAAM,WAAW,cAAc,UAAU,QACtC,aAAa,aAAa,iBAC5B;AAID,UAAM,mBAAmB,gBAFN;KAAE,GAAG;KAAe;KAAU,CAEG;;WAE/C,OAAO;AACd,aACE,CACE,iDAAiD,YAAY,WAAW,IAAI,IAC5E,MACD,EACD,EACE,WAAW,MACZ,CACF;;GAEH;AAQF,OAAM,YANoB,iBACvB,QAAQ,eAAe,CAAC,wBAAwB,SAAS,WAAW,IAAI,CAAC,CACzE,KAAK,eACJ,KAAK,cAAc,QAAQ,iBAAiB,GAAG,WAAW,IAAI,OAAO,CACtE,EAEkC,cAAc;AAEnD,OAAM,2BAA2B,cAAc;AAE/C,QAAO"}
1
+ {"version":3,"file":"cleanRemovedContentDeclaration.mjs","names":["changedDictionariesLocalIds: string[]","filesToRemove: string[]","excludeKeys: string[]","error: any","path"],"sources":["../../src/cleanRemovedContentDeclaration.ts"],"sourcesContent":["import { readFile, rm } from 'node:fs/promises';\nimport { join, normalize, relative } from 'node:path';\nimport {\n colorizeKey,\n colorizePath,\n getAppLogger,\n normalizePath,\n} from '@intlayer/config/client';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport fg from 'fast-glob';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint';\nimport { writeJsonIfChanged } from './writeJsonIfChanged';\n\nexport const cleanRemovedContentDeclaration = async (\n filePath: string,\n keysToKeep: string[],\n configuration: IntlayerConfig\n): Promise<{\n changedDictionariesLocalIds: string[];\n excludeKeys: string[];\n hasRebuilt: boolean;\n}> => {\n const appLogger = getAppLogger(configuration);\n\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n const baseDir = configuration.content.baseDir;\n\n const relativeFilePath = relative(baseDir, filePath);\n const flatUnmergedDictionaries = Object.values(unmergedDictionaries).flat();\n\n const filteredUnmergedDictionaries = flatUnmergedDictionaries.filter(\n (dictionary) =>\n dictionary.filePath === relativeFilePath &&\n !keysToKeep.includes(dictionary.key)\n );\n\n // Deduplicate dictionaries by key\n const uniqueUnmergedDictionaries = filteredUnmergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n const changedDictionariesLocalIds: string[] = [];\n const filesToRemove: string[] = [];\n const excludeKeys: string[] = [];\n\n // Identify Unmerged Dictionaries to remove or clean\n await Promise.all(\n uniqueUnmergedDictionaries.map(async (dictionary) => {\n const unmergedFilePath = normalize(\n join(\n configuration.content.unmergedDictionariesDir,\n `${dictionary.key}.json`\n )\n );\n\n try {\n const jsonContent = await readFile(unmergedFilePath, 'utf8');\n const parsedContent = JSON.parse(jsonContent);\n\n if (parsedContent.length === 1) {\n if (parsedContent[0].filePath === relativeFilePath) {\n appLogger(\n `Removing outdated dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n filesToRemove.push(unmergedFilePath);\n excludeKeys.push(dictionary.key);\n }\n } else {\n const filteredContent = parsedContent.filter(\n (content: any) => content.filePath !== relativeFilePath\n );\n await writeJsonIfChanged(unmergedFilePath, filteredContent);\n changedDictionariesLocalIds.push(dictionary.localId!);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n }\n })\n );\n\n const dictionaries = getDictionaries(configuration);\n const flatDictionaries = Object.values(dictionaries) as Dictionary[];\n\n const filteredMergedDictionaries = flatDictionaries?.filter(\n (dictionary) =>\n !keysToKeep.includes(dictionary.key) &&\n dictionary.localIds?.length === 1 &&\n (dictionary.localIds[0] as string).endsWith(\n `::local::${relativeFilePath}`\n )\n );\n\n const uniqueMergedDictionaries = filteredMergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n // Identify Merged Dictionaries, Types, and Dynamic Dictionaries to remove\n await Promise.all(\n uniqueMergedDictionaries.map(async (dictionary) => {\n const mergedFilePath = normalize(\n join(configuration.content.dictionariesDir, `${dictionary.key}.json`)\n );\n\n try {\n const fileContent = await readFile(mergedFilePath, 'utf8');\n const parsedContent = JSON.parse(fileContent) as Dictionary;\n\n if (parsedContent.localIds?.length === 1) {\n if (\n parsedContent.localIds[0].endsWith(`::local::${relativeFilePath}`)\n ) {\n appLogger(\n `Removing outdated unmerged dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n\n // Mark JSON for removal\n filesToRemove.push(mergedFilePath);\n\n // Mark TS Types for removal\n const typesFilePath = normalize(\n join(configuration.content.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n\n // Mark Dynamic Dictionaries for removal\n // We use glob to catch the loader files (.cjs, .mjs) AND the split locale files (.en.json, etc.)\n const dynamicFilesGlob = join(\n configuration.content.dynamicDictionariesDir,\n `${dictionary.key}.*`\n );\n const dynamicFiles = await fg(normalizePath(dynamicFilesGlob), {\n absolute: true,\n });\n filesToRemove.push(...dynamicFiles);\n\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n } else {\n const localIds = parsedContent.localIds?.filter(\n (localeId) => !localeId.endsWith(`::local::${relativeFilePath}`)\n ) as string[];\n const newContent = { ...parsedContent, localIds };\n await writeJsonIfChanged(mergedFilePath, newContent);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n const typesFilePath = normalize(\n join(configuration.content.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n }\n }\n })\n );\n\n // Execute Cleanup\n if (filesToRemove.length > 0 || excludeKeys.length > 0) {\n // Update entry points (indexes) first so the app doesn't import dead files\n await createDictionaryEntryPoint(configuration, { excludeKeys });\n\n // Remove the files synchronously (awaited) immediately after.\n if (filesToRemove.length > 0) {\n await Promise.all(\n filesToRemove.map(async (path) => {\n const relativePath = relative(baseDir, path);\n try {\n await rm(path, { force: true });\n\n appLogger(`Deleted artifact: ${colorizePath(relativePath)}`, {\n isVerbose: true,\n });\n } catch {\n appLogger(\n `Error while removing file ${colorizePath(relativePath)}`,\n {\n isVerbose: true,\n }\n );\n }\n })\n );\n }\n }\n\n return {\n changedDictionariesLocalIds,\n excludeKeys,\n hasRebuilt: filesToRemove.length > 0 || excludeKeys.length > 0,\n };\n};\n"],"mappings":";;;;;;;;;;AAeA,MAAa,iCAAiC,OAC5C,UACA,YACA,kBAKI;CACJ,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,uBAAuB,wBAAwB,cAAc;CAEnE,MAAM,UAAU,cAAc,QAAQ;CAEtC,MAAM,mBAAmB,SAAS,SAAS,SAAS;CAUpD,MAAM,6BAT2B,OAAO,OAAO,qBAAqB,CAAC,MAAM,CAEb,QAC3D,eACC,WAAW,aAAa,oBACxB,CAAC,WAAW,SAAS,WAAW,IAAI,CACvC,CAG+D,QAC7D,YAAY,OAAO,SAClB,UAAU,KAAK,WAAW,MAAM,EAAE,QAAQ,WAAW,IAAI,CAC5D;CAED,MAAMA,8BAAwC,EAAE;CAChD,MAAMC,gBAA0B,EAAE;CAClC,MAAMC,cAAwB,EAAE;AAGhC,OAAM,QAAQ,IACZ,2BAA2B,IAAI,OAAO,eAAe;EACnD,MAAM,mBAAmB,UACvB,KACE,cAAc,QAAQ,yBACtB,GAAG,WAAW,IAAI,OACnB,CACF;AAED,MAAI;GACF,MAAM,cAAc,MAAM,SAAS,kBAAkB,OAAO;GAC5D,MAAM,gBAAgB,KAAK,MAAM,YAAY;AAE7C,OAAI,cAAc,WAAW,GAC3B;QAAI,cAAc,GAAG,aAAa,kBAAkB;AAClD,eACE,gCAAgC,YAAY,WAAW,IAAI,IAC3D,EAAE,WAAW,MAAM,CACpB;AACD,mBAAc,KAAK,iBAAiB;AACpC,iBAAY,KAAK,WAAW,IAAI;;UAE7B;AAIL,UAAM,mBAAmB,kBAHD,cAAc,QACnC,YAAiB,QAAQ,aAAa,iBACxC,CAC0D;AAC3D,gCAA4B,KAAK,WAAW,QAAS;;WAEhDC,OAAY;AACnB,OAAI,MAAM,SAAS,UACjB;QAAI,CAAC,YAAY,SAAS,WAAW,IAAI,CACvC,aAAY,KAAK,WAAW,IAAI;;;GAItC,CACH;CAED,MAAM,eAAe,gBAAgB,cAAc;CAYnD,MAAM,4BAXmB,OAAO,OAAO,aAAa,EAEC,QAClD,eACC,CAAC,WAAW,SAAS,WAAW,IAAI,IACpC,WAAW,UAAU,WAAW,KAC/B,WAAW,SAAS,GAAc,SACjC,YAAY,mBACb,CACJ,EAE2D,QACzD,YAAY,OAAO,SAClB,UAAU,KAAK,WAAW,MAAM,EAAE,QAAQ,WAAW,IAAI,CAC5D;AAGD,OAAM,QAAQ,IACZ,yBAAyB,IAAI,OAAO,eAAe;EACjD,MAAM,iBAAiB,UACrB,KAAK,cAAc,QAAQ,iBAAiB,GAAG,WAAW,IAAI,OAAO,CACtE;AAED,MAAI;GACF,MAAM,cAAc,MAAM,SAAS,gBAAgB,OAAO;GAC1D,MAAM,gBAAgB,KAAK,MAAM,YAAY;AAE7C,OAAI,cAAc,UAAU,WAAW,GACrC;QACE,cAAc,SAAS,GAAG,SAAS,YAAY,mBAAmB,EAClE;AACA,eACE,yCAAyC,YAAY,WAAW,IAAI,IACpE,EAAE,WAAW,MAAM,CACpB;AAGD,mBAAc,KAAK,eAAe;KAGlC,MAAM,gBAAgB,UACpB,KAAK,cAAc,QAAQ,UAAU,GAAG,WAAW,IAAI,KAAK,CAC7D;AACD,mBAAc,KAAK,cAAc;KAQjC,MAAM,eAAe,MAAM,GAAG,cAJL,KACvB,cAAc,QAAQ,wBACtB,GAAG,WAAW,IAAI,IACnB,CAC4D,EAAE,EAC7D,UAAU,MACX,CAAC;AACF,mBAAc,KAAK,GAAG,aAAa;AAEnC,SAAI,CAAC,YAAY,SAAS,WAAW,IAAI,CACvC,aAAY,KAAK,WAAW,IAAI;;UAG/B;IACL,MAAM,WAAW,cAAc,UAAU,QACtC,aAAa,CAAC,SAAS,SAAS,YAAY,mBAAmB,CACjE;AAED,UAAM,mBAAmB,gBADN;KAAE,GAAG;KAAe;KAAU,CACG;;WAE/CA,OAAY;AACnB,OAAI,MAAM,SAAS,UAAU;AAC3B,QAAI,CAAC,YAAY,SAAS,WAAW,IAAI,CACvC,aAAY,KAAK,WAAW,IAAI;IAElC,MAAM,gBAAgB,UACpB,KAAK,cAAc,QAAQ,UAAU,GAAG,WAAW,IAAI,KAAK,CAC7D;AACD,kBAAc,KAAK,cAAc;;;GAGrC,CACH;AAGD,KAAI,cAAc,SAAS,KAAK,YAAY,SAAS,GAAG;AAEtD,QAAM,2BAA2B,eAAe,EAAE,aAAa,CAAC;AAGhE,MAAI,cAAc,SAAS,EACzB,OAAM,QAAQ,IACZ,cAAc,IAAI,OAAO,WAAS;GAChC,MAAM,eAAe,SAAS,SAASC,OAAK;AAC5C,OAAI;AACF,UAAM,GAAGA,QAAM,EAAE,OAAO,MAAM,CAAC;AAE/B,cAAU,qBAAqB,aAAa,aAAa,IAAI,EAC3D,WAAW,MACZ,CAAC;WACI;AACN,cACE,6BAA6B,aAAa,aAAa,IACvD,EACE,WAAW,MACZ,CACF;;IAEH,CACH;;AAIL,QAAO;EACL;EACA;EACA,YAAY,cAAc,SAAS,KAAK,YAAY,SAAS;EAC9D"}
@@ -20,41 +20,42 @@ const writeDictionaryFiles = async (paths, fileName, importType, functionName, f
20
20
  /**
21
21
  * This function generates a list of dictionaries in the main directory
22
22
  */
23
- const createDictionaryEntryPoint = async (configuration = getConfiguration(), formats) => {
23
+ const createDictionaryEntryPoint = async (configuration = getConfiguration(), options = {}) => {
24
+ const { formats, excludeKeys = [] } = options;
24
25
  const outputFormats = formats ?? configuration.build.outputFormat;
25
26
  const { mainDir } = configuration.content;
26
27
  await mkdir(mainDir, { recursive: true });
27
28
  await parallelize([
28
29
  ...outputFormats.map((format) => ({
29
- paths: getBuiltDictionariesPath(configuration),
30
+ paths: getBuiltDictionariesPath(configuration, excludeKeys),
30
31
  importType: "json",
31
32
  functionName: "getDictionaries",
32
33
  fileName: "dictionaries",
33
34
  format
34
35
  })),
35
36
  ...outputFormats.map((format) => ({
36
- paths: getBuiltUnmergedDictionariesPath(configuration),
37
+ paths: getBuiltUnmergedDictionariesPath(configuration, excludeKeys),
37
38
  importType: "json",
38
39
  functionName: "getUnmergedDictionaries",
39
40
  fileName: "unmerged_dictionaries",
40
41
  format
41
42
  })),
42
43
  ...outputFormats.map((format) => ({
43
- paths: getBuiltDynamicDictionariesPath(configuration, format),
44
+ paths: getBuiltDynamicDictionariesPath(configuration, format, excludeKeys),
44
45
  importType: "javascript",
45
46
  functionName: "getDynamicDictionaries",
46
47
  fileName: "dynamic_dictionaries",
47
48
  format
48
49
  })),
49
50
  ...outputFormats.map((format) => ({
50
- paths: getBuiltFetchDictionariesPath(configuration, format),
51
+ paths: getBuiltFetchDictionariesPath(configuration, format, excludeKeys),
51
52
  importType: "javascript",
52
53
  functionName: "getFetchDictionaries",
53
54
  fileName: "fetch_dictionaries",
54
55
  format
55
56
  })),
56
57
  ...outputFormats.map((format) => ({
57
- paths: getBuiltRemoteDictionariesPath(configuration),
58
+ paths: getBuiltRemoteDictionariesPath(configuration, excludeKeys),
58
59
  importType: "json",
59
60
  functionName: "getRemoteDictionaries",
60
61
  fileName: "remote_dictionaries",
@@ -1 +1 @@
1
- {"version":3,"file":"createDictionaryEntryPoint.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\nimport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nimport { getBuiltDynamicDictionariesPath } from './getBuiltDynamicDictionariesPath';\nimport { getBuiltFetchDictionariesPath } from './getBuiltFetchDictionariesPath';\nimport { getBuiltRemoteDictionariesPath } from './getBuiltRemoteDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\n\nconst writeDictionaryFiles = async (\n paths: Promise<string[]>,\n fileName: string,\n importType: 'json' | 'javascript',\n functionName: string,\n format: 'cjs' | 'esm',\n configuration = getConfiguration()\n) => {\n const content = generateDictionaryListContent(\n await paths,\n functionName,\n importType,\n format,\n configuration\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const { mainDir } = configuration.content;\n\n await writeFileIfChanged(\n resolve(mainDir, `${fileName}.${extension}`),\n content\n );\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = async (\n configuration = getConfiguration(),\n formats?: ('cjs' | 'esm')[]\n) => {\n const outputFormats = formats ?? configuration.build.outputFormat;\n const { mainDir } = configuration.content;\n\n await mkdir(mainDir, { recursive: true });\n\n const writeOperations = [\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltDictionariesPath(configuration),\n importType: 'json',\n functionName: 'getDictionaries',\n fileName: 'dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltUnmergedDictionariesPath(configuration),\n importType: 'json',\n functionName: 'getUnmergedDictionaries',\n fileName: 'unmerged_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltDynamicDictionariesPath(configuration, format),\n importType: 'javascript',\n functionName: 'getDynamicDictionaries',\n fileName: 'dynamic_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltFetchDictionariesPath(configuration, format),\n importType: 'javascript',\n functionName: 'getFetchDictionaries',\n fileName: 'fetch_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltRemoteDictionariesPath(configuration),\n importType: 'json',\n functionName: 'getRemoteDictionaries',\n fileName: 'remote_dictionaries' as const,\n format,\n }) as const\n ),\n ];\n\n await parallelize(\n writeOperations,\n async ({ paths, fileName, format, functionName, importType }) =>\n writeDictionaryFiles(\n paths,\n fileName,\n importType,\n functionName,\n format,\n configuration\n )\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAM,uBAAuB,OAC3B,OACA,UACA,YACA,cACA,QACA,gBAAgB,kBAAkB,KAC/B;CACH,MAAM,UAAU,8BACd,MAAM,OACN,cACA,YACA,QACA,cACD;CACD,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAE7C,MAAM,EAAE,YAAY,cAAc;AAElC,OAAM,mBACJ,QAAQ,SAAS,GAAG,SAAS,GAAG,YAAY,EAC5C,QACD;;;;;AAMH,MAAa,6BAA6B,OACxC,gBAAgB,kBAAkB,EAClC,YACG;CACH,MAAM,gBAAgB,WAAW,cAAc,MAAM;CACrD,MAAM,EAAE,YAAY,cAAc;AAElC,OAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;AAuDzC,OAAM,YArDkB;EACtB,GAAG,cAAc,KACd,YACE;GACC,OAAO,yBAAyB,cAAc;GAC9C,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,iCAAiC,cAAc;GACtD,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,gCAAgC,eAAe,OAAO;GAC7D,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,8BAA8B,eAAe,OAAO;GAC3D,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,+BAA+B,cAAc;GACpD,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACF,EAIC,OAAO,EAAE,OAAO,UAAU,QAAQ,cAAc,iBAC9C,qBACE,OACA,UACA,YACA,cACA,QACA,cACD,CACJ"}
1
+ {"version":3,"file":"createDictionaryEntryPoint.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\nimport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nimport { getBuiltDynamicDictionariesPath } from './getBuiltDynamicDictionariesPath';\nimport { getBuiltFetchDictionariesPath } from './getBuiltFetchDictionariesPath';\nimport { getBuiltRemoteDictionariesPath } from './getBuiltRemoteDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\n\nconst writeDictionaryFiles = async (\n paths: Promise<string[]>,\n fileName: string,\n importType: 'json' | 'javascript',\n functionName: string,\n format: 'cjs' | 'esm',\n configuration = getConfiguration()\n) => {\n const content = generateDictionaryListContent(\n await paths,\n functionName,\n importType,\n format,\n configuration\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const { mainDir } = configuration.content;\n\n await writeFileIfChanged(\n resolve(mainDir, `${fileName}.${extension}`),\n content\n );\n};\n\nexport type CreateDictionaryEntryPointOptions = {\n formats?: ('cjs' | 'esm')[];\n excludeKeys?: string[];\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = async (\n configuration = getConfiguration(),\n options: CreateDictionaryEntryPointOptions = {}\n) => {\n const { formats, excludeKeys = [] } = options;\n const outputFormats = formats ?? configuration.build.outputFormat;\n const { mainDir } = configuration.content;\n\n await mkdir(mainDir, { recursive: true });\n\n const writeOperations = [\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltDictionariesPath(configuration, excludeKeys),\n importType: 'json',\n functionName: 'getDictionaries',\n fileName: 'dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltUnmergedDictionariesPath(configuration, excludeKeys),\n importType: 'json',\n functionName: 'getUnmergedDictionaries',\n fileName: 'unmerged_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltDynamicDictionariesPath(\n configuration,\n format,\n excludeKeys\n ),\n importType: 'javascript',\n functionName: 'getDynamicDictionaries',\n fileName: 'dynamic_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltFetchDictionariesPath(\n configuration,\n format,\n excludeKeys\n ),\n importType: 'javascript',\n functionName: 'getFetchDictionaries',\n fileName: 'fetch_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltRemoteDictionariesPath(configuration, excludeKeys),\n importType: 'json',\n functionName: 'getRemoteDictionaries',\n fileName: 'remote_dictionaries' as const,\n format,\n }) as const\n ),\n ];\n\n await parallelize(\n writeOperations,\n async ({ paths, fileName, format, functionName, importType }) =>\n writeDictionaryFiles(\n paths,\n fileName,\n importType,\n functionName,\n format,\n configuration\n )\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAM,uBAAuB,OAC3B,OACA,UACA,YACA,cACA,QACA,gBAAgB,kBAAkB,KAC/B;CACH,MAAM,UAAU,8BACd,MAAM,OACN,cACA,YACA,QACA,cACD;CACD,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAE7C,MAAM,EAAE,YAAY,cAAc;AAElC,OAAM,mBACJ,QAAQ,SAAS,GAAG,SAAS,GAAG,YAAY,EAC5C,QACD;;;;;AAWH,MAAa,6BAA6B,OACxC,gBAAgB,kBAAkB,EAClC,UAA6C,EAAE,KAC5C;CACH,MAAM,EAAE,SAAS,cAAc,EAAE,KAAK;CACtC,MAAM,gBAAgB,WAAW,cAAc,MAAM;CACrD,MAAM,EAAE,YAAY,cAAc;AAElC,OAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;AA+DzC,OAAM,YA7DkB;EACtB,GAAG,cAAc,KACd,YACE;GACC,OAAO,yBAAyB,eAAe,YAAY;GAC3D,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,iCAAiC,eAAe,YAAY;GACnE,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,gCACL,eACA,QACA,YACD;GACD,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,8BACL,eACA,QACA,YACD;GACD,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,+BAA+B,eAAe,YAAY;GACjE,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACF,EAIC,OAAO,EAAE,OAAO,UAAU,QAAQ,cAAc,iBAC9C,qBACE,OACA,UACA,YACA,cACA,QACA,cACD,CACJ"}
@@ -1,15 +1,19 @@
1
1
  import { existsSync, mkdirSync } from "node:fs";
2
- import { normalizePath } from "@intlayer/config";
2
+ import { basename } from "node:path";
3
3
  import fg from "fast-glob";
4
+ import { normalizePath } from "@intlayer/config";
4
5
 
5
6
  //#region src/createDictionaryEntryPoint/getBuiltDictionariesPath.ts
6
7
  /**
7
8
  * This function generates a list of dictionaries in the main directory
8
9
  */
9
- const getBuiltDictionariesPath = async (configuration) => {
10
+ const getBuiltDictionariesPath = async (configuration, excludeKeys = []) => {
10
11
  const { dictionariesDir, mainDir } = configuration.content;
11
12
  if (!existsSync(mainDir)) mkdirSync(mainDir, { recursive: true });
12
- return await fg(`${normalizePath(dictionariesDir)}/**/*.json`);
13
+ return (await fg(`${normalizePath(dictionariesDir)}/**/*.json`)).filter((path$1) => {
14
+ const key = basename(path$1, ".json");
15
+ return !excludeKeys.includes(key);
16
+ });
13
17
  };
14
18
 
15
19
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getBuiltDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltDictionariesPath.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'node:fs';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDictionariesPath = async (\n configuration: IntlayerConfig\n) => {\n const { dictionariesDir, mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(dictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath;\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,2BAA2B,OACtC,kBACG;CACH,MAAM,EAAE,iBAAiB,YAAY,cAAc;AAGnD,KAAI,CAAC,WAAW,QAAQ,CACtB,WAAU,SAAS,EAAE,WAAW,MAAM,CAAC;AAOzC,QAJmC,MAAM,GACvC,GAAG,cAAc,gBAAgB,CAAC,YACnC"}
1
+ {"version":3,"file":"getBuiltDictionariesPath.mjs","names":["path"],"sources":["../../../src/createDictionaryEntryPoint/getBuiltDictionariesPath.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'node:fs';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDictionariesPath = async (\n configuration: IntlayerConfig,\n excludeKeys: string[] = []\n) => {\n const { dictionariesDir, mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(dictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, '.json');\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,2BAA2B,OACtC,eACA,cAAwB,EAAE,KACvB;CACH,MAAM,EAAE,iBAAiB,YAAY,cAAc;AAGnD,KAAI,CAAC,WAAW,QAAQ,CACtB,WAAU,SAAS,EAAE,WAAW,MAAM,CAAC;AAOzC,SAJmC,MAAM,GACvC,GAAG,cAAc,gBAAgB,CAAC,YACnC,EAEuB,QAAQ,WAAS;EACvC,MAAM,MAAM,SAASA,QAAM,QAAQ;AACnC,SAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
@@ -1,16 +1,20 @@
1
1
  import { existsSync, mkdirSync } from "node:fs";
2
- import { normalizePath } from "@intlayer/config";
2
+ import { basename } from "node:path";
3
3
  import fg from "fast-glob";
4
+ import { normalizePath } from "@intlayer/config";
4
5
 
5
6
  //#region src/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.ts
6
7
  /**
7
8
  * This function generates a list of dictionaries in the main directory
8
9
  */
9
- const getBuiltDynamicDictionariesPath = async (configuration, format = "esm") => {
10
+ const getBuiltDynamicDictionariesPath = async (configuration, format = "esm", excludeKeys = []) => {
10
11
  const { dynamicDictionariesDir, mainDir } = configuration.content;
11
12
  if (!existsSync(mainDir)) mkdirSync(mainDir, { recursive: true });
12
13
  const extension = format === "cjs" ? "cjs" : "mjs";
13
- return await fg(`${normalizePath(dynamicDictionariesDir)}/**/*.${extension}`);
14
+ return (await fg(`${normalizePath(dynamicDictionariesDir)}/**/*.${extension}`)).filter((path$1) => {
15
+ const key = basename(path$1, `.${extension}`);
16
+ return !excludeKeys.includes(key);
17
+ });
14
18
  };
15
19
 
16
20
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getBuiltDynamicDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'node:fs';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDynamicDictionariesPath = async (\n configuration: IntlayerConfig,\n format: 'cjs' | 'esm' = 'esm'\n) => {\n const { dynamicDictionariesDir, mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(dynamicDictionariesDir)}/**/*.${extension}`\n );\n\n return dictionariesPath;\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,kCAAkC,OAC7C,eACA,SAAwB,UACrB;CACH,MAAM,EAAE,wBAAwB,YAAY,cAAc;AAG1D,KAAI,CAAC,WAAW,QAAQ,CACtB,WAAU,SAAS,EAAE,WAAW,MAAM,CAAC;CAGzC,MAAM,YAAY,WAAW,QAAQ,QAAQ;AAM7C,QAJmC,MAAM,GACvC,GAAG,cAAc,uBAAuB,CAAC,QAAQ,YAClD"}
1
+ {"version":3,"file":"getBuiltDynamicDictionariesPath.mjs","names":["path"],"sources":["../../../src/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'node:fs';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDynamicDictionariesPath = async (\n configuration: IntlayerConfig,\n format: 'cjs' | 'esm' = 'esm',\n excludeKeys: string[] = []\n) => {\n const { dynamicDictionariesDir, mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(dynamicDictionariesDir)}/**/*.${extension}`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, `.${extension}`);\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,kCAAkC,OAC7C,eACA,SAAwB,OACxB,cAAwB,EAAE,KACvB;CACH,MAAM,EAAE,wBAAwB,YAAY,cAAc;AAG1D,KAAI,CAAC,WAAW,QAAQ,CACtB,WAAU,SAAS,EAAE,WAAW,MAAM,CAAC;CAGzC,MAAM,YAAY,WAAW,QAAQ,QAAQ;AAM7C,SAJmC,MAAM,GACvC,GAAG,cAAc,uBAAuB,CAAC,QAAQ,YAClD,EAEuB,QAAQ,WAAS;EACvC,MAAM,MAAM,SAASA,QAAM,IAAI,YAAY;AAC3C,SAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
@@ -1,16 +1,20 @@
1
1
  import { existsSync, mkdirSync } from "node:fs";
2
- import { normalizePath } from "@intlayer/config";
2
+ import { basename } from "node:path";
3
3
  import fg from "fast-glob";
4
+ import { normalizePath } from "@intlayer/config";
4
5
 
5
6
  //#region src/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.ts
6
7
  /**
7
8
  * This function generates a list of dictionaries in the main directory
8
9
  */
9
- const getBuiltFetchDictionariesPath = async (configuration, format = "esm") => {
10
+ const getBuiltFetchDictionariesPath = async (configuration, format = "esm", excludeKeys = []) => {
10
11
  const { fetchDictionariesDir, mainDir } = configuration.content;
11
12
  if (!existsSync(mainDir)) mkdirSync(mainDir, { recursive: true });
12
13
  const extension = format === "cjs" ? "cjs" : "mjs";
13
- return await fg(`${normalizePath(fetchDictionariesDir)}/**/*.${extension}`);
14
+ return (await fg(`${normalizePath(fetchDictionariesDir)}/**/*.${extension}`)).filter((path$1) => {
15
+ const key = basename(path$1, `.${extension}`);
16
+ return !excludeKeys.includes(key);
17
+ });
14
18
  };
15
19
 
16
20
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getBuiltFetchDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'node:fs';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltFetchDictionariesPath = async (\n configuration: IntlayerConfig,\n format: 'cjs' | 'esm' = 'esm'\n) => {\n const { fetchDictionariesDir, mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(fetchDictionariesDir)}/**/*.${extension}`\n );\n\n return dictionariesPath;\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,gCAAgC,OAC3C,eACA,SAAwB,UACrB;CACH,MAAM,EAAE,sBAAsB,YAAY,cAAc;AAGxD,KAAI,CAAC,WAAW,QAAQ,CACtB,WAAU,SAAS,EAAE,WAAW,MAAM,CAAC;CAGzC,MAAM,YAAY,WAAW,QAAQ,QAAQ;AAM7C,QAJmC,MAAM,GACvC,GAAG,cAAc,qBAAqB,CAAC,QAAQ,YAChD"}
1
+ {"version":3,"file":"getBuiltFetchDictionariesPath.mjs","names":["path"],"sources":["../../../src/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'node:fs';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltFetchDictionariesPath = async (\n configuration: IntlayerConfig,\n format: 'cjs' | 'esm' = 'esm',\n excludeKeys: string[] = []\n) => {\n const { fetchDictionariesDir, mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(fetchDictionariesDir)}/**/*.${extension}`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, `.${extension}`);\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,gCAAgC,OAC3C,eACA,SAAwB,OACxB,cAAwB,EAAE,KACvB;CACH,MAAM,EAAE,sBAAsB,YAAY,cAAc;AAGxD,KAAI,CAAC,WAAW,QAAQ,CACtB,WAAU,SAAS,EAAE,WAAW,MAAM,CAAC;CAGzC,MAAM,YAAY,WAAW,QAAQ,QAAQ;AAM7C,SAJmC,MAAM,GACvC,GAAG,cAAc,qBAAqB,CAAC,QAAQ,YAChD,EAEuB,QAAQ,WAAS;EACvC,MAAM,MAAM,SAASA,QAAM,IAAI,YAAY;AAC3C,SAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
@@ -1,15 +1,19 @@
1
1
  import { existsSync, mkdirSync } from "node:fs";
2
- import { normalizePath } from "@intlayer/config";
2
+ import { basename } from "node:path";
3
3
  import fg from "fast-glob";
4
+ import { normalizePath } from "@intlayer/config";
4
5
 
5
6
  //#region src/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.ts
6
7
  /**
7
8
  * This function generates a list of dictionaries in the main directory
8
9
  */
9
- const getBuiltRemoteDictionariesPath = async (configuration) => {
10
+ const getBuiltRemoteDictionariesPath = async (configuration, excludeKeys = []) => {
10
11
  const { remoteDictionariesDir, mainDir } = configuration.content;
11
12
  if (!existsSync(mainDir)) mkdirSync(mainDir, { recursive: true });
12
- return fg.sync(`${normalizePath(remoteDictionariesDir)}/**/*.json`);
13
+ return fg.sync(`${normalizePath(remoteDictionariesDir)}/**/*.json`).filter((path$1) => {
14
+ const key = basename(path$1, ".json");
15
+ return !excludeKeys.includes(key);
16
+ });
13
17
  };
14
18
 
15
19
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getBuiltRemoteDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'node:fs';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltRemoteDictionariesPath = async (\n configuration: IntlayerConfig\n) => {\n const { remoteDictionariesDir, mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = fg.sync(\n `${normalizePath(remoteDictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath;\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,iCAAiC,OAC5C,kBACG;CACH,MAAM,EAAE,uBAAuB,YAAY,cAAc;AAGzD,KAAI,CAAC,WAAW,QAAQ,CACtB,WAAU,SAAS,EAAE,WAAW,MAAM,CAAC;AAOzC,QAJmC,GAAG,KACpC,GAAG,cAAc,sBAAsB,CAAC,YACzC"}
1
+ {"version":3,"file":"getBuiltRemoteDictionariesPath.mjs","names":["path"],"sources":["../../../src/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'node:fs';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltRemoteDictionariesPath = async (\n configuration: IntlayerConfig,\n excludeKeys: string[] = []\n) => {\n const { remoteDictionariesDir, mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = fg.sync(\n `${normalizePath(remoteDictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, '.json');\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,iCAAiC,OAC5C,eACA,cAAwB,EAAE,KACvB;CACH,MAAM,EAAE,uBAAuB,YAAY,cAAc;AAGzD,KAAI,CAAC,WAAW,QAAQ,CACtB,WAAU,SAAS,EAAE,WAAW,MAAM,CAAC;AAOzC,QAJmC,GAAG,KACpC,GAAG,cAAc,sBAAsB,CAAC,YACzC,CAEuB,QAAQ,WAAS;EACvC,MAAM,MAAM,SAASA,QAAM,QAAQ;AACnC,SAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}