UNPKG

@puls-atlas/cli

Version:

The Puls Atlas CLI tool for managing Atlas projects

25 lines 6 kB
import handlers from './index.js'; import hooks from '../../hooks/index.js'; import { createOptionsOnlyAction } from '../options.js'; const registerSyncCommands = (program, { withEnvironmentOptions }, dependencies = {}) => { const commandHandlers = dependencies.handlers ?? handlers; const commandHooks = dependencies.hooks ?? hooks; const sync = program.command('sync').description('Atlas sync lifecycle commands.'); const syncWorkload = sync.command('workload').description('Atlas sync workload commands.'); withEnvironmentOptions(sync.command('apply').description('Compile the Atlas sync plan and write the local runtime config for the selected project.').option('--dry-run', 'Preview the generated Atlas sync runtime config without writing it.')).action(commandHandlers.apply).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(sync.command('init').description('Initialize Atlas sync config scaffolding in the current project.')).action(commandHandlers.init).hook('preAction', commandHooks.versionCheck); const syncPromote = withEnvironmentOptions(sync.command('promote').description('Promote or inspect the current Atlas sync release state for the selected project.')); syncPromote.action(commandHandlers.promote).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(syncPromote.command('status').description('Show Atlas sync promotion status for the selected project.')).action(createOptionsOnlyAction(commandHandlers.promoteStatus)).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(sync.command('deploy').description('Deploy Atlas sync runtime infrastructure and Cloud Run services for the selected project.').option('--dry-run', 'Generate a Terraform plan without applying any changes.')).action(commandHandlers.deploy).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(sync.command('destroy').description('Destroy all Atlas sync Cloud Run resources and clean up generated artifacts for the selected project.')).action(commandHandlers.destroy).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(sync.command('run <action>').description('Run an Atlas sync runtime action for one or more configured workloads. Actions: backfill, incremental.').option('--workloads <workloads>', 'Comma-separated workload keys to target (backfill).').option('--workload-key <workloadKey>', 'Workload key to target (incremental).').option('--document-id <documentId>', 'Source document ID to sync (incremental).').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(sync.command('status').description('Show Atlas sync config status for the selected project.').option('--local-only', 'Skip remote Cloud Run resource discovery.')).action(commandHandlers.status).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(sync.command('verify').description('Verify Atlas sync config for the selected project.').option('--local-only', 'Skip remote Cloud Run resource checks.')).action(commandHandlers.verify).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(syncWorkload.command('add').description('Scaffold a workload-first Atlas sync pipeline in the selected project.').option('--source-type <sourceType>', 'Source type to scaffold. Supported values: firestore, http, sql.', 'firestore').option('--destination-type <destinationType>', 'Destination type to scaffold. Supported values: bigquery, postgres.', 'bigquery').option('--name <name>', 'Logical workload base name when it cannot be derived.').option('--path <collectionPath>', 'Firestore collection path for --source-type firestore.').option('--mapper <mapperName>', 'Mapper function base name override.').option('--schedule <schedule>', 'Schedule override for http and sql bindings.').option('--url <url>', 'HTTP endpoint URL for --source-type http.').option('--method <method>', 'HTTP request method for --source-type http: GET or POST.').option('--sync-class <syncClass>', 'Source sync class override. Supported values depend on the selected source type.').option('--driver <driver>', 'SQL driver override for --source-type sql.').option('--query <query>', 'SQL watermark query override for --source-type sql.').option('--dataset <dataset>', 'BigQuery dataset binding override.').option('--table <table>', 'Destination table binding override.').option('--schema <schema>', 'PostgreSQL schema binding override.').option('--source-connection-secret <secretName>', 'Secret Manager binding override for http/sql source access.').option('--destination-connection-secret <secretName>', 'Secret Manager binding override for postgres destination access.').option('--firestore-database <database>', 'Firestore database override for source binding.').option('--trigger-region <region>', 'Firestore/Eventarc trigger region override.').option('--batch-size <batchSize>', 'Workload batch size override.').option('--enable', 'Enable the new workload binding immediately.').option('--dry-run', 'Preview scaffolded files and config updates without writing them.')).action(commandHandlers.workload.add).hook('preAction', commandHooks.versionCheck); withEnvironmentOptions(sync.command('repair').description('Replay a failed Atlas sync item from the DLQ back into the task queue.').requiredOption('--workload-key <workloadKey>', 'Workload key of the failing sync item.').requiredOption('--document-id <documentId>', 'Source document ID of the failed sync item.').option('--document-path <documentPath>', 'Full Firestore document path when the document ID is not sufficient to derive it.')).action(commandHandlers.repair).hook('preAction', commandHooks.versionCheck); return sync; }; export default registerSyncCommands;