@7n/rules 1.40.0 → 1.40.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.40.1] - 2026-07-22
4
+
5
+ ### Fixed
6
+
7
+ - `lint --full`: загублений `await` перед `ensureRunningInWorktree` ламав кожен прогін (у т.ч. зсередини `.worktrees/`) з `TypeError [ERR_INVALID_ARG_TYPE]`; заодно — guard проти видалення auto-created worktree при частковому провалі перенесення змін назад, і stack trace для programmer-помилок у top-level catch
8
+
3
9
  ## [1.40.0] - 2026-07-22
4
10
 
5
11
  ### Changed
package/bin/n-rules.js CHANGED
@@ -1848,7 +1848,7 @@ try {
1848
1848
  // дереві задачі, worktree-ізоляція зламала б саму суть дельти) — пропускаємо.
1849
1849
  const needsWorktreeIsolation = full && !noFix
1850
1850
  const worktree = needsWorktreeIsolation
1851
- ? ensureRunningInWorktree(cwdArg, spawnSync, line => console.log(line), {
1851
+ ? await ensureRunningInWorktree(cwdArg, spawnSync, line => console.log(line), {
1852
1852
  suffix: 'lint',
1853
1853
  description: 'n-rules lint --full: worktree-only full-repo run'
1854
1854
  })
@@ -1881,14 +1881,26 @@ try {
1881
1881
  } finally {
1882
1882
  // Лише для АВТОстворених worktree (лінт уже сидів у своєму — не наш, не чіпаємо).
1883
1883
  if (worktree.autoCreated) {
1884
+ let bringBackFailed = true
1884
1885
  try {
1885
- await bringChangesBackToOriginal(runCwd, cwdArg, spawnSync, line => console.log(line))
1886
+ const bringBackResult = await bringChangesBackToOriginal(runCwd, cwdArg, spawnSync, line =>
1887
+ console.log(line)
1888
+ )
1889
+ bringBackFailed = bringBackResult.failed
1886
1890
  } catch (error) {
1887
1891
  console.log(
1888
1892
  `⚠️ Перенесення змін назад провалилось: ${error instanceof Error ? error.message : String(error)}`
1889
1893
  )
1890
1894
  }
1891
- removeAutoCreatedWorktree(worktree.branchArg, cwdArg, spawnSync, line => console.log(line))
1895
+ // Прибираємо worktree лише якщо перенесення точно вдалось — інакше
1896
+ // не перенесені зміни згорять разом з деревом.
1897
+ if (bringBackFailed) {
1898
+ console.log(
1899
+ `⚠️ Перенесення назад не підтверджено — worktree "${worktree.branchArg}" лишається для ручного розбору.`
1900
+ )
1901
+ } else {
1902
+ removeAutoCreatedWorktree(worktree.branchArg, cwdArg, spawnSync, line => console.log(line))
1903
+ }
1892
1904
  }
1893
1905
  }
1894
1906
 
@@ -1964,8 +1976,15 @@ try {
1964
1976
  }
1965
1977
  }
1966
1978
  } catch (error) {
1979
+ // TypeError/RangeError/ReferenceError сигналять баг у самому коді (не навмисне
1980
+ // user-facing повідомлення) — друкуємо stack одразу, інакше діагностика вимагає
1981
+ // патчити node_modules вручну (як під час діагностики цього ж класу вад).
1982
+ const isProgrammerError = error instanceof TypeError || error instanceof RangeError || error instanceof ReferenceError
1967
1983
  if (error instanceof ReexecHandoff) {
1968
1984
  process.exitCode = error.code
1985
+ } else if (isProgrammerError && error.stack) {
1986
+ console.error(error.stack)
1987
+ process.exitCode = 1
1969
1988
  } else if (error instanceof Error && error.message) {
1970
1989
  console.error(error.message)
1971
1990
  process.exitCode = 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@7n/rules",
3
- "version": "1.40.0",
3
+ "version": "1.40.1",
4
4
  "description": "CLI еталонних правил і skills (префікс n-): синк у репозиторій, дельта-lint, конформність",
5
5
  "keywords": [
6
6
  "cli",