@intlayer/chokidar 5.5.10 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/cleanOutputDir.cjs +4 -0
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/fetchDistantDictionaries.cjs +5 -1
- package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/fetchDistantDictionaryKeys.cjs +5 -1
- package/dist/cjs/fetchDistantDictionaryKeys.cjs.map +1 -1
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/listGitFiles.cjs +69 -2
- package/dist/cjs/listGitFiles.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +4 -2
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.cjs +4 -31
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.cjs.map +1 -1
- package/dist/cjs/utils/resolveObjectPromises.cjs +51 -0
- package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -0
- package/dist/cjs/utils/resolveObjectPromises.test.cjs +107 -0
- package/dist/cjs/utils/resolveObjectPromises.test.cjs.map +1 -0
- package/dist/esm/cleanOutputDir.mjs +4 -0
- package/dist/esm/cleanOutputDir.mjs.map +1 -1
- package/dist/esm/fetchDistantDictionaries.mjs +5 -1
- package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/fetchDistantDictionaryKeys.mjs +5 -1
- package/dist/esm/fetchDistantDictionaryKeys.mjs.map +1 -1
- package/dist/esm/index.mjs +3 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/listGitFiles.mjs +67 -1
- package/dist/esm/listGitFiles.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +4 -2
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.mjs +3 -29
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.mjs.map +1 -1
- package/dist/esm/utils/resolveObjectPromises.mjs +27 -0
- package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -0
- package/dist/esm/utils/resolveObjectPromises.test.mjs +106 -0
- package/dist/esm/utils/resolveObjectPromises.test.mjs.map +1 -0
- package/dist/types/cleanOutputDir.d.ts.map +1 -1
- package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/fetchDistantDictionaryKeys.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/listGitFiles.d.ts +6 -0
- package/dist/types/listGitFiles.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts +1 -1
- package/dist/types/prepareIntlayer.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.d.ts +0 -5
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.d.ts.map +1 -1
- package/dist/types/utils/resolveObjectPromises.d.ts +6 -0
- package/dist/types/utils/resolveObjectPromises.d.ts.map +1 -0
- package/dist/types/utils/resolveObjectPromises.test.d.ts +2 -0
- package/dist/types/utils/resolveObjectPromises.test.d.ts.map +1 -0
- package/package.json +17 -15
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
<a href="https://www.facebook.com/intlayer" target="blank"><img align="center"
|
|
34
34
|
src="https://img.shields.io/badge/facebook-4267B2.svg?style=for-the-badge&logo=facebook&logoColor=white"
|
|
35
35
|
alt="Intlayer Facebook" height="30"/></a>
|
|
36
|
-
<a href="https://www.instagram.com/
|
|
36
|
+
<a href="https://www.instagram.com/intlayer/" target="blank"><img align="center"
|
|
37
37
|
src="https://img.shields.io/badge/instagram-%23E4405F.svg?style=for-the-badge&logo=Instagram&logoColor=white"
|
|
38
38
|
alt="Intlayer Instagram" height="30"/></a>
|
|
39
39
|
<a href="https://x.com/Intlayer183096" target="blank"><img align="center"
|
|
@@ -27,6 +27,7 @@ const cleanOutputDir = (configuration = (0, import_config.getConfiguration)()) =
|
|
|
27
27
|
const {
|
|
28
28
|
dictionariesDir,
|
|
29
29
|
unmergedDictionariesDir,
|
|
30
|
+
dynamicDictionariesDir,
|
|
30
31
|
mainDir,
|
|
31
32
|
typesDir,
|
|
32
33
|
configDir
|
|
@@ -38,6 +39,9 @@ const cleanOutputDir = (configuration = (0, import_config.getConfiguration)()) =
|
|
|
38
39
|
if ((0, import_fs.existsSync)(unmergedDictionariesDir)) {
|
|
39
40
|
(0, import_fs.rmSync)(unmergedDictionariesDir, { recursive: true });
|
|
40
41
|
}
|
|
42
|
+
if ((0, import_fs.existsSync)(dynamicDictionariesDir)) {
|
|
43
|
+
(0, import_fs.rmSync)(dynamicDictionariesDir, { recursive: true });
|
|
44
|
+
}
|
|
41
45
|
if ((0, import_fs.existsSync)(mainDir)) {
|
|
42
46
|
(0, import_fs.rmSync)(mainDir, { recursive: true });
|
|
43
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { getAppLogger, getConfiguration } from '@intlayer/config';\nimport { existsSync, rmSync } from 'fs';\n\nexport const cleanOutputDir = (configuration = getConfiguration()) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n } = configuration.content;\n\n const appLogger = getAppLogger(configuration);\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n if (existsSync(unmergedDictionariesDir)) {\n // Delete the unmerged dictionaries directory\n rmSync(unmergedDictionariesDir, { recursive: true });\n }\n\n // Delete the main directory\n if (existsSync(mainDir)) {\n rmSync(mainDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n // Delete the config directory\n if (existsSync(configDir)) {\n rmSync(configDir, { recursive: true });\n }\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,gBAAmC;AAE5B,MAAM,iBAAiB,CAAC,oBAAgB,gCAAiB,MAAM;AACpE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,cAAc;AAElB,QAAM,gBAAY,4BAAa,aAAa;AAE5C,UAAI,sBAAW,eAAe,GAAG;AAE/B,0BAAO,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAAA,EAC7C;AAEA,UAAI,sBAAW,uBAAuB,GAAG;AAEvC,0BAAO,yBAAyB,EAAE,WAAW,KAAK,CAAC;AAAA,EACrD;AAGA,UAAI,sBAAW,OAAO,GAAG;AACvB,0BAAO,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACrC;AAGA,UAAI,sBAAW,QAAQ,GAAG;AACxB,0BAAO,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACtC;AAGA,UAAI,sBAAW,SAAS,GAAG;AACzB,0BAAO,WAAW,EAAE,WAAW,KAAK,CAAC;AAAA,EACvC;AAEA,YAAU,4BAA4B;AAAA,IACpC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { getAppLogger, getConfiguration } from '@intlayer/config';\nimport { existsSync, rmSync } from 'fs';\n\nexport const cleanOutputDir = (configuration = getConfiguration()) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n } = configuration.content;\n\n const appLogger = getAppLogger(configuration);\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n if (existsSync(unmergedDictionariesDir)) {\n // Delete the unmerged dictionaries directory\n rmSync(unmergedDictionariesDir, { recursive: true });\n }\n\n if (existsSync(dynamicDictionariesDir)) {\n // Delete the dynamic dictionaries directory\n rmSync(dynamicDictionariesDir, { recursive: true });\n }\n\n // Delete the main directory\n if (existsSync(mainDir)) {\n rmSync(mainDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n // Delete the config directory\n if (existsSync(configDir)) {\n rmSync(configDir, { recursive: true });\n }\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,gBAAmC;AAE5B,MAAM,iBAAiB,CAAC,oBAAgB,gCAAiB,MAAM;AACpE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,cAAc;AAElB,QAAM,gBAAY,4BAAa,aAAa;AAE5C,UAAI,sBAAW,eAAe,GAAG;AAE/B,0BAAO,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAAA,EAC7C;AAEA,UAAI,sBAAW,uBAAuB,GAAG;AAEvC,0BAAO,yBAAyB,EAAE,WAAW,KAAK,CAAC;AAAA,EACrD;AAEA,UAAI,sBAAW,sBAAsB,GAAG;AAEtC,0BAAO,wBAAwB,EAAE,WAAW,KAAK,CAAC;AAAA,EACpD;AAGA,UAAI,sBAAW,OAAO,GAAG;AACvB,0BAAO,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACrC;AAGA,UAAI,sBAAW,QAAQ,GAAG;AACxB,0BAAO,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACtC;AAGA,UAAI,sBAAW,SAAS,GAAG;AACzB,0BAAO,WAAW,EAAE,WAAW,KAAK,CAAC;AAAA,EACvC;AAEA,YAAU,4BAA4B;AAAA,IACpC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -64,7 +64,11 @@ const fetchDistantDictionaries = async (options) => {
|
|
|
64
64
|
dictionaryKey,
|
|
65
65
|
void 0,
|
|
66
66
|
{
|
|
67
|
-
|
|
67
|
+
...oAuth2AccessToken && {
|
|
68
|
+
headers: {
|
|
69
|
+
Authorization: `Bearer ${oAuth2AccessToken}`
|
|
70
|
+
}
|
|
71
|
+
}
|
|
68
72
|
}
|
|
69
73
|
);
|
|
70
74
|
const distantDictionary = getDictionaryResult.data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getAuthAPI, getDictionaryAPI } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration } from '@intlayer/config';\nimport pLimit from 'p-limit';\nimport { logger } from './log';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const { clientId, clientSecret } = config.editor;\n const authAPI = getAuthAPI(undefined, config);\n const dictionaryAPI = getDictionaryAPI(undefined, config);\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n const distantDictionariesKeys = options.dictionaryKeys;\n\n // Process dictionaries in parallel with a concurrency limit\n const limit = pLimit(5); // Limit the number of concurrent requests\n\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n logger.updateStatus([\n {\n dictionaryKey,\n type: 'distant',\n status: { status: 'fetching' },\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult = await dictionaryAPI.getDictionary(\n dictionaryKey,\n undefined,\n {\n headers: {
|
|
1
|
+
{"version":3,"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getAuthAPI, getDictionaryAPI } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration } from '@intlayer/config';\nimport pLimit from 'p-limit';\nimport { logger } from './log';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const { clientId, clientSecret } = config.editor;\n const authAPI = getAuthAPI(undefined, config);\n const dictionaryAPI = getDictionaryAPI(undefined, config);\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n const distantDictionariesKeys = options.dictionaryKeys;\n\n // Process dictionaries in parallel with a concurrency limit\n const limit = pLimit(5); // Limit the number of concurrent requests\n\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n logger.updateStatus([\n {\n dictionaryKey,\n type: 'distant',\n status: { status: 'fetching' },\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult = await dictionaryAPI.getDictionary(\n dictionaryKey,\n undefined,\n {\n ...(oAuth2AccessToken && {\n headers: {\n Authorization: `Bearer ${oAuth2AccessToken}`,\n },\n }),\n }\n );\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n logger.updateStatus([\n { dictionaryKey, type: 'distant', status: { status: 'imported' } },\n ]);\n\n return distantDictionary;\n } catch (error) {\n logger.updateStatus([\n {\n dictionaryKey,\n type: 'distant',\n status: {\n status: 'error',\n error: error as Error,\n errorMessage: `${options?.logPrefix ?? ''}Error fetching dictionary ${dictionaryKey}: ${error}`,\n },\n },\n ]);\n return undefined;\n }\n };\n\n const fetchPromises = distantDictionariesKeys.map((dictionaryKey) =>\n limit(async () => await processDictionary(dictionaryKey))\n );\n\n const result = await Promise.all(fetchPromises);\n\n // Output any error messages\n const statuses = logger.getStatuses();\n for (const statusObj of statuses) {\n const currentState = statusObj.state.find((s) => s.type === 'distant');\n if (currentState && currentState.errorMessage) {\n appLogger(currentState.errorMessage, { level: 'error' });\n }\n }\n\n // Remove undefined values\n const filteredResult = result.filter(\n (dict): dict is DictionaryAPI => dict !== undefined\n );\n\n return filteredResult;\n } catch (error) {\n appLogger(error, { level: 'error' });\n return [];\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA6C;AAG7C,oBAA+C;AAC/C,qBAAmB;AACnB,iBAAuB;AAWhB,MAAM,2BAA2B,OACtC,YAC6B;AAC7B,QAAM,aAAS,gCAAiB;AAChC,QAAM,gBAAY,4BAAa,MAAM;AACrC,MAAI;AACF,UAAM,EAAE,UAAU,aAAa,IAAI,OAAO;AAC1C,UAAM,cAAU,uBAAW,QAAW,MAAM;AAC5C,UAAM,oBAAgB,6BAAiB,QAAW,MAAM;AAExD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,oBAAoB,MAAM,QAAQ,qBAAqB;AAE7D,UAAM,oBA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BAAgB,aAAa,cAAc;AAC7C,kBAAU,aAAa,cAAc,EAAE,OAAO,QAAQ,CAAC;AAAA,MACzD;AAAA,IACF;AAGA,UAAM,iBAAiB,OAAO;AAAA,MAC5B,CAAC,SAAgC,SAAS;AAAA,IAC5C;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,cAAU,OAAO,EAAE,OAAO,QAAQ,CAAC;AACnC,WAAO,CAAC;AAAA,EACV;AACF;","names":["pLimit"]}
|
|
@@ -34,7 +34,11 @@ const fetchDistantDictionaryKeys = async (configuration = (0, import_config.getC
|
|
|
34
34
|
const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();
|
|
35
35
|
const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
|
|
36
36
|
const getDictionariesKeysResult = await intlayerAPI.dictionary.getDictionariesKeys({
|
|
37
|
-
|
|
37
|
+
...oAuth2AccessToken && {
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: `Bearer ${oAuth2AccessToken}`
|
|
40
|
+
}
|
|
41
|
+
}
|
|
38
42
|
});
|
|
39
43
|
if (!getDictionariesKeysResult.data) {
|
|
40
44
|
throw new Error("No distant dictionaries found");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fetchDistantDictionaryKeys.ts"],"sourcesContent":["import { getIntlayerAPI } from '@intlayer/api';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config';\n\nexport const fetchDistantDictionaryKeys = async (\n configuration: IntlayerConfig = getConfiguration()\n): Promise<string[]> => {\n const { clientId, clientSecret } = configuration.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const intlayerAPI = getIntlayerAPI(undefined, configuration);\n\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Get the list of dictionary keys\n const getDictionariesKeysResult =\n await intlayerAPI.dictionary.getDictionariesKeys({\n headers: {
|
|
1
|
+
{"version":3,"sources":["../../src/fetchDistantDictionaryKeys.ts"],"sourcesContent":["import { getIntlayerAPI } from '@intlayer/api';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config';\n\nexport const fetchDistantDictionaryKeys = async (\n configuration: IntlayerConfig = getConfiguration()\n): Promise<string[]> => {\n const { clientId, clientSecret } = configuration.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const intlayerAPI = getIntlayerAPI(undefined, configuration);\n\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Get the list of dictionary keys\n const getDictionariesKeysResult =\n await intlayerAPI.dictionary.getDictionariesKeys({\n ...(oAuth2AccessToken && {\n headers: {\n Authorization: `Bearer ${oAuth2AccessToken}`,\n },\n }),\n });\n\n if (!getDictionariesKeysResult.data) {\n throw new Error('No distant dictionaries found');\n }\n\n const distantDictionariesKeys: string[] = getDictionariesKeysResult.data;\n\n // Apply any filtering if needed\n return distantDictionariesKeys;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA+B;AAC/B,oBAAsD;AAE/C,MAAM,6BAA6B,OACxC,oBAAgC,gCAAiB,MAC3B;AACtB,QAAM,EAAE,UAAU,aAAa,IAAI,cAAc;AAEjD,MAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,kBAAc,2BAAe,QAAW,aAAa;AAE3D,QAAM,oBAAoB,MAAM,YAAY,KAAK,qBAAqB;AAEtE,QAAM,oBAAoB,kBAAkB,MAAM;AAGlD,QAAM,4BACJ,MAAM,YAAY,WAAW,oBAAoB;AAAA,IAC/C,GAAI,qBAAqB;AAAA,MACvB,SAAS;AAAA,QACP,eAAe,UAAU,iBAAiB;AAAA,MAC5C;AAAA,IACF;AAAA,EACF,CAAC;AAEH,MAAI,CAAC,0BAA0B,MAAM;AACnC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAEA,QAAM,0BAAoC,0BAA0B;AAGpE,SAAO;AACT;","names":[]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
handleContentDeclarationFileChange: () => import_watcher.handleContentDeclarationFileChange,
|
|
36
36
|
listDictionaries: () => import_listDictionariesPath.listDictionaries,
|
|
37
37
|
listGitFiles: () => import_listGitFiles.listGitFiles,
|
|
38
|
+
listGitLines: () => import_listGitFiles.listGitLines,
|
|
38
39
|
loadDictionaries: () => import_loadDictionaries.loadDictionaries,
|
|
39
40
|
loadDistantDictionaries: () => import_loadDictionaries.loadDistantDictionaries,
|
|
40
41
|
loadLocalDictionaries: () => import_loadDictionaries.loadLocalDictionaries,
|
|
@@ -87,6 +88,7 @@ var import_writeContentDeclaration = require('./writeContentDeclaration/index.cj
|
|
|
87
88
|
handleContentDeclarationFileChange,
|
|
88
89
|
listDictionaries,
|
|
89
90
|
listGitFiles,
|
|
91
|
+
listGitLines,
|
|
90
92
|
loadDictionaries,
|
|
91
93
|
loadDistantDictionaries,
|
|
92
94
|
loadLocalDictionaries,
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { checkDictionaryChanges } from './checkDictionaryChanges';\nexport {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';\nexport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nexport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\nexport { getFilteredLocalesContent } from './getFilteredLocalesContent';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n type DiffMode,\n type ListGitFilesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadDistantDictionaries,\n loadLocalDictionaries,\n} from './loadDictionaries/index';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n} from './transpiler/dictionary_to_main';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { getFileHash } from './utils';\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,oCAAuC;AACvC,qBAKO;AACP,4BAA+B;AAC/B,sCAAyC;AACzC,wCAA2C;AAC3C,sCAAyC;AACzC,8CAAiD;AACjD,uCAA0C;AAC1C,kCAAiC;AACjC,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { checkDictionaryChanges } from './checkDictionaryChanges';\nexport {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';\nexport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nexport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\nexport { getFilteredLocalesContent } from './getFilteredLocalesContent';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n listGitLines,\n type DiffMode,\n type ListGitFilesOptions,\n type ListGitLinesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadDistantDictionaries,\n loadLocalDictionaries,\n} from './loadDictionaries/index';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n} from './transpiler/dictionary_to_main';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { getFileHash } from './utils';\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,oCAAuC;AACvC,qBAKO;AACP,4BAA+B;AAC/B,sCAAyC;AACzC,wCAA2C;AAC3C,sCAAyC;AACzC,8CAAiD;AACjD,uCAA0C;AAC1C,kCAAiC;AACjC,0BAMO;AACP,8BAIO;AACP,+BAAkC;AAClC,uCAA0C;AAC1C,6BAAgC;AAChC,wCAA2C;AAC3C,qCAAwC;AACxC,4CAAgC;AAChC,gCAGO;AACP,sCAAyC;AACzC,mBAA4B;AAC5B,qCAGO;","names":[]}
|
|
@@ -28,11 +28,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var listGitFiles_exports = {};
|
|
30
30
|
__export(listGitFiles_exports, {
|
|
31
|
-
listGitFiles: () => listGitFiles
|
|
31
|
+
listGitFiles: () => listGitFiles,
|
|
32
|
+
listGitLines: () => listGitLines
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(listGitFiles_exports);
|
|
34
35
|
var import_config = require("@intlayer/config");
|
|
35
36
|
var import_built = __toESM(require("@intlayer/config/built"));
|
|
37
|
+
var import_fs = require("fs");
|
|
36
38
|
var import_path = require("path");
|
|
37
39
|
var import_simple_git = __toESM(require("simple-git"));
|
|
38
40
|
const getGitRootDir = async () => {
|
|
@@ -93,8 +95,73 @@ const listGitFiles = async ({
|
|
|
93
95
|
console.warn("Failed to get changes list:", error);
|
|
94
96
|
}
|
|
95
97
|
};
|
|
98
|
+
const listGitLines = async (filePath, {
|
|
99
|
+
mode,
|
|
100
|
+
baseRef = "origin/main",
|
|
101
|
+
currentRef = "HEAD"
|
|
102
|
+
// HEAD points to the current branch's latest commit
|
|
103
|
+
}) => {
|
|
104
|
+
const git = (0, import_simple_git.default)();
|
|
105
|
+
const changedLines = /* @__PURE__ */ new Set();
|
|
106
|
+
const collectLinesFromDiff = (diffOutput) => {
|
|
107
|
+
const hunkRegex = /@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/g;
|
|
108
|
+
let match;
|
|
109
|
+
while ((match = hunkRegex.exec(diffOutput)) !== null) {
|
|
110
|
+
const oldCount = match[2] ? Number(match[2]) : 1;
|
|
111
|
+
const newStart = Number(match[3]);
|
|
112
|
+
const newCount = match[4] ? Number(match[4]) : 1;
|
|
113
|
+
if (newCount > 0) {
|
|
114
|
+
for (let i = 0; i < newCount; i++) {
|
|
115
|
+
changedLines.add(newStart + i);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (oldCount > 0 && newCount === 0) {
|
|
119
|
+
if (newStart > 1) {
|
|
120
|
+
changedLines.add(newStart - 1);
|
|
121
|
+
}
|
|
122
|
+
changedLines.add(newStart);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
if (mode.includes("untracked")) {
|
|
127
|
+
const status = await git.status();
|
|
128
|
+
const isUntracked = status.not_added.includes(filePath);
|
|
129
|
+
if (isUntracked) {
|
|
130
|
+
try {
|
|
131
|
+
const content = (0, import_fs.readFileSync)(filePath, "utf-8");
|
|
132
|
+
content.split("\n").forEach((_, idx) => changedLines.add(idx + 1));
|
|
133
|
+
} catch {
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (mode.includes("uncommitted")) {
|
|
138
|
+
const diffOutput = await git.diff(["--unified=0", "HEAD", "--", filePath]);
|
|
139
|
+
collectLinesFromDiff(diffOutput);
|
|
140
|
+
}
|
|
141
|
+
if (mode.includes("unpushed")) {
|
|
142
|
+
const diffOutput = await git.diff([
|
|
143
|
+
"--unified=0",
|
|
144
|
+
"@{push}...HEAD",
|
|
145
|
+
"--",
|
|
146
|
+
filePath
|
|
147
|
+
]);
|
|
148
|
+
collectLinesFromDiff(diffOutput);
|
|
149
|
+
}
|
|
150
|
+
if (mode.includes("gitDiff")) {
|
|
151
|
+
await git.fetch(baseRef);
|
|
152
|
+
const diffOutput = await git.diff([
|
|
153
|
+
"--unified=0",
|
|
154
|
+
`${baseRef}...${currentRef}`,
|
|
155
|
+
"--",
|
|
156
|
+
filePath
|
|
157
|
+
]);
|
|
158
|
+
collectLinesFromDiff(diffOutput);
|
|
159
|
+
}
|
|
160
|
+
return Array.from(changedLines).sort((a, b) => a - b);
|
|
161
|
+
};
|
|
96
162
|
// Annotate the CommonJS export names for ESM import in node:
|
|
97
163
|
0 && (module.exports = {
|
|
98
|
-
listGitFiles
|
|
164
|
+
listGitFiles,
|
|
165
|
+
listGitLines
|
|
99
166
|
});
|
|
100
167
|
//# sourceMappingURL=listGitFiles.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/listGitFiles.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport { join } from 'path';\nimport simpleGit from 'simple-git';\n\nexport type DiffMode = 'gitDiff' | 'uncommitted' | 'unpushed' | 'untracked';\n\nconst getGitRootDir = async (): Promise<string | null> => {\n try {\n const git = simpleGit();\n const rootDir = await git.revparse(['--show-toplevel']);\n return rootDir.trim();\n } catch (error) {\n const appLogger = getAppLogger(configuration);\n appLogger('Error getting git root directory:' + error, {\n level: 'error',\n });\n return null;\n }\n};\n\nexport type ListGitFilesOptions = {\n mode: DiffMode[];\n baseRef?: string;\n currentRef?: string;\n absolute?: boolean;\n};\n\nexport const listGitFiles = async ({\n mode,\n baseRef = 'origin/main',\n currentRef = 'HEAD', // HEAD points to the current branch's latest commit\n absolute = true,\n}: ListGitFilesOptions) => {\n try {\n const git = simpleGit();\n const diff: Set<string> = new Set();\n\n if (mode.includes('untracked')) {\n const status = await git.status();\n status.not_added.forEach((f) => diff.add(f));\n }\n\n if (mode.includes('uncommitted')) {\n // Get uncommitted changes\n const uncommittedDiff = await git.diff(['--name-only', 'HEAD']);\n\n const uncommittedFiles = uncommittedDiff.split('\\n').filter(Boolean);\n\n uncommittedFiles.forEach((file) => diff.add(file));\n }\n\n if (mode.includes('unpushed')) {\n // Get unpushed commits\n const unpushedDiff = await git.diff(['--name-only', '@{push}...HEAD']);\n\n const unpushedFiles = unpushedDiff.split('\\n').filter(Boolean);\n\n unpushedFiles.forEach((file) => diff.add(file));\n }\n\n if (mode.includes('gitDiff')) {\n // Get the base branch (usually main/master) from CI environment\n\n await git.fetch(baseRef);\n\n const diffBranch = await git.diff([\n '--name-only',\n `${baseRef}...${currentRef}`,\n ]);\n\n const gitDiffFiles = diffBranch.split('\\n').filter(Boolean);\n\n gitDiffFiles.forEach((file) => diff.add(file));\n }\n\n if (absolute) {\n const gitRootDir = await getGitRootDir();\n if (!gitRootDir) {\n return [];\n }\n return Array.from(diff).map((file) => join(gitRootDir, file));\n }\n\n return Array.from(diff);\n } catch (error) {\n console.warn('Failed to get changes list:', error);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6B;AAC7B,mBAA0B;AAC1B,kBAAqB;AACrB,wBAAsB;AAItB,MAAM,gBAAgB,YAAoC;AACxD,MAAI;AACF,UAAM,UAAM,kBAAAA,SAAU;AACtB,UAAM,UAAU,MAAM,IAAI,SAAS,CAAC,iBAAiB,CAAC;AACtD,WAAO,QAAQ,KAAK;AAAA,EACtB,SAAS,OAAO;AACd,UAAM,gBAAY,4BAAa,aAAAC,OAAa;AAC5C,cAAU,sCAAsC,OAAO;AAAA,MACrD,OAAO;AAAA,IACT,CAAC;AACD,WAAO;AAAA,EACT;AACF;AASO,MAAM,eAAe,OAAO;AAAA,EACjC;AAAA,EACA,UAAU;AAAA,EACV,aAAa;AAAA;AAAA,EACb,WAAW;AACb,MAA2B;AACzB,MAAI;AACF,UAAM,UAAM,kBAAAD,SAAU;AACtB,UAAM,OAAoB,oBAAI,IAAI;AAElC,QAAI,KAAK,SAAS,WAAW,GAAG;AAC9B,YAAM,SAAS,MAAM,IAAI,OAAO;AAChC,aAAO,UAAU,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;AAAA,IAC7C;AAEA,QAAI,KAAK,SAAS,aAAa,GAAG;AAEhC,YAAM,kBAAkB,MAAM,IAAI,KAAK,CAAC,eAAe,MAAM,CAAC;AAE9D,YAAM,mBAAmB,gBAAgB,MAAM,IAAI,EAAE,OAAO,OAAO;AAEnE,uBAAiB,QAAQ,CAAC,SAAS,KAAK,IAAI,IAAI,CAAC;AAAA,IACnD;AAEA,QAAI,KAAK,SAAS,UAAU,GAAG;AAE7B,YAAM,eAAe,MAAM,IAAI,KAAK,CAAC,eAAe,gBAAgB,CAAC;AAErE,YAAM,gBAAgB,aAAa,MAAM,IAAI,EAAE,OAAO,OAAO;AAE7D,oBAAc,QAAQ,CAAC,SAAS,KAAK,IAAI,IAAI,CAAC;AAAA,IAChD;AAEA,QAAI,KAAK,SAAS,SAAS,GAAG;AAG5B,YAAM,IAAI,MAAM,OAAO;AAEvB,YAAM,aAAa,MAAM,IAAI,KAAK;AAAA,QAChC;AAAA,QACA,GAAG,OAAO,MAAM,UAAU;AAAA,MAC5B,CAAC;AAED,YAAM,eAAe,WAAW,MAAM,IAAI,EAAE,OAAO,OAAO;AAE1D,mBAAa,QAAQ,CAAC,SAAS,KAAK,IAAI,IAAI,CAAC;AAAA,IAC/C;AAEA,QAAI,UAAU;AACZ,YAAM,aAAa,MAAM,cAAc;AACvC,UAAI,CAAC,YAAY;AACf,eAAO,CAAC;AAAA,MACV;AACA,aAAO,MAAM,KAAK,IAAI,EAAE,IAAI,CAAC,aAAS,kBAAK,YAAY,IAAI,CAAC;AAAA,IAC9D;AAEA,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB,SAAS,OAAO;AACd,YAAQ,KAAK,+BAA+B,KAAK;AAAA,EACnD;AACF;","names":["simpleGit","configuration"]}
|
|
1
|
+
{"version":3,"sources":["../../src/listGitFiles.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport simpleGit from 'simple-git';\n\nexport type DiffMode = 'gitDiff' | 'uncommitted' | 'unpushed' | 'untracked';\n\nconst getGitRootDir = async (): Promise<string | null> => {\n try {\n const git = simpleGit();\n const rootDir = await git.revparse(['--show-toplevel']);\n return rootDir.trim();\n } catch (error) {\n const appLogger = getAppLogger(configuration);\n appLogger('Error getting git root directory:' + error, {\n level: 'error',\n });\n return null;\n }\n};\n\nexport type ListGitFilesOptions = {\n mode: DiffMode[];\n baseRef?: string;\n currentRef?: string;\n absolute?: boolean;\n};\n\nexport const listGitFiles = async ({\n mode,\n baseRef = 'origin/main',\n currentRef = 'HEAD', // HEAD points to the current branch's latest commit\n absolute = true,\n}: ListGitFilesOptions) => {\n try {\n const git = simpleGit();\n const diff: Set<string> = new Set();\n\n if (mode.includes('untracked')) {\n const status = await git.status();\n status.not_added.forEach((f) => diff.add(f));\n }\n\n if (mode.includes('uncommitted')) {\n // Get uncommitted changes\n const uncommittedDiff = await git.diff(['--name-only', 'HEAD']);\n\n const uncommittedFiles = uncommittedDiff.split('\\n').filter(Boolean);\n\n uncommittedFiles.forEach((file) => diff.add(file));\n }\n\n if (mode.includes('unpushed')) {\n // Get unpushed commits\n const unpushedDiff = await git.diff(['--name-only', '@{push}...HEAD']);\n\n const unpushedFiles = unpushedDiff.split('\\n').filter(Boolean);\n\n unpushedFiles.forEach((file) => diff.add(file));\n }\n\n if (mode.includes('gitDiff')) {\n // Get the base branch (usually main/master) from CI environment\n\n await git.fetch(baseRef);\n\n const diffBranch = await git.diff([\n '--name-only',\n `${baseRef}...${currentRef}`,\n ]);\n\n const gitDiffFiles = diffBranch.split('\\n').filter(Boolean);\n\n gitDiffFiles.forEach((file) => diff.add(file));\n }\n\n if (absolute) {\n const gitRootDir = await getGitRootDir();\n if (!gitRootDir) {\n return [];\n }\n return Array.from(diff).map((file) => join(gitRootDir, file));\n }\n\n return Array.from(diff);\n } catch (error) {\n console.warn('Failed to get changes list:', error);\n }\n};\n\nexport type ListGitLinesOptions = {\n mode: DiffMode[];\n baseRef?: string;\n currentRef?: string;\n};\n\nexport const listGitLines = async (\n filePath: string,\n {\n mode,\n baseRef = 'origin/main',\n currentRef = 'HEAD', // HEAD points to the current branch's latest commit\n }: ListGitLinesOptions\n): Promise<number[]> => {\n const git = simpleGit();\n // We collect **line numbers** (1-based) that were modified/added by the diff.\n // Using a Set ensures uniqueness when the same line is reported by several modes.\n const changedLines: Set<number> = new Set();\n\n /**\n * Extracts line numbers from a diff generated with `--unified=0`.\n * Each hunk header looks like: @@ -<oldStart>,<oldCount> +<newStart>,<newCount> @@\n * We consider both the \"+\" (new) side for additions and the \"-\" (old) side for deletions.\n * For deletions, we add the line before and after the deletion point in the current file.\n */\n const collectLinesFromDiff = (diffOutput: string) => {\n const hunkRegex = /@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@/g;\n let match: RegExpExecArray | null;\n\n while ((match = hunkRegex.exec(diffOutput)) !== null) {\n const oldCount = match[2] ? Number(match[2]) : 1;\n const newStart = Number(match[3]);\n const newCount = match[4] ? Number(match[4]) : 1;\n\n // Handle additions/modifications (+ side)\n if (newCount > 0) {\n for (let i = 0; i < newCount; i++) {\n changedLines.add(newStart + i);\n }\n }\n\n // Handle deletions (- side)\n if (oldCount > 0 && newCount === 0) {\n // For deletions, add the line before and after the deletion point\n // The deletion point in the new file is at newStart\n if (newStart > 1) {\n changedLines.add(newStart - 1); // Line before deletion\n }\n changedLines.add(newStart); // Line after deletion (if it exists)\n }\n }\n };\n\n // 1. Handle untracked files – when a file is untracked its entire content is new.\n if (mode.includes('untracked')) {\n const status = await git.status();\n const isUntracked = status.not_added.includes(filePath);\n if (isUntracked) {\n try {\n const content = readFileSync(filePath, 'utf-8');\n content.split('\\n').forEach((_, idx) => changedLines.add(idx + 1));\n } catch {\n // ignore read errors – file may have been deleted, etc.\n }\n }\n }\n\n // 2. Uncommitted changes (working tree vs HEAD)\n if (mode.includes('uncommitted')) {\n const diffOutput = await git.diff(['--unified=0', 'HEAD', '--', filePath]);\n collectLinesFromDiff(diffOutput);\n }\n\n // 3. Unpushed commits – compare local branch to its upstream\n if (mode.includes('unpushed')) {\n const diffOutput = await git.diff([\n '--unified=0',\n '@{push}...HEAD',\n '--',\n filePath,\n ]);\n collectLinesFromDiff(diffOutput);\n }\n\n // 4. Regular git diff between baseRef and currentRef (e.g., CI pull-request diff)\n if (mode.includes('gitDiff')) {\n await git.fetch(baseRef);\n const diffOutput = await git.diff([\n '--unified=0',\n `${baseRef}...${currentRef}`,\n '--',\n filePath,\n ]);\n collectLinesFromDiff(diffOutput);\n }\n\n // Return the list sorted for convenience\n return Array.from(changedLines).sort((a, b) => a - b);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6B;AAC7B,mBAA0B;AAC1B,gBAA6B;AAC7B,kBAAqB;AACrB,wBAAsB;AAItB,MAAM,gBAAgB,YAAoC;AACxD,MAAI;AACF,UAAM,UAAM,kBAAAA,SAAU;AACtB,UAAM,UAAU,MAAM,IAAI,SAAS,CAAC,iBAAiB,CAAC;AACtD,WAAO,QAAQ,KAAK;AAAA,EACtB,SAAS,OAAO;AACd,UAAM,gBAAY,4BAAa,aAAAC,OAAa;AAC5C,cAAU,sCAAsC,OAAO;AAAA,MACrD,OAAO;AAAA,IACT,CAAC;AACD,WAAO;AAAA,EACT;AACF;AASO,MAAM,eAAe,OAAO;AAAA,EACjC;AAAA,EACA,UAAU;AAAA,EACV,aAAa;AAAA;AAAA,EACb,WAAW;AACb,MAA2B;AACzB,MAAI;AACF,UAAM,UAAM,kBAAAD,SAAU;AACtB,UAAM,OAAoB,oBAAI,IAAI;AAElC,QAAI,KAAK,SAAS,WAAW,GAAG;AAC9B,YAAM,SAAS,MAAM,IAAI,OAAO;AAChC,aAAO,UAAU,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;AAAA,IAC7C;AAEA,QAAI,KAAK,SAAS,aAAa,GAAG;AAEhC,YAAM,kBAAkB,MAAM,IAAI,KAAK,CAAC,eAAe,MAAM,CAAC;AAE9D,YAAM,mBAAmB,gBAAgB,MAAM,IAAI,EAAE,OAAO,OAAO;AAEnE,uBAAiB,QAAQ,CAAC,SAAS,KAAK,IAAI,IAAI,CAAC;AAAA,IACnD;AAEA,QAAI,KAAK,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C;AACtD;","names":["simpleGit","configuration"]}
|
|
@@ -29,9 +29,11 @@ var import_declaration_file_to_dictionary = require('./transpiler/declaration_fi
|
|
|
29
29
|
var import_createDictionaryEntryPoint = require('./transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs');
|
|
30
30
|
var import_dictionary_to_type = require('./transpiler/dictionary_to_type/index.cjs');
|
|
31
31
|
var import_writeConfiguration = require('./writeConfiguration/index.cjs');
|
|
32
|
-
const prepareIntlayer = async (configuration = (0, import_config.getConfiguration)(), projectRequire = import_config.ESMxCJSRequire) => {
|
|
32
|
+
const prepareIntlayer = async (configuration = (0, import_config.getConfiguration)(), projectRequire = import_config.ESMxCJSRequire, clean = false) => {
|
|
33
33
|
const appLogger = (0, import_config.getAppLogger)(configuration);
|
|
34
|
-
|
|
34
|
+
if (clean) {
|
|
35
|
+
(0, import_cleanOutputDir.cleanOutputDir)(configuration);
|
|
36
|
+
}
|
|
35
37
|
const files = (0, import_listDictionariesPath.listDictionaries)(configuration);
|
|
36
38
|
const dictionaries = await (0, import_loadDictionaries.loadDictionaries)(
|
|
37
39
|
files,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n type IntlayerConfig,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createModuleAugmentation,\n createTypes,\n} from './transpiler/dictionary_to_type/index';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n) => {\n const appLogger = getAppLogger(configuration);\n\n cleanOutputDir(configuration);\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(\n files,\n configuration,\n projectRequire\n );\n\n // Build locale dictionaries\n const dictionariesOutput = await buildDictionary(dictionaries, configuration);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint(configuration);\n\n appLogger('Dictionaries built');\n\n createModuleAugmentation(configuration);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n writeConfiguration(configuration);\n\n appLogger('Configuration written', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKO;AACP,4BAA+B;AAC/B,kCAAiC;AACjC,8BAAiC;AACjC,4CAAgC;AAChC,wCAA2C;AAC3C,gCAGO;AACP,gCAAmC;AAE5B,MAAM,kBAAkB,OAC7B,oBAAgC,gCAAiB,GACjD,iBAAiB,
|
|
1
|
+
{"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n type IntlayerConfig,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createModuleAugmentation,\n createTypes,\n} from './transpiler/dictionary_to_type/index';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire,\n clean = false\n) => {\n const appLogger = getAppLogger(configuration);\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 // Build locale dictionaries\n const dictionariesOutput = await buildDictionary(dictionaries, configuration);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint(configuration);\n\n appLogger('Dictionaries built');\n\n createModuleAugmentation(configuration);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n writeConfiguration(configuration);\n\n appLogger('Configuration written', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKO;AACP,4BAA+B;AAC/B,kCAAiC;AACjC,8BAAiC;AACjC,4CAAgC;AAChC,wCAA2C;AAC3C,gCAGO;AACP,gCAAmC;AAE5B,MAAM,kBAAkB,OAC7B,oBAAgC,gCAAiB,GACjD,iBAAiB,8BACjB,QAAQ,UACL;AACH,QAAM,gBAAY,4BAAa,aAAa;AAE5C,MAAI,OAAO;AACT,8CAAe,aAAa;AAAA,EAC9B;AAEA,QAAM,YAAkB,8CAAiB,aAAa;AAEtD,QAAM,eAAe,UAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGA,QAAM,qBAAqB,UAAM,uDAAgB,cAAc,aAAa;AAE5E,QAAM,oBAAoB,OAAO;AAAA,IAC/B,oBAAoB,sBAAsB,CAAC;AAAA,EAC7C,EAAE,IAAI,CAAC,eAAe,WAAW,cAAc;AAE/C,6CAAY,iBAAiB;AAE7B,oEAA2B,aAAa;AAExC,YAAU,oBAAoB;AAE9B,0DAAyB,aAAa;AAEtC,YAAU,6BAA6B;AAAA,IACrC,WAAW;AAAA,EACb,CAAC;AAED,oDAAmB,aAAa;AAEhC,YAAU,yBAAyB;AAAA,IACjC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -18,40 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var processContentDeclaration_exports = {};
|
|
20
20
|
__export(processContentDeclaration_exports, {
|
|
21
|
-
processContentDeclaration: () => processContentDeclaration
|
|
22
|
-
resolveContentPromises: () => resolveContentPromises
|
|
21
|
+
processContentDeclaration: () => processContentDeclaration
|
|
23
22
|
});
|
|
24
23
|
module.exports = __toCommonJS(processContentDeclaration_exports);
|
|
25
24
|
var import_client = require("@intlayer/config/client");
|
|
26
|
-
|
|
27
|
-
if (entry && typeof entry.then === "function") {
|
|
28
|
-
const awaited = await entry;
|
|
29
|
-
return resolveContentPromises(awaited);
|
|
30
|
-
}
|
|
31
|
-
if (typeof entry === "function") {
|
|
32
|
-
const result = entry();
|
|
33
|
-
return resolveContentPromises(result);
|
|
34
|
-
}
|
|
35
|
-
if (Array.isArray(entry)) {
|
|
36
|
-
return Promise.all(
|
|
37
|
-
entry.map(async (item) => resolveContentPromises(item))
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
if (entry && typeof entry === "object") {
|
|
41
|
-
const result = {};
|
|
42
|
-
const keys = Object.keys(entry);
|
|
43
|
-
await Promise.all(
|
|
44
|
-
keys.map(async (key) => {
|
|
45
|
-
result[key] = await resolveContentPromises(entry[key]);
|
|
46
|
-
})
|
|
47
|
-
);
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
return entry;
|
|
51
|
-
};
|
|
25
|
+
var import_resolveObjectPromises = require('../../../utils/resolveObjectPromises.cjs');
|
|
52
26
|
const processContentDeclaration = async (contentDeclaration) => {
|
|
53
27
|
try {
|
|
54
|
-
const content = await
|
|
28
|
+
const content = await (0, import_resolveObjectPromises.resolveObjectPromises)(
|
|
55
29
|
contentDeclaration.content
|
|
56
30
|
);
|
|
57
31
|
return {
|
|
@@ -66,7 +40,6 @@ const processContentDeclaration = async (contentDeclaration) => {
|
|
|
66
40
|
};
|
|
67
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
68
42
|
0 && (module.exports = {
|
|
69
|
-
processContentDeclaration
|
|
70
|
-
resolveContentPromises
|
|
43
|
+
processContentDeclaration
|
|
71
44
|
});
|
|
72
45
|
//# sourceMappingURL=processContentDeclaration.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { resolveObjectPromises } from '../../../utils/resolveObjectPromises';\n\n/**\n * Function to load, process the module and return the Intlayer Dictionary from the module file\n */\nexport const processContentDeclaration = async (\n contentDeclaration: Dictionary\n): Promise<Dictionary | undefined> => {\n try {\n const content = (await resolveObjectPromises(\n contentDeclaration.content\n )) as Dictionary['content'];\n\n return {\n ...contentDeclaration,\n content,\n } as Dictionary;\n } catch (error) {\n logger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AAEvB,mCAAsC;AAK/B,MAAM,4BAA4B,OACvC,uBACoC;AACpC,MAAI;AACF,UAAM,UAAW,UAAM;AAAA,MACrB,mBAAmB;AAAA,IACrB;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,8BAAO,OAAO;AAAA,MACZ,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 resolveObjectPromises_exports = {};
|
|
20
|
+
__export(resolveObjectPromises_exports, {
|
|
21
|
+
resolveObjectPromises: () => resolveObjectPromises
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(resolveObjectPromises_exports);
|
|
24
|
+
const resolveObjectPromises = async (entry) => {
|
|
25
|
+
if (entry && typeof entry.then === "function") {
|
|
26
|
+
const awaited = await entry;
|
|
27
|
+
return resolveObjectPromises(awaited);
|
|
28
|
+
}
|
|
29
|
+
if (typeof entry === "function") {
|
|
30
|
+
const result = entry();
|
|
31
|
+
return resolveObjectPromises(result);
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(entry)) {
|
|
34
|
+
return Promise.all(
|
|
35
|
+
entry.map(async (item) => resolveObjectPromises(item))
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
if (entry && typeof entry === "object") {
|
|
39
|
+
const result = {};
|
|
40
|
+
for (const key of Object.keys(entry)) {
|
|
41
|
+
result[key] = await resolveObjectPromises(entry[key]);
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
return entry;
|
|
46
|
+
};
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
resolveObjectPromises
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=resolveObjectPromises.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/resolveObjectPromises.ts"],"sourcesContent":["/**\n * A more \"unified\" approach where each type (function, array, object, primitive)\n * is handled inside the main recursive body.\n */\nexport const resolveObjectPromises = async <T = unknown>(\n entry: any\n): Promise<T> => {\n // Check if entry is a Promise (Thenable)\n if (entry && typeof entry.then === 'function') {\n const awaited = await entry;\n return resolveObjectPromises(awaited);\n }\n\n // If entry is a function, invoke it and process the result\n if (typeof entry === 'function') {\n const result = entry();\n return resolveObjectPromises(result);\n }\n\n if (Array.isArray(entry)) {\n return Promise.all(\n entry.map(async (item) => resolveObjectPromises(item))\n ) as unknown as T;\n }\n\n // Handle plain objects (but not arrays)\n if (entry && typeof entry === 'object') {\n // Arrays are handled in the `Array.isArray` branch above, so we know `entry` is a plain object here.\n\n const result: Record<string, any> = {};\n\n // Iterate over keys **sequentially** to make sure the insertion order of the\n // resulting object matches the original key order. Using `Promise.all` here\n // could lead to out-of-order insertions when asynchronous resolutions\n // finish at different times.\n for (const key of Object.keys(entry)) {\n result[key] = await resolveObjectPromises(entry[key]);\n }\n\n return result as T;\n }\n\n return entry as T;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,wBAAwB,OACnC,UACe;AAEf,MAAI,SAAS,OAAO,MAAM,SAAS,YAAY;AAC7C,UAAM,UAAU,MAAM;AACtB,WAAO,sBAAsB,OAAO;AAAA,EACtC;AAGA,MAAI,OAAO,UAAU,YAAY;AAC/B,UAAM,SAAS,MAAM;AACrB,WAAO,sBAAsB,MAAM;AAAA,EACrC;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,QAAQ;AAAA,MACb,MAAM,IAAI,OAAO,SAAS,sBAAsB,IAAI,CAAC;AAAA,IACvD;AAAA,EACF;AAGA,MAAI,SAAS,OAAO,UAAU,UAAU;AAGtC,UAAM,SAA8B,CAAC;AAMrC,eAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,aAAO,GAAG,IAAI,MAAM,sBAAsB,MAAM,GAAG,CAAC;AAAA,IACtD;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_vitest = require("vitest");
|
|
3
|
+
var import_resolveObjectPromises = require('./resolveObjectPromises.cjs');
|
|
4
|
+
const getKeysInOrder = (obj) => {
|
|
5
|
+
return Object.keys(obj);
|
|
6
|
+
};
|
|
7
|
+
const delay = async (ms) => {
|
|
8
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
9
|
+
};
|
|
10
|
+
const testCase = {
|
|
11
|
+
test1: 1,
|
|
12
|
+
test2: () => 2,
|
|
13
|
+
test3: async () => 3,
|
|
14
|
+
test4: [
|
|
15
|
+
41,
|
|
16
|
+
() => 42,
|
|
17
|
+
async () => {
|
|
18
|
+
await delay(100);
|
|
19
|
+
return 43;
|
|
20
|
+
},
|
|
21
|
+
[
|
|
22
|
+
Promise.resolve(44),
|
|
23
|
+
async () => {
|
|
24
|
+
await delay(100);
|
|
25
|
+
return 45;
|
|
26
|
+
},
|
|
27
|
+
46
|
|
28
|
+
]
|
|
29
|
+
],
|
|
30
|
+
test5: {
|
|
31
|
+
test51: () => 51,
|
|
32
|
+
test52: () => 52,
|
|
33
|
+
test53: () => 53
|
|
34
|
+
},
|
|
35
|
+
test6: {
|
|
36
|
+
test61: {
|
|
37
|
+
test611: 611,
|
|
38
|
+
test612: 612,
|
|
39
|
+
test613: 613
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
test7: {
|
|
43
|
+
test71: async () => {
|
|
44
|
+
await delay(100);
|
|
45
|
+
return {
|
|
46
|
+
test711: async () => 711,
|
|
47
|
+
test712: async () => {
|
|
48
|
+
await delay(100);
|
|
49
|
+
return 712;
|
|
50
|
+
},
|
|
51
|
+
test713: async () => {
|
|
52
|
+
await delay(100);
|
|
53
|
+
return [
|
|
54
|
+
7131,
|
|
55
|
+
async () => {
|
|
56
|
+
await delay(100);
|
|
57
|
+
return 7132;
|
|
58
|
+
},
|
|
59
|
+
async () => {
|
|
60
|
+
await delay(100);
|
|
61
|
+
return 7133;
|
|
62
|
+
},
|
|
63
|
+
7134
|
|
64
|
+
];
|
|
65
|
+
},
|
|
66
|
+
test714: 714
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
test8: 8
|
|
71
|
+
};
|
|
72
|
+
const testCaseResolved = {
|
|
73
|
+
test1: 1,
|
|
74
|
+
test2: 2,
|
|
75
|
+
test3: 3,
|
|
76
|
+
test4: [41, 42, 43, [44, 45, 46]],
|
|
77
|
+
test5: {
|
|
78
|
+
test51: 51,
|
|
79
|
+
test52: 52,
|
|
80
|
+
test53: 53
|
|
81
|
+
},
|
|
82
|
+
test6: {
|
|
83
|
+
test61: {
|
|
84
|
+
test611: 611,
|
|
85
|
+
test612: 612,
|
|
86
|
+
test613: 613
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
test7: {
|
|
90
|
+
test71: {
|
|
91
|
+
test711: 711,
|
|
92
|
+
test712: 712,
|
|
93
|
+
test713: [7131, 7132, 7133, 7134],
|
|
94
|
+
test714: 714
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
test8: 8
|
|
98
|
+
};
|
|
99
|
+
(0, import_vitest.describe)("resolveObjectPromises", () => {
|
|
100
|
+
(0, import_vitest.it)("should the result be in the same order as the original object", async () => {
|
|
101
|
+
const resolved = await (0, import_resolveObjectPromises.resolveObjectPromises)(testCase);
|
|
102
|
+
(0, import_vitest.expect)(JSON.stringify(resolved)).toStrictEqual(
|
|
103
|
+
JSON.stringify(testCaseResolved)
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=resolveObjectPromises.test.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/resolveObjectPromises.test.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport { resolveObjectPromises } from './resolveObjectPromises';\n\n// Helper to extract keys order of an object\nconst getKeysInOrder = (obj: Record<string, unknown>): string[] => {\n return Object.keys(obj);\n};\n\nconst delay = async (ms: number) => {\n await new Promise((resolve) => setTimeout(resolve, ms));\n};\n\nconst testCase = {\n test1: 1,\n test2: () => 2,\n test3: async () => 3,\n test4: [\n 41,\n () => 42,\n async () => {\n await delay(100);\n return 43;\n },\n [\n Promise.resolve(44),\n async () => {\n await delay(100);\n return 45;\n },\n 46,\n ],\n ],\n test5: {\n test51: () => 51,\n test52: () => 52,\n test53: () => 53,\n },\n test6: {\n test61: {\n test611: 611,\n test612: 612,\n test613: 613,\n },\n },\n test7: {\n test71: async () => {\n await delay(100);\n return {\n test711: async () => 711,\n test712: async () => {\n await delay(100);\n return 712;\n },\n test713: async () => {\n await delay(100);\n return [\n 7131,\n async () => {\n await delay(100);\n return 7132;\n },\n async () => {\n await delay(100);\n return 7133;\n },\n 7134,\n ];\n },\n test714: 714,\n };\n },\n },\n test8: 8,\n};\n\nconst testCaseResolved = {\n test1: 1,\n test2: 2,\n test3: 3,\n test4: [41, 42, 43, [44, 45, 46]],\n test5: {\n test51: 51,\n test52: 52,\n test53: 53,\n },\n test6: {\n test61: {\n test611: 611,\n test612: 612,\n test613: 613,\n },\n },\n test7: {\n test71: {\n test711: 711,\n test712: 712,\n test713: [7131, 7132, 7133, 7134],\n test714: 714,\n },\n },\n test8: 8,\n};\n\ndescribe('resolveObjectPromises', () => {\n it('should the result be in the same order as the original object', async () => {\n const resolved = await resolveObjectPromises<typeof testCase>(testCase);\n\n // Stringify the objects to ensure the order of the keys is the same\n expect(JSON.stringify(resolved)).toStrict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AAAA,EACA,OAAO;AACT;AAEA,MAAM,mBAAmB;AAAA,EACvB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;AAAA,EAChC,OAAO;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AAAA,EACA,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS,CAAC,MAAM,MAAM,MAAM,IAAI;AAAA,MAChC,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,OAAO;AACT;AAAA,IAEA,wBAAS,yBAAyB,MAAM;AACtC,wBAAG,iEAAiE,YAAY;AAC9E,UAAM,WAAW,UAAM,oDAAuC,QAAQ;AAGtE,8BAAO,KAAK,UAAU,QAAQ,CAAC,EAAE;AAAA,MAC/B,KAAK,UAAU,gBAAgB;AAAA,IACjC;AAAA,EACF,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -4,6 +4,7 @@ const cleanOutputDir = (configuration = getConfiguration()) => {
|
|
|
4
4
|
const {
|
|
5
5
|
dictionariesDir,
|
|
6
6
|
unmergedDictionariesDir,
|
|
7
|
+
dynamicDictionariesDir,
|
|
7
8
|
mainDir,
|
|
8
9
|
typesDir,
|
|
9
10
|
configDir
|
|
@@ -15,6 +16,9 @@ const cleanOutputDir = (configuration = getConfiguration()) => {
|
|
|
15
16
|
if (existsSync(unmergedDictionariesDir)) {
|
|
16
17
|
rmSync(unmergedDictionariesDir, { recursive: true });
|
|
17
18
|
}
|
|
19
|
+
if (existsSync(dynamicDictionariesDir)) {
|
|
20
|
+
rmSync(dynamicDictionariesDir, { recursive: true });
|
|
21
|
+
}
|
|
18
22
|
if (existsSync(mainDir)) {
|
|
19
23
|
rmSync(mainDir, { recursive: true });
|
|
20
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { getAppLogger, getConfiguration } from '@intlayer/config';\nimport { existsSync, rmSync } from 'fs';\n\nexport const cleanOutputDir = (configuration = getConfiguration()) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n } = configuration.content;\n\n const appLogger = getAppLogger(configuration);\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n if (existsSync(unmergedDictionariesDir)) {\n // Delete the unmerged dictionaries directory\n rmSync(unmergedDictionariesDir, { recursive: true });\n }\n\n // Delete the main directory\n if (existsSync(mainDir)) {\n rmSync(mainDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n // Delete the config directory\n if (existsSync(configDir)) {\n rmSync(configDir, { recursive: true });\n }\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":"AAAA,SAAS,cAAc,wBAAwB;AAC/C,SAAS,YAAY,cAAc;AAE5B,MAAM,iBAAiB,CAAC,gBAAgB,iBAAiB,MAAM;AACpE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,cAAc;AAElB,QAAM,YAAY,aAAa,aAAa;AAE5C,MAAI,WAAW,eAAe,GAAG;AAE/B,WAAO,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAAA,EAC7C;AAEA,MAAI,WAAW,uBAAuB,GAAG;AAEvC,WAAO,yBAAyB,EAAE,WAAW,KAAK,CAAC;AAAA,EACrD;AAGA,MAAI,WAAW,OAAO,GAAG;AACvB,WAAO,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACrC;AAGA,MAAI,WAAW,QAAQ,GAAG;AACxB,WAAO,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACtC;AAGA,MAAI,WAAW,SAAS,GAAG;AACzB,WAAO,WAAW,EAAE,WAAW,KAAK,CAAC;AAAA,EACvC;AAEA,YAAU,4BAA4B;AAAA,IACpC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { getAppLogger, getConfiguration } from '@intlayer/config';\nimport { existsSync, rmSync } from 'fs';\n\nexport const cleanOutputDir = (configuration = getConfiguration()) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n } = configuration.content;\n\n const appLogger = getAppLogger(configuration);\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n if (existsSync(unmergedDictionariesDir)) {\n // Delete the unmerged dictionaries directory\n rmSync(unmergedDictionariesDir, { recursive: true });\n }\n\n if (existsSync(dynamicDictionariesDir)) {\n // Delete the dynamic dictionaries directory\n rmSync(dynamicDictionariesDir, { recursive: true });\n }\n\n // Delete the main directory\n if (existsSync(mainDir)) {\n rmSync(mainDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n // Delete the config directory\n if (existsSync(configDir)) {\n rmSync(configDir, { recursive: true });\n }\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":"AAAA,SAAS,cAAc,wBAAwB;AAC/C,SAAS,YAAY,cAAc;AAE5B,MAAM,iBAAiB,CAAC,gBAAgB,iBAAiB,MAAM;AACpE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,cAAc;AAElB,QAAM,YAAY,aAAa,aAAa;AAE5C,MAAI,WAAW,eAAe,GAAG;AAE/B,WAAO,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAAA,EAC7C;AAEA,MAAI,WAAW,uBAAuB,GAAG;AAEvC,WAAO,yBAAyB,EAAE,WAAW,KAAK,CAAC;AAAA,EACrD;AAEA,MAAI,WAAW,sBAAsB,GAAG;AAEtC,WAAO,wBAAwB,EAAE,WAAW,KAAK,CAAC;AAAA,EACpD;AAGA,MAAI,WAAW,OAAO,GAAG;AACvB,WAAO,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACrC;AAGA,MAAI,WAAW,QAAQ,GAAG;AACxB,WAAO,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACtC;AAGA,MAAI,WAAW,SAAS,GAAG;AACzB,WAAO,WAAW,EAAE,WAAW,KAAK,CAAC;AAAA,EACvC;AAEA,YAAU,4BAA4B;AAAA,IACpC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -31,7 +31,11 @@ const fetchDistantDictionaries = async (options) => {
|
|
|
31
31
|
dictionaryKey,
|
|
32
32
|
void 0,
|
|
33
33
|
{
|
|
34
|
-
|
|
34
|
+
...oAuth2AccessToken && {
|
|
35
|
+
headers: {
|
|
36
|
+
Authorization: `Bearer ${oAuth2AccessToken}`
|
|
37
|
+
}
|
|
38
|
+
}
|
|
35
39
|
}
|
|
36
40
|
);
|
|
37
41
|
const distantDictionary = getDictionaryResult.data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getAuthAPI, getDictionaryAPI } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration } from '@intlayer/config';\nimport pLimit from 'p-limit';\nimport { logger } from './log';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const { clientId, clientSecret } = config.editor;\n const authAPI = getAuthAPI(undefined, config);\n const dictionaryAPI = getDictionaryAPI(undefined, config);\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n const distantDictionariesKeys = options.dictionaryKeys;\n\n // Process dictionaries in parallel with a concurrency limit\n const limit = pLimit(5); // Limit the number of concurrent requests\n\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n logger.updateStatus([\n {\n dictionaryKey,\n type: 'distant',\n status: { status: 'fetching' },\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult = await dictionaryAPI.getDictionary(\n dictionaryKey,\n undefined,\n {\n headers: {
|
|
1
|
+
{"version":3,"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getAuthAPI, getDictionaryAPI } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration } from '@intlayer/config';\nimport pLimit from 'p-limit';\nimport { logger } from './log';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const { clientId, clientSecret } = config.editor;\n const authAPI = getAuthAPI(undefined, config);\n const dictionaryAPI = getDictionaryAPI(undefined, config);\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n const distantDictionariesKeys = options.dictionaryKeys;\n\n // Process dictionaries in parallel with a concurrency limit\n const limit = pLimit(5); // Limit the number of concurrent requests\n\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n logger.updateStatus([\n {\n dictionaryKey,\n type: 'distant',\n status: { status: 'fetching' },\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult = await dictionaryAPI.getDictionary(\n dictionaryKey,\n undefined,\n {\n ...(oAuth2AccessToken && {\n headers: {\n Authorization: `Bearer ${oAuth2AccessToken}`,\n },\n }),\n }\n );\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n logger.updateStatus([\n { dictionaryKey, type: 'distant', status: { status: 'imported' } },\n ]);\n\n return distantDictionary;\n } catch (error) {\n logger.updateStatus([\n {\n dictionaryKey,\n type: 'distant',\n status: {\n status: 'error',\n error: error as Error,\n errorMessage: `${options?.logPrefix ?? ''}Error fetching dictionary ${dictionaryKey}: ${error}`,\n },\n },\n ]);\n return undefined;\n }\n };\n\n const fetchPromises = distantDictionariesKeys.map((dictionaryKey) =>\n limit(async () => await processDictionary(dictionaryKey))\n );\n\n const result = await Promise.all(fetchPromises);\n\n // Output any error messages\n const statuses = logger.getStatuses();\n for (const statusObj of statuses) {\n const currentState = statusObj.state.find((s) => s.type === 'distant');\n if (currentState && currentState.errorMessage) {\n appLogger(currentState.errorMessage, { level: 'error' });\n }\n }\n\n // Remove undefined values\n const filteredResult = result.filter(\n (dict): dict is DictionaryAPI => dict !== undefined\n );\n\n return filteredResult;\n } catch (error) {\n appLogger(error, { level: 'error' });\n return [];\n }\n};\n"],"mappings":"AAAA,SAAS,YAAY,wBAAwB;AAG7C,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