@bobfrankston/npmglobalize 1.0.40 → 1.0.42

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env pwsh
2
+ <#
3
+ .SYNOPSIS
4
+ Mark an npm package as private or delete it
5
+
6
+ .DESCRIPTION
7
+ Sets the access level of an npm package to private/restricted, or unpublishes it.
8
+ Assumes @bobfrankston scope if not specified.
9
+
10
+ .PARAMETER PackageName
11
+ Name of the package (with or without scope prefix)
12
+
13
+ .PARAMETER Delete
14
+ Unpublish the package completely (dangerous!)
15
+
16
+ .EXAMPLE
17
+ .\set-npm-private.ps1 npmglobalize
18
+ # Marks @bobfrankston/npmglobalize as private
19
+
20
+ .EXAMPLE
21
+ .\set-npm-private.ps1 @bobfrankston/npmglobalize
22
+ # Marks @bobfrankston/npmglobalize as private
23
+
24
+ .EXAMPLE
25
+ .\set-npm-private.ps1 npmglobalize -Delete
26
+ # Unpublishes @bobfrankston/npmglobalize completely
27
+
28
+ .EXAMPLE
29
+ .\set-npm-private.ps1 @someone/package -Delete
30
+ # Unpublishes @someone/package (works with any scope)
31
+ #>
32
+
33
+ param(
34
+ [Parameter(Mandatory=$true, Position=0)]
35
+ [string]$PackageName,
36
+
37
+ [Parameter(Mandatory=$false)]
38
+ [switch]$Delete
39
+ )
40
+
41
+ # Add @bobfrankston/ prefix if no scope present
42
+ if (-not $PackageName.StartsWith('@')) {
43
+ $PackageName = "@bobfrankston/$PackageName"
44
+ }
45
+
46
+ # Extract scope from package name for verification
47
+ $scope = $null
48
+ if ($PackageName -match '^@([^/]+)/') {
49
+ $scope = $matches[1]
50
+ }
51
+
52
+ if ($Delete) {
53
+ Write-Host "⚠️ WARNING: About to DELETE package: $PackageName" -ForegroundColor Yellow
54
+ Write-Host "This action CANNOT be undone!" -ForegroundColor Red
55
+ Write-Host ""
56
+
57
+ $confirm = Read-Host "Type the package name to confirm deletion"
58
+
59
+ if ($confirm -ne $PackageName) {
60
+ Write-Host "✗ Package name doesn't match. Aborting." -ForegroundColor Red
61
+ exit 1
62
+ }
63
+
64
+ Write-Host "`nDeleting $PackageName..." -ForegroundColor Cyan
65
+ $result = npm unpublish $PackageName --force 2>&1
66
+
67
+ if ($LASTEXITCODE -eq 0) {
68
+ Write-Host "✓ $PackageName has been deleted from npm" -ForegroundColor Green
69
+ } else {
70
+ Write-Host "✗ Failed to delete package" -ForegroundColor Red
71
+ Write-Host $result -ForegroundColor Red
72
+ exit 1
73
+ }
74
+ } else {
75
+ Write-Host "Setting $PackageName to private..." -ForegroundColor Cyan
76
+
77
+ # Set package to private using correct npm syntax
78
+ $result = npm access set status=private $PackageName 2>&1
79
+
80
+ if ($LASTEXITCODE -eq 0) {
81
+ Write-Host "✓ $PackageName is now private" -ForegroundColor Green
82
+
83
+ # Verify the change
84
+ if ($scope) {
85
+ Write-Host "`nVerifying access level..." -ForegroundColor Cyan
86
+ npm access get status $PackageName
87
+ }
88
+ } else {
89
+ Write-Host "✗ Failed to set private access" -ForegroundColor Red
90
+ Write-Host $result -ForegroundColor Red
91
+ exit 1
92
+ }
93
+ }