Skip to content

Commit

Permalink
fix(android): findComponentDescriptors should look in codegenConfig?.…
Browse files Browse the repository at this point in the history
…jsSrcsDir only and it should look into components starging with Native or ending with NativeComponent
  • Loading branch information
mfazekas committed Jul 14, 2024
1 parent d6982fc commit 348bef5
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,26 @@ import {extractComponentDescriptors} from './extractComponentDescriptors';
import {unixifyPaths} from '@react-native-community/cli-tools';

export function findComponentDescriptors(packageRoot: string) {
const files = glob.sync('**/+(*.js|*.jsx|*.ts|*.tsx)', {
cwd: unixifyPaths(packageRoot),
onlyFiles: true,
ignore: ['**/node_modules/**'],
});
let pjson: {codegenConfig?: {jsSrcsDir?: string}} = JSON.parse(
fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8'),
);
const jsSrcsDir = pjson?.codegenConfig?.jsSrcsDir;
if (jsSrcsDir === undefined) {
return [];
}

const jsSrcsRoot = path.join(packageRoot, jsSrcsDir);

const files = glob.sync(
'**/(Native*|*NativeComponent)(.android|)(.js|.jsx|.ts|.tsx)',
{
cwd: unixifyPaths(jsSrcsRoot),
onlyFiles: true,
ignore: ['**/node_modules/**'],
},
);
const codegenComponent = files
.map((filePath) =>
fs.readFileSync(path.join(packageRoot, filePath), 'utf8'),
)
.map((filePath) => fs.readFileSync(path.join(jsSrcsRoot, filePath), 'utf8'))
.map(extractComponentDescriptors)
.filter(Boolean);

Expand Down

0 comments on commit 348bef5

Please sign in to comment.