Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PD-1755 / 3.0 / Pd 1755 move cleanup script and run 3.0 #3529

Open
wants to merge 2 commits into
base: 3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions scripts/cleanup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Define relative paths
$docRoot = "$PSScriptRoot\.."
$targetFolders = @("$docRoot\static\includes", "$docRoot\static\images")
$contentDir = "$docRoot\content"
$includesDir = "$docRoot\static\includes"
$layoutsDir = "$docRoot\layouts"
$dataPropertiesDir = "$docRoot\data\properties"
$configFile = "$docRoot\config.toml"

# Initialize counters
$totalFiles = 0
$reviewedFiles = 0
$deletedFilesCount = 0
$deletedFiles = @()

# Get the current date and time
$dateTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss"

# Get the user who initiated the process
$userName = (Get-ItemProperty "HKCU:\\Software\\Microsoft\\Office\\Common\\UserInfo\\").UserName

# Process started indicator
Write-Output "Process started... Reviewing snippets and image files."

foreach ($targetFolder in $targetFolders) {
# Get all files in the target folder and its subdirectories
$files = Get-ChildItem -Path $targetFolder -Recurse -File
$totalFiles += $files.Count

foreach ($file in $files) {
$reviewedFiles++
$filename = $file.Name
$foundInContent = Get-ChildItem -Path $contentDir -Recurse -File | Select-String -Pattern "\b$filename\b"
$foundInIncludes = Get-ChildItem -Path $includesDir -Recurse -File | Select-String -Pattern "\b$filename\b"
$foundInLayouts = Get-ChildItem -Path $layoutsDir -Recurse -File | Select-String -Pattern "\b$filename\b"
$foundInDataProperties = Get-ChildItem -Path $dataPropertiesDir -Recurse -File | Select-String -Pattern "\b$filename\b"
$foundInConfig = Get-Content $configFile | Select-String -Pattern "\b$filename\b"

# If the file is not found in any of these locations, delete it
if (-not $foundInContent -and -not $foundInIncludes -and -not $foundInLayouts -and -not $foundInDataProperties -and -not $foundInConfig) {
Remove-Item $file.FullName
# Log the deletion
$deletedFiles += $file.FullName
$deletedFilesCount++
}

# Update progress
Write-Progress -Activity "Reviewing files in $targetFolder" -Status "$reviewedFiles of $totalFiles reviewed" -PercentComplete (($reviewedFiles / $totalFiles) * 100)
}

# Indicate completion for the current folder
Write-Progress -Activity "Reviewing files in $targetFolder" -Status "Done" -PercentComplete 100
Write-Output "Done processing $targetFolder"
}

# Prepare log content
$logFilePath = "$PSScriptRoot\cleanup_log.txt"
$logContent = @()
$logContent += "Process time: $dateTime"
$logContent += "Initiated by: $userName"
$logContent += ""
$logContent += "$reviewedFiles files reviewed."
$logContent += "$deletedFilesCount files deleted."

if ($deletedFilesCount -gt 0) {
$logContent += "The following files were deleted:"
$logContent += $deletedFiles
} else {
$logContent += "All files currently in use."
}

$logContent += ""
$logContent += "-" * 40 # Horizontal divider line

# Append log content to the beginning of the file
if (Test-Path $logFilePath) {
$existingContent = Get-Content $logFilePath
$logContent + $existingContent | Set-Content $logFilePath
} else {
$logContent | Set-Content $logFilePath
}

# Output final status
Write-Output "$reviewedFiles files reviewed."
Write-Output "$deletedFilesCount files deleted."
Write-Output "Log file updated: $logFilePath"
1,449 changes: 1,449 additions & 0 deletions scripts/cleanup_log.txt

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed static/images/SAML/GAClickAddApp.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed static/images/SAML/GASelectWebandMobileApps.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed static/images/TrueCommand/Clusters/ClusterCard.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed static/images/TrueCommand/Dashboard/NASUser5.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed static/images/TrueNAS_Open_Enterprise_Storage.png
Diff not rendered.
Binary file removed static/images/tn-enterprise-logo.png
Diff not rendered.
Diff not rendered.
5 changes: 0 additions & 5 deletions static/includes/ClusterDeprecated.md

This file was deleted.

32 changes: 0 additions & 32 deletions static/includes/ClusterTypes.md

This file was deleted.

57 changes: 0 additions & 57 deletions static/includes/General/LifecycleTable.html.part

This file was deleted.

2 changes: 0 additions & 2 deletions static/includes/General/MenuNav.md.part

This file was deleted.

55 changes: 0 additions & 55 deletions static/includes/General/TNQualityLifecycle.html.part

This file was deleted.

12 changes: 0 additions & 12 deletions static/includes/TC3.0ClusterCompatWarning.md

This file was deleted.