Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
37 changes: 28 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

## Prerequisites

- **PowerShell 7.2+** (required by the bootstrap script and ModuleFast)
- No other tooling required — the bootstrap script handles everything.
- **PowerShell 7.2+**

## Setup

Expand All @@ -13,22 +12,42 @@ cd Anvil
./build/bootstrap.ps1
```

## Development loop
## Development

```powershell
Invoke-Build -File ./build/module.build.ps1 -Task Lint, Test
```

Run the full pipeline before submitting:

```powershell
Invoke-Build -File ./build/module.build.ps1
```

To test your changes interactively:

```powershell
Import-Module ./src/Anvil/Anvil.psd1 -Force
```

## Conventions

- One function per file, filename matches function name.
- Public functions in `src/Anvil/Public/`, private in `Private/`.
- Always use `Join-Path` — never backslash concatenation.
- Pester 5 syntax only (`New-PesterConfiguration`, `BeforeAll`, `BeforeDiscovery`).
- Tag tests with `'Unit'` or `'Integration'`.
- One function per file, filename matches function name
- Public functions in `src/Anvil/Public/`, private in `Private/`
- Always use `Join-Path` for path construction
- Pester 5 syntax only
- Tag tests with `'Unit'` or `'Integration'`
- Template tokens use `<%Name%>` for content and `__Name__` for paths
- Template manifests (`template.psd1`) are the source of truth for template parameters and conditions

## Testing

Unit tests cover individual functions. Integration tests scaffold real projects and verify the output. Both must pass before merging.

When adding a new private function, include an "is not exported" test in the test file.

## Pull requests

1. Branch from `main`
2. Run `Invoke-Build -File ./build/module.build.ps1` — ensure it passes
2. Run the full pipeline and ensure it passes
3. Open a PR against `main`
105 changes: 57 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,51 @@
[![PowerShell Gallery][gallery-badge]][gallery-link]
[![License][license-badge]][license-link]

Anvil helps you create, develop, and ship PowerShell modules. It scaffolds a complete project structure with build pipelines, testing, linting, and CI/CD — then stays useful as you add functions, manage dependencies, and iterate.

> **Note:** Anvil is still in early development. Expect breaking changes, incomplete features, and rough edges.

## Features

- Scaffold a new module project that's ready to go from a single command
- Helpers to add functions, classes, tests, and dependencies to your module as you develop from the terminal
- A build process that auto-formats your code, lints it, runs tests with coverage, generates docs, compiles a single-file module, and packages it for publishing
- Pester (v5) test harness, with code coverage reporting and thresholds
- PSScriptAnalyzer linting with custom rules that ship with the project, and a simple process for adding your own
- Narkdown documentation generation using platyPS
- Anvil bootstraps its own build dependencies and your runtime dependencies during development via [ModuleFast](https://github.com/JustinGrote/ModuleFast)
- CI/CD workflows for GitHub Actions, Azure Pipelines, and GitLab CI
- Can build modules that are compatible with PowerShell 5.1, but authoring requires PowerShell >=7.2
Anvil scaffolds PowerShell module projects with a working build pipeline, test infrastructure, linting, and CI/CD. It also provides commands for adding functions, classes, and dependencies as you develop.

## Installation

```powershell
Install-Module -Name Anvil -Scope CurrentUser
```

## Quick Start
Requires PowerShell 7.2 or later. Modules you build can target any version down to 5.1.

Scaffold a new module:
## Create a module

```powershell
$Params = @{
Name = 'NetworkTools'
DestinationPath = '~/Projects'
Author = 'Jane Doe'
CIProvider = 'GitHub'
GitInit = $true
}
New-AnvilModule @Params
New-AnvilModule -Interactive
```

Or run `New-AnvilModule -Interactive` for a guided wizard.

Bootstrap and build:
This walks you through naming the module, choosing a CI provider, selecting a license, and configuring build options. When it finishes, you have a complete project that builds, lints, tests, and packages out of the box:

```powershell
cd ~/Projects/NetworkTools
cd MyModule
Invoke-AnvilBootstrapDeps
Invoke-Build -File ./build/module.build.ps1
Invoke-AnvilBuild
```

Then keep developing — Anvil stays with you after scaffolding:
For scripted or CI-driven usage, pass parameters directly:

```powershell
New-AnvilFunction -FunctionName 'Get-Widget' -Scope Public
New-AnvilFunction -FunctionName 'Format-Row' -Scope Private
New-AnvilClass -ClassName 'HttpClient'
Add-AnvilDependency -Name 'Az.Storage' -Version '>=5.0.0'
Invoke-AnvilBootstrapDeps
Import-AnvilModule
$Params = @{
Name = 'NetworkTools'
DestinationPath = '~/Projects'
Author = 'Jane Doe'
CIProvider = 'GitHub'
GitInit = $true
}
New-AnvilModule @Params
```

## What you get
## Project structure

```
NetworkTools/
├── src/NetworkTools/ Module source (Public/, Private/, PrivateClasses/)
├── build/ InvokeBuild pipeline, bootstrap, settings
├── tests/ Pester 5 unit and integration tests
├── docs/ platyPS documentation
├── docs/ Documentation
├── requirements.psd1 Module dependencies
├── .github/workflows/ CI/CD (or Azure Pipelines / GitLab CI)
├── PSScriptAnalyzerSettings.psd1
Expand All @@ -78,16 +57,35 @@ NetworkTools/
└── .gitignore
```

The build pipeline handles formatting, linting, unit tests with code coverage, module compilation into a single distributable file, integration tests, and packaging. Build dependencies are bootstrapped automatically — nothing to install manually beyond Anvil itself.

CI/CD workflows are included for GitHub Actions, Azure Pipelines, or GitLab CI, with tag-triggered releases to the PowerShell Gallery.

## Developing with Anvil

After scaffolding, Anvil provides commands for common tasks:

```powershell
New-AnvilFunction -FunctionName 'Get-Widget' -Scope Public # creates function + test
New-AnvilFunction -FunctionName 'Format-Row' -Scope Private # internal helper + test
New-AnvilClass -ClassName 'WidgetResult' # class + test
Add-AnvilDependency -Name 'Az.Storage' -Version '>=5.0.0' # adds to manifest + requirements
Import-AnvilModule # reload for interactive testing
```

## Custom templates

Anvil's scaffolding is driven by a manifest-based template system. You can create your own templates with custom parameters, conditions, and file structures. See [Template Authoring](docs/template-authoring.md).

## Documentation

- [Getting Started](docs/getting-started.md) — scaffold a project, bootstrap, first build
- [Development](docs/development.md) — adding functions, classes, dependencies, testing, the daily workflow
- [Project Structure](docs/project-structure.md) — what every file and directory does
- [Build Pipeline](docs/build-pipeline.md) — every build task explained, settings reference
- [CI/CD Integration](docs/cicd-integration.md) — GitHub Actions, Azure Pipelines, GitLab CI
- [Customization](docs/customization.md) — custom lint rules, types, formats, build tasks
- [FAQ](docs/faq.md) — common questions and troubleshooting
- [Command Reference](docs/commands/) — detailed help for all commands
| | |
|---|---|
| [Getting Started](docs/getting-started.md) | Scaffold a project, bootstrap, first build |
| [Reference](docs/reference.md) | Project structure, build pipeline, CI/CD, customization |
| [Template Authoring](docs/template-authoring.md) | Creating custom templates |
| [Command Reference](docs/commands/) | Detailed help for all commands |
| [FAQ](docs/faq.md) | Troubleshooting |

## Contributing

Expand All @@ -99,7 +97,18 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.

## Acknowledgements

Heavily inspired by [Catesta](https://github.com/techthoughts2/Catesta).
Anvil builds on and is inspired by the work of these projects:

| Project | License | Role |
|---------|---------|------|
| [Catesta](https://github.com/techthoughts2/Catesta) | MIT | Inspiration for Anvil's design |
| [InvokeBuild](https://github.com/nightroman/Invoke-Build) | Apache 2.0 | Build pipeline engine |
| [ModuleFast](https://github.com/JustinGrote/ModuleFast) | MIT | Dependency bootstrapping |
| [Pester](https://github.com/pester/Pester) | Apache 2.0 | Test framework |
| [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer) | MIT | Linting and formatting |
| [PSResourceGet](https://github.com/PowerShell/PSResourceGet) | MIT | Module publishing |
| [platyPS](https://github.com/PowerShell/platyPS) | MIT | Documentation generation |
| [Indented.ScriptAnalyzerRules](https://github.com/indented-automation/Indented.ScriptAnalyzerRules) | MIT | Custom PSScriptAnalyzer rules |

<!-- Badge links -->
[ci-badge]: https://github.com/f0oster/Anvil/actions/workflows/ci.yml/badge.svg?branch=main
Expand Down
168 changes: 0 additions & 168 deletions docs/build-pipeline.md

This file was deleted.

Loading