refactor: improve build configuration and code organization
- Add build scripts for Android and iOS platforms - Remove duplicate web implementation (src/web.ts) - Add proper TypeScript configuration - Add module documentation to index.ts - Clean up package.json scripts This commit improves the project structure and build process by: 1. Adding dedicated build scripts for native platforms 2. Removing redundant web implementation 3. Adding proper TypeScript configuration with strict mode 4. Improving code documentation 5. Organizing package.json scripts The changes maintain backward compatibility while improving the development experience and code quality.
This commit is contained in:
72
scripts/setup-native.js
Normal file
72
scripts/setup-native.js
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Setup script for native dependencies
|
||||
* Configures native build environments and dependencies
|
||||
*/
|
||||
|
||||
const { execSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function setupAndroid() {
|
||||
console.log('🔧 Setting up Android environment...');
|
||||
|
||||
// Create gradle wrapper if it doesn't exist
|
||||
const gradleWrapper = path.join('android', 'gradlew');
|
||||
if (!fs.existsSync(gradleWrapper)) {
|
||||
console.log('Creating Gradle wrapper...');
|
||||
execSync('cd android && gradle wrapper', { stdio: 'inherit' });
|
||||
}
|
||||
|
||||
// Make gradle wrapper executable
|
||||
fs.chmodSync(gradleWrapper, '755');
|
||||
|
||||
// Create local.properties if it doesn't exist
|
||||
const localProperties = path.join('android', 'local.properties');
|
||||
if (!fs.existsSync(localProperties)) {
|
||||
const androidHome = process.env.ANDROID_HOME;
|
||||
if (androidHome) {
|
||||
const content = `sdk.dir=${androidHome.replace(/\\/g, '\\\\')}\n`;
|
||||
fs.writeFileSync(localProperties, content);
|
||||
console.log('Created local.properties');
|
||||
}
|
||||
}
|
||||
|
||||
// Sync Gradle
|
||||
console.log('Syncing Gradle...');
|
||||
execSync('cd android && ./gradlew --refresh-dependencies', { stdio: 'inherit' });
|
||||
}
|
||||
|
||||
function setupIOS() {
|
||||
if (process.platform !== 'darwin') {
|
||||
console.warn('⚠️ Skipping iOS setup (macOS required)');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('🔧 Setting up iOS environment...');
|
||||
|
||||
// Install pods
|
||||
console.log('Installing CocoaPods dependencies...');
|
||||
execSync('cd ios && pod install', { stdio: 'inherit' });
|
||||
|
||||
// Create Xcode project if it doesn't exist
|
||||
const xcodeProject = path.join('ios', 'DailyNotificationPlugin.xcodeproj');
|
||||
if (!fs.existsSync(xcodeProject)) {
|
||||
console.log('Creating Xcode project...');
|
||||
execSync('cd ios && pod setup', { stdio: 'inherit' });
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
console.log('🚀 Setting up native development environment...\n');
|
||||
|
||||
try {
|
||||
setupAndroid();
|
||||
setupIOS();
|
||||
console.log('\n✅ Native environment setup completed successfully!');
|
||||
} catch (error) {
|
||||
console.error('\n❌ Native environment setup failed:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user