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/uninstall.sh
CHANGED
|
@@ -11,23 +11,86 @@ YELLOW='\033[1;33m'
|
|
|
11
11
|
BLUE='\033[0;34m'
|
|
12
12
|
NC='\033[0m'
|
|
13
13
|
|
|
14
|
+
# Check for help flag
|
|
15
|
+
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
|
|
16
|
+
printf "${BLUE}Usage:${NC}\n"
|
|
17
|
+
printf " aws-lambda-layer-cli ${GREEN}uninstall${NC}\n\n"
|
|
18
|
+
printf "${BLUE}Description:${NC}\n"
|
|
19
|
+
printf " Uninstalls the AWS Lambda Layer CLI tool and removes all associated files.\n"
|
|
20
|
+
printf " This includes:\n"
|
|
21
|
+
printf " - The CLI executable and symlinks\n"
|
|
22
|
+
printf " - The installation directory (/usr/local/lib/aws-lambda-layer-cli)\n"
|
|
23
|
+
printf " - Shell completion scripts\n"
|
|
24
|
+
exit 0
|
|
25
|
+
fi
|
|
26
|
+
|
|
14
27
|
printf "${RED}Uninstalling AWS Lambda Layer CLI Tool...${NC}\n"
|
|
15
28
|
|
|
29
|
+
# Check for other installation sources
|
|
30
|
+
printf "\n${BLUE}Checking installation sources...${NC}\n"
|
|
31
|
+
|
|
32
|
+
# Check NPM
|
|
33
|
+
if command -v npm &> /dev/null; then
|
|
34
|
+
if npm list -g aws-lambda-layer-cli --depth=0 &> /dev/null; then
|
|
35
|
+
printf "${YELLOW}Detected NPM installation.${NC}\n"
|
|
36
|
+
printf " Removing NPM package...\n"
|
|
37
|
+
npm uninstall -g aws-lambda-layer-cli
|
|
38
|
+
fi
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Check PyPI (pip)
|
|
42
|
+
if command -v pip &> /dev/null || command -v pip3 &> /dev/null; then
|
|
43
|
+
# Try pip then pip3
|
|
44
|
+
PIP_CMD="pip"
|
|
45
|
+
if ! command -v pip &> /dev/null; then
|
|
46
|
+
PIP_CMD="pip3"
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
if $PIP_CMD show aws-lambda-layer-cli &> /dev/null; then
|
|
50
|
+
printf "${YELLOW}Detected PyPI installation.${NC}\n"
|
|
51
|
+
printf " Removing PyPI package...\n"
|
|
52
|
+
$PIP_CMD uninstall -y aws-lambda-layer-cli
|
|
53
|
+
fi
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
# Check uv
|
|
57
|
+
if command -v uv &> /dev/null; then
|
|
58
|
+
if uv tool list | grep -q "aws-lambda-layer-cli"; then
|
|
59
|
+
printf "${YELLOW}Detected uv installation.${NC}\n"
|
|
60
|
+
printf " Removing uv tool...\n"
|
|
61
|
+
uv tool uninstall aws-lambda-layer-cli
|
|
62
|
+
fi
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
# Check Native (System)
|
|
66
|
+
if [ -d "/usr/local/lib/aws-lambda-layer-cli" ]; then
|
|
67
|
+
printf "${YELLOW}Detected Native/System installation.${NC}\n"
|
|
68
|
+
printf " Proceeding with removal of system files...\n"
|
|
69
|
+
else
|
|
70
|
+
printf "No Native/System installation found at /usr/local/lib/aws-lambda-layer-cli.\n"
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
printf "\n"
|
|
74
|
+
|
|
16
75
|
# Check if running as root
|
|
17
76
|
if [ "$EUID" -ne 0 ]; then
|
|
18
|
-
|
|
77
|
+
# Check if we need a password (sudo -n true returns 0 if we have access, 1 if we need password)
|
|
78
|
+
if ! sudo -n true 2>/dev/null; then
|
|
79
|
+
printf "${YELLOW}This script requires root privileges to uninstall from /usr/local/lib.${NC}\n"
|
|
80
|
+
printf "${YELLOW}Please enter your password if prompted.${NC}\n"
|
|
81
|
+
fi
|
|
19
82
|
SUDO="sudo"
|
|
20
83
|
else
|
|
21
84
|
SUDO=""
|
|
22
85
|
fi
|
|
23
86
|
|
|
24
|
-
INSTALL_DIR="/usr/local/lib/aws-lambda-layer"
|
|
87
|
+
INSTALL_DIR="/usr/local/lib/aws-lambda-layer-cli"
|
|
25
88
|
BIN_DIR="/usr/local/bin"
|
|
26
89
|
COMPLETION_DIR="/etc/bash_completion.d"
|
|
27
90
|
|
|
28
91
|
# Remove symlink
|
|
29
92
|
printf "${BLUE}Removing symlink...${NC}\n"
|
|
30
|
-
$SUDO rm -f "$BIN_DIR/aws-lambda-layer"
|
|
93
|
+
$SUDO rm -f "$BIN_DIR/aws-lambda-layer-cli"
|
|
31
94
|
|
|
32
95
|
# Remove installation directory
|
|
33
96
|
printf "${BLUE}Removing installation directory...${NC}\n"
|
|
@@ -35,24 +98,24 @@ $SUDO rm -rf "$INSTALL_DIR"
|
|
|
35
98
|
|
|
36
99
|
# Remove bash completion
|
|
37
100
|
printf "${BLUE}Removing bash completion...${NC}\n"
|
|
38
|
-
$SUDO rm -f "$COMPLETION_DIR/aws-lambda-layer"
|
|
101
|
+
$SUDO rm -f "$COMPLETION_DIR/aws-lambda-layer-cli"
|
|
39
102
|
|
|
40
103
|
# Remove zsh completion
|
|
41
|
-
if [ -f "/usr/local/share/zsh/site-functions/_aws-lambda-layer" ]; then
|
|
104
|
+
if [ -f "/usr/local/share/zsh/site-functions/_aws-lambda-layer-cli" ]; then
|
|
42
105
|
printf "${BLUE}Removing zsh completion (standard)...${NC}\n"
|
|
43
|
-
$SUDO rm -f "/usr/local/share/zsh/site-functions/_aws-lambda-layer"
|
|
106
|
+
$SUDO rm -f "/usr/local/share/zsh/site-functions/_aws-lambda-layer-cli"
|
|
44
107
|
fi
|
|
45
108
|
|
|
46
|
-
if [ -f "/opt/homebrew/share/zsh/site-functions/_aws-lambda-layer" ]; then
|
|
109
|
+
if [ -f "/opt/homebrew/share/zsh/site-functions/_aws-lambda-layer-cli" ]; then
|
|
47
110
|
printf "${BLUE}Removing zsh completion (Homebrew)...${NC}\n"
|
|
48
|
-
$SUDO rm -f "/opt/homebrew/share/zsh/site-functions/_aws-lambda-layer"
|
|
111
|
+
$SUDO rm -f "/opt/homebrew/share/zsh/site-functions/_aws-lambda-layer-cli"
|
|
49
112
|
fi
|
|
50
113
|
|
|
51
114
|
# Remove from .bashrc
|
|
52
115
|
if [ -f "$HOME/.bashrc" ]; then
|
|
53
116
|
printf "${BLUE}Cleaning up .bashrc...${NC}\n"
|
|
54
117
|
$SUDO sed -i '/# AWS Lambda Layer CLI completion/d' "$HOME/.bashrc"
|
|
55
|
-
$SUDO sed -i '/source.*aws-lambda-layer/d' "$HOME/.bashrc"
|
|
118
|
+
$SUDO sed -i '/source.*aws-lambda-layer-cli/d' "$HOME/.bashrc"
|
|
56
119
|
fi
|
|
57
120
|
|
|
58
121
|
printf "${GREEN}✅ Uninstallation complete!${NC}\n"
|
package/bin/aws-lambda-layer.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const { spawnSync } = require('child_process');
|
|
6
|
-
const fs = require('fs');
|
|
7
|
-
const path = require('path');
|
|
8
|
-
|
|
9
|
-
function which(cmd) {
|
|
10
|
-
const isWin = process.platform === 'win32';
|
|
11
|
-
const exts = isWin ? (process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM').split(';') : [''];
|
|
12
|
-
const paths = (process.env.PATH || '').split(path.delimiter);
|
|
13
|
-
|
|
14
|
-
for (const p of paths) {
|
|
15
|
-
if (!p) continue;
|
|
16
|
-
for (const ext of exts) {
|
|
17
|
-
const full = path.join(p, isWin ? cmd + ext.toLowerCase() : cmd);
|
|
18
|
-
if (fs.existsSync(full)) return full;
|
|
19
|
-
// Also check original case on Windows
|
|
20
|
-
const full2 = path.join(p, cmd + ext);
|
|
21
|
-
if (fs.existsSync(full2)) return full2;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function shQuote(s) {
|
|
28
|
-
// Single-quote for bash -lc
|
|
29
|
-
return `'${String(s).replace(/'/g, `'\\''`)}'`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function windowsPathToWsl(p) {
|
|
33
|
-
// C:\Users\me\x -> /mnt/c/Users/me/x
|
|
34
|
-
const m = /^([a-zA-Z]):\\(.*)$/.exec(p);
|
|
35
|
-
if (!m) return null;
|
|
36
|
-
return `/mnt/${m[1].toLowerCase()}/${m[2].replace(/\\/g, '/')}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function cygpathConvert(mode, p) {
|
|
40
|
-
const cygpath = which('cygpath');
|
|
41
|
-
if (!cygpath) return null;
|
|
42
|
-
const res = spawnSync(cygpath, [mode, p], { encoding: 'utf8' });
|
|
43
|
-
if (res.status !== 0) return null;
|
|
44
|
-
return (res.stdout || '').trim();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function run(cmd, args) {
|
|
48
|
-
const res = spawnSync(cmd, args, { stdio: 'inherit' });
|
|
49
|
-
process.exit(res.status ?? 1);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const args = process.argv.slice(2);
|
|
53
|
-
const bashScript = path.resolve(__dirname, '..', 'scripts', 'aws-lambda-layer');
|
|
54
|
-
|
|
55
|
-
if (!fs.existsSync(bashScript)) {
|
|
56
|
-
console.error('Error: packaged bash script not found:', bashScript);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// POSIX platforms
|
|
61
|
-
if (process.platform !== 'win32') {
|
|
62
|
-
run('bash', [bashScript, ...args]);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Windows platforms:
|
|
66
|
-
// - Prefer Git Bash / MSYS / Cygwin: convert to POSIX path using cygpath -u
|
|
67
|
-
// - Else attempt WSL: convert to /mnt/<drive>/... and run via wsl.exe
|
|
68
|
-
// - Else give a clear message
|
|
69
|
-
|
|
70
|
-
const posixPath = cygpathConvert('-u', bashScript);
|
|
71
|
-
if (posixPath) {
|
|
72
|
-
run('bash', [posixPath, ...args]);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const wsl = which('wsl.exe') || which('wsl');
|
|
76
|
-
if (wsl) {
|
|
77
|
-
const wslPath = windowsPathToWsl(bashScript);
|
|
78
|
-
if (!wslPath) {
|
|
79
|
-
console.error('Error: unable to convert path for WSL:', bashScript);
|
|
80
|
-
process.exit(1);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const cmd = `bash ${shQuote(wslPath)} ${args.map(shQuote).join(' ')}`.trim();
|
|
84
|
-
run(wsl, ['bash', '-lc', cmd]);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
console.error('Error: no compatible bash found on Windows.');
|
|
88
|
-
console.error('Install and run this tool inside WSL, or install Git Bash and ensure `bash`/`cygpath` are on PATH.');
|
|
89
|
-
process.exit(1);
|