mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 14:32:24 +00:00
e6ee09e23b
Update the pkg/pkg.dart script to also include information about the size of the pkg/ packages (so we know ~how much code is on older analysis options sets). Change-Id: Ief1b9a868752a01aef5dd95a4ce1c74795315bc4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290615 Reviewed-by: Srujan Gaddam <srujzs@google.com> Commit-Queue: Devon Carew <devoncarew@google.com> Reviewed-by: Nate Bosch <nbosch@google.com>
63 lines
1.8 KiB
Dart
63 lines
1.8 KiB
Dart
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
/// List the packages in pkg/ as well information about their
|
|
/// analysis_options.yaml configuration.
|
|
|
|
import 'dart:io';
|
|
|
|
void main(List<String> args) {
|
|
const indent = 29;
|
|
|
|
var dirs = Directory('pkg').listSync().whereType<Directory>().toList();
|
|
dirs.sort((a, b) => a.path.compareTo(b.path));
|
|
|
|
for (var dir in dirs) {
|
|
var pubspec = File('${dir.path}/pubspec.yaml');
|
|
if (!pubspec.existsSync()) continue;
|
|
|
|
var sloc = _calcLines(dir) / 1024.0;
|
|
var slocDesc = '(${sloc.toStringAsFixed(1).padLeft(6)}k lines)';
|
|
var options = File('${dir.path}/analysis_options.yaml');
|
|
var name = dir.path.split('/').last;
|
|
|
|
if (options.existsSync()) {
|
|
var type = '** custom **';
|
|
var optionsContent = options.readAsStringSync();
|
|
if (optionsContent.contains('package:lints/core.yaml')) {
|
|
type = 'core';
|
|
} else if (optionsContent.contains('package:lints/recommended.yaml')) {
|
|
type = 'recommended';
|
|
}
|
|
print('${name.padRight(indent)}: ${type.padRight(12)} $slocDesc');
|
|
} else {
|
|
print('${name.padRight(indent)}: default $slocDesc');
|
|
}
|
|
}
|
|
}
|
|
|
|
int _calcLines(Directory dir) {
|
|
var result = 0;
|
|
|
|
for (var entity in dir.listSync()) {
|
|
if (entity.name.startsWith('.')) continue;
|
|
|
|
if (entity is Directory) {
|
|
result += _calcLines(entity);
|
|
} else {
|
|
if (entity is File && entity.name.endsWith('.dart')) {
|
|
result += entity
|
|
.readAsLinesSync()
|
|
.where((line) => line.trim().isNotEmpty)
|
|
.length;
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
extension FileSystemEntityExtension on FileSystemEntity {
|
|
String get name => path.split('/').last;
|
|
}
|