chore(scripts): script for generating Firebase configuration [skip ci]

This commit is contained in:
Jagandeep Brar
2022-03-26 09:54:42 -07:00
parent f2050bdfe3
commit 49e963f052
15 changed files with 2590 additions and 2590 deletions

View File

@@ -12,14 +12,18 @@ void main() {
if (_assets.existsSync()) _assets.deleteSync(recursive: true);
// Go through each localization file
Directory _localization = Directory('localization');
_localization.listSync().forEach((folder) {
List<FileSystemEntity> _entities = _localization.listSync();
_entities.sort((a, b) => a.path.compareTo(b.path));
_entities.forEach((entity) {
// Ensure that the filesystem entity is a folder, and finds any files within
if (FileSystemEntity.isDirectorySync(folder.path)) {
Directory module = Directory(folder.path);
if (FileSystemEntity.isDirectorySync(entity.path)) {
Directory module = Directory(entity.path);
print(
'Processing Module: ${module.path.substring(module.path.lastIndexOf('/') + 1)}',
);
module.listSync().forEach((language) {
List<FileSystemEntity> _languages = module.listSync();
_languages.sort((a, b) => a.path.compareTo(b.path));
_languages.forEach((language) {
print(
'--> Adding language: ${language.path.substring(language.path.lastIndexOf('/') + 1)}...',
);
@@ -47,7 +51,6 @@ void _writeFile(String path, Map<dynamic, dynamic>? data) {
Map<dynamic, dynamic>? fileData = jsonDecode(file.readAsStringSync());
// Ensure the file exists
if (file.existsSync()) {
print(' Appending localization strings...');
// Add all the localization strings to the file, and write back the string version of the map.
fileData!.addAll(data!);
JsonEncoder encoder = const JsonEncoder.withIndent(' ');
@@ -64,11 +67,7 @@ void _writeFile(String path, Map<dynamic, dynamic>? data) {
void _createFile(String path) {
File file = File(path);
if (file.existsSync()) {
print(' Found file. Skipping file creation...');
return;
}
print(' Created empty file...');
if (file.existsSync()) return;
file.createSync(recursive: true);
file.writeAsStringSync(
'{}',