Skip to content

Commit b759e24

Browse files
committed
add logging to determine failure
1 parent fb758c3 commit b759e24

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

tools/GenerateModules.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ Set-Location (Join-Path $ScriptRoot "../autorest.powershell")
5151
rush install
5252
rush build
5353

54+
# Diagnostic: show autorest cache state and npm registry config before generation.
55+
Write-Host "--- Autorest/npm diagnostics ---"
56+
$autorestHome = if ($env:AUTOREST_HOME) { $env:AUTOREST_HOME } else { Join-Path $env:USERPROFILE ".autorest" }
57+
Write-Host "AUTOREST_HOME: $autorestHome"
58+
$coreCacheDir = Join-Path $autorestHome "@autorest\core"
59+
if (Test-Path $coreCacheDir) {
60+
Write-Host "Autorest core cache versions: $(Get-ChildItem $coreCacheDir -Directory | Select-Object -ExpandProperty Name)"
61+
$nodeModulesDir = Join-Path $coreCacheDir "3.10.4\node_modules\@autorest\core"
62+
Write-Host "Cache 3.10.4 node_modules present: $(Test-Path $nodeModulesDir)"
63+
} else {
64+
Write-Host "WARNING: Autorest core cache directory not found at $coreCacheDir"
65+
}
66+
Write-Host "npm registry: $(npm config get registry 2>&1)"
67+
Write-Host "NPM_CONFIG_USERCONFIG: $env:NPM_CONFIG_USERCONFIG"
68+
$userNpmrc = Join-Path $env:USERPROFILE ".npmrc"
69+
Write-Host "~/.npmrc exists: $(Test-Path $userNpmrc)"
70+
Write-Host "--- End diagnostics ---"
71+
5472
$RequiredGraphModules = @()
5573
$AuthModuleManifest = Join-Path $ModulesSrc "Authentication" "Authentication" "artifacts" "Microsoft.Graph.Authentication.psd1"
5674
$LoadedAuthModule = Import-Module $AuthModuleManifest -PassThru -ErrorAction SilentlyContinue

tools/GenerateServiceModule.ps1

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,15 @@ $ApiVersion | ForEach-Object {
6969
else {
7070
$FullModuleVersion = $ModuleMetadata.versions[$CurrentApiVersion].version
7171
}
72-
npx autorest --max-memory-size=$MaxMemorySize --module-version:$FullModuleVersion --module-name:$ModuleFullName --service-name:$Module --input-file:$OpenApiFile $AutoRestModuleConfig --max-cpu=2 --network-calls=2
73-
if ($LastExitCode -ne 0) {
74-
Write-Host -ForegroundColor Red "AutoREST failed to generate '$ModuleFullName' module."
75-
return $LastExitCode
72+
$autorestLog = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), "autorest-$($ModuleFullName -replace '[^a-zA-Z0-9-]', '-').log")
73+
npx autorest --verbose --max-memory-size=$MaxMemorySize --module-version:$FullModuleVersion --module-name:$ModuleFullName --service-name:$Module --input-file:$OpenApiFile $AutoRestModuleConfig --max-cpu=2 --network-calls=2 2>&1 | Out-File -FilePath $autorestLog -Encoding utf8
74+
$autorestExitCode = $LASTEXITCODE
75+
if ($autorestExitCode -ne 0) {
76+
Write-Host -ForegroundColor Red "AutoREST failed (exit $autorestExitCode) generating '$ModuleFullName'."
77+
Write-Host -ForegroundColor Yellow "=== AutoREST log: $autorestLog ==="
78+
if (Test-Path $autorestLog) { Get-Content $autorestLog | ForEach-Object { Write-Host $_ } }
79+
Write-Host -ForegroundColor Yellow "=== End AutoREST log ==="
80+
return $autorestExitCode
7681
}
7782
Write-Debug "AutoRest generated '$ModuleFullName' successfully."
7883

0 commit comments

Comments
 (0)