Skip to content

Commit

Permalink
Merge branch 'main' into fix/41514-back-nav-loop-from-details-page
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed Jun 5, 2024
2 parents 07dd15d + 432c2e7 commit 6a03051
Show file tree
Hide file tree
Showing 736 changed files with 16,862 additions and 11,013 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ module.exports = {
__DEV__: 'readonly',
},
rules: {
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
Expand Down Expand Up @@ -156,6 +155,7 @@ module.exports = {
fixMixedExportsWithInlineTypeSpecifier: false,
},
],
'@typescript-eslint/no-use-before-define': ['error', {functions: false}],

// ESLint core rules
'es/no-nullish-coalescing-operators': 'off',
Expand Down
11 changes: 8 additions & 3 deletions .github/actions/javascript/bumpVersion/bumpVersion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as core from '@actions/core';
import {exec as originalExec} from 'child_process';
import fs from 'fs';
import type {PackageJson} from 'type-fest';
import {promisify} from 'util';
import {generateAndroidVersionCode, updateAndroidVersion, updateiOSVersion} from '@github/libs/nativeVersionUpdater';
import * as versionUpdater from '@github/libs/versionUpdater';
Expand All @@ -19,7 +20,7 @@ function updateNativeVersions(version: string) {
.then(() => {
console.log('Successfully updated Android!');
})
.catch((err) => {
.catch((err: string | Error) => {
console.error('Error updating Android');
core.setFailed(err);
});
Expand Down Expand Up @@ -47,8 +48,12 @@ if (!semanticVersionLevel || !Object.keys(versionUpdater.SEMANTIC_VERSION_LEVELS
console.log(`Invalid input for 'SEMVER_LEVEL': ${semanticVersionLevel}`, `Defaulting to: ${semanticVersionLevel}`);
}

const {version: previousVersion} = JSON.parse(fs.readFileSync('./package.json').toString());
const newVersion = versionUpdater.incrementVersion(previousVersion, semanticVersionLevel);
const {version: previousVersion}: PackageJson = JSON.parse(fs.readFileSync('./package.json').toString());
if (!previousVersion) {
core.setFailed('Error: Could not read package.json');
}

const newVersion = versionUpdater.incrementVersion(previousVersion ?? '', semanticVersionLevel);
console.log(`Previous version: ${previousVersion}`, `New version: ${newVersion}`);

updateNativeVersions(newVersion);
Expand Down
5 changes: 4 additions & 1 deletion .github/actions/javascript/bumpVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3478,7 +3478,10 @@ if (!semanticVersionLevel || !Object.keys(versionUpdater.SEMANTIC_VERSION_LEVELS
console.log(`Invalid input for 'SEMVER_LEVEL': ${semanticVersionLevel}`, `Defaulting to: ${semanticVersionLevel}`);
}
const { version: previousVersion } = JSON.parse(fs_1.default.readFileSync('./package.json').toString());
const newVersion = versionUpdater.incrementVersion(previousVersion, semanticVersionLevel);
if (!previousVersion) {
core.setFailed('Error: Could not read package.json');
}
const newVersion = versionUpdater.incrementVersion(previousVersion ?? '', semanticVersionLevel);
console.log(`Previous version: ${previousVersion}`, `New version: ${newVersion}`);
updateNativeVersions(newVersion);
console.log(`Setting npm version to ${newVersion}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const run = function (): Promise<void> {
core.setOutput('HAS_DEPLOY_BLOCKERS', false);
}
})
.catch((error) => {
.catch((error: string | Error) => {
console.error('A problem occurred while trying to communicate with the GitHub API', error);
core.setFailed(error);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const run = () => {

// Extract timestamp, Graphite accepts timestamp in seconds
if (current.metadata?.creationDate) {
timestamp = Math.floor(new Date(current.metadata.creationDate).getTime() / 1000);
timestamp = Math.floor(new Date(current.metadata.creationDate as string).getTime() / 1000);
}

if (current.name && current.meanDuration && current.meanCount && timestamp) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import * as core from '@actions/core';
import {readFileSync} from 'fs';
import type {PackageJson} from 'type-fest';
import * as versionUpdater from '@github/libs/versionUpdater';

const semverLevel = core.getInput('SEMVER_LEVEL', {required: true});
if (!semverLevel || !Object.values<string>(versionUpdater.SEMANTIC_VERSION_LEVELS).includes(semverLevel)) {
core.setFailed(`'Error: Invalid input for 'SEMVER_LEVEL': ${semverLevel}`);
}

const {version: currentVersion} = JSON.parse(readFileSync('./package.json', 'utf8'));
const previousVersion = versionUpdater.getPreviousVersion(currentVersion, semverLevel);
const {version: currentVersion}: PackageJson = JSON.parse(readFileSync('./package.json', 'utf8'));
if (!currentVersion) {
core.setFailed('Error: Could not read package.json');
}

const previousVersion = versionUpdater.getPreviousVersion(currentVersion ?? '', semverLevel);
core.setOutput('PREVIOUS_VERSION', previousVersion);
5 changes: 4 additions & 1 deletion .github/actions/javascript/getPreviousVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2728,7 +2728,10 @@ if (!semverLevel || !Object.values(versionUpdater.SEMANTIC_VERSION_LEVELS).inclu
core.setFailed(`'Error: Invalid input for 'SEMVER_LEVEL': ${semverLevel}`);
}
const { version: currentVersion } = JSON.parse((0, fs_1.readFileSync)('./package.json', 'utf8'));
const previousVersion = versionUpdater.getPreviousVersion(currentVersion, semverLevel);
if (!currentVersion) {
core.setFailed('Error: Could not read package.json');
}
const previousVersion = versionUpdater.getPreviousVersion(currentVersion ?? '', semverLevel);
core.setOutput('PREVIOUS_VERSION', previousVersion);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems: number) {

getNumberOfItemsFromReviewerChecklist()
.then(checkIssueForCompletedChecklist)
.catch((err) => {
.catch((err: string | Error) => {
console.error(err);
core.setFailed(err);
});
2 changes: 1 addition & 1 deletion .github/libs/sanitizeStringForJSONParse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const replacer = (str: string): string =>
* Solution partly taken from SO user Gabriel Rodríguez Flores 🙇
* https://stackoverflow.com/questions/52789718/how-to-remove-special-characters-before-json-parse-while-file-reading
*/
const sanitizeStringForJSONParse = (inputString: string): string => {
const sanitizeStringForJSONParse = (inputString: string | number | boolean | null | undefined): string => {
if (typeof inputString !== 'string') {
throw new TypeError('Input must me of type String');
}
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/detectRedirectCycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function detectCycle(): boolean {

fs.createReadStream(`${process.cwd()}/docs/redirects.csv`)
.pipe(parser)
.on('data', (row) => {
.on('data', (row: [string, string]) => {
// Create a directed graph of sourceURL -> targetURL
addEdge(row[0], row[1]);
})
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/e2ePerformanceTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
type: string
required: true

concurrency:
group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-e2e
cancel-in-progress: true

jobs:
buildBaseline:
runs-on: ubuntu-latest-xl
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
paths: ['**.js', '**.ts', '**.tsx', '**.json', '**.mjs', '**.cjs', 'config/.editorconfig', '.watchmanconfig', '.imgbotconfig']

concurrency:
group: "${{ github.ref }}-lint"
group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-lint
cancel-in-progress: true

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
paths: ['**.js', '**.ts', '**.tsx', '**.sh', 'package.json', 'package-lock.json']

concurrency:
group: "${{ github.ref }}-jest"
group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-jest
cancel-in-progress: true

jobs:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches-ignore: [staging, production]
paths: ['**.js', '**.ts', '**.tsx', 'package.json', 'package-lock.json', 'tsconfig.json']

concurrency:
group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-typecheck
cancel-in-progress: true

jobs:
typecheck:
if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }}
Expand Down
12 changes: 1 addition & 11 deletions .storybook/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,38 @@ Sometimes it might be beneficial to generate a local production version instead
In order to generate a production web build, run `npm run build`, this will generate a production javascript build in the `dist/` folder.
#### Local production build of the MacOS desktop app
In order to compile a production desktop build, run `npm run desktop-build`, this will generate a production app in the `dist/Mac` folder named `Chat.app`.
The commands used to compile a production or staging desktop build are `npm run desktop-build` and `npm run desktop-build-staging`, respectively. These will product an app in the `dist/Mac` folder named NewExpensify.dmg that you can install like a normal app.
HOWEVER, by default those commands will try to notarize the build (signing it as Expensify) and publish it to the S3 bucket where it's hosted for users. In most cases you won't actually need or want to do that for your local testing. To get around that and disable those behaviors for your local build, apply the following diff:
```diff
diff --git a/config/electronBuilder.config.js b/config/electronBuilder.config.js
index e4ed685f65..4c7c1b3667 100644
--- a/config/electronBuilder.config.js
+++ b/config/electronBuilder.config.js
@@ -42,9 +42,6 @@ module.exports = {
entitlements: 'desktop/entitlements.mac.plist',
entitlementsInherit: 'desktop/entitlements.mac.plist',
type: 'distribution',
- notarize: {
- teamId: '368M544MTT',
- },
},
dmg: {
title: 'New Expensify',
diff --git a/scripts/build-desktop.sh b/scripts/build-desktop.sh
index 791f59d733..526306eec1 100755
--- a/scripts/build-desktop.sh
+++ b/scripts/build-desktop.sh
@@ -35,4 +35,4 @@ npx webpack --config config/webpack/webpack.desktop.ts --env file=$ENV_FILE
title "Building Desktop App Archive Using Electron"
info ""
shift 1
-npx electron-builder --config config/electronBuilder.config.js --publish always "$@"
+npx electron-builder --config config/electronBuilder.config.js --publish never "$@"
```
There may be some cases where you need to test a signed and published build, such as when testing the update flows. Instructions on setting that up can be found in [Testing Electron Auto-Update](https://github.com/Expensify/App/blob/main/desktop/README.md#testing-electron-auto-update). Good luck 🙃
#### Local production build the iOS app
In order to compile a production iOS build, run `npm run ios-build`, this will generate a `Chat.ipa` in the root directory of this project.
Expand Down
4 changes: 1 addition & 3 deletions __mocks__/@react-navigation/native/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import {useIsFocused as realUseIsFocused, useTheme as realUseTheme} from '@react
// We only want these mocked for storybook, not jest
const useIsFocused: typeof realUseIsFocused = process.env.NODE_ENV === 'test' ? realUseIsFocused : () => true;

// @ts-expect-error as we're mocking this function
const useTheme: typeof realUseTheme = process.env.NODE_ENV === 'test' ? realUseTheme : () => ({});
const useTheme = process.env.NODE_ENV === 'test' ? realUseTheme : () => ({});

export * from '@react-navigation/core';
export * from '@react-navigation/native';
export {useIsFocused, useTheme};
36 changes: 18 additions & 18 deletions __mocks__/react-native-permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ const requestNotifications: jest.Mock<Notification> = jest.fn((options: Record<s
status: RESULTS.GRANTED,
settings: Object.keys(options)
.filter((option: string) => notificationOptions.includes(option))
.reduce((acc: NotificationSettings, option: string) => ({...acc, [option]: true}), {
lockScreen: true,
notificationCenter: true,
}),
.reduce(
(acc: NotificationSettings, option: string) => {
acc[option] = true;
return acc;
},
{
lockScreen: true,
notificationCenter: true,
},
),
}));

const checkMultiple: jest.Mock<ResultsCollection> = jest.fn((permissions: string[]) =>
permissions.reduce(
(acc: ResultsCollection, permission: string) => ({
...acc,
[permission]: RESULTS.GRANTED,
}),
{},
),
permissions.reduce((acc: ResultsCollection, permission: string) => {
acc[permission] = RESULTS.GRANTED;
return acc;
}, {}),
);

const requestMultiple: jest.Mock<ResultsCollection> = jest.fn((permissions: string[]) =>
permissions.reduce(
(acc: ResultsCollection, permission: string) => ({
...acc,
[permission]: RESULTS.GRANTED,
}),
{},
),
permissions.reduce((acc: ResultsCollection, permission: string) => {
acc[permission] = RESULTS.GRANTED;
return acc;
}, {}),
);

export {
Expand Down
Loading

0 comments on commit 6a03051

Please sign in to comment.