desense.ps1 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. $ErrorActionPreference = 'Stop'
  2. $root = Split-Path -Parent $PSScriptRoot
  3. function Desense-Text([string]$c) {
  4. $n = $c
  5. $n = $n -replace 'Msq2025uqisad', 'TARGET_PARSE_MASTER_KEY'
  6. $n = $n -replace 'msq!post666', 'TARGET_DB_PASSWORD'
  7. $n = $n -replace 'https://server-msq\.fmode\.cn', 'https://TARGET_HOST'
  8. $n = $n -replace 'server-msq\.fmode\.cn', 'TARGET_HOST'
  9. $n = $n -replace "appId: 'msq-voc'", "appId: 'TARGET_PARSE_APP_ID'"
  10. $n = $n -replace 'appId msq-voc', 'appId TARGET_PARSE_APP_ID'
  11. $n = $n -replace "'msq-voc'", "'TARGET_PARSE_APP_ID'"
  12. $n = $n -replace '"msq-voc"', '"TARGET_PARSE_APP_ID"'
  13. $n = $n -replace 'BasicAuth [A-Za-z0-9+/=]+', 'BasicAuth TARGET_SORFTIME_TOKEN'
  14. $n = $n -replace 'Bearer [rt][A-Za-z0-9+/=]+', 'Bearer TARGET_TOKEN'
  15. return $n
  16. }
  17. function Desense-File([string]$path) {
  18. if (-not (Test-Path -LiteralPath $path)) {
  19. Write-Output "MISS $path"
  20. return
  21. }
  22. $c = Get-Content -Raw -LiteralPath $path
  23. $n = Desense-Text $c
  24. if ($n -ne $c) {
  25. Set-Content -LiteralPath $path -Value $n -NoNewline
  26. Write-Output ("UPDATED " + $path.Substring($root.Length + 1))
  27. }
  28. }
  29. $files = @(
  30. 'backend\modules\fmode-amazon-sp-api\src\parse-init.ts',
  31. 'backend\modules\fmode-eccang-api\src\parse-init.ts',
  32. 'backend\modules\fmode-sorftime-api\src\parse-init.ts',
  33. 'backend\modules\fmode-amazon-sp-api\src\dev-server.ts',
  34. 'backend\cloud\main.js',
  35. 'frontend\README.md',
  36. 'frontend\scripts\hongben\config.ts',
  37. 'frontend\scripts\hongben\README.md',
  38. 'frontend\scripts\backfill-amazon-product-fields.js',
  39. 'frontend\scripts\backfill-productdetail-owner-fields.js',
  40. 'frontend\scripts\cleanup-empty-user-emails.js',
  41. 'frontend\scripts\created-data.js',
  42. 'frontend\scripts\import-excel-categories.js',
  43. 'frontend\scripts\ingest-amazon-listings-for-shop.js',
  44. 'frontend\scripts\mark-admin-user.js',
  45. 'frontend\scripts\refresh-own-product-reviews.js',
  46. 'frontend\scripts\smoke-amazon-shop.js',
  47. 'frontend\scripts\test-single-api.js',
  48. 'frontend\scripts\test-sorftime-api.js',
  49. 'frontend\scripts\update-shop-spapi-credentials.js',
  50. 'frontend\scripts\audit-amazon-product.js',
  51. 'frontend\scripts\voc-create-schema.js',
  52. 'frontend\scripts\check-cert.js'
  53. )
  54. foreach ($rel in $files) {
  55. Desense-File (Join-Path $root $rel)
  56. }
  57. $dirs = @(
  58. (Join-Path $root 'backend\docs'),
  59. (Join-Path $root 'backend\modules'),
  60. (Join-Path $root 'frontend\docs'),
  61. (Join-Path $root 'frontend\scripts')
  62. )
  63. foreach ($dir in $dirs) {
  64. if (-not (Test-Path $dir)) { continue }
  65. Get-ChildItem -Path $dir -Recurse -File -Include *.md,*.ts,*.js,*.json -ErrorAction SilentlyContinue | ForEach-Object {
  66. Desense-File $_.FullName
  67. }
  68. }
  69. Write-Output 'DESENSE_DONE'