Skip to content

Commit

Permalink
Merge branch 'main' into blazejkustra/typescript-poc
Browse files Browse the repository at this point in the history
  • Loading branch information
blazejkustra committed Jul 11, 2023
2 parents f3034a7 + e5b7e3a commit 4e31da0
Show file tree
Hide file tree
Showing 271 changed files with 18,610 additions and 5,922 deletions.
16 changes: 14 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const globalRestrictedImport = [
];

module.exports = {
extends: ['expensify', 'plugin:storybook/recommended', 'plugin:react-hooks/recommended', 'prettier'],
plugins: ['react-hooks'],
extends: ['expensify', 'plugin:storybook/recommended', 'plugin:react-hooks/recommended', 'prettier', 'plugin:react-native-a11y/basic'],
plugins: ['react-hooks', 'react-native-a11y'],
parser: 'babel-eslint',
ignorePatterns: ['!.*', 'src/vendor', '.github/actions/**/index.js', 'desktop/dist/*.js', 'dist/*.js', 'node_modules/.bin/**', '.git/**'],
env: {
Expand All @@ -27,6 +27,18 @@ module.exports = {
__DEV__: 'readonly',
},
overrides: [
{
files: ['*.js', '*.jsx', '*.ts', '*.tsx'],
rules: {
'react-native-a11y/has-accessibility-hint': ['off'],
'react-native-a11y/has-valid-accessibility-descriptors': [
'error',
{
touchables: ['PressableWithoutFeedback', 'PressableWithFeedback'],
},
],
},
},
{
files: ['*.js', '*.jsx'],
settings: {
Expand Down
11 changes: 6 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

### Fixed Issues
<!---
1. Please replace GH_LINK with a URL link to the GitHub issue this Pull Request is fixing.
2. Please replace PROPOSAL: GH_LINK_ISSUE(COMMENT) with a URL link to your GitHub comment, which contains the approved proposal (i.e. the proposal that was approved by Expensify).
1. Please postfix `$` with a URL link to the GitHub issue this Pull Request is fixing. For example, `$ https://github.com/Expensify/App/issues/123`.
2. Please postfix `PROPOSAL:` with a URL link to your GitHub comment, which contains the approved proposal (i.e. the proposal that was approved by Expensify). For example, `PROPOSAL: https://github.com/Expensify/App/issues/123#issuecomment-1369752925`
Do NOT add the special GH keywords like `fixed` etc, we have our own process of managing the flow.
It MUST be an entire link to the github issue and your comment proposal ; otherwise, the linking will not work as expected.
It MUST be an entire link to the github issue and your comment proposal ; otherwise, the linking and its automation will not work as expected.
Make sure this section looks similar to this (you can link multiple issues using the same formatting, just add a new line):
Expand All @@ -18,8 +18,8 @@ $ https://github.com/Expensify/App/issues/<number-of-the-issue(comment)>
Do NOT only link the issue number like this: $ #<number-of-the-issue>
--->
$ GH_LINK
PROPOSAL: GH_LINK_ISSUE(COMMENT)
$
PROPOSAL:


### Tests
Expand Down Expand Up @@ -100,6 +100,7 @@ This is a checklist for PR authors. Please make sure to complete all tasks and c
- [ ] The file is named correctly
- [ ] The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
- [ ] The only data being stored in the state is data necessary for rendering and nothing else
- [ ] If we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
- [ ] For Class Components, any internal methods passed to components event handlers are bound to `this` properly so there are no scoping issues (i.e. for `onClick={this.submit}` the method `this.submit` should be bound to `this` in the constructor)
- [ ] Any internal methods bound to `this` are necessary to be bound (i.e. avoid `this.submit = this.submit.bind(this);` if `this.submit` is never passed to a component event handler like `onClick`)
- [ ] All JSX used for rendering exists in the render method
Expand Down
5 changes: 3 additions & 2 deletions .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,12 @@ class GithubUtils {
this.internalOctokit = new Octokit(
getOctokitOptions(token, {
throttle: {
retryAfterBaseValue: 2000,
onRateLimit: (retryAfter, options) => {
console.warn(`Request quota exhausted for request ${options.method} ${options.url}`);

// Retry once after hitting a rate limit error, then give up
if (options.request.retryCount <= 1) {
// Retry five times when hitting a rate limit error, then give up
if (options.request.retryCount <= 5) {
console.log(`Retrying after ${retryAfter} seconds!`);
return true;
}
Expand Down
5 changes: 3 additions & 2 deletions .github/actions/javascript/awaitStagingDeploys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@ class GithubUtils {
this.internalOctokit = new Octokit(
getOctokitOptions(token, {
throttle: {
retryAfterBaseValue: 2000,
onRateLimit: (retryAfter, options) => {
console.warn(`Request quota exhausted for request ${options.method} ${options.url}`);

// Retry once after hitting a rate limit error, then give up
if (options.request.retryCount <= 1) {
// Retry five times when hitting a rate limit error, then give up
if (options.request.retryCount <= 5) {
console.log(`Retrying after ${retryAfter} seconds!`);
return true;
}
Expand Down
36 changes: 36 additions & 0 deletions .github/actions/javascript/bumpVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,41 @@ const incrementVersion = (version, level) => {
return incrementPatch(major, minor, patch);
};

/**
* @param {String} currentVersion
* @param {String} level
* @returns {String}
*/
function getPreviousVersion(currentVersion, level) {
const [major, minor, patch, build] = getVersionNumberFromString(currentVersion);

if (level === SEMANTIC_VERSION_LEVELS.MAJOR) {
if (major === 1) {
return getVersionStringFromNumber(1, 0, 0, 0);
}
return getVersionStringFromNumber(major - 1, 0, 0, 0);
}

if (level === SEMANTIC_VERSION_LEVELS.MINOR) {
if (minor === 0) {
return getPreviousVersion(currentVersion, SEMANTIC_VERSION_LEVELS.MAJOR);
}
return getVersionStringFromNumber(major, minor - 1, 0, 0);
}

if (level === SEMANTIC_VERSION_LEVELS.PATCH) {
if (patch === 0) {
return getPreviousVersion(currentVersion, SEMANTIC_VERSION_LEVELS.MINOR);
}
return getVersionStringFromNumber(major, minor, patch - 1, 0);
}

if (build === 0) {
return getPreviousVersion(currentVersion, SEMANTIC_VERSION_LEVELS.PATCH);
}
return getVersionStringFromNumber(major, minor, patch, build - 1);
}

module.exports = {
getVersionNumberFromString,
getVersionStringFromNumber,
Expand All @@ -282,6 +317,7 @@ module.exports = {
SEMANTIC_VERSION_LEVELS,
incrementMinor,
incrementPatch,
getPreviousVersion,
};


Expand Down
5 changes: 3 additions & 2 deletions .github/actions/javascript/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,12 @@ class GithubUtils {
this.internalOctokit = new Octokit(
getOctokitOptions(token, {
throttle: {
retryAfterBaseValue: 2000,
onRateLimit: (retryAfter, options) => {
console.warn(`Request quota exhausted for request ${options.method} ${options.url}`);

// Retry once after hitting a rate limit error, then give up
if (options.request.retryCount <= 1) {
// Retry five times when hitting a rate limit error, then give up
if (options.request.retryCount <= 5) {
console.log(`Retrying after ${retryAfter} seconds!`);
return true;
}
Expand Down
190 changes: 169 additions & 21 deletions .github/actions/javascript/createOrUpdateStagingDeploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,29 +216,30 @@ const _ = __nccwpck_require__(3571);
const {spawn, execSync} = __nccwpck_require__(3129);
const CONST = __nccwpck_require__(4097);
const sanitizeStringForJSONParse = __nccwpck_require__(9338);
const {getPreviousVersion, SEMANTIC_VERSION_LEVELS} = __nccwpck_require__(8007);

/**
* @param {String} tag
*/
// eslint-disable-next-line no-unused-vars
function fetchTagIfNeeded(tag) {
function fetchTag(tag) {
const previousPatchVersion = getPreviousVersion(tag, SEMANTIC_VERSION_LEVELS.PATCH);
try {
console.log(`Checking if tag ${tag} exists locally`);
const command = `git rev-parse --verify ${tag}`;
console.log(`Running command: ${command}`);
const result = execSync(command).toString();
console.log(result);
} catch (e) {
console.log(`Tag ${tag} not found locally, attempting to fetch it.`);
let command = `git fetch origin tag ${tag} --no-tags`;

// Exclude commits reachable from the previous patch version (i.e: previous checklist),
// so that we don't have to fetch the full history
// Note that this condition would only ever _not_ be true in the 1.0.0-0 edge case
if (previousPatchVersion !== tag) {
command += ` --shallow-exclude=${previousPatchVersion}`;
}

console.log(`Running command: ${command}`);
let result = execSync(command).toString();
console.log(result);
console.log('Verifying that the tag is now available...');
command = `git rev-parse --verify ${tag}`;
execSync(command);
} catch (e) {
// This can happen if the tag was only created locally but does not exist in the remote. In this case, we'll fetch history of the staging branch instead
const command = `git fetch origin staging --no-tags --shallow-exclude=${previousPatchVersion}`;
console.log(`Running command: ${command}`);
result = execSync(command).toString();
console.log(result);
execSync(command);
}
}

Expand All @@ -250,10 +251,8 @@ function fetchTagIfNeeded(tag) {
* @returns {Promise<Array<Object<{commit: String, subject: String, authorName: String}>>>}
*/
function getCommitHistoryAsJSON(fromTag, toTag) {
// fetchTagIfNeeded(fromTag);
// fetchTagIfNeeded(toTag);
// Note: this is a temporary measure until we can figure out a faster way to fetch only what's needed
execSync('git fetch --all --tags');
fetchTag(fromTag);
fetchTag(toTag);

console.log('Getting pull requests merged between the following tags:', fromTag, toTag);
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -386,11 +385,12 @@ class GithubUtils {
this.internalOctokit = new Octokit(
getOctokitOptions(token, {
throttle: {
retryAfterBaseValue: 2000,
onRateLimit: (retryAfter, options) => {
console.warn(`Request quota exhausted for request ${options.method} ${options.url}`);

// Retry once after hitting a rate limit error, then give up
if (options.request.retryCount <= 1) {
// Retry five times when hitting a rate limit error, then give up
if (options.request.retryCount <= 5) {
console.log(`Retrying after ${retryAfter} seconds!`);
return true;
}
Expand Down Expand Up @@ -904,6 +904,154 @@ module.exports = function (inputString) {
};


/***/ }),

/***/ 8007:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

const _ = __nccwpck_require__(3571);

const SEMANTIC_VERSION_LEVELS = {
MAJOR: 'MAJOR',
MINOR: 'MINOR',
PATCH: 'PATCH',
BUILD: 'BUILD',
};
const MAX_INCREMENTS = 99;

/**
* Transforms a versions string into a number
*
* @param {String} versionString
* @returns {Array}
*/
const getVersionNumberFromString = (versionString) => {
const [version, build] = versionString.split('-');
const [major, minor, patch] = _.map(version.split('.'), (n) => Number(n));

return [major, minor, patch, Number.isInteger(Number(build)) ? Number(build) : 0];
};

/**
* Transforms version numbers components into a version string
*
* @param {Number} major
* @param {Number} minor
* @param {Number} patch
* @param {Number} [build]
* @returns {String}
*/
const getVersionStringFromNumber = (major, minor, patch, build = 0) => `${major}.${minor}.${patch}-${build}`;

/**
* Increments a minor version
*
* @param {Number} major
* @param {Number} minor
* @returns {String}
*/
const incrementMinor = (major, minor) => {
if (minor < MAX_INCREMENTS) {
return getVersionStringFromNumber(major, minor + 1, 0, 0);
}

return getVersionStringFromNumber(major + 1, 0, 0, 0);
};

/**
* Increments a Patch version
*
* @param {Number} major
* @param {Number} minor
* @param {Number} patch
* @returns {String}
*/
const incrementPatch = (major, minor, patch) => {
if (patch < MAX_INCREMENTS) {
return getVersionStringFromNumber(major, minor, patch + 1, 0);
}
return incrementMinor(major, minor);
};

/**
* Increments a build version
*
* @param {Number} version
* @param {Number} level
* @returns {String}
*/
const incrementVersion = (version, level) => {
const [major, minor, patch, build] = getVersionNumberFromString(version);

// Majors will always be incremented
if (level === SEMANTIC_VERSION_LEVELS.MAJOR) {
return getVersionStringFromNumber(major + 1, 0, 0, 0);
}

if (level === SEMANTIC_VERSION_LEVELS.MINOR) {
return incrementMinor(major, minor);
}

if (level === SEMANTIC_VERSION_LEVELS.PATCH) {
return incrementPatch(major, minor, patch);
}

if (build < MAX_INCREMENTS) {
return getVersionStringFromNumber(major, minor, patch, build + 1);
}

return incrementPatch(major, minor, patch);
};

/**
* @param {String} currentVersion
* @param {String} level
* @returns {String}
*/
function getPreviousVersion(currentVersion, level) {
const [major, minor, patch, build] = getVersionNumberFromString(currentVersion);

if (level === SEMANTIC_VERSION_LEVELS.MAJOR) {
if (major === 1) {
return getVersionStringFromNumber(1, 0, 0, 0);
}
return getVersionStringFromNumber(major - 1, 0, 0, 0);
}

if (level === SEMANTIC_VERSION_LEVELS.MINOR) {
if (minor === 0) {
return getPreviousVersion(currentVersion, SEMANTIC_VERSION_LEVELS.MAJOR);
}
return getVersionStringFromNumber(major, minor - 1, 0, 0);
}

if (level === SEMANTIC_VERSION_LEVELS.PATCH) {
if (patch === 0) {
return getPreviousVersion(currentVersion, SEMANTIC_VERSION_LEVELS.MINOR);
}
return getVersionStringFromNumber(major, minor, patch - 1, 0);
}

if (build === 0) {
return getPreviousVersion(currentVersion, SEMANTIC_VERSION_LEVELS.PATCH);
}
return getVersionStringFromNumber(major, minor, patch, build - 1);
}

module.exports = {
getVersionNumberFromString,
getVersionStringFromNumber,
incrementVersion,

// For tests
MAX_INCREMENTS,
SEMANTIC_VERSION_LEVELS,
incrementMinor,
incrementPatch,
getPreviousVersion,
};


/***/ }),

/***/ 7351:
Expand Down
Loading

0 comments on commit 4e31da0

Please sign in to comment.