Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,20 +462,6 @@ By using this package, you acknowledge that it is provided as-is, and you agree

## Future Roadmap

### Asset Management Optimization

Currently, the `islam.js` package includes a large `assets` folder, which increases the package size to approximately 33MB. To improve the efficiency of package distribution and installation, the following steps are planned:

1. **Compression of Assets:**
- **Objective:** Reduce the overall package size by compressing the assets folder before publishing the package.
- **Approach:** Implement a compression strategy to package assets into a compressed format (e.g., ZIP, GZIP) that will be included in the published package.
- **Benefit:** This will significantly decrease the package size, making it more manageable and quicker to download for users.

2. **Automatic Decompression on Installation:**
- **Objective:** Automatically decompress the assets folder during the installation process.
- **Approach:** Develop a post-install script or use existing tools to decompress the assets once the package is installed.
- **Benefit:** This ensures that users receive the full set of assets without manual intervention while maintaining a smaller initial package size.

### Test Coverage
I have setup the baseline for tests but currently the test coverage is 38%. We need to increase it to at least 80%.
1. **Unit Tests:**
Expand Down
Binary file added assets.zip
Binary file not shown.
6 changes: 5 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/test/**/*.spec.ts'],
collectCoverageFrom: ['<rootDir>/src/**/*.ts', '!<rootDir>/src/types/**/*.ts'],
collectCoverageFrom: [
'<rootDir>/src/**/*.ts',
'!<rootDir>/src/types/**/*.ts',
'<rootDir>/scripts/**/*.js',
],
transform: {
'^.+\\.tsx?$': [
'ts-jest',
Expand Down
19 changes: 16 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@
"description": "A comprehensive JavaScript package offering Quranic text with multiple dialects (Hafs and Warsh), translations in over 20 languages, 28 Tafseers, Hadith collections with multiple translations, Dua and Azkar in 134 categories, prayer timings, and Hijri calendar support. Perfect for developers building Islamic applications and tools.",
"main": "./lib/index.js",
"files": [
"lib/**/*"
"lib/**/*",
"scripts/extractAssets.js",
"scripts/deleteAssets.js",
"scripts/cleanupAssets.js"
],
"scripts": {
"prebuild": "npm run extract-assets",
"build": "tsc --project tsconfig.build.json",
"clean": "rm -rf ./lib/",
"release": "semantic-release",
"prepare": "husky install",
"lint": "eslint ./src/",
"lint:fix": "eslint ./src/ --fix",
"start": "npx ts-node src/test.ts",
"test": "jest --coverage"
"test": "jest --coverage",
"extract-assets": "node scripts/extractAssets.js",
"delete-zip": "node scripts/deleteAssets.js",
"cleanup-assets": "node scripts/cleanupAssets.js",
"pretest": "npm run extract-assets",
"posttest": "npm run cleanup-assets",
"postinstall": "npm run extract-assets && npm run delete-zip"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -57,14 +67,17 @@
"url": "https://github.com/dev-ahmadbilal/islam.js/issues"
},
"homepage": "https://github.com/dev-ahmadbilal/islam.js#readme",
"dependencies": {
"adm-zip": "^0.5.10"
},
"devDependencies": {
"@commitlint/config-conventional": "^19.5.0",
"@eslint/js": "^9.10.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/npm": "^12.0.1",
"@types/jest": "^29.5.13",
"@types/node": "^22.5.4",
"@types/node": "^22.13.4",
"commitlint": "^19.5.0",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
29 changes: 29 additions & 0 deletions scripts/cleanupAssets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable no-undef, @typescript-eslint/no-require-imports */
const fs = require('fs');
const path = require('path');

// __dirname is automatically available in CommonJS
const assetsDir = path.join(__dirname, '../src/assets');

function cleanupAssets() {
if (!fs.existsSync(assetsDir)) {
console.log('No assets directory found. Nothing to clean up.');
return;
}

try {
console.log('Cleaning up extracted assets...');
fs.rmSync(assetsDir, { recursive: true, force: true });
console.log('Assets cleaned up successfully.');
} catch (error) {
console.error('Error cleaning up assets:', error);
throw error;
}
}

// Export for testing, execute for runtime
if (require.main === module) {
cleanupAssets();
}

module.exports = { cleanupAssets, assetsDir };
27 changes: 27 additions & 0 deletions scripts/deleteAssets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* eslint-disable no-undef, @typescript-eslint/no-require-imports */
const fs = require('fs');
const path = require('path');

// __dirname is automatically available in CommonJS
const assetsZipPath = path.join(__dirname, '../assets.zip');

function deleteAssetsZip() {
if (!fs.existsSync(assetsZipPath)) {
console.log('No assets.zip file found to delete.');
return;
}

try {
fs.unlinkSync(assetsZipPath);
console.log('assets.zip deleted successfully.');
} catch (error) {
console.error('Error deleting assets.zip:', error);
}
}

// Export for testing, execute for runtime
if (require.main === module) {
deleteAssetsZip();
}

module.exports = { deleteAssetsZip, assetsZipPath };
31 changes: 31 additions & 0 deletions scripts/extractAssets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable no-undef, @typescript-eslint/no-require-imports */
const fs = require('fs');
const path = require('path');
const AdmZip = require('adm-zip');

// __dirname is already available in CommonJS
const assetsZipPath = path.join(__dirname, '../assets.zip'); // Moved outside src
const assetsDir = path.join(__dirname, '../src'); // Destination folder

function extractAssets() {
if (!fs.existsSync(assetsZipPath)) {
console.log('No assets archive found. Skipping extraction.');
return;
}

try {
console.log('Extracting assets...');
const zip = new AdmZip(assetsZipPath);
zip.extractAllTo(assetsDir, true);
console.log('Assets extracted successfully.');
} catch (error) {
console.error('Error extracting assets:', error);
}
}

// Export for testing, execute for runtime
if (require.main === module) {
extractAssets();
}

module.exports = { extractAssets, assetsZipPath, assetsDir };
Loading