Skip to content

Commit 10d8ee5

Browse files
committed
refactor: improve code formatting and structure across multiple files
- Adjusted formatting for better readability in `stac_template_builder_parser.dart`, `init_command.dart`, and various exception classes. - Enhanced JSON serialization/deserialization structure in `project.g.dart`, `subscription.g.dart`, and `ui_loads.g.dart`. - Refactored `auth_service.dart` and `build_service.dart` for consistent line breaks and improved clarity. - Updated `analysis_options.yaml` to switch linting from `flutter_lints` to `lints/recommended`.
1 parent 0fb0142 commit 10d8ee5

File tree

12 files changed

+137
-142
lines changed

12 files changed

+137
-142
lines changed

packages/stac/lib/src/parsers/widgets/stac_template_builder/stac_template_builder_parser.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ class StacTemplateBuilderParser extends StacParser<StacTemplateBuilder> {
6767
jsonDecode(jsonEncode(model.child.toJson())) as Map<String, dynamic>;
6868

6969
final childType = childJson['type'] as String?;
70-
if (childType == null || !_layoutWidgetTypesWithChildren.contains(childType)) {
70+
if (childType == null ||
71+
!_layoutWidgetTypesWithChildren.contains(childType)) {
7172
throw FormatException(
7273
'TemplateBuilder child must be a layout widget that supports "children". '
7374
'Got type: ${childType ?? "null"}. '

packages/stac_cli/lib/src/commands/init_command.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ StacWidget helloWorld() {
202202
'lib/default_stac_options.dart',
203203
);
204204

205-
final dartConfig = '''
205+
final dartConfig =
206+
'''
206207
// This file is automatically generated by stac init.
207208
208209
import 'package:stac/stac_core.dart';

packages/stac_cli/lib/src/exceptions/auth_exception.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ class AuthException extends StacException {
88
/// Exception thrown when user is not authenticated
99
class NotAuthenticatedException extends AuthException {
1010
const NotAuthenticatedException()
11-
: super('Not authenticated. Please run "stac login" first.');
11+
: super('Not authenticated. Please run "stac login" first.');
1212
}
1313

1414
/// Exception thrown when authentication fails
1515
class AuthenticationFailedException extends AuthException {
1616
const AuthenticationFailedException([String? reason])
17-
: super('Authentication failed${reason != null ? ': $reason' : ''}');
17+
: super('Authentication failed${reason != null ? ': $reason' : ''}');
1818
}

packages/stac_cli/lib/src/exceptions/build_exception.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ class BuildException extends StacException {
88
/// Exception thrown when Dart to JSON conversion fails
99
class ConversionException extends BuildException {
1010
const ConversionException(String message, {dynamic cause})
11-
: super('Dart to JSON conversion failed: $message', cause: cause);
11+
: super('Dart to JSON conversion failed: $message', cause: cause);
1212
}
1313

1414
/// Exception thrown when SDUI validation fails
1515
class ValidationException extends BuildException {
1616
const ValidationException(String message)
17-
: super('SDUI validation failed: $message');
17+
: super('SDUI validation failed: $message');
1818
}

packages/stac_cli/lib/src/models/project/project.g.dart

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/stac_cli/lib/src/models/project/subscription.g.dart

Lines changed: 23 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/stac_cli/lib/src/models/project/ui_loads.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ class UiLoads {
4444
}
4545

4646
return UiLoads(
47-
currentPeriodUiLoadCount:
48-
(data['currentPeriodUiLoadCount'] as num?)?.toInt(),
47+
currentPeriodUiLoadCount: (data['currentPeriodUiLoadCount'] as num?)
48+
?.toInt(),
4949
lastUiLoadCountFlushed: (data['lastUiLoadCountFlushed'] as num?)?.toInt(),
50-
lastUiLoadsFlushedDelta:
51-
(data['lastUiLoadsFlushedDelta'] as num?)?.toInt(),
50+
lastUiLoadsFlushedDelta: (data['lastUiLoadsFlushedDelta'] as num?)
51+
?.toInt(),
5252
lastUiLoadsCountFlushedAt: DateTimeUtils.parseDateTime(
5353
data['lastUiLoadsCountFlushedAt'],
5454
),

packages/stac_cli/lib/src/models/project/ui_loads.g.dart

Lines changed: 18 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/stac_cli/lib/src/services/auth_service.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ class AuthService {
166166

167167
final authToken = AuthToken(
168168
accessToken: newIdToken,
169-
refreshToken: newRefreshToken ??
169+
refreshToken:
170+
newRefreshToken ??
170171
refreshToken, // Keep old refresh token if new one not provided
171172
expiresAt: expiresAt,
172173
scopes: _scopes,
@@ -278,13 +279,10 @@ class AuthService {
278279
await Process.run('xdg-open', [authUrl.toString()]);
279280
ConsoleLogger.info('Opening browser for authentication...');
280281
} else if (Platform.isWindows) {
281-
await Process.run(
282-
'rundll32',
283-
[
284-
'url.dll,FileProtocolHandler',
285-
authUrl.toString(),
286-
],
287-
runInShell: false);
282+
await Process.run('rundll32', [
283+
'url.dll,FileProtocolHandler',
284+
authUrl.toString(),
285+
], runInShell: false);
288286
ConsoleLogger.info('Opening browser for authentication...');
289287
}
290288
} catch (e) {

packages/stac_cli/lib/src/services/build_service.dart

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,19 @@ class BuildService {
194194

195195
final description =
196196
RegExp(r"description:\s*'([^']*)'").firstMatch(content)?.group(1) ??
197-
'Stac';
197+
'Stac';
198198

199199
final projectId =
200200
RegExp(r"projectId:\s*'([^']*)'").firstMatch(content)?.group(1) ??
201-
'stac';
201+
'stac';
202202

203203
final sourceDir =
204204
RegExp(r"sourceDir:\s*'([^']*)'").firstMatch(content)?.group(1) ??
205-
'stac';
205+
'stac';
206206

207207
final outputDir =
208208
RegExp(r"outputDir:\s*'([^']*)'").firstMatch(content)?.group(1) ??
209-
'stac/.build';
209+
'stac/.build';
210210

211211
return StacOptions(
212212
name: name,
@@ -322,10 +322,12 @@ class BuildService {
322322
required StacDslArtifactType type,
323323
}) {
324324
final artifacts = <StacDslArtifact>[];
325-
final annotationName =
326-
type == StacDslArtifactType.screen ? 'StacScreen' : 'StacThemeRef';
327-
final parameterName =
328-
type == StacDslArtifactType.screen ? 'screenName' : 'name';
325+
final annotationName = type == StacDslArtifactType.screen
326+
? 'StacScreen'
327+
: 'StacThemeRef';
328+
final parameterName = type == StacDslArtifactType.screen
329+
? 'screenName'
330+
: 'name';
329331
final callablePrefixPattern = type == StacDslArtifactType.screen
330332
? r'(?:StacWidget\s+)?'
331333
: r'(?:StacTheme\s+)?';
@@ -515,18 +517,19 @@ Future<void> main(List<String> args) async {
515517
) async {
516518
try {
517519
// Execute Dart file in project context for proper dependency resolution
518-
final result = await Process.run(
519-
'dart',
520-
['run', path.basename(scriptFile.path)],
521-
workingDirectory: projectDir,
522-
runInShell: Platform
523-
.isWindows, // Use shell on Windows for proper PATH resolution
524-
).timeout(
525-
const Duration(seconds: 60),
526-
onTimeout: () {
527-
throw Exception('Script execution timed out after 60 seconds');
528-
},
529-
);
520+
final result =
521+
await Process.run(
522+
'dart',
523+
['run', path.basename(scriptFile.path)],
524+
workingDirectory: projectDir,
525+
runInShell: Platform
526+
.isWindows, // Use shell on Windows for proper PATH resolution
527+
).timeout(
528+
const Duration(seconds: 60),
529+
onTimeout: () {
530+
throw Exception('Script execution timed out after 60 seconds');
531+
},
532+
);
530533

531534
final stdout = result.stdout.toString();
532535
final stderr = result.stderr.toString();

0 commit comments

Comments
 (0)