Proper fix for building locally and through GH actions

This commit is contained in:
stopflock
2025-10-09 19:29:05 -05:00
parent 793e735452
commit 93f0d9edae
5 changed files with 75 additions and 36 deletions
+3 -23
View File
@@ -1,36 +1,16 @@
// OpenStreetMap OAuth client IDs for this app.
import 'dart:io';
String _readFromProperties(String key) {
final file = File('lib/keys.properties');
if (!file.existsSync()) return '';
final lines = file.readAsLinesSync();
for (final line in lines) {
if (line.startsWith(key + '=')) {
return line.substring(key.length + 1);
}
}
return '';
}
// These must be provided via --dart-define at build time.
String get kOsmProdClientId {
const fromBuild = String.fromEnvironment('OSM_PROD_CLIENTID');
if (fromBuild.isNotEmpty) return fromBuild;
final fromFile = _readFromProperties('OSM_PROD_CLIENTID');
if (fromFile.isNotEmpty) return fromFile;
throw Exception('OSM_PROD_CLIENTID not configured');
throw Exception('OSM_PROD_CLIENTID not configured. Use --dart-define=OSM_PROD_CLIENTID=your_id');
}
String get kOsmSandboxClientId {
const fromBuild = String.fromEnvironment('OSM_SANDBOX_CLIENTID');
if (fromBuild.isNotEmpty) return fromBuild;
final fromFile = _readFromProperties('OSM_SANDBOX_CLIENTID');
if (fromFile.isNotEmpty) return fromFile;
throw Exception('OSM_SANDBOX_CLIENTID not configured');
throw Exception('OSM_SANDBOX_CLIENTID not configured. Use --dart-define=OSM_SANDBOX_CLIENTID=your_id');
}
-10
View File
@@ -1,10 +0,0 @@
# OpenStreetMap OAuth Client IDs
# Copy this file to keys.properties and fill in your values for local development
# These are used as fallback when environment variables are not provided via --dart-define.
#
# Get your client IDs from:
# Production: https://www.openstreetmap.org/oauth2/applications
# Sandbox: https://master.apis.dev.openstreetmap.org/oauth2/applications
OSM_PROD_CLIENTID=your_production_client_id_here
OSM_SANDBOX_CLIENTID=your_sandbox_client_id_here