Skip to content

Commit 71397f9

Browse files
psarrasSandeepArup
andauthored
COMPSGH-200: add and remove scripts for debugging purposes (#146)
Co-authored-by: Sandeep Kumar <[email protected]>
1 parent 011158c commit 71397f9

5 files changed

+97
-11
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ ComposGHConverter/bin
2020
/ConverterTests/obj
2121
*.log
2222
/ComposGH.sln.DotSettings.user
23+
.idea

BumpVersion.ps1

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
function Has-Version {
3+
param ($version)
4+
5+
# Check if the version argument is provided
6+
if ($version.Count -eq 0) {
7+
Write-Host "Please provide the version number as an argument. Usage: .\bump-version.ps1 <new-version>"
8+
exit
9+
}
10+
11+
# Get the new version from the CLI argument
12+
return $version[0]
13+
}
14+
15+
$newVersion = Has-Version($args)
16+
17+
# Function to validate the version format (X.X.X where X is a number)
18+
function Validate-VersionFormat {
19+
param (
20+
[string]$version
21+
)
22+
23+
# Regex pattern for validating version format (X.X.X-beta)
24+
$versionPattern = '^\d+\.\d+\.\d+$'
25+
26+
# Check if version matches the pattern
27+
return $version -match $versionPattern
28+
}
29+
30+
# Function to update version in a file
31+
function Update-Version {
32+
param (
33+
[string]$filePath,
34+
[string]$searchPattern,
35+
[string]$newVersion,
36+
[string]$replacementPattern
37+
)
38+
39+
# Read the content of the file
40+
$content = Get-Content $filePath
41+
42+
# Replace the version based on the provided pattern and replacement
43+
$updatedContent = $content -replace $searchPattern, $replacementPattern
44+
45+
# Write the updated content back to the file
46+
Set-Content $filePath -Value $updatedContent
47+
48+
Write-Host "Updated version in $filePath to $newVersion"
49+
}
50+
51+
# Check if the version format is valid
52+
if (-not (Validate-VersionFormat $newVersion)) {
53+
Write-Host "Invalid version format. Please use the format: X.X.X where X is a number."
54+
exit
55+
}
56+
57+
# Define the paths and patterns for each file
58+
$filesToUpdate = @(
59+
@{
60+
FilePath = ".\ComposGH\ComposGH.csproj"
61+
SearchPattern = '<Version>(.*?)<\/Version>'
62+
ReplacementPattern = "<Version>$newVersion-beta</Version>"
63+
},
64+
@{
65+
FilePath = ".\Compos\ComposAPI.csproj"
66+
SearchPattern = '<Version>(.*?)<\/Version>'
67+
ReplacementPattern = "<Version>$newVersion-beta</Version>"
68+
},
69+
@{
70+
FilePath = ".\ComposGH\ComposGHInfo.cs"
71+
SearchPattern = 'string GrasshopperVersion = "(.*?)"'
72+
ReplacementPattern = 'string GrasshopperVersion = "' + $newVersion + '-beta"'
73+
}
74+
)
75+
76+
# Loop through each file and update the version
77+
foreach ($file in $filesToUpdate) {
78+
Update-Version -filePath $file.FilePath -searchPattern $file.SearchPattern -newVersion $newVersion -replacementPattern $file.ReplacementPattern
79+
}
80+
81+
Write-Host "Version update completed."

ComposGH/ComposGHInfo.cs

+3-11
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,13 @@ public class ComposGHInfo : GH_AssemblyInfo {
113113
public override Bitmap Icon => null;
114114
public override Guid Id => GUID;
115115
public override string Name => ProductName;
116-
public override string Version {
117-
get {
118-
if (isBeta) {
119-
return Vers + "-beta";
120-
} else {
121-
return Vers;
122-
}
123-
}
124-
}
116+
public override string Version => GrasshopperVersion;
125117
public const string Company = "Oasys";
126118
public const string Contact = "https://www.oasys-software.com/";
127119
public const string Copyright = "Copyright © Oasys 1985 - 2024";
128120
public const string PluginName = "ComposGH";
129121
public const string ProductName = "Compos";
130-
public const string Vers = "0.9.18";
122+
public const string GrasshopperVersion = "0.9.18";
131123
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.";
132124
public static Guid GUID = new Guid("c3884cdc-ac5b-4151-afc2-93590cef4f8f");
133125
public static bool isBeta = true;
@@ -139,7 +131,7 @@ internal sealed class PluginInfo {
139131
new Lazy<OasysPluginInfo>(() => new OasysPluginInfo(
140132
ComposGHInfo.ProductName,
141133
ComposGHInfo.PluginName,
142-
ComposGHInfo.Vers,
134+
ComposGHInfo.GrasshopperVersion,
143135
ComposGHInfo.isBeta,
144136
"phc_QjmqOoe8GqTMi3u88ynRR3WWvrJA9zAaqcQS1FDVnJD"
145137
));

addComposReference.ps1

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$relevantPath = "ComposGH\bin\x64\Debug\net48"
2+
$absolutePath = Resolve-Path $relevantPath
3+
4+
$destinationDir = "$env:APPDATA\Grasshopper\Libraries"
5+
6+
echo $absolutePath > "$destinationDir\ComposGhTests.ghlink"

removeComposReference.ps1

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$relevantPath = "ComposGH\bin\x64\Debug\net48"
2+
$absolutePath = Resolve-Path $relevantPath
3+
4+
$destinationDir = "$env:APPDATA\Grasshopper\Libraries"
5+
6+
rm "$destinationDir\ComposGhTests.ghlink"

0 commit comments

Comments
 (0)