Skip to content

Commit

Permalink
Merge pull request #282 from yumemi-inc/improve/remove-cores-init
Browse files Browse the repository at this point in the history
improve: cores/initパッケージを削除
  • Loading branch information
mj-hd authored Jul 19, 2024
2 parents 8a1ce13 + 1a5b24d commit 4cd0c8f
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 739 deletions.
4 changes: 0 additions & 4 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ labels:
files:
- packages/cores/designsystem/.+

- label: "@packages/cores/init"
files:
- packages/cores/init/.+

- label: "@packages/features/debug_mode"
files:
- packages/features/debug_mode/.+
Expand Down
5 changes: 0 additions & 5 deletions .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
description: packages cores designsystem package
from_name: "@cores/designsystem"

- name: "@packages/cores/init"
color: DC79FD
description: packages cores init package
from_name: "@cores/init"

- name: "@packages/features/debug_mode"
color: 48360E
description: packages features debug_mode package
Expand Down
30 changes: 23 additions & 7 deletions apps/app/lib/app_initializer.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
import 'dart:async';

import 'package:cores_core/model.dart';
import 'package:cores_core/provider.dart';
import 'package:cores_core/util.dart';
import 'package:cores_data/shared_preferences.dart';
import 'package:flutter_app/app_build_config.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:shared_preferences/shared_preferences.dart';

typedef InitializedValues = ({
BuildConfig buildConfig,
List<Override> overrideProviders,
});

final class AppInitializer {
AppInitializer._();

static Future<InitializedValues> initialize() async {
final buildConfig = await _initializeBuildConfig();
final overrideProviders = await _initializeProviders();

logger.info(buildConfig);
return (buildConfig: buildConfig);
return (overrideProviders: overrideProviders);
}

static Future<BuildConfig> _initializeBuildConfig() async {
/// Returns list of [Override] that should be applied to root [ProviderScope].
static Future<List<Override>> _initializeProviders() async {
final overrides = <Override>[];

final packageInfo = await PackageInfo.fromPlatform();
final preferences = await SharedPreferences.getInstance();

return AppBuildConfig(
final buildConfig = AppBuildConfig(
// ignore: do_not_use_environment
appFlavor: const String.fromEnvironment('flavor'),
appName: packageInfo.appName,
Expand All @@ -32,5 +38,15 @@ final class AppInitializer {
buildSignature: packageInfo.buildSignature,
installerStore: packageInfo.installerStore,
);

logger.info(buildConfig);

overrides.addAll(
[
sharedPreferencesProvider.overrideWithValue(preferences),
buildConfigProvider.overrideWithValue(buildConfig),
],
);
return overrides;
}
}
8 changes: 3 additions & 5 deletions apps/app/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import 'package:cores_core/app_status.dart';
import 'package:cores_core/exception.dart';
import 'package:cores_core/provider.dart';
import 'package:cores_core/ui.dart';
import 'package:cores_data/theme_mode.dart';
import 'package:cores_designsystem/themes.dart';
import 'package:cores_init/provider.dart';
import 'package:features_setting/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/app_initializer.dart';
Expand All @@ -15,13 +13,13 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();

final (buildConfig: buildConfig) = await AppInitializer.initialize();
final (overrideProviders: overrideProviders,) =
await AppInitializer.initialize();

runApp(
ProviderScope(
overrides: [
...await initializeProviders(),
buildConfigProvider.overrideWithValue(buildConfig),
...overrideProviders,
],
child: const MainApp(),
),
Expand Down
9 changes: 1 addition & 8 deletions apps/app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,6 @@ packages:
relative: true
source: path
version: "0.0.1"
cores_init:
dependency: "direct main"
description:
path: "../../packages/cores/init"
relative: true
source: path
version: "0.0.1"
coverage:
dependency: transitive
description:
Expand Down Expand Up @@ -814,7 +807,7 @@ packages:
source: hosted
version: "0.27.7"
shared_preferences:
dependency: transitive
dependency: "direct main"
description:
name: shared_preferences
sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02"
Expand Down
3 changes: 1 addition & 2 deletions apps/app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ dependencies:
path: ../../packages/cores/data
cores_designsystem:
path: ../../packages/cores/designsystem
cores_init:
path: ../../packages/cores/init
features_debug_mode:
path: ../../packages/features/debug_mode
features_github_repository:
Expand All @@ -35,6 +33,7 @@ dependencies:
json_annotation: ^4.8.1
package_info_plus: ^5.0.1
riverpod_annotation: ^2.3.5
shared_preferences: ^2.2.2

dev_dependencies:
build_runner: ^2.4.7
Expand Down
32 changes: 0 additions & 32 deletions packages/cores/init/.gitignore

This file was deleted.

10 changes: 0 additions & 10 deletions packages/cores/init/.metadata

This file was deleted.

1 change: 0 additions & 1 deletion packages/cores/init/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/cores/init/analysis_options.yaml

This file was deleted.

1 change: 0 additions & 1 deletion packages/cores/init/lib/provider.dart

This file was deleted.

16 changes: 0 additions & 16 deletions packages/cores/init/lib/src/provider/initialize_providers.dart

This file was deleted.

Loading

0 comments on commit 4cd0c8f

Please sign in to comment.