no-yolo-commits 1.1.1 → 1.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/README.md CHANGED
@@ -39,7 +39,7 @@ If you're the "I have thirty repos and I am not doing this thirty times" type:
39
39
  npx no-yolo-commits init --global
40
40
  ```
41
41
 
42
- This wires up git's own [hook template mechanism](https://git-scm.com/docs/git-init#_template_directory) (`git config --global init.templateDir`) — every `git init` and `git clone` from then on gets the hook automatically, no husky, no per-project npm install. The branch prefix is derived from each repo's folder name at commit time (since one script now serves every project you touch).
42
+ This wires up git's own [hook template mechanism](https://git-scm.com/docs/git-init#_template_directory) (`git config --global init.templateDir`) — every `git init` and `git clone` from then on gets the hook automatically, no husky, no per-project npm install. The branch prefix is derived per-repo at commit time (since one script now serves every project you touch): the first 3 letters of `package.json`'s `name` (scope dropped, e.g. `@acme/widgets` → `WID`) if there is one, otherwise the repo's folder name.
43
43
 
44
44
  Already-cloned repos won't retroactively pick it up — re-run `git init` inside one (safe, doesn't touch history or remotes) to copy it in. A project that later runs the regular per-project `init` gets its own `.husky/pre-commit`, which takes precedence over the global hook.
45
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "no-yolo-commits",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "AI pre-commit review (via the claude CLI) + a guard that auto-branches you off main/master instead of letting a direct commit land there.",
5
5
  "keywords": [
6
6
  "husky",
@@ -172,8 +172,24 @@ fi
172
172
  # prefix per-repo at commit time instead of baking one in at install time.
173
173
  configured_prefix="__PREFIX__"
174
174
  if [ "$configured_prefix" = "AUTO" ]; then
175
- prefix="$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null \
176
- | tr '[:lower:]' '[:upper:]' | tr -cs 'A-Z0-9' '-' | sed -e 's/^-*//' -e 's/-*$//' | cut -c1-20)"
175
+ toplevel="$(git rev-parse --show-toplevel 2>/dev/null)"
176
+ prefix=""
177
+ # Prefer package.json's name (first 3 letters, scope dropped) when there
178
+ # is one — falls back to the repo directory name for non-Node projects,
179
+ # or if package.json has no usable "name".
180
+ if [ -n "$toplevel" ] && [ -f "$toplevel/package.json" ] && command -v node >/dev/null 2>&1; then
181
+ prefix="$(node -e '
182
+ try {
183
+ const pkg = require(process.argv[1]);
184
+ const name = String(pkg.name || "").replace(/^@[^/]+\//, "");
185
+ process.stdout.write(name.slice(0, 3).toUpperCase());
186
+ } catch (e) {}
187
+ ' "$toplevel/package.json" 2>/dev/null)"
188
+ fi
189
+ if [ -z "$prefix" ]; then
190
+ prefix="$(basename "$toplevel" 2>/dev/null \
191
+ | tr '[:lower:]' '[:upper:]' | tr -cs 'A-Z0-9' '-' | sed -e 's/^-*//' -e 's/-*$//' | cut -c1-20)"
192
+ fi
177
193
  prefix="${prefix:-WIP}"
178
194
  else
179
195
  prefix="$configured_prefix"