@itcase/config 1.7.12 → 1.7.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/config",
3
- "version": "1.7.12",
3
+ "version": "1.7.14",
4
4
  "author": "ITCase",
5
5
  "description": "ITCase Config",
6
6
  "engines": {
@@ -68,8 +68,8 @@
68
68
  "commitizen": "^4.3.2",
69
69
  "conventional-changelog-conventionalcommits": "9.3.1",
70
70
  "conventional-changelog-writer": "9.2.1",
71
- "cssnano": "^9.1.0",
72
- "cssnano-preset-default": "^9.1.0",
71
+ "cssnano": "^9.1.1",
72
+ "cssnano-preset-default": "^9.1.1",
73
73
  "inquirer": "^14.2.2",
74
74
  "log-update": "^8.0.0",
75
75
  "postcss": "^8.5.28",
@@ -12,6 +12,24 @@ import { releaseNotesGeneratorConfig } from './common.js'
12
12
  // Writer 8, который semantic-release поднимает в корень монорепозитория,
13
13
  // для preset 10 печатает только заголовок версии.
14
14
 
15
+ function resolveRelativeEntry(packageJson) {
16
+ const exportEntry = packageJson.exports
17
+
18
+ // conventional-changelog-conventionalcommits@9 объявляет exports строкой.
19
+ if (typeof exportEntry === 'string') {
20
+ return exportEntry
21
+ }
22
+
23
+ const dotExport = exportEntry?.['.']
24
+
25
+ return (
26
+ exportEntry?.import ||
27
+ (typeof dotExport === 'string' ? dotExport : dotExport?.import) ||
28
+ packageJson.module ||
29
+ packageJson.main
30
+ )
31
+ }
32
+
15
33
  function resolvePackageEntry(cwd, packageName) {
16
34
  let directory = cwd
17
35
 
@@ -21,12 +39,13 @@ function resolvePackageEntry(cwd, packageName) {
21
39
 
22
40
  if (existsSync(packageJsonPath)) {
23
41
  const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
24
- const exportEntry = packageJson.exports
25
- const relativeEntry =
26
- exportEntry?.import ||
27
- exportEntry?.['.']?.import ||
28
- packageJson.module ||
29
- packageJson.main
42
+ const relativeEntry = resolveRelativeEntry(packageJson)
43
+
44
+ if (typeof relativeEntry !== 'string') {
45
+ throw new Error(
46
+ `Cannot resolve entry of "${packageName}" from "${packageJsonPath}"`,
47
+ )
48
+ }
30
49
 
31
50
  return pathToFileURL(join(packageDir, relativeEntry)).href
32
51
  }
@@ -420,6 +420,7 @@ function buildPrompt(scopes, types, files, cwd, type) {
420
420
 
421
421
  return `Plan git commits. Do not edit files or run git commit.
422
422
  Return ONLY JSON: {"commits":[{"message":"type(scope): subject","files":["a.ts"]}]}
423
+ Every message must be type(scope): subject. Put a scope from the list in parentheses, including when the type is "other".
423
424
  Types: ${types.join(', ')}
424
425
  Scopes (exact): ${buildScopeEnum(scopes).join(', ')}
425
426
  Subject rules:
@@ -1319,16 +1320,18 @@ async function validateAndNormalizePlans(cwd, plans, scopes, types) {
1319
1320
  report.errors?.map((error) => error.message).join('; ') || 'invalid'
1320
1321
  throw new Error(
1321
1322
  `Commit message failed commitlint:\n ${plan.message}\n ${errors}\n` +
1322
- 'Use lower-case subject without camelCase (e.g. "public dir" not "publicDir").',
1323
+ 'Use type(scope): subject. Scope in parentheses is required. Subject is lower-case without camelCase (e.g. "public dir" not "publicDir").',
1323
1324
  )
1324
1325
  }
1325
1326
  }
1326
1327
 
1327
1328
  function repairCommitHeader(message, scopes, types) {
1328
- const match = String(message || '').match(/^(\w+)\(([^)]+)\):\s*(.+)$/)
1329
+ const match = String(message || '')
1330
+ .trim()
1331
+ .match(/^(\w+)(?:\(([^)]*)\))?:\s*(.+)$/)
1329
1332
  if (!match) return message
1330
1333
 
1331
- let [, type, scope, subject] = match
1334
+ let [, type, rawScope, subject] = match
1332
1335
  const scopeEnum = buildScopeEnum(scopes)
1333
1336
  if (types.length && !types.includes(type)) {
1334
1337
  if (types.includes('chore')) type = 'chore'
@@ -1336,9 +1339,8 @@ function repairCommitHeader(message, scopes, types) {
1336
1339
  else type = types[0]
1337
1340
  }
1338
1341
 
1339
- const matchedScope = matchScope(scope, scopeEnum)
1340
- if (matchedScope) scope = matchedScope
1341
- else scope = pickScope(scopes, ['other'])
1342
+ const matchedScope = matchScope((rawScope || '').trim(), scopeEnum)
1343
+ const scope = matchedScope || pickScope(scopes, ['other'])
1342
1344
 
1343
1345
  return normalizeCommitSubject(`${type}(${scope}): ${subject}`)
1344
1346
  }