-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
COMPSGH-200: add and remove scripts for debugging purposes (#146)
Co-authored-by: Sandeep Kumar <[email protected]>
- Loading branch information
1 parent
011158c
commit 71397f9
Showing
5 changed files
with
97 additions
and
11 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 |
---|---|---|
|
@@ -20,3 +20,4 @@ ComposGHConverter/bin | |
/ConverterTests/obj | ||
*.log | ||
/ComposGH.sln.DotSettings.user | ||
.idea |
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,81 @@ | ||
|
||
function Has-Version { | ||
param ($version) | ||
|
||
# Check if the version argument is provided | ||
if ($version.Count -eq 0) { | ||
Write-Host "Please provide the version number as an argument. Usage: .\bump-version.ps1 <new-version>" | ||
exit | ||
} | ||
|
||
# Get the new version from the CLI argument | ||
return $version[0] | ||
} | ||
|
||
$newVersion = Has-Version($args) | ||
|
||
# Function to validate the version format (X.X.X where X is a number) | ||
function Validate-VersionFormat { | ||
param ( | ||
[string]$version | ||
) | ||
|
||
# Regex pattern for validating version format (X.X.X-beta) | ||
$versionPattern = '^\d+\.\d+\.\d+$' | ||
|
||
# Check if version matches the pattern | ||
return $version -match $versionPattern | ||
} | ||
|
||
# Function to update version in a file | ||
function Update-Version { | ||
param ( | ||
[string]$filePath, | ||
[string]$searchPattern, | ||
[string]$newVersion, | ||
[string]$replacementPattern | ||
) | ||
|
||
# Read the content of the file | ||
$content = Get-Content $filePath | ||
|
||
# Replace the version based on the provided pattern and replacement | ||
$updatedContent = $content -replace $searchPattern, $replacementPattern | ||
|
||
# Write the updated content back to the file | ||
Set-Content $filePath -Value $updatedContent | ||
|
||
Write-Host "Updated version in $filePath to $newVersion" | ||
} | ||
|
||
# Check if the version format is valid | ||
if (-not (Validate-VersionFormat $newVersion)) { | ||
Write-Host "Invalid version format. Please use the format: X.X.X where X is a number." | ||
exit | ||
} | ||
|
||
# Define the paths and patterns for each file | ||
$filesToUpdate = @( | ||
@{ | ||
FilePath = ".\ComposGH\ComposGH.csproj" | ||
SearchPattern = '<Version>(.*?)<\/Version>' | ||
ReplacementPattern = "<Version>$newVersion-beta</Version>" | ||
}, | ||
@{ | ||
FilePath = ".\Compos\ComposAPI.csproj" | ||
SearchPattern = '<Version>(.*?)<\/Version>' | ||
ReplacementPattern = "<Version>$newVersion-beta</Version>" | ||
}, | ||
@{ | ||
FilePath = ".\ComposGH\ComposGHInfo.cs" | ||
SearchPattern = 'string GrasshopperVersion = "(.*?)"' | ||
ReplacementPattern = 'string GrasshopperVersion = "' + $newVersion + '-beta"' | ||
} | ||
) | ||
|
||
# Loop through each file and update the version | ||
foreach ($file in $filesToUpdate) { | ||
Update-Version -filePath $file.FilePath -searchPattern $file.SearchPattern -newVersion $newVersion -replacementPattern $file.ReplacementPattern | ||
} | ||
|
||
Write-Host "Version update completed." |
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,6 @@ | ||
$relevantPath = "ComposGH\bin\x64\Debug\net48" | ||
$absolutePath = Resolve-Path $relevantPath | ||
|
||
$destinationDir = "$env:APPDATA\Grasshopper\Libraries" | ||
|
||
echo $absolutePath > "$destinationDir\ComposGhTests.ghlink" |
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,6 @@ | ||
$relevantPath = "ComposGH\bin\x64\Debug\net48" | ||
$absolutePath = Resolve-Path $relevantPath | ||
|
||
$destinationDir = "$env:APPDATA\Grasshopper\Libraries" | ||
|
||
rm "$destinationDir\ComposGhTests.ghlink" |