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.
This commit is contained in:
111
scripts/fix-capacitor-plugin-path.js
Executable file
111
scripts/fix-capacitor-plugin-path.js
Executable file
@@ -0,0 +1,111 @@
|
||||
#!/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 };
|
||||
Reference in New Issue
Block a user