Skip to content

Commit

Permalink
Merge pull request #14 from ShaunLawrie/prerelease
Browse files Browse the repository at this point in the history
Prerelease
  • Loading branch information
ShaunLawrie authored Dec 8, 2023
2 parents 0916f08 + a8f5e62 commit b78743e
Show file tree
Hide file tree
Showing 91 changed files with 2,340 additions and 2,089 deletions.
38 changes: 35 additions & 3 deletions .github/workflows/build-test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Publish to PSGallery
env:
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}
on:
workflow_dispatch:
push:
branches:
- main
- prerelease

permissions:
contents: write
Expand All @@ -14,17 +14,19 @@ jobs:
publish-to-psgallery:
name: Publish
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Version Bump
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
& .\PwshSpectreConsole\Build.ps1
$env:PSModulePath = @($env:PSModulePath, ".\PwshSpectreConsole\") -join ":"
$version = Get-Module PwshSpectreConsole -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1 -ExpandProperty Version
if($null -eq $version) { throw "Failed to load version" }
$newVersion = [version]::new($version.Major, $version.Minor, $version.Build + 1)
$newVersion = [version]::new($version.Major, $version.Minor + 1, 0)
Write-Host "Bumping version from $version to $newVersion"
Update-ModuleManifest -Path .\PwshSpectreConsole\PwshSpectreConsole.psd1 -ModuleVersion $newVersion
git config --global user.name 'Shaun Lawrie (via GitHub Actions)'
Expand All @@ -33,8 +35,38 @@ jobs:
git commit -m "[skip ci] Bump version to $newVersion"
git push
- name: Deploy Package
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
Publish-Module -Path "./PwshSpectreConsole/" -Exclude "Build.ps1" -NugetApiKey $env:PSGALLERY_API_KEY
publish-prerelease-to-psgallery:
name: Publish Prerelease
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/prerelease'
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Version Bump and Publish
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
& ./PwshSpectreConsole/Build.ps1
Publish-Module -Path "./PwshSpectreConsole/" -NugetApiKey $env:PSGALLERY_API_KEY
$env:PSModulePath = @($env:PSModulePath, ".\PwshSpectreConsole\") -join ":"
$version = Get-Module PwshSpectreConsole -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1 -ExpandProperty Version
if($null -eq $version) { throw "Failed to load version" }
$newVersion = [version]::new($version.Major, $version.Minor, $version.Build + 1)
Write-Host "Bumping version from $version to $newVersion"
Update-ModuleManifest -Path .\PwshSpectreConsole\PwshSpectreConsole.psd1 -ModuleVersion $newVersion
git config --global user.name 'Shaun Lawrie (via GitHub Actions)'
git config --global user.email '[email protected]'
git add PwshSpectreConsole/PwshSpectreConsole.psd1
git commit -m "[skip ci] Bump version to $newVersion"
git push
# Mark as prerelease
Update-ModuleManifest -Path .\PwshSpectreConsole\PwshSpectreConsole.psd1 -PrivateData @{ Prerelease = 'prerelease' }
# Publish pre-release version
Import-Module .\PwshSpectreConsole\PwshSpectreConsole.psd1 -Force
Publish-Module -Name PwshSpectreConsole -Exclude "Build.ps1" -NugetApiKey $env:PSGALLERY_API_KEY -AllowPrerelease
4 changes: 3 additions & 1 deletion .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Publish Doc Site

on:
workflow_dispatch:
push:
branches:
- main

permissions:
contents: write
Expand Down
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "PowerShell Launch Current File",
"type": "PowerShell",
"request": "launch",
"script": "${file}",
"cwd": "${cwd}"
},
{
"command": "./node_modules/.bin/astro dev",
"cwd": "${workspaceFolder}/PwshSpectreConsole.Docs",
Expand Down
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
{
}
"powershell.codeFormatting.preset": "OTBS",
"editor.formatOnPaste": false,
"editor.formatOnSave": false,
"editor.formatOnType": false
}
58 changes: 52 additions & 6 deletions PwshSpectreConsole.Docs/UpdateDocs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,45 @@ param(

$ErrorActionPreference = "Stop"

Remove-Module -Name PwshSpectreConsole -ErrorAction SilentlyContinue
Import-Module "$PSScriptRoot\..\PwshSpectreConsole\PwshSpectreConsole.psd1" -Force
Remove-Item -Recurse -Path "$PSScriptRoot\src\content\docs\reference\*" -Force
Get-Module PwshSpectreConsole | Save-MarkdownHelp -OutputPath "$PSScriptRoot\src\content\docs\reference\" -IncludeYamlHeader -YamlHeaderInformationType Metadata -ExcludeFile "*.gif", "*.png"
$module = Get-Module PwshSpectreConsole

if($null -eq $module) {
throw "Failed to import PwshSpectreConsole module"
}

$module | Save-MarkdownHelp -OutputPath "$PSScriptRoot\src\content\docs\reference\" -IncludeYamlHeader -YamlHeaderInformationType Metadata -ExcludeFile "*.gif", "*.png"

$new = @("New-SpectreChartItem.md", "Get-SpectreDemoColors.md", "Get-SpectreDemoEmoji.md")
$experimental = @("Get-SpectreImageExperimental.md", "Invoke-SpectreScriptBlockQuietly.md")

$newTag = @"
sidebar:
badge:
text: New
variant: tip
"@

$experimentalTag = @"
sidebar:
badge:
text: Experimental
variant: caution
"@

# Post-processing for astro stuff
$groups = @(
@{ Name = "Prompts"; Matches = @("read-") }
@{ Name = "Formatting"; Matches = @("format-") }
@{ Name = "Progress"; Matches = @("invoke-", "job") }
@{ Name = "Formatting"; Matches = @("format-", "chartitem") }
@{ Name = "Progress"; Matches = @("invoke-", "job", "spectrescriptblock") }
@{ Name = "Images"; Matches = @("image") }
@{ Name = "Writing"; Matches = @("write-", "escaped") }
@{ Name = "Config"; Matches = @("set-") }
@{ Name = "Demo"; Matches = @("spectredemo") }
)
$remove = @("Start-SpectreDemo.md")

$docs = Get-ChildItem "$PSScriptRoot\src\content\docs\reference\" -Filter "*.md" -Recurse
foreach($doc in $docs) {
if($remove -contains $doc.Name) {
Expand All @@ -43,19 +68,40 @@ foreach($doc in $docs) {
New-Item -ItemType Directory -Path "$PSScriptRoot\src\content\docs\reference\$($group.Name)" -Force | Out-Null
$content = Get-Content $doc.FullName -Raw
Remove-Item $doc.FullName
$content -replace '```PowerShell', '```powershell' -replace '(?m)^.+\n^[\-]{10,99}', '' | Out-File $outLocation
$content = $content -replace '```PowerShell', '```powershell' -replace '(?m)^.+\n^[\-]{10,99}', ''
if($experimental -contains $doc.Name) {
$content = $content -replace '(?s)^---', "---`n$experimentalTag"
} elseif($new -contains $doc.Name) {
$content = $content -replace '(?s)^---', "---`n$newTag"
}
$content | Out-File $outLocation
}

# Build the docs site
npm ci --prefix $PSScriptRoot
if($LASTEXITCODE -ne 0) {
throw "Failed to install npm dependencies"
}

npm run build --prefix $PSScriptRoot
if($LASTEXITCODE -ne 0) {
throw "Failed to run npm build"
}

if($NonInteractive) {
return
}

# Deploy to preview
if(npx --yes wrangler whoami | Where-Object { $_ -like "*You are logged in*" }) {
Write-Host "Already logged into cloudflare"
} else {
npx wrangler login
}
npx wrangler pages deploy "$PSScriptRoot\dist" --project-name pwshspectreconsole --commit-dirty=true --branch=test

# Yeet it to cloudflare
$choice = Read-Host "`nDeploy to CF pages? (y/n)"
$choice = Read-Host "`nDeploy to Prod CF pages? (y/n)"
if($choice -eq "y") {
if(npx wrangler whoami | Where-Object { $_ -like "*You are logged in*" }) {
Write-Host "Already logged into cloudflare"
Expand Down
1 change: 0 additions & 1 deletion PwshSpectreConsole.Docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default defineConfig({
label: "Command Reference",
autogenerate: {
directory: "reference",
collapsed: true,
},
},
],
Expand Down
Binary file added PwshSpectreConsole.Docs/public/accentcolor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PwshSpectreConsole.Docs/public/barchart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PwshSpectreConsole.Docs/public/breakdownchart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PwshSpectreConsole.Docs/public/colors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PwshSpectreConsole.Docs/public/defaultcolor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PwshSpectreConsole.Docs/public/emoji.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PwshSpectreConsole.Docs/public/panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PwshSpectreConsole.Docs/public/table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PwshSpectreConsole.Docs/public/withsetup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions PwshSpectreConsole.Docs/src/components/TerminalPreview.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const { speed } = Astro.props;
---

<animated-terminal class="mt-0" data-speed={speed}>
<div class="mt-6" data-terminal-frame>

<div class="mt-6 overflow-hidden" data-terminal-frame>
<pre class="font-mono bg-slate-50 dark:bg-slate-950">
What's for <span class="text-pink-500">dinner</span>?
&nbsp;
Expand All @@ -13,7 +14,8 @@ What's for <span class="text-pink-500">dinner</span>?
&nbsp;
<span class="text-slate-600">(Move up and down to reveal more choices)</span></pre>
</div>
<div class="mt-6 hidden" data-terminal-frame>

<div class="mt-6 overflow-hidden hidden" data-terminal-frame>
<pre class="font-mono bg-slate-50 dark:bg-slate-950">
What's for <span class="text-pink-500">dinner</span>?
&nbsp;
Expand All @@ -23,7 +25,8 @@ What's for <span class="text-pink-500">dinner</span>?
&nbsp;
<span class="text-slate-600">(Move up and down to reveal more choices)</span></pre>
</div>
<div class="mt-6 hidden" data-terminal-frame>

<div class="mt-6 overflow-hidden hidden" data-terminal-frame>
<pre class="font-mono bg-slate-50 dark:bg-slate-950">
What's for <span class="text-pink-500">dinner</span>?
&nbsp;
Expand All @@ -33,7 +36,8 @@ What's for <span class="text-pink-500">dinner</span>?
&nbsp;
<span class="text-slate-600">(Move up and down to reveal more choices)</span></pre>
</div>
<div class="mt-6 hidden" data-terminal-frame>

<div class="mt-6 overflow-hidden hidden" data-terminal-frame>
<pre class="font-mono bg-slate-50 dark:bg-slate-950">
What's for <span class="text-pink-500">dinner</span>?
&nbsp;
Expand All @@ -43,6 +47,7 @@ What's for <span class="text-pink-500">dinner</span>?
&nbsp;
<span class="text-slate-600">(Move up and down to reveal more choices)</span></pre>
</div>

</animated-terminal>

<script>
Expand Down
24 changes: 19 additions & 5 deletions PwshSpectreConsole.Docs/src/content/docs/guides/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,28 @@ description: Get started with PwshSpectre Console.

PwshSpectreConsole is a wrapper for the awesome [Spectre Console](https://spectreconsole.net/) which you can use to make your PowerShell scripts more interesting.

Install PwshSpectreConsole from <a class="not-content" href="https://www.powershellgallery.com/packages/PwshSpectreConsole"><img class="align-middle not-content" src="https://img.shields.io/powershellgallery/v/PwshSpectreConsole" /></a> using the following command in your terminal:
Install PwshSpectreConsole from PSGallery using the following command in your terminal (this requires PowerShell 7+):

```powershell
Install-Module PwshSpectreConsole -Scope CurrentUser
```

To get the best experience, you should also follow the [instructions on the official Spectre Console site to configure Windows Terminal for full Unicode and Emoji support](https://spectreconsole.net/best-practices#configuring-the-windows-terminal-for-unicode-and-emoji-support).
<a class="not-content" href="https://www.powershellgallery.com/packages/PwshSpectreConsole"><img class="not-content" src="https://img.shields.io/powershellgallery/v/PwshSpectreConsole?&color=%238acc00" /></a>
<a class="not-content" href="https://www.powershellgallery.com/packages/PwshSpectreConsole"><img class="not-content" src="https://img.shields.io/powershellgallery/dt/PwshSpectreConsole?&color=%238acc00" /></a>
<a class="not-content" href="https://github.com/ShaunLawrie/PwshSpectreConsole"><img class="not-content" src="https://img.shields.io/github/stars/ShaunLawrie/PwshSpectreConsole?&color=%238acc00" /></a>

:::caution
This requires PowerShell 7.0 or later. You can check your PowerShell version by running `$PSVersionTable.PSVersion` in your terminal.
:::

### 👻 Emoji Support and Line Drawing

With the default configuration Windows Terminal and the older console host don't support the full range of Spectre Console features. It will still work but you will find it doesn't look quite like all the examples.
![Old terminal setup showing missing rendering features](/withoutsetup.png)

To get the full feature set:

1. Use Windows Terminal instead of the old console host.
2. Install a NerdFont, a font with additional visual characters. I use "Cascadia Cove NF" from [https://www.nerdfonts.com/](https://www.nerdfonts.com/)
3. Enable full unicode by adding `$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding` as the **FIRST LINE** in your $PROFILE file.

![New terminal setup showing full rendering features](/withsetup.png)

For more details see the [instructions on the official Spectre Console site to configure Windows Terminal for full Unicode and Emoji support](https://spectreconsole.net/best-practices#configuring-the-windows-terminal-for-unicode-and-emoji-support).
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,23 @@ title: Set-SpectreColors







### Synopsis
Sets the accent color and default value color for Spectre Console.



---


### Description

This function sets the accent color and default value color for Spectre Console. The accent color is used for highlighting important information, while the default value color is used for displaying default values.

An example of the accent color is the highlight used in `Read-SpectreSelection`:
![Accent color example](/accentcolor.png)

An example of the default value color is the default value displayed in `Read-SpectreText`:
![Default value color example](/defaultcolor.png)

---


### Examples
Sets the accent color to Red and the default value color to Yellow.

Expand All @@ -37,46 +33,25 @@ Sets the accent color to Green and keeps the default value color as Grey.
Set-SpectreColors -AccentColor Green
```


---


### Parameters
#### **AccentColor**

The accent color to set. Must be a valid Spectre Console color name. Defaults to "Blue".






|Type |Required|Position|PipelineInput|
|----------|--------|--------|-------------|
|`[String]`|false |1 |false |



#### **DefaultValueColor**

The default value color to set. Must be a valid Spectre Console color name. Defaults to "Grey".






|Type |Required|Position|PipelineInput|
|----------|--------|--------|-------------|
|`[String]`|false |2 |false |





---


### Syntax
```powershell
Set-SpectreColors [[-AccentColor] <String>] [[-DefaultValueColor] <String>] [<CommonParameters>]
Expand Down
Loading

0 comments on commit b78743e

Please sign in to comment.