setup-kapelu 3.2.9 β†’ 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 +104 -126
  3. package/package.json +17 -9
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,12 +1,13 @@
1
1
  #!/usr/bin/env bash
2
2
  # ╔════════════════════════════════════════════════════╗
3
- # β”‚ Install - Script para comenzar la instalaciΓ³n. β”‚
4
- # β”‚ VersiΓ³n: 2.0 β”‚
3
+ # β”‚ Install - Script Post-Install Todo en Uno β”‚
4
+ # β”‚ VersiΓ³n: 3.2.9 β”‚
5
5
  # β”‚ Autor: Daniel Calderon - Kapelu β”‚
6
- # β”‚ Fecha: 06/03/2026 β”‚
6
+ # β”‚ Fecha: 04/03/2026 β”‚
7
7
  # β”‚ WebSite: https://danielcalderon.vercel.app/ β”‚
8
8
  # β”‚ Github: https://github.com/Kapelu β”‚
9
9
  # β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
10
+
10
11
  set -Eeuo pipefail
11
12
  IFS=$'\n\t'
12
13
 
@@ -15,103 +16,92 @@ HOME_DIR=$HOME
15
16
  DESKTOP_DIR=$(xdg-user-dir DESKTOP)
16
17
  TMP_DIR="/tmp/kape-setup-$RANDOM"
17
18
  REPO="https://github.com/Kapelu/kape-setup.git"
19
+ LOG="$HOME/setup-kapelu.log"
18
20
  green='\e[32m'
19
21
  reset='\e[0m'
20
- LOG="$HOME/setup-kapelu.log"
21
22
 
22
23
  log() {
23
- echo -e "\033[0;32mβœ… $1\033[0m"
24
+ echo -e "${green}βœ… $1${reset}"
24
25
  echo "$1" >> "$LOG"
25
26
  }
26
27
 
27
- detect_distro(){
28
-
29
- if [ ! -f /etc/os-release ]; then
30
- log "Sistema no soportado"
31
- exit 1
32
- fi
33
-
34
- source /etc/os-release
35
-
36
- case "$ID" in
37
- ubuntu|debian|linuxmint|pop)
38
- log "DistribuciΓ³n detectada: $ID"
39
- ;;
40
- *)
41
- log "DistribuciΓ³n no soportada"
42
- exit 1
43
- esac
28
+ # Detectar distro soportada
29
+ detect_distro() {
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
44
45
  }
45
46
 
46
- check_git(){
47
-
48
- if ! command -v git >/dev/null; then
49
- log "Instalando git"
50
- sudo apt update
51
- sudo apt install -y git
52
- fi
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
53
54
  }
54
55
 
55
- permits(){
56
- while IFS= read -r -d '' file
57
- do
58
- if head -n1 "$file" | grep -q "^#!"
59
- then
60
- chmod +x "$file"
61
- fi
62
- done < <(find . -type f -print0)
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)
63
63
  }
64
64
 
65
- backup_bashrc(){
66
-
67
- if [ -f "$HOME_DIR/.bashrc" ]; then
68
- cp "$HOME_DIR/.bashrc" "$HOME_DIR/.bashrc.backup.$(date +%s)"
69
- log "Backup de .bashrc creado"
70
- 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
71
70
  }
72
71
 
73
- clone_repo(){
74
-
75
- log "Clonando repositorio"
76
-
77
- git clone -b main "$REPO" "$TMP_DIR"
72
+ # Clonar repo temporal
73
+ clone_repo() {
74
+ log "Clonando repositorio"
75
+ git clone -b main "$REPO" "$TMP_DIR"
78
76
  }
79
77
 
80
- copy_scripts(){
81
-
82
- mkdir -p "$HOME_DIR/script"
83
-
84
- cp -r "$TMP_DIR/script/." "$HOME_DIR/script/"
85
-
86
- find "$HOME_DIR/script" -type f -name "*.sh" -exec chmod +x {} \;
87
-
78
+ # Copiar scripts al home
79
+ copy_scripts() {
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 {} \;
88
83
  }
89
84
 
90
- copy_config(){
91
-
92
- cp "$TMP_DIR/config/.bashrc" "$HOME_DIR/.bashrc"
93
-
94
- cp "$TMP_DIR/config/protect-main.json" "$HOME_DIR/"
85
+ # Copiar configs
86
+ copy_config() {
87
+ cp "$TMP_DIR/config/.bashrc" "$HOME_DIR/.bashrc"
88
+ cp "$TMP_DIR/config/protect-main.json" "$HOME_DIR/"
95
89
  }
96
90
 
97
- create_desktop(){
98
-
99
- mkdir -p "$DESKTOP_DIR"
91
+ # Crear accesos directos en el escritorio
92
+ create_desktop() {
93
+ mkdir -p "$DESKTOP_DIR"
100
94
 
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
- )
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
+ )
106
100
 
107
- for row in "${DATA[@]}"
108
- do
109
-
110
- IFS="|" read -r id name comment icon <<< "$row"
111
-
112
- file="$DESKTOP_DIR/btn_${id}.desktop"
113
-
114
- cat <<EOF > "$file"
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"
115
105
  [Desktop Entry]
116
106
  Name=$name
117
107
  Comment=$comment
@@ -121,66 +111,54 @@ Terminal=false
121
111
  Type=Application
122
112
  Categories=Utility;
123
113
  EOF
114
+ chmod +x "$file"
115
+ gio set "$file" metadata::trusted true
116
+ done
124
117
 
125
- chmod +x "$file"
126
- gio set "$file" metadata::trusted true
127
-
128
- done
129
-
130
- killall -q nautilus 2>/dev/null
131
- }
132
-
133
-
134
- system_update(){ sudo apt update -y; sudo apt upgrade -y; sudo apt full-upgrade -y; }
135
-
136
- system_cleanup(){
137
-
138
- sudo apt autoremove -y
139
- sudo apt clean
118
+ killall -q nautilus 2>/dev/null
140
119
  }
141
120
 
142
- cleanup(){ rm -rf "$TMP_DIR"; }
143
-
144
- run_setup(){
145
-
146
- printf "${green}πŸ“¦ ΒΏDesea ejecutar setup.sh? (s/n): ${reset}"
147
- read RESP
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; }
148
123
 
149
- if [ "$RESP" = "s" ]; then
124
+ # Ejecutar setup.sh final
125
+ run_setup() {
126
+ printf "${green}πŸ“¦ ΒΏDesea ejecutar setup.sh? (s/n): ${reset}"
127
+ read RESP
150
128
 
151
- FILE="$HOME_DIR/script/setup.sh"
129
+ if [ "$RESP" = "s" ]; then
130
+ FILE="$HOME_DIR/script/setup.sh"
152
131
 
153
- if [ ! -f "$FILE" ]; then
154
- echo "❌ Error: setup.sh no encontrado en $HOME_DIR/script/"
155
- return 1
156
- fi
132
+ if [ ! -f "$FILE" ]; then
133
+ echo "❌ Error: setup.sh no encontrado en $HOME_DIR/script/"
134
+ return 1
135
+ fi
157
136
 
158
- if [ ! -x "$FILE" ]; then
159
- chmod +x "$FILE"
160
- fi
161
-
162
- "$FILE"
163
-
164
- else
165
- system_update
166
- system_cleanup
167
- fi
137
+ if [ ! -x "$FILE" ]; then
138
+ chmod +x "$FILE"
139
+ fi
168
140
 
141
+ "$FILE"
142
+ else
143
+ system_update
144
+ system_cleanup
145
+ fi
169
146
  }
170
147
 
171
- main(){
148
+ cleanup() { rm -rf "$TMP_DIR"; }
172
149
 
173
- log "Iniciando Secuencia Post-Install setup-kape"
174
-
175
- detect_distro
176
- check_git
177
- clone_repo
178
- copy_scripts
179
- backup_bashrc
180
- copy_config
181
- create_desktop
182
- run_setup
183
- cleanup
150
+ main() {
151
+ log "Iniciando Secuencia Post-Install setup-kapelu"
184
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
185
162
  }
163
+
186
164
  main
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "setup-kapelu",
3
- "version": "3.2.9",
3
+ "version": "3.2.11",
4
4
  "description": "Script post-install de Ubuntu",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -10,12 +10,23 @@
10
10
  "type": "git",
11
11
  "url": "git+https://github.com/Kapelu/kape-setup.git"
12
12
  },
13
+ "files": [
14
+ "cli.js",
15
+ "install.sh",
16
+ "script/",
17
+ "config/"
18
+ ],
13
19
  "keywords": [
14
20
  "ubuntu",
15
21
  "setup",
16
22
  "post-install",
17
- "cli",
18
- "script"
23
+ "vscode",
24
+ "node",
25
+ "sublime-text",
26
+ "script",
27
+ "script-install",
28
+ "snap",
29
+ "tool"
19
30
  ],
20
31
  "author": "Daniel Calderon",
21
32
  "license": "ISC",
@@ -23,10 +34,7 @@
23
34
  "url": "https://github.com/Kapelu/kape-setup/issues"
24
35
  },
25
36
  "homepage": "https://github.com/Kapelu/kape-setup#readme",
26
- "files": [
27
- "cli.js",
28
- "install.sh",
29
- "script/",
30
- "config/"
31
- ]
37
+ "engines": {
38
+ "node": ">=18"
39
+ }
32
40
  }