@@ -41,7 +41,11 @@ param (
4141
4242 [Parameter (Mandatory = $false )]
4343 [string ]
44- $OutDir = " vendor"
44+ $OutDir = " vendor" ,
45+
46+ [Parameter (Mandatory = $false )]
47+ [switch ]
48+ $Symlink = $false
4549)
4650
4751function Get-ConfigConverter {
@@ -220,6 +224,11 @@ function Update-GenlinxRc {
220224
221225 $genlinxrc = Get-Content - Path $Path - Raw | & $convertFrom
222226
227+ # Ensure `.` is replaced with `-` in the owner and repo names, and version
228+ $DependencyOwner = $DependencyOwner.Replace (" ." , " -" )
229+ $DependencyUrl = $DependencyUrl.Replace (" ." , " -" )
230+ $DependencyVersion = $DependencyVersion.Replace (" ." , " -" )
231+
223232 $genlinxrc.build.nlrc.includePath += " ./$OutDir /$DependencyOwner /$DependencyUrl /$DependencyVersion "
224233 $genlinxrc.build.nlrc.modulePath += " ./$OutDir /$DependencyOwner /$DependencyUrl /$DependencyVersion "
225234
@@ -400,6 +409,46 @@ function Read-EnvFile {
400409 Write-Host " Loaded environment variables from .env file"
401410}
402411
412+ function Add-Symlinks {
413+ param (
414+ [string ]$Path ,
415+ [string ]$Extension ,
416+ [string ]$TargetDirectory ,
417+ [switch ]$GitIgnore = $false
418+ )
419+
420+ $files = Get-ChildItem - Path $Path - Recurse - Filter " *.$Extension " - ErrorAction SilentlyContinue
421+
422+ if (! $files ) {
423+ return
424+ }
425+
426+ Write-Host " Symlinking .$Extension files..."
427+
428+ if (-not (Test-Path $TargetDirectory )) {
429+ New-Item - ItemType Directory - Path $TargetDirectory | Out-Null
430+ }
431+
432+ foreach ($file in $files ) {
433+ $symlinkPath = Join-Path $TargetDirectory $file.Name
434+ New-Item - ItemType SymbolicLink - Path $symlinkPath - Target $file.FullName - Force | Out-Null
435+
436+ if (! $GitIgnore ) {
437+ continue
438+ }
439+
440+ # Update .gitignore file with relative path to symlink
441+ $gitignoreFile = " $PSScriptRoot /.gitignore"
442+ $ignorePath = " $ ( Split-Path - Path $TargetDirectory - Leaf) /$ ( $file.Name ) "
443+
444+ if (Select-String - Path $gitignoreFile - Pattern $ignorePath - Quiet) {
445+ continue
446+ }
447+
448+ Add-Content - Path $gitignoreFile - Value $ignorePath
449+ }
450+ }
451+
403452try {
404453 $Path = Resolve-Path - Path $Path
405454
@@ -410,10 +459,21 @@ try {
410459 exit 1
411460 }
412461
462+ if ($env: CI ) {
463+ Write-Host " Running in CI environment"
464+ } else {
465+ Write-Host " Running in local environment"
466+ }
467+
413468 # Look for a .env file in the same directory.
414469 # If it exists, load the environment variables from it
415470 Read-EnvFile
416471
472+ if (! $env: GITHUB_TOKEN ) {
473+ Write-Host " GITHUB_TOKEN environment variable not set"
474+ Write-Host " GitHub API rate limits may apply"
475+ }
476+
417477 $vendorPath = Join-Path $PSScriptRoot $OutDir
418478
419479 $genlinxrc = Find-GenlinxRc - Path $Path
@@ -443,7 +503,7 @@ try {
443503
444504 $version = Get-Version - Version $dependency.version
445505
446- $packagePath = Join-Path $vendorPath " $ ( $repoInfo.Owner ) /$ ( $repoInfo.Repo ) /$ ( $version ) "
506+ $packagePath = Join-Path $vendorPath " $ ( $repoInfo.Owner.Replace ( " . " , " - " ) ) /$ ( $repoInfo.Repo.Replace ( " . " , " - " ) ) /$ ( $version.Replace ( " . " , " - " ) ) "
447507 if (-not (Test-Path $packagePath )) {
448508 New-Item - ItemType Directory - Path $packagePath | Out-Null
449509 }
@@ -458,18 +518,31 @@ try {
458518 - version $version `
459519 - destinationPath $packagePath
460520
461- Write-Host " Successfully installed $ ( $repoInfo.Repo ) @$ ( $version ) "
521+ if (! $Symlink ) {
522+ # NLRC doesn't seem to like lots of paths in the includePath and modulePaths
523+ # Unsure of the exact number. It works upto a point and then fails.
524+ # If adding a lot of paths, it's better to symlink the files in the package instead
525+ if (! $genlinxrc ) {
526+ continue
527+ }
462528
463- if (! $genlinxrc ) {
464- continue
529+ Update-Genlinxrc `
530+ - Path $genlinxrc `
531+ - OutDir $OutDir `
532+ - DependencyOwner $repoInfo.Owner `
533+ - DependencyUrl $repoInfo.Repo `
534+ - DependencyVersion $version
535+ } else {
536+ # This will allow the NLRC to find the files without having to add them to the .genlinxrc file
537+ # This is a workaround until we can figure out how to add the paths to the .genlinxrc file
538+ Add-Symlinks - Path $packagePath - Extension " axi" - TargetDirectory " $Path /lib" - GitIgnore
539+
540+ # tko, jar files are already ignored by Git
541+ Add-Symlinks - Path $packagePath - Extension " tko" - TargetDirectory " $Path /src"
542+ Add-Symlinks - Path $packagePath - Extension " jar" - TargetDirectory " $Path /src"
465543 }
466544
467- Update-Genlinxrc `
468- - Path $genlinxrc `
469- - OutDir $OutDir `
470- - DependencyOwner $repoInfo.Owner `
471- - DependencyUrl $repoInfo.Repo `
472- - DependencyVersion $version
545+ Write-Host " Successfully installed $ ( $repoInfo.Repo ) @$ ( $version ) "
473546 }
474547 catch {
475548 Write-Error " Failed to process dependency $ ( $dependency.url ) : $_ "
0 commit comments