Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Expensify/App into jasper-roomChang…
Browse files Browse the repository at this point in the history
…eLogs
  • Loading branch information
jasperhuangg committed Sep 26, 2023
2 parents 53e45de + c6b7eae commit c129c76
Show file tree
Hide file tree
Showing 526 changed files with 8,075 additions and 3,599 deletions.
5 changes: 3 additions & 2 deletions .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', 'prettier', 'plugin:react-native-a11y/basic'],
extends: ['expensify', 'plugin:storybook/recommended', 'plugin:react-hooks/recommended', 'plugin:react-native-a11y/basic', '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 @@ -46,7 +46,6 @@ module.exports = {
touchables: ['PressableWithoutFeedback', 'PressableWithFeedback'],
},
],
curly: 'error',
},
},
{
Expand Down Expand Up @@ -76,6 +75,7 @@ module.exports = {
patterns: restrictedImportPatterns,
},
],
curly: 'error',
},
},
{
Expand Down Expand Up @@ -162,6 +162,7 @@ module.exports = {
patterns: restrictedImportPatterns,
},
],
curly: 'error',
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/Accessibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ What can we do to fix the issue?
<!---
Check off any platforms that are affected by this issue
--->
Which of our officially supported platforms is this issue occurring on?
Which of our officially supported platforms is this issue occurring on? Please only tick the box if you have provided a screen-recording in the thread for each platform:
- [ ] Android / native
- [ ] Android / Chrome
- [ ] iOS / native
Expand Down
53 changes: 39 additions & 14 deletions .github/scripts/createDocsRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ const yaml = require('js-yaml');
const fs = require('fs');
const _ = require('underscore');

const warn = 'Number of hubs in _routes.yml does not match number of hubs in docs/articles. Please update _routes.yml with hub info.';
const warnMessage = (platform) => `Number of hubs in _routes.yml does not match number of hubs in docs/${platform}/articles. Please update _routes.yml with hub info.`;
const disclaimer = '# This file is auto-generated. Do not edit it directly. Use npm run createDocsRoutes instead.\n';
const docsDir = `${process.cwd()}/docs`;
const routes = yaml.load(fs.readFileSync(`${docsDir}/_data/_routes.yml`, 'utf8'));
const platformNames = {
expensifyClassic: 'expensify-classic',
newExpensify: 'new-expensify',
};

/**
* @param {String} str - The string to convert to title case
* @returns {String}
*/
function toTitleCase(str) {
return str.replace(/\w\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
return str.replace(/\w\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1));
}

/**
Expand All @@ -28,7 +32,7 @@ function getArticleObj(filename) {
}

/**
* If the articlea / sections exist in the hub, then push the entry to the array.
* If the article / sections exist in the hub, then push the entry to the array.
* Otherwise, create the array and push the entry to it.
* @param {*} hubs - The hubs array
* @param {*} hub - The hub we are iterating
Expand All @@ -44,20 +48,20 @@ function pushOrCreateEntry(hubs, hub, key, entry) {
}
}

function run() {
const hubs = fs.readdirSync(`${docsDir}/articles`);
if (hubs.length !== routes.hubs.length) {
// If new hubs have been added without metadata addition to _routes.yml
console.error(warn);
process.exit(1);
}
/**
* Add articles and sections to hubs
* @param {Array} hubs - The hubs inside docs/articles/ for a platform
* @param {String} platformName - Expensify Classic or New Expensify
* @param {Array} routeHubs - The hubs insude docs/data/_routes.yml for a platform
*/
function createHubsWithArticles(hubs, platformName, routeHubs) {
_.each(hubs, (hub) => {
// Iterate through each directory in articles
fs.readdirSync(`${docsDir}/articles/${hub}`).forEach((fileOrFolder) => {
fs.readdirSync(`${docsDir}/articles/${platformName}/${hub}`).forEach((fileOrFolder) => {
// If the directory content is a markdown file, then it is an article
if (fileOrFolder.endsWith('.md')) {
const articleObj = getArticleObj(fileOrFolder);
pushOrCreateEntry(routes.hubs, hub, 'articles', articleObj);
pushOrCreateEntry(routeHubs, hub, 'articles', articleObj);
return;
}

Expand All @@ -66,17 +70,38 @@ function run() {
const articles = [];

// Each subfolder will be a section containing articles
fs.readdirSync(`${docsDir}/articles/${hub}/${section}`).forEach((subArticle) => {
fs.readdirSync(`${docsDir}/articles/${platformName}/${hub}/${section}`).forEach((subArticle) => {
articles.push(getArticleObj(subArticle));
});

pushOrCreateEntry(routes.hubs, hub, 'sections', {
pushOrCreateEntry(routeHubs, hub, 'sections', {
href: section,
title: toTitleCase(section.replaceAll('-', ' ')),
articles,
});
});
});
}

function run() {
const expensifyClassicArticleHubs = fs.readdirSync(`${docsDir}/articles/${platformNames.expensifyClassic}`);
const newExpensifyArticleHubs = fs.readdirSync(`${docsDir}/articles/${platformNames.newExpensify}`);

const expensifyClassicRoute = _.find(routes.platforms, (platform) => platform.href === platformNames.expensifyClassic);
const newExpensifyRoute = _.find(routes.platforms, (platform) => platform.href === platformNames.newExpensify);

if (expensifyClassicArticleHubs.length !== expensifyClassicRoute.hubs.length) {
console.error(warnMessage(platformNames.expensifyClassic));
process.exit(1);
}

if (newExpensifyArticleHubs.length !== newExpensifyRoute.hubs.length) {
console.error(warnMessage(platformNames.newExpensify));
process.exit(1);
}

createHubsWithArticles(expensifyClassicArticleHubs, platformNames.expensifyClassic, expensifyClassicRoute.hubs);
createHubsWithArticles(newExpensifyArticleHubs, platformNames.newExpensify, newExpensifyRoute.hubs);

// Convert the object to YAML and write it to the file
let yamlString = yaml.dump(routes);
Expand Down
Loading

0 comments on commit c129c76

Please sign in to comment.