Skip to content

Commit

Permalink
chore: dropped all barrel files to not export any files.
Browse files Browse the repository at this point in the history
  • Loading branch information
oppahansi committed Dec 22, 2023
1 parent 1a35715 commit a6f5873
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 68 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 1.0.1

- Dropped all barrel files to not export anything.

## 1.0.1

- Updated readme with the Run on Save configuration option.

## 1.0.0
Expand Down
7 changes: 4 additions & 3 deletions bin/better_imports.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import "package:intl/intl.dart";
import "package:logging/logging.dart";

// Project Imports
import "package:better_imports/cmds/cmds.dart";
import "package:better_imports/parser/parser.dart";
import "package:better_imports/utils/utils.dart";
import "package:better_imports/arg_parser.dart";
import "package:better_imports/constants.dart";
import "package:better_imports/log.dart";
import "package:better_imports/sort_cmd.dart";

void main(List<String> args) {
_setupLogging();
Expand Down
2 changes: 1 addition & 1 deletion lib/parser/arg_parser.dart → lib/arg_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import 'package:args/args.dart';

// Project Imports
import 'package:better_imports/utils/utils.dart';
import 'package:better_imports/constants.dart';

final argParser = ArgParser()
..addFlag(
Expand Down
5 changes: 3 additions & 2 deletions lib/config/cfg.dart → lib/cfg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import 'package:args/args.dart';
import 'package:yaml/yaml.dart';

// Project Imports
import 'package:better_imports/extensions/extensions.dart';
import 'package:better_imports/utils/utils.dart';
import 'package:better_imports/constants.dart';
import 'package:better_imports/file_extension.dart';
import 'package:better_imports/log.dart';

var logging = false;

Expand Down
1 change: 0 additions & 1 deletion lib/cmds/cmds.dart

This file was deleted.

1 change: 0 additions & 1 deletion lib/collectors/collectors.dart

This file was deleted.

1 change: 0 additions & 1 deletion lib/config/config.dart

This file was deleted.

File renamed without changes.
1 change: 0 additions & 1 deletion lib/extensions/extensions.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import 'dart:io';

// Project Imports
import 'package:better_imports/config/config.dart';
import 'package:better_imports/utils/utils.dart';
import 'package:better_imports/cfg.dart';
import 'package:better_imports/log.dart';

class Collector {
final Cfg cfg;
Expand Down Expand Up @@ -49,13 +49,15 @@ class Collector {

for (var pattern in cfg.ignoreFilesLike) {
log.fine("┠─ Removing ignored file like: $pattern");

_filteredFilePaths.removeWhere(
(filePath) => RegExp(pattern).hasMatch(filePath),
);
}

for (var ignored in cfg.ignoreFiles) {
log.fine("┠─ Removing ignored file: $ignored");

_filteredFilePaths.removeWhere(
(filePath) =>
filePath.endsWith("${Platform.pathSeparator}$ignored.dart"),
Expand All @@ -77,6 +79,7 @@ class Collector {

void _retainNamedFiles(List<String> files) {
log.fine("┠─ Retaining only named files..");

_filteredFilePaths.retainWhere((element) {
var fileName = element.split(Platform.pathSeparator).last;

Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions lib/sorters/import_sorter.dart → lib/import_sorter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import 'package:analyzer/dart/ast/token.dart';
import 'package:dart_style/dart_style.dart';

// Project Imports
import 'package:better_imports/collectors/collectors.dart';
import 'package:better_imports/config/config.dart';
import 'package:better_imports/utils/utils.dart';
import 'package:better_imports/cfg.dart';
import 'package:better_imports/constants.dart';
import 'package:better_imports/file_collector.dart';
import 'package:better_imports/log.dart';

enum ImportType {
dart,
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion lib/parser/parser.dart

This file was deleted.

10 changes: 5 additions & 5 deletions lib/cmds/sort_cmd.dart → lib/sort_cmd.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import 'package:args/args.dart';
import 'package:tint/tint.dart';

// Project Imports
import 'package:better_imports/collectors/collectors.dart';
import 'package:better_imports/config/config.dart';
import 'package:better_imports/extensions/extensions.dart';
import 'package:better_imports/sorters/sorters.dart';
import 'package:better_imports/utils/utils.dart';
import 'package:better_imports/cfg.dart';
import 'package:better_imports/file_collector.dart';
import 'package:better_imports/file_extension.dart';
import 'package:better_imports/import_sorter.dart';
import 'package:better_imports/log.dart';

class SortCmd {
final ArgResults argResults;
Expand Down
1 change: 0 additions & 1 deletion lib/sorters/sorters.dart

This file was deleted.

2 changes: 0 additions & 2 deletions lib/utils/utils.dart

This file was deleted.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: better_imports
description: A better imports sorter for your .dart files.
version: 1.0.1
version: 1.0.2
repository: https://github.com/oppahansi/better_imports

executables:
Expand Down
6 changes: 3 additions & 3 deletions test/cfg_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import 'dart:io';
import 'package:test/test.dart';

// Project Imports
import 'package:better_imports/config/config.dart';
import 'package:better_imports/extensions/extensions.dart';
import 'package:better_imports/parser/parser.dart';
import 'package:better_imports/arg_parser.dart';
import 'package:better_imports/cfg.dart';
import 'package:better_imports/file_extension.dart';

void main() {
group("Cfg Tests.", () {
Expand Down
47 changes: 11 additions & 36 deletions test/file_collector_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import 'package:test/test.dart';

// Project Imports
import 'package:better_imports/collectors/collectors.dart';
import 'package:better_imports/config/config.dart';
import 'package:better_imports/parser/parser.dart';
import 'package:better_imports/arg_parser.dart';
import 'package:better_imports/cfg.dart';
import 'package:better_imports/file_collector.dart';

void main() {
group("Collector Tests. Test amount of collected files.", () {
Expand All @@ -26,7 +26,7 @@ void main() {
var collector = Collector(cfg: cfg);
var collectorResult = collector.collect();

expect(collectorResult.filteredPaths.length, 3);
expect(collectorResult.filteredPaths.length, 2);
});

test("files-like arg provided", () {
Expand All @@ -41,7 +41,7 @@ void main() {
});

test("folders arg provided", () {
var args = <String>["--folders", "lib/cmds, lib/collectors, lib/utils"];
var args = <String>["--folders", "lib"];
var argResult = argParser.parse(args);
var cfg = Cfg(argResult);

Expand All @@ -52,22 +52,14 @@ void main() {
});

test("ignore-files arg provided, ignore some dart files", () {
var args = <String>[];
var args = <String>["--ignore-files", "sort_cmd"];
var argResult = argParser.parse(args);
var cfg = Cfg(argResult);

var collector = Collector(cfg: cfg);
var collectorResult = collector.collect();

args = <String>["--ignore-files", "parser"];
argResult = argParser.parse(args);
cfg = Cfg(argResult);

collector = Collector(cfg: cfg);
var collected = collector.collect();

expect(
collected.filteredPaths.length, collectorResult.allPaths.length - 1);
expect(collected.filteredPaths.length, collected.allPaths.length - 1);
});

test("ignore-files-like arg provided, ignore all dart files", () {
Expand All @@ -82,42 +74,25 @@ void main() {
});

test("ignore-files-like arg provided, ignore only given files", () {
var args = <String>[];
var args = <String>["--ignore-files-like", r".*sort_cmd\.dart"];
var argResult = argParser.parse(args);
var cfg = Cfg(argResult);

var collector = Collector(cfg: cfg);
var collectorResult = collector.collect();

args = <String>["--ignore-files-like", r".*sort_cmd\.dart"];
argResult = argParser.parse(args);
cfg = Cfg(argResult);

collector = Collector(cfg: cfg);
var collected = collector.collect();

expect(collected.filteredPaths.length,
collectorResult.filteredPaths.length - 1);
expect(collected.filteredPaths.length, collected.allPaths.length - 1);
});

test("recursive arg provided, recursive false", () {
var args = <String>[];
var args = <String>["--no-recursive"];
var argResult = argParser.parse(args);
var cfg = Cfg(argResult);

var collector = Collector(cfg: cfg);
var collectorResult = collector.collect();

args = <String>["--no-recursive"];
argResult = argParser.parse(args);
cfg = Cfg(argResult);

collector = Collector(cfg: cfg);
var collected = collector.collect();

expect(
collected.filteredPaths.length < collectorResult.filteredPaths.length,
true);
expect(collected.filteredPaths.length == collected.allPaths.length, true);
});
});
}
8 changes: 4 additions & 4 deletions test/sorter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import 'package:dart_style/dart_style.dart';
import 'package:test/test.dart';

// Project Imports
import 'package:better_imports/collectors/collectors.dart';
import 'package:better_imports/config/config.dart';
import 'package:better_imports/parser/parser.dart';
import 'package:better_imports/sorters/sorters.dart';
import 'package:better_imports/arg_parser.dart';
import 'package:better_imports/cfg.dart';
import 'package:better_imports/file_collector.dart';
import 'package:better_imports/import_sorter.dart';

// Relative Project Imports
import '../res/sorter_fixtures.dart';
Expand Down

0 comments on commit a6f5873

Please sign in to comment.