createAdditionalFiles function

Future<bool> createAdditionalFiles(
  1. PostgreSQLConnection connection,
  2. Map<String, DataField> record, {
  3. required String path,
  4. required bool schemaInName,
  5. required String packageName,
})

Implementation

Future<bool> createAdditionalFiles(
    PostgreSQLConnection connection, Map<String, DataField> record,
    {required String path,
    required bool schemaInName,
    required String packageName}) async {
  var serviceFileName = getServiceFileName(record, schemaInName);
  var serviceClassName = getServiceClassName(record, schemaInName);
  var serverFileName = getServerFileName(record, schemaInName);
  var servicePath = getServicePath(record, schemaInName);

  print('Generating additional files for $serviceClassName . . .');
  await createFold('$path/lib', 'proto_generated');
  return await writeInFile(
          '$path/bin/', 'server.dart', getServer(serverFileName)) &&
      await writeInFile(
          '$path/lib/src', 'connection.dart', getConnection(connection)) &&
      await writeInFile('$path', 'Dockerfile', getDockerFile()) &&
      await writeInFile(path, 'README.md', getReadMe()) &&
      await writeInFile(path, 'pubspec.yaml', getPubSpec(serviceClassName)) &&
      await writeInFile(path, 'CHANGELOG.md', getChangelog()) &&
      await writeInFile(
          '$path/lib/src',
          serverFileName,
          getTableService(
              serviceFileName, serviceClassName, servicePath, packageName));
}