You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

58 lines
1.6 KiB

#!/usr/bin/env node
/**
* Post-sync script to fix capacitor.plugins.json
* This ensures the DailyNotification plugin is always registered
* even after npx cap sync overwrites the file
*
* @author Matthew Raymer
*/
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const PLUGINS_JSON_PATH = path.join(__dirname, '../android/app/src/main/assets/capacitor.plugins.json');
const PLUGIN_ENTRY = {
name: "DailyNotification",
classpath: "com.timesafari.dailynotification.DailyNotificationPlugin"
};
function fixCapacitorPlugins() {
console.log('🔧 Fixing capacitor.plugins.json...');
try {
// Read current content
let plugins = [];
if (fs.existsSync(PLUGINS_JSON_PATH)) {
const content = fs.readFileSync(PLUGINS_JSON_PATH, 'utf8');
plugins = JSON.parse(content);
}
// Check if our plugin is already there
const hasPlugin = plugins.some(p => p.name === PLUGIN_ENTRY.name);
if (!hasPlugin) {
plugins.push(PLUGIN_ENTRY);
fs.writeFileSync(PLUGINS_JSON_PATH, JSON.stringify(plugins, null, 2));
console.log('✅ Added DailyNotification plugin to capacitor.plugins.json');
} else {
console.log('✅ DailyNotification plugin already exists in capacitor.plugins.json');
}
} catch (error) {
console.error('❌ Error fixing capacitor.plugins.json:', error.message);
process.exit(1);
}
}
// Run if called directly
if (import.meta.url === `file://${process.argv[1]}`) {
fixCapacitorPlugins();
}
export { fixCapacitorPlugins };