Files
daily-notification-plugin/scripts/fix-capacitor-plugin-path.js
Matthew Raymer d9bdeb6d02 refactor(android)!: restructure to standard Capacitor plugin layout
Restructure Android project from nested module layout to standard
Capacitor plugin structure following community conventions.

Structure Changes:
- Move plugin code from android/plugin/ to android/src/main/java/
- Move test app from android/app/ to test-apps/android-test-app/app/
- Remove nested android/plugin module structure
- Remove nested android/app test app structure

Build Infrastructure:
- Add Gradle wrapper files (gradlew, gradlew.bat, gradle/wrapper/)
- Transform android/build.gradle from root project to library module
- Update android/settings.gradle for standalone plugin builds
- Add android/gradle.properties with AndroidX configuration
- Add android/consumer-rules.pro for ProGuard rules

Configuration Updates:
- Add prepare script to package.json for automatic builds on npm install
- Update package.json version to 1.0.1
- Update android/build.gradle to properly resolve Capacitor dependencies
- Update test-apps/android-test-app/settings.gradle with correct paths
- Remove android/variables.gradle (hardcode values in build.gradle)

Documentation:
- Update BUILDING.md with new structure and build process
- Update INTEGRATION_GUIDE.md to reflect standard structure
- Update README.md to remove path fix warnings
- Add test-apps/BUILD_PROCESS.md documenting test app build flows

Test App Configuration:
- Fix android-test-app to correctly reference plugin and Capacitor
- Remove capacitor-cordova-android-plugins dependency (not needed)
- Update capacitor.settings.gradle path verification in fix script

BREAKING CHANGE: Plugin now uses standard Capacitor Android structure.
Consuming apps must update their capacitor.settings.gradle to reference
android/ instead of android/plugin/. This is automatically handled by
Capacitor CLI for apps using standard plugin installation.
2025-11-05 08:08:37 +00:00

112 lines
3.4 KiB
JavaScript
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* Verify Capacitor plugin Android structure (post-restructure)
*
* This script verifies that the plugin follows the standard Capacitor structure:
* - android/src/main/java/... (plugin code)
* - android/build.gradle (plugin build config)
*
* This script is now optional since the plugin uses standard structure.
* It can be used to verify the structure is correct.
*
* @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);
function findAppRoot() {
let currentDir = __dirname;
// Go up from scripts/ to plugin root
currentDir = path.dirname(currentDir);
// Verify we're in the plugin root
const pluginPackageJson = path.join(currentDir, 'package.json');
if (!fs.existsSync(pluginPackageJson)) {
throw new Error('Could not find plugin package.json - script may be in wrong location');
}
// Go up from plugin root to node_modules/@timesafari
currentDir = path.dirname(currentDir);
// Go up from node_modules/@timesafari to node_modules
currentDir = path.dirname(currentDir);
// Go up from node_modules to app root
const appRoot = path.dirname(currentDir);
// Verify we found an app root
const androidDir = path.join(appRoot, 'android');
if (!fs.existsSync(androidDir)) {
throw new Error(`Could not find app android directory. Looked in: ${appRoot}`);
}
return appRoot;
}
/**
* Verify plugin uses standard Capacitor structure
*/
function verifyPluginStructure() {
console.log('🔍 Verifying Daily Notification Plugin structure...');
try {
const APP_ROOT = findAppRoot();
const PLUGIN_PATH = path.join(APP_ROOT, 'node_modules', '@timesafari', 'daily-notification-plugin');
const ANDROID_PLUGIN_PATH = path.join(PLUGIN_PATH, 'android');
const PLUGIN_JAVA_PATH = path.join(ANDROID_PLUGIN_PATH, 'src', 'main', 'java');
if (!fs.existsSync(ANDROID_PLUGIN_PATH)) {
console.log(' Plugin not found in node_modules (may not be installed yet)');
return;
}
// Check for standard structure
const hasStandardStructure = fs.existsSync(PLUGIN_JAVA_PATH);
const hasOldStructure = fs.existsSync(path.join(ANDROID_PLUGIN_PATH, 'plugin'));
if (hasOldStructure) {
console.log('⚠️ WARNING: Plugin still uses old structure (android/plugin/)');
console.log(' This should not happen after restructure. Please rebuild plugin.');
return;
}
if (hasStandardStructure) {
console.log('✅ Plugin uses standard Capacitor structure (android/src/main/java/)');
console.log(' No fixes needed - plugin path is correct!');
} else {
console.log('⚠️ Plugin structure not recognized');
console.log(` Expected: ${PLUGIN_JAVA_PATH}`);
}
} catch (error) {
console.error('❌ Error verifying plugin structure:', error.message);
process.exit(1);
}
}
/**
* Run verification
*/
function verifyAll() {
console.log('🔍 Daily Notification Plugin - Structure Verification');
console.log('==================================================\n');
verifyPluginStructure();
console.log('\n✅ Verification complete!');
}
// Run if called directly
if (import.meta.url === `file://${process.argv[1]}`) {
verifyAll();
}
export { verifyPluginStructure, verifyAll };