chore: init repository with project sources
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
REM Wrapper to run export.ps1 with double-click or CLI
|
||||
set SCRIPT_DIR=%~dp0
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%export.ps1" %*
|
||||
set EXITCODE=%ERRORLEVEL%
|
||||
if %EXITCODE% NEQ 0 (
|
||||
echo Export failed. Exit code %EXITCODE%.
|
||||
exit /b %EXITCODE%
|
||||
)
|
||||
echo Archive created. Check the dist\ folder.
|
||||
endlocal
|
||||
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
Param(
|
||||
[switch]$Clean,
|
||||
[switch]$Minimal,
|
||||
[switch]$AsFolder,
|
||||
[switch]$Bundle,
|
||||
[int]$Chunk = 0,
|
||||
[string]$OutDir = "dist",
|
||||
[string]$Name = "multimediaFlutter-src"
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# Ensure output and temp directories
|
||||
if (-not (Test-Path $OutDir)) {
|
||||
New-Item -ItemType Directory -Path $OutDir | Out-Null
|
||||
}
|
||||
|
||||
$timestamp = Get-Date -Format 'yyyyMMdd-HHmm'
|
||||
$baseName = "$Name-$timestamp"
|
||||
$zipPath = Join-Path $OutDir ("$baseName.zip")
|
||||
$tempDir = Join-Path ([IO.Path]::GetTempPath()) ("mf_export_" + [Guid]::NewGuid().ToString('N'))
|
||||
if (-not (Test-Path $tempDir)) { New-Item -ItemType Directory -Path $tempDir -Force | Out-Null }
|
||||
$stageDir = Join-Path $tempDir 'stage'
|
||||
if (-not (Test-Path $stageDir)) { New-Item -ItemType Directory -Path $stageDir -Force | Out-Null }
|
||||
|
||||
try {
|
||||
if ($Clean) {
|
||||
try {
|
||||
Write-Host "Running 'flutter clean'..." -ForegroundColor Cyan
|
||||
flutter clean | Out-Null
|
||||
} catch {
|
||||
Write-Warning "'flutter clean' failed or Flutter not in PATH. Continuing."
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Staging files to temp folder..." -ForegroundColor Cyan
|
||||
if ($Minimal) {
|
||||
# Copy a minimal set for code review in ChatGPT
|
||||
$includeDirs = @('lib','test','assets')
|
||||
foreach ($dir in $includeDirs) {
|
||||
if (Test-Path $dir) {
|
||||
Copy-Item $dir -Destination (Join-Path $stageDir $dir) -Recurse -Force
|
||||
}
|
||||
}
|
||||
$rootFiles = @('pubspec.yaml','analysis_options.yaml','README.md')
|
||||
foreach ($f in $rootFiles) {
|
||||
if (Test-Path $f) { Copy-Item $f -Destination (Join-Path $stageDir $f) -Force }
|
||||
}
|
||||
if (Test-Path 'web') {
|
||||
New-Item -ItemType Directory -Force -Path (Join-Path $stageDir 'web') | Out-Null
|
||||
foreach ($wf in @('index.html','manifest.json')) {
|
||||
if (Test-Path (Join-Path 'web' $wf)) {
|
||||
Copy-Item (Join-Path 'web' $wf) -Destination (Join-Path $stageDir (Join-Path 'web' $wf)) -Force
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# Use robocopy to copy everything except heavy/generated folders
|
||||
$excludeDirs = @('build', '.dart_tool', 'ios\Pods', 'android\build', '.idea', '.vscode', 'web\build', 'android\.gradle', 'dist', 'tool', '.git', '.github')
|
||||
$xdArgs = @()
|
||||
foreach ($d in $excludeDirs) { $xdArgs += @('/XD', $d) }
|
||||
|
||||
# robocopy exit codes: treat 0-7 as success
|
||||
$robocopyCmd = @('robocopy', '.', $stageDir, '/E') + $xdArgs
|
||||
$p = Start-Process -FilePath $robocopyCmd[0] -ArgumentList $robocopyCmd[1..($robocopyCmd.Length-1)] -Wait -PassThru -NoNewWindow
|
||||
if ($p.ExitCode -gt 7) {
|
||||
throw "Robocopy failed with exit code $($p.ExitCode)"
|
||||
}
|
||||
}
|
||||
|
||||
# Option A: Single bundled text file (bypasses 10-file limit)
|
||||
if ($Bundle) {
|
||||
$bundlePath = Join-Path $OutDir ("$baseName-bundle.txt")
|
||||
if (Test-Path $bundlePath) { Remove-Item $bundlePath -Force }
|
||||
Write-Host "Creating bundled text: $bundlePath" -ForegroundColor Cyan
|
||||
$textExt = @('.dart','.yaml','.yml','.md','.json','.html','.htm','.css','.js','.xml','.gradle','.properties','.kt','.swift','.plist','.sh','.bat','.ps1','.txt','.php')
|
||||
$files = Get-ChildItem -Path $stageDir -Recurse -File | Where-Object { $textExt -contains ([IO.Path]::GetExtension($_.Name).ToLower()) }
|
||||
foreach ($f in $files) {
|
||||
$rel = $f.FullName.Substring($stageDir.Length + 1)
|
||||
"===== BEGIN FILE: $rel =====" | Out-File -FilePath $bundlePath -Append -Encoding utf8
|
||||
try { (Get-Content -Raw -Path $f.FullName) | Out-File -FilePath $bundlePath -Append -Encoding utf8 } catch { "[binary or unreadable content omitted]" | Out-File -FilePath $bundlePath -Append -Encoding utf8 }
|
||||
"\n===== END FILE =====\n" | Out-File -FilePath $bundlePath -Append -Encoding utf8
|
||||
}
|
||||
Write-Host "Done. Upload this single file to your ChatGPT Project:" -ForegroundColor Green
|
||||
Write-Host " $bundlePath"
|
||||
}
|
||||
elseif ($Chunk -gt 0) {
|
||||
# Option B: Chunk into folder packs of N files
|
||||
$outBase = Join-Path $OutDir $baseName
|
||||
if (Test-Path $outBase) { Remove-Item $outBase -Recurse -Force }
|
||||
New-Item -ItemType Directory -Path $outBase | Out-Null
|
||||
$allFiles = Get-ChildItem -Path $stageDir -Recurse -File
|
||||
if ($allFiles.Count -eq 0) { throw "No files found to export." }
|
||||
$pack = 1
|
||||
$inPack = 0
|
||||
$packDir = Join-Path $outBase ("pack-" + $pack.ToString('000'))
|
||||
New-Item -ItemType Directory -Path $packDir | Out-Null
|
||||
foreach ($file in $allFiles) {
|
||||
if ($inPack -ge $Chunk) {
|
||||
$pack++
|
||||
$inPack = 0
|
||||
$packDir = Join-Path $outBase ("pack-" + $pack.ToString('000'))
|
||||
New-Item -ItemType Directory -Path $packDir | Out-Null
|
||||
}
|
||||
$rel = $file.FullName.Substring($stageDir.Length + 1)
|
||||
$destPath = Join-Path $packDir $rel
|
||||
$destDir = Split-Path -Parent $destPath
|
||||
if (-not (Test-Path $destDir)) { New-Item -ItemType Directory -Path $destDir -Force | Out-Null }
|
||||
Copy-Item $file.FullName -Destination $destPath -Force
|
||||
$inPack++
|
||||
}
|
||||
Write-Host "Done. Upload each pack folder (<= $Chunk files) one by one:" -ForegroundColor Green
|
||||
Write-Host " $outBase"
|
||||
}
|
||||
elseif ($AsFolder) {
|
||||
$outFolder = Join-Path $OutDir $baseName
|
||||
if (Test-Path $outFolder) { Remove-Item $outFolder -Recurse -Force }
|
||||
Write-Host "Preparing folder for drag-and-drop: $outFolder" -ForegroundColor Cyan
|
||||
if (-not (Test-Path $outFolder)) { New-Item -ItemType Directory -Path $outFolder | Out-Null }
|
||||
Copy-Item (Join-Path $stageDir '*') -Destination $outFolder -Recurse -Force
|
||||
Write-Host "Done. Drag-and-drop this folder into your ChatGPT Project:" -ForegroundColor Green
|
||||
Write-Host " $outFolder"
|
||||
} else {
|
||||
Write-Host "Creating archive: $zipPath" -ForegroundColor Cyan
|
||||
if (Test-Path $zipPath) { Remove-Item $zipPath -Force }
|
||||
Compress-Archive -Path (Join-Path $stageDir '*') -DestinationPath $zipPath -Force
|
||||
Write-Host "Done. Upload this file to your ChatGPT Project:" -ForegroundColor Green
|
||||
Write-Host " $zipPath"
|
||||
}
|
||||
} finally {
|
||||
if (Test-Path $tempDir) { Remove-Item $tempDir -Recurse -Force }
|
||||
}
|
||||
Reference in New Issue
Block a user