setup-kapelu 3.0.0
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 +120 -0
- package/config/.bashrc +148 -0
- package/config/protect-main.json +47 -0
- package/index.js +78 -0
- package/install.sh +164 -0
- package/package.json +33 -0
- package/script/btn-log.sh +98 -0
- package/script/btn-shd.sh +170 -0
- package/script/btn-sus.sh +176 -0
- package/script/node-clean.sh +326 -0
- package/script/setup.sh +463 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ⠀
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1 style='margin: 0 0 2rem; font-size: 2.5rem;'>Post-Install</h1 >
|
|
3
|
+
</div>
|
|
4
|
+
<div align="center">
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<div align="center">
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Descripción general
|
|
17
|
+
|
|
18
|
+
`script-setup` es una colección de utilidades de terminal ***post-install*** orientadas al rendimiento, diseñadas para mejorar la productividad de los desarrolladores en sistemas Ubuntu. El proyecto prioriza la baja sobrecarga, la arquitectura modular de Bash y un comportamiento de ejecución predecible.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<div align="center">
|
|
24
|
+
|
|
25
|
+
## 📦 Modulos
|
|
26
|
+
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
### ***🧹 node-clean***
|
|
30
|
+
|
|
31
|
+
Herramienta CLI interactiva para localizar y eliminar `node_modules` y `.next` dentro de un árbol de directorios. Se pueden agregar más carpetas o archivos.
|
|
32
|
+
|
|
33
|
+
simplemente modificar la variable
|
|
34
|
+
```bash
|
|
35
|
+
TARGETS=("node_modules" ".next")()
|
|
36
|
+
```
|
|
37
|
+
### <u>Características:</u>
|
|
38
|
+
- Interfaz TUI basada en `dialog`
|
|
39
|
+
- Cálculo previo de espacio a liberar
|
|
40
|
+
- Borrado total o selectivo
|
|
41
|
+
- Soporte modo `--dry-run`
|
|
42
|
+
- Restauración segura del estado de la terminal
|
|
43
|
+
|
|
44
|
+
### <u>Uso</u>:
|
|
45
|
+
```bash
|
|
46
|
+
node-clean [--dry-run]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
------------------------------------------------------------------------
|
|
50
|
+
### ***⚙️ Motor de prompts de Bash optimizado (.bashrc)***
|
|
51
|
+
|
|
52
|
+
El archivo implementa un prompt dinámico optimizado con cacheo inteligente, orientado a entornos de desarrollo Node/Next.js.
|
|
53
|
+
|
|
54
|
+
### <u>Características:</u>
|
|
55
|
+
|
|
56
|
+
- Crea una carpeta llamada script donde se instalaran los script personalizables y ejecutables
|
|
57
|
+
- Cache global
|
|
58
|
+
- Busqueda de `package.json`
|
|
59
|
+
- Detección inteligente del `package manager`
|
|
60
|
+
- Detección inteligente de `git status`
|
|
61
|
+
|
|
62
|
+
🟢 → repo limpio
|
|
63
|
+
🟡 → cambios sin commit
|
|
64
|
+
🔴 → conflictos
|
|
65
|
+
🔵 → detached HEAD
|
|
66
|
+
- Prompt contextual con heurística de proyecto
|
|
67
|
+
|
|
68
|
+
</br>
|
|
69
|
+
<div align="center">
|
|
70
|
+
<p style='margin: 0 0 2rem; font-size: 1.5rem;'>📈 Comparación con <strong>.bashrc</strong> estándar de Ubuntu vs Prompt v2.0</p >
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<div align="center">
|
|
74
|
+
|
|
75
|
+
| Característica |Ubuntu default|Versión 3.0|
|
|
76
|
+
|----------------------------|--------------|-----------|
|
|
77
|
+
| Prompt dinámico | ❌ | ✔️ |
|
|
78
|
+
| Rama Git | ❌ | ✔️ |
|
|
79
|
+
| Detectar Node project | ❌ | ✔️ |
|
|
80
|
+
| Detectar package manager | ❌ | ✔️ |
|
|
81
|
+
| Cache de estado | ❌ | ✔️ |
|
|
82
|
+
| Optimización por PWD | ❌ | ✔️ |
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
#### Está más cerca de un mini framework de prompt que de un `.bashrc` común‼️
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
------------------------------------------------------------------------
|
|
89
|
+
|
|
90
|
+
### ***🛡️ protect-main.json***
|
|
91
|
+
|
|
92
|
+
Es un archivo `.json` que protege el main branch de un repositorio git, evitando pushes accidentales de terceroas.
|
|
93
|
+
|
|
94
|
+
### <u>Características:</u>
|
|
95
|
+
|
|
96
|
+
- `Estado de ejecución` Activo
|
|
97
|
+
- `Lista de omisión` Repository admin
|
|
98
|
+
- `Criterio de selección de rama` Default
|
|
99
|
+
- `Restrict updates` Permitir que solo los usuarios con permisos de omisión actualicen las referencias coincidentes.
|
|
100
|
+
- `Restrict deletions` Permitir que solo los usuarios con permisos de omisión eliminen referencias coincidentes.
|
|
101
|
+
- `Require linear history` Evita que las confirmaciones de fusión se envíen a referencias coincidentes.
|
|
102
|
+
- `Require a pull request before merging` Requerir que todas las confirmaciones se realicen en una rama distinta a la de destino y se envíen mediante una solicitud de extracción antes de que se puedan fusionar.
|
|
103
|
+
- `Require conversation resolution before merging` Todas las conversaciones sobre el código deben resolverse antes de que se pueda fusionar una solicitud de extracción.
|
|
104
|
+
- `Block force pushes` Evita que los usuarios con acceso de envío fuercen el envío a los árbitros.
|
|
105
|
+
|
|
106
|
+
### <u>Uso</u>:
|
|
107
|
+
|
|
108
|
+
Luego en el repositorio de `github` ir a `Settings` → `Branches` → `Add rule` → `Import` → `Upload JSON` y agregar → ***protect-main.json*** .
|
|
109
|
+
|
|
110
|
+
------------------------------------------------------------------------
|
|
111
|
+
|
|
112
|
+
------------------------------------------------------------------------
|
|
113
|
+
|
|
114
|
+
### ***🤝 Contribuciones***
|
|
115
|
+
|
|
116
|
+
Se agradecen las contribuciones.
|
|
117
|
+
|
|
118
|
+
Para cambios importantes:
|
|
119
|
+
- Abrir issue first
|
|
120
|
+
- Debatimos el impacto en la arquitectura
|
package/config/.bashrc
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ╔════════════════════════════════════════════════════╗
|
|
3
|
+
# │ cerrar-sesion - Script para cerrar la sesión │
|
|
4
|
+
# │ Versión: 2.0 │
|
|
5
|
+
# │ Autor: Daniel Calderon - Kapelu │
|
|
6
|
+
# │ Fecha: 04/03/2026 │
|
|
7
|
+
# │ WebSite: https://danielcalderon.vercel.app/ │
|
|
8
|
+
# │ Github: https://github.com/Kapelu │
|
|
9
|
+
# ╚════════════════════════════════════════════════════╝
|
|
10
|
+
# Alias
|
|
11
|
+
# =============================================================================
|
|
12
|
+
alias ls='lsd'
|
|
13
|
+
|
|
14
|
+
# Variables para cachear info de PWD, gestor y git branch
|
|
15
|
+
# =============================================================================
|
|
16
|
+
__LAST_PWD=""
|
|
17
|
+
__PKG_MANAGER=""
|
|
18
|
+
__GIT_BRANCH=""
|
|
19
|
+
# Definir carpeta única
|
|
20
|
+
#-----------------------------------------
|
|
21
|
+
SCRIPT_DIR="$HOME/script"
|
|
22
|
+
|
|
23
|
+
# Crear si no existe
|
|
24
|
+
#-----------------------------------------
|
|
25
|
+
[ -d "$SCRIPT_DIR" ] || mkdir -p "$SCRIPT_DIR"
|
|
26
|
+
|
|
27
|
+
# Añadir al PATH solo si no está ya
|
|
28
|
+
#-----------------------------------------
|
|
29
|
+
case ":$PATH:" in
|
|
30
|
+
*":$SCRIPT_DIR:"*) ;;
|
|
31
|
+
*) export PATH="$PATH:$SCRIPT_DIR" ;;
|
|
32
|
+
esac
|
|
33
|
+
|
|
34
|
+
# Hacer ejecutables los existentes en script
|
|
35
|
+
#-----------------------------------------
|
|
36
|
+
find "$SCRIPT_DIR" -type f -exec chmod +x {} \;
|
|
37
|
+
|
|
38
|
+
# Vigilar nuevos archivos para hacerlos ejecutables automáticamente
|
|
39
|
+
# =============================================================================
|
|
40
|
+
if command -v inotifywait >/dev/null 2>&1 && [ -z "$__SCRIPTS_WATCH_STARTED" ]; then
|
|
41
|
+
export __SCRIPTS_WATCH_STARTED=1
|
|
42
|
+
inotifywait -m -e create --format '%f' "$SCRIPT_DIR" 2>/dev/null |
|
|
43
|
+
while IFS= read -r file; do
|
|
44
|
+
chmod +x "$SCRIPT_DIR/$file"
|
|
45
|
+
done &
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# Función que busca recursivamente hacia arriba desde el directorio actual
|
|
49
|
+
# =============================================================================
|
|
50
|
+
find_package_json_upwards() {
|
|
51
|
+
local dir="$PWD"
|
|
52
|
+
while [ "$dir" != "/" ]; do
|
|
53
|
+
[ -f "$dir/package.json" ] && { echo "$dir/package.json"; return; }
|
|
54
|
+
dir=$(dirname "$dir")
|
|
55
|
+
done
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# Función que detecta el gestor de paquetes basado en package.json o archivos lock
|
|
59
|
+
# =============================================================================
|
|
60
|
+
detect_package_manager() {
|
|
61
|
+
local pkg_json manager dir="$PWD"
|
|
62
|
+
|
|
63
|
+
pkg_json=$(find_package_json_upwards)
|
|
64
|
+
if [ -n "$pkg_json" ]; then
|
|
65
|
+
manager=$(grep '"packageManager"' "$pkg_json" 2>/dev/null | sed -E 's/.*"([^"]+)".*/\1/' | cut -d@ -f1)
|
|
66
|
+
[ -n "$manager" ] && { echo "$manager"; return; }
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
while [ "$dir" != "/" ]; do
|
|
70
|
+
[ -f "$dir/pnpm-lock.yaml" ] && { echo "pnpm"; return; }
|
|
71
|
+
[ -f "$dir/yarn.lock" ] && { echo "yarn"; return; }
|
|
72
|
+
[ -f "$dir/package-lock.json" ] && { echo "npm"; return; }
|
|
73
|
+
dir=$(dirname "$dir")
|
|
74
|
+
done
|
|
75
|
+
|
|
76
|
+
echo "npm"
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# Función que instala pnpm globalmente si detecta un pnpm-lock.yaml pero no encuentra pnpm en el PATH
|
|
80
|
+
# =============================================================================
|
|
81
|
+
ensure_pnpm() {
|
|
82
|
+
[ ! -x "$(command -v pnpm)" ] && [ -f pnpm-lock.yaml ] && {
|
|
83
|
+
echo "📦 pnpm no está instalado. Instalando globalmente..."
|
|
84
|
+
npm install -g pnpm
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
# Estas funciones detectan el gestor de paquetes basado en el contexto del proyecto
|
|
89
|
+
# y ejecutan el comando correspondiente, asegurando pnpm si es necesario.
|
|
90
|
+
# =============================================================================
|
|
91
|
+
runpkg() { local gestor ; gestor=$(detect_package_manager); ensure_pnpm; command "$gestor" "$@"; }
|
|
92
|
+
npm() { local gestor; gestor=$(detect_package_manager); ensure_pnpm; command "$gestor" "$@"; }
|
|
93
|
+
pnpm() { local gestor; gestor=$(detect_package_manager); ensure_pnpm; command "$gestor" "$@"; }
|
|
94
|
+
|
|
95
|
+
# Función que obtiene el estado del repositorio git y lo muestra con colores en el prompt
|
|
96
|
+
# =============================================================================
|
|
97
|
+
git_prompt_status() {
|
|
98
|
+
git rev-parse --is-inside-work-tree &>/dev/null || return
|
|
99
|
+
|
|
100
|
+
local branch
|
|
101
|
+
branch=$(git symbolic-ref --short HEAD 2>/dev/null)
|
|
102
|
+
|
|
103
|
+
# 🔵 Detached HEAD
|
|
104
|
+
#-----------------------------------------
|
|
105
|
+
[ -z "$branch" ] && branch=$(git rev-parse --short HEAD 2>/dev/null) && \
|
|
106
|
+
{ printf "\033[38;5;39m[%s]\033[0m" "$branch"; return; }
|
|
107
|
+
|
|
108
|
+
# 🔴 Conflictos
|
|
109
|
+
#-----------------------------------------
|
|
110
|
+
git ls-files -u | grep -q . && { printf "\033[38;5;196m[%s]\033[0m" "$branch"; return; }
|
|
111
|
+
|
|
112
|
+
# 🟡 Cambios sin commit
|
|
113
|
+
#-----------------------------------------
|
|
114
|
+
(! git diff --quiet || ! git diff --cached --quiet) && { printf "\033[38;5;220m[%s]\033[0m" "$branch"; return; }
|
|
115
|
+
|
|
116
|
+
# 🟢 Repo limpio
|
|
117
|
+
#-----------------------------------------
|
|
118
|
+
printf "\033[38;5;82m[%s]\033[0m" "$branch"
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
# Función que actualiza el cache solo si cambia pwd o
|
|
122
|
+
# git branch, para mejorar rendimiento del prompt
|
|
123
|
+
# =============================================================================
|
|
124
|
+
update_prompt_cache() {
|
|
125
|
+
[ "$PWD" != "$__LAST_PWD" ] && {
|
|
126
|
+
__LAST_PWD="$PWD"
|
|
127
|
+
local manager
|
|
128
|
+
manager=$(detect_package_manager)
|
|
129
|
+
__PKG_MANAGER=$([ -n "$manager" ] && echo "[$manager]" || echo "")
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
__GIT_BRANCH="$(git_prompt_status)"
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
PROMPT_COMMAND=update_prompt_cache
|
|
136
|
+
|
|
137
|
+
# Diseño del prompt que muestra el gestor de paquetes, el branch de git
|
|
138
|
+
# y el directorio actual, con colores.
|
|
139
|
+
# =============================================================================
|
|
140
|
+
PS1=' \[\033[01;32m\]\h:\[\033[01;34m\]${__PKG_MANAGER}${__GIT_BRANCH} \[\033[00m\]\w \[\033[01;34m\]\$ \[\033[00m\]'
|
|
141
|
+
|
|
142
|
+
# NVM_DIR="$HOME/.nvm"
|
|
143
|
+
# =============================================================================
|
|
144
|
+
export NVM_DIR="$HOME/.nvm"
|
|
145
|
+
# shellcheck source=/dev/null
|
|
146
|
+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
147
|
+
# shellcheck source=/dev/null
|
|
148
|
+
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": 13362554,
|
|
3
|
+
"name": "protect-main",
|
|
4
|
+
"target": "branch",
|
|
5
|
+
"source_type": "Repository",
|
|
6
|
+
"source": "",
|
|
7
|
+
"enforcement": "active",
|
|
8
|
+
"conditions": {
|
|
9
|
+
"ref_name": {
|
|
10
|
+
"exclude": [],
|
|
11
|
+
"include": ["~DEFAULT_BRANCH"]
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"rules": [
|
|
15
|
+
{
|
|
16
|
+
"type": "non_fast_forward"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "pull_request",
|
|
20
|
+
"parameters": {
|
|
21
|
+
"required_approving_review_count": 0,
|
|
22
|
+
"dismiss_stale_reviews_on_push": false,
|
|
23
|
+
"required_reviewers": [],
|
|
24
|
+
"require_code_owner_review": false,
|
|
25
|
+
"require_last_push_approval": false,
|
|
26
|
+
"required_review_thread_resolution": true,
|
|
27
|
+
"allowed_merge_methods": ["squash", "merge"]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "update"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"type": "required_linear_history"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"type": "deletion"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"bypass_actors": [
|
|
41
|
+
{
|
|
42
|
+
"actor_id": 5,
|
|
43
|
+
"actor_type": "RepositoryRole",
|
|
44
|
+
"bypass_mode": "always"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require("child_process");
|
|
4
|
+
const pkg = require("./package.json");
|
|
5
|
+
|
|
6
|
+
function exists(cmd) {
|
|
7
|
+
try {
|
|
8
|
+
execSync(`command -v ${cmd}`, { stdio: "ignore" });
|
|
9
|
+
return true;
|
|
10
|
+
} catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function installNode() {
|
|
16
|
+
console.log("📦 Instalando Node.js y npm...\n");
|
|
17
|
+
execSync("sudo apt update", { stdio: "inherit" });
|
|
18
|
+
execSync("sudo apt install -y nodejs npm", { stdio: "inherit" });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function latestVersion() {
|
|
22
|
+
try {
|
|
23
|
+
return execSync(`npm view ${pkg.name} version`, {
|
|
24
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
25
|
+
})
|
|
26
|
+
.toString()
|
|
27
|
+
.trim();
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function updateIfNeeded() {
|
|
34
|
+
const current = pkg.version;
|
|
35
|
+
const latest = latestVersion();
|
|
36
|
+
if (!latest) return;
|
|
37
|
+
|
|
38
|
+
if (current !== latest) {
|
|
39
|
+
console.log(`⬆ Nueva versión disponible ${latest} (actual ${current})`);
|
|
40
|
+
console.log("Actualizando kapelu...\n");
|
|
41
|
+
execSync(`npm install -g ${pkg.name}`, { stdio: "inherit" });
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function autoUpdateGitHub() {
|
|
47
|
+
// Si el script existe, hacer pull del repo para tener versión más reciente
|
|
48
|
+
try {
|
|
49
|
+
execSync(
|
|
50
|
+
`if [ -d "/tmp/script-setup" ]; then cd /tmp/script-setup && git pull --rebase; fi`,
|
|
51
|
+
{ stdio: "inherit", shell: "/bin/bash" },
|
|
52
|
+
);
|
|
53
|
+
} catch {}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
console.log("🔎 Verificando Node.js y npm...");
|
|
58
|
+
if (!exists("node") || !exists("npm")) installNode();
|
|
59
|
+
console.log("✔ Node.js y npm OK\n");
|
|
60
|
+
|
|
61
|
+
console.log("🔎 Verificando actualizaciones en npm...");
|
|
62
|
+
updateIfNeeded();
|
|
63
|
+
|
|
64
|
+
console.log("🔎 Actualizando desde GitHub si existe repo local...");
|
|
65
|
+
autoUpdateGitHub();
|
|
66
|
+
|
|
67
|
+
console.log("🚀 Ejecutando install.sh\n");
|
|
68
|
+
execSync("bash install.sh", { stdio: "inherit" });
|
|
69
|
+
} catch (err) {
|
|
70
|
+
console.error("\n❌ Error ejecutando Post-Install:", err.message);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
//const { execSync } = require("child_process");
|
|
78
|
+
//execSync("bash install.sh", { stdio: "inherit" });
|
package/install.sh
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ╔════════════════════════════════════════════════════╗
|
|
3
|
+
# │ Install - Script para comenzar la instalación. │
|
|
4
|
+
# │ Versión: 2.0 │
|
|
5
|
+
# │ Autor: Daniel Calderon - Kapelu │
|
|
6
|
+
# │ Fecha: 06/03/2026 │
|
|
7
|
+
# │ WebSite: https://danielcalderon.vercel.app/ │
|
|
8
|
+
# │ Github: https://github.com/Kapelu │
|
|
9
|
+
# ╚════════════════════════════════════════════════════╝
|
|
10
|
+
set -Eeuo pipefail
|
|
11
|
+
IFS=$'\n\t'
|
|
12
|
+
|
|
13
|
+
USER_NAME=$(whoami)
|
|
14
|
+
HOME_DIR=$HOME
|
|
15
|
+
DESKTOP_DIR=$(xdg-user-dir DESKTOP)
|
|
16
|
+
TMP_DIR="/tmp/kape-setup-$RANDOM"
|
|
17
|
+
REPO="https://github.com/Kapelu/kape-setup/tree/main"
|
|
18
|
+
LOG_FILE="$HOME_DIR/setup-kape.log"
|
|
19
|
+
green='\e[32m'
|
|
20
|
+
reset='\e[0m'
|
|
21
|
+
LOG="$HOME/post-install.log"
|
|
22
|
+
|
|
23
|
+
log() {
|
|
24
|
+
echo -e "\033[0;32m✅ $1\033[0m"
|
|
25
|
+
echo "$1" >> "$LOG"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
detect_distro(){
|
|
29
|
+
|
|
30
|
+
if [ ! -f /etc/os-release ]; then
|
|
31
|
+
log "Sistema no soportado"
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
source /etc/os-release
|
|
36
|
+
|
|
37
|
+
case "$ID" in
|
|
38
|
+
ubuntu|debian|linuxmint|pop)
|
|
39
|
+
log "Distribución detectada: $ID"
|
|
40
|
+
;;
|
|
41
|
+
*)
|
|
42
|
+
log "Distribución no soportada"
|
|
43
|
+
exit 1
|
|
44
|
+
esac
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
check_git(){
|
|
48
|
+
|
|
49
|
+
if ! command -v git >/dev/null; then
|
|
50
|
+
log "Instalando git"
|
|
51
|
+
sudo apt update
|
|
52
|
+
sudo apt install -y git
|
|
53
|
+
fi
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
backup_bashrc(){
|
|
57
|
+
|
|
58
|
+
if [ -f "$HOME_DIR/.bashrc" ]; then
|
|
59
|
+
cp "$HOME_DIR/.bashrc" "$HOME_DIR/.bashrc.backup.$(date +%s)"
|
|
60
|
+
log "Backup de .bashrc creado"
|
|
61
|
+
fi
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
clone_repo(){
|
|
65
|
+
|
|
66
|
+
log "Clonando repositorio"
|
|
67
|
+
|
|
68
|
+
git clone "$REPO" "$TMP_DIR"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
copy_scripts(){
|
|
72
|
+
|
|
73
|
+
mkdir -p "$HOME_DIR/script"
|
|
74
|
+
|
|
75
|
+
cp "$TMP_DIR/script/"* "$HOME_DIR/script/"
|
|
76
|
+
|
|
77
|
+
chmod +x "$HOME_DIR/script/"*
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
copy_config(){
|
|
81
|
+
|
|
82
|
+
cp "$TMP_DIR/config/.bashrc" "$HOME_DIR/.bashrc"
|
|
83
|
+
|
|
84
|
+
cp "$TMP_DIR/config/protect-main.json" "$HOME_DIR/"
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
create_desktop(){
|
|
88
|
+
|
|
89
|
+
mkdir -p "DESKTOP_DIR"
|
|
90
|
+
|
|
91
|
+
cat <<EOF > "DESKTOP_DIR/btn_log.desktop"
|
|
92
|
+
[Desktop Entry]
|
|
93
|
+
Name=Logout
|
|
94
|
+
Comment=Cierra sesión con barra visual de 15 segundos
|
|
95
|
+
Exec=gnome-terminal --geometry=45x8 --hide-menubar -- bash -c "/home/$USER_NAME/script/btn-log.sh"
|
|
96
|
+
Icon=system-log-out
|
|
97
|
+
Terminal=false
|
|
98
|
+
Type=Application
|
|
99
|
+
Categories=Utility;
|
|
100
|
+
EOF
|
|
101
|
+
|
|
102
|
+
cat <<EOF > "DESKTOP_DIR/btn_shd.desktop"
|
|
103
|
+
[Desktop Entry]
|
|
104
|
+
Name=Apagar
|
|
105
|
+
Comment=Apaga la computadora con barra visual de 15 segundos
|
|
106
|
+
Exec=gnome-terminal --geometry=45x8 --hide-menubar -- bash -c "/home/$USER_NAME/script/btn-shd.sh"
|
|
107
|
+
Icon=system-shutdown
|
|
108
|
+
Terminal=false
|
|
109
|
+
Type=Application
|
|
110
|
+
Categories=System;
|
|
111
|
+
EOF
|
|
112
|
+
|
|
113
|
+
cat <<EOF > "DESKTOP_DIR/btn_sus.desktop"
|
|
114
|
+
[Desktop Entry]
|
|
115
|
+
Name=Suspender
|
|
116
|
+
Comment=Suspender la máquina con barra visual de 15 segundos
|
|
117
|
+
Exec=gnome-terminal --geometry=45x8 --hide-menubar -- bash -c "/home/$USER_NAME/script/btn-sus.sh"
|
|
118
|
+
Icon=system-suspend
|
|
119
|
+
Terminal=false
|
|
120
|
+
Type=Application
|
|
121
|
+
Categories=Utility;
|
|
122
|
+
EOF
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
system_update(){ sudo apt update -y; sudo apt upgrade -y; sudo apt full-upgrade -y; }
|
|
126
|
+
|
|
127
|
+
system_cleanup(){
|
|
128
|
+
|
|
129
|
+
sudo apt autoremove -y
|
|
130
|
+
sudo apt clean
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
cleanup(){ rm -rf "$TMP_DIR"; }
|
|
134
|
+
|
|
135
|
+
run_setup(){
|
|
136
|
+
|
|
137
|
+
printf "${green}📦 ¿Desea ejecutar setup.sh? (s/n): ${reset}"
|
|
138
|
+
read RESP
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
if [ "$RESP" = "s" ]; then
|
|
142
|
+
bash "$HOME_DIR/script/setup.sh"
|
|
143
|
+
else
|
|
144
|
+
system_update
|
|
145
|
+
system_cleanup
|
|
146
|
+
fi
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
main(){
|
|
150
|
+
|
|
151
|
+
log "Iniciando Secuencia Post-Install setup-kape"
|
|
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
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
main
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
|
|
3
|
+
"name": "setup-kapelu",
|
|
4
|
+
"version": "3.0.0",
|
|
5
|
+
"description": "Script post-install de Ubuntu",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"bin": {
|
|
8
|
+
"kapelu": "index.js"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/Kapelu/kape-setup.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"ubuntu",
|
|
16
|
+
"setup",
|
|
17
|
+
"post-install",
|
|
18
|
+
"cli",
|
|
19
|
+
"script"
|
|
20
|
+
],
|
|
21
|
+
"author": "Daniel Calderon",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/Kapelu/kape-setup/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/Kapelu/kape-setup#readme",
|
|
27
|
+
"files": [
|
|
28
|
+
"cli.js",
|
|
29
|
+
"install.sh",
|
|
30
|
+
"script/",
|
|
31
|
+
"config/"
|
|
32
|
+
]
|
|
33
|
+
}
|