diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 6221b1e..fbd2795 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -66,7 +66,7 @@ Custom xUnit attributes are sometimes used for conditional test execution: #### CI/CD Pipeline - **Build workflow**: `.github/workflows/build.yml` - runs on PR and push to main/rel/feature branches - **Publish workflow**: Builds Native AOT archives for the six-RID matrix and attaches them (plus install.sh / install.ps1) to the GitHub Release. Does not publish to nuget.org or Sleet. -- **CI prerelease**: `.github/workflows/ci-release.yml` runs after a successful `build` on `main` and rewrites a rolling `ci` prerelease (`--latest=false`) so dogfood is `NDNX_VERSION=ci` / `ndnx --update ci`. +- **CI prerelease**: `.github/workflows/ci-release.yml` runs after a successful `build` on `main` and rewrites a rolling `ci` prerelease (`--latest=false`) so dogfood is `NDX_VERSION=ci` / `ndx --update ci`. - **OS matrix**: Configured in `.github/workflows/os-matrix.json` (defaults to ubuntu-latest) ### Special Files and Tools diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index e5c4b98..0776f80 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -24,7 +24,7 @@ env: VersionLabel: ${{ github.event.workflow_run.head_sha || github.sha }} GH_TOKEN: ${{ secrets.GH_TOKEN }} MSBUILDTERMINALLOGGER: auto - NDNX_SHA: ${{ github.event.workflow_run.head_sha || github.sha }} + NDX_SHA: ${{ github.event.workflow_run.head_sha || github.sha }} jobs: native-aot: @@ -53,7 +53,7 @@ jobs: run: | $out = "artifacts/${{ matrix.rid }}" New-Item -ItemType Directory -Force -Path $out | Out-Null - dotnet publish src/ndnx/ndnx.csproj -c $env:Configuration -r ${{ matrix.rid }} --self-contained -p:PublishAot=true -o $out -bl:"publish-${{ matrix.rid }}.binlog" + dotnet publish src/ndx/ndx.csproj -c $env:Configuration -r ${{ matrix.rid }} --self-contained -p:PublishAot=true -o $out -bl:"publish-${{ matrix.rid }}.binlog" - name: 📦 pack shell: pwsh @@ -65,11 +65,11 @@ jobs: with: name: native-aot-${{ matrix.rid }} path: | - artifacts/${{ matrix.rid }}/ndnx - artifacts/${{ matrix.rid }}/ndnx.exe - artifacts/ndnx-*.zip - artifacts/ndnx-*.tar.gz - artifacts/ndnx-*.sha256 + artifacts/${{ matrix.rid }}/ndx + artifacts/${{ matrix.rid }}/ndx.exe + artifacts/ndx-*.zip + artifacts/ndx-*.tar.gz + artifacts/ndx-*.sha256 retention-days: 7 if-no-files-found: error @@ -131,11 +131,11 @@ jobs: Delete-CiRelease $notes = @" - Rolling native build from ``$env:NDNX_SHA``. Not a release. + Rolling native build from ``$env:NDX_SHA``. Not a release. - Install: ``curl -fsSL https://github.com/$env:GITHUB_REPOSITORY/releases/download/ci/install.sh | NDNX_VERSION=ci sh`` + Install: ``curl -fsSL https://github.com/$env:GITHUB_REPOSITORY/releases/download/ci/install.sh | NDX_VERSION=ci sh`` - Update: ``ndnx --update ci`` + Update: ``ndx --update ci`` "@ # Create the tag/release with no files. Passing assets to `gh release create` @@ -143,7 +143,7 @@ jobs: # publish.yml actually attaches archives. $created = $false for ($attempt = 1; $attempt -le 8; $attempt++) { - gh release create ci --prerelease --latest=false --title CI --target $env:NDNX_SHA --notes $notes + gh release create ci --prerelease --latest=false --title CI --target $env:NDX_SHA --notes $notes if ($LASTEXITCODE -eq 0) { $created = $true; break } Write-Host "ci tag still present (attempt $attempt); retrying..." Start-Sleep -Seconds ($attempt * 3) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 591ac98..59534a5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -50,7 +50,7 @@ jobs: run: | $out = "artifacts/${{ matrix.rid }}" New-Item -ItemType Directory -Force -Path $out | Out-Null - dotnet publish src/ndnx/ndnx.csproj -c $env:Configuration -r ${{ matrix.rid }} --self-contained -p:PublishAot=true -o $out -bl:"publish-${{ matrix.rid }}.binlog" + dotnet publish src/ndx/ndx.csproj -c $env:Configuration -r ${{ matrix.rid }} --self-contained -p:PublishAot=true -o $out -bl:"publish-${{ matrix.rid }}.binlog" - name: 📦 pack shell: pwsh @@ -63,11 +63,11 @@ jobs: with: name: native-aot-${{ matrix.rid }} path: | - artifacts/${{ matrix.rid }}/ndnx - artifacts/${{ matrix.rid }}/ndnx.exe - artifacts/ndnx-*.zip - artifacts/ndnx-*.tar.gz - artifacts/ndnx-*.sha256 + artifacts/${{ matrix.rid }}/ndx + artifacts/${{ matrix.rid }}/ndx.exe + artifacts/ndx-*.zip + artifacts/ndx-*.tar.gz + artifacts/ndx-*.sha256 retention-days: 30 if-no-files-found: error diff --git a/.v0.5.0-notes.md b/.v0.5.0-notes.md index 3fd4b47..4e7c944 100644 --- a/.v0.5.0-notes.md +++ b/.v0.5.0-notes.md @@ -2,7 +2,7 @@ Download `tool@version` from the constructed nupkg URL — no version-index roun ## Exact-version download -A first `ndnx stop@2.1.0` now: +A first `ndx stop@2.1.0` now: 1. Resolves `PackageBaseAddress` from the v3 service index (kept in memory for the process) 2. GETs `{base}{id}/{version}/{id}.{version}.nupkg` @@ -19,9 +19,9 @@ Cold is empty-cache download → start; cached is start only (`tool@version`). l | Tool | Runner | Cold linux-x64 | Cold win-x64 | Cached linux-x64 | Cached win-x64 | | --- | --- | ---: | ---: | ---: | ---: | | `stop@2.1.0` (native AOT) | `dnx` | 2.2 s | 2.1 s | 580 ms | 520 ms | -| | `ndnx` | **1.2 s** | **1.5 s** | **10 ms** | **34 ms** | +| | `ndx` | **1.2 s** | **1.5 s** | **10 ms** | **34 ms** | | `dotnetsay@1.0.0` (framework-dependent) | `dnx` | 1.6 s | 1.8 s | 570 ms | 545 ms | -| | `ndnx` | **849 ms** | **1.1 s** | **12 ms** | **50 ms** | +| | `ndx` | **849 ms** | **1.1 s** | **12 ms** | **50 ms** | Isolated `NUGET_PACKAGES`, source `https://kzu.blob.core.windows.net/nuget/index.json`. Cold is the median of 3 empty-cache runs. Cached is the median of 10 runs after one seed. diff --git a/changelog.md b/changelog.md index 9fad92e..28ecd8c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,93 +1,93 @@ # Changelog -## [ci](https://github.com/devlooped/ndnx/tree/ci) (2026-08-25) +## [ci](https://github.com/devlooped/ndx/tree/ci) (2026-08-25) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.6.6...ci) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.6.6...ci) -## [v0.6.6](https://github.com/devlooped/ndnx/tree/v0.6.6) (2026-08-25) +## [v0.6.6](https://github.com/devlooped/ndx/tree/v0.6.6) (2026-08-25) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.6.5...v0.6.6) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.6.5...v0.6.6) :twisted_rightwards_arrows: Merged: -- Fix ci-release when an untagged ci draft blocks create [\#15](https://github.com/devlooped/ndnx/pull/15) (@kzu) +- Fix ci-release when an untagged ci draft blocks create [\#15](https://github.com/devlooped/ndx/pull/15) (@kzu) -## [v0.6.5](https://github.com/devlooped/ndnx/tree/v0.6.5) (2026-08-25) +## [v0.6.5](https://github.com/devlooped/ndx/tree/v0.6.5) (2026-08-25) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.6.4...v0.6.5) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.6.4...v0.6.5) :twisted_rightwards_arrows: Merged: -- Skip publish.yml for the rolling ci tag [\#14](https://github.com/devlooped/ndnx/pull/14) (@kzu) +- Skip publish.yml for the rolling ci tag [\#14](https://github.com/devlooped/ndx/pull/14) (@kzu) -## [v0.6.4](https://github.com/devlooped/ndnx/tree/v0.6.4) (2026-08-25) +## [v0.6.4](https://github.com/devlooped/ndx/tree/v0.6.4) (2026-08-25) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.6.3...v0.6.4) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.6.3...v0.6.4) :bug: Fixed bugs: -- fix: show download progress on Windows PowerShell [\#13](https://github.com/devlooped/ndnx/pull/13) (@kzu) +- fix: show download progress on Windows PowerShell [\#13](https://github.com/devlooped/ndx/pull/13) (@kzu) -## [v0.6.3](https://github.com/devlooped/ndnx/tree/v0.6.3) (2026-08-25) +## [v0.6.3](https://github.com/devlooped/ndx/tree/v0.6.3) (2026-08-25) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.6.2...v0.6.3) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.6.2...v0.6.3) :sparkles: Implemented enhancements: -- feat: publish a rolling ci prerelease for dogfood [\#11](https://github.com/devlooped/ndnx/pull/11) (@kzu) -- Show download progress for large native nupkgs [\#10](https://github.com/devlooped/ndnx/pull/10) (@kzu) +- feat: publish a rolling ci prerelease for dogfood [\#11](https://github.com/devlooped/ndx/pull/11) (@kzu) +- Show download progress for large native nupkgs [\#10](https://github.com/devlooped/ndx/pull/10) (@kzu) :bug: Fixed bugs: -- fix: only start ci-release after a successful build on main [\#12](https://github.com/devlooped/ndnx/pull/12) (@kzu) +- fix: only start ci-release after a successful build on main [\#12](https://github.com/devlooped/ndx/pull/12) (@kzu) -## [v0.6.2](https://github.com/devlooped/ndnx/tree/v0.6.2) (2026-08-20) +## [v0.6.2](https://github.com/devlooped/ndx/tree/v0.6.2) (2026-08-20) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.6.1...v0.6.2) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.6.1...v0.6.2) :sparkles: Implemented enhancements: -- Report a dnx-style error when a tool version is missing from the feed [\#8](https://github.com/devlooped/ndnx/pull/8) (@kzu) +- Report a dnx-style error when a tool version is missing from the feed [\#8](https://github.com/devlooped/ndx/pull/8) (@kzu) -## [v0.6.1](https://github.com/devlooped/ndnx/tree/v0.6.1) (2026-08-20) +## [v0.6.1](https://github.com/devlooped/ndx/tree/v0.6.1) (2026-08-20) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.6.0...v0.6.1) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.6.0...v0.6.1) -## [v0.6.0](https://github.com/devlooped/ndnx/tree/v0.6.0) (2026-08-15) +## [v0.6.0](https://github.com/devlooped/ndx/tree/v0.6.0) (2026-08-15) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.5.2...v0.6.0) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.5.2...v0.6.0) -## [v0.5.2](https://github.com/devlooped/ndnx/tree/v0.5.2) (2026-08-15) +## [v0.5.2](https://github.com/devlooped/ndx/tree/v0.5.2) (2026-08-15) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.5.1...v0.5.2) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.5.1...v0.5.2) -## [v0.5.1](https://github.com/devlooped/ndnx/tree/v0.5.1) (2026-08-15) +## [v0.5.1](https://github.com/devlooped/ndx/tree/v0.5.1) (2026-08-15) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.5.0...v0.5.1) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.5.0...v0.5.1) -## [v0.5.0](https://github.com/devlooped/ndnx/tree/v0.5.0) (2026-08-15) +## [v0.5.0](https://github.com/devlooped/ndx/tree/v0.5.0) (2026-08-15) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.4.0...v0.5.0) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.4.0...v0.5.0) -## [v0.4.0](https://github.com/devlooped/ndnx/tree/v0.4.0) (2026-08-15) +## [v0.4.0](https://github.com/devlooped/ndx/tree/v0.4.0) (2026-08-15) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.3.0...v0.4.0) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.3.0...v0.4.0) -## [v0.3.0](https://github.com/devlooped/ndnx/tree/v0.3.0) (2026-08-15) +## [v0.3.0](https://github.com/devlooped/ndx/tree/v0.3.0) (2026-08-15) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.2.0...v0.3.0) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.2.0...v0.3.0) -## [v0.2.0](https://github.com/devlooped/ndnx/tree/v0.2.0) (2026-08-14) +## [v0.2.0](https://github.com/devlooped/ndx/tree/v0.2.0) (2026-08-14) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.1.1...v0.2.0) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.1.1...v0.2.0) -## [v0.1.1](https://github.com/devlooped/ndnx/tree/v0.1.1) (2026-08-14) +## [v0.1.1](https://github.com/devlooped/ndx/tree/v0.1.1) (2026-08-14) -[Full Changelog](https://github.com/devlooped/ndnx/compare/v0.1.0...v0.1.1) +[Full Changelog](https://github.com/devlooped/ndx/compare/v0.1.0...v0.1.1) -## [v0.1.0](https://github.com/devlooped/ndnx/tree/v0.1.0) (2026-08-13) +## [v0.1.0](https://github.com/devlooped/ndx/tree/v0.1.0) (2026-08-13) -[Full Changelog](https://github.com/devlooped/ndnx/compare/5d6336c96c3e2b75ef31dccbf9b312230fe94afa...v0.1.0) +[Full Changelog](https://github.com/devlooped/ndx/compare/5d6336c96c3e2b75ef31dccbf9b312230fe94afa...v0.1.0) diff --git a/install.ps1 b/install.ps1 index 0bbe76a..0930cfd 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1,24 +1,24 @@ -# Install ndnx from GitHub Releases. -# irm https://github.com/devlooped/ndnx/releases/latest/download/install.ps1 | iex -# Env / flags: NDNX_VERSION, NDNX_PREFIX, NDNX_ARCHIVE, NDNX_RID, NDNX_REPO, NDNX_SKIP_PATH +# Install ndx from GitHub Releases. +# irm https://github.com/devlooped/ndx/releases/latest/download/install.ps1 | iex +# Env / flags: NDX_VERSION, NDX_PREFIX, NDX_ARCHIVE, NDX_RID, NDX_REPO, NDX_SKIP_PATH # Also accepts --version --prefix --archive --rid --repo --skip-path $ErrorActionPreference = 'Stop' -$Repo = if ($env:NDNX_REPO) { $env:NDNX_REPO } else { 'devlooped/ndnx' } -$Version = $env:NDNX_VERSION -$Prefix = $env:NDNX_PREFIX -$Archive = $env:NDNX_ARCHIVE -$Rid = $env:NDNX_RID -$SkipPath = $env:NDNX_SKIP_PATH -eq '1' +$Repo = if ($env:NDX_REPO) { $env:NDX_REPO } else { 'devlooped/ndx' } +$Version = $env:NDX_VERSION +$Prefix = $env:NDX_PREFIX +$Archive = $env:NDX_ARCHIVE +$Rid = $env:NDX_RID +$SkipPath = $env:NDX_SKIP_PATH -eq '1' -function Get-NdnxRuntimeIdentifier { +function Get-NdxRuntimeIdentifier { $arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture $archName = switch ($arch) { 'X64' { 'x64' } 'Arm64' { 'arm64' } default { - throw "ndnx: unsupported architecture '$arch'" + throw "ndx: unsupported architecture '$arch'" } } @@ -31,7 +31,7 @@ function Get-NdnxRuntimeIdentifier { if ($IsLinux) { return "linux-$archName" } } - throw "ndnx: unsupported OS" + throw "ndx: unsupported OS" } function Send-EnvironmentChange { @@ -59,7 +59,7 @@ public static extern IntPtr SendMessageTimeout( [ref]$result) } -function Add-NdnxToUserPath([string]$dir) { +function Add-NdxToUserPath([string]$dir) { $parts = [Environment]::GetEnvironmentVariable('Path', 'User') if (-not $parts) { $parts = '' } $entries = $parts.Split([char]';', [StringSplitOptions]::RemoveEmptyEntries) @@ -82,27 +82,27 @@ for ($i = 0; $i -lt $args.Count; $i++) { '^--rid$|^-Rid$' { $Rid = $args[++$i]; continue } '^--repo$|^-Repo$' { $Repo = $args[++$i]; continue } '^--skip-path$|^-SkipPath$' { $SkipPath = $true; continue } - default { throw "ndnx: unrecognized argument '$($args[$i])'" } + default { throw "ndx: unrecognized argument '$($args[$i])'" } } } if (-not $Rid) { - $Rid = Get-NdnxRuntimeIdentifier + $Rid = Get-NdxRuntimeIdentifier } $windows = $Rid.StartsWith('win', [StringComparison]::OrdinalIgnoreCase) -$binary = if ($windows) { 'ndnx.exe' } else { 'ndnx' } +$binary = if ($windows) { 'ndx.exe' } else { 'ndx' } $ext = if ($windows) { 'zip' } else { 'tar.gz' } if (-not $Prefix) { $Prefix = if ($windows) { - Join-Path $env:LOCALAPPDATA 'ndnx' + Join-Path $env:LOCALAPPDATA 'ndx' } else { Join-Path $HOME '.local/bin' } } -$tmp = Join-Path ([IO.Path]::GetTempPath()) ("ndnx-install-" + [guid]::NewGuid().ToString('n')) +$tmp = Join-Path ([IO.Path]::GetTempPath()) ("ndx-install-" + [guid]::NewGuid().ToString('n')) New-Item -ItemType Directory -Path $tmp | Out-Null try { if (-not $Archive) { @@ -121,11 +121,11 @@ try { $release = Invoke-RestMethod -Headers @{ Accept = 'application/vnd.github+json' } ` -Uri "https://api.github.com/repos/$Repo/releases/latest" $tag = $release.tag_name - if (-not $tag) { throw "ndnx: could not resolve latest release of $Repo" } + if (-not $tag) { throw "ndx: could not resolve latest release of $Repo" } $resolved = $tag.TrimStart('v') } - $name = "ndnx-$resolved-$Rid.$ext" + $name = "ndx-$resolved-$Rid.$ext" $base = "https://github.com/$Repo/releases/download/$tag" $Archive = Join-Path $tmp $name Invoke-WebRequest -Uri "$base/$name" -OutFile $Archive @@ -136,7 +136,7 @@ try { $expected = ((Get-Content -Raw "$Archive.sha256").Trim() -split '\s+')[0].ToLowerInvariant() $actual = (Get-FileHash -Algorithm SHA256 -Path $Archive).Hash.ToLowerInvariant() if ($actual -ne $expected) { - throw "ndnx: SHA256 mismatch for $(Split-Path $Archive -Leaf)`n expected: $expected`n actual: $actual" + throw "ndx: SHA256 mismatch for $(Split-Path $Archive -Leaf)`n expected: $expected`n actual: $actual" } } @@ -150,7 +150,7 @@ try { $source = Join-Path $extract $binary if (-not (Test-Path $source)) { - throw "ndnx: archive did not contain $binary" + throw "ndx: archive did not contain $binary" } New-Item -ItemType Directory -Force -Path $Prefix | Out-Null @@ -159,7 +159,7 @@ try { Write-Host "installed $dest" if (-not $SkipPath) { - Add-NdnxToUserPath $Prefix + Add-NdxToUserPath $Prefix } } finally { diff --git a/install.sh b/install.sh index ee3552d..34a27fe 100755 --- a/install.sh +++ b/install.sh @@ -1,14 +1,14 @@ #!/bin/sh -# Install ndnx from GitHub Releases. -# curl -fsSL https://github.com/devlooped/ndnx/releases/latest/download/install.sh | sh +# Install ndx from GitHub Releases. +# curl -fsSL https://github.com/devlooped/ndx/releases/latest/download/install.sh | sh set -eu -REPO="${NDNX_REPO:-devlooped/ndnx}" -VERSION="${NDNX_VERSION:-}" -PREFIX="${NDNX_PREFIX:-${HOME}/.local/bin}" -ARCHIVE="${NDNX_ARCHIVE:-}" -RID="${NDNX_RID:-}" -SKIP_PATH="${NDNX_SKIP_PATH:-0}" +REPO="${NDX_REPO:-devlooped/ndx}" +VERSION="${NDX_VERSION:-}" +PREFIX="${NDX_PREFIX:-${HOME}/.local/bin}" +ARCHIVE="${NDX_ARCHIVE:-}" +RID="${NDX_RID:-}" +SKIP_PATH="${NDX_SKIP_PATH:-0}" detect_rid() { os=$(uname -s | tr '[:upper:]' '[:lower:]') @@ -18,7 +18,7 @@ detect_rid() { x86_64|amd64) arch=x64 ;; aarch64|arm64) arch=arm64 ;; *) - echo "ndnx: unsupported architecture '$arch'" >&2 + echo "ndx: unsupported architecture '$arch'" >&2 exit 1 ;; esac @@ -28,7 +28,7 @@ detect_rid() { darwin) echo "osx-${arch}" ;; mingw*|msys*|cygwin*) echo "win-${arch}" ;; *) - echo "ndnx: unsupported OS '$os'" >&2 + echo "ndx: unsupported OS '$os'" >&2 exit 1 ;; esac @@ -41,7 +41,7 @@ github_json() { elif command -v wget >/dev/null 2>&1; then wget -qO- --header="Accept: application/vnd.github+json" "$url" else - echo "ndnx: need curl or wget" >&2 + echo "ndx: need curl or wget" >&2 exit 1 fi } @@ -73,12 +73,12 @@ verify_sha256() { elif command -v openssl >/dev/null 2>&1; then actual=$(openssl dgst -sha256 "$file" | awk '{print $NF}') else - echo "ndnx: no sha256 tool found (sha256sum, shasum, or openssl)" >&2 + echo "ndx: no sha256 tool found (sha256sum, shasum, or openssl)" >&2 exit 1 fi actual=$(printf '%s' "$actual" | tr '[:upper:]' '[:lower:]') if [ "$actual" != "$expected" ]; then - echo "ndnx: SHA256 mismatch for $(basename "$file")" >&2 + echo "ndx: SHA256 mismatch for $(basename "$file")" >&2 echo " expected: $expected" >&2 echo " actual: $actual" >&2 exit 1 @@ -90,10 +90,10 @@ if [ -z "$RID" ]; then fi case "$RID" in - win-*) binary=ndnx.exe; ext=zip ;; - linux-*|osx-*) binary=ndnx; ext=tar.gz ;; + win-*) binary=ndx.exe; ext=zip ;; + linux-*|osx-*) binary=ndx; ext=tar.gz ;; *) - echo "ndnx: unsupported RID '$RID'" >&2 + echo "ndx: unsupported RID '$RID'" >&2 exit 1 ;; esac @@ -121,13 +121,13 @@ if [ -z "$ARCHIVE" ]; then json=$(github_json "https://api.github.com/repos/${REPO}/releases/latest") tag=$(printf '%s' "$json" | json_string tag_name) if [ -z "$tag" ]; then - echo "ndnx: could not resolve latest release of ${REPO}" >&2 + echo "ndx: could not resolve latest release of ${REPO}" >&2 exit 1 fi version=${tag#v} fi - name="ndnx-${version}-${RID}.${ext}" + name="ndx-${version}-${RID}.${ext}" base="https://github.com/${REPO}/releases/download/${tag}" ARCHIVE="${tmp}/${name}" download "${base}/${name}" "$ARCHIVE" @@ -148,7 +148,7 @@ case "$ext" in if command -v unzip >/dev/null 2>&1; then unzip -o -q "$ARCHIVE" -d "$extract" else - echo "ndnx: unzip is required to extract Windows archives" >&2 + echo "ndx: unzip is required to extract Windows archives" >&2 exit 1 fi ;; @@ -158,7 +158,7 @@ case "$ext" in esac if [ ! -f "${extract}/${binary}" ]; then - echo "ndnx: archive did not contain ${binary}" >&2 + echo "ndx: archive did not contain ${binary}" >&2 exit 1 fi @@ -177,12 +177,12 @@ write_path_block() { file=$1 kind=$2 mkdir -p "$(dirname "$file")" - tmpfile="${file}.ndnx.tmp.$$" + tmpfile="${file}.ndx.tmp.$$" if [ -f "$file" ]; then awk ' BEGIN { skip=0 } - /# >>> ndnx path >>>/ { skip=1; next } - /# <<< ndnx path <<>> ndx path >>>/ { skip=1; next } + /# <<< ndx path << "$tmpfile" else @@ -193,18 +193,18 @@ write_path_block() { fi if [ "$kind" = fish ]; then cat >> "$tmpfile" <>> ndnx path >>> +# >>> ndx path >>> fish_add_path ${PREFIX} -# <<< ndnx path <<< +# <<< ndx path <<< EOF else cat >> "$tmpfile" <>> ndnx path >>> +# >>> ndx path >>> case ":\$PATH:" in *":${PREFIX}:"*) ;; *) export PATH="${PREFIX}:\$PATH" ;; esac -# <<< ndnx path <<< +# <<< ndx path <<< EOF fi mv "$tmpfile" "$file" @@ -232,7 +232,7 @@ if [ "$SKIP_PATH" != "1" ]; then case ":${PATH}:" in *":${PREFIX}:"*) ;; *) - echo "restart your shell so ndnx is on PATH" >&2 + echo "restart your shell so ndx is on PATH" >&2 ;; esac fi diff --git a/ndnx.slnx b/ndx.slnx similarity index 74% rename from ndnx.slnx rename to ndx.slnx index a2a82a3..fba7c02 100644 --- a/ndnx.slnx +++ b/ndx.slnx @@ -1,5 +1,5 @@ - + diff --git a/readme.md b/readme.md index f26e090..ee4b6f9 100644 --- a/readme.md +++ b/readme.md @@ -1,19 +1,19 @@ -# ndnx +# ndx -[![Release](https://img.shields.io/github/v/release/devlooped/ndnx?include_prereleases&color=darkmagenta)](https://github.com/devlooped/ndnx/releases) +[![Release](https://img.shields.io/github/v/release/devlooped/ndx?include_prereleases&color=darkmagenta)](https://github.com/devlooped/ndx/releases) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/devlooped/oss/blob/main/license.txt) -`ndnx` is [`dnx`](https://learn.microsoft.com/dotnet/core/tools/dotnet-tool-exec) for +`ndx` (*n*ative *d*otnet e*x*ecute) is [`dnx`](https://learn.microsoft.com/dotnet/core/tools/dotnet-tool-exec) for native tools packaged and distributed as NuGet packages. Same one-shot CLI, same `PACKAGE[@VERSION]` identity, same restore flags, same global packages folder. -If you can `dnx stop`, you can `ndnx stop`. `dotnet dnx` and `dotnet tool exec` -are the same command; `ndnx` speaks that protocol, including RID-specific Native +If you can `dnx stop`, you can `ndx stop`. `dotnet dnx` and `dotnet tool exec` +are the same command; `ndx` speaks that protocol, including RID-specific Native AOT tools (`stop`, `go`, `winget`) and ordinary framework-dependent tools (`dotnetsay`). -A first run downloads into the NuGet cache. A later `ndnx tool@version` starts +A first run downloads into the NuGet cache. A later `ndx tool@version` starts the cached binary — no SDK, no restore. ## Install @@ -21,13 +21,13 @@ the cached binary — no SDK, no restore. macOS / Linux: ```bash -curl -fsSL https://github.com/devlooped/ndnx/releases/latest/download/install.sh | sh +curl -fsSL https://github.com/devlooped/ndx/releases/latest/download/install.sh | sh ``` Windows (PowerShell): ```powershell -irm https://github.com/devlooped/ndnx/releases/latest/download/install.ps1 | iex +irm https://github.com/devlooped/ndx/releases/latest/download/install.ps1 | iex ``` ## Update @@ -35,35 +35,35 @@ irm https://github.com/devlooped/ndnx/releases/latest/download/install.ps1 | iex Self-update the installed binary (optional version, including downgrades): ```bash -ndnx --update -ndnx --update 0.1.0 +ndx --update +ndx --update 0.1.0 ``` ## Usage -*ndnx* +*ndx* Same shape as `dnx` / `dotnet dnx` / `dotnet tool exec`: ```bash -dnx stop -- --help -ndnx stop -- --help +dnx stop -- --help +ndx stop -- --help -dnx stop@2.1.0 -- --help -ndnx stop@2.1.0 -- --help +dnx stop@2.1.0 -- --help +ndx stop@2.1.0 -- --help -dnx dotnetsay@1.0.0 -- Hello -ndnx dotnetsay@1.0.0 -- Hello +dnx dotnetsay@1.0.0 -- Hello +ndx dotnetsay@1.0.0 -- Hello ``` Pin a feed the same way (here the CI feed used for the timings below): ```bash -dnx --source https://kzu.blob.core.windows.net/nuget/index.json stop@2.1.0 -- --help -ndnx --source https://kzu.blob.core.windows.net/nuget/index.json stop@2.1.0 -- --help +dnx --source https://kzu.blob.core.windows.net/nuget/index.json stop@2.1.0 -- --help +ndx --source https://kzu.blob.core.windows.net/nuget/index.json stop@2.1.0 -- --help ``` `stop` is a Native AOT RID tool. `dotnetsay` is a classic framework-dependent -tool. Both are just NuGet packages; ndnx picks the host RID and starts +tool. Both are just NuGet packages; ndx picks the host RID and starts `Runner=executable` binaries directly, or `dotnet exec` for `Runner=dotnet`. An exact version already in the cache (`NUGET_PACKAGES`, then @@ -71,10 +71,10 @@ An exact version already in the cache (`NUGET_PACKAGES`, then downloaded again. A first `tool@version` run builds the nupkg URL from the service index (cached for the process) and lists versions only if that GET is 404. Packages written by `dnx` or `dotnet restore` are reused; packages -written by ndnx are visible to them. +written by ndx are visible to them. A floating version — unspecified, `@*`, `@*-*`, or a NuGet range — stays -current. ndnx starts the latest match, watches the feed, downloads a newer +current. ndx starts the latest match, watches the feed, downloads a newer matching version *before* stopping the child, then sends SIGINT / Ctrl+C (and `WM_CLOSE` if the tool is a GUI) and restarts. Short tools still exit as soon as the child exits. Pin an exact version (`tool@2.1.0`) to disable @@ -83,11 +83,11 @@ that loop. The poll interval defaults to 5 seconds and can be set in `.netconfig`: ``` -[ndnx] +[ndx] interval = 5 ``` -ndnx walks from the working directory up, then `~/.netconfig`. `--verbosity +ndx walks from the working directory up, then `~/.netconfig`. `--verbosity quiet` hides the `Updating …` line. Shared flags: `--source`, `--add-source`, `--configfile`, `--version`, @@ -104,18 +104,18 @@ SDK 10.0.303. | Tool | Runner | Cold linux-x64 | Cold win-x64 | Cached linux-x64 | Cached win-x64 | | --- | --- | ---: | ---: | ---: | ---: | | `stop@2.1.0` (native AOT) | `dnx` | 2.2 s | 2.1 s | 580 ms | 520 ms | -| | `ndnx` | **1.2 s** | **1.5 s** | **10 ms** | **34 ms** | +| | `ndx` | **1.2 s** | **1.5 s** | **10 ms** | **34 ms** | | `dotnetsay@1.0.0` (framework-dependent) | `dnx` | 1.6 s | 1.8 s | 570 ms | 545 ms | -| | `ndnx` | **849 ms** | **1.1 s** | **12 ms** | **50 ms** | +| | `ndx` | **849 ms** | **1.1 s** | **12 ms** | **50 ms** | | `winget` (native AOT TUI, Windows) | `dnx` | — | 2.7 s | — | 820 ms | -| | `ndnx` | — | **1.2 s** | — | **275 ms** | +| | `ndx` | — | **1.2 s** | — | **275 ms** | Isolated `NUGET_PACKAGES`. `stop` / `dotnetsay` from `https://kzu.blob.core.windows.net/nuget/index.json`; `winget` from nuget.org. Cold is the median of 3 empty-cache runs. Cached is the median of 10 runs after -one seed. `stop` invoked as `-- --help`; `dotnetsay` as `-- ndnx`. `winget` is +one seed. `stop` invoked as `-- --help`; `dotnetsay` as `-- ndx`. `winget` is a TUI so it does not exit on its own: cold is `winget` (latest), cached is -`winget@0.13.2`; each run waits until `winget-tui` is up, then `ndnx stop@2.1.0` +`winget@0.13.2`; each run waits until `winget-tui` is up, then `ndx stop@2.1.0` signals that PID and the clock stops when the runner exits. `dnx` is the SDK script (`dotnet dnx`). `winget` timings are win-x64 SDK 11.0.100-preview. diff --git a/src/Directory.props b/src/Directory.props index c136f7c..b7b9783 100644 --- a/src/Directory.props +++ b/src/Directory.props @@ -1,6 +1,6 @@ - ndnx + ndx true \ No newline at end of file diff --git a/src/Tests/ArgParserTests.cs b/src/Tests/ArgParserTests.cs index f74bd60..7092663 100644 --- a/src/Tests/ArgParserTests.cs +++ b/src/Tests/ArgParserTests.cs @@ -1,4 +1,4 @@ -using ndnx; +using ndx; namespace Tests; @@ -19,7 +19,7 @@ public void Package_at_version_yes_source_and_terminator_forwards_remaining() } [Fact] - public void Tokens_after_terminator_that_look_like_ndnx_flags_still_forward() + public void Tokens_after_terminator_that_look_like_ndx_flags_still_forward() { var parsed = ArgParser.Parse( "pkg", "--", "--yes", "--source", "https://feed.example", "-v", "detailed"); @@ -107,7 +107,7 @@ public void Equals_form_is_accepted_for_valued_options() [Theory] [InlineData("--version")] [InlineData("--VERSION")] - public void Version_alone_prints_the_ndnx_version(string arg) + public void Version_alone_prints_the_ndx_version(string arg) { var parsed = ArgParser.Parse(arg); diff --git a/src/Tests/DownloadProgressTests.cs b/src/Tests/DownloadProgressTests.cs index 04badf3..b047270 100644 --- a/src/Tests/DownloadProgressTests.cs +++ b/src/Tests/DownloadProgressTests.cs @@ -1,4 +1,4 @@ -using ndnx; +using ndx; namespace Tests; diff --git a/src/Tests/EvergreenTests.cs b/src/Tests/EvergreenTests.cs index 188d72e..ff15ceb 100644 --- a/src/Tests/EvergreenTests.cs +++ b/src/Tests/EvergreenTests.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using System.IO.Compression; using System.Xml.Linq; -using ndnx; +using ndx; namespace Tests; @@ -67,7 +67,7 @@ public async Task Stages_newer_package_then_stops_and_restarts() runner.Next.Enqueue(second); var host = NewHost(runner, feedDir); - host = new NdnxHost + host = new NdxHost { WorkingDirectory = host.WorkingDirectory, StoreDirectory = host.StoreDirectory, @@ -101,7 +101,7 @@ public async Task Unchanged_feed_does_not_stop_the_running_child() var runner = new RecordingProcessRunner(); runner.Next.Enqueue(first); var host = NewHost(runner); - host = new NdnxHost + host = new NdxHost { WorkingDirectory = host.WorkingDirectory, StoreDirectory = host.StoreDirectory, @@ -130,11 +130,11 @@ public async Task Unchanged_feed_does_not_stop_the_running_child() [Fact] public async Task Host_update_interval_overrides_netconfig() { - var dir = Path.Combine(Path.GetTempPath(), "ndnx-evergreen-cfg", Guid.NewGuid().ToString("n")); + var dir = Path.Combine(Path.GetTempPath(), "ndx-evergreen-cfg", Guid.NewGuid().ToString("n")); Directory.CreateDirectory(dir); File.WriteAllText(Path.Combine(dir, ".netconfig"), """ - [ndnx] + [ndx] interval = 30 """); @@ -142,7 +142,7 @@ public async Task Host_update_interval_overrides_netconfig() Assert.Equal(TimeSpan.FromSeconds(30), interval); var runner = new RecordingProcessRunner { ExitCode = 0 }; - var host = new NdnxHost + var host = new NdxHost { WorkingDirectory = dir, StoreDirectory = Path.Combine(dir, "store"), @@ -161,18 +161,18 @@ public async Task Host_update_interval_overrides_netconfig() [Fact] public void Ci_feed_stop_star_help_exits() { - var store = Path.Combine(Path.GetTempPath(), "ndnx-evergreen-ci", Guid.NewGuid().ToString("n")); + var store = Path.Combine(Path.GetTempPath(), "ndx-evergreen-ci", Guid.NewGuid().ToString("n")); Directory.CreateDirectory(store); - var result = LaunchNdnx(store, ["stop@*", "--yes", "--source", CiFeed, "--", "--help"]); + var result = LaunchNdx(store, ["stop@*", "--yes", "--source", CiFeed, "--", "--help"]); Assert.Equal(0, result.ExitCode); Assert.Contains("timeout", result.Stdout + result.Stderr, StringComparison.OrdinalIgnoreCase); } - NdnxHost NewHost(IProcessRunner runner, string? sourceDir = null) + NdxHost NewHost(IProcessRunner runner, string? sourceDir = null) { - var root = Path.Combine(Path.GetTempPath(), "ndnx-evergreen", Guid.NewGuid().ToString("n")); + var root = Path.Combine(Path.GetTempPath(), "ndx-evergreen", Guid.NewGuid().ToString("n")); Directory.CreateDirectory(root); - return new NdnxHost + return new NdxHost { WorkingDirectory = sourceDir ?? root, StoreDirectory = Path.Combine(root, "store"), @@ -185,7 +185,7 @@ NdnxHost NewHost(IProcessRunner runner, string? sourceDir = null) string IsolatedHelloFeed() { - var dir = Path.Combine(Path.GetTempPath(), "ndnx-evergreen-feed", Guid.NewGuid().ToString("n")); + var dir = Path.Combine(Path.GetTempPath(), "ndx-evergreen-feed", Guid.NewGuid().ToString("n")); Directory.CreateDirectory(dir); var nupkg = Path.Combine(feed.FeedDirectory, $"{HelloToolFeed.PackageId}.{HelloToolFeed.PackageVersion}.nupkg"); File.Copy(nupkg, Path.Combine(dir, Path.GetFileName(nupkg))); @@ -237,10 +237,10 @@ static async Task WaitUntil(Func condition, TimeSpan timeout) throw new TimeoutException("Condition was not met in time."); } - static (int ExitCode, string Stdout, string Stderr) LaunchNdnx(string store, string[] args) + static (int ExitCode, string Stdout, string Stderr) LaunchNdx(string store, string[] args) { - var ndnxDll = Path.Combine(AppContext.BaseDirectory, "ndnx.dll"); - Assert.True(File.Exists(ndnxDll), $"Expected shipped ndnx.dll at {ndnxDll}"); + var ndxDll = Path.Combine(AppContext.BaseDirectory, "ndx.dll"); + Assert.True(File.Exists(ndxDll), $"Expected shipped ndx.dll at {ndxDll}"); var start = new ProcessStartInfo { @@ -250,10 +250,10 @@ static async Task WaitUntil(Func condition, TimeSpan timeout) UseShellExecute = false, }; start.ArgumentList.Add("exec"); - start.ArgumentList.Add(ndnxDll); + start.ArgumentList.Add(ndxDll); foreach (var arg in args) start.ArgumentList.Add(arg); - start.Environment["NDNX_STORE"] = store; + start.Environment["NDX_STORE"] = store; return ProcessCapture.Run(start); } } diff --git a/src/Tests/FrameworkDependentTests.cs b/src/Tests/FrameworkDependentTests.cs index db9acd6..401401f 100644 --- a/src/Tests/FrameworkDependentTests.cs +++ b/src/Tests/FrameworkDependentTests.cs @@ -1,5 +1,5 @@ using System.Runtime.InteropServices; -using ndnx; +using ndx; namespace Tests; @@ -216,7 +216,7 @@ public async Task App_does_not_launch_when_muxer_is_too_old() hello-tool 1.0.0 - ndnx + ndx fdd fixture @@ -227,7 +227,7 @@ public async Task App_does_not_launch_when_muxer_is_too_old() ZipFileFromDirectory(staging, Path.Combine(feedDir, "hello-tool.1.0.0.nupkg")); var runner = new RecordingProcessRunner(); - var host = new NdnxHost + var host = new NdxHost { WorkingDirectory = root.Path, StoreDirectory = Path.Combine(root.Path, "app-store"), @@ -310,7 +310,7 @@ static void ZipFileFromDirectory(string source, string nupkg) sealed class TempDir : IDisposable { public string Path { get; } = System.IO.Path.Combine( - System.IO.Path.GetTempPath(), "ndnx-fx-tests", Guid.NewGuid().ToString("n")); + System.IO.Path.GetTempPath(), "ndx-fx-tests", Guid.NewGuid().ToString("n")); public TempDir() => Directory.CreateDirectory(Path); diff --git a/src/Tests/HelloToolFeed.cs b/src/Tests/HelloToolFeed.cs index a699429..08659c0 100644 --- a/src/Tests/HelloToolFeed.cs +++ b/src/Tests/HelloToolFeed.cs @@ -31,7 +31,7 @@ public sealed class HelloToolFeed : IDisposable public HelloToolFeed() { - Root = Path.Combine(Path.GetTempPath(), "ndnx-hello-tool-feed"); + Root = Path.Combine(Path.GetTempPath(), "ndx-hello-tool-feed"); FeedDirectory = Path.Combine(Root, "feed"); lock (Gate) Build(); @@ -88,8 +88,8 @@ static void WriteProject(string projectDir) hello-tool hello-tool 1.0.0 - ndnx - ndnx test fixture + ndx + ndx test fixture ../feed @@ -144,7 +144,7 @@ void PublishAndPackExecutable(string projectDir) {ExePackageId} {PackageVersion} - ndnx + ndx executable fixture @@ -285,7 +285,7 @@ void WriteNupkg(string packageId, string packageType, Action populate) {packageId} {PackageVersion} - ndnx + ndx {packageId} fixture diff --git a/src/Tests/InstallScriptTests.cs b/src/Tests/InstallScriptTests.cs index 6ed4b98..196a2e4 100644 --- a/src/Tests/InstallScriptTests.cs +++ b/src/Tests/InstallScriptTests.cs @@ -1,5 +1,5 @@ using System.Diagnostics; -using ndnx; +using ndx; namespace Tests; @@ -42,7 +42,7 @@ public void Powershell_install_script_installs_from_a_local_archive() using var dir = new TempDir(); var payload = "installed-by-script"u8.ToArray(); - File.WriteAllBytes(Path.Combine(dir.Publish, "ndnx.exe"), payload); + File.WriteAllBytes(Path.Combine(dir.Publish, "ndx.exe"), payload); var packed = NativePacker.Pack(dir.Publish, "win-x64", dir.Output, "1.0.0"); var start = new ProcessStartInfo @@ -74,7 +74,7 @@ public void Powershell_install_script_installs_from_a_local_archive() process.WaitForExit(); Assert.True(process.ExitCode == 0, $"install.ps1 failed ({process.ExitCode}).{Environment.NewLine}{stdout}{Environment.NewLine}{stderr}"); - var dest = Path.Combine(dir.Prefix, "ndnx.exe"); + var dest = Path.Combine(dir.Prefix, "ndx.exe"); Assert.True(File.Exists(dest), stdout); Assert.Equal(payload, File.ReadAllBytes(dest)); Assert.Contains("installed", stdout, StringComparison.OrdinalIgnoreCase); @@ -88,7 +88,7 @@ public void Powershell_installer_persists_user_path_and_broadcasts_environment_c Assert.Contains("SendMessageTimeout", ps); Assert.Contains("'Environment'", ps); Assert.Contains("0x1a", ps); - Assert.Contains("Add-NdnxToUserPath", ps); + Assert.Contains("Add-NdxToUserPath", ps); } [Fact] @@ -99,18 +99,18 @@ public void Shell_installer_writes_a_guarded_path_block_into_zshrc() var root = FindRepoRoot(); using var dir = new TempDir(); - File.WriteAllBytes(Path.Combine(dir.Publish, "ndnx"), "unix-ndnx"u8.ToArray()); + File.WriteAllBytes(Path.Combine(dir.Publish, "ndx"), "unix-ndx"u8.ToArray()); var packed = NativePacker.Pack(dir.Publish, "linux-x64", dir.Output, "1.0.0"); RunInstallSh(bash, root, dir, packed.ArchivePath, skipPath: false); RunInstallSh(bash, root, dir, packed.ArchivePath, skipPath: false); var zshrc = File.ReadAllText(Path.Combine(dir.Home, ".zshrc")); - Assert.Contains("# >>> ndnx path >>>", zshrc); - Assert.Contains("# <<< ndnx path <<<", zshrc); + Assert.Contains("# >>> ndx path >>>", zshrc); + Assert.Contains("# <<< ndx path <<<", zshrc); Assert.Contains(ToBashPath(bash, dir.Prefix), zshrc); - Assert.Equal(1, CountOccurrences(zshrc, "# >>> ndnx path >>>")); - Assert.True(File.Exists(Path.Combine(dir.Prefix, "ndnx"))); + Assert.Equal(1, CountOccurrences(zshrc, "# >>> ndx path >>>")); + Assert.True(File.Exists(Path.Combine(dir.Prefix, "ndx"))); } [Fact] @@ -121,13 +121,13 @@ public void Shell_installer_skip_path_does_not_write_rc() var root = FindRepoRoot(); using var dir = new TempDir(); - File.WriteAllBytes(Path.Combine(dir.Publish, "ndnx"), "unix-ndnx"u8.ToArray()); + File.WriteAllBytes(Path.Combine(dir.Publish, "ndx"), "unix-ndx"u8.ToArray()); var packed = NativePacker.Pack(dir.Publish, "linux-x64", dir.Output, "1.0.0"); RunInstallSh(bash, root, dir, packed.ArchivePath, skipPath: true); Assert.False(File.Exists(Path.Combine(dir.Home, ".zshrc"))); - Assert.True(File.Exists(Path.Combine(dir.Prefix, "ndnx"))); + Assert.True(File.Exists(Path.Combine(dir.Prefix, "ndx"))); } [Fact] @@ -174,10 +174,10 @@ static void RunInstallSh(string bash, string repoRoot, TempDir dir, string archi start.ArgumentList.Add(ToBashPath(bash, Path.Combine(repoRoot, "install.sh"))); start.Environment["HOME"] = ToBashPath(bash, dir.Home); start.Environment["SHELL"] = "/bin/zsh"; - start.Environment["NDNX_ARCHIVE"] = ToBashPath(bash, archive); - start.Environment["NDNX_PREFIX"] = ToBashPath(bash, dir.Prefix); - start.Environment["NDNX_RID"] = "linux-x64"; - start.Environment["NDNX_SKIP_PATH"] = skipPath ? "1" : "0"; + start.Environment["NDX_ARCHIVE"] = ToBashPath(bash, archive); + start.Environment["NDX_PREFIX"] = ToBashPath(bash, dir.Prefix); + start.Environment["NDX_RID"] = "linux-x64"; + start.Environment["NDX_SKIP_PATH"] = skipPath ? "1" : "0"; using var process = Process.Start(start) ?? throw new InvalidOperationException("failed to start bash"); var stdout = process.StandardOutput.ReadToEnd(); @@ -243,7 +243,7 @@ static string FindRepoRoot() var dir = new DirectoryInfo(AppContext.BaseDirectory); while (dir is not null) { - if (File.Exists(Path.Combine(dir.FullName, "ndnx.slnx"))) + if (File.Exists(Path.Combine(dir.FullName, "ndx.slnx"))) return dir.FullName; dir = dir.Parent; } @@ -253,7 +253,7 @@ static string FindRepoRoot() sealed class TempDir : IDisposable { - public string Root { get; } = Path.Combine(Path.GetTempPath(), "ndnx-install-tests", Guid.NewGuid().ToString("n")); + public string Root { get; } = Path.Combine(Path.GetTempPath(), "ndx-install-tests", Guid.NewGuid().ToString("n")); public string Publish => Path.Combine(Root, "publish"); public string Output => Path.Combine(Root, "out"); public string Prefix => Path.Combine(Root, "prefix"); diff --git a/src/Tests/NativePackerTests.cs b/src/Tests/NativePackerTests.cs index c9f7fbc..bda2c1c 100644 --- a/src/Tests/NativePackerTests.cs +++ b/src/Tests/NativePackerTests.cs @@ -1,7 +1,7 @@ using System.Formats.Tar; using System.IO.Compression; using System.Security.Cryptography; -using ndnx; +using ndx; namespace Tests; @@ -10,23 +10,23 @@ public class NativePackerTests [Theory] [InlineData("win-x64")] [InlineData("win-arm64")] - public void Windows_rid_emits_zip_of_ndnx_exe_and_matching_sha256(string rid) + public void Windows_rid_emits_zip_of_ndx_exe_and_matching_sha256(string rid) { using var dir = new TempDir(); var payload = "windows-native-bytes"u8.ToArray(); - File.WriteAllBytes(Path.Combine(dir.Publish, "ndnx.exe"), payload); + File.WriteAllBytes(Path.Combine(dir.Publish, "ndx.exe"), payload); var result = NativePacker.Pack(dir.Publish, rid, dir.Output, "1.2.3"); - Assert.Equal($"ndnx-1.2.3-{rid}.zip", Path.GetFileName(result.ArchivePath)); - Assert.Equal($"ndnx-ci-{rid}.zip", NativePacker.ArchiveFileName(rid, "ci")); + Assert.Equal($"ndx-1.2.3-{rid}.zip", Path.GetFileName(result.ArchivePath)); + Assert.Equal($"ndx-ci-{rid}.zip", NativePacker.ArchiveFileName(rid, "ci")); Assert.True(File.Exists(result.ArchivePath)); Assert.True(File.Exists(result.Sha256Path)); using (var zip = ZipFile.OpenRead(result.ArchivePath)) { var entry = Assert.Single(zip.Entries); - Assert.Equal("ndnx.exe", entry.FullName); + Assert.Equal("ndx.exe", entry.FullName); using var stream = entry.Open(); using var memory = new MemoryStream(); stream.CopyTo(memory); @@ -41,22 +41,22 @@ public void Windows_rid_emits_zip_of_ndnx_exe_and_matching_sha256(string rid) [InlineData("linux-arm64")] [InlineData("osx-x64")] [InlineData("osx-arm64")] - public void Unix_rid_emits_targz_of_ndnx_and_matching_sha256(string rid) + public void Unix_rid_emits_targz_of_ndx_and_matching_sha256(string rid) { using var dir = new TempDir(); var payload = "unix-native-bytes"u8.ToArray(); - File.WriteAllBytes(Path.Combine(dir.Publish, "ndnx"), payload); + File.WriteAllBytes(Path.Combine(dir.Publish, "ndx"), payload); var result = NativePacker.Pack(dir.Publish, rid, dir.Output, "4.5.6"); - Assert.Equal($"ndnx-4.5.6-{rid}.tar.gz", Path.GetFileName(result.ArchivePath)); + Assert.Equal($"ndx-4.5.6-{rid}.tar.gz", Path.GetFileName(result.ArchivePath)); using var file = File.OpenRead(result.ArchivePath); using var gzip = new GZipStream(file, CompressionMode.Decompress); using var tar = new TarReader(gzip); var entry = tar.GetNextEntry(copyData: true); Assert.NotNull(entry); - Assert.Equal("ndnx", entry.Name); + Assert.Equal("ndx", entry.Name); using var memory = new MemoryStream(); entry.DataStream!.CopyTo(memory); Assert.Equal(payload, memory.ToArray()); @@ -69,17 +69,17 @@ public void Unix_rid_emits_targz_of_ndnx_and_matching_sha256(string rid) public void Program_main_packs_through_the_shipped_entry_point() { using var dir = new TempDir(); - File.WriteAllBytes(Path.Combine(dir.Publish, "ndnx.exe"), "entry-point"u8.ToArray()); + File.WriteAllBytes(Path.Combine(dir.Publish, "ndx.exe"), "entry-point"u8.ToArray()); var code = PackProgram.Main([dir.Publish, "win-x64", dir.Output, "9.9.9"]); Assert.Equal(0, code); - var archive = Path.Combine(dir.Output, "ndnx-9.9.9-win-x64.zip"); + var archive = Path.Combine(dir.Output, "ndx-9.9.9-win-x64.zip"); var sha = archive + ".sha256"; Assert.True(File.Exists(archive)); Assert.True(File.Exists(sha)); using var zip = ZipFile.OpenRead(archive); - Assert.Equal("ndnx.exe", Assert.Single(zip.Entries).FullName); + Assert.Equal("ndx.exe", Assert.Single(zip.Entries).FullName); var expected = Convert.ToHexString(SHA256.HashData(File.ReadAllBytes(archive))).ToLowerInvariant(); Assert.StartsWith(expected, File.ReadAllText(sha).Trim(), StringComparison.OrdinalIgnoreCase); } @@ -90,7 +90,7 @@ public void Missing_binary_is_a_packer_error() using var dir = new TempDir(); var ex = Assert.Throws( () => NativePacker.Pack(dir.Publish, "win-x64", dir.Output, "1.0.0")); - Assert.Contains("ndnx.exe", ex.Message); + Assert.Contains("ndx.exe", ex.Message); Assert.Equal(1, PackProgram.Main([dir.Publish, "linux-x64", dir.Output, "1.0.0"])); } @@ -106,7 +106,7 @@ static void AssertSha256File(NativePackResult result) sealed class TempDir : IDisposable { - public string Root { get; } = Path.Combine(Path.GetTempPath(), "ndnx-pack-tests", Guid.NewGuid().ToString("n")); + public string Root { get; } = Path.Combine(Path.GetTempPath(), "ndx-pack-tests", Guid.NewGuid().ToString("n")); public string Publish => Path.Combine(Root, "publish"); public string Output => Path.Combine(Root, "out"); diff --git a/src/Tests/NetConfigTests.cs b/src/Tests/NetConfigTests.cs index c669814..32c277f 100644 --- a/src/Tests/NetConfigTests.cs +++ b/src/Tests/NetConfigTests.cs @@ -1,4 +1,4 @@ -using ndnx; +using ndx; namespace Tests; @@ -18,7 +18,7 @@ public void Reads_interval_from_working_directory_netconfig() var dir = NewDir(); File.WriteAllText(Path.Combine(dir, ".netconfig"), """ - [ndnx] + [ndx] interval = 2 """); @@ -33,7 +33,7 @@ public void Quoted_and_commented_values_parse() File.WriteAllText(Path.Combine(dir, ".netconfig"), """ # comment - [ndnx] + [ndx] interval = "7" ; seconds """); @@ -47,7 +47,7 @@ public void Invalid_or_non_positive_interval_is_ignored() var dir = NewDir(); File.WriteAllText(Path.Combine(dir, ".netconfig"), """ - [ndnx] + [ndx] interval = 0 """); @@ -61,7 +61,7 @@ public void Walks_up_to_parent_netconfig() var root = NewDir(); File.WriteAllText(Path.Combine(root, ".netconfig"), """ - [ndnx] + [ndx] interval = 3 """); var child = Path.Combine(root, "sub"); @@ -78,7 +78,7 @@ public void User_profile_is_used_when_cwd_has_no_interval() var home = NewDir(); File.WriteAllText(Path.Combine(home, ".netconfig"), """ - [ndnx] + [ndx] interval = 9 """); @@ -94,7 +94,7 @@ public void Other_sections_are_ignored() """ [evergreen] interval = 1 - [ndnx "other"] + [ndx "other"] interval = 2 """); @@ -104,7 +104,7 @@ public void Other_sections_are_ignored() static string NewDir() { - var dir = Path.Combine(Path.GetTempPath(), "ndnx-netconfig", Guid.NewGuid().ToString("n")); + var dir = Path.Combine(Path.GetTempPath(), "ndx-netconfig", Guid.NewGuid().ToString("n")); Directory.CreateDirectory(dir); return dir; } diff --git a/src/Tests/PackageFeedTests.cs b/src/Tests/PackageFeedTests.cs index c96b838..d90bb46 100644 --- a/src/Tests/PackageFeedTests.cs +++ b/src/Tests/PackageFeedTests.cs @@ -2,7 +2,7 @@ using System.Net; using System.Runtime.InteropServices; using System.Text; -using ndnx; +using ndx; namespace Tests; @@ -227,7 +227,7 @@ public async Task Http_download_with_progress_disabled_writes_no_progress_ui() MapCatalog(handler, PackageId, body.Length); using var error = new StringWriter(); using var output = new StringWriter(); - var host = new NdnxHost + var host = new NdxHost { HttpHandler = handler, Error = error, @@ -258,7 +258,7 @@ public async Task App_writes_download_progress_to_host_Progress() using var error = new StringWriter(); using var progress = new StringWriter(); using var output = new StringWriter(); - var host = new NdnxHost + var host = new NdxHost { HttpHandler = handler, Error = error, @@ -345,7 +345,7 @@ static byte[] SizedBody(int length) static void SaveEvidence(string fileName, string content) { - var dir = Environment.GetEnvironmentVariable("NDNX_PROGRESS_EVIDENCE"); + var dir = Environment.GetEnvironmentVariable("NDX_PROGRESS_EVIDENCE"); if (string.IsNullOrWhiteSpace(dir)) return; Directory.CreateDirectory(dir); @@ -376,14 +376,14 @@ static PackageVersion ParseVersion() static string NewStore() { - var store = Path.Combine(Path.GetTempPath(), "ndnx-feed-tests", Guid.NewGuid().ToString("n")); + var store = Path.Combine(Path.GetTempPath(), "ndx-feed-tests", Guid.NewGuid().ToString("n")); Directory.CreateDirectory(store); return store; } sealed class TempNupkgs : IDisposable { - public string Root { get; } = Path.Combine(Path.GetTempPath(), "ndnx-feed-nupkgs", Guid.NewGuid().ToString("n")); + public string Root { get; } = Path.Combine(Path.GetTempPath(), "ndx-feed-nupkgs", Guid.NewGuid().ToString("n")); public string Plain { get; } public string RidWrapper { get; } public string RidImpl { get; } @@ -430,7 +430,7 @@ string WriteTool(string packageId, string commandName, (string Rid, string Id)? {packageId} {VersionText} - ndnx + ndx {packageId} diff --git a/src/Tests/ProcessStopTests.cs b/src/Tests/ProcessStopTests.cs index 047a1af..c2e22da 100644 --- a/src/Tests/ProcessStopTests.cs +++ b/src/Tests/ProcessStopTests.cs @@ -1,5 +1,5 @@ using System.Diagnostics; -using ndnx; +using ndx; namespace Tests; @@ -43,7 +43,7 @@ public async Task Windows_wm_close_stops_a_hidden_window() static ChildProcess StartLinger(bool ignoreCancel) { - var dir = Path.Combine(Path.GetTempPath(), "ndnx-linger", Guid.NewGuid().ToString("n")); + var dir = Path.Combine(Path.GetTempPath(), "ndx-linger", Guid.NewGuid().ToString("n")); Directory.CreateDirectory(dir); var file = Path.Combine(dir, "linger.cs"); File.WriteAllText(file, ignoreCancel @@ -72,7 +72,7 @@ static ChildProcess StartLinger(bool ignoreCancel) static ChildProcess StartGuiLinger() { - var dir = Path.Combine(Path.GetTempPath(), "ndnx-linger-gui", Guid.NewGuid().ToString("n")); + var dir = Path.Combine(Path.GetTempPath(), "ndx-linger-gui", Guid.NewGuid().ToString("n")); Directory.CreateDirectory(dir); var file = Path.Combine(dir, "linger-gui.cs"); File.WriteAllText(file, @@ -87,10 +87,10 @@ public static void Run() var wndClass = new WndClass { lpfnWndProc = WndProc, - lpszClassName = "ndnxLingerGui", + lpszClassName = "ndxLingerGui", }; RegisterClass(ref wndClass); - var hwnd = CreateWindowEx(0, "ndnxLingerGui", "ndnx-linger", 0x00CF0000, 0, 0, 80, 80, 0, 0, 0, 0); + var hwnd = CreateWindowEx(0, "ndxLingerGui", "ndx-linger", 0x00CF0000, 0, 0, 80, 80, 0, 0, 0, 0); ShowWindow(hwnd, 0); Console.WriteLine("ready"); while (GetMessage(out var msg, 0, 0, 0) > 0) diff --git a/src/Tests/PublishWorkflowTests.cs b/src/Tests/PublishWorkflowTests.cs index e5d4e64..9e6620e 100644 --- a/src/Tests/PublishWorkflowTests.cs +++ b/src/Tests/PublishWorkflowTests.cs @@ -27,7 +27,7 @@ public void Ci_release_workflow_publishes_a_rolling_prerelease() Assert.Contains("--clobber", yml); Assert.Contains("select(.tag_name == \"ci\")", yml); Assert.Contains("git/refs/tags/ci", yml); - Assert.Contains("--target $env:NDNX_SHA", yml); + Assert.Contains("--target $env:NDX_SHA", yml); Assert.Contains("Expected archives on the ci release", yml); Assert.Contains("Get-ChildItem native -Recurse -File", yml); Assert.Contains("cancel-in-progress: false", yml); @@ -112,7 +112,7 @@ static string FindRepoRoot() var dir = new DirectoryInfo(AppContext.BaseDirectory); while (dir is not null) { - if (File.Exists(Path.Combine(dir.FullName, "ndnx.slnx"))) + if (File.Exists(Path.Combine(dir.FullName, "ndx.slnx"))) return dir.FullName; dir = dir.Parent; } diff --git a/src/Tests/PublishedToolTests.cs b/src/Tests/PublishedToolTests.cs index 9ec3a9a..82da669 100644 --- a/src/Tests/PublishedToolTests.cs +++ b/src/Tests/PublishedToolTests.cs @@ -1,6 +1,6 @@ using System.Diagnostics; using System.Runtime.InteropServices; -using ndnx; +using ndx; namespace Tests; @@ -18,7 +18,7 @@ public class PublishedToolTests const string GoId = "go"; const string GoVersion = "1.1.1"; - static readonly string Store = Path.Combine(Path.GetTempPath(), "ndnx-published-tool-store"); + static readonly string Store = Path.Combine(Path.GetTempPath(), "ndx-published-tool-store"); [Fact] public async Task Published_stop_hops_to_rid_package_and_runs_help() @@ -38,7 +38,7 @@ public async Task Published_stop_hops_to_rid_package_and_runs_help() Path.GetFullPath(command.EntryPointPath), StringComparison.OrdinalIgnoreCase); - var result = LaunchNdnx([StopId + "@" + StopVersion, "--yes", "--source", NugetOrg, "--", "--help"]); + var result = LaunchNdx([StopId + "@" + StopVersion, "--yes", "--source", NugetOrg, "--", "--help"]); Assert.Equal(0, result.ExitCode); Assert.Contains("timeout", result.Stdout + result.Stderr, StringComparison.OrdinalIgnoreCase); Assert.True(Cached(expectedPackage, StopVersion), expectedPackage); @@ -70,7 +70,7 @@ public async Task Published_go_hops_to_portable_rid_without_any_fallback() command.EntryPointPath, StringComparison.OrdinalIgnoreCase); - var result = LaunchNdnx([GoId + "@" + GoVersion, "--yes", "--source", NugetOrg, "--", "--help"]); + var result = LaunchNdx([GoId + "@" + GoVersion, "--yes", "--source", NugetOrg, "--", "--help"]); Assert.Equal(0, result.ExitCode); Assert.Contains("file-based", result.Stdout + result.Stderr, StringComparison.OrdinalIgnoreCase); Assert.True(Cached(expectedPackage, GoVersion), expectedPackage); @@ -157,10 +157,10 @@ static async Task GetPublishedAsync(string packageId, string versio static bool Cached(string packageId, string version) => ToolPackageStore.IsCached(Path.Combine(Store, packageId.ToLowerInvariant(), version.ToLowerInvariant())); - static (int ExitCode, string Stdout, string Stderr) LaunchNdnx(string[] args) + static (int ExitCode, string Stdout, string Stderr) LaunchNdx(string[] args) { - var ndnxDll = Path.Combine(AppContext.BaseDirectory, "ndnx.dll"); - Assert.True(File.Exists(ndnxDll), $"Expected shipped ndnx.dll at {ndnxDll}"); + var ndxDll = Path.Combine(AppContext.BaseDirectory, "ndx.dll"); + Assert.True(File.Exists(ndxDll), $"Expected shipped ndx.dll at {ndxDll}"); var start = new ProcessStartInfo { @@ -170,10 +170,10 @@ static bool Cached(string packageId, string version) UseShellExecute = false, }; start.ArgumentList.Add("exec"); - start.ArgumentList.Add(ndnxDll); + start.ArgumentList.Add(ndxDll); foreach (var arg in args) start.ArgumentList.Add(arg); - start.Environment["NDNX_STORE"] = Store; + start.Environment["NDX_STORE"] = Store; return ProcessCapture.Run(start); } } diff --git a/src/Tests/RecordingProcessRunner.cs b/src/Tests/RecordingProcessRunner.cs index fe073a2..05737d2 100644 --- a/src/Tests/RecordingProcessRunner.cs +++ b/src/Tests/RecordingProcessRunner.cs @@ -1,4 +1,4 @@ -using ndnx; +using ndx; namespace Tests; diff --git a/src/Tests/RidPackageResolverTests.cs b/src/Tests/RidPackageResolverTests.cs index 6661c92..dc1be50 100644 --- a/src/Tests/RidPackageResolverTests.cs +++ b/src/Tests/RidPackageResolverTests.cs @@ -1,5 +1,5 @@ using System.Runtime.InteropServices; -using ndnx; +using ndx; namespace Tests; diff --git a/src/Tests/SelfUpdateTests.cs b/src/Tests/SelfUpdateTests.cs index c67af47..4e19698 100644 --- a/src/Tests/SelfUpdateTests.cs +++ b/src/Tests/SelfUpdateTests.cs @@ -1,28 +1,28 @@ using System.Net; using System.Text; -using ndnx; +using ndx; namespace Tests; public class SelfUpdateTests { - const string Repo = "devlooped/ndnx"; + const string Repo = "devlooped/ndx"; const string Rid = "win-x64"; [Theory] - [InlineData("0.2.0", "ndnx 0.2.0")] - [InlineData("v0.2.0", "ndnx 0.2.0")] - [InlineData("0.2.0+abcdef123", "ndnx 0.2.0 (abcdef123)")] - [InlineData("0.2.0+abcdef1234567890", "ndnx 0.2.0 (abcdef123)")] - [InlineData("v0.2.0+abcdef123.dirty", "ndnx 0.2.0 (abcdef123)")] - public void FormatVersion_renders_ndnx_version_and_short_sha(string informational, string expected) + [InlineData("0.2.0", "ndx 0.2.0")] + [InlineData("v0.2.0", "ndx 0.2.0")] + [InlineData("0.2.0+abcdef123", "ndx 0.2.0 (abcdef123)")] + [InlineData("0.2.0+abcdef1234567890", "ndx 0.2.0 (abcdef123)")] + [InlineData("v0.2.0+abcdef123.dirty", "ndx 0.2.0 (abcdef123)")] + public void FormatVersion_renders_ndx_version_and_short_sha(string informational, string expected) => Assert.Equal(expected, SelfUpdate.FormatVersion(informational)); [Fact] public void FormatVersion_reads_assembly_informational_version() { var formatted = SelfUpdate.FormatVersion(); - Assert.StartsWith("ndnx ", formatted); + Assert.StartsWith("ndx ", formatted); Assert.Contains(SelfUpdate.ReadCurrentVersion(), formatted); } @@ -30,7 +30,7 @@ public void FormatVersion_reads_assembly_informational_version() public async Task Update_to_latest_replaces_the_binary_and_prints_the_target_version() { using var dir = new TempDir(); - var current = Path.Combine(dir.Prefix, "ndnx.exe"); + var current = Path.Combine(dir.Prefix, "ndx.exe"); File.WriteAllBytes(current, "old-binary"u8.ToArray()); using var handler = Feed(dir, latest: "0.2.0", payload: "new-binary"u8.ToArray()); @@ -49,7 +49,7 @@ public async Task Update_to_latest_replaces_the_binary_and_prints_the_target_ver public async Task Update_skips_download_when_already_on_latest() { using var dir = new TempDir(); - var current = Path.Combine(dir.Prefix, "ndnx.exe"); + var current = Path.Combine(dir.Prefix, "ndx.exe"); var payload = "same-binary"u8.ToArray(); File.WriteAllBytes(current, payload); @@ -69,7 +69,7 @@ public async Task Update_skips_download_when_already_on_latest() public async Task Update_to_ci_downloads_the_rolling_prerelease_tag() { using var dir = new TempDir(); - var current = Path.Combine(dir.Prefix, "ndnx.exe"); + var current = Path.Combine(dir.Prefix, "ndx.exe"); File.WriteAllBytes(current, "old-binary"u8.ToArray()); using var handler = new MapHandler(); @@ -90,7 +90,7 @@ public async Task Update_to_ci_downloads_the_rolling_prerelease_tag() public async Task Update_to_ci_redownloads_even_when_already_labeled_ci() { using var dir = new TempDir(); - var current = Path.Combine(dir.Prefix, "ndnx.exe"); + var current = Path.Combine(dir.Prefix, "ndx.exe"); File.WriteAllBytes(current, "stale-ci"u8.ToArray()); using var handler = new MapHandler(); @@ -108,7 +108,7 @@ public async Task Update_to_ci_redownloads_even_when_already_labeled_ci() public async Task Update_to_an_older_version_is_allowed() { using var dir = new TempDir(); - var current = Path.Combine(dir.Prefix, "ndnx.exe"); + var current = Path.Combine(dir.Prefix, "ndx.exe"); File.WriteAllBytes(current, "newer-binary"u8.ToArray()); using var handler = Feed(dir, latest: "0.2.0", payload: "older-binary"u8.ToArray(), extraVersion: "0.1.0"); @@ -126,7 +126,7 @@ public async Task Update_to_an_older_version_is_allowed() public async Task Update_to_a_missing_version_fails() { using var dir = new TempDir(); - var current = Path.Combine(dir.Prefix, "ndnx.exe"); + var current = Path.Combine(dir.Prefix, "ndx.exe"); File.WriteAllBytes(current, "old-binary"u8.ToArray()); using var handler = Feed(dir, latest: "0.2.0", payload: "new-binary"u8.ToArray()); @@ -144,14 +144,14 @@ public async Task Update_to_a_missing_version_fails() public async Task Update_extracts_a_unix_targz_archive() { using var dir = new TempDir(); - var current = Path.Combine(dir.Prefix, "ndnx"); + var current = Path.Combine(dir.Prefix, "ndx"); File.WriteAllBytes(current, "old-unix"u8.ToArray()); const string unixRid = "linux-x64"; using var handler = new MapHandler(); var publish = Path.Combine(dir.Root, "publish-unix"); Directory.CreateDirectory(publish); - File.WriteAllBytes(Path.Combine(publish, "ndnx"), "new-unix"u8.ToArray()); + File.WriteAllBytes(Path.Combine(publish, "ndx"), "new-unix"u8.ToArray()); var packed = NativePacker.Pack(publish, unixRid, Path.Combine(dir.Root, "out-unix"), "0.3.0"); var name = Path.GetFileName(packed.ArchivePath); handler.Map[SelfUpdate.AssetUrl(Repo, "v0.3.0", name)] = @@ -159,7 +159,7 @@ public async Task Update_extracts_a_unix_targz_archive() handler.Map[SelfUpdate.AssetUrl(Repo, "v0.3.0", name) + ".sha256"] = (HttpStatusCode.OK, File.ReadAllBytes(packed.Sha256Path), "text/plain"); - var host = new NdnxHost + var host = new NdxHost { WorkingDirectory = dir.Root, StoreDirectory = dir.Store, @@ -183,7 +183,7 @@ public async Task Update_extracts_a_unix_targz_archive() public async Task Update_does_not_launch_a_child() { using var dir = new TempDir(); - var current = Path.Combine(dir.Prefix, "ndnx.exe"); + var current = Path.Combine(dir.Prefix, "ndx.exe"); File.WriteAllBytes(current, "old-binary"u8.ToArray()); using var handler = Feed(dir, latest: "0.2.0", payload: "new-binary"u8.ToArray()); @@ -200,7 +200,7 @@ public async Task Update_does_not_launch_a_child() public async Task Sha256_mismatch_leaves_the_current_binary() { using var dir = new TempDir(); - var current = Path.Combine(dir.Prefix, "ndnx.exe"); + var current = Path.Combine(dir.Prefix, "ndx.exe"); File.WriteAllBytes(current, "old-binary"u8.ToArray()); using var handler = Feed(dir, latest: "0.2.0", payload: "new-binary"u8.ToArray()); @@ -216,7 +216,7 @@ public async Task Sha256_mismatch_leaves_the_current_binary() Assert.Contains("SHA256", host.Error.ToString()); } - static NdnxHost NewHost(TempDir dir, string executable, string currentVersion, MapHandler handler, IProcessRunner? runner = null) + static NdxHost NewHost(TempDir dir, string executable, string currentVersion, MapHandler handler, IProcessRunner? runner = null) => new() { WorkingDirectory = dir.Root, @@ -252,7 +252,7 @@ static void AddRelease(MapHandler handler, TempDir dir, string version, byte[] p { var publish = Path.Combine(dir.Root, "publish-" + version); Directory.CreateDirectory(publish); - File.WriteAllBytes(Path.Combine(publish, "ndnx.exe"), payload); + File.WriteAllBytes(Path.Combine(publish, "ndx.exe"), payload); var packed = NativePacker.Pack(publish, Rid, Path.Combine(dir.Root, "out-" + version), version); var archive = File.ReadAllBytes(packed.ArchivePath); var sha = File.ReadAllBytes(packed.Sha256Path); @@ -292,7 +292,7 @@ protected override Task SendAsync(HttpRequestMessage reques sealed class TempDir : IDisposable { - public string Root { get; } = Path.Combine(Path.GetTempPath(), "ndnx-update-tests", Guid.NewGuid().ToString("n")); + public string Root { get; } = Path.Combine(Path.GetTempPath(), "ndx-update-tests", Guid.NewGuid().ToString("n")); public string Prefix => Path.Combine(Root, "prefix"); public string Store => Path.Combine(Root, "store"); diff --git a/src/Tests/SourceGuardTests.cs b/src/Tests/SourceGuardTests.cs index 0ea52e3..a6a5b60 100644 --- a/src/Tests/SourceGuardTests.cs +++ b/src/Tests/SourceGuardTests.cs @@ -3,12 +3,12 @@ namespace Tests; public class SourceGuardTests { [Fact] - public void Ndnx_sources_do_not_gate_on_child_aot() + public void Ndx_sources_do_not_gate_on_child_aot() { - var ndnxDir = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", "ndnx")); - Assert.True(Directory.Exists(ndnxDir), $"Could not find ndnx sources at {ndnxDir}"); + var ndxDir = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", "ndx")); + Assert.True(Directory.Exists(ndxDir), $"Could not find ndx sources at {ndxDir}"); - foreach (var file in Directory.GetFiles(ndnxDir, "*.cs")) + foreach (var file in Directory.GetFiles(ndxDir, "*.cs")) { var text = File.ReadAllText(file); Assert.DoesNotContain("IsNativeAot", text, StringComparison.OrdinalIgnoreCase); diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index a3aec35..8dc5347 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -13,7 +13,7 @@ - + \ No newline at end of file diff --git a/src/Tests/ToolInvokeTests.cs b/src/Tests/ToolInvokeTests.cs index 4448c05..decd843 100644 --- a/src/Tests/ToolInvokeTests.cs +++ b/src/Tests/ToolInvokeTests.cs @@ -1,5 +1,5 @@ using System.Diagnostics; -using ndnx; +using ndx; namespace Tests; @@ -10,10 +10,10 @@ public class ToolInvokeTests : IClassFixture public ToolInvokeTests(HelloToolFeed feed) => this.feed = feed; [Fact] - public async Task Version_alone_prints_ndnx_version_and_does_not_launch() + public async Task Version_alone_prints_ndx_version_and_does_not_launch() { var runner = new RecordingProcessRunner(); - var host = new NdnxHost + var host = new NdxHost { WorkingDirectory = feed.Root, StoreDirectory = NewStore(), @@ -27,7 +27,7 @@ public async Task Version_alone_prints_ndnx_version_and_does_not_launch() Assert.Equal(0, code); Assert.Equal(0, runner.Calls); - Assert.Equal("ndnx 0.2.0" + Environment.NewLine, host.Out.ToString()); + Assert.Equal("ndx 0.2.0" + Environment.NewLine, host.Out.ToString()); Assert.Equal("", host.Error.ToString()); } @@ -35,7 +35,7 @@ public async Task Version_alone_prints_ndnx_version_and_does_not_launch() public async Task Version_alone_includes_the_short_sha_from_informational_version() { var runner = new RecordingProcessRunner(); - var host = new NdnxHost + var host = new NdxHost { WorkingDirectory = feed.Root, StoreDirectory = NewStore(), @@ -49,7 +49,7 @@ public async Task Version_alone_includes_the_short_sha_from_informational_versio Assert.Equal(0, code); Assert.Equal(0, runner.Calls); - Assert.Equal("ndnx 0.2.0 (abcdef123)" + Environment.NewLine, host.Out.ToString()); + Assert.Equal("ndx 0.2.0 (abcdef123)" + Environment.NewLine, host.Out.ToString()); } [Fact] @@ -113,10 +113,10 @@ public async Task Executable_runner_fixture_runs_the_same_way() } [Fact] - public void Real_entry_point_writes_fixture_stdout_on_ndnx_stdout() + public void Real_entry_point_writes_fixture_stdout_on_ndx_stdout() { var store = NewStore(); - var result = LaunchNdnx( + var result = LaunchNdx( store, [HelloToolFeed.PackageId + "@" + HelloToolFeed.PackageVersion, "--yes", "--source", feed.FeedDirectory, "--", "0", "via-entry"]); @@ -130,7 +130,7 @@ public void Real_entry_point_writes_fixture_stdout_on_ndnx_stdout() public void Real_entry_point_relays_nonzero_exit_and_stdout() { var store = NewStore(); - var result = LaunchNdnx( + var result = LaunchNdx( store, [HelloToolFeed.PackageId + "@" + HelloToolFeed.PackageVersion, "--yes", "--source", feed.FeedDirectory, "--", "11"]); @@ -174,7 +174,7 @@ public async Task Multi_rid_any_fallback_uses_any_package_not_wrapper() StringComparison.OrdinalIgnoreCase); Assert.True(File.Exists(Path.Combine(wrapperDir, "tools", "any", "any", "DotnetToolSettings.xml"))); - var result = LaunchNdnx( + var result = LaunchNdx( storeDir, [HelloToolFeed.AnyWrapperId + "@" + HelloToolFeed.PackageVersion, "--yes", "--source", feed.FeedDirectory, "--", "0", "from-any"]); Assert.Equal(0, result.ExitCode); @@ -220,14 +220,14 @@ public void Multi_rid_real_entry_prints_rid_phrase_and_caches() "via-multirid", }; - var first = LaunchNdnx(store, args); + var first = LaunchNdx(store, args); Assert.Equal(0, first.ExitCode); Assert.Contains(HelloToolFeed.Phrase, first.Stdout); Assert.DoesNotContain("declares RID-specific packages", first.Stdout + first.Stderr); Assert.True(Cached(store, HelloToolFeed.RidImplId)); var markerTime = File.GetLastWriteTimeUtc(Marker(store, HelloToolFeed.RidImplId)); - var second = LaunchNdnx(store, args); + var second = LaunchNdx(store, args); Assert.Equal(0, second.ExitCode); Assert.Contains(HelloToolFeed.Phrase, second.Stdout); Assert.Equal(markerTime, File.GetLastWriteTimeUtc(Marker(store, HelloToolFeed.RidImplId))); @@ -286,10 +286,10 @@ public async Task Exact_version_that_is_not_installed_queries_the_feed() Assert.Contains("Unexpected HTTP", error.Message); } - NdnxHost NewHost(IProcessRunner runner, string? store = null) + NdxHost NewHost(IProcessRunner runner, string? store = null) { store ??= NewStore(); - return new NdnxHost + return new NdxHost { WorkingDirectory = feed.Root, StoreDirectory = store, @@ -355,7 +355,7 @@ static PackageVersion ParsedFixtureVersion() static string NewStore() { - var store = Path.Combine(Path.GetTempPath(), "ndnx-test-store", Guid.NewGuid().ToString("n")); + var store = Path.Combine(Path.GetTempPath(), "ndx-test-store", Guid.NewGuid().ToString("n")); Directory.CreateDirectory(store); return store; } @@ -374,10 +374,10 @@ static string Marker(string store, string packageId) return Path.Combine(store, packageId.ToLowerInvariant(), version, ToolPackageStore.ReadyMarker); } - static (int ExitCode, string Stdout, string Stderr) LaunchNdnx(string store, string[] args) + static (int ExitCode, string Stdout, string Stderr) LaunchNdx(string store, string[] args) { - var ndnxDll = Path.Combine(AppContext.BaseDirectory, "ndnx.dll"); - Assert.True(File.Exists(ndnxDll), $"Expected shipped ndnx.dll at {ndnxDll}"); + var ndxDll = Path.Combine(AppContext.BaseDirectory, "ndx.dll"); + Assert.True(File.Exists(ndxDll), $"Expected shipped ndx.dll at {ndxDll}"); var start = new ProcessStartInfo { @@ -387,10 +387,10 @@ static string Marker(string store, string packageId) UseShellExecute = false, }; start.ArgumentList.Add("exec"); - start.ArgumentList.Add(ndnxDll); + start.ArgumentList.Add(ndxDll); foreach (var arg in args) start.ArgumentList.Add(arg); - start.Environment["NDNX_STORE"] = store; + start.Environment["NDX_STORE"] = store; return ProcessCapture.Run(start); } } diff --git a/src/Tests/ToolLauncherTests.cs b/src/Tests/ToolLauncherTests.cs index fa0b1ba..7320f23 100644 --- a/src/Tests/ToolLauncherTests.cs +++ b/src/Tests/ToolLauncherTests.cs @@ -1,4 +1,4 @@ -using ndnx; +using ndx; namespace Tests; diff --git a/src/Tests/V3PackageLayoutTests.cs b/src/Tests/V3PackageLayoutTests.cs index a704823..5fb6f15 100644 --- a/src/Tests/V3PackageLayoutTests.cs +++ b/src/Tests/V3PackageLayoutTests.cs @@ -1,7 +1,7 @@ using System.IO.Compression; using System.Security.Cryptography; using System.Text; -using ndnx; +using ndx; namespace Tests; @@ -195,7 +195,7 @@ static void WriteTinyToolNupkg(string path) hello-tool 1.0.0 - ndnx + ndx tiny @@ -222,7 +222,7 @@ static void WriteEntry(ZipArchive zip, string name, string content) sealed class TempDir : IDisposable { public string Path { get; } = System.IO.Path.Combine( - System.IO.Path.GetTempPath(), "ndnx-v3-tests", Guid.NewGuid().ToString("n")); + System.IO.Path.GetTempPath(), "ndx-v3-tests", Guid.NewGuid().ToString("n")); public TempDir() => Directory.CreateDirectory(Path); diff --git a/src/Tests/VersionRangeTests.cs b/src/Tests/VersionRangeTests.cs index bcdfc07..5ee61dd 100644 --- a/src/Tests/VersionRangeTests.cs +++ b/src/Tests/VersionRangeTests.cs @@ -1,4 +1,4 @@ -using ndnx; +using ndx; namespace Tests; diff --git a/src/nativepack/NativePacker.cs b/src/nativepack/NativePacker.cs index 0fbf3dc..ebc3662 100644 --- a/src/nativepack/NativePacker.cs +++ b/src/nativepack/NativePacker.cs @@ -2,7 +2,7 @@ using System.IO.Compression; using System.Security.Cryptography; -namespace ndnx; +namespace ndx; /// /// Turns a Native AOT publish directory into the archive + SHA256 @@ -14,12 +14,12 @@ public static bool IsWindowsRid(string rid) => rid.StartsWith("win", StringComparison.OrdinalIgnoreCase); public static string BinaryFileName(string rid) - => IsWindowsRid(rid) ? "ndnx.exe" : "ndnx"; + => IsWindowsRid(rid) ? "ndx.exe" : "ndx"; public static string ArchiveFileName(string rid, string version) => IsWindowsRid(rid) - ? $"ndnx-{version}-{rid}.zip" - : $"ndnx-{version}-{rid}.tar.gz"; + ? $"ndx-{version}-{rid}.zip" + : $"ndx-{version}-{rid}.tar.gz"; public static NativePackResult Pack( string publishDirectory, diff --git a/src/nativepack/Program.cs b/src/nativepack/Program.cs index 35e57c4..0deb3c4 100644 --- a/src/nativepack/Program.cs +++ b/src/nativepack/Program.cs @@ -1,4 +1,4 @@ -namespace ndnx; +namespace ndx; public static class PackProgram { diff --git a/src/nativepack/nativepack.csproj b/src/nativepack/nativepack.csproj index a49123f..eb02657 100644 --- a/src/nativepack/nativepack.csproj +++ b/src/nativepack/nativepack.csproj @@ -4,10 +4,10 @@ net10.0 enable enable - ndnx + ndx nativepack false false - ndnx.PackProgram + ndx.PackProgram diff --git a/src/ndnx/App.cs b/src/ndx/App.cs similarity index 85% rename from src/ndnx/App.cs rename to src/ndx/App.cs index 18b99c9..461c799 100644 --- a/src/ndnx/App.cs +++ b/src/ndx/App.cs @@ -1,9 +1,9 @@ -namespace ndnx; +namespace ndx; /// -/// Host overrides used by tests. Production uses . +/// Host overrides used by tests. Production uses . /// -public sealed class NdnxHost +public sealed class NdxHost { public string WorkingDirectory { get; init; } = Directory.GetCurrentDirectory(); public string StoreDirectory { get; init; } = DefaultStoreDirectory(); @@ -21,7 +21,7 @@ public sealed class NdnxHost public bool ShowProgress { get; init; } public TextWriter? Progress { get; init; } - public static NdnxHost CreateDefault() + public static NdxHost CreateDefault() { var progress = ConsoleProgress.TryOpen(); return new() @@ -32,22 +32,22 @@ public static NdnxHost CreateDefault() } public static string DefaultStoreDirectory(string? workingDirectory = null) - => Environment.GetEnvironmentVariable("NDNX_STORE") + => Environment.GetEnvironmentVariable("NDX_STORE") ?? GlobalPackagesFolder.Resolve(workingDirectory); } /// -/// ndnx entry orchestration: parse, download-to-cache, start child, relay exit code. +/// ndx entry orchestration: parse, download-to-cache, start child, relay exit code. /// public static class App { const string Usage = """ - Usage: ndnx [options] [--] [tool arguments] - ndnx --update [VERSION|ci] - ndnx --version + Usage: ndx [options] [--] [tool arguments] + ndx --update [VERSION|ci] + ndx --version A floating version (unspecified, @*, @*-*, or a range) stays current: - ndnx watches the feed and restarts the tool when a newer match appears. + ndx watches the feed and restarts the tool when a newer match appears. Options: --source Override package sources @@ -63,14 +63,14 @@ ndnx watches the feed and restarts the tool when a newer match appears. --no-http-cache Do not use an HTTP cache --interactive Allow interactive restore prompts --update [VERSION] Self-update to latest, a version, or ci (rolling prerelease) - --version Print the ndnx version + --version Print the ndx version """; public static int Run(string[] args) => RunAsync(args).GetAwaiter().GetResult(); - public static async Task RunAsync(string[] args, NdnxHost? host = null, CancellationToken cancellationToken = default) + public static async Task RunAsync(string[] args, NdxHost? host = null, CancellationToken cancellationToken = default) { - host ??= NdnxHost.CreateDefault(); + host ??= NdxHost.CreateDefault(); var invocation = ArgParser.Parse(args); if (invocation.ShowHelp) { @@ -133,7 +133,7 @@ public static async Task RunAsync(string[] args, NdnxHost? host = null, Can } } - static HttpClient CreateHttpClient(NdnxHost host) + static HttpClient CreateHttpClient(NdxHost host) => host.HttpHandler is { } handler ? new HttpClient(handler, disposeHandler: false) : new HttpClient(new SocketsHttpHandler diff --git a/src/ndnx/ArgParser.cs b/src/ndx/ArgParser.cs similarity index 98% rename from src/ndnx/ArgParser.cs rename to src/ndx/ArgParser.cs index f78f0bd..7397907 100644 --- a/src/ndnx/ArgParser.cs +++ b/src/ndx/ArgParser.cs @@ -1,10 +1,10 @@ -namespace ndnx; +namespace ndx; /// /// dnx.cmd-compatible argv split: first operand is PACKAGE[@VERSION], listed -/// flags are consumed by ndnx, everything else (including tokens after --) is +/// flags are consumed by ndx, everything else (including tokens after --) is /// forwarded to the child. --update [VERSION] is a standalone self-update. -/// A lone --version prints the ndnx version. +/// A lone --version prints the ndx version. /// public static class ArgParser { diff --git a/src/ndnx/ChildProcess.cs b/src/ndx/ChildProcess.cs similarity index 99% rename from src/ndnx/ChildProcess.cs rename to src/ndx/ChildProcess.cs index b2772ca..9ee9e8d 100644 --- a/src/ndnx/ChildProcess.cs +++ b/src/ndx/ChildProcess.cs @@ -1,6 +1,6 @@ using System.Diagnostics; -namespace ndnx; +namespace ndx; public interface IChildProcess : IAsyncDisposable { diff --git a/src/ndnx/ConsoleProgress.cs b/src/ndx/ConsoleProgress.cs similarity index 98% rename from src/ndnx/ConsoleProgress.cs rename to src/ndx/ConsoleProgress.cs index 65f9ee6..36fd7e8 100644 --- a/src/ndnx/ConsoleProgress.cs +++ b/src/ndx/ConsoleProgress.cs @@ -1,4 +1,4 @@ -namespace ndnx; +namespace ndx; /// /// Live console writer for download progress. PowerShell 7 on Windows pipes diff --git a/src/ndnx/DotnetMuxer.cs b/src/ndx/DotnetMuxer.cs similarity index 99% rename from src/ndnx/DotnetMuxer.cs rename to src/ndx/DotnetMuxer.cs index d34b25e..2a7d7ad 100644 --- a/src/ndnx/DotnetMuxer.cs +++ b/src/ndx/DotnetMuxer.cs @@ -1,6 +1,6 @@ using System.Diagnostics; -namespace ndnx; +namespace ndx; /// /// The dotnet muxer that will exec a framework-dependent tool. diff --git a/src/ndnx/DownloadProgress.cs b/src/ndx/DownloadProgress.cs similarity index 99% rename from src/ndnx/DownloadProgress.cs rename to src/ndx/DownloadProgress.cs index d149953..c62fc33 100644 --- a/src/ndnx/DownloadProgress.cs +++ b/src/ndx/DownloadProgress.cs @@ -1,6 +1,6 @@ using System.Globalization; -namespace ndnx; +namespace ndx; /// /// Renders HTTP nupkg download progress: a byte bar when the total is known, diff --git a/src/ndnx/Evergreen.cs b/src/ndx/Evergreen.cs similarity index 99% rename from src/ndnx/Evergreen.cs rename to src/ndx/Evergreen.cs index 92b63a0..881e89f 100644 --- a/src/ndnx/Evergreen.cs +++ b/src/ndx/Evergreen.cs @@ -1,4 +1,4 @@ -namespace ndnx; +namespace ndx; /// /// Runs a floating-version tool and restarts it when a newer matching version @@ -8,7 +8,7 @@ public static class Evergreen { public static async Task RunAsync( Invocation invocation, - NdnxHost host, + NdxHost host, ToolPackageStore store, IReadOnlyList sources, ToolCommand command, diff --git a/src/ndnx/FrameworkDependentGuard.cs b/src/ndx/FrameworkDependentGuard.cs similarity index 99% rename from src/ndnx/FrameworkDependentGuard.cs rename to src/ndx/FrameworkDependentGuard.cs index b6f16e0..49979c2 100644 --- a/src/ndnx/FrameworkDependentGuard.cs +++ b/src/ndx/FrameworkDependentGuard.cs @@ -1,6 +1,6 @@ using System.Text.Json; -namespace ndnx; +namespace ndx; /// /// Best-effort preflight for Runner=dotnet: can the resolved muxer's diff --git a/src/ndnx/FrameworkMoniker.cs b/src/ndx/FrameworkMoniker.cs similarity index 99% rename from src/ndnx/FrameworkMoniker.cs rename to src/ndx/FrameworkMoniker.cs index 4c15d9d..5472263 100644 --- a/src/ndnx/FrameworkMoniker.cs +++ b/src/ndx/FrameworkMoniker.cs @@ -1,7 +1,7 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; -namespace ndnx; +namespace ndx; /// /// Major.minor of a .NET runtime / tools TFM folder (net10.0, netcoreapp3.1). diff --git a/src/ndnx/GlobalPackagesFolder.cs b/src/ndx/GlobalPackagesFolder.cs similarity index 99% rename from src/ndnx/GlobalPackagesFolder.cs rename to src/ndx/GlobalPackagesFolder.cs index 3b620b9..ea5913e 100644 --- a/src/ndnx/GlobalPackagesFolder.cs +++ b/src/ndx/GlobalPackagesFolder.cs @@ -1,6 +1,6 @@ using System.Xml.Linq; -namespace ndnx; +namespace ndx; /// /// Resolves the NuGet global packages folder the same way restore does, diff --git a/src/ndnx/Invocation.cs b/src/ndx/Invocation.cs similarity index 93% rename from src/ndnx/Invocation.cs rename to src/ndx/Invocation.cs index 5727252..8e2b7de 100644 --- a/src/ndnx/Invocation.cs +++ b/src/ndx/Invocation.cs @@ -1,7 +1,7 @@ -namespace ndnx; +namespace ndx; /// -/// Result of splitting argv into ndnx options versus child arguments. +/// Result of splitting argv into ndx options versus child arguments. /// public sealed record Invocation { diff --git a/src/ndnx/NetConfig.cs b/src/ndx/NetConfig.cs similarity index 93% rename from src/ndnx/NetConfig.cs rename to src/ndx/NetConfig.cs index 68ece22..12b9600 100644 --- a/src/ndnx/NetConfig.cs +++ b/src/ndx/NetConfig.cs @@ -1,9 +1,9 @@ using System.Globalization; -namespace ndnx; +namespace ndx; /// -/// Tiny git-config / .netconfig reader for the [ndnx] section. +/// Tiny git-config / .netconfig reader for the [ndx] section. /// public static class NetConfig { @@ -15,7 +15,7 @@ public static TimeSpan ReadUpdateInterval(string workingDirectory, string? userP foreach (var path in Enumerate(workingDirectory, userProfile)) { - if (TryReadNumber(path, "ndnx", "interval", out var seconds) && seconds > 0) + if (TryReadNumber(path, "ndx", "interval", out var seconds) && seconds > 0) return TimeSpan.FromSeconds(seconds); } diff --git a/src/ndnx/NuGetJson.cs b/src/ndx/NuGetJson.cs similarity index 99% rename from src/ndnx/NuGetJson.cs rename to src/ndx/NuGetJson.cs index 573ff72..fe16e5f 100644 --- a/src/ndnx/NuGetJson.cs +++ b/src/ndx/NuGetJson.cs @@ -1,7 +1,7 @@ using System.Text.Json.Serialization; using static System.Text.Json.Serialization.JsonIgnoreCondition; -namespace ndnx; +namespace ndx; sealed class ServiceIndex { diff --git a/src/ndnx/PackageFeed.cs b/src/ndx/PackageFeed.cs similarity index 99% rename from src/ndnx/PackageFeed.cs rename to src/ndx/PackageFeed.cs index 5e4aa1c..7fddcf0 100644 --- a/src/ndnx/PackageFeed.cs +++ b/src/ndx/PackageFeed.cs @@ -5,7 +5,7 @@ using System.Text.Json; using System.Xml.Linq; -namespace ndnx; +namespace ndx; public sealed record PackageIdentity(string Id, PackageVersion Version, string Source); diff --git a/src/ndnx/PackageSources.cs b/src/ndx/PackageSources.cs similarity index 99% rename from src/ndnx/PackageSources.cs rename to src/ndx/PackageSources.cs index 1cd9aee..a7e30ce 100644 --- a/src/ndnx/PackageSources.cs +++ b/src/ndx/PackageSources.cs @@ -1,6 +1,6 @@ using System.Xml.Linq; -namespace ndnx; +namespace ndx; /// /// Resolves NuGet sources from --source / --add-source / --configfile / nuget.config. diff --git a/src/ndnx/PackageVersion.cs b/src/ndx/PackageVersion.cs similarity index 99% rename from src/ndnx/PackageVersion.cs rename to src/ndx/PackageVersion.cs index fe917a5..cadd0d6 100644 --- a/src/ndnx/PackageVersion.cs +++ b/src/ndx/PackageVersion.cs @@ -1,7 +1,7 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; -namespace ndnx; +namespace ndx; /// /// NuGet-compatible enough package version (major.minor.patch[-release][+metadata]). diff --git a/src/ndnx/PortableRuntimeIdentifierGraph.json b/src/ndx/PortableRuntimeIdentifierGraph.json similarity index 100% rename from src/ndnx/PortableRuntimeIdentifierGraph.json rename to src/ndx/PortableRuntimeIdentifierGraph.json diff --git a/src/ndnx/ProcessStartSettings.cs b/src/ndx/ProcessStartSettings.cs similarity index 95% rename from src/ndnx/ProcessStartSettings.cs rename to src/ndx/ProcessStartSettings.cs index 295160c..edbaf53 100644 --- a/src/ndnx/ProcessStartSettings.cs +++ b/src/ndx/ProcessStartSettings.cs @@ -1,9 +1,9 @@ using System.Diagnostics; -namespace ndnx; +namespace ndx; /// -/// Process start settings for the downloaded tool. ndnx always starts the child +/// Process start settings for the downloaded tool. ndx always starts the child /// without a shell and with inherited standard in/out/error. /// public sealed record ProcessStartSettings diff --git a/src/ndnx/ProcessStop.cs b/src/ndx/ProcessStop.cs similarity index 99% rename from src/ndnx/ProcessStop.cs rename to src/ndx/ProcessStop.cs index cca3ad9..9a415d1 100644 --- a/src/ndnx/ProcessStop.cs +++ b/src/ndx/ProcessStop.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; using System.Runtime.Versioning; -namespace ndnx; +namespace ndx; /// /// Gracefully stops a child we started: SIGINT / Ctrl+C, then Windows @@ -34,7 +34,7 @@ public static void Signal(Process process) [SupportedOSPlatform("windows")] static void SignalWindows(Process process) { -#if NDNX_WINDOWS +#if NDX_WINDOWS if (TryCloseGui(process)) return; @@ -74,7 +74,7 @@ static void SignalUnix(int pid) } } -#if NDNX_WINDOWS +#if NDX_WINDOWS [SupportedOSPlatform("windows")] static bool TryCloseGui(Process process) { diff --git a/src/ndnx/Program.cs b/src/ndx/Program.cs similarity index 85% rename from src/ndnx/Program.cs rename to src/ndx/Program.cs index 231194d..133efe1 100644 --- a/src/ndnx/Program.cs +++ b/src/ndx/Program.cs @@ -1,4 +1,4 @@ -namespace ndnx; +namespace ndx; public static class Program { diff --git a/src/ndnx/RidPackageResolver.cs b/src/ndx/RidPackageResolver.cs similarity index 99% rename from src/ndnx/RidPackageResolver.cs rename to src/ndx/RidPackageResolver.cs index aa5dd38..53ab3b6 100644 --- a/src/ndnx/RidPackageResolver.cs +++ b/src/ndx/RidPackageResolver.cs @@ -1,6 +1,6 @@ using System.Text.Json; -namespace ndnx; +namespace ndx; /// /// Picks a RID-specific tool package the way the SDK's diff --git a/src/ndnx/SelfUpdate.cs b/src/ndx/SelfUpdate.cs similarity index 91% rename from src/ndnx/SelfUpdate.cs rename to src/ndx/SelfUpdate.cs index f2616db..5b0bd60 100644 --- a/src/ndnx/SelfUpdate.cs +++ b/src/ndx/SelfUpdate.cs @@ -6,14 +6,14 @@ using System.Runtime.InteropServices; using System.Security.Cryptography; -namespace ndnx; +namespace ndx; /// -/// Replaces the running ndnx binary with a GitHub Release asset. +/// Replaces the running ndx binary with a GitHub Release asset. /// public static class SelfUpdate { - public const string DefaultRepository = "devlooped/ndnx"; + public const string DefaultRepository = "devlooped/ndx"; public const string CiChannel = "ci"; public static bool IsCiChannel(string? value) @@ -24,13 +24,13 @@ public static string ReleaseTag(string version) public static async Task RunAsync( Invocation invocation, - NdnxHost host, + NdxHost host, HttpClient http, CancellationToken cancellationToken = default) { var currentVersion = host.CurrentVersion ?? ReadCurrentVersion(); var repo = host.UpdateRepository - ?? Environment.GetEnvironmentVariable("NDNX_REPO") + ?? Environment.GetEnvironmentVariable("NDX_REPO") ?? DefaultRepository; var rid = host.RuntimeIdentifier ?? DetectRuntimeIdentifier(); var executable = host.ExecutablePath ?? ResolveExecutablePath(); @@ -57,7 +57,7 @@ public static async Task RunAsync( if (PackageVersion.TryParse(currentVersion, out var current) && current.Equals(targetVersion)) { - host.Out.WriteLine($"ndnx is already {targetVersion}"); + host.Out.WriteLine($"ndx is already {targetVersion}"); return 0; } @@ -78,7 +78,7 @@ public static async Task RunAsync( var archiveUrl = AssetUrl(repo, tag, archiveName); var shaUrl = archiveUrl + ".sha256"; - var tmp = Path.Combine(Path.GetTempPath(), "ndnx-update-" + Guid.NewGuid().ToString("n")); + var tmp = Path.Combine(Path.GetTempPath(), "ndx-update-" + Guid.NewGuid().ToString("n")); Directory.CreateDirectory(tmp); try { @@ -107,7 +107,7 @@ public static string ReadCurrentVersion() => NormalizeVersion(ReadInformationalVersion()); /// - /// ndnx {version} ({short_sha}) when a commit is present, otherwise ndnx {version}. + /// ndx {version} ({short_sha}) when a commit is present, otherwise ndx {version}. /// public static string FormatVersion(string? informational = null) { @@ -115,7 +115,7 @@ public static string FormatVersion(string? informational = null) var plus = value.IndexOf('+'); var version = NormalizeVersion(plus >= 0 ? value[..plus] : value); if (plus < 0) - return $"ndnx {version}"; + return $"ndx {version}"; var sha = value.AsSpan(plus + 1); var separator = sha.IndexOfAny(".-+"); @@ -124,9 +124,9 @@ public static string FormatVersion(string? informational = null) if (sha.Length > 9) sha = sha[..9]; if (sha.IsEmpty) - return $"ndnx {version}"; + return $"ndx {version}"; - return $"ndnx {version} ({sha})"; + return $"ndx {version} ({sha})"; } static string ReadInformationalVersion() @@ -139,12 +139,12 @@ public static string ResolveExecutablePath() { var process = Environment.ProcessPath; if (process is not null && - Path.GetFileNameWithoutExtension(process).Equals("ndnx", StringComparison.OrdinalIgnoreCase)) + Path.GetFileNameWithoutExtension(process).Equals("ndx", StringComparison.OrdinalIgnoreCase)) { return process; } - return Path.Combine(AppContext.BaseDirectory, OperatingSystem.IsWindows() ? "ndnx.exe" : "ndnx"); + return Path.Combine(AppContext.BaseDirectory, OperatingSystem.IsWindows() ? "ndx.exe" : "ndx"); } public static string DetectRuntimeIdentifier() @@ -154,7 +154,7 @@ public static string DetectRuntimeIdentifier() Architecture.X64 => "x64", Architecture.Arm64 => "arm64", _ => throw new InvalidOperationException( - $"ndnx: unsupported architecture '{RuntimeInformation.OSArchitecture}'."), + $"ndx: unsupported architecture '{RuntimeInformation.OSArchitecture}'."), }; if (OperatingSystem.IsWindows()) @@ -164,7 +164,7 @@ public static string DetectRuntimeIdentifier() if (OperatingSystem.IsLinux()) return $"linux-{arch}"; - throw new InvalidOperationException("ndnx: unsupported OS."); + throw new InvalidOperationException("ndx: unsupported OS."); } public static string LatestReleaseUrl(string repo) @@ -175,11 +175,11 @@ public static string AssetUrl(string repo, string tag, string fileName) public static string ArchiveFileName(string rid, string version) => IsWindowsRid(rid) - ? $"ndnx-{version}-{rid}.zip" - : $"ndnx-{version}-{rid}.tar.gz"; + ? $"ndx-{version}-{rid}.zip" + : $"ndx-{version}-{rid}.tar.gz"; public static string BinaryFileName(string rid) - => IsWindowsRid(rid) ? "ndnx.exe" : "ndnx"; + => IsWindowsRid(rid) ? "ndx.exe" : "ndx"; static bool IsWindowsRid(string rid) => rid.StartsWith("win", StringComparison.OrdinalIgnoreCase); @@ -342,7 +342,7 @@ static void TryDelete(string path) static void EnsureGitHubHeaders(HttpClient http) { if (http.DefaultRequestHeaders.UserAgent.Count == 0) - http.DefaultRequestHeaders.UserAgent.ParseAdd("ndnx"); + http.DefaultRequestHeaders.UserAgent.ParseAdd("ndx"); if (http.DefaultRequestHeaders.Accept.Count == 0) http.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github+json")); } diff --git a/src/ndnx/ToolCommand.cs b/src/ndx/ToolCommand.cs similarity index 99% rename from src/ndnx/ToolCommand.cs rename to src/ndx/ToolCommand.cs index 97f3a34..878af52 100644 --- a/src/ndnx/ToolCommand.cs +++ b/src/ndx/ToolCommand.cs @@ -1,4 +1,4 @@ -namespace ndnx; +namespace ndx; /// /// Command declared by a downloaded tool package. diff --git a/src/ndnx/ToolPackageStore.cs b/src/ndx/ToolPackageStore.cs similarity index 99% rename from src/ndnx/ToolPackageStore.cs rename to src/ndx/ToolPackageStore.cs index 234084a..7c749b5 100644 --- a/src/ndnx/ToolPackageStore.cs +++ b/src/ndx/ToolPackageStore.cs @@ -1,7 +1,7 @@ using System.Runtime.InteropServices; using System.Xml.Linq; -namespace ndnx; +namespace ndx; /// /// Downloads a tool package into a local cache (no PATH / global install) and diff --git a/src/ndnx/ToolSettingsLocator.cs b/src/ndx/ToolSettingsLocator.cs similarity index 99% rename from src/ndnx/ToolSettingsLocator.cs rename to src/ndx/ToolSettingsLocator.cs index 4a68814..9feecab 100644 --- a/src/ndnx/ToolSettingsLocator.cs +++ b/src/ndx/ToolSettingsLocator.cs @@ -1,4 +1,4 @@ -namespace ndnx; +namespace ndx; /// /// Picks DotnetToolSettings.xml inside an extracted tool package. diff --git a/src/ndnx/V3PackageLayout.cs b/src/ndx/V3PackageLayout.cs similarity index 99% rename from src/ndnx/V3PackageLayout.cs rename to src/ndx/V3PackageLayout.cs index b03a55e..4566e8c 100644 --- a/src/ndnx/V3PackageLayout.cs +++ b/src/ndx/V3PackageLayout.cs @@ -3,7 +3,7 @@ using System.Text.Encodings.Web; using System.Text.Json; -namespace ndnx; +namespace ndx; /// /// NuGet v3 global-packages layout: {id}/{version}/{id}.{version}.nupkg, diff --git a/src/ndnx/ndnx.csproj b/src/ndx/ndx.csproj similarity index 53% rename from src/ndnx/ndnx.csproj rename to src/ndx/ndx.csproj index 05ec99e..da1ccb0 100644 --- a/src/ndnx/ndnx.csproj +++ b/src/ndx/ndx.csproj @@ -8,12 +8,13 @@ true true false - ndnx - <_NdnxWindows>false - <_NdnxWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true - <_NdnxWindows Condition="$(RuntimeIdentifier.StartsWith('win'))">true - <_NdnxWindows Condition="$(RuntimeIdentifier) != '' and !$(RuntimeIdentifier.StartsWith('win'))">false - $(DefineConstants);NDNX_WINDOWS + ndx + ndx + <_NdxWindows>false + <_NdxWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true + <_NdxWindows Condition="$(RuntimeIdentifier.StartsWith('win'))">true + <_NdxWindows Condition="$(RuntimeIdentifier) != '' and !$(RuntimeIdentifier.StartsWith('win'))">false + $(DefineConstants);NDX_WINDOWS diff --git a/src/ndnx/readme.md b/src/ndx/readme.md similarity index 86% rename from src/ndnx/readme.md rename to src/ndx/readme.md index 213f8fe..a41a5fb 100644 --- a/src/ndnx/readme.md +++ b/src/ndx/readme.md @@ -1,5 +1,5 @@ [![OSS](https://img.shields.io/github/license/devlooped/oss.svg?color=blue)](license.txt) -[![GitHub](https://img.shields.io/badge/-source-181717.svg?logo=GitHub)](https://github.com/devlooped/ndnx) +[![GitHub](https://img.shields.io/badge/-source-181717.svg?logo=GitHub)](https://github.com/devlooped/ndx)