This repository holds the codebase for the Fyle Mobile App. This document provides the tools and guidelines to set up, develop, test, and deploy the app efficiently. Built using the Ionic Framework, it supports both Android and iOS platforms.
- π§ Prerequisites
- β¨ Quick Setup
- π Environment Setup
- β Troubleshooting
- π Project Structure
- π§ͺ Testing
- π± Running on Devices
- π Deployment
- π Further Help
-
Node.js: Install Node.js (v14.17.2 or higher) using nvm.
-
Ionic CLI: Follow the instructions here and Install Ionic globally with
npm
by running:
npm install -g @ionic/cli
Follow the following steps to run the app locally in your browser:
- Clone the repository:
git clone https://github.com/fylein/fyle-mobile-app.git
cd fyle-mobile-app
- Install dependencies:
npm install
-
Set Environment Variables: Add the environment files corresponding to the build you want in the environment folder. (Follow Environment Setup)
-
Run Locally: Use the following command to run the application locally:
ionic serve -c [env_name]
Note
Replace env_name with the name of the environment file you want to use. For example, if you > have an environment file named staging, you would run:
ionic serve -c staging
For setting environment variables
- Environment Files: Ping the mobile app team and get the necessary environment files (environment.[env_name].ts).
- Place them inside the
/src/environments
folder
Important
Do not make any changes to the environment.ts
file - this is a template folder for creating > configurations. Also, make sure not to put staging environments in this file.
Here are some common issues and how to fix them:
- If you encounter any similar error like this:
Property 'LIVE_UPDATE_APP_VERSION' does not exist on type ...
Property 'LIVE_UPDATE_APP_VERSION' does not exist on type
'{ production: boolean; NAME: string; CLUSTER_DOMAIN: string; ROOT_URL: string; ROUTER_API_ENDPOINT: string;
ANDROID_CLIENT_ID: string; IP_FIND_KEY: string; GOOGLE_MAPS_API_KEY: string; FRESHCHAT_TOKEN: string;
SENTRY_DSN: string; REFINER_NPS_FORM_ID: string; }'
Solution:
Ensure that you have the latest environment.staging.ts file. This file might have been updated with new properties that are missing in your current version.
Error: Cannot GET /
when running the app locally in the browser
This error typically occurs when some of the dependencies listed in package.json
are not installed properly.
Solution:
- Delete the node_modules folder by running:
rm -rf node_modules
- Reinstall the dependencies by running:
npm install
This will ensure that all required packages are correctly installed, resolving the issue.
- Unable to create PR
Solution:
- Ping the mobile app team for write access to the repository
.
βββ .angular/ # Angular-related configuration
βββ .github/ # GitHub-specific configuration (e.g., workflows)
βββ .husky/ # Git hooks for pre-commit, etc.
βββ android/ # Android-specific configuration and source files
βββ coverage/ # Code coverage reports
βββ e2e/ # End-to-end tests
βββ eslint-custom-rules/ # Custom ESLint rules
βββ hooks/ # Custom hooks for the project
βββ ios/ # iOS-specific configuration and source files
βββ node_modules/ # Installed Node.js dependencies
βββ resources/ # Shared resources like images, fonts, etc.
βββ src/ # Main source code of the app
β βββ app/ # Application core
β β βββ auth/ # Authentication module
β β βββ core/ # Core application utilities and services
β β βββ deep-link-redirection/ # Deep link handling module
β β βββ fyle/ # Fyle-specific features or modules
β β βββ post-verification/ # Post-verification module
β β βββ shared/ # Shared components, directives, services, or icons
β β βββ app-routing.module.ts # Routing configuration for the app
β β βββ app.component.html # Main HTML template for the app
β β βββ app.component.scss # Main SCSS styles for the app
β β βββ app.component.spec.ts # Unit tests for the main app component
β β βββ app.component.ts # Main app component logic
β β βββ app.module.ts # Root module of the app
β β βββ constants.ts # Application-wide constants
β βββ assets/ # Static assets like images, icons, font, etc.
β βββ environments/ # Environment file-specific configuration
β βββ theme/ # Application themes (scss)
β βββ global.scss # Global styles for the app
β βββ index.html # Main HTML file of the application
β βββ main.ts # Main entry point for Angular app
β βββ polyfills.ts # Polyfills needed by Angular to load before the app
β βββ test.ts # File is required by karma.conf.js and loads recursively all the .spec
β βββ zone-flags.ts # Zone.js configuration flags
βββ .eslintrc.json # configuration file for ESLin
βββ .gitignore # Files and folders ignored by Git
βββ .npmrc # NPM configuration
βββ .prettierignore # Files ignored by Prettier
βββ angular.json # Angular workspace configuration
βββ appflow.config.json # Configuration for Appflow
βββ browserslist # Browser compatibility configuration
βββ build_appflow.sh # Shell script for Appflow build
βββ build_prod.sh # Shell script for production build
βββ build_staging.sh # Shell script for staging build
βββ capacitor.config.ts # Capacitor configuration
βββ ionic.config.json # Ionic CLI configuration
βββ karma.conf.js # Karma test runner configuration
βββ LICENSE # License file
βββ package-lock.json # Lockfile for NPM dependencies
βββ package.json # Project dependencies and scripts
βββ README.md # Documentation for the project
βββ tsconfig.app.json # TypeScript configuration for the app
βββ tsconfig.json # Base TypeScript configuration
βββ tsconfig.spec.json # TypeScript configuration for tests
βββ ...
- Run unit tests:
npm run test
- For non-parallel execution (Recommended method for preventing excessive CPU utilization and memory hogging.):
npm run test:no-parallel
After running the tests, you can view the test coverage report by following these steps:
- Open the generated
index.html
file present in theapp/coverage/index.html
. - Metrics Explanation: In this file, you will see 4 metrics for the files you have changed:
- Statements: Percentage of executed statements
- Branches: Percentage of executed branches (e.g., conditions in if, else, switch statements,
&&
,||
,?
operators) - Functions: Percentage of executed functions
- Lines: Percentage of executed lines of code
- To increase code coverage, write additional test cases to cover the missing metrics.
For running the app directly on an Android device for staging
- Build and sync the app:
ionic capacitor run android -l --external --configuration=staging
- It will open Android Studio, and let it build index files and Gradle build for some time. Then check that the studio recognized the right device in the top bar. Press the run button. After every change, you make in the
src
directory. It will automatically build the app on the device.
For running the app directly on an ios device for staging
- Add .env file to project (ping mobile app team for the file)
- Install Xcode from the App Store
- Build and sync:
ionic build --staging
npx cap sync
npx cap open ios
- Open Xcode, select the connected device from the top bar and click on the run button.
- Go to the GitHub Actions tab.
- From Workflows List, Select
Manual Workflow - Appflow
- On the right-hand side, you can see the list of workflow runs.
- In the list view you can see a
Run Workflow
button. Click on that button - Select the branch on which you want to run the workflow from the dropdown available for
Use workflow from
- Click on
Run Workflow
- This will now run the workflow on your private branch, and the Diawi APK and IPA links will be shared on Slack
For access to environment files or repository write permissions, contact the mobile app team.
For additional documentation, refer to the Ionic Framework Docs.