diff --git a/.github/PSModule.yml b/.github/PSModule.yml index 60d3f27..6276b1b 100644 --- a/.github/PSModule.yml +++ b/.github/PSModule.yml @@ -16,9 +16,9 @@ Test: # Skip: true # MacOS: # Skip: true -# Build: -# Docs: -# Skip: true +Build: + Site: + Skip: true Linter: env: diff --git a/.github/mkdocs.yml b/.github/mkdocs.yml deleted file mode 100644 index df5e17a..0000000 --- a/.github/mkdocs.yml +++ /dev/null @@ -1,75 +0,0 @@ -site_name: -{{ REPO_NAME }}- -theme: - name: material - language: en - font: - text: Roboto - code: Sono - logo: Assets/icon.png - favicon: Assets/icon.png - palette: - # Palette toggle for automatic mode - - media: "(prefers-color-scheme)" - toggle: - icon: material/link - name: Switch to dark mode - # Palette toggle for dark mode - - media: '(prefers-color-scheme: dark)' - scheme: slate - toggle: - primary: black - accent: green - icon: material/toggle-switch-off-outline - name: Switch to light mode - # Palette toggle for light mode - - media: '(prefers-color-scheme: light)' - scheme: default - toggle: - primary: indigo - accent: green - icon: material/toggle-switch - name: Switch to system preference - icon: - repo: material/github - features: - - navigation.instant - - navigation.instant.progress - - navigation.indexes - - navigation.top - - navigation.tracking - - navigation.expand - - search.suggest - - search.highlight - -repo_name: -{{ REPO_OWNER }}-/-{{ REPO_NAME }}- -repo_url: https://github.com/-{{ REPO_OWNER }}-/-{{ REPO_NAME }}- - -plugins: - - search - -markdown_extensions: - - toc: - permalink: true # Adds a link icon to headings - - attr_list - - admonition - - md_in_html - - pymdownx.details # Enables collapsible admonitions - -extra: - social: - - icon: fontawesome/brands/discord - link: https://discord.gg/jedJWCPAhD - name: -{{ REPO_OWNER }}- on Discord - - icon: fontawesome/brands/github - link: https://github.com/-{{ REPO_OWNER }}-/ - name: -{{ REPO_OWNER }}- on GitHub - consent: - title: Cookie consent - description: >- - We use cookies to recognize your repeated visits and preferences, as well - as to measure the effectiveness of our documentation and whether users - find what they're searching for. With your consent, you're helping us to - make our documentation better. - actions: - - accept - - reject diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index 67f2c25..023f2c0 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -27,5 +27,6 @@ permissions: jobs: Process-PSModule: - uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@11117919e65242d3388727819a751f74ad24ea9e # v5.5.0 - secrets: inherit + uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@1653be8d36607d9535f600278c44789979477813 # v6.1.16 + secrets: + APIKey: ${{ secrets.APIKey }} diff --git a/.github/workflows/Update-FontsData.yml b/.github/workflows/Update-FontsData.yml index 9b1b812..504fba7 100644 --- a/.github/workflows/Update-FontsData.yml +++ b/.github/workflows/Update-FontsData.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false diff --git a/.github/zensical.toml b/.github/zensical.toml new file mode 100644 index 0000000..f5abd9e --- /dev/null +++ b/.github/zensical.toml @@ -0,0 +1,71 @@ +[project] +site_name = "-{{ REPO_NAME }}-" +repo_name = "-{{ REPO_OWNER }}-/-{{ REPO_NAME }}-" +repo_url = "https://github.com/-{{ REPO_OWNER }}-/-{{ REPO_NAME }}-" + +[project.theme] +variant = "classic" +language = "en" +font.text = "Roboto" +font.code = "Sono" +logo = "Assets/icon.png" +favicon = "Assets/icon.png" +features = [ + "navigation.instant", + "navigation.instant.progress", + "navigation.indexes", + "navigation.top", + "navigation.tracking", + "navigation.expand", + "search.suggest", + "search.highlight", + "content.code.copy" +] + +[[project.theme.palette]] +media = "(prefers-color-scheme)" +toggle.icon = "material/link" +toggle.name = "Switch to dark mode" + +[[project.theme.palette]] +media = "(prefers-color-scheme: dark)" +scheme = "slate" +primary = "black" +accent = "green" +toggle.icon = "material/toggle-switch-off-outline" +toggle.name = "Switch to light mode" + +[[project.theme.palette]] +media = "(prefers-color-scheme: light)" +scheme = "default" +primary = "indigo" +accent = "green" +toggle.icon = "material/toggle-switch" +toggle.name = "Switch to system preference" + +[project.theme.icon] +repo = "material/github" + +[project.markdown_extensions.toc] +permalink = true + +[project.markdown_extensions.attr_list] +[project.markdown_extensions.admonition] +[project.markdown_extensions.md_in_html] +[project.markdown_extensions."pymdownx.details"] +[project.markdown_extensions."pymdownx.superfences"] + +[[project.extra.social]] +icon = "fontawesome/brands/discord" +link = "https://discord.gg/jedJWCPAhD" +name = "-{{ REPO_OWNER }}- on Discord" + +[[project.extra.social]] +icon = "fontawesome/brands/github" +link = "https://github.com/-{{ REPO_OWNER }}-/" +name = "-{{ REPO_OWNER }}- on GitHub" + +[project.extra.consent] +title = "Cookie consent" +description = "We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better." +actions = ["accept", "reject"] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..3830a19 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,41 @@ +# Contributing to NerdFonts + +Thank you for your interest in contributing! This repository is part of the +[PSModule](https://github.com/PSModule) framework and follows the shared +contribution guidelines. + +## Getting started + +1. Read the repository [README](README.md) to understand what the module does + and how it is built. +2. Familiarize yourself with the PSModule framework documentation at + . + +## How to contribute + +- **Bug reports and feature requests:** open a [GitHub issue](../../issues). +- **Code changes:** open a [pull request](../../pulls). +- **Keep changes small and focused.** Each pull request should address one + concern. +- **Open draft pull requests early** so maintainers can provide feedback while + work is in progress. + +## Repository conventions + +- Source code lives in `src/`. +- Tests live in `tests/` and are run with [Pester](https://pester.dev/). +- The module manifest is generated by the + [Process-PSModule](https://github.com/PSModule/Process-PSModule) workflow. +- Commit messages should be short and specific. + +## Development + +```powershell +Import-Module ./src +Invoke-Pester +``` + +## Code of conduct + +Be respectful and constructive. We want this project to be welcoming for +everyone. diff --git a/README.md b/README.md index 4e5bf49..e39da46 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,15 @@ To uninstall a NerdFont for all users (requires elevated privileges): Uninstall-Font -Name 'FiraCode*' -Scope AllUsers ``` +## Documentation + +Every command has full reference documentation, generated from its comment-based help and published at [psmodule.io/NerdFonts](https://psmodule.io/NerdFonts/). Explore the commands and read detailed help directly from PowerShell: + +```powershell +Get-Command -Module NerdFonts +Get-Help -Name Install-NerdFont -Examples +``` + ## Contributing Coder or not, you can contribute to the project! We welcome all contributions. diff --git a/src/functions/public/Get-NerdFont.ps1 b/src/functions/public/Get-NerdFont.ps1 index 4e1537a..933aacb 100644 --- a/src/functions/public/Get-NerdFont.ps1 +++ b/src/functions/public/Get-NerdFont.ps1 @@ -22,7 +22,7 @@ Get the NerdFont with the name ending with 'Code'. .LINK - https://psmodule.io/NerdFonts/Functions/Get-NerdFont + https://psmodule.io/NerdFonts/Functions/Get-NerdFont/ .NOTES More information about the NerdFonts can be found at: diff --git a/src/functions/public/Install-NerdFont.ps1 b/src/functions/public/Install-NerdFont.ps1 index 94c3b39..5d36eda 100644 --- a/src/functions/public/Install-NerdFont.ps1 +++ b/src/functions/public/Install-NerdFont.ps1 @@ -1,5 +1,5 @@ -#Requires -Modules @{ ModuleName = 'Fonts'; RequiredVersion = '1.1.21' } -#Requires -Modules @{ ModuleName = 'Admin'; RequiredVersion = '1.1.6' } +#Requires -Modules @{ ModuleName = 'Fonts'; ModuleVersion = '1.1.27'; MaximumVersion = '1.999.999' } +#Requires -Modules @{ ModuleName = 'Admin'; ModuleVersion = '1.1.13'; MaximumVersion = '1.999.999' } function Install-NerdFont { <# @@ -40,7 +40,7 @@ function Install-NerdFont { Installs only the monospace variant of all Nerd Fonts to the current user. .LINK - https://psmodule.io/NerdFonts/Functions/Install-NerdFont + https://psmodule.io/NerdFonts/Functions/Install-NerdFont/ .NOTES More information about the NerdFonts can be found at: @@ -95,7 +95,7 @@ Please run the command again with elevated rights (Run as Administrator) or prov $seenNames = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase) $guid = (New-Guid).Guid - $tempPath = Join-Path -Path $HOME -ChildPath "NerdFonts-$guid" + $tempPath = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath "NerdFonts-$guid" if (-not (Test-Path -Path $tempPath -PathType Container)) { Write-Verbose "Create folder [$tempPath]" $null = New-Item -Path $tempPath -ItemType Directory diff --git a/tests/NerdFonts.Tests.ps1 b/tests/NerdFonts.Tests.ps1 index 5d0fb06..515e3c7 100644 --- a/tests/NerdFonts.Tests.ps1 +++ b/tests/NerdFonts.Tests.ps1 @@ -265,25 +265,36 @@ Describe 'Module' { $script:NerdFonts = $fonts } + $fileLock = $null try { - # Place a regular placeholder file so Test-Path returns true for cache-hit detection + # Lock the cached file with an exclusive share so Copy-Item fails, forcing the + # function to fall back to a real download using live test data. if (-not (Test-Path -LiteralPath $cacheTagDir)) { $null = New-Item -ItemType Directory -Path $cacheTagDir -Force } - Set-Content -LiteralPath $cachedFile -Value 'placeholder' + if (Test-Path -LiteralPath $cachedFile) { + Remove-Item -LiteralPath $cachedFile -Recurse -Force -ErrorAction SilentlyContinue + } + Set-Content -LiteralPath $cachedFile -Value 'locked-cache-entry' -Force + $fileLock = [System.IO.File]::Open( + $cachedFile, + [System.IO.FileMode]::Open, + [System.IO.FileAccess]::Read, + [System.IO.FileShare]::None + ) Mock -ModuleName NerdFonts Get-Font { @() } Mock -ModuleName NerdFonts Install-Font {} - # Mock Copy-Item to throw only for the cache-read path, simulating - # a locked/unreadable cached file cross-platform. - Mock -ModuleName NerdFonts Copy-Item { - throw 'Simulated cache read failure' - } -ParameterFilter { $LiteralPath -and $LiteralPath -eq $cachedFile } # Should not throw — falls back to download { Install-NerdFont -Name $fontName -Force:$false -ErrorAction Stop } | Should -Not -Throw Should -Invoke -ModuleName NerdFonts Install-Font -Times 1 -Exactly } finally { + # Release the lock before restoring cache state. + if ($fileLock) { + $fileLock.Dispose() + $fileLock = $null + } # Restore original cache state so no user/CI state is mutated if ($hadExistingCache) { Move-Item -LiteralPath $backupPath -Destination $cachedFile -Force -ErrorAction SilentlyContinue