@itcase/config 1.6.64 → 1.6.65

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
@@ -93,7 +93,7 @@ npm install --save-dev commitizen @commitlint/cz-commitlint
93
93
  .husky/_run.sh
94
94
  ```
95
95
 
96
- Скрипт не трогает `.husky` самого `@itcase/config` и репы без обёрток. `npm i --ignore-scripts` файл не создаст.
96
+ Репы без обёрток скрипт не трогает. `npm i --ignore-scripts` файл не создаст.
97
97
 
98
98
  В каждом git-hook оставьте обёртку:
99
99
 
@@ -41,10 +41,10 @@ itcase_export_release_branch_env() {
41
41
  fi
42
42
  }
43
43
 
44
- itcase_has_conflict_markers() {
45
- git grep -I --untracked --exclude-standard \
44
+ itcase_conflict_marker_files() {
45
+ git grep -lI --untracked --exclude-standard \
46
46
  -e '^<<<<<<< ' -e '^=======$' -e '^>>>>>>> ' \
47
- -- . ':!node_modules' ':!dist' >/dev/null 2>&1
47
+ -- . ':!node_modules' ':!dist' 2>/dev/null
48
48
  }
49
49
 
50
50
  itcase_run_lint_staged() {
@@ -9,8 +9,9 @@ fi
9
9
 
10
10
  ROOT="$(CDPATH= cd -- "$HUSKY_DIR/.." && pwd)"
11
11
  for candidate in \
12
- "$ROOT/node_modules/@itcase/config/husky-hooks/run.cjs" \
13
- "$ROOT/../itcase-config/husky-hooks/run.cjs"
12
+ "$ROOT/husky-hooks/run.js" \
13
+ "$ROOT/node_modules/@itcase/config/husky-hooks/run.js" \
14
+ "$ROOT/../itcase-config/husky-hooks/run.js"
14
15
  do
15
16
  if [ -f "$candidate" ]; then
16
17
  exec node "$candidate" "$HOOK_NAME" "$@"
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Copies husky-hooks/_run.sh into the consumer .husky/ on install.
4
- * Skips @itcase/config itself and repos that do not use the wrappers.
3
+ * Copies husky-hooks/_run.sh into the project .husky/ on install.
4
+ * Skips repos that do not use the wrappers.
5
5
  */
6
- const fs = require('node:fs')
7
- const path = require('node:path')
6
+ import fs from 'node:fs'
7
+ import path from 'node:path'
8
8
 
9
9
  const GIT_HOOKS = [
10
10
  'pre-commit',
@@ -36,14 +36,6 @@ function projectRoot() {
36
36
  return cwd
37
37
  }
38
38
 
39
- function packageName(root) {
40
- try {
41
- return JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')).name
42
- } catch {
43
- return ''
44
- }
45
- }
46
-
47
39
  function usesItcaseHooks(huskyDir) {
48
40
  if (fs.existsSync(path.join(huskyDir, '_run.sh'))) {
49
41
  return true
@@ -60,16 +52,12 @@ function usesItcaseHooks(huskyDir) {
60
52
  }
61
53
 
62
54
  const root = projectRoot()
63
- if (packageName(root) === '@itcase/config') {
64
- process.exit(0)
65
- }
66
-
67
55
  const huskyDir = path.join(root, '.husky')
68
56
  if (!fs.existsSync(huskyDir) || !usesItcaseHooks(huskyDir)) {
69
57
  process.exit(0)
70
58
  }
71
59
 
72
- const src = path.join(__dirname, '_run.sh')
60
+ const src = path.join(import.meta.dirname, '_run.sh')
73
61
  const dest = path.join(huskyDir, '_run.sh')
74
62
  fs.copyFileSync(src, dest)
75
63
  try {
@@ -28,8 +28,9 @@ if [ -n "${PROTECTED_BRANCHES:-}" ]; then
28
28
  fi
29
29
 
30
30
  # Проверка на конфликты слияния
31
- if itcase_has_conflict_markers; then
31
+ if conflict_files="$(itcase_conflict_marker_files)"; then
32
32
  echo 'Fix conflicts'
33
+ printf '%s\n' "$conflict_files" | sed 's/^/ /'
33
34
  exit 1
34
35
  fi
35
36
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- const { spawnSync } = require('node:child_process')
3
- const fs = require('node:fs')
4
- const path = require('node:path')
2
+ import { spawnSync } from 'node:child_process'
3
+ import fs from 'node:fs'
4
+ import path from 'node:path'
5
5
 
6
6
  const ALLOWED_HOOKS = new Set([
7
7
  'pre-commit',
@@ -17,14 +17,18 @@ const hookName = process.argv[2]
17
17
  const hookArgs = process.argv.slice(3)
18
18
 
19
19
  if (!hookName || !ALLOWED_HOOKS.has(hookName)) {
20
- process.stderr.write('Usage: itcase-config-husky-hooks <hook-name> [args...]\n')
20
+ process.stderr.write(
21
+ 'Usage: itcase-config-husky-hooks <hook-name> [args...]\n',
22
+ )
21
23
  process.exit(1)
22
24
  }
23
25
 
24
- const hookScript = path.join(__dirname, hookName)
26
+ const hookScript = path.join(import.meta.dirname, hookName)
25
27
 
26
28
  if (!fs.existsSync(hookScript)) {
27
- process.stderr.write(`❌ Husky hook '${hookName}' not found in @itcase/config.\n`)
29
+ process.stderr.write(
30
+ `❌ Husky hook '${hookName}' not found in @itcase/config.\n`,
31
+ )
28
32
  process.stderr.write(` Expected: ${hookScript}\n`)
29
33
  process.exit(1)
30
34
  }
@@ -35,7 +39,8 @@ function resolveBash() {
35
39
  }
36
40
 
37
41
  const candidates = [
38
- process.env.PROGRAMFILES && path.join(process.env.PROGRAMFILES, 'Git', 'bin', 'bash.exe'),
42
+ process.env.PROGRAMFILES &&
43
+ path.join(process.env.PROGRAMFILES, 'Git', 'bin', 'bash.exe'),
39
44
  process.env['PROGRAMFILES(X86)'] &&
40
45
  path.join(process.env['PROGRAMFILES(X86)'], 'Git', 'bin', 'bash.exe'),
41
46
  'C:\\Program Files\\Git\\bin\\bash.exe',
@@ -51,8 +56,8 @@ function resolveBash() {
51
56
  }
52
57
 
53
58
  const result = spawnSync(resolveBash(), [hookScript, ...hookArgs], {
54
- stdio: 'inherit',
55
59
  env: { ...process.env, HUSKY_DIR: process.env.HUSKY_DIR || '' },
60
+ stdio: 'inherit',
56
61
  })
57
62
 
58
63
  if (result.error) {
@@ -10,7 +10,7 @@ export default {
10
10
  // Проверяем, есть ли package.json в корне репозитория
11
11
  const rootPackageJson = resolve(process.cwd(), 'package.json')
12
12
  if (existsSync(rootPackageJson) && files.includes(rootPackageJson)) {
13
- return ['npm install --package-lock-only', 'git add package-lock.json']
13
+ return 'npm install --package-lock-only'
14
14
  }
15
15
  return 'true' // Пропускаем, если не найден
16
16
  },
@@ -18,7 +18,7 @@ export default {
18
18
  // Проверяем, есть ли package.json в корне репозитория
19
19
  const rootPackageJson = resolve(process.cwd(), 'package.json')
20
20
  if (existsSync(rootPackageJson) && files.includes(rootPackageJson)) {
21
- return ['npm install --package-lock-only', 'git add package-lock.json']
21
+ return 'npm install --package-lock-only'
22
22
  }
23
23
  return 'true' // Пропускаем, если не найден
24
24
  },
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@itcase/config",
3
- "version": "1.6.64",
3
+ "version": "1.6.65",
4
4
  "author": "ITCase",
5
5
  "description": "ITCase Config",
6
6
  "engines": {
7
7
  "node": ">=22.0.0"
8
8
  },
9
9
  "bin": {
10
- "itcase-config-husky-hooks": "./husky-hooks/run.cjs"
10
+ "itcase-config-husky-hooks": "./husky-hooks/run.js"
11
11
  },
12
12
  "scripts": {
13
13
  "prepare": "husky",
14
- "postinstall": "node ./husky-hooks/install-launcher.cjs",
14
+ "postinstall": "node ./husky-hooks/install-launcher.js",
15
15
  "semantic-release": "semantic-release"
16
16
  },
17
17
  "type": "module",