Skip to content

Commit

Permalink
Refactor: Dart version bump 3.4 (#223)
Browse files Browse the repository at this point in the history
* chore(release): publish packages

 - conduit@5.0.1
 - conduit_codable@5.0.1
 - conduit_common@5.0.1
 - conduit_config@5.0.1
 - conduit_core@5.0.1
 - conduit_isolate_exec@5.0.1
 - conduit_open_api@5.0.1
 - conduit_password_hash@5.0.1
 - conduit_postgresql@5.0.1
 - conduit_runtime@5.0.1
 - conduit_test@5.0.1
 - fs_test_agent@5.0.1

* Refactor/dimoshka fix dependencies (#221)

* chore(release): publish packages

 - conduit@5.0.2
 - conduit_codable@5.0.2
 - conduit_common@5.0.2
 - conduit_config@5.0.2
 - conduit_core@5.0.2
 - conduit_isolate_exec@5.0.2
 - conduit_open_api@5.0.2
 - conduit_password_hash@5.0.2
 - conduit_postgresql@5.0.2
 - conduit_runtime@5.0.2
 - conduit_test@5.0.2
 - fs_test_agent@5.0.2

* Fix

* FIxes

* version: 5.0.2 bump

* Upgrade dependenciea and fix pubspec

* Restore

* Revert version upgrade, #219

* Refactoring

* Fix

---------

Co-authored-by: Dmytro Prylutskyi <dmytro.prylutskyi@dipdev.studio>

* Refactor: ci and code quality (#222)

* chore(release): publish packages

 - conduit@5.0.1
 - conduit_codable@5.0.1
 - conduit_common@5.0.1
 - conduit_config@5.0.1
 - conduit_core@5.0.1
 - conduit_isolate_exec@5.0.1
 - conduit_open_api@5.0.1
 - conduit_password_hash@5.0.1
 - conduit_postgresql@5.0.1
 - conduit_runtime@5.0.1
 - conduit_test@5.0.1
 - fs_test_agent@5.0.1

* refactor(ci): Reintroduce publishing pipeline and some code changes

* postgres setup

* No longer supporting nullable map elements

* chore(release): publish packages

 - conduit@5.0.3
 - conduit_codable@5.0.3
 - conduit_common@5.0.3
 - conduit_config@5.0.3
 - conduit_core@5.0.3
 - conduit_isolate_exec@5.0.3
 - conduit_open_api@5.0.3
 - conduit_password_hash@5.0.3
 - conduit_postgresql@5.0.3
 - conduit_runtime@5.0.3
 - conduit_test@5.0.3
 - fs_test_agent@5.0.3

* refactor: Version bump, includes analyzer upgrade

* remove some nullables

* feat: Allow passing `sslMode` to `PostgreSQLPersistentStore`

This change keeps backward compatibility for `bool useSSL`, but `useSSL` forces `SslMode.verifyFull` which is not always suitable.

Signed-off-by: Martin Edlman <ac@anycode.dev>

* add testing for sslMode

---------

Signed-off-by: Martin Edlman <ac@anycode.dev>
Co-authored-by: Dmytro Prylutskyi <3213606+Dimoshka@users.noreply.github.com>
Co-authored-by: Dmytro Prylutskyi <dmytro.prylutskyi@dipdev.studio>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Martin Edlman <ac@anycode.dev>
  • Loading branch information
5 people committed May 18, 2024
1 parent 3daf802 commit e70f5fe
Show file tree
Hide file tree
Showing 137 changed files with 841 additions and 812 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
dart pub global activate -spath packages/cli
dart pub global activate melos
melos bootstrap
melos cache-source
melos cache-source --no-select
dart pub get --directory=packages/isolate_exec_test_packages/test_package --offline
dart pub get --directory=packages/runtime_test_packages/application --offline
dart pub get --directory=packages/runtime_test_packages/dependency --offline
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
dart pub global activate -spath packages/cli
dart pub global activate melos
melos bootstrap
melos cache-source
melos cache-source --no-select
dart pub get --directory=packages/isolate_exec_test_packages/test_package --offline
dart pub get --directory=packages/runtime_test_packages/application --offline
dart pub get --directory=packages/runtime_test_packages/dependency --offline
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
dart pub global activate -spath packages/cli
dart pub global activate melos
dart pub global run melos:melos bootstrap
dart pub global run melos:melos cache-source-win
dart pub global run melos:melos cache-source-win --no-select
dart pub get --directory=packages/isolate_exec_test_packages/test_package --offline
dart pub get --directory=packages/runtime_test_packages/application --offline
dart pub get --directory=packages/runtime_test_packages/dependency --offline
Expand Down
2 changes: 1 addition & 1 deletion melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ command:
linkToCommits: true
scripts:
test-unit:
run: melos exec -c1 --fail-fast --ignore "*common*" --ignore "*application*" --ignore "*dependency*" -- "dart test"
run: melos exec -c1 --fail-fast --ignore "*common*" --ignore "*application*" --ignore "*dependency*" -- "dart test -r failures-only"
packageFilters:
noPrivate: true
test-with-coverage:
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Future main() async {
}

class App extends ApplicationChannel {
ManagedContext? context;
AuthServer? authServer;
late ManagedContext context;
late final AuthServer authServer;

@override
Future prepare() async {
Expand Down Expand Up @@ -61,7 +61,7 @@ class UserController extends ResourceController {
UserController(this.context, this.authServer);

final ManagedContext? context;
final AuthServer? authServer;
final AuthServer authServer;

@Operation.get()
Future<Response> getUsers() async {
Expand Down Expand Up @@ -90,7 +90,7 @@ class UserController extends ResourceController {
}

final salt = generateRandomSalt();
final hashedPassword = authServer!.hashPassword(user.password!, salt);
final hashedPassword = authServer.hashPassword(user.password!, salt);

final query = Query<User>(context!)
..values = user
Expand All @@ -99,7 +99,7 @@ class UserController extends ResourceController {
..values.email = user.username;

final u = await query.insert();
final token = await authServer!.authenticate(
final token = await authServer.authenticate(
u.username,
query.values.password,
request!.authorization!.credentials!.username,
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/lib/src/command.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore_for_file: avoid_print

import 'dart:async';
import 'dart:io';
import 'dart:mirrors';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/src/commands/auth_add_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class CLIAuthAddClient extends CLICommand
context = ManagedContext(dataModel, persistentStore);

final credentials = generateAPICredentialPair(
clientID,
clientID!,
secret,
redirectURI: redirectUri,
hashLength: hashLength,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/src/commands/auth_scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CLIAuthScopeClient extends CLICommand
);

final query = Query<ManagedAuthClient>(context)
..where((o) => o.id).equalTo(clientID)
..where((o) => o.id).equalTo(clientID!)
..values.allowedScope =
scopingClient.allowedScopes?.map((s) => s.toString()).join(" ");

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/src/commands/db_upgrade.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CLIDatabaseUpgrade extends CLICommand
s.port,
s.databaseName,
s.timeZone,
useSSL: s.isSSLConnection,
sslMode: s.sslMode,
);
}

Expand Down
10 changes: 5 additions & 5 deletions packages/cli/lib/src/migration_source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ class MigrationSource {
MigrationSource(this.source, this.uri, int nameStartIndex, int nameEndIndex) {
originalName = source!.substring(nameStartIndex, nameEndIndex);
name = "M${md5.convert(source!.codeUnits)}";
source = source!.replaceRange(nameStartIndex, nameEndIndex, name!);
source = source!.replaceRange(nameStartIndex, nameEndIndex, name);
}

MigrationSource.fromMap(Map<String, dynamic> map) {
originalName = map["originalName"] as String?;
originalName = map["originalName"] as String;
source = map["source"] as String?;
name = map["name"] as String?;
name = map["name"] as String;
uri = map["uri"] as String?;
}

Expand Down Expand Up @@ -58,9 +58,9 @@ class MigrationSource {

String? source;

String? originalName;
late final String originalName;

String? name;
late final String name;

String? uri;

Expand Down
10 changes: 8 additions & 2 deletions packages/cli/lib/src/mixins/database_connecting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ mixin CLIDatabaseConnectingCommand implements CLICommand, CLIProject {

@Flag(
"use-ssl",
help: "Whether or not the database connection should use SSL",
help: "DEPRECATED: Use ssl-mode instead",
defaultsTo: false,
)
bool get useSSL => decode("use-ssl");

@Option("ssl-mode",
help:
"Whether or not the database connection should use SSL (disable/require/verifyFull)",
defaultsTo: "disable")
String get sslMode => decode("ssl-mode");

@Option(
"connect",
abbr: "c",
Expand Down Expand Up @@ -102,7 +108,7 @@ mixin CLIDatabaseConnectingCommand implements CLICommand, CLIProject {
connectedDatabase.host,
connectedDatabase.port,
connectedDatabase.databaseName,
useSSL: useSSL,
sslMode: sslMode,
);
}

Expand Down
12 changes: 6 additions & 6 deletions packages/cli/lib/src/scripts/run_upgrade.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RunUpgradeExecutable extends Executable<Map<String, dynamic>> {
dbInfo.port,
dbInfo.databaseName,
timeZone: dbInfo.timeZone,
useSSL: dbInfo.useSSL,
sslMode: dbInfo.sslMode,
);
}

Expand All @@ -71,7 +71,7 @@ class RunUpgradeExecutable extends Executable<Map<String, dynamic>> {
}).toList();

try {
final updatedSchema = (await store.upgrade(inputSchema, instances))!;
final updatedSchema = (await store.upgrade(inputSchema, instances));
await store.close();

return updatedSchema.asMap();
Expand Down Expand Up @@ -129,7 +129,7 @@ class DBInfo {
this.port,
this.databaseName,
this.timeZone, {
this.useSSL = false,
this.sslMode,
});

DBInfo.fromMap(Map<String, dynamic> map)
Expand All @@ -140,7 +140,7 @@ class DBInfo {
port = map["port"] as int?,
databaseName = map["databaseName"] as String?,
timeZone = map["timeZone"] as String?,
useSSL = (map["useSSL"] ?? false) as bool;
sslMode = map["sslMode"] as String?;

final String? flavor;
final String? username;
Expand All @@ -149,7 +149,7 @@ class DBInfo {
final int? port;
final String? databaseName;
final String? timeZone;
final bool useSSL;
final String? sslMode;

Map<String, dynamic>? asMap() {
return {
Expand All @@ -160,7 +160,7 @@ class DBInfo {
"port": port,
"databaseName": databaseName,
"timeZone": timeZone,
"useSSL": useSSL
"sslMode": sslMode
};
}
}
6 changes: 3 additions & 3 deletions packages/cli/lib/src/scripts/schema_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class SchemaBuilderExecutable extends Executable<Map<String, dynamic>> {
PostgreSQLPersistentStore.logger.level = Level.ALL;
PostgreSQLPersistentStore.logger.onRecord.listen((r) => log(r.message));
try {
Schema? outputSchema = inputSchema;
Schema outputSchema = inputSchema;
for (final source in sources) {
final Migration instance = instanceOf(
source.name!,
source.name,
positionalArguments: const [],
namedArguments: const <Symbol, dynamic>{},
constructorName: Symbol.empty,
Expand All @@ -39,7 +39,7 @@ class SchemaBuilderExecutable extends Executable<Map<String, dynamic>> {
await instance.upgrade();
outputSchema = instance.currentSchema;
}
return outputSchema!.asMap();
return outputSchema.asMap();
} on SchemaException catch (e) {
return {
"error":
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ repository: https://github.com/conduit-dart/conduit
issue_tracker: https://github.com/conduit-dart/conduit/issues

environment:
sdk: ">=3.3.0 <4.0.0"
sdk: ">=3.4.0 <4.0.0"

dependencies:
analyzer: ^6.4.1
analyzer: ^6.5.0
args: ^2.4.2
collection: ^1.18.0
conduit_common: ^5.0.3
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/db/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ homepage: https://github.com/conduit-dart/conduit-codable
publish_to: none

environment:
sdk: ">=3.3.0 <4.0.0"
sdk: ">=3.4.0 <4.0.0"

dependencies:
conduit: ^5.0.1
Expand Down
18 changes: 9 additions & 9 deletions packages/cli/templates/db_and_auth/lib/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import 'package:wildfire/wildfire.dart';
class WildfireChannel extends ApplicationChannel
implements AuthRedirectControllerDelegate {
final HTMLRenderer htmlRenderer = HTMLRenderer();
AuthServer? authServer;
ManagedContext? context;
late final authServer;
late ManagedContext context;

/// Initialize services in this method.
///
Expand Down Expand Up @@ -49,25 +49,25 @@ class WildfireChannel extends ApplicationChannel

router
.route("/auth/form")
.link(() => AuthRedirectController(authServer!, delegate: this));
.link(() => AuthRedirectController(authServer, delegate: this));

/* Create an account */
router
.route("/register")
.link(() => Authorizer.basic(authServer!))!
.link(() => RegisterController(context!, authServer!));
.link(() => Authorizer.basic(authServer))!
.link(() => RegisterController(context!, authServer));

/* Gets profile for user with bearer token */
router
.route("/me")
.link(() => Authorizer.bearer(authServer!))!
.link(() => Authorizer.bearer(authServer))!
.link(() => IdentityController(context!));

/* Gets all users or one specific user by id */
router
.route("/users/[:id]")
.link(() => Authorizer.bearer(authServer!))!
.link(() => UserController(context!, authServer!));
.link(() => Authorizer.bearer(authServer))!
.link(() => UserController(context!, authServer));

return router;
}
Expand All @@ -94,7 +94,7 @@ class WildfireChannel extends ApplicationChannel
AuthRedirectController forController,
Uri requestUri,
String? responseType,
String? clientID,
String clientID,
String? state,
String? scope) async {
final map = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RegisterController extends ResourceController {
final token = await authServer.authenticate(
user.username,
user.password,
request?.authorization?.credentials?.username,
request!.authorization!.credentials!.username,
request?.authorization?.credentials?.password);

final response = AuthController.tokenResponse(token);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/db_and_auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.0.1
publish_to: none

environment:
sdk: ">=3.3.0 <4.0.0"
sdk: ">=3.4.0 <4.0.0"

dependencies:
conduit: ^5.0.1
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/db_and_auth/test/harness/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Harness extends TestHarness<WildfireChannel>
ManagedContext? get context => channel?.context;

@override
AuthServer? get authServer => channel?.authServer;
AuthServer get authServer => channel!.authServer;

Agent? publicAgent;

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/default/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.0.1
publish_to: none

environment:
sdk: ">=3.3.0 <4.0.0"
sdk: ">=3.4.0 <4.0.0"

dependencies:
conduit: ^5.0.1
Expand Down
Loading

0 comments on commit e70f5fe

Please sign in to comment.