Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .cursor/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions .cursor/environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "NetDiagram-PS",
"build": {
"dockerfile": "Dockerfile"
},
"user": "ubuntu",
"install": "bash ./.cursor/install.sh"
}
31 changes: 31 additions & 0 deletions .cursor/install.sh
Original file line number Diff line number Diff line change
@@ -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."
'