feat: add deployment config sync commands
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import json
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from workflows.portal_config_sync import export_portal_deployment_config_payload, write_portal_deployment_config_export
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Export branding and company configuration to JSON for environment sync.'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--output', help='Write the export to a file instead of stdout.')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
output = options.get('output')
|
||||
if output:
|
||||
path = write_portal_deployment_config_export(output)
|
||||
self.stdout.write(self.style.SUCCESS(f'Exported portal deployment config to {path}'))
|
||||
return
|
||||
|
||||
payload = export_portal_deployment_config_payload()
|
||||
self.stdout.write(json.dumps(payload, indent=2, default=str))
|
||||
@@ -0,0 +1,23 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
from workflows.portal_config_sync import import_portal_deployment_config_payload, load_portal_deployment_config_payload
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Import branding and company configuration JSON for environment sync.'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('input', help='Path to a previously exported deployment config JSON file.')
|
||||
parser.add_argument('--dry-run', action='store_true', help='Validate and report without saving.')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
try:
|
||||
payload = load_portal_deployment_config_payload(options['input'])
|
||||
summary = import_portal_deployment_config_payload(payload, dry_run=options['dry_run'])
|
||||
except (OSError, ValueError) as exc:
|
||||
raise CommandError(str(exc)) from exc
|
||||
|
||||
mode = 'Dry run' if options['dry_run'] else 'Import'
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(f"{mode} complete. updated_fields={summary['updated_fields']}")
|
||||
)
|
||||
Reference in New Issue
Block a user