commit-sheriff 1.3.0 → 1.4.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 +10 -5
- package/bin/commit-sheriff.js +8 -9
- package/package.json +1 -1
- package/templates/commit-msg +1 -1
package/README.md
CHANGED
|
@@ -77,9 +77,9 @@ Run this once per repo, from the repo root (where `package.json` lives). This wo
|
|
|
77
77
|
3. Creates a default `.commitsheriffrc.json` file at the repo root **only if one doesn't already exist** (and only if there's no legacy `package.json` → `commitGuard` block either — see [Configuration](#configuration-commitsheriffrcjson)) — re-running `init` never overwrites your customized config.
|
|
78
78
|
4. Adds a default `lint-staged` block to `package.json` **only if one doesn't already exist**.
|
|
79
79
|
5. Adds a `"prepare": "husky"` npm script if missing, so hooks are (re)installed automatically after `npm install`.
|
|
80
|
-
6. If `react` and `typescript` are both present in your `dependencies`/`devDependencies`, also runs [`add-eslint-react`](#advanced-eslint-module-boundary-template-typescriptreact) automatically. Otherwise it's skipped and you can add it manually later.
|
|
80
|
+
6. If `react` and `typescript` are both present in your `dependencies`/`devDependencies`, also runs [`add-eslint-react`](#advanced-eslint-module-boundary-template-typescriptreact) automatically, which **overwrites** `.eslintrc.js` and `.prettierrc.js` with the latest template. Otherwise it's skipped and you can add it manually later.
|
|
81
81
|
|
|
82
|
-
Re-running `npx commit-sheriff init` later (e.g. after updating the package) is safe: it refreshes the
|
|
82
|
+
Re-running `npx commit-sheriff init` later (e.g. after updating the package) is safe for your project-specific settings: it refreshes the hook scripts and (on react+typescript projects) the ESLint/Prettier templates to the latest version, but leaves your `.commitsheriffrc.json` / `lint-staged` config alone. If you've hand-edited `.eslintrc.js` or `.prettierrc.js`, back them up first — those two get overwritten on every re-run.
|
|
83
83
|
|
|
84
84
|
## Commit message format
|
|
85
85
|
|
|
@@ -162,7 +162,6 @@ Add/edit this file at your project's **root** (next to `package.json`) — the `
|
|
|
162
162
|
],
|
|
163
163
|
"types": [
|
|
164
164
|
"feat",
|
|
165
|
-
"feature",
|
|
166
165
|
"fix",
|
|
167
166
|
"docs",
|
|
168
167
|
"style",
|
|
@@ -219,7 +218,7 @@ Allowed prefixes for **branch names**. This is intentionally a coarser, workflow
|
|
|
219
218
|
|
|
220
219
|
### `types`
|
|
221
220
|
|
|
222
|
-
`string[]`, default: `["feat", "
|
|
221
|
+
`string[]`, default: `["feat", "fix", "docs", "style", "refactor", "test", "chore", "perf", "ci", "build", "revert"]`.
|
|
223
222
|
|
|
224
223
|
Allowed `type` words in **commit messages**, following [Conventional Commits](https://www.conventionalcommits.org/) style.
|
|
225
224
|
|
|
@@ -258,12 +257,18 @@ other through a public barrel file, never through deep/internal paths:
|
|
|
258
257
|
npx commit-sheriff add-eslint-react
|
|
259
258
|
```
|
|
260
259
|
|
|
261
|
-
This copies two templates into your repo root, **
|
|
260
|
+
This copies two templates into your repo root, **always overwriting** whatever is already
|
|
261
|
+
there at those exact filenames (same behavior as the `commit-msg`/`pre-commit` hooks — re-running
|
|
262
|
+
it refreshes both files to the latest version of the template):
|
|
262
263
|
|
|
263
264
|
- `.eslintrc.js` — legacy-format ESLint config (TypeScript + React + a11y + import + sonarjs +
|
|
264
265
|
testing-library/jest/vitest rules) with a module-boundary `no-restricted-imports` rule.
|
|
265
266
|
- `.prettierrc.js` — matching Prettier config.
|
|
266
267
|
|
|
268
|
+
If you've customized either file by hand, back it up under a different name before re-running
|
|
269
|
+
`add-eslint-react` (or `init` on a react+typescript project, which calls it automatically) —
|
|
270
|
+
your edits will be replaced.
|
|
271
|
+
|
|
267
272
|
The module list for the boundary rule isn't hardcoded — it's read straight from the `modules`
|
|
268
273
|
array in your root `.commitsheriffrc.json` (the same list the commit-msg/branch-name hooks use
|
|
269
274
|
for the `[MODULE]` tag), lowercased. For older installs still using `package.json`'s
|
package/bin/commit-sheriff.js
CHANGED
|
@@ -24,7 +24,6 @@ const DEFAULT_COMMIT_GUARD = {
|
|
|
24
24
|
],
|
|
25
25
|
types: [
|
|
26
26
|
"feat",
|
|
27
|
-
"feature",
|
|
28
27
|
"fix",
|
|
29
28
|
"docs",
|
|
30
29
|
"style",
|
|
@@ -162,24 +161,24 @@ const ESLINT_REACT_DEV_DEPS = [
|
|
|
162
161
|
"prettier",
|
|
163
162
|
];
|
|
164
163
|
|
|
165
|
-
function
|
|
164
|
+
function copyTemplateOverwrite(templateName, destName) {
|
|
166
165
|
const src = path.join(__dirname, "..", "templates", templateName);
|
|
167
166
|
const dest = path.join(cwd, destName);
|
|
168
|
-
|
|
169
|
-
console.log(`• ${destName} artıq var, toxunulmadı`);
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
167
|
+
const existed = fs.existsSync(dest);
|
|
172
168
|
fs.copyFileSync(src, dest);
|
|
173
|
-
console.log(`✔ ${destName} yazıldı`);
|
|
169
|
+
console.log(existed ? `✔ ${destName} yeniləndi (üzərinə yazıldı)` : `✔ ${destName} yazıldı`);
|
|
174
170
|
}
|
|
175
171
|
|
|
176
172
|
function addEslintReact() {
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
copyTemplateOverwrite("eslintrc.module-boundaries.js", ".eslintrc.js");
|
|
174
|
+
copyTemplateOverwrite("prettier.module-boundaries.js", ".prettierrc.js");
|
|
179
175
|
console.log(
|
|
180
176
|
"\nBu şablon TypeScript/React + modul-sərhəd (module-boundary) qaydaları üçündür.\n" +
|
|
181
177
|
`Modul siyahısı ${CONFIG_FILE_NAME}.modules-dən avtomatik oxunur (boşdursa nümunə\n` +
|
|
182
178
|
"siyahı istifadə olunur — .eslintrc.js içindəki şərhi oxuyun).\n\n" +
|
|
179
|
+
"Diqqət: .eslintrc.js və .prettierrc.js hər dəfə şablonun ən son versiyası ilə\n" +
|
|
180
|
+
"üzərinə yazılır (commit-msg/pre-commit hook-ları kimi) — özünüzə uyğun etdiyiniz\n" +
|
|
181
|
+
"dəyişiklikləri qorumaq istəsəniz, əvvəlcə fərqli adla backup götürün.\n\n" +
|
|
183
182
|
"Lazımi devDependencies (özünüz quraşdırın, layihənizin real versiyalarına uyğun):\n" +
|
|
184
183
|
` npm install --save-dev ${ESLINT_REACT_DEV_DEPS.join(" ")}\n`,
|
|
185
184
|
);
|
package/package.json
CHANGED
package/templates/commit-msg
CHANGED
|
@@ -21,7 +21,7 @@ eval "$(node -e "
|
|
|
21
21
|
}
|
|
22
22
|
const useModules = cfg.useModules !== undefined ? cfg.useModules : true;
|
|
23
23
|
const modules = (cfg.modules && cfg.modules.length ? cfg.modules.join('|') : '[A-Z]+');
|
|
24
|
-
const types = (cfg.types || ['feat','
|
|
24
|
+
const types = (cfg.types || ['feat','fix','docs','style','refactor','test','chore','perf','ci','build','revert']).join('|');
|
|
25
25
|
console.log('USE_MODULES=' + useModules);
|
|
26
26
|
console.log('MODULES=\"' + modules + '\"');
|
|
27
27
|
console.log('TYPES=\"' + types + '\"');
|