@intlayer/cli 9.5.9-canary.0 → 9.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_virtual/_utils_asset.cjs +1 -1
- package/dist/cjs/auth/login.cjs +4 -4
- package/dist/cjs/build.cjs +1 -1
- package/dist/cjs/ci.cjs +1 -1
- package/dist/cjs/cli.cjs +9 -4
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/config.cjs +1 -1
- package/dist/cjs/editor.cjs +1 -1
- package/dist/cjs/extract.cjs +5 -5
- package/dist/cjs/fill/fill.cjs +2 -2
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs +1 -1
- package/dist/cjs/fill/listTranslationsTasks.cjs +1 -1
- package/dist/cjs/fill/translateDictionary.cjs +1 -1
- package/dist/cjs/fill/writeFill.cjs +1 -1
- package/dist/cjs/getTargetDictionary.cjs +1 -1
- package/dist/cjs/index.cjs +21 -7
- package/dist/cjs/init.cjs +111 -39
- package/dist/cjs/init.cjs.map +1 -1
- package/dist/cjs/initChromeExtension.cjs +36 -0
- package/dist/cjs/initChromeExtension.cjs.map +1 -0
- package/dist/cjs/initInfra.cjs +1 -1
- package/dist/cjs/initInfra.cjs.map +1 -1
- package/dist/cjs/initSkills.cjs +1 -1
- package/dist/cjs/listContentDeclaration.cjs +2 -2
- package/dist/cjs/liveSync.cjs +4 -4
- package/dist/cjs/pull.cjs +4 -4
- package/dist/cjs/push/push.cjs +5 -5
- package/dist/cjs/pushConfig.cjs +1 -1
- package/dist/cjs/reviewDoc/reviewDoc.cjs +3 -3
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +3 -3
- package/dist/cjs/reviewDoc/reviewDocLog.cjs +1 -1
- package/dist/cjs/searchDoc.cjs +2 -1
- package/dist/cjs/searchDoc.cjs.map +1 -1
- package/dist/cjs/test/listMissingTranslations.cjs +1 -1
- package/dist/cjs/test/test.cjs +1 -1
- package/dist/cjs/translateDoc/translateDoc.cjs +2 -2
- package/dist/cjs/translateDoc/translateFile.cjs +2 -2
- package/dist/cjs/utils/getOutputFilePath.cjs +1 -1
- package/dist/cjs/utils/getParentPackageJSON.cjs +1 -1
- package/dist/cjs/utils/selectCmsEnvironment.cjs +1 -1
- package/dist/cjs/utils/selectCmsEnvironment.cjs.map +1 -1
- package/dist/cjs/watch.cjs +1 -1
- package/dist/esm/_virtual/_utils_asset.mjs +1 -1
- package/dist/esm/auth/login.mjs +3 -3
- package/dist/esm/build.mjs +1 -1
- package/dist/esm/ci.mjs +1 -1
- package/dist/esm/cli.mjs +9 -4
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/config.mjs +1 -1
- package/dist/esm/editor.mjs +1 -1
- package/dist/esm/extract.mjs +6 -6
- package/dist/esm/extract.mjs.map +1 -1
- package/dist/esm/fill/fill.mjs +4 -4
- package/dist/esm/fill/fill.mjs.map +1 -1
- package/dist/esm/fill/formatAutoFilledFilePath.mjs +1 -1
- package/dist/esm/fill/listTranslationsTasks.mjs +1 -1
- package/dist/esm/fill/translateDictionary.mjs +1 -1
- package/dist/esm/fill/writeFill.mjs +1 -1
- package/dist/esm/getTargetDictionary.mjs +1 -1
- package/dist/esm/index.mjs +10 -9
- package/dist/esm/init.mjs +104 -41
- package/dist/esm/init.mjs.map +1 -1
- package/dist/esm/initChromeExtension.mjs +32 -0
- package/dist/esm/initChromeExtension.mjs.map +1 -0
- package/dist/esm/initInfra.mjs +1 -1
- package/dist/esm/initInfra.mjs.map +1 -1
- package/dist/esm/initSkills.mjs +1 -1
- package/dist/esm/listContentDeclaration.mjs +2 -2
- package/dist/esm/liveSync.mjs +3 -3
- package/dist/esm/pull.mjs +4 -4
- package/dist/esm/push/push.mjs +7 -7
- package/dist/esm/push/push.mjs.map +1 -1
- package/dist/esm/pushConfig.mjs +1 -1
- package/dist/esm/reviewDoc/reviewDoc.mjs +3 -3
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +3 -3
- package/dist/esm/reviewDoc/reviewDocLog.mjs +1 -1
- package/dist/esm/searchDoc.mjs +2 -1
- package/dist/esm/searchDoc.mjs.map +1 -1
- package/dist/esm/test/listMissingTranslations.mjs +1 -1
- package/dist/esm/test/test.mjs +1 -1
- package/dist/esm/translateDoc/translateDoc.mjs +2 -2
- package/dist/esm/translateDoc/translateFile.mjs +2 -2
- package/dist/esm/utils/getOutputFilePath.mjs +1 -1
- package/dist/esm/utils/getParentPackageJSON.mjs +1 -1
- package/dist/esm/utils/selectCmsEnvironment.mjs +1 -1
- package/dist/esm/utils/selectCmsEnvironment.mjs.map +1 -1
- package/dist/esm/watch.mjs +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/init.d.ts +43 -1
- package/dist/types/init.d.ts.map +1 -1
- package/dist/types/initChromeExtension.d.ts +11 -0
- package/dist/types/initChromeExtension.d.ts.map +1 -0
- package/dist/types/searchDoc.d.ts.map +1 -1
- package/package.json +11 -11
package/dist/esm/push/push.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { loadPrompts } from "../loadPrompts.mjs";
|
|
1
2
|
import { checkCMSAuth, getAuthenticatedAPI } from "../utils/checkAccess.mjs";
|
|
2
3
|
import { selectCmsEnvironment } from "../utils/selectCmsEnvironment.mjs";
|
|
3
4
|
import { PushLogger } from "../pushLog.mjs";
|
|
4
|
-
import { loadPrompts } from "../loadPrompts.mjs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
|
+
import { listGitFiles, logConfigDetails } from "@intlayer/engine/cli";
|
|
6
7
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
7
8
|
import { colorize, colorizeKey, getAppLogger } from "@intlayer/config/logger";
|
|
8
9
|
import { getConfiguration } from "@intlayer/config/node";
|
|
9
|
-
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
10
|
-
import { prepareIntlayer, writeContentDeclaration } from "@intlayer/engine/build";
|
|
11
|
-
import { listGitFiles, logConfigDetails } from "@intlayer/engine/cli";
|
|
12
|
-
import { formatPath, parallelize } from "@intlayer/engine/utils";
|
|
13
10
|
import * as fsPromises from "node:fs/promises";
|
|
11
|
+
import { formatPath, parallelize } from "@intlayer/engine/utils";
|
|
12
|
+
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
13
|
+
import { prepareIntlayer as prepareIntlayer$1, writeContentDeclaration } from "@intlayer/engine/build";
|
|
14
14
|
|
|
15
15
|
//#region src/push/push.ts
|
|
16
16
|
const statusIconsAndColors = {
|
|
@@ -45,8 +45,8 @@ const push = async (options) => {
|
|
|
45
45
|
const config = getConfiguration(options?.configOptions);
|
|
46
46
|
logConfigDetails(options?.configOptions);
|
|
47
47
|
const appLogger = getAppLogger(config);
|
|
48
|
-
if (options?.build === true) await prepareIntlayer(config, { forceRun: true });
|
|
49
|
-
else if (typeof options?.build === "undefined") await prepareIntlayer(config);
|
|
48
|
+
if (options?.build === true) await prepareIntlayer$1(config, { forceRun: true });
|
|
49
|
+
else if (typeof options?.build === "undefined") await prepareIntlayer$1(config);
|
|
50
50
|
try {
|
|
51
51
|
if (!await checkCMSAuth(config)) return;
|
|
52
52
|
const intlayerAPI = await getAuthenticatedAPI(config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.mjs","names":[],"sources":["../../../src/push/push.ts"],"sourcesContent":["import * as fsPromises from 'node:fs/promises';\nimport { join } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getUnmergedDictionaries } from '@intlayer/dictionaries-entry/unmerged';\nimport {\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/engine/build';\nimport {\n type ListGitFilesOptions,\n listGitFiles,\n logConfigDetails,\n} from '@intlayer/engine/cli';\nimport { formatPath, parallelize } from '@intlayer/engine/utils';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { loadPrompts } from '../loadPrompts';\nimport { PushLogger, type PushStatus } from '../pushLog';\nimport { checkCMSAuth, getAuthenticatedAPI } from '../utils/checkAccess';\nimport { selectCmsEnvironment } from '../utils/selectCmsEnvironment';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status:\n | 'pending'\n | 'pushing'\n | 'modified'\n | 'pushed'\n | 'up-to-date'\n | 'unknown'\n | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n// Print per-dictionary summary similar to loadDictionaries\nconst statusIconsAndColors = {\n pushed: { icon: '✔', color: ANSIColors.GREEN },\n modified: { icon: '✔', color: ANSIColors.GREEN },\n 'up-to-date': { icon: '=', color: ANSIColors.GREY },\n error: { icon: '✖', color: ANSIColors.RED },\n default: { icon: '⏲', color: ANSIColors.BLUE },\n};\n\nconst getIconAndColor = (status: DictionariesStatus['status']) => {\n return (\n statusIconsAndColors[status as keyof typeof statusIconsAndColors] ??\n statusIconsAndColors.default\n );\n};\n\n/**\n * Get all local dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n try {\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = await getAuthenticatedAPI(config);\n\n await selectCmsEnvironment(\n options?.configOptions?.env,\n intlayerAPI,\n config\n );\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n const allDictionaries = Object.values(unmergedDictionariesRecord).flat();\n\n const customLocations = Array.from(\n new Set(\n allDictionaries\n .map((dictionary) => dictionary.location)\n .filter(\n (location) =>\n location && !['remote', 'local', 'hybrid'].includes(location)\n )\n )\n ) as string[];\n\n // Include all custom locations automatically — no interactive prompt needed.\n const selectedCustomLocations: string[] = customLocations;\n\n let dictionaries: Dictionary[] = allDictionaries.filter((dictionary) => {\n const location =\n dictionary.location ?? config.dictionary?.location ?? 'local';\n\n return (\n location === 'remote' ||\n location === 'hybrid' ||\n selectedCustomLocations.includes(location)\n );\n });\n\n // Check if the dictionaries list is empty after filtering by location\n if (dictionaries.length === 0) {\n appLogger(\n `No dictionaries found to push. Only dictionaries with location ${colorize('remote', ANSIColors.BLUE, ANSIColors.RESET)}, ${colorize('hybrid', ANSIColors.BLUE, ANSIColors.RESET)} or selected custom locations are pushed.`,\n { level: 'warn' }\n );\n appLogger(\n `You can set the location in your dictionary file (e.g. ${colorize(\"{ key: 'my-key', location: 'hybrid', ... }\", ANSIColors.BLUE, ANSIColors.RESET)} or globally in your intlayer.config.ts file (e.g. ${colorize(\"{ dictionary: { location: 'hybrid' } }\", ANSIColors.BLUE, ANSIColors.RESET)}).`,\n { level: 'info' }\n );\n return;\n }\n\n const existingDictionariesKeys: string[] = Object.keys(\n unmergedDictionariesRecord\n );\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 appLogger(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`,\n {\n level: 'error',\n }\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 if (options?.gitOptions) {\n const gitFiles = await listGitFiles(options.gitOptions);\n\n dictionaries = dictionaries.filter((dictionary) =>\n gitFiles.includes(\n join(config.system.baseDir, dictionary.filePath ?? '')\n )\n );\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n appLogger('No local dictionaries found', {\n level: 'error',\n });\n return;\n }\n\n appLogger('Pushing dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary) => ({\n dictionary,\n status: 'pending',\n })\n );\n\n // Initialize aggregated logger similar to loadDictionaries\n const logger = new PushLogger();\n logger.update(\n dictionariesStatuses.map<PushStatus>((s) => ({\n dictionaryKey: s.dictionary.key,\n status: 'pending',\n }))\n );\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushing' },\n ]);\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries([\n statusObj.dictionary,\n ]);\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries ?? [];\n const newDictionaries = pushResult.data?.newDictionaries ?? [];\n const upToDateDictionaries =\n pushResult.data?.upToDateDictionaries ?? [];\n\n const allDictionaries = [\n ...updatedDictionaries,\n ...newDictionaries,\n ...upToDateDictionaries,\n ];\n\n for (const remoteDictionaryData of allDictionaries) {\n const localDictionary = unmergedDictionariesRecord[\n remoteDictionaryData.key\n ]?.find(\n (dictionary) => dictionary.localId === remoteDictionaryData.localId\n );\n\n if (!localDictionary) continue;\n\n await writeContentDeclaration(\n { ...localDictionary, id: remoteDictionaryData.id },\n config\n );\n }\n\n if (\n updatedDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'modified' },\n ]);\n } else if (\n newDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushed' },\n ]);\n } else if (\n upToDateDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'up-to-date';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'up-to-date' },\n ]);\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 logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit (reuse parallelize)\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n for (const dictionaryStatus of dictionariesStatuses) {\n const { icon, color } = getIconAndColor(dictionaryStatus.status);\n appLogger(\n ` - ${colorizeKey(dictionaryStatus.dictionary.key)} ${ANSIColors.GREY}[${color}${icon} ${dictionaryStatus.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n appLogger(statusObj.errorMessage, {\n level: 'error',\n });\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, options);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const remoteDictionaries = successfullyPushedDictionaries.filter(\n (dictionary) => dictionary.location === 'remote'\n );\n const remoteDictionariesKeys = remoteDictionaries.map(\n (dictionary) => dictionary.key\n );\n\n if (remoteDictionaries.length > 0) {\n const { confirm, isCancel } = await loadPrompts();\n\n const shouldDelete = await confirm({\n message: `Do you want to delete the local dictionaries that were successfully pushed? ${colorize('(Dictionaries:', ANSIColors.GREY, ANSIColors.RESET)} ${colorizeKey(remoteDictionariesKeys)}${colorize(')', ANSIColors.GREY, ANSIColors.RESET)}`,\n initialValue: false,\n });\n\n if (isCancel(shouldDelete)) {\n return;\n }\n\n if (shouldDelete) {\n await deleteLocalDictionaries(remoteDictionaries, options);\n }\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\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 appLogger(\n `Dictionary ${colorizeKey(dictionary.key)} does not have a file path`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n appLogger(`Deleted file ${formatPath(filePath)}`, {});\n } else if (stats.isDirectory()) {\n appLogger(`Path is a directory ${formatPath(filePath)}, skipping.`, {});\n } else {\n appLogger(\n `Unknown file type for ${formatPath(filePath)}, skipping.`,\n {}\n );\n }\n } catch (err) {\n appLogger(`Error deleting ${formatPath(filePath)}: ${err}`, {\n level: 'error',\n });\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;AAiDA,MAAM,uBAAuB;CAC3B,QAAQ;EAAE,MAAM;EAAK,OAAO,WAAW;CAAM;CAC7C,UAAU;EAAE,MAAM;EAAK,OAAO,WAAW;CAAM;CAC/C,cAAc;EAAE,MAAM;EAAK,OAAO,WAAW;CAAK;CAClD,OAAO;EAAE,MAAM;EAAK,OAAO,WAAW;CAAI;CAC1C,SAAS;EAAE,MAAM;EAAK,OAAO,WAAW;CAAK;AAC/C;AAEA,MAAM,mBAAmB,WA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MAAM,WAAW,MAAM,QAAQ;EAE7C,IAAI,MAAM,OAAO,GAAG;GAClB,MAAM,WAAW,OAAO,QAAQ;GAChC,UAAU,gBAAgB,WAAW,QAAQ,KAAK,CAAC,CAAC;EACtD,OAAO,IAAI,MAAM,YAAY,GAC3B,UAAU,uBAAuB,WAAW,QAAQ,EAAE,cAAc,CAAC,CAAC;OAEtE,UACE,yBAAyB,WAAW,QAAQ,EAAE,cAC9C,CAAC,CACH;CAEJ,SAAS,KAAK;EACZ,UAAU,kBAAkB,WAAW,QAAQ,EAAE,IAAI,OAAO,EAC1D,OAAO,QACT,CAAC;CACH;AAEJ"}
|
|
1
|
+
{"version":3,"file":"push.mjs","names":["prepareIntlayer"],"sources":["../../../src/push/push.ts"],"sourcesContent":["import * as fsPromises from 'node:fs/promises';\nimport { join } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getUnmergedDictionaries } from '@intlayer/dictionaries-entry/unmerged';\nimport {\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/engine/build';\nimport {\n type ListGitFilesOptions,\n listGitFiles,\n logConfigDetails,\n} from '@intlayer/engine/cli';\nimport { formatPath, parallelize } from '@intlayer/engine/utils';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { loadPrompts } from '../loadPrompts';\nimport { PushLogger, type PushStatus } from '../pushLog';\nimport { checkCMSAuth, getAuthenticatedAPI } from '../utils/checkAccess';\nimport { selectCmsEnvironment } from '../utils/selectCmsEnvironment';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status:\n | 'pending'\n | 'pushing'\n | 'modified'\n | 'pushed'\n | 'up-to-date'\n | 'unknown'\n | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n// Print per-dictionary summary similar to loadDictionaries\nconst statusIconsAndColors = {\n pushed: { icon: '✔', color: ANSIColors.GREEN },\n modified: { icon: '✔', color: ANSIColors.GREEN },\n 'up-to-date': { icon: '=', color: ANSIColors.GREY },\n error: { icon: '✖', color: ANSIColors.RED },\n default: { icon: '⏲', color: ANSIColors.BLUE },\n};\n\nconst getIconAndColor = (status: DictionariesStatus['status']) => {\n return (\n statusIconsAndColors[status as keyof typeof statusIconsAndColors] ??\n statusIconsAndColors.default\n );\n};\n\n/**\n * Get all local dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n try {\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = await getAuthenticatedAPI(config);\n\n await selectCmsEnvironment(\n options?.configOptions?.env,\n intlayerAPI,\n config\n );\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n const allDictionaries = Object.values(unmergedDictionariesRecord).flat();\n\n const customLocations = Array.from(\n new Set(\n allDictionaries\n .map((dictionary) => dictionary.location)\n .filter(\n (location) =>\n location && !['remote', 'local', 'hybrid'].includes(location)\n )\n )\n ) as string[];\n\n // Include all custom locations automatically — no interactive prompt needed.\n const selectedCustomLocations: string[] = customLocations;\n\n let dictionaries: Dictionary[] = allDictionaries.filter((dictionary) => {\n const location =\n dictionary.location ?? config.dictionary?.location ?? 'local';\n\n return (\n location === 'remote' ||\n location === 'hybrid' ||\n selectedCustomLocations.includes(location)\n );\n });\n\n // Check if the dictionaries list is empty after filtering by location\n if (dictionaries.length === 0) {\n appLogger(\n `No dictionaries found to push. Only dictionaries with location ${colorize('remote', ANSIColors.BLUE, ANSIColors.RESET)}, ${colorize('hybrid', ANSIColors.BLUE, ANSIColors.RESET)} or selected custom locations are pushed.`,\n { level: 'warn' }\n );\n appLogger(\n `You can set the location in your dictionary file (e.g. ${colorize(\"{ key: 'my-key', location: 'hybrid', ... }\", ANSIColors.BLUE, ANSIColors.RESET)} or globally in your intlayer.config.ts file (e.g. ${colorize(\"{ dictionary: { location: 'hybrid' } }\", ANSIColors.BLUE, ANSIColors.RESET)}).`,\n { level: 'info' }\n );\n return;\n }\n\n const existingDictionariesKeys: string[] = Object.keys(\n unmergedDictionariesRecord\n );\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 appLogger(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`,\n {\n level: 'error',\n }\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 if (options?.gitOptions) {\n const gitFiles = await listGitFiles(options.gitOptions);\n\n dictionaries = dictionaries.filter((dictionary) =>\n gitFiles.includes(\n join(config.system.baseDir, dictionary.filePath ?? '')\n )\n );\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n appLogger('No local dictionaries found', {\n level: 'error',\n });\n return;\n }\n\n appLogger('Pushing dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary) => ({\n dictionary,\n status: 'pending',\n })\n );\n\n // Initialize aggregated logger similar to loadDictionaries\n const logger = new PushLogger();\n logger.update(\n dictionariesStatuses.map<PushStatus>((s) => ({\n dictionaryKey: s.dictionary.key,\n status: 'pending',\n }))\n );\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushing' },\n ]);\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries([\n statusObj.dictionary,\n ]);\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries ?? [];\n const newDictionaries = pushResult.data?.newDictionaries ?? [];\n const upToDateDictionaries =\n pushResult.data?.upToDateDictionaries ?? [];\n\n const allDictionaries = [\n ...updatedDictionaries,\n ...newDictionaries,\n ...upToDateDictionaries,\n ];\n\n for (const remoteDictionaryData of allDictionaries) {\n const localDictionary = unmergedDictionariesRecord[\n remoteDictionaryData.key\n ]?.find(\n (dictionary) => dictionary.localId === remoteDictionaryData.localId\n );\n\n if (!localDictionary) continue;\n\n await writeContentDeclaration(\n { ...localDictionary, id: remoteDictionaryData.id },\n config\n );\n }\n\n if (\n updatedDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'modified' },\n ]);\n } else if (\n newDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushed' },\n ]);\n } else if (\n upToDateDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'up-to-date';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'up-to-date' },\n ]);\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 logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit (reuse parallelize)\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n for (const dictionaryStatus of dictionariesStatuses) {\n const { icon, color } = getIconAndColor(dictionaryStatus.status);\n appLogger(\n ` - ${colorizeKey(dictionaryStatus.dictionary.key)} ${ANSIColors.GREY}[${color}${icon} ${dictionaryStatus.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n appLogger(statusObj.errorMessage, {\n level: 'error',\n });\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, options);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const remoteDictionaries = successfullyPushedDictionaries.filter(\n (dictionary) => dictionary.location === 'remote'\n );\n const remoteDictionariesKeys = remoteDictionaries.map(\n (dictionary) => dictionary.key\n );\n\n if (remoteDictionaries.length > 0) {\n const { confirm, isCancel } = await loadPrompts();\n\n const shouldDelete = await confirm({\n message: `Do you want to delete the local dictionaries that were successfully pushed? ${colorize('(Dictionaries:', ANSIColors.GREY, ANSIColors.RESET)} ${colorizeKey(remoteDictionariesKeys)}${colorize(')', ANSIColors.GREY, ANSIColors.RESET)}`,\n initialValue: false,\n });\n\n if (isCancel(shouldDelete)) {\n return;\n }\n\n if (shouldDelete) {\n await deleteLocalDictionaries(remoteDictionaries, options);\n }\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\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 appLogger(\n `Dictionary ${colorizeKey(dictionary.key)} does not have a file path`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n appLogger(`Deleted file ${formatPath(filePath)}`, {});\n } else if (stats.isDirectory()) {\n appLogger(`Path is a directory ${formatPath(filePath)}, skipping.`, {});\n } else {\n appLogger(\n `Unknown file type for ${formatPath(filePath)}, skipping.`,\n {}\n );\n }\n } catch (err) {\n appLogger(`Error deleting ${formatPath(filePath)}: ${err}`, {\n level: 'error',\n });\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;AAiDA,MAAM,uBAAuB;CAC3B,QAAQ;EAAE,MAAM;EAAK,OAAO,WAAW;CAAM;CAC7C,UAAU;EAAE,MAAM;EAAK,OAAO,WAAW;CAAM;CAC/C,cAAc;EAAE,MAAM;EAAK,OAAO,WAAW;CAAK;CAClD,OAAO;EAAE,MAAM;EAAK,OAAO,WAAW;CAAI;CAC1C,SAAS;EAAE,MAAM;EAAK,OAAO,WAAW;CAAK;AAC/C;AAEA,MAAM,mBAAmB,WAAyC;CAChE,OACE,qBAAqB,WACrB,qBAAqB;AAEzB;;;;AAKA,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,SAAS,iBAAiB,SAAS,aAAa;CACtD,iBAAiB,SAAS,aAAa;CAEvC,MAAM,YAAY,aAAa,MAAM;CAErC,IAAI,SAAS,UAAU,MACrB,MAAMA,kBAAgB,QAAQ,EAAE,UAAU,KAAK,CAAC;MAC3C,IAAI,OAAO,SAAS,UAAU,aACnC,MAAMA,kBAAgB,MAAM;CAG9B,IAAI;EAGF,IAAI,CAAC,MAFoB,aAAa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AO,EAC1D,OAAO,QACT,CAAC;CACH;AAEJ"}
|
package/dist/esm/pushConfig.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { checkCMSAuth, getAuthenticatedAPI } from "./utils/checkAccess.mjs";
|
|
2
2
|
import { selectCmsEnvironment } from "./utils/selectCmsEnvironment.mjs";
|
|
3
|
+
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
3
4
|
import { CYAN, GREY_DARK } from "@intlayer/config/colors";
|
|
4
5
|
import { colorize, colorizeObject, getAppLogger } from "@intlayer/config/logger";
|
|
5
6
|
import { getConfiguration } from "@intlayer/config/node";
|
|
6
|
-
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
7
7
|
|
|
8
8
|
//#region src/pushConfig.ts
|
|
9
9
|
const pushConfig = async (options) => {
|
|
@@ -6,14 +6,14 @@ import { reviewFileBlockAware } from "./reviewDocBlockAware.mjs";
|
|
|
6
6
|
import { buildFileReviewReport, logReviewFileBlocks } from "./reviewDocLog.mjs";
|
|
7
7
|
import { createReviewProgressLogger } from "./reviewDocProgress.mjs";
|
|
8
8
|
import { formatReviewSynthesis } from "./reviewDocSynthesis.mjs";
|
|
9
|
-
import { existsSync } from "node:fs";
|
|
10
9
|
import { join, relative } from "node:path";
|
|
10
|
+
import { listGitFiles, listGitLines, logConfigDetails } from "@intlayer/engine/cli";
|
|
11
|
+
import { existsSync } from "node:fs";
|
|
11
12
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
12
13
|
import { colorize, colorizeNumber, getAppLogger, x } from "@intlayer/config/logger";
|
|
13
14
|
import { getConfiguration } from "@intlayer/config/node";
|
|
14
|
-
import { listGitFiles, listGitLines, logConfigDetails } from "@intlayer/engine/cli";
|
|
15
|
-
import { formatLocale, formatPath, parallelize } from "@intlayer/engine/utils";
|
|
16
15
|
import { readFile } from "node:fs/promises";
|
|
16
|
+
import { formatLocale, formatPath, parallelize } from "@intlayer/engine/utils";
|
|
17
17
|
import { buildReviewReport } from "@intlayer/engine/docReview";
|
|
18
18
|
import fg from "fast-glob";
|
|
19
19
|
|
|
@@ -2,14 +2,14 @@ import { readAsset } from "../_virtual/_utils_asset.mjs";
|
|
|
2
2
|
import { sanitizeChunk, validateTranslation } from "../translateDoc/validation.mjs";
|
|
3
3
|
import { chunkInference } from "../utils/chunkInference.mjs";
|
|
4
4
|
import { fixChunkStartEndChars } from "../utils/fixChunkStartEndChars.mjs";
|
|
5
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
6
5
|
import { dirname } from "node:path";
|
|
6
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
7
7
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
8
8
|
import { colon, colorize, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
|
|
9
9
|
import { getConfiguration } from "@intlayer/config/node";
|
|
10
|
-
import { retryManager } from "@intlayer/config/utils";
|
|
11
|
-
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
12
10
|
import { readFile } from "node:fs/promises";
|
|
11
|
+
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
12
|
+
import { retryManager } from "@intlayer/config/utils";
|
|
13
13
|
import { buildAlignmentPlan, mergeReviewedSegments } from "@intlayer/engine/docReview";
|
|
14
14
|
import { getLocaleName } from "@intlayer/core/localization";
|
|
15
15
|
import { ENGLISH } from "@intlayer/types/locales";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { getAppLogger } from "@intlayer/config/logger";
|
|
3
3
|
import { getConfiguration } from "@intlayer/config/node";
|
|
4
|
-
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
5
4
|
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
6
6
|
import { buildReviewReport, formatReviewReport } from "@intlayer/engine/docReview";
|
|
7
7
|
|
|
8
8
|
//#region src/reviewDoc/reviewDocLog.ts
|
package/dist/esm/searchDoc.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
1
2
|
import { colorizeKey, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
|
|
2
3
|
import { getConfiguration } from "@intlayer/config/node";
|
|
3
|
-
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
4
4
|
import { getSearchAPI } from "@intlayer/api";
|
|
5
5
|
|
|
6
6
|
//#region src/searchDoc.ts
|
|
@@ -27,6 +27,7 @@ const searchDoc = async ({ query, limit = 10, configOptions }) => {
|
|
|
27
27
|
appLogger(`${colorizeKey("Title")}: ${chunk.docName}`);
|
|
28
28
|
appLogger(`${colorizeKey("URL")}: ${chunk.docUrl}`);
|
|
29
29
|
appLogger(`${colorizeKey("Chunk")}: ${chunk.chunkNumber}`);
|
|
30
|
+
if (chunk.priority !== void 0) appLogger(`${colorizeKey("Priority")}: ${colorizeNumber(chunk.priority)}`);
|
|
30
31
|
appLogger(`${colorizeKey("Content")}:`);
|
|
31
32
|
appLogger(chunk.content);
|
|
32
33
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchDoc.mjs","names":[],"sources":["../../src/searchDoc.ts"],"sourcesContent":["import { getSearchAPI } from '@intlayer/api';\nimport {\n colorizeKey,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { logConfigDetails } from '@intlayer/engine/cli';\n\ninterface SearchDocOptions {\n query: string;\n limit?: number;\n configOptions?: GetConfigurationOptions;\n}\n\nexport const searchDoc = async ({\n query,\n limit = 10,\n configOptions,\n}: SearchDocOptions) => {\n const config = getConfiguration(configOptions);\n logConfigDetails(configOptions);\n\n const appLogger = getAppLogger(config);\n\n try {\n const { searchDoc } = getSearchAPI(undefined, config);\n const response = await searchDoc({\n input: query,\n limit: limit.toString(),\n returnContent: 'true',\n });\n\n if (!response.data || !Array.isArray(response.data)) {\n appLogger('No relevant chunks found.');\n return;\n }\n\n const chunks = response.data;\n\n appLogger(`Found ${colorizeNumber(chunks.length)} relevant chunks:`);\n\n chunks.forEach((chunk
|
|
1
|
+
{"version":3,"file":"searchDoc.mjs","names":[],"sources":["../../src/searchDoc.ts"],"sourcesContent":["import { getSearchAPI } from '@intlayer/api';\nimport {\n colorizeKey,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { logConfigDetails } from '@intlayer/engine/cli';\n\n/** A documentation chunk returned by the search endpoint with `returnContent`. */\ntype SearchDocChunk = Exclude<\n NonNullable<\n Awaited<ReturnType<ReturnType<typeof getSearchAPI>['searchDoc']>>['data']\n >,\n string[]\n>[number];\n\ninterface SearchDocOptions {\n query: string;\n limit?: number;\n configOptions?: GetConfigurationOptions;\n}\n\nexport const searchDoc = async ({\n query,\n limit = 10,\n configOptions,\n}: SearchDocOptions) => {\n const config = getConfiguration(configOptions);\n logConfigDetails(configOptions);\n\n const appLogger = getAppLogger(config);\n\n try {\n const { searchDoc } = getSearchAPI(undefined, config);\n const response = await searchDoc({\n input: query,\n limit: limit.toString(),\n returnContent: 'true',\n });\n\n if (!response.data || !Array.isArray(response.data)) {\n appLogger('No relevant chunks found.');\n return;\n }\n\n // Ranked by relevance, weighted by the `priority` front matter of each doc\n const chunks = response.data as SearchDocChunk[];\n\n appLogger(`Found ${colorizeNumber(chunks.length)} relevant chunks:`);\n\n chunks.forEach((chunk) => {\n appLogger('---');\n appLogger(`${colorizeKey('File')}: ${chunk.fileKey}`);\n appLogger(`${colorizeKey('Title')}: ${chunk.docName}`);\n appLogger(`${colorizeKey('URL')}: ${chunk.docUrl}`);\n appLogger(`${colorizeKey('Chunk')}: ${chunk.chunkNumber}`);\n if (chunk.priority !== undefined) {\n appLogger(\n `${colorizeKey('Priority')}: ${colorizeNumber(chunk.priority)}`\n );\n }\n appLogger(`${colorizeKey('Content')}:`);\n appLogger(chunk.content);\n });\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n appLogger(`Search failed: ${errorMessage}`, { level: 'error' });\n }\n};\n"],"mappings":";;;;;;AA0BA,MAAa,YAAY,OAAO,EAC9B,OACA,QAAQ,IACR,oBACsB;CACtB,MAAM,SAAS,iBAAiB,aAAa;CAC7C,iBAAiB,aAAa;CAE9B,MAAM,YAAY,aAAa,MAAM;CAErC,IAAI;EACF,MAAM,EAAE,cAAc,aAAa,QAAW,MAAM;EACpD,MAAM,WAAW,MAAM,UAAU;GAC/B,OAAO;GACP,OAAO,MAAM,SAAS;GACtB,eAAe;EACjB,CAAC;EAED,IAAI,CAAC,SAAS,QAAQ,CAAC,MAAM,QAAQ,SAAS,IAAI,GAAG;GACnD,UAAU,2BAA2B;GACrC;EACF;EAGA,MAAM,SAAS,SAAS;EAExB,UAAU,SAAS,eAAe,OAAO,MAAM,EAAE,kBAAkB;EAEnE,OAAO,SAAS,UAAU;GACxB,UAAU,KAAK;GACf,UAAU,GAAG,YAAY,MAAM,EAAE,IAAI,MAAM,SAAS;GACpD,UAAU,GAAG,YAAY,OAAO,EAAE,IAAI,MAAM,SAAS;GACrD,UAAU,GAAG,YAAY,KAAK,EAAE,IAAI,MAAM,QAAQ;GAClD,UAAU,GAAG,YAAY,OAAO,EAAE,IAAI,MAAM,aAAa;GACzD,IAAI,MAAM,aAAa,QACrB,UACE,GAAG,YAAY,UAAU,EAAE,IAAI,eAAe,MAAM,QAAQ,GAC9D;GAEF,UAAU,GAAG,YAAY,SAAS,EAAE,EAAE;GACtC,UAAU,MAAM,OAAO;EACzB,CAAC;CACH,SAAS,OAAO;EAGd,UAAU,kBADR,iBAAiB,QAAQ,MAAM,UAAU,+BACC,EAAE,OAAO,QAAQ,CAAC;CAChE;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
1
2
|
import { getConfiguration } from "@intlayer/config/node";
|
|
2
3
|
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
3
|
-
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
4
4
|
import { getMissingLocalesContentFromDictionary } from "@intlayer/core/plugins";
|
|
5
5
|
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
6
6
|
|
package/dist/esm/test/test.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { listMissingTranslations } from "./listMissingTranslations.mjs";
|
|
|
2
2
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
3
3
|
import { colon, colorize, colorizeKey, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
|
|
4
4
|
import { getConfiguration } from "@intlayer/config/node";
|
|
5
|
-
import { prepareIntlayer } from "@intlayer/engine/build";
|
|
6
5
|
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
6
|
+
import { prepareIntlayer } from "@intlayer/engine/build";
|
|
7
7
|
|
|
8
8
|
//#region src/test/test.ts
|
|
9
9
|
const testMissingTranslations = async (options) => {
|
|
@@ -2,12 +2,12 @@ import { setupAI } from "../utils/setupAI.mjs";
|
|
|
2
2
|
import { getOutputFilePath } from "../utils/getOutputFilePath.mjs";
|
|
3
3
|
import { checkFileModifiedRange } from "../utils/checkFileModifiedRange.mjs";
|
|
4
4
|
import { translateFile } from "./translateFile.mjs";
|
|
5
|
-
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
6
5
|
import { dirname, join } from "node:path";
|
|
6
|
+
import { listGitFiles, logConfigDetails } from "@intlayer/engine/cli";
|
|
7
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
7
8
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
8
9
|
import { colorize, colorizeNumber, getAppLogger, x } from "@intlayer/config/logger";
|
|
9
10
|
import { getConfiguration } from "@intlayer/config/node";
|
|
10
|
-
import { listGitFiles, logConfigDetails } from "@intlayer/engine/cli";
|
|
11
11
|
import { pLimit, parallelize } from "@intlayer/engine/utils";
|
|
12
12
|
import fg from "fast-glob";
|
|
13
13
|
import { performance } from "node:perf_hooks";
|
|
@@ -6,9 +6,9 @@ import { chunkText } from "../utils/calculateChunks.mjs";
|
|
|
6
6
|
import { dirname, relative } from "node:path";
|
|
7
7
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
8
8
|
import { colon, colorize, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
|
|
9
|
-
import { retryManager } from "@intlayer/config/utils";
|
|
10
|
-
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
11
9
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
10
|
+
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
11
|
+
import { retryManager } from "@intlayer/config/utils";
|
|
12
12
|
import { performance } from "node:perf_hooks";
|
|
13
13
|
|
|
14
14
|
//#region src/translateDoc/translateFile.ts
|
|
@@ -32,7 +32,7 @@ const selectCmsEnvironment = async (environmentName, intlayerAPI, config) => {
|
|
|
32
32
|
appLogger(`Using environment: ${colorize(targetEnvironment.name, ANSIColors.CYAN)} (default)`);
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
await intlayerAPI.
|
|
35
|
+
await intlayerAPI.environment.selectEnvironment(String(targetEnvironment.id));
|
|
36
36
|
appLogger(`Using environment: ${colorize(targetEnvironment.name, ANSIColors.CYAN)}`);
|
|
37
37
|
} catch (error) {
|
|
38
38
|
appLogger(`Failed to select environment "${environmentName}": ${error}`, { level: "warn" });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectCmsEnvironment.mjs","names":[],"sources":["../../../src/utils/selectCmsEnvironment.ts"],"sourcesContent":["import type { IntlayerAPIProxy } from '@intlayer/api';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Selects the CMS project environment that matches `environmentName`.\n *\n * Convention: session.activeEnvironmentId = null means \"production\" (default).\n * When the target environment is the project's default, we reset the session to\n * null instead of storing the env's ObjectId — so no API call is needed.\n *\n * No-op when `environmentName` is undefined.\n */\nexport const selectCmsEnvironment = async (\n environmentName: string | undefined,\n intlayerAPI: IntlayerAPIProxy,\n config: IntlayerConfig\n): Promise<void> => {\n if (!environmentName) return;\n\n const appLogger = getAppLogger(config);\n\n try {\n const sessionResult = await intlayerAPI.oAuth.getCliSessionMe();\n const project = sessionResult.data?.project;\n\n if (!project) {\n appLogger(\n `Cannot resolve environment \"${environmentName}\": no project selected in session.`,\n { level: 'warn' }\n );\n return;\n }\n\n const projectEnvironments: any[] = (project as any).environments ?? [];\n\n if (projectEnvironments.length === 0) {\n // No environments stored — everything is implicitly production; nothing to select\n return;\n }\n\n const targetEnvironment = projectEnvironments.find(\n (environment: any) =>\n environment.name.toLowerCase() === environmentName.toLowerCase() ||\n String(environment.id) === environmentName\n );\n\n if (!targetEnvironment) {\n const availableNames = projectEnvironments\n .map((environment: any) => environment.name)\n .join(', ');\n appLogger(\n `Environment \"${environmentName}\" not found in project. Available: ${colorize(availableNames, ANSIColors.BLUE)}.`,\n { level: 'error' }\n );\n return;\n }\n\n // Production / default env → null convention; no API call needed\n if (targetEnvironment.isDefault) {\n appLogger(\n `Using environment: ${colorize(targetEnvironment.name, ANSIColors.CYAN)} (default)`\n );\n return;\n }\n\n await intlayerAPI.
|
|
1
|
+
{"version":3,"file":"selectCmsEnvironment.mjs","names":[],"sources":["../../../src/utils/selectCmsEnvironment.ts"],"sourcesContent":["import type { IntlayerAPIProxy } from '@intlayer/api';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Selects the CMS project environment that matches `environmentName`.\n *\n * Convention: session.activeEnvironmentId = null means \"production\" (default).\n * When the target environment is the project's default, we reset the session to\n * null instead of storing the env's ObjectId — so no API call is needed.\n *\n * No-op when `environmentName` is undefined.\n */\nexport const selectCmsEnvironment = async (\n environmentName: string | undefined,\n intlayerAPI: IntlayerAPIProxy,\n config: IntlayerConfig\n): Promise<void> => {\n if (!environmentName) return;\n\n const appLogger = getAppLogger(config);\n\n try {\n const sessionResult = await intlayerAPI.oAuth.getCliSessionMe();\n const project = sessionResult.data?.project;\n\n if (!project) {\n appLogger(\n `Cannot resolve environment \"${environmentName}\": no project selected in session.`,\n { level: 'warn' }\n );\n return;\n }\n\n const projectEnvironments: any[] = (project as any).environments ?? [];\n\n if (projectEnvironments.length === 0) {\n // No environments stored — everything is implicitly production; nothing to select\n return;\n }\n\n const targetEnvironment = projectEnvironments.find(\n (environment: any) =>\n environment.name.toLowerCase() === environmentName.toLowerCase() ||\n String(environment.id) === environmentName\n );\n\n if (!targetEnvironment) {\n const availableNames = projectEnvironments\n .map((environment: any) => environment.name)\n .join(', ');\n appLogger(\n `Environment \"${environmentName}\" not found in project. Available: ${colorize(availableNames, ANSIColors.BLUE)}.`,\n { level: 'error' }\n );\n return;\n }\n\n // Production / default env → null convention; no API call needed\n if (targetEnvironment.isDefault) {\n appLogger(\n `Using environment: ${colorize(targetEnvironment.name, ANSIColors.CYAN)} (default)`\n );\n return;\n }\n\n await intlayerAPI.environment.selectEnvironment(\n String(targetEnvironment.id)\n );\n\n appLogger(\n `Using environment: ${colorize(targetEnvironment.name, ANSIColors.CYAN)}`\n );\n } catch (error) {\n appLogger(`Failed to select environment \"${environmentName}\": ${error}`, {\n level: 'warn',\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,uBAAuB,OAClC,iBACA,aACA,WACkB;CAClB,IAAI,CAAC,iBAAiB;CAEtB,MAAM,YAAY,aAAa,MAAM;CAErC,IAAI;EAEF,MAAM,WAAU,MADY,YAAY,MAAM,gBAAgB,EACjC,CAAC,MAAM;EAEpC,IAAI,CAAC,SAAS;GACZ,UACE,+BAA+B,gBAAgB,qCAC/C,EAAE,OAAO,OAAO,CAClB;GACA;EACF;EAEA,MAAM,sBAA8B,QAAgB,gBAAgB,CAAC;EAErE,IAAI,oBAAoB,WAAW,GAEjC;EAGF,MAAM,oBAAoB,oBAAoB,MAC3C,gBACC,YAAY,KAAK,YAAY,MAAM,gBAAgB,YAAY,KAC/D,OAAO,YAAY,EAAE,MAAM,eAC/B;EAEA,IAAI,CAAC,mBAAmB;GACtB,MAAM,iBAAiB,oBACpB,KAAK,gBAAqB,YAAY,IAAI,CAAC,CAC3C,KAAK,IAAI;GACZ,UACE,gBAAgB,gBAAgB,qCAAqC,SAAS,gBAAgB,WAAW,IAAI,EAAE,IAC/G,EAAE,OAAO,QAAQ,CACnB;GACA;EACF;EAGA,IAAI,kBAAkB,WAAW;GAC/B,UACE,sBAAsB,SAAS,kBAAkB,MAAM,WAAW,IAAI,EAAE,WAC1E;GACA;EACF;EAEA,MAAM,YAAY,YAAY,kBAC5B,OAAO,kBAAkB,EAAE,CAC7B;EAEA,UACE,sBAAsB,SAAS,kBAAkB,MAAM,WAAW,IAAI,GACxE;CACF,SAAS,OAAO;EACd,UAAU,iCAAiC,gBAAgB,KAAK,SAAS,EACvE,OAAO,OACT,CAAC;CACH;AACF"}
|
package/dist/esm/watch.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
1
2
|
import { getAppLogger } from "@intlayer/config/logger";
|
|
2
3
|
import { getConfiguration } from "@intlayer/config/node";
|
|
3
|
-
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
4
4
|
import { claimCliContentWatcher, reportRedundantContentWatcher, runParallel } from "@intlayer/engine/utils";
|
|
5
5
|
import { watch } from "@intlayer/engine/watcher";
|
|
6
6
|
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { ConfigurationOptions, dirname, setAPI } from "./cli.js";
|
|
|
4
4
|
import { startEditor } from "./editor.js";
|
|
5
5
|
import { extract } from "./extract.js";
|
|
6
6
|
import { FillOptions, fill } from "./fill/fill.js";
|
|
7
|
-
import { findProjectRoot, init } from "./init.js";
|
|
7
|
+
import { ESLINT_CONFIG_FILES, INIT_STEP_GROUPS, InitStep, InitStepOption, LOCALE_ROUTING_CHOICES, LocaleRoutingChoice, OPT_IN_INIT_STEPS, findProjectRoot, getInitialInitSteps, getProjectDependencies, getRoutingInitOptions, init, isEslintInstalled, parseLocaleRoutingChoice } from "./init.js";
|
|
8
|
+
import { BROWSER_EXTENSION_OPTIONS, CHROME_EXTENSION_URL, MOZILLA_EXTENSION_URL, initChromeExtension } from "./initChromeExtension.js";
|
|
8
9
|
import { INFRA_MODES, INSTALL_SCRIPT_URL, INSTALL_SCRIPT_URL_WINDOWS, InfraMode, InitInfraOptions, initInfra, parseInfraMode } from "./initInfra.js";
|
|
9
10
|
import { PLATFORM_OPTIONS, getDetectedPlatform, initSkills, promptPlatform } from "./initSkills.js";
|
|
10
11
|
import { listContentDeclaration, listContentDeclarationRows } from "./listContentDeclaration.js";
|
|
@@ -24,4 +25,4 @@ export type * from "@intlayer/engine/cli";
|
|
|
24
25
|
export type * from "@intlayer/engine/build";
|
|
25
26
|
export type * from "@intlayer/engine/utils";
|
|
26
27
|
export type * from "@intlayer/engine/watcher";
|
|
27
|
-
export { ConfigurationOptions, FillOptions, INFRA_MODES, INSTALL_SCRIPT_URL, INSTALL_SCRIPT_URL_WINDOWS, InfraMode, InitInfraOptions, ListProjectsCommandOptions, PLATFORM_OPTIONS, ReviewDocMode, ScanCommandOptions, build, bundle, dirname, extract, fill, findProjectRoot, getDetectedPlatform, init, initInfra, initSkills, listContentDeclaration, listContentDeclarationRows, listMissingTranslations, listMissingTranslationsWithConfig, listProjectsCommand, liveSync, parseInfraMode, promptPlatform, pull, push, pushConfig, reviewDoc, scan, searchDoc, setAPI, startEditor, testMissingTranslations, translateDoc };
|
|
28
|
+
export { BROWSER_EXTENSION_OPTIONS, CHROME_EXTENSION_URL, ConfigurationOptions, ESLINT_CONFIG_FILES, FillOptions, INFRA_MODES, INIT_STEP_GROUPS, INSTALL_SCRIPT_URL, INSTALL_SCRIPT_URL_WINDOWS, InfraMode, InitInfraOptions, InitStep, InitStepOption, LOCALE_ROUTING_CHOICES, ListProjectsCommandOptions, LocaleRoutingChoice, MOZILLA_EXTENSION_URL, OPT_IN_INIT_STEPS, PLATFORM_OPTIONS, ReviewDocMode, ScanCommandOptions, build, bundle, dirname, extract, fill, findProjectRoot, getDetectedPlatform, getInitialInitSteps, getProjectDependencies, getRoutingInitOptions, init, initChromeExtension, initInfra, initSkills, isEslintInstalled, listContentDeclaration, listContentDeclarationRows, listMissingTranslations, listMissingTranslationsWithConfig, listProjectsCommand, liveSync, parseInfraMode, parseLocaleRoutingChoice, promptPlatform, pull, push, pushConfig, reviewDoc, scan, searchDoc, setAPI, startEditor, testMissingTranslations, translateDoc };
|
package/dist/types/init.d.ts
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
|
-
import { InitOptions } from "@intlayer/engine/cli";
|
|
1
|
+
import { InitOptions, RoutingMode } from "@intlayer/engine/cli";
|
|
2
2
|
//#region src/init.d.ts
|
|
3
3
|
export declare const findProjectRoot: (startDir: string) => string;
|
|
4
|
+
/** Individually selectable setup steps exposed by the interactive init flow. */
|
|
5
|
+
export type InitStep = 'packages' | 'githubActions' | 'projectSetup' | 'vscodeExtension' | 'lsp' | 'eslint' | 'skills' | 'mcp' | 'infra' | 'cms' | 'chromeExtension';
|
|
6
|
+
/** A checkbox entry of the interactive init flow. */
|
|
7
|
+
export type InitStepOption = {
|
|
8
|
+
value: InitStep;
|
|
9
|
+
label: string;
|
|
10
|
+
hint: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Steps shown but not pre-selected. The infrastructure installer touches the
|
|
14
|
+
* machine (downloads an app, pulls Docker images) and browser extensions open external URLs
|
|
15
|
+
* rather than modifying the project, so they must be an explicit choice.
|
|
16
|
+
*/
|
|
17
|
+
export declare const OPT_IN_INIT_STEPS: InitStep[];
|
|
18
|
+
/** Grouped checkbox entries of the interactive init flow, in display order. */
|
|
19
|
+
export declare const INIT_STEP_GROUPS: Record<string, InitStepOption[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Locale routing choice: a `routing.mode` served through the locale proxy, or
|
|
22
|
+
* `none` to leave routing to the app (`no-prefix` with the proxy disabled).
|
|
23
|
+
*/
|
|
24
|
+
export type LocaleRoutingChoice = RoutingMode | 'none';
|
|
25
|
+
/** Locale routing choices accepted by `--routing`. */
|
|
26
|
+
export declare const LOCALE_ROUTING_CHOICES: LocaleRoutingChoice[];
|
|
27
|
+
/** Validates a `--routing` value, throwing on an unknown choice. */
|
|
28
|
+
export declare const parseLocaleRoutingChoice: (value: string) => LocaleRoutingChoice;
|
|
29
|
+
/** Maps a routing choice to the init options it sets. */
|
|
30
|
+
export declare const getRoutingInitOptions: (choice: LocaleRoutingChoice) => Pick<InitOptions, 'routingMode' | 'enableProxy'>;
|
|
31
|
+
/** Known ESLint and oxlint configuration file names. */
|
|
32
|
+
export declare const ESLINT_CONFIG_FILES: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Checks whether ESLint or a compatible linter (oxlint) is installed or
|
|
35
|
+
* configured in the project.
|
|
36
|
+
*/
|
|
37
|
+
export declare const isEslintInstalled: (dependencies: Record<string, string>, root?: string) => boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Computes the initial setup steps selected by default in the interactive prompt.
|
|
40
|
+
* Steps like infrastructure and browser extension require opt-in, while
|
|
41
|
+
* eslint is preselected only if installed on the project.
|
|
42
|
+
*/
|
|
43
|
+
export declare const getInitialInitSteps: (dependencies: Record<string, string>, root?: string) => InitStep[];
|
|
44
|
+
/** Reads the merged dependencies of the project at `root`. */
|
|
45
|
+
export declare const getProjectDependencies: (root: string) => Record<string, string>;
|
|
4
46
|
export declare const init: (projectRoot?: string, options?: InitOptions, interactive?: boolean) => Promise<void>;
|
|
5
47
|
//#endregion
|
|
6
48
|
//# sourceMappingURL=init.d.ts.map
|
package/dist/types/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","names":[],"sources":["../../src/init.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"init.d.ts","names":[],"sources":["../../src/init.ts"],"mappings":";;qBAmBa,kBAAe;;YAgBhB;;YAcA;EACV,OAAO;EACP;EACA;;;;;;;qBAQW,mBAAmB;;qBAGnB,kBAAkB,eAAe;;;;;YAsElC,sBAAsB;;qBAoCrB,wBAAsB;;qBAKtB,2BAAwB,kBAElC;;qBAaU,wBAAqB,QACxB,wBACP,KAAK;;qBAMK;;;;;qBAoBA,oBAAiB,cACd,wBAAsB;;;;;;qBAkBzB,sBAAmB,cAChB,wBAAsB,kBAEnC;;qBAcU,yBAAsB,iBAEhC;qBAgJU,OAAI,sBACK,UACV,aAAW,0BACA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/initChromeExtension.d.ts
|
|
2
|
+
export declare const CHROME_EXTENSION_URL = "https://chromewebstore.google.com/detail/intlayer_i18n_scanner/pmlehcgmjmfimmjnembihbakhnheiabc";
|
|
3
|
+
export declare const MOZILLA_EXTENSION_URL = "https://addons.mozilla.org/en-US/firefox/addon/intlayer-i18n-scanner/";
|
|
4
|
+
export declare const BROWSER_EXTENSION_OPTIONS: {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
hint: string;
|
|
8
|
+
}[];
|
|
9
|
+
export declare const initChromeExtension: () => Promise<void>;
|
|
10
|
+
//#endregion
|
|
11
|
+
//# sourceMappingURL=initChromeExtension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initChromeExtension.d.ts","names":[],"sources":["../../src/initChromeExtension.ts"],"mappings":";qBAGa;qBAGA;qBAGA;;;;;qBAaA,2BAAmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchDoc.d.ts","names":[],"sources":["../../src/searchDoc.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"searchDoc.d.ts","names":[],"sources":["../../src/searchDoc.ts"],"mappings":";;UAoBU;EACR;EACA;EACA,gBAAgB;;qBAGL,cAAS,OAAA,OAAA,iBAInB,qBAAgB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/cli",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Provides uniform command-line interface scripts for Intlayer, used in packages like intlayer-cli and intlayer.",
|
|
6
6
|
"keywords": [
|
|
@@ -68,20 +68,20 @@
|
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@clack/prompts": "1.7.0",
|
|
71
|
-
"@intlayer/api": "9.5.
|
|
72
|
-
"@intlayer/babel": "9.5.
|
|
73
|
-
"@intlayer/config": "9.5.
|
|
74
|
-
"@intlayer/core": "9.5.
|
|
75
|
-
"@intlayer/dictionaries-entry": "9.5.
|
|
76
|
-
"@intlayer/engine": "9.5.
|
|
77
|
-
"@intlayer/types": "9.5.
|
|
71
|
+
"@intlayer/api": "9.5.10",
|
|
72
|
+
"@intlayer/babel": "9.5.10",
|
|
73
|
+
"@intlayer/config": "9.5.10",
|
|
74
|
+
"@intlayer/core": "9.5.10",
|
|
75
|
+
"@intlayer/dictionaries-entry": "9.5.10",
|
|
76
|
+
"@intlayer/engine": "9.5.10",
|
|
77
|
+
"@intlayer/types": "9.5.10",
|
|
78
78
|
"commander": "15.0.0",
|
|
79
79
|
"enquirer": "2.4.1",
|
|
80
80
|
"eventsource": "5.1.1",
|
|
81
81
|
"fast-glob": "3.3.3"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@intlayer/ai": "9.5.
|
|
84
|
+
"@intlayer/ai": "9.5.10",
|
|
85
85
|
"@types/node": "^22",
|
|
86
86
|
"@utils/ts-config": "1.0.4",
|
|
87
87
|
"@utils/ts-config-types": "1.0.4",
|
|
@@ -89,10 +89,10 @@
|
|
|
89
89
|
"rimraf": "6.1.3",
|
|
90
90
|
"tsdown": "0.23.0",
|
|
91
91
|
"typescript": "7.0.2",
|
|
92
|
-
"vitest": "5.0.
|
|
92
|
+
"vitest": "5.0.2"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@intlayer/ai": "9.5.
|
|
95
|
+
"@intlayer/ai": "9.5.10"
|
|
96
96
|
},
|
|
97
97
|
"peerDependenciesMeta": {
|
|
98
98
|
"@intlayer/ai": {
|