aws-lambda-layer-cli 1.4.1
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/LICENSE +21 -0
- package/README.md +393 -0
- package/bin/aws-lambda-layer.js +89 -0
- package/completion/aws-lambda-layer-completion.bash +101 -0
- package/completion/aws-lambda-layer-completion.zsh +110 -0
- package/package.json +31 -0
- package/scripts/aws-lambda-layer +821 -0
- package/scripts/build_pypi.sh +37 -0
- package/scripts/create_nodejs_layer.sh +459 -0
- package/scripts/create_python_layer.sh +465 -0
- package/scripts/install.js +34 -0
- package/scripts/install.ps1 +663 -0
- package/scripts/install.sh +107 -0
- package/scripts/pypi_resources/__init__.py +9 -0
- package/scripts/pypi_resources/cli.py +83 -0
- package/scripts/sync_version.js +24 -0
- package/scripts/uninstall.ps1 +180 -0
- package/scripts/uninstall.sh +58 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Installation script for aws-lambda-layer CLI tool
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
# Colors
|
|
8
|
+
RED='\033[0;31m'
|
|
9
|
+
GREEN='\033[0;32m'
|
|
10
|
+
YELLOW='\033[0;33m'
|
|
11
|
+
BLUE='\033[0;34m'
|
|
12
|
+
MAGENTA='\033[0;35m'
|
|
13
|
+
CYAN='\033[0;36m'
|
|
14
|
+
WHITE='\033[0;37m'
|
|
15
|
+
NC='\033[0m' # No Color
|
|
16
|
+
|
|
17
|
+
# Styles
|
|
18
|
+
BOLD='\033[1m'
|
|
19
|
+
ITALIC='\033[3m'
|
|
20
|
+
UNDERLINE='\033[4m'
|
|
21
|
+
|
|
22
|
+
printf "${CYAN}${BOLD}Installing AWS Lambda Layer CLI Tool...${NC}\n"
|
|
23
|
+
|
|
24
|
+
# Check if running as root
|
|
25
|
+
if [ "$EUID" -ne 0 ]; then
|
|
26
|
+
if command -v sudo &> /dev/null; then
|
|
27
|
+
printf "${YELLOW}Warning: Not running as root. Using sudo for installation.${NC}\n"
|
|
28
|
+
SUDO="sudo"
|
|
29
|
+
else
|
|
30
|
+
SUDO=""
|
|
31
|
+
fi
|
|
32
|
+
else
|
|
33
|
+
SUDO=""
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# Get script directory
|
|
37
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
38
|
+
BASE_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
39
|
+
INSTALL_DIR="/usr/local/lib/aws-lambda-layer"
|
|
40
|
+
BIN_DIR="/usr/local/bin"
|
|
41
|
+
COMPLETION_DIR="/etc/bash_completion.d"
|
|
42
|
+
|
|
43
|
+
# Create installation directory
|
|
44
|
+
printf "${BLUE}Creating installation directory...${NC}\n"
|
|
45
|
+
$SUDO mkdir -p "$INSTALL_DIR"
|
|
46
|
+
|
|
47
|
+
# Copy scripts
|
|
48
|
+
printf "${BLUE}Copying scripts...${NC}\n"
|
|
49
|
+
$SUDO cp "$SCRIPT_DIR/aws-lambda-layer" "$INSTALL_DIR/"
|
|
50
|
+
$SUDO cp "$SCRIPT_DIR/create_nodejs_layer.sh" "$INSTALL_DIR/"
|
|
51
|
+
$SUDO cp "$SCRIPT_DIR/create_python_layer.sh" "$INSTALL_DIR/"
|
|
52
|
+
$SUDO cp "$BASE_DIR/VERSION.txt" "$INSTALL_DIR/"
|
|
53
|
+
|
|
54
|
+
# Make scripts executable
|
|
55
|
+
printf "${BLUE}Setting executable permissions...${NC}\n"
|
|
56
|
+
$SUDO chmod +x "$INSTALL_DIR/aws-lambda-layer"
|
|
57
|
+
$SUDO chmod +x "$INSTALL_DIR/create_nodejs_layer.sh"
|
|
58
|
+
$SUDO chmod +x "$INSTALL_DIR/create_python_layer.sh"
|
|
59
|
+
|
|
60
|
+
# Create symlink in bin directory
|
|
61
|
+
printf "${BLUE}Creating symlink in $BIN_DIR...${NC}\n"
|
|
62
|
+
$SUDO ln -sf "$INSTALL_DIR/aws-lambda-layer" "$BIN_DIR/aws-lambda-layer"
|
|
63
|
+
|
|
64
|
+
# Install bash completion
|
|
65
|
+
printf "${BLUE}Installing bash completion...${NC}\n"
|
|
66
|
+
if [ -d "$COMPLETION_DIR" ]; then
|
|
67
|
+
$SUDO cp "$BASE_DIR/completion/aws-lambda-layer-completion.bash" "$COMPLETION_DIR/aws-lambda-layer"
|
|
68
|
+
# Source the completion script
|
|
69
|
+
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"
|
|
72
|
+
fi
|
|
73
|
+
fi
|
|
74
|
+
printf "${GREEN}Bash completion installed.${NC}\n"
|
|
75
|
+
else
|
|
76
|
+
printf "${YELLOW}Bash completion directory not found. Skipping completion installation.${NC}\n"
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
# Install zsh completion
|
|
80
|
+
printf "${BLUE}Installing zsh completion...${NC}\n"
|
|
81
|
+
# Try Homebrew location first (macOS with Homebrew), then standard location
|
|
82
|
+
ZSH_COMPLETION_DIR=""
|
|
83
|
+
if [ -d "/opt/homebrew/share/zsh/site-functions" ]; then
|
|
84
|
+
ZSH_COMPLETION_DIR="/opt/homebrew/share/zsh/site-functions"
|
|
85
|
+
elif [ -d "/usr/local/share/zsh/site-functions" ]; then
|
|
86
|
+
ZSH_COMPLETION_DIR="/usr/local/share/zsh/site-functions"
|
|
87
|
+
else
|
|
88
|
+
# Create standard location if neither exists
|
|
89
|
+
ZSH_COMPLETION_DIR="/usr/local/share/zsh/site-functions"
|
|
90
|
+
printf "${YELLOW}Creating zsh completion directory...${NC}\n"
|
|
91
|
+
$SUDO mkdir -p "$ZSH_COMPLETION_DIR"
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
if [ -n "$ZSH_COMPLETION_DIR" ]; then
|
|
95
|
+
$SUDO cp "$BASE_DIR/completion/aws-lambda-layer-completion.zsh" "$ZSH_COMPLETION_DIR/_aws-lambda-layer"
|
|
96
|
+
printf "${GREEN}Zsh completion installed to: $ZSH_COMPLETION_DIR${NC}\n"
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
printf "${GREEN}${BOLD}✅ Installation complete!${NC}\n\n"
|
|
100
|
+
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"
|
|
103
|
+
printf "${YELLOW}To enable tab completion, restart your shell:${NC}\n"
|
|
104
|
+
printf " For bash: source ~/.bashrc\n"
|
|
105
|
+
printf " For zsh: exec zsh\n\n"
|
|
106
|
+
printf "${YELLOW}Or reload zsh completions:${NC}\n"
|
|
107
|
+
printf " autoload -U compinit && compinit\n"
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import shutil
|
|
5
|
+
import subprocess
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
from importlib.resources import files as _res_files
|
|
11
|
+
except Exception: # pragma: no cover
|
|
12
|
+
_res_files = None # type: ignore
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _run(cmd: list[str]) -> int:
|
|
16
|
+
completed = subprocess.run(cmd)
|
|
17
|
+
return int(completed.returncode)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _which(name: str) -> str | None:
|
|
21
|
+
return shutil.which(name)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _windows_path_to_wsl(p: Path) -> str | None:
|
|
25
|
+
# Convert like C:\Users\me\x -> /mnt/c/Users/me/x
|
|
26
|
+
drive = p.drive
|
|
27
|
+
if not drive or len(drive) < 2 or drive[1] != ":":
|
|
28
|
+
return None
|
|
29
|
+
drive_letter = drive[0].lower()
|
|
30
|
+
rest = str(p)[2:].lstrip("\\/")
|
|
31
|
+
return f"/mnt/{drive_letter}/" + rest.replace("\\", "/")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _cygpath(mode: str, p: str) -> str | None:
|
|
35
|
+
cygpath = _which("cygpath")
|
|
36
|
+
if not cygpath:
|
|
37
|
+
return None
|
|
38
|
+
res = subprocess.run([cygpath, mode, p], capture_output=True, text=True)
|
|
39
|
+
if res.returncode != 0:
|
|
40
|
+
return None
|
|
41
|
+
return (res.stdout or "").strip()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def main() -> None:
|
|
45
|
+
# Simple package-manager install: provide aws-lambda-layer command.
|
|
46
|
+
# This runs the bundled bash script (same behavior as the repo script).
|
|
47
|
+
if _res_files is not None:
|
|
48
|
+
assets_dir = Path(_res_files("aws_lambda_layer_cli").joinpath("assets"))
|
|
49
|
+
else:
|
|
50
|
+
assets_dir = Path(__file__).resolve().parent / "assets"
|
|
51
|
+
|
|
52
|
+
script_path = assets_dir / "aws-lambda-layer"
|
|
53
|
+
if not script_path.exists():
|
|
54
|
+
raise SystemExit(f"Packaged script missing: {script_path}")
|
|
55
|
+
|
|
56
|
+
args = sys.argv[1:]
|
|
57
|
+
|
|
58
|
+
# POSIX
|
|
59
|
+
if os.name != "nt":
|
|
60
|
+
raise SystemExit(_run(["bash", str(script_path), *args]))
|
|
61
|
+
|
|
62
|
+
# Windows
|
|
63
|
+
# 1) Git Bash / MSYS / Cygwin: use cygpath -u and run bash
|
|
64
|
+
posix = _cygpath("-u", str(script_path))
|
|
65
|
+
if posix and _which("bash"):
|
|
66
|
+
raise SystemExit(_run(["bash", posix, *args]))
|
|
67
|
+
|
|
68
|
+
# 2) WSL
|
|
69
|
+
wsl = _which("wsl.exe") or _which("wsl")
|
|
70
|
+
if wsl:
|
|
71
|
+
wsl_path = _windows_path_to_wsl(script_path)
|
|
72
|
+
if not wsl_path:
|
|
73
|
+
raise SystemExit(f"Unable to convert path for WSL: {script_path}")
|
|
74
|
+
|
|
75
|
+
def q(s: str) -> str:
|
|
76
|
+
return "'" + s.replace("'", "'\\''") + "'"
|
|
77
|
+
|
|
78
|
+
cmd = "bash " + q(wsl_path) + (" " + " ".join(q(a) for a in args) if args else "")
|
|
79
|
+
raise SystemExit(_run([wsl, "bash", "-lc", cmd]))
|
|
80
|
+
|
|
81
|
+
raise SystemExit(
|
|
82
|
+
"No compatible bash found on Windows. Install WSL (recommended) or Git Bash and ensure bash is on PATH."
|
|
83
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const rootDir = path.resolve(__dirname, '..');
|
|
7
|
+
const versionFile = path.join(rootDir, 'VERSION.txt');
|
|
8
|
+
const packageJsonFile = path.join(rootDir, 'package.json');
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
const version = fs.readFileSync(versionFile, 'utf8').trim();
|
|
12
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonFile, 'utf8'));
|
|
13
|
+
|
|
14
|
+
if (packageJson.version !== version) {
|
|
15
|
+
console.log(`Updating package.json version from ${packageJson.version} to ${version}`);
|
|
16
|
+
packageJson.version = version;
|
|
17
|
+
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2) + '\n');
|
|
18
|
+
} else {
|
|
19
|
+
console.log('package.json version is already up to date.');
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error('Error syncing version:', error);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
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 if tool is installed
|
|
144
|
+
$isInstalled = Test-Installation
|
|
145
|
+
if (-not $isInstalled) {
|
|
146
|
+
if (-not $Force) {
|
|
147
|
+
$continue = Read-Host "Continue with uninstallation anyway? (y/N)"
|
|
148
|
+
if ($continue -notmatch "^[Yy]$") {
|
|
149
|
+
Write-ColorOutput "Uninstallation cancelled." $Red
|
|
150
|
+
exit 0
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
# Confirm uninstallation unless forced
|
|
156
|
+
if (-not $Force) {
|
|
157
|
+
Write-ColorOutput "This will remove the AWS Lambda Layer CLI tool from your system." $Yellow
|
|
158
|
+
$confirm = Read-Host "Are you sure you want to continue? (y/N)"
|
|
159
|
+
if ($confirm -notmatch "^[Yy]$") {
|
|
160
|
+
Write-ColorOutput "Uninstallation cancelled." $Red
|
|
161
|
+
exit 0
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
# Remove from PATH
|
|
166
|
+
Remove-FromPath
|
|
167
|
+
|
|
168
|
+
# Remove installation files
|
|
169
|
+
$uninstallSuccess = Remove-Installation
|
|
170
|
+
if (-not $uninstallSuccess) {
|
|
171
|
+
Write-ColorOutput "`nUninstallation failed!" $Red
|
|
172
|
+
exit 1
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
# Show post-uninstallation information
|
|
176
|
+
Show-PostUninstall
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
# Run main function
|
|
180
|
+
Main
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Uninstallation script for aws-lambda-layer CLI tool
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
# Colors
|
|
8
|
+
RED='\033[0;31m'
|
|
9
|
+
GREEN='\033[0;32m'
|
|
10
|
+
YELLOW='\033[1;33m'
|
|
11
|
+
BLUE='\033[0;34m'
|
|
12
|
+
NC='\033[0m'
|
|
13
|
+
|
|
14
|
+
printf "${RED}Uninstalling AWS Lambda Layer CLI Tool...${NC}\n"
|
|
15
|
+
|
|
16
|
+
# Check if running as root
|
|
17
|
+
if [ "$EUID" -ne 0 ]; then
|
|
18
|
+
printf "${YELLOW}Warning: Not running as root. Using sudo for uninstallation.${NC}\n"
|
|
19
|
+
SUDO="sudo"
|
|
20
|
+
else
|
|
21
|
+
SUDO=""
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
INSTALL_DIR="/usr/local/lib/aws-lambda-layer"
|
|
25
|
+
BIN_DIR="/usr/local/bin"
|
|
26
|
+
COMPLETION_DIR="/etc/bash_completion.d"
|
|
27
|
+
|
|
28
|
+
# Remove symlink
|
|
29
|
+
printf "${BLUE}Removing symlink...${NC}\n"
|
|
30
|
+
$SUDO rm -f "$BIN_DIR/aws-lambda-layer"
|
|
31
|
+
|
|
32
|
+
# Remove installation directory
|
|
33
|
+
printf "${BLUE}Removing installation directory...${NC}\n"
|
|
34
|
+
$SUDO rm -rf "$INSTALL_DIR"
|
|
35
|
+
|
|
36
|
+
# Remove bash completion
|
|
37
|
+
printf "${BLUE}Removing bash completion...${NC}\n"
|
|
38
|
+
$SUDO rm -f "$COMPLETION_DIR/aws-lambda-layer"
|
|
39
|
+
|
|
40
|
+
# Remove zsh completion
|
|
41
|
+
if [ -f "/usr/local/share/zsh/site-functions/_aws-lambda-layer" ]; then
|
|
42
|
+
printf "${BLUE}Removing zsh completion (standard)...${NC}\n"
|
|
43
|
+
$SUDO rm -f "/usr/local/share/zsh/site-functions/_aws-lambda-layer"
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
if [ -f "/opt/homebrew/share/zsh/site-functions/_aws-lambda-layer" ]; then
|
|
47
|
+
printf "${BLUE}Removing zsh completion (Homebrew)...${NC}\n"
|
|
48
|
+
$SUDO rm -f "/opt/homebrew/share/zsh/site-functions/_aws-lambda-layer"
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
# Remove from .bashrc
|
|
52
|
+
if [ -f "$HOME/.bashrc" ]; then
|
|
53
|
+
printf "${BLUE}Cleaning up .bashrc...${NC}\n"
|
|
54
|
+
$SUDO sed -i '/# AWS Lambda Layer CLI completion/d' "$HOME/.bashrc"
|
|
55
|
+
$SUDO sed -i '/source.*aws-lambda-layer/d' "$HOME/.bashrc"
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
printf "${GREEN}✅ Uninstallation complete!${NC}\n"
|