Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ export function findComponentDescriptors(packageRoot: string) {
onlyFiles: true,
ignore: ['**/node_modules/**'],
});
const codegenComponent = files
.map((filePath) =>
fs.readFileSync(path.join(packageRoot, filePath), 'utf8'),
)
.map(extractComponentDescriptors)
.filter(Boolean);

// Filter out duplicates as it happens that libraries contain multiple outputs due to package publishing.
// TODO: consider using "codegenConfig" to avoid this.
return Array.from(new Set(codegenComponent as string[]));
const descriptors = new Set<string>();
for (const filePath of files) {
const descriptor = extractComponentDescriptors(
fs.readFileSync(path.join(packageRoot, filePath), 'utf8'),
);
if (descriptor) {
descriptors.add(descriptor);
}
}
return Array.from(descriptors);
}
26 changes: 14 additions & 12 deletions packages/cli-config-android/src/config/findPackageClassName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export function getMainActivityFiles(

export default function getPackageClassName(folder: string) {
let files = getMainActivityFiles(folder);
let packages = getClassNameMatches(files, folder);
const packageClassName = getClassName(files, folder);

if (packages && packages.length > 0 && Array.isArray(packages[0])) {
return packages[0][1];
if (packageClassName) {
return packageClassName;
}

/*
Expand All @@ -55,17 +55,19 @@ export default function getPackageClassName(folder: string) {
}

files = getMainActivityFiles(folder, false);
packages = getClassNameMatches(files, folder);

// @ts-ignore
return packages.length ? packages[0][1] : null;
return getClassName(files, folder);
}

function getClassNameMatches(files: string[], folder: string) {
return files
.map((filePath) => fs.readFileSync(path.join(folder, filePath), 'utf8'))
.map(matchClassName)
.filter((match) => match);
function getClassName(files: string[], folder: string) {
for (const filePath of files) {
const match = matchClassName(
fs.readFileSync(path.join(folder, filePath), 'utf8'),
);
if (match) {
return match[1];
}
}
return null;
}

export function matchClassName(file: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default function getMainActivity(manifestPath: string): string | null {
});
});

return mainActivity ? mainActivity['@_android:name'] : null;
return mainActivity?.['@_android:name'] ?? null;
} else {
return null;
}
Expand Down
Loading