@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.
- 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/buildIntlayerDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.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/utils/getFormatFromExtension.d.ts.map +1 -1
- package/dist/types/watcher.d.ts.map +1 -1
- package/package.json +10 -10
|
@@ -1,65 +1,94 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_createDictionaryEntryPoint_createDictionaryEntryPoint = require('./createDictionaryEntryPoint/createDictionaryEntryPoint.cjs');
|
|
3
|
-
const require_createType_createType = require('./createType/createType.cjs');
|
|
4
3
|
const require_writeJsonIfChanged = require('./writeJsonIfChanged.cjs');
|
|
5
4
|
let node_fs_promises = require("node:fs/promises");
|
|
6
5
|
let _intlayer_config_client = require("@intlayer/config/client");
|
|
7
6
|
let node_path = require("node:path");
|
|
8
7
|
let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
|
|
9
8
|
let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
|
|
9
|
+
let fast_glob = require("fast-glob");
|
|
10
|
+
fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
10
11
|
|
|
11
12
|
//#region src/cleanRemovedContentDeclaration.ts
|
|
12
|
-
const cleanRemovedContentDeclaration = async (filePath,
|
|
13
|
+
const cleanRemovedContentDeclaration = async (filePath, keysToKeep, configuration) => {
|
|
13
14
|
const appLogger = (0, _intlayer_config_client.getAppLogger)(configuration);
|
|
14
15
|
const unmergedDictionaries = (0, _intlayer_unmerged_dictionaries_entry.getUnmergedDictionaries)(configuration);
|
|
15
|
-
const
|
|
16
|
-
const
|
|
16
|
+
const baseDir = configuration.content.baseDir;
|
|
17
|
+
const relativeFilePath = (0, node_path.relative)(baseDir, filePath);
|
|
18
|
+
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));
|
|
17
19
|
const changedDictionariesLocalIds = [];
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
20
|
+
const filesToRemove = [];
|
|
21
|
+
const excludeKeys = [];
|
|
22
|
+
await Promise.all(uniqueUnmergedDictionaries.map(async (dictionary) => {
|
|
21
23
|
const unmergedFilePath = (0, node_path.normalize)((0, node_path.join)(configuration.content.unmergedDictionariesDir, `${dictionary.key}.json`));
|
|
22
24
|
try {
|
|
23
25
|
const jsonContent = await (0, node_fs_promises.readFile)(unmergedFilePath, "utf8");
|
|
24
26
|
const parsedContent = JSON.parse(jsonContent);
|
|
25
27
|
if (parsedContent.length === 1) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
if (parsedContent[0].filePath === relativeFilePath) {
|
|
29
|
+
appLogger(`Removing outdated dictionary ${(0, _intlayer_config_client.colorizeKey)(dictionary.key)}`, { isVerbose: true });
|
|
30
|
+
filesToRemove.push(unmergedFilePath);
|
|
31
|
+
excludeKeys.push(dictionary.key);
|
|
32
|
+
}
|
|
29
33
|
} else {
|
|
30
34
|
await require_writeJsonIfChanged.writeJsonIfChanged(unmergedFilePath, parsedContent.filter((content) => content.filePath !== relativeFilePath));
|
|
31
35
|
changedDictionariesLocalIds.push(dictionary.localId);
|
|
32
36
|
}
|
|
33
|
-
} catch {
|
|
34
|
-
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error.code === "ENOENT") {
|
|
39
|
+
if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
|
|
40
|
+
}
|
|
35
41
|
}
|
|
36
|
-
});
|
|
42
|
+
}));
|
|
37
43
|
const dictionaries = (0, _intlayer_dictionaries_entry.getDictionaries)(configuration);
|
|
38
|
-
const
|
|
39
|
-
|
|
44
|
+
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));
|
|
45
|
+
await Promise.all(uniqueMergedDictionaries.map(async (dictionary) => {
|
|
40
46
|
const mergedFilePath = (0, node_path.normalize)((0, node_path.join)(configuration.content.dictionariesDir, `${dictionary.key}.json`));
|
|
41
47
|
try {
|
|
42
48
|
const fileContent = await (0, node_fs_promises.readFile)(mergedFilePath, "utf8");
|
|
43
49
|
const parsedContent = JSON.parse(fileContent);
|
|
44
50
|
if (parsedContent.localIds?.length === 1) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
if (parsedContent.localIds[0].endsWith(`::local::${relativeFilePath}`)) {
|
|
52
|
+
appLogger(`Removing outdated unmerged dictionary ${(0, _intlayer_config_client.colorizeKey)(dictionary.key)}`, { isVerbose: true });
|
|
53
|
+
filesToRemove.push(mergedFilePath);
|
|
54
|
+
const typesFilePath = (0, node_path.normalize)((0, node_path.join)(configuration.content.typesDir, `${dictionary.key}.ts`));
|
|
55
|
+
filesToRemove.push(typesFilePath);
|
|
56
|
+
const dynamicFiles = await (0, fast_glob.default)((0, _intlayer_config_client.normalizePath)((0, node_path.join)(configuration.content.dynamicDictionariesDir, `${dictionary.key}.*`)), { absolute: true });
|
|
57
|
+
filesToRemove.push(...dynamicFiles);
|
|
58
|
+
if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
|
|
59
|
+
}
|
|
49
60
|
} else {
|
|
50
|
-
const localIds = parsedContent.localIds?.filter((localeId) => localeId
|
|
61
|
+
const localIds = parsedContent.localIds?.filter((localeId) => !localeId.endsWith(`::local::${relativeFilePath}`));
|
|
51
62
|
await require_writeJsonIfChanged.writeJsonIfChanged(mergedFilePath, {
|
|
52
63
|
...parsedContent,
|
|
53
64
|
localIds
|
|
54
65
|
});
|
|
55
66
|
}
|
|
56
67
|
} catch (error) {
|
|
57
|
-
|
|
68
|
+
if (error.code === "ENOENT") {
|
|
69
|
+
if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
|
|
70
|
+
const typesFilePath = (0, node_path.normalize)((0, node_path.join)(configuration.content.typesDir, `${dictionary.key}.ts`));
|
|
71
|
+
filesToRemove.push(typesFilePath);
|
|
72
|
+
}
|
|
58
73
|
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
74
|
+
}));
|
|
75
|
+
if (filesToRemove.length > 0 || excludeKeys.length > 0) {
|
|
76
|
+
await require_createDictionaryEntryPoint_createDictionaryEntryPoint.createDictionaryEntryPoint(configuration, { excludeKeys });
|
|
77
|
+
if (filesToRemove.length > 0) await Promise.all(filesToRemove.map(async (path) => {
|
|
78
|
+
const relativePath = (0, node_path.relative)(baseDir, path);
|
|
79
|
+
try {
|
|
80
|
+
await (0, node_fs_promises.rm)(path, { force: true });
|
|
81
|
+
appLogger(`Deleted artifact: ${(0, _intlayer_config_client.colorizePath)(relativePath)}`, { isVerbose: true });
|
|
82
|
+
} catch {
|
|
83
|
+
appLogger(`Error while removing file ${(0, _intlayer_config_client.colorizePath)(relativePath)}`, { isVerbose: true });
|
|
84
|
+
}
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
changedDictionariesLocalIds,
|
|
89
|
+
excludeKeys,
|
|
90
|
+
hasRebuilt: filesToRemove.length > 0 || excludeKeys.length > 0
|
|
91
|
+
};
|
|
63
92
|
};
|
|
64
93
|
|
|
65
94
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanRemovedContentDeclaration.cjs","names":["changedDictionariesLocalIds: string[]","
|
|
1
|
+
{"version":3,"file":"cleanRemovedContentDeclaration.cjs","names":["changedDictionariesLocalIds: string[]","filesToRemove: string[]","excludeKeys: string[]","writeJsonIfChanged","error: any","createDictionaryEntryPoint"],"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,sDAAyB,cAAc;CAE7C,MAAM,0FAA+C,cAAc;CAEnE,MAAM,UAAU,cAAc,QAAQ;CAEtC,MAAM,2CAA4B,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,gEAEF,cAAc,QAAQ,yBACtB,GAAG,WAAW,IAAI,OACnB,CACF;AAED,MAAI;GACF,MAAM,cAAc,qCAAe,kBAAkB,OAAO;GAC5D,MAAM,gBAAgB,KAAK,MAAM,YAAY;AAE7C,OAAI,cAAc,WAAW,GAC3B;QAAI,cAAc,GAAG,aAAa,kBAAkB;AAClD,eACE,yEAA4C,WAAW,IAAI,IAC3D,EAAE,WAAW,MAAM,CACpB;AACD,mBAAc,KAAK,iBAAiB;AACpC,iBAAY,KAAK,WAAW,IAAI;;UAE7B;AAIL,UAAMC,8CAAmB,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,iEAA+B,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,8DACC,cAAc,QAAQ,iBAAiB,GAAG,WAAW,IAAI,OAAO,CACtE;AAED,MAAI;GACF,MAAM,cAAc,qCAAe,gBAAgB,OAAO;GAC1D,MAAM,gBAAgB,KAAK,MAAM,YAAY;AAE7C,OAAI,cAAc,UAAU,WAAW,GACrC;QACE,cAAc,SAAS,GAAG,SAAS,YAAY,mBAAmB,EAClE;AACA,eACE,kFAAqD,WAAW,IAAI,IACpE,EAAE,WAAW,MAAM,CACpB;AAGD,mBAAc,KAAK,eAAe;KAGlC,MAAM,6DACC,cAAc,QAAQ,UAAU,GAAG,WAAW,IAAI,KAAK,CAC7D;AACD,mBAAc,KAAK,cAAc;KAQjC,MAAM,eAAe,4FAHnB,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,UAAMD,8CAAmB,gBADN;KAAE,GAAG;KAAe;KAAU,CACG;;WAE/CC,OAAY;AACnB,OAAI,MAAM,SAAS,UAAU;AAC3B,QAAI,CAAC,YAAY,SAAS,WAAW,IAAI,CACvC,aAAY,KAAK,WAAW,IAAI;IAElC,MAAM,6DACC,cAAc,QAAQ,UAAU,GAAG,WAAW,IAAI,KAAK,CAC7D;AACD,kBAAc,KAAK,cAAc;;;GAGrC,CACH;AAGD,KAAI,cAAc,SAAS,KAAK,YAAY,SAAS,GAAG;AAEtD,QAAMC,yFAA2B,eAAe,EAAE,aAAa,CAAC;AAGhE,MAAI,cAAc,SAAS,EACzB,OAAM,QAAQ,IACZ,cAAc,IAAI,OAAO,SAAS;GAChC,MAAM,uCAAwB,SAAS,KAAK;AAC5C,OAAI;AACF,mCAAS,MAAM,EAAE,OAAO,MAAM,CAAC;AAE/B,cAAU,+DAAkC,aAAa,IAAI,EAC3D,WAAW,MACZ,CAAC;WACI;AACN,cACE,uEAA0C,aAAa,IACvD,EACE,WAAW,MACZ,CACF;;IAEH,CACH;;AAIL,QAAO;EACL;EACA;EACA,YAAY,cAAc,SAAS,KAAK,YAAY,SAAS;EAC9D"}
|
|
@@ -21,41 +21,42 @@ const writeDictionaryFiles = async (paths, fileName, importType, functionName, f
|
|
|
21
21
|
/**
|
|
22
22
|
* This function generates a list of dictionaries in the main directory
|
|
23
23
|
*/
|
|
24
|
-
const createDictionaryEntryPoint = async (configuration = (0, _intlayer_config.getConfiguration)(),
|
|
24
|
+
const createDictionaryEntryPoint = async (configuration = (0, _intlayer_config.getConfiguration)(), options = {}) => {
|
|
25
|
+
const { formats, excludeKeys = [] } = options;
|
|
25
26
|
const outputFormats = formats ?? configuration.build.outputFormat;
|
|
26
27
|
const { mainDir } = configuration.content;
|
|
27
28
|
await (0, node_fs_promises.mkdir)(mainDir, { recursive: true });
|
|
28
29
|
await require_utils_parallelize.parallelize([
|
|
29
30
|
...outputFormats.map((format) => ({
|
|
30
|
-
paths: require_createDictionaryEntryPoint_getBuiltDictionariesPath.getBuiltDictionariesPath(configuration),
|
|
31
|
+
paths: require_createDictionaryEntryPoint_getBuiltDictionariesPath.getBuiltDictionariesPath(configuration, excludeKeys),
|
|
31
32
|
importType: "json",
|
|
32
33
|
functionName: "getDictionaries",
|
|
33
34
|
fileName: "dictionaries",
|
|
34
35
|
format
|
|
35
36
|
})),
|
|
36
37
|
...outputFormats.map((format) => ({
|
|
37
|
-
paths: require_createDictionaryEntryPoint_getBuiltUnmergedDictionariesPath.getBuiltUnmergedDictionariesPath(configuration),
|
|
38
|
+
paths: require_createDictionaryEntryPoint_getBuiltUnmergedDictionariesPath.getBuiltUnmergedDictionariesPath(configuration, excludeKeys),
|
|
38
39
|
importType: "json",
|
|
39
40
|
functionName: "getUnmergedDictionaries",
|
|
40
41
|
fileName: "unmerged_dictionaries",
|
|
41
42
|
format
|
|
42
43
|
})),
|
|
43
44
|
...outputFormats.map((format) => ({
|
|
44
|
-
paths: require_createDictionaryEntryPoint_getBuiltDynamicDictionariesPath.getBuiltDynamicDictionariesPath(configuration, format),
|
|
45
|
+
paths: require_createDictionaryEntryPoint_getBuiltDynamicDictionariesPath.getBuiltDynamicDictionariesPath(configuration, format, excludeKeys),
|
|
45
46
|
importType: "javascript",
|
|
46
47
|
functionName: "getDynamicDictionaries",
|
|
47
48
|
fileName: "dynamic_dictionaries",
|
|
48
49
|
format
|
|
49
50
|
})),
|
|
50
51
|
...outputFormats.map((format) => ({
|
|
51
|
-
paths: require_createDictionaryEntryPoint_getBuiltFetchDictionariesPath.getBuiltFetchDictionariesPath(configuration, format),
|
|
52
|
+
paths: require_createDictionaryEntryPoint_getBuiltFetchDictionariesPath.getBuiltFetchDictionariesPath(configuration, format, excludeKeys),
|
|
52
53
|
importType: "javascript",
|
|
53
54
|
functionName: "getFetchDictionaries",
|
|
54
55
|
fileName: "fetch_dictionaries",
|
|
55
56
|
format
|
|
56
57
|
})),
|
|
57
58
|
...outputFormats.map((format) => ({
|
|
58
|
-
paths: require_createDictionaryEntryPoint_getBuiltRemoteDictionariesPath.getBuiltRemoteDictionariesPath(configuration),
|
|
59
|
+
paths: require_createDictionaryEntryPoint_getBuiltRemoteDictionariesPath.getBuiltRemoteDictionariesPath(configuration, excludeKeys),
|
|
59
60
|
importType: "json",
|
|
60
61
|
functionName: "getRemoteDictionaries",
|
|
61
62
|
fileName: "remote_dictionaries",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDictionaryEntryPoint.cjs","names":["generateDictionaryListContent","writeFileIfChanged","parallelize","getBuiltDictionariesPath","getBuiltUnmergedDictionariesPath","getBuiltDynamicDictionariesPath","getBuiltFetchDictionariesPath","getBuiltRemoteDictionariesPath"],"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
|
|
1
|
+
{"version":3,"file":"createDictionaryEntryPoint.cjs","names":["generateDictionaryListContent","writeFileIfChanged","parallelize","getBuiltDictionariesPath","getBuiltUnmergedDictionariesPath","getBuiltDynamicDictionariesPath","getBuiltFetchDictionariesPath","getBuiltRemoteDictionariesPath"],"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,wDAAkC,KAC/B;CACH,MAAM,UAAUA,+FACd,MAAM,OACN,cACA,YACA,QACA,cACD;CACD,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAE7C,MAAM,EAAE,YAAY,cAAc;AAElC,OAAMC,qEACI,SAAS,GAAG,SAAS,GAAG,YAAY,EAC5C,QACD;;;;;AAWH,MAAa,6BAA6B,OACxC,wDAAkC,EAClC,UAA6C,EAAE,KAC5C;CACH,MAAM,EAAE,SAAS,cAAc,EAAE,KAAK;CACtC,MAAM,gBAAgB,WAAW,cAAc,MAAM;CACrD,MAAM,EAAE,YAAY,cAAc;AAElC,mCAAY,SAAS,EAAE,WAAW,MAAM,CAAC;AA+DzC,OAAMC,sCA7DkB;EACtB,GAAG,cAAc,KACd,YACE;GACC,OAAOC,qFAAyB,eAAe,YAAY;GAC3D,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAOC,qGAAiC,eAAe,YAAY;GACnE,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAOC,mGACL,eACA,QACA,YACD;GACD,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAOC,+FACL,eACA,QACA,YACD;GACD,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAOC,iGAA+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,17 +1,21 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
|
-
let
|
|
3
|
+
let node_path = require("node:path");
|
|
4
4
|
let fast_glob = require("fast-glob");
|
|
5
5
|
fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
6
|
+
let _intlayer_config = require("@intlayer/config");
|
|
6
7
|
|
|
7
8
|
//#region src/createDictionaryEntryPoint/getBuiltDictionariesPath.ts
|
|
8
9
|
/**
|
|
9
10
|
* This function generates a list of dictionaries in the main directory
|
|
10
11
|
*/
|
|
11
|
-
const getBuiltDictionariesPath = async (configuration) => {
|
|
12
|
+
const getBuiltDictionariesPath = async (configuration, excludeKeys = []) => {
|
|
12
13
|
const { dictionariesDir, mainDir } = configuration.content;
|
|
13
14
|
if (!(0, node_fs.existsSync)(mainDir)) (0, node_fs.mkdirSync)(mainDir, { recursive: true });
|
|
14
|
-
return await (0, fast_glob.default)(`${(0, _intlayer_config.normalizePath)(dictionariesDir)}/**/*.json`)
|
|
15
|
+
return (await (0, fast_glob.default)(`${(0, _intlayer_config.normalizePath)(dictionariesDir)}/**/*.json`)).filter((path) => {
|
|
16
|
+
const key = (0, node_path.basename)(path, ".json");
|
|
17
|
+
return !excludeKeys.includes(key);
|
|
18
|
+
});
|
|
15
19
|
};
|
|
16
20
|
|
|
17
21
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBuiltDictionariesPath.cjs","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":"
|
|
1
|
+
{"version":3,"file":"getBuiltDictionariesPath.cjs","names":[],"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,yBAAY,QAAQ,CACtB,wBAAU,SAAS,EAAE,WAAW,MAAM,CAAC;AAOzC,SAJmC,6BACjC,uCAAiB,gBAAgB,CAAC,YACnC,EAEuB,QAAQ,SAAS;EACvC,MAAM,8BAAe,MAAM,QAAQ;AACnC,SAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
|
-
let
|
|
3
|
+
let node_path = require("node:path");
|
|
4
4
|
let fast_glob = require("fast-glob");
|
|
5
5
|
fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
6
|
+
let _intlayer_config = require("@intlayer/config");
|
|
6
7
|
|
|
7
8
|
//#region src/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.ts
|
|
8
9
|
/**
|
|
9
10
|
* This function generates a list of dictionaries in the main directory
|
|
10
11
|
*/
|
|
11
|
-
const getBuiltDynamicDictionariesPath = async (configuration, format = "esm") => {
|
|
12
|
+
const getBuiltDynamicDictionariesPath = async (configuration, format = "esm", excludeKeys = []) => {
|
|
12
13
|
const { dynamicDictionariesDir, mainDir } = configuration.content;
|
|
13
14
|
if (!(0, node_fs.existsSync)(mainDir)) (0, node_fs.mkdirSync)(mainDir, { recursive: true });
|
|
14
15
|
const extension = format === "cjs" ? "cjs" : "mjs";
|
|
15
|
-
return await (0, fast_glob.default)(`${(0, _intlayer_config.normalizePath)(dynamicDictionariesDir)}/**/*.${extension}`)
|
|
16
|
+
return (await (0, fast_glob.default)(`${(0, _intlayer_config.normalizePath)(dynamicDictionariesDir)}/**/*.${extension}`)).filter((path) => {
|
|
17
|
+
const key = (0, node_path.basename)(path, `.${extension}`);
|
|
18
|
+
return !excludeKeys.includes(key);
|
|
19
|
+
});
|
|
16
20
|
};
|
|
17
21
|
|
|
18
22
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBuiltDynamicDictionariesPath.cjs","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":"
|
|
1
|
+
{"version":3,"file":"getBuiltDynamicDictionariesPath.cjs","names":[],"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,yBAAY,QAAQ,CACtB,wBAAU,SAAS,EAAE,WAAW,MAAM,CAAC;CAGzC,MAAM,YAAY,WAAW,QAAQ,QAAQ;AAM7C,SAJmC,6BACjC,uCAAiB,uBAAuB,CAAC,QAAQ,YAClD,EAEuB,QAAQ,SAAS;EACvC,MAAM,8BAAe,MAAM,IAAI,YAAY;AAC3C,SAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
|
-
let
|
|
3
|
+
let node_path = require("node:path");
|
|
4
4
|
let fast_glob = require("fast-glob");
|
|
5
5
|
fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
6
|
+
let _intlayer_config = require("@intlayer/config");
|
|
6
7
|
|
|
7
8
|
//#region src/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.ts
|
|
8
9
|
/**
|
|
9
10
|
* This function generates a list of dictionaries in the main directory
|
|
10
11
|
*/
|
|
11
|
-
const getBuiltFetchDictionariesPath = async (configuration, format = "esm") => {
|
|
12
|
+
const getBuiltFetchDictionariesPath = async (configuration, format = "esm", excludeKeys = []) => {
|
|
12
13
|
const { fetchDictionariesDir, mainDir } = configuration.content;
|
|
13
14
|
if (!(0, node_fs.existsSync)(mainDir)) (0, node_fs.mkdirSync)(mainDir, { recursive: true });
|
|
14
15
|
const extension = format === "cjs" ? "cjs" : "mjs";
|
|
15
|
-
return await (0, fast_glob.default)(`${(0, _intlayer_config.normalizePath)(fetchDictionariesDir)}/**/*.${extension}`)
|
|
16
|
+
return (await (0, fast_glob.default)(`${(0, _intlayer_config.normalizePath)(fetchDictionariesDir)}/**/*.${extension}`)).filter((path) => {
|
|
17
|
+
const key = (0, node_path.basename)(path, `.${extension}`);
|
|
18
|
+
return !excludeKeys.includes(key);
|
|
19
|
+
});
|
|
16
20
|
};
|
|
17
21
|
|
|
18
22
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBuiltFetchDictionariesPath.cjs","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":"
|
|
1
|
+
{"version":3,"file":"getBuiltFetchDictionariesPath.cjs","names":[],"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,yBAAY,QAAQ,CACtB,wBAAU,SAAS,EAAE,WAAW,MAAM,CAAC;CAGzC,MAAM,YAAY,WAAW,QAAQ,QAAQ;AAM7C,SAJmC,6BACjC,uCAAiB,qBAAqB,CAAC,QAAQ,YAChD,EAEuB,QAAQ,SAAS;EACvC,MAAM,8BAAe,MAAM,IAAI,YAAY;AAC3C,SAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
|
-
let
|
|
3
|
+
let node_path = require("node:path");
|
|
4
4
|
let fast_glob = require("fast-glob");
|
|
5
5
|
fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
6
|
+
let _intlayer_config = require("@intlayer/config");
|
|
6
7
|
|
|
7
8
|
//#region src/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.ts
|
|
8
9
|
/**
|
|
9
10
|
* This function generates a list of dictionaries in the main directory
|
|
10
11
|
*/
|
|
11
|
-
const getBuiltRemoteDictionariesPath = async (configuration) => {
|
|
12
|
+
const getBuiltRemoteDictionariesPath = async (configuration, excludeKeys = []) => {
|
|
12
13
|
const { remoteDictionariesDir, mainDir } = configuration.content;
|
|
13
14
|
if (!(0, node_fs.existsSync)(mainDir)) (0, node_fs.mkdirSync)(mainDir, { recursive: true });
|
|
14
|
-
return fast_glob.default.sync(`${(0, _intlayer_config.normalizePath)(remoteDictionariesDir)}/**/*.json`)
|
|
15
|
+
return fast_glob.default.sync(`${(0, _intlayer_config.normalizePath)(remoteDictionariesDir)}/**/*.json`).filter((path) => {
|
|
16
|
+
const key = (0, node_path.basename)(path, ".json");
|
|
17
|
+
return !excludeKeys.includes(key);
|
|
18
|
+
});
|
|
15
19
|
};
|
|
16
20
|
|
|
17
21
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBuiltRemoteDictionariesPath.cjs","names":["fg"],"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":"
|
|
1
|
+
{"version":3,"file":"getBuiltRemoteDictionariesPath.cjs","names":["fg"],"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,yBAAY,QAAQ,CACtB,wBAAU,SAAS,EAAE,WAAW,MAAM,CAAC;AAOzC,QAJmCA,kBAAG,KACpC,uCAAiB,sBAAsB,CAAC,YACzC,CAEuB,QAAQ,SAAS;EACvC,MAAM,8BAAe,MAAM,QAAQ;AACnC,SAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
|
-
let
|
|
3
|
+
let node_path = require("node:path");
|
|
4
4
|
let fast_glob = require("fast-glob");
|
|
5
5
|
fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
6
|
+
let _intlayer_config = require("@intlayer/config");
|
|
6
7
|
|
|
7
8
|
//#region src/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.ts
|
|
8
9
|
/**
|
|
9
10
|
* This function generates a list of dictionaries in the main directory
|
|
10
11
|
*/
|
|
11
|
-
const getBuiltUnmergedDictionariesPath = async (configuration) => {
|
|
12
|
+
const getBuiltUnmergedDictionariesPath = async (configuration, excludeKeys = []) => {
|
|
12
13
|
const { unmergedDictionariesDir, mainDir } = configuration.content;
|
|
13
14
|
if (!(0, node_fs.existsSync)(mainDir)) (0, node_fs.mkdirSync)(mainDir, { recursive: true });
|
|
14
|
-
return await (0, fast_glob.default)(`${(0, _intlayer_config.normalizePath)(unmergedDictionariesDir)}/**/*.json`)
|
|
15
|
+
return (await (0, fast_glob.default)(`${(0, _intlayer_config.normalizePath)(unmergedDictionariesDir)}/**/*.json`)).filter((path) => {
|
|
16
|
+
const key = (0, node_path.basename)(path, ".json");
|
|
17
|
+
return !excludeKeys.includes(key);
|
|
18
|
+
});
|
|
15
19
|
};
|
|
16
20
|
|
|
17
21
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBuiltUnmergedDictionariesPath.cjs","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.cjs","names":[],"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,yBAAY,QAAQ,CACtB,wBAAU,SAAS,EAAE,WAAW,MAAM,CAAC;AAOzC,SAJmC,6BACjC,uCAAiB,wBAAwB,CAAC,YAC3C,EAEuB,QAAQ,SAAS;EACvC,MAAM,8BAAe,MAAM,QAAQ;AACnC,SAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
|
|
@@ -3,9 +3,9 @@ const require_writeFileIfChanged = require('../writeFileIfChanged.cjs');
|
|
|
3
3
|
const require_utils_getFileHash = require('../utils/getFileHash.cjs');
|
|
4
4
|
let node_fs_promises = require("node:fs/promises");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
|
-
let _intlayer_config = require("@intlayer/config");
|
|
7
6
|
let fast_glob = require("fast-glob");
|
|
8
7
|
fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
8
|
+
let _intlayer_config = require("@intlayer/config");
|
|
9
9
|
|
|
10
10
|
//#region src/createType/createModuleAugmentation.ts
|
|
11
11
|
const getTypeName = (key) => `${(0, _intlayer_config.kebabCaseToCamelCase)(key)}Content`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
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
3
|
const require_utils_formatter = require('./utils/formatter.cjs');
|
|
6
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');
|
|
7
7
|
const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
|
|
8
8
|
let _intlayer_config = require("@intlayer/config");
|
|
9
9
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_createDictionaryEntryPoint_getBuiltDictionariesPath = require('./createDictionaryEntryPoint/getBuiltDictionariesPath.cjs');
|
|
3
3
|
const require_createDictionaryEntryPoint_createDictionaryEntryPoint = require('./createDictionaryEntryPoint/createDictionaryEntryPoint.cjs');
|
|
4
|
-
const require_createType_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
|
|
5
|
-
const require_createType_createType = require('./createType/createType.cjs');
|
|
6
4
|
const require_cleanRemovedContentDeclaration = require('./cleanRemovedContentDeclaration.cjs');
|
|
7
5
|
const require_utils_formatter = require('./utils/formatter.cjs');
|
|
8
6
|
const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./buildIntlayerDictionary/buildIntlayerDictionary.cjs');
|
|
7
|
+
const require_createType_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
|
|
8
|
+
const require_createType_createType = require('./createType/createType.cjs');
|
|
9
9
|
const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
|
|
10
10
|
let _intlayer_config = require("@intlayer/config");
|
|
11
11
|
|
|
@@ -13,21 +13,22 @@ let _intlayer_config = require("@intlayer/config");
|
|
|
13
13
|
const handleContentDeclarationFileChange = async (filePath, config) => {
|
|
14
14
|
const appLogger = (0, _intlayer_config.getAppLogger)(config);
|
|
15
15
|
appLogger(`Change detected: ${require_utils_formatter.formatPath(filePath)}`, { isVerbose: true });
|
|
16
|
+
const allDictionariesPaths = await require_createDictionaryEntryPoint_getBuiltDictionariesPath.getBuiltDictionariesPath(config);
|
|
16
17
|
const localeDictionaries = await require_loadDictionaries_loadLocalDictionaries.loadLocalDictionaries(filePath, config);
|
|
17
|
-
localeDictionaries.forEach(async (dictionary) => {
|
|
18
|
-
await require_cleanRemovedContentDeclaration.cleanRemovedContentDeclaration(filePath, dictionary.key, config);
|
|
19
|
-
});
|
|
20
18
|
const dictionariesOutput = await require_buildIntlayerDictionary_buildIntlayerDictionary.buildDictionary(localeDictionaries, config);
|
|
21
19
|
const updatedDictionariesPaths = Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionaryPath);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
const { excludeKeys, hasRebuilt } = await require_cleanRemovedContentDeclaration.cleanRemovedContentDeclaration(filePath, localeDictionaries.map((dictionary) => dictionary.key), config);
|
|
21
|
+
const hasNewDictionaries = updatedDictionariesPaths.some((updatedDictionaryPath) => !allDictionariesPaths.includes(updatedDictionaryPath));
|
|
22
|
+
if (hasRebuilt || hasNewDictionaries) {
|
|
23
|
+
if (!hasRebuilt) {
|
|
24
|
+
await require_createDictionaryEntryPoint_createDictionaryEntryPoint.createDictionaryEntryPoint(config, { excludeKeys });
|
|
25
|
+
appLogger("Dictionary list built", { isVerbose: true });
|
|
26
|
+
}
|
|
27
|
+
await require_createType_createType.createTypes(updatedDictionariesPaths, config);
|
|
28
|
+
appLogger("TypeScript types built", { isVerbose: true });
|
|
29
|
+
await require_createType_createModuleAugmentation.createModuleAugmentation(config);
|
|
30
|
+
appLogger("Module augmentation built", { isVerbose: true });
|
|
28
31
|
}
|
|
29
|
-
require_createType_createModuleAugmentation.createModuleAugmentation(config);
|
|
30
|
-
appLogger("Module augmentation built", { isVerbose: true });
|
|
31
32
|
for await (const plugin of config.plugins ?? []) {
|
|
32
33
|
const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;
|
|
33
34
|
await plugin.afterBuild?.({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleContentDeclarationFileChange.cjs","names":["formatPath","
|
|
1
|
+
{"version":3,"file":"handleContentDeclarationFileChange.cjs","names":["formatPath","allDictionariesPaths: string[]","getBuiltDictionariesPath","loadLocalDictionaries","buildDictionary","cleanRemovedContentDeclaration","createDictionaryEntryPoint","createTypes","createModuleAugmentation"],"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,+CAAyB,OAAO;AAGtC,WAAU,oBAAoBA,mCAAW,SAAS,IAAI,EACpD,WAAW,MACZ,CAAC;CAEF,MAAMC,uBAAiC,MAAMC,qFAAyB,OAAO;CAE7E,MAAM,qBAAqB,MAAMC,qEAAsB,UAAU,OAAO;CAExE,MAAM,qBAAqB,MAAMC,wEAAgB,oBAAoB,OAAO;CAC5E,MAAM,2BAA2B,OAAO,OACtC,oBAAoB,sBAAsB,EAAE,CAC7C,CAAC,KAAK,eAAe,WAAW,eAAe;CAEhD,MAAM,EAAE,aAAa,eAAe,MAAMC,sEACxC,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,SAAMC,yFAA2B,QAAQ,EAAE,aAAa,CAAC;AACzD,aAAU,yBAAyB,EACjC,WAAW,MACZ,CAAC;;AAIJ,QAAMC,0CAAY,0BAA0B,OAAO;AACnD,YAAU,0BAA0B,EAClC,WAAW,MACZ,CAAC;AAEF,QAAMC,qEAAyB,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,24 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_cleanRemovedContentDeclaration = require('./cleanRemovedContentDeclaration.cjs');
|
|
3
|
+
const require_utils_formatter = require('./utils/formatter.cjs');
|
|
4
|
+
const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
|
|
5
|
+
const require_handleContentDeclarationFileChange = require('./handleContentDeclarationFileChange.cjs');
|
|
6
|
+
let _intlayer_config = require("@intlayer/config");
|
|
7
|
+
|
|
8
|
+
//#region src/handleContentDeclarationFileMoved.ts
|
|
9
|
+
const handleContentDeclarationFileMoved = async (oldFilePath, newFilePath, config) => {
|
|
10
|
+
const appLogger = (0, _intlayer_config.getAppLogger)(config);
|
|
11
|
+
appLogger(`File moved from ${require_utils_formatter.formatPath(oldFilePath)} to ${require_utils_formatter.formatPath(newFilePath)}`, { isVerbose: true });
|
|
12
|
+
let keysToKeep = [];
|
|
13
|
+
try {
|
|
14
|
+
keysToKeep = (await require_loadDictionaries_loadLocalDictionaries.loadLocalDictionaries(newFilePath, config)).map((d) => d.key);
|
|
15
|
+
} catch {
|
|
16
|
+
appLogger(`Error parsing new file during move operation: ${require_utils_formatter.formatPath(newFilePath)}`, { isVerbose: true });
|
|
17
|
+
}
|
|
18
|
+
await require_cleanRemovedContentDeclaration.cleanRemovedContentDeclaration(oldFilePath, keysToKeep, config);
|
|
19
|
+
await require_handleContentDeclarationFileChange.handleContentDeclarationFileChange(newFilePath, config);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.handleContentDeclarationFileMoved = handleContentDeclarationFileMoved;
|
|
24
|
+
//# sourceMappingURL=handleContentDeclarationFileMoved.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleContentDeclarationFileMoved.cjs","names":["formatPath","keysToKeep: string[]","loadLocalDictionaries","cleanRemovedContentDeclaration","handleContentDeclarationFileChange"],"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,+CAAyB,OAAO;AAEtC,WACE,mBAAmBA,mCAAW,YAAY,CAAC,MAAMA,mCAAW,YAAY,IACxE,EACE,WAAW,MACZ,CACF;CAED,IAAIC,aAAuB,EAAE;AAE7B,KAAI;AAQF,gBAJ8B,MAAMC,qEAClC,aACA,OACD,EACkC,KAAK,MAAM,EAAE,IAAI;SAC9C;AACN,YACE,iDAAiDF,mCAAW,YAAY,IACxE,EACE,WAAW,MACZ,CACF;;AASH,OAAMG,sEAA+B,aAAa,YAAY,OAAO;AAKrE,OAAMC,8EAAmC,aAAa,OAAO"}
|