export { ResolutionResult, CDecodeConfig as ServerCDecodeConfig, ServerConfig, analyzeModuleDependencies, generateResolutionsFromCDecodeConfig, generateServerResolutions, getServersFromCDecodeConfig, readCDecodeConfig as readCDecodeConfigFromServer, updateServerPackageJson } from '@common-stack/rollup-vite-utils'; import { Command } from 'commander'; /** * Central configuration types for cdecode-config.json * * This file defines the structure of the cdecode-config.json configuration file * that drives all the common-tools utilities. */ interface CDecodeConfig { /** Server config.json paths for codegen */ servers?: string[]; /** Codegen configuration */ codegen?: CodegenConfig; /** Update dependencies configuration */ updateDependencies?: UpdateDependenciesConfig; /** Update dependency version configuration */ updateDependencyVersion?: UpdateDependencyVersionConfig; /** Sort package.json configuration */ sortPackageJson?: SortPackageJsonConfig; /** Deploy version update configuration */ deployVersionUpdate?: DeployVersionUpdateConfig; /** Project paths configuration */ projectPaths?: ProjectPathsConfig; /** Service schemas configuration */ serviceSchemas?: ServiceSchemasConfig; } interface CodegenConfig { outputFile?: string; rootSchema?: string; fullConfig?: Record; } interface UpdateDependenciesConfig { /** Packages to check for updates */ packagesToCheck?: string[]; /** Package paths by category */ packagePaths?: { backend?: string[]; frontend?: string[]; mobile?: string[]; }; } interface UpdateDependencyVersionConfig { /** Root directories to scan */ roots?: string[]; /** Pattern to ignore */ ignorePattern?: string; /** JSON indentation spacing */ jsonSpacing?: number; /** Add newline at end of files */ addEndNewLine?: boolean; /** Git commit message */ commitMessage?: string; } interface SortPackageJsonConfig { /** Directories to process */ directories?: string[]; /** Skip node_modules directories */ skipNodeModules?: boolean; } interface DeployVersionUpdateConfig { lernaJsonPath?: string; jenkinsfilePath?: string; valuesDevYamlPath?: string; valuesProdYamlPath?: string; } interface ProjectPathsConfig { packages?: string; packagesModules?: string; servers?: string; portableDevices?: string; } interface ServiceSchemasConfig { servicesDir?: string; outputFile?: string; skipServices?: string[]; knownEnums?: string[]; constEnumSchemas?: string[]; graphqlSchemasPath?: string; } /** * Default configuration values */ declare const DEFAULT_CONFIG: Partial; /** * Configuration loader for cdecode-config.json */ /** * Finds the cdecode-config.json file by walking up the directory tree */ declare function findConfigFile(startDir?: string): string | null; /** * Loads and parses the cdecode-config.json file */ declare function loadConfig(rootDir?: string): { config: CDecodeConfig; configPath: string; repoRoot: string; }; /** * Loads config with defaults merged in */ declare function loadConfigWithDefaults(rootDir?: string): { config: CDecodeConfig; configPath: string; repoRoot: string; }; /** * Resolves relative paths in config to absolute paths */ declare function resolveConfigPaths(config: CDecodeConfig, repoRoot: string): CDecodeConfig; /** * Package.json utility functions */ declare const JSON_SPACING = 4; declare const ADD_END_NEWLINE = true; interface PackageJson { name?: string; version?: string; dependencies?: Record; devDependencies?: Record; peerDependencies?: Record; resolutions?: Record; [key: string]: unknown; } /** * Reads and parses a package.json file */ declare function readPackageJson(filePath: string): Promise; /** * Reads and parses a package.json file synchronously */ declare function readPackageJsonSync(filePath: string): PackageJson; /** * Writes a package.json file with proper formatting */ declare function writePackageJson(filePath: string, content: PackageJson, options?: { spacing?: number; endNewline?: boolean; }): Promise; /** * Writes a package.json file synchronously with proper formatting */ declare function writePackageJsonSync(filePath: string, content: PackageJson, options?: { spacing?: number; endNewline?: boolean; }): void; /** * Merges dependencies from source into target */ declare function mergeDependencies(target?: Record, source?: Record): Record; /** * Sorts an object's keys alphabetically */ declare function sortObjectKeys>(obj: T): T; /** * Checks if a file exists */ declare function fileExists(filePath: string): Promise; /** * Checks if a file exists synchronously */ declare function fileExistsSync(filePath: string): boolean; /** * Dependency management utilities */ /** * Executes a command in a directory and returns a promise */ declare function execCommand(command: string, cwd: string): Promise; /** * Configuration for dependency update operations */ interface DependencyUpdateConfig { /** Paths to server/app package.json files by category */ packagePaths: { backend?: string[]; frontend?: string[]; mobile?: string[]; }; /** Packages to check and update */ packagesToCheck: string[]; /** Root directory of the monorepo */ rootDir: string; } /** * Default packages to check for @common-stack based monorepos */ declare const DEFAULT_COMMON_STACK_PACKAGES: string[]; /** * Updates dependencies in a target package.json from a source package.json */ declare function updateDependencies(targetPackagePath: string, sourcePackagePath: string): Promise; /** * Gets the target package paths based on the package name */ declare function getTargetPathsForPackage(packageName: string, config: DependencyUpdateConfig): string[]; /** * Runs npm-check-updates for @common-stack packages */ declare function runNcuUpdate(rootDir: string): Promise; /** * Runs yarn install from the root directory */ declare function runYarnInstall(rootDir: string): Promise; /** * Runs the complete dependency update workflow */ declare function runUpdateDependenciesWorkflow(config: DependencyUpdateConfig): Promise; /** * Monorepo utilities for finding and processing packages */ /** * Finds all package.json files in a monorepo */ declare function findPackageJsonFiles(rootDir: string, patterns?: string[]): Promise; /** * Builds a map of package name to path and version */ declare function buildPackageMap(rootDir: string, patterns?: string[]): Promise>; /** * Recursively finds all directories containing package.json */ declare function findPackageDirectories(dir: string, options?: { exclude?: string[]; }): Promise; /** * Gets all workspace packages from yarn/npm workspaces config */ declare function getWorkspacePackages(rootPackageJsonPath: string): Promise; /** * Reads cdecode-config.json from a directory */ declare function readCDecodeConfigFile(rootDir: string): Record | null; /** * CLI for generating package resolutions * * Reads configuration from cdecode-config.json: * - updateDependencies.packagePaths: Server package.json paths by category */ interface GenerateResolutionsOptions { category: 'backend' | 'frontend' | 'mobile' | 'all'; dryRun: boolean; packages: string[]; } /** * Creates the generate-resolutions command */ declare function createGenerateResolutionsCommand(): Command; /** * Runs the resolution generation process */ declare function runGenerateResolutions(repoRoot: string, options: GenerateResolutionsOptions): Promise; /** * Standalone CLI entry point */ declare function runGenerateResolutionsCLI(args?: string[]): Promise; /** * CLI for updating dependencies from @common-stack packages * * Reads configuration from cdecode-config.json: * - updateDependencies.packagesToCheck: Packages to check for updates * - updateDependencies.packagePaths: Server package.json paths by category */ interface UpdateDependenciesOptions { packages?: string[]; skipNcu?: boolean; skipYarn?: boolean; } /** * Creates the update-dependencies command */ declare function createUpdateDependenciesCommand(): Command; /** * Runs the update dependencies CLI action */ declare function runUpdateDependenciesCLIAction(rootDir: string, options: UpdateDependenciesOptions, configPackagePaths?: DependencyUpdateConfig['packagePaths']): Promise; /** * Standalone CLI entry point */ declare function runUpdateDependenciesCLI(args?: string[]): Promise; /** * CLI for sorting package.json files * * Reads configuration from cdecode-config.json: * - sortPackageJson.directories: Directories to process * - sortPackageJson.skipNodeModules: Skip node_modules directories */ interface SortPackageJsonOptions { directories?: string[]; recursive?: boolean; dryRun?: boolean; } /** * Creates the sort-package-json command */ declare function createSortPackageJsonCommand(): Command; /** * Sorts a single package.json file */ declare function sortPackageJsonFile(filePath: string, options?: { dryRun?: boolean; }): Promise; /** * Recursively sorts all package.json files in a directory */ declare function sortAllPackageJsonFiles(dir: string, options?: { dryRun?: boolean; }): Promise<{ sorted: string[]; unchanged: string[]; errors: string[]; }>; /** * Runs the sort package.json process */ declare function runSortPackageJson(rootDir: string, options: SortPackageJsonOptions): Promise; /** * Standalone CLI entry point */ declare function runSortPackageJsonCLI(args?: string[]): Promise; /** * CLI for updating dependency versions across monorepo packages * * Reads configuration from cdecode-config.json: * - updateDependencyVersion.roots: Root directories to scan * - updateDependencyVersion.ignorePattern: Pattern to ignore * - updateDependencyVersion.jsonSpacing: JSON indentation * - updateDependencyVersion.addEndNewLine: Add newline at end * - updateDependencyVersion.commitMessage: Git commit message * * This tool updates all package.json files to use consistent versions * for internal monorepo packages and replaces link: references with actual versions. */ interface UpdateDependencyVersionOptions { commit?: boolean; dryRun?: boolean; } /** * Creates the update-dependency-version command */ declare function createUpdateDependencyVersionCommand(): Command; /** * Updates all package.json files in the monorepo */ declare function updateDependencyVersions(monorepoRoot: string, options?: { dryRun?: boolean; config?: UpdateDependencyVersionConfig; }): Promise; /** * Runs the update dependency version process */ declare function runUpdateDependencyVersion(rootDir: string, options: UpdateDependencyVersionOptions, config?: UpdateDependencyVersionConfig): Promise; /** * Standalone CLI entry point */ declare function runUpdateDependencyVersionCLI(args?: string[]): Promise; /** * CLI command: prepWebConfig * * Generates the merged configuration (cde-webconfig.json) for a frontend server * by resolving default-config.json + project config.json + environment variables. * * Usage: * cdecodecli prepWebConfig [options] * * Options: * --config Path to project config.json (default: ./config.json) * --out Output directory for the generated config (default: ./app) * --env-file Path to a .env file to load (falls back to ENV_FILE env var) */ declare function createPrepWebConfigCommand(): Command; interface PrepWebConfigOptions { configPath: string; outputDir: string; envFile?: string; } declare function runPrepWebConfig(options: PrepWebConfigOptions): Promise; export { ADD_END_NEWLINE, DEFAULT_COMMON_STACK_PACKAGES, DEFAULT_CONFIG, JSON_SPACING, buildPackageMap, createGenerateResolutionsCommand, createPrepWebConfigCommand, createSortPackageJsonCommand, createUpdateDependenciesCommand, createUpdateDependencyVersionCommand, execCommand, fileExists, fileExistsSync, findConfigFile, findPackageDirectories, findPackageJsonFiles, getTargetPathsForPackage, getWorkspacePackages, loadConfig, loadConfigWithDefaults, mergeDependencies, readCDecodeConfigFile, readPackageJson, readPackageJsonSync, resolveConfigPaths, runGenerateResolutions, runGenerateResolutionsCLI, runNcuUpdate, runPrepWebConfig, runSortPackageJson, runSortPackageJsonCLI, runUpdateDependenciesCLI, runUpdateDependenciesCLIAction, runUpdateDependenciesWorkflow, runUpdateDependencyVersion, runUpdateDependencyVersionCLI, runYarnInstall, sortAllPackageJsonFiles, sortObjectKeys, sortPackageJsonFile, updateDependencies, updateDependencyVersions, writePackageJson, writePackageJsonSync }; export type { CDecodeConfig, CodegenConfig, DependencyUpdateConfig, DeployVersionUpdateConfig, GenerateResolutionsOptions, PackageJson, PrepWebConfigOptions, ProjectPathsConfig, ServiceSchemasConfig, SortPackageJsonConfig, SortPackageJsonOptions, UpdateDependenciesConfig, UpdateDependenciesOptions, UpdateDependencyVersionConfig, UpdateDependencyVersionOptions };