diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..98c6e59 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,75 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at . All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html) + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..0e9e7aa --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,21 @@ +# Contributing + +Thanks for your interest in contributing to the **PSPrettier** module! + +Whether it's a bug report, new feature, correction, or additional documentation, your feedback and contributions are appreciated. + +Please read through this document before submitting any issues or pull requests to ensure all the necessary information is provided to effectively respond to your bug report or contribution. + +Please note there is a code of conduct, please follow it in all your interactions with the project. + +## Contributing via Pull Requests + +Please use the `prerelease` branch as your target when submitting a pull request. If you have questions about how to do that, I would be more than happy to walk you through the steps over in the [discussions](https://github.com/SamErde/PSPreworkout/discussions)! + +## Code of Conduct + +This project has a [Code of Conduct](CODE_OF_CONDUCT.md). + +## Licensing + +See the [LICENSE](LICENSE) file for our project's licensing. diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..43abf4b --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,15 @@ +# These are supported funding model platforms + +github: SamErde # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: SamErde # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +polar: # Replace with a single Polar username +buy_me_a_coffee: SamErde # Replace with a single Buy Me a Coffee username +thanks_dev: # Replace with a single thanks.dev username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 0000000..8f09b75 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,39 @@ +--- +name: Bug Report +about: Submit a new bug +title: '๐Ÿชฒ Bug report' +labels: bug +assignees: SamErde + +--- + + + +### Expected Behavior + + +### Current Behavior + + +### Possible Solution + + +### Steps to Reproduce + + + +1. +2. +3. +4. + +### Context (Environment) + + +* Operating System and version as reported by `$PSVersionTable.OS`: +* PowerShell versions as reported by `$PSVersionTable.PSEdition`: + + + +### Detailed Description + diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..d365b70 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,15 @@ +blank_issues_enabled: false + +contact_links: + - name: Questions & Discussions ๐Ÿ’ฌ + url: https://github.com/SamErde/PSPrettier/discussions + about: Please use GitHub discussions for any questions. + - name: Documentation ๐Ÿ“š + url: https://day3bits.com/PSPrettier + about: Documentation for the PSPrettier project. + - name: ReadTheDocs ๐Ÿ“– (Alternate/Backup Documentation Site) + url: https://psprettier.readthedocs.io/en/latest/ + about: ReadTheDocs for the PSPrettier project. +# - name: Basic FAQs โ“ +# url: https://github.com/SamErde/PSPrettier/wiki/FAQs +# about: Answers to the Basic Frequently Asked Questions diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..9da13cb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature Request +about: Suggest an idea for this project +title: '๐Ÿ™ Feature request' +labels: 'enhancement' +assignees: '' + +--- + +### Description + + +### Describe the solution you'd like + + +### Describe any alternatives you've considered + + +### Additional context + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..0ce81da --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,22 @@ +# Pull Request + +## Type of Change + +- [ ] ๐Ÿ“– Documentation +- [ ] ๐Ÿชฒ Fix +- [ ] ๐Ÿฉน Patch +- [ ] โš ๏ธ Security Fix +- [ ] ๐Ÿš€ Feature +- [ ] ๐Ÿ’ฅ Breaking Change + +## Issue + + +## Description + + +## Checklist + +- [ ] ๐Ÿ•ต๏ธ I have reviewed my code for errors and tested it. +- [ ] ๐Ÿšฉ My pull request does not contain multiple types of changes. +- [ ] ๐Ÿ“„ By submitting this pull request, I confirm that my contribution is made under the terms of the projects associated license. diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..28d32dd --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,15 @@ +# Security Policy + +## Reporting a Vulnerability + +If you discover a vulnerability in PSPreworkout, please follow the _process_: + +1. Open a generic bug issue advising you have discovered a vulnerability. + - Avoid sharing specifics or details of the vulnerability in an open GitHub issue. +2. A repo owner will reach out to you to establish a private form of communication. +3. We will evaluate the vulnerability and, if necessary, release a fix or mitigating steps to address it. We will contact you to let you know the outcome, and will credit you in the report. + + Please **do not disclose the vulnerability publicly** until a fix is released! + +4. Once we have either a) published a fix, or b) declined to address the vulnerability for +whatever reason, you are free to publicly disclose it. diff --git a/.github/SUPPORT.md b/.github/SUPPORT.md new file mode 100644 index 0000000..20a5d38 --- /dev/null +++ b/.github/SUPPORT.md @@ -0,0 +1,9 @@ +# Support + +There is no express or implied warranty provided with this code. Please review and test before using in a production environment. + +If you have any questions, please use the [Discussions](https://github.com/SamErde/PSPrettier/discussions). + +If you have an issue that you believe may be fixable, please [submit an issue](https://github.com/SamErde/PSPrettier/issues). Pull requests are also always welcomed! + +๐Ÿ™ diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..cd23db0 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,62 @@ +# PowerShell Coding Standards +- Always use approved PowerShell verbs for function names (get, set, new, start, remove, update, etc.) +- Use Pascal case for all function names, variables, and parameters +- Follow OTBS (One True Brace Style) formatting +- Include one blank line at the end of every script +- Remove all trailing spaces +- Use proper cmdlet binding and parameter validation +- Always include comment-based help for functions + +# General Coding Guidelines +- Always add meaningful comments for complex logic +- Prefer explicit error handling over silent failures +- Include unit tests for all new functions + +# Response Preferences +- Include brief explanations of why a particular approach is recommended +- When suggesting refactoring, explain the benefits +- Provide both the solution and alternative approaches when applicable + +# Security Guidelines +- Never hardcode credentials or API keys +- Always validate input parameters +- Implement proper authentication and authorization checks + +# PowerShell Commit Message Template + +Generate commit messages for PowerShell projects using this format: + +`[optional scope]: ` + +Follow the GitMoji specifications at for +commit messages. Tailor commit messages for PowerShell development, using the provided types and scopes. + +## PowerShell-Specific Types: +- feat: โœจ New cmdlet, function, or module feature +- fix: ๐Ÿ› Bug fix in PowerShell code +- docs: ๐Ÿ“š Help documentation, comment-based help +- style: ๐ŸŽจ Code formatting, OTBS compliance, Pascal case fixes +- refactor: โ™ป๏ธ Code restructuring, approved verb compliance +- test: โœ… Pester tests, unit tests +- build: ๐Ÿ› ๏ธ Module manifest, build scripts +- ci: ๐Ÿค– Azure DevOps, GitHub Actions for PowerShell +- chore: ๐Ÿงน Module organization, file cleanup +- perf: โšก Performance improvements in cmdlets or functions +- revert: โช Reverting changes in PowerShell scripts or modules +- packaging: ๐Ÿ“ฆ Packaging changes, module version updates +- security: ๐Ÿ”’ Security-related changes, input validation, authentication + +## PowerShell Scopes: +- module: Module-level changes +- cmdlet: Specific cmdlet modifications +- function: Function updates +- help: Documentation changes +- manifest: Module manifest updates +- tests: Test-related changes + +## Examples: +โœจfeat(cmdlet): add Get-UserProfile with parameter validation +๐Ÿ›fix(function): resolve Invoke-ApiCall error handling +๐Ÿ“šdocs(help): update comment-based help for Set-Configuration +๐ŸŽจstyle(module): apply OTBS formatting and Pascal case +โœ…test(cmdlet): add Pester tests for Get-SystemInfo diff --git a/.github/workflows/PowerShell.yml b/.github/workflows/PowerShell.yml new file mode 100644 index 0000000..2ae0604 --- /dev/null +++ b/.github/workflows/PowerShell.yml @@ -0,0 +1,40 @@ +name: ๐Ÿ‘ฎโ€โ™‚๏ธ PSScriptAnalyzer + +on: + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + permissions: + contents: read # for actions/checkout to fetch code + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results + actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status + + name: ๐Ÿ‘ฎโ€โ™‚๏ธ PSScriptAnalyzer + runs-on: ubuntu-latest + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + steps: + - uses: actions/checkout@v4 + + - name: ๐Ÿ‘ฎโ€โ™‚๏ธ Run PSScriptAnalyzer + uses: microsoft/psscriptanalyzer-action@6b2948b1944407914a58661c49941824d149734f # v1.6.0 + with: + # Check https://github.com/microsoft/action-psscriptanalyzer for more info about the options. + # The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules. + path: ./ + recurse: true + # Include your own basic security rules. Removing this option will run all the rules + includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"' + output: results.sarif + + # Upload the SARIF file generated in the previous step + - name: โฌ†๏ธ Upload SARIF results file + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: results.sarif diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d034a39 --- /dev/null +++ b/.gitignore @@ -0,0 +1,96 @@ +# Created by https://www.toptal.com/developers/gitignore/api/linux,macos,windows,powershell,visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=linux,macos,windows,powershell,visualstudiocode + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Code Analysis Tools +.codacy/* + +# End of https://www.toptal.com/developers/gitignore/api/linux,macos,windows,powershell,visualstudiocode diff --git a/Build/PSPrettier.psd1 b/Build/PSPrettier.psd1 new file mode 100644 index 0000000..a8bcfc0 --- /dev/null +++ b/Build/PSPrettier.psd1 @@ -0,0 +1,139 @@ +# +# Module manifest for module 'PSPrettier' +# +# Generated by: SamErde +# +# Generated on: 8/6/2025 +# + +@{ + +# Script module or binary module file associated with this manifest. +RootModule = 'PSPrettier.psm1' + +# Version number of this module. +ModuleVersion = '0.0.1' + +# Supported PSEditions +# CompatiblePSEditions = @() + +# ID used to uniquely identify this module +GUID = 'ac7cc63f-dc52-4193-83d2-c231eebf76dd' + +# Author of this module +Author = 'SamErde' + +# Company or vendor of this module +CompanyName = 'Unknown' + +# Copyright statement for this module +Copyright = '(c) SamErde. All rights reserved.' + +# Description of the functionality provided by this module +# Description = '' + +# Minimum version of the PowerShell engine required by this module +PowerShellVersion = '5.1.0' + +# Name of the PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# DotNetFrameworkVersion = '' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# ClrVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +# RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = 'Invoke-Prettier' + +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = @() + +# Variables to export from this module +# VariablesToExport = @() + +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = @() + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = 'CrescendoBuilt' + + # A URL to the license for this module. + # LicenseUri = '' + + # A URL to the main website for this project. + # ProjectUri = '' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + # Prerelease string of this module + # Prerelease = '' + + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false + + # External dependent modules of this module + # ExternalModuleDependencies = @() + + } # End of PSData hashtable + + + # CrescendoVersion + CrescendoVersion = '1.1.0' + + # CrescendoGenerated + CrescendoGenerated = '08/06/2025 09:06:34' + +} # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + diff --git a/Build/PSPrettier.psm1 b/Build/PSPrettier.psm1 new file mode 100644 index 0000000..33a706b --- /dev/null +++ b/Build/PSPrettier.psm1 @@ -0,0 +1,380 @@ +# Module created by Microsoft.PowerShell.Crescendo +# Version: 1.1.0 +# Schema: https://aka.ms/PowerShell/Crescendo/Schemas/2021-11 +# Generated at: 08/06/2025 09:06:34 +class PowerShellCustomFunctionAttribute : System.Attribute { + [bool]$RequiresElevation + [string]$Source + PowerShellCustomFunctionAttribute() { $this.RequiresElevation = $false; $this.Source = "Microsoft.PowerShell.Crescendo" } + PowerShellCustomFunctionAttribute([bool]$rElevation) { + $this.RequiresElevation = $rElevation + $this.Source = "Microsoft.PowerShell.Crescendo" + } +} + +# Returns available errors +# Assumes that we are being called from within a script cmdlet when EmitAsError is used. +function Pop-CrescendoNativeError { +param ([switch]$EmitAsError) + while ($__CrescendoNativeErrorQueue.Count -gt 0) { + if ($EmitAsError) { + $msg = $__CrescendoNativeErrorQueue.Dequeue() + $er = [System.Management.Automation.ErrorRecord]::new([system.invalidoperationexception]::new($msg), $PSCmdlet.Name, "InvalidOperation", $msg) + $PSCmdlet.WriteError($er) + } + else { + $__CrescendoNativeErrorQueue.Dequeue() + } + } +} +# this is purposefully a filter rather than a function for streaming errors +filter Push-CrescendoNativeError { + if ($_ -is [System.Management.Automation.ErrorRecord]) { + $__CrescendoNativeErrorQueue.Enqueue($_) + } + else { + $_ + } +} + +function Invoke-Prettier +{ +[PowerShellCustomFunctionAttribute(RequiresElevation=$False)] +[CmdletBinding()] + +param( +[Parameter(Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] +[string]$Path, +[Parameter()] +[switch]$Write, +[Parameter()] +[switch]$Check, +[Parameter()] +[string]$Config, +[Parameter()] +[string]$IgnorePath, +[Parameter()] +[string]$LogLevel, +[Parameter()] +[string]$Parser, +[Parameter()] +[string]$Plugin, +[Parameter()] +[int]$TabWidth, +[Parameter()] +[switch]$UseTabs, +[Parameter()] +[switch]$SingleQuote, +[Parameter()] +[switch]$Semi, +[Parameter()] +[int]$PrintWidth, +[Parameter()] +[switch]$Stdin + ) + +BEGIN { + $PSNativeCommandUseErrorActionPreference = $false + $__CrescendoNativeErrorQueue = [System.Collections.Queue]::new() + $__PARAMETERMAP = @{ + Path = @{ + OriginalName = '' + OriginalPosition = '0' + Position = '0' + ParameterType = 'string' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '$args' + ArgumentTransformType = 'inline' + } + Write = @{ + OriginalName = '--write' + OriginalPosition = '0' + Position = '2147483647' + ParameterType = 'switch' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '$args' + ArgumentTransformType = 'inline' + } + Check = @{ + OriginalName = '--check' + OriginalPosition = '0' + Position = '2147483647' + ParameterType = 'switch' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '$args' + ArgumentTransformType = 'inline' + } + Config = @{ + OriginalName = '--config' + OriginalPosition = '0' + Position = '2147483647' + ParameterType = 'string' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '$args' + ArgumentTransformType = 'inline' + } + IgnorePath = @{ + OriginalName = '--ignore-path' + OriginalPosition = '0' + Position = '2147483647' + ParameterType = 'string' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '$args' + ArgumentTransformType = 'inline' + } + LogLevel = @{ + OriginalName = '--loglevel' + OriginalPosition = '0' + Position = '2147483647' + ParameterType = 'string' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '[string[]]@(''error'',''warn'',''info'',''debug'')' + ArgumentTransformType = 'inline' + } + Parser = @{ + OriginalName = '--parser' + OriginalPosition = '0' + Position = '2147483647' + ParameterType = 'string' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '[string[]]@(''babel'',''typescript'',''json'',''json5'',''css'',''scss'',''less'',''html'',''vue'',''yaml'',''markdown'',''graphql'',''mdx'',''handlebars'',''angular'',''lwc'')' + ArgumentTransformType = 'inline' + } + Plugin = @{ + OriginalName = '--plugin' + OriginalPosition = '0' + Position = '2147483647' + ParameterType = 'string' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '[string[]]@(''@prettier/plugin-xml'',''prettier-plugin-tailwindcss'',''prettier-plugin-organize-imports'')' + ArgumentTransformType = 'inline' + } + TabWidth = @{ + OriginalName = '--tab-width' + OriginalPosition = '0' + Position = '2147483647' + ParameterType = 'int' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '$args' + ArgumentTransformType = 'inline' + } + UseTabs = @{ + OriginalName = '--use-tabs' + OriginalPosition = '0' + Position = '2147483647' + ParameterType = 'switch' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '$args' + ArgumentTransformType = 'inline' + } + SingleQuote = @{ + OriginalName = '--single-quote' + OriginalPosition = '0' + Position = '2147483647' + ParameterType = 'switch' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '$args' + ArgumentTransformType = 'inline' + } + Semi = @{ + OriginalName = '--no-semi' + OriginalPosition = '0' + Position = '2147483647' + ParameterType = 'switch' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '$args' + ArgumentTransformType = 'inline' + } + PrintWidth = @{ + OriginalName = '--print-width' + OriginalPosition = '0' + Position = '2147483647' + ParameterType = 'int' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '$args' + ArgumentTransformType = 'inline' + } + Stdin = @{ + OriginalName = '--stdin' + OriginalPosition = '0' + Position = '2147483647' + ParameterType = 'switch' + ApplyToExecutable = $False + NoGap = $False + ArgumentTransform = '$args' + ArgumentTransformType = 'inline' + } + } + + $__outputHandlers = @{ + Default = @{ StreamOutput = $False; Handler = { Write-Output $args[0] } } + } +} + +PROCESS { + $__boundParameters = $PSBoundParameters + $__defaultValueParameters = $PSCmdlet.MyInvocation.MyCommand.Parameters.Values.Where({$_.Attributes.Where({$_.TypeId.Name -eq "PSDefaultValueAttribute"})}).Name + $__defaultValueParameters.Where({ !$__boundParameters["$_"] }).ForEach({$__boundParameters["$_"] = get-variable -value $_}) + $__commandArgs = @() + $MyInvocation.MyCommand.Parameters.Values.Where({$_.SwitchParameter -and $_.Name -notmatch "Debug|Whatif|Confirm|Verbose" -and ! $__boundParameters[$_.Name]}).ForEach({$__boundParameters[$_.Name] = [switch]::new($false)}) + if ($__boundParameters["Debug"]){wait-debugger} + foreach ($paramName in $__boundParameters.Keys| + Where-Object {!$__PARAMETERMAP[$_].ApplyToExecutable}| + Where-Object {!$__PARAMETERMAP[$_].ExcludeAsArgument}| + Sort-Object {$__PARAMETERMAP[$_].OriginalPosition}) { + $value = $__boundParameters[$paramName] + $param = $__PARAMETERMAP[$paramName] + if ($param) { + if ($value -is [switch]) { + if ($value.IsPresent) { + if ($param.OriginalName) { $__commandArgs += $param.OriginalName } + } + elseif ($param.DefaultMissingValue) { $__commandArgs += $param.DefaultMissingValue } + } + elseif ( $param.NoGap ) { + # if a transform is specified, use it and the construction of the values is up to the transform + if($param.ArgumentTransform -ne '$args') { + $transform = $param.ArgumentTransform + if($param.ArgumentTransformType -eq 'inline') { + $transform = [scriptblock]::Create($param.ArgumentTransform) + } + $__commandArgs += & $transform $value + } + else { + $pFmt = "{0}{1}" + # quote the strings if they have spaces + if($value -match "\s") { $pFmt = "{0}""{1}""" } + $__commandArgs += $pFmt -f $param.OriginalName, $value + } + } + else { + if($param.OriginalName) { $__commandArgs += $param.OriginalName } + if($param.ArgumentTransformType -eq 'inline') { + $transform = [scriptblock]::Create($param.ArgumentTransform) + } + else { + $transform = $param.ArgumentTransform + } + $__commandArgs += & $transform $value + } + } + } + $__commandArgs = $__commandArgs | Where-Object {$_ -ne $null} + if ($__boundParameters["Debug"]){wait-debugger} + if ( $__boundParameters["Verbose"]) { + Write-Verbose -Verbose -Message "prettier" + $__commandArgs | Write-Verbose -Verbose + } + $__handlerInfo = $__outputHandlers[$PSCmdlet.ParameterSetName] + if (! $__handlerInfo ) { + $__handlerInfo = $__outputHandlers["Default"] # Guaranteed to be present + } + $__handler = $__handlerInfo.Handler + if ( $PSCmdlet.ShouldProcess("prettier $__commandArgs")) { + # check for the application and throw if it cannot be found + if ( -not (Get-Command -ErrorAction Ignore "prettier")) { + throw "Cannot find executable 'prettier'" + } + if ( $__handlerInfo.StreamOutput ) { + if ( $null -eq $__handler ) { + & "prettier" $__commandArgs + } + else { + & "prettier" $__commandArgs 2>&1| Push-CrescendoNativeError | & $__handler + } + } + else { + $result = & "prettier" $__commandArgs 2>&1| Push-CrescendoNativeError + & $__handler $result + } + } + # be sure to let the user know if there are any errors + Pop-CrescendoNativeError -EmitAsError + } # end PROCESS + +<# + + +.DESCRIPTION +Format files using Prettier + +.PARAMETER Path +File(s) or directory to format + + +.PARAMETER Write +Edit files in-place + + +.PARAMETER Check +Check if files are formatted + + +.PARAMETER Config +Path to a Prettier configuration file + + +.PARAMETER IgnorePath +Path to .prettierignore file + + +.PARAMETER LogLevel +Log level (error, warn, info, debug) + + +.PARAMETER Parser +Parser to use (babel, typescript, json, html, etc.) + + +.PARAMETER Plugin +Add a plugin (e.g., @prettier/plugin-xml) + + +.PARAMETER TabWidth +Number of spaces per indentation level + + +.PARAMETER UseTabs +Indent with tabs instead of spaces + + +.PARAMETER SingleQuote +Use single quotes instead of double quotes + + +.PARAMETER Semi +Do not print semicolons at the ends of statements + + +.PARAMETER PrintWidth +Line length that Prettier will wrap on + + +.PARAMETER Stdin +Read input from stdin + + + +.EXAMPLE +PS> prettier + +Formats the specified file in-place using Prettier. + + +#> +} + +