@intlayer/cli 8.4.0-canary.0 → 8.4.1
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/IntlayerEventListener.cjs +1 -1
- package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
- package/dist/cjs/_utils_asset-ghp_Cjwk.cjs +2 -0
- package/dist/cjs/auth/login.cjs +1 -1
- package/dist/cjs/auth/login.cjs.map +1 -1
- package/dist/cjs/build.cjs +1 -1
- package/dist/cjs/build.cjs.map +1 -1
- package/dist/cjs/{_virtual/_rolldown/runtime.cjs → chunk-Bmb41Sf3.cjs} +1 -1
- package/dist/cjs/ci.cjs +1 -1
- package/dist/cjs/ci.cjs.map +1 -1
- package/dist/cjs/cli.cjs +1 -1
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/config.cjs +1 -1
- package/dist/cjs/config.cjs.map +1 -1
- package/dist/cjs/editor.cjs +1 -1
- package/dist/cjs/editor.cjs.map +1 -1
- package/dist/cjs/extract.cjs +1 -1
- package/dist/cjs/extract.cjs.map +1 -1
- package/dist/cjs/fill/fill.cjs +1 -1
- package/dist/cjs/fill/fill.cjs.map +1 -1
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs +1 -1
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -1
- package/dist/cjs/fill/formatFillData.cjs +1 -1
- package/dist/cjs/fill/formatFillData.cjs.map +1 -1
- package/dist/cjs/fill/listTranslationsTasks.cjs +1 -1
- package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -1
- package/dist/cjs/fill/translateDictionary.cjs +1 -1
- package/dist/cjs/fill/translateDictionary.cjs.map +1 -1
- package/dist/cjs/fill/writeFill.cjs +1 -1
- package/dist/cjs/fill/writeFill.cjs.map +1 -1
- package/dist/cjs/getTargetDictionary.cjs +1 -1
- package/dist/cjs/getTargetDictionary.cjs.map +1 -1
- package/dist/cjs/init.cjs +1 -1
- package/dist/cjs/init.cjs.map +1 -1
- package/dist/cjs/initMCP.cjs +1 -1
- package/dist/cjs/initMCP.cjs.map +1 -1
- package/dist/cjs/initSkills.cjs +1 -1
- package/dist/cjs/initSkills.cjs.map +1 -1
- package/dist/cjs/listContentDeclaration.cjs +1 -1
- package/dist/cjs/listContentDeclaration.cjs.map +1 -1
- package/dist/cjs/listProjects.cjs +1 -1
- package/dist/cjs/listProjects.cjs.map +1 -1
- package/dist/cjs/liveSync.cjs +1 -1
- package/dist/cjs/liveSync.cjs.map +1 -1
- package/dist/cjs/pull.cjs +1 -1
- package/dist/cjs/pull.cjs.map +1 -1
- package/dist/cjs/push/pullLog.cjs +1 -1
- package/dist/cjs/push/pullLog.cjs.map +1 -1
- package/dist/cjs/push/push.cjs +1 -1
- package/dist/cjs/push/push.cjs.map +1 -1
- package/dist/cjs/pushConfig.cjs +1 -1
- package/dist/cjs/pushConfig.cjs.map +1 -1
- package/dist/cjs/pushLog.cjs +1 -1
- package/dist/cjs/pushLog.cjs.map +1 -1
- package/dist/cjs/reviewDoc/reviewDoc.cjs +1 -1
- package/dist/cjs/reviewDoc/reviewDoc.cjs.map +1 -1
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +1 -1
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs.map +1 -1
- package/dist/cjs/searchDoc.cjs +1 -1
- package/dist/cjs/searchDoc.cjs.map +1 -1
- package/dist/cjs/test/listMissingTranslations.cjs +1 -1
- package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
- package/dist/cjs/test/test.cjs +1 -1
- package/dist/cjs/test/test.cjs.map +1 -1
- package/dist/cjs/translateDoc/index.cjs +1 -1
- package/dist/cjs/translateDoc/translateDoc.cjs +1 -1
- package/dist/cjs/translateDoc/translateDoc.cjs.map +1 -1
- package/dist/cjs/translateDoc/translateFile.cjs +1 -1
- package/dist/cjs/translateDoc/translateFile.cjs.map +1 -1
- package/dist/cjs/translation-alignment/fingerprintBlock.cjs +1 -1
- package/dist/cjs/translation-alignment/fingerprintBlock.cjs.map +1 -1
- package/dist/cjs/utils/calculateChunks.cjs +1 -1
- package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
- package/dist/cjs/utils/checkAccess.cjs +1 -1
- package/dist/cjs/utils/checkAccess.cjs.map +1 -1
- package/dist/cjs/utils/checkLastUpdateTime.cjs +1 -1
- package/dist/cjs/utils/checkLastUpdateTime.cjs.map +1 -1
- package/dist/cjs/utils/chunkInference.cjs +1 -1
- package/dist/cjs/utils/chunkInference.cjs.map +1 -1
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +1 -1
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs.map +1 -1
- package/dist/cjs/utils/getParentPackageJSON.cjs +1 -1
- package/dist/cjs/utils/getParentPackageJSON.cjs.map +1 -1
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs +1 -1
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
- package/dist/cjs/utils/openBrowser.cjs +1 -1
- package/dist/cjs/utils/openBrowser.cjs.map +1 -1
- package/dist/cjs/utils/setupAI.cjs +1 -1
- package/dist/cjs/utils/setupAI.cjs.map +1 -1
- package/dist/cjs/watch.cjs +1 -1
- package/dist/cjs/watch.cjs.map +1 -1
- package/dist/esm/{_virtual/_utils_asset.mjs → _utils_asset-B187VPMw.mjs} +1 -1
- package/dist/esm/cli.mjs +1 -1
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/editor-D8BGlLzF.mjs +2 -0
- package/dist/esm/editor-D8BGlLzF.mjs.map +1 -0
- package/dist/esm/editor.mjs +1 -2
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/reviewDoc/reviewDoc.mjs +1 -1
- package/dist/esm/reviewDoc/reviewDoc.mjs.map +1 -1
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +1 -1
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs.map +1 -1
- package/dist/esm/translateDoc/index.mjs +1 -1
- package/dist/esm/translateDoc/translateDoc.mjs +1 -1
- package/dist/esm/translateDoc/translateDoc.mjs.map +1 -1
- package/dist/esm/translateDoc/translateFile.mjs +1 -1
- package/dist/esm/translateDoc/translateFile.mjs.map +1 -1
- package/dist/types/fill/fill.d.ts +1 -1
- package/dist/types/fill/translateDictionary.d.ts +1 -1
- package/dist/types/getTargetDictionary-RBSRtaQj.d.ts +19 -0
- package/dist/types/getTargetDictionary-RBSRtaQj.d.ts.map +1 -0
- package/dist/types/getTargetDictionary.d.ts +2 -19
- package/dist/types/index.d.ts +2 -2
- package/dist/types/listMissingTranslations-DxKw7nqI.d.ts +28 -0
- package/dist/types/listMissingTranslations-DxKw7nqI.d.ts.map +1 -0
- package/dist/types/reviewDoc/reviewDocBlockAware.d.ts +1 -1
- package/dist/types/setupAI-Bosjx7ah.d.ts +21 -0
- package/dist/types/setupAI-Bosjx7ah.d.ts.map +1 -0
- package/dist/types/test/index.d.ts +2 -2
- package/dist/types/test/listMissingTranslations.d.ts +2 -28
- package/dist/types/test/test.d.ts +2 -11
- package/dist/types/test-DUTiJR5_.d.ts +11 -0
- package/dist/types/test-DUTiJR5_.d.ts.map +1 -0
- package/dist/types/translateDoc/index.d.ts +1 -1
- package/dist/types/translateDoc/translateDoc.d.ts +1 -1
- package/dist/types/translateDoc/translateFile.d.ts +1 -1
- package/dist/types/translateDoc/types.d.ts +2 -48
- package/dist/types/types-BKvc3FmV.d.ts +48 -0
- package/dist/types/types-BKvc3FmV.d.ts.map +1 -0
- package/dist/types/utils/chunkInference.d.ts +1 -1
- package/dist/types/utils/setupAI.d.ts +2 -21
- package/package.json +12 -12
- package/dist/cjs/_virtual/_utils_asset.cjs +0 -2
- package/dist/esm/_virtual/_rolldown/runtime.mjs +0 -1
- package/dist/esm/editor.mjs.map +0 -1
- package/dist/types/getTargetDictionary.d.ts.map +0 -1
- package/dist/types/test/listMissingTranslations.d.ts.map +0 -1
- package/dist/types/test/test.d.ts.map +0 -1
- package/dist/types/translateDoc/types.d.ts.map +0 -1
- package/dist/types/utils/setupAI.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupAI.cjs","names":["ANSIColors","checkAIAccess"],"sources":["../../../src/utils/setupAI.ts"],"sourcesContent":["import type { AIConfig, AIOptions } from '@intlayer/ai';\nimport {\n ANSIColors,\n colorize,\n getAppLogger,\n type logger,\n} from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { checkAIAccess } from './checkAccess';\n\nexport type AIClient = typeof import('@intlayer/ai');\n\ntype SetupAIResult = {\n aiClient?: AIClient;\n aiConfig?: AIConfig;\n isCustomAI: boolean;\n hasAIAccess: boolean;\n};\n\n// Disable warnings from the AI SDK\nglobalThis.AI_SDK_LOG_WARNINGS = false;\n\nconst logAIConfig = (aiOptions: AIOptions, appLogger: typeof logger) => {\n appLogger([\n colorize('Provider:', ANSIColors.GREY_DARK),\n colorize(aiOptions?.provider ?? '(default)', ANSIColors.BLUE),\n colorize('- Model:', ANSIColors.GREY_DARK),\n colorize(aiOptions?.model ?? '(default)', ANSIColors.BLUE),\n colorize('- API Key:', ANSIColors.GREY_DARK),\n colorize(aiOptions?.apiKey ? '✓' : '(not set)', ANSIColors.BLUE),\n ]);\n};\n\n/**\n * Checks if the @intlayer/ai package is available and configured when an API key is provided.\n * If API key is present but package is missing, logs a warning.\n * Also checks if the user has access to AI (either via local key or CMS auth).\n */\nexport const setupAI = async (\n configuration: IntlayerConfig,\n aiOptions?: AIOptions\n): Promise<SetupAIResult | undefined> => {\n const appLogger = getAppLogger(configuration);\n\n const isLocalAI =\n aiOptions?.apiKey ||\n aiOptions?.provider === 'ollama' ||\n configuration.ai?.apiKey ||\n configuration.ai?.provider === 'ollama';\n\n if (isLocalAI) {\n // Try to import the AI package for local AI usage\n let aiClient: AIClient | undefined;\n\n try {\n aiClient = await import('@intlayer/ai');\n } catch {\n // Package not installed - log warning and fall back to backend\n appLogger(\n [\n colorize('Using your API key, you can install the', ANSIColors.GREY),\n colorize('@intlayer/ai', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to run the process locally, with no dependency on the Intlayer server',\n ANSIColors.GREY\n ),\n ],\n {\n level: 'warn',\n }\n );\n\n // Fall back to backend API check\n const hasAIAccess = await checkAIAccess(configuration, aiOptions);\n logAIConfig(aiOptions ?? {}, appLogger);\n return {\n isCustomAI: false,\n hasAIAccess,\n };\n }\n\n // Package found - now configure it (errors here should propagate, not fall back)\n appLogger([\n colorize('@intlayer/ai', ANSIColors.GREY_LIGHT),\n colorize('found - Run process locally', ANSIColors.GREY_DARK),\n ]);\n\n const aiConfig = await aiClient.getAIConfig({\n userOptions: aiOptions,\n accessType: ['public'],\n });\n\n logAIConfig(aiOptions ?? {}, appLogger);\n\n return {\n aiClient,\n aiConfig,\n isCustomAI: true,\n hasAIAccess: true, // Local AI always has access\n };\n }\n\n // No local AI configured - use backend API\n const hasAIAccess = await checkAIAccess(configuration, aiOptions);\n logAIConfig(aiOptions ?? {}, appLogger);\n\n return {\n isCustomAI: false,\n hasAIAccess,\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"setupAI.cjs","names":["ANSIColors","checkAIAccess"],"sources":["../../../src/utils/setupAI.ts"],"sourcesContent":["import type { AIConfig, AIOptions } from '@intlayer/ai';\nimport {\n ANSIColors,\n colorize,\n getAppLogger,\n type logger,\n} from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { checkAIAccess } from './checkAccess';\n\nexport type AIClient = typeof import('@intlayer/ai');\n\ntype SetupAIResult = {\n aiClient?: AIClient;\n aiConfig?: AIConfig;\n isCustomAI: boolean;\n hasAIAccess: boolean;\n};\n\n// Disable warnings from the AI SDK\nglobalThis.AI_SDK_LOG_WARNINGS = false;\n\nconst logAIConfig = (aiOptions: AIOptions, appLogger: typeof logger) => {\n appLogger([\n colorize('Provider:', ANSIColors.GREY_DARK),\n colorize(aiOptions?.provider ?? '(default)', ANSIColors.BLUE),\n colorize('- Model:', ANSIColors.GREY_DARK),\n colorize(aiOptions?.model ?? '(default)', ANSIColors.BLUE),\n colorize('- API Key:', ANSIColors.GREY_DARK),\n colorize(aiOptions?.apiKey ? '✓' : '(not set)', ANSIColors.BLUE),\n ]);\n};\n\n/**\n * Checks if the @intlayer/ai package is available and configured when an API key is provided.\n * If API key is present but package is missing, logs a warning.\n * Also checks if the user has access to AI (either via local key or CMS auth).\n */\nexport const setupAI = async (\n configuration: IntlayerConfig,\n aiOptions?: AIOptions\n): Promise<SetupAIResult | undefined> => {\n const appLogger = getAppLogger(configuration);\n\n const isLocalAI =\n aiOptions?.apiKey ||\n aiOptions?.provider === 'ollama' ||\n configuration.ai?.apiKey ||\n configuration.ai?.provider === 'ollama';\n\n if (isLocalAI) {\n // Try to import the AI package for local AI usage\n let aiClient: AIClient | undefined;\n\n try {\n aiClient = await import('@intlayer/ai');\n } catch {\n // Package not installed - log warning and fall back to backend\n appLogger(\n [\n colorize('Using your API key, you can install the', ANSIColors.GREY),\n colorize('@intlayer/ai', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to run the process locally, with no dependency on the Intlayer server',\n ANSIColors.GREY\n ),\n ],\n {\n level: 'warn',\n }\n );\n\n // Fall back to backend API check\n const hasAIAccess = await checkAIAccess(configuration, aiOptions);\n logAIConfig(aiOptions ?? {}, appLogger);\n return {\n isCustomAI: false,\n hasAIAccess,\n };\n }\n\n // Package found - now configure it (errors here should propagate, not fall back)\n appLogger([\n colorize('@intlayer/ai', ANSIColors.GREY_LIGHT),\n colorize('found - Run process locally', ANSIColors.GREY_DARK),\n ]);\n\n const aiConfig = await aiClient.getAIConfig({\n userOptions: aiOptions,\n accessType: ['public'],\n });\n\n logAIConfig(aiOptions ?? {}, appLogger);\n\n return {\n aiClient,\n aiConfig,\n isCustomAI: true,\n hasAIAccess: true, // Local AI always has access\n };\n }\n\n // No local AI configured - use backend API\n const hasAIAccess = await checkAIAccess(configuration, aiOptions);\n logAIConfig(aiOptions ?? {}, appLogger);\n\n return {\n isCustomAI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AEhC,CACL,WAAY,GACZ,cACD"}
|
package/dist/cjs/watch.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunk-Bmb41Sf3.cjs`);let e=require(`@intlayer/chokidar/cli`),t=require(`@intlayer/chokidar/utils`),n=require(`@intlayer/config/logger`),r=require(`@intlayer/config/node`),i=require(`@intlayer/chokidar/watcher`);const a=async a=>{let o=(0,r.getConfiguration)(a?.configOptions);(0,e.logConfigDetails)(a?.configOptions);let s=(0,n.getAppLogger)(o),c;a?.with&&(c=(0,t.runParallel)(a.with),c.result.catch(()=>{process.exit(1)}));let l=(0,i.watch)({persistent:!0,skipPrepare:a?.skipPrepare??!1}),u=async()=>{process.off(`SIGINT`,u),process.off(`SIGTERM`,u),s(`Stopping Intlayer watcher...`);try{await l.close(),c&&`child`in c&&c.child?.kill(`SIGTERM`)}catch(e){console.error(`Error during shutdown:`,e)}finally{process.exit(0)}};process.on(`SIGINT`,u),process.on(`SIGTERM`,u)};exports.watchContentDeclaration=a;
|
|
2
2
|
//# sourceMappingURL=watch.cjs.map
|
package/dist/cjs/watch.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.cjs","names":[],"sources":["../../src/watch.ts"],"sourcesContent":["import { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { runParallel } from '@intlayer/chokidar/utils';\nimport { watch } from '@intlayer/chokidar/watcher';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\n\ntype WatchOptions = {\n skipPrepare?: boolean;\n with?: string | string[];\n configOptions?: GetConfigurationOptions;\n};\n\n/**\n * Get locales dictionaries .content.{json|ts|tsx|js|jsx|mjs|cjs} and build the JSON dictionaries in the .intlayer directory.\n * Watch mode available to get the change in the .content.{json|ts|tsx|js|jsx|mjs|cjs}\n */\nexport const watchContentDeclaration = async (options?: WatchOptions) => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n // Store references to the child process\n let parallelProcess: ReturnType<typeof runParallel> | undefined;\n\n if (options?.with) {\n parallelProcess = runParallel(options.with);\n // Handle the promise to avoid unhandled rejection\n parallelProcess.result.catch(() => {\n // Parallel process failed or was terminated\n process.exit(1);\n });\n }\n\n // Capture the watcher instance\n const watcher = watch({\n persistent: true,\n skipPrepare: options?.skipPrepare ?? false,\n });\n\n // Define a Graceful Shutdown function\n const handleShutdown = async () => {\n // Prevent multiple calls\n process.off('SIGINT', handleShutdown);\n process.off('SIGTERM', handleShutdown);\n\n appLogger('Stopping Intlayer watcher...');\n\n try {\n // Close the file watcher immediately to stop \"esbuild service not running\" errors\n await watcher.close();\n\n // If runParallel exposes the child process, we can try to kill it explicitly.\n // Even if it doesn't, process.exit() below usually cleans up attached children.\n if (parallelProcess && 'child' in parallelProcess) {\n // @ts-ignore - Assuming child exists on the return type if runParallel is based on spawn/exec\n parallelProcess.child?.kill('SIGTERM');\n }\n } catch (error) {\n console.error('Error during shutdown:', error);\n } finally {\n process.exit(0);\n }\n };\n\n // Attach Signal Listeners\n process.on('SIGINT', handleShutdown);\n process.on('SIGTERM', handleShutdown);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"watch.cjs","names":[],"sources":["../../src/watch.ts"],"sourcesContent":["import { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { runParallel } from '@intlayer/chokidar/utils';\nimport { watch } from '@intlayer/chokidar/watcher';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\n\ntype WatchOptions = {\n skipPrepare?: boolean;\n with?: string | string[];\n configOptions?: GetConfigurationOptions;\n};\n\n/**\n * Get locales dictionaries .content.{json|ts|tsx|js|jsx|mjs|cjs} and build the JSON dictionaries in the .intlayer directory.\n * Watch mode available to get the change in the .content.{json|ts|tsx|js|jsx|mjs|cjs}\n */\nexport const watchContentDeclaration = async (options?: WatchOptions) => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n // Store references to the child process\n let parallelProcess: ReturnType<typeof runParallel> | undefined;\n\n if (options?.with) {\n parallelProcess = runParallel(options.with);\n // Handle the promise to avoid unhandled rejection\n parallelProcess.result.catch(() => {\n // Parallel process failed or was terminated\n process.exit(1);\n });\n }\n\n // Capture the watcher instance\n const watcher = watch({\n persistent: true,\n skipPrepare: options?.skipPrepare ?? false,\n });\n\n // Define a Graceful Shutdown function\n const handleShutdown = async () => {\n // Prevent multiple calls\n process.off('SIGINT', handleShutdown);\n process.off('SIGTERM', handleShutdown);\n\n appLogger('Stopping Intlayer watcher...');\n\n try {\n // Close the file watcher immediately to stop \"esbuild service not running\" errors\n await watcher.close();\n\n // If runParallel exposes the child process, we can try to kill it explicitly.\n // Even if it doesn't, process.exit() below usually cleans up attached children.\n if (parallelProcess && 'child' in parallelProcess) {\n // @ts-ignore - Assuming child exists on the return type if runParallel is based on spawn/exec\n parallelProcess.child?.kill('SIGTERM');\n }\n } catch (error) {\n console.error('Error during shutdown:', error);\n } finally {\n process.exit(0);\n }\n };\n\n // Attach Signal Listeners\n process.on('SIGINT', handleShutdown);\n process.on('SIGTERM', handleShutdown);\n};\n"],"mappings":"iSAmBA,MAAa,EAA0B,KAAO,IAA2B,CACvE,IAAM,GAAA,EAAA,EAAA,kBAA0B,GAAS,cAAc,EACvD,EAAA,EAAA,kBAAiB,GAAS,cAAc,CAExC,IAAM,GAAA,EAAA,EAAA,cAAyB,EAAO,CAGlC,EAEA,GAAS,OACX,GAAA,EAAA,EAAA,aAA8B,EAAQ,KAAK,CAE3C,EAAgB,OAAO,UAAY,CAEjC,QAAQ,KAAK,EAAE,EACf,EAIJ,IAAM,GAAA,EAAA,EAAA,OAAgB,CACpB,WAAY,GACZ,YAAa,GAAS,aAAe,GACtC,CAAC,CAGI,EAAiB,SAAY,CAEjC,QAAQ,IAAI,SAAU,EAAe,CACrC,QAAQ,IAAI,UAAW,EAAe,CAEtC,EAAU,+BAA+B,CAEzC,GAAI,CAEF,MAAM,EAAQ,OAAO,CAIjB,GAAmB,UAAW,GAEhC,EAAgB,OAAO,KAAK,UAAU,OAEjC,EAAO,CACd,QAAQ,MAAM,yBAA0B,EAAM,QACtC,CACR,QAAQ,KAAK,EAAE,GAKnB,QAAQ,GAAG,SAAU,EAAe,CACpC,QAAQ,GAAG,UAAW,EAAe"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{existsSync as e,readFileSync as t}from"node:fs";import{basename as n,dirname as r,join as i,relative as a,resolve as o,sep as s}from"node:path";import{fileURLToPath as c}from"node:url";const l=()=>{try{return r(c(import.meta.url))}catch{return typeof __dirname<`u`?__dirname:process.cwd()}},u=e=>{let t=e;for(let e=0;e<12;e++){if(n(t)===`dist`)return t;let e=o(t,`..`);if(e===t)break;t=e}return null},d=e=>{if(!e)return null;try{if(e.startsWith(`file://`))return c(e)}catch{}return e},f=()=>{let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error();Error.captureStackTrace(e,f);let t=e.stack||[],n=e=>e.includes(`${s}_virtual${s}`)||e.includes(`/_virtual/`);for(let e of t){let t=d(typeof e.getFileName==`function`?e.getFileName():null);if(t&&!(t.includes(`node:internal`)||t.includes(`${s}internal${s}modules${s}`))&&!n(t))return r(t)}for(let e of t){let t=d(typeof e.getFileName==`function`?e.getFileName():null);if(t)return r(t)}}catch{}finally{Error.prepareStackTrace=e}return l()},p=(n,r=`utf8`)=>{let s=l(),c=u(s)??o(s,`..`,`..`,`dist`),d=i(c,`assets`),p=[],m=a(c,f()).split(`\\`).join(`/`).replace(/^(?:dist\/)?(?:esm|cjs)\//,``).replace(/^_virtual\//,``);if(n.startsWith(`./`)||n.startsWith(`../`)){let i=o(d,m,n);if(p.push(i),e(i))return t(i,r)}let h=i(d,n);if(p.push(h),e(h))return t(h,r);if(m){let a=i(d,m,n);if(p.push(a),e(a))return t(a,r)}let g=[`readAsset: file not found.`,`Searched:`,...p.map(e=>`- ${e}`)].join(`
|
|
2
|
-
`);throw Error(g)};export{p as
|
|
2
|
+
`);throw Error(g)};export{p as t};
|
package/dist/esm/cli.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{extract as e}from"./extract.mjs";import{listProjectsCommand as t}from"./listProjects.mjs";import{liveSync as n}from"./liveSync.mjs";import{listContentDeclaration as r}from"./listContentDeclaration.mjs";import{init as i}from"./init.mjs";import{startEditor as a}from"./editor.mjs";import{watchContentDeclaration as o}from"./watch.mjs";import{login as s}from"./auth/login.mjs";import{build as c}from"./build.mjs";import{runCI as l}from"./ci.mjs";import{getConfig as ee}from"./config.mjs";import{testMissingTranslations as u}from"./test/test.mjs";import{fill as te}from"./fill/fill.mjs";import{initSkills as d}from"./initSkills.mjs";import{initMCP as ne}from"./initMCP.mjs";import{pull as f}from"./pull.mjs";import{push as p}from"./push/push.mjs";import{pushConfig as re}from"./pushConfig.mjs";import{reviewDoc as ie}from"./reviewDoc/reviewDoc.mjs";import{searchDoc as ae}from"./searchDoc.mjs";import{translateDoc as oe}from"./translateDoc/translateDoc.mjs";import{getParentPackageJSON as m}from"./utils/getParentPackageJSON.mjs";import{dirname as h}from"node:path";import{setPrefix as se}from"@intlayer/config/logger";import{getConfiguration as g}from"@intlayer/config/node";import{fileURLToPath as _}from"node:url";import{Command as v}from"commander";const y=typeof import.meta.url==`string`?h(_(import.meta.url)):__dirname,b=m(y),x=[[`--env-file [envFile]`,`Environment file`],[`-e, --env [env]`,`Environment`],[`--base-dir [baseDir]`,`Base directory`],[`--no-cache [noCache]`,`No cache`],...[[`--verbose`,`Verbose (default to true using CLI)`],[`--prefix [prefix]`,`Prefix`]]],S=[[`--provider [provider]`,`Provider`],[`--temperature [temperature]`,`Temperature`],[`--model [model]`,`Model`],[`--api-key [apiKey]`,`Provider API key`],[`--custom-prompt [prompt]`,`Custom prompt`],[`--application-context [applicationContext]`,`Application context`],[`--data-serialization [dataSerialization]`,`Data serialization`]],C=[[`--git-diff [gitDiff]`,`Git diff mode - Check git diff between two refs`],[`--git-diff-base [gitDiffBase]`,`Git diff base ref`],[`--git-diff-current [gitDiffCurrent]`,`Git diff current ref`],[`--uncommitted [uncommitted]`,`Uncommitted`],[`--unpushed [unpushed]`,`Unpushed`],[`--untracked [untracked]`,`Untracked`]],w=(e,t)=>t.filter(t=>e[t]!==void 0),T=(e,t)=>(t.forEach(([t,n])=>{e.option(t,n)}),e),E=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>t!==void 0)),D=e=>T(e,x),O=e=>T(e,S),k=e=>T(e,C),A=e=>{let{apiKey:t,provider:n,model:r,temperature:i,applicationContext:a,customPrompt:o,dataSerialization:s}=e,c=g(),{ai:l}=c;return E({...l,apiKey:t??c.ai?.apiKey,provider:n??c.ai?.provider,model:r??c.ai?.model,temperature:i??c.ai?.temperature,applicationContext:a??c.ai?.applicationContext,customPrompt:o??c.ai?.customPrompt,dataSerialization:s??c.ai?.dataSerialization})},j=[`gitDiff`,`gitDiffBase`,`gitDiffCurrent`,`uncommitted`,`unpushed`,`untracked`],M=e=>{if(w(e,j).length===0)return;let{gitDiff:t,gitDiffBase:n,gitDiffCurrent:r,uncommitted:i,unpushed:a,untracked:o}=e;return E({mode:[t&&`gitDiff`,i&&`uncommitted`,a&&`unpushed`,o&&`untracked`].filter(Boolean),baseRef:n,currentRef:r,absolute:!0})},N=[`baseDir`,`env`,`envFile`,`verbose`,`prefix`,`checkTypes`],P=e=>{if(w(e,N).length===0)return;let{baseDir:t,env:n,envFile:r,verbose:i,noCache:a,checkTypes:o}=e,s=E({mode:i===void 0?void 0:i?`verbose`:`default`}),c=E({checkTypes:o}),l=E({log:Object.keys(s).length>0?s:void 0,build:Object.keys(c).length>0?c:void 0});return E({baseDir:t,env:n,envFile:r,override:Object.keys(l).length>0?l:void 0,cache:a===void 0?void 0:!a})},F=()=>{process.argv.includes(`--with`)||se(``);let m=new v;m.version(b.version).description(`Intlayer CLI`),m.command(`version`).description(`Print the Intlayer CLI version`).action(()=>{console.log(b.version??`unknown`)});let h=m.command(`login`).description(`Login to Intlayer`).option(`--cms-url [cmsUrl]`,`CMS URL`);D(h),h.action(e=>{let t=P(e)??{override:{log:{prefix:``,mode:`verbose`}}};return s({cmsUrl:e.cmsUrl,configOptions:t})});let g=m.command(`init`).description(`Initialize Intlayer in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>i(e.projectRoot));g.command(`skills`).description(`Initialize Intlayer skills in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>d(e.projectRoot)),g.command(`mcp`).description(`Initialize Intlayer MCP server in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>ne(e.projectRoot));let _=m.command(`dictionary`).alias(`dictionaries`).alias(`dic`).description(`Dictionaries operations`),y={description:`Build the dictionaries`,options:[[`-w, --watch`,`Watch for changes`],[`--skip-prepare`,`Skip the prepare step`],[`--with [with...]`,`Start command in parallel with the build`],[`--check-types`,`Check TypeScript type and log errors`]]},x=_.command(`build`).description(y.description);T(x,y.options),D(x),x.action(e=>{c({...e,configOptions:P(e)})});let S=m.command(`build`).description(y.description);T(S,y.options),D(S),S.action(e=>{c({...e,configOptions:P(e)})});let C={description:`Watch the dictionaries changes`,options:[[`--with [with...]`,`Start command in parallel with the build`]]},w=_.command(`watch`).description(y.description);T(w,C.options),D(w),w.action(e=>{o({...e,configOptions:P(e)})});let E=m.command(`watch`).description(y.description);T(E,C.options),D(E),E.action(e=>{o({...e,configOptions:P(e)})});let j={description:`Pull dictionaries from the server`,options:[[`-d, --dictionaries [ids...]`,`List of dictionary IDs to pull`],[`--dictionary [ids...]`,`List of dictionary IDs to pull (alias for --dictionaries)`],[`--new-dictionaries-path [path]`,`Path to save the new dictionaries`],[`--newDictionariesPath [path]`,`[alias] Path to save the new dictionaries`]]},N=_.command(`pull`).description(j.description);T(N,j.options),D(N),N.action(e=>{let t=[...e.dictionaries??[],...e.dictionary??[]];f({...e,dictionaries:t.length>0?t:void 0,configOptions:{...e.configOptions,baseDir:e.baseDir}})});let F=m.command(`pull`).description(j.description);T(F,j.options),D(F),F.action(e=>{let t=[...e.dictionaries??[],...e.dictionary??[]];f({...e,dictionaries:t.length>0?t:void 0,configOptions:P(e)})});let I={description:`Push all dictionaries. Create or update the pushed dictionaries`,options:[[`-d, --dictionaries [ids...]`,`List of dictionary IDs to push`],[`--dictionary [ids...]`,`List of dictionary IDs to push (alias for --dictionaries)`],[`-r, --delete-locale-dictionary`,`Delete the local dictionaries after pushing`],[`-k, --keep-locale-dictionary`,`Keep the local dictionaries after pushing`],[`--deleteLocaleDictionary`,`[alias] Delete the local dictionaries after pushing`],[`--keepLocaleDictionary`,`[alias] Keep the local dictionaries after pushing`],[`--build [build]`,`Build the dictionaries before pushing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build`]]},L=_.command(`push`).description(I.description);T(L,I.options),D(L),k(L),L.action(e=>{let t=[...e.dictionaries||[],...e.dictionary||[]];return p({...e,dictionaries:t.length>0?t:void 0,gitOptions:M(e),configOptions:P(e)})});let R=m.command(`push`).description(I.description);T(R,I.options),D(R),k(R),R.action(e=>{let t=[...e.dictionaries||[],...e.dictionary||[]];return p({...e,dictionaries:t.length>0?t:void 0,gitOptions:M(e),configOptions:P(e)})});let z=m.command(`configuration`).alias(`config`).alias(`conf`).description(`Configuration operations`),B=z.command(`get`).description(`Get the configuration`);D(B),B.action(e=>{ee({...e,configOptions:P(e)})});let V=z.command(`push`).description(`Push the configuration`);D(V),V.action(e=>{re({...e,configOptions:P(e)})}),m.command(`projects`).alias(`project`).description(`List Intlayer projects`).command(`list`).description(`List all Intlayer projects in the directory`).option(`--base-dir [baseDir]`,`Base directory to search from`).option(`--git-root`,`Search from the git root directory instead of the base directory`).option(`--json`,`Output the results as JSON`).action(e=>{t({baseDir:e.baseDir,gitRoot:e.gitRoot,json:e.json})}),m.command(`projects-list`).alias(`pl`).description(`List all Intlayer projects in the directory`).option(`--base-dir [baseDir]`,`Base directory to search from`).option(`--git-root`,`Search from the git root directory instead of the base directory`).option(`--absolute`,`Output the results as absolute paths`).option(`--json`,`Output the results as JSON`).action(e=>{t({baseDir:e.baseDir,gitRoot:e.gitRoot,json:e.json,absolute:e.absolute})});let H=m.command(`content`).description(`Content declaration operations`);H.command(`list`).description(`List the content declaration files`).option(`--json`,`Output the results as JSON`).option(`--absolute`,`Output the results as absolute paths`).action(e=>{r({json:e.json,absolute:e.absolute})}),m.command(`list`).description(`List the content declaration files`).option(`--json`,`Output the results as JSON`).option(`--absolute`,`Output the results as absolute paths`).action(e=>{r({json:e.json,absolute:e.absolute})});let U=H.command(`test`).description(`Test if there are missing translations`).option(`--build [build]`,`Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build`);D(U),U.action(e=>{u({...e,configOptions:P(e)})});let W=m.command(`test`).description(`Test if there are missing translations`).option(`--build [build]`,`Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build`);D(W),W.action(e=>{u({...e,configOptions:P(e)})});let G=m.command(`fill`).description(`Fill the dictionaries`).option(`-f, --file [files...]`,`List of Dictionary files to fill`).option(`--source-locale [sourceLocale]`,`Source locale to translate from`).option(`--output-locales [outputLocales...]`,`Target locales to translate to`).option(`--mode [mode]`,`Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys`,`complete`).option(`-k, --keys [keys...]`,`Filter dictionaries based on keys`).option(`--key [keys...]`,`Filter dictionaries based on keys (alias for --keys)`).option(`--excluded-keys [excludedKeys...]`,`Filter out dictionaries based on keys`).option(`--excluded-key [excludedKeys...]`,`Filter out dictionaries based on keys (alias for --excluded-keys)`).option(`--path-filter [pathFilters...]`,`Filter dictionaries based on glob pattern`).option(`--build [build]`,`Build the dictionaries before filling to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build`).option(`--skip-metadata`,`Skip filling missing metadata (description, title, tags) for dictionaries`);D(G),O(G),k(G),G.action(e=>{let t=[...e.keys??[],...e.key??[]],n=[...e.excludedKeys??[],...e.excludedKey??[]],r=[...e.dictionaries??[],...e.dictionary??[]];return te({...e,keys:t.length>0?t:void 0,excludedKeys:n.length>0?n:void 0,dictionaries:r.length>0?r:void 0,aiOptions:A(e),gitOptions:M(e),configOptions:P(e)})});let K=[[`--doc-pattern [docPattern...]`,`Documentation pattern`],[`--excluded-glob-pattern [excludedGlobPattern...]`,`Excluded glob pattern`],[`--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]`,`Number of simultaneous file processed`],[`--locales [locales...]`,`Locales`],[`--base-locale [baseLocale]`,`Base locale`],[`--custom-instructions [customInstructions]`,`Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc.`],[`--skip-if-modified-before [skipIfModifiedBefore]`,'Skip the file if it has been modified before the given time. Can be an absolute time as "2025-12-05" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file.'],[`--skip-if-modified-after [skipIfModifiedAfter]`,'Skip the file if it has been modified within the given time. Can be an absolute time as "2025-12-05" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file.'],[`--skip-if-exists`,`Skip the file if it already exists`]],q=m.command(`doc`).description(`Documentation operations`),J=q.command(`translate`).description(`Translate the documentation`);D(J),O(J),k(J),T(J,K),J.action(e=>oe({docPattern:e.docPattern,excludedGlobPattern:e.excludedGlobPattern,locales:e.locales,baseLocale:e.baseLocale,aiOptions:A(e),gitOptions:M(e),nbSimultaneousFileProcessed:e.nbSimultaneousFileProcessed,configOptions:P(e),customInstructions:e.customInstructions,skipIfModifiedBefore:e.skipIfModifiedBefore,skipIfModifiedAfter:e.skipIfModifiedAfter,skipIfExists:e.skipIfExists}));let Y=q.command(`review`).description(`Review the documentation`);D(Y),O(Y),k(Y),T(Y,K),Y.action(e=>ie({docPattern:e.docPattern,excludedGlobPattern:e.excludedGlobPattern,locales:e.locales,baseLocale:e.baseLocale,aiOptions:A(e),gitOptions:M(e),nbSimultaneousFileProcessed:e.nbSimultaneousFileProcessed,configOptions:P(e),customInstructions:e.customInstructions,skipIfModifiedBefore:e.skipIfModifiedBefore,skipIfModifiedAfter:e.skipIfModifiedAfter,skipIfExists:e.skipIfExists}));let X=q.command(`search`).description(`Search the documentation`).argument(`<query>`,`Search query`).option(`--limit [limit]`,`Limit the number of results`,`10`);D(X),X.action((e,t)=>ae({query:e,limit:t.limit?parseInt(t.limit,10):10,configOptions:P(t)}));let ce=[[`--with [with...]`,`Start command in parallel with the live sync`]],Z=m.command(`live`).description(`Live sync - Watch for changes made on the CMS and update the application content accordingly`);T(Z,ce),D(Z),Z.action(e=>n(e));let Q=m.command(`editor`).description(`Visual editor operations`).command(`start`).description(`Start the Intlayer visual editor`);D(Q),Q.action(e=>{a({env:e.env,envFile:e.envFile})});let $=m.command(`extract`).alias(`ext`).description(`Extract strings from components to be placed in a .content file close to the component`);return $.option(`-f, --file [files...]`,`List of files to extract`).option(`-o, --output-content-declarations [outputContentDeclarations]`,`Path to output content declaration files`).option(`--code-only`,`Only extract the component code`,!1).option(`--declaration-only`,`Only generate content declaration`,!1).action(t=>{e({files:t.file,outputContentDeclarations:t.outputContentDeclarations,configOptions:P(t),codeOnly:t.codeOnly,declarationOnly:t.declarationOnly})}),D($),m.parse(process.argv),m.command(`ci`).description(`Run Intlayer commands with auto-injected credentials from INTLAYER_PROJECT_CREDENTIALS. Detects current project or iterates over all projects.`).argument(`<command...>`,`The intlayer command to execute (e.g., "fill", "push")`).allowUnknownOption().action(e=>{l(e)}),m};export{y as dirname,F as setAPI};
|
|
1
|
+
import{t as e}from"./editor-D8BGlLzF.mjs";import{extract as t}from"./extract.mjs";import{listProjectsCommand as n}from"./listProjects.mjs";import{liveSync as r}from"./liveSync.mjs";import{listContentDeclaration as i}from"./listContentDeclaration.mjs";import{init as a}from"./init.mjs";import{watchContentDeclaration as o}from"./watch.mjs";import{login as s}from"./auth/login.mjs";import{build as c}from"./build.mjs";import{runCI as l}from"./ci.mjs";import{getConfig as ee}from"./config.mjs";import{testMissingTranslations as u}from"./test/test.mjs";import{fill as te}from"./fill/fill.mjs";import{initSkills as d}from"./initSkills.mjs";import{initMCP as ne}from"./initMCP.mjs";import{pull as f}from"./pull.mjs";import{push as p}from"./push/push.mjs";import{pushConfig as re}from"./pushConfig.mjs";import"./_utils_asset-B187VPMw.mjs";import{reviewDoc as ie}from"./reviewDoc/reviewDoc.mjs";import{searchDoc as ae}from"./searchDoc.mjs";import{translateDoc as oe}from"./translateDoc/translateDoc.mjs";import{getParentPackageJSON as m}from"./utils/getParentPackageJSON.mjs";import{dirname as h}from"node:path";import{setPrefix as se}from"@intlayer/config/logger";import{getConfiguration as g}from"@intlayer/config/node";import{fileURLToPath as _}from"node:url";import{Command as v}from"commander";const y=typeof import.meta.url==`string`?h(_(import.meta.url)):__dirname,b=m(y),x=[[`--env-file [envFile]`,`Environment file`],[`-e, --env [env]`,`Environment`],[`--base-dir [baseDir]`,`Base directory`],[`--no-cache [noCache]`,`No cache`],...[[`--verbose`,`Verbose (default to true using CLI)`],[`--prefix [prefix]`,`Prefix`]]],S=[[`--provider [provider]`,`Provider`],[`--temperature [temperature]`,`Temperature`],[`--model [model]`,`Model`],[`--api-key [apiKey]`,`Provider API key`],[`--custom-prompt [prompt]`,`Custom prompt`],[`--application-context [applicationContext]`,`Application context`],[`--data-serialization [dataSerialization]`,`Data serialization`]],C=[[`--git-diff [gitDiff]`,`Git diff mode - Check git diff between two refs`],[`--git-diff-base [gitDiffBase]`,`Git diff base ref`],[`--git-diff-current [gitDiffCurrent]`,`Git diff current ref`],[`--uncommitted [uncommitted]`,`Uncommitted`],[`--unpushed [unpushed]`,`Unpushed`],[`--untracked [untracked]`,`Untracked`]],w=(e,t)=>t.filter(t=>e[t]!==void 0),T=(e,t)=>(t.forEach(([t,n])=>{e.option(t,n)}),e),E=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>t!==void 0)),D=e=>T(e,x),O=e=>T(e,S),k=e=>T(e,C),A=e=>{let{apiKey:t,provider:n,model:r,temperature:i,applicationContext:a,customPrompt:o,dataSerialization:s}=e,c=g(),{ai:l}=c;return E({...l,apiKey:t??c.ai?.apiKey,provider:n??c.ai?.provider,model:r??c.ai?.model,temperature:i??c.ai?.temperature,applicationContext:a??c.ai?.applicationContext,customPrompt:o??c.ai?.customPrompt,dataSerialization:s??c.ai?.dataSerialization})},j=[`gitDiff`,`gitDiffBase`,`gitDiffCurrent`,`uncommitted`,`unpushed`,`untracked`],M=e=>{if(w(e,j).length===0)return;let{gitDiff:t,gitDiffBase:n,gitDiffCurrent:r,uncommitted:i,unpushed:a,untracked:o}=e;return E({mode:[t&&`gitDiff`,i&&`uncommitted`,a&&`unpushed`,o&&`untracked`].filter(Boolean),baseRef:n,currentRef:r,absolute:!0})},N=[`baseDir`,`env`,`envFile`,`verbose`,`prefix`,`checkTypes`],P=e=>{if(w(e,N).length===0)return;let{baseDir:t,env:n,envFile:r,verbose:i,noCache:a,checkTypes:o}=e,s=E({mode:i===void 0?void 0:i?`verbose`:`default`}),c=E({checkTypes:o}),l=E({log:Object.keys(s).length>0?s:void 0,build:Object.keys(c).length>0?c:void 0});return E({baseDir:t,env:n,envFile:r,override:Object.keys(l).length>0?l:void 0,cache:a===void 0?void 0:!a})},F=()=>{process.argv.includes(`--with`)||se(``);let m=new v;m.version(b.version).description(`Intlayer CLI`),m.command(`version`).description(`Print the Intlayer CLI version`).action(()=>{console.log(b.version??`unknown`)});let h=m.command(`login`).description(`Login to Intlayer`).option(`--cms-url [cmsUrl]`,`CMS URL`);D(h),h.action(e=>{let t=P(e)??{override:{log:{prefix:``,mode:`verbose`}}};return s({cmsUrl:e.cmsUrl,configOptions:t})});let g=m.command(`init`).description(`Initialize Intlayer in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>a(e.projectRoot));g.command(`skills`).description(`Initialize Intlayer skills in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>d(e.projectRoot)),g.command(`mcp`).description(`Initialize Intlayer MCP server in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>ne(e.projectRoot));let _=m.command(`dictionary`).alias(`dictionaries`).alias(`dic`).description(`Dictionaries operations`),y={description:`Build the dictionaries`,options:[[`-w, --watch`,`Watch for changes`],[`--skip-prepare`,`Skip the prepare step`],[`--with [with...]`,`Start command in parallel with the build`],[`--check-types`,`Check TypeScript type and log errors`]]},x=_.command(`build`).description(y.description);T(x,y.options),D(x),x.action(e=>{c({...e,configOptions:P(e)})});let S=m.command(`build`).description(y.description);T(S,y.options),D(S),S.action(e=>{c({...e,configOptions:P(e)})});let C={description:`Watch the dictionaries changes`,options:[[`--with [with...]`,`Start command in parallel with the build`]]},w=_.command(`watch`).description(y.description);T(w,C.options),D(w),w.action(e=>{o({...e,configOptions:P(e)})});let E=m.command(`watch`).description(y.description);T(E,C.options),D(E),E.action(e=>{o({...e,configOptions:P(e)})});let j={description:`Pull dictionaries from the server`,options:[[`-d, --dictionaries [ids...]`,`List of dictionary IDs to pull`],[`--dictionary [ids...]`,`List of dictionary IDs to pull (alias for --dictionaries)`],[`--new-dictionaries-path [path]`,`Path to save the new dictionaries`],[`--newDictionariesPath [path]`,`[alias] Path to save the new dictionaries`]]},N=_.command(`pull`).description(j.description);T(N,j.options),D(N),N.action(e=>{let t=[...e.dictionaries??[],...e.dictionary??[]];f({...e,dictionaries:t.length>0?t:void 0,configOptions:{...e.configOptions,baseDir:e.baseDir}})});let F=m.command(`pull`).description(j.description);T(F,j.options),D(F),F.action(e=>{let t=[...e.dictionaries??[],...e.dictionary??[]];f({...e,dictionaries:t.length>0?t:void 0,configOptions:P(e)})});let I={description:`Push all dictionaries. Create or update the pushed dictionaries`,options:[[`-d, --dictionaries [ids...]`,`List of dictionary IDs to push`],[`--dictionary [ids...]`,`List of dictionary IDs to push (alias for --dictionaries)`],[`-r, --delete-locale-dictionary`,`Delete the local dictionaries after pushing`],[`-k, --keep-locale-dictionary`,`Keep the local dictionaries after pushing`],[`--deleteLocaleDictionary`,`[alias] Delete the local dictionaries after pushing`],[`--keepLocaleDictionary`,`[alias] Keep the local dictionaries after pushing`],[`--build [build]`,`Build the dictionaries before pushing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build`]]},L=_.command(`push`).description(I.description);T(L,I.options),D(L),k(L),L.action(e=>{let t=[...e.dictionaries||[],...e.dictionary||[]];return p({...e,dictionaries:t.length>0?t:void 0,gitOptions:M(e),configOptions:P(e)})});let R=m.command(`push`).description(I.description);T(R,I.options),D(R),k(R),R.action(e=>{let t=[...e.dictionaries||[],...e.dictionary||[]];return p({...e,dictionaries:t.length>0?t:void 0,gitOptions:M(e),configOptions:P(e)})});let z=m.command(`configuration`).alias(`config`).alias(`conf`).description(`Configuration operations`),B=z.command(`get`).description(`Get the configuration`);D(B),B.action(e=>{ee({...e,configOptions:P(e)})});let V=z.command(`push`).description(`Push the configuration`);D(V),V.action(e=>{re({...e,configOptions:P(e)})}),m.command(`projects`).alias(`project`).description(`List Intlayer projects`).command(`list`).description(`List all Intlayer projects in the directory`).option(`--base-dir [baseDir]`,`Base directory to search from`).option(`--git-root`,`Search from the git root directory instead of the base directory`).option(`--json`,`Output the results as JSON`).action(e=>{n({baseDir:e.baseDir,gitRoot:e.gitRoot,json:e.json})}),m.command(`projects-list`).alias(`pl`).description(`List all Intlayer projects in the directory`).option(`--base-dir [baseDir]`,`Base directory to search from`).option(`--git-root`,`Search from the git root directory instead of the base directory`).option(`--absolute`,`Output the results as absolute paths`).option(`--json`,`Output the results as JSON`).action(e=>{n({baseDir:e.baseDir,gitRoot:e.gitRoot,json:e.json,absolute:e.absolute})});let H=m.command(`content`).description(`Content declaration operations`);H.command(`list`).description(`List the content declaration files`).option(`--json`,`Output the results as JSON`).option(`--absolute`,`Output the results as absolute paths`).action(e=>{i({json:e.json,absolute:e.absolute})}),m.command(`list`).description(`List the content declaration files`).option(`--json`,`Output the results as JSON`).option(`--absolute`,`Output the results as absolute paths`).action(e=>{i({json:e.json,absolute:e.absolute})});let U=H.command(`test`).description(`Test if there are missing translations`).option(`--build [build]`,`Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build`);D(U),U.action(e=>{u({...e,configOptions:P(e)})});let W=m.command(`test`).description(`Test if there are missing translations`).option(`--build [build]`,`Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build`);D(W),W.action(e=>{u({...e,configOptions:P(e)})});let G=m.command(`fill`).description(`Fill the dictionaries`).option(`-f, --file [files...]`,`List of Dictionary files to fill`).option(`--source-locale [sourceLocale]`,`Source locale to translate from`).option(`--output-locales [outputLocales...]`,`Target locales to translate to`).option(`--mode [mode]`,`Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys`,`complete`).option(`-k, --keys [keys...]`,`Filter dictionaries based on keys`).option(`--key [keys...]`,`Filter dictionaries based on keys (alias for --keys)`).option(`--excluded-keys [excludedKeys...]`,`Filter out dictionaries based on keys`).option(`--excluded-key [excludedKeys...]`,`Filter out dictionaries based on keys (alias for --excluded-keys)`).option(`--path-filter [pathFilters...]`,`Filter dictionaries based on glob pattern`).option(`--build [build]`,`Build the dictionaries before filling to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build`).option(`--skip-metadata`,`Skip filling missing metadata (description, title, tags) for dictionaries`);D(G),O(G),k(G),G.action(e=>{let t=[...e.keys??[],...e.key??[]],n=[...e.excludedKeys??[],...e.excludedKey??[]],r=[...e.dictionaries??[],...e.dictionary??[]];return te({...e,keys:t.length>0?t:void 0,excludedKeys:n.length>0?n:void 0,dictionaries:r.length>0?r:void 0,aiOptions:A(e),gitOptions:M(e),configOptions:P(e)})});let K=[[`--doc-pattern [docPattern...]`,`Documentation pattern`],[`--excluded-glob-pattern [excludedGlobPattern...]`,`Excluded glob pattern`],[`--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]`,`Number of simultaneous file processed`],[`--locales [locales...]`,`Locales`],[`--base-locale [baseLocale]`,`Base locale`],[`--custom-instructions [customInstructions]`,`Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc.`],[`--skip-if-modified-before [skipIfModifiedBefore]`,'Skip the file if it has been modified before the given time. Can be an absolute time as "2025-12-05" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file.'],[`--skip-if-modified-after [skipIfModifiedAfter]`,'Skip the file if it has been modified within the given time. Can be an absolute time as "2025-12-05" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file.'],[`--skip-if-exists`,`Skip the file if it already exists`]],q=m.command(`doc`).description(`Documentation operations`),J=q.command(`translate`).description(`Translate the documentation`);D(J),O(J),k(J),T(J,K),J.action(e=>oe({docPattern:e.docPattern,excludedGlobPattern:e.excludedGlobPattern,locales:e.locales,baseLocale:e.baseLocale,aiOptions:A(e),gitOptions:M(e),nbSimultaneousFileProcessed:e.nbSimultaneousFileProcessed,configOptions:P(e),customInstructions:e.customInstructions,skipIfModifiedBefore:e.skipIfModifiedBefore,skipIfModifiedAfter:e.skipIfModifiedAfter,skipIfExists:e.skipIfExists}));let Y=q.command(`review`).description(`Review the documentation`);D(Y),O(Y),k(Y),T(Y,K),Y.action(e=>ie({docPattern:e.docPattern,excludedGlobPattern:e.excludedGlobPattern,locales:e.locales,baseLocale:e.baseLocale,aiOptions:A(e),gitOptions:M(e),nbSimultaneousFileProcessed:e.nbSimultaneousFileProcessed,configOptions:P(e),customInstructions:e.customInstructions,skipIfModifiedBefore:e.skipIfModifiedBefore,skipIfModifiedAfter:e.skipIfModifiedAfter,skipIfExists:e.skipIfExists}));let X=q.command(`search`).description(`Search the documentation`).argument(`<query>`,`Search query`).option(`--limit [limit]`,`Limit the number of results`,`10`);D(X),X.action((e,t)=>ae({query:e,limit:t.limit?parseInt(t.limit,10):10,configOptions:P(t)}));let ce=[[`--with [with...]`,`Start command in parallel with the live sync`]],Z=m.command(`live`).description(`Live sync - Watch for changes made on the CMS and update the application content accordingly`);T(Z,ce),D(Z),Z.action(e=>r(e));let Q=m.command(`editor`).description(`Visual editor operations`).command(`start`).description(`Start the Intlayer visual editor`);D(Q),Q.action(t=>{e({env:t.env,envFile:t.envFile})});let $=m.command(`extract`).alias(`ext`).description(`Extract strings from components to be placed in a .content file close to the component`);return $.option(`-f, --file [files...]`,`List of files to extract`).option(`-o, --output-content-declarations [outputContentDeclarations]`,`Path to output content declaration files`).option(`--code-only`,`Only extract the component code`,!1).option(`--declaration-only`,`Only generate content declaration`,!1).action(e=>{t({files:e.file,outputContentDeclarations:e.outputContentDeclarations,configOptions:P(e),codeOnly:e.codeOnly,declarationOnly:e.declarationOnly})}),D($),m.parse(process.argv),m.command(`ci`).description(`Run Intlayer commands with auto-injected credentials from INTLAYER_PROJECT_CREDENTIALS. Detects current project or iterates over all projects.`).argument(`<command...>`,`The intlayer command to execute (e.g., "fill", "push")`).allowUnknownOption().action(e=>{l(e)}),m};export{y as dirname,F as setAPI};
|
|
2
2
|
//# sourceMappingURL=cli.mjs.map
|
package/dist/esm/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":["pathDirname"],"sources":["../../src/cli.ts"],"sourcesContent":["import { dirname as pathDirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { AIOptions as BaseAIOptions } from '@intlayer/api';\nimport type { DiffMode, ListGitFilesOptions } from '@intlayer/chokidar/cli';\nimport { setPrefix } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { CustomIntlayerConfig } from '@intlayer/types/config';\nimport { Command } from 'commander';\nimport { login } from './auth/login';\nimport { build } from './build';\nimport { runCI } from './ci';\nimport { getConfig } from './config';\nimport { startEditor } from './editor';\nimport { extract } from './extract';\nimport { type FillOptions, fill } from './fill/fill';\nimport { init } from './init';\nimport { initMCP } from './initMCP';\nimport { initSkills } from './initSkills';\nimport { listContentDeclaration } from './listContentDeclaration';\nimport { listProjectsCommand } from './listProjects';\nimport { liveSync } from './liveSync';\nimport { pull } from './pull';\nimport { push } from './push/push';\nimport { pushConfig } from './pushConfig';\nimport { reviewDoc } from './reviewDoc/reviewDoc';\nimport { searchDoc } from './searchDoc';\nimport { testMissingTranslations } from './test';\nimport { translateDoc } from './translateDoc/translateDoc';\nimport { getParentPackageJSON } from './utils/getParentPackageJSON';\nimport { watchContentDeclaration } from './watch';\n\n// Extended AI options to include customPrompt\ntype AIOptions = BaseAIOptions & {\n customPrompt?: string;\n};\n\nconst isESModule = typeof import.meta.url === 'string';\n\nexport const dirname = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson = getParentPackageJSON(dirname);\n\nconst logOptions = [\n ['--verbose', 'Verbose (default to true using CLI)'],\n ['--prefix [prefix]', 'Prefix'],\n];\n\nconst configurationOptions = [\n ['--env-file [envFile]', 'Environment file'],\n ['-e, --env [env]', 'Environment'],\n ['--base-dir [baseDir]', 'Base directory'],\n ['--no-cache [noCache]', 'No cache'],\n ...logOptions,\n];\n\nconst aiOptions = [\n ['--provider [provider]', 'Provider'],\n ['--temperature [temperature]', 'Temperature'],\n ['--model [model]', 'Model'],\n ['--api-key [apiKey]', 'Provider API key'],\n ['--custom-prompt [prompt]', 'Custom prompt'],\n ['--application-context [applicationContext]', 'Application context'],\n ['--data-serialization [dataSerialization]', 'Data serialization'],\n];\n\nconst gitOptions = [\n ['--git-diff [gitDiff]', 'Git diff mode - Check git diff between two refs'],\n ['--git-diff-base [gitDiffBase]', 'Git diff base ref'],\n ['--git-diff-current [gitDiffCurrent]', 'Git diff current ref'],\n ['--uncommitted [uncommitted]', 'Uncommitted'],\n ['--unpushed [unpushed]', 'Unpushed'],\n ['--untracked [untracked]', 'Untracked'],\n];\n\nconst extractKeysFromOptions = (options: object, keys: string[]) =>\n keys.filter((key) => options[key as keyof typeof options] !== undefined);\n\n/**\n * Helper functions to apply common options to commands\n */\nconst applyOptions = (command: Command, options: string[][]) => {\n options.forEach(([flag, description]) => {\n command.option(flag, description);\n });\n return command;\n};\n\nconst removeUndefined = <T extends Record<string, any>>(obj: T): T =>\n Object.fromEntries(\n Object.entries(obj).filter(([_, value]) => value !== undefined)\n ) as T;\n\nconst applyConfigOptions = (command: Command) =>\n applyOptions(command, configurationOptions);\nconst applyAIOptions = (command: Command) => applyOptions(command, aiOptions);\nconst applyGitOptions = (command: Command) => applyOptions(command, gitOptions);\n\nconst extractAiOptions = (options: AIOptions): AIOptions | undefined => {\n const {\n apiKey,\n provider,\n model,\n temperature,\n applicationContext,\n customPrompt,\n dataSerialization,\n } = options;\n\n const configuration = getConfiguration();\n\n const { ai } = configuration;\n\n return removeUndefined({\n ...ai,\n apiKey: apiKey ?? configuration.ai?.apiKey,\n provider: provider ?? (configuration.ai?.provider as AIOptions['provider']),\n model: model ?? configuration.ai?.model,\n temperature: temperature ?? configuration.ai?.temperature,\n applicationContext:\n applicationContext ?? configuration.ai?.applicationContext,\n customPrompt: customPrompt ?? (configuration.ai as any)?.customPrompt,\n dataSerialization: dataSerialization ?? configuration.ai?.dataSerialization,\n });\n};\n\ntype GitOptions = {\n gitDiff?: boolean;\n gitDiffBase?: string;\n gitDiffCurrent?: string;\n uncommitted?: boolean;\n unpushed?: boolean;\n untracked?: boolean;\n};\n\nconst gitOptionKeys: (keyof GitOptions)[] = [\n 'gitDiff',\n 'gitDiffBase',\n 'gitDiffCurrent',\n 'uncommitted',\n 'unpushed',\n 'untracked',\n];\n\nconst extractGitOptions = (\n options: GitOptions\n): ListGitFilesOptions | undefined => {\n const filteredOptions = extractKeysFromOptions(options, gitOptionKeys);\n\n const isOptionEmpty = filteredOptions.length === 0;\n\n if (isOptionEmpty) return undefined;\n\n const {\n gitDiff,\n gitDiffBase,\n gitDiffCurrent,\n uncommitted,\n unpushed,\n untracked,\n } = options;\n\n const mode = [\n gitDiff && 'gitDiff',\n uncommitted && 'uncommitted',\n unpushed && 'unpushed',\n untracked && 'untracked',\n ].filter(Boolean) as DiffMode[];\n\n return removeUndefined({\n mode,\n baseRef: gitDiffBase,\n currentRef: gitDiffCurrent,\n absolute: true,\n });\n};\n\ntype LogOptions = {\n prefix?: string;\n verbose?: boolean;\n};\n\nexport type ConfigurationOptions = {\n baseDir?: string;\n env?: string;\n envFile?: string;\n noCache?: boolean;\n checkTypes?: boolean;\n} & LogOptions;\n\nconst configurationOptionKeys: (keyof ConfigurationOptions)[] = [\n 'baseDir',\n 'env',\n 'envFile',\n 'verbose',\n 'prefix',\n 'checkTypes',\n];\n\nconst extractConfigOptions = (\n options: ConfigurationOptions & { with?: string }\n): GetConfigurationOptions | undefined => {\n const filteredOptions = extractKeysFromOptions(\n options,\n configurationOptionKeys\n );\n\n const isOptionEmpty = filteredOptions.length === 0;\n\n if (isOptionEmpty) {\n return undefined;\n }\n\n const { baseDir, env, envFile, verbose, noCache, checkTypes } = options;\n\n const log = removeUndefined({\n mode:\n typeof verbose !== 'undefined'\n ? verbose\n ? 'verbose'\n : 'default'\n : undefined,\n });\n\n const build = removeUndefined({\n checkTypes,\n });\n\n const override: CustomIntlayerConfig = removeUndefined({\n log:\n Object.keys(log).length > 0\n ? (log as CustomIntlayerConfig['log'])\n : undefined,\n build: Object.keys(build).length > 0 ? build : undefined,\n });\n\n return removeUndefined({\n baseDir,\n env,\n envFile,\n override: Object.keys(override).length > 0 ? override : undefined,\n cache: typeof noCache !== 'undefined' ? !noCache : undefined,\n });\n};\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 isWithCommand = process.argv.includes('--with');\n\n if (!isWithCommand) {\n setPrefix('');\n }\n\n const program = new Command();\n\n program.version(packageJson.version!).description('Intlayer CLI');\n\n // Explicit version subcommand for convenience: `npx intlayer version`\n program\n .command('version')\n .description('Print the Intlayer CLI version')\n .action(() => {\n // Prefer the resolved package.json version; fallback to unknown\n // Keeping output minimal to align with common CLI behavior\n console.log(packageJson.version ?? 'unknown');\n });\n\n /**\n * AUTH\n */\n const loginCmd = program\n .command('login')\n .description('Login to Intlayer')\n .option('--cms-url [cmsUrl]', 'CMS URL');\n\n applyConfigOptions(loginCmd);\n\n loginCmd.action((options) => {\n const configOptions = extractConfigOptions(options) ?? {\n override: {\n log: {\n prefix: '',\n mode: 'verbose',\n },\n },\n };\n\n return login({\n cmsUrl: options.cmsUrl,\n configOptions,\n });\n });\n\n /**\n * INIT\n */\n const initCmd = program\n .command('init')\n .description('Initialize Intlayer in the project')\n .option('--project-root [projectRoot]', 'Project root directory')\n .action((options) => init(options.projectRoot));\n\n initCmd\n .command('skills')\n .description('Initialize Intlayer skills in the project')\n .option('--project-root [projectRoot]', 'Project root directory')\n .action((options) => initSkills(options.projectRoot));\n\n initCmd\n .command('mcp')\n .description('Initialize Intlayer MCP server in the project')\n .option('--project-root [projectRoot]', 'Project root directory')\n .action((options) => initMCP(options.projectRoot));\n\n /**\n * DICTIONARIES\n */\n\n const dictionariesProgram = program\n .command('dictionary')\n .alias('dictionaries')\n .alias('dic')\n .description('Dictionaries operations');\n\n // Dictionary build command\n const buildOptions = {\n description: 'Build the dictionaries',\n options: [\n ['-w, --watch', 'Watch for changes'],\n ['--skip-prepare', 'Skip the prepare step'],\n ['--with [with...]', 'Start command in parallel with the build'],\n ['--check-types', 'Check TypeScript type and log errors'],\n ],\n };\n\n // Add build command to dictionaries program\n const dictionariesBuildCmd = dictionariesProgram\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(dictionariesBuildCmd, buildOptions.options);\n applyConfigOptions(dictionariesBuildCmd);\n dictionariesBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add build command to root program as well\n const rootBuildCmd = program\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(rootBuildCmd, buildOptions.options);\n applyConfigOptions(rootBuildCmd);\n rootBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n const watchOptions = {\n description: 'Watch the dictionaries changes',\n options: [['--with [with...]', 'Start command in parallel with the build']],\n };\n\n // Add build command to dictionaries program\n const dictionariesWatchCmd = dictionariesProgram\n .command('watch')\n .description(buildOptions.description);\n\n applyOptions(dictionariesWatchCmd, watchOptions.options);\n applyConfigOptions(dictionariesWatchCmd);\n dictionariesWatchCmd.action((options) => {\n watchContentDeclaration({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add build command to root program as well\n const rootWatchCmd = program\n .command('watch')\n .description(buildOptions.description);\n\n applyOptions(rootWatchCmd, watchOptions.options);\n applyConfigOptions(rootWatchCmd);\n rootWatchCmd.action((options) => {\n watchContentDeclaration({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary pull command\n const pullOptions = {\n description: 'Pull dictionaries from the server',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to pull'],\n [\n '--dictionary [ids...]',\n 'List of dictionary IDs to pull (alias for --dictionaries)',\n ],\n ['--new-dictionaries-path [path]', 'Path to save the new dictionaries'],\n // Backward-compatibility for older tests/flags (camelCase)\n [\n '--newDictionariesPath [path]',\n '[alias] Path to save the new dictionaries',\n ],\n ],\n };\n\n // Add pull command to dictionaries program\n const dictionariesPullCmd = dictionariesProgram\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(dictionariesPullCmd, pullOptions.options);\n applyConfigOptions(dictionariesPullCmd);\n dictionariesPullCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries ?? []),\n ...(options.dictionary ?? []),\n ];\n\n pull({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n configOptions: {\n ...options.configOptions,\n baseDir: options.baseDir,\n },\n });\n });\n\n // Add pull command to root program as well\n const rootPullCmd = program\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(rootPullCmd, pullOptions.options);\n applyConfigOptions(rootPullCmd);\n rootPullCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries ?? []),\n ...(options.dictionary ?? []),\n ];\n\n pull({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary push command\n const pushOptions = {\n description:\n 'Push all dictionaries. Create or update the pushed dictionaries',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to push'],\n [\n '--dictionary [ids...]',\n 'List of dictionary IDs to push (alias for --dictionaries)',\n ],\n [\n '-r, --delete-locale-dictionary',\n 'Delete the local dictionaries after pushing',\n ],\n [\n '-k, --keep-locale-dictionary',\n 'Keep the local dictionaries after pushing',\n ],\n // Backward-compatibility for older tests/flags (camelCase)\n [\n '--deleteLocaleDictionary',\n '[alias] Delete the local dictionaries after pushing',\n ],\n [\n '--keepLocaleDictionary',\n '[alias] Keep the local dictionaries after pushing',\n ],\n [\n '--build [build]',\n 'Build the dictionaries before pushing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build',\n ],\n ],\n };\n\n // Add push command to dictionaries program\n const dictionariesPushCmd = dictionariesProgram\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(dictionariesPushCmd, pushOptions.options);\n applyConfigOptions(dictionariesPushCmd);\n applyGitOptions(dictionariesPushCmd);\n\n dictionariesPushCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries || []),\n ...(options.dictionary || []),\n ];\n\n return push({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions);\n });\n\n // Add push command to root program as well\n const rootPushCmd = program\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(rootPushCmd, pushOptions.options);\n applyConfigOptions(rootPushCmd);\n applyGitOptions(rootPushCmd);\n\n rootPushCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries || []),\n ...(options.dictionary || []),\n ];\n\n return push({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions);\n });\n\n /**\n * CONFIGURATION\n */\n\n // Define the parent command\n const configurationProgram = program\n .command('configuration')\n .alias('config')\n .alias('conf')\n .description('Configuration operations');\n\n const configGetCmd = configurationProgram\n .command('get')\n .description('Get the configuration');\n\n applyConfigOptions(configGetCmd);\n configGetCmd.action((options) => {\n getConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Define the `push config` subcommand and add it to the `push` command\n const configPushCmd = configurationProgram\n .command('push')\n .description('Push the configuration');\n\n applyConfigOptions(configPushCmd);\n configPushCmd.action((options) => {\n pushConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n /**\n * PROJECTS\n */\n\n const projectsProgram = program\n .command('projects')\n .alias('project')\n .description('List Intlayer projects');\n\n const projectsListCmd = projectsProgram\n .command('list')\n .description('List all Intlayer projects in the directory')\n .option('--base-dir [baseDir]', 'Base directory to search from')\n .option(\n '--git-root',\n 'Search from the git root directory instead of the base directory'\n )\n .option('--json', 'Output the results as JSON');\n\n projectsListCmd.action((options) => {\n listProjectsCommand({\n baseDir: options.baseDir,\n gitRoot: options.gitRoot,\n json: options.json,\n });\n });\n\n // Add alias for projects list command at root level\n const rootProjectsListCmd = program\n .command('projects-list')\n .alias('pl')\n .description('List all Intlayer projects in the directory')\n .option('--base-dir [baseDir]', 'Base directory to search from')\n .option(\n '--git-root',\n 'Search from the git root directory instead of the base directory'\n )\n .option('--absolute', 'Output the results as absolute paths')\n .option('--json', 'Output the results as JSON');\n\n rootProjectsListCmd.action((options) => {\n listProjectsCommand({\n baseDir: options.baseDir,\n gitRoot: options.gitRoot,\n json: options.json,\n absolute: options.absolute,\n });\n });\n\n /**\n * CONTENT DECLARATION\n */\n\n const contentProgram = program\n .command('content')\n .description('Content declaration operations');\n\n contentProgram\n .command('list')\n .description('List the content declaration files')\n .option('--json', 'Output the results as JSON')\n .option('--absolute', 'Output the results as absolute paths')\n .action((options) => {\n listContentDeclaration({\n json: options.json,\n absolute: options.absolute,\n });\n });\n\n // Add alias for content list command\n program\n .command('list')\n .description('List the content declaration files')\n .option('--json', 'Output the results as JSON')\n .option('--absolute', 'Output the results as absolute paths')\n .action((options) => {\n listContentDeclaration({\n json: options.json,\n absolute: options.absolute,\n });\n });\n\n const testProgram = contentProgram\n .command('test')\n .description('Test if there are missing translations')\n .option(\n '--build [build]',\n 'Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build'\n );\n\n applyConfigOptions(testProgram);\n testProgram.action((options) => {\n testMissingTranslations({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add alias for content test command\n const rootTestCmd = program\n .command('test')\n .description('Test if there are missing translations')\n .option(\n '--build [build]',\n 'Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build'\n );\n\n applyConfigOptions(rootTestCmd);\n rootTestCmd.action((options) => {\n testMissingTranslations({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n const fillProgram = program\n .command('fill')\n .description('Fill the dictionaries')\n .option('-f, --file [files...]', 'List of Dictionary files to fill')\n .option('--source-locale [sourceLocale]', 'Source locale to translate from')\n .option(\n '--output-locales [outputLocales...]',\n 'Target locales to translate to'\n )\n .option(\n '--mode [mode]',\n 'Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys',\n 'complete'\n )\n .option('-k, --keys [keys...]', 'Filter dictionaries based on keys')\n .option(\n '--key [keys...]',\n 'Filter dictionaries based on keys (alias for --keys)'\n )\n .option(\n '--excluded-keys [excludedKeys...]',\n 'Filter out dictionaries based on keys'\n )\n .option(\n '--excluded-key [excludedKeys...]',\n 'Filter out dictionaries based on keys (alias for --excluded-keys)'\n )\n .option(\n '--path-filter [pathFilters...]',\n 'Filter dictionaries based on glob pattern'\n )\n .option(\n '--build [build]',\n 'Build the dictionaries before filling to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build'\n )\n .option(\n '--skip-metadata',\n 'Skip filling missing metadata (description, title, tags) for dictionaries'\n );\n\n applyConfigOptions(fillProgram);\n applyAIOptions(fillProgram);\n applyGitOptions(fillProgram);\n\n fillProgram.action((options) => {\n // Merge key aliases\n const keys = [...(options.keys ?? []), ...(options.key ?? [])];\n const excludedKeys = [\n ...(options.excludedKeys ?? []),\n ...(options.excludedKey ?? []),\n ];\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries ?? []),\n ...(options.dictionary ?? []),\n ];\n\n return fill({\n ...options,\n keys: keys.length > 0 ? keys : undefined,\n excludedKeys: excludedKeys.length > 0 ? excludedKeys : undefined,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions);\n });\n\n /**\n * DOCS\n */\n\n const docParams = [\n ['--doc-pattern [docPattern...]', 'Documentation pattern'],\n [\n '--excluded-glob-pattern [excludedGlobPattern...]',\n 'Excluded glob pattern',\n ],\n [\n '--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]',\n 'Number of simultaneous file processed',\n ],\n ['--locales [locales...]', 'Locales'],\n ['--base-locale [baseLocale]', 'Base locale'],\n [\n '--custom-instructions [customInstructions]',\n 'Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc.',\n ],\n [\n '--skip-if-modified-before [skipIfModifiedBefore]',\n 'Skip the file if it has been modified before the given time. Can be an absolute time as \"2025-12-05\" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file.',\n ],\n [\n '--skip-if-modified-after [skipIfModifiedAfter]',\n 'Skip the file if it has been modified within the given time. Can be an absolute time as \"2025-12-05\" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file.',\n ],\n ['--skip-if-exists', 'Skip the file if it already exists'],\n ];\n\n const docProgram = program\n .command('doc')\n .description('Documentation operations');\n\n const translateProgram = docProgram\n .command('translate')\n .description('Translate the documentation');\n\n applyConfigOptions(translateProgram);\n applyAIOptions(translateProgram);\n applyGitOptions(translateProgram);\n applyOptions(translateProgram, docParams);\n\n translateProgram.action((options) =>\n translateDoc({\n docPattern: options.docPattern,\n excludedGlobPattern: options.excludedGlobPattern,\n locales: options.locales,\n baseLocale: options.baseLocale,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,\n configOptions: extractConfigOptions(options),\n customInstructions: options.customInstructions,\n skipIfModifiedBefore: options.skipIfModifiedBefore,\n skipIfModifiedAfter: options.skipIfModifiedAfter,\n skipIfExists: options.skipIfExists,\n })\n );\n\n const reviewProgram = docProgram\n .command('review')\n .description('Review the documentation');\n\n applyConfigOptions(reviewProgram);\n applyAIOptions(reviewProgram);\n applyGitOptions(reviewProgram);\n applyOptions(reviewProgram, docParams);\n\n reviewProgram.action((options) =>\n reviewDoc({\n docPattern: options.docPattern,\n excludedGlobPattern: options.excludedGlobPattern,\n locales: options.locales,\n baseLocale: options.baseLocale,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,\n configOptions: extractConfigOptions(options),\n customInstructions: options.customInstructions,\n skipIfModifiedBefore: options.skipIfModifiedBefore,\n skipIfModifiedAfter: options.skipIfModifiedAfter,\n skipIfExists: options.skipIfExists,\n })\n );\n\n const searchProgram = docProgram\n .command('search')\n .description('Search the documentation')\n .argument('<query>', 'Search query')\n .option('--limit [limit]', 'Limit the number of results', '10');\n\n applyConfigOptions(searchProgram);\n\n searchProgram.action((query, options) =>\n searchDoc({\n query,\n limit: options.limit ? parseInt(options.limit, 10) : 10,\n configOptions: extractConfigOptions(options),\n })\n );\n\n /**\n * LIVE SYNC\n */\n\n const liveOptions = [\n ['--with [with...]', 'Start command in parallel with the live sync'],\n ];\n\n const liveCmd = program\n .command('live')\n .description(\n 'Live sync - Watch for changes made on the CMS and update the application content accordingly'\n );\n\n applyOptions(liveCmd, liveOptions);\n applyConfigOptions(liveCmd);\n\n liveCmd.action((options) => liveSync(options));\n\n /**\n * EDITOR\n */\n\n const editorProgram = program\n .command('editor')\n .description('Visual editor operations');\n\n const editorStartCmd = editorProgram\n .command('start')\n .description('Start the Intlayer visual editor');\n\n applyConfigOptions(editorStartCmd);\n\n editorStartCmd.action((options) => {\n startEditor({\n env: options.env,\n envFile: options.envFile,\n });\n });\n\n /**\n * EXTRACT\n */\n const extractProgram = program\n .command('extract')\n .alias('ext')\n .description(\n 'Extract strings from components to be placed in a .content file close to the component'\n );\n\n extractProgram\n .option('-f, --file [files...]', 'List of files to extract')\n .option(\n '-o, --output-content-declarations [outputContentDeclarations]',\n 'Path to output content declaration files'\n )\n .option('--code-only', 'Only extract the component code', false)\n .option('--declaration-only', 'Only generate content declaration', false)\n .action((options) => {\n extract({\n files: options.file,\n outputContentDeclarations: options.outputContentDeclarations,\n configOptions: extractConfigOptions(options),\n codeOnly: options.codeOnly,\n declarationOnly: options.declarationOnly,\n });\n });\n\n applyConfigOptions(extractProgram);\n\n program.parse(process.argv);\n\n /**\n * CI / AUTOMATION\n *\n * Used to iterate over all projects in a monorepo, and help to parse secrets\n */\n program\n .command('ci')\n .description(\n 'Run Intlayer commands with auto-injected credentials from INTLAYER_PROJECT_CREDENTIALS. Detects current project or iterates over all projects.'\n )\n .argument(\n '<command...>',\n 'The intlayer command to execute (e.g., \"fill\", \"push\")'\n )\n .allowUnknownOption() // Allows passing flags like --verbose to the subcommand\n .action((args) => {\n runCI(args);\n });\n\n return program;\n};\n"],"mappings":"wuCAyCA,MAAa,EAFM,OAAO,OAAO,KAAK,KAAQ,SAG1CA,EAAY,EAAc,OAAO,KAAK,IAAI,CAAC,CAC3C,UAEE,EAAc,EAAqB,EAAQ,CAO3C,EAAuB,CAC3B,CAAC,uBAAwB,mBAAmB,CAC5C,CAAC,kBAAmB,cAAc,CAClC,CAAC,uBAAwB,iBAAiB,CAC1C,CAAC,uBAAwB,WAAW,CACpC,GAViB,CACjB,CAAC,YAAa,sCAAsC,CACpD,CAAC,oBAAqB,SAAS,CAChC,CAQA,CAEK,EAAY,CAChB,CAAC,wBAAyB,WAAW,CACrC,CAAC,8BAA+B,cAAc,CAC9C,CAAC,kBAAmB,QAAQ,CAC5B,CAAC,qBAAsB,mBAAmB,CAC1C,CAAC,2BAA4B,gBAAgB,CAC7C,CAAC,6CAA8C,sBAAsB,CACrE,CAAC,2CAA4C,qBAAqB,CACnE,CAEK,EAAa,CACjB,CAAC,uBAAwB,kDAAkD,CAC3E,CAAC,gCAAiC,oBAAoB,CACtD,CAAC,sCAAuC,uBAAuB,CAC/D,CAAC,8BAA+B,cAAc,CAC9C,CAAC,wBAAyB,WAAW,CACrC,CAAC,0BAA2B,YAAY,CACzC,CAEK,GAA0B,EAAiB,IAC/C,EAAK,OAAQ,GAAQ,EAAQ,KAAiC,IAAA,GAAU,CAKpE,GAAgB,EAAkB,KACtC,EAAQ,SAAS,CAAC,EAAM,KAAiB,CACvC,EAAQ,OAAO,EAAM,EAAY,EACjC,CACK,GAGH,EAAkD,GACtD,OAAO,YACL,OAAO,QAAQ,EAAI,CAAC,QAAQ,CAAC,EAAG,KAAW,IAAU,IAAA,GAAU,CAChE,CAEG,EAAsB,GAC1B,EAAa,EAAS,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,CAElD,EAAmB,EAAe,CAElC,EAAe,OAAQ,GAAY,CACjC,EAAY,CACV,IAAK,EAAQ,IACb,QAAS,EAAQ,QAClB,CAAC,EACF,CAKF,IAAM,EAAiB,EACpB,QAAQ,UAAU,CAClB,MAAM,MAAM,CACZ,YACC,yFACD,CA2CH,OAzCA,EACG,OAAO,wBAAyB,2BAA2B,CAC3D,OACC,gEACA,2CACD,CACA,OAAO,cAAe,kCAAmC,GAAM,CAC/D,OAAO,qBAAsB,oCAAqC,GAAM,CACxE,OAAQ,GAAY,CACnB,EAAQ,CACN,MAAO,EAAQ,KACf,0BAA2B,EAAQ,0BACnC,cAAe,EAAqB,EAAQ,CAC5C,SAAU,EAAQ,SAClB,gBAAiB,EAAQ,gBAC1B,CAAC,EACF,CAEJ,EAAmB,EAAe,CAElC,EAAQ,MAAM,QAAQ,KAAK,CAO3B,EACG,QAAQ,KAAK,CACb,YACC,iJACD,CACA,SACC,eACA,yDACD,CACA,oBAAoB,CACpB,OAAQ,GAAS,CAChB,EAAM,EAAK,EACX,CAEG"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":["pathDirname"],"sources":["../../src/cli.ts"],"sourcesContent":["import { dirname as pathDirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { AIOptions as BaseAIOptions } from '@intlayer/api';\nimport type { DiffMode, ListGitFilesOptions } from '@intlayer/chokidar/cli';\nimport { setPrefix } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { CustomIntlayerConfig } from '@intlayer/types/config';\nimport { Command } from 'commander';\nimport { login } from './auth/login';\nimport { build } from './build';\nimport { runCI } from './ci';\nimport { getConfig } from './config';\nimport { startEditor } from './editor';\nimport { extract } from './extract';\nimport { type FillOptions, fill } from './fill/fill';\nimport { init } from './init';\nimport { initMCP } from './initMCP';\nimport { initSkills } from './initSkills';\nimport { listContentDeclaration } from './listContentDeclaration';\nimport { listProjectsCommand } from './listProjects';\nimport { liveSync } from './liveSync';\nimport { pull } from './pull';\nimport { push } from './push/push';\nimport { pushConfig } from './pushConfig';\nimport { reviewDoc } from './reviewDoc/reviewDoc';\nimport { searchDoc } from './searchDoc';\nimport { testMissingTranslations } from './test';\nimport { translateDoc } from './translateDoc/translateDoc';\nimport { getParentPackageJSON } from './utils/getParentPackageJSON';\nimport { watchContentDeclaration } from './watch';\n\n// Extended AI options to include customPrompt\ntype AIOptions = BaseAIOptions & {\n customPrompt?: string;\n};\n\nconst isESModule = typeof import.meta.url === 'string';\n\nexport const dirname = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson = getParentPackageJSON(dirname);\n\nconst logOptions = [\n ['--verbose', 'Verbose (default to true using CLI)'],\n ['--prefix [prefix]', 'Prefix'],\n];\n\nconst configurationOptions = [\n ['--env-file [envFile]', 'Environment file'],\n ['-e, --env [env]', 'Environment'],\n ['--base-dir [baseDir]', 'Base directory'],\n ['--no-cache [noCache]', 'No cache'],\n ...logOptions,\n];\n\nconst aiOptions = [\n ['--provider [provider]', 'Provider'],\n ['--temperature [temperature]', 'Temperature'],\n ['--model [model]', 'Model'],\n ['--api-key [apiKey]', 'Provider API key'],\n ['--custom-prompt [prompt]', 'Custom prompt'],\n ['--application-context [applicationContext]', 'Application context'],\n ['--data-serialization [dataSerialization]', 'Data serialization'],\n];\n\nconst gitOptions = [\n ['--git-diff [gitDiff]', 'Git diff mode - Check git diff between two refs'],\n ['--git-diff-base [gitDiffBase]', 'Git diff base ref'],\n ['--git-diff-current [gitDiffCurrent]', 'Git diff current ref'],\n ['--uncommitted [uncommitted]', 'Uncommitted'],\n ['--unpushed [unpushed]', 'Unpushed'],\n ['--untracked [untracked]', 'Untracked'],\n];\n\nconst extractKeysFromOptions = (options: object, keys: string[]) =>\n keys.filter((key) => options[key as keyof typeof options] !== undefined);\n\n/**\n * Helper functions to apply common options to commands\n */\nconst applyOptions = (command: Command, options: string[][]) => {\n options.forEach(([flag, description]) => {\n command.option(flag, description);\n });\n return command;\n};\n\nconst removeUndefined = <T extends Record<string, any>>(obj: T): T =>\n Object.fromEntries(\n Object.entries(obj).filter(([_, value]) => value !== undefined)\n ) as T;\n\nconst applyConfigOptions = (command: Command) =>\n applyOptions(command, configurationOptions);\nconst applyAIOptions = (command: Command) => applyOptions(command, aiOptions);\nconst applyGitOptions = (command: Command) => applyOptions(command, gitOptions);\n\nconst extractAiOptions = (options: AIOptions): AIOptions | undefined => {\n const {\n apiKey,\n provider,\n model,\n temperature,\n applicationContext,\n customPrompt,\n dataSerialization,\n } = options;\n\n const configuration = getConfiguration();\n\n const { ai } = configuration;\n\n return removeUndefined({\n ...ai,\n apiKey: apiKey ?? configuration.ai?.apiKey,\n provider: provider ?? (configuration.ai?.provider as AIOptions['provider']),\n model: model ?? configuration.ai?.model,\n temperature: temperature ?? configuration.ai?.temperature,\n applicationContext:\n applicationContext ?? configuration.ai?.applicationContext,\n customPrompt: customPrompt ?? (configuration.ai as any)?.customPrompt,\n dataSerialization: dataSerialization ?? configuration.ai?.dataSerialization,\n });\n};\n\ntype GitOptions = {\n gitDiff?: boolean;\n gitDiffBase?: string;\n gitDiffCurrent?: string;\n uncommitted?: boolean;\n unpushed?: boolean;\n untracked?: boolean;\n};\n\nconst gitOptionKeys: (keyof GitOptions)[] = [\n 'gitDiff',\n 'gitDiffBase',\n 'gitDiffCurrent',\n 'uncommitted',\n 'unpushed',\n 'untracked',\n];\n\nconst extractGitOptions = (\n options: GitOptions\n): ListGitFilesOptions | undefined => {\n const filteredOptions = extractKeysFromOptions(options, gitOptionKeys);\n\n const isOptionEmpty = filteredOptions.length === 0;\n\n if (isOptionEmpty) return undefined;\n\n const {\n gitDiff,\n gitDiffBase,\n gitDiffCurrent,\n uncommitted,\n unpushed,\n untracked,\n } = options;\n\n const mode = [\n gitDiff && 'gitDiff',\n uncommitted && 'uncommitted',\n unpushed && 'unpushed',\n untracked && 'untracked',\n ].filter(Boolean) as DiffMode[];\n\n return removeUndefined({\n mode,\n baseRef: gitDiffBase,\n currentRef: gitDiffCurrent,\n absolute: true,\n });\n};\n\ntype LogOptions = {\n prefix?: string;\n verbose?: boolean;\n};\n\nexport type ConfigurationOptions = {\n baseDir?: string;\n env?: string;\n envFile?: string;\n noCache?: boolean;\n checkTypes?: boolean;\n} & LogOptions;\n\nconst configurationOptionKeys: (keyof ConfigurationOptions)[] = [\n 'baseDir',\n 'env',\n 'envFile',\n 'verbose',\n 'prefix',\n 'checkTypes',\n];\n\nconst extractConfigOptions = (\n options: ConfigurationOptions & { with?: string }\n): GetConfigurationOptions | undefined => {\n const filteredOptions = extractKeysFromOptions(\n options,\n configurationOptionKeys\n );\n\n const isOptionEmpty = filteredOptions.length === 0;\n\n if (isOptionEmpty) {\n return undefined;\n }\n\n const { baseDir, env, envFile, verbose, noCache, checkTypes } = options;\n\n const log = removeUndefined({\n mode:\n typeof verbose !== 'undefined'\n ? verbose\n ? 'verbose'\n : 'default'\n : undefined,\n });\n\n const build = removeUndefined({\n checkTypes,\n });\n\n const override: CustomIntlayerConfig = removeUndefined({\n log:\n Object.keys(log).length > 0\n ? (log as CustomIntlayerConfig['log'])\n : undefined,\n build: Object.keys(build).length > 0 ? build : undefined,\n });\n\n return removeUndefined({\n baseDir,\n env,\n envFile,\n override: Object.keys(override).length > 0 ? override : undefined,\n cache: typeof noCache !== 'undefined' ? !noCache : undefined,\n });\n};\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 isWithCommand = process.argv.includes('--with');\n\n if (!isWithCommand) {\n setPrefix('');\n }\n\n const program = new Command();\n\n program.version(packageJson.version!).description('Intlayer CLI');\n\n // Explicit version subcommand for convenience: `npx intlayer version`\n program\n .command('version')\n .description('Print the Intlayer CLI version')\n .action(() => {\n // Prefer the resolved package.json version; fallback to unknown\n // Keeping output minimal to align with common CLI behavior\n console.log(packageJson.version ?? 'unknown');\n });\n\n /**\n * AUTH\n */\n const loginCmd = program\n .command('login')\n .description('Login to Intlayer')\n .option('--cms-url [cmsUrl]', 'CMS URL');\n\n applyConfigOptions(loginCmd);\n\n loginCmd.action((options) => {\n const configOptions = extractConfigOptions(options) ?? {\n override: {\n log: {\n prefix: '',\n mode: 'verbose',\n },\n },\n };\n\n return login({\n cmsUrl: options.cmsUrl,\n configOptions,\n });\n });\n\n /**\n * INIT\n */\n const initCmd = program\n .command('init')\n .description('Initialize Intlayer in the project')\n .option('--project-root [projectRoot]', 'Project root directory')\n .action((options) => init(options.projectRoot));\n\n initCmd\n .command('skills')\n .description('Initialize Intlayer skills in the project')\n .option('--project-root [projectRoot]', 'Project root directory')\n .action((options) => initSkills(options.projectRoot));\n\n initCmd\n .command('mcp')\n .description('Initialize Intlayer MCP server in the project')\n .option('--project-root [projectRoot]', 'Project root directory')\n .action((options) => initMCP(options.projectRoot));\n\n /**\n * DICTIONARIES\n */\n\n const dictionariesProgram = program\n .command('dictionary')\n .alias('dictionaries')\n .alias('dic')\n .description('Dictionaries operations');\n\n // Dictionary build command\n const buildOptions = {\n description: 'Build the dictionaries',\n options: [\n ['-w, --watch', 'Watch for changes'],\n ['--skip-prepare', 'Skip the prepare step'],\n ['--with [with...]', 'Start command in parallel with the build'],\n ['--check-types', 'Check TypeScript type and log errors'],\n ],\n };\n\n // Add build command to dictionaries program\n const dictionariesBuildCmd = dictionariesProgram\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(dictionariesBuildCmd, buildOptions.options);\n applyConfigOptions(dictionariesBuildCmd);\n dictionariesBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add build command to root program as well\n const rootBuildCmd = program\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(rootBuildCmd, buildOptions.options);\n applyConfigOptions(rootBuildCmd);\n rootBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n const watchOptions = {\n description: 'Watch the dictionaries changes',\n options: [['--with [with...]', 'Start command in parallel with the build']],\n };\n\n // Add build command to dictionaries program\n const dictionariesWatchCmd = dictionariesProgram\n .command('watch')\n .description(buildOptions.description);\n\n applyOptions(dictionariesWatchCmd, watchOptions.options);\n applyConfigOptions(dictionariesWatchCmd);\n dictionariesWatchCmd.action((options) => {\n watchContentDeclaration({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add build command to root program as well\n const rootWatchCmd = program\n .command('watch')\n .description(buildOptions.description);\n\n applyOptions(rootWatchCmd, watchOptions.options);\n applyConfigOptions(rootWatchCmd);\n rootWatchCmd.action((options) => {\n watchContentDeclaration({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary pull command\n const pullOptions = {\n description: 'Pull dictionaries from the server',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to pull'],\n [\n '--dictionary [ids...]',\n 'List of dictionary IDs to pull (alias for --dictionaries)',\n ],\n ['--new-dictionaries-path [path]', 'Path to save the new dictionaries'],\n // Backward-compatibility for older tests/flags (camelCase)\n [\n '--newDictionariesPath [path]',\n '[alias] Path to save the new dictionaries',\n ],\n ],\n };\n\n // Add pull command to dictionaries program\n const dictionariesPullCmd = dictionariesProgram\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(dictionariesPullCmd, pullOptions.options);\n applyConfigOptions(dictionariesPullCmd);\n dictionariesPullCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries ?? []),\n ...(options.dictionary ?? []),\n ];\n\n pull({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n configOptions: {\n ...options.configOptions,\n baseDir: options.baseDir,\n },\n });\n });\n\n // Add pull command to root program as well\n const rootPullCmd = program\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(rootPullCmd, pullOptions.options);\n applyConfigOptions(rootPullCmd);\n rootPullCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries ?? []),\n ...(options.dictionary ?? []),\n ];\n\n pull({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary push command\n const pushOptions = {\n description:\n 'Push all dictionaries. Create or update the pushed dictionaries',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to push'],\n [\n '--dictionary [ids...]',\n 'List of dictionary IDs to push (alias for --dictionaries)',\n ],\n [\n '-r, --delete-locale-dictionary',\n 'Delete the local dictionaries after pushing',\n ],\n [\n '-k, --keep-locale-dictionary',\n 'Keep the local dictionaries after pushing',\n ],\n // Backward-compatibility for older tests/flags (camelCase)\n [\n '--deleteLocaleDictionary',\n '[alias] Delete the local dictionaries after pushing',\n ],\n [\n '--keepLocaleDictionary',\n '[alias] Keep the local dictionaries after pushing',\n ],\n [\n '--build [build]',\n 'Build the dictionaries before pushing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build',\n ],\n ],\n };\n\n // Add push command to dictionaries program\n const dictionariesPushCmd = dictionariesProgram\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(dictionariesPushCmd, pushOptions.options);\n applyConfigOptions(dictionariesPushCmd);\n applyGitOptions(dictionariesPushCmd);\n\n dictionariesPushCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries || []),\n ...(options.dictionary || []),\n ];\n\n return push({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions);\n });\n\n // Add push command to root program as well\n const rootPushCmd = program\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(rootPushCmd, pushOptions.options);\n applyConfigOptions(rootPushCmd);\n applyGitOptions(rootPushCmd);\n\n rootPushCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries || []),\n ...(options.dictionary || []),\n ];\n\n return push({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions);\n });\n\n /**\n * CONFIGURATION\n */\n\n // Define the parent command\n const configurationProgram = program\n .command('configuration')\n .alias('config')\n .alias('conf')\n .description('Configuration operations');\n\n const configGetCmd = configurationProgram\n .command('get')\n .description('Get the configuration');\n\n applyConfigOptions(configGetCmd);\n configGetCmd.action((options) => {\n getConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Define the `push config` subcommand and add it to the `push` command\n const configPushCmd = configurationProgram\n .command('push')\n .description('Push the configuration');\n\n applyConfigOptions(configPushCmd);\n configPushCmd.action((options) => {\n pushConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n /**\n * PROJECTS\n */\n\n const projectsProgram = program\n .command('projects')\n .alias('project')\n .description('List Intlayer projects');\n\n const projectsListCmd = projectsProgram\n .command('list')\n .description('List all Intlayer projects in the directory')\n .option('--base-dir [baseDir]', 'Base directory to search from')\n .option(\n '--git-root',\n 'Search from the git root directory instead of the base directory'\n )\n .option('--json', 'Output the results as JSON');\n\n projectsListCmd.action((options) => {\n listProjectsCommand({\n baseDir: options.baseDir,\n gitRoot: options.gitRoot,\n json: options.json,\n });\n });\n\n // Add alias for projects list command at root level\n const rootProjectsListCmd = program\n .command('projects-list')\n .alias('pl')\n .description('List all Intlayer projects in the directory')\n .option('--base-dir [baseDir]', 'Base directory to search from')\n .option(\n '--git-root',\n 'Search from the git root directory instead of the base directory'\n )\n .option('--absolute', 'Output the results as absolute paths')\n .option('--json', 'Output the results as JSON');\n\n rootProjectsListCmd.action((options) => {\n listProjectsCommand({\n baseDir: options.baseDir,\n gitRoot: options.gitRoot,\n json: options.json,\n absolute: options.absolute,\n });\n });\n\n /**\n * CONTENT DECLARATION\n */\n\n const contentProgram = program\n .command('content')\n .description('Content declaration operations');\n\n contentProgram\n .command('list')\n .description('List the content declaration files')\n .option('--json', 'Output the results as JSON')\n .option('--absolute', 'Output the results as absolute paths')\n .action((options) => {\n listContentDeclaration({\n json: options.json,\n absolute: options.absolute,\n });\n });\n\n // Add alias for content list command\n program\n .command('list')\n .description('List the content declaration files')\n .option('--json', 'Output the results as JSON')\n .option('--absolute', 'Output the results as absolute paths')\n .action((options) => {\n listContentDeclaration({\n json: options.json,\n absolute: options.absolute,\n });\n });\n\n const testProgram = contentProgram\n .command('test')\n .description('Test if there are missing translations')\n .option(\n '--build [build]',\n 'Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build'\n );\n\n applyConfigOptions(testProgram);\n testProgram.action((options) => {\n testMissingTranslations({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add alias for content test command\n const rootTestCmd = program\n .command('test')\n .description('Test if there are missing translations')\n .option(\n '--build [build]',\n 'Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build'\n );\n\n applyConfigOptions(rootTestCmd);\n rootTestCmd.action((options) => {\n testMissingTranslations({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n const fillProgram = program\n .command('fill')\n .description('Fill the dictionaries')\n .option('-f, --file [files...]', 'List of Dictionary files to fill')\n .option('--source-locale [sourceLocale]', 'Source locale to translate from')\n .option(\n '--output-locales [outputLocales...]',\n 'Target locales to translate to'\n )\n .option(\n '--mode [mode]',\n 'Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys',\n 'complete'\n )\n .option('-k, --keys [keys...]', 'Filter dictionaries based on keys')\n .option(\n '--key [keys...]',\n 'Filter dictionaries based on keys (alias for --keys)'\n )\n .option(\n '--excluded-keys [excludedKeys...]',\n 'Filter out dictionaries based on keys'\n )\n .option(\n '--excluded-key [excludedKeys...]',\n 'Filter out dictionaries based on keys (alias for --excluded-keys)'\n )\n .option(\n '--path-filter [pathFilters...]',\n 'Filter dictionaries based on glob pattern'\n )\n .option(\n '--build [build]',\n 'Build the dictionaries before filling to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build'\n )\n .option(\n '--skip-metadata',\n 'Skip filling missing metadata (description, title, tags) for dictionaries'\n );\n\n applyConfigOptions(fillProgram);\n applyAIOptions(fillProgram);\n applyGitOptions(fillProgram);\n\n fillProgram.action((options) => {\n // Merge key aliases\n const keys = [...(options.keys ?? []), ...(options.key ?? [])];\n const excludedKeys = [\n ...(options.excludedKeys ?? []),\n ...(options.excludedKey ?? []),\n ];\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries ?? []),\n ...(options.dictionary ?? []),\n ];\n\n return fill({\n ...options,\n keys: keys.length > 0 ? keys : undefined,\n excludedKeys: excludedKeys.length > 0 ? excludedKeys : undefined,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions);\n });\n\n /**\n * DOCS\n */\n\n const docParams = [\n ['--doc-pattern [docPattern...]', 'Documentation pattern'],\n [\n '--excluded-glob-pattern [excludedGlobPattern...]',\n 'Excluded glob pattern',\n ],\n [\n '--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]',\n 'Number of simultaneous file processed',\n ],\n ['--locales [locales...]', 'Locales'],\n ['--base-locale [baseLocale]', 'Base locale'],\n [\n '--custom-instructions [customInstructions]',\n 'Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc.',\n ],\n [\n '--skip-if-modified-before [skipIfModifiedBefore]',\n 'Skip the file if it has been modified before the given time. Can be an absolute time as \"2025-12-05\" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file.',\n ],\n [\n '--skip-if-modified-after [skipIfModifiedAfter]',\n 'Skip the file if it has been modified within the given time. Can be an absolute time as \"2025-12-05\" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file.',\n ],\n ['--skip-if-exists', 'Skip the file if it already exists'],\n ];\n\n const docProgram = program\n .command('doc')\n .description('Documentation operations');\n\n const translateProgram = docProgram\n .command('translate')\n .description('Translate the documentation');\n\n applyConfigOptions(translateProgram);\n applyAIOptions(translateProgram);\n applyGitOptions(translateProgram);\n applyOptions(translateProgram, docParams);\n\n translateProgram.action((options) =>\n translateDoc({\n docPattern: options.docPattern,\n excludedGlobPattern: options.excludedGlobPattern,\n locales: options.locales,\n baseLocale: options.baseLocale,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,\n configOptions: extractConfigOptions(options),\n customInstructions: options.customInstructions,\n skipIfModifiedBefore: options.skipIfModifiedBefore,\n skipIfModifiedAfter: options.skipIfModifiedAfter,\n skipIfExists: options.skipIfExists,\n })\n );\n\n const reviewProgram = docProgram\n .command('review')\n .description('Review the documentation');\n\n applyConfigOptions(reviewProgram);\n applyAIOptions(reviewProgram);\n applyGitOptions(reviewProgram);\n applyOptions(reviewProgram, docParams);\n\n reviewProgram.action((options) =>\n reviewDoc({\n docPattern: options.docPattern,\n excludedGlobPattern: options.excludedGlobPattern,\n locales: options.locales,\n baseLocale: options.baseLocale,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,\n configOptions: extractConfigOptions(options),\n customInstructions: options.customInstructions,\n skipIfModifiedBefore: options.skipIfModifiedBefore,\n skipIfModifiedAfter: options.skipIfModifiedAfter,\n skipIfExists: options.skipIfExists,\n })\n );\n\n const searchProgram = docProgram\n .command('search')\n .description('Search the documentation')\n .argument('<query>', 'Search query')\n .option('--limit [limit]', 'Limit the number of results', '10');\n\n applyConfigOptions(searchProgram);\n\n searchProgram.action((query, options) =>\n searchDoc({\n query,\n limit: options.limit ? parseInt(options.limit, 10) : 10,\n configOptions: extractConfigOptions(options),\n })\n );\n\n /**\n * LIVE SYNC\n */\n\n const liveOptions = [\n ['--with [with...]', 'Start command in parallel with the live sync'],\n ];\n\n const liveCmd = program\n .command('live')\n .description(\n 'Live sync - Watch for changes made on the CMS and update the application content accordingly'\n );\n\n applyOptions(liveCmd, liveOptions);\n applyConfigOptions(liveCmd);\n\n liveCmd.action((options) => liveSync(options));\n\n /**\n * EDITOR\n */\n\n const editorProgram = program\n .command('editor')\n .description('Visual editor operations');\n\n const editorStartCmd = editorProgram\n .command('start')\n .description('Start the Intlayer visual editor');\n\n applyConfigOptions(editorStartCmd);\n\n editorStartCmd.action((options) => {\n startEditor({\n env: options.env,\n envFile: options.envFile,\n });\n });\n\n /**\n * EXTRACT\n */\n const extractProgram = program\n .command('extract')\n .alias('ext')\n .description(\n 'Extract strings from components to be placed in a .content file close to the component'\n );\n\n extractProgram\n .option('-f, --file [files...]', 'List of files to extract')\n .option(\n '-o, --output-content-declarations [outputContentDeclarations]',\n 'Path to output content declaration files'\n )\n .option('--code-only', 'Only extract the component code', false)\n .option('--declaration-only', 'Only generate content declaration', false)\n .action((options) => {\n extract({\n files: options.file,\n outputContentDeclarations: options.outputContentDeclarations,\n configOptions: extractConfigOptions(options),\n codeOnly: options.codeOnly,\n declarationOnly: options.declarationOnly,\n });\n });\n\n applyConfigOptions(extractProgram);\n\n program.parse(process.argv);\n\n /**\n * CI / AUTOMATION\n *\n * Used to iterate over all projects in a monorepo, and help to parse secrets\n */\n program\n .command('ci')\n .description(\n 'Run Intlayer commands with auto-injected credentials from INTLAYER_PROJECT_CREDENTIALS. Detects current project or iterates over all projects.'\n )\n .argument(\n '<command...>',\n 'The intlayer command to execute (e.g., \"fill\", \"push\")'\n )\n .allowUnknownOption() // Allows passing flags like --verbose to the subcommand\n .action((args) => {\n runCI(args);\n });\n\n return program;\n};\n"],"mappings":"2wCAyCA,MAAa,EAFM,OAAO,OAAO,KAAK,KAAQ,SAG1CA,EAAY,EAAc,OAAO,KAAK,IAAI,CAAC,CAC3C,UAEE,EAAc,EA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,qBAAsB,oCAAqC,GAAM,CACxE,OAAQ,GAAY,CACnB,EAAQ,CACN,MAAO,EAAQ,KACf,0BAA2B,EAAQ,0BACnC,cAAe,EAAqB,EAAQ,CAC5C,SAAU,EAAQ,SAClB,gBAAiB,EAAQ,gBAC1B,CAAC,EACF,CAEJ,EAAmB,EAAe,CAElC,EAAQ,MAAM,QAAQ,KAAK,CAO3B,EACG,QAAQ,KAAK,CACb,YACC,iJACD,CACA,SACC,eACA,yDACD,CACA,oBAAoB,CACpB,OAAQ,GAAS,CAChB,EAAM,EAAK,EACX,CAEG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{dirname as e,resolve as t}from"node:path";import{spawn as n}from"node:child_process";import{createRequire as r}from"node:module";import{isESModule as i}from"@intlayer/config/utils";var a=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});const o=o=>{let s=[`start`];o.env&&s.push(`--env`,o.env),o.envFile&&s.push(`--env-file`,o.envFile);let c=e=>n(process.execPath,[e,...s],{stdio:`inherit`,env:{...process.env}}),l=(e,t)=>n(e,t,{stdio:`inherit`,env:{...process.env}});try{let n=c(t(e((i?r(import.meta.url):a).resolve(`intlayer-editor/package.json`)),`bin`,`intlayer-editor.mjs`));n.on(`error`,()=>u()),n.on(`exit`,e=>{e===255&&process.exit(e??0)})}catch{u()}function u(){l(`bun`,[`dlx`,`intlayer-editor`,...s]).on(`error`,()=>{l(`npx`,[`-y`,`intlayer-editor`,...s]).on(`error`,e=>{console.error(`Unable to execute intlayer-editor via bun or npx.`),console.error(String(e?.message??e)),process.exit(1)})})}};export{o as t};
|
|
2
|
+
//# sourceMappingURL=editor-D8BGlLzF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-D8BGlLzF.mjs","names":["pathResolve","pathDirname"],"sources":["../../src/editor.ts"],"sourcesContent":["import { spawn } from 'node:child_process';\nimport { createRequire } from 'node:module';\nimport { dirname as pathDirname, resolve as pathResolve } from 'node:path';\nimport { isESModule } from '@intlayer/config/utils';\n\ntype StartEditorOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const startEditor = (options: StartEditorOptions): void => {\n const args: string[] = ['start'];\n\n if (options.env) args.push('--env', options.env);\n if (options.envFile) args.push('--env-file', options.envFile);\n\n const spawnNodeProcess = (binPath: string) =>\n spawn(process.execPath, [binPath, ...args], {\n stdio: 'inherit',\n env: { ...process.env },\n });\n\n const spawnWith = (cmd: string, cmdArgs: string[]) =>\n spawn(cmd, cmdArgs, {\n stdio: 'inherit',\n env: { ...process.env },\n });\n\n try {\n const requireFunction = isESModule\n ? createRequire(import.meta.url)\n : require;\n const pkgJsonPath = requireFunction.resolve('intlayer-editor/package.json');\n const pkgDir = pathDirname(pkgJsonPath);\n const binPath = pathResolve(pkgDir, 'bin', 'intlayer-editor.mjs');\n\n const child = spawnNodeProcess(binPath);\n child.on('error', () => runFallback());\n child.on('exit', (code) => {\n if (code === 255) process.exit(code ?? 0);\n });\n } catch {\n runFallback();\n }\n\n function runFallback() {\n const bun = spawnWith('bun', ['dlx', 'intlayer-editor', ...args]);\n bun.on('error', () => {\n const npx = spawnWith('npx', ['-y', 'intlayer-editor', ...args]);\n npx.on('error', (err) => {\n console.error('Unable to execute intlayer-editor via bun or npx.');\n console.error(String(err?.message ?? err));\n process.exit(1);\n });\n });\n }\n};\n"],"mappings":"+jBAUA,MAAa,EAAe,GAAsC,CAChE,IAAM,EAAiB,CAAC,QAAQ,CAE5B,EAAQ,KAAK,EAAK,KAAK,QAAS,EAAQ,IAAI,CAC5C,EAAQ,SAAS,EAAK,KAAK,aAAc,EAAQ,QAAQ,CAE7D,IAAM,EAAoB,GACxB,EAAM,QAAQ,SAAU,CAAC,EAAS,GAAG,EAAK,CAAE,CAC1C,MAAO,UACP,IAAK,CAAE,GAAG,QAAQ,IAAK,CACxB,CAAC,CAEE,GAAa,EAAa,IAC9B,EAAM,EAAK,EAAS,CAClB,MAAO,UACP,IAAK,CAAE,GAAG,QAAQ,IAAK,CACxB,CAAC,CAEJ,GAAI,CAQF,IAAM,EAAQ,EAFEA,EADDC,GAJS,EACpB,EAAc,OAAO,KAAK,IAAI,CAAA,GAEE,QAAQ,+BAA+B,CACpC,CACH,MAAO,sBAAsB,CAE1B,CACvC,EAAM,GAAG,YAAe,GAAa,CAAC,CACtC,EAAM,GAAG,OAAS,GAAS,CACrB,IAAS,KAAK,QAAQ,KAAK,GAAQ,EAAE,EACzC,MACI,CACN,GAAa,CAGf,SAAS,GAAc,CACT,EAAU,MAAO,CAAC,MAAO,kBAAmB,GAAG,EAAK,CAAC,CAC7D,GAAG,YAAe,CACR,EAAU,MAAO,CAAC,KAAM,kBAAmB,GAAG,EAAK,CAAC,CAC5D,GAAG,QAAU,GAAQ,CACvB,QAAQ,MAAM,oDAAoD,CAClE,QAAQ,MAAM,OAAO,GAAK,SAAW,EAAI,CAAC,CAC1C,QAAQ,KAAK,EAAE,EACf,EACF"}
|
package/dist/esm/editor.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=editor.mjs.map
|
|
1
|
+
import{t as e}from"./editor-D8BGlLzF.mjs";export{e as startEditor};
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"./editor-D8BGlLzF.mjs";import{extract as t}from"./extract.mjs";import{listProjectsCommand as n}from"./listProjects.mjs";import{liveSync as r}from"./liveSync.mjs";import{listContentDeclaration as i,listContentDeclarationRows as a}from"./listContentDeclaration.mjs";import{findProjectRoot as o,init as s}from"./init.mjs";import{build as c}from"./build.mjs";import{listMissingTranslations as l,listMissingTranslationsWithConfig as u}from"./test/listMissingTranslations.mjs";import{testMissingTranslations as d}from"./test/test.mjs";import{fill as f}from"./fill/fill.mjs";import{PLATFORM_OPTIONS as p,getDetectedPlatform as m,initSkills as h}from"./initSkills.mjs";import{pull as g}from"./pull.mjs";import{push as _}from"./push/push.mjs";import{pushConfig as v}from"./pushConfig.mjs";import"./_utils_asset-B187VPMw.mjs";import{reviewDoc as y}from"./reviewDoc/reviewDoc.mjs";import{searchDoc as b}from"./searchDoc.mjs";import{translateDoc as x}from"./translateDoc/translateDoc.mjs";import{dirname as S,setAPI as C}from"./cli.mjs";export{p as PLATFORM_OPTIONS,c as build,S as dirname,t as extract,f as fill,o as findProjectRoot,m as getDetectedPlatform,s as init,h as initSkills,i as listContentDeclaration,a as listContentDeclarationRows,l as listMissingTranslations,u as listMissingTranslationsWithConfig,n as listProjectsCommand,r as liveSync,g as pull,_ as push,v as pushConfig,y as reviewDoc,b as searchDoc,C as setAPI,e as startEditor,d as testMissingTranslations,x as translateDoc};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{setupAI as e}from"../utils/setupAI.mjs";import{checkFileModifiedRange as t}from"../utils/checkFileModifiedRange.mjs";import{getOutputFilePath as n}from"../utils/getOutputFilePath.mjs";import{reviewFileBlockAware as r}from"./reviewDocBlockAware.mjs";import{existsSync as i}from"node:fs";import{join as a,relative as o}from"node:path";import{listGitFiles as s,listGitLines as c,logConfigDetails as l}from"@intlayer/chokidar/cli";import{formatLocale as u,formatPath as d,parallelize as f}from"@intlayer/chokidar/utils";import{ANSIColors as p,colorize as m,colorizeNumber as h,getAppLogger as g}from"@intlayer/config/logger";import{getConfiguration as _}from"@intlayer/config/node";import v from"fast-glob";const y=async({docPattern:y,locales:b,excludedGlobPattern:x,baseLocale:S,aiOptions:C,nbSimultaneousFileProcessed:w,configOptions:T,customInstructions:E,skipIfModifiedBefore:D,skipIfModifiedAfter:O,skipIfExists:k,gitOptions:A})=>{let j=_(T);l(T);let M=g(j),N=await e(j,C);if(!N?.hasAIAccess)return;let{aiClient:P,aiConfig:F}=N;w&&w>10&&(M(`Warning: nbSimultaneousFileProcessed is set to ${w}, which is greater than 10. Setting it to 10.`),w=10);let I=await v(y,{ignore:x});if(A){let e=await s(A);e&&(I=I.filter(t=>e.some(e=>a(process.cwd(),t)===e)))}M(`Base locale is ${u(S)}`),M(`Reviewing ${h(b.length)} locales: [ ${u(b)} ]`),M(`Reviewing ${h(I.length)} files:`),M(I.map(e=>` - ${d(e)}\n`)),await f(I.flatMap(e=>b.map(s=>async()=>{M(`Reviewing file: ${d(e)} to ${u(s)}`);let l=a(j.system.baseDir,e),f=n(l,s,S);if(k&&i(f)){let e=o(j.system.baseDir,f);M(`${m(`⊘`,p.YELLOW)} File ${d(e)} already exists, skipping.`);return}if(i(f)){let e=t(f,{skipIfModifiedBefore:D,skipIfModifiedAfter:O});if(e.isSkipped){M(e.message);return}}else (D||O)&&M(`${m(`!`,p.YELLOW)} File ${d(f)} does not exist, skipping modification date check.`);let h;if(A){let e=await c(l,A);M(`Git changed lines: ${e.join(`, `)}`),h=e}await r(l,f,s,S,C,T,E,h,P,F)})),e=>e(),w??3)};export{y as reviewDoc};
|
|
1
|
+
import{setupAI as e}from"../utils/setupAI.mjs";import{checkFileModifiedRange as t}from"../utils/checkFileModifiedRange.mjs";import{getOutputFilePath as n}from"../utils/getOutputFilePath.mjs";import"../_utils_asset-B187VPMw.mjs";import{reviewFileBlockAware as r}from"./reviewDocBlockAware.mjs";import{existsSync as i}from"node:fs";import{join as a,relative as o}from"node:path";import{listGitFiles as s,listGitLines as c,logConfigDetails as l}from"@intlayer/chokidar/cli";import{formatLocale as u,formatPath as d,parallelize as f}from"@intlayer/chokidar/utils";import{ANSIColors as p,colorize as m,colorizeNumber as h,getAppLogger as g}from"@intlayer/config/logger";import{getConfiguration as _}from"@intlayer/config/node";import v from"fast-glob";const y=async({docPattern:y,locales:b,excludedGlobPattern:x,baseLocale:S,aiOptions:C,nbSimultaneousFileProcessed:w,configOptions:T,customInstructions:E,skipIfModifiedBefore:D,skipIfModifiedAfter:O,skipIfExists:k,gitOptions:A})=>{let j=_(T);l(T);let M=g(j),N=await e(j,C);if(!N?.hasAIAccess)return;let{aiClient:P,aiConfig:F}=N;w&&w>10&&(M(`Warning: nbSimultaneousFileProcessed is set to ${w}, which is greater than 10. Setting it to 10.`),w=10);let I=await v(y,{ignore:x});if(A){let e=await s(A);e&&(I=I.filter(t=>e.some(e=>a(process.cwd(),t)===e)))}M(`Base locale is ${u(S)}`),M(`Reviewing ${h(b.length)} locales: [ ${u(b)} ]`),M(`Reviewing ${h(I.length)} files:`),M(I.map(e=>` - ${d(e)}\n`)),await f(I.flatMap(e=>b.map(s=>async()=>{M(`Reviewing file: ${d(e)} to ${u(s)}`);let l=a(j.system.baseDir,e),f=n(l,s,S);if(k&&i(f)){let e=o(j.system.baseDir,f);M(`${m(`⊘`,p.YELLOW)} File ${d(e)} already exists, skipping.`);return}if(i(f)){let e=t(f,{skipIfModifiedBefore:D,skipIfModifiedAfter:O});if(e.isSkipped){M(e.message);return}}else (D||O)&&M(`${m(`!`,p.YELLOW)} File ${d(f)} does not exist, skipping modification date check.`);let h;if(A){let e=await c(l,A);M(`Git changed lines: ${e.join(`, `)}`),h=e}await r(l,f,s,S,C,T,E,h,P,F)})),e=>e(),w??3)};export{y as reviewDoc};
|
|
2
2
|
//# sourceMappingURL=reviewDoc.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewDoc.mjs","names":[],"sources":["../../../src/reviewDoc/reviewDoc.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport type { AIOptions } from '@intlayer/api';\nimport {\n type ListGitFilesOptions,\n listGitFiles,\n listGitLines,\n logConfigDetails,\n} from '@intlayer/chokidar/cli';\nimport {\n formatLocale,\n formatPath,\n parallelize,\n} from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colorize,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport fg from 'fast-glob';\nimport { checkFileModifiedRange } from '../utils/checkFileModifiedRange';\nimport { getOutputFilePath } from '../utils/getOutputFilePath';\nimport { setupAI } from '../utils/setupAI';\nimport { reviewFileBlockAware } from './reviewDocBlockAware';\n\ntype ReviewDocOptions = {\n docPattern: string[];\n locales: Locale[];\n excludedGlobPattern: string[];\n baseLocale: Locale;\n aiOptions?: AIOptions;\n nbSimultaneousFileProcessed?: number;\n configOptions?: GetConfigurationOptions;\n customInstructions?: string;\n skipIfModifiedBefore?: number | string | Date;\n skipIfModifiedAfter?: number | string | Date;\n skipIfExists?: boolean;\n gitOptions?: ListGitFilesOptions;\n};\n\n/**\n * Main audit function: scans all .md files in \"en/\" (unless you specified DOC_LIST),\n * then audits them to each locale in LOCALE_LIST.\n */\nexport const reviewDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed,\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n}: ReviewDocOptions) => {\n const configuration = getConfiguration(configOptions);\n logConfigDetails(configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n const aiResult = await setupAI(configuration, aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig } = aiResult;\n\n if (nbSimultaneousFileProcessed && nbSimultaneousFileProcessed > 10) {\n appLogger(\n `Warning: nbSimultaneousFileProcessed is set to ${nbSimultaneousFileProcessed}, which is greater than 10. Setting it to 10.`\n );\n nbSimultaneousFileProcessed = 10; // Limit the number of simultaneous file processed to 10\n }\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n // OAuth handled by API proxy internally\n\n appLogger(`Base locale is ${formatLocale(baseLocale)}`);\n appLogger(\n `Reviewing ${colorizeNumber(locales.length)} locales: [ ${formatLocale(locales)} ]`\n );\n\n appLogger(`Reviewing ${colorizeNumber(docList.length)} files:`);\n appLogger(docList.map((path) => ` - ${formatPath(path)}\\n`));\n\n // Create all tasks to be processed\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n appLogger(\n `Reviewing file: ${formatPath(docPath)} to ${formatLocale(locale)}`\n );\n\n const absoluteBaseFilePath = join(configuration.system.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip if file exists and skipIfExists option is enabled\n if (skipIfExists && existsSync(outputFilePath)) {\n const relativePath = relative(\n configuration.system.baseDir,\n outputFilePath\n );\n appLogger(\n `${colorize('⊘', ANSIColors.YELLOW)} File ${formatPath(relativePath)} already exists, skipping.`\n );\n return;\n }\n\n // Check modification range only if the file exists\n if (existsSync(outputFilePath)) {\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n } else if (skipIfModifiedBefore || skipIfModifiedAfter) {\n // Log if we intended to check modification time but couldn't because the file doesn't exist\n appLogger(\n `${colorize('!', ANSIColors.YELLOW)} File ${formatPath(outputFilePath)} does not exist, skipping modification date check.`\n );\n }\n\n let changedLines: number[] | undefined;\n // FIXED: Enable git optimization that was previously commented out\n if (gitOptions) {\n const gitChangedLines = await listGitLines(\n absoluteBaseFilePath,\n gitOptions\n );\n\n appLogger(`Git changed lines: ${gitChangedLines.join(', ')}`);\n changedLines = gitChangedLines;\n }\n\n await reviewFileBlockAware(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locale,\n baseLocale,\n aiOptions,\n configOptions,\n customInstructions,\n changedLines,\n aiClient,\n aiConfig\n );\n })\n );\n\n await parallelize(\n allTasks,\n (task) => task(),\n nbSimultaneousFileProcessed ?? 3\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"reviewDoc.mjs","names":[],"sources":["../../../src/reviewDoc/reviewDoc.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport type { AIOptions } from '@intlayer/api';\nimport {\n type ListGitFilesOptions,\n listGitFiles,\n listGitLines,\n logConfigDetails,\n} from '@intlayer/chokidar/cli';\nimport {\n formatLocale,\n formatPath,\n parallelize,\n} from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colorize,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport fg from 'fast-glob';\nimport { checkFileModifiedRange } from '../utils/checkFileModifiedRange';\nimport { getOutputFilePath } from '../utils/getOutputFilePath';\nimport { setupAI } from '../utils/setupAI';\nimport { reviewFileBlockAware } from './reviewDocBlockAware';\n\ntype ReviewDocOptions = {\n docPattern: string[];\n locales: Locale[];\n excludedGlobPattern: string[];\n baseLocale: Locale;\n aiOptions?: AIOptions;\n nbSimultaneousFileProcessed?: number;\n configOptions?: GetConfigurationOptions;\n customInstructions?: string;\n skipIfModifiedBefore?: number | string | Date;\n skipIfModifiedAfter?: number | string | Date;\n skipIfExists?: boolean;\n gitOptions?: ListGitFilesOptions;\n};\n\n/**\n * Main audit function: scans all .md files in \"en/\" (unless you specified DOC_LIST),\n * then audits them to each locale in LOCALE_LIST.\n */\nexport const reviewDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed,\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n}: ReviewDocOptions) => {\n const configuration = getConfiguration(configOptions);\n logConfigDetails(configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n const aiResult = await setupAI(configuration, aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig } = aiResult;\n\n if (nbSimultaneousFileProcessed && nbSimultaneousFileProcessed > 10) {\n appLogger(\n `Warning: nbSimultaneousFileProcessed is set to ${nbSimultaneousFileProcessed}, which is greater than 10. Setting it to 10.`\n );\n nbSimultaneousFileProcessed = 10; // Limit the number of simultaneous file processed to 10\n }\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n // OAuth handled by API proxy internally\n\n appLogger(`Base locale is ${formatLocale(baseLocale)}`);\n appLogger(\n `Reviewing ${colorizeNumber(locales.length)} locales: [ ${formatLocale(locales)} ]`\n );\n\n appLogger(`Reviewing ${colorizeNumber(docList.length)} files:`);\n appLogger(docList.map((path) => ` - ${formatPath(path)}\\n`));\n\n // Create all tasks to be processed\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n appLogger(\n `Reviewing file: ${formatPath(docPath)} to ${formatLocale(locale)}`\n );\n\n const absoluteBaseFilePath = join(configuration.system.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip if file exists and skipIfExists option is enabled\n if (skipIfExists && existsSync(outputFilePath)) {\n const relativePath = relative(\n configuration.system.baseDir,\n outputFilePath\n );\n appLogger(\n `${colorize('⊘', ANSIColors.YELLOW)} File ${formatPath(relativePath)} already exists, skipping.`\n );\n return;\n }\n\n // Check modification range only if the file exists\n if (existsSync(outputFilePath)) {\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n } else if (skipIfModifiedBefore || skipIfModifiedAfter) {\n // Log if we intended to check modification time but couldn't because the file doesn't exist\n appLogger(\n `${colorize('!', ANSIColors.YELLOW)} File ${formatPath(outputFilePath)} does not exist, skipping modification date check.`\n );\n }\n\n let changedLines: number[] | undefined;\n // FIXED: Enable git optimization that was previously commented out\n if (gitOptions) {\n const gitChangedLines = await listGitLines(\n absoluteBaseFilePath,\n gitOptions\n );\n\n appLogger(`Git changed lines: ${gitChangedLines.join(', ')}`);\n changedLines = gitChangedLines;\n }\n\n await reviewFileBlockAware(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locale,\n baseLocale,\n aiOptions,\n configOptions,\n customInstructions,\n changedLines,\n aiClient,\n aiConfig\n );\n })\n );\n\n await parallelize(\n allTasks,\n (task) => task(),\n nbSimultaneousFileProcessed ?? 3\n );\n};\n"],"mappings":"2uBAkDA,MAAa,EAAY,MAAO,CAC9B,aACA,UACA,sBACA,aACA,YACA,8BACA,gBACA,qBACA,uBACA,sBACA,eACA,gBACsB,CACtB,IAAM,EAAgB,EAAiB,EAAc,CACrD,EAAiB,EAAc,CAE/B,IAAM,EAAY,EAAa,EAAc,CAEvC,EAAW,MAAM,EAAQ,EAAe,EAAU,CAExD,GAAI,CAAC,GAAU,YAAa,OAE5B,GAAM,CAAE,WAAU,YAAa,EAE3B,GAA+B,EAA8B,KAC/D,EACE,kDAAkD,EAA4B,+CAC/E,CACD,EAA8B,IAGhC,IAAI,EAAoB,MAAM,EAAG,EAAY,CAC3C,OAAQ,EACT,CAAC,CAEF,GAAI,EAAY,CACd,IAAM,EAAkB,MAAM,EAAa,EAAW,CAElD,IAIF,EAAU,EAAQ,OAAQ,GACxB,EAAgB,KAAM,GAAY,EAAK,QAAQ,KAAK,CAAE,EAAK,GAAK,EAAQ,CACzE,EAML,EAAU,kBAAkB,EAAa,EAAW,GAAG,CACvD,EACE,aAAa,EAAe,EAAQ,OAAO,CAAC,cAAc,EAAa,EAAQ,CAAC,IACjF,CAED,EAAU,aAAa,EAAe,EAAQ,OAAO,CAAC,SAAS,CAC/D,EAAU,EAAQ,IAAK,GAAS,MAAM,EAAW,EAAK,CAAC,IAAI,CAAC,CAyE5D,MAAM,EAtEW,EAAQ,QAAS,GAChC,EAAQ,IAAK,GAAW,SAAY,CAClC,EACE,mBAAmB,EAAW,EAAQ,CAAC,MAAM,EAAa,EAAO,GAClE,CAED,IAAM,EAAuB,EAAK,EAAc,OAAO,QAAS,EAAQ,CAClE,EAAiB,EACrB,EACA,EACA,EACD,CAGD,GAAI,GAAgB,EAAW,EAAe,CAAE,CAC9C,IAAM,EAAe,EACnB,EAAc,OAAO,QACrB,EACD,CACD,EACE,GAAG,EAAS,IAAK,EAAW,OAAO,CAAC,QAAQ,EAAW,EAAa,CAAC,4BACtE,CACD,OAIF,GAAI,EAAW,EAAe,CAAE,CAC9B,IAAM,EAAuB,EAAuB,EAAgB,CAClE,uBACA,sBACD,CAAC,CAEF,GAAI,EAAqB,UAAW,CAClC,EAAU,EAAqB,QAAQ,CACvC,cAEO,GAAwB,IAEjC,EACE,GAAG,EAAS,IAAK,EAAW,OAAO,CAAC,QAAQ,EAAW,EAAe,CAAC,oDACxE,CAGH,IAAI,EAEJ,GAAI,EAAY,CACd,IAAM,EAAkB,MAAM,EAC5B,EACA,EACD,CAED,EAAU,sBAAsB,EAAgB,KAAK,KAAK,GAAG,CAC7D,EAAe,EAGjB,MAAM,EACJ,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACD,EACD,CACH,CAIE,GAAS,GAAM,CAChB,GAA+B,EAChC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"../_utils_asset-B187VPMw.mjs";import{sanitizeChunk as t,validateTranslation as n}from"../translateDoc/validation.mjs";import{mergeReviewedSegments as r}from"../translation-alignment/rebuildDocument.mjs";import{buildAlignmentPlan as i}from"../translation-alignment/pipeline.mjs";import{chunkInference as a}from"../utils/chunkInference.mjs";import{fixChunkStartEndChars as o}from"../utils/fixChunkStartEndChars.mjs";import{mkdirSync as s,writeFileSync as c}from"node:fs";import{dirname as l}from"node:path";import{formatLocale as u,formatPath as d}from"@intlayer/chokidar/utils";import{ANSIColors as f,colon as p,colorize as m,colorizeNumber as h,getAppLogger as g}from"@intlayer/config/logger";import{getConfiguration as _}from"@intlayer/config/node";import{retryManager as v}from"@intlayer/config/utils";import{readFile as y}from"node:fs/promises";import{getLocaleName as b}from"@intlayer/core/localization";import{ENGLISH as x}from"@intlayer/types/locales";const S=async(S,C,w,T,E,D,O,k,A,j)=>{let M=_(D),N=g(M),P=await y(S,`utf-8`),F=await y(C,`utf-8`).catch(()=>``),I=e(`./prompts/REVIEW_PROMPT.md`,`utf-8`).replaceAll(`{{localeName}}`,`${u(w,!1)}`).replaceAll(`{{baseLocaleName}}`,`${u(T,!1)}`).replace(`{{applicationContext}}`,E?.applicationContext??`-`).replace(`{{customInstructions}}`,O??`-`),L=[p(`${f.GREY_DARK}[${d(S)}${f.GREY_DARK}] `,{colSize:40}),`→ ${f.RESET}`].join(``),R=[p(`${f.GREY_DARK}[${d(S)}${f.GREY_DARK}][${u(w)}${f.GREY_DARK}] `,{colSize:40}),`→ ${f.RESET}`].join(``),{englishBlocks:z,frenchBlocks:B,plan:V,segmentsToReview:H}=i({englishText:P,frenchText:F,changedLines:k});if(N(`${L}Block-aware alignment complete. Total blocks: EN=${h(z.length)}, FR=${h(B.length)}`),N(`${L}Actions: reuse=${h(V.actions.filter(e=>e.kind===`reuse`).length)}, review=${h(V.actions.filter(e=>e.kind===`review`).length)}, new=${h(V.actions.filter(e=>e.kind===`insert_new`).length)}, delete=${h(V.actions.filter(e=>e.kind===`delete`).length)}`),H.length===0){N(`${L}No segments need review, reusing existing translation`),s(l(C),{recursive:!0}),c(C,r(V,B,new Map)),N(`${m(`✔`,f.GREEN)} File ${d(C)} updated successfully (no changes needed).`);return}N(`${L}Segments to review: ${h(H.length)}`);let U=new Map;for(let e of H){let r=H.indexOf(e)+1,i=e.englishBlock,s=()=>`**BLOCK ${r} of ${H.length}** is the base block in ${u(T,!1)} as reference.\n///chunksStart///\n`+i.content+`///chunksEnd///`,c=()=>`**BLOCK ${r} of ${H.length}** is the current block to review in ${u(w,!1)}.\n///chunksStart///\n`+(e.frenchBlockText??``)+`///chunksEnd///`,l=await v(async()=>{let e=await a([{role:`system`,content:I},{role:`system`,content:s()},{role:`system`,content:c()},{role:`system`,content:`The next user message will be the **BLOCK ${h(r)} of ${h(H.length)}** that should be translated in ${b(w,x)} (${w}).`},{role:`user`,content:i.content}],E,M,A,j);N(`${R}${h(e.tokenUsed)} tokens used - Block ${h(r)} of ${h(H.length)}`);let l=t(e?.fileContent,i.content);if(l=o(l,i.content),!n(i.content,l,N))throw Error(`Validation failed for chunk (structure or length mismatch). Retrying...`);return l})();U.set(e.actionIndex,l)}let W=r(V,B,U);s(l(C),{recursive:!0}),c(C,W),N(`${m(`✔`,f.GREEN)} File ${d(C)} created/updated successfully.`)};export{S as reviewFileBlockAware};
|
|
2
2
|
//# sourceMappingURL=reviewDocBlockAware.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewDocBlockAware.mjs","names":[],"sources":["../../../src/reviewDoc/reviewDocBlockAware.ts"],"sourcesContent":["import { mkdirSync, writeFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { dirname } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport type { AIConfig } from '@intlayer/ai';\nimport type { AIOptions } from '@intlayer/api';\nimport { formatLocale, formatPath } from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { retryManager } from '@intlayer/config/utils';\nimport { getLocaleName } from '@intlayer/core/localization';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport
|
|
1
|
+
{"version":3,"file":"reviewDocBlockAware.mjs","names":[],"sources":["../../../src/reviewDoc/reviewDocBlockAware.ts"],"sourcesContent":["import { mkdirSync, writeFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { dirname } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport type { AIConfig } from '@intlayer/ai';\nimport type { AIOptions } from '@intlayer/api';\nimport { formatLocale, formatPath } from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { retryManager } from '@intlayer/config/utils';\nimport { getLocaleName } from '@intlayer/core/localization';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { ENGLISH } from '@intlayer/types/locales';\nimport { sanitizeChunk, validateTranslation } from '../translateDoc/validation';\nimport {\n buildAlignmentPlan,\n mergeReviewedSegments,\n} from '../translation-alignment/pipeline';\nimport { chunkInference } from '../utils/chunkInference';\nimport { fixChunkStartEndChars } from '../utils/fixChunkStartEndChars';\nimport type { AIClient } from '../utils/setupAI';\n\n/**\n * Review a file using block-aware alignment.\n * This approach:\n * 1. Segments both English and French documents into semantic blocks\n * 2. Aligns blocks using structure (special chars, numbers) and context\n * 3. Detects which blocks changed, were added, or deleted\n * 4. Only sends changed/new blocks to AI for translation\n * 5. Handles reordering automatically\n */\nexport const reviewFileBlockAware = async (\n baseFilePath: string,\n outputFilePath: string,\n locale: Locale,\n baseLocale: Locale,\n aiOptions?: AIOptions,\n configOptions?: GetConfigurationOptions,\n customInstructions?: string,\n changedLines?: number[],\n aiClient?: AIClient,\n aiConfig?: AIConfig\n) => {\n const configuration = getConfiguration(configOptions);\n const applicationLogger = getAppLogger(configuration);\n\n const englishText = await readFile(baseFilePath, 'utf-8');\n const frenchText = await readFile(outputFilePath, 'utf-8').catch(() => '');\n\n const basePrompt = readAsset('./prompts/REVIEW_PROMPT.md', 'utf-8')\n .replaceAll('{{localeName}}', `${formatLocale(locale, false)}`)\n .replaceAll('{{baseLocaleName}}', `${formatLocale(baseLocale, false)}`)\n .replace('{{applicationContext}}', aiOptions?.applicationContext ?? '-')\n .replace('{{customInstructions}}', customInstructions ?? '-');\n\n const filePrefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}] `;\n const filePrefix = [\n colon(filePrefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n const prefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}][${formatLocale(locale)}${ANSIColors.GREY_DARK}] `;\n const prefix = [\n colon(prefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n\n // Build block-aware alignment and plan\n const { englishBlocks, frenchBlocks, plan, segmentsToReview } =\n buildAlignmentPlan({\n englishText,\n frenchText,\n changedLines,\n });\n\n applicationLogger(\n `${filePrefix}Block-aware alignment complete. Total blocks: EN=${colorizeNumber(englishBlocks.length)}, FR=${colorizeNumber(frenchBlocks.length)}`\n );\n applicationLogger(\n `${filePrefix}Actions: reuse=${colorizeNumber(plan.actions.filter((a) => a.kind === 'reuse').length)}, review=${colorizeNumber(plan.actions.filter((a) => a.kind === 'review').length)}, new=${colorizeNumber(plan.actions.filter((a) => a.kind === 'insert_new').length)}, delete=${colorizeNumber(plan.actions.filter((a) => a.kind === 'delete').length)}`\n );\n\n if (segmentsToReview.length === 0) {\n applicationLogger(\n `${filePrefix}No segments need review, reusing existing translation`\n );\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(\n outputFilePath,\n mergeReviewedSegments(plan, frenchBlocks, new Map())\n );\n applicationLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(outputFilePath)} updated successfully (no changes needed).`\n );\n return;\n }\n\n applicationLogger(\n `${filePrefix}Segments to review: ${colorizeNumber(segmentsToReview.length)}`\n );\n\n // Review segments that need AI translation\n const reviewedSegmentsMap = new Map<number, string>();\n\n for (const segment of segmentsToReview) {\n const segmentNumber = segmentsToReview.indexOf(segment) + 1;\n const englishBlock = segment.englishBlock;\n\n const getBaseChunkContextPrompt = () =>\n `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the base block in ${formatLocale(baseLocale, false)} as reference.\\n` +\n `///chunksStart///\\n` +\n englishBlock.content +\n `///chunksEnd///`;\n\n const getFrenchChunkPrompt = () =>\n `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the current block to review in ${formatLocale(locale, false)}.\\n` +\n `///chunksStart///\\n` +\n (segment.frenchBlockText ?? '') +\n `///chunksEnd///`;\n\n const reviewedChunkResult = await retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n { role: 'system', content: getBaseChunkContextPrompt() },\n { role: 'system', content: getFrenchChunkPrompt() },\n {\n role: 'system',\n content: `The next user message will be the **BLOCK ${colorizeNumber(segmentNumber)} of ${colorizeNumber(segmentsToReview.length)}** that should be translated in ${getLocaleName(locale, ENGLISH)} (${locale}).`,\n },\n { role: 'user', content: englishBlock.content },\n ],\n aiOptions,\n configuration,\n aiClient,\n aiConfig\n );\n\n applicationLogger(\n `${prefix}${colorizeNumber(result.tokenUsed)} tokens used - Block ${colorizeNumber(segmentNumber)} of ${colorizeNumber(segmentsToReview.length)}`\n );\n\n // Sanitize artifacts (e.g. Markdown code block wrappers)\n let processedChunk = sanitizeChunk(\n result?.fileContent,\n englishBlock.content\n );\n\n // Fix start/end characters\n processedChunk = fixChunkStartEndChars(\n processedChunk,\n englishBlock.content\n );\n\n // Validate Translation (YAML, Code fences, Length ratio)\n const isValid = validateTranslation(\n englishBlock.content,\n processedChunk,\n applicationLogger\n );\n\n if (!isValid) {\n throw new Error(\n 'Validation failed for chunk (structure or length mismatch). Retrying...'\n );\n }\n\n return processedChunk;\n })();\n\n reviewedSegmentsMap.set(segment.actionIndex, reviewedChunkResult);\n }\n\n // Merge reviewed segments back into final document\n const finalFrenchOutput = mergeReviewedSegments(\n plan,\n frenchBlocks,\n reviewedSegmentsMap\n );\n\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, finalFrenchOutput);\n\n applicationLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(outputFilePath)} created/updated successfully.`\n );\n};\n"],"mappings":"i9BAwCA,MAAa,EAAuB,MAClC,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,IACG,CACH,IAAM,EAAgB,EAAiB,EAAc,CAC/C,EAAoB,EAAa,EAAc,CAE/C,EAAc,MAAM,EAAS,EAAc,QAAQ,CACnD,EAAa,MAAM,EAAS,EAAgB,QAAQ,CAAC,UAAY,GAAG,CAEpE,EAAa,EAAU,6BAA8B,QAAQ,CAChE,WAAW,iBAAkB,GAAG,EAAa,EAAQ,GAAM,GAAG,CAC9D,WAAW,qBAAsB,GAAG,EAAa,EAAY,GAAM,GAAG,CACtE,QAAQ,yBAA0B,GAAW,oBAAsB,IAAI,CACvE,QAAQ,yBAA0B,GAAsB,IAAI,CAGzD,EAAa,CACjB,EAFqB,GAAG,EAAW,UAAU,GAAG,EAAW,EAAa,GAAG,EAAW,UAAU,IAE1E,CAAE,QAAS,GAAI,CAAC,CACtC,KAAK,EAAW,QACjB,CAAC,KAAK,GAAG,CAEJ,EAAS,CACb,EAFiB,GAAG,EAAW,UAAU,GAAG,EAAW,EAAa,GAAG,EAAW,UAAU,IAAI,EAAa,EAAO,GAAG,EAAW,UAAU,IAE1H,CAAE,QAAS,GAAI,CAAC,CAClC,KAAK,EAAW,QACjB,CAAC,KAAK,GAAG,CAGJ,CAAE,gBAAe,eAAc,OAAM,oBACzC,EAAmB,CACjB,cACA,aACA,eACD,CAAC,CASJ,GAPA,EACE,GAAG,EAAW,mDAAmD,EAAe,EAAc,OAAO,CA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AAM,EAAe,EAAiB,OAAO,CAAC,kCAAkC,EAAc,EAAQ,EAAQ,CAAC,IAAI,EAAO,IAC/M,CACD,CAAE,KAAM,OAAQ,QAAS,EAAa,QAAS,CAChD,CACD,EACA,EACA,EACA,EACD,CAED,EACE,GAAG,IAAS,EAAe,EAAO,UAAU,CAAC,uBAAuB,EAAe,EAAc,CAAC,MAAM,EAAe,EAAiB,OAAO,GAChJ,CAGD,IAAI,EAAiB,EACnB,GAAQ,YACR,EAAa,QACd,CAeD,GAZA,EAAiB,EACf,EACA,EAAa,QACd,CASG,CANY,EACd,EAAa,QACb,EACA,EACD,CAGC,MAAU,MACR,0EACD,CAGH,OAAO,GACP,EAAE,CAEJ,EAAoB,IAAI,EAAQ,YAAa,EAAoB,CAInE,IAAM,EAAoB,EACxB,EACA,EACA,EACD,CAED,EAAU,EAAQ,EAAe,CAAE,CAAE,UAAW,GAAM,CAAC,CACvD,EAAc,EAAgB,EAAkB,CAEhD,EACE,GAAG,EAAS,IAAK,EAAW,MAAM,CAAC,QAAQ,EAAW,EAAe,CAAC,gCACvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sanitizeChunk as e,validateTranslation as t}from"./validation.mjs";import{translateFile as n}from"./translateFile.mjs";import{translateDoc as r}from"./translateDoc.mjs";export{e as sanitizeChunk,r as translateDoc,n as translateFile,t as validateTranslation};
|
|
1
|
+
import"../_utils_asset-B187VPMw.mjs";import{sanitizeChunk as e,validateTranslation as t}from"./validation.mjs";import{translateFile as n}from"./translateFile.mjs";import{translateDoc as r}from"./translateDoc.mjs";import"./types.mjs";export{e as sanitizeChunk,r as translateDoc,n as translateFile,t as validateTranslation};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{setupAI as e}from"../utils/setupAI.mjs";import{checkFileModifiedRange as t}from"../utils/checkFileModifiedRange.mjs";import{getOutputFilePath as n}from"../utils/getOutputFilePath.mjs";import{translateFile as r}from"./translateFile.mjs";import{existsSync as i,mkdirSync as a,writeFileSync as o}from"node:fs";import{dirname as s,join as c}from"node:path";import{listGitFiles as l,logConfigDetails as u}from"@intlayer/chokidar/cli";import{pLimit as d,parallelize as f}from"@intlayer/chokidar/utils";import{ANSIColors as p,colorize as m,colorizeNumber as h,getAppLogger as g}from"@intlayer/config/logger";import{getConfiguration as _}from"@intlayer/config/node";import v from"fast-glob";import{performance as y}from"node:perf_hooks";const b=async({docPattern:b,locales:x,excludedGlobPattern:S,baseLocale:C,aiOptions:w,nbSimultaneousFileProcessed:T=20,configOptions:E,customInstructions:D,skipIfModifiedBefore:O,skipIfModifiedAfter:k,skipIfExists:A,gitOptions:j,flushStrategy:M=`incremental`})=>{let N=_(E);u(E);let P=g(N),F=T,I=d(F),L=await v(b,{ignore:S}),R=await e(N,w);if(!R?.hasAIAccess)return;let{aiClient:z,aiConfig:B}=R;if(j){let e=await l(j);e&&(L=L.filter(t=>e.some(e=>c(process.cwd(),t)===e)))}let V=y.now();P(`Translating ${h(L.length)} files to ${h(x.length)} locales. \nGlobal Concurrency: ${h(F)} chunks in parallel.`);let H={count:0,maxErrors:5,shouldStop:!1};await f(L.flatMap(e=>x.map(l=>async()=>{if(H.shouldStop)return;let u=c(N.system.baseDir,e),d=n(u,l,C);if(A&&i(d))return;M===`incremental`&&!i(d)&&(a(s(d),{recursive:!0}),o(d,``));let f=t(d,{skipIfModifiedBefore:O,skipIfModifiedAfter:k});if(f.isSkipped){P(f.message);return}await r({baseFilePath:u,outputFilePath:d,locale:l,baseLocale:C,configuration:N,errorState:H,aiOptions:w,customInstructions:D,aiClient:z,aiConfig:B,flushStrategy:M,limit:I})})),e=>e(),50);let U=((y.now()-V)/1e3).toFixed(2);H.count>0?P(`Finished with ${H.count} errors in ${U}s.`):P(`${m(`✔`,p.GREEN)} Batch completed successfully in ${h(U)}s.`)};export{b as translateDoc};
|
|
1
|
+
import{setupAI as e}from"../utils/setupAI.mjs";import{checkFileModifiedRange as t}from"../utils/checkFileModifiedRange.mjs";import{getOutputFilePath as n}from"../utils/getOutputFilePath.mjs";import"../_utils_asset-B187VPMw.mjs";import{translateFile as r}from"./translateFile.mjs";import{existsSync as i,mkdirSync as a,writeFileSync as o}from"node:fs";import{dirname as s,join as c}from"node:path";import{listGitFiles as l,logConfigDetails as u}from"@intlayer/chokidar/cli";import{pLimit as d,parallelize as f}from"@intlayer/chokidar/utils";import{ANSIColors as p,colorize as m,colorizeNumber as h,getAppLogger as g}from"@intlayer/config/logger";import{getConfiguration as _}from"@intlayer/config/node";import v from"fast-glob";import{performance as y}from"node:perf_hooks";const b=async({docPattern:b,locales:x,excludedGlobPattern:S,baseLocale:C,aiOptions:w,nbSimultaneousFileProcessed:T=20,configOptions:E,customInstructions:D,skipIfModifiedBefore:O,skipIfModifiedAfter:k,skipIfExists:A,gitOptions:j,flushStrategy:M=`incremental`})=>{let N=_(E);u(E);let P=g(N),F=T,I=d(F),L=await v(b,{ignore:S}),R=await e(N,w);if(!R?.hasAIAccess)return;let{aiClient:z,aiConfig:B}=R;if(j){let e=await l(j);e&&(L=L.filter(t=>e.some(e=>c(process.cwd(),t)===e)))}let V=y.now();P(`Translating ${h(L.length)} files to ${h(x.length)} locales. \nGlobal Concurrency: ${h(F)} chunks in parallel.`);let H={count:0,maxErrors:5,shouldStop:!1};await f(L.flatMap(e=>x.map(l=>async()=>{if(H.shouldStop)return;let u=c(N.system.baseDir,e),d=n(u,l,C);if(A&&i(d))return;M===`incremental`&&!i(d)&&(a(s(d),{recursive:!0}),o(d,``));let f=t(d,{skipIfModifiedBefore:O,skipIfModifiedAfter:k});if(f.isSkipped){P(f.message);return}await r({baseFilePath:u,outputFilePath:d,locale:l,baseLocale:C,configuration:N,errorState:H,aiOptions:w,customInstructions:D,aiClient:z,aiConfig:B,flushStrategy:M,limit:I})})),e=>e(),50);let U=((y.now()-V)/1e3).toFixed(2);H.count>0?P(`Finished with ${H.count} errors in ${U}s.`):P(`${m(`✔`,p.GREEN)} Batch completed successfully in ${h(U)}s.`)};export{b as translateDoc};
|
|
2
2
|
//# sourceMappingURL=translateDoc.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translateDoc.mjs","names":[],"sources":["../../../src/translateDoc/translateDoc.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { performance } from 'node:perf_hooks';\nimport { listGitFiles, logConfigDetails } from '@intlayer/chokidar/cli';\nimport { parallelize, pLimit } from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colorize,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport fg from 'fast-glob';\nimport { checkFileModifiedRange } from '../utils/checkFileModifiedRange';\nimport { getOutputFilePath } from '../utils/getOutputFilePath';\nimport { setupAI } from '../utils/setupAI';\nimport { translateFile } from './translateFile';\nimport type { ErrorState, TranslateDocOptions } from './types';\n\nexport const translateDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed = 20, // Default to a higher concurrency for chunks\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n flushStrategy = 'incremental',\n}: TranslateDocOptions) => {\n const configuration = getConfiguration(configOptions);\n logConfigDetails(configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n // 1. GLOBAL QUEUE SETUP\n // We use pLimit to create a single bottleneck for AI requests.\n // This queue is shared across all files and locales.\n const maxConcurrentChunks = nbSimultaneousFileProcessed;\n const globalChunkLimiter = pLimit(maxConcurrentChunks);\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n const aiResult = await setupAI(configuration, aiOptions);\n if (!aiResult?.hasAIAccess) return;\n const { aiClient, aiConfig } = aiResult;\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n if (gitChangedFiles) {\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n const batchStartTime = performance.now();\n\n appLogger(\n `Translating ${colorizeNumber(docList.length)} files to ${colorizeNumber(locales.length)} locales. \\n` +\n `Global Concurrency: ${colorizeNumber(maxConcurrentChunks)} chunks in parallel.`\n );\n\n const errorState: ErrorState = {\n count: 0,\n maxErrors: 5,\n shouldStop: false,\n };\n\n // 2. FLATTENED TASK LIST\n // We create a task for every File x Locale combination.\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n if (errorState.shouldStop) return;\n\n const absoluteBaseFilePath = join(configuration.system.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip logic\n if (skipIfExists && existsSync(outputFilePath)) return;\n\n if (flushStrategy === 'incremental' && !existsSync(outputFilePath)) {\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, '');\n }\n\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n\n // Execute translation using the SHARED limiter\n await translateFile({\n baseFilePath: absoluteBaseFilePath,\n outputFilePath,\n locale: locale as Locale,\n baseLocale,\n configuration,\n errorState,\n aiOptions,\n customInstructions,\n aiClient,\n aiConfig,\n flushStrategy,\n limit: globalChunkLimiter, // Pass the global queue\n });\n })\n );\n\n // 3. HIGH-THROUGHPUT FILE OPENER\n // We open many files simultaneously (e.g., 50) to ensure the global chunk queue\n // is always saturated with work.\n // If we open too few files, the chunk queue might drain faster than we can read new files.\n const FILE_OPEN_LIMIT = 50;\n\n await parallelize(allTasks, (task) => task(), FILE_OPEN_LIMIT);\n\n const batchEndTime = performance.now();\n const batchDuration = ((batchEndTime - batchStartTime) / 1000).toFixed(2);\n\n if (errorState.count > 0) {\n appLogger(`Finished with ${errorState.count} errors in ${batchDuration}s.`);\n } else {\n appLogger(\n `${colorize('✔', ANSIColors.GREEN)} Batch completed successfully in ${colorizeNumber(batchDuration)}s.`\n );\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"translateDoc.mjs","names":[],"sources":["../../../src/translateDoc/translateDoc.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { performance } from 'node:perf_hooks';\nimport { listGitFiles, logConfigDetails } from '@intlayer/chokidar/cli';\nimport { parallelize, pLimit } from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colorize,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport fg from 'fast-glob';\nimport { checkFileModifiedRange } from '../utils/checkFileModifiedRange';\nimport { getOutputFilePath } from '../utils/getOutputFilePath';\nimport { setupAI } from '../utils/setupAI';\nimport { translateFile } from './translateFile';\nimport type { ErrorState, TranslateDocOptions } from './types';\n\nexport const translateDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed = 20, // Default to a higher concurrency for chunks\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n flushStrategy = 'incremental',\n}: TranslateDocOptions) => {\n const configuration = getConfiguration(configOptions);\n logConfigDetails(configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n // 1. GLOBAL QUEUE SETUP\n // We use pLimit to create a single bottleneck for AI requests.\n // This queue is shared across all files and locales.\n const maxConcurrentChunks = nbSimultaneousFileProcessed;\n const globalChunkLimiter = pLimit(maxConcurrentChunks);\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n const aiResult = await setupAI(configuration, aiOptions);\n if (!aiResult?.hasAIAccess) return;\n const { aiClient, aiConfig } = aiResult;\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n if (gitChangedFiles) {\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n const batchStartTime = performance.now();\n\n appLogger(\n `Translating ${colorizeNumber(docList.length)} files to ${colorizeNumber(locales.length)} locales. \\n` +\n `Global Concurrency: ${colorizeNumber(maxConcurrentChunks)} chunks in parallel.`\n );\n\n const errorState: ErrorState = {\n count: 0,\n maxErrors: 5,\n shouldStop: false,\n };\n\n // 2. FLATTENED TASK LIST\n // We create a task for every File x Locale combination.\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n if (errorState.shouldStop) return;\n\n const absoluteBaseFilePath = join(configuration.system.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip logic\n if (skipIfExists && existsSync(outputFilePath)) return;\n\n if (flushStrategy === 'incremental' && !existsSync(outputFilePath)) {\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, '');\n }\n\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n\n // Execute translation using the SHARED limiter\n await translateFile({\n baseFilePath: absoluteBaseFilePath,\n outputFilePath,\n locale: locale as Locale,\n baseLocale,\n configuration,\n errorState,\n aiOptions,\n customInstructions,\n aiClient,\n aiConfig,\n flushStrategy,\n limit: globalChunkLimiter, // Pass the global queue\n });\n })\n );\n\n // 3. HIGH-THROUGHPUT FILE OPENER\n // We open many files simultaneously (e.g., 50) to ensure the global chunk queue\n // is always saturated with work.\n // If we open too few files, the chunk queue might drain faster than we can read new files.\n const FILE_OPEN_LIMIT = 50;\n\n await parallelize(allTasks, (task) => task(), FILE_OPEN_LIMIT);\n\n const batchEndTime = performance.now();\n const batchDuration = ((batchEndTime - batchStartTime) / 1000).toFixed(2);\n\n if (errorState.count > 0) {\n appLogger(`Finished with ${errorState.count} errors in ${batchDuration}s.`);\n } else {\n appLogger(\n `${colorize('✔', ANSIColors.GREEN)} Batch completed successfully in ${colorizeNumber(batchDuration)}s.`\n );\n }\n};\n"],"mappings":"qwBAoBA,MAAa,EAAe,MAAO,CACjC,aACA,UACA,sBACA,aACA,YACA,8BAA8B,GAC9B,gBACA,qBACA,uBACA,sBACA,eACA,aACA,gBAAgB,iBACS,CACzB,IAAM,EAAgB,EAAiB,EAAc,CACrD,EAAiB,EAAc,CAE/B,IAAM,EAAY,EAAa,EAAc,CAKvC,EAAsB,EACtB,EAAqB,EAAO,EAAoB,CAElD,EAAoB,MAAM,EAAG,EAAY,CAC3C,OAAQ,EACT,CAAC,CAEI,EAAW,MAAM,EAAQ,EAAe,EAAU,CACxD,GAAI,CAAC,GAAU,YAAa,OAC5B,GAAM,CAAE,WAAU,YAAa,EAE/B,GAAI,EAAY,CACd,IAAM,EAAkB,MAAM,EAAa,EAAW,CAClD,IACF,EAAU,EAAQ,OAAQ,GACxB,EAAgB,KAAM,GAAY,EAAK,QAAQ,KAAK,CAAE,EAAK,GAAK,EAAQ,CACzE,EAIL,IAAM,EAAiB,EAAY,KAAK,CAExC,EACE,eAAe,EAAe,EAAQ,OAAO,CAAC,YAAY,EAAe,EAAQ,OAAO,CAAC,kCAChE,EAAe,EAAoB,CAAC,sBAC9D,CAED,IAAM,EAAyB,CAC7B,MAAO,EACP,UAAW,EACX,WAAY,GACb,CAyDD,MAAM,EArDW,EAAQ,QAAS,GAChC,EAAQ,IAAK,GAAW,SAAY,CAClC,GAAI,EAAW,WAAY,OAE3B,IAAM,EAAuB,EAAK,EAAc,OAAO,QAAS,EAAQ,CAClE,EAAiB,EACrB,EACA,EACA,EACD,CAGD,GAAI,GAAgB,EAAW,EAAe,CAAE,OAE5C,IAAkB,eAAiB,CAAC,EAAW,EAAe,GAChE,EAAU,EAAQ,EAAe,CAAE,CAAE,UAAW,GAAM,CAAC,CACvD,EAAc,EAAgB,GAAG,EAGnC,IAAM,EAAuB,EAAuB,EAAgB,CAClE,uBACA,sBACD,CAAC,CAEF,GAAI,EAAqB,UAAW,CAClC,EAAU,EAAqB,QAAQ,CACvC,OAIF,MAAM,EAAc,CAClB,aAAc,EACd,iBACQ,SACR,aACA,gBACA,aACA,YACA,qBACA,WACA,WACA,gBACA,MAAO,EACR,CAAC,EACF,CACH,CAQ4B,GAAS,GAAM,CAFpB,GAEsC,CAG9D,IAAM,IADe,EAAY,KAAK,CACC,GAAkB,KAAM,QAAQ,EAAE,CAErE,EAAW,MAAQ,EACrB,EAAU,iBAAiB,EAAW,MAAM,aAAa,EAAc,IAAI,CAE3E,EACE,GAAG,EAAS,IAAK,EAAW,MAAM,CAAC,mCAAmC,EAAe,EAAc,CAAC,IACrG"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"../_utils_asset-B187VPMw.mjs";import{sanitizeChunk as t,validateTranslation as n}from"./validation.mjs";import{chunkInference as r}from"../utils/chunkInference.mjs";import{fixChunkStartEndChars as i}from"../utils/fixChunkStartEndChars.mjs";import{chunkText as a}from"../utils/calculateChunks.mjs";import{mkdirSync as o,writeFileSync as s}from"node:fs";import{dirname as c,relative as l}from"node:path";import{formatLocale as u,formatPath as d}from"@intlayer/chokidar/utils";import{ANSIColors as f,colon as p,colorize as m,colorizeNumber as h,getAppLogger as g}from"@intlayer/config/logger";import{retryManager as _}from"@intlayer/config/utils";import{readFile as v}from"node:fs/promises";import{performance as y}from"node:perf_hooks";const b=async({baseFilePath:b,outputFilePath:x,locale:S,baseLocale:C,configuration:w,errorState:T,aiOptions:E,customInstructions:D,aiClient:O,aiConfig:k,flushStrategy:A=`incremental`,onChunkReceive:j,limit:M})=>{if(T.shouldStop)return null;let N=g(w,{config:{prefix:``}}),P=y.now();try{let F=a(await v(b,`utf-8`)),I=F.length,L=`${p(`${f.GREY_DARK}[${d(b)}${f.GREY_DARK}] `,{colSize:40})}${f.RESET}`,R=`${p(`${f.GREY_DARK}[${d(b)}${f.GREY_DARK}][${u(S)}${f.GREY_DARK}] `,{colSize:40})}${f.RESET}`;N(`${L}Split into ${h(I)} chunks. Queuing...`);let z=e(`./prompts/TRANSLATE_PROMPT.md`,`utf-8`).replaceAll(`{{localeName}}`,`${u(S,!1)}`).replaceAll(`{{baseLocaleName}}`,`${u(C,!1)}`).replace(`{{applicationContext}}`,E?.applicationContext??`-`).replace(`{{customInstructions}}`,D??`-`),B=Array(I).fill(``),V=M??(e=>e()),H=F.map((e,a)=>V(async()=>{if(T.shouldStop)return null;let l=g(w,{config:{prefix:`${R} ${f.GREY_DARK}[${a+1}/${I}] ${f.RESET}`}}),u=y.now(),d=a===0,p=e.content,m=()=>">>> CONTEXT: PREVIOUS SOURCE CONTENT <<<\n```\n"+(F[a-1]?.content??``)+"\n```\n>>> END PREVIOUS CONTEXT <<<",v=()=>">>> CONTEXT: NEXT CONTENT <<<\n```\n"+(F[a+1]?.content??``)+"\n```\n>>> END NEXT CONTEXT <<<";l(`Process started`);let{content:b,tokens:S}=await _(async()=>{let e=await r([{role:`system`,content:z},...F[a+1]?[{role:`system`,content:v()}]:[],...d?[]:[{role:`system`,content:m()}],{role:`system`,content:[`You are translating TARGET CHUNK (${a+1}/${I}).`,`Translate ONLY the target chunk. Preserve frontmatter/code exactly.`].join(`
|
|
2
2
|
`)},{role:`user`,content:`>>> TARGET CHUNK START <<<\n${p}\n>>> TARGET CHUNK END <<<`}],E,w,O,k),o=t(e?.fileContent,p);if(o=i(o,p),!n(p,o,l))throw Error(`Validation failed for chunk ${a+1}/${I}`);return{content:o,tokens:e.tokenUsed}})(),C=(y.now()-u).toFixed(0);if(B[a]=b,j&&j(b,a,I),A===`incremental`&&B.slice(0,a+1).every(e=>e&&e!==``)){let e=0;for(;e<I&&B[e]&&B[e]!==``;)e++;let t=B.slice(0,e).join(``);o(c(x),{recursive:!0}),s(x,t)}l([`${h(S)} tokens used `,`${f.GREY_DARK}in ${h(C)}ms${f.RESET}`].join(``))}));await Promise.all(H);let U=B.join(``);(A===`end`||A===`incremental`)&&(o(c(x),{recursive:!0}),s(x,U));let W=((y.now()-P)/1e3).toFixed(2),G=l(w.system.baseDir,x);return N(`${m(`✔`,f.GREEN)} File ${d(G)} completed in ${h(W)}s.`),U}catch(e){T.count++;let t=e?.message??JSON.stringify(e);return N(`${m(`✖`,f.RED)} Error: ${t}`),T.count>=T.maxErrors&&(T.shouldStop=!0),null}};export{b as translateFile};
|
|
3
3
|
//# sourceMappingURL=translateFile.mjs.map
|