对齐桌面壳生成目录扫描边界
排除 Tauri gen 目录进入桌面壳生产源码扫描 排除 Tauri autogenerated 权限目录进入替身词扫描 保留生成权限漂移和未跟踪文件门禁
This commit is contained in:
@@ -220,6 +220,10 @@ const productionFileExtensions = new Set(['.json', '.mjs', '.plist', '.rs', '.to
|
||||
const productionSourceExcludedDirectories = new Set([
|
||||
'target',
|
||||
]);
|
||||
const productionSourceExcludedRelativePaths = new Set([
|
||||
'src-tauri/gen',
|
||||
'src-tauri/permissions/autogenerated',
|
||||
]);
|
||||
const devScaffoldTerms = [
|
||||
'mo' + 'ck',
|
||||
'fa' + 'ke',
|
||||
@@ -590,6 +594,11 @@ function assertCargoLockDirectDependency(
|
||||
function collectProductionSourceFiles(entry) {
|
||||
const stats = fs.statSync(entry);
|
||||
if (stats.isDirectory()) {
|
||||
const relativePath = pathRelativeToDesktopShell(entry);
|
||||
if (productionSourceExcludedRelativePaths.has(relativePath)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const directory = entry.href.endsWith('/') ? entry : new URL(`${entry.href}/`);
|
||||
return fs
|
||||
.readdirSync(entry, { withFileTypes: true })
|
||||
@@ -616,6 +625,18 @@ function collectProductionSourceFiles(entry) {
|
||||
return [entry];
|
||||
}
|
||||
|
||||
function pathRelativeToDesktopShell(entry) {
|
||||
const desktopShellRoot = new URL('../', import.meta.url);
|
||||
return pathRelative(desktopShellRoot.pathname, entry.pathname);
|
||||
}
|
||||
|
||||
function pathRelative(fromPath, toPath) {
|
||||
return toPath
|
||||
.slice(fromPath.length)
|
||||
.replace(/^\/+/, '')
|
||||
.replace(/\/$/, '');
|
||||
}
|
||||
|
||||
const productionSourceFiles = productionSourceRoots.flatMap((root) =>
|
||||
collectProductionSourceFiles(root),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user