From 6d30d542f0fd13974cdf088ed31c161bac24a702 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 16 Sep 2026 18:11:28 +0000 Subject: [PATCH] Add Cloud Agent development environment for NetDiagram-PS Provide a reproducible repo-managed environment so agents can run the module, test suite, and linter end to end: - .cursor/Dockerfile: Ubuntu 24.04 base with PowerShell 7, net-snmp, and the Linux networking tools (iproute2, net-tools) the discovery wizard shells out to. - .cursor/install.sh: idempotent bootstrap that installs Pester (>= 5) and PSScriptAnalyzer for the current user and validates the module manifest. - .cursor/environment.json: wires the Dockerfile build and install step, running as the ubuntu user. Co-authored-by: jacob --- .cursor/Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ .cursor/environment.json | 8 ++++++++ .cursor/install.sh | 31 +++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 .cursor/Dockerfile create mode 100644 .cursor/environment.json create mode 100755 .cursor/install.sh diff --git a/.cursor/Dockerfile b/.cursor/Dockerfile new file mode 100644 index 0000000..faa4287 --- /dev/null +++ b/.cursor/Dockerfile @@ -0,0 +1,37 @@ +# Cloud Agent base image for NetDiagram-PS. +# Provides the stable system toolchain: PowerShell 7 (the module targets 7.4+), +# net-snmp (optional SNMP discovery), and the Linux networking tools the +# discovery wizard shells out to (ip / arp). Project-level PowerShell modules +# (Pester, PSScriptAnalyzer) are installed by .cursor/install.sh after checkout. +FROM ubuntu:24.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + wget \ + git \ + sudo \ + apt-transport-https \ + snmp \ + iproute2 \ + net-tools \ + && rm -rf /var/lib/apt/lists/* + +# Install PowerShell 7 from Microsoft's package repository for this Ubuntu release. +RUN . /etc/os-release \ + && wget -q "https://packages.microsoft.com/config/ubuntu/${VERSION_ID}/packages-microsoft-prod.deb" \ + -O /tmp/packages-microsoft-prod.deb \ + && dpkg -i /tmp/packages-microsoft-prod.deb \ + && rm -f /tmp/packages-microsoft-prod.deb \ + && apt-get update \ + && apt-get install -y --no-install-recommends powershell \ + && rm -rf /var/lib/apt/lists/* + +# Passwordless sudo for the default agent user (matches Cursor's conventions). +RUN echo "ubuntu ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/ubuntu \ + && chmod 0440 /etc/sudoers.d/ubuntu + +USER ubuntu diff --git a/.cursor/environment.json b/.cursor/environment.json new file mode 100644 index 0000000..260bf81 --- /dev/null +++ b/.cursor/environment.json @@ -0,0 +1,8 @@ +{ + "name": "NetDiagram-PS", + "build": { + "dockerfile": "Dockerfile" + }, + "user": "ubuntu", + "install": "bash ./.cursor/install.sh" +} diff --git a/.cursor/install.sh b/.cursor/install.sh new file mode 100755 index 0000000..8a2e3ef --- /dev/null +++ b/.cursor/install.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# Idempotent repository bootstrap for the NetDiagram-PS Cloud Agent environment. +# Ensures the PowerShell modules required to run the test suite (Pester 5+) and +# the linter (PSScriptAnalyzer) are available for the current user. Safe to run +# repeatedly: modules are only installed when missing. +set -euo pipefail + +pwsh -NoLogo -NoProfile -NonInteractive -Command ' + $ErrorActionPreference = "Stop" + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted + + $hasPester = Get-Module -ListAvailable -Name Pester | + Where-Object { $_.Version -ge [version]"5.0.0" } + if (-not $hasPester) { + Write-Host "Installing Pester (>= 5.0.0)..." + Install-Module -Name Pester -MinimumVersion 5.0.0 -Force -Scope CurrentUser -SkipPublisherCheck + } else { + Write-Host "Pester already present: $((($hasPester | Sort-Object Version -Descending)[0]).Version)" + } + + if (-not (Get-Module -ListAvailable -Name PSScriptAnalyzer)) { + Write-Host "Installing PSScriptAnalyzer..." + Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser + } else { + Write-Host "PSScriptAnalyzer already present: $((Get-Module -ListAvailable -Name PSScriptAnalyzer | Sort-Object Version -Descending)[0].Version)" + } + + Write-Host "Validating module manifest..." + Test-ModuleManifest ./NetDiagram-PS/NetDiagram-PS.psd1 | Out-Null + Write-Host "NetDiagram-PS environment bootstrap complete." +'