copyServerTemplate method

Future<void> copyServerTemplate()

Copy the server template

Implementation

Future<void> copyServerTemplate() async {
  if (!config.createServer) return;

  final Directory templateDir = Directory(getTemplatePath('arcane_server'));
  final Directory targetDir = Directory(
    p.join(config.outputDir, config.serverPackageName),
  );

  if (!templateDir.existsSync()) {
    throw Exception('Server template not found: ${templateDir.path}');
  }

  info('Copying server template...');

  // Copy template files
  await _copyDirectory(templateDir, targetDir);

  // Process placeholders
  await _replacer.processDirectory(targetDir);

  // Update pubspec
  final File pubspecFile = File(p.join(targetDir.path, 'pubspec.yaml'));
  await _replacer.updatePubspec(pubspecFile, config.serverPackageName);

  // Add models dependency if needed
  if (config.createModels) {
    await _replacer.addModelsDependency(pubspecFile);
  }

  success('Server app created at: ${targetDir.path}');
}