handleDeployServer function

Future<void> handleDeployServer()

Deploy the arcane_server companion package to Cloud Run.

Standalone entry point invoked by oracular deploy arcane-server. Identical to the arcane_server stage of handleDeployAll but re-runnable in isolation when only the server binary needs to be shipped (e.g. when Firebase hosting and Jaspr deploys are already current).

Exits the process non-zero on failure so CI / shell pipelines treat it as an error.

Implementation

Future<void> handleDeployServer() async {
  final SetupConfig? config = await ProjectConfigLoader.load();
  if (config == null) {
    ProjectConfigLoader.printMissingConfigHelp();
    exit(1);
  }
  if (!config.createServer) {
    error('arcane_server is not enabled for this project.');
    print('');
    UserPrompt.printList(<String>[
      'oracular deploy arcane-server only applies when the project was '
          'scaffolded with --with-server.',
      'Re-scaffold or set CREATE_SERVER=yes in setup_config.env to enable.',
    ]);
    exit(2);
  }
  if (config.firebaseProjectId == null ||
      config.firebaseProjectId!.trim().isEmpty) {
    error(
      'No FIREBASE_PROJECT_ID configured \u2014 cannot deploy to Cloud Run.',
    );
    print('');
    UserPrompt.printList(<String>[
      'Set FIREBASE_PROJECT_ID in '
          '${p.join(config.outputDir, 'config', 'setup_config.env')}.',
    ]);
    exit(2);
  }

  print('');
  UserPrompt.printDivider(title: 'Deploy server (Cloud Run)');
  final ServerSetup server = ServerSetup(config);
  final String? url = await server.deployToCloudRun();

  print('');
  UserPrompt.printDivider(title: 'arcane_server deploy summary');
  if (url == null) {
    error('arcane_server deploy failed. See errors above.');
    exit(1);
  }
  UserPrompt.printList(<String>[
    'Service:  ${server.serverServiceName}',
    'URL:      $url',
  ]);
  print('');
  success('arcane_server deployed.');
}