Skip to content

Commit

Permalink
refactor!: use Dart 3 (#598)
Browse files Browse the repository at this point in the history
* refactor!: use Dart 3

* refactor: upgrade dependencies

* ci: use correct versions to test

* ci: use correct flutter version
  • Loading branch information
Vinzent03 committed Aug 23, 2023
1 parent e5ba4fe commit 02c4071
Show file tree
Hide file tree
Showing 30 changed files with 73 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/functions_client_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
matrix:
os: [ubuntu-latest]
node: ['12']
sdk: [2.17.0, stable, beta, dev]
sdk: [stable, beta, dev]

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gotrue_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
os: [ubuntu-latest]
node: ['12']
sdk: [2.17.0, stable, beta, dev]
sdk: [stable, beta, dev]

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/postgrest_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
matrix:
os: [ubuntu-latest]
node: ['12']
sdk: [2.17.0, stable, beta, dev]
sdk: [stable, beta, dev]

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/realtime_client_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
os: [ubuntu-latest]
node: ['12']
sdk: [2.17.0, stable, beta, dev]
sdk: [stable, beta, dev]

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/storage_client_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
matrix:
os: [ubuntu-latest]
node: ['12']
sdk: [2.17.0, stable, beta, dev]
sdk: [stable, beta, dev]

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/supabase_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
matrix:
os: [ubuntu-latest]
node: ['12']
sdk: [2.17.0, stable, beta, dev]
sdk: [stable, beta, dev]

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/supabase_flutter_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
flutter-version: ['3.0.0', '3.x']
flutter-version: ['3.10.x', '3.x']

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/yet_another_json_isolate_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
os: [ubuntu-latest]
node: ['12']
sdk: [2.17.0, stable, beta, dev]
sdk: [stable, beta, dev]

defaults:
run:
Expand Down
4 changes: 2 additions & 2 deletions packages/functions_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ repository: 'https://github.com/supabase/supabase-flutter/tree/main/packages/fun
documentation: 'https://supabase.com/docs/reference/dart/functions-invoke'

environment:
sdk: '>=2.17.0 <4.0.0'
sdk: '>=3.0.0 <4.0.0'

dependencies:
http: '>=0.13.4 <2.0.0'
yet_another_json_isolate: ^1.1.1

dev_dependencies:
lints: ^1.0.1
lints: ^2.1.1
test: ^1.16.4
6 changes: 3 additions & 3 deletions packages/gotrue/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository: 'https://github.com/supabase/supabase-flutter/tree/main/packages/got
documentation: 'https://supabase.com/docs/reference/dart/auth-signup'

environment:
sdk: '>=2.17.0 <4.0.0'
sdk: '>=3.0.0 <4.0.0'

dependencies:
collection: ^1.15.0
Expand All @@ -19,8 +19,8 @@ dependencies:

dev_dependencies:
dart_jsonwebtoken: ^2.4.1
dotenv: ^3.0.0
lints: ^1.0.1
dotenv: ^4.1.0
lints: ^2.1.1
test: ^1.16.4
otp: ^3.1.3

Expand Down
9 changes: 5 additions & 4 deletions packages/gotrue/test/admin_test.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'dart:math';

import 'package:dotenv/dotenv.dart' show env, load;
import 'package:dotenv/dotenv.dart';
import 'package:gotrue/gotrue.dart';
import 'package:http/http.dart' as http;
import 'package:test/test.dart';

import 'utils.dart';

void main() {
load(); // Load env variables from .env file
final env = DotEnv();
env.load(); // Load env variables from .env file

final gotrueUrl = env['GOTRUE_URL'] ?? 'http://localhost:9998';

Expand All @@ -24,8 +25,8 @@ void main() {
client = GoTrueClient(
url: gotrueUrl,
headers: {
'Authorization': 'Bearer ${getServiceRoleToken()}',
'apikey': getServiceRoleToken(),
'Authorization': 'Bearer ${getServiceRoleToken(env)}',
'apikey': getServiceRoleToken(env),
},
);
});
Expand Down
10 changes: 6 additions & 4 deletions packages/gotrue/test/client_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:convert';

import 'package:dotenv/dotenv.dart' show env, load;
import 'package:dotenv/dotenv.dart';
import 'package:gotrue/gotrue.dart';
import 'package:http/http.dart' as http;
import 'package:jwt_decode/jwt_decode.dart';
Expand All @@ -10,7 +10,9 @@ import 'custom_http_client.dart';
import 'utils.dart';

void main() {
load(); // Load env variables from .env file
final env = DotEnv();

env.load(); // Load env variables from .env file

final gotrueUrl = env['GOTRUE_URL'] ?? 'http://localhost:9998';
final anonToken = env['GOTRUE_TOKEN'] ?? 'anonKey';
Expand Down Expand Up @@ -45,8 +47,8 @@ void main() {
adminClient = client = GoTrueClient(
url: gotrueUrl,
headers: {
'Authorization': 'Bearer ${getServiceRoleToken()}',
'apikey': getServiceRoleToken(),
'Authorization': 'Bearer ${getServiceRoleToken(env)}',
'apikey': getServiceRoleToken(env),
},
asyncStorage: asyncStorage,
);
Expand Down
6 changes: 4 additions & 2 deletions packages/gotrue/test/provider_test.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import 'package:dotenv/dotenv.dart' show env, load;
import 'package:dotenv/dotenv.dart';
import 'package:gotrue/gotrue.dart';
import 'package:http/http.dart' as http;
import 'package:test/test.dart';

import 'utils.dart';

void main() {
load(); // Load env variables from .env file
final env = DotEnv();

env.load(); // Load env variables from .env file

final gotrueUrl = env['GOTRUE_URL'] ?? 'http://localhost:9998';
final anonToken = env['GOTRUE_TOKEN'] ?? 'anonKey';
Expand Down
6 changes: 4 additions & 2 deletions packages/gotrue/test/src/gotrue_admin_mfa_api_test.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
import 'package:dotenv/dotenv.dart' show env, load;
import 'package:dotenv/dotenv.dart';
import 'package:gotrue/gotrue.dart';
import 'package:http/http.dart' as http;
import 'package:test/test.dart';

import '../utils.dart';

void main() {
load(); // Load env variables from .env file
final env = DotEnv();

env.load(); // Load env variables from .env file

final gotrueUrl = env['GOTRUE_URL'] ?? 'http://localhost:9998';
final serviceRoleToken = JWT(
Expand Down
6 changes: 4 additions & 2 deletions packages/gotrue/test/src/gotrue_mfa_api_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:collection/collection.dart';
import 'package:dotenv/dotenv.dart' show env, load;
import 'package:dotenv/dotenv.dart';
import 'package:gotrue/gotrue.dart';
import 'package:http/http.dart' as http;
import 'package:otp/otp.dart';
Expand All @@ -8,7 +8,9 @@ import 'package:test/test.dart';
import '../utils.dart';

void main() {
load(); // Load env variables from .env file
final env = DotEnv();

env.load(); // Load env variables from .env file

final gotrueUrl = env['GOTRUE_URL'] ?? 'http://localhost:9998';

Expand Down
2 changes: 1 addition & 1 deletion packages/gotrue/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ String getNewPhone() {
return '$timestamp';
}

String getServiceRoleToken() {
String getServiceRoleToken(DotEnv env) {
return JWT(
{
'role': 'service_role',
Expand Down
2 changes: 1 addition & 1 deletion packages/postgrest/lib/src/postgrest_query_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class PostgrestQueryBuilder<T> extends PostgrestBuilder<T, T> {
'resolution=${ignoreDuplicates ? 'ignore' : 'merge'}-duplicates';

if (!defaultToNull) {
_headers['Prefer'] = _headers['Prefer']! + ',missing=default';
_headers['Prefer'] = '${_headers['Prefer']!},missing=default';
}

if (onConflict != null) {
Expand Down
4 changes: 2 additions & 2 deletions packages/postgrest/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ repository: 'https://github.com/supabase/supabase-flutter/tree/main/packages/pos
documentation: 'https://supabase.com/docs/reference/dart/select'

environment:
sdk: '>=2.17.0 <4.0.0'
sdk: '>=3.0.0 <4.0.0'

dependencies:
http: '>=0.13.0 <2.0.0'
yet_another_json_isolate: ^1.1.1

dev_dependencies:
collection: ^1.16.0
lints: ^1.0.1
lints: ^2.1.1
test: ^1.21.4
6 changes: 3 additions & 3 deletions packages/realtime_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ repository: 'https://github.com/supabase/supabase-flutter/tree/main/packages/rea
documentation: 'https://supabase.com/docs/reference/dart/subscribe'

environment:
sdk: '>=2.17.0 <4.0.0'
sdk: '>=3.0.0 <4.0.0'

dependencies:
collection: ^1.15.0
meta: ^1.7.0
web_socket_channel: ^2.3.0

dev_dependencies:
lints: ^1.0.1
mocktail: ^0.1.0
lints: ^2.1.1
mocktail: ^1.0.0
test: ^1.16.5
8 changes: 4 additions & 4 deletions packages/storage_client/lib/src/storage_file_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class StorageFileApi {
'retryAttempts has to be greater or equal to 0');

final cleanPath = _removeEmptyFolders(path);
final _path = _getFinalPath(cleanPath);
var url = Uri.parse('${this.url}/object/upload/sign/$_path');
final finalPath = _getFinalPath(cleanPath);
var url = Uri.parse('${this.url}/object/upload/sign/$finalPath');
url = url.replace(queryParameters: {'token': token});

await storageFetch.putFile(
Expand Down Expand Up @@ -150,8 +150,8 @@ class StorageFileApi {
'retryAttempts has to be greater or equal to 0');

final cleanPath = _removeEmptyFolders(path);
final _path = _getFinalPath(cleanPath);
var url = Uri.parse('${this.url}/object/upload/sign/$_path');
final path0 = _getFinalPath(cleanPath);
var url = Uri.parse('${this.url}/object/upload/sign/$path0');
url = url.replace(queryParameters: {'token': token});

await storageFetch.putBinaryFile(
Expand Down
4 changes: 2 additions & 2 deletions packages/storage_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository: 'https://github.com/supabase/supabase-flutter/tree/main/packages/sto
documentation: 'https://supabase.com/docs/reference/dart/storage-createbucket'

environment:
sdk: '>=2.17.0 <4.0.0'
sdk: '>=3.0.0 <4.0.0'

dependencies:
http: '>=0.13.4 <2.0.0'
Expand All @@ -18,5 +18,5 @@ dependencies:
dev_dependencies:
mocktail: ^0.3.0
test: ^1.21.4
lints: ^1.0.1
lints: ^2.1.1
path: ^1.8.2
4 changes: 2 additions & 2 deletions packages/supabase/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository: 'https://github.com/supabase/supabase-flutter/tree/main/packages/sup
documentation: 'https://supabase.com/docs/reference/dart/introduction'

environment:
sdk: '>=2.17.0 <4.0.0'
sdk: '>=3.0.0 <4.0.0'

dependencies:
functions_client: ^1.3.2
Expand All @@ -19,6 +19,6 @@ dependencies:
yet_another_json_isolate: ^1.1.1

dev_dependencies:
lints: ^1.0.1
lints: ^2.1.1
test: ^1.17.9
web_socket_channel: ^2.2.0
2 changes: 1 addition & 1 deletion packages/supabase/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ List<String> getSessionData(DateTime dateTime) {
final expiresAt = dateTime.millisecondsSinceEpoch ~/ 1000;
final accessTokenMid = base64.encode(utf8.encode(json.encode(
{"exp": expiresAt, "sub": "1234567890", "role": "authenticated"})));
final accessToken = "any." + accessTokenMid + ".any";
final accessToken = "any.$accessTokenMid.any";
final currentSession =
'{"access_token":"$accessToken","expires_in":${dateTime.difference(DateTime.now()).inSeconds},"refresh_token":"-yeS4omysFs9tpUYBws9Rg","token_type":"bearer","provider_token":null,"provider_refresh_token":null,"user":{"id":"4d2583da-8de4-49d3-9cd1-37a9a74f55bd","app_metadata":{"provider":"email","providers":["email"]},"user_metadata":{"Hello":"World"},"aud":"","email":"fake1680338105@email.com","phone":"","created_at":"2023-04-01T08:35:05.208586Z","confirmed_at":null,"email_confirmed_at":"2023-04-01T08:35:05.220096086Z","phone_confirmed_at":null,"last_sign_in_at":"2023-04-01T08:35:05.222755878Z","role":"","updated_at":"2023-04-01T08:35:05.226938Z"}}';
final sessionString =
Expand Down
2 changes: 1 addition & 1 deletion packages/supabase_flutter/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include: package:lints/recommended.yaml
include: package:flutter_lints/flutter.yaml

linter:
rules:
Expand Down

0 comments on commit 02c4071

Please sign in to comment.