Language Starter Scripts
Documentation for extending setup-project.ps1 with language-specific setup
This directory contains modular PowerShell scripts for generating language-specific starter files when creating a new project.
Overview
The setup-project.ps1 script automatically calls language starter scripts if they exist:
setup-starter-<language>.ps1
This allows projects to have:
- Language-specific configuration files (package.json, Cargo.toml, etc.)
- Starter source code and test stubs
- Build/development tool configurations
- Dependency specifications
Existing Starters
Node.js — setup-starter-node.ps1
Generates:
package.json— Dependencies and scriptstsconfig.json— TypeScript configuration.eslintrc.json— Code linting rulesjest.config.js— Test runner configuration.prettierrc.json— Code formatter settingssrc/index.js— Starter entry pointtests/index.test.js— Starter test file
Usage:
.\scripts\setup-project.ps1 -ProjectPath 'D:\Projects\MyApp' -ProjectName 'MyApp' -Language 'node'
Python — setup-starter-python.ps1
Generates:
requirements.txt— Production dependenciesrequirements-dev.txt— Development dependenciessetup.py— Package installation scriptpyproject.toml— Modern Python project configpytest.ini— Test runner configuration.flake8— Code style checkersrc/__init__.py— Package initializationsrc/main.py— Starter entry pointtests/test_main.py— Starter test file
Usage:
.\scripts\setup-project.ps1 -ProjectPath 'D:\Projects\MyApp' -ProjectName 'MyApp' -Language 'python'
Creating a New Language Starter
To add support for a new language, create a script following this pattern:
Script Template
#Requires -Version 5.1
<#
.SYNOPSIS
Generate [Language] project starter files
.DESCRIPTION
Creates language-specific starter files for a [Language] project.
Called automatically by setup-project.ps1 if this script exists.
.PARAMETER ProjectPath
Project root directory.
.PARAMETER ProjectName
Project display name (used in configuration files).
#>
param(
[Parameter(Mandatory)][string]$ProjectPath,
[Parameter(Mandatory)][string]$ProjectName
)
# Import shared setup module functions
$modulePath = Join-Path $PSScriptRoot '..\modules\Setup.psm1'
Import-Module $modulePath -Force
Write-Step "Setting up [Language] starter files"
# ============================================================================
# Config File 1: [Description]
# ============================================================================
$content1 = @"
# Your configuration content here
"@
Set-Content -Path (Join-Path $ProjectPath 'config-file-1.ext') -Value $content1
Write-Success "Generated config-file-1.ext"
# ============================================================================
# Config File 2: [Description]
# ============================================================================
# ... create more files ...
Write-Success "[Language] starter setup complete"
Naming Convention
- Script name:
setup-starter-<language>.ps1where<language>matches the Language parameter value used insetup-project.ps1- Examples:
setup-starter-csharp.ps1,setup-starter-rust.ps1,setup-starter-go.ps1
- Examples:
File Organization
Each starter should typically generate:
-
Build/Dependency Files
package.json(Node)Cargo.toml(Rust)setup.py/pyproject.toml(Python).csproj(C#)pom.xml(Java)go.mod(Go)
-
Config Files
- Linting:
.eslintrc,.pylintrc, etc. - Formatting:
.prettierrc,black.toml, etc. - Testing:
jest.config.js,pytest.ini, etc.
- Linting:
-
Source Stubs
src/index.jsorsrc/main.rsorsrc/main.py- Typical "Hello World" or starter code
-
Test Stubs
tests/index.test.jsor equivalent- Demonstrates test structure
Best Practices
-
Use shared setup module functions
$modulePath = Join-Path $PSScriptRoot '..\modules\Setup.psm1'
Import-Module $modulePath -Force
Write-Step, Write-Success, Write-WarningMessage -
Create directories first
$srcDir = Join-Path $ProjectPath 'src'
$null = New-Item -ItemType Directory -Path $srcDir -Force -ErrorAction SilentlyContinue -
Generate from templates
- Use here-strings (
@"..."@) for multi-line content - Keep formatting clear and production-ready
- Use here-strings (
-
Report progress
- Call
Write-Successafter each file - Help users see what was created
- Call
-
Handle errors gracefully
- Use
-ErrorAction SilentlyContinuewhere appropriate - The orchestrator catches errors and reports them
- Use
Example: C# Starter
#Requires -Version 5.1
param(
[Parameter(Mandatory)][string]$ProjectPath,
[Parameter(Mandatory)][string]$ProjectName
)
$modulePath = Join-Path $PSScriptRoot '..\modules\Setup.psm1'
Import-Module $modulePath -Force
Write-Step "Setting up C# starter files"
# .csproj
$csprojContent = @"
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<OutputType>Exe</OutputType>
<RootNamespace>$ProjectName</RootNamespace>
</PropertyGroup>
</Project>
"@
Set-Content -Path (Join-Path $ProjectPath "$ProjectName.csproj") -Value $csprojContent
Write-Success "Generated .csproj"
# Program.cs
$programContent = @"
namespace $ProjectName;
class Program
{
static void Main()
{
Console.WriteLine("Welcome to $ProjectName");
}
}
"@
Set-Content -Path (Join-Path $ProjectPath 'src/Program.cs') -Value $programContent
Write-Success "Generated Program.cs"
# ... more files ...
Write-Success "C# starter setup complete"
Troubleshooting
Starter Script Not Found
If setup-starter-<language>.ps1 doesn't exist for your chosen language:
- The
setup-project.ps1will skip language-specific setup - You'll need to manually create language config files
- Consider creating the starter script using the template above
Starter Script Fails
If a starter script errors during execution:
- The orchestrator catches and reports the error
- It continues with the rest of setup
- Check the error message for details
- Fix the starter script and re-run
Extending for New Languages
To add support for another language:
- Create the starter script using the template
- Name it
setup-starter-<language>.ps1where<language>matches a supported value insetup-project.ps1 - Add the language to
setup-project.ps1parameter validation if needed - Test it:
.\scripts\setup-project.ps1 -ProjectPath 'D:\Test\Project' -ProjectName 'Test' -Language '<language>' - Document it in this README
References
scripts/modules/Setup.psm1— Shared utility + core functions for file generationscripts/setup-project.ps1— Main orchestrator- Setup specification — Overall setup specification