Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ insert_final_newline = true
tab_width = 2
trim_trailing_whitespace = true

[*.cs]
csharp_indent_case_contents_when_block = false
csharp_indent_labels = no_change
csharp_new_line_before_open_brace = none
csharp_prefer_braces = false
csharp_space_after_cast = true
csharp_space_before_colon_in_inheritance_clause = false
csharp_style_expression_bodied_constructors = true
csharp_style_expression_bodied_local_functions = true
csharp_style_expression_bodied_methods = true
csharp_style_expression_bodied_operators = true
csharp_style_namespace_declarations = file_scoped
csharp_style_var_elsewhere = true
csharp_style_var_for_built_in_types = true
csharp_style_var_when_type_is_apparent = true
csharp_using_directive_placement = inside_namespace
dotnet_diagnostic.CS8524.severity = silent
dotnet_sort_system_directives_first = false
dotnet_style_namespace_match_folder = false

[*.md]
trim_trailing_whitespace = false

Expand Down
11 changes: 10 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
* text=auto
.* text

*.cjs text
*.config text
*.cs text diff=csharp
*.csproj text
*.css text diff=css
*.esproj text
*.html text diff=html
*.http text
*.ini text
*.iss text
*.js text
*.json text
*.md text diff=markdown
*.mjs text
*.php text diff=php
*.ps1 text
*.psd1 text
*.razor text
*.scss text diff=css
*.slnx text
*.sql text
*.svg text
*.ts text
*.txt text
*.webmanifest text
*.xml text
*.yaml text
*.yml text
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
/.idea/
/.vs/
/bin/
/src/obj/
/*/obj/
/var/
5 changes: 5 additions & 0 deletions .runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RunSettings>
<RunConfiguration>
<ResultsDirectory>var/TestResults</ResultsDirectory>
</RunConfiguration>
</RunSettings>
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"recommendations": [
"ms-dotnettools.csdevkit",
"ms-vscode.powershell"
]
}
5 changes: 4 additions & 1 deletion Invoke.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ param (
param ($commandName, $parameterName, $wordToComplete)
(Get-Item "$PSScriptRoot/tool/$wordToComplete*.ps1").BaseName
})]
[string] $Command = "Default"
[string] $Command = "Default",

[Parameter()]
[switch] $Release
)

$ErrorActionPreference = "Stop"
Expand Down
11 changes: 3 additions & 8 deletions SetupAnt.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
DefaultCommandPrefix = "Ant"
ModuleVersion = "5.1.0"
PowerShellVersion = "7.4"
RootModule = "src/Main.psm1"
RootModule = "bin/Belin.SetupAnt.dll"

Author = "Cédric Belin <cedx@outlook.com>"
CompanyName = "Cedric-Belin.fr"
Expand All @@ -11,22 +11,17 @@
GUID = "30b52520-21cd-44c4-aa11-b1f0dc085686"

AliasesToExport = @()
CmdletsToExport = @()
FunctionsToExport = @()
VariablesToExport = @()

FunctionsToExport = @(
CmdletsToExport = @(
"Find-Release"
"Get-Release"
"Install-Release"
"New-Release"
"Test-Release"
)

NestedModules = @(
"src/Release.psm1"
"src/Setup.psm1"
)

PrivateData = @{
PSData = @{
LicenseUri = "https://github.com/cedx/setup-ant/blob/main/License.md"
Expand Down
16 changes: 9 additions & 7 deletions SetupAnt.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<File Path=".editorconfig" />
<File Path=".gitattributes" />
<File Path=".gitignore" />
<File Path=".runsettings" />
<File Path="PSModules.psd1" />
<File Path="SetupAnt.psd1" />
</Folder>
Expand All @@ -21,24 +22,25 @@
<File Path="Start.ps1" />
</Folder>
<Folder Name="/Scripts/Tools/">
<File Path="tool/Build.ps1" />
<File Path="tool/Clean.ps1" />
<File Path="tool/Default.ps1" />
<File Path="tool/Format.ps1" />
<File Path="tool/Install.ps1" />
<File Path="tool/Lint.ps1" />
<File Path="tool/Outdated.ps1" />
<File Path="tool/Publish.ps1" />
<File Path="tool/Test.ps1" />
<File Path="tool/Update.ps1" />
<File Path="tool/Version.ps1" />
<File Path="tool/Watch.ps1" />
</Folder>
<Folder Name="/Workflows/">
<File Path="action.yaml" />
<File Path=".github/workflows/ContinuousIntegration.yaml" />
</Folder>
<Project Path="src/SetupAnt.esproj">
<Build />
<Deploy />
</Project>
<Project Path="test/SetupAnt.Tests.esproj">
<Build />
<Deploy />
<Project Path="src/SetupAnt.csproj" />
<Project Path="test/SetupAnt.Tests.csproj">
<Build Solution="Release|*" Project="false" />
</Project>
</Solution>
6 changes: 3 additions & 3 deletions Start.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env pwsh
using module ./src/Release.psm1
using module ./src/Setup.psm1
using assembly ./bin/Belin.SetupAnt.dll
using namespace Belin.SetupAnt

$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
Set-StrictMode -Version Latest
if (-not (Test-Path Env:SETUP_ANT_VERSION)) { $Env:SETUP_ANT_VERSION = "latest" }
if (-not (Test-Path Env:SETUP_ANT_VERSION)) { $Env:SETUP_ANT_VERSION = "Latest" }

$release = [Release]::Find($Env:SETUP_ANT_VERSION)
if (-not $release) { throw "No release matching the version constraint." }
Expand Down
20 changes: 20 additions & 0 deletions src/Cmdlets/Find-Release.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Belin.SetupAnt.Cmdlets;

/// <summary>
/// Finds a release that matches the specified version constraint.
/// </summary>
[Cmdlet(VerbsCommon.Find, "Release")]
[OutputType(typeof(Release))]
public class FindReleaseCommand: Cmdlet {

/// <summary>
/// The version constraint.
/// </summary>
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
public required string Constraint { get; set; }

/// <summary>
/// Performs execution of this command.
/// </summary>
protected override void ProcessRecord() => WriteObject(Release.Find(Constraint));
}
24 changes: 24 additions & 0 deletions src/Cmdlets/Get-Release.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Belin.SetupAnt.Cmdlets;

using System.Data;
using System.Text.RegularExpressions;

/// <summary>
/// Gets the release corresponding to the specified version.
/// </summary>
[Cmdlet(VerbsCommon.Get, "Release")]
[OutputType(typeof(Release))]
public class GetReleaseCommand: Cmdlet {

/// <summary>
/// The version number. Use `*` or `Latest` to get the latest release.
/// </summary>
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
public required string Version { get; set; }

/// <summary>
/// Performs execution of this command.
/// </summary>
protected override void ProcessRecord() =>
WriteObject(Release.LatestReleasePattern().IsMatch(Version) ? Release.Latest : Release.Get(Version));
}
35 changes: 35 additions & 0 deletions src/Cmdlets/Install-Release.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace Belin.SetupAnt.Cmdlets;

/// <summary>
/// Installs Apache Ant, after downloading it.
/// </summary>
[Cmdlet(VerbsLifecycle.Install, "Release")]
[OutputType(typeof(string))]
public class InstallReleaseCommand: PSCmdlet {

/// <summary>
/// The instance of the release to be installed.
/// </summary>
[Parameter(Mandatory = true, ParameterSetName = "InputObject", ValueFromPipeline = true)]
public required Release InputObject { get; set; }

/// <summary>
/// Value indicating whether to fetch the Ant optional tasks.
/// </summary>
[Parameter]
public SwitchParameter OptionalTasks { get; set; }

/// <summary>
/// The version number of the release to be installed.
/// </summary>
[Parameter(Mandatory = true, ParameterSetName = "Version", Position = 0, ValueFromPipeline = true)]
public required Version Version { get; set; }

/// <summary>
/// Performs execution of this command.
/// </summary>
protected override void ProcessRecord() {
var release = ParameterSetName == "InputObject" ? InputObject : new Release(Version);
WriteObject(new Setup(release).Install(OptionalTasks).GetAwaiter().GetResult());
}
}
20 changes: 20 additions & 0 deletions src/Cmdlets/New-Release.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Belin.SetupAnt.Cmdlets;

/// <summary>
/// Creates a new release.
/// </summary>
[Cmdlet(VerbsCommon.New, "Release")]
[OutputType(typeof(Release))]
public class NewReleaseCommand: Cmdlet {

/// <summary>
/// The version number.
/// </summary>
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
public required Version Version { get; set; }

/// <summary>
/// Performs execution of this command.
/// </summary>
protected override void ProcessRecord() => WriteObject(new Release(Version));
}
29 changes: 29 additions & 0 deletions src/Cmdlets/Test-Release.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Belin.SetupAnt.Cmdlets;

/// <summary>
/// Gets a value indicating whether a release with the specified version exists.
/// </summary>
[Cmdlet(VerbsDiagnostic.Test, "Release", DefaultParameterSetName = "Version")]
[OutputType(typeof(bool))]
public class TestReleaseCommand: PSCmdlet {

/// <summary>
/// The version number of the release to be tested.
/// </summary>
[Parameter(Mandatory = true, ParameterSetName = "InputObject", ValueFromPipeline = true)]
public required Release InputObject { get; set; }

/// <summary>
/// The version number of the release to be tested.
/// </summary>
[Parameter(Mandatory = true, ParameterSetName = "Version", Position = 0, ValueFromPipeline = true)]
public required Version Version { get; set; }

/// <summary>
/// Performs execution of this command.
/// </summary>
protected override void ProcessRecord() {
var release = ParameterSetName == "InputObject" ? InputObject : new Release(Version);
WriteObject(release.Exists);
}
}
52 changes: 0 additions & 52 deletions src/Data.psd1

This file was deleted.

Loading