初始提交:浩瑞(HaoRui)头条自动化工程
- app/:Kotlin 全部源码、AndroidManifest 与资源 - docs/:技术文档、UI 原型、回归清单 - img/:文档引用的对照规格截图 - scripts/:环境加载与回归统计脚本 - 构建配置:Gradle 入口脚本与属性 - 新增 .gitignore:排除工具链、构建缓存、临时产物与本机配置 Co-Authored-By: Claude Code <[email protected]>
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
# HaoRui - C-drive write checker
|
||||
# Usage: .\scripts\check-c-drive.ps1 [-Baseline]
|
||||
# Note: written in UTF-8 with BOM so PowerShell 5.1 parses Chinese correctly.
|
||||
|
||||
param([switch]$Baseline)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
$snapPath = Join-Path $root '.tmp\c-drive-snapshot.txt'
|
||||
|
||||
# Hotspot dirs under C that our build might touch
|
||||
$hotspots = @(
|
||||
"$env:USERPROFILE\.gradle",
|
||||
"$env:USERPROFILE\.android",
|
||||
"$env:USERPROFILE\.m2",
|
||||
"$env:USERPROFILE\.npm",
|
||||
"$env:LOCALAPPDATA\Android",
|
||||
"$env:LOCALAPPDATA\Temp",
|
||||
"$env:TEMP"
|
||||
)
|
||||
|
||||
function Get-Snapshot {
|
||||
$rows = @()
|
||||
foreach ($h in $hotspots) {
|
||||
if (-not (Test-Path $h)) { $rows += "$h|0|0|-"; continue }
|
||||
$files = Get-ChildItem -Path $h -Recurse -File -ErrorAction SilentlyContinue
|
||||
$count = ($files | Measure-Object).Count
|
||||
$sum = ($files | Measure-Object -Property Length -Sum).Sum
|
||||
if ($null -eq $sum) { $sum = 0 }
|
||||
$newest = ($files | Sort-Object LastWriteTime -Descending | Select-Object -First 1)
|
||||
$ts = if ($newest) { $newest.LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss') } else { '-' }
|
||||
$rows += "$h|$count|$sum|$ts"
|
||||
}
|
||||
return $rows
|
||||
}
|
||||
|
||||
$snap = Get-Snapshot
|
||||
|
||||
if ($Baseline) {
|
||||
$snap | Set-Content -Path $snapPath -Encoding utf8
|
||||
Write-Host "[BASELINE SAVED] $snapPath" -ForegroundColor Green
|
||||
foreach ($r in $snap) { Write-Host " $r" }
|
||||
exit 0
|
||||
}
|
||||
|
||||
if (-not (Test-Path $snapPath)) {
|
||||
Write-Host "[MISSING BASELINE] run: .\scripts\check-c-drive.ps1 -Baseline" -ForegroundColor Yellow
|
||||
Write-Host "Current hotspots:" -ForegroundColor Cyan
|
||||
foreach ($r in $snap) { Write-Host " $r" }
|
||||
exit 1
|
||||
}
|
||||
|
||||
$base = Get-Content $snapPath -Encoding utf8
|
||||
Write-Host "---- C-drive write check ----" -ForegroundColor Cyan
|
||||
Write-Host ("{0,-34} {1,10} {2,14} {3,20} {4}" -f 'dir', 'files', 'bytes', 'newest', 'status')
|
||||
Write-Host ("-" * 92)
|
||||
|
||||
$violations = 0
|
||||
for ($i = 0; $i -lt $snap.Count; $i++) {
|
||||
$b = $base[$i].Split('|')
|
||||
$n = $snap[$i].Split('|')
|
||||
$changed = ($b[1] -ne $n[1]) -or ($b[2] -ne $n[2])
|
||||
if ($changed) { $violations++ }
|
||||
$mark = if ($changed) { '[CHANGED]' } else { '[OK]' }
|
||||
$leaf = Split-Path $n[0] -Leaf
|
||||
Write-Host ("{0,-34} {1,10} {2,14} {3,20} {4}" -f $leaf, $n[1], $n[2], $n[3], $mark)
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
if ($violations -eq 0) {
|
||||
Write-Host "[PASS] C-drive zero write" -ForegroundColor Green
|
||||
exit 0
|
||||
} else {
|
||||
Write-Host "[WARN] $violations hotspot dir(s) changed" -ForegroundColor Yellow
|
||||
Write-Host " If caused by build, verify env.ps1 was loaded first." -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
# 浩瑞(HaoRui)· C 盘零占用环境加载
|
||||
# 用法: . .\scripts\env.ps1 # 点号调用,环境变量注入当前会话
|
||||
# 之后所有 gradle / java / adb 命令都继承这些隔离路径
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# ── 工程根(本脚本位于 scripts\ 下)──────────────────────────
|
||||
$root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
|
||||
# ── 全部落在 D:\headlineScript 内 ─────────────────────────────
|
||||
$toolchain = Join-Path $root '.toolchain'
|
||||
$gradleHome = Join-Path $toolchain 'gradle-home'
|
||||
$androidSdk = Join-Path $toolchain 'android-sdk'
|
||||
$tmpDir = Join-Path $root '.tmp'
|
||||
|
||||
foreach ($p in @($gradleHome, $androidSdk, $tmpDir, (Join-Path $toolchain '.android'))) {
|
||||
if (-not (Test-Path $p)) { New-Item -ItemType Directory -Force -Path $p | Out-Null }
|
||||
}
|
||||
|
||||
# ── JDK:复用本机既有安装(只读,不新增 C 盘占用)────────────
|
||||
# 如需彻底无 C 盘依赖,把 JDK 复制到 .toolchain\jdk-21 并改下行
|
||||
$javaHome = Join-Path $toolchain 'jdk-21'
|
||||
if (-not (Test-Path $javaHome)) {
|
||||
$javaHome = 'C:\Program Files\Java\jdk-21' # 兜底:本机既有 JDK
|
||||
}
|
||||
|
||||
# ── 注入环境变量:全部指向工程目录 ───────────────────────────
|
||||
$env:GRADLE_USER_HOME = $gradleHome
|
||||
# 注意:不要在这里设 -Duser.home,否则 AGP 会用 user.home/.android 再派生一条路径,
|
||||
# 与 ANDROID_USER_HOME 冲突(AndroidLocationsException)
|
||||
# 关键:让 JVM user.home 与 ANDROID_USER_HOME 收敛到同一目录。
|
||||
# AGP 的 AndroidLocations 会同时读取 user.home/.android 与 ANDROID_USER_HOME,
|
||||
# 两者不一致时抛 AndroidLocationsException;一致时才相安无事,且 analytics 落 D 盘。
|
||||
$env:GRADLE_OPTS = "-Dorg.gradle.daemon=false -Djava.io.tmpdir=$tmpDir -Duser.home=$toolchain"
|
||||
$env:ANDROID_SDK_ROOT = $androidSdk
|
||||
$env:ANDROID_HOME = $androidSdk
|
||||
# Android 偏好目录(~/.android,含 analytics.settings / debug.keystore)
|
||||
# 只能设一个规范变量:AGP 若发现多个变量指向不同路径会抛
|
||||
# AndroidLocationsException: Several environment variables ... contain different paths
|
||||
# 因此只设 ANDROID_USER_HOME,不要同时设 ANDROID_SDK_HOME / ANDROID_EMULATOR_HOME / ANDROID_AVD_HOME
|
||||
# 必须等于 user.home/.android 的解析结果(user.home=$toolchain)→ .toolchain\.android
|
||||
$androidUser = Join-Path $toolchain '.android'
|
||||
$env:ANDROID_USER_HOME = $androidUser
|
||||
# 关闭 Android SDK 匿名分析
|
||||
$env:ANDROID_SDK_DISABLE_ANALYTICS = '1'
|
||||
$env:JAVA_HOME = $javaHome
|
||||
$env:TMP = $tmpDir
|
||||
$env:TEMP = $tmpDir
|
||||
$env:_JAVA_OPTIONS = "-Djava.io.tmpdir=$tmpDir"
|
||||
|
||||
# ── npm / pip 等其它包管理器(如后续引入)────────────────────
|
||||
$env:npm_config_cache = Join-Path $toolchain 'npm-cache'
|
||||
$env:npm_config_prefix = Join-Path $toolchain 'npm-global'
|
||||
$env:PIP_CACHE_DIR = Join-Path $toolchain 'pip-cache'
|
||||
|
||||
Write-Host "── C 盘隔离环境已加载 ─────────────────────────" -ForegroundColor Cyan
|
||||
Write-Host "工程根 : $root"
|
||||
Write-Host "GRADLE_USER_HOME: $env:GRADLE_USER_HOME"
|
||||
Write-Host "ANDROID_SDK_ROOT: $env:ANDROID_SDK_ROOT"
|
||||
Write-Host "JAVA_HOME : $env:JAVA_HOME"
|
||||
Write-Host "TEMP / TMP : $env:TEMP"
|
||||
Write-Host "──────────────────────────────────────────────" -ForegroundColor Cyan
|
||||
@@ -0,0 +1,28 @@
|
||||
# 浩瑞回归统计(回归清单 §五 判据)
|
||||
# 用法:powershell -File scripts\regress-stats.ps1 <regression.txt>
|
||||
param([string]$LogPath = ".tmp\regression.txt")
|
||||
$L = Get-Content $LogPath
|
||||
"═══ 硬门禁 ═══"
|
||||
"1 采集相位循环 : " + ($L | Select-String -Pattern "相位 SHARE -> CLIPBOARD").Count
|
||||
"2 取到链接 : " + ($L | Select-String -Pattern "CLIPBOARD\] 取到链接").Count
|
||||
"3 解析成功 : " + ($L | Select-String -Pattern "Resolver: 解析成功").Count
|
||||
"4 VOD 主路径 : " + ($L | Select-String -Pattern "发现 GetPlayInfoToken").Count
|
||||
"5 下载完成 : " + ($L | Select-String -Pattern "Download: 下载完成").Count
|
||||
"6 下载不完整 : " + ($L | Select-String -Pattern "下载不完整").Count + " / 非MP4: " + ($L | Select-String -Pattern "下载内容非 MP4").Count
|
||||
"7 发布完成 : " + ($L | Select-String -Pattern "\[DONE\] 发布成功").Count
|
||||
"8 发布失败 : " + ($L | Select-String -Pattern "发布失败").Count + " / 回执: " + ($L | Select-String -Pattern "收到「.*」回执").Count
|
||||
"9 去重拦截 : " + ($L | Select-String -Pattern "跳过重复视频").Count
|
||||
"10 让路 : " + ($L | Select-String -Pattern "让路").Count
|
||||
"═══ 软门禁 ═══"
|
||||
"S4 step 异常 : " + ($L | Select-String -Pattern "step 异常").Count
|
||||
"S5 step 跳过 : " + ($L | Select-String -Pattern "step 跳过").Count
|
||||
"S6 放弃/超限 : " + ($L | Select-String -Pattern "放弃").Count
|
||||
"═══ 新增判据(本轮) ═══"
|
||||
"草稿回执 : " + ($L | Select-String -Pattern "收到「存草稿」回执|草稿模式").Count
|
||||
"发布模式 : " + ($L | Select-String -Pattern "发布模式切换").Count
|
||||
"门控放行 : " + ($L | Select-String -Pattern "门槛 60 → 放行|→ 放行").Count
|
||||
"互动相位 : " + ($L | Select-String -Pattern "HaoRui-Interact").Count
|
||||
"孤儿回收 : " + ($L | Select-String -Pattern "孤儿素材回收").Count
|
||||
"═══ 心跳/自愈 ═══"
|
||||
"自愈监控 : " + ($L | Select-String -Pattern "自愈监控 #").Count
|
||||
"心跳(如适用): " + ($L | Select-String -Pattern "心跳").Count
|
||||
Reference in New Issue
Block a user