pi-revit 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/setup-workspace.ps1 +26 -2
- package/scripts/uninstall.ps1 +27 -4
package/package.json
CHANGED
|
@@ -40,7 +40,31 @@ Write-Host "Workspace ready: $WorkspaceDir" -ForegroundColor Green
|
|
|
40
40
|
|
|
41
41
|
# 2. Global pi-revit command next to pi (that directory is on PATH by definition).
|
|
42
42
|
# The template's workspace path is rewritten to honor -WorkspaceDir.
|
|
43
|
-
|
|
43
|
+
# Under `npx pi-revit`, npx prepends its ephemeral cache's node_modules\.bin to
|
|
44
|
+
# PATH, and that folder holds a pi shim pulled in via peerDependencies. A launcher
|
|
45
|
+
# written next to that shim lands in a folder that is neither on the user's own
|
|
46
|
+
# PATH nor long-lived, so skip pi entries inside this package's node_modules tree
|
|
47
|
+
# or any npx cache and use the user's permanent pi instead.
|
|
48
|
+
function Get-PermanentPiCommand {
|
|
49
|
+
# Long-form both sides of the prefix comparison: PATH entries may carry 8.3
|
|
50
|
+
# short names (AHMAD~1.TAH) while $PSScriptRoot is normalized, and a form
|
|
51
|
+
# mismatch would silently defeat the own-tree exclusion.
|
|
52
|
+
function Resolve-LongPath([string]$p) {
|
|
53
|
+
try { (Get-Item -LiteralPath $p -ErrorAction Stop).FullName } catch { $p }
|
|
54
|
+
}
|
|
55
|
+
$ownTree = $null
|
|
56
|
+
$repoRoot = Resolve-LongPath (Split-Path $PSScriptRoot -Parent)
|
|
57
|
+
$idx = $repoRoot.LastIndexOf('\node_modules\', [StringComparison]::OrdinalIgnoreCase)
|
|
58
|
+
if ($idx -ge 0) { $ownTree = $repoRoot.Substring(0, $idx + '\node_modules\'.Length) }
|
|
59
|
+
Get-Command pi -All -ErrorAction SilentlyContinue | Where-Object {
|
|
60
|
+
if (-not $_.Source) { return $false }
|
|
61
|
+
$src = Resolve-LongPath $_.Source
|
|
62
|
+
($src -notmatch '\\_npx\\') -and
|
|
63
|
+
(-not $ownTree -or -not $src.StartsWith($ownTree, [StringComparison]::OrdinalIgnoreCase))
|
|
64
|
+
} | Select-Object -First 1
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
$pi = Get-PermanentPiCommand
|
|
44
68
|
if ($pi) {
|
|
45
69
|
$binDir = Split-Path $pi.Source -Parent
|
|
46
70
|
# Literal line swap (no regex): the workspace path may contain characters
|
|
@@ -55,5 +79,5 @@ if ($pi) {
|
|
|
55
79
|
Write-Host "Global command installed: $(Join-Path $binDir 'pi-revit.cmd')" -ForegroundColor Green
|
|
56
80
|
Write-Host 'Run pi-revit from any terminal (pi-revit <project> for a project folder).'
|
|
57
81
|
} else {
|
|
58
|
-
Write-Warning 'pi command
|
|
82
|
+
Write-Warning 'No permanent pi command found on PATH. Install Pi first (npm install -g --ignore-scripts @earendil-works/pi-coding-agent), then run npx.cmd -y pi-revit again (or re-run this script) to get the global pi-revit command.'
|
|
59
83
|
}
|
package/scripts/uninstall.ps1
CHANGED
|
@@ -54,13 +54,36 @@ foreach ($v in $versions) {
|
|
|
54
54
|
Remove-IfExists (Join-Path $dir 'RevitBridge') "Revit $v add-in folder"
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
# 2. Global pi-revit command next to pi.
|
|
57
|
+
# 2. Global pi-revit command next to the user's permanent pi. When this script runs
|
|
58
|
+
# from an npx cache or a node_modules copy, PATH may lead Get-Command to a pi shim
|
|
59
|
+
# inside that ephemeral tree first (see setup-workspace.ps1) — the launcher was
|
|
60
|
+
# never installed there, so resolve the permanent pi the same way setup does.
|
|
61
|
+
function Get-PermanentPiCommand {
|
|
62
|
+
# Long-form both sides of the prefix comparison: PATH entries may carry 8.3
|
|
63
|
+
# short names (AHMAD~1.TAH) while $PSScriptRoot is normalized, and a form
|
|
64
|
+
# mismatch would silently defeat the own-tree exclusion.
|
|
65
|
+
function Resolve-LongPath([string]$p) {
|
|
66
|
+
try { (Get-Item -LiteralPath $p -ErrorAction Stop).FullName } catch { $p }
|
|
67
|
+
}
|
|
68
|
+
$ownTree = $null
|
|
69
|
+
$repoRoot = Resolve-LongPath (Split-Path $PSScriptRoot -Parent)
|
|
70
|
+
$idx = $repoRoot.LastIndexOf('\node_modules\', [StringComparison]::OrdinalIgnoreCase)
|
|
71
|
+
if ($idx -ge 0) { $ownTree = $repoRoot.Substring(0, $idx + '\node_modules\'.Length) }
|
|
72
|
+
Get-Command pi -All -ErrorAction SilentlyContinue | Where-Object {
|
|
73
|
+
if (-not $_.Source) { return $false }
|
|
74
|
+
$src = Resolve-LongPath $_.Source
|
|
75
|
+
($src -notmatch '\\_npx\\') -and
|
|
76
|
+
(-not $ownTree -or -not $src.StartsWith($ownTree, [StringComparison]::OrdinalIgnoreCase))
|
|
77
|
+
} | Select-Object -First 1
|
|
78
|
+
}
|
|
79
|
+
|
|
58
80
|
$pi = Get-Command pi -ErrorAction SilentlyContinue
|
|
59
|
-
|
|
60
|
-
|
|
81
|
+
$piPermanent = Get-PermanentPiCommand
|
|
82
|
+
if ($piPermanent) {
|
|
83
|
+
$binDir = Split-Path $piPermanent.Source -Parent
|
|
61
84
|
Remove-IfExists (Join-Path $binDir 'pi-revit.cmd') 'global pi-revit command'
|
|
62
85
|
} else {
|
|
63
|
-
Write-Host 'pi
|
|
86
|
+
Write-Host 'No permanent pi found on PATH; skipping the global pi-revit command.'
|
|
64
87
|
}
|
|
65
88
|
|
|
66
89
|
# 3. Bridge runtime folder (connection token; recreated on each Revit start).
|