Skip to content

Commit

Permalink
Outline plans for Sugar 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Pante committed Jan 24, 2025
1 parent 101d0a3 commit 964f5ef
Show file tree
Hide file tree
Showing 44 changed files with 291 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/stevia_integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- uses: actions/checkout@v4
- uses: futureware-tech/simulator-action@v4
with:
model: iPhone 14
model: iPhone 16
- run: flutter pub get
- run: flutter build ios --debug --no-codesign
- run: flutter test integration_test
9 changes: 9 additions & 0 deletions flint/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 2.11.0 (24/01/2025)
Core ruleset:
- Add `use_truncating_division`
- Add `invalid_runtime_check_with_js_interop_types`
- Add `missing_code_block_language_in_doc_comment`
- Add `unintended_html_in_doc_comment`
- Add `unnecessary_library_name`
- Remove deprecated `package_api_docs`

# 2.10.0 (25/05/2024)
Flutter ruleset:
- Add `diagnostic_describe_all_properties`
Expand Down
10 changes: 8 additions & 2 deletions flint/lib/analysis_options.dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ linter:
- one_member_abstracts
- only_throw_errors
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_adjacent_string_concatenation
Expand Down Expand Up @@ -180,6 +179,11 @@ linter:
- use_to_and_as_if_applicable
- valid_regexps
- void_checks
- use_truncating_division
- invalid_runtime_check_with_js_interop_types
- missing_code_block_language_in_doc_comment
- unintended_html_in_doc_comment
- unnecessary_library_name
ignore:
- always_declare_return_types
- always_put_required_named_parameters
Expand Down Expand Up @@ -214,4 +218,6 @@ ignore:
- use_colored_box
- use_decorated_box
- use_full_hex_values_for_flutter_colors
- use_key_in_widget_constructors
- use_key_in_widget_constructors
- document_ignores
- use_build_context_synchronously
5 changes: 3 additions & 2 deletions flint/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: flint
description: Analyzer lints used internally in Forus Labs' Dart & Flutter projects.
version: 2.10.0
version: 2.11.0
homepage: https://github.com/forus-labs/cauldron
repository: https://github.com/forus-labs/cauldron
topics: [lints]

environment:
sdk: '>=3.4.0 <4.0.0'
sdk: '>=3.6.0 <4.0.0'
resolution: workspace

dev_dependencies:
html: ^0.15.0
Expand Down
40 changes: 25 additions & 15 deletions flint/tool/update.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,28 @@ Future<Set<String>> fetch() async {
print('Fetching lint rules from $remote.');

final response = parse((await get(remote)).body);
return response.getElementsByClassName('code-block-body').single.innerHtml
.split(RegExp('[ ]+-[ ]+'))

final rules = RegExp(r'<span[^>]*>(\w+)</span>')
.allMatches(response.getElementsByTagName('code').last.innerHtml)
.map((m) => m.group(1))
.skip(1)
.where((element) => !element.startsWith('<'))
.map((e) => e.trim())
.whereType<String>()
.toSet();

if (rules.isEmpty) {
throw StateError('No rules found.');
}

return rules;
}

Future<(Set<String> released, Set<String> removed)> process(Set<String> remote) async {
final existing = <String> { ...rules['linter']['rules'], ...rules['ignore'] };
final existing = <String>{...rules['linter']['rules'], ...rules['ignore']};
final released = <String>{};
final experimental = <String>{};
final removed = <String> {};

final removed = <String>{};

print('Checking rules. This might take awhile.');
for (final rule in remote) {
final response = await get(Uri.parse('https://dart.dev/tools/linter-rules/$rule'));
if (response.statusCode == 404) {
Expand All @@ -33,16 +41,20 @@ Future<(Set<String> released, Set<String> removed)> process(Set<String> remote)
}

final content = parse(response.body)
.getElementsByClassName('content')[0]
.getElementsByTagName('p')[1]
.getElementsByTagName('em')[0]
.text;
.getElementsByClassName('content')[0]
.getElementsByTagName('p')[1]
.getElementsByTagName('em')[0]
.text;

if (existing.contains(rule) && (content.contains('deprecated') || content.contains('removed'))) {
removed.add(rule);
} else if (!existing.contains(rule) && !content.contains('experimental') && !content.contains('deprecated') && !content.contains('removed')) {
} else if (!existing.contains(rule) &&
!content.contains('experimental') &&
!content.contains('deprecated') &&
!content.contains('removed')) {
released.add(rule);
} if (!existing.contains(rule) && content.contains('experimental')) {
}
if (!existing.contains(rule) && content.contains('experimental')) {
experimental.add(rule);
}
}
Expand All @@ -68,7 +80,6 @@ void write((Set<String> released, Set<String> removed) rules) {
print('https://dart.dev/tools/linter-rules/$rule');
options.writeAsStringSync(' - $rule\n', mode: FileMode.append);
}

} else {
print('No new stable lint rules released.');
}
Expand All @@ -81,7 +92,6 @@ void write((Set<String> released, Set<String> removed) rules) {
print('https://dart.dev/tools/linter-rules/$rule');
options.writeAsStringSync(' - $rule\n', mode: FileMode.append);
}

} else {
print('No new lint rules removed.');
}
Expand Down
2 changes: 2 additions & 0 deletions nitrogen/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock
/.flutter-plugins
/.flutter-plugins-dependencies
3 changes: 2 additions & 1 deletion nitrogen/lib/src/libraries.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:code_builder/code_builder.dart';
import 'package:dart_style/dart_style.dart';
import 'package:pub_semver/pub_semver.dart';

/// Provides utilities for working with libraries.
extension Libraries on Library {
Expand All @@ -23,7 +24,7 @@ extension Libraries on Library {
static final importNitrogenTypes = Directive.import('package:nitrogen_types/nitrogen_types.dart');

static final _emitter = DartEmitter(orderDirectives: true, useNullSafetySyntax: true);
static final _formatter = DartFormatter(pageWidth: 160);
static final _formatter = DartFormatter(pageWidth: 160, languageVersion: Version(3, 6, 0));

/// Returns this library, formatted.
String format() {
Expand Down
18 changes: 8 additions & 10 deletions nitrogen/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,26 @@ homepage: https://github.com/forus-labs/cauldron/tree/master/nitrogen
repository: https://github.com/forus-labs/cauldron/

environment:
sdk: '>=3.3.0 <4.0.0'
flutter: ">=3.22.0"
sdk: '>=3.6.0 <4.0.0'
flutter: ">=3.27.0"
resolution: workspace

dependencies:
build: ^2.4.1
build_runner: ^2.4.6
code_builder: ^4.10.0
dart_style: ^2.3.6
dart_style: ^3.0.0
flutter:
sdk: flutter
glob: ^2.1.2
meta: ^1.9.1
nitrogen_types: ^0.3.0+1
nitrogen_types:
path: ^1.9.0
sugar: ^3.0.0
pub_semver: ^2.1.5
sugar:
yaml: ^3.1.2

dev_dependencies:
build_test: ^2.2.2
flint: ^2.7.0
import_sorter: ^4.6.0
flint:
test: ^1.25.2

import_sorter:
comments: false
3 changes: 2 additions & 1 deletion nitrogen/test/src/generators/asset_generator_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:code_builder/code_builder.dart';
import 'package:dart_style/dart_style.dart';
import 'package:nitrogen_types/assets.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:test/test.dart';

import 'package:nitrogen/src/file_system.dart';
Expand Down Expand Up @@ -256,7 +257,7 @@ class $PrefixPathToDirectory {
''';

void main() {
final formatter = DartFormatter(pageWidth: 160);
final formatter = DartFormatter(pageWidth: 160, languageVersion: Version(3, 6, 0));
final emitter = DartEmitter(useNullSafetySyntax: true);

final subdirectory = AssetDirectory(['path', 'to', 'directory', 'subdirectory']);
Expand Down
7 changes: 4 additions & 3 deletions nitrogen_flutter_svg/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ homepage: https://github.com/forus-labs/cauldron/nitrogen
repository: https://github.com/forus-labs/cauldron/

environment:
sdk: '>=3.3.0 <4.0.0'
sdk: '>=3.6.0 <4.0.0'
resolution: workspace

dependencies:
flutter:
sdk: flutter
flutter_svg: ^2.0.9
nitrogen_types: ^0.3.0+1
nitrogen_types:

dev_dependencies:
flint: ^2.7.0
flint:
9 changes: 5 additions & 4 deletions nitrogen_lottie/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ homepage: https://github.com/forus-labs/cauldron/nitrogen
repository: https://github.com/forus-labs/cauldron/

environment:
sdk: '>=3.3.0 <4.0.0'
flutter: ">=3.3.0"
sdk: '>=3.6.0 <4.0.0'
flutter: ">=3.27.0"
resolution: workspace

dependencies:
flutter:
sdk: flutter
lottie: ^3.1.0
nitrogen_types: ^0.3.0+1
nitrogen_types:

dev_dependencies:
flint: ^2.7.0
flint:
4 changes: 2 additions & 2 deletions nitrogen_types/lib/assets.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// This library exports only the assets. It is used by Nitrogen since builders cannot import Flutter.
library nitrogen_types.assets;
library;

export 'src/assets.dart';
export 'src/assets.dart';
2 changes: 1 addition & 1 deletion nitrogen_types/lib/nitrogen_types.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// The companion library for [Nitrogen](https://github.com/forus-labs/cauldron/nitrogen), a type-safe asset generation
/// tool.
library nitrogen_types;
library;

export 'src/assets.dart';
export 'src/image_asset_extension.dart';
7 changes: 4 additions & 3 deletions nitrogen_types/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ homepage: https://github.com/forus-labs/cauldron/tree/master/nitrogen
repository: https://github.com/forus-labs/cauldron/

environment:
sdk: '>=3.3.0 <4.0.0'
flutter: ">=3.3.0"
sdk: '>=3.6.0 <4.0.0'
flutter: ">=3.27.0"
resolution: workspace

dependencies:
flutter:
sdk: flutter

dev_dependencies:
flint: ^2.7.0
flint:
14 changes: 14 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: _
environment:
sdk: ">=3.6.0 <4.0.0"
workspace:
- flint
- nitrogen
- nitrogen_flutter_svg
- nitrogen_lottie
- nitrogen_types
- stevia
- sugar

dev_dependencies:
flint: ^2.8.1
2 changes: 1 addition & 1 deletion stevia/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Stevia - Assorted utilities for Flutter

Stevia contains utilities for working with Flutter that includes haptic feedback and timezone utilities for Android & iOS.
It is currently under active development.
It is under development

```YAML
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion stevia/lib/services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/// Controllers that simply the implementation of timers.
///
/// * [TimerController]
library stevia.services;
library;

import 'package:stevia/services.dart';

Expand Down
2 changes: 1 addition & 1 deletion stevia/lib/services_haptic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
/// [Haptic.heavy].
///
/// TL;DR: Haptic feedback on Android devices is a mess.
library stevia.services.haptic;
library;

import 'package:stevia/src/services/haptic/haptic.dart';

Expand Down
2 changes: 1 addition & 1 deletion stevia/lib/services_time.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
///
/// After setting [Timezone.platformTimezoneProvider], [ZonedDateTime.now] and other current timezone dependent functions
/// will return the current platform's timezone on Android and iOS.
library stevia.services.time;
library;

import 'package:sugar/sugar.dart';
import 'package:stevia/src/services/time/flutter_timezone_provider.dart';
Expand Down
2 changes: 1 addition & 1 deletion stevia/lib/src/services/haptic/platform_haptic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:stevia/src/services/haptic/haptic_pattern.dart';
static final Object _token = Object();

/// Creates a [PlatformHaptic] for the current platform.
factory PlatformHaptic.platform() => switch (const Runtime().type) {
factory PlatformHaptic.platform() => switch (const System().type) {
PlatformType.android => AndroidHaptic(),
PlatformType.ios => IOSHaptic(),
_ => PlatformHaptic(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import 'package:sugar/sugar.dart';
/// }
/// ```
Future<String Function()> flutterPlatformTimezoneProvider() async {
switch (const Runtime().type) {
switch (const System().type) {
case PlatformType.android || PlatformType.ios:
final platform = await PlatformTimezone.of();
return () => platform.current;
Expand Down
6 changes: 3 additions & 3 deletions stevia/lib/src/widgets/async/future/future_result_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ part of 'future_builder.dart';
/// The result of the given [future] is always returned. It is assumed that [future] will never throw an error. Doing so
/// will result in undefined behaviour.
///
/// ## Working with [showsFutureResultDialog]:
/// ## Working with [showFutureResultDialog]:
///
/// To show a dialog that is automatically dismissed after the [future] is completed:
/// ```dart
/// FloatingActionButton(
/// onPressed: () => showsFutureResultDialog(
/// onPressed: () => showFutureResultDialog(
/// context: context,
/// future: () async {
/// await Future.delayed(const Duration(seconds: 5));
Expand All @@ -34,7 +34,7 @@ part of 'future_builder.dart';
/// To show a dialog that appears after the [future] has successfully completed:
/// ```dart
/// FloatingActionButton(
/// onPressed: () => showsFutureResultDialog(
/// onPressed: () => showFutureResultDialog(
/// context: context,
/// future: () async {
/// await Future.delayed(const Duration(seconds: 5);
Expand Down
Loading

0 comments on commit 964f5ef

Please sign in to comment.