handleDeployJasprServer function

Future<void> handleDeployJasprServer()

Deploy the Jaspr server (SSR / hybrid render modes) to Cloud Run.

Standalone entry point invoked by oracular deploy jaspr-server. Identical to the Jaspr-server stage of handleDeployAll but re-runnable in isolation when only the Jaspr binary needs to be shipped (e.g. content-only updates or hot fixes that don't touch Firebase rules or arcane_server).

Implementation

Future<void> handleDeployJasprServer() async {
  final SetupConfig? config = await ProjectConfigLoader.load();
  if (config == null) {
    ProjectConfigLoader.printMissingConfigHelp();
    return;
  }

  if (!config.template.isJasprApp) {
    error('This project is not a Jaspr app — nothing to deploy.');
    print('');
    UserPrompt.printList(<String>[
      'oracular deploy jaspr-server only applies to Jaspr templates '
          'rendered in SSR / hybrid mode.',
      'Current template: ${config.template.displayName}',
    ]);
    return;
  }

  if (!config.hasJasprServer) {
    error(
      'Render mode "${config.jasprRenderMode.displayName}" does not '
      'produce a Cloud Run image — nothing to deploy.',
    );
    print('');
    UserPrompt.printList(<String>[
      'To enable a Jaspr Cloud Run service, set:',
      '  JASPR_RENDER_MODE=ssr   # (or hybrid)',
      'in ${p.join(config.outputDir, 'config', 'setup_config.env')} and re-run.',
    ]);
    return;
  }

  final JasprServerDeployer deployer = JasprServerDeployer(config);
  final JasprServerDeployResult result = await deployer.deploy();

  print('');
  UserPrompt.printDivider(title: 'Jaspr server deploy summary');
  if (result.success) {
    UserPrompt.printList(<String>[
      'Service:  ${result.serviceName}',
      'Region:   ${result.region}',
      'Image:    ${result.imageTag}',
      'URL:      ${result.serviceUrl}',
    ]);
    print('');
    success('Jaspr server deployed.');
  } else {
    error('Jaspr server deploy failed: ${result.message}');
  }
}