add signals package

This commit is contained in:
2026-01-14 00:33:42 -08:00
parent 9220cfd890
commit fd9f3509d4
3 changed files with 91 additions and 3 deletions
+82
View File
@@ -0,0 +1,82 @@
import 'dart:io';
void main() async {
final rootDir = Directory.current;
final packagesDir = Directory('${rootDir.path}/packages');
final readmeFile = File('${rootDir.path}/README.md');
if (!packagesDir.existsSync()) {
print('Error: packages directory not found at ${packagesDir.path}');
return;
}
final packages = <_Package>[];
await for (final entity in packagesDir.list(recursive: true)) {
if (entity is File && entity.path.endsWith('pubspec.yaml')) {
// Skip if likely in a build or hidden folder (simple heuristic)
if (entity.path.contains('/.') || entity.path.contains('/build/')) {
continue;
}
final pubspecContent = await entity.readAsString();
final name = _getValue(pubspecContent, 'name');
final description = _getValue(pubspecContent, 'description');
final version = _getValue(pubspecContent, 'version');
final publishTo = _getValue(pubspecContent, 'publish_to');
if (name != null && version != null && publishTo != 'none') {
// Calculate relative path from root
final relativePath = entity.parent.path.replaceFirst(rootDir.path, '.');
packages.add(_Package(
name: name,
description: description ?? '',
path: relativePath,
));
}
}
}
packages.sort((a, b) => a.name.compareTo(b.name));
final sb = StringBuffer();
sb.writeln('# packages.dart');
sb.writeln();
sb.writeln('A collection of Flutter packages maintained by @rodydavis.');
sb.writeln();
sb.writeln('## Packages');
sb.writeln();
sb.writeln('| Package | Description | Version | Pub |');
sb.writeln('| :--- | :--- | :--- | :--- |');
for (final pkg in packages) {
sb.writeln(
'| [${pkg.name}](${pkg.path}) | ${pkg.description} | [![Pub](https://img.shields.io/pub/v/${pkg.name}.svg?style=popout)] | [![pub package](https://img.shields.io/pub/v/${pkg.name}.svg)](https://pub.dev/packages/${pkg.name}) |');
}
await readmeFile.writeAsString(sb.toString());
print('README.md updated with ${packages.length} packages.');
}
String? _getValue(String content, String key) {
final regex = RegExp('^$key:\\s*(.*)\$', multiLine: true);
final match = regex.firstMatch(content);
var value = match?.group(1)?.trim();
if (value != null) {
if (value.startsWith("'") && value.endsWith("'")) {
value = value.substring(1, value.length - 1);
} else if (value.startsWith('"') && value.endsWith('"')) {
value = value.substring(1, value.length - 1);
}
}
return value;
}
class _Package {
final String name;
final String description;
final String path;
_Package({required this.name, required this.description, required this.path});
}