forked from firka/firka
codegen: generate missing .g.dart files
This commit is contained in:
@@ -31,11 +31,11 @@ void main() async {
|
|||||||
ran = true;
|
ran = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isarOutOfDate(root)) {
|
if (_isarOutOfDate(root) || _isarGeneratedFilesMissing(root)) {
|
||||||
final inputs = _isarInputs(root);
|
final inputs = _isarInputs(root);
|
||||||
final hashes = _computeHashes(root, inputs);
|
final hashes = _computeHashes(root, inputs);
|
||||||
stdout.writeln(
|
stdout.writeln(
|
||||||
'Isar generated dart files out of date, running build_runner...',
|
'Isar generated dart files out of date or missing, running build_runner...',
|
||||||
);
|
);
|
||||||
await _run('dart', ['run', 'build_runner', 'build'], root);
|
await _run('dart', ['run', 'build_runner', 'build'], root);
|
||||||
_updateLockWithHashes(root, 'isar', hashes);
|
_updateLockWithHashes(root, 'isar', hashes);
|
||||||
@@ -240,6 +240,18 @@ bool _isarOutOfDate(String root) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _isarGeneratedFilesMissing(String root) {
|
||||||
|
final inputs = _isarInputs(root);
|
||||||
|
if (inputs.isEmpty) return false;
|
||||||
|
final modelsDir = p.join(root, 'lib/data/models');
|
||||||
|
for (final dartFile in inputs) {
|
||||||
|
final baseName = p.basenameWithoutExtension(dartFile.path);
|
||||||
|
final gFile = File(p.join(modelsDir, '$baseName.g.dart'));
|
||||||
|
if (!gFile.existsSync()) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
List<File> _splashInputs(String root) {
|
List<File> _splashInputs(String root) {
|
||||||
final config = File(p.join(root, 'flutter_native_splash.yaml'));
|
final config = File(p.join(root, 'flutter_native_splash.yaml'));
|
||||||
final splashImage = File(p.join(root, 'assets/images/logos/splash.png'));
|
final splashImage = File(p.join(root, 'assets/images/logos/splash.png'));
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ void main() async {
|
|||||||
ran = true;
|
ran = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isarOutOfDate(root)) {
|
if (_isarOutOfDate(root) || _isarGeneratedFilesMissing(root)) {
|
||||||
final inputs = _isarInputs(root);
|
final inputs = _isarInputs(root);
|
||||||
final hashes = _computeHashes(root, inputs);
|
final hashes = _computeHashes(root, inputs);
|
||||||
stdout.writeln(
|
stdout.writeln(
|
||||||
'Isar generated dart files out of date, running build_runner...',
|
'Isar generated dart files out of date or missing, running build_runner...',
|
||||||
);
|
);
|
||||||
await _run('dart', ['run', 'build_runner', 'build'], root);
|
await _run('dart', ['run', 'build_runner', 'build'], root);
|
||||||
_updateLockWithHashes(root, 'isar', hashes);
|
_updateLockWithHashes(root, 'isar', hashes);
|
||||||
@@ -228,6 +228,18 @@ bool _isarOutOfDate(String root) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _isarGeneratedFilesMissing(String root) {
|
||||||
|
final inputs = _isarInputs(root);
|
||||||
|
if (inputs.isEmpty) return false;
|
||||||
|
final modelsDir = p.join(root, 'lib/data/models');
|
||||||
|
for (final dartFile in inputs) {
|
||||||
|
final baseName = p.basenameWithoutExtension(dartFile.path);
|
||||||
|
final gFile = File(p.join(modelsDir, '$baseName.g.dart'));
|
||||||
|
if (!gFile.existsSync()) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> _run(
|
Future<bool> _run(
|
||||||
String executable,
|
String executable,
|
||||||
List<String> args,
|
List<String> args,
|
||||||
|
|||||||
Reference in New Issue
Block a user