@intlayer/chokidar 6.1.2 → 6.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/getContentDeclarationFileTemplate/{cjsTemplate.md → cjsTemplate.txt} +2 -2
- package/dist/cjs/getContentDeclarationFileTemplate/{esmTemplate.md → esmTemplate.txt} +2 -2
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +18 -9
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
- package/dist/cjs/getContentDeclarationFileTemplate/jsonTemplate.txt +5 -0
- package/dist/cjs/getContentDeclarationFileTemplate/{tsTemplate.md → tsTemplate.txt} +2 -2
- package/dist/cjs/index.cjs +15 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +1 -1
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/utils/getFormatFromExtension.cjs +59 -0
- package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -0
- package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +54 -0
- package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -0
- package/dist/cjs/writeContentDeclaration/index.cjs +10 -2
- package/dist/cjs/writeContentDeclaration/index.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +2 -8
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
- package/dist/esm/getContentDeclarationFileTemplate/{cjsTemplate.md → cjsTemplate.txt} +2 -2
- package/dist/esm/getContentDeclarationFileTemplate/{esmTemplate.md → esmTemplate.txt} +2 -2
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +18 -9
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
- package/dist/esm/getContentDeclarationFileTemplate/jsonTemplate.txt +5 -0
- package/dist/esm/getContentDeclarationFileTemplate/{tsTemplate.md → tsTemplate.txt} +2 -2
- package/dist/esm/index.mjs +16 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +1 -1
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/utils/getFormatFromExtension.mjs +34 -0
- package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -0
- package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +30 -0
- package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -0
- package/dist/esm/writeContentDeclaration/index.mjs +5 -1
- package/dist/esm/writeContentDeclaration/index.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs +4 -8
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
- package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts +2 -1
- package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/getFormatFromExtension.d.ts +5 -0
- package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -0
- package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts +9 -0
- package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts.map +1 -0
- package/dist/types/writeContentDeclaration/index.d.ts +5 -1
- package/dist/types/writeContentDeclaration/index.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -1
- package/package.json +15 -15
|
@@ -28,11 +28,20 @@ var import_kebabCaseToCamelCase = require('../utils/kebabCaseToCamelCase.cjs');
|
|
|
28
28
|
const import_meta = {};
|
|
29
29
|
const getContentDeclarationFileTemplate = async (key, format, fileParams = {}) => {
|
|
30
30
|
const dirname = __dirname ?? (0, import_url.fileURLToPath)(import_meta.url);
|
|
31
|
-
let fileTemplate
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
let fileTemplate;
|
|
32
|
+
switch (format) {
|
|
33
|
+
case "ts":
|
|
34
|
+
fileTemplate = "./tsTemplate.txt";
|
|
35
|
+
break;
|
|
36
|
+
case "cjs":
|
|
37
|
+
fileTemplate = "./cjsTemplate.txt";
|
|
38
|
+
break;
|
|
39
|
+
case "json":
|
|
40
|
+
fileTemplate = "./jsonTemplate.txt";
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
fileTemplate = "./esmTemplate.txt";
|
|
44
|
+
break;
|
|
36
45
|
}
|
|
37
46
|
const fileContent = await (0, import_promises.readFile)((0, import_path.join)(dirname, fileTemplate), "utf-8");
|
|
38
47
|
const camelCaseKey = (0, import_kebabCaseToCamelCase.kebabCaseToCamelCase)(key);
|
|
@@ -40,18 +49,18 @@ const getContentDeclarationFileTemplate = async (key, format, fileParams = {}) =
|
|
|
40
49
|
const fileParmsString = Object.entries(fileParams).filter(([, value]) => value !== void 0).map(([key2, value]) => {
|
|
41
50
|
if (typeof value === "object") {
|
|
42
51
|
return `
|
|
43
|
-
${key2}: ${JSON.stringify(value)},`;
|
|
52
|
+
'${key2}': ${JSON.stringify(value)},`;
|
|
44
53
|
}
|
|
45
54
|
if (typeof value === "boolean" || typeof value === "number") {
|
|
46
55
|
return `
|
|
47
|
-
${key2}: ${value},`;
|
|
56
|
+
'${key2}': ${value},`;
|
|
48
57
|
}
|
|
49
58
|
if (typeof value === "string") {
|
|
50
59
|
return `
|
|
51
|
-
${key2}: '${value}',`;
|
|
60
|
+
'${key2}': '${value}',`;
|
|
52
61
|
}
|
|
53
62
|
return `
|
|
54
|
-
${key2}: ${value},`;
|
|
63
|
+
'${key2}': ${value},`;
|
|
55
64
|
}).join("");
|
|
56
65
|
return fileContent.replace("{{key}}", key).replaceAll("{{name}}", nonCapitalizedCamelCaseKey).replace("{{fileParams}}", fileParmsString);
|
|
57
66
|
};
|
package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"sourcesContent":["import { readFile } from 'fs/promises';\nimport { join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { kebabCaseToCamelCase } from '../utils/kebabCaseToCamelCase';\n\nexport const getContentDeclarationFileTemplate = async (\n key: string,\n format:
|
|
1
|
+
{"version":3,"sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"sourcesContent":["import { readFile } from 'fs/promises';\nimport { join } from 'path';\nimport { fileURLToPath } from 'url';\nimport type { Format } from '../utils/getFormatFromExtension';\nimport { kebabCaseToCamelCase } from '../utils/kebabCaseToCamelCase';\n\nexport const getContentDeclarationFileTemplate = async (\n key: string,\n format: Format,\n fileParams: Record<string, any> = {}\n) => {\n const dirname = __dirname ?? fileURLToPath(import.meta.url);\n\n let fileTemplate: string;\n\n switch (format) {\n case 'ts':\n fileTemplate = './tsTemplate.txt';\n break;\n case 'cjs':\n fileTemplate = './cjsTemplate.txt';\n break;\n case 'json':\n fileTemplate = './jsonTemplate.txt';\n break;\n default:\n fileTemplate = './esmTemplate.txt';\n break;\n }\n\n const fileContent = await readFile(join(dirname, fileTemplate), 'utf-8');\n const camelCaseKey = kebabCaseToCamelCase(key);\n const nonCapitalizedCamelCaseKey =\n camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);\n\n const fileParmsString = Object.entries(fileParams)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => {\n if (typeof value === 'object') {\n return `\\n'${key}': ${JSON.stringify(value)},`;\n }\n\n if (typeof value === 'boolean' || typeof value === 'number') {\n return `\\n'${key}': ${value},`;\n }\n\n if (typeof value === 'string') {\n return `\\n'${key}': '${value}',`;\n }\n\n return `\\n'${key}': ${value},`;\n })\n .join('');\n\n return fileContent\n .replace('{{key}}', key)\n .replaceAll('{{name}}', nonCapitalizedCamelCaseKey)\n .replace('{{fileParams}}', fileParmsString);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AACzB,kBAAqB;AACrB,iBAA8B;AAE9B,kCAAqC;AAJrC;AAMO,MAAM,oCAAoC,OAC/C,KACA,QACA,aAAkC,CAAC,MAChC;AACH,QAAM,UAAU,iBAAa,0BAAc,YAAY,GAAG;AAE1D,MAAI;AAEJ,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,qBAAe;AACf;AAAA,IACF,KAAK;AACH,qBAAe;AACf;AAAA,IACF,KAAK;AACH,qBAAe;AACf;AAAA,IACF;AACE,qBAAe;AACf;AAAA,EACJ;AAEA,QAAM,cAAc,UAAM,8BAAS,kBAAK,SAAS,YAAY,GAAG,OAAO;AACvE,QAAM,mBAAe,kDAAqB,GAAG;AAC7C,QAAM,6BACJ,aAAa,OAAO,CAAC,EAAE,YAAY,IAAI,aAAa,MAAM,CAAC;AAE7D,QAAM,kBAAkB,OAAO,QAAQ,UAAU,EAC9C,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS,EACzC,IAAI,CAAC,CAACA,MAAK,KAAK,MAAM;AACrB,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;AAAA,GAAMA,IAAG,MAAM,KAAK,UAAU,KAAK,CAAC;AAAA,IAC7C;AAEA,QAAI,OAAO,UAAU,aAAa,OAAO,UAAU,UAAU;AAC3D,aAAO;AAAA,GAAMA,IAAG,MAAM,KAAK;AAAA,IAC7B;AAEA,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;AAAA,GAAMA,IAAG,OAAO,KAAK;AAAA,IAC9B;AAEA,WAAO;AAAA,GAAMA,IAAG,MAAM,KAAK;AAAA,EAC7B,CAAC,EACA,KAAK,EAAE;AAEV,SAAO,YACJ,QAAQ,WAAW,GAAG,EACtB,WAAW,YAAY,0BAA0B,EACjD,QAAQ,kBAAkB,eAAe;AAC9C;","names":["key"]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -24,8 +24,10 @@ __export(index_exports, {
|
|
|
24
24
|
createDictionaryEntryPoint: () => import_createDictionaryEntryPoint.createDictionaryEntryPoint,
|
|
25
25
|
createModuleAugmentation: () => import_createModuleAugmentation.createModuleAugmentation,
|
|
26
26
|
createTypes: () => import_createType.createTypes,
|
|
27
|
+
detectExportedComponentName: () => import_writeContentDeclaration.detectExportedComponentName,
|
|
27
28
|
extractErrorMessage: () => import_extractErrorMessage.extractErrorMessage,
|
|
28
29
|
fetchDistantDictionaries: () => import_fetchDistantDictionaries.fetchDistantDictionaries,
|
|
30
|
+
formatCode: () => import_writeContentDeclaration.formatCode,
|
|
29
31
|
formatLocale: () => import_formatter.formatLocale,
|
|
30
32
|
formatPath: () => import_formatter.formatPath,
|
|
31
33
|
generateDictionaryListContent: () => import_createDictionaryEntryPoint.generateDictionaryListContent,
|
|
@@ -36,7 +38,9 @@ __export(index_exports, {
|
|
|
36
38
|
getBuiltUnmergedDictionariesPath: () => import_createDictionaryEntryPoint.getBuiltUnmergedDictionariesPath,
|
|
37
39
|
getContentDeclarationFileTemplate: () => import_getContentDeclarationFileTemplate.getContentDeclarationFileTemplate,
|
|
38
40
|
getExtension: () => import_getExtention.getExtension,
|
|
41
|
+
getExtensionFromFormat: () => import_getFormatFromExtension.getExtensionFromFormat,
|
|
39
42
|
getFileHash: () => import_getFileHash.getFileHash,
|
|
43
|
+
getFormatFromExtension: () => import_getFormatFromExtension.getFormatFromExtension,
|
|
40
44
|
handleAdditionalContentDeclarationFile: () => import_handleAdditionalContentDeclarationFile.handleAdditionalContentDeclarationFile,
|
|
41
45
|
handleContentDeclarationFileChange: () => import_handleContentDeclarationFileChange.handleContentDeclarationFileChange,
|
|
42
46
|
handleUnlikedContentDeclarationFile: () => import_handleUnlikedContentDeclarationFile.handleUnlikedContentDeclarationFile,
|
|
@@ -59,8 +63,10 @@ __export(index_exports, {
|
|
|
59
63
|
runOnce: () => import_runOnce.runOnce,
|
|
60
64
|
runParallel: () => import_runParallel.runParallel,
|
|
61
65
|
sortAlphabetically: () => import_sortAlphabetically.sortAlphabetically,
|
|
66
|
+
transformJSFile: () => import_writeContentDeclaration.transformJSFile,
|
|
62
67
|
watch: () => import_watcher.watch,
|
|
63
|
-
writeContentDeclaration: () => import_writeContentDeclaration.writeContentDeclaration
|
|
68
|
+
writeContentDeclaration: () => import_writeContentDeclaration.writeContentDeclaration,
|
|
69
|
+
writeJSFile: () => import_writeContentDeclaration.writeJSFile
|
|
64
70
|
});
|
|
65
71
|
module.exports = __toCommonJS(index_exports);
|
|
66
72
|
var import_buildIntlayerDictionary = require('./buildIntlayerDictionary/buildIntlayerDictionary.cjs');
|
|
@@ -86,6 +92,7 @@ var import_extractErrorMessage = require('./utils/extractErrorMessage.cjs');
|
|
|
86
92
|
var import_formatter = require('./utils/formatter.cjs');
|
|
87
93
|
var import_getExtention = require('./utils/getExtention.cjs');
|
|
88
94
|
var import_getFileHash = require('./utils/getFileHash.cjs');
|
|
95
|
+
var import_getFormatFromExtension = require('./utils/getFormatFromExtension.cjs');
|
|
89
96
|
var import_kebabCaseToCamelCase = require('./utils/kebabCaseToCamelCase.cjs');
|
|
90
97
|
var import_parallelize = require('./utils/parallelize.cjs');
|
|
91
98
|
var import_resolveObjectPromises = require('./utils/resolveObjectPromises.cjs');
|
|
@@ -102,8 +109,10 @@ var import_writeContentDeclaration = require('./writeContentDeclaration/index.cj
|
|
|
102
109
|
createDictionaryEntryPoint,
|
|
103
110
|
createModuleAugmentation,
|
|
104
111
|
createTypes,
|
|
112
|
+
detectExportedComponentName,
|
|
105
113
|
extractErrorMessage,
|
|
106
114
|
fetchDistantDictionaries,
|
|
115
|
+
formatCode,
|
|
107
116
|
formatLocale,
|
|
108
117
|
formatPath,
|
|
109
118
|
generateDictionaryListContent,
|
|
@@ -114,7 +123,9 @@ var import_writeContentDeclaration = require('./writeContentDeclaration/index.cj
|
|
|
114
123
|
getBuiltUnmergedDictionariesPath,
|
|
115
124
|
getContentDeclarationFileTemplate,
|
|
116
125
|
getExtension,
|
|
126
|
+
getExtensionFromFormat,
|
|
117
127
|
getFileHash,
|
|
128
|
+
getFormatFromExtension,
|
|
118
129
|
handleAdditionalContentDeclarationFile,
|
|
119
130
|
handleContentDeclarationFileChange,
|
|
120
131
|
handleUnlikedContentDeclarationFile,
|
|
@@ -137,7 +148,9 @@ var import_writeContentDeclaration = require('./writeContentDeclaration/index.cj
|
|
|
137
148
|
runOnce,
|
|
138
149
|
runParallel,
|
|
139
150
|
sortAlphabetically,
|
|
151
|
+
transformJSFile,
|
|
140
152
|
watch,
|
|
141
|
-
writeContentDeclaration
|
|
153
|
+
writeContentDeclaration,
|
|
154
|
+
writeJSFile
|
|
142
155
|
});
|
|
143
156
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n getBuiltDictionariesPath,\n getBuiltDynamicDictionariesPath,\n getBuiltFetchDictionariesPath,\n getBuiltRemoteDictionariesPath,\n getBuiltUnmergedDictionariesPath,\n} from './createDictionaryEntryPoint';\nexport { createTypes } from './createType';\nexport { createModuleAugmentation } from './createType/createModuleAugmentation';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { isInvalidDictionary } from './filterInvalidDictionaries';\nexport { getContentDeclarationFileTemplate } from './getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nexport { handleAdditionalContentDeclarationFile } from './handleAdditionalContentDeclarationFile';\nexport { handleContentDeclarationFileChange } from './handleContentDeclarationFileChange';\nexport { handleUnlikedContentDeclarationFile } from './handleUnlikedContentDeclarationFile';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n listGitLines,\n type DiffMode,\n type ListGitFilesOptions,\n type ListGitLinesOptions,\n} from './listGitFiles';\nexport {\n loadContentDeclarations,\n loadDictionaries,\n loadLocalDictionaries,\n loadRemoteDictionaries,\n} from './loadDictionaries';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { extractErrorMessage } from './utils/extractErrorMessage';\nexport { formatLocale, formatPath } from './utils/formatter';\nexport { getExtension } from './utils/getExtention';\nexport { getFileHash } from './utils/getFileHash';\nexport { kebabCaseToCamelCase } from './utils/kebabCaseToCamelCase';\nexport { parallelize } from './utils/parallelize';\nexport { resolveObjectPromises } from './utils/resolveObjectPromises';\nexport { runOnce } from './utils/runOnce';\nexport { runParallel, type ParallelHandle } from './utils/runParallel';\nexport { sortAlphabetically } from './utils/sortAlphabetically';\nexport { buildAndWatchIntlayer, watch } from './watcher';\nexport {\n writeContentDeclaration,\n type DictionaryStatus,\n} from './writeContentDeclaration';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qCAAgC;AAChC,4BAA+B;AAC/B,wCAQO;AACP,wBAA4B;AAC5B,sCAAyC;AACzC,sCAAyC;AACzC,uCAAoC;AACpC,+CAAkD;AAClD,oDAAuD;AACvD,gDAAmD;AACnD,iDAAoD;AACpD,kCAAiC;AACjC,0BAMO;AACP,8BAKO;AACP,+BAAkC;AAClC,uCAA0C;AAC1C,6BAAgC;AAChC,wCAA2C;AAC3C,qCAAwC;AACxC,iCAAoC;AACpC,uBAAyC;AACzC,0BAA6B;AAC7B,yBAA4B;AAC5B,kCAAqC;AACrC,yBAA4B;AAC5B,mCAAsC;AACtC,qBAAwB;AACxB,yBAAiD;AACjD,gCAAmC;AACnC,qBAA6C;AAC7C,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n getBuiltDictionariesPath,\n getBuiltDynamicDictionariesPath,\n getBuiltFetchDictionariesPath,\n getBuiltRemoteDictionariesPath,\n getBuiltUnmergedDictionariesPath,\n} from './createDictionaryEntryPoint';\nexport { createTypes } from './createType';\nexport { createModuleAugmentation } from './createType/createModuleAugmentation';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { isInvalidDictionary } from './filterInvalidDictionaries';\nexport { getContentDeclarationFileTemplate } from './getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nexport { handleAdditionalContentDeclarationFile } from './handleAdditionalContentDeclarationFile';\nexport { handleContentDeclarationFileChange } from './handleContentDeclarationFileChange';\nexport { handleUnlikedContentDeclarationFile } from './handleUnlikedContentDeclarationFile';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n listGitLines,\n type DiffMode,\n type ListGitFilesOptions,\n type ListGitLinesOptions,\n} from './listGitFiles';\nexport {\n loadContentDeclarations,\n loadDictionaries,\n loadLocalDictionaries,\n loadRemoteDictionaries,\n} from './loadDictionaries';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { extractErrorMessage } from './utils/extractErrorMessage';\nexport { formatLocale, formatPath } from './utils/formatter';\nexport { getExtension } from './utils/getExtention';\nexport { getFileHash } from './utils/getFileHash';\nexport {\n getExtensionFromFormat,\n getFormatFromExtension,\n} from './utils/getFormatFromExtension';\nexport { kebabCaseToCamelCase } from './utils/kebabCaseToCamelCase';\nexport { parallelize } from './utils/parallelize';\nexport { resolveObjectPromises } from './utils/resolveObjectPromises';\nexport { runOnce } from './utils/runOnce';\nexport { runParallel, type ParallelHandle } from './utils/runParallel';\nexport { sortAlphabetically } from './utils/sortAlphabetically';\nexport { buildAndWatchIntlayer, watch } from './watcher';\nexport {\n detectExportedComponentName,\n formatCode,\n transformJSFile,\n writeContentDeclaration,\n writeJSFile,\n type DictionaryStatus,\n} from './writeContentDeclaration';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qCAAgC;AAChC,4BAA+B;AAC/B,wCAQO;AACP,wBAA4B;AAC5B,sCAAyC;AACzC,sCAAyC;AACzC,uCAAoC;AACpC,+CAAkD;AAClD,oDAAuD;AACvD,gDAAmD;AACnD,iDAAoD;AACpD,kCAAiC;AACjC,0BAMO;AACP,8BAKO;AACP,+BAAkC;AAClC,uCAA0C;AAC1C,6BAAgC;AAChC,wCAA2C;AAC3C,qCAAwC;AACxC,iCAAoC;AACpC,uBAAyC;AACzC,0BAA6B;AAC7B,yBAA4B;AAC5B,oCAGO;AACP,kCAAqC;AACrC,yBAA4B;AAC5B,mCAAsC;AACtC,qBAAwB;AACxB,yBAAiD;AACjD,gCAAmC;AACnC,qBAA6C;AAC7C,qCAOO;","names":[]}
|
|
@@ -112,7 +112,7 @@ const prepareIntlayer = async (configuration = (0, import_config.getConfiguratio
|
|
|
112
112
|
[
|
|
113
113
|
"Configuration written",
|
|
114
114
|
(0, import_config.colorize)(
|
|
115
|
-
`(${configurationWrittenTime -
|
|
115
|
+
`(${configurationWrittenTime - moduleAugmentationBuiltTime}ms)`,
|
|
116
116
|
import_config.ANSIColors.GREY_DARK
|
|
117
117
|
)
|
|
118
118
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ANSIColors,\n ESMxCJSRequire,\n type IntlayerConfig,\n colorize,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire,\n clean = false,\n format: ('cjs' | 'esm')[] = ['cjs', 'esm']\n) => {\n const appLogger = getAppLogger(configuration);\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n if (clean) {\n cleanOutputDir(configuration);\n }\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(\n files,\n configuration,\n projectRequire\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length > 0\n ? ` (Total: ${dictionariesLoadedTime - preparationStartMs}ms - Local: ${dictionaries.time.localDictionaries}ms - Remote: ${dictionaries.time.remoteDictionaries}ms)`\n : `(${dictionariesLoadedTime - preparationStartMs}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [...dictionaries.localDictionaries, ...dictionaries.remoteDictionaries],\n configuration,\n format,\n false\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(dictionaries.remoteDictionaries, configuration);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths);\n\n await createDictionaryEntryPoint(configuration);\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime -
|
|
1
|
+
{"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ANSIColors,\n ESMxCJSRequire,\n type IntlayerConfig,\n colorize,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire,\n clean = false,\n format: ('cjs' | 'esm')[] = ['cjs', 'esm']\n) => {\n const appLogger = getAppLogger(configuration);\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n if (clean) {\n cleanOutputDir(configuration);\n }\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(\n files,\n configuration,\n projectRequire\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length > 0\n ? ` (Total: ${dictionariesLoadedTime - preparationStartMs}ms - Local: ${dictionaries.time.localDictionaries}ms - Remote: ${dictionaries.time.remoteDictionaries}ms)`\n : `(${dictionariesLoadedTime - preparationStartMs}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [...dictionaries.localDictionaries, ...dictionaries.remoteDictionaries],\n configuration,\n format,\n false\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(dictionaries.remoteDictionaries, configuration);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths);\n\n await createDictionaryEntryPoint(configuration);\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - moduleAugmentationBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const preparationElapsedMs = Date.now() - preparationStartMs;\n appLogger([`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)], {\n level: 'info',\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOO;AACP,qBAAwB;AACxB,qCAAgC;AAChC,mCAAsC;AACtC,4BAA+B;AAC/B,wCAA2C;AAC3C,wBAAsD;AACtD,kCAAiC;AACjC,8BAAiC;AACjC,gCAAmC;AAE5B,MAAM,kBAAkB,OAC7B,oBAAgC,gCAAiB,GACjD,iBAAiB,8BACjB,QAAQ,OACR,SAA4B,CAAC,OAAO,KAAK,MACtC;AACH,QAAM,gBAAY,4BAAa,aAAa;AAC5C,QAAM,qBAAqB,KAAK,IAAI;AAEpC,YAAU;AAAA,IACR;AAAA,QACA,wBAAS,KAAK,eAAAA,QAAY,OAAO,KAAK,yBAAW,SAAS;AAAA,EAC5D,CAAC;AAED,MAAI,OAAO;AACT,8CAAe,aAAa;AAAA,EAC9B;AAEA,QAAM,YAAkB,8CAAiB,aAAa;AAEtD,QAAM,eAAe,UAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,yBAAyB,KAAK,IAAI;AAExC;AAAA,IACE;AAAA,MACE;AAAA,UACA;AAAA,QACE;AAAA,UACE,aAAa,mBAAmB,SAAS,IACrC,YAAY,yBAAyB,kBAAkB,eAAe,aAAa,KAAK,iBAAiB,gBAAgB,aAAa,KAAK,kBAAkB,QAC7J,IAAI,yBAAyB,kBAAkB;AAAA,QACrD,EAAE,KAAK,EAAE;AAAA,QACT,yBAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA;AAAA,MACE,WAAW;AAAA,IACb;AAAA,EACF;AAGA,QAAM,qBAAqB,UAAM;AAAA,IAC/B,CAAC,GAAG,aAAa,mBAAmB,GAAG,aAAa,kBAAkB;AAAA,IACtE;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAIA,YAAM,oDAAsB,aAAa,oBAAoB,aAAa;AAE1E,QAAM,oBAAoB,OAAO;AAAA,IAC/B,oBAAoB,sBAAsB,CAAC;AAAA,EAC7C,EAAE,IAAI,CAAC,eAAe,WAAW,cAAc;AAE/C,YAAM,+BAAY,iBAAiB;AAEnC,YAAM,8DAA2B,aAAa;AAE9C,QAAM,wBAAwB,KAAK,IAAI;AAEvC,YAAU;AAAA,IACR;AAAA,QACA;AAAA,MACE,IAAI,wBAAwB,kBAAkB;AAAA,MAC9C,yBAAW;AAAA,IACb;AAAA,EACF,CAAC;AAED,YAAM,4CAAyB,aAAa;AAE5C,QAAM,8BAA8B,KAAK,IAAI;AAE7C;AAAA,IACE;AAAA,MACE;AAAA,UACA;AAAA,QACE,IAAI,8BAA8B,qBAAqB;AAAA,QACvD,yBAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA;AAAA,MACE,WAAW;AAAA,IACb;AAAA,EACF;AAEA,YAAM,8CAAmB,aAAa;AAEtC,QAAM,2BAA2B,KAAK,IAAI;AAE1C;AAAA,IACE;AAAA,MACE;AAAA,UACA;AAAA,QACE,IAAI,2BAA2B,2BAA2B;AAAA,QAC1D,yBAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA;AAAA,MACE,WAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,uBAAuB,KAAK,IAAI,IAAI;AAC1C,YAAU,CAAC,YAAQ,wBAAS,GAAG,oBAAoB,MAAM,yBAAW,KAAK,CAAC,GAAG;AAAA,IAC3E,OAAO;AAAA,IACP,WAAW;AAAA,EACb,CAAC;AACH;","names":["packageJson"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var getFormatFromExtension_exports = {};
|
|
20
|
+
__export(getFormatFromExtension_exports, {
|
|
21
|
+
getExtensionFromFormat: () => getExtensionFromFormat,
|
|
22
|
+
getFormatFromExtension: () => getFormatFromExtension
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(getFormatFromExtension_exports);
|
|
25
|
+
const getFormatFromExtension = (extension) => {
|
|
26
|
+
switch (extension) {
|
|
27
|
+
case ".ts":
|
|
28
|
+
case ".tsx":
|
|
29
|
+
return "ts";
|
|
30
|
+
case ".cjs":
|
|
31
|
+
case ".cjsx":
|
|
32
|
+
return "cjs";
|
|
33
|
+
case ".mjs":
|
|
34
|
+
return "esm";
|
|
35
|
+
case ".json":
|
|
36
|
+
case ".json5":
|
|
37
|
+
return "json";
|
|
38
|
+
}
|
|
39
|
+
return "esm";
|
|
40
|
+
};
|
|
41
|
+
const getExtensionFromFormat = (format) => {
|
|
42
|
+
switch (format) {
|
|
43
|
+
case "ts":
|
|
44
|
+
return ".ts";
|
|
45
|
+
case "cjs":
|
|
46
|
+
return ".cjs";
|
|
47
|
+
case "json":
|
|
48
|
+
return ".json";
|
|
49
|
+
case "esm":
|
|
50
|
+
return ".mjs";
|
|
51
|
+
}
|
|
52
|
+
return ".mjs";
|
|
53
|
+
};
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
getExtensionFromFormat,
|
|
57
|
+
getFormatFromExtension
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=getFormatFromExtension.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/getFormatFromExtension.ts"],"sourcesContent":["export type Format = 'ts' | 'cjs' | 'esm' | 'json';\nexport type Extension =\n | '.ts'\n | '.tsx'\n | '.js'\n | '.jsx'\n | '.cjs'\n | '.cjsx'\n | '.mjs'\n | '.mjsx'\n | '.json'\n | '.json5';\n\nexport const getFormatFromExtension = (extension: Extension): Format => {\n switch (extension) {\n case '.ts':\n case '.tsx':\n return 'ts';\n case '.cjs':\n case '.cjsx':\n return 'cjs';\n case '.mjs':\n return 'esm';\n case '.json':\n case '.json5':\n return 'json';\n }\n\n return 'esm';\n};\n\nexport const getExtensionFromFormat = (format: Format): Extension => {\n switch (format) {\n case 'ts':\n return '.ts';\n case 'cjs':\n return '.cjs';\n case 'json':\n return '.json';\n case 'esm':\n return '.mjs';\n }\n\n return '.mjs';\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,MAAM,yBAAyB,CAAC,cAAiC;AACtE,UAAQ,WAAW;AAAA,IACjB,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,EACX;AAEA,SAAO;AACT;AAEO,MAAM,yBAAyB,CAAC,WAA8B;AACnE,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var detectExportedComponentName_exports = {};
|
|
20
|
+
__export(detectExportedComponentName_exports, {
|
|
21
|
+
detectExportedComponentName: () => detectExportedComponentName
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(detectExportedComponentName_exports);
|
|
24
|
+
const detectExportedComponentName = (fileText) => {
|
|
25
|
+
const defaultEsmFnRegex = /export\s+default\s+function\s+(\w+)/;
|
|
26
|
+
const defaultEsmVarRegex = /export\s+default\s+(\w+)/;
|
|
27
|
+
const cjsDefaultRegex = /module\.exports\s*=\s*(\w+)/;
|
|
28
|
+
const cjsDefaultVarRegex = /exports\.default\s*=\s*(\w+)/;
|
|
29
|
+
const namedExportRegex = /export\s+(?:const|function)\s+(\w+)/g;
|
|
30
|
+
const defaultEsmFnMatch = fileText.match(defaultEsmFnRegex);
|
|
31
|
+
if (defaultEsmFnMatch) {
|
|
32
|
+
return defaultEsmFnMatch[1];
|
|
33
|
+
}
|
|
34
|
+
const defaultEsmVarMatch = fileText.match(defaultEsmVarRegex);
|
|
35
|
+
if (defaultEsmVarMatch) {
|
|
36
|
+
return defaultEsmVarMatch[1];
|
|
37
|
+
}
|
|
38
|
+
const cjsDefaultMatch = fileText.match(cjsDefaultRegex) || fileText.match(cjsDefaultVarRegex);
|
|
39
|
+
if (cjsDefaultMatch) {
|
|
40
|
+
return cjsDefaultMatch[1];
|
|
41
|
+
}
|
|
42
|
+
let match;
|
|
43
|
+
while ((match = namedExportRegex.exec(fileText)) !== null) {
|
|
44
|
+
if (/^[A-Z]/.test(match[1])) {
|
|
45
|
+
return match[1];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
detectExportedComponentName
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=detectExportedComponentName.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/writeContentDeclaration/detectExportedComponentName.ts"],"sourcesContent":["/**\n * Attempt to detect an exported React component name in the file text.\n * Looks for patterns like:\n * - export const MyComponent = ...\n * - export function MyComponent(...)\n * - export default function MyComponent(...)\n */\nexport const detectExportedComponentName = (\n fileText: string\n): string | null => {\n // Added regexes for default ESM, default CJS, and named exports\n const defaultEsmFnRegex = /export\\s+default\\s+function\\s+(\\w+)/;\n const defaultEsmVarRegex = /export\\s+default\\s+(\\w+)/;\n const cjsDefaultRegex = /module\\.exports\\s*=\\s*(\\w+)/;\n const cjsDefaultVarRegex = /exports\\.default\\s*=\\s*(\\w+)/;\n const namedExportRegex = /export\\s+(?:const|function)\\s+(\\w+)/g;\n\n // 1) Check for default ESM function or variable\n const defaultEsmFnMatch = fileText.match(defaultEsmFnRegex);\n if (defaultEsmFnMatch) {\n return defaultEsmFnMatch[1];\n }\n\n const defaultEsmVarMatch = fileText.match(defaultEsmVarRegex);\n if (defaultEsmVarMatch) {\n return defaultEsmVarMatch[1];\n }\n\n // 2) Check for default CJS\n const cjsDefaultMatch =\n fileText.match(cjsDefaultRegex) || fileText.match(cjsDefaultVarRegex);\n if (cjsDefaultMatch) {\n return cjsDefaultMatch[1];\n }\n\n // 3) Otherwise, look for capitalized named exports\n let match;\n while ((match = namedExportRegex.exec(fileText)) !== null) {\n if (/^[A-Z]/.test(match[1])) {\n return match[1];\n }\n }\n\n // If we can’t find it, return null\n return null;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,MAAM,8BAA8B,CACzC,aACkB;AAElB,QAAM,oBAAoB;AAC1B,QAAM,qBAAqB;AAC3B,QAAM,kBAAkB;AACxB,QAAM,qBAAqB;AAC3B,QAAM,mBAAmB;AAGzB,QAAM,oBAAoB,SAAS,MAAM,iBAAiB;AAC1D,MAAI,mBAAmB;AACrB,WAAO,kBAAkB,CAAC;AAAA,EAC5B;AAEA,QAAM,qBAAqB,SAAS,MAAM,kBAAkB;AAC5D,MAAI,oBAAoB;AACtB,WAAO,mBAAmB,CAAC;AAAA,EAC7B;AAGA,QAAM,kBACJ,SAAS,MAAM,eAAe,KAAK,SAAS,MAAM,kBAAkB;AACtE,MAAI,iBAAiB;AACnB,WAAO,gBAAgB,CAAC;AAAA,EAC1B;AAGA,MAAI;AACJ,UAAQ,QAAQ,iBAAiB,KAAK,QAAQ,OAAO,MAAM;AACzD,QAAI,SAAS,KAAK,MAAM,CAAC,CAAC,GAAG;AAC3B,aAAO,MAAM,CAAC;AAAA,IAChB;AAAA,EACF;AAGA,SAAO;AACT;","names":[]}
|
|
@@ -15,11 +15,19 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var writeContentDeclaration_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(writeContentDeclaration_exports);
|
|
18
|
-
__reExport(writeContentDeclaration_exports, require('./
|
|
18
|
+
__reExport(writeContentDeclaration_exports, require('./detectExportedComponentName.cjs'), module.exports);
|
|
19
19
|
__reExport(writeContentDeclaration_exports, require('./dictionaryStatus.cjs'), module.exports);
|
|
20
|
+
__reExport(writeContentDeclaration_exports, require('./formatCode.cjs'), module.exports);
|
|
21
|
+
__reExport(writeContentDeclaration_exports, require('./transformJSFile.cjs'), module.exports);
|
|
22
|
+
__reExport(writeContentDeclaration_exports, require('./writeContentDeclaration.cjs'), module.exports);
|
|
23
|
+
__reExport(writeContentDeclaration_exports, require('./writeJSFile.cjs'), module.exports);
|
|
20
24
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21
25
|
0 && (module.exports = {
|
|
26
|
+
...require('./detectExportedComponentName.cjs'),
|
|
27
|
+
...require('./dictionaryStatus.cjs'),
|
|
28
|
+
...require('./formatCode.cjs'),
|
|
29
|
+
...require('./transformJSFile.cjs'),
|
|
22
30
|
...require('./writeContentDeclaration.cjs'),
|
|
23
|
-
...require('./
|
|
31
|
+
...require('./writeJSFile.cjs')
|
|
24
32
|
});
|
|
25
33
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/writeContentDeclaration/index.ts"],"sourcesContent":["export * from './
|
|
1
|
+
{"version":3,"sources":["../../../src/writeContentDeclaration/index.ts"],"sourcesContent":["export * from './detectExportedComponentName';\nexport * from './dictionaryStatus';\nexport * from './formatCode';\nexport * from './transformJSFile';\nexport * from './writeContentDeclaration';\nexport * from './writeJSFile';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4CAAc,0CAAd;AACA,4CAAc,+BADd;AAEA,4CAAc,yBAFd;AAGA,4CAAc,8BAHd;AAIA,4CAAc,sCAJd;AAKA,4CAAc,0BALd;","names":[]}
|
|
@@ -26,6 +26,7 @@ var import_fs = require("fs");
|
|
|
26
26
|
var import_promises = require("fs/promises");
|
|
27
27
|
var import_path = require("path");
|
|
28
28
|
var import_getContentDeclarationFileTemplate = require('../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs');
|
|
29
|
+
var import_getFormatFromExtension = require('../utils/getFormatFromExtension.cjs');
|
|
29
30
|
var import_formatCode = require('./formatCode.cjs');
|
|
30
31
|
var import_transformJSFile = require('./transformJSFile.cjs');
|
|
31
32
|
const writeJSFile = async (filePath, dictionary, configuration = (0, import_config.getConfiguration)()) => {
|
|
@@ -33,14 +34,7 @@ const writeJSFile = async (filePath, dictionary, configuration = (0, import_conf
|
|
|
33
34
|
const appLogger = (0, import_config.getAppLogger)(configuration);
|
|
34
35
|
if (!(0, import_fs.existsSync)(filePath)) {
|
|
35
36
|
const fileExtension = (0, import_path.extname)(filePath);
|
|
36
|
-
let format =
|
|
37
|
-
if (fileExtension === ".ts" || fileExtension === ".tsx") {
|
|
38
|
-
format = "ts";
|
|
39
|
-
} else if (fileExtension === ".cjs" || fileExtension === ".cjsx") {
|
|
40
|
-
format = "cjs";
|
|
41
|
-
} else {
|
|
42
|
-
format = "esm";
|
|
43
|
-
}
|
|
37
|
+
let format = (0, import_getFormatFromExtension.getFormatFromExtension)(fileExtension);
|
|
44
38
|
appLogger("File does not exist, creating it", {
|
|
45
39
|
isVerbose: true
|
|
46
40
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"sourcesContent":["import {\n getAppLogger,\n getConfiguration,\n IntlayerConfig,\n logger,\n} from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { existsSync } from 'fs';\nimport { readFile, writeFile } from 'fs/promises';\nimport { extname } from 'path';\nimport { getContentDeclarationFileTemplate } from '../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nimport { formatCode } from './formatCode';\nimport { transformJSFile } from './transformJSFile';\n\n/**\n * Updates a JavaScript/TypeScript file based on the provided JSON instructions.\n * It targets a specific dictionary object within the file (identified by its 'key' property)\n * and updates its 'content' entries. Currently, it focuses on modifying arguments\n * of 't' (translation) function calls.\n */\nexport const writeJSFile = async (\n filePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig = getConfiguration()\n): Promise<void> => {\n const { key, locale, autoFilled } = dictionary;\n const appLogger = getAppLogger(configuration);\n\n // Check if the file exist\n if (!existsSync(filePath)) {\n const fileExtension = extname(filePath)
|
|
1
|
+
{"version":3,"sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"sourcesContent":["import {\n getAppLogger,\n getConfiguration,\n IntlayerConfig,\n logger,\n} from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { existsSync } from 'fs';\nimport { readFile, writeFile } from 'fs/promises';\nimport { extname } from 'path';\nimport { getContentDeclarationFileTemplate } from '../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nimport {\n Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport { formatCode } from './formatCode';\nimport { transformJSFile } from './transformJSFile';\n\n/**\n * Updates a JavaScript/TypeScript file based on the provided JSON instructions.\n * It targets a specific dictionary object within the file (identified by its 'key' property)\n * and updates its 'content' entries. Currently, it focuses on modifying arguments\n * of 't' (translation) function calls.\n */\nexport const writeJSFile = async (\n filePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig = getConfiguration()\n): Promise<void> => {\n const { key, locale, autoFilled } = dictionary;\n const appLogger = getAppLogger(configuration);\n\n // Check if the file exist\n if (!existsSync(filePath)) {\n const fileExtension = extname(filePath) as Extension;\n\n let format = getFormatFromExtension(fileExtension);\n\n appLogger('File does not exist, creating it', {\n isVerbose: true,\n });\n const template = await getContentDeclarationFileTemplate(key, format, {\n locale,\n autoFilled,\n });\n\n await writeFile(filePath, template, 'utf-8');\n }\n\n const fileContent = await readFile(filePath, 'utf-8');\n\n const finalCode = await transformJSFile(fileContent, dictionary);\n\n const formattedCode = await formatCode(filePath, finalCode);\n\n // Write the modified code back to the file\n try {\n await writeFile(filePath, formattedCode, 'utf-8');\n logger(`Successfully updated ${filePath}`, {\n level: 'info',\n isVerbose: true,\n });\n } catch (error) {\n const err = error as Error;\n logger(`Failed to write updated file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKO;AAEP,gBAA2B;AAC3B,sBAAoC;AACpC,kBAAwB;AACxB,+CAAkD;AAClD,oCAGO;AACP,wBAA2B;AAC3B,6BAAgC;AAQzB,MAAM,cAAc,OACzB,UACA,YACA,oBAAgC,gCAAiB,MAC/B;AAClB,QAAM,EAAE,KAAK,QAAQ,WAAW,IAAI;AACpC,QAAM,gBAAY,4BAAa,aAAa;AAG5C,MAAI,KAAC,sBAAW,QAAQ,GAAG;AACzB,UAAM,oBAAgB,qBAAQ,QAAQ;AAEtC,QAAI,aAAS,sDAAuB,aAAa;AAEjD,cAAU,oCAAoC;AAAA,MAC5C,WAAW;AAAA,IACb,CAAC;AACD,UAAM,WAAW,UAAM,4EAAkC,KAAK,QAAQ;AAAA,MACpE;AAAA,MACA;AAAA,IACF,CAAC;AAED,cAAM,2BAAU,UAAU,UAAU,OAAO;AAAA,EAC7C;AAEA,QAAM,cAAc,UAAM,0BAAS,UAAU,OAAO;AAEpD,QAAM,YAAY,UAAM,wCAAgB,aAAa,UAAU;AAE/D,QAAM,gBAAgB,UAAM,8BAAW,UAAU,SAAS;AAG1D,MAAI;AACF,cAAM,2BAAU,UAAU,eAAe,OAAO;AAChD,8BAAO,wBAAwB,QAAQ,IAAI;AAAA,MACzC,OAAO;AAAA,MACP,WAAW;AAAA,IACb,CAAC;AAAA,EACH,SAAS,OAAO;AACd,UAAM,MAAM;AACZ,8BAAO,iCAAiC,QAAQ,IAAI;AAAA,MAClD,OAAO;AAAA,IACT,CAAC;AACD,UAAM,IAAI,MAAM,gCAAgC,QAAQ,KAAK,IAAI,OAAO,EAAE;AAAA,EAC5E;AACF;","names":[]}
|
|
@@ -4,11 +4,20 @@ import { fileURLToPath } from "url";
|
|
|
4
4
|
import { kebabCaseToCamelCase } from "../utils/kebabCaseToCamelCase.mjs";
|
|
5
5
|
const getContentDeclarationFileTemplate = async (key, format, fileParams = {}) => {
|
|
6
6
|
const dirname = __dirname ?? fileURLToPath(import.meta.url);
|
|
7
|
-
let fileTemplate
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
let fileTemplate;
|
|
8
|
+
switch (format) {
|
|
9
|
+
case "ts":
|
|
10
|
+
fileTemplate = "./tsTemplate.txt";
|
|
11
|
+
break;
|
|
12
|
+
case "cjs":
|
|
13
|
+
fileTemplate = "./cjsTemplate.txt";
|
|
14
|
+
break;
|
|
15
|
+
case "json":
|
|
16
|
+
fileTemplate = "./jsonTemplate.txt";
|
|
17
|
+
break;
|
|
18
|
+
default:
|
|
19
|
+
fileTemplate = "./esmTemplate.txt";
|
|
20
|
+
break;
|
|
12
21
|
}
|
|
13
22
|
const fileContent = await readFile(join(dirname, fileTemplate), "utf-8");
|
|
14
23
|
const camelCaseKey = kebabCaseToCamelCase(key);
|
|
@@ -16,18 +25,18 @@ const getContentDeclarationFileTemplate = async (key, format, fileParams = {}) =
|
|
|
16
25
|
const fileParmsString = Object.entries(fileParams).filter(([, value]) => value !== void 0).map(([key2, value]) => {
|
|
17
26
|
if (typeof value === "object") {
|
|
18
27
|
return `
|
|
19
|
-
${key2}: ${JSON.stringify(value)},`;
|
|
28
|
+
'${key2}': ${JSON.stringify(value)},`;
|
|
20
29
|
}
|
|
21
30
|
if (typeof value === "boolean" || typeof value === "number") {
|
|
22
31
|
return `
|
|
23
|
-
${key2}: ${value},`;
|
|
32
|
+
'${key2}': ${value},`;
|
|
24
33
|
}
|
|
25
34
|
if (typeof value === "string") {
|
|
26
35
|
return `
|
|
27
|
-
${key2}: '${value}',`;
|
|
36
|
+
'${key2}': '${value}',`;
|
|
28
37
|
}
|
|
29
38
|
return `
|
|
30
|
-
${key2}: ${value},`;
|
|
39
|
+
'${key2}': ${value},`;
|
|
31
40
|
}).join("");
|
|
32
41
|
return fileContent.replace("{{key}}", key).replaceAll("{{name}}", nonCapitalizedCamelCaseKey).replace("{{fileParams}}", fileParmsString);
|
|
33
42
|
};
|
package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"sourcesContent":["import { readFile } from 'fs/promises';\nimport { join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { kebabCaseToCamelCase } from '../utils/kebabCaseToCamelCase';\n\nexport const getContentDeclarationFileTemplate = async (\n key: string,\n format:
|
|
1
|
+
{"version":3,"sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"sourcesContent":["import { readFile } from 'fs/promises';\nimport { join } from 'path';\nimport { fileURLToPath } from 'url';\nimport type { Format } from '../utils/getFormatFromExtension';\nimport { kebabCaseToCamelCase } from '../utils/kebabCaseToCamelCase';\n\nexport const getContentDeclarationFileTemplate = async (\n key: string,\n format: Format,\n fileParams: Record<string, any> = {}\n) => {\n const dirname = __dirname ?? fileURLToPath(import.meta.url);\n\n let fileTemplate: string;\n\n switch (format) {\n case 'ts':\n fileTemplate = './tsTemplate.txt';\n break;\n case 'cjs':\n fileTemplate = './cjsTemplate.txt';\n break;\n case 'json':\n fileTemplate = './jsonTemplate.txt';\n break;\n default:\n fileTemplate = './esmTemplate.txt';\n break;\n }\n\n const fileContent = await readFile(join(dirname, fileTemplate), 'utf-8');\n const camelCaseKey = kebabCaseToCamelCase(key);\n const nonCapitalizedCamelCaseKey =\n camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);\n\n const fileParmsString = Object.entries(fileParams)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => {\n if (typeof value === 'object') {\n return `\\n'${key}': ${JSON.stringify(value)},`;\n }\n\n if (typeof value === 'boolean' || typeof value === 'number') {\n return `\\n'${key}': ${value},`;\n }\n\n if (typeof value === 'string') {\n return `\\n'${key}': '${value}',`;\n }\n\n return `\\n'${key}': ${value},`;\n })\n .join('');\n\n return fileContent\n .replace('{{key}}', key)\n .replaceAll('{{name}}', nonCapitalizedCamelCaseKey)\n .replace('{{fileParams}}', fileParmsString);\n};\n"],"mappings":"AAAA,SAAS,gBAAgB;AACzB,SAAS,YAAY;AACrB,SAAS,qBAAqB;AAE9B,SAAS,4BAA4B;AAE9B,MAAM,oCAAoC,OAC/C,KACA,QACA,aAAkC,CAAC,MAChC;AACH,QAAM,UAAU,aAAa,cAAc,YAAY,GAAG;AAE1D,MAAI;AAEJ,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,qBAAe;AACf;AAAA,IACF,KAAK;AACH,qBAAe;AACf;AAAA,IACF,KAAK;AACH,qBAAe;AACf;AAAA,IACF;AACE,qBAAe;AACf;AAAA,EACJ;AAEA,QAAM,cAAc,MAAM,SAAS,KAAK,SAAS,YAAY,GAAG,OAAO;AACvE,QAAM,eAAe,qBAAqB,GAAG;AAC7C,QAAM,6BACJ,aAAa,OAAO,CAAC,EAAE,YAAY,IAAI,aAAa,MAAM,CAAC;AAE7D,QAAM,kBAAkB,OAAO,QAAQ,UAAU,EAC9C,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS,EACzC,IAAI,CAAC,CAACA,MAAK,KAAK,MAAM;AACrB,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;AAAA,GAAMA,IAAG,MAAM,KAAK,UAAU,KAAK,CAAC;AAAA,IAC7C;AAEA,QAAI,OAAO,UAAU,aAAa,OAAO,UAAU,UAAU;AAC3D,aAAO;AAAA,GAAMA,IAAG,MAAM,KAAK;AAAA,IAC7B;AAEA,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;AAAA,GAAMA,IAAG,OAAO,KAAK;AAAA,IAC9B;AAEA,WAAO;AAAA,GAAMA,IAAG,MAAM,KAAK;AAAA,EAC7B,CAAC,EACA,KAAK,EAAE;AAEV,SAAO,YACJ,QAAQ,WAAW,GAAG,EACtB,WAAW,YAAY,0BAA0B,EACjD,QAAQ,kBAAkB,eAAe;AAC9C;","names":["key"]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -37,6 +37,10 @@ import { extractErrorMessage } from "./utils/extractErrorMessage.mjs";
|
|
|
37
37
|
import { formatLocale, formatPath } from "./utils/formatter.mjs";
|
|
38
38
|
import { getExtension } from "./utils/getExtention.mjs";
|
|
39
39
|
import { getFileHash } from "./utils/getFileHash.mjs";
|
|
40
|
+
import {
|
|
41
|
+
getExtensionFromFormat,
|
|
42
|
+
getFormatFromExtension
|
|
43
|
+
} from "./utils/getFormatFromExtension.mjs";
|
|
40
44
|
import { kebabCaseToCamelCase } from "./utils/kebabCaseToCamelCase.mjs";
|
|
41
45
|
import { parallelize } from "./utils/parallelize.mjs";
|
|
42
46
|
import { resolveObjectPromises } from "./utils/resolveObjectPromises.mjs";
|
|
@@ -45,7 +49,11 @@ import { runParallel } from "./utils/runParallel.mjs";
|
|
|
45
49
|
import { sortAlphabetically } from "./utils/sortAlphabetically.mjs";
|
|
46
50
|
import { buildAndWatchIntlayer, watch } from "./watcher.mjs";
|
|
47
51
|
import {
|
|
48
|
-
|
|
52
|
+
detectExportedComponentName,
|
|
53
|
+
formatCode,
|
|
54
|
+
transformJSFile,
|
|
55
|
+
writeContentDeclaration,
|
|
56
|
+
writeJSFile
|
|
49
57
|
} from "./writeContentDeclaration/index.mjs";
|
|
50
58
|
export {
|
|
51
59
|
buildAndWatchIntlayer,
|
|
@@ -54,8 +62,10 @@ export {
|
|
|
54
62
|
createDictionaryEntryPoint,
|
|
55
63
|
createModuleAugmentation,
|
|
56
64
|
createTypes,
|
|
65
|
+
detectExportedComponentName,
|
|
57
66
|
extractErrorMessage,
|
|
58
67
|
fetchDistantDictionaries,
|
|
68
|
+
formatCode,
|
|
59
69
|
formatLocale,
|
|
60
70
|
formatPath,
|
|
61
71
|
generateDictionaryListContent,
|
|
@@ -66,7 +76,9 @@ export {
|
|
|
66
76
|
getBuiltUnmergedDictionariesPath,
|
|
67
77
|
getContentDeclarationFileTemplate,
|
|
68
78
|
getExtension,
|
|
79
|
+
getExtensionFromFormat,
|
|
69
80
|
getFileHash,
|
|
81
|
+
getFormatFromExtension,
|
|
70
82
|
handleAdditionalContentDeclarationFile,
|
|
71
83
|
handleContentDeclarationFileChange,
|
|
72
84
|
handleUnlikedContentDeclarationFile,
|
|
@@ -89,7 +101,9 @@ export {
|
|
|
89
101
|
runOnce,
|
|
90
102
|
runParallel,
|
|
91
103
|
sortAlphabetically,
|
|
104
|
+
transformJSFile,
|
|
92
105
|
watch,
|
|
93
|
-
writeContentDeclaration
|
|
106
|
+
writeContentDeclaration,
|
|
107
|
+
writeJSFile
|
|
94
108
|
};
|
|
95
109
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n getBuiltDictionariesPath,\n getBuiltDynamicDictionariesPath,\n getBuiltFetchDictionariesPath,\n getBuiltRemoteDictionariesPath,\n getBuiltUnmergedDictionariesPath,\n} from './createDictionaryEntryPoint';\nexport { createTypes } from './createType';\nexport { createModuleAugmentation } from './createType/createModuleAugmentation';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { isInvalidDictionary } from './filterInvalidDictionaries';\nexport { getContentDeclarationFileTemplate } from './getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nexport { handleAdditionalContentDeclarationFile } from './handleAdditionalContentDeclarationFile';\nexport { handleContentDeclarationFileChange } from './handleContentDeclarationFileChange';\nexport { handleUnlikedContentDeclarationFile } from './handleUnlikedContentDeclarationFile';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n listGitLines,\n type DiffMode,\n type ListGitFilesOptions,\n type ListGitLinesOptions,\n} from './listGitFiles';\nexport {\n loadContentDeclarations,\n loadDictionaries,\n loadLocalDictionaries,\n loadRemoteDictionaries,\n} from './loadDictionaries';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { extractErrorMessage } from './utils/extractErrorMessage';\nexport { formatLocale, formatPath } from './utils/formatter';\nexport { getExtension } from './utils/getExtention';\nexport { getFileHash } from './utils/getFileHash';\nexport { kebabCaseToCamelCase } from './utils/kebabCaseToCamelCase';\nexport { parallelize } from './utils/parallelize';\nexport { resolveObjectPromises } from './utils/resolveObjectPromises';\nexport { runOnce } from './utils/runOnce';\nexport { runParallel, type ParallelHandle } from './utils/runParallel';\nexport { sortAlphabetically } from './utils/sortAlphabetically';\nexport { buildAndWatchIntlayer, watch } from './watcher';\nexport {\n writeContentDeclaration,\n type DictionaryStatus,\n} from './writeContentDeclaration';\n"],"mappings":"AAAA,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,gCAAgC;AACzC,SAAS,2BAA2B;AACpC,SAAS,yCAAyC;AAClD,SAAS,8CAA8C;AACvD,SAAS,0CAA0C;AACnD,SAAS,2CAA2C;AACpD,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,iCAAiC;AAC1C,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C,SAAS,+BAA+B;AACxC,SAAS,2BAA2B;AACpC,SAAS,cAAc,kBAAkB;AACzC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AACtC,SAAS,eAAe;AACxB,SAAS,mBAAwC;AACjD,SAAS,0BAA0B;AACnC,SAAS,uBAAuB,aAAa;AAC7C;AAAA,EACE;AAAA,OAEK;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n getBuiltDictionariesPath,\n getBuiltDynamicDictionariesPath,\n getBuiltFetchDictionariesPath,\n getBuiltRemoteDictionariesPath,\n getBuiltUnmergedDictionariesPath,\n} from './createDictionaryEntryPoint';\nexport { createTypes } from './createType';\nexport { createModuleAugmentation } from './createType/createModuleAugmentation';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { isInvalidDictionary } from './filterInvalidDictionaries';\nexport { getContentDeclarationFileTemplate } from './getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nexport { handleAdditionalContentDeclarationFile } from './handleAdditionalContentDeclarationFile';\nexport { handleContentDeclarationFileChange } from './handleContentDeclarationFileChange';\nexport { handleUnlikedContentDeclarationFile } from './handleUnlikedContentDeclarationFile';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n listGitLines,\n type DiffMode,\n type ListGitFilesOptions,\n type ListGitLinesOptions,\n} from './listGitFiles';\nexport {\n loadContentDeclarations,\n loadDictionaries,\n loadLocalDictionaries,\n loadRemoteDictionaries,\n} from './loadDictionaries';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { extractErrorMessage } from './utils/extractErrorMessage';\nexport { formatLocale, formatPath } from './utils/formatter';\nexport { getExtension } from './utils/getExtention';\nexport { getFileHash } from './utils/getFileHash';\nexport {\n getExtensionFromFormat,\n getFormatFromExtension,\n} from './utils/getFormatFromExtension';\nexport { kebabCaseToCamelCase } from './utils/kebabCaseToCamelCase';\nexport { parallelize } from './utils/parallelize';\nexport { resolveObjectPromises } from './utils/resolveObjectPromises';\nexport { runOnce } from './utils/runOnce';\nexport { runParallel, type ParallelHandle } from './utils/runParallel';\nexport { sortAlphabetically } from './utils/sortAlphabetically';\nexport { buildAndWatchIntlayer, watch } from './watcher';\nexport {\n detectExportedComponentName,\n formatCode,\n transformJSFile,\n writeContentDeclaration,\n writeJSFile,\n type DictionaryStatus,\n} from './writeContentDeclaration';\n"],"mappings":"AAAA,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,gCAAgC;AACzC,SAAS,2BAA2B;AACpC,SAAS,yCAAyC;AAClD,SAAS,8CAA8C;AACvD,SAAS,0CAA0C;AACnD,SAAS,2CAA2C;AACpD,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,iCAAiC;AAC1C,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C,SAAS,+BAA+B;AACxC,SAAS,2BAA2B;AACpC,SAAS,cAAc,kBAAkB;AACzC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AACtC,SAAS,eAAe;AACxB,SAAS,mBAAwC;AACjD,SAAS,0BAA0B;AACnC,SAAS,uBAAuB,aAAa;AAC7C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;","names":[]}
|
|
@@ -85,7 +85,7 @@ const prepareIntlayer = async (configuration = getConfiguration(), projectRequir
|
|
|
85
85
|
[
|
|
86
86
|
"Configuration written",
|
|
87
87
|
colorize(
|
|
88
|
-
`(${configurationWrittenTime -
|
|
88
|
+
`(${configurationWrittenTime - moduleAugmentationBuiltTime}ms)`,
|
|
89
89
|
ANSIColors.GREY_DARK
|
|
90
90
|
)
|
|
91
91
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ANSIColors,\n ESMxCJSRequire,\n type IntlayerConfig,\n colorize,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire,\n clean = false,\n format: ('cjs' | 'esm')[] = ['cjs', 'esm']\n) => {\n const appLogger = getAppLogger(configuration);\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n if (clean) {\n cleanOutputDir(configuration);\n }\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(\n files,\n configuration,\n projectRequire\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length > 0\n ? ` (Total: ${dictionariesLoadedTime - preparationStartMs}ms - Local: ${dictionaries.time.localDictionaries}ms - Remote: ${dictionaries.time.remoteDictionaries}ms)`\n : `(${dictionariesLoadedTime - preparationStartMs}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [...dictionaries.localDictionaries, ...dictionaries.remoteDictionaries],\n configuration,\n format,\n false\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(dictionaries.remoteDictionaries, configuration);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths);\n\n await createDictionaryEntryPoint(configuration);\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime -
|
|
1
|
+
{"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ANSIColors,\n ESMxCJSRequire,\n type IntlayerConfig,\n colorize,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire,\n clean = false,\n format: ('cjs' | 'esm')[] = ['cjs', 'esm']\n) => {\n const appLogger = getAppLogger(configuration);\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n if (clean) {\n cleanOutputDir(configuration);\n }\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(\n files,\n configuration,\n projectRequire\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length > 0\n ? ` (Total: ${dictionariesLoadedTime - preparationStartMs}ms - Local: ${dictionaries.time.localDictionaries}ms - Remote: ${dictionaries.time.remoteDictionaries}ms)`\n : `(${dictionariesLoadedTime - preparationStartMs}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [...dictionaries.localDictionaries, ...dictionaries.remoteDictionaries],\n configuration,\n format,\n false\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(dictionaries.remoteDictionaries, configuration);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths);\n\n await createDictionaryEntryPoint(configuration);\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - moduleAugmentationBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const preparationElapsedMs = Date.now() - preparationStartMs;\n appLogger([`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)], {\n level: 'info',\n isVerbose: true,\n });\n};\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,iBAAiB,gCAAgC,KAAK,EAAE,MAAM,OAAO;AAC5E,SAAS,uBAAuB;AAChC,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,kCAAkC;AAC3C,SAAS,0BAA0B,mBAAmB;AACtD,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AAE5B,MAAM,kBAAkB,OAC7B,gBAAgC,iBAAiB,GACjD,iBAAiB,gBACjB,QAAQ,OACR,SAA4B,CAAC,OAAO,KAAK,MACtC;AACH,QAAM,YAAY,aAAa,aAAa;AAC5C,QAAM,qBAAqB,KAAK,IAAI;AAEpC,YAAU;AAAA,IACR;AAAA,IACA,SAAS,KAAK,YAAY,OAAO,KAAK,WAAW,SAAS;AAAA,EAC5D,CAAC;AAED,MAAI,OAAO;AACT,mBAAe,aAAa;AAAA,EAC9B;AAEA,QAAM,QAAkB,iBAAiB,aAAa;AAEtD,QAAM,eAAe,MAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,yBAAyB,KAAK,IAAI;AAExC;AAAA,IACE;AAAA,MACE;AAAA,MACA;AAAA,QACE;AAAA,UACE,aAAa,mBAAmB,SAAS,IACrC,YAAY,yBAAyB,kBAAkB,eAAe,aAAa,KAAK,iBAAiB,gBAAgB,aAAa,KAAK,kBAAkB,QAC7J,IAAI,yBAAyB,kBAAkB;AAAA,QACrD,EAAE,KAAK,EAAE;AAAA,QACT,WAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA;AAAA,MACE,WAAW;AAAA,IACb;AAAA,EACF;AAGA,QAAM,qBAAqB,MAAM;AAAA,IAC/B,CAAC,GAAG,aAAa,mBAAmB,GAAG,aAAa,kBAAkB;AAAA,IACtE;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAIA,QAAM,sBAAsB,aAAa,oBAAoB,aAAa;AAE1E,QAAM,oBAAoB,OAAO;AAAA,IAC/B,oBAAoB,sBAAsB,CAAC;AAAA,EAC7C,EAAE,IAAI,CAAC,eAAe,WAAW,cAAc;AAE/C,QAAM,YAAY,iBAAiB;AAEnC,QAAM,2BAA2B,aAAa;AAE9C,QAAM,wBAAwB,KAAK,IAAI;AAEvC,YAAU;AAAA,IACR;AAAA,IACA;AAAA,MACE,IAAI,wBAAwB,kBAAkB;AAAA,MAC9C,WAAW;AAAA,IACb;AAAA,EACF,CAAC;AAED,QAAM,yBAAyB,aAAa;AAE5C,QAAM,8BAA8B,KAAK,IAAI;AAE7C;AAAA,IACE;AAAA,MACE;AAAA,MACA;AAAA,QACE,IAAI,8BAA8B,qBAAqB;AAAA,QACvD,WAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA;AAAA,MACE,WAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,mBAAmB,aAAa;AAEtC,QAAM,2BAA2B,KAAK,IAAI;AAE1C;AAAA,IACE;AAAA,MACE;AAAA,MACA;AAAA,QACE,IAAI,2BAA2B,2BAA2B;AAAA,QAC1D,WAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA;AAAA,MACE,WAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,uBAAuB,KAAK,IAAI,IAAI;AAC1C,YAAU,CAAC,QAAQ,SAAS,GAAG,oBAAoB,MAAM,WAAW,KAAK,CAAC,GAAG;AAAA,IAC3E,OAAO;AAAA,IACP,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const getFormatFromExtension = (extension) => {
|
|
2
|
+
switch (extension) {
|
|
3
|
+
case ".ts":
|
|
4
|
+
case ".tsx":
|
|
5
|
+
return "ts";
|
|
6
|
+
case ".cjs":
|
|
7
|
+
case ".cjsx":
|
|
8
|
+
return "cjs";
|
|
9
|
+
case ".mjs":
|
|
10
|
+
return "esm";
|
|
11
|
+
case ".json":
|
|
12
|
+
case ".json5":
|
|
13
|
+
return "json";
|
|
14
|
+
}
|
|
15
|
+
return "esm";
|
|
16
|
+
};
|
|
17
|
+
const getExtensionFromFormat = (format) => {
|
|
18
|
+
switch (format) {
|
|
19
|
+
case "ts":
|
|
20
|
+
return ".ts";
|
|
21
|
+
case "cjs":
|
|
22
|
+
return ".cjs";
|
|
23
|
+
case "json":
|
|
24
|
+
return ".json";
|
|
25
|
+
case "esm":
|
|
26
|
+
return ".mjs";
|
|
27
|
+
}
|
|
28
|
+
return ".mjs";
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
getExtensionFromFormat,
|
|
32
|
+
getFormatFromExtension
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=getFormatFromExtension.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/getFormatFromExtension.ts"],"sourcesContent":["export type Format = 'ts' | 'cjs' | 'esm' | 'json';\nexport type Extension =\n | '.ts'\n | '.tsx'\n | '.js'\n | '.jsx'\n | '.cjs'\n | '.cjsx'\n | '.mjs'\n | '.mjsx'\n | '.json'\n | '.json5';\n\nexport const getFormatFromExtension = (extension: Extension): Format => {\n switch (extension) {\n case '.ts':\n case '.tsx':\n return 'ts';\n case '.cjs':\n case '.cjsx':\n return 'cjs';\n case '.mjs':\n return 'esm';\n case '.json':\n case '.json5':\n return 'json';\n }\n\n return 'esm';\n};\n\nexport const getExtensionFromFormat = (format: Format): Extension => {\n switch (format) {\n case 'ts':\n return '.ts';\n case 'cjs':\n return '.cjs';\n case 'json':\n return '.json';\n case 'esm':\n return '.mjs';\n }\n\n return '.mjs';\n};\n"],"mappings":"AAaO,MAAM,yBAAyB,CAAC,cAAiC;AACtE,UAAQ,WAAW;AAAA,IACjB,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,EACX;AAEA,SAAO;AACT;AAEO,MAAM,yBAAyB,CAAC,WAA8B;AACnE,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const detectExportedComponentName = (fileText) => {
|
|
2
|
+
const defaultEsmFnRegex = /export\s+default\s+function\s+(\w+)/;
|
|
3
|
+
const defaultEsmVarRegex = /export\s+default\s+(\w+)/;
|
|
4
|
+
const cjsDefaultRegex = /module\.exports\s*=\s*(\w+)/;
|
|
5
|
+
const cjsDefaultVarRegex = /exports\.default\s*=\s*(\w+)/;
|
|
6
|
+
const namedExportRegex = /export\s+(?:const|function)\s+(\w+)/g;
|
|
7
|
+
const defaultEsmFnMatch = fileText.match(defaultEsmFnRegex);
|
|
8
|
+
if (defaultEsmFnMatch) {
|
|
9
|
+
return defaultEsmFnMatch[1];
|
|
10
|
+
}
|
|
11
|
+
const defaultEsmVarMatch = fileText.match(defaultEsmVarRegex);
|
|
12
|
+
if (defaultEsmVarMatch) {
|
|
13
|
+
return defaultEsmVarMatch[1];
|
|
14
|
+
}
|
|
15
|
+
const cjsDefaultMatch = fileText.match(cjsDefaultRegex) || fileText.match(cjsDefaultVarRegex);
|
|
16
|
+
if (cjsDefaultMatch) {
|
|
17
|
+
return cjsDefaultMatch[1];
|
|
18
|
+
}
|
|
19
|
+
let match;
|
|
20
|
+
while ((match = namedExportRegex.exec(fileText)) !== null) {
|
|
21
|
+
if (/^[A-Z]/.test(match[1])) {
|
|
22
|
+
return match[1];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
detectExportedComponentName
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=detectExportedComponentName.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/writeContentDeclaration/detectExportedComponentName.ts"],"sourcesContent":["/**\n * Attempt to detect an exported React component name in the file text.\n * Looks for patterns like:\n * - export const MyComponent = ...\n * - export function MyComponent(...)\n * - export default function MyComponent(...)\n */\nexport const detectExportedComponentName = (\n fileText: string\n): string | null => {\n // Added regexes for default ESM, default CJS, and named exports\n const defaultEsmFnRegex = /export\\s+default\\s+function\\s+(\\w+)/;\n const defaultEsmVarRegex = /export\\s+default\\s+(\\w+)/;\n const cjsDefaultRegex = /module\\.exports\\s*=\\s*(\\w+)/;\n const cjsDefaultVarRegex = /exports\\.default\\s*=\\s*(\\w+)/;\n const namedExportRegex = /export\\s+(?:const|function)\\s+(\\w+)/g;\n\n // 1) Check for default ESM function or variable\n const defaultEsmFnMatch = fileText.match(defaultEsmFnRegex);\n if (defaultEsmFnMatch) {\n return defaultEsmFnMatch[1];\n }\n\n const defaultEsmVarMatch = fileText.match(defaultEsmVarRegex);\n if (defaultEsmVarMatch) {\n return defaultEsmVarMatch[1];\n }\n\n // 2) Check for default CJS\n const cjsDefaultMatch =\n fileText.match(cjsDefaultRegex) || fileText.match(cjsDefaultVarRegex);\n if (cjsDefaultMatch) {\n return cjsDefaultMatch[1];\n }\n\n // 3) Otherwise, look for capitalized named exports\n let match;\n while ((match = namedExportRegex.exec(fileText)) !== null) {\n if (/^[A-Z]/.test(match[1])) {\n return match[1];\n }\n }\n\n // If we can’t find it, return null\n return null;\n};\n"],"mappings":"AAOO,MAAM,8BAA8B,CACzC,aACkB;AAElB,QAAM,oBAAoB;AAC1B,QAAM,qBAAqB;AAC3B,QAAM,kBAAkB;AACxB,QAAM,qBAAqB;AAC3B,QAAM,mBAAmB;AAGzB,QAAM,oBAAoB,SAAS,MAAM,iBAAiB;AAC1D,MAAI,mBAAmB;AACrB,WAAO,kBAAkB,CAAC;AAAA,EAC5B;AAEA,QAAM,qBAAqB,SAAS,MAAM,kBAAkB;AAC5D,MAAI,oBAAoB;AACtB,WAAO,mBAAmB,CAAC;AAAA,EAC7B;AAGA,QAAM,kBACJ,SAAS,MAAM,eAAe,KAAK,SAAS,MAAM,kBAAkB;AACtE,MAAI,iBAAiB;AACnB,WAAO,gBAAgB,CAAC;AAAA,EAC1B;AAGA,MAAI;AACJ,UAAQ,QAAQ,iBAAiB,KAAK,QAAQ,OAAO,MAAM;AACzD,QAAI,SAAS,KAAK,MAAM,CAAC,CAAC,GAAG;AAC3B,aAAO,MAAM,CAAC;AAAA,IAChB;AAAA,EACF;AAGA,SAAO;AACT;","names":[]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./detectExportedComponentName.mjs";
|
|
2
2
|
export * from "./dictionaryStatus.mjs";
|
|
3
|
+
export * from "./formatCode.mjs";
|
|
4
|
+
export * from "./transformJSFile.mjs";
|
|
5
|
+
export * from "./writeContentDeclaration.mjs";
|
|
6
|
+
export * from "./writeJSFile.mjs";
|
|
3
7
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/writeContentDeclaration/index.ts"],"sourcesContent":["export * from './
|
|
1
|
+
{"version":3,"sources":["../../../src/writeContentDeclaration/index.ts"],"sourcesContent":["export * from './detectExportedComponentName';\nexport * from './dictionaryStatus';\nexport * from './formatCode';\nexport * from './transformJSFile';\nexport * from './writeContentDeclaration';\nexport * from './writeJSFile';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -7,6 +7,9 @@ import { existsSync } from "fs";
|
|
|
7
7
|
import { readFile, writeFile } from "fs/promises";
|
|
8
8
|
import { extname } from "path";
|
|
9
9
|
import { getContentDeclarationFileTemplate } from "../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";
|
|
10
|
+
import {
|
|
11
|
+
getFormatFromExtension
|
|
12
|
+
} from "../utils/getFormatFromExtension.mjs";
|
|
10
13
|
import { formatCode } from "./formatCode.mjs";
|
|
11
14
|
import { transformJSFile } from "./transformJSFile.mjs";
|
|
12
15
|
const writeJSFile = async (filePath, dictionary, configuration = getConfiguration()) => {
|
|
@@ -14,14 +17,7 @@ const writeJSFile = async (filePath, dictionary, configuration = getConfiguratio
|
|
|
14
17
|
const appLogger = getAppLogger(configuration);
|
|
15
18
|
if (!existsSync(filePath)) {
|
|
16
19
|
const fileExtension = extname(filePath);
|
|
17
|
-
let format =
|
|
18
|
-
if (fileExtension === ".ts" || fileExtension === ".tsx") {
|
|
19
|
-
format = "ts";
|
|
20
|
-
} else if (fileExtension === ".cjs" || fileExtension === ".cjsx") {
|
|
21
|
-
format = "cjs";
|
|
22
|
-
} else {
|
|
23
|
-
format = "esm";
|
|
24
|
-
}
|
|
20
|
+
let format = getFormatFromExtension(fileExtension);
|
|
25
21
|
appLogger("File does not exist, creating it", {
|
|
26
22
|
isVerbose: true
|
|
27
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"sourcesContent":["import {\n getAppLogger,\n getConfiguration,\n IntlayerConfig,\n logger,\n} from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { existsSync } from 'fs';\nimport { readFile, writeFile } from 'fs/promises';\nimport { extname } from 'path';\nimport { getContentDeclarationFileTemplate } from '../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nimport { formatCode } from './formatCode';\nimport { transformJSFile } from './transformJSFile';\n\n/**\n * Updates a JavaScript/TypeScript file based on the provided JSON instructions.\n * It targets a specific dictionary object within the file (identified by its 'key' property)\n * and updates its 'content' entries. Currently, it focuses on modifying arguments\n * of 't' (translation) function calls.\n */\nexport const writeJSFile = async (\n filePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig = getConfiguration()\n): Promise<void> => {\n const { key, locale, autoFilled } = dictionary;\n const appLogger = getAppLogger(configuration);\n\n // Check if the file exist\n if (!existsSync(filePath)) {\n const fileExtension = extname(filePath)
|
|
1
|
+
{"version":3,"sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"sourcesContent":["import {\n getAppLogger,\n getConfiguration,\n IntlayerConfig,\n logger,\n} from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { existsSync } from 'fs';\nimport { readFile, writeFile } from 'fs/promises';\nimport { extname } from 'path';\nimport { getContentDeclarationFileTemplate } from '../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nimport {\n Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport { formatCode } from './formatCode';\nimport { transformJSFile } from './transformJSFile';\n\n/**\n * Updates a JavaScript/TypeScript file based on the provided JSON instructions.\n * It targets a specific dictionary object within the file (identified by its 'key' property)\n * and updates its 'content' entries. Currently, it focuses on modifying arguments\n * of 't' (translation) function calls.\n */\nexport const writeJSFile = async (\n filePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig = getConfiguration()\n): Promise<void> => {\n const { key, locale, autoFilled } = dictionary;\n const appLogger = getAppLogger(configuration);\n\n // Check if the file exist\n if (!existsSync(filePath)) {\n const fileExtension = extname(filePath) as Extension;\n\n let format = getFormatFromExtension(fileExtension);\n\n appLogger('File does not exist, creating it', {\n isVerbose: true,\n });\n const template = await getContentDeclarationFileTemplate(key, format, {\n locale,\n autoFilled,\n });\n\n await writeFile(filePath, template, 'utf-8');\n }\n\n const fileContent = await readFile(filePath, 'utf-8');\n\n const finalCode = await transformJSFile(fileContent, dictionary);\n\n const formattedCode = await formatCode(filePath, finalCode);\n\n // Write the modified code back to the file\n try {\n await writeFile(filePath, formattedCode, 'utf-8');\n logger(`Successfully updated ${filePath}`, {\n level: 'info',\n isVerbose: true,\n });\n } catch (error) {\n const err = error as Error;\n logger(`Failed to write updated file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);\n }\n};\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAEP,SAAS,kBAAkB;AAC3B,SAAS,UAAU,iBAAiB;AACpC,SAAS,eAAe;AACxB,SAAS,yCAAyC;AAClD;AAAA,EAEE;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAQzB,MAAM,cAAc,OACzB,UACA,YACA,gBAAgC,iBAAiB,MAC/B;AAClB,QAAM,EAAE,KAAK,QAAQ,WAAW,IAAI;AACpC,QAAM,YAAY,aAAa,aAAa;AAG5C,MAAI,CAAC,WAAW,QAAQ,GAAG;AACzB,UAAM,gBAAgB,QAAQ,QAAQ;AAEtC,QAAI,SAAS,uBAAuB,aAAa;AAEjD,cAAU,oCAAoC;AAAA,MAC5C,WAAW;AAAA,IACb,CAAC;AACD,UAAM,WAAW,MAAM,kCAAkC,KAAK,QAAQ;AAAA,MACpE;AAAA,MACA;AAAA,IACF,CAAC;AAED,UAAM,UAAU,UAAU,UAAU,OAAO;AAAA,EAC7C;AAEA,QAAM,cAAc,MAAM,SAAS,UAAU,OAAO;AAEpD,QAAM,YAAY,MAAM,gBAAgB,aAAa,UAAU;AAE/D,QAAM,gBAAgB,MAAM,WAAW,UAAU,SAAS;AAG1D,MAAI;AACF,UAAM,UAAU,UAAU,eAAe,OAAO;AAChD,WAAO,wBAAwB,QAAQ,IAAI;AAAA,MACzC,OAAO;AAAA,MACP,WAAW;AAAA,IACb,CAAC;AAAA,EACH,SAAS,OAAO;AACd,UAAM,MAAM;AACZ,WAAO,iCAAiC,QAAQ,IAAI;AAAA,MAClD,OAAO;AAAA,IACT,CAAC;AACD,UAAM,IAAI,MAAM,gCAAgC,QAAQ,KAAK,IAAI,OAAO,EAAE;AAAA,EAC5E;AACF;","names":[]}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Format } from '../utils/getFormatFromExtension';
|
|
2
|
+
export declare const getContentDeclarationFileTemplate: (key: string, format: Format, fileParams?: Record<string, any>) => Promise<string>;
|
|
2
3
|
//# sourceMappingURL=getContentDeclarationFileTemplate.d.ts.map
|
package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getContentDeclarationFileTemplate.d.ts","sourceRoot":"","sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getContentDeclarationFileTemplate.d.ts","sourceRoot":"","sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAG9D,eAAO,MAAM,iCAAiC,GAC5C,KAAK,MAAM,EACX,QAAQ,MAAM,EACd,aAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,oBAiDrC,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export { extractErrorMessage } from './utils/extractErrorMessage';
|
|
|
21
21
|
export { formatLocale, formatPath } from './utils/formatter';
|
|
22
22
|
export { getExtension } from './utils/getExtention';
|
|
23
23
|
export { getFileHash } from './utils/getFileHash';
|
|
24
|
+
export { getExtensionFromFormat, getFormatFromExtension, } from './utils/getFormatFromExtension';
|
|
24
25
|
export { kebabCaseToCamelCase } from './utils/kebabCaseToCamelCase';
|
|
25
26
|
export { parallelize } from './utils/parallelize';
|
|
26
27
|
export { resolveObjectPromises } from './utils/resolveObjectPromises';
|
|
@@ -28,5 +29,5 @@ export { runOnce } from './utils/runOnce';
|
|
|
28
29
|
export { runParallel, type ParallelHandle } from './utils/runParallel';
|
|
29
30
|
export { sortAlphabetically } from './utils/sortAlphabetically';
|
|
30
31
|
export { buildAndWatchIntlayer, watch } from './watcher';
|
|
31
|
-
export { writeContentDeclaration, type DictionaryStatus, } from './writeContentDeclaration';
|
|
32
|
+
export { detectExportedComponentName, formatCode, transformJSFile, writeContentDeclaration, writeJSFile, type DictionaryStatus, } from './writeContentDeclaration';
|
|
32
33
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,wBAAwB,EACxB,+BAA+B,EAC/B,6BAA6B,EAC7B,8BAA8B,EAC9B,gCAAgC,GACjC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,iCAAiC,EAAE,MAAM,uEAAuE,CAAC;AAC1H,OAAO,EAAE,sCAAsC,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,GACtB,MAAM,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,wBAAwB,EACxB,+BAA+B,EAC/B,6BAA6B,EAC7B,8BAA8B,EAC9B,gCAAgC,GACjC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,iCAAiC,EAAE,MAAM,uEAAuE,CAAC;AAC1H,OAAO,EAAE,sCAAsC,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EACL,2BAA2B,EAC3B,UAAU,EACV,eAAe,EACf,uBAAuB,EACvB,WAAW,EACX,KAAK,gBAAgB,GACtB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type Format = 'ts' | 'cjs' | 'esm' | 'json';
|
|
2
|
+
export type Extension = '.ts' | '.tsx' | '.js' | '.jsx' | '.cjs' | '.cjsx' | '.mjs' | '.mjsx' | '.json' | '.json5';
|
|
3
|
+
export declare const getFormatFromExtension: (extension: Extension) => Format;
|
|
4
|
+
export declare const getExtensionFromFormat: (format: Format) => Extension;
|
|
5
|
+
//# sourceMappingURL=getFormatFromExtension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFormatFromExtension.d.ts","sourceRoot":"","sources":["../../../src/utils/getFormatFromExtension.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AACnD,MAAM,MAAM,SAAS,GACjB,KAAK,GACL,MAAM,GACN,KAAK,GACL,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,OAAO,GACP,OAAO,GACP,QAAQ,CAAC;AAEb,eAAO,MAAM,sBAAsB,GAAI,WAAW,SAAS,KAAG,MAgB7D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,QAAQ,MAAM,KAAG,SAavD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attempt to detect an exported React component name in the file text.
|
|
3
|
+
* Looks for patterns like:
|
|
4
|
+
* - export const MyComponent = ...
|
|
5
|
+
* - export function MyComponent(...)
|
|
6
|
+
* - export default function MyComponent(...)
|
|
7
|
+
*/
|
|
8
|
+
export declare const detectExportedComponentName: (fileText: string) => string | null;
|
|
9
|
+
//# sourceMappingURL=detectExportedComponentName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectExportedComponentName.d.ts","sourceRoot":"","sources":["../../../src/writeContentDeclaration/detectExportedComponentName.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GACtC,UAAU,MAAM,KACf,MAAM,GAAG,IAoCX,CAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './detectExportedComponentName';
|
|
2
2
|
export * from './dictionaryStatus';
|
|
3
|
+
export * from './formatCode';
|
|
4
|
+
export * from './transformJSFile';
|
|
5
|
+
export * from './writeContentDeclaration';
|
|
6
|
+
export * from './writeJSFile';
|
|
3
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/writeContentDeclaration/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/writeContentDeclaration/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeJSFile.d.ts","sourceRoot":"","sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"writeJSFile.d.ts","sourceRoot":"","sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAY5C;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,MAAM,EAChB,YAAY,UAAU,EACtB,gBAAe,cAAmC,KACjD,OAAO,CAAC,IAAI,CAyCd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.4",
|
|
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": [
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"fast-glob": "^3.3.3",
|
|
66
66
|
"simple-git": "^3.28.0",
|
|
67
67
|
"ts-morph": "^27.0.0",
|
|
68
|
-
"@intlayer/api": "6.1.
|
|
69
|
-
"@intlayer/
|
|
70
|
-
"@intlayer/
|
|
71
|
-
"@intlayer/dictionaries-entry": "6.1.
|
|
72
|
-
"@intlayer/unmerged-dictionaries-entry": "6.1.
|
|
73
|
-
"@intlayer/
|
|
68
|
+
"@intlayer/api": "6.1.4",
|
|
69
|
+
"@intlayer/core": "6.1.4",
|
|
70
|
+
"@intlayer/dictionaries-entry": "6.1.4",
|
|
71
|
+
"@intlayer/remote-dictionaries-entry": "6.1.4",
|
|
72
|
+
"@intlayer/unmerged-dictionaries-entry": "6.1.4",
|
|
73
|
+
"@intlayer/config": "6.1.4"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@changesets/cli": "2.29.7",
|
|
@@ -85,21 +85,21 @@
|
|
|
85
85
|
"tsup": "^8.5.0",
|
|
86
86
|
"typescript": "^5.9.2",
|
|
87
87
|
"vitest": "^3.2.4",
|
|
88
|
-
"@utils/eslint-config": "1.0.4",
|
|
89
88
|
"@utils/ts-config": "1.0.4",
|
|
89
|
+
"@utils/eslint-config": "1.0.4",
|
|
90
90
|
"@utils/ts-config-types": "1.0.4",
|
|
91
91
|
"@utils/tsup-config": "1.0.4"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"fast-glob": "^3.3.3",
|
|
95
95
|
"react": ">=16.0.0",
|
|
96
|
-
"@intlayer/api": "6.1.
|
|
97
|
-
"@intlayer/
|
|
98
|
-
"@intlayer/
|
|
99
|
-
"@intlayer/remote-dictionaries-entry": "6.1.
|
|
100
|
-
"
|
|
101
|
-
"intlayer": "6.1.
|
|
102
|
-
"@intlayer/
|
|
96
|
+
"@intlayer/api": "6.1.4",
|
|
97
|
+
"@intlayer/core": "6.1.4",
|
|
98
|
+
"@intlayer/dictionaries-entry": "6.1.4",
|
|
99
|
+
"@intlayer/remote-dictionaries-entry": "6.1.4",
|
|
100
|
+
"intlayer": "6.1.4",
|
|
101
|
+
"@intlayer/unmerged-dictionaries-entry": "6.1.4",
|
|
102
|
+
"@intlayer/config": "6.1.4"
|
|
103
103
|
},
|
|
104
104
|
"engines": {
|
|
105
105
|
"node": ">=14.18"
|