aws-lambda-layer-cli 1.4.1 → 2.0.2
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/README.md +41 -338
- package/bin/aws-lambda-layer-cli.js +183 -0
- package/completion/aws-lambda-layer-completion.bash +8 -4
- package/completion/aws-lambda-layer-completion.zsh +3 -3
- package/package.json +17 -3
- package/scripts/{aws-lambda-layer → aws-lambda-layer-cli} +133 -18
- package/scripts/build_pypi.sh +11 -3
- package/scripts/install.js +54 -16
- package/scripts/install.ps1 +662 -662
- package/scripts/install.sh +22 -11
- package/scripts/pypi_resources/cli.py +89 -1
- package/scripts/uninstall.js +47 -0
- package/scripts/uninstall.ps1 +209 -179
- package/scripts/uninstall.sh +72 -9
- package/bin/aws-lambda-layer.js +0 -89
package/scripts/install.sh
CHANGED
|
@@ -24,7 +24,11 @@ printf "${CYAN}${BOLD}Installing AWS Lambda Layer CLI Tool...${NC}\n"
|
|
|
24
24
|
# Check if running as root
|
|
25
25
|
if [ "$EUID" -ne 0 ]; then
|
|
26
26
|
if command -v sudo &> /dev/null; then
|
|
27
|
-
|
|
27
|
+
# Check if we need a password
|
|
28
|
+
if ! sudo -n true 2>/dev/null; then
|
|
29
|
+
printf "${YELLOW}This script requires root privileges to install to /usr/local/lib.${NC}\n"
|
|
30
|
+
printf "${YELLOW}Please enter your password if prompted.${NC}\n"
|
|
31
|
+
fi
|
|
28
32
|
SUDO="sudo"
|
|
29
33
|
else
|
|
30
34
|
SUDO=""
|
|
@@ -36,7 +40,7 @@ fi
|
|
|
36
40
|
# Get script directory
|
|
37
41
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
38
42
|
BASE_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
39
|
-
INSTALL_DIR="/usr/local/lib/aws-lambda-layer"
|
|
43
|
+
INSTALL_DIR="/usr/local/lib/aws-lambda-layer-cli"
|
|
40
44
|
BIN_DIR="/usr/local/bin"
|
|
41
45
|
COMPLETION_DIR="/etc/bash_completion.d"
|
|
42
46
|
|
|
@@ -46,29 +50,36 @@ $SUDO mkdir -p "$INSTALL_DIR"
|
|
|
46
50
|
|
|
47
51
|
# Copy scripts
|
|
48
52
|
printf "${BLUE}Copying scripts...${NC}\n"
|
|
49
|
-
$SUDO cp "$SCRIPT_DIR/aws-lambda-layer" "$INSTALL_DIR/"
|
|
53
|
+
$SUDO cp "$SCRIPT_DIR/aws-lambda-layer-cli" "$INSTALL_DIR/"
|
|
50
54
|
$SUDO cp "$SCRIPT_DIR/create_nodejs_layer.sh" "$INSTALL_DIR/"
|
|
51
55
|
$SUDO cp "$SCRIPT_DIR/create_python_layer.sh" "$INSTALL_DIR/"
|
|
56
|
+
$SUDO cp "$SCRIPT_DIR/uninstall.sh" "$INSTALL_DIR/"
|
|
52
57
|
$SUDO cp "$BASE_DIR/VERSION.txt" "$INSTALL_DIR/"
|
|
53
58
|
|
|
59
|
+
# Copy completion files for the CLI to use
|
|
60
|
+
printf "${BLUE}Copying completion files...${NC}\n"
|
|
61
|
+
$SUDO mkdir -p "$INSTALL_DIR/completion"
|
|
62
|
+
$SUDO cp "$BASE_DIR/completion/aws-lambda-layer-completion.bash" "$INSTALL_DIR/completion/"
|
|
63
|
+
$SUDO cp "$BASE_DIR/completion/aws-lambda-layer-completion.zsh" "$INSTALL_DIR/completion/"
|
|
64
|
+
|
|
54
65
|
# Make scripts executable
|
|
55
66
|
printf "${BLUE}Setting executable permissions...${NC}\n"
|
|
56
|
-
$SUDO chmod +x "$INSTALL_DIR/aws-lambda-layer"
|
|
67
|
+
$SUDO chmod +x "$INSTALL_DIR/aws-lambda-layer-cli"
|
|
57
68
|
$SUDO chmod +x "$INSTALL_DIR/create_nodejs_layer.sh"
|
|
58
69
|
$SUDO chmod +x "$INSTALL_DIR/create_python_layer.sh"
|
|
59
70
|
|
|
60
71
|
# Create symlink in bin directory
|
|
61
72
|
printf "${BLUE}Creating symlink in $BIN_DIR...${NC}\n"
|
|
62
|
-
$SUDO ln -sf "$INSTALL_DIR/aws-lambda-layer" "$BIN_DIR/aws-lambda-layer"
|
|
73
|
+
$SUDO ln -sf "$INSTALL_DIR/aws-lambda-layer-cli" "$BIN_DIR/aws-lambda-layer-cli"
|
|
63
74
|
|
|
64
75
|
# Install bash completion
|
|
65
76
|
printf "${BLUE}Installing bash completion...${NC}\n"
|
|
66
77
|
if [ -d "$COMPLETION_DIR" ]; then
|
|
67
|
-
$SUDO cp "$BASE_DIR/completion/aws-lambda-layer-completion.bash" "$COMPLETION_DIR/aws-lambda-layer"
|
|
78
|
+
$SUDO cp "$BASE_DIR/completion/aws-lambda-layer-completion.bash" "$COMPLETION_DIR/aws-lambda-layer-cli"
|
|
68
79
|
# Source the completion script
|
|
69
80
|
if [ -f "$HOME/.bashrc" ]; then
|
|
70
|
-
if ! grep -q "aws-lambda-layer" "$HOME/.bashrc"; then
|
|
71
|
-
printf "\n# AWS Lambda Layer CLI completion\nsource $COMPLETION_DIR/aws-lambda-layer\n" >> "$HOME/.bashrc"
|
|
81
|
+
if ! grep -q "aws-lambda-layer-cli" "$HOME/.bashrc"; then
|
|
82
|
+
printf "\n# AWS Lambda Layer CLI completion\nsource $COMPLETION_DIR/aws-lambda-layer-cli\n" >> "$HOME/.bashrc"
|
|
72
83
|
fi
|
|
73
84
|
fi
|
|
74
85
|
printf "${GREEN}Bash completion installed.${NC}\n"
|
|
@@ -92,14 +103,14 @@ else
|
|
|
92
103
|
fi
|
|
93
104
|
|
|
94
105
|
if [ -n "$ZSH_COMPLETION_DIR" ]; then
|
|
95
|
-
$SUDO cp "$BASE_DIR/completion/aws-lambda-layer-completion.zsh" "$ZSH_COMPLETION_DIR/_aws-lambda-layer"
|
|
106
|
+
$SUDO cp "$BASE_DIR/completion/aws-lambda-layer-completion.zsh" "$ZSH_COMPLETION_DIR/_aws-lambda-layer-cli"
|
|
96
107
|
printf "${GREEN}Zsh completion installed to: $ZSH_COMPLETION_DIR${NC}\n"
|
|
97
108
|
fi
|
|
98
109
|
|
|
99
110
|
printf "${GREEN}${BOLD}✅ Installation complete!${NC}\n\n"
|
|
100
111
|
printf "${MAGENTA}${UNDERLINE}Usage examples:${NC}\n"
|
|
101
|
-
printf " aws-lambda-layer ${GREEN}zip${NC} ${YELLOW}--nodejs${NC} \"express@^4.0.0,lodash@~4.17.0\"\n"
|
|
102
|
-
printf " aws-lambda-layer ${GREEN}zip${NC} ${YELLOW}--python${NC} \"numpy==1.26.0,pandas>=2.1.0\"\n\n"
|
|
112
|
+
printf " aws-lambda-layer-cli ${GREEN}zip${NC} ${YELLOW}--nodejs${NC} \"express@^4.0.0,lodash@~4.17.0\"\n"
|
|
113
|
+
printf " aws-lambda-layer-cli ${GREEN}zip${NC} ${YELLOW}--python${NC} \"numpy==1.26.0,pandas>=2.1.0\"\n\n"
|
|
103
114
|
printf "${YELLOW}To enable tab completion, restart your shell:${NC}\n"
|
|
104
115
|
printf " For bash: source ~/.bashrc\n"
|
|
105
116
|
printf " For zsh: exec zsh\n\n"
|
|
@@ -49,12 +49,100 @@ def main() -> None:
|
|
|
49
49
|
else:
|
|
50
50
|
assets_dir = Path(__file__).resolve().parent / "assets"
|
|
51
51
|
|
|
52
|
-
script_path = assets_dir / "aws-lambda-layer"
|
|
52
|
+
script_path = assets_dir / "aws-lambda-layer-cli"
|
|
53
53
|
if not script_path.exists():
|
|
54
54
|
raise SystemExit(f"Packaged script missing: {script_path}")
|
|
55
55
|
|
|
56
56
|
args = sys.argv[1:]
|
|
57
57
|
|
|
58
|
+
# Handle uninstall command
|
|
59
|
+
if args and args[0] == "uninstall":
|
|
60
|
+
if "--help" in args or "-h" in args:
|
|
61
|
+
GREEN = '\033[0;32m'
|
|
62
|
+
BLUE = '\033[0;34m'
|
|
63
|
+
NC = '\033[0m'
|
|
64
|
+
|
|
65
|
+
print(f"{BLUE}Usage:{NC}")
|
|
66
|
+
print(f" aws-lambda-layer-cli {GREEN}uninstall{NC}")
|
|
67
|
+
print("")
|
|
68
|
+
print(f"{BLUE}Description:{NC}")
|
|
69
|
+
print(" Uninstalls the AWS Lambda Layer CLI tool and removes all associated files.")
|
|
70
|
+
print(" This includes:")
|
|
71
|
+
print(" - The CLI executable and symlinks")
|
|
72
|
+
print(" - The installation directory")
|
|
73
|
+
print(" - Shell completion scripts")
|
|
74
|
+
raise SystemExit(0)
|
|
75
|
+
|
|
76
|
+
uninstall_script = assets_dir / "uninstall.sh"
|
|
77
|
+
if not uninstall_script.exists():
|
|
78
|
+
raise SystemExit(f"Uninstall script missing: {uninstall_script}")
|
|
79
|
+
|
|
80
|
+
# Use the same execution logic as the main script, but pointing to uninstall.sh
|
|
81
|
+
script_path = uninstall_script
|
|
82
|
+
# Remove 'uninstall' from args
|
|
83
|
+
args = args[1:]
|
|
84
|
+
|
|
85
|
+
# Handle completion command
|
|
86
|
+
if args and args[0] == "completion":
|
|
87
|
+
has_zsh = "--zsh" in args
|
|
88
|
+
has_bash = "--bash" in args
|
|
89
|
+
|
|
90
|
+
if "--help" in args or "-h" in args or (not has_zsh and not has_bash):
|
|
91
|
+
GREEN = '\033[0;32m'
|
|
92
|
+
YELLOW = '\033[0;33m'
|
|
93
|
+
BLUE = '\033[0;34m'
|
|
94
|
+
MAGENTA = '\033[0;35m'
|
|
95
|
+
NC = '\033[0m'
|
|
96
|
+
UNDERLINE = '\033[4m'
|
|
97
|
+
|
|
98
|
+
print(f"{BLUE}Usage:{NC}")
|
|
99
|
+
print(f" aws-lambda-layer-cli {GREEN}completion{NC} [options]")
|
|
100
|
+
print("")
|
|
101
|
+
print(f"{BLUE}Options:{NC}")
|
|
102
|
+
print(f" {YELLOW}--zsh{NC} Output zsh completion script")
|
|
103
|
+
print(f" {YELLOW}--bash{NC} Output bash completion script")
|
|
104
|
+
print("")
|
|
105
|
+
print(f"{MAGENTA}{UNDERLINE}Examples:{NC}")
|
|
106
|
+
print(" # Load completion in current shell")
|
|
107
|
+
print(f" source <(aws-lambda-layer-cli {GREEN}completion{NC} {YELLOW}--bash{NC})")
|
|
108
|
+
print("")
|
|
109
|
+
print(" # Add to .zshrc")
|
|
110
|
+
print(f" aws-lambda-layer-cli {GREEN}completion{NC} {YELLOW}--zsh{NC} >> ~/.zshrc")
|
|
111
|
+
raise SystemExit(0)
|
|
112
|
+
|
|
113
|
+
completion_dir = assets_dir.parent / "completion"
|
|
114
|
+
shell = ""
|
|
115
|
+
|
|
116
|
+
if has_zsh:
|
|
117
|
+
shell = "zsh"
|
|
118
|
+
elif has_bash:
|
|
119
|
+
shell = "bash"
|
|
120
|
+
|
|
121
|
+
if shell == "zsh":
|
|
122
|
+
file = completion_dir / "aws-lambda-layer-completion.zsh"
|
|
123
|
+
if file.exists():
|
|
124
|
+
content = file.read_text(encoding="utf-8")
|
|
125
|
+
# Remove the auto-execution line if present
|
|
126
|
+
import re
|
|
127
|
+
content = re.sub(r'_aws-lambda-layer-cli "\$@"\s*$', "", content)
|
|
128
|
+
print(content)
|
|
129
|
+
print("\n# Register completion")
|
|
130
|
+
print("if type compdef &>/dev/null; then")
|
|
131
|
+
print(" compdef _aws-lambda-layer-cli aws-lambda-layer-cli")
|
|
132
|
+
print("fi")
|
|
133
|
+
else:
|
|
134
|
+
print("Completion script not found for zsh", file=sys.stderr)
|
|
135
|
+
raise SystemExit(1)
|
|
136
|
+
else:
|
|
137
|
+
# bash
|
|
138
|
+
file = completion_dir / "aws-lambda-layer-completion.bash"
|
|
139
|
+
if file.exists():
|
|
140
|
+
print(file.read_text(encoding="utf-8"))
|
|
141
|
+
else:
|
|
142
|
+
print("Completion script not found for bash", file=sys.stderr)
|
|
143
|
+
raise SystemExit(1)
|
|
144
|
+
raise SystemExit(0)
|
|
145
|
+
|
|
58
146
|
# POSIX
|
|
59
147
|
if os.name != "nt":
|
|
60
148
|
raise SystemExit(_run(["bash", str(script_path), *args]))
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execSync } = require('child_process');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const isWindows = os.platform() === 'win32';
|
|
9
|
+
const scriptPath = isWindows ? path.join('scripts', 'uninstall.ps1') : path.join('scripts', 'uninstall.sh');
|
|
10
|
+
const fullPath = path.join(__dirname, '..', scriptPath);
|
|
11
|
+
const args = process.argv.slice(2).map(arg => `"${arg}"`).join(' ');
|
|
12
|
+
|
|
13
|
+
if (!fs.existsSync(fullPath)) {
|
|
14
|
+
console.error(`Uninstallation script not found: ${fullPath}`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (isWindows) {
|
|
19
|
+
// Run PowerShell script with proper execution policy
|
|
20
|
+
execSync(`powershell -ExecutionPolicy Bypass -File "${fullPath}" ${args}`, {
|
|
21
|
+
stdio: 'inherit',
|
|
22
|
+
shell: true
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
// Check if we are root
|
|
26
|
+
const isRoot = process.getuid && process.getuid() === 0;
|
|
27
|
+
|
|
28
|
+
if (!isRoot) {
|
|
29
|
+
console.log('This script requires root privileges to uninstall from /usr/local/lib.');
|
|
30
|
+
console.log('Requesting sudo permissions...');
|
|
31
|
+
// Run with sudo directly from node
|
|
32
|
+
execSync(`sudo bash "${fullPath}" ${args}`, {
|
|
33
|
+
stdio: 'inherit'
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
// Already root, just run it
|
|
37
|
+
execSync(`bash "${fullPath}" ${args}`, {
|
|
38
|
+
stdio: 'inherit'
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log('✓ Uninstallation completed successfully');
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('✗ Uninstallation failed:', error.message);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
package/scripts/uninstall.ps1
CHANGED
|
@@ -1,180 +1,210 @@
|
|
|
1
|
-
#Requires -Version 5.1
|
|
2
|
-
|
|
3
|
-
<#
|
|
4
|
-
.SYNOPSIS
|
|
5
|
-
AWS Lambda Layer CLI Tool Uninstaller for Windows
|
|
6
|
-
|
|
7
|
-
.DESCRIPTION
|
|
8
|
-
Uninstalls the AWS Lambda Layer CLI tool from Windows systems.
|
|
9
|
-
|
|
10
|
-
.PARAMETER InstallDir
|
|
11
|
-
Directory where the tool is installed (default: $env:USERPROFILE\.aws-lambda-layer)
|
|
12
|
-
|
|
13
|
-
.PARAMETER Force
|
|
14
|
-
Force uninstallation without confirmation
|
|
15
|
-
|
|
16
|
-
.EXAMPLE
|
|
17
|
-
# Uninstall with default settings
|
|
18
|
-
.\uninstall.ps1
|
|
19
|
-
|
|
20
|
-
.EXAMPLE
|
|
21
|
-
# Uninstall from custom directory
|
|
22
|
-
.\uninstall.ps1 -InstallDir "C:\Tools\aws-lambda-layer"
|
|
23
|
-
|
|
24
|
-
.EXAMPLE
|
|
25
|
-
# Force uninstall
|
|
26
|
-
.\uninstall.ps1 -Force
|
|
27
|
-
#>
|
|
28
|
-
|
|
29
|
-
param(
|
|
30
|
-
[string]$InstallDir = "",
|
|
31
|
-
[switch]$Force
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
# Determine InstallDir if not provided
|
|
35
|
-
if ([string]::IsNullOrEmpty($InstallDir)) {
|
|
36
|
-
if ($env:USERPROFILE) {
|
|
37
|
-
$InstallDir = Join-Path $env:USERPROFILE ".aws-lambda-layer"
|
|
38
|
-
} elseif ($env:HOME) {
|
|
39
|
-
$InstallDir = Join-Path $env:HOME ".aws-lambda-layer"
|
|
40
|
-
} else {
|
|
41
|
-
Write-Error "Could not determine home directory. Please specify -InstallDir."
|
|
42
|
-
exit 1
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
# Colors for output
|
|
47
|
-
$Green = "Green"
|
|
48
|
-
$Yellow = "Yellow"
|
|
49
|
-
$Red = "Red"
|
|
50
|
-
$Cyan = "Cyan"
|
|
51
|
-
$White = "White"
|
|
52
|
-
|
|
53
|
-
function Write-ColorOutput {
|
|
54
|
-
param(
|
|
55
|
-
[string]$Message,
|
|
56
|
-
[string]$Color = $White
|
|
57
|
-
)
|
|
58
|
-
Write-Host $Message -ForegroundColor $Color
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function Write-Header {
|
|
62
|
-
Write-ColorOutput "`n=========================================" $Cyan
|
|
63
|
-
Write-ColorOutput "AWS Lambda Layer CLI Tool Uninstaller" $Green
|
|
64
|
-
Write-ColorOutput "=========================================" $Cyan
|
|
65
|
-
Write-ColorOutput "Install Directory: $InstallDir" $White
|
|
66
|
-
Write-ColorOutput ""
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function Test-Installation {
|
|
70
|
-
Write-ColorOutput "Checking installation..." $Yellow
|
|
71
|
-
|
|
72
|
-
if (-not (Test-Path $InstallDir)) {
|
|
73
|
-
Write-ColorOutput "Installation directory not found: $InstallDir" $Yellow
|
|
74
|
-
Write-ColorOutput "The tool doesn't appear to be installed." $White
|
|
75
|
-
return $false
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
$mainScript = Join-Path $InstallDir "aws-lambda-layer"
|
|
79
|
-
if (-not (Test-Path $mainScript)) {
|
|
80
|
-
Write-ColorOutput "Main script not found: $mainScript" $Yellow
|
|
81
|
-
Write-ColorOutput "This doesn't look like a valid installation." $White
|
|
82
|
-
return $false
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
Write-ColorOutput "✓ Found installation at $InstallDir" $Green
|
|
86
|
-
return $true
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function Remove-FromPath {
|
|
90
|
-
Write-ColorOutput "Removing from PATH..." $Yellow
|
|
91
|
-
|
|
92
|
-
# Get current user PATH
|
|
93
|
-
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
94
|
-
|
|
95
|
-
# Remove our directory from PATH if present
|
|
96
|
-
if ($currentPath -like "*$InstallDir*") {
|
|
97
|
-
# Split PATH into array, filter out our directory, and rejoin
|
|
98
|
-
$pathArray = $currentPath -split ';' | Where-Object { $_ -ne $InstallDir -and $_ -ne "$InstallDir\" }
|
|
99
|
-
$newPath = $pathArray -join ';'
|
|
100
|
-
|
|
101
|
-
# Update PATH
|
|
102
|
-
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
|
|
103
|
-
Write-ColorOutput "✓ Removed $InstallDir from user PATH" $Green
|
|
104
|
-
Write-ColorOutput " Note: Restart your terminal for PATH changes to take effect" $Yellow
|
|
105
|
-
} else {
|
|
106
|
-
Write-ColorOutput "✓ $InstallDir not found in user PATH" $Green
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function Remove-Installation {
|
|
111
|
-
Write-ColorOutput "Removing installation files..." $Yellow
|
|
112
|
-
|
|
113
|
-
try {
|
|
114
|
-
# Remove the entire installation directory
|
|
115
|
-
Remove-Item $InstallDir -Recurse -Force
|
|
116
|
-
Write-ColorOutput "✓ Removed installation directory" $Green
|
|
117
|
-
return $true
|
|
118
|
-
} catch {
|
|
119
|
-
Write-ColorOutput "✗ Failed to remove installation directory" $Red
|
|
120
|
-
Write-ColorOutput "Error: $($_.Exception.Message)" $Red
|
|
121
|
-
return $false
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function Show-PostUninstall {
|
|
126
|
-
Write-ColorOutput "`n=========================================" $Cyan
|
|
127
|
-
Write-ColorOutput "Uninstallation Complete!" $Green
|
|
128
|
-
Write-ColorOutput "=========================================" $Cyan
|
|
129
|
-
Write-ColorOutput ""
|
|
130
|
-
Write-ColorOutput "The AWS Lambda Layer CLI tool has been removed from your system." $White
|
|
131
|
-
Write-ColorOutput ""
|
|
132
|
-
Write-ColorOutput "What was removed:" $Yellow
|
|
133
|
-
Write-ColorOutput " • Installation directory: $InstallDir" $White
|
|
134
|
-
Write-ColorOutput " • PATH entry (if present)" $White
|
|
135
|
-
Write-ColorOutput ""
|
|
136
|
-
Write-ColorOutput "Note: You may need to restart your terminal for PATH changes to take effect." $Yellow
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
# Main uninstallation process
|
|
140
|
-
function Main {
|
|
141
|
-
Write-Header
|
|
142
|
-
|
|
143
|
-
# Check
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
1
|
+
#Requires -Version 5.1
|
|
2
|
+
|
|
3
|
+
<#
|
|
4
|
+
.SYNOPSIS
|
|
5
|
+
AWS Lambda Layer CLI Tool Uninstaller for Windows
|
|
6
|
+
|
|
7
|
+
.DESCRIPTION
|
|
8
|
+
Uninstalls the AWS Lambda Layer CLI tool from Windows systems.
|
|
9
|
+
|
|
10
|
+
.PARAMETER InstallDir
|
|
11
|
+
Directory where the tool is installed (default: $env:USERPROFILE\.aws-lambda-layer-cli)
|
|
12
|
+
|
|
13
|
+
.PARAMETER Force
|
|
14
|
+
Force uninstallation without confirmation
|
|
15
|
+
|
|
16
|
+
.EXAMPLE
|
|
17
|
+
# Uninstall with default settings
|
|
18
|
+
.\uninstall.ps1
|
|
19
|
+
|
|
20
|
+
.EXAMPLE
|
|
21
|
+
# Uninstall from custom directory
|
|
22
|
+
.\uninstall.ps1 -InstallDir "C:\Tools\aws-lambda-layer"
|
|
23
|
+
|
|
24
|
+
.EXAMPLE
|
|
25
|
+
# Force uninstall
|
|
26
|
+
.\uninstall.ps1 -Force
|
|
27
|
+
#>
|
|
28
|
+
|
|
29
|
+
param(
|
|
30
|
+
[string]$InstallDir = "",
|
|
31
|
+
[switch]$Force
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# Determine InstallDir if not provided
|
|
35
|
+
if ([string]::IsNullOrEmpty($InstallDir)) {
|
|
36
|
+
if ($env:USERPROFILE) {
|
|
37
|
+
$InstallDir = Join-Path $env:USERPROFILE ".aws-lambda-layer-cli"
|
|
38
|
+
} elseif ($env:HOME) {
|
|
39
|
+
$InstallDir = Join-Path $env:HOME ".aws-lambda-layer-cli"
|
|
40
|
+
} else {
|
|
41
|
+
Write-Error "Could not determine home directory. Please specify -InstallDir."
|
|
42
|
+
exit 1
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# Colors for output
|
|
47
|
+
$Green = "Green"
|
|
48
|
+
$Yellow = "Yellow"
|
|
49
|
+
$Red = "Red"
|
|
50
|
+
$Cyan = "Cyan"
|
|
51
|
+
$White = "White"
|
|
52
|
+
|
|
53
|
+
function Write-ColorOutput {
|
|
54
|
+
param(
|
|
55
|
+
[string]$Message,
|
|
56
|
+
[string]$Color = $White
|
|
57
|
+
)
|
|
58
|
+
Write-Host $Message -ForegroundColor $Color
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function Write-Header {
|
|
62
|
+
Write-ColorOutput "`n=========================================" $Cyan
|
|
63
|
+
Write-ColorOutput "AWS Lambda Layer CLI Tool Uninstaller" $Green
|
|
64
|
+
Write-ColorOutput "=========================================" $Cyan
|
|
65
|
+
Write-ColorOutput "Install Directory: $InstallDir" $White
|
|
66
|
+
Write-ColorOutput ""
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function Test-Installation {
|
|
70
|
+
Write-ColorOutput "Checking installation..." $Yellow
|
|
71
|
+
|
|
72
|
+
if (-not (Test-Path $InstallDir)) {
|
|
73
|
+
Write-ColorOutput "Installation directory not found: $InstallDir" $Yellow
|
|
74
|
+
Write-ColorOutput "The tool doesn't appear to be installed." $White
|
|
75
|
+
return $false
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
$mainScript = Join-Path $InstallDir "aws-lambda-layer-cli"
|
|
79
|
+
if (-not (Test-Path $mainScript)) {
|
|
80
|
+
Write-ColorOutput "Main script not found: $mainScript" $Yellow
|
|
81
|
+
Write-ColorOutput "This doesn't look like a valid installation." $White
|
|
82
|
+
return $false
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
Write-ColorOutput "✓ Found installation at $InstallDir" $Green
|
|
86
|
+
return $true
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function Remove-FromPath {
|
|
90
|
+
Write-ColorOutput "Removing from PATH..." $Yellow
|
|
91
|
+
|
|
92
|
+
# Get current user PATH
|
|
93
|
+
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
94
|
+
|
|
95
|
+
# Remove our directory from PATH if present
|
|
96
|
+
if ($currentPath -like "*$InstallDir*") {
|
|
97
|
+
# Split PATH into array, filter out our directory, and rejoin
|
|
98
|
+
$pathArray = $currentPath -split ';' | Where-Object { $_ -ne $InstallDir -and $_ -ne "$InstallDir\" }
|
|
99
|
+
$newPath = $pathArray -join ';'
|
|
100
|
+
|
|
101
|
+
# Update PATH
|
|
102
|
+
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
|
|
103
|
+
Write-ColorOutput "✓ Removed $InstallDir from user PATH" $Green
|
|
104
|
+
Write-ColorOutput " Note: Restart your terminal for PATH changes to take effect" $Yellow
|
|
105
|
+
} else {
|
|
106
|
+
Write-ColorOutput "✓ $InstallDir not found in user PATH" $Green
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function Remove-Installation {
|
|
111
|
+
Write-ColorOutput "Removing installation files..." $Yellow
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
# Remove the entire installation directory
|
|
115
|
+
Remove-Item $InstallDir -Recurse -Force
|
|
116
|
+
Write-ColorOutput "✓ Removed installation directory" $Green
|
|
117
|
+
return $true
|
|
118
|
+
} catch {
|
|
119
|
+
Write-ColorOutput "✗ Failed to remove installation directory" $Red
|
|
120
|
+
Write-ColorOutput "Error: $($_.Exception.Message)" $Red
|
|
121
|
+
return $false
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function Show-PostUninstall {
|
|
126
|
+
Write-ColorOutput "`n=========================================" $Cyan
|
|
127
|
+
Write-ColorOutput "Uninstallation Complete!" $Green
|
|
128
|
+
Write-ColorOutput "=========================================" $Cyan
|
|
129
|
+
Write-ColorOutput ""
|
|
130
|
+
Write-ColorOutput "The AWS Lambda Layer CLI tool has been removed from your system." $White
|
|
131
|
+
Write-ColorOutput ""
|
|
132
|
+
Write-ColorOutput "What was removed:" $Yellow
|
|
133
|
+
Write-ColorOutput " • Installation directory: $InstallDir" $White
|
|
134
|
+
Write-ColorOutput " • PATH entry (if present)" $White
|
|
135
|
+
Write-ColorOutput ""
|
|
136
|
+
Write-ColorOutput "Note: You may need to restart your terminal for PATH changes to take effect." $Yellow
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
# Main uninstallation process
|
|
140
|
+
function Main {
|
|
141
|
+
Write-Header
|
|
142
|
+
|
|
143
|
+
# Check NPM
|
|
144
|
+
if (Get-Command npm -ErrorAction SilentlyContinue) {
|
|
145
|
+
$npmList = npm list -g aws-lambda-layer-cli --depth=0 2>$null
|
|
146
|
+
if ($npmList -match "aws-lambda-layer-cli@") {
|
|
147
|
+
Write-ColorOutput "Detected NPM installation." $Yellow
|
|
148
|
+
Write-ColorOutput "Removing NPM package..." $White
|
|
149
|
+
npm uninstall -g aws-lambda-layer-cli
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
# Check PyPI
|
|
154
|
+
if (Get-Command pip -ErrorAction SilentlyContinue) {
|
|
155
|
+
pip show aws-lambda-layer-cli 2>$null | Out-Null
|
|
156
|
+
if ($LASTEXITCODE -eq 0) {
|
|
157
|
+
Write-ColorOutput "Detected PyPI installation." $Yellow
|
|
158
|
+
Write-ColorOutput "Removing PyPI package..." $White
|
|
159
|
+
pip uninstall -y aws-lambda-layer-cli
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
# Check uv
|
|
164
|
+
if (Get-Command uv -ErrorAction SilentlyContinue) {
|
|
165
|
+
$uvList = uv tool list 2>$null
|
|
166
|
+
if ($uvList -match "aws-lambda-layer-cli") {
|
|
167
|
+
Write-ColorOutput "Detected uv installation." $Yellow
|
|
168
|
+
Write-ColorOutput "Removing uv tool..." $White
|
|
169
|
+
uv tool uninstall aws-lambda-layer-cli
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
# Check if tool is installed
|
|
174
|
+
$isInstalled = Test-Installation
|
|
175
|
+
if (-not $isInstalled) {
|
|
176
|
+
if (-not $Force) {
|
|
177
|
+
$continue = Read-Host "Continue with uninstallation anyway? (y/N)"
|
|
178
|
+
if ($continue -notmatch "^[Yy]$") {
|
|
179
|
+
Write-ColorOutput "Uninstallation cancelled." $Red
|
|
180
|
+
exit 0
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
# Confirm uninstallation unless forced
|
|
186
|
+
if (-not $Force) {
|
|
187
|
+
Write-ColorOutput "This will remove the AWS Lambda Layer CLI tool from your system." $Yellow
|
|
188
|
+
$confirm = Read-Host "Are you sure you want to continue? (y/N)"
|
|
189
|
+
if ($confirm -notmatch "^[Yy]$") {
|
|
190
|
+
Write-ColorOutput "Uninstallation cancelled." $Red
|
|
191
|
+
exit 0
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
# Remove from PATH
|
|
196
|
+
Remove-FromPath
|
|
197
|
+
|
|
198
|
+
# Remove installation files
|
|
199
|
+
$uninstallSuccess = Remove-Installation
|
|
200
|
+
if (-not $uninstallSuccess) {
|
|
201
|
+
Write-ColorOutput "`nUninstallation failed!" $Red
|
|
202
|
+
exit 1
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
# Show post-uninstallation information
|
|
206
|
+
Show-PostUninstall
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
# Run main function
|
|
180
210
|
Main
|