generateLibDirectory method
generate asset directory
Implementation
Future<void> generateLibDirectory() async {
final skelentons = [
...ApplicationStructorConfig.skeleton,
if (flutter) ...[
ApplicationStructorConfig.widgets,
ApplicationStructorConfig.providers
]
];
for (var directory in skelentons) {
final _innerLibPath = path.join(libraryPath, directory.path);
final _innerTestPath = path.join(testPath, directory.path);
var createdDir = DirectoryCreator(_innerLibPath).run();
if (createdDir) {
var missExports = <String>[];
var scan = scanningFilesWithAsyncRecursive(io.Directory(_innerLibPath));
for (var f in (await scan.toList())) {
var _path = f.path.split(RegExp("$_innerLibPath/")).last;
if (_path != "${directory.path}.dart") {
missExports.add(_path);
}
}
/// create its tests directory
DirectoryCreator(_innerTestPath).run();
/// lib file
/// and test file
for (var innerFile in directory.inners) {
final _currentLibFilePath = path.join(_innerLibPath, innerFile.path);
var innerFileContent = innerFile.contents!;
if (missExports.isNotEmpty) {
innerFileContent +=
missExports.map((f) => "\nexport '$f';").join('');
}
var createdFile = FileCreator(_currentLibFilePath,
contents: innerFileContent, rewrite: rewrite)
.run();
/// [disabled]
/// create test file
/// if (createdFile) {
/// final _testFileName =
/// innerFile.path.replaceAll(RegExp(r'.dart'), '_test.dart');
/// final _currentTestFilePath =
/// path.join(_innerTestPath, _testFileName);
/// var contents = flutter
/// ? testTemplate.replaceAll(RegExp(r'package:test/test.dart'),
/// 'package:flutter_test/flutter_test.dart')
/// : testTemplate;
/// FileCreator(_currentTestFilePath,
/// contents: contents, rewrite: rewrite)
/// .run();
/// }
}
}
}
}