@intlayer/chokidar 7.5.2 → 7.5.4
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.
- package/dist/cjs/cleanRemovedContentDeclaration.cjs +54 -25
- package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +7 -6
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +7 -3
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +7 -3
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +7 -3
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +7 -3
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +7 -3
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createType/createModuleAugmentation.cjs +1 -1
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +2 -2
- package/dist/cjs/handleContentDeclarationFileChange.cjs +14 -13
- package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileMoved.cjs +24 -0
- package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -0
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +5 -8
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/prepareIntlayer.cjs +1 -1
- package/dist/cjs/watcher.cjs +36 -15
- package/dist/cjs/watcher.cjs.map +1 -1
- package/dist/esm/cleanRemovedContentDeclaration.mjs +54 -26
- package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +7 -6
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +7 -3
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +7 -3
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +7 -3
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +7 -3
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +7 -3
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
- package/dist/esm/createType/createModuleAugmentation.mjs +1 -1
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs +2 -2
- package/dist/esm/handleContentDeclarationFileChange.mjs +14 -13
- package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileMoved.mjs +23 -0
- package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -0
- package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +5 -8
- package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/prepareIntlayer.mjs +1 -1
- package/dist/esm/watcher.mjs +36 -15
- package/dist/esm/watcher.mjs.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
- package/dist/types/cleanRemovedContentDeclaration.d.ts +5 -1
- package/dist/types/cleanRemovedContentDeclaration.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +7 -3
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
- package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/index.d.ts +2 -2
- package/dist/types/handleContentDeclarationFileMoved.d.ts +7 -0
- package/dist/types/handleContentDeclarationFileMoved.d.ts.map +1 -0
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +2 -2
- package/dist/types/watcher.d.ts.map +1 -1
- package/package.json +10 -10
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { existsSync, mkdirSync } from "node:fs";
|
|
2
|
-
import {
|
|
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/getBuiltUnmergedDictionariesPath.ts
|
|
6
7
|
/**
|
|
7
8
|
* This function generates a list of dictionaries in the main directory
|
|
8
9
|
*/
|
|
9
|
-
const getBuiltUnmergedDictionariesPath = async (configuration) => {
|
|
10
|
+
const getBuiltUnmergedDictionariesPath = async (configuration, excludeKeys = []) => {
|
|
10
11
|
const { unmergedDictionariesDir, mainDir } = configuration.content;
|
|
11
12
|
if (!existsSync(mainDir)) mkdirSync(mainDir, { recursive: true });
|
|
12
|
-
return await fg(`${normalizePath(unmergedDictionariesDir)}/**/*.json`)
|
|
13
|
+
return (await fg(`${normalizePath(unmergedDictionariesDir)}/**/*.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":"getBuiltUnmergedDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.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 getBuiltUnmergedDictionariesPath = async (\n configuration: IntlayerConfig\n) => {\n const { unmergedDictionariesDir, 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(unmergedDictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getBuiltUnmergedDictionariesPath.mjs","names":["path"],"sources":["../../../src/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.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 getBuiltUnmergedDictionariesPath = async (\n configuration: IntlayerConfig,\n excludeKeys: string[] = []\n) => {\n const { unmergedDictionariesDir, 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(unmergedDictionariesDir)}/**/*.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,mCAAmC,OAC9C,eACA,cAAwB,EAAE,KACvB;CACH,MAAM,EAAE,yBAAyB,YAAY,cAAc;AAG3D,KAAI,CAAC,WAAW,QAAQ,CACtB,WAAU,SAAS,EAAE,WAAW,MAAM,CAAC;AAOzC,SAJmC,MAAM,GACvC,GAAG,cAAc,wBAAwB,CAAC,YAC3C,EAEuB,QAAQ,WAAS;EACvC,MAAM,MAAM,SAASA,QAAM,QAAQ;AACnC,SAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
|
|
@@ -2,8 +2,8 @@ import { writeFileIfChanged } from "../writeFileIfChanged.mjs";
|
|
|
2
2
|
import { getFileHash } from "../utils/getFileHash.mjs";
|
|
3
3
|
import { mkdir } from "node:fs/promises";
|
|
4
4
|
import { basename, extname, join, relative } from "node:path";
|
|
5
|
-
import { kebabCaseToCamelCase, normalizePath } from "@intlayer/config";
|
|
6
5
|
import fg from "fast-glob";
|
|
6
|
+
import { kebabCaseToCamelCase, normalizePath } from "@intlayer/config";
|
|
7
7
|
|
|
8
8
|
//#region src/createType/createModuleAugmentation.ts
|
|
9
9
|
const getTypeName = (key) => `${kebabCaseToCamelCase(key)}Content`;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";
|
|
2
|
-
import { createModuleAugmentation } from "./createType/createModuleAugmentation.mjs";
|
|
3
|
-
import { createTypes } from "./createType/createType.mjs";
|
|
4
2
|
import { formatPath } from "./utils/formatter.mjs";
|
|
5
3
|
import { buildDictionary } from "./buildIntlayerDictionary/buildIntlayerDictionary.mjs";
|
|
4
|
+
import { createModuleAugmentation } from "./createType/createModuleAugmentation.mjs";
|
|
5
|
+
import { createTypes } from "./createType/createType.mjs";
|
|
6
6
|
import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.mjs";
|
|
7
7
|
import { getAppLogger } from "@intlayer/config";
|
|
8
8
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getBuiltDictionariesPath } from "./createDictionaryEntryPoint/getBuiltDictionariesPath.mjs";
|
|
2
2
|
import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";
|
|
3
|
-
import { createModuleAugmentation } from "./createType/createModuleAugmentation.mjs";
|
|
4
|
-
import { createTypes } from "./createType/createType.mjs";
|
|
5
3
|
import { cleanRemovedContentDeclaration } from "./cleanRemovedContentDeclaration.mjs";
|
|
6
4
|
import { formatPath } from "./utils/formatter.mjs";
|
|
7
5
|
import { buildDictionary } from "./buildIntlayerDictionary/buildIntlayerDictionary.mjs";
|
|
6
|
+
import { createModuleAugmentation } from "./createType/createModuleAugmentation.mjs";
|
|
7
|
+
import { createTypes } from "./createType/createType.mjs";
|
|
8
8
|
import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.mjs";
|
|
9
9
|
import { getAppLogger } from "@intlayer/config";
|
|
10
10
|
|
|
@@ -12,21 +12,22 @@ import { getAppLogger } from "@intlayer/config";
|
|
|
12
12
|
const handleContentDeclarationFileChange = async (filePath, config) => {
|
|
13
13
|
const appLogger = getAppLogger(config);
|
|
14
14
|
appLogger(`Change detected: ${formatPath(filePath)}`, { isVerbose: true });
|
|
15
|
+
const allDictionariesPaths = await getBuiltDictionariesPath(config);
|
|
15
16
|
const localeDictionaries = await loadLocalDictionaries(filePath, config);
|
|
16
|
-
localeDictionaries.forEach(async (dictionary) => {
|
|
17
|
-
await cleanRemovedContentDeclaration(filePath, dictionary.key, config);
|
|
18
|
-
});
|
|
19
17
|
const dictionariesOutput = await buildDictionary(localeDictionaries, config);
|
|
20
18
|
const updatedDictionariesPaths = Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionaryPath);
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const { excludeKeys, hasRebuilt } = await cleanRemovedContentDeclaration(filePath, localeDictionaries.map((dictionary) => dictionary.key), config);
|
|
20
|
+
const hasNewDictionaries = updatedDictionariesPaths.some((updatedDictionaryPath) => !allDictionariesPaths.includes(updatedDictionaryPath));
|
|
21
|
+
if (hasRebuilt || hasNewDictionaries) {
|
|
22
|
+
if (!hasRebuilt) {
|
|
23
|
+
await createDictionaryEntryPoint(config, { excludeKeys });
|
|
24
|
+
appLogger("Dictionary list built", { isVerbose: true });
|
|
25
|
+
}
|
|
26
|
+
await createTypes(updatedDictionariesPaths, config);
|
|
27
|
+
appLogger("TypeScript types built", { isVerbose: true });
|
|
28
|
+
await createModuleAugmentation(config);
|
|
29
|
+
appLogger("Module augmentation built", { isVerbose: true });
|
|
27
30
|
}
|
|
28
|
-
createModuleAugmentation(config);
|
|
29
|
-
appLogger("Module augmentation built", { isVerbose: true });
|
|
30
31
|
for await (const plugin of config.plugins ?? []) {
|
|
31
32
|
const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;
|
|
32
33
|
await plugin.afterBuild?.({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleContentDeclarationFileChange.mjs","names":["allDictionariesPaths: string[]"],"sources":["../../src/handleContentDeclarationFileChange.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 { getBuiltDictionariesPath } from './createDictionaryEntryPoint/getBuiltDictionariesPath';\nimport { createTypes } from './createType';\nimport { createModuleAugmentation } from './createType/createModuleAugmentation';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const
|
|
1
|
+
{"version":3,"file":"handleContentDeclarationFileChange.mjs","names":["allDictionariesPaths: string[]"],"sources":["../../src/handleContentDeclarationFileChange.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 { getBuiltDictionariesPath } from './createDictionaryEntryPoint/getBuiltDictionariesPath';\nimport { createTypes } from './createType';\nimport { createModuleAugmentation } from './createType/createModuleAugmentation';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const allDictionariesPaths: string[] = await getBuiltDictionariesPath(config);\n\n const localeDictionaries = await loadLocalDictionaries(filePath, config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n const updatedDictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n const { excludeKeys, hasRebuilt } = await cleanRemovedContentDeclaration(\n filePath,\n localeDictionaries.map((dictionary) => dictionary.key),\n config\n );\n\n const hasNewDictionaries = updatedDictionariesPaths.some(\n (updatedDictionaryPath) =>\n !allDictionariesPaths.includes(updatedDictionaryPath)\n );\n\n // Rebuild artifacts if we cleaned up old files (hasRebuilt) OR if new files were added (hasNewDictionaries)\n if (hasRebuilt || hasNewDictionaries) {\n // If hasRebuilt is true, cleanRemovedContentDeclaration has already updated the entry point\n // to remove the old keys (and it likely included the new ones if they were already on disk).\n // If NOT hasRebuilt, we explicitly need to update the entry point to include the new dictionaries.\n if (!hasRebuilt) {\n await createDictionaryEntryPoint(config, { excludeKeys });\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n }\n\n // Always regenerate types and module augmentation when keys change (rename or add)\n await createTypes(updatedDictionariesPaths, config);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n await createModuleAugmentation(config);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n }\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of 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,qCAAqC,OAChD,UACA,WACG;CACH,MAAM,YAAY,aAAa,OAAO;AAGtC,WAAU,oBAAoB,WAAW,SAAS,IAAI,EACpD,WAAW,MACZ,CAAC;CAEF,MAAMA,uBAAiC,MAAM,yBAAyB,OAAO;CAE7E,MAAM,qBAAqB,MAAM,sBAAsB,UAAU,OAAO;CAExE,MAAM,qBAAqB,MAAM,gBAAgB,oBAAoB,OAAO;CAC5E,MAAM,2BAA2B,OAAO,OACtC,oBAAoB,sBAAsB,EAAE,CAC7C,CAAC,KAAK,eAAe,WAAW,eAAe;CAEhD,MAAM,EAAE,aAAa,eAAe,MAAM,+BACxC,UACA,mBAAmB,KAAK,eAAe,WAAW,IAAI,EACtD,OACD;CAED,MAAM,qBAAqB,yBAAyB,MACjD,0BACC,CAAC,qBAAqB,SAAS,sBAAsB,CACxD;AAGD,KAAI,cAAc,oBAAoB;AAIpC,MAAI,CAAC,YAAY;AACf,SAAM,2BAA2B,QAAQ,EAAE,aAAa,CAAC;AACzD,aAAU,yBAAyB,EACjC,WAAW,MACZ,CAAC;;AAIJ,QAAM,YAAY,0BAA0B,OAAO;AACnD,YAAU,0BAA0B,EAClC,WAAW,MACZ,CAAC;AAEF,QAAM,yBAAyB,OAAO;AAEtC,YAAU,6BAA6B,EACrC,WAAW,MACZ,CAAC;;AAKJ,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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { cleanRemovedContentDeclaration } from "./cleanRemovedContentDeclaration.mjs";
|
|
2
|
+
import { formatPath } from "./utils/formatter.mjs";
|
|
3
|
+
import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.mjs";
|
|
4
|
+
import { handleContentDeclarationFileChange } from "./handleContentDeclarationFileChange.mjs";
|
|
5
|
+
import { getAppLogger } from "@intlayer/config";
|
|
6
|
+
|
|
7
|
+
//#region src/handleContentDeclarationFileMoved.ts
|
|
8
|
+
const handleContentDeclarationFileMoved = async (oldFilePath, newFilePath, config) => {
|
|
9
|
+
const appLogger = getAppLogger(config);
|
|
10
|
+
appLogger(`File moved from ${formatPath(oldFilePath)} to ${formatPath(newFilePath)}`, { isVerbose: true });
|
|
11
|
+
let keysToKeep = [];
|
|
12
|
+
try {
|
|
13
|
+
keysToKeep = (await loadLocalDictionaries(newFilePath, config)).map((d) => d.key);
|
|
14
|
+
} catch {
|
|
15
|
+
appLogger(`Error parsing new file during move operation: ${formatPath(newFilePath)}`, { isVerbose: true });
|
|
16
|
+
}
|
|
17
|
+
await cleanRemovedContentDeclaration(oldFilePath, keysToKeep, config);
|
|
18
|
+
await handleContentDeclarationFileChange(newFilePath, config);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { handleContentDeclarationFileMoved };
|
|
23
|
+
//# sourceMappingURL=handleContentDeclarationFileMoved.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleContentDeclarationFileMoved.mjs","names":["keysToKeep: string[]"],"sources":["../../src/handleContentDeclarationFileMoved.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { cleanRemovedContentDeclaration } from './cleanRemovedContentDeclaration';\nimport { handleContentDeclarationFileChange } from './handleContentDeclarationFileChange';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleContentDeclarationFileMoved = async (\n oldFilePath: string,\n newFilePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n appLogger(\n `File moved from ${formatPath(oldFilePath)} to ${formatPath(newFilePath)}`,\n {\n isVerbose: true,\n }\n );\n\n let keysToKeep: string[] = [];\n\n try {\n // Pre-load the new file to identify the keys inside it.\n // We need to pass these keys to the cleaner so it knows NOT to completely delete\n // the dictionary artifacts (types/json) if the key has simply moved to a new file.\n const newLocaleDictionaries = await loadLocalDictionaries(\n newFilePath,\n config\n );\n keysToKeep = newLocaleDictionaries.map((d) => d.key);\n } catch {\n appLogger(\n `Error parsing new file during move operation: ${formatPath(newFilePath)}`,\n {\n isVerbose: true,\n }\n );\n // Proceed with empty keysToKeep; this will result in the old dictionary being cleaned up\n // entirely, and the new one being re-created in the next step.\n }\n\n // Clean up the artifacts associated with the old file path.\n // By passing 'keysToKeep', we instruct the cleaner to remove the specific file association\n // (filePath reference) from the dictionaries, but preserve the dictionary Entry Point and Types\n // if the key is still present in the new file.\n await cleanRemovedContentDeclaration(oldFilePath, keysToKeep, config);\n\n // Process the new file.\n // This will add the new file association, rebuild the dictionary JSONs with the new path,\n // and ensure types and module augmentation are up to date.\n await handleContentDeclarationFileChange(newFilePath, config);\n};\n"],"mappings":";;;;;;;AAOA,MAAa,oCAAoC,OAC/C,aACA,aACA,WACG;CACH,MAAM,YAAY,aAAa,OAAO;AAEtC,WACE,mBAAmB,WAAW,YAAY,CAAC,MAAM,WAAW,YAAY,IACxE,EACE,WAAW,MACZ,CACF;CAED,IAAIA,aAAuB,EAAE;AAE7B,KAAI;AAQF,gBAJ8B,MAAM,sBAClC,aACA,OACD,EACkC,KAAK,MAAM,EAAE,IAAI;SAC9C;AACN,YACE,iDAAiD,WAAW,YAAY,IACxE,EACE,WAAW,MACZ,CACF;;AASH,OAAM,+BAA+B,aAAa,YAAY,OAAO;AAKrE,OAAM,mCAAmC,aAAa,OAAO"}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";
|
|
2
|
-
import { createModuleAugmentation } from "./createType/createModuleAugmentation.mjs";
|
|
3
|
-
import { createTypes } from "./createType/createType.mjs";
|
|
4
1
|
import { cleanRemovedContentDeclaration } from "./cleanRemovedContentDeclaration.mjs";
|
|
5
2
|
import { formatPath } from "./utils/formatter.mjs";
|
|
6
3
|
import { buildDictionary } from "./buildIntlayerDictionary/buildIntlayerDictionary.mjs";
|
|
4
|
+
import { createModuleAugmentation } from "./createType/createModuleAugmentation.mjs";
|
|
5
|
+
import { createTypes } from "./createType/createType.mjs";
|
|
7
6
|
import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.mjs";
|
|
8
7
|
import { listDictionaries } from "./listDictionariesPath.mjs";
|
|
8
|
+
import { normalize } from "node:path";
|
|
9
9
|
import { getAppLogger } from "@intlayer/config";
|
|
10
10
|
|
|
11
11
|
//#region src/handleUnlinkedContentDeclarationFile.ts
|
|
12
12
|
const handleUnlinkedContentDeclarationFile = async (filePath, config) => {
|
|
13
13
|
const appLogger = getAppLogger(config);
|
|
14
14
|
appLogger(`Unlinked detected: ${formatPath(filePath)}`, { isVerbose: true });
|
|
15
|
-
const localeDictionaries = await loadLocalDictionaries(await listDictionaries(config), config);
|
|
16
|
-
|
|
17
|
-
await cleanRemovedContentDeclaration(filePath, dictionary.key, config);
|
|
18
|
-
});
|
|
15
|
+
const localeDictionaries = await loadLocalDictionaries((await listDictionaries(config)).filter((file) => normalize(file) !== normalize(filePath)), config);
|
|
16
|
+
await cleanRemovedContentDeclaration(filePath, [], config);
|
|
19
17
|
const dictionariesOutput = await buildDictionary(localeDictionaries, config);
|
|
20
18
|
await createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionaryPath), config);
|
|
21
|
-
await createDictionaryEntryPoint();
|
|
22
19
|
appLogger("Dictionaries rebuilt", { isVerbose: true });
|
|
23
20
|
await createModuleAugmentation(config);
|
|
24
21
|
appLogger("Module augmentation built", { isVerbose: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleUnlinkedContentDeclarationFile.mjs","names":[],"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 {
|
|
1
|
+
{"version":3,"file":"handleUnlinkedContentDeclarationFile.mjs","names":[],"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,YAAY,aAAa,OAAO;AAGtC,WAAU,sBAAsB,WAAW,SAAS,IAAI,EACtD,WAAW,MACZ,CAAC;CAQF,MAAM,qBAAqB,MAAM,uBANT,MAAM,iBAAiB,OAAO,EAE1B,QACzB,SAAS,UAAU,KAAK,KAAK,UAAU,SAAS,CAClD,EAEqE,OAAO;AAE7E,OAAM,+BAA+B,UAAU,EAAE,EAAE,OAAO;CAE1D,MAAM,qBAAqB,MAAM,gBAAgB,oBAAoB,OAAO;AAM5E,OAAM,YAJoB,OAAO,OAC/B,oBAAoB,sBAAsB,EAAE,CAC7C,CAAC,KAAK,eAAe,WAAW,eAAe,EAEX,OAAO;AAE5C,WAAU,wBAAwB,EAChC,WAAW,MACZ,CAAC;AAEF,OAAM,yBAAyB,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"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -9,13 +9,13 @@ import { getBuiltFetchDictionariesPath } from "./createDictionaryEntryPoint/getB
|
|
|
9
9
|
import { getBuiltRemoteDictionariesPath } from "./createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs";
|
|
10
10
|
import { getBuiltUnmergedDictionariesPath } from "./createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs";
|
|
11
11
|
import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";
|
|
12
|
-
import { createModuleAugmentation } from "./createType/createModuleAugmentation.mjs";
|
|
13
|
-
import { createTypes } from "./createType/createType.mjs";
|
|
14
12
|
import { fetchDistantDictionaries } from "./fetchDistantDictionaries.mjs";
|
|
15
13
|
import { formatLocale, formatPath } from "./utils/formatter.mjs";
|
|
16
14
|
import { isInvalidDictionary } from "./filterInvalidDictionaries.mjs";
|
|
17
15
|
import { formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput } from "./formatDictionary.mjs";
|
|
18
16
|
import { buildDictionary } from "./buildIntlayerDictionary/buildIntlayerDictionary.mjs";
|
|
17
|
+
import { createModuleAugmentation } from "./createType/createModuleAugmentation.mjs";
|
|
18
|
+
import { createTypes } from "./createType/createType.mjs";
|
|
19
19
|
import { resolveObjectPromises } from "./utils/resolveObjectPromises.mjs";
|
|
20
20
|
import { loadContentDeclarations } from "./loadDictionaries/loadContentDeclaration.mjs";
|
|
21
21
|
import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { cleanOutputDir } from "./cleanOutputDir.mjs";
|
|
2
2
|
import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";
|
|
3
|
+
import { buildDictionary } from "./buildIntlayerDictionary/buildIntlayerDictionary.mjs";
|
|
3
4
|
import { createModuleAugmentation } from "./createType/createModuleAugmentation.mjs";
|
|
4
5
|
import { createTypes } from "./createType/createType.mjs";
|
|
5
|
-
import { buildDictionary } from "./buildIntlayerDictionary/buildIntlayerDictionary.mjs";
|
|
6
6
|
import { listDictionariesWithStats } from "./listDictionariesPath.mjs";
|
|
7
7
|
import { loadDictionaries } from "./loadDictionaries/loadDictionaries.mjs";
|
|
8
8
|
import { writeRemoteDictionary } from "./buildIntlayerDictionary/writeRemoteDictionary.mjs";
|
package/dist/esm/watcher.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { handleAdditionalContentDeclarationFile } from "./handleAdditionalContentDeclarationFile.mjs";
|
|
2
2
|
import { handleContentDeclarationFileChange } from "./handleContentDeclarationFileChange.mjs";
|
|
3
|
+
import { handleContentDeclarationFileMoved } from "./handleContentDeclarationFileMoved.mjs";
|
|
3
4
|
import { handleUnlinkedContentDeclarationFile } from "./handleUnlinkedContentDeclarationFile.mjs";
|
|
4
5
|
import { prepareIntlayer } from "./prepareIntlayer.mjs";
|
|
5
6
|
import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.mjs";
|
|
@@ -10,7 +11,7 @@ import { watch as watch$1 } from "chokidar";
|
|
|
10
11
|
|
|
11
12
|
//#region src/watcher.ts
|
|
12
13
|
/** @ts-ignore remove error Module '"chokidar"' has no exported member 'ChokidarOptions'. */
|
|
13
|
-
const
|
|
14
|
+
const pendingUnlinks = /* @__PURE__ */ new Map();
|
|
14
15
|
const watch = (options) => {
|
|
15
16
|
const configuration = options?.configuration ?? getConfiguration(options?.configOptions);
|
|
16
17
|
const appLogger = getAppLogger(configuration);
|
|
@@ -31,23 +32,43 @@ const watch = (options) => {
|
|
|
31
32
|
...options
|
|
32
33
|
}).on("add", async (filePath) => {
|
|
33
34
|
const fileName = basename(filePath);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
let isMove = false;
|
|
36
|
+
let matchedOldPath;
|
|
37
|
+
for (const [oldPath] of pendingUnlinks) if (basename(oldPath) === fileName) {
|
|
38
|
+
matchedOldPath = oldPath;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
if (!matchedOldPath && pendingUnlinks.size === 1) matchedOldPath = pendingUnlinks.keys().next().value;
|
|
42
|
+
if (matchedOldPath) {
|
|
43
|
+
const pending = pendingUnlinks.get(matchedOldPath);
|
|
44
|
+
if (pending) {
|
|
45
|
+
clearTimeout(pending.timer);
|
|
46
|
+
pendingUnlinks.delete(matchedOldPath);
|
|
47
|
+
}
|
|
48
|
+
isMove = true;
|
|
49
|
+
appLogger(`File moved from ${matchedOldPath} to ${filePath}`);
|
|
50
|
+
await handleContentDeclarationFileMoved(matchedOldPath, filePath, configuration);
|
|
51
|
+
}
|
|
52
|
+
if (!isMove) {
|
|
53
|
+
if (await readFile(filePath, "utf-8") === "") {
|
|
54
|
+
const extensionPattern = fileExtensions.map((ext) => ext.replace(/\./g, "\\.")).join("|");
|
|
55
|
+
await writeContentDeclaration({
|
|
56
|
+
key: fileName.replace(/* @__PURE__ */ new RegExp(`(${extensionPattern})$`), ""),
|
|
57
|
+
content: {},
|
|
58
|
+
filePath
|
|
59
|
+
}, configuration);
|
|
60
|
+
}
|
|
42
61
|
}
|
|
43
62
|
await handleAdditionalContentDeclarationFile(filePath, configuration);
|
|
44
|
-
setTimeout(() => recentlyAddedFiles.delete(fileName), 1e3);
|
|
45
63
|
}).on("change", async (filePath) => await handleContentDeclarationFileChange(filePath, configuration)).on("unlink", async (filePath) => {
|
|
46
|
-
setTimeout(async () => {
|
|
47
|
-
|
|
48
|
-
if (recentlyAddedFiles.has(fileName)) return;
|
|
64
|
+
const timer = setTimeout(async () => {
|
|
65
|
+
pendingUnlinks.delete(filePath);
|
|
49
66
|
await handleUnlinkedContentDeclarationFile(filePath, configuration);
|
|
50
|
-
},
|
|
67
|
+
}, 200);
|
|
68
|
+
pendingUnlinks.set(filePath, {
|
|
69
|
+
timer,
|
|
70
|
+
oldPath: filePath
|
|
71
|
+
});
|
|
51
72
|
}).on("error", async (error) => {
|
|
52
73
|
appLogger(`Watcher error: ${error}`, { level: "error" });
|
|
53
74
|
appLogger("Restarting watcher");
|
|
@@ -57,7 +78,7 @@ const watch = (options) => {
|
|
|
57
78
|
const buildAndWatchIntlayer = async (options) => {
|
|
58
79
|
const { skipPrepare, ...rest } = options ?? {};
|
|
59
80
|
const configuration = options?.configuration ?? getConfiguration(options?.configOptions);
|
|
60
|
-
if (!
|
|
81
|
+
if (!skipPrepare) await prepareIntlayer(configuration, { forceRun: true });
|
|
61
82
|
if (configuration.content.watch || options?.persistent) {
|
|
62
83
|
getAppLogger(configuration)("Watching Intlayer content declarations");
|
|
63
84
|
watch({
|
package/dist/esm/watcher.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watcher.mjs","names":["chokidarWatch"],"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
|
|
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,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,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,SAAM,kCACJ,gBACA,UACA,cACD;;AAIH,MAAI,CAAC,QAKH;OAJoB,MAAM,SAAS,UAAU,QAAQ,KACrB,IAGnB;IACX,MAAM,mBAAmB,eACtB,KAAK,QAAQ,IAAI,QAAQ,OAAO,MAAM,CAAC,CACvC,KAAK,IAAI;AAMZ,UAAM,wBACJ;KACE,KAPS,SAAS,wBACpB,IAAI,OAAO,IAAI,iBAAiB,IAAI,EACpC,GACD;KAKG,SAAS,EAAE;KACX;KACD,EACD,cACD;;;AAKL,QAAM,uCAAuC,UAAU,cAAc;GACrE,CACD,GACC,UACA,OAAO,aACL,MAAM,mCAAmC,UAAU,cAAc,CACpE,CACA,GAAG,UAAU,OAAO,aAAa;EAEhC,MAAM,QAAQ,WAAW,YAAY;AAEnC,kBAAe,OAAO,SAAS;AAC/B,SAAM,qCAAqC,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,QAAM,gBAAgB,cAAc;GACpC;;AAGN,MAAa,wBAAwB,OAAO,YAA2B;CACrE,MAAM,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,5 +1,5 @@
|
|
|
1
1
|
import { MergedDictionaryOutput } from "./writeMergedDictionary.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types21 from "@intlayer/types";
|
|
3
3
|
import { Dictionary, Locale } from "@intlayer/types";
|
|
4
4
|
|
|
5
5
|
//#region src/buildIntlayerDictionary/writeDynamicDictionary.d.ts
|
|
@@ -12,7 +12,7 @@ type LocalizedDictionaryOutput = Record<string, LocalizedDictionaryResult>;
|
|
|
12
12
|
/**
|
|
13
13
|
* This function generates the content of the dictionary list file
|
|
14
14
|
*/
|
|
15
|
-
declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?:
|
|
15
|
+
declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?: _intlayer_types21.IntlayerConfig) => string;
|
|
16
16
|
/**
|
|
17
17
|
* Write the localized dictionaries to the dictionariesDir
|
|
18
18
|
* @param mergedDictionaries - The merged dictionaries
|
|
@@ -29,7 +29,7 @@ declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: L
|
|
|
29
29
|
* // { key: 'home', content: { ... } },
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration?:
|
|
32
|
+
declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration?: _intlayer_types21.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
|
|
33
33
|
//#endregion
|
|
34
34
|
export { DictionaryResult, LocalizedDictionaryOutput, LocalizedDictionaryResult, generateDictionaryEntryPoint, writeDynamicDictionary };
|
|
35
35
|
//# sourceMappingURL=writeDynamicDictionary.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UnmergedDictionaryOutput } from "./writeUnmergedDictionary.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types18 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?:
|
|
27
|
+
declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration?: _intlayer_types18.IntlayerConfig) => Promise<MergedDictionaryOutput>;
|
|
28
28
|
//#endregion
|
|
29
29
|
export { MergedDictionaryOutput, MergedDictionaryResult, writeMergedDictionaries };
|
|
30
30
|
//# sourceMappingURL=writeMergedDictionary.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types19 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?:
|
|
26
|
+
declare const writeRemoteDictionary: (remoteDictionaries: Dictionary[], configuration?: _intlayer_types19.IntlayerConfig) => Promise<RemoteDictionaryOutput>;
|
|
27
27
|
//#endregion
|
|
28
28
|
export { RemoteDictionaryOutput, RemoteDictionaryResult, writeRemoteDictionary };
|
|
29
29
|
//# sourceMappingURL=writeRemoteDictionary.d.ts.map
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/cleanRemovedContentDeclaration.d.ts
|
|
4
|
-
declare const cleanRemovedContentDeclaration: (filePath: string,
|
|
4
|
+
declare const cleanRemovedContentDeclaration: (filePath: string, keysToKeep: string[], configuration: IntlayerConfig) => Promise<{
|
|
5
|
+
changedDictionariesLocalIds: string[];
|
|
6
|
+
excludeKeys: string[];
|
|
7
|
+
hasRebuilt: boolean;
|
|
8
|
+
}>;
|
|
5
9
|
//#endregion
|
|
6
10
|
export { cleanRemovedContentDeclaration };
|
|
7
11
|
//# sourceMappingURL=cleanRemovedContentDeclaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanRemovedContentDeclaration.d.ts","names":[],"sources":["../../src/cleanRemovedContentDeclaration.ts"],"sourcesContent":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"cleanRemovedContentDeclaration.d.ts","names":[],"sources":["../../src/cleanRemovedContentDeclaration.ts"],"sourcesContent":[],"mappings":";;;cAea,wFAGI,mBACd;;EAJU,WAAA,EAAA,MAAA,EAAA"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types13 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts
|
|
4
|
+
type CreateDictionaryEntryPointOptions = {
|
|
5
|
+
formats?: ('cjs' | 'esm')[];
|
|
6
|
+
excludeKeys?: string[];
|
|
7
|
+
};
|
|
4
8
|
/**
|
|
5
9
|
* This function generates a list of dictionaries in the main directory
|
|
6
10
|
*/
|
|
7
|
-
declare const createDictionaryEntryPoint: (configuration?:
|
|
11
|
+
declare const createDictionaryEntryPoint: (configuration?: _intlayer_types13.IntlayerConfig, options?: CreateDictionaryEntryPointOptions) => Promise<void>;
|
|
8
12
|
//#endregion
|
|
9
|
-
export { createDictionaryEntryPoint };
|
|
13
|
+
export { CreateDictionaryEntryPointOptions, createDictionaryEntryPoint };
|
|
10
14
|
//# sourceMappingURL=createDictionaryEntryPoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDictionaryEntryPoint.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"sourcesContent":[],"mappings":"
|
|
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
|
|
1
|
+
import * as _intlayer_types14 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?:
|
|
7
|
+
declare const generateDictionaryListContent: (dictionaries: string[], functionName: string, importType: "json" | "javascript", format?: "cjs" | "esm", configuration?: _intlayer_types14.IntlayerConfig) => string;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { generateDictionaryListContent };
|
|
10
10
|
//# sourceMappingURL=generateDictionaryListContent.d.ts.map
|
|
@@ -5,7 +5,7 @@ import { IntlayerConfig } from "@intlayer/types";
|
|
|
5
5
|
/**
|
|
6
6
|
* This function generates a list of dictionaries in the main directory
|
|
7
7
|
*/
|
|
8
|
-
declare const getBuiltDictionariesPath: (configuration: IntlayerConfig) => Promise<string[]>;
|
|
8
|
+
declare const getBuiltDictionariesPath: (configuration: IntlayerConfig, excludeKeys?: string[]) => Promise<string[]>;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { getBuiltDictionariesPath };
|
|
11
11
|
//# sourceMappingURL=getBuiltDictionariesPath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBuiltDictionariesPath.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltDictionariesPath.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"getBuiltDictionariesPath.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltDictionariesPath.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;cAAa,0CACI,2CACW"}
|
|
@@ -5,7 +5,7 @@ import { IntlayerConfig } from "@intlayer/types";
|
|
|
5
5
|
/**
|
|
6
6
|
* This function generates a list of dictionaries in the main directory
|
|
7
7
|
*/
|
|
8
|
-
declare const getBuiltDynamicDictionariesPath: (configuration: IntlayerConfig, format?: "cjs" | "esm") => Promise<string[]>;
|
|
8
|
+
declare const getBuiltDynamicDictionariesPath: (configuration: IntlayerConfig, format?: "cjs" | "esm", excludeKeys?: string[]) => Promise<string[]>;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { getBuiltDynamicDictionariesPath };
|
|
11
11
|
//# sourceMappingURL=getBuiltDynamicDictionariesPath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBuiltDynamicDictionariesPath.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"getBuiltDynamicDictionariesPath.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;cAAa,iDACI,mEAEW"}
|
|
@@ -5,7 +5,7 @@ import { IntlayerConfig } from "@intlayer/types";
|
|
|
5
5
|
/**
|
|
6
6
|
* This function generates a list of dictionaries in the main directory
|
|
7
7
|
*/
|
|
8
|
-
declare const getBuiltFetchDictionariesPath: (configuration: IntlayerConfig, format?: "cjs" | "esm") => Promise<string[]>;
|
|
8
|
+
declare const getBuiltFetchDictionariesPath: (configuration: IntlayerConfig, format?: "cjs" | "esm", excludeKeys?: string[]) => Promise<string[]>;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { getBuiltFetchDictionariesPath };
|
|
11
11
|
//# sourceMappingURL=getBuiltFetchDictionariesPath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBuiltFetchDictionariesPath.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"getBuiltFetchDictionariesPath.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;cAAa,+CACI,mEAEW"}
|
|
@@ -5,7 +5,7 @@ import { IntlayerConfig } from "@intlayer/types";
|
|
|
5
5
|
/**
|
|
6
6
|
* This function generates a list of dictionaries in the main directory
|
|
7
7
|
*/
|
|
8
|
-
declare const getBuiltRemoteDictionariesPath: (configuration: IntlayerConfig) => Promise<string[]>;
|
|
8
|
+
declare const getBuiltRemoteDictionariesPath: (configuration: IntlayerConfig, excludeKeys?: string[]) => Promise<string[]>;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { getBuiltRemoteDictionariesPath };
|
|
11
11
|
//# sourceMappingURL=getBuiltRemoteDictionariesPath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBuiltRemoteDictionariesPath.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"getBuiltRemoteDictionariesPath.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;cAAa,gDACI,2CACW"}
|
|
@@ -5,7 +5,7 @@ import { IntlayerConfig } from "@intlayer/types";
|
|
|
5
5
|
/**
|
|
6
6
|
* This function generates a list of dictionaries in the main directory
|
|
7
7
|
*/
|
|
8
|
-
declare const getBuiltUnmergedDictionariesPath: (configuration: IntlayerConfig) => Promise<string[]>;
|
|
8
|
+
declare const getBuiltUnmergedDictionariesPath: (configuration: IntlayerConfig, excludeKeys?: string[]) => Promise<string[]>;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { getBuiltUnmergedDictionariesPath };
|
|
11
11
|
//# sourceMappingURL=getBuiltUnmergedDictionariesPath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBuiltUnmergedDictionariesPath.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"getBuiltUnmergedDictionariesPath.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;cAAa,kDACI,2CACW"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint.js";
|
|
1
|
+
import { CreateDictionaryEntryPointOptions, createDictionaryEntryPoint } from "./createDictionaryEntryPoint.js";
|
|
2
2
|
import { generateDictionaryListContent } from "./generateDictionaryListContent.js";
|
|
3
3
|
import { getBuiltDictionariesPath } from "./getBuiltDictionariesPath.js";
|
|
4
4
|
import { getBuiltDynamicDictionariesPath } from "./getBuiltDynamicDictionariesPath.js";
|
|
5
5
|
import { getBuiltFetchDictionariesPath } from "./getBuiltFetchDictionariesPath.js";
|
|
6
6
|
import { getBuiltRemoteDictionariesPath } from "./getBuiltRemoteDictionariesPath.js";
|
|
7
7
|
import { getBuiltUnmergedDictionariesPath } from "./getBuiltUnmergedDictionariesPath.js";
|
|
8
|
-
export { createDictionaryEntryPoint, generateDictionaryListContent, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath };
|
|
8
|
+
export { CreateDictionaryEntryPointOptions, createDictionaryEntryPoint, generateDictionaryListContent, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IntlayerConfig } from "@intlayer/types";
|
|
2
|
+
|
|
3
|
+
//#region src/handleContentDeclarationFileMoved.d.ts
|
|
4
|
+
declare const handleContentDeclarationFileMoved: (oldFilePath: string, newFilePath: string, config: IntlayerConfig) => Promise<void>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { handleContentDeclarationFileMoved };
|
|
7
|
+
//# sourceMappingURL=handleContentDeclarationFileMoved.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleContentDeclarationFileMoved.d.ts","names":[],"sources":["../../src/handleContentDeclarationFileMoved.ts"],"sourcesContent":[],"mappings":";;;cAOa,sFAGH,mBAAc"}
|