Skip to content

Commit

Permalink
change generator folder name
Browse files Browse the repository at this point in the history
  • Loading branch information
mmvergara committed Aug 24, 2024
1 parent 32fb4c4 commit b2f7840
Show file tree
Hide file tree
Showing 23 changed files with 30 additions and 30 deletions.
3 changes: 2 additions & 1 deletion cli/bin/supadart.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'dart:io';
import 'package:args/args.dart';
import 'package:supadart/config_init.dart';
import 'package:supadart/new/index.dart';
import 'package:supadart/generators/index.dart';
import 'package:supadart/generators/utils/fetch_swagger.dart';
import 'package:yaml/yaml.dart';

const String version = 'v1.5.4';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 1 addition & 22 deletions cli/lib/new/index.dart → cli/lib/generators/index.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:convert';
import 'package:http/http.dart' as http;

import 'package:yaml/yaml.dart';

import 'swagger/swagger.dart';
Expand All @@ -11,27 +10,7 @@ import 'utils/get_imports.dart';
import 'utils/string_formatters.dart';
import 'class/class.dart';

Future<DatabaseSwagger?> fetchDatabaseSwagger(
String url, String anonKey) async {
final response = await http.get(Uri.parse('$url/rest/v1/?apikey=$anonKey'));
String responseBody = "";
if (response.statusCode == 200) {
return DatabaseSwagger.fromJson(jsonDecode(response.body));
} else {
print("Error Fetching Supabase Swagger");
responseBody = response.body;
}

print("Trying without the api key...");
final response2 = await http.get(Uri.parse('$url/rest/v1/'));
if (response2.statusCode == 200) {
print("Fetched Supabase Swagger!");
return DatabaseSwagger.fromJson(jsonDecode(response.body));
}

print(responseBody);
return null;
}

List<GeneratedFile> supadartRun(
DatabaseSwagger swagger,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions cli/lib/generators/utils/fetch_swagger.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import '../swagger/swagger.dart';

Future<DatabaseSwagger?> fetchDatabaseSwagger(
String url, String anonKey) async {
final response = await http.get(Uri.parse('$url/rest/v1/?apikey=$anonKey'));
String responseBody = "";
if (response.statusCode == 200) {
return DatabaseSwagger.fromJson(jsonDecode(response.body));
} else {
print("Error Fetching Supabase Swagger");
responseBody = response.body;
}

print("Trying without the api key...");
final response2 = await http.get(Uri.parse('$url/rest/v1/'));
if (response2.statusCode == 200) {
print("Fetched Supabase Swagger!");
return DatabaseSwagger.fromJson(jsonDecode(response.body));
}

print(responseBody);
return null;
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,3 @@ String pascalCasingToSnakeCasing(String name) {

String classNameToFileName(String name) =>
'${pascalCasingToSnakeCasing(name)}.dart';

// extension EqualCaseInsensitiveExtension on String {
// bool equalCaseInsensitive(String other) {
// return toLowerCase() == other.toLowerCase();
// }
// }
File renamed without changes.
Empty file.
3 changes: 2 additions & 1 deletion cli/test/supadart_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:dotenv/dotenv.dart';
import 'package:supabase/supabase.dart';
import 'package:supadart/new/index.dart';
import 'package:supadart/generators/index.dart';
import 'package:supadart/generators/utils/fetch_swagger.dart';
import '../bin/supadart.dart';
import 'boolean_bit_types.dart';
import 'datatypes/enums.dart';
Expand Down

0 comments on commit b2f7840

Please sign in to comment.