@intlayer/chokidar 5.5.8 → 5.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -9
- package/dist/cjs/getBuiltDictionariesPath.cjs +4 -2
- package/dist/cjs/getBuiltDictionariesPath.cjs.map +1 -1
- package/dist/cjs/getBuiltDynamicDictionariesPath.cjs +1 -1
- package/dist/cjs/getBuiltDynamicDictionariesPath.cjs.map +1 -1
- package/dist/cjs/getBuiltUnmergedDictionariesPath.cjs +1 -1
- package/dist/cjs/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/generateDictionaryListContent.cjs +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/generateDictionaryListContent.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +1 -1
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +1 -1
- package/dist/esm/getBuiltDictionariesPath.mjs +5 -3
- package/dist/esm/getBuiltDictionariesPath.mjs.map +1 -1
- package/dist/esm/getBuiltDynamicDictionariesPath.mjs +2 -2
- package/dist/esm/getBuiltDynamicDictionariesPath.mjs.map +1 -1
- package/dist/esm/getBuiltUnmergedDictionariesPath.mjs +2 -2
- package/dist/esm/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_main/generateDictionaryListContent.mjs +2 -2
- package/dist/esm/transpiler/dictionary_to_main/generateDictionaryListContent.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +2 -6
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +1 -1
- package/dist/types/getBuiltDictionariesPath.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_type/createModuleAugmentation.d.ts.map +1 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -5,15 +5,48 @@
|
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
7
|
<div align="center">
|
|
8
|
-
<a href="https://www.npmjs.com/package/intlayer"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
<a href="https://www.npmjs.com/package/intlayer" target="blank"><img
|
|
9
|
+
align="center"
|
|
10
|
+
alt="npm"
|
|
11
|
+
src="https://img.shields.io/npm/v/intlayer.svg?labelColor=49516F&color=8994BC&style=for-the-badge"
|
|
12
|
+
height="30" /></a>
|
|
13
|
+
<a href="https://npmjs.org/package/intlayer" target="blank"><img
|
|
14
|
+
align="center"
|
|
15
|
+
src="https://img.shields.io/npm/dm/intlayer?labelColor=49516F&color=8994BC&style=for-the-badge"
|
|
16
|
+
alt="monthly downloads"
|
|
17
|
+
height="30"
|
|
18
|
+
/></a>
|
|
19
|
+
<a href="https://npmjs.org/package/intlayer" target="blank"><img
|
|
20
|
+
align="center"
|
|
21
|
+
src="https://img.shields.io/npm/types/intlayer?label=types%20included&labelColor=49516F&color=8994BC&style=for-the-badge"
|
|
22
|
+
alt="types included"
|
|
23
|
+
height="30"
|
|
24
|
+
/></a>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<div>
|
|
28
|
+
<br/>
|
|
29
|
+
<p align="center">
|
|
30
|
+
<a href="https://www.linkedin.com/company/intlayerorg" target="blank"><img align="center"
|
|
31
|
+
src="https://img.shields.io/badge/linkedin-%231DA1F2.svg?style=for-the-badge&logo=linkedin&logoColor=white"
|
|
32
|
+
alt="Intlayer LinkedIn" height="30"/></a>
|
|
33
|
+
<a href="https://www.facebook.com/intlayer" target="blank"><img align="center"
|
|
34
|
+
src="https://img.shields.io/badge/facebook-4267B2.svg?style=for-the-badge&logo=facebook&logoColor=white"
|
|
35
|
+
alt="Intlayer Facebook" height="30"/></a>
|
|
36
|
+
<a href="https://www.instagram.com/intlayer_org/" target="blank"><img align="center"
|
|
37
|
+
src="https://img.shields.io/badge/instagram-%23E4405F.svg?style=for-the-badge&logo=Instagram&logoColor=white"
|
|
38
|
+
alt="Intlayer Instagram" height="30"/></a>
|
|
39
|
+
<a href="https://x.com/Intlayer183096" target="blank"><img align="center"
|
|
40
|
+
src="https://img.shields.io/badge/x-1DA1F2.svg?style=for-the-badge&logo=x&logoColor=white"
|
|
41
|
+
alt="Intlayer X" height="30"/></a>
|
|
42
|
+
<a href="https://www.youtube.com/@intlayer" target="blank"><img align="center"
|
|
43
|
+
src="https://img.shields.io/badge/youtube-FF0000.svg?style=for-the-badge&logo=youtube&logoColor=white"
|
|
44
|
+
alt="Intlayer YouTube" height="30"/></a>
|
|
45
|
+
<a href="https://www.tiktok.com/@intlayer" target="blank"><img align="center"
|
|
46
|
+
src="https://img.shields.io/badge/tiktok-000000.svg?style=for-the-badge&logo=tiktok&logoColor=white"
|
|
47
|
+
alt="Intlayer TikTok" height="30"/></a>
|
|
48
|
+
<br>
|
|
49
|
+
</p>
|
|
17
50
|
</div>
|
|
18
51
|
|
|
19
52
|
# @intlayer/chokidar: Scan and build Intlayer declaration files into dictionaries
|
|
@@ -31,15 +31,17 @@ __export(getBuiltDictionariesPath_exports, {
|
|
|
31
31
|
getBuiltDictionariesPath: () => getBuiltDictionariesPath
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(getBuiltDictionariesPath_exports);
|
|
34
|
-
var import_fs = require("fs");
|
|
35
34
|
var import_config = require("@intlayer/config");
|
|
36
35
|
var import_fast_glob = __toESM(require("fast-glob"));
|
|
36
|
+
var import_fs = require("fs");
|
|
37
37
|
const getBuiltDictionariesPath = (configuration = (0, import_config.getConfiguration)()) => {
|
|
38
38
|
const { dictionariesDir, mainDir } = configuration.content;
|
|
39
39
|
if (!(0, import_fs.existsSync)(mainDir)) {
|
|
40
40
|
(0, import_fs.mkdirSync)(mainDir, { recursive: true });
|
|
41
41
|
}
|
|
42
|
-
const dictionariesPath = import_fast_glob.default.sync(
|
|
42
|
+
const dictionariesPath = import_fast_glob.default.sync(
|
|
43
|
+
`${(0, import_config.normalizePath)(dictionariesDir)}/**/*.json`
|
|
44
|
+
);
|
|
43
45
|
return dictionariesPath;
|
|
44
46
|
};
|
|
45
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getBuiltDictionariesPath.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/getBuiltDictionariesPath.ts"],"sourcesContent":["import { getConfiguration, normalizePath } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync } from 'fs';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDictionariesPath = (\n configuration = getConfiguration()\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[] = fg.sync(\n `${normalizePath(dictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgD;AAChD,uBAAe;AACf,gBAAsC;AAK/B,MAAM,2BAA2B,CACtC,oBAAgB,gCAAiB,MAC9B;AACH,QAAM,EAAE,iBAAiB,QAAQ,IAAI,cAAc;AAGnD,MAAI,KAAC,sBAAW,OAAO,GAAG;AACxB,6BAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,mBAA6B,iBAAAA,QAAG;AAAA,IACpC,OAAG,6BAAc,eAAe,CAAC;AAAA,EACnC;AAEA,SAAO;AACT;","names":["fg"]}
|
|
@@ -41,7 +41,7 @@ const getBuiltDynamicDictionariesPath = (configuration = (0, import_config.getCo
|
|
|
41
41
|
}
|
|
42
42
|
const extension = format === "cjs" ? "cjs" : "mjs";
|
|
43
43
|
const dictionariesPath = import_fast_glob.default.sync(
|
|
44
|
-
`${dynamicDictionariesDir}/**/*.${extension}`
|
|
44
|
+
`${(0, import_config.normalizePath)(dynamicDictionariesDir)}/**/*.${extension}`
|
|
45
45
|
);
|
|
46
46
|
return dictionariesPath;
|
|
47
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getBuiltDynamicDictionariesPath.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync } from 'fs';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDynamicDictionariesPath = (\n configuration = getConfiguration(),\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[] = fg.sync(\n `${dynamicDictionariesDir}/**/*.${extension}`\n );\n\n return dictionariesPath;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/getBuiltDynamicDictionariesPath.ts"],"sourcesContent":["import { getConfiguration, normalizePath } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync } from 'fs';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDynamicDictionariesPath = (\n configuration = getConfiguration(),\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[] = fg.sync(\n `${normalizePath(dynamicDictionariesDir)}/**/*.${extension}`\n );\n\n return dictionariesPath;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgD;AAChD,uBAAe;AACf,gBAAsC;AAK/B,MAAM,kCAAkC,CAC7C,oBAAgB,gCAAiB,GACjC,SAAwB,UACrB;AACH,QAAM,EAAE,wBAAwB,QAAQ,IAAI,cAAc;AAG1D,MAAI,KAAC,sBAAW,OAAO,GAAG;AACxB,6BAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,YAAY,WAAW,QAAQ,QAAQ;AAE7C,QAAM,mBAA6B,iBAAAA,QAAG;AAAA,IACpC,OAAG,6BAAc,sBAAsB,CAAC,SAAS,SAAS;AAAA,EAC5D;AAEA,SAAO;AACT;","names":["fg"]}
|
|
@@ -40,7 +40,7 @@ const getBuiltUnmergedDictionariesPath = (configuration = (0, import_config.getC
|
|
|
40
40
|
(0, import_fs.mkdirSync)(mainDir, { recursive: true });
|
|
41
41
|
}
|
|
42
42
|
const dictionariesPath = import_fast_glob.default.sync(
|
|
43
|
-
`${(0, import_config.
|
|
43
|
+
`${(0, import_config.normalizePath)(unmergedDictionariesDir)}/**/*.json`
|
|
44
44
|
);
|
|
45
45
|
return dictionariesPath;
|
|
46
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getBuiltUnmergedDictionariesPath.ts"],"sourcesContent":["import { getConfiguration,
|
|
1
|
+
{"version":3,"sources":["../../src/getBuiltUnmergedDictionariesPath.ts"],"sourcesContent":["import { getConfiguration, normalizePath } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync } from 'fs';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltUnmergedDictionariesPath = (\n configuration = getConfiguration()\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[] = fg.sync(\n `${normalizePath(unmergedDictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgD;AAChD,uBAAe;AACf,gBAAsC;AAK/B,MAAM,mCAAmC,CAC9C,oBAAgB,gCAAiB,MAC9B;AACH,QAAM,EAAE,yBAAyB,QAAQ,IAAI,cAAc;AAG3D,MAAI,KAAC,sBAAW,OAAO,GAAG;AACxB,6BAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,mBAA6B,iBAAAA,QAAG;AAAA,IACpC,OAAG,6BAAc,uBAAuB,CAAC;AAAA,EAC3C;AAEA,SAAO;AACT;","names":["fg"]}
|
|
@@ -28,7 +28,7 @@ const generateDictionaryListContent = (dictionaries, format = "esm", configurati
|
|
|
28
28
|
const { mainDir } = configuration.content;
|
|
29
29
|
let content = "";
|
|
30
30
|
const dictionariesRef = dictionaries.map((dictionaryPath) => ({
|
|
31
|
-
relativePath: (0, import_path.relative)(mainDir, dictionaryPath),
|
|
31
|
+
relativePath: (0, import_config.normalizePath)((0, import_path.relative)(mainDir, dictionaryPath)),
|
|
32
32
|
id: (0, import_path.basename)(dictionaryPath, (0, import_path.extname)(dictionaryPath)),
|
|
33
33
|
// Get the base name as the dictionary id
|
|
34
34
|
hash: `_${(0, import_utils.getFileHash)(dictionaryPath)}`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/generateDictionaryListContent.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { basename, extname, relative } from 'path';\nimport { getFileHash } from '../../utils';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.content;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: relative(mainDir, dictionaryPath),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/generateDictionaryListContent.ts"],"sourcesContent":["import { getConfiguration, normalizePath } from '@intlayer/config';\nimport { basename, extname, relative } from 'path';\nimport { getFileHash } from '../../utils';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.content;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: normalizePath(relative(mainDir, dictionaryPath)),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgD;AAChD,kBAA4C;AAC5C,mBAA4B;AAKrB,MAAM,gCAAgC,CAC3C,cACA,SAAwB,OACxB,oBAAgB,gCAAiB,MACtB;AACX,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,MAAI,UAAU;AAEd,QAAM,kBAAkB,aAAa,IAAI,CAAC,oBAAoB;AAAA,IAC5D,kBAAc,iCAAc,sBAAS,SAAS,cAAc,CAAC;AAAA,IAC7D,QAAI,sBAAS,oBAAgB,qBAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,QAAI,0BAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,QAAI,WAAW;AACb,iBAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AACvE,QAAI,WAAW;AACb,iBAAW,SAAS,WAAW,IAAI,eAAe,WAAW,YAAY;AAAA;AAAA,EAC7E,CAAC;AAED,aAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,MAAM,WAAW,EAAE,MAAM,WAAW,IAAI,EAAE,EAC9D,KAAK,KAAK;AAEb,MAAI,WAAW;AACb,eAAW;AAAA,EAAqB,sBAAsB;AAAA;AAAA;AACxD,MAAI,WAAW;AACb,eAAW;AAAA,EAAuB,sBAAsB;AAAA;AAAA;AAE1D,SAAO;AACT;","names":[]}
|
|
@@ -95,7 +95,7 @@ const createModuleAugmentation = (configuration = (0, import_config.getConfigura
|
|
|
95
95
|
(0, import_fs.mkdirSync)(moduleAugmentationDir, { recursive: true });
|
|
96
96
|
}
|
|
97
97
|
const dictionariesTypesDefinitions = import_fast_glob.default.sync(
|
|
98
|
-
(0, import_config.
|
|
98
|
+
(0, import_config.normalizePath)(`${typesDir}/*.ts`),
|
|
99
99
|
{
|
|
100
100
|
ignore: ["**/*.d.ts"]
|
|
101
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"sourcesContent":["import { Locales, getConfiguration, normalizePath } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, join, relative } from 'path';\nimport { getFileHash, kebabCaseToCamelCase } from '../../utils';\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\nconst formatLocales = (locales: Locales[]): string =>\n locales\n .map((locale) => {\n for (const key in Locales) {\n if (Locales[key as keyof typeof Locales] === locale) {\n return `Locales.${key}`;\n }\n }\n })\n .join(' | ');\n\n/**\n * This function generates the content of the module augmentation file\n */\nconst generateTypeIndexContent = (\n typeFiles: string[],\n configuration = getConfiguration()\n): string => {\n const { content, internationalization } = configuration;\n const { moduleAugmentationDir } = content;\n const { locales, requiredLocales, strictMode } = internationalization;\n\n let fileContent =\n \"/* eslint-disable */\\nimport { Locales } from 'intlayer';\\n\";\n\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id (without the extension)\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n });\n\n fileContent += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n const requiredLocalesValues =\n requiredLocales.length > 0\n ? requiredLocales.filter((locale) =>\n locales.map((locale) => String(locale)).includes(String(locale))\n )\n : locales;\n\n const formattedLocales = formatLocales(locales);\n const formattedRequiredLocales = formatLocales(requiredLocalesValues);\n\n const strictModeRecord =\n strictMode === 'strict'\n ? `interface IConfigLocales<Content> extends Record<DeclaredLocales, Content> {}`\n : strictMode === 'inclusive'\n ? `interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}`\n : `interface IConfigLocales<Content> extends Partial<Record<Locales, Content>> {}`;\n\n /**\n * Write the module augmentation to extend the intlayer module with the dictionaries types\n * Will suggest the type resulting of the dictionaries\n *\n * declare module 'intlayer' {\n * interface IntlayerDictionaryTypesConnector = {\n * dictionaries: {\n * id: DictionaryType;\n * }\n * }\n *\n * type ConfigLocales = Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH;\n * type ExtractedLocales = Extract<Locales, ConfigLocales>;\n *\n * interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}\n *\n *\n * }\n * See https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\n */\n fileContent += `declare module 'intlayer' {\\n`;\n fileContent += ` interface IntlayerDictionaryTypesConnector {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n fileContent += ` type DeclaredLocales = ${formattedLocales};\\n`;\n fileContent += ` type RequiredLocales = ${formattedRequiredLocales};\\n`;\n fileContent += ` type ExtractedLocales = Extract<Locales, RequiredLocales>;\\n`;\n fileContent += ` type ExcludedLocales = Exclude<Locales, RequiredLocales>;\\n`;\n fileContent += ` ${strictModeRecord}\\n`;\n fileContent += `}`;\n\n return fileContent;\n};\n\n/**\n * This function generates a index file merging all the types\n */\nexport const createModuleAugmentation = (\n configuration = getConfiguration()\n) => {\n const { moduleAugmentationDir, typesDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(moduleAugmentationDir)) {\n mkdirSync(moduleAugmentationDir, { recursive: true });\n }\n\n const dictionariesTypesDefinitions: string[] = fg.sync(\n normalizePath(`${typesDir}/*.ts`),\n {\n ignore: ['**/*.d.ts'],\n }\n );\n // Create the dictionary list file\n\n const tsContent = generateTypeIndexContent(dictionariesTypesDefinitions);\n writeFileSync(join(moduleAugmentationDir, 'intlayer.d.ts'), tsContent);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyD;AACzD,uBAAe;AACf,gBAAqD;AACrD,kBAAkD;AAClD,mBAAkD;AAE3C,MAAM,cAAc,CAAC,QAC1B,OAAG,mCAAqB,GAAG,CAAC;AAE9B,MAAM,gBAAgB,CAAC,YACrB,QACG,IAAI,CAAC,WAAW;AACf,aAAW,OAAO,uBAAS;AACzB,QAAI,sBAAQ,GAA2B,MAAM,QAAQ;AACnD,aAAO,WAAW,GAAG;AAAA,IACvB;AAAA,EACF;AACF,CAAC,EACA,KAAK,KAAK;AAKf,MAAM,2BAA2B,CAC/B,WACA,oBAAgB,gCAAiB,MACtB;AACX,QAAM,EAAE,SAAS,qBAAqB,IAAI;AAC1C,QAAM,EAAE,sBAAsB,IAAI;AAClC,QAAM,EAAE,SAAS,iBAAiB,WAAW,IAAI;AAEjD,MAAI,cACF;AAEF,QAAM,kBAAkB,UAAU,IAAI,CAAC,oBAAoB;AAAA,IACzD,cAAc,SAAK,sBAAS,uBAAuB,cAAc,CAAC;AAAA,IAClE,QAAI,sBAAS,oBAAgB,qBAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,QAAI,0BAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,mBAAe,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AAAA,EAC3E,CAAC;AAED,iBAAe;AAGf,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,QAAQ,WAAW,EAAE,aAAa,WAAW,IAAI,GAAG,EACxE,KAAK,IAAI;AAEZ,QAAM,wBACJ,gBAAgB,SAAS,IACrB,gBAAgB;AAAA,IAAO,CAAC,WACtB,QAAQ,IAAI,CAACA,YAAW,OAAOA,OAAM,CAAC,EAAE,SAAS,OAAO,MAAM,CAAC;AAAA,EACjE,IACA;AAEN,QAAM,mBAAmB,cAAc,OAAO;AAC9C,QAAM,2BAA2B,cAAc,qBAAqB;AAEpE,QAAM,mBACJ,eAAe,WACX,kFACA,eAAe,cACb,8HACA;AAsBR,iBAAe;AAAA;AACf,iBAAe;AAAA,EAAmD,sBAAsB;AAAA;AAAA;AAAA;AACxF,iBAAe,4BAA4B,gBAAgB;AAAA;AAC3D,iBAAe,4BAA4B,wBAAwB;AAAA;AACnE,iBAAe;AAAA;AACf,iBAAe;AAAA;AACf,iBAAe,KAAK,gBAAgB;AAAA;AACpC,iBAAe;AAEf,SAAO;AACT;AAKO,MAAM,2BAA2B,CACtC,oBAAgB,gCAAiB,MAC9B;AACH,QAAM,EAAE,uBAAuB,SAAS,IAAI,cAAc;AAG1D,MAAI,KAAC,sBAAW,qBAAqB,GAAG;AACtC,6BAAU,uBAAuB,EAAE,WAAW,KAAK,CAAC;AAAA,EACtD;AAEA,QAAM,+BAAyC,iBAAAC,QAAG;AAAA,QAChD,6BAAc,GAAG,QAAQ,OAAO;AAAA,IAChC;AAAA,MACE,QAAQ,CAAC,WAAW;AAAA,IACtB;AAAA,EACF;AAGA,QAAM,YAAY,yBAAyB,4BAA4B;AACvE,mCAAc,kBAAK,uBAAuB,eAAe,GAAG,SAAS;AACvE;","names":["locale","fg"]}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getConfiguration } from "@intlayer/config";
|
|
1
|
+
import { getConfiguration, normalizePath } from "@intlayer/config";
|
|
3
2
|
import fg from "fast-glob";
|
|
3
|
+
import { existsSync, mkdirSync } from "fs";
|
|
4
4
|
const getBuiltDictionariesPath = (configuration = getConfiguration()) => {
|
|
5
5
|
const { dictionariesDir, mainDir } = configuration.content;
|
|
6
6
|
if (!existsSync(mainDir)) {
|
|
7
7
|
mkdirSync(mainDir, { recursive: true });
|
|
8
8
|
}
|
|
9
|
-
const dictionariesPath = fg.sync(
|
|
9
|
+
const dictionariesPath = fg.sync(
|
|
10
|
+
`${normalizePath(dictionariesDir)}/**/*.json`
|
|
11
|
+
);
|
|
10
12
|
return dictionariesPath;
|
|
11
13
|
};
|
|
12
14
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getBuiltDictionariesPath.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/getBuiltDictionariesPath.ts"],"sourcesContent":["import { getConfiguration, normalizePath } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync } from 'fs';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDictionariesPath = (\n configuration = getConfiguration()\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[] = fg.sync(\n `${normalizePath(dictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath;\n};\n"],"mappings":"AAAA,SAAS,kBAAkB,qBAAqB;AAChD,OAAO,QAAQ;AACf,SAAS,YAAY,iBAAiB;AAK/B,MAAM,2BAA2B,CACtC,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,EAAE,iBAAiB,QAAQ,IAAI,cAAc;AAGnD,MAAI,CAAC,WAAW,OAAO,GAAG;AACxB,cAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,mBAA6B,GAAG;AAAA,IACpC,GAAG,cAAc,eAAe,CAAC;AAAA,EACnC;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getConfiguration } from "@intlayer/config";
|
|
1
|
+
import { getConfiguration, normalizePath } from "@intlayer/config";
|
|
2
2
|
import fg from "fast-glob";
|
|
3
3
|
import { existsSync, mkdirSync } from "fs";
|
|
4
4
|
const getBuiltDynamicDictionariesPath = (configuration = getConfiguration(), format = "esm") => {
|
|
@@ -8,7 +8,7 @@ const getBuiltDynamicDictionariesPath = (configuration = getConfiguration(), for
|
|
|
8
8
|
}
|
|
9
9
|
const extension = format === "cjs" ? "cjs" : "mjs";
|
|
10
10
|
const dictionariesPath = fg.sync(
|
|
11
|
-
`${dynamicDictionariesDir}/**/*.${extension}`
|
|
11
|
+
`${normalizePath(dynamicDictionariesDir)}/**/*.${extension}`
|
|
12
12
|
);
|
|
13
13
|
return dictionariesPath;
|
|
14
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getBuiltDynamicDictionariesPath.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync } from 'fs';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDynamicDictionariesPath = (\n configuration = getConfiguration(),\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[] = fg.sync(\n `${dynamicDictionariesDir}/**/*.${extension}`\n );\n\n return dictionariesPath;\n};\n"],"mappings":"AAAA,SAAS,
|
|
1
|
+
{"version":3,"sources":["../../src/getBuiltDynamicDictionariesPath.ts"],"sourcesContent":["import { getConfiguration, normalizePath } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync } from 'fs';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDynamicDictionariesPath = (\n configuration = getConfiguration(),\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[] = fg.sync(\n `${normalizePath(dynamicDictionariesDir)}/**/*.${extension}`\n );\n\n return dictionariesPath;\n};\n"],"mappings":"AAAA,SAAS,kBAAkB,qBAAqB;AAChD,OAAO,QAAQ;AACf,SAAS,YAAY,iBAAiB;AAK/B,MAAM,kCAAkC,CAC7C,gBAAgB,iBAAiB,GACjC,SAAwB,UACrB;AACH,QAAM,EAAE,wBAAwB,QAAQ,IAAI,cAAc;AAG1D,MAAI,CAAC,WAAW,OAAO,GAAG;AACxB,cAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,YAAY,WAAW,QAAQ,QAAQ;AAE7C,QAAM,mBAA6B,GAAG;AAAA,IACpC,GAAG,cAAc,sBAAsB,CAAC,SAAS,SAAS;AAAA,EAC5D;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getConfiguration,
|
|
1
|
+
import { getConfiguration, normalizePath } from "@intlayer/config";
|
|
2
2
|
import fg from "fast-glob";
|
|
3
3
|
import { existsSync, mkdirSync } from "fs";
|
|
4
4
|
const getBuiltUnmergedDictionariesPath = (configuration = getConfiguration()) => {
|
|
@@ -7,7 +7,7 @@ const getBuiltUnmergedDictionariesPath = (configuration = getConfiguration()) =>
|
|
|
7
7
|
mkdirSync(mainDir, { recursive: true });
|
|
8
8
|
}
|
|
9
9
|
const dictionariesPath = fg.sync(
|
|
10
|
-
`${
|
|
10
|
+
`${normalizePath(unmergedDictionariesDir)}/**/*.json`
|
|
11
11
|
);
|
|
12
12
|
return dictionariesPath;
|
|
13
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getBuiltUnmergedDictionariesPath.ts"],"sourcesContent":["import { getConfiguration,
|
|
1
|
+
{"version":3,"sources":["../../src/getBuiltUnmergedDictionariesPath.ts"],"sourcesContent":["import { getConfiguration, normalizePath } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync } from 'fs';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltUnmergedDictionariesPath = (\n configuration = getConfiguration()\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[] = fg.sync(\n `${normalizePath(unmergedDictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath;\n};\n"],"mappings":"AAAA,SAAS,kBAAkB,qBAAqB;AAChD,OAAO,QAAQ;AACf,SAAS,YAAY,iBAAiB;AAK/B,MAAM,mCAAmC,CAC9C,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,EAAE,yBAAyB,QAAQ,IAAI,cAAc;AAG3D,MAAI,CAAC,WAAW,OAAO,GAAG;AACxB,cAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,mBAA6B,GAAG;AAAA,IACpC,GAAG,cAAc,uBAAuB,CAAC;AAAA,EAC3C;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getConfiguration } from "@intlayer/config";
|
|
1
|
+
import { getConfiguration, normalizePath } from "@intlayer/config";
|
|
2
2
|
import { basename, extname, relative } from "path";
|
|
3
3
|
import { getFileHash } from "../../utils.mjs";
|
|
4
4
|
const generateDictionaryListContent = (dictionaries, format = "esm", configuration = getConfiguration()) => {
|
|
5
5
|
const { mainDir } = configuration.content;
|
|
6
6
|
let content = "";
|
|
7
7
|
const dictionariesRef = dictionaries.map((dictionaryPath) => ({
|
|
8
|
-
relativePath: relative(mainDir, dictionaryPath),
|
|
8
|
+
relativePath: normalizePath(relative(mainDir, dictionaryPath)),
|
|
9
9
|
id: basename(dictionaryPath, extname(dictionaryPath)),
|
|
10
10
|
// Get the base name as the dictionary id
|
|
11
11
|
hash: `_${getFileHash(dictionaryPath)}`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/generateDictionaryListContent.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { basename, extname, relative } from 'path';\nimport { getFileHash } from '../../utils';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.content;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: relative(mainDir, dictionaryPath),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n"],"mappings":"AAAA,SAAS,
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/generateDictionaryListContent.ts"],"sourcesContent":["import { getConfiguration, normalizePath } from '@intlayer/config';\nimport { basename, extname, relative } from 'path';\nimport { getFileHash } from '../../utils';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.content;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: normalizePath(relative(mainDir, dictionaryPath)),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n"],"mappings":"AAAA,SAAS,kBAAkB,qBAAqB;AAChD,SAAS,UAAU,SAAS,gBAAgB;AAC5C,SAAS,mBAAmB;AAKrB,MAAM,gCAAgC,CAC3C,cACA,SAAwB,OACxB,gBAAgB,iBAAiB,MACtB;AACX,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,MAAI,UAAU;AAEd,QAAM,kBAAkB,aAAa,IAAI,CAAC,oBAAoB;AAAA,IAC5D,cAAc,cAAc,SAAS,SAAS,cAAc,CAAC;AAAA,IAC7D,IAAI,SAAS,gBAAgB,QAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,IAAI,YAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,QAAI,WAAW;AACb,iBAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AACvE,QAAI,WAAW;AACb,iBAAW,SAAS,WAAW,IAAI,eAAe,WAAW,YAAY;AAAA;AAAA,EAC7E,CAAC;AAED,aAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,MAAM,WAAW,EAAE,MAAM,WAAW,IAAI,EAAE,EAC9D,KAAK,KAAK;AAEb,MAAI,WAAW;AACb,eAAW;AAAA,EAAqB,sBAAsB;AAAA;AAAA;AACxD,MAAI,WAAW;AACb,eAAW;AAAA,EAAuB,sBAAsB;AAAA;AAAA;AAE1D,SAAO;AACT;","names":[]}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Locales,
|
|
3
|
-
getConfiguration,
|
|
4
|
-
normalizePathForGlob
|
|
5
|
-
} from "@intlayer/config";
|
|
1
|
+
import { Locales, getConfiguration, normalizePath } from "@intlayer/config";
|
|
6
2
|
import fg from "fast-glob";
|
|
7
3
|
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
8
4
|
import { basename, extname, join, relative } from "path";
|
|
@@ -65,7 +61,7 @@ const createModuleAugmentation = (configuration = getConfiguration()) => {
|
|
|
65
61
|
mkdirSync(moduleAugmentationDir, { recursive: true });
|
|
66
62
|
}
|
|
67
63
|
const dictionariesTypesDefinitions = fg.sync(
|
|
68
|
-
|
|
64
|
+
normalizePath(`${typesDir}/*.ts`),
|
|
69
65
|
{
|
|
70
66
|
ignore: ["**/*.d.ts"]
|
|
71
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"sourcesContent":["import { Locales, getConfiguration, normalizePath } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, join, relative } from 'path';\nimport { getFileHash, kebabCaseToCamelCase } from '../../utils';\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\nconst formatLocales = (locales: Locales[]): string =>\n locales\n .map((locale) => {\n for (const key in Locales) {\n if (Locales[key as keyof typeof Locales] === locale) {\n return `Locales.${key}`;\n }\n }\n })\n .join(' | ');\n\n/**\n * This function generates the content of the module augmentation file\n */\nconst generateTypeIndexContent = (\n typeFiles: string[],\n configuration = getConfiguration()\n): string => {\n const { content, internationalization } = configuration;\n const { moduleAugmentationDir } = content;\n const { locales, requiredLocales, strictMode } = internationalization;\n\n let fileContent =\n \"/* eslint-disable */\\nimport { Locales } from 'intlayer';\\n\";\n\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id (without the extension)\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n });\n\n fileContent += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n const requiredLocalesValues =\n requiredLocales.length > 0\n ? requiredLocales.filter((locale) =>\n locales.map((locale) => String(locale)).includes(String(locale))\n )\n : locales;\n\n const formattedLocales = formatLocales(locales);\n const formattedRequiredLocales = formatLocales(requiredLocalesValues);\n\n const strictModeRecord =\n strictMode === 'strict'\n ? `interface IConfigLocales<Content> extends Record<DeclaredLocales, Content> {}`\n : strictMode === 'inclusive'\n ? `interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}`\n : `interface IConfigLocales<Content> extends Partial<Record<Locales, Content>> {}`;\n\n /**\n * Write the module augmentation to extend the intlayer module with the dictionaries types\n * Will suggest the type resulting of the dictionaries\n *\n * declare module 'intlayer' {\n * interface IntlayerDictionaryTypesConnector = {\n * dictionaries: {\n * id: DictionaryType;\n * }\n * }\n *\n * type ConfigLocales = Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH;\n * type ExtractedLocales = Extract<Locales, ConfigLocales>;\n *\n * interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}\n *\n *\n * }\n * See https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\n */\n fileContent += `declare module 'intlayer' {\\n`;\n fileContent += ` interface IntlayerDictionaryTypesConnector {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n fileContent += ` type DeclaredLocales = ${formattedLocales};\\n`;\n fileContent += ` type RequiredLocales = ${formattedRequiredLocales};\\n`;\n fileContent += ` type ExtractedLocales = Extract<Locales, RequiredLocales>;\\n`;\n fileContent += ` type ExcludedLocales = Exclude<Locales, RequiredLocales>;\\n`;\n fileContent += ` ${strictModeRecord}\\n`;\n fileContent += `}`;\n\n return fileContent;\n};\n\n/**\n * This function generates a index file merging all the types\n */\nexport const createModuleAugmentation = (\n configuration = getConfiguration()\n) => {\n const { moduleAugmentationDir, typesDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(moduleAugmentationDir)) {\n mkdirSync(moduleAugmentationDir, { recursive: true });\n }\n\n const dictionariesTypesDefinitions: string[] = fg.sync(\n normalizePath(`${typesDir}/*.ts`),\n {\n ignore: ['**/*.d.ts'],\n }\n );\n // Create the dictionary list file\n\n const tsContent = generateTypeIndexContent(dictionariesTypesDefinitions);\n writeFileSync(join(moduleAugmentationDir, 'intlayer.d.ts'), tsContent);\n};\n"],"mappings":"AAAA,SAAS,SAAS,kBAAkB,qBAAqB;AACzD,OAAO,QAAQ;AACf,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,UAAU,SAAS,MAAM,gBAAgB;AAClD,SAAS,aAAa,4BAA4B;AAE3C,MAAM,cAAc,CAAC,QAC1B,GAAG,qBAAqB,GAAG,CAAC;AAE9B,MAAM,gBAAgB,CAAC,YACrB,QACG,IAAI,CAAC,WAAW;AACf,aAAW,OAAO,SAAS;AACzB,QAAI,QAAQ,GAA2B,MAAM,QAAQ;AACnD,aAAO,WAAW,GAAG;AAAA,IACvB;AAAA,EACF;AACF,CAAC,EACA,KAAK,KAAK;AAKf,MAAM,2BAA2B,CAC/B,WACA,gBAAgB,iBAAiB,MACtB;AACX,QAAM,EAAE,SAAS,qBAAqB,IAAI;AAC1C,QAAM,EAAE,sBAAsB,IAAI;AAClC,QAAM,EAAE,SAAS,iBAAiB,WAAW,IAAI;AAEjD,MAAI,cACF;AAEF,QAAM,kBAAkB,UAAU,IAAI,CAAC,oBAAoB;AAAA,IACzD,cAAc,KAAK,SAAS,uBAAuB,cAAc,CAAC;AAAA,IAClE,IAAI,SAAS,gBAAgB,QAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,IAAI,YAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,mBAAe,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AAAA,EAC3E,CAAC;AAED,iBAAe;AAGf,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,QAAQ,WAAW,EAAE,aAAa,WAAW,IAAI,GAAG,EACxE,KAAK,IAAI;AAEZ,QAAM,wBACJ,gBAAgB,SAAS,IACrB,gBAAgB;AAAA,IAAO,CAAC,WACtB,QAAQ,IAAI,CAACA,YAAW,OAAOA,OAAM,CAAC,EAAE,SAAS,OAAO,MAAM,CAAC;AAAA,EACjE,IACA;AAEN,QAAM,mBAAmB,cAAc,OAAO;AAC9C,QAAM,2BAA2B,cAAc,qBAAqB;AAEpE,QAAM,mBACJ,eAAe,WACX,kFACA,eAAe,cACb,8HACA;AAsBR,iBAAe;AAAA;AACf,iBAAe;AAAA,EAAmD,sBAAsB;AAAA;AAAA;AAAA;AACxF,iBAAe,4BAA4B,gBAAgB;AAAA;AAC3D,iBAAe,4BAA4B,wBAAwB;AAAA;AACnE,iBAAe;AAAA;AACf,iBAAe;AAAA;AACf,iBAAe,KAAK,gBAAgB;AAAA;AACpC,iBAAe;AAEf,SAAO;AACT;AAKO,MAAM,2BAA2B,CACtC,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,EAAE,uBAAuB,SAAS,IAAI,cAAc;AAG1D,MAAI,CAAC,WAAW,qBAAqB,GAAG;AACtC,cAAU,uBAAuB,EAAE,WAAW,KAAK,CAAC;AAAA,EACtD;AAEA,QAAM,+BAAyC,GAAG;AAAA,IAChD,cAAc,GAAG,QAAQ,OAAO;AAAA,IAChC;AAAA,MACE,QAAQ,CAAC,WAAW;AAAA,IACtB;AAAA,EACF;AAGA,QAAM,YAAY,yBAAyB,4BAA4B;AACvE,gBAAc,KAAK,uBAAuB,eAAe,GAAG,SAAS;AACvE;","names":["locale"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBuiltDictionariesPath.d.ts","sourceRoot":"","sources":["../../src/getBuiltDictionariesPath.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,yDAAkC,
|
|
1
|
+
{"version":3,"file":"getBuiltDictionariesPath.d.ts","sourceRoot":"","sources":["../../src/getBuiltDictionariesPath.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,yDAAkC,aAcnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createModuleAugmentation.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createModuleAugmentation.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MACH,CAAC;AA8FxC;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,yDAAkC,SAmBnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.",
|
|
6
6
|
"keywords": [
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
"fast-glob": "^3.3.3",
|
|
69
69
|
"p-limit": "^3.1.0",
|
|
70
70
|
"simple-git": "^3.27.0",
|
|
71
|
-
"@intlayer/api": "5.5.
|
|
72
|
-
"@intlayer/config": "5.5.
|
|
73
|
-
"@intlayer/dictionaries-entry": "5.5.
|
|
74
|
-
"
|
|
75
|
-
"@intlayer/
|
|
76
|
-
"intlayer": "5.5.
|
|
71
|
+
"@intlayer/api": "5.5.10",
|
|
72
|
+
"@intlayer/config": "5.5.10",
|
|
73
|
+
"@intlayer/dictionaries-entry": "5.5.10",
|
|
74
|
+
"intlayer": "5.5.10",
|
|
75
|
+
"@intlayer/core": "5.5.10",
|
|
76
|
+
"@intlayer/unmerged-dictionaries-entry": "5.5.10"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@changesets/cli": "2.29.4",
|
|
@@ -90,19 +90,19 @@
|
|
|
90
90
|
"tsc-alias": "^1.8.16",
|
|
91
91
|
"tsup": "^8.5.0",
|
|
92
92
|
"typescript": "^5.8.3",
|
|
93
|
-
"@intlayer/backend": "5.5.
|
|
93
|
+
"@intlayer/backend": "5.5.10",
|
|
94
94
|
"@utils/eslint-config": "1.0.4",
|
|
95
|
-
"@utils/ts-config
|
|
95
|
+
"@utils/ts-config": "1.0.4",
|
|
96
96
|
"@utils/tsup-config": "1.0.4",
|
|
97
|
-
"@utils/ts-config": "1.0.4"
|
|
97
|
+
"@utils/ts-config-types": "1.0.4"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
100
100
|
"fast-glob": "^3.3.3",
|
|
101
101
|
"react": ">=16.0.0",
|
|
102
|
-
"@intlayer/
|
|
103
|
-
"@intlayer/core": "5.5.
|
|
104
|
-
"intlayer": "5.5.
|
|
105
|
-
"
|
|
102
|
+
"@intlayer/api": "5.5.10",
|
|
103
|
+
"@intlayer/core": "5.5.10",
|
|
104
|
+
"@intlayer/config": "5.5.10",
|
|
105
|
+
"intlayer": "5.5.10"
|
|
106
106
|
},
|
|
107
107
|
"engines": {
|
|
108
108
|
"node": ">=14.18"
|