//#region src/init/utils/packageManager.d.ts /** Package managers supported for dependency installation. */ export type PackageManager = 'bun' | 'pnpm' | 'yarn' | 'npm'; /** * Configuration for the syncJSON plugin injected into intlayer.config * when a compat i18n library is detected. */ export type CompatSyncConfig = { /** * Which sync plugin ingests the catalogs: * - `'json'` → `syncJSON` from `@intlayer/sync-json-plugin` (default). * - `'po'` → `syncPO` from `@intlayer/sync-po-plugin` (lingui's default * format). */ plugin?: 'json' | 'po'; /** * JSON format matching the compat library's conventions. Ignored when * `plugin` is `'po'` (PO catalogs are always serialized as gettext). */ format: 'icu' | 'i18next' | 'vue-i18n'; /** * Source path template using ${locale} and ${key} placeholders. * Rendered as a template literal in the generated config. */ sourceTemplate: string; /** * Force `splitKeys: true` in the generated `syncJSON(...)` call so each * top-level key of a single per-locale file becomes its own dictionary. * * Set for libraries whose single `messages/${locale}.json` file groups * namespaces by its first-level keys (`next-intl` / `use-intl`, where * `useTranslations('Hero')` resolves to the `Hero` dictionary). Left * undefined for libraries whose top-level keys are plain message keys * (e.g. `i18next`, `react-intl`); for those, syncJSON's auto-detection * (split only when the source has no `${key}` segment) stays in control. * * Only meaningful for flat templates (no `${key}` segment); it is dropped * automatically when the resolved template addresses one namespace per file. */ splitKeys?: boolean; }; /** * Configuration for injecting a compat vite plugin into vite.config. * The plugin replaces the generic `intlayer` plugin for libraries that * require alias injection (e.g. `vue-i18n` → `@intlayer/vue-i18n`). */ export type CompatVitePluginConfig = { /** Exported function name from the plugin package, e.g. `'vueI18nVitePlugin'`. */ pluginFunctionName: string; /** Import path for the plugin package, e.g. `'@intlayer/vue-i18n/plugin'`. */ pluginPackageSource: string; /** * Set when the compat plugin is a drop-in replacement for an i18n library's * own Vite plugin (e.g. lingui ships `@lingui/vite-plugin`). When the original * import is present, init rewrites only that import's module source to * `pluginPackageSource` — keeping the binding and its call site — instead of * injecting a second import and appending another plugin to the array. */ replacesVitePlugin?: { /** Imported binding to keep, e.g. `'lingui'`. */ importName: string; /** Original package source to rewrite, e.g. `'@lingui/vite-plugin'`. */ fromPackageSource: string; }; }; /** Result of analyzing project dependencies for intlayer package gaps. */ export type IntlayerPackageAnalysis = { /** Intlayer packages that are referenced but not yet installed. */ packagesToInstall: string[]; /** Intlayer dev packages that are referenced but not yet installed. */ devPackagesToInstall: string[]; /** * syncJSON plugin configuration to inject when a compat i18n library is * detected. Undefined when no compat library is present or format is not * yet implemented. */ compatSyncConfig: CompatSyncConfig | undefined; /** * Vite config plugin to inject when a vite-based compat library is * detected. Undefined for Next.js/Nuxt-only compat libs or when no compat * library requires alias injection. */ compatVitePluginConfig: CompatVitePluginConfig | undefined; }; /** * Detects the package manager in use by checking for lock files in the * project root. Falls back to npm when no lock file is found. */ export declare const detectPackageManager: (rootDir: string) => PackageManager; /** * Analyzes existing project dependencies to determine which intlayer packages * are missing and what syncJSON configuration to inject when compat i18n * libraries are present. */ /** Extra signals (from a filesystem scan) that refine compat detection. */ export type DetectMissingPackagesOptions = { /** * Catalog format detected for a lingui project (`'po'` or `'json'`), or * `null`/undefined when none was found. Decides which sync plugin + dev * dependency the lingui compat setup uses. */ linguiCatalogFormat?: 'po' | 'json' | null; }; /** An existing i18n library Intlayer ships a compat adapter for. */ export type CompatI18nLibrary = { /** Human-readable name, used to report the detection back to the user. */ label: string; /** * Dependency names that reveal the library — both the upstream packages and * the Intlayer adapters, so a project that already ran `init` is still * recognized. */ packages: readonly string[]; }; /** * Existing i18n libraries Intlayer can adapt, keyed by the dependencies that * reveal them. Mirrors the compat branches of * {@link detectMissingIntlayerPackages}: a library listed here is one that * detection will wire up on its own once its package is in `package.json`. */ export declare const COMPAT_I18N_LIBRARIES: readonly CompatI18nLibrary[]; /** * Returns the labels of the compat i18n libraries present in `dependencies`. * * Lets the init flow report (and branch on) the libraries it found without * asking the user, since {@link detectMissingIntlayerPackages} already derives * the adapters, sync plugin and config from the very same dependency map. * * @param dependencies - Merged dependencies of the target project. */ export declare const detectCompatI18nLibraries: (dependencies: Record) => string[]; /** * True when the project already lints, and so has something to plug the * Intlayer lint rules into. * * `eslint-plugin-intlayer` loads in both ESLint and oxlint, so either linter is * enough. Shared with the init flow so that installing the plugin and wiring up * its configuration are gated on exactly the same condition — a project that * does not lint is left alone entirely. * * @param dependencies - Merged dependencies of the target project. */ export declare const hasLintTooling: (dependencies: Record) => boolean; export declare const detectMissingIntlayerPackages: (allDependencies: Record, options?: DetectMissingPackagesOptions) => IntlayerPackageAnalysis; /** * Runs the package install command synchronously. * Throws if the install process exits with a non-zero code. */ export declare const installPackages: (rootDir: string, packages: string[], packageManager: PackageManager, isDev?: boolean) => void; /** * Determines whether a dependency name belongs to the Intlayer ecosystem. * * Matches the core `intlayer` package, every scoped `@intlayer/*` package * (including compat adapters such as `@intlayer/next-intl`) and the framework * runtime integrations that follow the `-intlayer` convention * (e.g. `next-intlayer`, `react-intlayer`, `express-intlayer`). */ export declare const isIntlayerPackageName: (packageName: string) => boolean; /** * Reduces a semver range or full version to its `major.minor.patch` core, * stripping range prefixes (`^`, `~`), pre-release identifiers and build * metadata. Returns `null` when no `major.minor.patch` can be extracted. * * @example normalizeVersion('^9.0.0-canary.3') // '9.0.0' */ export declare const normalizeVersion: (version?: string) => string | null; /** * Reads the installed version of a package from its `package.json` inside the * project's `node_modules`. Returns `null` when the package is not installed or * its manifest cannot be read. */ export declare const getInstalledPackageVersion: (rootDir: string, packageName: string) => string | null; /** * Returns the Intlayer packages from `dependencies` whose installed version is * behind `targetVersion` (compared on `major.minor.patch`). Packages that are * not installed yet are ignored — those are handled by * {@link detectMissingIntlayerPackages}. */ export declare const detectOutdatedIntlayerPackages: (rootDir: string, dependencies: Record, targetVersion: string) => string[]; /** * Upgrades the given packages to `targetVersion` synchronously, preserving the * dependency type via the `isDev` flag. Throws if the install process exits * with a non-zero code. */ export declare const upgradePackages: (rootDir: string, packages: string[], packageManager: PackageManager, targetVersion: string, isDev?: boolean) => void; //#endregion //# sourceMappingURL=packageManager.d.ts.map