Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Automated theme hook migration #31034

Merged
merged 18 commits into from
Nov 16, 2023
Merged

Conversation

roryabraham
Copy link
Contributor

@roryabraham roryabraham commented Nov 7, 2023

Details

I used a Node.js script to automatically migrate all these files. I don't recommend that you try to read or review this messy code, but for posterity this is the script that I used:

☠️ Read this messy code at your own peril ☠️
#!/usr/bin/env node

// NOTE: This script is dependent upon Node.js 20+

/*
 * This file contains a script that performs a code modification (codemod) to migrate all our static files to use the new theme hooks instead.
 * An example PR containing the migration for a few components can be found here: https://github.com/Expensify/App/pull/27346/files
 *
 * At a high level, the input to this script is a directory, and it will then:
 *
 * - Iterate through the JS/TS files in that directory
 * - If a file contains a React component, look for any uses of styles or theme colors
 * - Import the new theme and style hooks useTheme and useThemeStyles
 * - Use the hook or HOC in the component
 * - Replace the usages of the old static styles with a hook
 * - Remove the unused import of the old static styles
 */

/* eslint-disable @lwc/lwc/no-async-await */
/* eslint-disable no-await-in-loop */
/* eslint-disable no-restricted-syntax */
/* eslint-disable es/no-optional-chaining */
/* eslint-disable no-console */
/* eslint-disable no-param-reassign */
/* eslint-disable rulesdir/prefer-underscore-method */

const fs = require('fs').promises;
const path = require('path');
const {promisify} = require('util');
const exec = promisify(require('child_process').exec);
const parser = require('@babel/parser');
const traverse = require('@babel/traverse');
const generate = require('@babel/generator');

function getComponentInfo(ast) {
    let componentInfo = {};
    const functionNames = new Set();
    traverse.default(ast, {
        FunctionDeclaration({node}) {
            functionNames.add(node.id?.name);
        },
        VariableDeclaration({node}) {
            if (node.declarations[0].init?.callee?.name !== 'forwardRef' && node.declarations[0].init?.property?.name !== 'forwardRef') {
                return;
            }
            functionNames.add(node.declarations[0].id.name);
        },
        ExpressionStatement({node}) {
            if (Object.keys(componentInfo).length !== 0) {
                return;
            }

            const expression = node.expression;
            if (expression.type === 'AssignmentExpression' && functionNames.has(expression.left.object?.name) && expression.left.property?.name === 'displayName') {
                componentInfo = {
                    name: expression.left.object.name,
                    isClassComponent: false,
                };
            }
        },
        ClassDeclaration({node}) {
            if (Object.keys(componentInfo).length !== 0) {
                return;
            }

            if (
                !node.superClass ||
                !(
                    ['Component', 'PureComponent'].includes(node.superClass.name) ||
                    (node.superClass.type === 'MemberExpression' && node.superClass.object.name === 'React' && ['Component', 'PureComponent'].includes(node.superClass.property.name))
                )
            ) {
                return;
            }
            componentInfo = {
                name: node.id.name,
                isClassComponent: true,
            };
        },
    });
    return componentInfo;
}

async function writeASTToFile(filePath, fileContents, ast) {
    // Generate the modified code from the AST
    const modifiedCode = generate.default(ast, {compact: false, retainLines: true, retainFunctionParens: true}, fileContents).code;

    // Replace the contents of the file with the new code
    await fs.writeFile(filePath, modifiedCode, {encoding: 'utf8'});
}

function addComposeImport(filePath, ast) {
    const relativePathToLibsDir = path.relative(path.dirname(filePath), '/Users/roryabraham/Expensidev/App/src/libs') || '.';
    const hasComposeImport = ast.program.body.find((node) => node.type === 'ImportDeclaration' && node.specifiers[0].local.name === 'compose');
    if (hasComposeImport) {
        return;
    }

    const lastImportIndex = ast.program.body.findLastIndex((node) => node.type === 'ImportDeclaration');
    const lastImportLine = ast.program.body[lastImportIndex].loc.start.line;
    ast.program.body.splice(lastImportIndex + 1, 0, {
        type: 'ImportDeclaration',
        specifiers: [
            {
                type: 'ImportDefaultSpecifier',
                local: {
                    type: 'Identifier',
                    name: 'compose',
                },
            },
        ],
        source: {
            type: 'StringLiteral',
            value: `${relativePathToLibsDir}/compose`,
        },
        loc: {
            start: {
                line: lastImportLine + 1,
            },
        },
    });
}

async function migrateStylesForClassComponent(filePath, fileContents, ast) {
    const relativePathToStylesDir = path.relative(path.dirname(filePath), '/Users/roryabraham/Expensidev/App/src/styles') || '.';
    const relativePathToComponentsDir = path.relative(path.dirname(filePath), '/Users/roryabraham/Expensidev/App/src/components') || '.';
    let styleIdentifier = '';
    let themeColorsIdentifier = '';

    // Swap out static style/theme imports for HOC imports
    traverse.default(ast, {
        ImportDeclaration({node}) {
            const source = node.source.value;
            if (source === `${relativePathToStylesDir}/styles` || source === '@styles/styles') {
                styleIdentifier = node.specifiers[0].local.name;
                node.specifiers[0].local.name = 'withThemeStyles';
                node.specifiers.push({
                    type: 'ImportSpecifier',
                    imported: {
                        type: 'Identifier',
                        name: 'withThemeStylesPropTypes',
                    },
                });
                node.source.value = `${relativePathToComponentsDir}/withThemeStyles`;
            }
            if (source === `${relativePathToStylesDir}/themes/default` || source === '@styles/themes/default') {
                themeColorsIdentifier = node.specifiers[0].local.name;
                node.specifiers[0].local.name = 'withTheme';
                node.specifiers.push({
                    type: 'ImportSpecifier',
                    imported: {
                        type: 'Identifier',
                        name: 'withThemePropTypes',
                    },
                });
                node.source.value = `${relativePathToComponentsDir}/withTheme`;
            }
        },
        VariableDeclarator({node}) {
            if (node.id.name !== 'propTypes') {
                return;
            }

            if (styleIdentifier) {
                node.init.properties.push({type: 'SpreadElement', argument: {type: 'Identifier', name: 'withThemeStylesPropTypes'}});
            }

            if (themeColorsIdentifier) {
                node.init.properties.push({type: 'SpreadElement', argument: {type: 'Identifier', name: 'withThemePropTypes'}});
            }
        },
        MemberExpression({node}) {
            if (styleIdentifier && node.object.name === styleIdentifier) {
                node.object = {
                    type: 'MemberExpression',
                    object: {
                        type: 'MemberExpression',
                        object: {
                            type: 'ThisExpression',
                        },
                        property: {
                            type: 'Identifier',
                            name: 'props',
                        },
                    },
                    property: {
                        type: 'Identifier',
                        name: 'themeStyles',
                    },
                };
            }
            if (styleIdentifier && node.object.name === themeColorsIdentifier) {
                node.object = {
                    type: 'MemberExpression',
                    object: {
                        type: 'MemberExpression',
                        object: {
                            type: 'ThisExpression',
                        },
                        property: {
                            type: 'Identifier',
                            name: 'props',
                        },
                    },
                    property: {
                        type: 'Identifier',
                        name: 'theme',
                    },
                };
            }
        },
        ExportDefaultDeclaration({node}) {
            const newHOCs = [];
            if (styleIdentifier) {
                newHOCs.push({
                    type: 'Identifier',
                    name: 'withThemeStyles',
                });
            }
            if (themeColorsIdentifier) {
                newHOCs.push({
                    type: 'Identifier',
                    name: 'withTheme',
                });
            }

            if (newHOCs.length === 0) {
                return;
            }

            if (node.declaration.type === 'Identifier') {
                const prevDeclaration = node.declaration;
                if (newHOCs.length === 1) {
                    node.declaration = {
                        type: 'CallExpression',
                        callee: newHOCs[0],
                        arguments: [prevDeclaration],
                    };
                } else {
                    node.declaration = {
                        type: 'CallExpression',
                        callee: {
                            type: 'CallExpression',
                            callee: {
                                type: 'Identifier',
                                name: 'compose',
                            },
                            arguments: newHOCs,
                        },
                        arguments: [prevDeclaration],
                    };
                    addComposeImport(filePath, ast);
                }
                return;
            }

            // Export is wrapped with composed HOCs
            if (node.declaration.callee?.callee?.name === 'compose') {
                node.declaration.callee.arguments = node.declaration.callee.arguments.concat(newHOCs);
                return;
            }

            // Export is wrapped with a single HOC
            const previousHOC = node.declaration.callee?.callee || node.declaration.callee;
            if (previousHOC.name?.startsWith('with')) {
                node.declaration.callee = {
                    type: 'CallExpression',
                    callee: {
                        type: 'Identifier',
                        name: 'compose',
                    },
                    arguments: [
                        {
                            type: previousHOC.type,
                            name: previousHOC.name,
                        },
                        ...newHOCs,
                    ],
                };
                addComposeImport(filePath, ast);
                return;
            }

            // Export is another function, most probably React.forwardRef
            const prevDeclaration = node.declaration;
            if (newHOCs.length === 1) {
                node.declaration = {
                    type: 'CallExpression',
                    callee: newHOCs[0],
                    arguments: [prevDeclaration],
                };
            } else {
                node.declaration = {
                    type: 'CallExpression',
                    callee: {
                        type: 'CallExpression',
                        callee: {
                            type: 'Identifier',
                            name: 'compose',
                        },
                        arguments: newHOCs,
                    },
                    arguments: [prevDeclaration],
                };
                addComposeImport(filePath, ast);
            }
        },
    });

    if (!styleIdentifier && !themeColorsIdentifier) {
        return;
    }

    // Migrate defaultProps
    const defaultPropsToMigrate = {};
    traverse.default(ast, {
        VariableDeclaration({node}) {
            if (node.declarations[0].id?.name !== 'defaultProps') {
                return;
            }
            for (const prop of node.declarations[0].init.properties) {
                if (
                    prop.value &&
                    prop.value.type === 'MemberExpression' &&
                    prop.value.object.type === 'MemberExpression' &&
                    [styleIdentifier, themeColorsIdentifier, 'theme'].includes(prop.value.object.property.name)
                ) {
                    defaultPropsToMigrate[prop.key.name] = prop.value;
                    prop.value = {
                        type: 'Identifier',
                        name: 'undefined',
                    };
                }
            }
        },
        enter(nodePath) {
            if (
                !nodePath.isMemberExpression() ||
                nodePath.node.object.type !== 'MemberExpression' ||
                nodePath.node.object.object.type !== 'ThisExpression' ||
                nodePath.node.object.property.name !== 'props' ||
                !(nodePath.node.property.name in defaultPropsToMigrate)
            ) {
                return;
            }
            nodePath.replaceWith({
                type: 'LogicalExpression',
                left: nodePath.node,
                right: defaultPropsToMigrate[nodePath.node.property.name],
                operator: '||',
            });
            nodePath.skip();
        },
    });

    writeASTToFile(filePath, fileContents, ast);
}

async function migrateStylesForFunctionComponent(filePath, fileContents, ast, componentName) {
    const relativePathToStylesDir = path.relative(path.dirname(filePath), '/Users/roryabraham/Expensidev/App/src/styles') || '.';
    let styleIdentifier = '';
    let themeColorsIdentifier = '';
    let isUsingPropDestructuring = false;
    traverse.default(ast, {
        ImportDeclaration({node}) {
            const source = node.source.value;
            if (source === `${relativePathToStylesDir}/styles` || source === '@styles/styles') {
                styleIdentifier = node.specifiers[0].local.name;
                node.specifiers[0].local.name = 'useThemeStyles';
                node.source.value = `${relativePathToStylesDir}/useThemeStyles`;
            }
            if (source === `${relativePathToStylesDir}/themes/default` || source === '@styles/themes/default') {
                themeColorsIdentifier = node.specifiers[0].local.name;
                node.specifiers[0].local.name = 'useTheme';
                node.source.value = `${relativePathToStylesDir}/themes/useTheme`;
            }
        },
        VariableDeclaration({node}) {
            if (
                node.declarations[0].id?.name === componentName &&
                (node.declarations[0].init?.callee?.property?.name === 'forwardRef' || node.declarations[0].init?.callee?.name === 'forwardRef')
            ) {
                if (styleIdentifier) {
                    if (node.declarations[0].init.arguments[0].body.type === 'JSXElement') {
                        node.declarations[0].init.arguments[0].body = {
                            type: 'BlockStatement',
                            body: [
                                {
                                    type: 'VariableDeclaration',
                                    kind: 'const',
                                    declarations: [
                                        {
                                            type: 'VariableDeclarator',
                                            id: {
                                                type: 'Identifier',
                                                name: styleIdentifier,
                                            },
                                            init: {
                                                type: 'CallExpression',
                                                callee: {
                                                    type: 'Identifier',
                                                    name: 'useThemeStyles',
                                                },
                                                arguments: [],
                                            },
                                        },
                                    ],
                                },
                                {
                                    type: 'ReturnStatement',
                                    argument: node.declarations[0].init.arguments[0].body,
                                },
                            ],
                            directives: [],
                        };
                    } else {
                        node.declarations[0].init.arguments[0].body.body.unshift({
                            type: 'VariableDeclaration',
                            kind: 'const',
                            declarations: [
                                {
                                    type: 'VariableDeclarator',
                                    id: {
                                        type: 'Identifier',
                                        name: styleIdentifier,
                                    },
                                    init: {
                                        type: 'CallExpression',
                                        callee: {
                                            type: 'Identifier',
                                            name: 'useThemeStyles',
                                        },
                                        arguments: [],
                                    },
                                },
                            ],
                        });
                    }
                }
                if (themeColorsIdentifier) {
                    if (node.declarations[0].init.arguments[0].body.type === 'JSXElement') {
                        node.declarations[0].init.arguments[0].body = {
                            type: 'BlockStatement',
                            body: [
                                {
                                    type: 'VariableDeclaration',
                                    kind: 'const',
                                    declarations: [
                                        {
                                            type: 'VariableDeclarator',
                                            id: {
                                                type: 'Identifier',
                                                name: 'theme',
                                            },
                                            init: {
                                                type: 'CallExpression',
                                                callee: {
                                                    type: 'Identifier',
                                                    name: 'useTheme',
                                                },
                                                arguments: [],
                                            },
                                        },
                                    ],
                                },
                                {
                                    type: 'ReturnStatement',
                                    argument: node.declarations[0].init.arguments[0].body,
                                },
                            ],
                            directives: [],
                        };
                    } else {
                        node.declarations[0].init.arguments[0].body.body.unshift({
                            type: 'VariableDeclaration',
                            kind: 'const',
                            declarations: [
                                {
                                    type: 'VariableDeclarator',
                                    id: {
                                        type: 'Identifier',
                                        name: 'theme',
                                    },
                                    init: {
                                        type: 'CallExpression',
                                        callee: {
                                            type: 'Identifier',
                                            name: 'useTheme',
                                        },
                                        arguments: [],
                                    },
                                },
                            ],
                        });
                    }
                }
            }
        },
        FunctionDeclaration({node}) {
            if (node.id?.name !== componentName) {
                return;
            }
            isUsingPropDestructuring = node.params.length > 0 && node.params[0].type === 'ObjectPattern';
            if (styleIdentifier) {
                node.body.body.unshift({
                    type: 'VariableDeclaration',
                    kind: 'const',
                    declarations: [
                        {
                            type: 'VariableDeclarator',
                            id: {
                                type: 'Identifier',
                                name: styleIdentifier,
                            },
                            init: {
                                type: 'CallExpression',
                                callee: {
                                    type: 'Identifier',
                                    name: 'useThemeStyles',
                                },
                                arguments: [],
                            },
                        },
                    ],
                });
            }
            if (themeColorsIdentifier) {
                node.body.body.unshift({
                    type: 'VariableDeclaration',
                    kind: 'const',
                    declarations: [
                        {
                            type: 'VariableDeclarator',
                            id: {
                                type: 'Identifier',
                                name: 'theme',
                            },
                            init: {
                                type: 'CallExpression',
                                callee: {
                                    type: 'Identifier',
                                    name: 'useTheme',
                                },
                                arguments: [],
                            },
                        },
                    ],
                });
            }
        },
        MemberExpression({node}) {
            if (!themeColorsIdentifier || node.object.name !== themeColorsIdentifier) {
                return;
            }
            node.object.name = 'theme';
        },
    });

    if (!styleIdentifier && !themeColorsIdentifier) {
        return;
    }

    // Migrate defaultProps
    const defaultPropsToMigrate = {};
    traverse.default(ast, {
        VariableDeclaration({node}) {
            if (node.declarations[0].id?.name !== 'defaultProps') {
                return;
            }
            for (const prop of node.declarations[0].init.properties) {
                if (prop.value && prop.value.type === 'MemberExpression' && [styleIdentifier, themeColorsIdentifier, 'theme'].includes(prop.value.object.name)) {
                    defaultPropsToMigrate[prop.key.name] = prop.value;
                    prop.value = {
                        type: 'Identifier',
                        name: 'undefined',
                    };
                }
            }
        },
        FunctionDeclaration(nodePath) {
            if (nodePath.node.id?.name !== componentName) {
                return;
            }

            if (Object.keys(defaultPropsToMigrate).length > 0) {
                nodePath.traverse({
                    enter(funcSubPath) {
                        if (funcSubPath.isMemberExpression() && funcSubPath.node.object.name === 'props' && funcSubPath.node.property.name in defaultPropsToMigrate) {
                            funcSubPath.replaceWith({
                                type: 'LogicalExpression',
                                left: funcSubPath.node,
                                right: defaultPropsToMigrate[funcSubPath.node.property.name],
                                operator: '||',
                            });
                            funcSubPath.skip();
                        }
                        if (!isUsingPropDestructuring) {
                            return;
                        }
                        if (funcSubPath.isIdentifier() && funcSubPath.parentPath?.parent?.type === 'ObjectPattern') {
                            return;
                        }
                        if (funcSubPath.isIdentifier() && funcSubPath.node.name in defaultPropsToMigrate) {
                            funcSubPath.replaceWith({
                                type: 'LogicalExpression',
                                left: funcSubPath.node,
                                right: defaultPropsToMigrate[funcSubPath.node.name],
                                operator: '||',
                            });
                            funcSubPath.skip();
                        }
                    },
                });
            } else if (isUsingPropDestructuring) {
                for (const prop of nodePath.node.params[0].properties) {
                    if (
                        prop.value?.type === 'AssignmentPattern' &&
                        prop.value.right.type === 'MemberExpression' &&
                        [styleIdentifier, themeColorsIdentifier, 'theme'].includes(prop.value.right.object.name)
                    ) {
                        defaultPropsToMigrate[prop.key.name] = prop.value.right;
                        prop.value = prop.key;
                    }
                }
                if (Object.keys(defaultPropsToMigrate).length === 0) {
                    return;
                }
                nodePath.traverse({
                    enter(funcSubPath) {
                        if (funcSubPath.isObjectProperty() && funcSubPath.node.shorthand && funcSubPath.node.key.name in defaultPropsToMigrate) {
                            if (funcSubPath.parentPath.parent.id?.name !== componentName) {
                                funcSubPath.replaceWith({
                                    ...funcSubPath.node,
                                    shorthand: false,
                                    value: {
                                        type: 'LogicalExpression',
                                        left: funcSubPath.node.value,
                                        right: defaultPropsToMigrate[funcSubPath.node.key.name],
                                        operator: '??',
                                    },
                                });
                            }
                            funcSubPath.skip();
                        }

                        if (funcSubPath.isIdentifier() && funcSubPath.node.name in defaultPropsToMigrate) {
                            funcSubPath.replaceWith({
                                type: 'LogicalExpression',
                                left: funcSubPath.node,
                                right: defaultPropsToMigrate[funcSubPath.node.name],
                                operator: '??',
                            });
                            funcSubPath.skip();
                        }
                    },
                });
            }
        },
    });

    writeASTToFile(filePath, fileContents, ast);
}

async function migrateStaticStylesForFile(filePath) {
    const fileContents = await fs.readFile(filePath, 'utf8');
    const ast = parser.parse(fileContents, {
        sourceType: 'module',
        plugins: ['jsx', 'typescript'], // Enable JSX and TSX parsing
    });

    console.log('Parsing file:', filePath);
    const {name: componentName, isClassComponent} = getComponentInfo(ast);

    if (!componentName) {
        return;
    }

    if (isClassComponent) {
        console.log('File contains class component', filePath);
        migrateStylesForClassComponent(filePath, fileContents, ast);
        return;
    }

    console.log('File contains function component', filePath);
    migrateStylesForFunctionComponent(filePath, fileContents, ast, componentName);
}

async function migrateStaticStylesForDirectory(directoryPath) {
    const files = await fs.readdir(directoryPath);
    for (const file of files) {
        const filePath = path.join(directoryPath, file);
        const stat = await fs.stat(filePath);

        if (stat.isDirectory()) {
            await migrateStaticStylesForDirectory(filePath);
        } else if (stat.isFile() && (file.endsWith('.js') || file.endsWith('.jsx') || file.endsWith('.tsx')) && !file.endsWith('withThemeStyles.tsx')) {
            await migrateStaticStylesForFile(filePath);
        }
    }
}

/**
 * If the diff includes any lines that are just whitespace, undo them.
 * Sometimes blank lines are added in weird places by babel's generator due to the retainLines flag,
 * which is necessary to keep the formatting from the original source as much as possible.
 *
 * @param {String} directoryPath
 * @returns {Promise<void>}
 */
async function stripBlankLinesFromDiff(directoryPath) {
    try {
        console.log('Stripping blank lines from diff...');
        await exec("git diff --ignore-blank-lines -- ':!scripts/codemods/MigrateStaticStylesToThemeHooks.js' > tmp.patch");
        await exec(`git restore ${directoryPath}`);
        await exec(`git apply -v tmp.patch`);
        await exec('rm tmp.patch');
    } catch (error) {
        console.error('Error stripping blank lines from diff', error);
    }
}

async function run() {
    // Usage
    const directoryPath = process.argv[2]; // Get the directory path from command line arguments

    if (!directoryPath) {
        console.error('Usage: node script.js <directory_path>');
    } else {
        try {
            await migrateStaticStylesForDirectory(directoryPath);
            // await migrateStaticStylesForFile('/Users/roryabraham/Expensidev/App/src/components/Text.tsx');
            console.log('Running prettier...');
            let {stdout, stderr} = await exec("npx prettier --write $(git diff --name-only --diff-filter d | grep -E '\\.js|\\.tsx$' | xargs)");
            console.log(stdout);
            console.error(stderr);
            console.log('Running ESLint...');
            ({stdout, stderr} = await exec(
                "npm run --silent lint-changed -- --rule 'react-hooks/exhaustive-deps: [warn, {enableDangerousAutofixThisMayCauseInfiniteLoops: true}]' --format json | jq 'map(select(.messages!=[]) | .filePath)' || true",
            ));
            console.error(stderr);
            let filesNeedingManualMigration = JSON.parse(stdout || '[]');
            console.log('Running prettier ... again ...');
            ({stdout, stderr} = await exec("npx prettier --write $(git diff --name-only --diff-filter d | grep -E '\\.js|\\.tsx$' | xargs)"));
            console.log(stdout);
            console.error(stderr);
            await stripBlankLinesFromDiff(directoryPath);
            console.log('Running tsc...');
            ({stdout, stderr} = await exec("npm run --silent typecheck -- --pretty false | grep -oE '.*\\.tsx' | uniq | jq -ncR '[inputs]'"));
            filesNeedingManualMigration = filesNeedingManualMigration.concat(JSON.parse(stdout || '[]'));
            filesNeedingManualMigration = filesNeedingManualMigration.map((item) => item.replace('/Users/roryabraham/Expensidev/App/', ''));
            filesNeedingManualMigration = Array.from(new Set(filesNeedingManualMigration));
            console.log('The following files need manual migration – resetting them to their previous state...', filesNeedingManualMigration);
            await exec(`git restore ${filesNeedingManualMigration.join(' ')}`);
            console.error(stderr);
        } catch (error) {
            console.error('Error:', error);
        }
    }
}

run();

The only files I touched manually in this PR were:

  • src/components/withTheme.tsx
  • src/components/withThemeStyles.tsx
  • src/styles/ThemeStylesContext.tsx

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/318357

Tests

Perform basic regression tests across the app and try to find bugs.

  • Verify that no errors appear in the JS console

Offline tests

n/a

QA Steps

No specific test steps as this affects almost the whole app. Relying by regression testing here.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • 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
      • 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
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native image image image image image
Android: mWeb Chrome image image
iOS: Native image image image image
iOS: mWeb Safari image image image
MacOS: Chrome / Safari image
MacOS: Desktop image image image

@roryabraham roryabraham self-assigned this Nov 7, 2023
Copy link

melvin-bot bot commented Nov 7, 2023

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@roryabraham roryabraham force-pushed the Rory-AutomatedThemeHookMigration branch from 9af18c6 to cfee0d6 Compare November 10, 2023 17:38
@OSBotify
Copy link
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪

Android 🤖 iOS 🍎
https://ad-hoc-expensify-cash.s3.amazonaws.com/android/31034/index.html https://ad-hoc-expensify-cash.s3.amazonaws.com/ios/31034/index.html
Android iOS
Desktop 💻 Web 🕸️
https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/31034/NewExpensify.dmg https://31034.pr-testing.expensify.com
Desktop Web

@roryabraham roryabraham force-pushed the Rory-AutomatedThemeHookMigration branch from cfee0d6 to 7f72372 Compare November 10, 2023 20:59
@OSBotify
Copy link
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪

Android 🤖 iOS 🍎
https://ad-hoc-expensify-cash.s3.amazonaws.com/android/31034/index.html https://ad-hoc-expensify-cash.s3.amazonaws.com/ios/31034/index.html
Android iOS
Desktop 💻 Web 🕸️
https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/31034/NewExpensify.dmg https://31034.pr-testing.expensify.com
Desktop Web

@roryabraham roryabraham changed the title Automated theme hook migration [No QA] Automated theme hook migration Nov 10, 2023
@roryabraham roryabraham marked this pull request as ready for review November 10, 2023 21:37
@roryabraham roryabraham requested a review from a team as a code owner November 10, 2023 21:37
@melvin-bot melvin-bot bot removed the request for review from a team November 10, 2023 21:37
Copy link

melvin-bot bot commented Nov 10, 2023

@eVoloshchak Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@roryabraham roryabraham force-pushed the Rory-AutomatedThemeHookMigration branch from 7f72372 to 00b56e1 Compare November 10, 2023 21:44
@roryabraham roryabraham force-pushed the Rory-AutomatedThemeHookMigration branch from 00b56e1 to 28d0ac2 Compare November 11, 2023 14:08
Copy link
Contributor

@chrispader chrispader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

I didn't check every file, but multiple for both class and functional components. The script works great, thanks @roryabraham !

cc @grgia

@grgia
Copy link
Contributor

grgia commented Nov 13, 2023

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • 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
    • 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
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native image
iOS: mWeb Safari image
MacOS: Chrome / Safari image
MacOS: Desktop image

@grgia
Copy link
Contributor

grgia commented Nov 13, 2023

@roryabraham @chrispader did you encounter these warnings?

[web-server] WARNING in ./src/components/AvatarWithImagePicker.js 88:27-51
[web-server] export 'withThemeStylesPropTypes' (imported as 'withThemeStylesPropTypes') was not found in './withThemeStyles' (possible exports: default)
[web-server]  @ ./src/pages/settings/Profile/ProfilePage.js 12:0-70 98:90-111
[web-server]  @ ./src/libs/Navigation/AppNavigator/ModalStackNavigators.js 209:9-74
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js 7:0-91 30:15-63 33:15-62 36:15-61 43:15-62 46:15-62 49:15-68 52:15-69 55:15-75 58:15-73 61:15-66 64:15-65 67:15-67 70:15-62 73:15-61 76:15-59 79:15-64 82:15-67 85:15-77 88:15-65 91:15-61 94:15-61 97:15-61 100:15-67
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 40:0-67 305:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/components/AvatarWithImagePicker.js 88:54-72
[web-server] export 'withThemePropTypes' (imported as 'withThemePropTypes') was not found in './withTheme' (possible exports: default)
[web-server]  @ ./src/pages/settings/Profile/ProfilePage.js 12:0-70 98:90-111
[web-server]  @ ./src/libs/Navigation/AppNavigator/ModalStackNavigators.js 209:9-74
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js 7:0-91 30:15-63 33:15-62 36:15-61 43:15-62 46:15-62 49:15-68 52:15-69 55:15-75 58:15-73 61:15-66 64:15-65 67:15-67 70:15-62 73:15-61 76:15-59 79:15-64 82:15-67 85:15-77 88:15-65 91:15-61 94:15-61 97:15-61 100:15-67
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 40:0-67 305:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/components/CollapsibleSection/index.js 27:3-27
[web-server] export 'withThemeStylesPropTypes' (imported as 'withThemeStylesPropTypes') was not found in '@components/withThemeStyles' (possible exports: default)
[web-server]  @ ./src/pages/EnablePayments/TermsPage/LongTermsForm.js 4:0-64 76:97-115
[web-server]  @ ./src/pages/EnablePayments/TermsStep.js 19:0-54 69:39-52
[web-server]  @ ./src/pages/EnablePayments/EnablePaymentsPage.js 19:0-36 70:48-57
[web-server]  @ ./src/libs/Navigation/AppNavigator/ModalStackNavigators.js 74:11-81 265:9-79 311:11-81
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js 7:0-91 30:15-63 33:15-62 36:15-61 43:15-62 46:15-62 49:15-68 52:15-69 55:15-75 58:15-73 61:15-66 64:15-65 67:15-67 70:15-62 73:15-61 76:15-59 79:15-64 82:15-67 85:15-77 88:15-65 91:15-61 94:15-61 97:15-61 100:15-67
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 40:0-67 305:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/components/EmojiPicker/EmojiPickerMenuItem/index.js 38:3-27
[web-server] export 'withThemeStylesPropTypes' (imported as 'withThemeStylesPropTypes') was not found in '@components/withThemeStyles' (possible exports: default)
[web-server]  @ ./src/components/EmojiPicker/EmojiPickerMenu/index.js 15:0-78 474:44-63
[web-server]  @ ./src/components/EmojiPicker/EmojiPicker.js 13:0-48 189:38-53
[web-server]  @ ./src/Expensify.js 14:0-63 207:39-50
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/components/FloatingActionButton.js 37:27-51
[web-server] export 'withThemeStylesPropTypes' (imported as 'withThemeStylesPropTypes') was not found in './withThemeStyles' (possible exports: default)
[web-server]  @ ./src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js 12:0-68 243:39-59
[web-server]  @ ./src/pages/home/sidebar/SidebarScreen/index.js 5:0-78 39:44-74
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 45:9-72
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/components/FloatingActionButton.js 37:54-72
[web-server] export 'withThemePropTypes' (imported as 'withThemePropTypes') was not found in './withTheme' (possible exports: default)
[web-server]  @ ./src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js 12:0-68 243:39-59
[web-server]  @ ./src/pages/home/sidebar/SidebarScreen/index.js 5:0-78 39:44-74
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 45:9-72
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/components/NewDatePicker/CalendarPicker/index.js 40:27-51
export 'withThemeStylesPropTypes' (imported as 'withThemeStylesPropTypes') was not found in '@components/withThemeStyles' (possible exports: default)
[web-server]  @ ./src/components/NewDatePicker/index.js 17:0-46 98:38-52
[web-server]  @ ./src/pages/iou/MoneyRequestDatePage.js 8:0-54 94:38-51
[web-server]  @ ./src/libs/Navigation/AppNavigator/ModalStackNavigators.js 53:11-72
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js 7:0-91 30:15-63 33:15-62 36:15-61 43:15-62 46:15-62 49:15-68 52:15-69 55:15-75 58:15-73 61:15-66 64:15-65 67:15-67 70:15-62 73:15-61 76:15-59 79:15-64 82:15-67 85:15-77 88:15-65 91:15-61 94:15-61 97:15-61 100:15-67
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 40:0-67 305:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/components/OptionsListSkeletonView.js 24:3-27
[web-server] export 'withThemeStylesPropTypes' (imported as 'withThemeStylesPropTypes') was not found in './withThemeStyles' (possible exports: default)
[web-server]  @ ./src/pages/home/sidebar/SidebarLinks.js 16:0-74 171:52-75
[web-server]  @ ./src/pages/home/sidebar/SidebarLinksData.js 21:0-61 22:48-61 102:38-50
[web-server]  @ ./src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js 6:0-68 34:40-56
[web-server]  @ ./src/pages/home/sidebar/SidebarScreen/index.js 4:0-52 37:38-55
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 45:9-72
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/components/OptionsListSkeletonView.js 24:30-48
[web-server] export 'withThemePropTypes' (imported as 'withThemePropTypes') was not found in './withTheme' (possible exports: default)
[web-server]  @ ./src/pages/home/sidebar/SidebarLinks.js 16:0-74 171:52-75
[web-server]  @ ./src/pages/home/sidebar/SidebarLinksData.js 21:0-61 22:48-61 102:38-50
[web-server]  @ ./src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js 6:0-68 34:40-56
[web-server]  @ ./src/pages/home/sidebar/SidebarScreen/index.js 4:0-52 37:38-55
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 45:9-72
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/components/QRShare/index.js 25:161-185
[web-server] export 'withThemeStylesPropTypes' (imported as 'withThemeStylesPropTypes') was not found in '@components/withThemeStyles' (possible exports: default)
[web-server]  @ ./src/components/QRShare/QRShareWithDownload/index.js 16:0-25 47:46-53
[web-server]  @ ./src/pages/ShareCodePage.js 22:0-74 106:42-61
[web-server]  @ ./src/libs/Navigation/AppNavigator/ModalStackNavigators.js 205:9-59
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js 7:0-91 30:15-63 33:15-62 36:15-61 43:15-62 46:15-62 49:15-68 52:15-69 55:15-75 58:15-73 61:15-66 64:15-65 67:15-67 70:15-62 73:15-61 76:15-59 79:15-64 82:15-67 85:15-77 88:15-65 91:15-61 94:15-61 97:15-61 100:15-67
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 40:0-67 305:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/components/QRShare/index.js 25:188-206
[web-server] export 'withThemePropTypes' (imported as 'withThemePropTypes') was not found in '@components/withTheme' (possible exports: default)
[web-server]  @ ./src/components/QRShare/QRShareWithDownload/index.js 16:0-25 47:46-53
[web-server]  @ ./src/pages/ShareCodePage.js 22:0-74 106:42-61
[web-server]  @ ./src/libs/Navigation/AppNavigator/ModalStackNavigators.js 205:9-59
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js 7:0-91 30:15-63 33:15-62 36:15-61 43:15-62 46:15-62 49:15-68 52:15-69 55:15-75 58:15-73 61:15-66 64:15-65 67:15-67 70:15-62 73:15-61 76:15-59 79:15-64 82:15-67 85:15-77 88:15-65 91:15-61 94:15-61 97:15-61 100:15-67
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 40:0-67 305:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/pages/ReimbursementAccount/ReimbursementAccountPage.js 81:27-51
[web-server] export 'withThemeStylesPropTypes' (imported as 'withThemeStylesPropTypes') was not found in '@components/withThemeStyles' (possible exports: default)
[web-server]  @ ./src/libs/Navigation/AppNavigator/ModalStackNavigators.js 299:9-91 321:11-93
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js 7:0-91 30:15-63 33:15-62 36:15-61 43:15-62 46:15-62 49:15-68 52:15-69 55:15-75 58:15-73 61:15-66 64:15-65 67:15-67 70:15-62 73:15-61 76:15-59 79:15-64 82:15-67 85:15-77 88:15-65 91:15-61 94:15-61 97:15-61 100:15-67
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 40:0-67 305:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/pages/SearchPage.js 50:3-27
[web-server] export 'withThemeStylesPropTypes' (imported as 'withThemeStylesPropTypes') was not found in '@components/withThemeStyles' (possible exports: default)
[web-server]  @ ./src/libs/Navigation/AppNavigator/ModalStackNavigators.js 165:11-58
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js 7:0-91 30:15-63 33:15-62 36:15-61 43:15-62 46:15-62 49:15-68 52:15-69 55:15-75 58:15-73 61:15-66 64:15-65 67:15-67 70:15-62 73:15-61 76:15-59 79:15-64 82:15-67 85:15-77 88:15-65 91:15-61 94:15-61 97:15-61 100:15-67
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 40:0-67 305:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/pages/ShareCodePage.js 43:69-93
[web-server] export 'withThemeStylesPropTypes' (imported as 'withThemeStylesPropTypes') was not found in '@components/withThemeStyles' (possible exports: default)
[web-server]  @ ./src/libs/Navigation/AppNavigator/ModalStackNavigators.js 205:9-59
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js 7:0-91 30:15-63 33:15-62 36:15-61 43:15-62 46:15-62 49:15-68 52:15-69 55:15-75 58:15-73 61:15-66 64:15-65 67:15-67 70:15-62 73:15-61 76:15-59 79:15-64 82:15-67 85:15-77 88:15-65 91:15-61 94:15-61 97:15-61 100:15-67
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 40:0-67 305:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/pages/home/report/ListBoundaryLoader/ListBoundaryLoader.js 59:14-46
[web-server] export 'stylesGenerator' (imported as 'stylesGenerator') was not found in '@styles/useThemeStyles' (possible exports: default)
[web-server]  @ ./src/pages/home/report/ReportActionsList.js 28:0-73 365:44-62 380:44-62
 @ ./src/pages/home/report/ReportActionsView.js 31:0-52 231:97-114
[web-server]  @ ./src/pages/home/ReportScreen.js 41:0-59 370:113-130
[web-server]  @ ./src/libs/Navigation/AppNavigator/ReportScreenWrapper.js 3:0-52 25:97-109
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.js 3:0-84 24:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/index.js 2:0-66 7:42-66
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 39:0-69 262:15-35
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js 77:27-51
[web-server] export 'withThemeStylesPropTypes' (imported as 'withThemeStylesPropTypes') was not found in '@components/withThemeStyles' (possible exports: default)
[web-server]  @ ./src/libs/Navigation/AppNavigator/ModalStackNavigators.js 231:9-96
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js 7:0-91 30:15-63 33:15-62 36:15-61 43:15-62 46:15-62 49:15-68 52:15-69 55:15-75 58:15-73 61:15-66 64:15-65 67:15-67 70:15-62 73:15-61 76:15-59 79:15-64 82:15-67 85:15-77 88:15-65 91:15-61 94:15-61 97:15-61 100:15-67
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 40:0-67 305:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js 77:54-72
[web-server] export 'withThemePropTypes' (imported as 'withThemePropTypes') was not found in '@components/withTheme' (possible exports: default)
[web-server]  @ ./src/libs/Navigation/AppNavigator/ModalStackNavigators.js 231:9-96
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js 7:0-91 30:15-63 33:15-62 36:15-61 43:15-62 46:15-62 49:15-68 52:15-69 55:15-75 58:15-73 61:15-66 64:15-65 67:15-67 70:15-62 73:15-61 76:15-59 79:15-64 82:15-67 85:15-77 88:15-65 91:15-61 94:15-61 97:15-61 100:15-67
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 40:0-67 305:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/pages/workspace/WorkspaceInviteMessagePage.js 65:45-69
[web-server] export 'withThemeStylesPropTypes' (imported as 'withThemeStylesPropTypes') was not found in '@components/withThemeStyles' (possible exports: default)
[web-server]  @ ./src/libs/Navigation/AppNavigator/ModalStackNavigators.js 297:9-82
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js 7:0-91 30:15-63 33:15-62 36:15-61 43:15-62 46:15-62 49:15-68 52:15-69 55:15-75 58:15-73 61:15-66 64:15-65 67:15-67 70:15-62 73:15-61 76:15-59 79:15-64 82:15-67 85:15-77 88:15-65 91:15-61 94:15-61 97:15-61 100:15-67
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 40:0-67 305:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] WARNING in ./src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js 43:45-69
[web-server] export 'withThemeStylesPropTypes' (imported as 'withThemeStylesPropTypes') was not found in '@components/withThemeStyles' (possible exports: default)
[web-server]  @ ./src/libs/Navigation/AppNavigator/ModalStackNavigators.js 285:9-90
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js 7:0-91 30:15-63 33:15-62 36:15-61 43:15-62 46:15-62 49:15-68 52:15-69 55:15-75 58:15-73 61:15-66 64:15-65 67:15-67 70:15-62 73:15-61 76:15-59 79:15-64 82:15-67 85:15-77 88:15-65 91:15-61 94:15-61 97:15-61 100:15-67
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 40:0-67 305:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12
[web-server]
[web-server] webpack 5.88.2 compiled with 19 warnings in 40409 ms

@grgia
Copy link
Contributor

grgia commented Nov 14, 2023

Still seeing one warning @roryabraham


[web-server] WARNING in ./src/pages/home/report/ListBoundaryLoader/ListBoundaryLoader.js 59:14-46
[web-server] export 'stylesGenerator' (imported as 'stylesGenerator') was not found in '@styles/useThemeStyles' (possible exports: default)
[web-server]  @ ./src/pages/home/report/ReportActionsList.js 28:0-73 365:44-62 380:44-62
[web-server]  @ ./src/pages/home/report/ReportActionsView.js 31:0-52 231:97-114
[web-server]  @ ./src/pages/home/ReportScreen.js 41:0-59 370:113-130
[web-server]  @ ./src/libs/Navigation/AppNavigator/ReportScreenWrapper.js 3:0-52 25:97-109
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.js 3:0-84 24:15-34
[web-server]  @ ./src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/index.js 2:0-66 7:42-66
[web-server]  @ ./src/libs/Navigation/AppNavigator/AuthScreens.js 39:0-69 262:15-35
[web-server]  @ ./src/libs/Navigation/AppNavigator/index.js 9:22-57
[web-server]  @ ./src/libs/Navigation/NavigationRoot.js 14:0-42 166:38-50
[web-server]  @ ./src/Expensify.js 31:0-62 221:38-52
[web-server]  @ ./src/App.js 21:0-36 52:38-47
[web-server]  @ ./index.js 6:0-28 11:9-12

@grgia
Copy link
Contributor

grgia commented Nov 14, 2023

@roryabraham cc @chrispader
I think we can just do this?

diff --git a/src/pages/home/report/ListBoundaryLoader/ListBoundaryLoader.js b/src/pages/home/report/ListBoundaryLoader/ListBoundaryLoader.js
index 459df668e1..6dd56471af 100644
--- a/src/pages/home/report/ListBoundaryLoader/ListBoundaryLoader.js
+++ b/src/pages/home/report/ListBoundaryLoader/ListBoundaryLoader.js
@@ -4,7 +4,7 @@ import {ActivityIndicator, View} from 'react-native';
 import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView';
 import useNetwork from '@hooks/useNetwork';
 import useTheme from '@styles/themes/useTheme';
-import useThemeStyles, {stylesGenerator} from '@styles/useThemeStyles';
+import useThemeStyles from '@styles/useThemeStyles';
 import CONST from '@src/CONST';

 const propTypes = {
@@ -58,7 +58,7 @@ function ListBoundaryLoader({type, isLoadingOlderReportActions, isLoadingInitial
         // applied for a header of the list, i.e. when you scroll to the bottom of the list
         // the styles for android and the rest components are different that's why we use two different components
         return (
-            <View style={[stylesGenerator.alignItemsCenter, styles.justifyContentCenter, styles.chatBottomLoader]}>
+            <View style={[styles.alignItemsCenter, styles.justifyContentCenter, styles.chatBottomLoader]}>
                 <ActivityIndicator
                     color={theme.spinner}
                     size="small"

@roryabraham roryabraham force-pushed the Rory-AutomatedThemeHookMigration branch from 29587fb to 49d8cdb Compare November 14, 2023 16:14
@roryabraham
Copy link
Contributor Author

@grgia fixed!

@roryabraham
Copy link
Contributor Author

Updated and confirmed no webpack build errors.

@roryabraham roryabraham force-pushed the Rory-AutomatedThemeHookMigration branch from 49d8cdb to e5ba6da Compare November 15, 2023 00:07
@grgia
Copy link
Contributor

grgia commented Nov 15, 2023

conflicts, but I'll review when you're online tonight so we can get this merged @roryabraham!

Copy link
Contributor

@chrispader chrispader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@roryabraham roryabraham force-pushed the Rory-AutomatedThemeHookMigration branch from e5ba6da to 05adf05 Compare November 15, 2023 16:24
@roryabraham roryabraham force-pushed the Rory-AutomatedThemeHookMigration branch from 05adf05 to 8717d94 Compare November 15, 2023 17:22
@roryabraham roryabraham force-pushed the Rory-AutomatedThemeHookMigration branch from 8717d94 to 5fff069 Compare November 15, 2023 21:03
@roryabraham

This comment was marked as outdated.

@roryabraham roryabraham force-pushed the Rory-AutomatedThemeHookMigration branch from b07edc8 to d521dd6 Compare November 15, 2023 21:12
@roryabraham
Copy link
Contributor Author

From the last run:

The following files need manual migration – resetting them to their previous state... [
  'src/components/AnimatedStep/index.js',
  'src/components/ConfirmedRoute.js',
  'src/components/GrowlNotification/index.js',
  'src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js',
  'src/components/Icon/index.tsx',
  'src/components/OfflineIndicator.js',
  'src/components/OfflineWithFeedback.js',
  'src/components/Onfido/BaseOnfidoWeb.js',
  'src/components/OptionsSelector/BaseOptionsSelector.js',
  'src/components/PDFView/index.js',
  'src/components/Picker/BasePicker.js',
  'src/components/Pressable/GenericPressable/BaseGenericPressable.tsx',
  'src/components/TabSelector/TabSelector.js',
  'src/libs/Navigation/AppNavigator/ModalStackNavigators.js',
  'src/libs/Navigation/NavigationRoot.js',
  'src/pages/EnablePayments/TermsPage/LongTermsForm.js',
  'src/pages/home/report/ReportActionItemGrouped.js',
  'src/pages/home/report/ReportActionItemSingle.js',
  'src/pages/signin/Terms.js',
  'src/styles/ThemeStylesProvider.tsx',
  'src/components/CollapsibleSection/index.tsx',
  'src/components/InlineSystemMessage.tsx',
  'src/components/MapView/PendingMapView.tsx',
  'src/components/MultipleAvatars.tsx',
  'src/components/Pressable/PressableWithDelayToggle.tsx',
  'src/components/SelectCircle.tsx'
]

Copy link
Contributor

@marcochavezf marcochavezf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code LGTM

@grgia grgia merged commit 69a3358 into main Nov 16, 2023
16 checks passed
@grgia grgia deleted the Rory-AutomatedThemeHookMigration branch November 16, 2023 10:37
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 1.4.1-13 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants