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:
Matthew Raymer
2025-03-25 13:13:55 +00:00
parent e946767cba
commit 71e0f297ff
92 changed files with 11523 additions and 69 deletions

View File

@@ -0,0 +1,123 @@
/**
* Environment check script for the Daily Notification plugin
* Validates that all required tools and dependencies are installed
*/
const { execSync } = require('child_process');
const os = require('os');
// Constants
const REQUIRED_NODE_VERSION = 14;
const REQUIRED_JAVA_VERSION = 11;
// Colors for output
const GREEN = '\x1b[32m';
const YELLOW = '\x1b[33m';
const RED = '\x1b[31m';
const RESET = '\x1b[0m';
// Logging functions
const log = {
info: (msg) => console.log(`🔍 ${msg}`),
success: (msg) => console.log(`${GREEN}${msg}${RESET}`),
warn: (msg) => console.log(`${YELLOW}⚠️ ${msg}${RESET}`),
error: (msg) => console.log(`${RED}${msg}${RESET}`)
};
// Check if a command exists
function commandExists(command) {
try {
execSync(`which ${command}`, { stdio: 'ignore' });
return true;
} catch {
return false;
}
}
// Get Node.js version
function checkNodeVersion() {
const version = process.version.match(/^v(\d+)/)[1];
if (version < REQUIRED_NODE_VERSION) {
throw new Error(`Node.js version ${REQUIRED_NODE_VERSION} or higher is required`);
}
log.success(`Node.js: v${version}`);
}
// Check npm
function checkNpm() {
if (!commandExists('npm')) {
throw new Error('npm is not installed');
}
log.success('npm is installed');
}
// Get Java version
function checkJava() {
try {
const output = execSync('java -version 2>&1').toString();
const version = output.match(/version "(\d+)/)[1];
if (version < REQUIRED_JAVA_VERSION) {
throw new Error(`Java version ${REQUIRED_JAVA_VERSION} or higher is required`);
}
log.success(`Java: version ${version}`);
} catch (error) {
throw new Error('Java is not installed or invalid version');
}
}
// Check Android environment
function checkAndroid() {
if (!process.env.ANDROID_HOME) {
throw new Error('ANDROID_HOME environment variable is not set');
}
log.success('Android environment is properly configured');
}
// Main function
async function main() {
log.info('Checking development environment...\n');
let hasErrors = false;
try {
checkNodeVersion();
checkNpm();
checkJava();
checkAndroid();
} catch (error) {
log.error(error.message);
hasErrors = true;
}
// Check iOS requirements only on macOS
if (os.platform() === 'darwin') {
try {
if (!commandExists('xcodebuild')) {
log.error('Xcode is not installed');
hasErrors = true;
} else {
log.success('Xcode is installed');
}
} catch (error) {
log.error('Failed to check Xcode installation');
hasErrors = true;
}
} else {
log.warn('iOS development requires macOS');
}
console.log(''); // Empty line for readability
// Exit with appropriate code
if (hasErrors && os.platform() === 'darwin') {
log.error('Environment check failed. Please fix the issues above.');
process.exit(1);
} else {
log.success('Environment check completed successfully for the current platform.');
process.exit(0);
}
}
main().catch(error => {
log.error('Unexpected error:', error);
process.exit(1);
});