Skip to content

Convert Plaster into a DSL #334

@bwright86

Description

@bwright86

Not sure if this has been already discussed, but Plaster could benefit from becoming a DSL in Powershell.

Some of the benefits from doing this would be:

The XML nodes in the PlasterManifest.xml are already mostly DSL words, here is an example manifest:

Manifest "Plaster Manifest Template" {
    Metadata {
        Name "NewPlasterTemplate"
        ID "bcd7b44b-0fda-4a08-9857-3e064abd6e2b"
        Version 0.0.1
        Title "A new Plaster Manifest"
        Description "A short description"
        Author "Brent W"
        Tags Tag1, Tag2, Tag3, etc...
    }
    Parameters {

        Text "ModuleName" "Enter the name of the module"

        Choices "License" "Select a license for your module" "Apache" {
            Choice '&Apache' "Adds an Apache license file." "Apache"
            Choice '&MIT' "Adds an MIT license file." "MIT"
            Choice '&None' "No license specified." "None"
        }

        MultiChoice 'Options' 'Select desired options' @("Pester", "PSake","Git") {
            Choice '&Pester test support' "Adds Tests directory and a starter Pester Tests file." "Pester"
            Choice 'P&Sake build script' "Adds a PSake build script that generates the module directory for publishing to the PSGallery." "PSake"
            Choice '&Git' "Adds a .gitignore file." "Git"
            Choice '&None' "No options specified." "None"
        }

        MultiChoice 'FruitSelection' 'Please pick some fruit' @("Apple", "Banana") {
            Choice '&Apple' "Pick an Apple" "Apple"
            Choice '&Banana' "Pick a Banana" "Banana"
            Choice '&Grapes' "Pick a cluster of grapes" "Grapes"
        }

        Other 'FullName' 'Enter your full name' 'user-fullname' 
    }
    Content {

        File 'ReleaseNotes.md' ''
        
        Directory "src\bin"
        
        File 'Tests\*.tests.ps1' 'test\' {
            $PLASTER_PARAM_Options -contains "Pester"
        }

        TemplateFile 'en-US\about_Module.help.txt' 'en-US\about_${PLASTER_PARAM_ModuleName}.help.txt'

        foreach ($fruit in $PLASTER_PARAM_FruitSelection) {
            TemplateFile '$fruit.json.txt' 'Fruits\$fruit.json'
        }
    }

Kevin Marquette wrote some good articles on creating a DSL:
https://kevinmarquette.github.io/2017-02-26-Powershell-DSL-intro-to-domain-specific-languages-part-1/

I think the Data Sections could help scope cmdlets as well, not sure if it could replace the constrained runspaces (It would require all scaffolded files to become DSL formatted as well, which is a big ask.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions