@intlayer/cli 3.5.3 → 3.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/audit/CJS_FORMAT.md +23 -0
- package/dist/cjs/audit/JSON_FORMAT.md +26 -0
- package/dist/cjs/audit/JSX_FORMAT.md +28 -0
- package/dist/cjs/audit/MJS_FORMAT.md +23 -0
- package/dist/cjs/audit/PROMPT.md +146 -0
- package/dist/cjs/audit/TSX_FORMAT.md +28 -0
- package/dist/cjs/audit/TS_FORMAT.md +22 -0
- package/dist/cjs/audit/index.cjs +131 -0
- package/dist/cjs/audit/index.cjs.map +1 -0
- package/dist/cjs/cli.cjs +15 -3
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/config.cjs +33 -0
- package/dist/cjs/config.cjs.map +1 -0
- package/dist/cjs/index.cjs +5 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/listContentDeclaration.cjs +58 -0
- package/dist/cjs/listContentDeclaration.cjs.map +1 -0
- package/dist/cjs/pull.cjs +1 -1
- package/dist/cjs/pull.cjs.map +1 -1
- package/dist/cjs/push.cjs.map +1 -1
- package/dist/esm/audit/CJS_FORMAT.md +23 -0
- package/dist/esm/audit/JSON_FORMAT.md +26 -0
- package/dist/esm/audit/JSX_FORMAT.md +28 -0
- package/dist/esm/audit/MJS_FORMAT.md +23 -0
- package/dist/esm/audit/PROMPT.md +146 -0
- package/dist/esm/audit/TSX_FORMAT.md +28 -0
- package/dist/esm/audit/TS_FORMAT.md +22 -0
- package/dist/esm/audit/index.mjs +96 -0
- package/dist/esm/audit/index.mjs.map +1 -0
- package/dist/esm/cli.mjs +15 -3
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/config.mjs +9 -0
- package/dist/esm/config.mjs.map +1 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/listContentDeclaration.mjs +23 -0
- package/dist/esm/listContentDeclaration.mjs.map +1 -0
- package/dist/esm/pull.mjs +1 -1
- package/dist/esm/pull.mjs.map +1 -1
- package/dist/esm/push.mjs.map +1 -1
- package/dist/types/audit/index.d.ts +36 -0
- package/dist/types/audit/index.d.ts.map +1 -0
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/config.d.ts +4 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/listContentDeclaration.d.ts +8 -0
- package/dist/types/listContentDeclaration.d.ts.map +1 -0
- package/package.json +12 -10
package/dist/cjs/pull.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pull.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport * as fsPromises from 'fs/promises';\nimport { basename, dirname, extname } from 'path';\nimport * as readline from 'readline';\nimport { getConfiguration } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { intlayerAPI } from '@intlayer/design-system/libs';\nimport dictionariesRecord from '@intlayer/dictionaries-entry';\nimport _ from 'lodash';\nimport pLimit from 'p-limit';\n\ntype PullOptions = {\n dictionaries?: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\ntype DictionariesStatus = {\n dictionaryKey: string;\n status:\n | 'pending'\n | 'fetching'\n | 'up-to-date'\n | 'updated'\n | 'fetched'\n | 'unknown'\n | 'error'\n | 'imported'\n | 'reimported in JSON'\n | 'reimported in new location';\n icon: string;\n index: number;\n error?: Error;\n errorMessage?: string;\n spinnerFrameIndex?: number;\n};\n\nconst spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\nconst RESET = '\\x1b[0m';\nconst GREEN = '\\x1b[32m';\nconst RED = '\\x1b[31m';\nconst BLUE = '\\x1b[34m';\nconst GREY = '\\x1b[90m';\nconst YELLOW = '\\x1b[33m';\nconst GREY_DARK = '\\x1b[90m';\n\nconst DEFAULT_NEW_DICTIONARY_PATH = 'intlayer-dictionaries';\n\n/**\n * Fetch distant dictionaries and write them locally,\n * with progress indicators and concurrency control.\n */\nexport const pull = async (options?: PullOptions): Promise<void> => {\n try {\n const {\n editor: { clientId, clientSecret },\n } = getConfiguration();\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 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: { Authorization: `Bearer ${oAuth2AccessToken}` },\n });\n\n if (!getDictionariesKeysResult.data) {\n throw new Error('No distant dictionaries found');\n }\n\n let distantDictionariesKeys: string[] = getDictionariesKeysResult.data;\n\n if (options?.dictionaries) {\n // Filter the dictionaries from the provided list of IDs\n distantDictionariesKeys = distantDictionariesKeys.filter(\n (dictionaryKey) => options.dictionaries!.includes(dictionaryKey)\n );\n }\n\n // Check if dictionaries list is empty\n if (distantDictionariesKeys.length === 0) {\n console.error('No dictionaries to fetch');\n return;\n }\n\n console.info('Fetching dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] =\n distantDictionariesKeys.map((dictionaryKey, index) => ({\n dictionaryKey,\n icon: getStatusIcon('pending'),\n status: 'pending',\n index,\n spinnerFrameIndex: 0,\n }));\n\n // Output initial statuses\n for (const statusObj of dictionariesStatuses) {\n process.stdout.write(getStatusLine(statusObj) + '\\n');\n }\n\n // Start spinner timer\n const spinnerTimer = setInterval(() => {\n updateAllStatusLines(dictionariesStatuses);\n }, 100); // Update every 100ms\n\n // Process dictionaries in parallel with a concurrency limit\n const limit = pLimit(5); // Adjust the limit as needed\n\n const successfullyFetchedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'fetching';\n try {\n // Fetch the dictionary\n const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(\n statusObj.dictionaryKey,\n undefined,\n {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n }\n );\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(\n `Dictionary ${statusObj.dictionaryKey} not found on remote`\n );\n }\n\n // Now, write the dictionary to local file\n const writeStatus = await writeDictionary(distantDictionary, options);\n\n statusObj.status = writeStatus;\n\n successfullyFetchedDictionaries.push(distantDictionary);\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error fetching dictionary ${statusObj.dictionaryKey}: ${error}`;\n }\n };\n\n const fetchPromises = dictionariesStatuses.map((statusObj) =>\n limit(() => processDictionary(statusObj))\n );\n\n await Promise.all(fetchPromises);\n\n // Stop the spinner timer\n clearInterval(spinnerTimer);\n\n // Update statuses one last time\n updateAllStatusLines(dictionariesStatuses);\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n console.error(statusObj.errorMessage);\n }\n }\n } catch (error) {\n console.error(error);\n }\n};\n\nconst getStatusIcon = (status: string): string => {\n const statusIcons: Record<string, string> = {\n pending: '⏲',\n fetching: '', // Spinner handled separately\n 'up-to-date': '✔',\n updated: '✔',\n fetched: '✔',\n error: '✖',\n };\n return statusIcons[status] || '';\n};\n\nconst getStatusLine = (statusObj: DictionariesStatus): string => {\n let icon = getStatusIcon(statusObj.status);\n let colorStart = '';\n let colorEnd = '';\n\n if (statusObj.status === 'fetching') {\n // Use spinner frame\n icon = spinnerFrames[statusObj.spinnerFrameIndex! % spinnerFrames.length];\n colorStart = BLUE;\n colorEnd = RESET;\n } else if (statusObj.status === 'error') {\n colorStart = RED;\n colorEnd = RESET;\n } else if (\n statusObj.status === 'fetched' ||\n statusObj.status === 'imported' ||\n statusObj.status === 'updated' ||\n statusObj.status === 'up-to-date'\n ) {\n colorStart = GREEN;\n colorEnd = RESET;\n } else if (\n statusObj.status === 'reimported in JSON' ||\n statusObj.status === 'reimported in new location'\n ) {\n colorStart = YELLOW;\n colorEnd = RESET;\n } else {\n colorStart = GREY;\n colorEnd = RESET;\n }\n\n return `- ${statusObj.dictionaryKey} ${GREY_DARK}[${colorStart}${icon} ${statusObj.status}${colorEnd}]`;\n};\n\nconst updateAllStatusLines = (dictionariesStatuses: DictionariesStatus[]) => {\n // Move cursor up to the first status line\n readline.moveCursor(process.stdout, 0, -dictionariesStatuses.length);\n for (const statusObj of dictionariesStatuses) {\n // Clear the line\n readline.clearLine(process.stdout, 0);\n\n if (statusObj.status === 'fetching') {\n // Update spinner frame\n statusObj.spinnerFrameIndex =\n (statusObj.spinnerFrameIndex! + 1) % spinnerFrames.length;\n }\n\n // Write the status line\n process.stdout.write(getStatusLine(statusObj) + '\\n');\n }\n};\n\nconst writeDictionary = async (\n distantDictionary: Dictionary,\n options?: PullOptions\n): Promise<DictionariesStatus['status']> => {\n const {\n content: { baseDir },\n } = getConfiguration();\n\n const newDictionaryRelativeLocationPath =\n options?.newDictionariesPath ?? DEFAULT_NEW_DICTIONARY_PATH;\n const newDictionaryLocationPath = `${baseDir}/${newDictionaryRelativeLocationPath}`;\n\n const existingDictionary = dictionariesRecord[distantDictionary.key];\n\n if (existingDictionary) {\n const { filePath } = existingDictionary;\n\n // Compare existing dictionary with distant dictionary\n if (_.isEqual(existingDictionary, distantDictionary)) {\n // Up to date, nothing to do\n return 'up-to-date';\n } else {\n if (filePath) {\n const isDictionaryJSON = filePath.endsWith('.json');\n\n if (isDictionaryJSON) {\n // Write the dictionary to the same location of the existing dictionary file\n await fsPromises.writeFile(\n `${baseDir}/${filePath}`,\n JSON.stringify(distantDictionary, null, 2)\n );\n return 'updated';\n } else {\n // Write the dictionary to the intlayer-dictionaries directory\n const dictionariesDirPath = dirname(filePath);\n const dictionariesFileName = basename(filePath, extname(filePath));\n\n const newFilePath = `${dictionariesDirPath}/${dictionariesFileName}.json`;\n\n await writeFileWithDirectories(\n newFilePath,\n JSON.stringify(distantDictionary, null, 2)\n );\n return 'reimported in JSON';\n }\n } else {\n // Write the dictionary to the intlayer-dictionaries directory\n const dictionaryPath = `${newDictionaryLocationPath}/${distantDictionary.key}.content.json`;\n await writeFileWithDirectories(\n dictionaryPath,\n JSON.stringify(distantDictionary, null, 2)\n );\n return 'reimported in new location';\n }\n }\n } else {\n // No existing dictionary, write to new location\n const dictionaryPath = `${newDictionaryLocationPath}/${distantDictionary.key}.content.json`;\n\n await writeFileWithDirectories(\n dictionaryPath,\n JSON.stringify(distantDictionary, null, 2)\n );\n\n return 'imported';\n }\n};\n\nconst writeFileWithDirectories = async (\n filePath: string,\n data: string | Buffer\n): Promise<void> => {\n try {\n // Extract the directory from the file path\n const dir = dirname(filePath);\n\n // Check if the directory exists\n const directoryExists = existsSync(dir);\n\n if (!directoryExists) {\n // Create the directory recursively\n await fsPromises.mkdir(dir, { recursive: true });\n }\n\n // Write the file\n await fsPromises.writeFile(filePath, data);\n } catch (error) {\n throw new Error(`Error writing file to ${filePath}: ${error}`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA2B;AAC3B,iBAA4B;AAC5B,kBAA2C;AAC3C,eAA0B;AAC1B,oBAAiC;AAEjC,kBAA4B;AAC5B,gCAA+B;AAC/B,oBAAc;AACd,qBAAmB;AA4BnB,MAAM,gBAAgB,CAAC,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,QAAG;AAEvE,MAAM,QAAQ;AACd,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,OAAO;AACb,MAAM,SAAS;AACf,MAAM,YAAY;AAElB,MAAM,8BAA8B;AAM7B,MAAM,OAAO,OAAO,YAAyC;AAClE,MAAI;AACF,UAAM;AAAA,MACJ,QAAQ,EAAE,UAAU,aAAa;AAAA,IACnC,QAA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AEL,gBAAM,0BAAsB,qBAAQ,QAAQ;AAC5C,gBAAM,2BAAuB,sBAAS,cAAU,qBAAQ,QAAQ,CAAC;AAEjE,gBAAM,cAAc,GAAG,mBAAmB,IAAI,oBAAoB;AAElE,gBAAM;AAAA,YACJ;AAAA,YACA,KAAK,UAAU,mBAAmB,MAAM,CAAC;AAAA,UAC3C;AACA,iBAAO;AAAA,QACT;AAAA,MACF,OAAO;AAEL,cAAM,iBAAiB,GAAG,yBAAyB,IAAI,kBAAkB,GAAG;AAC5E,cAAM;AAAA,UACJ;AAAA,UACA,KAAK,UAAU,mBAAmB,MAAM,CAAC;AAAA,QAC3C;AACA,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,OAAO;AAEL,UAAM,iBAAiB,GAAG,yBAAyB,IAAI,kBAAkB,GAAG;AAE5E,UAAM;AAAA,MACJ;AAAA,MACA,KAAK,UAAU,mBAAmB,MAAM,CAAC;AAAA,IAC3C;AAEA,WAAO;AAAA,EACT;AACF;AAEA,MAAM,2BAA2B,OAC/B,UACA,SACkB;AAClB,MAAI;AAEF,UAAM,UAAM,qBAAQ,QAAQ;AAG5B,UAAM,sBAAkB,sBAAW,GAAG;AAEtC,QAAI,CAAC,iBAAiB;AAEpB,YAAM,WAAW,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,IACjD;AAGA,UAAM,WAAW,UAAU,UAAU,IAAI;AAAA,EAC3C,SAAS,OAAO;AACd,UAAM,IAAI,MAAM,yBAAyB,QAAQ,KAAK,KAAK,EAAE;AAAA,EAC/D;AACF;","names":["pLimit","dictionariesRecord","_"]}
|
|
1
|
+
{"version":3,"sources":["../../src/pull.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport * as fsPromises from 'fs/promises';\nimport { basename, dirname, extname } from 'path';\nimport * as readline from 'readline';\nimport { getConfiguration } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { intlayerAPI } from '@intlayer/design-system/libs';\nimport dictionariesRecord from '@intlayer/dictionaries-entry';\nimport _ from 'lodash';\nimport pLimit from 'p-limit';\n\ntype PullOptions = {\n dictionaries?: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\ntype DictionariesStatus = {\n dictionaryKey: string;\n status:\n | 'pending'\n | 'fetching'\n | 'up-to-date'\n | 'updated'\n | 'fetched'\n | 'unknown'\n | 'error'\n | 'imported'\n | 'reimported in JSON'\n | 'reimported in new location';\n icon: string;\n index: number;\n error?: Error;\n errorMessage?: string;\n spinnerFrameIndex?: number;\n};\n\nconst spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\nconst RESET = '\\x1b[0m';\nconst GREEN = '\\x1b[32m';\nconst RED = '\\x1b[31m';\nconst BLUE = '\\x1b[34m';\nconst GREY = '\\x1b[90m';\nconst YELLOW = '\\x1b[33m';\nconst GREY_DARK = '\\x1b[90m';\n\nconst DEFAULT_NEW_DICTIONARY_PATH = 'intlayer-dictionaries';\n\n/**\n * Fetch distant dictionaries and write them locally,\n * with progress indicators and concurrency control.\n */\nexport const pull = async (options?: PullOptions): Promise<void> => {\n try {\n const {\n editor: { clientId, clientSecret },\n } = getConfiguration();\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 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: { Authorization: `Bearer ${oAuth2AccessToken}` },\n });\n\n if (!getDictionariesKeysResult.data) {\n throw new Error('No distant dictionaries found');\n }\n\n let distantDictionariesKeys: string[] = getDictionariesKeysResult.data;\n\n if (options?.dictionaries) {\n // Filter the dictionaries from the provided list of IDs\n distantDictionariesKeys = distantDictionariesKeys.filter(\n (dictionaryKey) => options.dictionaries!.includes(dictionaryKey)\n );\n }\n\n // Check if dictionaries list is empty\n if (distantDictionariesKeys.length === 0) {\n console.error('No dictionaries to fetch');\n return;\n }\n\n console.info('Fetching dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] =\n distantDictionariesKeys.map((dictionaryKey, index) => ({\n dictionaryKey,\n icon: getStatusIcon('pending'),\n status: 'pending',\n index,\n spinnerFrameIndex: 0,\n }));\n\n // Output initial statuses\n for (const statusObj of dictionariesStatuses) {\n process.stdout.write(getStatusLine(statusObj) + '\\n');\n }\n\n // Start spinner timer\n const spinnerTimer = setInterval(() => {\n updateAllStatusLines(dictionariesStatuses);\n }, 100); // Update every 100ms\n\n // Process dictionaries in parallel with a concurrency limit\n const limit = pLimit(5); // Limit the number of concurrent requests\n\n const successfullyFetchedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'fetching';\n try {\n // Fetch the dictionary\n const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(\n statusObj.dictionaryKey,\n undefined,\n {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n }\n );\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(\n `Dictionary ${statusObj.dictionaryKey} not found on remote`\n );\n }\n\n // Now, write the dictionary to local file\n const writeStatus = await writeDictionary(distantDictionary, options);\n\n statusObj.status = writeStatus;\n\n successfullyFetchedDictionaries.push(distantDictionary);\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error fetching dictionary ${statusObj.dictionaryKey}: ${error}`;\n }\n };\n\n const fetchPromises = dictionariesStatuses.map((statusObj) =>\n limit(() => processDictionary(statusObj))\n );\n\n await Promise.all(fetchPromises);\n\n // Stop the spinner timer\n clearInterval(spinnerTimer);\n\n // Update statuses one last time\n updateAllStatusLines(dictionariesStatuses);\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n console.error(statusObj.errorMessage);\n }\n }\n } catch (error) {\n console.error(error);\n }\n};\n\nconst getStatusIcon = (status: string): string => {\n const statusIcons: Record<string, string> = {\n pending: '⏲',\n fetching: '', // Spinner handled separately\n 'up-to-date': '✔',\n updated: '✔',\n fetched: '✔',\n error: '✖',\n };\n return statusIcons[status] ?? '';\n};\n\nconst getStatusLine = (statusObj: DictionariesStatus): string => {\n let icon = getStatusIcon(statusObj.status);\n let colorStart = '';\n let colorEnd = '';\n\n if (statusObj.status === 'fetching') {\n // Use spinner frame\n icon = spinnerFrames[statusObj.spinnerFrameIndex! % spinnerFrames.length];\n colorStart = BLUE;\n colorEnd = RESET;\n } else if (statusObj.status === 'error') {\n colorStart = RED;\n colorEnd = RESET;\n } else if (\n statusObj.status === 'fetched' ||\n statusObj.status === 'imported' ||\n statusObj.status === 'updated' ||\n statusObj.status === 'up-to-date'\n ) {\n colorStart = GREEN;\n colorEnd = RESET;\n } else if (\n statusObj.status === 'reimported in JSON' ||\n statusObj.status === 'reimported in new location'\n ) {\n colorStart = YELLOW;\n colorEnd = RESET;\n } else {\n colorStart = GREY;\n colorEnd = RESET;\n }\n\n return `- ${statusObj.dictionaryKey} ${GREY_DARK}[${colorStart}${icon} ${statusObj.status}${colorEnd}]`;\n};\n\nconst updateAllStatusLines = (dictionariesStatuses: DictionariesStatus[]) => {\n // Move cursor up to the first status line\n readline.moveCursor(process.stdout, 0, -dictionariesStatuses.length);\n for (const statusObj of dictionariesStatuses) {\n // Clear the line\n readline.clearLine(process.stdout, 0);\n\n if (statusObj.status === 'fetching') {\n // Update spinner frame\n statusObj.spinnerFrameIndex =\n (statusObj.spinnerFrameIndex! + 1) % spinnerFrames.length;\n }\n\n // Write the status line\n process.stdout.write(getStatusLine(statusObj) + '\\n');\n }\n};\n\nconst writeDictionary = async (\n distantDictionary: Dictionary,\n options?: PullOptions\n): Promise<DictionariesStatus['status']> => {\n const {\n content: { baseDir },\n } = getConfiguration();\n\n const newDictionaryRelativeLocationPath =\n options?.newDictionariesPath ?? DEFAULT_NEW_DICTIONARY_PATH;\n const newDictionaryLocationPath = `${baseDir}/${newDictionaryRelativeLocationPath}`;\n\n const existingDictionary = dictionariesRecord[distantDictionary.key];\n\n if (existingDictionary) {\n const { filePath } = existingDictionary;\n\n // Compare existing dictionary with distant dictionary\n if (_.isEqual(existingDictionary, distantDictionary)) {\n // Up to date, nothing to do\n return 'up-to-date';\n } else {\n if (filePath) {\n const isDictionaryJSON = filePath.endsWith('.json');\n\n if (isDictionaryJSON) {\n // Write the dictionary to the same location of the existing dictionary file\n await fsPromises.writeFile(\n `${baseDir}/${filePath}`,\n JSON.stringify(distantDictionary, null, 2)\n );\n return 'updated';\n } else {\n // Write the dictionary to the intlayer-dictionaries directory\n const dictionariesDirPath = dirname(filePath);\n const dictionariesFileName = basename(filePath, extname(filePath));\n\n const newFilePath = `${dictionariesDirPath}/${dictionariesFileName}.json`;\n\n await writeFileWithDirectories(\n newFilePath,\n JSON.stringify(distantDictionary, null, 2)\n );\n return 'reimported in JSON';\n }\n } else {\n // Write the dictionary to the intlayer-dictionaries directory\n const dictionaryPath = `${newDictionaryLocationPath}/${distantDictionary.key}.content.json`;\n await writeFileWithDirectories(\n dictionaryPath,\n JSON.stringify(distantDictionary, null, 2)\n );\n return 'reimported in new location';\n }\n }\n } else {\n // No existing dictionary, write to new location\n const dictionaryPath = `${newDictionaryLocationPath}/${distantDictionary.key}.content.json`;\n\n await writeFileWithDirectories(\n dictionaryPath,\n JSON.stringify(distantDictionary, null, 2)\n );\n\n return 'imported';\n }\n};\n\nconst writeFileWithDirectories = async (\n filePath: string,\n data: string | Buffer\n): Promise<void> => {\n try {\n // Extract the directory from the file path\n const dir = dirname(filePath);\n\n // Check if the directory exists\n const directoryExists = existsSync(dir);\n\n if (!directoryExists) {\n // Create the directory recursively\n await fsPromises.mkdir(dir, { recursive: true });\n }\n\n // Write the file\n await fsPromises.writeFile(filePath, data);\n } catch (error) {\n throw new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A,SACkB;AAClB,MAAI;AAEF,UAAM,UAAM,qBAAQ,QAAQ;AAG5B,UAAM,sBAAkB,sBAAW,GAAG;AAEtC,QAAI,CAAC,iBAAiB;AAEpB,YAAM,WAAW,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,IACjD;AAGA,UAAM,WAAW,UAAU,UAAU,IAAI;AAAA,EAC3C,SAAS,OAAO;AACd,UAAM,IAAI,MAAM,yBAAyB,QAAQ,KAAK,KAAK,EAAE;AAAA,EAC/D;AACF;","names":["pLimit","dictionariesRecord","_"]}
|
package/dist/cjs/push.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/push.ts"],"sourcesContent":["import * as fsPromises from 'fs/promises';\nimport { relative } from 'path';\nimport * as readline from 'readline';\nimport { getConfiguration } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { intlayerAPI } from '@intlayer/design-system/libs';\nimport dictionariesRecord from '@intlayer/dictionaries-entry';\nimport pLimit from 'p-limit';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status: 'pending' | 'pushing' | 'modified' | 'pushed' | 'unknown' | 'error';\n icon: string;\n index: number;\n error?: Error;\n errorMessage?: string;\n spinnerFrameIndex?: number;\n};\n\nconst spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\nconst RESET = '\\x1b[0m';\nconst GREEN = '\\x1b[32m';\nconst RED = '\\x1b[31m';\nconst BLUE = '\\x1b[34m';\nconst GREY = '\\x1b[90m';\n\n/**\n * Get all locale dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n try {\n const { clientId, clientSecret } = getConfiguration().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 oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n let dictionaries: Dictionary[] = Object.values(dictionariesRecord);\n const existingDictionariesKeys: string[] = Object.keys(dictionariesRecord);\n\n if (options?.dictionaries) {\n // Check if the provided dictionaries exist\n const noneExistingDictionariesOption = options.dictionaries.filter(\n (dictionaryId) => !existingDictionariesKeys.includes(dictionaryId)\n );\n\n if (noneExistingDictionariesOption.length > 0) {\n console.error(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`\n );\n }\n\n // Filter the dictionaries from the provided list of IDs\n dictionaries = dictionaries.filter((dictionary) =>\n options.dictionaries!.includes(dictionary.key)\n );\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n console.error('No local dictionaries found');\n return;\n }\n\n console.info('Pushing dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary, index) => ({\n dictionary,\n icon: getStatusIcon('pending'),\n status: 'pending',\n index,\n spinnerFrameIndex: 0,\n })\n );\n\n // Output initial statuses\n for (const statusObj of dictionariesStatuses) {\n process.stdout.write(getStatusLine(statusObj) + '\\n');\n }\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n // Start spinner timer\n const spinnerTimer = setInterval(() => {\n updateAllStatusLines(dictionariesStatuses);\n }, 100); // Update every 100ms\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries(\n [statusObj.dictionary],\n {\n headers: {\n Authorization: `Bearer ${oAuth2AccessToken}`,\n },\n }\n );\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries || [];\n const newDictionaries = pushResult.data?.newDictionaries || [];\n\n if (updatedDictionaries.includes(statusObj.dictionary.key)) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n } else if (newDictionaries.includes(statusObj.dictionary.key)) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n } else {\n statusObj.status = 'unknown';\n }\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error pushing dictionary ${statusObj.dictionary.key}: ${error}`;\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit\n const limit = pLimit(5); // Adjust the limit as needed\n const pushPromises = dictionariesStatuses.map((statusObj) =>\n limit(() => processDictionary(statusObj))\n );\n await Promise.all(pushPromises);\n\n // Stop the spinner timer\n clearInterval(spinnerTimer);\n\n // Update statuses one last time\n updateAllStatusLines(dictionariesStatuses);\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n console.error(statusObj.errorMessage);\n }\n }\n\n // Handle delete or keep options\n const deleteOption = options?.deleteLocaleDictionary;\n const keepOption = options?.keepLocaleDictionary;\n\n if (deleteOption && keepOption) {\n throw new Error(\n 'Cannot specify both --deleteLocaleDictionary and --keepLocaleDictionary options.'\n );\n }\n\n if (deleteOption) {\n // Delete only the successfully pushed dictionaries\n await deleteLocalDictionaries(successfullyPushedDictionaries);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const answer = await askUser(\n 'Do you want to delete the local dictionaries that were successfully pushed? (yes/no): '\n );\n if (answer.toLowerCase() === 'yes' || answer.toLowerCase() === 'y') {\n await deleteLocalDictionaries(successfullyPushedDictionaries);\n }\n }\n } catch (error) {\n console.error(error);\n }\n};\n\nconst askUser = (question: string): Promise<string> => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n return new Promise((resolve) => {\n rl.question(question, (answer: string) => {\n rl.close();\n resolve(answer);\n });\n });\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[]\n): Promise<void> => {\n const { baseDir } = getConfiguration().content;\n\n // Use a Set to collect all unique file paths\n const filePathsSet: Set<string> = new Set();\n\n for (const dictionary of dictionariesToDelete) {\n const { filePath } = dictionary;\n\n if (!filePath) {\n console.error(`Dictionary ${dictionary.key} does not have a file path`);\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n const relativePath = relative(baseDir, filePath);\n\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n console.info(`Deleted file ${relativePath}`);\n } else if (stats.isDirectory()) {\n console.warn(`Path is a directory ${relativePath}, skipping.`);\n } else {\n console.warn(`Unknown file type for ${relativePath}, skipping.`);\n }\n } catch (err) {\n console.error(`Error deleting ${relativePath}:`, err);\n }\n }\n};\n\nconst getStatusIcon = (status: string): string => {\n const statusIcons: Record<string, string> = {\n pending: '⏲',\n pushing: '', // Spinner handled separately\n modified: '✔',\n pushed: '✔',\n error: '✖',\n };\n return statusIcons[status] || '';\n};\n\nconst getStatusLine = (statusObj: DictionariesStatus): string => {\n let icon = getStatusIcon(statusObj.status);\n let colorStart = '';\n let colorEnd = '';\n\n if (statusObj.status === 'pushing') {\n // Use spinner frame\n icon = spinnerFrames[statusObj.spinnerFrameIndex! % spinnerFrames.length];\n colorStart = BLUE;\n colorEnd = RESET;\n } else if (statusObj.status === 'error') {\n colorStart = RED;\n colorEnd = RESET;\n } else if (statusObj.status === 'pushed' || statusObj.status === 'modified') {\n colorStart = GREEN;\n colorEnd = RESET;\n } else {\n colorStart = GREY;\n colorEnd = RESET;\n }\n\n return `- ${statusObj.dictionary.key} [${colorStart}${icon} ${statusObj.status}${colorEnd}]`;\n};\n\nconst updateAllStatusLines = (dictionariesStatuses: DictionariesStatus[]) => {\n // Move cursor up to the first status line\n readline.moveCursor(process.stdout, 0, -dictionariesStatuses.length);\n for (const statusObj of dictionariesStatuses) {\n // Clear the line\n readline.clearLine(process.stdout, 0);\n\n if (statusObj.status === 'pushing') {\n // Update spinner frame\n statusObj.spinnerFrameIndex =\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,QAAQ,GAAG,CAAC,qBAAqB,MAAM;AACnE,aAAW,aAAa,sBAAsB;AAE5C,aAAS,UAAU,QAAQ,QAAQ,CAAC;AAEpC,QAAI,UAAU,WAAW,WAAW;AAElC,gBAAU,qBACP,UAAU,oBAAqB,KAAK,cAAc;AAAA,IACvD;AAGA,YAAQ,OAAO,MAAM,cAAc,SAAS,IAAI,IAAI;AAAA,EACtD;AACF;","names":["dictionariesRecord","pLimit"]}
|
|
1
|
+
{"version":3,"sources":["../../src/push.ts"],"sourcesContent":["import * as fsPromises from 'fs/promises';\nimport { relative } from 'path';\nimport * as readline from 'readline';\nimport { getConfiguration } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { intlayerAPI } from '@intlayer/design-system/libs';\nimport dictionariesRecord from '@intlayer/dictionaries-entry';\nimport pLimit from 'p-limit';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status: 'pending' | 'pushing' | 'modified' | 'pushed' | 'unknown' | 'error';\n icon: string;\n index: number;\n error?: Error;\n errorMessage?: string;\n spinnerFrameIndex?: number;\n};\n\nconst spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\nconst RESET = '\\x1b[0m';\nconst GREEN = '\\x1b[32m';\nconst RED = '\\x1b[31m';\nconst BLUE = '\\x1b[34m';\nconst GREY = '\\x1b[90m';\n\n/**\n * Get all locale dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n try {\n const { clientId, clientSecret } = getConfiguration().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 oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n let dictionaries: Dictionary[] = Object.values(dictionariesRecord);\n const existingDictionariesKeys: string[] = Object.keys(dictionariesRecord);\n\n if (options?.dictionaries) {\n // Check if the provided dictionaries exist\n const noneExistingDictionariesOption = options.dictionaries.filter(\n (dictionaryId) => !existingDictionariesKeys.includes(dictionaryId)\n );\n\n if (noneExistingDictionariesOption.length > 0) {\n console.error(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`\n );\n }\n\n // Filter the dictionaries from the provided list of IDs\n dictionaries = dictionaries.filter((dictionary) =>\n options.dictionaries!.includes(dictionary.key)\n );\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n console.error('No local dictionaries found');\n return;\n }\n\n console.info('Pushing dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary, index) => ({\n dictionary,\n icon: getStatusIcon('pending'),\n status: 'pending',\n index,\n spinnerFrameIndex: 0,\n })\n );\n\n // Output initial statuses\n for (const statusObj of dictionariesStatuses) {\n process.stdout.write(getStatusLine(statusObj) + '\\n');\n }\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n // Start spinner timer\n const spinnerTimer = setInterval(() => {\n updateAllStatusLines(dictionariesStatuses);\n }, 100); // Update every 100ms\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries(\n [statusObj.dictionary],\n {\n headers: {\n Authorization: `Bearer ${oAuth2AccessToken}`,\n },\n }\n );\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries || [];\n const newDictionaries = pushResult.data?.newDictionaries || [];\n\n if (updatedDictionaries.includes(statusObj.dictionary.key)) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n } else if (newDictionaries.includes(statusObj.dictionary.key)) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n } else {\n statusObj.status = 'unknown';\n }\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error pushing dictionary ${statusObj.dictionary.key}: ${error}`;\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit\n const limit = pLimit(5); // Limit the number of concurrent requests\n const pushPromises = dictionariesStatuses.map((statusObj) =>\n limit(() => processDictionary(statusObj))\n );\n await Promise.all(pushPromises);\n\n // Stop the spinner timer\n clearInterval(spinnerTimer);\n\n // Update statuses one last time\n updateAllStatusLines(dictionariesStatuses);\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n console.error(statusObj.errorMessage);\n }\n }\n\n // Handle delete or keep options\n const deleteOption = options?.deleteLocaleDictionary;\n const keepOption = options?.keepLocaleDictionary;\n\n if (deleteOption && keepOption) {\n throw new Error(\n 'Cannot specify both --deleteLocaleDictionary and --keepLocaleDictionary options.'\n );\n }\n\n if (deleteOption) {\n // Delete only the successfully pushed dictionaries\n await deleteLocalDictionaries(successfullyPushedDictionaries);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const answer = await askUser(\n 'Do you want to delete the local dictionaries that were successfully pushed? (yes/no): '\n );\n if (answer.toLowerCase() === 'yes' || answer.toLowerCase() === 'y') {\n await deleteLocalDictionaries(successfullyPushedDictionaries);\n }\n }\n } catch (error) {\n console.error(error);\n }\n};\n\nconst askUser = (question: string): Promise<string> => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n return new Promise((resolve) => {\n rl.question(question, (answer: string) => {\n rl.close();\n resolve(answer);\n });\n });\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[]\n): Promise<void> => {\n const { baseDir } = getConfiguration().content;\n\n // Use a Set to collect all unique file paths\n const filePathsSet: Set<string> = new Set();\n\n for (const dictionary of dictionariesToDelete) {\n const { filePath } = dictionary;\n\n if (!filePath) {\n console.error(`Dictionary ${dictionary.key} does not have a file path`);\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n const relativePath = relative(baseDir, filePath);\n\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n console.info(`Deleted file ${relativePath}`);\n } else if (stats.isDirectory()) {\n console.warn(`Path is a directory ${relativePath}, skipping.`);\n } else {\n console.warn(`Unknown file type for ${relativePath}, skipping.`);\n }\n } catch (err) {\n console.error(`Error deleting ${relativePath}:`, err);\n }\n }\n};\n\nconst getStatusIcon = (status: string): string => {\n const statusIcons: Record<string, string> = {\n pending: '⏲',\n pushing: '', // Spinner handled separately\n modified: '✔',\n pushed: '✔',\n error: '✖',\n };\n return statusIcons[status] || '';\n};\n\nconst getStatusLine = (statusObj: DictionariesStatus): string => {\n let icon = getStatusIcon(statusObj.status);\n let colorStart = '';\n let colorEnd = '';\n\n if (statusObj.status === 'pushing') {\n // Use spinner frame\n icon = spinnerFrames[statusObj.spinnerFrameIndex! % spinnerFrames.length];\n colorStart = BLUE;\n colorEnd = RESET;\n } else if (statusObj.status === 'error') {\n colorStart = RED;\n colorEnd = RESET;\n } else if (statusObj.status === 'pushed' || statusObj.status === 'modified') {\n colorStart = GREEN;\n colorEnd = RESET;\n } else {\n colorStart = GREY;\n colorEnd = RESET;\n }\n\n return `- ${statusObj.dictionary.key} [${colorStart}${icon} ${statusObj.status}${colorEnd}]`;\n};\n\nconst updateAllStatusLines = (dictionariesStatuses: DictionariesStatus[]) => {\n // Move cursor up to the first status line\n readline.moveCursor(process.stdout, 0, -dictionariesStatuses.length);\n for (const statusObj of dictionariesStatuses) {\n // Clear the line\n readline.clearLine(process.stdout, 0);\n\n if (statusObj.status === 'pushing') {\n // Update spinner frame\n statusObj.spinnerFrameIndex =\n (statusObj.spinnerFrameIndex! + 1) % spinnerFrames.length;\n }\n\n // Write the status line\n process.stdout.write(getStatusLine(statusObj) + '\\n');\n }\n};\n"],"mappings":";;;;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AI,UAAU,WAAW,WAAW;AAElC,gBAAU,qBACP,UAAU,oBAAqB,KAAK,cAAc;AAAA,IACvD;AAGA,YAAQ,OAAO,MAAM,cAAc,SAAS,IAAI,IAAI;AAAA,EACtD;AACF;","names":["dictionariesRecord","pLimit"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
```javascript
|
|
2
|
+
const { t, enu } = require("intlayer");
|
|
3
|
+
|
|
4
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
5
|
+
module.exports = {
|
|
6
|
+
key: "my-key",
|
|
7
|
+
content: {
|
|
8
|
+
exampleText: t({
|
|
9
|
+
en: "Example of content in English",
|
|
10
|
+
fr: "Example de contenu en français",
|
|
11
|
+
es: "Ejemplo de contenido en español",
|
|
12
|
+
}),
|
|
13
|
+
numberOfCar: enu({
|
|
14
|
+
"<-1": "Less than minus one car",
|
|
15
|
+
"-1": "Minus one car",
|
|
16
|
+
0: "No cars",
|
|
17
|
+
1: "One car",
|
|
18
|
+
">5": "Some cars",
|
|
19
|
+
">19": "Many cars",
|
|
20
|
+
}),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
```json
|
|
2
|
+
{
|
|
3
|
+
"key": "my-key",
|
|
4
|
+
"content": {
|
|
5
|
+
"profileText": {
|
|
6
|
+
"NodeType": "translation",
|
|
7
|
+
"translation": {
|
|
8
|
+
"en": "Manage profile",
|
|
9
|
+
"fr": "Gérer le profil",
|
|
10
|
+
"es": "Administrar perfil"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"numberOfCar": {
|
|
14
|
+
"NodeType": "enumeration",
|
|
15
|
+
"enumeration": {
|
|
16
|
+
"<-1": "Less than minus one car",
|
|
17
|
+
"-1": "Minus one car",
|
|
18
|
+
"0": "No cars",
|
|
19
|
+
"1": "One car",
|
|
20
|
+
">5": "Some cars",
|
|
21
|
+
">19": "Many cars"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
```tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { t, enu, type DeclarationContent } from "intlayer";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
key: "my-key",
|
|
7
|
+
content: {
|
|
8
|
+
exampleText: t({
|
|
9
|
+
en: "Example of content in English",
|
|
10
|
+
fr: "Example de contenu en français",
|
|
11
|
+
es: "Ejemplo de contenido en español",
|
|
12
|
+
}),
|
|
13
|
+
exampleOfReactNode: t({
|
|
14
|
+
en: <h1>Example of ReactNode in English</h1>,
|
|
15
|
+
fr: <h1>Example de ReactNode en français</h1>,
|
|
16
|
+
es: <h1>Ejemplo de ReactNode en español</h1>,
|
|
17
|
+
}),
|
|
18
|
+
numberOfCar: enu({
|
|
19
|
+
"<-1": "Less than minus one car",
|
|
20
|
+
"-1": "Minus one car",
|
|
21
|
+
"0": "No cars",
|
|
22
|
+
"1": "One car",
|
|
23
|
+
">5": "Some cars",
|
|
24
|
+
">19": "Many cars",
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
```javascript
|
|
2
|
+
import { t, enu } from "intlayer";
|
|
3
|
+
|
|
4
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
5
|
+
export default {
|
|
6
|
+
key: "my-key",
|
|
7
|
+
content: {
|
|
8
|
+
exampleText: t({
|
|
9
|
+
en: "Example of content in English",
|
|
10
|
+
fr: "Example de contenu en français",
|
|
11
|
+
es: "Ejemplo de contenido en español",
|
|
12
|
+
}),
|
|
13
|
+
numberOfCar: enu({
|
|
14
|
+
"<-1": "Less than minus one car",
|
|
15
|
+
"-1": "Minus one car",
|
|
16
|
+
0: "No cars",
|
|
17
|
+
1: "One car",
|
|
18
|
+
">5": "Some cars",
|
|
19
|
+
">19": "Many cars",
|
|
20
|
+
}),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
```
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
You are an expert in internationalization and content management. Your task is to audit the content declaration files in the project and identify any potential issues or inconsistencies. Provide a detailed report of any issues found, including the file path, line number, and a brief explanation of the issue.
|
|
2
|
+
|
|
3
|
+
**Instructions:**
|
|
4
|
+
|
|
5
|
+
1. **File Location:**
|
|
6
|
+
|
|
7
|
+
- The content declaration files are located in the `{{filePath}}` directory relative to the project root.
|
|
8
|
+
|
|
9
|
+
2. **Locales:**
|
|
10
|
+
|
|
11
|
+
- Default locale: {{defaultLocale}}
|
|
12
|
+
- Required Locales: {{otherLocales}} (add the missing locales in `t({ ... })` function)
|
|
13
|
+
|
|
14
|
+
3. **Content Declaration Format:**
|
|
15
|
+
|
|
16
|
+
- Example format:
|
|
17
|
+
|
|
18
|
+
{{declarationsContentTemplate}}
|
|
19
|
+
|
|
20
|
+
4. **Audit Requirements:**
|
|
21
|
+
|
|
22
|
+
- **Consistency:** Ensure that all keys have translations for all specified locales.
|
|
23
|
+
- **Missing Content:** Identify any missing translations and specify the expected content.
|
|
24
|
+
- **Misplaced Content:** Detect if any translations are placed under incorrect keys.
|
|
25
|
+
- **Type Compliance:** Verify that the content types match the declarations (e.g., strings, string arrays).
|
|
26
|
+
|
|
27
|
+
5. **Modification Guidelines:**
|
|
28
|
+
|
|
29
|
+
- **Do Not Alter Structure:** If the file structure is correct, do not modify it. Only add, update, or remove content declarations as necessary.
|
|
30
|
+
- **Do Not Change a value type** If a key value is like `exampleKey: "exampleValue"`, avoid a maximum to not change the value type to `exampleKey: t({ en: "exampleValue" })`.
|
|
31
|
+
- **Return Only Final File Content:** Provide the updated file content without any additional comments or explanations.
|
|
32
|
+
- **Ensure No Translations are Missing:** If an element is a multilingual content and a translation is missing, add it. Including localized content as `es-MX` or `en-UK`.
|
|
33
|
+
- **Manage Localizations:** If the required languages contains similar languages, as `en` and `en-GB`, consider `en` as English US and `en-GB` as English UK, and insert or review both translations to maintain clarity and correctness.
|
|
34
|
+
- **Order Translations:** If the translations are not in the same order as the required languages list, consider reordering the translations to maintain clarity and correctness.
|
|
35
|
+
- **Escape Special Characters:** If the translations contain special characters, escape them using the appropriate escape sequence.
|
|
36
|
+
|
|
37
|
+
6. **Example Scenario:**
|
|
38
|
+
|
|
39
|
+
- **Example 1:**
|
|
40
|
+
|
|
41
|
+
- **Input File:**
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { t, type DeclarationContent } from "intlayer";
|
|
45
|
+
|
|
46
|
+
export default {
|
|
47
|
+
key: "creative-work-structured-data",
|
|
48
|
+
content: {
|
|
49
|
+
audienceType: t({
|
|
50
|
+
en: "Developers, Content Managers",
|
|
51
|
+
fr: "Développeurs, Responsables de contenu",
|
|
52
|
+
es: "Desarrolladores, Gestores de Contenido",
|
|
53
|
+
}),
|
|
54
|
+
},
|
|
55
|
+
} satisfies DeclarationContent;
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- **Expected Output (No Changes Needed):**
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { t, type DeclarationContent } from "intlayer";
|
|
62
|
+
|
|
63
|
+
export default {
|
|
64
|
+
key: "creative-work-structured-data",
|
|
65
|
+
content: {
|
|
66
|
+
audienceType: t({
|
|
67
|
+
en: "Developers, Content Managers",
|
|
68
|
+
fr: "Développeurs, Responsables de contenu",
|
|
69
|
+
es: "Desarrolladores, Gestores de Contenido",
|
|
70
|
+
}),
|
|
71
|
+
},
|
|
72
|
+
} satisfies DeclarationContent;
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- **Incorrect Output (Unwanted Structural Change):**
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { t, type DeclarationContent } from "intlayer";
|
|
79
|
+
|
|
80
|
+
export default {
|
|
81
|
+
key: "creative-work-structured-data",
|
|
82
|
+
content: {
|
|
83
|
+
audienceType: t({
|
|
84
|
+
en: "Developers, Content Managers",
|
|
85
|
+
fr: "Développeurs, Responsables de contenu",
|
|
86
|
+
es: "Desarrolladores, Gestores de Contenido",
|
|
87
|
+
}),
|
|
88
|
+
// Missing multilingual content for 'projectDescription'
|
|
89
|
+
projectDescription: t({
|
|
90
|
+
en: "This project involves structured data for creative work.",
|
|
91
|
+
fr: "Ce projet implique des données structurées pour le travail créatif.",
|
|
92
|
+
es: "Este proyecto involucra datos estructurados para trabajo creativo.",
|
|
93
|
+
}),
|
|
94
|
+
},
|
|
95
|
+
} satisfies DeclarationContent;
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
- **Clarification:** In this scenario, since the input file is already valid and complete, the expected output should be identical to the input without any additional fields or comments.
|
|
99
|
+
|
|
100
|
+
- **Example 2:**
|
|
101
|
+
|
|
102
|
+
- **Input File:**
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { t } from "react-intlayer";
|
|
106
|
+
|
|
107
|
+
const content = {
|
|
108
|
+
key: "creative-work-structured-data",
|
|
109
|
+
content: {
|
|
110
|
+
audienceType: t({
|
|
111
|
+
en: "Developers, Content Managers",
|
|
112
|
+
es: "Desarrolladores, Gestores de Contenido",
|
|
113
|
+
}),
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
- **Expected Output (No Changes Needed):**
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import { t, type DeclarationContent } from "intlayer";
|
|
122
|
+
|
|
123
|
+
const content = {
|
|
124
|
+
key: "creative-work-structured-data",
|
|
125
|
+
content: {
|
|
126
|
+
audienceType: t({
|
|
127
|
+
en: "Developers, Content Managers",
|
|
128
|
+
fr: "Développeurs, Responsables de contenu",
|
|
129
|
+
es: "Desarrolladores, Gestores de Contenido",
|
|
130
|
+
}),
|
|
131
|
+
},
|
|
132
|
+
} satisfies DeclarationContent;
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- **Clarification:** In this scenario:
|
|
136
|
+
- A missing translation for the `audienceType` key was added.
|
|
137
|
+
- The import of the `t` function was imported from `react-intlayer` instead of `intlayer`.
|
|
138
|
+
- A type `DeclarationContent` was added to the file to strengthen the content declaration.
|
|
139
|
+
|
|
140
|
+
**File to Audit:**
|
|
141
|
+
|
|
142
|
+
{{fileContent}}
|
|
143
|
+
|
|
144
|
+
**Expected Response:**
|
|
145
|
+
|
|
146
|
+
After auditing, provide only the final content of the file as plain text without any Markdown or code block formatting. If no changes are needed, return the file content exactly as it is.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
```tsx
|
|
2
|
+
import React, { type ReactNode } from "react";
|
|
3
|
+
import { t, enu, type DeclarationContent } from "intlayer";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
key: "my-key",
|
|
7
|
+
content: {
|
|
8
|
+
exampleText: t({
|
|
9
|
+
en: "Example of content in English",
|
|
10
|
+
fr: "Example de contenu en français",
|
|
11
|
+
es: "Ejemplo de contenido en español",
|
|
12
|
+
}),
|
|
13
|
+
exampleOfReactNode: t<ReactNode>({
|
|
14
|
+
en: <h1>Example of ReactNode in English</h1>,
|
|
15
|
+
fr: <h1>Example de ReactNode en français</h1>,
|
|
16
|
+
es: <h1>Ejemplo de ReactNode en español</h1>,
|
|
17
|
+
}),
|
|
18
|
+
numberOfCar: enu({
|
|
19
|
+
"<-1": "Less than minus one car",
|
|
20
|
+
"-1": "Minus one car",
|
|
21
|
+
"0": "No cars",
|
|
22
|
+
"1": "One car",
|
|
23
|
+
">5": "Some cars",
|
|
24
|
+
">19": "Many cars",
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
} satisfies DeclarationContent;
|
|
28
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
```typescript
|
|
2
|
+
import { t, enu, type DeclarationContent } from "intlayer";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "my-key",
|
|
6
|
+
content: {
|
|
7
|
+
exampleText: t({
|
|
8
|
+
en: "Example of content in English",
|
|
9
|
+
fr: "Example de contenu en français",
|
|
10
|
+
es: "Ejemplo de contenido en español",
|
|
11
|
+
}),
|
|
12
|
+
numberOfCar: enu({
|
|
13
|
+
"<-1": "Less than minus one car",
|
|
14
|
+
"-1": "Minus one car",
|
|
15
|
+
"0": "No cars",
|
|
16
|
+
"1": "One car",
|
|
17
|
+
">5": "Some cars",
|
|
18
|
+
">19": "Many cars",
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
} satisfies DeclarationContent;
|
|
22
|
+
```
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
2
|
+
import { join, relative } from "path";
|
|
3
|
+
import { getConfiguration } from "@intlayer/config";
|
|
4
|
+
import { getLocaleName } from "@intlayer/core";
|
|
5
|
+
import { OpenAI } from "openai";
|
|
6
|
+
import pLimit from "p-limit";
|
|
7
|
+
import { getContentDeclaration } from '../listContentDeclaration.mjs';
|
|
8
|
+
const projectPath = process.cwd();
|
|
9
|
+
const getFileContent = (filePath) => {
|
|
10
|
+
const fileContent = readFileSync(filePath, "utf-8");
|
|
11
|
+
return fileContent;
|
|
12
|
+
};
|
|
13
|
+
const writeFileContent = (filePath, content) => {
|
|
14
|
+
writeFileSync(filePath, content);
|
|
15
|
+
};
|
|
16
|
+
const getAbsolutePath = (filePath) => {
|
|
17
|
+
const absolutePath = join(__dirname, filePath);
|
|
18
|
+
return absolutePath;
|
|
19
|
+
};
|
|
20
|
+
const FILE_TEMPLATE = {
|
|
21
|
+
ts: getFileContent(getAbsolutePath("./TS_FORMAT.md")),
|
|
22
|
+
tsx: getFileContent(getAbsolutePath("./TSX_FORMAT.md")),
|
|
23
|
+
js: getFileContent(getAbsolutePath("./MJS_FORMAT.md")),
|
|
24
|
+
mjs: getFileContent(getAbsolutePath("./MJS_FORMAT.md")),
|
|
25
|
+
cjs: getFileContent(getAbsolutePath("./CJS_FORMAT.md")),
|
|
26
|
+
jsx: getFileContent(getAbsolutePath("./JSX_FORMAT.md")),
|
|
27
|
+
json: getFileContent(getAbsolutePath("./JSON_FORMAT.md"))
|
|
28
|
+
};
|
|
29
|
+
const CHAT_GPT_PROMPT = getFileContent(getAbsolutePath("./PROMPT.md"));
|
|
30
|
+
const formatLocaleWithName = (locale) => {
|
|
31
|
+
const localeName = getLocaleName(locale);
|
|
32
|
+
return `${locale}: ${localeName}`;
|
|
33
|
+
};
|
|
34
|
+
const auditFile = async (filePath, options) => {
|
|
35
|
+
try {
|
|
36
|
+
const relativePath = relative(projectPath, filePath);
|
|
37
|
+
console.info(`Auditing file: ${relativePath}`);
|
|
38
|
+
const { internationalization } = getConfiguration();
|
|
39
|
+
const { defaultLocale, locales } = internationalization;
|
|
40
|
+
const openai = new OpenAI({
|
|
41
|
+
apiKey: options?.openAiApiKey
|
|
42
|
+
});
|
|
43
|
+
const fileContent = getFileContent(filePath);
|
|
44
|
+
const splitted = filePath.split(".");
|
|
45
|
+
const fileExtension = splitted[splitted.length - 1];
|
|
46
|
+
const prompt = options?.customPrompt ?? CHAT_GPT_PROMPT.replace("{{filePath}}", filePath).replace(
|
|
47
|
+
"{{defaultLocale}}",
|
|
48
|
+
`{${formatLocaleWithName(defaultLocale)}}`
|
|
49
|
+
).replace(
|
|
50
|
+
"{{otherLocales}}",
|
|
51
|
+
`{${locales.map(formatLocaleWithName).join(", ")}}`
|
|
52
|
+
).replace(
|
|
53
|
+
"{{declarationsContentTemplate}}",
|
|
54
|
+
FILE_TEMPLATE[fileExtension]
|
|
55
|
+
).replace("{{fileContent}}", fileContent);
|
|
56
|
+
const chatCompletion = await openai.chat.completions.create({
|
|
57
|
+
model: options?.model ?? "gpt-4o-mini",
|
|
58
|
+
messages: [{ role: "system", content: prompt }]
|
|
59
|
+
});
|
|
60
|
+
const newContent = chatCompletion.choices[0].message?.content;
|
|
61
|
+
if (newContent) {
|
|
62
|
+
writeFileContent(filePath, newContent);
|
|
63
|
+
console.info(`${options?.logPrefix ?? ""}File ${relativePath} updated`);
|
|
64
|
+
}
|
|
65
|
+
console.info(
|
|
66
|
+
`${options?.logPrefix ?? ""}${chatCompletion.usage?.total_tokens} tokens used in the request`
|
|
67
|
+
);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(error);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const audit = async (options) => {
|
|
73
|
+
if (!options?.openAiApiKey) {
|
|
74
|
+
console.error(
|
|
75
|
+
"OpenAI API key is required to audit the content declaration files."
|
|
76
|
+
);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
let contentDeclarationFilesList = options?.files;
|
|
80
|
+
if (!contentDeclarationFilesList) {
|
|
81
|
+
const contentDeclarationFilesPath = getContentDeclaration({
|
|
82
|
+
exclude: options?.excludedGlobs
|
|
83
|
+
});
|
|
84
|
+
contentDeclarationFilesList = contentDeclarationFilesPath;
|
|
85
|
+
}
|
|
86
|
+
const limit = pLimit(options?.asyncLimit ? Number(options?.asyncLimit) : 5);
|
|
87
|
+
const pushPromises = contentDeclarationFilesList.map(
|
|
88
|
+
(filePath) => limit(() => auditFile(filePath, options))
|
|
89
|
+
);
|
|
90
|
+
await Promise.all(pushPromises);
|
|
91
|
+
};
|
|
92
|
+
export {
|
|
93
|
+
audit,
|
|
94
|
+
auditFile
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/audit/index.ts"],"sourcesContent":["import { readFileSync, writeFileSync } from 'fs';\nimport { join, relative } from 'path';\nimport { getConfiguration, Locales } from '@intlayer/config';\nimport { getLocaleName } from '@intlayer/core';\nimport { OpenAI } from 'openai';\nimport pLimit from 'p-limit';\nimport { getContentDeclaration } from '../listContentDeclaration';\n\n// Depending on your implementation, you may need the OpenAI API client.\n// For instance, you can use `openai` npm package (https://www.npmjs.com/package/openai).\n\ntype AuditOptions = {\n files?: string[];\n logPrefix?: string;\n model?: string;\n customPrompt?: string;\n asyncLimit?: number;\n openAiApiKey?: string;\n excludedGlobs?: string[];\n};\n\nconst projectPath = process.cwd();\n\n/**\n * Reads the content of a file synchronously.\n *\n * @function\n * @param filePath - The relative or absolute path to the target file.\n * @returns The entire contents of the specified file as a UTF-8 encoded string.\n */\nconst getFileContent = (filePath: string): string => {\n // Read the file content using Node.js fs module.\n const fileContent = readFileSync(filePath, 'utf-8');\n return fileContent;\n};\n\nconst writeFileContent = (filePath: string, content: string) => {\n writeFileSync(filePath, content);\n};\n\nconst getAbsolutePath = (filePath: string): string => {\n const absolutePath = join(__dirname, filePath);\n\n return absolutePath;\n};\n\nconst FILE_TEMPLATE: Record<string, string> = {\n ts: getFileContent(getAbsolutePath('./TS_FORMAT.md')),\n tsx: getFileContent(getAbsolutePath('./TSX_FORMAT.md')),\n js: getFileContent(getAbsolutePath('./MJS_FORMAT.md')),\n mjs: getFileContent(getAbsolutePath('./MJS_FORMAT.md')),\n cjs: getFileContent(getAbsolutePath('./CJS_FORMAT.md')),\n jsx: getFileContent(getAbsolutePath('./JSX_FORMAT.md')),\n json: getFileContent(getAbsolutePath('./JSON_FORMAT.md')),\n};\n\n// The prompt template to send to ChatGPT, requesting an audit of content declaration files.\nconst CHAT_GPT_PROMPT = getFileContent(getAbsolutePath('./PROMPT.md'));\n\n/**\n * Formats a locale with its full name and returns a string representation.\n *\n * @function\n * @param locale - A locale from the project's configuration (e.g., 'en-US', 'fr-FR').\n * @returns A formatted string combining the locale's name and code. Example: \"English (US): en-US\".\n */\nconst formatLocaleWithName = (locale: Locales): string => {\n // getLocaleName returns a human-readable name for the locale.\n const localeName = getLocaleName(locale);\n\n // Concatenate both the readable name and the locale code.\n return `${locale}: ${localeName}`;\n};\n\n/**\n * Audits a content declaration file by constructing a prompt for ChatGPT.\n * The prompt includes details about the project's locales, file paths of content declarations,\n * and requests for identifying issues or inconsistencies. It prints the prompt for each file,\n * and could be adapted to send requests to the ChatGPT model.\n *\n * @async\n * @function\n * @param filePath - The relative or absolute path to the target file.\n * @param options - Optional configuration for the audit process.\n * @returns This function returns a Promise that resolves once the audit is complete.\n */\nexport const auditFile = async (filePath: string, options?: AuditOptions) => {\n try {\n const relativePath = relative(projectPath, filePath);\n console.info(`Auditing file: ${relativePath}`);\n\n // Extract internationalization configuration, including locales and the default locale.\n const { internationalization } = getConfiguration();\n const { defaultLocale, locales } = internationalization;\n\n // Optionally, you could initialize and configure the OpenAI client here, if you intend to make API calls.\n // Uncomment and configure the following lines if you have `openai` installed and want to call the API:\n\n const openai = new OpenAI({\n apiKey: options?.openAiApiKey,\n });\n\n // Read the file's content.\n const fileContent = getFileContent(filePath);\n const splitted = filePath.split('.');\n const fileExtension = splitted[splitted.length - 1];\n\n // Prepare the prompt for ChatGPT by replacing placeholders with actual values.\n const prompt =\n options?.customPrompt ??\n CHAT_GPT_PROMPT.replace('{{filePath}}', filePath)\n .replace(\n '{{defaultLocale}}',\n `{${formatLocaleWithName(defaultLocale)}}`\n )\n .replace(\n '{{otherLocales}}',\n `{${locales.map(formatLocaleWithName).join(', ')}}`\n )\n .replace(\n '{{declarationsContentTemplate}}',\n FILE_TEMPLATE[fileExtension]\n )\n .replace('{{fileContent}}', fileContent);\n\n // Example of how you might request a completion from ChatGPT:\n const chatCompletion = await openai.chat.completions.create({\n model: options?.model ?? 'gpt-4o-mini',\n messages: [{ role: 'system', content: prompt }],\n });\n\n const newContent = chatCompletion.choices[0].message?.content;\n\n if (newContent) {\n writeFileContent(filePath, newContent);\n\n console.info(`${options?.logPrefix ?? ''}File ${relativePath} updated`);\n }\n\n console.info(\n `${options?.logPrefix ?? ''}${chatCompletion.usage?.total_tokens} tokens used in the request`\n );\n } catch (error) {\n console.error(error);\n }\n};\n\n/**\n * Audits the content declaration files by constructing a prompt for ChatGPT.\n * The prompt includes details about the project's locales, file paths of content declarations,\n * and requests for identifying issues or inconsistencies. It prints the prompt for each file,\n * and could be adapted to send requests to the ChatGPT model.\n *\n * @async\n * @function\n * @param options - Optional configuration for the audit process.\n * @returns This function returns a Promise that resolves once the audit is complete.\n */\nexport const audit = async (options: AuditOptions) => {\n if (!options?.openAiApiKey) {\n console.error(\n 'OpenAI API key is required to audit the content declaration files.'\n );\n return;\n }\n\n let contentDeclarationFilesList = options?.files;\n\n if (!contentDeclarationFilesList) {\n // Retrieve all content declaration file paths using a helper function.\n const contentDeclarationFilesPath = getContentDeclaration({\n exclude: options?.excludedGlobs,\n });\n\n contentDeclarationFilesList = contentDeclarationFilesPath;\n }\n\n const limit = pLimit(options?.asyncLimit ? Number(options?.asyncLimit) : 5); // Limit the number of concurrent requests\n const pushPromises = contentDeclarationFilesList.map((filePath) =>\n limit(() => auditFile(filePath, options))\n );\n await Promise.all(pushPromises);\n};\n"],"mappings":"AAAA,SAAS,cAAc,qBAAqB;AAC5C,SAAS,MAAM,gBAAgB;AAC/B,SAAS,wBAAiC;AAC1C,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AACvB,OAAO,YAAY;AACnB,SAAS,6BAA6B;AAetC,MAAM,cAAc,QAAQ,IAAI;AAShC,MAAM,iBAAiB,CAAC,aAA6B;AAEnD,QAAM,cAAc,aAAa,UAAU,OAAO;AAClD,SAAO;AACT;AAEA,MAAM,mBAAmB,CAAC,UAAkB,YAAoB;AAC9D,gBAAc,UAAU,OAAO;AACjC;AAEA,MAAM,kBAAkB,CAAC,aAA6B;AACpD,QAAM,eAAe,KAAK,WAAW,QAAQ;AAE7C,SAAO;AACT;AAEA,MAAM,gBAAwC;AAAA,EAC5C,IAAI,eAAe,gBAAgB,gBAAgB,CAAC;AAAA,EACpD,KAAK,eAAe,gBAAgB,iBAAiB,CAAC;AAAA,EACtD,IAAI,eAAe,gBAAgB,iBAAiB,CAAC;AAAA,EACrD,KAAK,eAAe,gBAAgB,iBAAiB,CAAC;AAAA,EACtD,KAAK,eAAe,gBAAgB,iBAAiB,CAAC;AAAA,EACtD,KAAK,eAAe,gBAAgB,iBAAiB,CAAC;AAAA,EACtD,MAAM,eAAe,gBAAgB,kBAAkB,CAAC;AAC1D;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Ae,OAAO,YAAY;AAAA,IAClE;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AAAA,EACrB;AACF;AAaO,MAAM,QAAQ,OAAO,YAA0B;AACpD,MAAI,CAAC,SAAS,cAAc;AAC1B,YAAQ;AAAA,MACN;AAAA,IACF;AACA;AAAA,EACF;AAEA,MAAI,8BAA8B,SAAS;AAE3C,MAAI,CAAC,6BAA6B;AAEhC,UAAM,8BAA8B,sBAAsB;AAAA,MACxD,SAAS,SAAS;AAAA,IACpB,CAAC;AAED,kCAA8B;AAAA,EAChC;AAEA,QAAM,QAAQ,OAAO,SAAS,aAAa,OAAO,SAAS,UAAU,IAAI,CAAC;AAC1E,QAAM,eAAe,4BAA4B;AAAA,IAAI,CAAC,aACpD,MAAM,MAAM,UAAU,UAAU,OAAO,CAAC;AAAA,EAC1C;AACA,QAAM,QAAQ,IAAI,YAAY;AAChC;","names":[]}
|
package/dist/esm/cli.mjs
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
+
import { audit } from './audit/index.mjs';
|
|
2
3
|
import { build } from './build.mjs';
|
|
4
|
+
import { getConfig } from './config.mjs';
|
|
5
|
+
import { listContentDeclaration } from './listContentDeclaration.mjs';
|
|
3
6
|
import { pull } from './pull.mjs';
|
|
4
7
|
import { push } from './push.mjs';
|
|
5
8
|
const setAPI = () => {
|
|
6
9
|
const program = new Command();
|
|
7
10
|
program.version("1.0.0").description("Intlayer CLI");
|
|
8
|
-
program.command("build").description("Build the dictionaries").option("-w, --watch", "Watch for changes").action(
|
|
11
|
+
program.command("build").description("Build the dictionaries").option("-w, --watch", "Watch for changes").action(build);
|
|
9
12
|
program.command("push").description(
|
|
10
13
|
"Push all dictionaries. Create or update the pushed dictionaries"
|
|
11
14
|
).option("-d, --dictionaries [ids...]", "List of dictionary IDs to push").option(
|
|
@@ -14,8 +17,17 @@ const setAPI = () => {
|
|
|
14
17
|
).option(
|
|
15
18
|
"-k, --keepLocaleDictionary",
|
|
16
19
|
"Keep the local dictionaries after pushing"
|
|
17
|
-
).action(
|
|
18
|
-
program.command("pull").option("-d, --dictionaries [ids...]", "List of dictionary IDs to pull").option("--newDictionariesPath [path]", "Path to save the new dictionaries").action(
|
|
20
|
+
).action(push);
|
|
21
|
+
program.command("pull").option("-d, --dictionaries [ids...]", "List of dictionary IDs to pull").option("--newDictionariesPath [path]", "Path to save the new dictionaries").action(pull);
|
|
22
|
+
program.command("get config").description("Get the configuration").action(getConfig);
|
|
23
|
+
program.command("content list").description("List the content declaration files").action(listContentDeclaration);
|
|
24
|
+
program.command("audit").description("Audit the dictionaries").option(
|
|
25
|
+
"-f, --files [files...]",
|
|
26
|
+
"List of Content Declaration files to audit"
|
|
27
|
+
).option(
|
|
28
|
+
"--exclude [excludedGlobs...]",
|
|
29
|
+
"Globs pattern to exclude from the audit"
|
|
30
|
+
).option("-m, --model [model]", "Model").option("-p, --custom-prompt [prompt]", "Custom prompt").option("-l, --async-limit [asyncLimit]", "Async limit").option("-k, --open-ai-api-key [openAiApiKey]", "OpenAI API key").action(audit);
|
|
19
31
|
program.parse(process.argv);
|
|
20
32
|
return program;
|
|
21
33
|
};
|
package/dist/esm/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { build } from './build';\nimport { pull } from './pull';\nimport { push } from './push';\n\n/**\n * Set the API for the CLI\n *\n * Example of commands:\n *\n * npm run intlayer build --watch\n * npm run intlayer push --dictionaries id1 id2 id3 --deleteLocaleDir\n */\nexport const setAPI = (): Command => {\n const program = new Command();\n\n program.version('1.0.0').description('Intlayer CLI');\n\n program\n .command('build')\n .description('Build the dictionaries')\n .option('-w, --watch', 'Watch for changes')\n .action(
|
|
1
|
+
{"version":3,"sources":["../../src/cli.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { audit } from './audit/index';\nimport { build } from './build';\nimport { getConfig } from './config';\nimport { listContentDeclaration } from './listContentDeclaration';\nimport { pull } from './pull';\nimport { push } from './push';\n\n/**\n * Set the API for the CLI\n *\n * Example of commands:\n *\n * npm run intlayer build --watch\n * npm run intlayer push --dictionaries id1 id2 id3 --deleteLocaleDir\n */\nexport const setAPI = (): Command => {\n const program = new Command();\n\n program.version('1.0.0').description('Intlayer CLI');\n\n program\n .command('build')\n .description('Build the dictionaries')\n .option('-w, --watch', 'Watch for changes')\n .action(build);\n\n program\n .command('push')\n .description(\n 'Push all dictionaries. Create or update the pushed dictionaries'\n )\n .option('-d, --dictionaries [ids...]', 'List of dictionary IDs to push')\n .option(\n '-r, --deleteLocaleDictionary',\n 'Delete the local dictionaries after pushing'\n )\n .option(\n '-k, --keepLocaleDictionary',\n 'Keep the local dictionaries after pushing'\n )\n .action(push);\n\n program\n .command('pull')\n .option('-d, --dictionaries [ids...]', 'List of dictionary IDs to pull')\n .option('--newDictionariesPath [path]', 'Path to save the new dictionaries')\n .action(pull);\n\n program\n .command('get config')\n .description('Get the configuration')\n .action(getConfig);\n\n program\n .command('content list')\n .description('List the content declaration files')\n .action(listContentDeclaration);\n\n program\n .command('audit')\n .description('Audit the dictionaries')\n .option(\n '-f, --files [files...]',\n 'List of Content Declaration files to audit'\n )\n .option(\n '--exclude [excludedGlobs...]',\n 'Globs pattern to exclude from the audit'\n )\n .option('-m, --model [model]', 'Model')\n .option('-p, --custom-prompt [prompt]', 'Custom prompt')\n .option('-l, --async-limit [asyncLimit]', 'Async limit')\n .option('-k, --open-ai-api-key [openAiApiKey]', 'OpenAI API key')\n .action(audit);\n\n program.parse(process.argv);\n\n return program;\n};\n"],"mappings":"AAAA,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,8BAA8B;AACvC,SAAS,YAAY;AACrB,SAAS,YAAY;AAUd,MAAM,SAAS,MAAe;AACnC,QAAM,UAAU,IAAI,QAAQ;AAE5B,UAAQ,QAAQ,OAAO,EAAE,YAAY,cAAc;AAEnD,UACG,QAAQ,OAAO,EACf,YAAY,wBAAwB,EACpC,OAAO,eAAe,mBAAmB,EACzC,OAAO,KAAK;AAEf,UACG,QAAQ,MAAM,EACd;AAAA,IACC;AAAA,EACF,EACC,OAAO,+BAA+B,gCAAgC,EACtE;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,IAAI;AAEd,UACG,QAAQ,MAAM,EACd,OAAO,+BAA+B,gCAAgC,EACtE,OAAO,gCAAgC,mCAAmC,EAC1E,OAAO,IAAI;AAEd,UACG,QAAQ,YAAY,EACpB,YAAY,uBAAuB,EACnC,OAAO,SAAS;AAEnB,UACG,QAAQ,cAAc,EACtB,YAAY,oCAAoC,EAChD,OAAO,sBAAsB;AAEhC,UACG,QAAQ,OAAO,EACf,YAAY,wBAAwB,EACpC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,uBAAuB,OAAO,EACrC,OAAO,gCAAgC,eAAe,EACtD,OAAO,kCAAkC,aAAa,EACtD,OAAO,wCAAwC,gBAAgB,EAC/D,OAAO,KAAK;AAEf,UAAQ,MAAM,QAAQ,IAAI;AAE1B,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/config.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\n\ntype ConfigOptions = {};\n\nexport const getConfig = (_options?: ConfigOptions) => {\n const config = getConfiguration();\n\n console.info(config);\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AAI1B,MAAM,YAAY,CAAC,aAA6B;AACrD,QAAM,SAAS,iBAAiB;AAEhC,UAAQ,KAAK,MAAM;AACrB;","names":[]}
|