Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Expensify/App into rocio-LoungePage
Browse files Browse the repository at this point in the history
  • Loading branch information
pecanoro committed Oct 30, 2023
2 parents bbb2b71 + 592317f commit ed115da
Show file tree
Hide file tree
Showing 1,124 changed files with 9,994 additions and 8,724 deletions.
25 changes: 24 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const restrictedImportPatterns = [
];

module.exports = {
extends: ['expensify', 'plugin:storybook/recommended', 'plugin:react-hooks/recommended', 'plugin:react-native-a11y/basic', 'prettier'],
extends: ['expensify', 'plugin:storybook/recommended', 'plugin:react-hooks/recommended', 'plugin:react-native-a11y/basic', 'plugin:@dword-design/import-alias/recommended', 'prettier'],
plugins: ['react-hooks', 'react-native-a11y'],
parser: 'babel-eslint',
ignorePatterns: ['!.*', 'src/vendor', '.github/actions/**/index.js', 'desktop/dist/*.js', 'dist/*.js', 'node_modules/.bin/**', 'node_modules/.cache/**', '.git/**'],
Expand All @@ -49,8 +49,31 @@ module.exports = {
touchables: ['PressableWithoutFeedback', 'PressableWithFeedback'],
},
],
'@dword-design/import-alias/prefer-alias': [
'warn',
{
alias: {
'@assets': './assets',
'@components': './src/components',
'@hooks': './src/hooks',
// This is needed up here, if not @libs/actions would take the priority
'@userActions': './src/libs/actions',
'@libs': './src/libs',
'@navigation': './src/libs/Navigation',
'@pages': './src/pages',
'@styles': './src/styles',
// This path is provide alias for files like `ONYXKEYS` and `CONST`.
'@src': './src',
},
},
],
},
},
// This helps disable the `prefer-alias` rule to be enabled for specific directories
{
files: ['tests/**/*.js', 'tests/**/*.ts', 'tests/**/*.jsx', 'assets/**/*.js', '.storybook/**/*.js'],
rules: {'@dword-design/import-alias/prefer-alias': ['off']},
},
{
files: ['*.js', '*.jsx'],
settings: {
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,6 @@ tsconfig.tsbuildinfo
# Yalc
.yalc
yalc.lock

# Local https certificate/key
config/webpack/*.pem
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ package-lock.json
*.css
*.scss
*.md
# We need to modify the import here specifically, hence we disable prettier to get rid of the sorted imports
src/libs/E2E/reactNativeLaunchingTest.js
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ module.exports = {
arrowParens: 'always',
printWidth: 190,
singleAttributePerLine: true,
importOrder: ['@assets/(.*)$', '@components/(.*)$', '@hooks/(.*)$', '@libs/(.*)$', '@navigation/(.*)$', '@pages/(.*)$', '@styles/(.*)$', '@userActions/(.*)$', '@src/(.*)$', '^[./]'],
importOrderSortSpecifiers: true,
importOrderCaseInsensitive: true,
};
8 changes: 4 additions & 4 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {PortalProvider} from '@gorhom/portal';
import React from 'react';
import Onyx from 'react-native-onyx';
import {SafeAreaProvider} from 'react-native-safe-area-context';
import {PortalProvider} from '@gorhom/portal';
import './fonts.css';
import ComposeProviders from '../src/components/ComposeProviders';
import HTMLEngineProvider from '../src/components/HTMLEngineProvider';
import OnyxProvider from '../src/components/OnyxProvider';
import {LocaleContextProvider} from '../src/components/LocaleContextProvider';
import {KeyboardStateProvider} from '../src/components/withKeyboardState';
import OnyxProvider from '../src/components/OnyxProvider';
import {EnvironmentProvider} from '../src/components/withEnvironment';
import {KeyboardStateProvider} from '../src/components/withKeyboardState';
import {WindowDimensionsProvider} from '../src/components/withWindowDimensions';
import ONYXKEYS from '../src/ONYXKEYS';
import './fonts.css';

Onyx.init({
keys: ONYXKEYS,
Expand Down
3 changes: 3 additions & 0 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ module.exports = ({config}) => {
'react-native-web': '@expensify/react-native-web',
'@react-native-community/netinfo': path.resolve(__dirname, '../__mocks__/@react-native-community/netinfo.js'),
'@react-navigation/native': path.resolve(__dirname, '../__mocks__/@react-navigation/native'),

// Module alias support for storybook files, coping from `webpack.common.js`
...custom.resolve.alias,
};

// Necessary to overwrite the values in the existing DefinePlugin hardcoded to the Config staging values
Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#### Table of Contents
* [Local Development](#local-development)
* [Testing on browsers on simulators and emulators](#testing-on-browsers-on-simulators-and-emulators)
* [Running The Tests](#running-the-tests)
* [Debugging](#debugging)
* [App Structure and Conventions](#app-structure-and-conventions)
Expand All @@ -34,12 +35,22 @@ These instructions should get you set up ready to work on New Expensify 🙌
1. Install `nvm` then `node` & `npm`: `brew install nvm && nvm install`
2. Install `watchman`: `brew install watchman`
3. Install dependencies: `npm install`
4. Install `mkcert`: `brew install mkcert` followed by `npm run setup-https`. If you are not using macOS, follow the instructions [here](https://github.com/FiloSottile/mkcert?tab=readme-ov-file#installation).
5. Create a host entry in your local hosts file, `/etc/hosts` for dev.new.expensify.com pointing to localhost:
```
127.0.0.1 dev.new.expensify.com
```

You can use any IDE or code editing tool for developing on any platform. Use your favorite!

## Recommended `node` setup
In order to have more consistent builds, we use a strict `node` and `npm` version as defined in the `package.json` `engines` field and `.nvmrc` file. `npm install` will fail if you do not use the version defined, so it is recommended to install `node` via `nvm` for easy node version management. Automatic `node` version switching can be installed for [`zsh`](https://github.com/nvm-sh/nvm#zsh) or [`bash`](https://github.com/nvm-sh/nvm#bash) using `nvm`.

## Configuring HTTPS
The webpack development server now uses https. If you're using a mac, you can simply run `npm run setup-https`.

If you're using another operating system, you will need to ensure `mkcert` is installed, and then follow the instructions in the repository to generate certificates valid for `new.expesify.com.dev` and `localhost`. The certificate should be named `certificate.pem` and the key should be named `key.pem`. They should be placed in `config/webpack`.

## Running the web app 🕸
* To run the **development web app**: `npm run web`
* Changes applied to Javascript will be applied automatically via WebPack as configured in `webpack.dev.js`
Expand Down Expand Up @@ -103,6 +114,43 @@ variables referenced here get updated since your local `.env` file is ignored.

----

# Testing on browsers in simulators and emulators

The development server is reached through the HTTPS protocol, and any client that access the development server needs a certificate.

You create this certificate by following the instructions in [`Configuring HTTPS`](#configuring-https) of this readme. When accessing the website served from the development server on browsers in iOS simulator or Android emulator, these virtual devices need to have the same certificate installed. Follow the steps below to install them.

#### Pre-requisite for Android flow
1. Open any emulator using Android Studio
2. Use `adb push "$(mkcert -CAROOT)/rootCA.pem" /storage/emulated/0/Download/` to push certificate to install in Download folder.
3. Install the certificate as CA certificate from the settings. On the Android emulator, this option can be found in Settings > Security > Encryption & Credentials > Install a certificate > CA certificate.
4. Close the emulator.

Note - If you want to run app on `https://127.0.0.1:8082`, then just install the certificate and use `adb reverse tcp:8082 tcp:8082` on every startup.

#### Android Flow
1. Run `npm run setupNewDotWebForEmulators android`
2. Select the emulator you want to run if prompted. (If single emulator is available, then it will open automatically)
3. Let the script execute till the message `🎉 Done!`.

Note - If you want to run app on `https://dev.new.expensify.com:8082`, then just do the Android flow and use `npm run startAndroidEmulator` to start the Android Emulator every time (It will configure the emulator).


Possible Scenario:
The flow may fail to root with error `adbd cannot run as root in production builds`. In this case, please refer to https://stackoverflow.com/a/45668555. Or use `https://127.0.0.1:8082` for less hassle.

#### iOS Flow
1. Run `npm run setupNewDotWebForEmulators ios`
2. Select the emulator you want to run if prompted. (If single emulator is available, then it will open automatically)
3. Let the script execute till the message `🎉 Done!`.

#### All Flow
1. Run `npm run setupNewDotWebForEmulators all` or `npm run setupNewDotWebForEmulators`
2. Check if the iOS flow runs first and then Android flow runs.
3. Let the script execute till the message `🎉 Done!`.

----

# Running the tests
## Unit tests
Unit tests are valuable when you want to test one component. They should be short, fast, and ideally only test one thing.
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001039203
versionName "1.3.92-3"
versionCode 1001039300
versionName "1.3.93-0"
}

flavorDimensions "default"
Expand Down
8 changes: 4 additions & 4 deletions assets/emojis/common.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Smiley from '../images/emoji.svg';
import AnimalsAndNature from '../images/emojiCategoryIcons/plant.svg';
import Flags from '../images/emojiCategoryIcons/flag.svg';
import FoodAndDrink from '../images/emojiCategoryIcons/hamburger.svg';
import TravelAndPlaces from '../images/emojiCategoryIcons/plane.svg';
import Activities from '../images/emojiCategoryIcons/soccer-ball.svg';
import Objects from '../images/emojiCategoryIcons/light-bulb.svg';
import Symbols from '../images/emojiCategoryIcons/peace-sign.svg';
import Flags from '../images/emojiCategoryIcons/flag.svg';
import TravelAndPlaces from '../images/emojiCategoryIcons/plane.svg';
import AnimalsAndNature from '../images/emojiCategoryIcons/plant.svg';
import Activities from '../images/emojiCategoryIcons/soccer-ball.svg';
import FrequentlyUsed from '../images/history.svg';

const skinTones = [
Expand Down
6 changes: 6 additions & 0 deletions assets/images/bell.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/images/bellSlash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,42 @@ const metro = {
['@babel/plugin-proposal-private-property-in-object', {loose: true}],
// The reanimated babel plugin needs to be last, as stated here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation
'react-native-reanimated/plugin',
// Import alias for native devices
[
'module-resolver',
{
extensions: [
'.native.js',
'.native.jsx',
'.native.ts',
'.native.tsx',
'.js',
'.jsx',
'.ts',
'.tsx',
'.ios.js',
'.ios.jsx',
'.ios.ts',
'.ios.tsx',
'.android.js',
'.android.jsx',
'.android.ts',
'.android.tx',
],
alias: {
'@assets': './assets',
'@components': './src/components',
'@hooks': './src/hooks',
'@libs': './src/libs',
'@navigation': './src/libs/Navigation',
'@pages': './src/pages',
'@styles': './src/styles',
// This path is provide alias for files like `ONYXKEYS` and `CONST`.
'@src': './src',
'@userActions': './src/libs/actions',
},
},
],
],
};

Expand All @@ -62,6 +98,7 @@ if (process.env.CAPTURE_METRICS === 'true') {
'scheduler/tracing': 'scheduler/tracing-profiling',
},
},
'extra-alias',
]);
}

Expand Down
13 changes: 13 additions & 0 deletions config/webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,19 @@ const webpackConfig = ({envFile = '.env', platform = 'web'}) => ({
'react-native-web': '@expensify/react-native-web',
'react-content-loader/native': 'react-content-loader',
'lottie-react-native': 'react-native-web-lottie',

// Module alias for web & desktop
// https://webpack.js.org/configuration/resolve/#resolvealias
'@assets': path.resolve(__dirname, '../../assets'),
'@components': path.resolve(__dirname, '../../src/components/'),
'@hooks': path.resolve(__dirname, '../../src/hooks/'),
'@libs': path.resolve(__dirname, '../../src/libs/'),
'@navigation': path.resolve(__dirname, '../../src/libs/Navigation/'),
'@pages': path.resolve(__dirname, '../../src/pages/'),
'@styles': path.resolve(__dirname, '../../src/styles/'),
// This path is provide alias for files like `ONYXKEYS` and `CONST`.
'@src': path.resolve(__dirname, '../../src/'),
'@userActions': path.resolve(__dirname, '../../src/libs/actions/'),
},

// React Native libraries may have web-specific module implementations that appear with the extension `.web.js`
Expand Down
8 changes: 8 additions & 0 deletions config/webpack/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ module.exports = (env = {}) =>
...proxySettings,
historyApiFallback: true,
port,
host: 'dev.new.expensify.com',
server: {
type: 'https',
options: {
key: path.join(__dirname, 'key.pem'),
cert: path.join(__dirname, 'certificate.pem'),
},
},
},
plugins: [
new DefinePlugin({
Expand Down
4 changes: 2 additions & 2 deletions contributingGuides/APPLE_GOOGLE_SIGNIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ function beginAppleSignIn(idToken) {

You can use any SSH tunneling service that allows you to configure custom subdomains so that we have a consistent address to use. We'll use ngrok in these examples, but ngrok requires a paid account for this. If you need a free option, try serveo.net.

After you've set ngrok up to be able to run on your machine (requires configuring a key with the command line tool, instructions provided by the ngrok website after you create an account), test hosting the web app on a custom subdomain. This example assumes the development web app is running at `localhost:8082`:
After you've set ngrok up to be able to run on your machine (requires configuring a key with the command line tool, instructions provided by the ngrok website after you create an account), test hosting the web app on a custom subdomain. This example assumes the development web app is running at `dev.new.expensify.com:8082`:

```
ngrok http 8082 --host-header="localhost:8082" --subdomain=mysubdomain
ngrok http 8082 --host-header="dev.new.expensify.com:8082" --subdomain=mysubdomain
```

The `--host-header` flag is there to avoid webpack errors with header validation. In addition, add `allowedHosts: 'all'` to the dev server config in `webpack.dev.js`:
Expand Down
4 changes: 2 additions & 2 deletions desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ _.assign(console, log.functions);
// until it detects that it has been upgraded to the correct version.

const EXPECTED_UPDATE_VERSION_FLAG = '--expected-update-version';
const APP_DOMAIN = __DEV__ ? `http://localhost:${port}` : 'app://-';
const APP_DOMAIN = __DEV__ ? `https://dev.new.expensify.com:${port}` : 'app://-';

let expectedUpdateVersion;
for (let i = 0; i < process.argv.length; i++) {
Expand Down Expand Up @@ -226,7 +226,7 @@ const mainWindow = () => {
let deeplinkUrl;
let browserWindow;

const loadURL = __DEV__ ? (win) => win.loadURL(`http://localhost:${port}`) : serve({directory: `${__dirname}/www`});
const loadURL = __DEV__ ? (win) => win.loadURL(`https://dev.new.expensify.com:${port}`) : serve({directory: `${__dirname}/www`});

// Prod and staging set the icon in the electron-builder config, so only update it here for dev
if (__DEV__) {
Expand Down
2 changes: 1 addition & 1 deletion desktop/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ portfinder
env,
},
{
command: `wait-port localhost:${port} && npx electronmon ./desktop/dev.js`,
command: `wait-port dev.new.expensify.com:${port} && npx electronmon ./desktop/dev.js`,
name: 'Electron',
prefixColor: 'cyan.dim',
env,
Expand Down
2 changes: 1 addition & 1 deletion docs/_includes/CONST.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% if jekyll.environment == "production" %}
{% assign MAIN_SITE_URL = "https://new.expensify.com" %}
{% else %}
{% assign MAIN_SITE_URL = "http://localhost:8082" %}
{% assign MAIN_SITE_URL = "https://dev.new.expensify.com:8082" %}
{% endif %}

{% capture CONCIERGE_CHAT_URL %}{{MAIN_SITE_URL}}/concierge{% endcapture %}
Loading

0 comments on commit ed115da

Please sign in to comment.