createFolderStructureAndFiles function
void
createFolderStructureAndFiles(
- String moduleTitle
)
Implementation
void createFolderStructureAndFiles(String moduleTitle) {
var baseDir = Directory('lib/modules');
if (!baseDir.existsSync()) {
baseDir.createSync();
}
///This line defines the module directory
var rootDir = Directory('lib/modules/${moduleTitle.toLowerCase()}');
print(moduleTitle);
///Creation of the module directory
if (!rootDir.existsSync()) {
rootDir.createSync();
}
///We then create subdirectories
var infrastructureDir = Directory('${rootDir.path}/infrastructure');
var serviceDir = Directory('${rootDir.path}/infrastructure/service');
var repoDir = Directory('${rootDir.path}/infrastructure/repository');
var modelDir = Directory('${rootDir.path}/infrastructure/models');
var domainDir = Directory('${rootDir.path}/domain');
var datasourceDir = Directory('${rootDir.path}/domain/datasource');
var presenterDir = Directory("${rootDir.path}/presenter");
if (!infrastructureDir.existsSync()) {
print("+Creating infrastructure directory........");
infrastructureDir.createSync();
}
if (!serviceDir.existsSync()) {
print("-Creating service directory........");
serviceDir.createSync();
createServiceWithTemplate(moduleTitle, serviceDir);
}
if (!repoDir.existsSync()) {
print("-Creating repository directory........");
repoDir.createSync();
createAbstractRepo(moduleTitle, repoDir);
createRepoImpl(moduleTitle, repoDir);
}
if (!modelDir.existsSync()) {
print("-Creating model directory........");
modelDir.createSync();
}
if (!domainDir.existsSync()) {
print("+Creating domain directory........");
domainDir.createSync();
}
if (!datasourceDir.existsSync()) {
print("-Creating datasource directory........");
datasourceDir.createSync();
createAbstractDataSource(moduleTitle, datasourceDir);
createDataSourceImpl(moduleTitle, datasourceDir);
}
if (!presenterDir.existsSync()) {
print("+Creating presenter directory........");
presenterDir.createSync();
}
}