mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-30 20:24:25 +00:00
chore(scripts): script for generating Firebase configuration [skip ci]
This commit is contained in:
@@ -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(
|
||||
'{}',
|
||||
|
||||
Reference in New Issue
Block a user