Skip to content

Commit fbc99fb

Browse files
committed
Run formatter
1 parent ff6b0f6 commit fbc99fb

2 files changed

Lines changed: 91 additions & 65 deletions

File tree

‎packages/camera/camera_android_camerax/.agents/skills/check-readiness/lib/check_readiness.dart‎

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class ReadinessChecker {
1515
FileSystem? fileSystem,
1616
ProcessManager? processManager,
1717
void Function(Object?)? log,
18-
}) : _fileSystem = fileSystem ?? const LocalFileSystem(),
19-
_processManager = processManager ?? const LocalProcessManager(),
20-
_log = log ?? ((Object? msg) => stdout.writeln(msg));
18+
}) : _fileSystem = fileSystem ?? const LocalFileSystem(),
19+
_processManager = processManager ?? const LocalProcessManager(),
20+
_log = log ?? ((Object? msg) => stdout.writeln(msg));
2121

2222
final FileSystem _fileSystem;
2323
final ProcessManager _processManager;
@@ -61,17 +61,20 @@ class ReadinessChecker {
6161

6262
Future<bool> _checkSymlinks(String workspaceRoot) async {
6363
_log('1. Checking skill symlinks...');
64-
final Directory agentsDir =
65-
_fileSystem.directory(_fileSystem.path.join(workspaceRoot, '.agents', 'skills'));
64+
final Directory agentsDir = _fileSystem.directory(
65+
_fileSystem.path.join(workspaceRoot, '.agents', 'skills'),
66+
);
6667
if (!agentsDir.existsSync()) {
6768
// If it doesn't exist, there are no broken symlinks.
6869
_log('All symlinks resolve correctly.');
6970
return true;
7071
}
7172

7273
final brokenLinks = <String>[];
73-
await for (final FileSystemEntity entity
74-
in agentsDir.list(recursive: true, followLinks: false)) {
74+
await for (final FileSystemEntity entity in agentsDir.list(
75+
recursive: true,
76+
followLinks: false,
77+
)) {
7578
if (entity is Link) {
7679
if (_fileSystem.typeSync(entity.path) == FileSystemEntityType.notFound) {
7780
brokenLinks.add(entity.path);
@@ -93,10 +96,11 @@ class ReadinessChecker {
9396
_log('2. Checking git state...');
9497
final ProcessResult result;
9598
try {
96-
result = await _processManager.run(
97-
<String>['git', 'status', '--porcelain'],
98-
workingDirectory: workspaceRoot,
99-
);
99+
result = await _processManager.run(<String>[
100+
'git',
101+
'status',
102+
'--porcelain',
103+
], workingDirectory: workspaceRoot);
100104
} on ProcessException catch (e) {
101105
_log('Error: Failed to run git status. Is git installed and on the PATH?');
102106
_log(e.toString());
@@ -109,7 +113,8 @@ class ReadinessChecker {
109113
final String stdoutStr = (result.stdout as String).trim();
110114
if (stdoutStr.isNotEmpty) {
111115
_log(
112-
'Error: Git working directory is not clean. Please commit or stash your changes before starting new work.');
116+
'Error: Git working directory is not clean. Please commit or stash your changes before starting new work.',
117+
);
113118
return false;
114119
}
115120
_log('Git working directory is clean.');
@@ -120,10 +125,12 @@ class ReadinessChecker {
120125
_log('3. Checking Git hooks configuration...');
121126
final ProcessResult result;
122127
try {
123-
result = await _processManager.run(
124-
<String>['git', 'config', '--get', 'core.hooksPath'],
125-
workingDirectory: workspaceRoot,
126-
);
128+
result = await _processManager.run(<String>[
129+
'git',
130+
'config',
131+
'--get',
132+
'core.hooksPath',
133+
], workingDirectory: workspaceRoot);
127134
} on ProcessException catch (e) {
128135
_log('Error: Failed to check git config. Is git installed and on the PATH?');
129136
_log(e.toString());
@@ -166,10 +173,11 @@ class ReadinessChecker {
166173

167174
Future<bool> _checkDependencies(String workspaceRoot) async {
168175
_log('5. Checking dependencies in camera_android_camerax...');
169-
final ProcessResult result = await _processManager.run(
170-
<String>['flutter', 'pub', 'get'],
171-
workingDirectory: workspaceRoot,
172-
);
176+
final ProcessResult result = await _processManager.run(<String>[
177+
'flutter',
178+
'pub',
179+
'get',
180+
], workingDirectory: workspaceRoot);
173181
if (result.exitCode != 0) {
174182
_log('Error: Failed to resolve dependencies.');
175183
return false;
@@ -185,18 +193,15 @@ class ReadinessChecker {
185193
_log('Error: Failed to find repository root (no .git directory found).');
186194
return false;
187195
}
188-
final ProcessResult activateResult = await _processManager.run(
189-
[
190-
'dart',
191-
'pub',
192-
'global',
193-
'activate',
194-
'--source',
195-
'path',
196-
_fileSystem.path.join(repoRoot, 'script', 'tool')
197-
],
198-
workingDirectory: workspaceRoot,
199-
);
196+
final ProcessResult activateResult = await _processManager.run([
197+
'dart',
198+
'pub',
199+
'global',
200+
'activate',
201+
'--source',
202+
'path',
203+
_fileSystem.path.join(repoRoot, 'script', 'tool'),
204+
], workingDirectory: workspaceRoot);
200205
if (activateResult.exitCode != 0) {
201206
_log('Error: Failed to globally activate flutter_plugin_tools.');
202207
_log(activateResult.stderr);

‎packages/camera/camera_android_camerax/.agents/skills/check-readiness/test/check_test.dart‎

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@ void main() {
6868
);
6969
workspaceRoot = fileSystem.path.absolute('workspace');
7070
fileSystem.file(fileSystem.path.join(workspaceRoot, '.git')).createSync(recursive: true);
71-
processManager.runMock['git config --get core.hooksPath'] =
72-
ProcessResult(0, 0, 'script/githooks\n', '');
71+
processManager.runMock['git config --get core.hooksPath'] = ProcessResult(
72+
0,
73+
0,
74+
'script/githooks\n',
75+
'',
76+
);
7377
printLogs.clear();
7478
});
7579

@@ -93,9 +97,9 @@ void main() {
9397
});
9498

9599
test('fails when a broken symlink is present', () async {
96-
final Directory skillsDir = fileSystem
97-
.directory(fileSystem.path.join(workspaceRoot, '.agents', 'skills'))
98-
..createSync(recursive: true);
100+
final Directory skillsDir = fileSystem.directory(
101+
fileSystem.path.join(workspaceRoot, '.agents', 'skills'),
102+
)..createSync(recursive: true);
99103

100104
// MemoryFileSystem supports links
101105
final Link link = fileSystem.link(fileSystem.path.join(skillsDir.path, 'broken_link'));
@@ -104,7 +108,9 @@ void main() {
104108
final bool result = await runChecker();
105109
expect(result, isFalse);
106110
expect(
107-
printLogs.any((line) => line.contains('Found broken symlinks in .agents/skills:')), isTrue);
111+
printLogs.any((line) => line.contains('Found broken symlinks in .agents/skills:')),
112+
isTrue,
113+
);
108114
});
109115

110116
test('fails when git is dirty', () async {
@@ -117,9 +123,11 @@ void main() {
117123
final bool result = await runChecker();
118124
expect(result, isFalse);
119125
expect(
120-
printLogs,
121-
contains(
122-
'Error: Git working directory is not clean. Please commit or stash your changes before starting new work.'));
126+
printLogs,
127+
contains(
128+
'Error: Git working directory is not clean. Please commit or stash your changes before starting new work.',
129+
),
130+
);
123131
});
124132

125133
test('fails when git hooks are not configured', () async {
@@ -142,8 +150,12 @@ void main() {
142150
.directory(fileSystem.path.join(workspaceRoot, '.agents', 'skills'))
143151
.createSync(recursive: true);
144152

145-
processManager.runMock['git config --get core.hooksPath'] =
146-
ProcessResult(0, 0, 'other/hooks\n', '');
153+
processManager.runMock['git config --get core.hooksPath'] = ProcessResult(
154+
0,
155+
0,
156+
'other/hooks\n',
157+
'',
158+
);
147159

148160
final bool result = await runChecker();
149161
expect(result, isFalse);
@@ -190,24 +202,26 @@ void main() {
190202
expect(printLogs, contains('Error: Failed to resolve dependencies.'));
191203
});
192204

193-
test('does not return early and reports multiple failures if git is dirty and tools are missing',
194-
() async {
195-
fileSystem
196-
.directory(fileSystem.path.join(workspaceRoot, '.agents', 'skills'))
197-
.createSync(recursive: true);
205+
test(
206+
'does not return early and reports multiple failures if git is dirty and tools are missing',
207+
() async {
208+
fileSystem
209+
.directory(fileSystem.path.join(workspaceRoot, '.agents', 'skills'))
210+
.createSync(recursive: true);
198211

199-
// Git returns dirty
200-
processManager.runMock['git status --porcelain'] = ProcessResult(0, 0, ' M file.txt\n', '');
201-
// Flutter is missing
202-
processManager.canRunMock['flutter'] = false;
212+
// Git returns dirty
213+
processManager.runMock['git status --porcelain'] = ProcessResult(0, 0, ' M file.txt\n', '');
214+
// Flutter is missing
215+
processManager.canRunMock['flutter'] = false;
203216

204-
final bool result = await runChecker();
205-
expect(result, isFalse);
217+
final bool result = await runChecker();
218+
expect(result, isFalse);
206219

207-
// Both errors should be printed
208-
expect(printLogs.any((line) => line.contains('Git working directory is not clean')), isTrue);
209-
expect(printLogs.any((line) => line.contains("'flutter' is not on the PATH")), isTrue);
210-
});
220+
// Both errors should be printed
221+
expect(printLogs.any((line) => line.contains('Git working directory is not clean')), isTrue);
222+
expect(printLogs.any((line) => line.contains("'flutter' is not on the PATH")), isTrue);
223+
},
224+
);
211225

212226
group('Windows style', () {
213227
late MemoryFileSystem winFileSystem;
@@ -229,22 +243,29 @@ void main() {
229243
});
230244

231245
test('fails when a broken symlink is present on Windows', () async {
232-
final Directory skillsDir = winFileSystem
233-
.directory(winFileSystem.path.join(winWorkspaceRoot, '.agents', 'skills'))
234-
..createSync(recursive: true);
246+
final Directory skillsDir = winFileSystem.directory(
247+
winFileSystem.path.join(winWorkspaceRoot, '.agents', 'skills'),
248+
)..createSync(recursive: true);
235249

236250
final Link link = winFileSystem.link(winFileSystem.path.join(skillsDir.path, 'broken_link'));
237251
link.createSync('non_existent_target');
238252

239253
final bool result = await winChecker.checkReadiness(winWorkspaceRoot);
240254
expect(result, isFalse);
241-
expect(printLogs.any((line) => line.contains('Found broken symlinks in .agents/skills:')),
242-
isTrue);
255+
expect(
256+
printLogs.any((line) => line.contains('Found broken symlinks in .agents/skills:')),
257+
isTrue,
258+
);
243259
});
244260

245261
test('passes when git hooks use Windows backslashes', () async {
246-
processManager.runMock['git config --get core.hooksPath'] =
247-
ProcessResult(0, 0, r'script\githooks' '\n', '');
262+
processManager.runMock['git config --get core.hooksPath'] = ProcessResult(
263+
0,
264+
0,
265+
r'script\githooks'
266+
'\n',
267+
'',
268+
);
248269
processManager.runMock['git status --porcelain'] = ProcessResult(0, 0, '', '');
249270

250271
final bool result = await winChecker.checkReadiness(winWorkspaceRoot);

0 commit comments

Comments
 (0)