Skip to content

Commit

Permalink
COMPSGH-200: add and remove scripts for debugging purposes (#146)
Browse files Browse the repository at this point in the history
Co-authored-by: Sandeep Kumar <[email protected]>
  • Loading branch information
psarras and SandeepArup authored Dec 16, 2024
1 parent 011158c commit 71397f9
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ ComposGHConverter/bin
/ConverterTests/obj
*.log
/ComposGH.sln.DotSettings.user
.idea
81 changes: 81 additions & 0 deletions BumpVersion.ps1
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."
14 changes: 3 additions & 11 deletions ComposGH/ComposGHInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,13 @@ public class ComposGHInfo : GH_AssemblyInfo {
public override Bitmap Icon => null;
public override Guid Id => GUID;
public override string Name => ProductName;
public override string Version {
get {
if (isBeta) {
return Vers + "-beta";
} else {
return Vers;
}
}
}
public override string Version => GrasshopperVersion;
public const string Company = "Oasys";
public const string Contact = "https://www.oasys-software.com/";
public const string Copyright = "Copyright © Oasys 1985 - 2024";
public const string PluginName = "ComposGH";
public const string ProductName = "Compos";
public const string Vers = "0.9.18";
public const string GrasshopperVersion = "0.9.18";
public static string Disclaimer = PluginName + " is pre-release and under active development, including further testing to be undertaken. It is provided \"as-is\" and you bear the risk of using it. Future versions may contain breaking changes. Any files, results, or other types of output information created using " + PluginName + " should not be relied upon without thorough and independent checking.";
public static Guid GUID = new Guid("c3884cdc-ac5b-4151-afc2-93590cef4f8f");
public static bool isBeta = true;
Expand All @@ -139,7 +131,7 @@ internal sealed class PluginInfo {
new Lazy<OasysPluginInfo>(() => new OasysPluginInfo(
ComposGHInfo.ProductName,
ComposGHInfo.PluginName,
ComposGHInfo.Vers,
ComposGHInfo.GrasshopperVersion,
ComposGHInfo.isBeta,
"phc_QjmqOoe8GqTMi3u88ynRR3WWvrJA9zAaqcQS1FDVnJD"
));
Expand Down
6 changes: 6 additions & 0 deletions addComposReference.ps1
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"
6 changes: 6 additions & 0 deletions removeComposReference.ps1
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"

0 comments on commit 71397f9

Please sign in to comment.