UNPKG

@puls-atlas/cli

Version:

The Puls Atlas CLI tool for managing Atlas projects

24 lines 6.08 kB
import handlers from './index.js'; import hooks from '../../hooks/index.js'; import { createOptionsOnlyAction } from '../options.js'; const registerSearchCommands = (program, { withEnvironmentOptions }, dependencies = {}) => { const commandHandlers = dependencies.handlers ?? handlers; const commandHooks = dependencies.hooks ?? hooks; const search = program.command('search').description('Atlas search lifecycle commands.'); const searchSource = search.command('source').description('Atlas search source commands.'); withEnvironmentOptions(search.command('apply').description('Apply the Atlas search lifecycle plan for the selected project.').option('--platform <platform>', 'Managed provider runtime platform: compute or gke.').option('--zone <zone>', 'Compute Engine zone used when platform=compute.').option('--create-cluster', 'Create a managed GKE cluster before deploying the provider workload.').option('--cluster-name <clusterName>', 'GKE cluster name to create or target when platform=gke.').option('--cluster-location <clusterLocation>', 'GKE cluster location to create or target when platform=gke.').option('--generate-config-only', 'Skip provisioning and generate only the local Atlas search runtime config from deployed Cloud Run services.').option('--dry-run', 'Render and validate the apply flow without executing remote changes.')).action(commandHandlers.apply).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(searchSource.command('add').description('Add or scaffold a source in Atlas search config.').option('--type <sourceType>', 'Source type to onboard. Supported values: firestore, http.', 'firestore').option('--path <sourcePath>', 'Use an explicit Firestore source path for --type firestore onboarding.').option('--name <sourceName>', 'Canonical source name for scheduled-source scaffolding.').option('--index <indexName>', 'Logical index name for --type http onboarding.').option('--mapper <mapperName>', 'Mapper name to use or create for the source.').option('--method <method>', 'HTTP request method for --type http: GET or POST.').option('--url <url>', 'HTTP endpoint URL for --type http.').option('--schedule <schedule>', 'Cloud Scheduler cron expression for scheduled sources.').option('--connection-secret <secretName>', 'Secret Manager secret name that holds source access credentials.').option('--sync-class <syncClass>', 'Scheduled source sync class for --type http: delta-merge or append-only.').option('--interactive', 'Prompt for source onboarding inputs.').option('--dry-run', 'Preview generated config and mapper changes without writing files.')).action(commandHandlers.source.add).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(search.command('destroy').description('Destroy Atlas search runtime components.')).action(commandHandlers.destroy).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(search.command('init').description('Initialize Atlas search config and search scaffolding in the current project.').option('--interactive', 'Prompt for provider selection when scaffolding search config.').option('--provider <provider>', 'Search provider to persist in the active Atlas search config file.').option('--platform <platform>', 'Managed provider runtime platform to persist during init: compute or gke.').option('--zone <zone>', 'Compute Engine zone to persist when platform=compute.').option('--create-cluster', 'Persist a managed GKE cluster selection when platform=gke.').option('--cluster-name <clusterName>', 'GKE cluster name to persist or create when platform=gke.').option('--cluster-location <clusterLocation>', 'GKE cluster location to persist or create when platform=gke.')).action(commandHandlers.init).hook('preAction', commandHooks.versionCheck); const searchPromote = withEnvironmentOptions(search.command('promote').description('Promote Atlas search runtime routing or release metadata for the selected project.').option('--mode <mode>', 'Promotion mode. Supported values: cutover, rollback, cleanup, release, manual.', 'cutover').option('--force', 'Force runtime cleanup even when the rollback grace period is active.').option('--indexes <indexes>', 'Comma-separated index names to target.')); searchPromote.action(commandHandlers.promote).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(searchPromote.command('status').description('Show Atlas search promotion status for the selected project.')).action(createOptionsOnlyAction(commandHandlers.promoteStatus)).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(search.command('repair <target>').description('Repair a failed Atlas search runtime item.').option('--collection <collection>', 'Logical Atlas source collection name.').option('--document-id <documentId>', 'Logical Atlas source document id.')).action(commandHandlers.repair).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(search.command('run <action>').description('Run an Atlas search runtime action. Actions: backfill, reindex, source.').option('--indexes <indexes>', 'Comma-separated index names to target.').option('--source <sourceName>', 'Source name for "atlas search run source".').option('--dry-run', 'Print the concrete runtime action command without executing it.').option('--detached', 'Start the runtime execution without following it to completion.').option('--timeout <seconds>', 'Maximum runtime watch duration in seconds.')).action(commandHandlers.run).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(search.command('status').description('Show Atlas search resource status for the selected project.').option('--json', 'Print the normalized Atlas search status payload as JSON.')).action(commandHandlers.status).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(search.command('verify').description('Verify Atlas search resources in the selected project.')).action(commandHandlers.verify).hook('preAction', commandHooks.versionCheck); return search; }; export default registerSearchCommands;