Blame view

泰额版/Food Labeling Management App UniApp/scripts/sync-native-fast-printer.ps1 2.71 KB
59e51671   “wangming”   1
1
2
3
4
5
6
7
8
  $ErrorActionPreference = "Stop"
  
  $appRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
  $repoRoot = Split-Path -Parent (Split-Path -Parent $appRoot)
  $dstPluginRoot = Join-Path $appRoot "nativeplugins\native-fast-printer"
  $manifestPath = Join-Path $appRoot "src\manifest.json"
  
  Write-Host "[1/4] Validate source plugin files..."
540ac0e3   杨鑫   前端修改bug
9
10
11
12
13
14
15
16
17
  $preferredAar = Join-Path $repoRoot "打印机安卓基座\native-fast-printer\android\native_fast_printer-release.aar"
  $sourceAarItem = $null
  if (Test-Path -LiteralPath $preferredAar) {
    $sourceAarItem = Get-Item -LiteralPath $preferredAar
  } else {
    $sourceAarItem = Get-ChildItem -LiteralPath (Join-Path $repoRoot "打印机安卓基座") -Recurse -File -Filter "native_fast_printer-release.aar" -ErrorAction SilentlyContinue |
      Sort-Object LastWriteTime -Descending |
      Select-Object -First 1
  }
59e51671   “wangming”   1
18
  if ($null -eq $sourceAarItem) {
540ac0e3   杨鑫   前端修改bug
19
    throw "AAR not found. Build first: 打印机安卓基座/native-fast-printer/android-src/build-aar-windows.bat"
59e51671   “wangming”   1
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  }
  
  $srcPluginRoot = Split-Path -Parent (Split-Path -Parent $sourceAarItem.FullName)
  $srcAar = $sourceAarItem.FullName
  Write-Host "Selected SRC AAR: $srcAar"
  $srcPkg = Join-Path $srcPluginRoot "package.json"
  $srcReadme = Join-Path $srcPluginRoot "README.md"
  if (!(Test-Path -LiteralPath $srcPkg)) { throw "package.json not found: $srcPkg" }
  if (!(Test-Path -LiteralPath $srcReadme)) { throw "README.md not found: $srcReadme" }
  
  Write-Host "[2/4] Sync files into uniapp nativeplugins..."
  if (Test-Path -LiteralPath $dstPluginRoot) {
    Remove-Item -LiteralPath $dstPluginRoot -Recurse -Force
  }
  New-Item -ItemType Directory -Path (Join-Path $dstPluginRoot "android") -Force | Out-Null
  Copy-Item -LiteralPath $srcPkg -Destination (Join-Path $dstPluginRoot "package.json")
  Copy-Item -LiteralPath $srcReadme -Destination (Join-Path $dstPluginRoot "README.md")
  Copy-Item -LiteralPath $srcAar -Destination (Join-Path $dstPluginRoot "android\native_fast_printer-release.aar")
  
  Write-Host "[3/4] Validate manifest plugin declaration..."
  if (!(Test-Path -LiteralPath $manifestPath)) { throw "manifest not found: $manifestPath" }
  $manifestContent = Get-Content -LiteralPath $manifestPath -Raw
  if ($manifestContent -notmatch '"native-fast-printer"\s*:\s*\{') {
    throw "manifest.json missing app-plus.nativePlugins.native-fast-printer declaration"
  }
  
  Write-Host "[4/4] Print summary..."
  $srcInfo = Get-Item -LiteralPath $srcAar
  $dstAar = Join-Path $dstPluginRoot "android\native_fast_printer-release.aar"
  $dstInfo = Get-Item -LiteralPath $dstAar
  Write-Host "SRC AAR: $($srcInfo.Length) bytes, $($srcInfo.LastWriteTime.ToString("s"))"
  Write-Host "DST AAR: $($dstInfo.Length) bytes, $($dstInfo.LastWriteTime.ToString("s"))"
  Write-Host "Done: native-fast-printer synced. Next: build custom base in HBuilderX."