stylelint-standard 0.0.1-security → 1.2.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.
Potentially problematic release.
This version of stylelint-standard might be problematic. Click here for more details.
- package/.editorconfig +5 -0
- package/.shellcheckrc +1 -0
- package/LICENSE +21 -0
- package/README.md +1 -5
- package/docs/.vitepress/config.mts +125 -0
- package/docs/es/get-started.md +79 -0
- package/docs/es/how-to.md +335 -0
- package/docs/es/index.md +82 -0
- package/docs/es/migrate-from-v4.md +65 -0
- package/docs/es/troubleshoot.md +41 -0
- package/docs/get-started.md +80 -0
- package/docs/how-to.md +326 -0
- package/docs/index.md +82 -0
- package/docs/manifest +1 -0
- package/docs/migrate-from-v4.md +65 -0
- package/docs/package-lock.json +2914 -0
- package/docs/package.json +10 -0
- package/docs/ru/get-started.md +79 -0
- package/docs/ru/how-to.md +326 -0
- package/docs/ru/index.md +80 -0
- package/docs/ru/migrate-from-v4.md +66 -0
- package/docs/ru/troubleshoot.md +41 -0
- package/docs/sponsorkit/sponsors.svg +573 -0
- package/docs/sponsorkit.config.js +40 -0
- package/docs/troubleshoot.md +41 -0
- package/docs/zh/get-started.md +63 -0
- package/docs/zh/how-to.md +326 -0
- package/docs/zh/index.md +81 -0
- package/docs/zh/migrate-from-v4.md +72 -0
- package/docs/zh/troubleshoot.md +41 -0
- package/husky +22 -0
- package/index.d.ts +1 -0
- package/index.js +25 -0
- package/package.json +8 -4
package/.editorconfig
ADDED
package/.shellcheckrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
disable=SC1090,SC2164
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 typicode
|
|
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
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
|
|
4
|
-
|
|
5
|
-
Please refer to www.npmjs.com/advisories?search=stylelint-standard for more information.
|
|
1
|
+
https://typicode.github.io/husky
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { defineConfig } from "vitepress";
|
|
2
|
+
|
|
3
|
+
// https://vitepress.dev/reference/site-config
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
title: "Husky",
|
|
6
|
+
description: "Git hooks made easy",
|
|
7
|
+
head: [
|
|
8
|
+
[
|
|
9
|
+
"link",
|
|
10
|
+
{
|
|
11
|
+
rel: "icon",
|
|
12
|
+
href: 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y=".9em" font-size="85">🐶</text></svg>',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
],
|
|
16
|
+
base: "/husky/",
|
|
17
|
+
themeConfig: {
|
|
18
|
+
// outline: [2, 3],
|
|
19
|
+
socialLinks: [
|
|
20
|
+
{ icon: "github", link: "https://github.com/typicode/husky" },
|
|
21
|
+
{ icon: "twitter", link: "https://x.com/typicode" },
|
|
22
|
+
],
|
|
23
|
+
// carbonAds: {
|
|
24
|
+
// code: 'CWYDP53L',
|
|
25
|
+
// placement: 'typicodegithubio',
|
|
26
|
+
// },
|
|
27
|
+
sidebar: [
|
|
28
|
+
{ text: "Introduction", link: "/" },
|
|
29
|
+
{ text: "Get Started", link: "/get-started" },
|
|
30
|
+
{ text: "How To", link: "/how-to" },
|
|
31
|
+
{ text: "Troubleshoot", link: "/troubleshoot" },
|
|
32
|
+
{ text: "Migrate from v4", link: "/migrate-from-v4" },
|
|
33
|
+
],
|
|
34
|
+
nav: [{ text: "Sponsor", link: "https://github.com/sponsors/typicode" }],
|
|
35
|
+
},
|
|
36
|
+
locales: {
|
|
37
|
+
root: {
|
|
38
|
+
label: "English",
|
|
39
|
+
lang: "en-US",
|
|
40
|
+
},
|
|
41
|
+
zh: {
|
|
42
|
+
label: "简体中文",
|
|
43
|
+
lang: "zh-hans",
|
|
44
|
+
description: "使 Git hooks 变得简单",
|
|
45
|
+
link: "/zh/",
|
|
46
|
+
themeConfig: {
|
|
47
|
+
sidebar: [
|
|
48
|
+
{ text: "简介", link: "/zh/" },
|
|
49
|
+
{ text: "快速开始", link: "/zh/get-started" },
|
|
50
|
+
{ text: "如何使用", link: "/zh/how-to" },
|
|
51
|
+
{ text: "故障排查", link: "/zh/troubleshoot" },
|
|
52
|
+
{ text: "从 v4 迁移", link: "/zh/migrate-from-v4" },
|
|
53
|
+
],
|
|
54
|
+
docFooter: {
|
|
55
|
+
prev: "上一页",
|
|
56
|
+
next: "下一页",
|
|
57
|
+
},
|
|
58
|
+
outline: {
|
|
59
|
+
label: "页面导航",
|
|
60
|
+
},
|
|
61
|
+
nav: [
|
|
62
|
+
{
|
|
63
|
+
text: "v9.0.1",
|
|
64
|
+
items: [
|
|
65
|
+
{
|
|
66
|
+
text: "更新日志",
|
|
67
|
+
link: "https://github.com/typicode/husky/releases/tag/v9.0.1",
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
ru: {
|
|
75
|
+
label: "Русский",
|
|
76
|
+
lang: "ru-RU",
|
|
77
|
+
description: "Git hooks made easy",
|
|
78
|
+
link: "/ru/",
|
|
79
|
+
themeConfig: {
|
|
80
|
+
sidebar: [
|
|
81
|
+
{ text: "Введение", link: "/ru/" },
|
|
82
|
+
{ text: "Начало работы", link: "/ru/get-started" },
|
|
83
|
+
{ text: "Как использовать", link: "/ru/how-to" },
|
|
84
|
+
{ text: "Устранение неполадок", link: "/ru/troubleshoot" },
|
|
85
|
+
{ text: "Миграция с v4", link: "/ru/migrate-from-v4" },
|
|
86
|
+
],
|
|
87
|
+
docFooter: {
|
|
88
|
+
prev: "Предыдущая страница",
|
|
89
|
+
next: "Следующая страница",
|
|
90
|
+
},
|
|
91
|
+
outline: {
|
|
92
|
+
label: "Содержание страницы",
|
|
93
|
+
},
|
|
94
|
+
nav: [
|
|
95
|
+
{ text: "Sponsor", link: "https://github.com/sponsors/typicode" },
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
es: {
|
|
100
|
+
label: "Español",
|
|
101
|
+
lang: "es-EC",
|
|
102
|
+
description: "Git hooks se vuelven fáciles",
|
|
103
|
+
link: "/es/",
|
|
104
|
+
themeConfig: {
|
|
105
|
+
sidebar: [
|
|
106
|
+
{ text: "Introducción", link: "/es/" },
|
|
107
|
+
{ text: "Comenzar", link: "/es/get-started" },
|
|
108
|
+
{ text: "Cómo hacerlo", link: "/es/how-to" },
|
|
109
|
+
{ text: "Solucionar problemas", link: "/es/troubleshoot" },
|
|
110
|
+
{ text: "Migrar desde v4", link: "/es/migrate-from-v4" },
|
|
111
|
+
],
|
|
112
|
+
docFooter: {
|
|
113
|
+
prev: "Página anterior",
|
|
114
|
+
next: "Página siguiente",
|
|
115
|
+
},
|
|
116
|
+
outline: {
|
|
117
|
+
label: "Contenido de la página",
|
|
118
|
+
},
|
|
119
|
+
nav: [
|
|
120
|
+
{ text: "Sponsor", link: "https://github.com/sponsors/typicode" },
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Comenzar
|
|
2
|
+
|
|
3
|
+
## Instalar
|
|
4
|
+
|
|
5
|
+
::: code-group
|
|
6
|
+
|
|
7
|
+
```shell [npm]
|
|
8
|
+
npm install --save-dev husky
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```shell [pnpm]
|
|
12
|
+
pnpm add --save-dev husky
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```shell [yarn]
|
|
16
|
+
yarn add --dev husky
|
|
17
|
+
# Agregue pinst SÓLO si su paquete no es privado
|
|
18
|
+
yarn add --dev pinst
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```shell [bun]
|
|
22
|
+
bun add --dev husky
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
:::
|
|
26
|
+
|
|
27
|
+
## `husky init` (recomendado)
|
|
28
|
+
|
|
29
|
+
El comando `init` simplifica la configuración de husky en un proyecto. Crea un script `pre-commit` en `.husky/` y actualiza el script `prepare` en `package.json`. Luego se pueden realizar modificaciones para que se adapten a su flujo de trabajo.
|
|
30
|
+
|
|
31
|
+
::: code-group
|
|
32
|
+
|
|
33
|
+
```shell [npm]
|
|
34
|
+
npx husky init
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```shell [pnpm]
|
|
38
|
+
pnpm exec husky init
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```shell [yarn]
|
|
42
|
+
# Debido a advertencias específicas y diferencias con otros administradores de paquetes,
|
|
43
|
+
# consulte la sección Cómo hacerlo.
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```shell [bun]
|
|
47
|
+
bunx husky init
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
:::
|
|
51
|
+
|
|
52
|
+
## Pruébalo
|
|
53
|
+
|
|
54
|
+
¡Felicitaciones! Has configurado exitosamente tu primer gancho de Git (Git hook) con solo un comando 🎉. Probémoslo:
|
|
55
|
+
|
|
56
|
+
```shell
|
|
57
|
+
git commit -m "Keep calm and commit"
|
|
58
|
+
# El script de prueba se ejecutará cada vez que realices un commit
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Unas pocas palabras...
|
|
62
|
+
|
|
63
|
+
### Scripting
|
|
64
|
+
|
|
65
|
+
Si bien la mayoría de las veces, solo ejecutarás algunos comandos `npm run` o `npx` en tus ganchos (hooks), también puedes crear scripts con el shell POSIX para flujos de trabajo personalizados (custom workflows).
|
|
66
|
+
|
|
67
|
+
Por ejemplo, aquí se muestra cómo puedes analizar (lint) tus archivos preparados (staged files) en cada confirmación (commit) con solo dos líneas de código de shell y sin dependencia externa:
|
|
68
|
+
|
|
69
|
+
```shell
|
|
70
|
+
# .husky/pre-commit
|
|
71
|
+
prettier $(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g') --write --ignore-unknown
|
|
72
|
+
git update-index --again
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
_Este es un ejemplo básico pero funcional, si necesita saber más verifique [lint-staged](https://github.com/lint-staged/lint-staged)._
|
|
76
|
+
|
|
77
|
+
### Deshabilitar ganchos (hooks)
|
|
78
|
+
|
|
79
|
+
Husky no fuerza los ganchos de Git (Git hooks). Se pueden deshabilitar globalmente (`HUSKY=0`) o se pueden habilitar si se desea. Consulta la sección [Cómo hacerlo](how-to) para obtener más información y realizar una configuración manual.
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
# Cómo hacerlo
|
|
2
|
+
|
|
3
|
+
## Agregar un nuevo gancho (Hook)
|
|
4
|
+
|
|
5
|
+
Agregar un gancho (hook) es tan simple como crear un archivo. Esto se puede lograr usando su editor favorito, un script o un comando echo básico. Por ejemplo, en Linux/macOS:
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
echo "npm test" > .husky/pre-commit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Archivos de inicio
|
|
12
|
+
|
|
13
|
+
Husky le permite ejecutar comandos locales antes de ejecutar ganchos (hooks). Husky lee comandos de estos archivos:
|
|
14
|
+
|
|
15
|
+
- `$XDG_CONFIG_HOME/husky/init.sh`
|
|
16
|
+
- `~/.config/husky/init.sh`
|
|
17
|
+
- `~/.huskyrc` (obsoleto (deprecated))
|
|
18
|
+
|
|
19
|
+
En Windows: `C:\Users\yourusername\.config\husky\init.sh`
|
|
20
|
+
|
|
21
|
+
## Omitir ganchos de Git (Git Hooks)
|
|
22
|
+
|
|
23
|
+
### Para un solo comando
|
|
24
|
+
|
|
25
|
+
La mayoría de los comandos de Git incluyen una opción `-n/--no-verify` para omitir ganchos (hooks):
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
git commit -m "..." -n # Skips Git hooks
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Para los comandos sin esta bandera, deshabilite los ganchos (hooks) temporalmente con HUSKY=0:
|
|
32
|
+
|
|
33
|
+
```shell
|
|
34
|
+
HUSKY=0 git ... # Desactiva temporalmente todos los ganchos de Git (Git hooks)
|
|
35
|
+
git ... # Los ganchos (Hooks) se ejecutarán nuevamente
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Para varios comandos
|
|
39
|
+
|
|
40
|
+
Para deshabilitar los ganchos (hooks) durante un período prolongado (por ejemplo, durante la rebase/fusión (rebase/merge)):
|
|
41
|
+
|
|
42
|
+
```shell
|
|
43
|
+
export HUSKY=0 # Deshabilita todos los ganchos (hooks) de Git
|
|
44
|
+
git ...
|
|
45
|
+
git ...
|
|
46
|
+
unset HUSKY # Vuelve a habilitar los ganchos (hooks)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Para una GUI o globalmente
|
|
50
|
+
|
|
51
|
+
Para deshabilitar los ganchos (hooks) de Git en un cliente GUI o globalmente, modifica la configuración de husky:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
# ~/.config/husky/init.sh
|
|
55
|
+
export HUSKY=0 # Husky no instalará ni ejecutará ganchos (hooks) en tu máquina
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Servidor CI y Docker
|
|
59
|
+
|
|
60
|
+
Para evitar instalar ganchos de Git (Git Hooks) en servidores de CI o en Docker, use `HUSKY=0`. Por ejemplo, en acciones de GitHub (GitHub Actions):
|
|
61
|
+
|
|
62
|
+
```yml
|
|
63
|
+
# https://docs.github.com/en/actions/learn-github-actions/variables
|
|
64
|
+
env:
|
|
65
|
+
HUSKY: 0
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Si instala solo `dependencies` (no `devDependencies`), el script `"prepare": "husky"` puede fallar porque Husky no se instalará.
|
|
69
|
+
|
|
70
|
+
Tiene varias soluciones.
|
|
71
|
+
|
|
72
|
+
Modifique el script `prepare` para que nunca falle:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
// package.json
|
|
76
|
+
"prepare": "husky || true"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Aún recibirá un mensaje de error `command not found` en su salida que puede ser confuso. Para que sea silencioso, cree `.husky/install.mjs`:
|
|
80
|
+
|
|
81
|
+
<!-- Dado que es posible que husky no esté instalado, se debe importar dinámicamente después de la verificación de producción/CI (prod/CI) -->
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
// Omitir la instalación de Husky en producción y CI
|
|
85
|
+
if (process.env.NODE_ENV === "production" || process.env.CI === "true") {
|
|
86
|
+
process.exit(0);
|
|
87
|
+
}
|
|
88
|
+
const husky = (await import("husky")).default;
|
|
89
|
+
console.log(husky());
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Luego, úsalo en `prepare`:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
"prepare": "node .husky/install.mjs"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Probar (testear) Ganchos (Hooks) sin confirmar (Committing)
|
|
99
|
+
|
|
100
|
+
Para probar/testear un gancho (hook), agregue `exit 1` al script del gancho (hook) para cancelar el comando Git:
|
|
101
|
+
|
|
102
|
+
```shell
|
|
103
|
+
# .husky/pre-commit
|
|
104
|
+
|
|
105
|
+
# Your WIP script
|
|
106
|
+
# ...
|
|
107
|
+
|
|
108
|
+
exit 1
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
```shell
|
|
112
|
+
git commit -m "testing pre-commit code"
|
|
113
|
+
# No se creará una confirmación (commit)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## El proyecto no está en el directorio raíz de Git
|
|
117
|
+
|
|
118
|
+
Por razones de seguridad, Husky no se instala en los directorios padres (`../`). Sin embargo, puedes cambiar el directorio en el script `prepare`.
|
|
119
|
+
|
|
120
|
+
Considera esta estructura de proyecto:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
.
|
|
124
|
+
├── .git/
|
|
125
|
+
├── backend/ # No package.json
|
|
126
|
+
└── frontend/ # Package.json con husky
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Configure su script de preparación de la siguiente manera:
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
"prepare": "cd .. && husky frontend/.husky"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
En el script de gancho (hook script), cambie el directorio nuevamente al subdirectorio correspondiente:
|
|
136
|
+
|
|
137
|
+
```shell
|
|
138
|
+
# frontend/.husky/pre-commit
|
|
139
|
+
cd frontend
|
|
140
|
+
npm test
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Ganchos (hooks) que no son de shell
|
|
144
|
+
|
|
145
|
+
Para ejecutar scripts que requieren el uso de un lenguaje de script, use el siguiente patrón para cada gancho (hook) en el que aplique:
|
|
146
|
+
|
|
147
|
+
(Ejemplo usando el gancho (hook) `pre-commit` y NodeJS)
|
|
148
|
+
|
|
149
|
+
1. Cree un punto de entrada para el gancho (hook):
|
|
150
|
+
|
|
151
|
+
```shell
|
|
152
|
+
.husky/pre-commit
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
2. En el archivo agregue lo siguiente
|
|
156
|
+
|
|
157
|
+
```shell
|
|
158
|
+
node .husky/pre-commit.js
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
3. en `.husky/pre-commit.js`
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
// Su código NodeJS
|
|
165
|
+
// ...
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Bash
|
|
169
|
+
|
|
170
|
+
Los scripts de gancho (hook) deben ser compatibles con POSIX para garantizar la mejor compatibilidad, ya que no todos tienen "bash" (por ejemplo, los usuarios de Windows).
|
|
171
|
+
|
|
172
|
+
Dicho esto, si su equipo no usa Windows, puede usar Bash de esta manera:
|
|
173
|
+
|
|
174
|
+
```shell
|
|
175
|
+
# .husky/pre-commit
|
|
176
|
+
|
|
177
|
+
bash << EOF
|
|
178
|
+
# Coloque dentro su script de bash
|
|
179
|
+
# ...
|
|
180
|
+
EOF
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Administradores de versiones de Node y GUI
|
|
184
|
+
|
|
185
|
+
Si usas ganchos de Git (Git hooks) en GUI con Node instalado a través de un administrador de versiones (como `nvm`, `n`, `fnm`, `asdf`, `volta`, etc.), es posible que te aparezca un error de `comando no encontrado` debido a problemas con la variable de entorno `PATH`.
|
|
186
|
+
|
|
187
|
+
### Entender `PATH` y los administradores de versiones
|
|
188
|
+
|
|
189
|
+
`PATH` es una variable de entorno que contiene una lista de directorios. Su shell busca comandos en estos directorios. Si no encuentra un comando, recibirá un mensaje de `comando no encontrado`.
|
|
190
|
+
|
|
191
|
+
Ejecute `echo $PATH` en un shell para ver su contenido.
|
|
192
|
+
|
|
193
|
+
Los administradores de versiones funcionan de la siguiente manera:
|
|
194
|
+
|
|
195
|
+
1. Agregando el código de inicialización al archivo de inicio de su shell (`.zshrc`, `.bashrc`, etc.), que se ejecuta cada vez que abre una terminal.
|
|
196
|
+
2. Descargando versiones de Node a un directorio en su carpeta de inicio (home folder).
|
|
197
|
+
|
|
198
|
+
Por ejemplo, si tiene dos versiones de Node:
|
|
199
|
+
|
|
200
|
+
```shell
|
|
201
|
+
~/version-manager/Node-X/node
|
|
202
|
+
~/version-manager/Node-Y/node
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Al abrir una terminal se inicializa el administrador de versiones, que selecciona una versión (por ejemplo, `Node-Y`) y antepone su ruta a `PATH`:
|
|
206
|
+
|
|
207
|
+
```shell
|
|
208
|
+
echo $PATH
|
|
209
|
+
# Salida
|
|
210
|
+
~/version-manager/Node-Y/:...
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Ahora, el node hace referencia a `Nodo-Y`. Al cambiar a `Nodo-X`, `PATH` cambia en concordancia:
|
|
214
|
+
|
|
215
|
+
```shell
|
|
216
|
+
echo $PATH
|
|
217
|
+
# Salida
|
|
218
|
+
~/version-manager/Node-X/:...
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
El problema surge porque las GUI, lanzadas fuera de una terminal, no inicializan el administrador de versiones, lo que deja a `PATH` sin la ruta de instalación de Node. Por lo tanto, los ganchos de Git (Git hooks) desde las GUI suelen fallar.
|
|
222
|
+
|
|
223
|
+
### Solución
|
|
224
|
+
|
|
225
|
+
Husky obtiene `~/.config/husky/init.sh` antes de cada gancho de Git (Git hooks). Copie aquí el código de inicialización del administrador de versiones para asegurarse de que se ejecute en las GUI.
|
|
226
|
+
|
|
227
|
+
Ejemplo con `nvm`:
|
|
228
|
+
|
|
229
|
+
```shell
|
|
230
|
+
# ~/.config/husky/init.sh
|
|
231
|
+
export NVM_DIR="$HOME/.nvm"
|
|
232
|
+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Como alternativa, si su archivo de inicio de shell es rápido y liviano, consígalo directamente:
|
|
236
|
+
|
|
237
|
+
```shell
|
|
238
|
+
# ~/.config/husky/init.sh
|
|
239
|
+
. ~/.zshrc
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Configuración manual
|
|
243
|
+
|
|
244
|
+
Git necesita ser configurado y husky debe configurar los archivos en `.husky/`.
|
|
245
|
+
|
|
246
|
+
Ejecute el comando `husky` una vez en su repositorio. Lo ideal es incluirlo en el script `prepare` en `package.json` para su ejecución automática después de cada instalación (recomendado).
|
|
247
|
+
|
|
248
|
+
::: code-group
|
|
249
|
+
|
|
250
|
+
```json [npm]
|
|
251
|
+
{
|
|
252
|
+
"scripts": {
|
|
253
|
+
"prepare": "husky" // [!code hl]
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
```json [pnpm]
|
|
259
|
+
{
|
|
260
|
+
"scripts": {
|
|
261
|
+
"prepare": "husky" // [!code hl]
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
```json [yarn]
|
|
267
|
+
{
|
|
268
|
+
"scripts": {
|
|
269
|
+
// Yarn doesn't support prepare script
|
|
270
|
+
"postinstall": "husky",
|
|
271
|
+
// Include this if publishing to npmjs.com
|
|
272
|
+
"prepack": "pinst --disable",
|
|
273
|
+
"postpack": "pinst --enable"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
```json [bun]
|
|
279
|
+
{
|
|
280
|
+
"scripts": {
|
|
281
|
+
"prepare": "husky" // [!code hl]
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
:::
|
|
287
|
+
|
|
288
|
+
Ejecute `prepare` una vez
|
|
289
|
+
|
|
290
|
+
::: code-group
|
|
291
|
+
|
|
292
|
+
```sh [npm]
|
|
293
|
+
npm run prepare
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
```sh [pnpm]
|
|
297
|
+
pnpm run prepare
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
```sh [yarn]
|
|
301
|
+
# Yarn doesn't support `prepare`
|
|
302
|
+
yarn run postinstall
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
```sh [bun]
|
|
306
|
+
bun run prepare
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
:::
|
|
310
|
+
|
|
311
|
+
Cree un archivo `pre-commit` en el directorio `.husky/`:
|
|
312
|
+
|
|
313
|
+
::: code-group
|
|
314
|
+
|
|
315
|
+
```shell [npm]
|
|
316
|
+
# .husky/pre-commit
|
|
317
|
+
npm test
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
```shell [pnpm]
|
|
321
|
+
# .husky/pre-commit
|
|
322
|
+
pnpm test
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
```shell [yarn]
|
|
326
|
+
# .husky/pre-commit
|
|
327
|
+
yarn test
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
```sh [bun]
|
|
331
|
+
# .husky/pre-commit
|
|
332
|
+
bun test
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
:::
|
package/docs/es/index.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
> Hooks nativos de Git ultrarrápidos y modernos
|
|
4
|
+
|
|
5
|
+
Husky mejora tus commits y más 🐶 _¡guau!_
|
|
6
|
+
|
|
7
|
+
Automáticamente hace un **análisis (lint) de tus mensages de commit**, **código**, y **ejecuta pruebas (test)** al confirmarse (committing ) o al enviar (pushing).
|
|
8
|
+
|
|
9
|
+
Comienza [aquí](/es/get-started.md).
|
|
10
|
+
|
|
11
|
+
## Características
|
|
12
|
+
|
|
13
|
+
- Solo `2 kB` (📦 _gzipped_) sin dependencias
|
|
14
|
+
- Más rápido por ser ligero (se ejecuta en `~1ms`)
|
|
15
|
+
- Utiliza la nueva característica de Git (`core.hooksPath`)
|
|
16
|
+
- Soporta:
|
|
17
|
+
- macOS, Linux, Windows
|
|
18
|
+
- GUI de Git (Git GUIs), administradores de versiones de Node, directorio de ganchos personalizados (custom hooks directory), proyectos anidados, monorepositorios (monorepos)
|
|
19
|
+
- [Todos los 13 ganchos de Git (Git hooks) del lado del cliente](https://git-scm.com/docs/githooks)
|
|
20
|
+
|
|
21
|
+
Y más:
|
|
22
|
+
|
|
23
|
+
- Ganchos específicos de la rama
|
|
24
|
+
- Uso de shell POSIX para crear scripts de casos avanzados
|
|
25
|
+
- Se adhiere a la organización de ganchos (hooks) nativa de Git (Git's native hook organization)
|
|
26
|
+
- Se alinea con las mejores prácticas de [npm](https://docs.npmjs.com/cli/v10/using-npm/scripts#best-practices) usando el script `prepare`
|
|
27
|
+
- Opciones de inclusión/exclusión (Opt-in/opt-out)
|
|
28
|
+
- Se puede deshabilitar globalmente
|
|
29
|
+
- Mensajes de error amigables con el usuario
|
|
30
|
+
|
|
31
|
+
## Patrocinadores (Sponsors)
|
|
32
|
+
|
|
33
|
+
Apoya este proyecto convirtiéndote en patrocinador (sponsor) [aquí](https://github.com/sponsors/typicode) 💖
|
|
34
|
+
|
|
35
|
+
### Patrocinador especial (Special Sponsor)
|
|
36
|
+
|
|
37
|
+
<p align="center">
|
|
38
|
+
<a href="https://app.tea.xyz/sign-up?r=8L2HWfJB6hs">
|
|
39
|
+
<img src="https://github.com/typicode/husky/assets/5502029/1b95c571-0157-48bc-a147-0d8d2fbc1d8a" /><br/>
|
|
40
|
+
Obtenga recompensas por sus contribuciones de código abierto
|
|
41
|
+
</a>
|
|
42
|
+
</p>
|
|
43
|
+
|
|
44
|
+
### GitHub
|
|
45
|
+
|
|
46
|
+
<p align="center">
|
|
47
|
+
<a href="../sponsorkit/sponsors.svg">
|
|
48
|
+
<img src='../sponsorkit/sponsors.svg'/>
|
|
49
|
+
</a>
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
### Colectivo Abierto (Open Collective)
|
|
53
|
+
|
|
54
|
+
<a href="https://opencollective.com/husky/tiers/company/0/website"><img src="https://opencollective.com/husky/tiers/company/0/avatar.svg?avatarHeight=120"></a>
|
|
55
|
+
<a href="https://opencollective.com/husky/tiers/company/1/website"><img src="https://opencollective.com/husky/tiers/company/1/avatar.svg?avatarHeight=120"></a>
|
|
56
|
+
<a href="https://opencollective.com/husky/tiers/company/2/website"><img src="https://opencollective.com/husky/tiers/company/2/avatar.svg?avatarHeight=120"></a>
|
|
57
|
+
<a href="https://opencollective.com/husky/tiers/company/3/website"><img src="https://opencollective.com/husky/tiers/company/3/avatar.svg?avatarHeight=120"></a>
|
|
58
|
+
<a href="https://opencollective.com/husky/tiers/company/4/website"><img src="https://opencollective.com/husky/tiers/company/4/avatar.svg?avatarHeight=120"></a>
|
|
59
|
+
<a href="https://opencollective.com/husky/tiers/company/5/website"><img src="https://opencollective.com/husky/tiers/company/5/avatar.svg?avatarHeight=120"></a>
|
|
60
|
+
[](https://www.sanity.io/)
|
|
61
|
+
|
|
62
|
+
## Usado por
|
|
63
|
+
|
|
64
|
+
Husky se utiliza en [**más de 1,5 millones de proyectos**](https://github.com/typicode/husky/network/dependents?package_id=UGFja2FnZS0xODQzNTgwNg%3D%3D) en GitHub, incluidos:
|
|
65
|
+
|
|
66
|
+
- [vercel/next.js](https://github.com/vercel/next.js)
|
|
67
|
+
- [vercel/hyper](https://github.com/vercel/hyper)
|
|
68
|
+
- [webpack/webpack](https://github.com/webpack/webpack)
|
|
69
|
+
- [angular/angular](https://github.com/angular/angular)
|
|
70
|
+
- [facebook/docusaurus](https://github.com/facebook/docusaurus)
|
|
71
|
+
- [microsoft/vscode](https://github.com/microsoft/vscode)
|
|
72
|
+
- [11ty/eleventy](https://github.com/11ty/eleventy)
|
|
73
|
+
- [stylelint/stylelint](https://github.com/stylelint/stylelint)
|
|
74
|
+
- [colinhacks/zod](https://github.com/colinhacks/zod)
|
|
75
|
+
- [rollup/rollup](https://github.com/rollup/rollup)
|
|
76
|
+
- [tinyhttp/tinyhttp](https://github.com/tinyhttp/tinyhttp)
|
|
77
|
+
- ...
|
|
78
|
+
|
|
79
|
+
## Artículos
|
|
80
|
+
|
|
81
|
+
- [Por qué Husky ha abandonado la configuración JS convencional](https://blog.typicode.com/posts/husky-git-hooks-javascript-config/)
|
|
82
|
+
- [Por qué Husky ya no se instala automáticamente](https://blog.typicode.com/posts/husky-git-hooks-autoinstall/)
|