Skip to content

Commit aa15ae1

Browse files
🩹 [Patch]: Initialize Hcl module (#3)
The `Hcl` module is now available on the [PowerShell Gallery](https://www.powershellgallery.com/) as version `0.0.1`. This initial release reserves the module name and establishes the intended API surface — `ConvertFrom-Hcl` and `ConvertTo-Hcl` — for working with [HashiCorp Configuration Language](https://github.com/hashicorp/hcl) as used in Terraform, OpenTofu, and related infrastructure-as-code tooling. Both functions are placeholders that throw `NotImplementedException` until the full parser and serializer are implemented. - Fixes #2 ## New: Hcl module on the PowerShell Gallery The module can be installed from the PowerShell Gallery: ```powershell Install-PSResource -Name Hcl Import-Module -Name Hcl ``` `ConvertFrom-Hcl` and `ConvertTo-Hcl` are available as commands but throw `NotImplementedException` until the implementation is complete. Their presence reserves the intended API and allows downstream tooling to take a dependency on the module name. ## Technical Details - All template boilerplate removed: `Test-PSModuleTest.ps1`, `completers.ps1`, `PSModule/` and `SomethingElse/` subdirectories, and `tests/PSModuleTest.Tests.ps1`. - `ConvertFrom-Hcl` and `ConvertTo-Hcl` added as public placeholder functions, following the same pattern as [PSModule/Toml#init](https://github.com/PSModule/Toml/tree/init). - `src/manifest.psd1` set to `ModuleVersion = '0.0.1'` to trigger the first publish pipeline run. - `tests/Hcl.Tests.ps1` added with assertions that both placeholders throw as expected. - `examples/General.ps1` and `README.md` updated with HCL-specific content (Terraform locals, `.tfvars` examples). --------- Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 14a6404 commit aa15ae1

36 files changed

Lines changed: 134 additions & 666 deletions

.github/workflows/Process-PSModule.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ permissions:
2727

2828
jobs:
2929
Process-PSModule:
30-
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@60bdf8a5a4c92c53fcf2a8d23f7d5f5c93e6864e # v5.4.3
30+
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@11117919e65242d3388727819a751f74ad24ea9e # v5.5.0
3131
secrets:
3232
APIKEY: ${{ secrets.APIKEY }}

README.md

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# {{ NAME }}
1+
# Hcl
22

3-
{{ DESCRIPTION }}
3+
A PowerShell module for working with [HashiCorp Configuration Language (HCL)](https://github.com/hashicorp/hcl), as used in [Terraform](https://www.terraform.io/), [OpenTofu](https://opentofu.org/), and other infrastructure-as-code tools. Supports parsing `.tf` configuration files, `.tfvars` variable files, `locals {}` blocks, and converting PowerShell objects back to HCL format.
44

55
## Prerequisites
66

@@ -12,58 +12,80 @@ This uses the following external resources:
1212
To install the module from the PowerShell Gallery, you can use the following command:
1313

1414
```powershell
15-
Install-PSResource -Name {{ NAME }}
16-
Import-Module -Name {{ NAME }}
15+
Install-PSResource -Name Hcl
16+
Import-Module -Name Hcl
1717
```
1818

1919
## Usage
2020

21-
Here is a list of example that are typical use cases for the module.
21+
Here is a list of examples that are typical use cases for the module.
2222

23-
### Example 1: Greet an entity
24-
25-
Provide examples for typical commands that a user would like to do with the module.
23+
### Example 1: Parse a Terraform locals block
2624

2725
```powershell
28-
Greet-Entity -Name 'World'
29-
Hello, World!
26+
$hcl = @'
27+
locals {
28+
environment = "production"
29+
region = "us-east-1"
30+
tags = {
31+
project = "myapp"
32+
team = "platform"
33+
}
34+
}
35+
'@
36+
$result = ConvertFrom-Hcl -InputObject $hcl
37+
$result.locals.environment # production
38+
$result.locals.tags.project # myapp
3039
```
3140

32-
### Example 2
41+
### Example 2: Parse a .tfvars file
3342

34-
Provide examples for typical commands that a user would like to do with the module.
43+
```powershell
44+
$tfvars = Get-Content -Path 'terraform.tfvars' -Raw
45+
$variables = ConvertFrom-Hcl -InputObject $tfvars
46+
$variables.region # us-east-1
47+
```
48+
49+
### Example 3: Convert a PowerShell object to HCL
3550

3651
```powershell
37-
Import-Module -Name PSModuleTemplate
52+
$config = [ordered]@{
53+
resource = [ordered]@{
54+
aws_instance = [ordered]@{
55+
example = [ordered]@{
56+
ami = 'ami-0c55b159cbfafe1f0'
57+
instance_type = 't2.micro'
58+
}
59+
}
60+
}
61+
}
62+
ConvertTo-Hcl -InputObject $config
3863
```
3964

4065
### Find more examples
4166

4267
To find more examples of how to use the module, please refer to the [examples](examples) folder.
4368

44-
Alternatively, you can use the Get-Command -Module 'This module' to find more commands that are available in the module.
45-
To find examples of each of the commands you can use Get-Help -Examples 'CommandName'.
69+
Alternatively, you can use `Get-Command -Module 'Hcl'` to find commands available in the module.
70+
To find examples of each command, use `Get-Help -Examples 'CommandName'`.
4671

4772
## Documentation
4873

49-
Link to further documentation if available, or describe where in the repository users can find more detailed documentation about
50-
the module's functions and features.
74+
For detailed documentation on each function, use the built-in help system:
75+
76+
```powershell
77+
Get-Help ConvertFrom-Hcl -Full
78+
Get-Help ConvertTo-Hcl -Full
79+
```
5180

5281
## Contributing
5382

5483
Coder or not, you can contribute to the project! We welcome all contributions.
5584

56-
### For Users
57-
58-
If you don't code, you still sit on valuable information that can make this project even better. If you experience that the
59-
product does unexpected things, throw errors or is missing functionality, you can help by submitting bugs and feature requests.
60-
Please see the issues tab on this project and submit a new issue that matches your needs.
61-
62-
### For Developers
85+
### For users
6386

64-
If you do code, we'd love to have your contributions. Please read the [Contribution guidelines](CONTRIBUTING.md) for more information.
65-
You can either help by picking up an existing issue or submit a new one if you have an idea for a new feature or improvement.
87+
If you don't code, you still sit on valuable information that can make this project even better. If you experience that the product does unexpected things, throw errors or is missing functionality, you can help by submitting bugs and feature requests. Please see the issues tab on this project and submit a new issue that matches your needs.
6688

67-
## Acknowledgements
89+
### For developers
6890

69-
Here is a list of people and projects that helped this project in some way.
91+
If you do code, we'd love to have your contributions. Please read the [Contribution guidelines](CONTRIBUTING.md) for more information. You can either help by picking up an existing issue or submit a new one if you have an idea for a new feature or improvement.

examples/General.ps1

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
<#
1+
<#
22
.SYNOPSIS
3-
This is a general example of how to use the module.
3+
This is a general example of how to use the Hcl module.
44
#>
55

66
# Import the module
7-
Import-Module -Name 'PSModule'
7+
Import-Module -Name 'Hcl'
88

9-
# Define the path to the font file
10-
$FontFilePath = 'C:\Fonts\CodeNewRoman\CodeNewRomanNerdFontPropo-Regular.tff'
11-
12-
# Install the font
13-
Install-Font -Path $FontFilePath -Verbose
14-
15-
# List installed fonts
16-
Get-Font -Name 'CodeNewRomanNerdFontPropo-Regular'
17-
18-
# Uninstall the font
19-
Get-Font -Name 'CodeNewRomanNerdFontPropo-Regular' | Uninstall-Font -Verbose
9+
# Convert an HCL locals block to a PowerShell object
10+
$hcl = @'
11+
locals {
12+
environment = "production"
13+
region = "us-east-1"
14+
}
15+
'@
16+
ConvertFrom-Hcl -InputObject $hcl

src/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/assemblies/LsonLib.dll

-42.5 KB
Binary file not shown.

src/classes/private/SecretWriter.ps1

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/classes/public/Book.ps1

Lines changed: 0 additions & 147 deletions
This file was deleted.

src/data/Config.psd1

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/data/Settings.psd1

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/finally.ps1

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)