createProject function
builds a project and generates the files. Should be placed in the main method.
Takes in a Project
void main(args) {
// create Project takes in one project and compiles it
createProject(
Project(...),
args
)
}
Implementation
Future<void> createProject(Project prj, [List<String> args = const []]) async {
var stopwatchAll = Stopwatch()..start();
var opt = GenOptions(args);
var bPrj = BuildProject(prj, prod: opt.prod);
print(
'Compiled Project ${prj.name} in ${stopwatchAll.elapsedMilliseconds}ms',
);
if (opt.hotreload) hotreload.reloadProject(bPrj);
if (opt.generateZip) {
saveAsZip(
_getFiles(bPrj, opt),
opt.output ?? '${bPrj.path}${bPrj.name}.zip',
);
} else if (bPrj.isGen) {
var path = opt.output != null
? io.getPath(opt.output!, '')
: io.getPath(bPrj.path, bPrj.name);
var stopwatchFiles = Stopwatch()..start();
final saved = await io.generateIO(
_getFiles(bPrj, opt),
path,
useIsolates: opt.useIsolates,
clean: opt.clean,
);
print(
'Finished saving ${saved.length} files in ${stopwatchFiles.elapsedMilliseconds}ms',
);
stopwatchFiles.stop();
}
print('Total Time: ${stopwatchAll.elapsedMilliseconds}ms');
stopwatchAll.stop();
}