gt 2.26.12 → 2.27.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/CHANGELOG.md +39 -0
- package/dist/auth/cliApiKey.d.ts +7 -0
- package/dist/auth/cliApiKey.js +18 -0
- package/dist/auth/cliApiKey.js.map +1 -0
- package/dist/cli/base.d.ts +1 -1
- package/dist/cli/base.js +60 -16
- package/dist/cli/base.js.map +1 -1
- package/dist/cli/commands/api.js +2 -1
- package/dist/cli/commands/api.js.map +1 -1
- package/dist/cli/commands/utils/validation.js +1 -1
- package/dist/cli/commands/utils/validation.js.map +1 -1
- package/dist/config/generateSettings.js +2 -1
- package/dist/config/generateSettings.js.map +1 -1
- package/dist/console/index.d.ts +1 -1
- package/dist/console/index.js +7 -1
- package/dist/console/index.js.map +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/generated/version.js.map +1 -1
- package/dist/setup/buildTools/index.d.ts +2 -0
- package/dist/setup/buildTools/index.js +11 -1
- package/dist/setup/buildTools/index.js.map +1 -1
- package/dist/setup/buildTools/vite.js +2 -1
- package/dist/setup/buildTools/vite.js.map +1 -1
- package/dist/setup/detectFramework.d.ts +5 -4
- package/dist/setup/detectFramework.js +7 -2
- package/dist/setup/detectFramework.js.map +1 -1
- package/dist/setup/developmentCredentials.js +1 -1
- package/dist/setup/instructions/base.md +1 -1
- package/dist/setup/instructions/gt-next.md +1 -1
- package/dist/setup/instructions/gt-react.md +1 -1
- package/dist/setup/nextSteps.d.ts +31 -0
- package/dist/setup/nextSteps.js +46 -0
- package/dist/setup/nextSteps.js.map +1 -0
- package/dist/setup/onboarding.d.ts +3 -0
- package/dist/setup/onboarding.js +3 -2
- package/dist/setup/onboarding.js.map +1 -1
- package/dist/setup/setupTarget.d.ts +2 -0
- package/dist/setup/setupTarget.js +10 -1
- package/dist/setup/setupTarget.js.map +1 -1
- package/dist/setup/wizard.d.ts +1 -1
- package/dist/setup/wizard.js +6 -8
- package/dist/setup/wizard.js.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/api.d.ts +21 -0
- package/dist/utils/constants.d.ts +4 -1
- package/dist/utils/constants.js +5 -2
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/credentials.d.ts +3 -2
- package/dist/utils/credentials.js +18 -10
- package/dist/utils/credentials.js.map +1 -1
- package/dist/utils/loadEnv.d.ts +2 -0
- package/dist/utils/loadEnv.js +9 -1
- package/dist/utils/loadEnv.js.map +1 -1
- package/dist/workflows/stage.js +2 -1
- package/dist/workflows/stage.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateSettings.js","names":[],"sources":["../../src/config/generateSettings.ts"],"sourcesContent":["import {\n displayProjectId,\n exitSync,\n logErrorAndExit,\n warnApiKeyInConfig,\n warnDeprecatedField,\n} from '../console/logging.js';\nimport { loadConfig, withJsonExtension } from '../fs/config/loadConfig.js';\nimport { FilesOptions, Settings } from '../types/index.js';\nimport { libraryDefaultLocale } from 'generaltranslation/internal';\nimport { resolveFiles } from '../fs/config/parseFilesConfig.js';\nimport { validateSettings } from './validateSettings.js';\nimport {\n DEFAULT_GIT_REMOTE_NAME,\n GT_DASHBOARD_URL,\n} from '../utils/constants.js';\nimport { resolveProjectId } from '../fs/utils.js';\nimport { createUserTokenProvider } from '../auth/oauth.js';\nimport crypto from 'node:crypto';\nimport { execSync } from 'node:child_process';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport chalk from 'chalk';\nimport { resolveConfig } from './resolveConfig.js';\nimport { configureApiClient } from '../utils/api.js';\nimport { resolveApiBaseUrl } from '../utils/apiBaseUrl.js';\nimport { generatePreset } from './optionPresets.js';\nimport { GT_PARSING_FLAGS_DEFAULT } from './defaults.js';\nimport { normalizeFilesOptions } from '../formats/files/transformFormat.js';\nimport { logger } from '../console/logger.js';\n\nexport const DEFAULT_SRC_PATTERNS = [\n 'src/**/*.{js,jsx,ts,tsx}',\n 'app/**/*.{js,jsx,ts,tsx}',\n 'pages/**/*.{js,jsx,ts,tsx}',\n 'components/**/*.{js,jsx,ts,tsx}',\n];\n\nexport const DEFAULT_PYTHON_SRC_PATTERNS = ['**/*.py'];\nexport const DEFAULT_PYTHON_SRC_EXCLUDES = [\n 'venv/**',\n '.venv/**',\n '__pycache__/**',\n '**/migrations/**',\n '**/tests/**',\n '**/test_*.py',\n '**/*_test.py',\n];\n\ntype GenerateSettingsInput = Partial<Omit<Settings, 'tag'>> & {\n config?: string;\n projectId?: string;\n locales?: string[];\n options?: Settings['options'];\n files?: unknown;\n publish?: boolean;\n omitConfigIds?: boolean;\n saveLocal?: boolean;\n tag?: string | boolean;\n message?: string;\n branch?: string;\n enableBranching?: boolean;\n disableBranchDetection?: boolean;\n remoteName?: string;\n experimentalLocalizeStaticImports?: boolean;\n experimentalLocalizeStaticUrls?: boolean;\n experimentalLocalizeRelativeAssets?: boolean;\n experimentalHideDefaultLocale?: boolean;\n experimentalFlattenJsonFiles?: boolean;\n experimentalClearLocaleDirs?: boolean;\n clearLocaleDirsExclude?: string[];\n [key: string]: unknown;\n};\n\nfunction hasConfiguredTranslationFiles(files: unknown): boolean {\n if (!files || typeof files !== 'object' || Array.isArray(files)) {\n return false;\n }\n return Object.keys(files).some((key) => key !== 'gt');\n}\n\n/**\n * Generates settings from any\n * @param flags - The CLI flags to generate settings from\n * @param cwd - The current working directory\n * @param options - Additional options\n * @param options.requireConfig - If true, exit with an error when no config file is found\n * @param options.resolvedConfig - Config content to validate instead of the file, e.g. what setup is about to write\n * @returns The generated settings\n */\nexport async function generateSettings(\n flags: GenerateSettingsInput,\n cwd: string = process.cwd(),\n options?: {\n requireConfig?: boolean;\n resolvedConfig?: Record<string, unknown>;\n }\n): Promise<Settings> {\n // Load config file\n let gtConfig: GenerateSettingsInput = {};\n\n if (flags.config) {\n flags.config = withJsonExtension(flags.config);\n }\n if (options?.resolvedConfig) {\n gtConfig = options.resolvedConfig as GenerateSettingsInput;\n } else if (flags.config) {\n gtConfig = loadConfig(flags.config);\n } else {\n const config = resolveConfig(cwd);\n if (config) {\n gtConfig = config.config as GenerateSettingsInput;\n flags.config = config.path;\n } else {\n if (options?.requireConfig) {\n return logErrorAndExit(\n 'No gt.config.json file was found. Run `npx gt init` to create one, pass --config, or run this command from your project root.'\n );\n }\n gtConfig = {};\n }\n }\n\n // Warn if apiKey is present in gt.config.json\n if (gtConfig.apiKey) {\n warnApiKeyInConfig(flags.config ?? 'gt.config.json');\n exitSync(1);\n }\n const projectIdEnv = resolveProjectId();\n // Resolve mismatched projectIds\n if (\n gtConfig.projectId &&\n flags.projectId &&\n gtConfig.projectId !== flags.projectId\n ) {\n logErrorAndExit(\n `Project ID mismatch: gt.config.json uses ${chalk.green(gtConfig.projectId)}, but the CLI flag uses ${chalk.green(flags.projectId)}. Use the same projectId in all configs.`\n );\n } else if (\n gtConfig.projectId &&\n projectIdEnv &&\n gtConfig.projectId !== projectIdEnv\n ) {\n logErrorAndExit(\n `Project ID mismatch: gt.config.json uses ${chalk.green(gtConfig.projectId)}, but GT_PROJECT_ID uses ${chalk.green(projectIdEnv)}. Use the same projectId in all configs.`\n );\n }\n\n const docsUrlPatterns = flags.options?.docsUrlPattern;\n if (\n docsUrlPatterns &&\n (Array.isArray(docsUrlPatterns) ? docsUrlPatterns : [docsUrlPatterns]).some(\n (pattern) => !pattern.includes('[locale]')\n )\n ) {\n logErrorAndExit(\n 'Static URLs could not be localized because the URL pattern is missing \"[locale]\". Add \"[locale]\" where the locale should appear in the generated URL.'\n );\n }\n\n if (\n flags.options?.docsImportPattern &&\n !flags.options?.docsImportPattern.includes('[locale]')\n ) {\n logErrorAndExit(\n 'Static imports could not be localized because the import pattern is missing \"[locale]\". Add \"[locale]\" where the locale should appear in the generated import path.'\n );\n }\n\n if (flags.options?.copyFiles) {\n for (const file of flags.options.copyFiles) {\n if (!file.includes('[locale]')) {\n logErrorAndExit(\n 'Files could not be copied because the file path is missing \"[locale]\". Add \"[locale]\" where the locale should appear in the copied path.'\n );\n }\n }\n }\n\n // Warn on deprecated includeSourceCodeContext\n const configuredFiles = gtConfig.files as FilesOptions | undefined;\n if (configuredFiles?.gt?.includeSourceCodeContext != null) {\n warnDeprecatedField(\n 'files.gt.includeSourceCodeContext',\n 'files.gt.parsingFlags.includeSourceCodeContext'\n );\n }\n\n // merge options\n const mergedOptions: Settings = { ...gtConfig, ...flags } as Settings;\n\n if (\n !hasConfiguredTranslationFiles(mergedOptions.files) &&\n !['package.json', 'pyproject.toml', 'requirements.txt', 'setup.py'].some(\n (file) => fs.existsSync(path.join(cwd, file))\n )\n ) {\n logger.warn(\n chalk.yellow(\n 'No package.json or Python project file found in the current directory. Run this command from the root of your project.'\n )\n );\n }\n\n // Add defaultLocale if not provided\n mergedOptions.defaultLocale =\n mergedOptions.defaultLocale || libraryDefaultLocale;\n\n // merge locales\n mergedOptions.locales = Array.from(\n new Set([...(gtConfig.locales || []), ...(flags.locales || [])])\n );\n // Separate defaultLocale from locales\n mergedOptions.locales = mergedOptions.locales.filter(\n (locale) => locale !== mergedOptions.defaultLocale\n );\n\n // Add projectId if not provided\n mergedOptions.projectId = mergedOptions.projectId || resolveProjectId();\n\n mergedOptions.baseUrl = resolveApiBaseUrl(mergedOptions.baseUrl);\n\n // The API client prefers apiKey when both are set; the provider is lazy.\n mergedOptions.apiKey = mergedOptions.apiKey || process.env.GT_API_KEY;\n mergedOptions.userTokenProvider = createUserTokenProvider({\n baseUrl: mergedOptions.baseUrl,\n });\n\n // Add dashboardUrl if not provided\n mergedOptions.dashboardUrl = mergedOptions.dashboardUrl || GT_DASHBOARD_URL;\n\n // Add locales if not provided\n mergedOptions.locales = mergedOptions.locales || [];\n\n // Only set config path if one was actually found or explicitly provided.\n // Do not default to a phantom path — that would cause downstream writes\n // (e.g. updateConfig) to silently create a config file.\n if (!mergedOptions.config) {\n mergedOptions.config = '';\n }\n\n // Display projectId if present\n if (mergedOptions.projectId) {\n displayProjectId(mergedOptions.projectId);\n }\n\n // Add stageTranslations if not provided\n // For human review, always stage the project\n mergedOptions.stageTranslations = mergedOptions.stageTranslations ?? false;\n\n // Top-level default for whether translated files require approval before use.\n // Effective policy is hash-changing, so reject anything but a real boolean.\n if (\n mergedOptions.requiresReview !== undefined &&\n typeof mergedOptions.requiresReview !== 'boolean'\n ) {\n logErrorAndExit(\n 'requiresReview in gt.config.json must be a boolean. Use files.<type>.requiresReview for glob-scoped overrides.'\n );\n }\n mergedOptions.requiresReview = mergedOptions.requiresReview ?? false;\n\n // Add publish — only set if explicitly configured or passed via flag.\n // When neither is set, leave undefined so the publish step knows\n // there is no global publish intent.\n if (flags.publish) {\n mergedOptions.publish = true;\n } else if (gtConfig.publish !== undefined) {\n mergedOptions.publish = gtConfig.publish;\n } else {\n mergedOptions.publish = undefined;\n }\n\n mergedOptions.omitConfigIds =\n flags.omitConfigIds === true || gtConfig.omitConfigIds === true;\n\n // Don't default src here — each pipeline (JS/Python) has its own defaults.\n // Only set src if the user explicitly provided it via flags or config.\n\n // Resolve all glob patterns in the files object\n const compositePatterns = Object.entries(\n mergedOptions.options?.jsonSchema || {}\n )\n .filter(([, schema]) => schema.composite)\n .map(([key]) => key);\n mergedOptions.files = mergedOptions.files\n ? resolveFiles(\n normalizeFilesOptions(mergedOptions.files as FilesOptions),\n mergedOptions.defaultLocale,\n mergedOptions.locales,\n cwd,\n compositePatterns,\n mergedOptions.requiresReview\n )\n : {\n resolvedPaths: {},\n placeholderPaths: {},\n transformPaths: {},\n transformFormats: {},\n publishPaths: new Set<string>(),\n unpublishPaths: new Set<string>(),\n requiresReviewPaths: new Set<string>(),\n parsingFlags: {},\n gtJson: {\n parsingFlags: GT_PARSING_FLAGS_DEFAULT,\n },\n };\n\n mergedOptions.options = {\n ...mergedOptions.options,\n mintlify: {\n ...mergedOptions.options?.mintlify,\n inferTitleFromFilename:\n gtConfig.options?.mintlify?.inferTitleFromFilename ||\n mergedOptions.options?.mintlify?.inferTitleFromFilename,\n },\n experimentalLocalizeStaticImports:\n gtConfig.options?.experimentalLocalizeStaticImports ||\n flags.experimentalLocalizeStaticImports,\n experimentalLocalizeStaticUrls:\n gtConfig.options?.experimentalLocalizeStaticUrls ||\n flags.experimentalLocalizeStaticUrls,\n experimentalLocalizeRelativeAssets:\n gtConfig.options?.experimentalLocalizeRelativeAssets ||\n flags.experimentalLocalizeRelativeAssets,\n experimentalHideDefaultLocale:\n gtConfig.options?.experimentalHideDefaultLocale ||\n flags.experimentalHideDefaultLocale,\n experimentalFlattenJsonFiles:\n gtConfig.options?.experimentalFlattenJsonFiles ||\n flags.experimentalFlattenJsonFiles,\n experimentalClearLocaleDirs:\n gtConfig.options?.experimentalClearLocaleDirs ||\n flags.experimentalClearLocaleDirs,\n clearLocaleDirsExclude:\n gtConfig.options?.clearLocaleDirsExclude || flags.clearLocaleDirsExclude,\n saveLocal: flags.saveLocal ?? gtConfig.options?.saveLocal ?? false,\n };\n\n if (\n mergedOptions.omitConfigIds &&\n (mergedOptions.publish === true ||\n mergedOptions.files.gtJson.publish === true)\n ) {\n logger.warn(\n chalk.yellow(\n 'Config IDs will be omitted even though CDN publishing is enabled. Remote cache/CDN consumers may load the latest available translations instead of a pinned version.'\n )\n );\n }\n\n // Add additional options if provided\n if (mergedOptions.options) {\n if (mergedOptions.options.jsonSchema) {\n for (const fileGlob of Object.keys(mergedOptions.options.jsonSchema)) {\n const jsonSchema = mergedOptions.options.jsonSchema[fileGlob];\n if (jsonSchema.preset) {\n mergedOptions.options.jsonSchema[fileGlob] = {\n ...generatePreset(jsonSchema.preset, 'json'),\n ...jsonSchema,\n };\n }\n }\n }\n if (mergedOptions.options.yamlSchema) {\n for (const fileGlob of Object.keys(mergedOptions.options.yamlSchema)) {\n const yamlSchema = mergedOptions.options.yamlSchema[fileGlob];\n if (yamlSchema.preset) {\n mergedOptions.options.yamlSchema[fileGlob] = {\n ...generatePreset(yamlSchema.preset, 'yaml'),\n ...yamlSchema,\n };\n }\n }\n }\n }\n\n // Add parsing options if not provided\n mergedOptions.parsingOptions = mergedOptions.parsingOptions || {};\n mergedOptions.parsingOptions.conditionNames = mergedOptions.parsingOptions\n .conditionNames || [\n 'development',\n 'browser',\n 'module',\n 'import',\n 'require',\n 'default',\n ];\n\n // Add branch options if not provided\n const branchOptions = mergedOptions.branchOptions || {};\n // If --branch is set, enable branching\n branchOptions.enabled =\n flags.enableBranching ??\n gtConfig.branchOptions?.enabled ??\n (flags.branch ? true : false);\n branchOptions.currentBranch =\n flags.branch ?? gtConfig.branchOptions?.currentBranch ?? undefined;\n branchOptions.autoDetectBranches = flags.disableBranchDetection\n ? false\n : (gtConfig.branchOptions?.autoDetectBranches ?? true);\n branchOptions.remoteName =\n flags.remoteName ??\n gtConfig.branchOptions?.remoteName ??\n DEFAULT_GIT_REMOTE_NAME;\n mergedOptions.branchOptions = branchOptions;\n\n // Map -m/--message flag to tagMessage\n if (flags.message) {\n mergedOptions.tagMessage = flags.message;\n }\n\n // Resolve tag:\n // --tag (bare) or -m without --tag: try git SHA, fall back to random hex\n // --tag <value>: use as-is\n // No flags: no tag\n if (flags.tag === true || (!flags.tag && mergedOptions.tagMessage)) {\n try {\n mergedOptions.tag = execSync('git rev-parse --short HEAD', {\n encoding: 'utf-8',\n }).trim();\n // If no message provided, use git commit message\n if (!mergedOptions.tagMessage) {\n mergedOptions.tagMessage = execSync('git log -1 --format=%s', {\n encoding: 'utf-8',\n }).trim();\n }\n } catch {\n // Not in a git repo or git unavailable — fall back to random hex\n mergedOptions.tag = crypto.randomBytes(4).toString('hex');\n }\n }\n\n mergedOptions.configDirectory = path.join(cwd, '.gt');\n\n validateSettings(mergedOptions);\n\n configureApiClient({\n projectId: mergedOptions.projectId,\n apiKey: mergedOptions.apiKey,\n userTokenProvider: mergedOptions.userTokenProvider,\n baseUrl: mergedOptions.baseUrl,\n customMapping: mergedOptions.customMapping,\n });\n\n return mergedOptions;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;A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,oBAAmB;EACjB,WAAW,cAAc;EACzB,QAAQ,cAAc;EACtB,mBAAmB,cAAc;EACjC,SAAS,cAAc;EACvB,eAAe,cAAc;EAC9B,CAAC;AAEF,QAAO"}
|
|
1
|
+
{"version":3,"file":"generateSettings.js","names":[],"sources":["../../src/config/generateSettings.ts"],"sourcesContent":["import {\n displayProjectId,\n exitSync,\n logErrorAndExit,\n warnApiKeyInConfig,\n warnDeprecatedField,\n} from '../console/logging.js';\nimport { loadConfig, withJsonExtension } from '../fs/config/loadConfig.js';\nimport { FilesOptions, Settings } from '../types/index.js';\nimport { libraryDefaultLocale } from 'generaltranslation/internal';\nimport { resolveFiles } from '../fs/config/parseFilesConfig.js';\nimport { validateSettings } from './validateSettings.js';\nimport {\n DEFAULT_GIT_REMOTE_NAME,\n GT_DASHBOARD_URL,\n} from '../utils/constants.js';\nimport { resolveProjectId } from '../fs/utils.js';\nimport { createUserTokenProvider } from '../auth/oauth.js';\nimport { resolveCliApiKey } from '../auth/cliApiKey.js';\nimport crypto from 'node:crypto';\nimport { execSync } from 'node:child_process';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport chalk from 'chalk';\nimport { resolveConfig } from './resolveConfig.js';\nimport { configureApiClient } from '../utils/api.js';\nimport { resolveApiBaseUrl } from '../utils/apiBaseUrl.js';\nimport { generatePreset } from './optionPresets.js';\nimport { GT_PARSING_FLAGS_DEFAULT } from './defaults.js';\nimport { normalizeFilesOptions } from '../formats/files/transformFormat.js';\nimport { logger } from '../console/logger.js';\n\nexport const DEFAULT_SRC_PATTERNS = [\n 'src/**/*.{js,jsx,ts,tsx}',\n 'app/**/*.{js,jsx,ts,tsx}',\n 'pages/**/*.{js,jsx,ts,tsx}',\n 'components/**/*.{js,jsx,ts,tsx}',\n];\n\nexport const DEFAULT_PYTHON_SRC_PATTERNS = ['**/*.py'];\nexport const DEFAULT_PYTHON_SRC_EXCLUDES = [\n 'venv/**',\n '.venv/**',\n '__pycache__/**',\n '**/migrations/**',\n '**/tests/**',\n '**/test_*.py',\n '**/*_test.py',\n];\n\ntype GenerateSettingsInput = Partial<Omit<Settings, 'tag'>> & {\n config?: string;\n projectId?: string;\n locales?: string[];\n options?: Settings['options'];\n files?: unknown;\n publish?: boolean;\n omitConfigIds?: boolean;\n saveLocal?: boolean;\n tag?: string | boolean;\n message?: string;\n branch?: string;\n enableBranching?: boolean;\n disableBranchDetection?: boolean;\n remoteName?: string;\n experimentalLocalizeStaticImports?: boolean;\n experimentalLocalizeStaticUrls?: boolean;\n experimentalLocalizeRelativeAssets?: boolean;\n experimentalHideDefaultLocale?: boolean;\n experimentalFlattenJsonFiles?: boolean;\n experimentalClearLocaleDirs?: boolean;\n clearLocaleDirsExclude?: string[];\n [key: string]: unknown;\n};\n\nfunction hasConfiguredTranslationFiles(files: unknown): boolean {\n if (!files || typeof files !== 'object' || Array.isArray(files)) {\n return false;\n }\n return Object.keys(files).some((key) => key !== 'gt');\n}\n\n/**\n * Generates settings from any\n * @param flags - The CLI flags to generate settings from\n * @param cwd - The current working directory\n * @param options - Additional options\n * @param options.requireConfig - If true, exit with an error when no config file is found\n * @param options.resolvedConfig - Config content to validate instead of the file, e.g. what setup is about to write\n * @returns The generated settings\n */\nexport async function generateSettings(\n flags: GenerateSettingsInput,\n cwd: string = process.cwd(),\n options?: {\n requireConfig?: boolean;\n resolvedConfig?: Record<string, unknown>;\n }\n): Promise<Settings> {\n // Load config file\n let gtConfig: GenerateSettingsInput = {};\n\n if (flags.config) {\n flags.config = withJsonExtension(flags.config);\n }\n if (options?.resolvedConfig) {\n gtConfig = options.resolvedConfig as GenerateSettingsInput;\n } else if (flags.config) {\n gtConfig = loadConfig(flags.config);\n } else {\n const config = resolveConfig(cwd);\n if (config) {\n gtConfig = config.config as GenerateSettingsInput;\n flags.config = config.path;\n } else {\n if (options?.requireConfig) {\n return logErrorAndExit(\n 'No gt.config.json file was found. Run `npx gt init` to create one, pass --config, or run this command from your project root.'\n );\n }\n gtConfig = {};\n }\n }\n\n // Warn if apiKey is present in gt.config.json\n if (gtConfig.apiKey) {\n warnApiKeyInConfig(flags.config ?? 'gt.config.json');\n exitSync(1);\n }\n const projectIdEnv = resolveProjectId();\n // Resolve mismatched projectIds\n if (\n gtConfig.projectId &&\n flags.projectId &&\n gtConfig.projectId !== flags.projectId\n ) {\n logErrorAndExit(\n `Project ID mismatch: gt.config.json uses ${chalk.green(gtConfig.projectId)}, but the CLI flag uses ${chalk.green(flags.projectId)}. Use the same projectId in all configs.`\n );\n } else if (\n gtConfig.projectId &&\n projectIdEnv &&\n gtConfig.projectId !== projectIdEnv\n ) {\n logErrorAndExit(\n `Project ID mismatch: gt.config.json uses ${chalk.green(gtConfig.projectId)}, but GT_PROJECT_ID uses ${chalk.green(projectIdEnv)}. Use the same projectId in all configs.`\n );\n }\n\n const docsUrlPatterns = flags.options?.docsUrlPattern;\n if (\n docsUrlPatterns &&\n (Array.isArray(docsUrlPatterns) ? docsUrlPatterns : [docsUrlPatterns]).some(\n (pattern) => !pattern.includes('[locale]')\n )\n ) {\n logErrorAndExit(\n 'Static URLs could not be localized because the URL pattern is missing \"[locale]\". Add \"[locale]\" where the locale should appear in the generated URL.'\n );\n }\n\n if (\n flags.options?.docsImportPattern &&\n !flags.options?.docsImportPattern.includes('[locale]')\n ) {\n logErrorAndExit(\n 'Static imports could not be localized because the import pattern is missing \"[locale]\". Add \"[locale]\" where the locale should appear in the generated import path.'\n );\n }\n\n if (flags.options?.copyFiles) {\n for (const file of flags.options.copyFiles) {\n if (!file.includes('[locale]')) {\n logErrorAndExit(\n 'Files could not be copied because the file path is missing \"[locale]\". Add \"[locale]\" where the locale should appear in the copied path.'\n );\n }\n }\n }\n\n // Warn on deprecated includeSourceCodeContext\n const configuredFiles = gtConfig.files as FilesOptions | undefined;\n if (configuredFiles?.gt?.includeSourceCodeContext != null) {\n warnDeprecatedField(\n 'files.gt.includeSourceCodeContext',\n 'files.gt.parsingFlags.includeSourceCodeContext'\n );\n }\n\n // merge options\n const mergedOptions: Settings = { ...gtConfig, ...flags } as Settings;\n\n if (\n !hasConfiguredTranslationFiles(mergedOptions.files) &&\n !['package.json', 'pyproject.toml', 'requirements.txt', 'setup.py'].some(\n (file) => fs.existsSync(path.join(cwd, file))\n )\n ) {\n logger.warn(\n chalk.yellow(\n 'No package.json or Python project file found in the current directory. Run this command from the root of your project.'\n )\n );\n }\n\n // Add defaultLocale if not provided\n mergedOptions.defaultLocale =\n mergedOptions.defaultLocale || libraryDefaultLocale;\n\n // merge locales\n mergedOptions.locales = Array.from(\n new Set([...(gtConfig.locales || []), ...(flags.locales || [])])\n );\n // Separate defaultLocale from locales\n mergedOptions.locales = mergedOptions.locales.filter(\n (locale) => locale !== mergedOptions.defaultLocale\n );\n\n // Add projectId if not provided\n mergedOptions.projectId = mergedOptions.projectId || resolveProjectId();\n\n mergedOptions.baseUrl = resolveApiBaseUrl(mergedOptions.baseUrl);\n\n // The API client prefers apiKey when both are set; the provider is lazy.\n mergedOptions.apiKey =\n mergedOptions.apiKey || (await resolveCliApiKey(mergedOptions.baseUrl));\n mergedOptions.userTokenProvider = createUserTokenProvider({\n baseUrl: mergedOptions.baseUrl,\n });\n\n // Add dashboardUrl if not provided\n mergedOptions.dashboardUrl = mergedOptions.dashboardUrl || GT_DASHBOARD_URL;\n\n // Add locales if not provided\n mergedOptions.locales = mergedOptions.locales || [];\n\n // Only set config path if one was actually found or explicitly provided.\n // Do not default to a phantom path — that would cause downstream writes\n // (e.g. updateConfig) to silently create a config file.\n if (!mergedOptions.config) {\n mergedOptions.config = '';\n }\n\n // Display projectId if present\n if (mergedOptions.projectId) {\n displayProjectId(mergedOptions.projectId);\n }\n\n // Add stageTranslations if not provided\n // For human review, always stage the project\n mergedOptions.stageTranslations = mergedOptions.stageTranslations ?? false;\n\n // Top-level default for whether translated files require approval before use.\n // Effective policy is hash-changing, so reject anything but a real boolean.\n if (\n mergedOptions.requiresReview !== undefined &&\n typeof mergedOptions.requiresReview !== 'boolean'\n ) {\n logErrorAndExit(\n 'requiresReview in gt.config.json must be a boolean. Use files.<type>.requiresReview for glob-scoped overrides.'\n );\n }\n mergedOptions.requiresReview = mergedOptions.requiresReview ?? false;\n\n // Add publish — only set if explicitly configured or passed via flag.\n // When neither is set, leave undefined so the publish step knows\n // there is no global publish intent.\n if (flags.publish) {\n mergedOptions.publish = true;\n } else if (gtConfig.publish !== undefined) {\n mergedOptions.publish = gtConfig.publish;\n } else {\n mergedOptions.publish = undefined;\n }\n\n mergedOptions.omitConfigIds =\n flags.omitConfigIds === true || gtConfig.omitConfigIds === true;\n\n // Don't default src here — each pipeline (JS/Python) has its own defaults.\n // Only set src if the user explicitly provided it via flags or config.\n\n // Resolve all glob patterns in the files object\n const compositePatterns = Object.entries(\n mergedOptions.options?.jsonSchema || {}\n )\n .filter(([, schema]) => schema.composite)\n .map(([key]) => key);\n mergedOptions.files = mergedOptions.files\n ? resolveFiles(\n normalizeFilesOptions(mergedOptions.files as FilesOptions),\n mergedOptions.defaultLocale,\n mergedOptions.locales,\n cwd,\n compositePatterns,\n mergedOptions.requiresReview\n )\n : {\n resolvedPaths: {},\n placeholderPaths: {},\n transformPaths: {},\n transformFormats: {},\n publishPaths: new Set<string>(),\n unpublishPaths: new Set<string>(),\n requiresReviewPaths: new Set<string>(),\n parsingFlags: {},\n gtJson: {\n parsingFlags: GT_PARSING_FLAGS_DEFAULT,\n },\n };\n\n mergedOptions.options = {\n ...mergedOptions.options,\n mintlify: {\n ...mergedOptions.options?.mintlify,\n inferTitleFromFilename:\n gtConfig.options?.mintlify?.inferTitleFromFilename ||\n mergedOptions.options?.mintlify?.inferTitleFromFilename,\n },\n experimentalLocalizeStaticImports:\n gtConfig.options?.experimentalLocalizeStaticImports ||\n flags.experimentalLocalizeStaticImports,\n experimentalLocalizeStaticUrls:\n gtConfig.options?.experimentalLocalizeStaticUrls ||\n flags.experimentalLocalizeStaticUrls,\n experimentalLocalizeRelativeAssets:\n gtConfig.options?.experimentalLocalizeRelativeAssets ||\n flags.experimentalLocalizeRelativeAssets,\n experimentalHideDefaultLocale:\n gtConfig.options?.experimentalHideDefaultLocale ||\n flags.experimentalHideDefaultLocale,\n experimentalFlattenJsonFiles:\n gtConfig.options?.experimentalFlattenJsonFiles ||\n flags.experimentalFlattenJsonFiles,\n experimentalClearLocaleDirs:\n gtConfig.options?.experimentalClearLocaleDirs ||\n flags.experimentalClearLocaleDirs,\n clearLocaleDirsExclude:\n gtConfig.options?.clearLocaleDirsExclude || flags.clearLocaleDirsExclude,\n saveLocal: flags.saveLocal ?? gtConfig.options?.saveLocal ?? false,\n };\n\n if (\n mergedOptions.omitConfigIds &&\n (mergedOptions.publish === true ||\n mergedOptions.files.gtJson.publish === true)\n ) {\n logger.warn(\n chalk.yellow(\n 'Config IDs will be omitted even though CDN publishing is enabled. Remote cache/CDN consumers may load the latest available translations instead of a pinned version.'\n )\n );\n }\n\n // Add additional options if provided\n if (mergedOptions.options) {\n if (mergedOptions.options.jsonSchema) {\n for (const fileGlob of Object.keys(mergedOptions.options.jsonSchema)) {\n const jsonSchema = mergedOptions.options.jsonSchema[fileGlob];\n if (jsonSchema.preset) {\n mergedOptions.options.jsonSchema[fileGlob] = {\n ...generatePreset(jsonSchema.preset, 'json'),\n ...jsonSchema,\n };\n }\n }\n }\n if (mergedOptions.options.yamlSchema) {\n for (const fileGlob of Object.keys(mergedOptions.options.yamlSchema)) {\n const yamlSchema = mergedOptions.options.yamlSchema[fileGlob];\n if (yamlSchema.preset) {\n mergedOptions.options.yamlSchema[fileGlob] = {\n ...generatePreset(yamlSchema.preset, 'yaml'),\n ...yamlSchema,\n };\n }\n }\n }\n }\n\n // Add parsing options if not provided\n mergedOptions.parsingOptions = mergedOptions.parsingOptions || {};\n mergedOptions.parsingOptions.conditionNames = mergedOptions.parsingOptions\n .conditionNames || [\n 'development',\n 'browser',\n 'module',\n 'import',\n 'require',\n 'default',\n ];\n\n // Add branch options if not provided\n const branchOptions = mergedOptions.branchOptions || {};\n // If --branch is set, enable branching\n branchOptions.enabled =\n flags.enableBranching ??\n gtConfig.branchOptions?.enabled ??\n (flags.branch ? true : false);\n branchOptions.currentBranch =\n flags.branch ?? gtConfig.branchOptions?.currentBranch ?? undefined;\n branchOptions.autoDetectBranches = flags.disableBranchDetection\n ? false\n : (gtConfig.branchOptions?.autoDetectBranches ?? true);\n branchOptions.remoteName =\n flags.remoteName ??\n gtConfig.branchOptions?.remoteName ??\n DEFAULT_GIT_REMOTE_NAME;\n mergedOptions.branchOptions = branchOptions;\n\n // Map -m/--message flag to tagMessage\n if (flags.message) {\n mergedOptions.tagMessage = flags.message;\n }\n\n // Resolve tag:\n // --tag (bare) or -m without --tag: try git SHA, fall back to random hex\n // --tag <value>: use as-is\n // No flags: no tag\n if (flags.tag === true || (!flags.tag && mergedOptions.tagMessage)) {\n try {\n mergedOptions.tag = execSync('git rev-parse --short HEAD', {\n encoding: 'utf-8',\n }).trim();\n // If no message provided, use git commit message\n if (!mergedOptions.tagMessage) {\n mergedOptions.tagMessage = execSync('git log -1 --format=%s', {\n encoding: 'utf-8',\n }).trim();\n }\n } catch {\n // Not in a git repo or git unavailable — fall back to random hex\n mergedOptions.tag = crypto.randomBytes(4).toString('hex');\n }\n }\n\n mergedOptions.configDirectory = path.join(cwd, '.gt');\n\n validateSettings(mergedOptions);\n\n configureApiClient({\n projectId: mergedOptions.projectId,\n apiKey: mergedOptions.apiKey,\n userTokenProvider: mergedOptions.userTokenProvider,\n baseUrl: mergedOptions.baseUrl,\n customMapping: mergedOptions.customMapping,\n });\n\n return mergedOptions;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACD;AAED,MAAa,8BAA8B,CAAC,UAAU;AACtD,MAAa,8BAA8B;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AA2BD,SAAS,8BAA8B,OAAyB;AAC9D,KAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,MAAM,CAC7D,QAAO;AAET,QAA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K,cAAc,QAAQ,WAAW,EAAE;GACpE,MAAM,aAAa,cAAc,QAAQ,WAAW;AACpD,OAAI,WAAW,OACb,eAAc,QAAQ,WAAW,YAAY;IAC3C,GAAG,eAAe,WAAW,QAAQ,OAAO;IAC5C,GAAG;IACJ;;;AAOT,eAAc,iBAAiB,cAAc,kBAAkB,EAAE;AACjE,eAAc,eAAe,iBAAiB,cAAc,eACzD,kBAAkB;EACnB;EACA;EACA;EACA;EACA;EACA;EACD;CAGD,MAAM,gBAAgB,cAAc,iBAAiB,EAAE;AAEvD,eAAc,UACZ,MAAM,mBACN,SAAS,eAAe,YACvB,MAAM,SAAS,OAAO;AACzB,eAAc,gBACZ,MAAM,UAAU,SAAS,eAAe,iBAAiB,KAAA;AAC3D,eAAc,qBAAqB,MAAM,yBACrC,QACC,SAAS,eAAe,sBAAsB;AACnD,eAAc,aACZ,MAAM,cACN,SAAS,eAAe,cAAA;AAE1B,eAAc,gBAAgB;AAG9B,KAAI,MAAM,QACR,eAAc,aAAa,MAAM;AAOnC,KAAI,MAAM,QAAQ,QAAS,CAAC,MAAM,OAAO,cAAc,WACrD,KAAI;AACF,gBAAc,MAAM,SAAS,8BAA8B,EACzD,UAAU,SACX,CAAC,CAAC,MAAM;AAET,MAAI,CAAC,cAAc,WACjB,eAAc,aAAa,SAAS,0BAA0B,EAC5D,UAAU,SACX,CAAC,CAAC,MAAM;SAEL;AAEN,gBAAc,MAAM,OAAO,YAAY,EAAE,CAAC,SAAS,MAAM;;AAI7D,eAAc,kBAAkB,KAAK,KAAK,KAAK,MAAM;AAErD,kBAAiB,cAAc;AAE/B,oBAAmB;EACjB,WAAW,cAAc;EACzB,QAAQ,cAAc;EACtB,mBAAmB,cAAc;EACjC,SAAS,cAAc;EACvB,eAAe,cAAc;EAC9B,CAAC;AAEF,QAAO"}
|
package/dist/console/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare const noLocalesError = "No target locales were found. Add locales
|
|
|
37
37
|
export declare const noDefaultLocaleError = "No default locale was found. Add defaultLocale to gt.config.json or pass it with --default-locale.";
|
|
38
38
|
export declare const noFilesError = "The files configuration is missing or invalid. Check the files section in gt.config.json and try again.";
|
|
39
39
|
export declare const noSourceFileError = "No source translation file was found. Check your translations directory and default locale configuration.";
|
|
40
|
-
export declare const noProjectIdError
|
|
40
|
+
export declare const noProjectIdError: (dashboardUrl: string) => string;
|
|
41
41
|
export declare const noVersionIdError = "No version ID was found. Pass --version-id or add _versionId to gt.config.json.";
|
|
42
42
|
export declare const invalidConfigurationError = "The files configuration cannot be used for this operation. Provide a valid download configuration or set --publish true to upload translations to the CDN.";
|
|
43
43
|
export declare const lottieTranslateError = "Lottie translations are processed asynchronously, so the translate command cannot complete them in one run. Use the stage and download flow instead:\n 1. Stage the files for translation: npx gt stage\n 2. Fetch the finished translations: npx gt download\nTranslations that are still processing are skipped, so re-run npx gt download until all of them have been downloaded.";
|
package/dist/console/index.js
CHANGED
|
@@ -50,7 +50,13 @@ const noLocalesError = `No target locales were found. Add locales to gt.config.j
|
|
|
50
50
|
const noDefaultLocaleError = `No default locale was found. Add defaultLocale to gt.config.json or pass it with --default-locale.`;
|
|
51
51
|
const noFilesError = `The files configuration is missing or invalid. Check the files section in gt.config.json and try again.`;
|
|
52
52
|
const noSourceFileError = `No source translation file was found. Check your translations directory and default locale configuration.`;
|
|
53
|
-
const noProjectIdError =
|
|
53
|
+
const noProjectIdError = (dashboardUrl) => createDiagnosticMessage({
|
|
54
|
+
source: "gt",
|
|
55
|
+
severity: "Error",
|
|
56
|
+
whatHappened: "No project ID was found",
|
|
57
|
+
fix: "Pass --project-id, add projectId to gt.config.json, or set the GT_PROJECT_ID environment variable",
|
|
58
|
+
wayOut: `Find your project ID, or create a project, in the dashboard (${dashboardUrl})`
|
|
59
|
+
});
|
|
54
60
|
const noVersionIdError = `No version ID was found. Pass --version-id or add _versionId to gt.config.json.`;
|
|
55
61
|
const invalidConfigurationError = `The files configuration cannot be used for this operation. Provide a valid download configuration or set --publish true to upload translations to the CDN.`;
|
|
56
62
|
const lottieTranslateError = `Lottie translations are processed asynchronously, so the translate command cannot complete them in one run. Use the stage and download flow instead:\n 1. Stage the files for translation: npx gt stage\n 2. Fetch the finished translations: npx gt download\nTranslations that are still processing are skipped, so re-run npx gt download until all of them have been downloaded.`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/console/index.ts"],"sourcesContent":["import { createDiagnosticMessage } from 'generaltranslation/diagnostics';\nimport { BRANCH_COMPONENT } from '../react/jsx/utils/constants.js';\nimport {\n colorizeFilepath,\n colorizeComponent,\n colorizeIdString,\n colorizeContent,\n colorizeLine,\n colorizeFunctionName,\n} from './colors.js';\nimport { formatCodeClamp } from './formatting.js';\n\nconst withWillErrorInNextVersion = (message: string): string =>\n `${message} (This will become an error in the next major version of the CLI.)`;\n\n// Derive function related errors\nconst withDeriveComponentError = (message: string): string =>\n `<Derive> rules violation: ${message}`;\n\nconst withDeriveFunctionError = (message: string): string =>\n `derive() rules violation: ${message}`;\n// Synchronous wrappers for backward compatibility\nexport const warnApiKeyInConfigSync = (optionsFilepath: string): string =>\n `${colorizeFilepath(\n optionsFilepath\n )}: Your API key is exposed! Remove it from the file and include it as an environment variable.`;\n\nexport const warnVariablePropSync = (\n file: string,\n attrName: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `${colorizeComponent('<T>')} component has dynamic attribute ${colorizeIdString(attrName)} with value: ${colorizeContent(\n value\n )}. Change ${colorizeIdString(attrName)} to ensure this content is translated.`,\n location\n );\n\nexport const warnInvalidReturnSync = (\n file: string,\n functionName: string,\n expression: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveComponentError(\n `Function ${colorizeFunctionName(functionName)} does not return a derivable (statically analyzable) expression. ${colorizeFunctionName(functionName)} must return either (1) a derivable string literal, (2) another derivable function invocation, (3) derivable JSX content, or (4) a ternary expression. Instead got:\\n${colorizeContent(expression)}`\n ),\n location\n );\n\n// TODO: this is temporary until we handle implicit returns\nexport const warnMissingReturnSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Function ${colorizeFunctionName(functionName)} is wrapped in ${colorizeComponent('<Derive>')} tags but does not have an explicit return statement. Derivable functions must have an explicit return statement.`,\n location\n );\n\nexport const warnHasUnwrappedExpressionSync = (\n file: string,\n unwrappedExpressions: string[],\n id?: string,\n location?: string\n): string =>\n withLocation(\n file,\n `${colorizeComponent('<T>')} component${\n id ? ` with id ${colorizeIdString(id)}` : ''\n } has children that could change at runtime. Use a variable component like ${colorizeComponent(\n '<Var>'\n )} to ensure this content is translated.\\n${colorizeContent(\n unwrappedExpressions.join('\\n')\n )}`,\n location\n );\n\nexport const warnFailedToConstructJsxTreeSync = (\n file: string,\n code: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Failed to construct JsxTree! Call expression is not a valid createElement call: ${colorizeContent(code)}`,\n location\n );\n\nexport const warnNestedTComponent = (file: string, location?: string): string =>\n withLocation(\n file,\n `Found nested <T> component. <T> components cannot be directly nested.`,\n location\n );\n\nexport const warnNestedInternalTComponent = (\n file: string,\n location?: string\n): string =>\n withLocation(\n file,\n `DEBUG: Found nested <GtInternalTranslateJsx> component. <GtInternalTranslateJsx> components cannot be directly nested.`,\n location\n );\n\nexport const warnNonStaticExpressionSync = (\n file: string,\n attrName: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found non-static expression for attribute ${colorizeIdString(\n attrName\n )}: ${colorizeContent(value)}. Change \"${colorizeIdString(attrName)}\" to ensure this content is translated.`,\n location\n );\n\nexport const warnInvalidMaxCharsSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found invalid maxChars value: ${colorizeContent(value)}. maxChars must be a numeric literal, e.g. maxChars={10}, to ensure this content is translated.`,\n location\n );\n\nexport const warnDeprecatedTSugarPropsSync = (locations: string[]): string =>\n createDiagnosticMessage({\n whatHappened: `Found ${locations.length} deprecated ${colorizeIdString(\n '$'\n )}-prefixed prop${locations.length === 1 ? '' : 's'} on ${colorizeComponent(\n '<T>'\n )} components`,\n fix: `Use the unprefixed forms instead (${colorizeIdString(\n 'context'\n )}, ${colorizeIdString('id')}, ${colorizeIdString('maxChars')}, ${colorizeIdString(\n 'requiresReview'\n )}); support for the ${colorizeIdString('$')}-prefixed forms will be removed in the next major version`,\n }) +\n '\\n' +\n locations.map((location) => ` ${colorizeLine(location)}`).join('\\n');\n\nexport const warnInvalidFormatSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found invalid $format value: ${colorizeContent(value)}. Must be one of: 'ICU', 'STRING', 'I18NEXT'.`,\n location\n );\n\nexport const warnInvalidRequiresReviewSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found invalid requiresReview value: ${colorizeContent(value)}. Must be a boolean literal (true or false) — strings and dynamic expressions are not allowed.`,\n location\n );\n\nexport const warnInvalidIcuSync = (\n file: string,\n value: string,\n error: string,\n location?: string\n): string =>\n withWillErrorInNextVersion(\n withLocation(\n file,\n `Found invalid ICU string: ${colorizeContent(value)}. Change the value to a valid ICU to ensure this content is translated. Error message: ${error}.`,\n location\n )\n );\n\nexport const warnTemplateLiteralSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found template literal with quasis (${colorizeContent(value)}). Change the template literal to a string to ensure this content is translated.`,\n location\n );\n\nexport const warnNonStringSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found non-string literal (${colorizeContent(value)}). Change the value to a string literal to ensure this content is translated.`,\n location\n );\n\nexport const warnAsyncUseGT = (file: string, location?: string): string =>\n withLocation(\n file,\n `Found useGT() in an async function. Use getGT() instead, or make the function synchronous.`,\n location\n );\n\nexport const warnSyncGetGT = (file: string, location?: string): string =>\n withLocation(\n file,\n `Found getGT() in a synchronous function. Use useGT() instead, or make the function async.`,\n location\n );\n\nexport const warnTernarySync = (file: string, location?: string): string =>\n withLocation(\n file,\n 'Found ternary expression. A Branch component may be more appropriate here.',\n location\n );\n\nexport const withLocation = (\n file: string,\n message: string,\n location?: string\n): string =>\n `${colorizeFilepath(file)}${location ? ` (${colorizeLine(location)})` : ''}: ${message}`;\n\nexport const warnFunctionNotFoundSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Function ${colorizeFunctionName(functionName)} definition could not be resolved. This might affect translation resolution for this ${colorizeComponent('<T>')} component.`,\n location\n );\n\nexport const warnInvalidDeclareVarNameSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found invalid declareVar() $name tag. Must be a derivable (statically analyzable) expression. Received: ${colorizeContent(value)}.`,\n location\n );\n\nexport const warnDuplicateFunctionDefinitionSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Function ${colorizeFunctionName(functionName)} is defined multiple times. Only the first definition will be used.`,\n location\n );\n\nexport const warnInvalidDeriveInitSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveComponentError(\n `The definition for ${colorizeFunctionName(functionName)} could not be resolved. When using arrow syntax to define a derivable (statically analyzable) function, the right hand side or the assignment MUST only contain the arrow function itself and no other expressions.\nExample: ${colorizeContent(`const ${colorizeFunctionName(functionName)} = () => { ... }`)}\nInvalid: ${colorizeContent(`const ${colorizeFunctionName(functionName)} = [() => { ... }][0]`)}`\n ),\n location\n );\n\nexport const warnDataAttrOnBranch = (\n file: string,\n attrName: string,\n location?: string\n): string =>\n withLocation(\n file,\n `${colorizeComponent(`<${BRANCH_COMPONENT}>`)} component ignores attributes prefixed with ${colorizeIdString('\"data-\"')}. Found ${colorizeIdString(attrName)}. Remove it or use a different attribute name.`,\n location\n );\n\nexport const warnRecursiveFunctionCallSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveComponentError(\n `Recursive function call detected: ${colorizeFunctionName(functionName)}. A derivable (statically analyzable) function cannot use recursive calls to construct its result.`\n ),\n location\n );\n\nexport const warnDeriveFunctionNotWrappedSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Could not resolve ${colorizeFunctionName(formatCodeClamp(functionName))}. This call is not wrapped in derive(). Ensure the function is properly wrapped with derive() and does not have circular import dependencies.`\n ),\n location\n );\n\nexport const warnDeriveNonConstVariableSync = (\n file: string,\n varName: string,\n kind: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Variable ${colorizeFunctionName(varName)} is declared with '${kind}' but only 'const' declarations can be resolved statically. Change it to 'const'.`\n ),\n location\n );\n\nexport const warnDeriveFunctionNoResultsSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Could not resolve ${colorizeFunctionName(formatCodeClamp(functionName))}. derive() can only receive function invocations and cannot use undefined values or looped calls to construct its result.`\n ),\n location\n );\n\nexport const warnAutoderiveNoResultsSync = (\n file: string,\n expression: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Autoderive could not resolve ${colorizeFunctionName(formatCodeClamp(expression))}. Only function calls with statically determinable return values can be used directly in t(). Consider wrapping with derive() for explicit derivation, or use an interpolation variable instead.`,\n location\n );\n\nexport const warnDeriveUnresolvableValueSync = (\n file: string,\n key: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Object property ${colorizeFunctionName(formatCodeClamp(key))} could not be resolved to a static string value. Only string literals, template literals, conditionals, and function calls returning strings are supported.`\n ),\n location\n );\n\nexport const warnDeriveCircularSpreadSync = (\n file: string,\n varName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Circular spread detected involving ${colorizeFunctionName(varName)}. Spread references that form a cycle cannot be resolved statically.`\n ),\n location\n );\n\nexport const warnDeriveDestructuringSync = (\n file: string,\n varName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Variable ${colorizeFunctionName(varName)} uses destructuring syntax, which is not yet supported in derive(). Assign the value to a const variable directly instead.`\n ),\n location\n );\n\nexport const warnDeriveOptionalChainingSync = (\n file: string,\n code: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Optional chaining (${colorizeFunctionName(formatCodeClamp(code))}) is not supported in derive(). Optional chaining implies the value could be undefined, which cannot be resolved statically. Use a non-optional access instead.`\n ),\n location\n );\n\nexport const warnUnresolvedImportSync = (\n file: string,\n functionName: string,\n importPath: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Could not resolve import ${colorizeFunctionName(importPath)} for function ${colorizeFunctionName(functionName)}. Translation strings inside this function will not be extracted.`,\n location\n );\n\n// Re-export error messages\nexport const noLocalesError = `No target locales were found. Add locales to gt.config.json or pass them with the --locales flag.`;\nexport const noDefaultLocaleError = `No default locale was found. Add defaultLocale to gt.config.json or pass it with --default-locale.`;\nexport const noFilesError = `The files configuration is missing or invalid. Check the files section in gt.config.json and try again.`;\nexport const noSourceFileError = `No source translation file was found. Check your translations directory and default locale configuration.`;\nexport const noProjectIdError = `No project ID was found. Pass --project-id, add projectId to gt.config.json, or set the GT_PROJECT_ID environment variable.`;\nexport const noVersionIdError = `No version ID was found. Pass --version-id or add _versionId to gt.config.json.`;\nexport const invalidConfigurationError = `The files configuration cannot be used for this operation. Provide a valid download configuration or set --publish true to upload translations to the CDN.`;\nexport const lottieTranslateError = `Lottie translations are processed asynchronously, so the translate command cannot complete them in one run. Use the stage and download flow instead:\\n 1. Stage the files for translation: npx gt stage\\n 2. Fetch the finished translations: npx gt download\\nTranslations that are still processing are skipped, so re-run npx gt download until all of them have been downloaded.`;\nexport const branchResolutionError = `The current git branch could not be resolved. Specify a branch explicitly or run the command from a git worktree with branch metadata available.`;\n\nexport const lottieExpressionsError = (files: string[]): string =>\n `The following Lottie file(s) use After Effects expressions, which contain executable code and are not supported yet:\\n${files\n .map((file) => ` - ${file}`)\n .join(\n '\\n'\n )}\\nRe-export the animation with expressions baked into keyframes (or removed), then try again.`;\n\nexport const xcstringsSourceLanguageMismatchError = (\n catalogs: { file: string; sourceLanguage: string }[],\n defaultLocale: string\n): string =>\n `The following .xcstrings catalog(s) declare a sourceLanguage that does not match the configured defaultLocale \"${defaultLocale}\":\\n${catalogs\n .map(\n ({ file, sourceLanguage }) =>\n ` - ${file} (sourceLanguage \"${sourceLanguage}\")`\n )\n .join(\n '\\n'\n )}\\nSet defaultLocale in gt.config.json to the catalog's sourceLanguage, or change the catalog's source language in Xcode, then try again.`;\n\nexport const fileEncodingSkipReason = (error: unknown): string =>\n `File could not be decoded: ${error instanceof Error ? error.message : String(error)}`;\n\nexport const withOriginalError = (message: string, error: unknown): string =>\n error != null ? `${message} Original error: ${String(error)}` : message;\n"],"mappings":";;;;;AAYA,MAAM,8BAA8B,YAClC,GAAG,QAAQ;AAGb,MAAM,4BAA4B,YAChC,6BAA6B;AAE/B,MAAM,2BAA2B,YAC/B,6BAA6B;AAE/B,MAAa,0BAA0B,oBACrC,GAAG,iBACD,gBACD,CAAC;AAEJ,MAAa,wBACX,MACA,UACA,OACA,aAEA,aACE,MACA,GAAG,kBAAkB,MAAM,CAAC,mCAAmC,iBAAiB,SAAS,CAAC,eAAe,gBACvG,MACD,CAAC,WAAW,iBAAiB,SAAS,CAAC,yCACxC,SACD;AAEH,MAAa,yBACX,MACA,cACA,YACA,aAEA,aACE,MACA,yBACE,YAAY,qBAAqB,aAAa,CAAC,mEAAmE,qBAAqB,aAAa,CAAC,uKAAuK,gBAAgB,WAAW,GACxV,EACD,SACD;AAGH,MAAa,yBACX,MACA,cACA,aAEA,aACE,MACA,YAAY,qBAAqB,aAAa,CAAC,iBAAiB,kBAAkB,WAAW,CAAC,oHAC9F,SACD;AAEH,MAAa,kCACX,MACA,sBACA,IACA,aAEA,aACE,MACA,GAAG,kBAAkB,MAAM,CAAC,YAC1B,KAAK,YAAY,iBAAiB,GAAG,KAAK,GAC3C,4EAA4E,kBAC3E,QACD,CAAC,0CAA0C,gBAC1C,qBAAqB,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O,MAAM;AAEtF,MAAa,qBAAqB,SAAiB,UACjD,SAAS,OAAO,GAAG,QAAQ,mBAAmB,OAAO,MAAM,KAAK"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/console/index.ts"],"sourcesContent":["import { createDiagnosticMessage } from 'generaltranslation/diagnostics';\nimport { BRANCH_COMPONENT } from '../react/jsx/utils/constants.js';\nimport {\n colorizeFilepath,\n colorizeComponent,\n colorizeIdString,\n colorizeContent,\n colorizeLine,\n colorizeFunctionName,\n} from './colors.js';\nimport { formatCodeClamp } from './formatting.js';\n\nconst withWillErrorInNextVersion = (message: string): string =>\n `${message} (This will become an error in the next major version of the CLI.)`;\n\n// Derive function related errors\nconst withDeriveComponentError = (message: string): string =>\n `<Derive> rules violation: ${message}`;\n\nconst withDeriveFunctionError = (message: string): string =>\n `derive() rules violation: ${message}`;\n// Synchronous wrappers for backward compatibility\nexport const warnApiKeyInConfigSync = (optionsFilepath: string): string =>\n `${colorizeFilepath(\n optionsFilepath\n )}: Your API key is exposed! Remove it from the file and include it as an environment variable.`;\n\nexport const warnVariablePropSync = (\n file: string,\n attrName: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `${colorizeComponent('<T>')} component has dynamic attribute ${colorizeIdString(attrName)} with value: ${colorizeContent(\n value\n )}. Change ${colorizeIdString(attrName)} to ensure this content is translated.`,\n location\n );\n\nexport const warnInvalidReturnSync = (\n file: string,\n functionName: string,\n expression: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveComponentError(\n `Function ${colorizeFunctionName(functionName)} does not return a derivable (statically analyzable) expression. ${colorizeFunctionName(functionName)} must return either (1) a derivable string literal, (2) another derivable function invocation, (3) derivable JSX content, or (4) a ternary expression. Instead got:\\n${colorizeContent(expression)}`\n ),\n location\n );\n\n// TODO: this is temporary until we handle implicit returns\nexport const warnMissingReturnSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Function ${colorizeFunctionName(functionName)} is wrapped in ${colorizeComponent('<Derive>')} tags but does not have an explicit return statement. Derivable functions must have an explicit return statement.`,\n location\n );\n\nexport const warnHasUnwrappedExpressionSync = (\n file: string,\n unwrappedExpressions: string[],\n id?: string,\n location?: string\n): string =>\n withLocation(\n file,\n `${colorizeComponent('<T>')} component${\n id ? ` with id ${colorizeIdString(id)}` : ''\n } has children that could change at runtime. Use a variable component like ${colorizeComponent(\n '<Var>'\n )} to ensure this content is translated.\\n${colorizeContent(\n unwrappedExpressions.join('\\n')\n )}`,\n location\n );\n\nexport const warnFailedToConstructJsxTreeSync = (\n file: string,\n code: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Failed to construct JsxTree! Call expression is not a valid createElement call: ${colorizeContent(code)}`,\n location\n );\n\nexport const warnNestedTComponent = (file: string, location?: string): string =>\n withLocation(\n file,\n `Found nested <T> component. <T> components cannot be directly nested.`,\n location\n );\n\nexport const warnNestedInternalTComponent = (\n file: string,\n location?: string\n): string =>\n withLocation(\n file,\n `DEBUG: Found nested <GtInternalTranslateJsx> component. <GtInternalTranslateJsx> components cannot be directly nested.`,\n location\n );\n\nexport const warnNonStaticExpressionSync = (\n file: string,\n attrName: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found non-static expression for attribute ${colorizeIdString(\n attrName\n )}: ${colorizeContent(value)}. Change \"${colorizeIdString(attrName)}\" to ensure this content is translated.`,\n location\n );\n\nexport const warnInvalidMaxCharsSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found invalid maxChars value: ${colorizeContent(value)}. maxChars must be a numeric literal, e.g. maxChars={10}, to ensure this content is translated.`,\n location\n );\n\nexport const warnDeprecatedTSugarPropsSync = (locations: string[]): string =>\n createDiagnosticMessage({\n whatHappened: `Found ${locations.length} deprecated ${colorizeIdString(\n '$'\n )}-prefixed prop${locations.length === 1 ? '' : 's'} on ${colorizeComponent(\n '<T>'\n )} components`,\n fix: `Use the unprefixed forms instead (${colorizeIdString(\n 'context'\n )}, ${colorizeIdString('id')}, ${colorizeIdString('maxChars')}, ${colorizeIdString(\n 'requiresReview'\n )}); support for the ${colorizeIdString('$')}-prefixed forms will be removed in the next major version`,\n }) +\n '\\n' +\n locations.map((location) => ` ${colorizeLine(location)}`).join('\\n');\n\nexport const warnInvalidFormatSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found invalid $format value: ${colorizeContent(value)}. Must be one of: 'ICU', 'STRING', 'I18NEXT'.`,\n location\n );\n\nexport const warnInvalidRequiresReviewSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found invalid requiresReview value: ${colorizeContent(value)}. Must be a boolean literal (true or false) — strings and dynamic expressions are not allowed.`,\n location\n );\n\nexport const warnInvalidIcuSync = (\n file: string,\n value: string,\n error: string,\n location?: string\n): string =>\n withWillErrorInNextVersion(\n withLocation(\n file,\n `Found invalid ICU string: ${colorizeContent(value)}. Change the value to a valid ICU to ensure this content is translated. Error message: ${error}.`,\n location\n )\n );\n\nexport const warnTemplateLiteralSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found template literal with quasis (${colorizeContent(value)}). Change the template literal to a string to ensure this content is translated.`,\n location\n );\n\nexport const warnNonStringSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found non-string literal (${colorizeContent(value)}). Change the value to a string literal to ensure this content is translated.`,\n location\n );\n\nexport const warnAsyncUseGT = (file: string, location?: string): string =>\n withLocation(\n file,\n `Found useGT() in an async function. Use getGT() instead, or make the function synchronous.`,\n location\n );\n\nexport const warnSyncGetGT = (file: string, location?: string): string =>\n withLocation(\n file,\n `Found getGT() in a synchronous function. Use useGT() instead, or make the function async.`,\n location\n );\n\nexport const warnTernarySync = (file: string, location?: string): string =>\n withLocation(\n file,\n 'Found ternary expression. A Branch component may be more appropriate here.',\n location\n );\n\nexport const withLocation = (\n file: string,\n message: string,\n location?: string\n): string =>\n `${colorizeFilepath(file)}${location ? ` (${colorizeLine(location)})` : ''}: ${message}`;\n\nexport const warnFunctionNotFoundSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Function ${colorizeFunctionName(functionName)} definition could not be resolved. This might affect translation resolution for this ${colorizeComponent('<T>')} component.`,\n location\n );\n\nexport const warnInvalidDeclareVarNameSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found invalid declareVar() $name tag. Must be a derivable (statically analyzable) expression. Received: ${colorizeContent(value)}.`,\n location\n );\n\nexport const warnDuplicateFunctionDefinitionSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Function ${colorizeFunctionName(functionName)} is defined multiple times. Only the first definition will be used.`,\n location\n );\n\nexport const warnInvalidDeriveInitSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveComponentError(\n `The definition for ${colorizeFunctionName(functionName)} could not be resolved. When using arrow syntax to define a derivable (statically analyzable) function, the right hand side or the assignment MUST only contain the arrow function itself and no other expressions.\nExample: ${colorizeContent(`const ${colorizeFunctionName(functionName)} = () => { ... }`)}\nInvalid: ${colorizeContent(`const ${colorizeFunctionName(functionName)} = [() => { ... }][0]`)}`\n ),\n location\n );\n\nexport const warnDataAttrOnBranch = (\n file: string,\n attrName: string,\n location?: string\n): string =>\n withLocation(\n file,\n `${colorizeComponent(`<${BRANCH_COMPONENT}>`)} component ignores attributes prefixed with ${colorizeIdString('\"data-\"')}. Found ${colorizeIdString(attrName)}. Remove it or use a different attribute name.`,\n location\n );\n\nexport const warnRecursiveFunctionCallSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveComponentError(\n `Recursive function call detected: ${colorizeFunctionName(functionName)}. A derivable (statically analyzable) function cannot use recursive calls to construct its result.`\n ),\n location\n );\n\nexport const warnDeriveFunctionNotWrappedSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Could not resolve ${colorizeFunctionName(formatCodeClamp(functionName))}. This call is not wrapped in derive(). Ensure the function is properly wrapped with derive() and does not have circular import dependencies.`\n ),\n location\n );\n\nexport const warnDeriveNonConstVariableSync = (\n file: string,\n varName: string,\n kind: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Variable ${colorizeFunctionName(varName)} is declared with '${kind}' but only 'const' declarations can be resolved statically. Change it to 'const'.`\n ),\n location\n );\n\nexport const warnDeriveFunctionNoResultsSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Could not resolve ${colorizeFunctionName(formatCodeClamp(functionName))}. derive() can only receive function invocations and cannot use undefined values or looped calls to construct its result.`\n ),\n location\n );\n\nexport const warnAutoderiveNoResultsSync = (\n file: string,\n expression: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Autoderive could not resolve ${colorizeFunctionName(formatCodeClamp(expression))}. Only function calls with statically determinable return values can be used directly in t(). Consider wrapping with derive() for explicit derivation, or use an interpolation variable instead.`,\n location\n );\n\nexport const warnDeriveUnresolvableValueSync = (\n file: string,\n key: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Object property ${colorizeFunctionName(formatCodeClamp(key))} could not be resolved to a static string value. Only string literals, template literals, conditionals, and function calls returning strings are supported.`\n ),\n location\n );\n\nexport const warnDeriveCircularSpreadSync = (\n file: string,\n varName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Circular spread detected involving ${colorizeFunctionName(varName)}. Spread references that form a cycle cannot be resolved statically.`\n ),\n location\n );\n\nexport const warnDeriveDestructuringSync = (\n file: string,\n varName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Variable ${colorizeFunctionName(varName)} uses destructuring syntax, which is not yet supported in derive(). Assign the value to a const variable directly instead.`\n ),\n location\n );\n\nexport const warnDeriveOptionalChainingSync = (\n file: string,\n code: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Optional chaining (${colorizeFunctionName(formatCodeClamp(code))}) is not supported in derive(). Optional chaining implies the value could be undefined, which cannot be resolved statically. Use a non-optional access instead.`\n ),\n location\n );\n\nexport const warnUnresolvedImportSync = (\n file: string,\n functionName: string,\n importPath: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Could not resolve import ${colorizeFunctionName(importPath)} for function ${colorizeFunctionName(functionName)}. Translation strings inside this function will not be extracted.`,\n location\n );\n\n// Re-export error messages\nexport const noLocalesError = `No target locales were found. Add locales to gt.config.json or pass them with the --locales flag.`;\nexport const noDefaultLocaleError = `No default locale was found. Add defaultLocale to gt.config.json or pass it with --default-locale.`;\nexport const noFilesError = `The files configuration is missing or invalid. Check the files section in gt.config.json and try again.`;\nexport const noSourceFileError = `No source translation file was found. Check your translations directory and default locale configuration.`;\n// TODO: add a CLI command that finds or creates a project for the signed-in\n// user and prints its ID (e.g. `gt project list`), and name it in this error.\nexport const noProjectIdError = (dashboardUrl: string): string =>\n createDiagnosticMessage({\n source: 'gt',\n severity: 'Error',\n whatHappened: 'No project ID was found',\n fix: 'Pass --project-id, add projectId to gt.config.json, or set the GT_PROJECT_ID environment variable',\n wayOut: `Find your project ID, or create a project, in the dashboard (${dashboardUrl})`,\n });\nexport const noVersionIdError = `No version ID was found. Pass --version-id or add _versionId to gt.config.json.`;\nexport const invalidConfigurationError = `The files configuration cannot be used for this operation. Provide a valid download configuration or set --publish true to upload translations to the CDN.`;\nexport const lottieTranslateError = `Lottie translations are processed asynchronously, so the translate command cannot complete them in one run. Use the stage and download flow instead:\\n 1. Stage the files for translation: npx gt stage\\n 2. Fetch the finished translations: npx gt download\\nTranslations that are still processing are skipped, so re-run npx gt download until all of them have been downloaded.`;\nexport const branchResolutionError = `The current git branch could not be resolved. Specify a branch explicitly or run the command from a git worktree with branch metadata available.`;\n\nexport const lottieExpressionsError = (files: string[]): string =>\n `The following Lottie file(s) use After Effects expressions, which contain executable code and are not supported yet:\\n${files\n .map((file) => ` - ${file}`)\n .join(\n '\\n'\n )}\\nRe-export the animation with expressions baked into keyframes (or removed), then try again.`;\n\nexport const xcstringsSourceLanguageMismatchError = (\n catalogs: { file: string; sourceLanguage: string }[],\n defaultLocale: string\n): string =>\n `The following .xcstrings catalog(s) declare a sourceLanguage that does not match the configured defaultLocale \"${defaultLocale}\":\\n${catalogs\n .map(\n ({ file, sourceLanguage }) =>\n ` - ${file} (sourceLanguage \"${sourceLanguage}\")`\n )\n .join(\n '\\n'\n )}\\nSet defaultLocale in gt.config.json to the catalog's sourceLanguage, or change the catalog's source language in Xcode, then try again.`;\n\nexport const fileEncodingSkipReason = (error: unknown): string =>\n `File could not be decoded: ${error instanceof Error ? error.message : String(error)}`;\n\nexport const withOriginalError = (message: string, error: unknown): string =>\n error != null ? `${message} Original error: ${String(error)}` : message;\n"],"mappings":";;;;;AAYA,MAAM,8BAA8B,YAClC,GAAG,QAAQ;AAGb,MAAM,4BAA4B,YAChC,6BAA6B;AAE/B,MAAM,2BAA2B,YAC/B,6BAA6B;AAE/B,MAAa,0BAA0B,oBACrC,GAAG,iBACD,gBACD,CAAC;AAEJ,MAAa,wBACX,MACA,UACA,OACA,aAEA,aACE,MACA,GAAG,kBAAkB,MAAM,CAAC,mCAAmC,iBAAiB,SAAS,CAAC,eAAe,gBACvG,MACD,CAAC,WAAW,iBAAiB,SAAS,CAAC,yCACxC,SACD;AAEH,MAAa,yBACX,MACA,cACA,YACA,aAEA,aACE,MACA,yBACE,YAAY,qBAAqB,aAAa,CAAC,mEAAmE,qBAAqB,aAAa,CAAC,uKAAuK,gBAAgB,WAAW,GACxV,EACD,SACD;AAGH,MAAa,yBACX,MACA,cACA,aAEA,aACE,MACA,YAAY,qBAAqB,aAAa,CAAC,iBAAiB,kBAAkB,WAAW,CAAC,oHAC9F,SACD;AAEH,MAAa,kCACX,MACA,sBACA,IACA,aAEA,aACE,MACA,GAAG,kBAAkB,MAAM,CAAC,YAC1B,KAAK,YAAY,iB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UACA,kBAEA,kHAAkH,cAAc,MAAM,SACnI,KACE,EAAE,MAAM,qBACP,OAAO,KAAK,oBAAoB,eAAe,IAClD,CACA,KACC,KACD,CAAC;AAEN,MAAa,0BAA0B,UACrC,8BAA8B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAEtF,MAAa,qBAAqB,SAAiB,UACjD,SAAS,OAAO,GAAG,QAAQ,mBAAmB,OAAO,MAAM,KAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "2.
|
|
1
|
+
export declare const PACKAGE_VERSION = "2.27.1";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/generated/version.ts"],"sourcesContent":["// This file is auto-generated. Do not edit manually.\nexport const PACKAGE_VERSION = '2.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/generated/version.ts"],"sourcesContent":["// This file is auto-generated. Do not edit manually.\nexport const PACKAGE_VERSION = '2.27.1';\n"],"mappings":";AACA,MAAa,kBAAkB"}
|
|
@@ -50,3 +50,5 @@ export type BuildToolSetup = {
|
|
|
50
50
|
};
|
|
51
51
|
export declare const BUILD_TOOL_SETUPS: BuildToolSetup[];
|
|
52
52
|
export declare function getBuildToolSetup(framework?: string): BuildToolSetup | undefined;
|
|
53
|
+
/** The setup guide the wizard links for a framework. */
|
|
54
|
+
export declare function getSetupDocsUrl(framework?: string): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NEXT_APP_QUICKSTART_URL, NEXT_PAGES_QUICKSTART_URL } from "../../utils/constants.js";
|
|
1
2
|
import { reactRouterSetup } from "./reactRouter/index.js";
|
|
2
3
|
import { viteSetup } from "./vite.js";
|
|
3
4
|
import { tanstackStartSetup } from "./tanstackStart/index.js";
|
|
@@ -10,7 +11,16 @@ const BUILD_TOOL_SETUPS = [
|
|
|
10
11
|
function getBuildToolSetup(framework) {
|
|
11
12
|
return BUILD_TOOL_SETUPS.find((setup) => setup.framework === framework);
|
|
12
13
|
}
|
|
14
|
+
/** Quickstarts for frameworks set up without a build-tool hook. */
|
|
15
|
+
const FRAMEWORK_DOCS_URLS = {
|
|
16
|
+
"next-app": NEXT_APP_QUICKSTART_URL,
|
|
17
|
+
"next-pages": NEXT_PAGES_QUICKSTART_URL
|
|
18
|
+
};
|
|
19
|
+
/** The setup guide the wizard links for a framework. */
|
|
20
|
+
function getSetupDocsUrl(framework) {
|
|
21
|
+
return getBuildToolSetup(framework)?.docsUrl ?? (framework && FRAMEWORK_DOCS_URLS[framework]) ?? "https://generaltranslation.com/docs/react/react-quickstart";
|
|
22
|
+
}
|
|
13
23
|
//#endregion
|
|
14
|
-
export { BUILD_TOOL_SETUPS, getBuildToolSetup };
|
|
24
|
+
export { BUILD_TOOL_SETUPS, getBuildToolSetup, getSetupDocsUrl };
|
|
15
25
|
|
|
16
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/setup/buildTools/index.ts"],"sourcesContent":["import type { SupportedReactFrameworks } from '../../types/index.js';\nimport { reactRouterSetup } from './reactRouter/index.js';\nimport { tanstackStartSetup } from './tanstackStart/index.js';\nimport { viteSetup } from './vite.js';\n\n/** A change setup left to a person, reported as a warning. */\nexport type ManualAction = { whatHappened: string; fix: string };\n\n/** What a build-tool hook changed, and what a person still has to do. */\nexport type SetupResult = { steps: string[]; manualActions: ManualAction[] };\n\nexport type BuildToolContext = {\n appDirectory: string;\n configFilepath: string;\n defaultLocale: string;\n locales: string[];\n /** Set when translations are stored locally. */\n translationsDir?: string;\n /** The translations directory in the existing config. */\n previousTranslationsDir?: string;\n};\n\n/** Setup steps for a build tool whose app entry GT configures itself. */\nexport type BuildToolSetup = {\n framework: SupportedReactFrameworks;\n defaultTranslationsDir: string;\n /** The runtime entry named in the defaults text. */\n initializer: string;\n /** Loads local translations itself instead of loadTranslations.js. */\n ownsLoader: boolean;\n skipsGTInstall(isUsingGT: boolean): boolean;\n /** Setup guide linked after setup; the React quickstart otherwise. */\n docsUrl?: string;\n /** The development credentials question asked with local storage. */\n devCredentialsOption: '--live-translations' | '--dev-credentials';\n /** Rejects an app layout it cannot configure, before any change. */\n preflight(appDirectory: string): Promise<void>;\n /** Keeps an existing loader in sync when the React setup is skipped. */\n syncLoader(\n ctx: BuildToolContext & { translationsDir: string; keepAppSource?: boolean }\n ): Promise<SetupResult>;\n /**\n * The change a configured app entry needs after translations switch to the\n * CDN: null when it needs none, undefined to keep the generic loader-removal\n * action.\n */\n getCDNStorageAction?(\n ctx: BuildToolContext\n ): Promise<ManualAction | null | undefined>;\n /** Configures the app entry after gt.config.json is written. */\n apply(ctx: BuildToolContext): Promise<SetupResult>;\n};\n\nexport const BUILD_TOOL_SETUPS: BuildToolSetup[] = [\n viteSetup,\n tanstackStartSetup,\n reactRouterSetup,\n];\n\nexport function getBuildToolSetup(\n framework?: string\n): BuildToolSetup | undefined {\n return BUILD_TOOL_SETUPS.find((setup) => setup.framework === framework);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/setup/buildTools/index.ts"],"sourcesContent":["import type { SupportedReactFrameworks } from '../../types/index.js';\nimport {\n NEXT_APP_QUICKSTART_URL,\n NEXT_PAGES_QUICKSTART_URL,\n REACT_QUICKSTART_URL,\n} from '../../utils/constants.js';\nimport { reactRouterSetup } from './reactRouter/index.js';\nimport { tanstackStartSetup } from './tanstackStart/index.js';\nimport { viteSetup } from './vite.js';\n\n/** A change setup left to a person, reported as a warning. */\nexport type ManualAction = { whatHappened: string; fix: string };\n\n/** What a build-tool hook changed, and what a person still has to do. */\nexport type SetupResult = { steps: string[]; manualActions: ManualAction[] };\n\nexport type BuildToolContext = {\n appDirectory: string;\n configFilepath: string;\n defaultLocale: string;\n locales: string[];\n /** Set when translations are stored locally. */\n translationsDir?: string;\n /** The translations directory in the existing config. */\n previousTranslationsDir?: string;\n};\n\n/** Setup steps for a build tool whose app entry GT configures itself. */\nexport type BuildToolSetup = {\n framework: SupportedReactFrameworks;\n defaultTranslationsDir: string;\n /** The runtime entry named in the defaults text. */\n initializer: string;\n /** Loads local translations itself instead of loadTranslations.js. */\n ownsLoader: boolean;\n skipsGTInstall(isUsingGT: boolean): boolean;\n /** Setup guide linked after setup; the React quickstart otherwise. */\n docsUrl?: string;\n /** The development credentials question asked with local storage. */\n devCredentialsOption: '--live-translations' | '--dev-credentials';\n /** Rejects an app layout it cannot configure, before any change. */\n preflight(appDirectory: string): Promise<void>;\n /** Keeps an existing loader in sync when the React setup is skipped. */\n syncLoader(\n ctx: BuildToolContext & { translationsDir: string; keepAppSource?: boolean }\n ): Promise<SetupResult>;\n /**\n * The change a configured app entry needs after translations switch to the\n * CDN: null when it needs none, undefined to keep the generic loader-removal\n * action.\n */\n getCDNStorageAction?(\n ctx: BuildToolContext\n ): Promise<ManualAction | null | undefined>;\n /** Configures the app entry after gt.config.json is written. */\n apply(ctx: BuildToolContext): Promise<SetupResult>;\n};\n\nexport const BUILD_TOOL_SETUPS: BuildToolSetup[] = [\n viteSetup,\n tanstackStartSetup,\n reactRouterSetup,\n];\n\nexport function getBuildToolSetup(\n framework?: string\n): BuildToolSetup | undefined {\n return BUILD_TOOL_SETUPS.find((setup) => setup.framework === framework);\n}\n\n/** Quickstarts for frameworks set up without a build-tool hook. */\nconst FRAMEWORK_DOCS_URLS: Partial<Record<string, string>> = {\n 'next-app': NEXT_APP_QUICKSTART_URL,\n 'next-pages': NEXT_PAGES_QUICKSTART_URL,\n} satisfies Partial<Record<SupportedReactFrameworks, string>>;\n\n/** The setup guide the wizard links for a framework. */\nexport function getSetupDocsUrl(framework?: string): string {\n return (\n getBuildToolSetup(framework)?.docsUrl ??\n (framework && FRAMEWORK_DOCS_URLS[framework]) ??\n REACT_QUICKSTART_URL\n );\n}\n"],"mappings":";;;;;AA0DA,MAAa,oBAAsC;CACjD;CACA;CACA;CACD;AAED,SAAgB,kBACd,WAC4B;AAC5B,QAAO,kBAAkB,MAAM,UAAU,MAAM,cAAc,UAAU;;;AAIzE,MAAM,sBAAuD;CAC3D,YAAY;CACZ,cAAc;CACf;;AAGD,SAAgB,gBAAgB,WAA4B;AAC1D,QACE,kBAAkB,UAAU,EAAE,YAC7B,aAAa,oBAAoB,eAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_VITE_TRANSLATIONS_DIR } from "../../utils/constants.js";
|
|
1
|
+
import { DEFAULT_VITE_TRANSLATIONS_DIR, REACT_SPA_QUICKSTART_URL } from "../../utils/constants.js";
|
|
2
2
|
import { inspectViteSPA, setupViteSPA, writeViteLoader } from "../setupViteSPA.js";
|
|
3
3
|
import { getLoaderUpdateActions } from "./shared/loader.js";
|
|
4
4
|
import path from "node:path";
|
|
@@ -11,6 +11,7 @@ const viteSetup = {
|
|
|
11
11
|
initializer: "initializeGTSPA",
|
|
12
12
|
ownsLoader: true,
|
|
13
13
|
skipsGTInstall: (isUsingGT) => isUsingGT,
|
|
14
|
+
docsUrl: REACT_SPA_QUICKSTART_URL,
|
|
14
15
|
devCredentialsOption: "--live-translations",
|
|
15
16
|
async preflight(appDirectory) {
|
|
16
17
|
await inspectViteSPA(appDirectory);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../../../src/setup/buildTools/vite.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport {
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../../../src/setup/buildTools/vite.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport {\n DEFAULT_VITE_TRANSLATIONS_DIR,\n REACT_SPA_QUICKSTART_URL,\n} from '../../utils/constants.js';\nimport {\n inspectViteSPA,\n setupViteSPA,\n writeViteLoader,\n} from '../setupViteSPA.js';\nimport type { BuildToolSetup } from './index.js';\nimport { getLoaderUpdateActions } from './shared/loader.js';\n\nexport const VITE_LOADER_FILE = 'src/loadTranslations.ts';\n\nexport const viteSetup: BuildToolSetup = {\n framework: 'vite',\n defaultTranslationsDir: DEFAULT_VITE_TRANSLATIONS_DIR,\n initializer: 'initializeGTSPA',\n ownsLoader: true,\n skipsGTInstall: (isUsingGT) => isUsingGT,\n docsUrl: REACT_SPA_QUICKSTART_URL,\n devCredentialsOption: '--live-translations',\n async preflight(appDirectory) {\n await inspectViteSPA(appDirectory);\n },\n // Configure keeps an existing loader in sync; init leaves application\n // source to the person.\n async syncLoader({\n appDirectory,\n defaultLocale,\n locales,\n translationsDir,\n previousTranslationsDir,\n keepAppSource,\n }) {\n if (keepAppSource) {\n return {\n steps: [],\n manualActions: fs.existsSync(path.join(appDirectory, VITE_LOADER_FILE))\n ? getLoaderUpdateActions(\n VITE_LOADER_FILE,\n translationsDir,\n previousTranslationsDir,\n false\n )\n : [],\n };\n }\n const loader = await writeViteLoader({\n appDirectory,\n defaultLocale,\n locales,\n translationsDir,\n previousTranslationsDir,\n create: false,\n });\n return {\n steps: loader === 'updated' ? [`updated ${VITE_LOADER_FILE}`] : [],\n manualActions:\n loader === 'custom'\n ? getLoaderUpdateActions(\n VITE_LOADER_FILE,\n translationsDir,\n previousTranslationsDir,\n true\n )\n : [],\n };\n },\n async apply(ctx) {\n const { manualAction } = await setupViteSPA(ctx);\n return manualAction\n ? {\n steps: [],\n manualActions: [\n {\n whatHappened: 'The existing Vite setup needs a manual review',\n fix: manualAction,\n },\n ],\n }\n : { steps: ['configured initializeGTSPA'], manualActions: [] };\n },\n};\n"],"mappings":";;;;;;AAcA,MAAa,mBAAmB;AAEhC,MAAa,YAA4B;CACvC,WAAW;CACX,wBAAwB;CACxB,aAAa;CACb,YAAY;CACZ,iBAAiB,cAAc;CAC/B,SAAS;CACT,sBAAsB;CACtB,MAAM,UAAU,cAAc;AAC5B,QAAM,eAAe,aAAa;;CAIpC,MAAM,WAAW,EACf,cACA,eACA,SACA,iBACA,yBACA,iBACC;AACD,MAAI,cACF,QAAO;GACL,OAAO,EAAE;GACT,eAAe,GAAG,WAAW,KAAK,KAAK,cAAA,0BAA+B,CAAC,GACnE,uBACE,kBACA,iBACA,yBACA,MACD,GACD,EAAE;GACP;EAEH,MAAM,SAAS,MAAM,gBAAgB;GACnC;GACA;GACA;GACA;GACA;GACA,QAAQ;GACT,CAAC;AACF,SAAO;GACL,OAAO,WAAW,YAAY,CAAC,WAAW,mBAAmB,GAAG,EAAE;GAClE,eACE,WAAW,WACP,uBACE,kBACA,iBACA,yBACA,KACD,GACD,EAAE;GACT;;CAEH,MAAM,MAAM,KAAK;EACf,MAAM,EAAE,iBAAiB,MAAM,aAAa,IAAI;AAChD,SAAO,eACH;GACE,OAAO,EAAE;GACT,eAAe,CACb;IACE,cAAc;IACd,KAAK;IACN,CACF;GACF,GACD;GAAE,OAAO,CAAC,6BAA6B;GAAE,eAAe,EAAE;GAAE;;CAEnE"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FrameworkObject } from '../types/index.js';
|
|
1
|
+
import { FrameworkObject, ReactNativeFrameworkObject } from '../types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Detects the frontend framework used in the current project.
|
|
4
4
|
*
|
|
5
5
|
* Analyzes the project structure and dependencies to identify the framework.
|
|
6
|
-
* Detection order: Mintlify → Next.js (App/Pages Router) → Gatsby → RedwoodJS → TanStack Start → React Router → Vite → React.
|
|
6
|
+
* Detection order: Mintlify → Next.js (App/Pages Router) → Gatsby → RedwoodJS → TanStack Start → React Router → React Native (Expo or bare) → Vite → React.
|
|
7
7
|
*
|
|
8
8
|
* For Next.js projects, further determines whether it uses App Router or Pages Router
|
|
9
9
|
* by checking for the presence of `app/` or `pages/` directories.
|
|
@@ -11,9 +11,10 @@ import { FrameworkObject } from '../types/index.js';
|
|
|
11
11
|
* @returns A promise resolving to a FrameworkObject containing:
|
|
12
12
|
* - `name`: The detected framework identifier (e.g., 'next-app', 'gatsby', 'react')
|
|
13
13
|
* or undefined if no framework is detected
|
|
14
|
-
* - `type`: The framework category
|
|
14
|
+
* - `type`: The framework category: 'react' for React-based web frameworks,
|
|
15
|
+
* or 'react-native' for Expo and bare React Native apps
|
|
15
16
|
*/
|
|
16
|
-
export declare function detectFramework(): Promise<FrameworkObject | {
|
|
17
|
+
export declare function detectFramework(): Promise<FrameworkObject | ReactNativeFrameworkObject | {
|
|
17
18
|
name: undefined;
|
|
18
19
|
type?: undefined;
|
|
19
20
|
}>;
|
|
@@ -6,7 +6,7 @@ import fs from "node:fs";
|
|
|
6
6
|
* Detects the frontend framework used in the current project.
|
|
7
7
|
*
|
|
8
8
|
* Analyzes the project structure and dependencies to identify the framework.
|
|
9
|
-
* Detection order: Mintlify → Next.js (App/Pages Router) → Gatsby → RedwoodJS → TanStack Start → React Router → Vite → React.
|
|
9
|
+
* Detection order: Mintlify → Next.js (App/Pages Router) → Gatsby → RedwoodJS → TanStack Start → React Router → React Native (Expo or bare) → Vite → React.
|
|
10
10
|
*
|
|
11
11
|
* For Next.js projects, further determines whether it uses App Router or Pages Router
|
|
12
12
|
* by checking for the presence of `app/` or `pages/` directories.
|
|
@@ -14,7 +14,8 @@ import fs from "node:fs";
|
|
|
14
14
|
* @returns A promise resolving to a FrameworkObject containing:
|
|
15
15
|
* - `name`: The detected framework identifier (e.g., 'next-app', 'gatsby', 'react')
|
|
16
16
|
* or undefined if no framework is detected
|
|
17
|
-
* - `type`: The framework category
|
|
17
|
+
* - `type`: The framework category: 'react' for React-based web frameworks,
|
|
18
|
+
* or 'react-native' for Expo and bare React Native apps
|
|
18
19
|
*/
|
|
19
20
|
async function detectFramework() {
|
|
20
21
|
const packageJson = await searchForPackageJson();
|
|
@@ -53,6 +54,10 @@ async function detectFramework() {
|
|
|
53
54
|
name: "react-router",
|
|
54
55
|
type: "react"
|
|
55
56
|
};
|
|
57
|
+
if (isPackageInstalled("expo", packageJson, false, true) || isPackageInstalled("react-native", packageJson, false, true)) return {
|
|
58
|
+
name: "react-native",
|
|
59
|
+
type: "react-native"
|
|
60
|
+
};
|
|
56
61
|
if (isPackageInstalled("vite", packageJson, false, true)) return {
|
|
57
62
|
name: "vite",
|
|
58
63
|
type: "react"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectFramework.js","names":[],"sources":["../../src/setup/detectFramework.ts"],"sourcesContent":["import { FrameworkObject } from '../types/index.js';\nimport { isPackageInstalled } from '../utils/packageJson.js';\nimport { searchForPackageJson } from '../utils/packageJson.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\n/* ----- MAIN ----- */\n\n/**\n * Detects the frontend framework used in the current project.\n *\n * Analyzes the project structure and dependencies to identify the framework.\n * Detection order: Mintlify → Next.js (App/Pages Router) → Gatsby → RedwoodJS → TanStack Start → React Router → Vite → React.\n *\n * For Next.js projects, further determines whether it uses App Router or Pages Router\n * by checking for the presence of `app/` or `pages/` directories.\n *\n * @returns A promise resolving to a FrameworkObject containing:\n * - `name`: The detected framework identifier (e.g., 'next-app', 'gatsby', 'react')\n * or undefined if no framework is detected\n * - `type`: The framework category
|
|
1
|
+
{"version":3,"file":"detectFramework.js","names":[],"sources":["../../src/setup/detectFramework.ts"],"sourcesContent":["import { FrameworkObject, ReactNativeFrameworkObject } from '../types/index.js';\nimport { isPackageInstalled } from '../utils/packageJson.js';\nimport { searchForPackageJson } from '../utils/packageJson.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\n/* ----- MAIN ----- */\n\n/**\n * Detects the frontend framework used in the current project.\n *\n * Analyzes the project structure and dependencies to identify the framework.\n * Detection order: Mintlify → Next.js (App/Pages Router) → Gatsby → RedwoodJS → TanStack Start → React Router → React Native (Expo or bare) → Vite → React.\n *\n * For Next.js projects, further determines whether it uses App Router or Pages Router\n * by checking for the presence of `app/` or `pages/` directories.\n *\n * @returns A promise resolving to a FrameworkObject containing:\n * - `name`: The detected framework identifier (e.g., 'next-app', 'gatsby', 'react')\n * or undefined if no framework is detected\n * - `type`: The framework category: 'react' for React-based web frameworks,\n * or 'react-native' for Expo and bare React Native apps\n */\nexport async function detectFramework(): Promise<\n | FrameworkObject\n | ReactNativeFrameworkObject\n | { name: undefined; type?: undefined }\n> {\n const packageJson = await searchForPackageJson();\n\n if (isMintlifyProject(packageJson)) {\n return { name: 'mintlify' };\n }\n\n if (!packageJson) {\n return { name: undefined };\n }\n\n // Check for Next.js first\n if (isPackageInstalled('next', packageJson, false, true)) {\n // Determine if it's App Router or Pages Router\n const cwd = process.cwd();\n const hasAppDir =\n fs.existsSync(path.join(cwd, 'app')) ||\n fs.existsSync(path.join(cwd, 'src', 'app'));\n const hasPagesDir =\n fs.existsSync(path.join(cwd, 'pages')) ||\n fs.existsSync(path.join(cwd, 'src', 'pages'));\n\n // App Router takes precedence if both exist\n if (hasAppDir) {\n return { name: 'next-app', type: 'react' };\n }\n if (hasPagesDir) {\n return { name: 'next-pages', type: 'react' };\n }\n // Default to app router for new Next.js projects\n return { name: 'next-app', type: 'react' };\n }\n\n // Check for Gatsby\n if (isPackageInstalled('gatsby', packageJson, false, true)) {\n return { name: 'gatsby', type: 'react' };\n }\n\n // Check for RedwoodJS\n if (isPackageInstalled('@redwoodjs/core', packageJson, false, true)) {\n return { name: 'redwood', type: 'react' };\n }\n\n // TanStack Start depends on Vite, so check it first\n if (isPackageInstalled('@tanstack/react-start', packageJson, false, true)) {\n return { name: 'tanstack-start', type: 'react' };\n }\n\n // React Router framework apps (e.g. Shopify Hydrogen) depend on Vite, so check them first\n // Detect @react-router/dev (not react-router) since plain Vite apps can install react-router\n if (isPackageInstalled('@react-router/dev', packageJson, false, true)) {\n return { name: 'react-router', type: 'react' };\n }\n\n // Expo and React Native apps also depend on react, so check them before\n // the generic Vite and React checks\n if (\n isPackageInstalled('expo', packageJson, false, true) ||\n isPackageInstalled('react-native', packageJson, false, true)\n ) {\n return { name: 'react-native', type: 'react-native' };\n }\n\n // Check for Vite\n if (isPackageInstalled('vite', packageJson, false, true)) {\n return { name: 'vite', type: 'react' };\n }\n\n // Check for React (generic)\n if (isPackageInstalled('react', packageJson, false, true)) {\n return { name: 'react', type: 'react' };\n }\n\n return { name: undefined };\n}\n\n// ----- HELPER FUNCTIONS ----- //\n\n/**\n * Detects if the current project is a Mintlify documentation project.\n *\n * Checks for the presence of docs.json (preferred) or mint.json (legacy) files.\n * For docs.json, validates that the $schema field contains \"mintlify.com/docs.json\".\n * Rejects projects with Next.js config files to avoid misclassification.\n *\n * @param _packageJson - The parsed package.json object (not used for Mintlify detection,\n * but kept for API consistency with other detection functions)\n * @returns True if the project is identified as a Mintlify project, false otherwise\n */\nexport function isMintlifyProject(\n _packageJson: Record<string, unknown> | null\n): boolean {\n const cwd = process.cwd();\n\n // Check for Next.js config files - if present, this is not a Mintlify project\n const nextConfigFiles = [\n 'next.config.js',\n 'next.config.ts',\n 'next.config.mjs',\n 'next.config.cjs',\n ];\n\n for (const configFile of nextConfigFiles) {\n if (fs.existsSync(path.join(cwd, configFile))) {\n return false;\n }\n }\n\n // Check for docs.json (preferred format)\n const docsJsonPath = path.join(cwd, 'docs.json');\n if (fs.existsSync(docsJsonPath)) {\n try {\n const docsJson = JSON.parse(fs.readFileSync(docsJsonPath, 'utf-8'));\n // Validate the $schema field contains mintlify.com/docs.json\n if (\n docsJson.$schema &&\n docsJson.$schema.includes('mintlify.com/docs.json')\n ) {\n return true;\n }\n } catch {\n return false;\n }\n }\n\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA,eAAsB,kBAIpB;CACA,MAAM,cAAc,MAAM,sBAAsB;AAEhD,KAAI,kBAAkB,YAAY,CAChC,QAAO,EAAE,MAAM,YAAY;AAG7B,KAAI,CAAC,YACH,QAAO,EAAE,MAAM,KAAA,GAAW;AAI5B,KAAI,mBAAmB,QAAQ,aAAa,OAAO,KAAK,EAAE;EAExD,MAAM,MAAM,QAAQ,KAAK;EACzB,MAAM,YACJ,GAAG,WAAW,KAAK,KAAK,KAAK,MAAM,CAAC,IACpC,GAAG,WAAW,KAAK,KAAK,KAAK,OAAO,MAAM,CAAC;EAC7C,MA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,CAC7B,KAAI;EACF,MAAM,WAAW,KAAK,MAAM,GAAG,aAAa,cAAc,QAAQ,CAAC;AAEnE,MACE,SAAS,WACT,SAAS,QAAQ,SAAS,yBAAyB,CAEnD,QAAO;SAEH;AACN,SAAO;;AAIX,QAAO"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { logger } from "../console/logger.js";
|
|
2
2
|
import { promptConfirm, promptSelect, promptText } from "../console/logging.js";
|
|
3
3
|
import { createUserAuthError } from "../auth/errors.js";
|
|
4
|
+
import { envFiles } from "../utils/loadEnv.js";
|
|
4
5
|
import { api } from "../utils/api.js";
|
|
5
6
|
import { setCredentials } from "../utils/credentials.js";
|
|
6
|
-
import { envFiles } from "../utils/loadEnv.js";
|
|
7
7
|
import { loginInteractively } from "../auth/interactiveLogin.js";
|
|
8
8
|
import { OnboardingError } from "./onboarding.js";
|
|
9
9
|
import chalk from "chalk";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# General Translation (GT) Internationalization Rules
|
|
2
2
|
|
|
3
|
-
This project is using [General Translation](https://generaltranslation.com/docs/overview.md) for internationalization (i18n) and translations. General Translation is a developer-first localization stack, built for the world's best engineering teams to ship apps in every language with ease.
|
|
3
|
+
This project is using [General Translation](https://generaltranslation.com/docs/overview/get-started.md) for internationalization (i18n) and translations. General Translation is a developer-first localization stack, built for the world's best engineering teams to ship apps in every language with ease.
|
|
4
4
|
|
|
5
5
|
## Configuration
|
|
6
6
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SupportedReactFrameworks } from '../types/index.js';
|
|
2
|
+
export type InitNextStepsContext = {
|
|
3
|
+
framework: SupportedReactFrameworks;
|
|
4
|
+
/** Setup added the GT provider or initializer to the app entry. */
|
|
5
|
+
configuredAppEntry: boolean;
|
|
6
|
+
/** Setup guide for the framework. */
|
|
7
|
+
docsUrl: string;
|
|
8
|
+
locales: string[];
|
|
9
|
+
/** The config setup wrote; named in the translate command unless default. */
|
|
10
|
+
configFilepath: string;
|
|
11
|
+
/** Set when translations are stored locally. */
|
|
12
|
+
translationsDir?: string;
|
|
13
|
+
/** The command that starts the dev server, when the app has a dev script. */
|
|
14
|
+
devCommand?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* What a person still has to do after the React setup: it configures the
|
|
18
|
+
* app entry but never marks content for translation. Plain text, so the same
|
|
19
|
+
* steps can be printed and reported in the --json result.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getInitNextSteps({ framework, configuredAppEntry, docsUrl, locales, configFilepath, translationsDir, devCommand, }: InitNextStepsContext): string[];
|
|
22
|
+
/**
|
|
23
|
+
* gt translate reads gt.config.json from the working directory by default,
|
|
24
|
+
* so another config is named with --config. A path goes into the command
|
|
25
|
+
* only when POSIX shells, Command Prompt and PowerShell all read it
|
|
26
|
+
* literally; no quoting works the same in all of them, so any other path is
|
|
27
|
+
* named outside the command.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getTranslateInstruction(configFilepath: string, platform?: NodeJS.Platform): string;
|
|
30
|
+
/** The final wizard message: one Done!, then the numbered next steps. */
|
|
31
|
+
export declare function formatInitNextSteps(steps: string[]): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getReactFrameworkLibrary } from "./frameworkUtils.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
//#region src/setup/nextSteps.ts
|
|
4
|
+
/**
|
|
5
|
+
* What a person still has to do after the React setup: it configures the
|
|
6
|
+
* app entry but never marks content for translation. Plain text, so the same
|
|
7
|
+
* steps can be printed and reported in the --json result.
|
|
8
|
+
*/
|
|
9
|
+
function getInitNextSteps({ framework, configuredAppEntry, docsUrl, locales, configFilepath, translationsDir, devCommand }) {
|
|
10
|
+
const library = getReactFrameworkLibrary({
|
|
11
|
+
name: framework,
|
|
12
|
+
type: "react"
|
|
13
|
+
});
|
|
14
|
+
const destination = translationsDir ? ` and save them to ${translationsDir}` : "";
|
|
15
|
+
return [
|
|
16
|
+
...configuredAppEntry ? [] : [`Add <GTProvider> from ${library} to the root of your app (see ${docsUrl})`],
|
|
17
|
+
`Wrap the text you want translated in <T>, or translate strings with useGT(); both come from ${library} (see ${docsUrl})`,
|
|
18
|
+
`Add <LocaleSelector /> from ${library} so visitors can switch language`,
|
|
19
|
+
`${getTranslateInstruction(configFilepath)} to translate your content into ${locales.join(", ")}${destination}`,
|
|
20
|
+
devCommand ? `Start the dev server with \`${devCommand}\` and switch language` : "Start your dev server and switch language"
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* gt translate reads gt.config.json from the working directory by default,
|
|
25
|
+
* so another config is named with --config. A path goes into the command
|
|
26
|
+
* only when POSIX shells, Command Prompt and PowerShell all read it
|
|
27
|
+
* literally; no quoting works the same in all of them, so any other path is
|
|
28
|
+
* named outside the command.
|
|
29
|
+
*/
|
|
30
|
+
function getTranslateInstruction(configFilepath, platform = process.platform) {
|
|
31
|
+
if (path.resolve(configFilepath) === path.resolve("gt.config.json")) return "Run `npx gt translate`";
|
|
32
|
+
return (platform === "win32" ? /^[\w./\\:+=-]+$/ : /^[\w./:+=-]+$/).test(configFilepath) ? `Run \`npx gt translate --config ${configFilepath}\`` : `Run \`npx gt translate\` with --config set to your config file (${configFilepath})`;
|
|
33
|
+
}
|
|
34
|
+
/** The final wizard message: one Done!, then the numbered next steps. */
|
|
35
|
+
function formatInitNextSteps(steps) {
|
|
36
|
+
return [
|
|
37
|
+
"Done! Setup did not mark any content for translation, so your app still renders only in its default locale. Since this wizard is experimental, please review its changes.",
|
|
38
|
+
"",
|
|
39
|
+
"Next steps:",
|
|
40
|
+
...steps.map((step, index) => `${index + 1}. ${step}`)
|
|
41
|
+
].join("\n");
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { formatInitNextSteps, getInitNextSteps, getTranslateInstruction };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=nextSteps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextSteps.js","names":[],"sources":["../../src/setup/nextSteps.ts"],"sourcesContent":["import path from 'node:path';\nimport type { SupportedReactFrameworks } from '../types/index.js';\nimport { getReactFrameworkLibrary } from './frameworkUtils.js';\n\nexport type InitNextStepsContext = {\n framework: SupportedReactFrameworks;\n /** Setup added the GT provider or initializer to the app entry. */\n configuredAppEntry: boolean;\n /** Setup guide for the framework. */\n docsUrl: string;\n locales: string[];\n /** The config setup wrote; named in the translate command unless default. */\n configFilepath: string;\n /** Set when translations are stored locally. */\n translationsDir?: string;\n /** The command that starts the dev server, when the app has a dev script. */\n devCommand?: string;\n};\n\n/**\n * What a person still has to do after the React setup: it configures the\n * app entry but never marks content for translation. Plain text, so the same\n * steps can be printed and reported in the --json result.\n */\nexport function getInitNextSteps({\n framework,\n configuredAppEntry,\n docsUrl,\n locales,\n configFilepath,\n translationsDir,\n devCommand,\n}: InitNextStepsContext): string[] {\n const library = getReactFrameworkLibrary({ name: framework, type: 'react' });\n const destination = translationsDir\n ? ` and save them to ${translationsDir}`\n : '';\n return [\n ...(configuredAppEntry\n ? []\n : [\n `Add <GTProvider> from ${library} to the root of your app (see ${docsUrl})`,\n ]),\n `Wrap the text you want translated in <T>, or translate strings with useGT(); both come from ${library} (see ${docsUrl})`,\n `Add <LocaleSelector /> from ${library} so visitors can switch language`,\n `${getTranslateInstruction(configFilepath)} to translate your content into ${locales.join(', ')}${destination}`,\n devCommand\n ? `Start the dev server with \\`${devCommand}\\` and switch language`\n : 'Start your dev server and switch language',\n ];\n}\n\n/**\n * gt translate reads gt.config.json from the working directory by default,\n * so another config is named with --config. A path goes into the command\n * only when POSIX shells, Command Prompt and PowerShell all read it\n * literally; no quoting works the same in all of them, so any other path is\n * named outside the command.\n */\nexport function getTranslateInstruction(\n configFilepath: string,\n platform: NodeJS.Platform = process.platform\n): string {\n if (path.resolve(configFilepath) === path.resolve('gt.config.json')) {\n return 'Run `npx gt translate`';\n }\n const literal = platform === 'win32' ? /^[\\w./\\\\:+=-]+$/ : /^[\\w./:+=-]+$/;\n return literal.test(configFilepath)\n ? `Run \\`npx gt translate --config ${configFilepath}\\``\n : `Run \\`npx gt translate\\` with --config set to your config file (${configFilepath})`;\n}\n\n/** The final wizard message: one Done!, then the numbered next steps. */\nexport function formatInitNextSteps(steps: string[]): string {\n return [\n 'Done! Setup did not mark any content for translation, so your app still renders only in its default locale. Since this wizard is experimental, please review its changes.',\n '',\n 'Next steps:',\n ...steps.map((step, index) => `${index + 1}. ${step}`),\n ].join('\\n');\n}\n"],"mappings":";;;;;;;;AAwBA,SAAgB,iBAAiB,EAC/B,WACA,oBACA,SACA,SACA,gBACA,iBACA,cACiC;CACjC,MAAM,UAAU,yBAAyB;EAAE,MAAM;EAAW,MAAM;EAAS,CAAC;CAC5E,MAAM,cAAc,kBAChB,qBAAqB,oBACrB;AACJ,QAAO;EACL,GAAI,qBACA,EAAE,GACF,CACE,yBAAyB,QAAQ,gCAAgC,QAAQ,GAC1E;EACL,+FAA+F,QAAQ,QAAQ,QAAQ;EACvH,+BAA+B,QAAQ;EACvC,GAAG,wBAAwB,eAAe,CAAC,kCAAkC,QAAQ,KAAK,KAAK,GAAG;EAClG,aACI,+BAA+B,WAAW,0BAC1C;EACL;;;;;;;;;AAUH,SAAgB,wBACd,gBACA,WAA4B,QAAQ,UAC5B;AACR,KAAI,KAAK,QAAQ,eAAe,KAAK,KAAK,QAAQ,iBAAiB,CACjE,QAAO;AAGT,SADgB,aAAa,UAAU,oBAAoB,iBAC5C,KAAK,eAAe,GAC/B,mCAAmC,eAAe,MAClD,mEAAmE,eAAe;;;AAIxF,SAAgB,oBAAoB,OAAyB;AAC3D,QAAO;EACL;EACA;EACA;EACA,GAAG,MAAM,KAAK,MAAM,UAAU,GAAG,QAAQ,EAAE,IAAI,OAAO;EACvD,CAAC,KAAK,KAAK"}
|
|
@@ -57,6 +57,8 @@ export type OnboardingEvent = {
|
|
|
57
57
|
url?: string;
|
|
58
58
|
/** Manual steps setup could not do, for needs_human_action. */
|
|
59
59
|
actions?: string[];
|
|
60
|
+
/** What to do next once setup succeeded, e.g. marking content for translation. */
|
|
61
|
+
nextSteps?: string[];
|
|
60
62
|
missingOptions?: string[];
|
|
61
63
|
error?: string;
|
|
62
64
|
};
|
|
@@ -104,6 +106,7 @@ export declare class OnboardingSession {
|
|
|
104
106
|
}
|
|
105
107
|
export type OnboardingOutcome = {
|
|
106
108
|
outcome: 'success';
|
|
109
|
+
nextSteps?: string[];
|
|
107
110
|
} | {
|
|
108
111
|
outcome: 'needs_human_action';
|
|
109
112
|
url: string;
|
package/dist/setup/onboarding.js
CHANGED
|
@@ -6,8 +6,8 @@ import { withJsonExtension } from "../fs/config/loadConfig.js";
|
|
|
6
6
|
import { SETUP_FILE_FORMATS } from "../formats/files/supportedFiles.js";
|
|
7
7
|
import { getFrameworkDisplayName, getReactFrameworkLibrary } from "./frameworkUtils.js";
|
|
8
8
|
import { getBuildToolSetup } from "./buildTools/index.js";
|
|
9
|
-
import { SUPPORTED_REACT_FRAMEWORKS } from "../types/index.js";
|
|
10
9
|
import { NoPackageManagerError, getPackageManager, packageManagers } from "../utils/packageManager.js";
|
|
10
|
+
import { SUPPORTED_REACT_FRAMEWORKS } from "../types/index.js";
|
|
11
11
|
import { installPackage } from "../utils/installPackage.js";
|
|
12
12
|
import { createDiagnosticMessage, formatDiagnosticErrorDetails } from "generaltranslation/internal";
|
|
13
13
|
import fs from "node:fs";
|
|
@@ -172,7 +172,8 @@ async function runOnboarding(command, options, run) {
|
|
|
172
172
|
outcome: needsHuman ? "needs_human_action" : "success",
|
|
173
173
|
completedSteps: session.completedSteps,
|
|
174
174
|
...result.outcome === "needs_human_action" && { url: result.url },
|
|
175
|
-
...session.humanActions.length > 0 && { actions: session.humanActions }
|
|
175
|
+
...session.humanActions.length > 0 && { actions: session.humanActions },
|
|
176
|
+
...result.outcome === "success" && result.nextSteps !== void 0 && result.nextSteps.length > 0 && { nextSteps: result.nextSteps }
|
|
176
177
|
});
|
|
177
178
|
} catch (error) {
|
|
178
179
|
const message = error instanceof Error ? error.message : formatDiagnosticErrorDetails(error) ?? "Setup failed";
|