收紧移动壳生产源码扫描边界
排除移动壳本地依赖目录进入生产源码扫描 排除移动壳测试工具目录进入生产源码扫描 反查根级 native shells 门禁保持同一排除口径
This commit is contained in:
@@ -332,6 +332,10 @@ const requiredMobileShellScriptModules = [
|
||||
'check-expo-config.mjs',
|
||||
'check-expo-export.mjs',
|
||||
];
|
||||
const productionSourceExcludedDirectories = new Set([
|
||||
'node_modules',
|
||||
'test-utils',
|
||||
]);
|
||||
const devScaffoldTerms = [
|
||||
'mo' + 'ck',
|
||||
'fa' + 'ke',
|
||||
@@ -649,6 +653,11 @@ function collectProductionSourceFiles(entry) {
|
||||
const directory = entry.href.endsWith('/') ? entry : new URL(`${entry.href}/`);
|
||||
return fs
|
||||
.readdirSync(entry, { withFileTypes: true })
|
||||
.filter(
|
||||
(child) =>
|
||||
!child.isDirectory() ||
|
||||
!productionSourceExcludedDirectories.has(child.name),
|
||||
)
|
||||
.flatMap((child) =>
|
||||
collectProductionSourceFiles(
|
||||
new URL(`${child.name}${child.isDirectory() ? '/' : ''}`, directory),
|
||||
@@ -806,6 +815,14 @@ for (const snippet of [
|
||||
}
|
||||
}
|
||||
|
||||
for (const excludedDirectory of productionSourceExcludedDirectories) {
|
||||
if (!nativeShellCheckSource.includes(`'${excludedDirectory}'`)) {
|
||||
throw new Error(
|
||||
`root native shell check is missing mobile source exclusion: ${excludedDirectory}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
assertNoDevScaffoldTerms(
|
||||
productionSourceRoots.flatMap((root) => collectProductionSourceFiles(root)),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user