@bobfrankston/npmglobalize 1.0.12

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.
@@ -0,0 +1,14 @@
1
+ declare module 'libnpmversion' {
2
+ interface VersionOptions {
3
+ path?: string;
4
+ 'git-tag-version'?: boolean;
5
+ 'commit-hooks'?: boolean;
6
+ }
7
+
8
+ function libversion(
9
+ bump: 'major' | 'minor' | 'patch' | 'premajor' | 'preminor' | 'prepatch' | 'prerelease',
10
+ options?: VersionOptions
11
+ ): Promise<string>;
12
+
13
+ export = libversion;
14
+ }
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@bobfrankston/npmglobalize",
3
+ "version": "1.0.12",
4
+ "description": "Transform file: dependencies to npm versions for publishing",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "npmglobalize": "cli.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "watch": "tsc -w"
13
+ },
14
+ "keywords": [
15
+ "npm",
16
+ "publish",
17
+ "dependencies",
18
+ "release"
19
+ ],
20
+ "author": "Bob Frankston",
21
+ "license": "MIT",
22
+ "devDependencies": {
23
+ "@types/node": "^22.0.0"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/BobFrankston/npmglobalize.git"
28
+ },
29
+ "dependencies": {
30
+ "libnpmversion": "^8.0.3"
31
+ }
32
+ }
@@ -0,0 +1,139 @@
1
+ # Set npm token on Windows and WSL
2
+ # Usage: .\set-npm-token.ps1
3
+ # Reads token from token.env file
4
+
5
+ $tokenFile = Join-Path $PSScriptRoot "token.env"
6
+
7
+ if (-not (Test-Path $tokenFile)) {
8
+ Write-Host "ERROR: token.env file not found" -ForegroundColor Red
9
+ Write-Host ""
10
+ Write-Host "Create a token.env file with your npm token:" -ForegroundColor Yellow
11
+ Write-Host " NPM_TOKEN=npm_YOUR_TOKEN_HERE"
12
+ Write-Host ""
13
+ Write-Host "Get your token from: https://www.npmjs.com/settings/[username]/tokens" -ForegroundColor Cyan
14
+ Write-Host " 1. Click 'Generate New Token' -> 'Granular Access Token'"
15
+ Write-Host " 2. Set permissions: Read and write"
16
+ Write-Host " 3. Enable 'Bypass 2FA requirement'"
17
+ Write-Host ""
18
+ exit 1
19
+ }
20
+
21
+ # Read token from file
22
+ $tokenContent = Get-Content $tokenFile -Raw
23
+ if ($tokenContent -match 'NPM_TOKEN\s*=\s*(.+)') {
24
+ $Token = $matches[1].Trim()
25
+ } else {
26
+ Write-Host "ERROR: Could not find NPM_TOKEN in token.env" -ForegroundColor Red
27
+ Write-Host "Expected format: NPM_TOKEN=npm_YOUR_TOKEN_HERE" -ForegroundColor Yellow
28
+ exit 1
29
+ }
30
+
31
+ if (-not $Token.StartsWith("npm_")) {
32
+ Write-Host "WARNING: Token should start with 'npm_'" -ForegroundColor Yellow
33
+ Write-Host "Current token: $($Token.Substring(0, [Math]::Min(10, $Token.Length)))..." -ForegroundColor Yellow
34
+ Write-Host ""
35
+ $continue = Read-Host "Continue anyway? (y/N)"
36
+ if ($continue -ne "y" -and $continue -ne "Y") {
37
+ exit 1
38
+ }
39
+ }
40
+
41
+ Write-Host "Setting npm token on Windows..." -ForegroundColor Cyan
42
+ Write-Host ""
43
+
44
+ # Method 1: Set in Windows Registry (permanent, user-level)
45
+ Write-Host "Setting NPM_TOKEN in registry (permanent)..." -ForegroundColor Cyan
46
+ try {
47
+ # Using setx to set user environment variable permanently
48
+ $process = Start-Process -FilePath "setx" -ArgumentList "NPM_TOKEN", $Token -NoNewWindow -Wait -PassThru
49
+ if ($process.ExitCode -eq 0) {
50
+ Write-Host "✓ NPM_TOKEN set in registry via setx" -ForegroundColor Green
51
+ } else {
52
+ Write-Host "✗ setx failed with exit code $($process.ExitCode)" -ForegroundColor Red
53
+ }
54
+ } catch {
55
+ Write-Host "✗ Failed to set registry value: $_" -ForegroundColor Red
56
+ }
57
+
58
+ # Set in current session
59
+ $env:NPM_TOKEN = $Token
60
+ Write-Host "✓ NPM_TOKEN set for this PowerShell session" -ForegroundColor Green
61
+ Write-Host ""
62
+
63
+ # Method 2: Use npm config set (recommended by npm)
64
+ Write-Host "Setting auth token via npm config..." -ForegroundColor Cyan
65
+ try {
66
+ npm config set //registry.npmjs.org/:_authToken $Token 2>&1 | Out-Null
67
+ if ($LASTEXITCODE -eq 0) {
68
+ Write-Host "✓ Auth token set via 'npm config set'" -ForegroundColor Green
69
+ } else {
70
+ Write-Host "✗ npm config set failed" -ForegroundColor Red
71
+ }
72
+ } catch {
73
+ Write-Host "✗ npm config set failed: $_" -ForegroundColor Red
74
+ }
75
+ Write-Host ""
76
+
77
+ # Test Windows npm authentication
78
+ Write-Host "Testing Windows npm authentication..."
79
+ try {
80
+ $username = npm whoami 2>&1
81
+ if ($LASTEXITCODE -eq 0) {
82
+ Write-Host "✓ Windows authentication successful: $username" -ForegroundColor Green
83
+ } else {
84
+ Write-Host "✗ Windows authentication failed" -ForegroundColor Red
85
+ Write-Host "Error: $username" -ForegroundColor Red
86
+ }
87
+ } catch {
88
+ Write-Host "✗ Windows authentication failed: $_" -ForegroundColor Red
89
+ }
90
+ Write-Host ""
91
+
92
+ # Method 3: Set in WSL if available
93
+ if (Get-Command wsl -ErrorAction SilentlyContinue) {
94
+ Write-Host "Setting npm token in WSL..." -ForegroundColor Cyan
95
+
96
+ # Export token to WSL and use npm config set
97
+ $wslScript = @"
98
+ export NPM_TOKEN='$Token'
99
+ npm config set //registry.npmjs.org/:_authToken '$Token' 2>/dev/null
100
+ if [ \$? -eq 0 ]; then
101
+ echo '✓ WSL auth token set via npm config'
102
+ if command -v npm >/dev/null 2>&1; then
103
+ username=\$(npm whoami 2>&1)
104
+ if [ \$? -eq 0 ]; then
105
+ echo '✓ WSL authentication successful:' \$username
106
+ else
107
+ echo '✗ WSL authentication failed'
108
+ fi
109
+ fi
110
+ else
111
+ echo '⚠ npm not installed in WSL or npm config failed'
112
+ fi
113
+ "@
114
+
115
+ wsl bash -c $wslScript
116
+ Write-Host ""
117
+ } else {
118
+ Write-Host "WSL not found - skipping WSL setup" -ForegroundColor Yellow
119
+ Write-Host ""
120
+ }
121
+
122
+ Write-Host ""
123
+ Write-Host "=== Setup Complete ===" -ForegroundColor Green
124
+ Write-Host ""
125
+ Write-Host "Methods used:" -ForegroundColor Cyan
126
+ Write-Host " 1. setx NPM_TOKEN (permanent in Windows registry)" -ForegroundColor Yellow
127
+ Write-Host " 2. `$env:NPM_TOKEN (current PowerShell session)" -ForegroundColor Yellow
128
+ Write-Host " 3. npm config set (adds to .npmrc)" -ForegroundColor Yellow
129
+ Write-Host ""
130
+ Write-Host "Differences from manual approach:" -ForegroundColor Cyan
131
+ Write-Host " Your method: setx + set + npm set" -ForegroundColor Gray
132
+ Write-Host " This script: Same thing, automated + WSL support" -ForegroundColor Gray
133
+ Write-Host ""
134
+ Write-Host "To verify authentication:"
135
+ Write-Host " Windows: npm whoami" -ForegroundColor Green
136
+ Write-Host " WSL: wsl npm whoami" -ForegroundColor Green
137
+ Write-Host ""
138
+ Write-Host "Note: Close and reopen PowerShell for setx changes to take effect in new sessions" -ForegroundColor Yellow
139
+ Write-Host ""
@@ -0,0 +1,123 @@
1
+ #!/bin/bash
2
+ # Set npm token on Linux/WSL
3
+ # Usage: ./set-npm-token.sh
4
+ # Reads token from token.env file
5
+
6
+ set -e # Exit on error
7
+
8
+ # Colors
9
+ RED='\033[0;31m'
10
+ GREEN='\033[0;32m'
11
+ YELLOW='\033[1;33m'
12
+ CYAN='\033[0;36m'
13
+ NC='\033[0m' # No Color
14
+
15
+ # Get script directory
16
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17
+ TOKEN_FILE="$SCRIPT_DIR/token.env"
18
+
19
+ if [ ! -f "$TOKEN_FILE" ]; then
20
+ echo -e "${RED}ERROR: token.env file not found${NC}"
21
+ echo ""
22
+ echo -e "${YELLOW}Create a token.env file with your npm token:${NC}"
23
+ echo " NPM_TOKEN=npm_YOUR_TOKEN_HERE"
24
+ echo ""
25
+ echo -e "${CYAN}Get your token from: https://www.npmjs.com/settings/[username]/tokens${NC}"
26
+ echo " 1. Click 'Generate New Token' -> 'Granular Access Token'"
27
+ echo " 2. Set permissions: Read and write"
28
+ echo " 3. Enable 'Bypass 2FA requirement'"
29
+ echo ""
30
+ exit 1
31
+ fi
32
+
33
+ # Read token from file
34
+ if grep -q "NPM_TOKEN" "$TOKEN_FILE"; then
35
+ TOKEN=$(grep "NPM_TOKEN" "$TOKEN_FILE" | cut -d '=' -f 2- | tr -d ' \r\n')
36
+ else
37
+ echo -e "${RED}ERROR: Could not find NPM_TOKEN in token.env${NC}"
38
+ echo -e "${YELLOW}Expected format: NPM_TOKEN=npm_YOUR_TOKEN_HERE${NC}"
39
+ exit 1
40
+ fi
41
+
42
+ if [[ ! "$TOKEN" =~ ^npm_ ]]; then
43
+ echo -e "${YELLOW}WARNING: Token should start with 'npm_'${NC}"
44
+ echo -e "${YELLOW}Current token: ${TOKEN:0:10}...${NC}"
45
+ echo ""
46
+ read -p "Continue anyway? (y/N) " -n 1 -r
47
+ echo
48
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
49
+ exit 1
50
+ fi
51
+ fi
52
+
53
+ echo -e "${CYAN}Setting npm token on Linux/WSL...${NC}"
54
+ echo ""
55
+
56
+ # Method 1: Export for current session
57
+ export NPM_TOKEN="$TOKEN"
58
+ echo -e "${GREEN}✓ NPM_TOKEN set for this shell session${NC}"
59
+
60
+ # Method 2: Add to shell profile for persistence
61
+ SHELL_RC=""
62
+ if [ -n "$BASH_VERSION" ]; then
63
+ if [ -f "$HOME/.bashrc" ]; then
64
+ SHELL_RC="$HOME/.bashrc"
65
+ elif [ -f "$HOME/.bash_profile" ]; then
66
+ SHELL_RC="$HOME/.bash_profile"
67
+ fi
68
+ elif [ -n "$ZSH_VERSION" ]; then
69
+ SHELL_RC="$HOME/.zshrc"
70
+ fi
71
+
72
+ if [ -n "$SHELL_RC" ]; then
73
+ # Check if NPM_TOKEN is already in the file
74
+ if grep -q "^export NPM_TOKEN=" "$SHELL_RC"; then
75
+ # Update existing line
76
+ sed -i.bak "s|^export NPM_TOKEN=.*|export NPM_TOKEN=\"$TOKEN\"|" "$SHELL_RC"
77
+ echo -e "${GREEN}✓ Updated NPM_TOKEN in $SHELL_RC${NC}"
78
+ else
79
+ # Add new line
80
+ echo "" >> "$SHELL_RC"
81
+ echo "# npm authentication token (added by set-npm-token.sh)" >> "$SHELL_RC"
82
+ echo "export NPM_TOKEN=\"$TOKEN\"" >> "$SHELL_RC"
83
+ echo -e "${GREEN}✓ Added NPM_TOKEN to $SHELL_RC${NC}"
84
+ fi
85
+ fi
86
+ echo ""
87
+
88
+ # Method 3: Use npm config set (recommended)
89
+ echo -e "${CYAN}Setting auth token via npm config...${NC}"
90
+ if npm config set //registry.npmjs.org/:_authToken "$TOKEN" 2>/dev/null; then
91
+ echo -e "${GREEN}✓ Auth token set via 'npm config set'${NC}"
92
+ else
93
+ echo -e "${RED}✗ npm config set failed${NC}"
94
+ fi
95
+ echo ""
96
+
97
+ # Test authentication
98
+ echo -e "${CYAN}Testing npm authentication...${NC}"
99
+ if username=$(npm whoami 2>&1); then
100
+ echo -e "${GREEN}✓ Authentication successful: $username${NC}"
101
+ else
102
+ echo -e "${RED}✗ Authentication failed${NC}"
103
+ echo -e "${RED}$username${NC}"
104
+ fi
105
+ echo ""
106
+
107
+ echo ""
108
+ echo -e "${GREEN}=== Setup Complete ===${NC}"
109
+ echo ""
110
+ echo -e "${CYAN}Methods used:${NC}"
111
+ echo -e " ${YELLOW}1. export NPM_TOKEN (current shell session)${NC}"
112
+ if [ -n "$SHELL_RC" ]; then
113
+ echo -e " ${YELLOW}2. Added to $SHELL_RC (permanent)${NC}"
114
+ fi
115
+ echo -e " ${YELLOW}3. npm config set (adds to ~/.npmrc)${NC}"
116
+ echo ""
117
+ echo -e "${CYAN}To verify authentication:${NC}"
118
+ echo -e " ${GREEN}npm whoami${NC}"
119
+ echo ""
120
+ if [ -n "$SHELL_RC" ]; then
121
+ echo -e "${YELLOW}Note: Reopen terminal or run 'source $SHELL_RC' for permanent changes${NC}"
122
+ echo ""
123
+ fi
package/token.env ADDED
@@ -0,0 +1,10 @@
1
+ # NPM Authentication Token
2
+ # Copy this file to token.env and replace with your actual token
3
+ # Get token from: https://www.npmjs.com/settings/[username]/tokens
4
+ #
5
+ # Generate a Granular Access Token with:
6
+ # - Permissions: Read and write
7
+ # - Bypass 2FA requirement: Enabled
8
+ #
9
+ NPM_TOKEN=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
10
+
@@ -0,0 +1,9 @@
1
+ # NPM Authentication Token
2
+ # Copy this file to token.env and replace with your actual token
3
+ # Get token from: https://www.npmjs.com/settings/[username]/tokens
4
+ #
5
+ # Generate a Granular Access Token with:
6
+ # - Permissions: Read and write
7
+ # - Bypass 2FA requirement: Enabled
8
+ #
9
+ NPM_TOKEN=npm_YOUR_TOKEN_HERE
package/tsconfig.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "allowSyntheticDefaultImports": true,
7
+ "esModuleInterop": true,
8
+ "allowJs": true,
9
+ "strict": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "skipLibCheck": true,
12
+ "declaration": true,
13
+ "declarationMap": true,
14
+ "sourceMap": true,
15
+ "strictNullChecks": false,
16
+ "noImplicitAny": true,
17
+ "noImplicitReturns": false,
18
+ "noImplicitThis": true,
19
+ "newLine": "lf"
20
+ },
21
+ "exclude": [
22
+ "node_modules",
23
+ "cruft",
24
+ ".git",
25
+ "tests",
26
+ "prev"
27
+ ]
28
+ }