@iamandersonp/prettier-staged 0.2.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/.editorconfig +13 -0
- package/.env.example +14 -0
- package/.git-hooks/commit-msg +25 -0
- package/.git-hooks/pre-commit +19 -0
- package/.git-hooks/pre-commit-sample +15 -0
- package/.git-hooks/prepare-commit-msg +42 -0
- package/.prettierrc +6 -0
- package/.versionrc.json +14 -0
- package/.vscode/extensions.json +17 -0
- package/.vscode/settings.json +6 -0
- package/CHANGELOG.md +49 -0
- package/LICENSE +674 -0
- package/README.md +176 -0
- package/commitlint.config.js +3 -0
- package/jest.config.js +38 -0
- package/package.json +44 -0
- package/src/index.js +44 -0
- package/src/install-hooks.js +165 -0
- package/tests/index.test.js +233 -0
- package/tests/install-hooks.test.js +295 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Editor configuration, see http://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
indent_style = space
|
|
7
|
+
indent_size = 2
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
|
|
11
|
+
[*.md]
|
|
12
|
+
max_line_length = off
|
|
13
|
+
trim_trailing_whitespace = false
|
package/.env.example
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Configuración del directorio de hooks de Git
|
|
2
|
+
#
|
|
3
|
+
# HOOKS_DIR define el directorio donde se almacenarán los hooks de Git
|
|
4
|
+
# versionables. Si no se especifica, se usará '.git-hooks' por defecto.
|
|
5
|
+
#
|
|
6
|
+
# Ejemplos:
|
|
7
|
+
# HOOKS_DIR=.git-hooks # Valor por defecto
|
|
8
|
+
# HOOKS_DIR=custom-hooks # Directorio personalizado
|
|
9
|
+
# HOOKS_DIR="hooks-dir" # Con comillas dobles
|
|
10
|
+
# HOOKS_DIR='my-hooks' # Con comillas simples
|
|
11
|
+
#
|
|
12
|
+
# Nota: Las comillas son opcionales y serán removidas automáticamente
|
|
13
|
+
|
|
14
|
+
HOOKS_DIR=.git-hooks
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# An example hook script to check the commit log message.
|
|
4
|
+
# Called by "git commit" with one argument, the name of the file
|
|
5
|
+
# that has the commit message. The hook should exit with non-zero
|
|
6
|
+
# status after issuing an appropriate message if it wants to stop the
|
|
7
|
+
# commit. The hook is allowed to edit the commit message file.
|
|
8
|
+
#
|
|
9
|
+
# To enable this hook, rename this file to "commit-msg".
|
|
10
|
+
|
|
11
|
+
# Uncomment the below to add a Signed-off-by line to the message.
|
|
12
|
+
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
|
|
13
|
+
# hook is more suited to it.
|
|
14
|
+
#
|
|
15
|
+
SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
|
16
|
+
grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
|
17
|
+
|
|
18
|
+
# # This example catches duplicate Signed-off-by lines.
|
|
19
|
+
# test "" = "$(grep '^Signed-off-by: ' "$1" |
|
|
20
|
+
# sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
|
21
|
+
# echo >&2 Duplicate Signed-off-by lines.
|
|
22
|
+
# exit 1
|
|
23
|
+
# }
|
|
24
|
+
|
|
25
|
+
npx --no -- commitlint --edit $1;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
if git ls-files -u | grep -q .; then
|
|
5
|
+
echo "⚠️ Merge in progress with conflicts. Skipping Prettier to avoid issues."
|
|
6
|
+
exit 0
|
|
7
|
+
fi
|
|
8
|
+
|
|
9
|
+
find src -name .DS_Store -exec rm {} \;
|
|
10
|
+
|
|
11
|
+
npm run test:coverage
|
|
12
|
+
|
|
13
|
+
npm run prettier-staged
|
|
14
|
+
|
|
15
|
+
STAGED_FILES=$(git diff --name-only --cached --diff-filter=ACM | grep -E '\.(html|ts|scss|css|json)$')
|
|
16
|
+
|
|
17
|
+
if [ -n "$STAGED_FILES" ]; then
|
|
18
|
+
echo "$STAGED_FILES" | xargs git add
|
|
19
|
+
fi
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
if git ls-files -u | grep -q .; then
|
|
5
|
+
echo "⚠️ Merge in progress with conflicts. Skipping Prettier to avoid issues."
|
|
6
|
+
exit 0
|
|
7
|
+
fi
|
|
8
|
+
|
|
9
|
+
npm run prettier-staged
|
|
10
|
+
|
|
11
|
+
STAGED_FILES=$(git diff --name-only --cached --diff-filter=ACM | grep -E '\.(html|ts|scss|css|json)$')
|
|
12
|
+
|
|
13
|
+
if [ -n "$STAGED_FILES" ]; then
|
|
14
|
+
echo "$STAGED_FILES" | xargs git add
|
|
15
|
+
fi
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# An example hook script to prepare the commit log message.
|
|
4
|
+
# Called by "git commit" with the name of the file that has the
|
|
5
|
+
# commit message, followed by the description of the commit
|
|
6
|
+
# message's source. The hook's purpose is to edit the commit
|
|
7
|
+
# message file. If the hook fails with a non-zero status,
|
|
8
|
+
# the commit is aborted.
|
|
9
|
+
#
|
|
10
|
+
# To enable this hook, rename this file to "prepare-commit-msg".
|
|
11
|
+
|
|
12
|
+
# This hook includes three examples. The first one removes the
|
|
13
|
+
# "# Please enter the commit message..." help message.
|
|
14
|
+
#
|
|
15
|
+
# The second includes the output of "git diff --name-status -r"
|
|
16
|
+
# into the message, just before the "git status" output. It is
|
|
17
|
+
# commented because it doesn't cope with --amend or with squashed
|
|
18
|
+
# commits.
|
|
19
|
+
#
|
|
20
|
+
# The third example adds a Signed-off-by line to the message, that can
|
|
21
|
+
# still be edited. This is rarely a good idea.
|
|
22
|
+
|
|
23
|
+
COMMIT_MSG_FILE=$1
|
|
24
|
+
COMMIT_SOURCE=$2
|
|
25
|
+
SHA1=$3
|
|
26
|
+
|
|
27
|
+
/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
|
|
28
|
+
|
|
29
|
+
case "$COMMIT_SOURCE,$SHA1" in
|
|
30
|
+
,|template,)
|
|
31
|
+
/usr/bin/perl -i.bak -pe '
|
|
32
|
+
print "\n" . `git diff --cached --name-status -r`
|
|
33
|
+
if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
|
|
34
|
+
*) ;;
|
|
35
|
+
esac
|
|
36
|
+
|
|
37
|
+
SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
|
38
|
+
git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
|
|
39
|
+
if test -z "$COMMIT_SOURCE"
|
|
40
|
+
then
|
|
41
|
+
/usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
|
|
42
|
+
fi
|
package/.prettierrc
ADDED
package/.versionrc.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"types": [
|
|
3
|
+
{ "type": "feat", "section": "Features" },
|
|
4
|
+
{ "type": "fix", "section": "Bug Fixes" },
|
|
5
|
+
{ "type": "chore", "hidden": true },
|
|
6
|
+
{ "type": "docs", "hidden": true },
|
|
7
|
+
{ "type": "style", "hidden": true },
|
|
8
|
+
{ "type": "refactor", "hidden": true },
|
|
9
|
+
{ "type": "perf", "hidden": true },
|
|
10
|
+
{ "type": "test", "hidden": true }
|
|
11
|
+
],
|
|
12
|
+
"commitUrlFormat": "https://github.com/iamandersonp/preetier-staged/commits/{{hash}}",
|
|
13
|
+
"compareUrlFormat": "https://github.com/iamandersonp/preetier-staged/compare/{{previousTag}}...{{currentTag}}"
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"recommendations": [
|
|
3
|
+
"esbenp.prettier-vscode",
|
|
4
|
+
"angular.ng-template",
|
|
5
|
+
"cyrilletuzi.angular-schematics",
|
|
6
|
+
"formulahendry.auto-close-tag",
|
|
7
|
+
"steoates.autoimport",
|
|
8
|
+
"formulahendry.auto-rename-tag",
|
|
9
|
+
"oouo-diogo-perdigao.docthis",
|
|
10
|
+
"dbaeumer.vscode-eslint",
|
|
11
|
+
"mhutchie.git-graph",
|
|
12
|
+
"donjayamanne.githistory",
|
|
13
|
+
"mohsen1.prettify-json",
|
|
14
|
+
"vivaxy.vscode-conventional-commits",
|
|
15
|
+
"firsttris.vscode-jest-runner"
|
|
16
|
+
]
|
|
17
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
+
|
|
5
|
+
## [0.2.0](https://github.com/iamandersonp/preetier-staged/compare/v0.1.1...v0.2.0) (2026-04-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* :rocket: rename to prettier-staged for consistence ([d7ae9f4](https://github.com/iamandersonp/preetier-staged/commits/d7ae9f40006e0040ee5045f3f642a6f02c860db2))
|
|
11
|
+
|
|
12
|
+
### [0.1.1](https://github.com/iamandersonp/preetier-staged/compare/v0.1.0...v0.1.1) (2026-04-06)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* :sparkles: instalation hook folder from .env file ([2414b31](https://github.com/iamandersonp/preetier-staged/commits/2414b317c6c6c40bd6818738e20cc8b6091fad5e))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* :zap: instalation hook folder ([5acc701](https://github.com/iamandersonp/preetier-staged/commits/5acc701139e9f0bf7cdc0a0714e4c7285093efcc))
|
|
23
|
+
|
|
24
|
+
## [0.1.0](https://github.com/iamandersonp/preetier-staged/compare/v0.0.7...v0.1.0) (2026-04-06)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* :sparkles: add installation hook to copy sample pre-commit hook ([8fd317d](https://github.com/iamandersonp/preetier-staged/commits/8fd317d17b122cd6067c86e2ce7f187e89deaf38))
|
|
30
|
+
|
|
31
|
+
### [0.0.5](https://github.com/iamandersonp/preetier-staged/compare/v0.0.4...v0.0.5) (2026-04-01)
|
|
32
|
+
|
|
33
|
+
### [0.0.4](https://github.com/iamandersonp/preetier-staged/compare/v0.0.3...v0.0.4) (2026-04-01)
|
|
34
|
+
|
|
35
|
+
### [0.0.3](https://github.com/iamandersonp/preetier-staged/compare/v0.0.2...v0.0.3) (2026-04-01)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Bug Fixes
|
|
39
|
+
|
|
40
|
+
* :rocket: add preetier dependency ([c892b0d](https://github.com/iamandersonp/preetier-staged/commits/c892b0dc699bc07411907d70386114f84ecf3c3c))
|
|
41
|
+
|
|
42
|
+
### [0.0.2](https://github.com/iamandersonp/preetier-staged/compare/v0.0.1...v0.0.2) (2026-04-01)
|
|
43
|
+
|
|
44
|
+
### 0.0.1 (2026-04-01)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Features
|
|
48
|
+
|
|
49
|
+
* :tada: initial versión ([d9e520f](https://github.com/iamandersonp/preetier-staged/commits/d9e520f49456489c396a61d87b56cd3c90c22b7b))
|