setup-kapelu 3.2.10 β†’ 3.2.11

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.
Files changed (3) hide show
  1. package/cli.js +39 -63
  2. package/install.sh +112 -104
  3. package/package.json +5 -2
package/cli.js CHANGED
@@ -1,10 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const { execSync } = require("child_process");
4
+ const { existsSync } = require("fs");
4
5
  const pkg = require("./package.json");
5
- const { clear } = require("console");
6
6
 
7
- function exists(cmd) {
7
+ function run(cmd, options = {}) {
8
+ execSync(cmd, { stdio: "inherit", shell: "/bin/bash", ...options });
9
+ }
10
+
11
+ function commandExists(cmd) {
8
12
  try {
9
13
  execSync(`command -v ${cmd}`, { stdio: "ignore" });
10
14
  return true;
@@ -13,78 +17,50 @@ function exists(cmd) {
13
17
  }
14
18
  }
15
19
 
16
- function installNode() {
17
- console.log("πŸ“¦ Instalando Node.js y npm...\n");
18
- execSync("sudo apt update", { stdio: "inherit" });
19
- execSync("sudo apt install -y nodejs npm", { stdio: "inherit" });
20
- }
21
-
22
- function latestVersion() {
23
- try {
24
- return execSync(`npm view ${pkg.name} version`, {
25
- stdio: ["ignore", "pipe", "ignore"],
26
- })
27
- .toString()
28
- .trim();
29
- } catch {
30
- return null;
20
+ function ensureNode() {
21
+ if (!commandExists("node") || !commandExists("npm")) {
22
+ console.log("πŸ“¦ Node.js y npm no detectados. Instalando...");
23
+ run(
24
+ "curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash",
25
+ );
26
+ run(
27
+ 'export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"',
28
+ );
29
+ run("nvm install --lts && nvm use --lts");
30
+ run("npm install -g pnpm yarn");
31
+ } else {
32
+ console.log("βœ” Node.js y npm OK");
31
33
  }
32
34
  }
33
35
 
34
- function updateIfNeeded() {
35
- const current = pkg.version;
36
- const latest = latestVersion();
37
- if (!latest) return;
38
-
39
- if (current !== latest) {
40
- console.log(`⬆ Nueva versiΓ³n disponible ${latest} (actual ${current})`);
41
- console.log("Actualizando kapelu...\n");
42
- execSync(`npm install -g ${pkg.name}`, { stdio: "inherit" });
36
+ function updateKapelu() {
37
+ const latest = execSync(`npm view ${pkg.name} version`, {
38
+ stdio: ["ignore", "pipe", "ignore"],
39
+ })
40
+ .toString()
41
+ .trim();
42
+ if (pkg.version !== latest) {
43
+ console.log(`⬆ Nueva versiΓ³n disponible: ${latest}. Actualizando...`);
44
+ run(`npm install -g ${pkg.name}`);
43
45
  process.exit(0);
44
46
  }
45
47
  }
46
48
 
47
- function autoUpdateGitHub() {
48
- // Si el script existe, hacer pull del repo para tener versiΓ³n mΓ‘s reciente
49
- try {
50
- execSync(
51
- `if [ -d "/tmp/script-setup" ]; then cd /tmp/script-setup && git pull --rebase; fi`,
52
- { stdio: "inherit", shell: "/bin/bash" },
53
- );
54
- } catch {}
55
- }
56
-
57
49
  try {
58
- console.log("πŸ”Ž Verificando Node.js y npm...");
59
- if (!exists("node") || !exists("npm")) installNode();
60
- console.log("βœ” Node.js y npm OK\n");
61
-
62
- console.log("πŸ”Ž Verificando actualizaciones en npm...");
63
- updateIfNeeded();
50
+ console.log("πŸ”Ž Verificando Node/npm...");
51
+ ensureNode();
64
52
 
65
- console.log("πŸ”Ž Actualizando desde GitHub si existe repo local...");
66
- autoUpdateGitHub();
53
+ console.log("πŸ”Ž Verificando actualizaciones...");
54
+ updateKapelu();
67
55
 
68
- console.log("πŸš€ Ejecutando install.sh\n");
69
- execSync(`bash ${__dirname}/install.sh`, { stdio: "inherit" });
56
+ console.log("πŸš€ Ejecutando instalador completo...");
57
+ run(`bash ${__dirname}/install.sh`);
70
58
  } catch (err) {
71
59
  console.clear();
72
-
73
- console.error("\n❌ Error ejecutando Post-Install\n");
74
-
75
- if (err.status) {
76
- console.error("CΓ³digo de salida:", err.status);
77
- }
78
-
79
- if (err.cmd) {
80
- console.error("Comando:", err.cmd);
81
- }
82
-
83
- if (err.stderr) {
84
- console.error(err.stderr.toString());
85
- }
86
-
60
+ console.error("\n❌ Error ejecutando setup-kapelu\n");
61
+ if (err.status) console.error("CΓ³digo de salida:", err.status);
62
+ if (err.cmd) console.error("Comando:", err.cmd);
63
+ if (err.stderr) console.error(err.stderr.toString());
87
64
  console.error(err.message);
88
-
89
65
  process.exit(1);
90
- }
66
+ }
package/install.sh CHANGED
@@ -1,112 +1,107 @@
1
1
  #!/usr/bin/env bash
2
2
  # ╔════════════════════════════════════════════════════╗
3
- # β”‚ setup-kapelu installer completo Ubuntu β”‚
3
+ # β”‚ Install - Script Post-Install Todo en Uno β”‚
4
+ # β”‚ VersiΓ³n: 3.2.9 β”‚
4
5
  # β”‚ Autor: Daniel Calderon - Kapelu β”‚
5
- # β”‚ Fecha: 14/03/2026 β”‚
6
+ # β”‚ Fecha: 04/03/2026 β”‚
7
+ # β”‚ WebSite: https://danielcalderon.vercel.app/ β”‚
8
+ # β”‚ Github: https://github.com/Kapelu β”‚
6
9
  # β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
7
10
 
8
11
  set -Eeuo pipefail
9
12
  IFS=$'\n\t'
10
13
 
11
- GREEN='\e[32m'
12
- RESET='\e[0m'
13
-
14
14
  USER_NAME=$(whoami)
15
- HOME_DIR="$HOME"
15
+ HOME_DIR=$HOME
16
16
  DESKTOP_DIR=$(xdg-user-dir DESKTOP)
17
17
  TMP_DIR="/tmp/kape-setup-$RANDOM"
18
18
  REPO="https://github.com/Kapelu/kape-setup.git"
19
+ LOG="$HOME/setup-kapelu.log"
20
+ green='\e[32m'
21
+ reset='\e[0m'
19
22
 
20
- log() { echo -e "${GREEN}βœ… $1${RESET}"; }
23
+ log() {
24
+ echo -e "${green}βœ… $1${reset}"
25
+ echo "$1" >> "$LOG"
26
+ }
21
27
 
22
- # 1️⃣ Detectar distro
28
+ # Detectar distro soportada
23
29
  detect_distro() {
24
- if [[ -f /etc/os-release ]]; then
25
- . /etc/os-release
26
- else
27
- echo "❌ No se puede detectar la distro"
28
- exit 1
29
- fi
30
- case "$ID" in
31
- ubuntu|debian|linuxmint|pop)
32
- log "DistribuciΓ³n soportada: $ID"
33
- ;;
34
- *)
35
- echo "❌ Distro no soportada: $ID"
36
- exit 1
37
- ;;
38
- esac
30
+ if [ ! -f /etc/os-release ]; then
31
+ log "Sistema no soportado"
32
+ exit 1
33
+ fi
34
+
35
+ source /etc/os-release
36
+ case "$ID" in
37
+ ubuntu|debian|linuxmint|pop)
38
+ log "DistribuciΓ³n detectada: $ID"
39
+ ;;
40
+ *)
41
+ log "DistribuciΓ³n no soportada: $ID"
42
+ exit 1
43
+ ;;
44
+ esac
39
45
  }
40
46
 
41
- # 2️⃣ Actualizar sistema
42
- system_update() {
43
- log "Actualizando sistema..."
44
- sudo apt update -y
45
- sudo apt upgrade -y
46
- sudo apt install -y curl git build-essential xdg-utils
47
+ # Instalar git si no existe
48
+ check_git() {
49
+ if ! command -v git >/dev/null; then
50
+ log "Instalando git"
51
+ sudo apt update
52
+ sudo apt install -y git
53
+ fi
47
54
  }
48
55
 
49
- # 3️⃣ Instalar NVM + Node LTS
50
- install_node() {
51
- log "Instalando NVM..."
52
- export NVM_DIR="$HOME/.nvm"
53
- if [ ! -d "$NVM_DIR" ]; then
54
- curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
55
- fi
56
- [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
57
- [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
58
-
59
- log "Instalando Node LTS..."
60
- nvm install --lts
61
- nvm use --lts
62
- nvm alias default 'lts/*'
63
-
64
- log "Node $(node -v) y npm $(npm -v) listos"
56
+ # Dar permisos a scripts con shebang
57
+ permits() {
58
+ while IFS= read -r -d '' file; do
59
+ if head -n1 "$file" | grep -q "^#!"; then
60
+ chmod +x "$file"
61
+ fi
62
+ done < <(find . -type f -print0)
65
63
  }
66
64
 
67
- # 4️⃣ Instalar setup-kapelu globalmente
68
- install_kapelu() {
69
- log "Instalando setup-kapelu globalmente..."
70
- npm install -g setup-kapelu
71
- if command -v kapelu >/dev/null 2>&1; then
72
- log "setup-kapelu instalado correctamente"
73
- else
74
- echo "❌ Error instalando setup-kapelu"
75
- exit 1
76
- fi
65
+ backup_bashrc() {
66
+ if [ -f "$HOME_DIR/.bashrc" ]; then
67
+ cp "$HOME_DIR/.bashrc" "$HOME_DIR/.bashrc.backup.$(date +%s)"
68
+ log "Backup de .bashrc creado"
69
+ fi
77
70
  }
78
71
 
79
- # 5️⃣ Clonar repositorio temporal
72
+ # Clonar repo temporal
80
73
  clone_repo() {
81
- log "Clonando repositorio..."
82
- git clone -b main "$REPO" "$TMP_DIR"
74
+ log "Clonando repositorio"
75
+ git clone -b main "$REPO" "$TMP_DIR"
83
76
  }
84
77
 
85
- # 6️⃣ Copiar scripts y dar permisos
78
+ # Copiar scripts al home
86
79
  copy_scripts() {
87
- mkdir -p "$HOME_DIR/script"
88
- cp -r "$TMP_DIR/script/." "$HOME_DIR/script/"
89
- find "$HOME_DIR/script" -type f -exec chmod +x {} \;
80
+ mkdir -p "$HOME_DIR/script"
81
+ cp -r "$TMP_DIR/script/." "$HOME_DIR/script/"
82
+ find "$HOME_DIR/script" -type f -name "*.sh" -exec chmod +x {} \;
90
83
  }
91
84
 
92
- # 7️⃣ Copiar configuraciΓ³n
85
+ # Copiar configs
93
86
  copy_config() {
94
- cp "$TMP_DIR/config/.bashrc" "$HOME_DIR/.bashrc"
95
- cp "$TMP_DIR/config/protect-main.json" "$HOME_DIR/"
87
+ cp "$TMP_DIR/config/.bashrc" "$HOME_DIR/.bashrc"
88
+ cp "$TMP_DIR/config/protect-main.json" "$HOME_DIR/"
96
89
  }
97
90
 
98
- # 8️⃣ Crear accesos directos en escritorio
91
+ # Crear accesos directos en el escritorio
99
92
  create_desktop() {
100
- mkdir -p "$DESKTOP_DIR"
101
- DATA=(
102
- "log|Logout|Cierra sesiΓ³n en 10 segundos|system-log-out"
103
- "shd|Apagar|Apaga la PC en 10 segundos|system-shutdown"
104
- "sus|Suspender|Suspende la PC en 10 segundos|system-suspend"
105
- )
106
- for row in "${DATA[@]}"; do
107
- IFS="|" read -r id name comment icon <<< "$row"
108
- file="$DESKTOP_DIR/btn_${id}.desktop"
109
- cat <<EOF > "$file"
93
+ mkdir -p "$DESKTOP_DIR"
94
+
95
+ DATA=(
96
+ "log|Logout|Cierra sesiΓ³n en 10 segundos|system-log-out"
97
+ "shd|Apagar|Apaga la PC en 10 segundos|system-shutdown"
98
+ "sus|Suspender|Suspende la PC en 10 segundos|system-suspend"
99
+ )
100
+
101
+ for row in "${DATA[@]}"; do
102
+ IFS="|" read -r id name comment icon <<< "$row"
103
+ file="$DESKTOP_DIR/btn_${id}.desktop"
104
+ cat <<EOF > "$file"
110
105
  [Desktop Entry]
111
106
  Name=$name
112
107
  Comment=$comment
@@ -116,41 +111,54 @@ Terminal=false
116
111
  Type=Application
117
112
  Categories=Utility;
118
113
  EOF
119
- chmod +x "$file"
120
- gio set "$file" metadata::trusted true
121
- done
122
- killall -q nautilus 2>/dev/null || true
114
+ chmod +x "$file"
115
+ gio set "$file" metadata::trusted true
116
+ done
117
+
118
+ killall -q nautilus 2>/dev/null
123
119
  }
124
120
 
125
- # 9️⃣ Ejecutar setup.sh
121
+ system_update() { sudo apt update -y; sudo apt upgrade -y; sudo apt full-upgrade -y; }
122
+ system_cleanup() { sudo apt autoremove -y; sudo apt clean; }
123
+
124
+ # Ejecutar setup.sh final
126
125
  run_setup() {
127
- FILE="$HOME_DIR/script/setup.sh"
128
- if [ ! -f "$FILE" ]; then
129
- echo "❌ setup.sh no encontrado"
130
- return 1
131
- fi
132
- chmod +x "$FILE"
133
- "$FILE"
126
+ printf "${green}πŸ“¦ ΒΏDesea ejecutar setup.sh? (s/n): ${reset}"
127
+ read RESP
128
+
129
+ if [ "$RESP" = "s" ]; then
130
+ FILE="$HOME_DIR/script/setup.sh"
131
+
132
+ if [ ! -f "$FILE" ]; then
133
+ echo "❌ Error: setup.sh no encontrado en $HOME_DIR/script/"
134
+ return 1
135
+ fi
136
+
137
+ if [ ! -x "$FILE" ]; then
138
+ chmod +x "$FILE"
139
+ fi
140
+
141
+ "$FILE"
142
+ else
143
+ system_update
144
+ system_cleanup
145
+ fi
134
146
  }
135
147
 
136
- # πŸ”Ÿ Limpieza
137
- cleanup() {
138
- rm -rf "$TMP_DIR"
139
- }
148
+ cleanup() { rm -rf "$TMP_DIR"; }
140
149
 
141
- # ────────────── Main ──────────────
142
150
  main() {
143
- detect_distro
144
- system_update
145
- install_node
146
- install_kapelu
147
- clone_repo
148
- copy_scripts
149
- copy_config
150
- create_desktop
151
- run_setup
152
- cleanup
153
- log "πŸŽ‰ Secuencia Post-Install completada con Γ©xito"
151
+ log "Iniciando Secuencia Post-Install setup-kapelu"
152
+
153
+ detect_distro
154
+ check_git
155
+ clone_repo
156
+ copy_scripts
157
+ backup_bashrc
158
+ copy_config
159
+ create_desktop
160
+ run_setup
161
+ cleanup
154
162
  }
155
163
 
156
164
  main
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "setup-kapelu",
3
- "version": "3.2.10",
3
+ "version": "3.2.11",
4
4
  "description": "Script post-install de Ubuntu",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -33,5 +33,8 @@
33
33
  "bugs": {
34
34
  "url": "https://github.com/Kapelu/kape-setup/issues"
35
35
  },
36
- "homepage": "https://github.com/Kapelu/kape-setup#readme"
36
+ "homepage": "https://github.com/Kapelu/kape-setup#readme",
37
+ "engines": {
38
+ "node": ">=18"
39
+ }
37
40
  }