-
Notifications
You must be signed in to change notification settings - Fork 10k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Checkout a separate repo instead of the submodule
- Loading branch information
Showing
3 changed files
with
39 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,18 @@ | ||
$repoRoot = Resolve-Path -Path "$PSScriptRoot/../.."; | ||
|
||
# Update the .npmrc file to point to the cache location as a repo instead of a submodule | ||
$npmrcPath = Join-Path -Path $repoRoot -ChildPath ".npmrc" | ||
$content = Get-Content -Path $npmrcPath; | ||
$content = $content -replace "cache=./src/submodules/Node-Externals/cache", "cache=../Node-Externals/cache"; | ||
$content | Set-Content -Path $npmrcPath; | ||
|
||
Remove-Item -Path "package-lock.json" -Force -ErrorAction Stop | ||
npm install | ||
$diffResult = git diff-index HEAD -- ./package-lock.json | ||
if ($null -eq $diffResult) { | ||
# There are no changes so we don't need to do anything | ||
Write-Host "No changes detected in package-lock.json" | ||
} else { | ||
# There are changes so we need to perform the following actions: | ||
# Commit package-lock.json with the message "Update NPM dependencies". | ||
# Get the current commit hash of the repository. We'll call it $CurrentCommitHash | ||
# Navigate to src/submodules/Node-Externals (which is a submodule) that contains the npm-cache | ||
# Commit the changes to the submodule with the message. Update offline NPM Cache (Get-Date -Format "yyyy-MM-dd") $CurrentCommitHash | ||
# Go back to the root of the repository | ||
# Add the submodule changes to the commit | ||
# Commit the changes with the message "Update Node-Externals submodule" | ||
|
||
git add package-lock.json | ||
git commit -m "[Infrastructure] Update NPM dependencies" | ||
$CurrentCommitHash = (git rev-parse HEAD).Trim() | ||
Push-Location -Path (Join-Path $repoRoot -ChildPath "src/submodules/Node-Externals") | ||
git add . | ||
$commitMessage = @" | ||
[Infrastructure] Update offline NPM Cache $(Get-Date -Format "yyyy-MM-dd") | ||
https://github.com/dotnet/aspnetcore/commit/$CurrentCommitHash | ||
"@; | ||
git commit -m $commitMessage | ||
Pop-Location | ||
git add . | ||
git commit -m "[Infrastructure] Update Node-Externals submodule" | ||
|
||
# Notify the github workflow by setting the result output variable | ||
Write-Output "changes=true" >> $GITHUB_OUTPUT | ||
} | ||
|
||
# Undo the changes to the .npmrc file | ||
git checkout -- ./.npmrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Define a parameter to accept the commit sha | ||
param( | ||
[string]$CommitSha | ||
) | ||
|
||
# Fetch and checkout the commit sha in the submodule in src/submodules/Node-Externals | ||
Set-Location src/submodules/Node-Externals | ||
git fetch origin | ||
git checkout $CommitSha |