gitverse-release 3.3.1 → 3.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/dist/cli.js CHANGED
@@ -43,14 +43,22 @@ var DEFAULT_CONFIG = {
43
43
  }
44
44
  },
45
45
  commitlint: {
46
+ bodyMaxLineLength: null,
46
47
  comments: true,
48
+ footerMaxLineLength: null,
47
49
  format: "ts",
48
50
  headerMaxLength: 100,
51
+ headerMinLength: null,
49
52
  output: "commitlint.config.ts",
50
53
  scopeRequired: false,
51
- scopes: ["deps", "ci", "docs"]
54
+ scopes: ["deps", "ci", "docs"],
55
+ strictMode: false,
56
+ subjectCase: null,
57
+ subjectFullStop: false,
58
+ warningRules: ["header-max-length"]
52
59
  },
53
60
  git: {
61
+ beforeCommit: "",
54
62
  commitChanges: true,
55
63
  commitMessage: "chore(release): {{package}} v{{version}} [skip ci]",
56
64
  push: true,
@@ -601,9 +609,9 @@ class q3 {
601
609
  }
602
610
 
603
611
  // ../sdk/dist/client.js
604
- var F = { DELETE: "DELETE", GET: "GET", PATCH: "PATCH", POST: "POST", PUT: "PUT" };
612
+ var J2 = { DELETE: "DELETE", GET: "GET", PATCH: "PATCH", POST: "POST", PUT: "PUT" };
605
613
 
606
- class _ {
614
+ class $ {
607
615
  baseUrl;
608
616
  token;
609
617
  apiVersion;
@@ -615,10 +623,11 @@ class _ {
615
623
  this.token = j5;
616
624
  }
617
625
  extractRateLimitInfo(j5) {
618
- let x2 = j5.get("GitVerse-RateLimit-Limit"), q4 = j5.get("GitVerse-RateLimit-Remaining"), z2 = j5.get("GitVerse-RateLimit-Retry-After"), B2 = j5.get("Gitverse-Ratelimit-Reset");
619
- if (!(x2 && q4 && z2 && B2))
626
+ let x2 = j5.get("GitVerse-RateLimit-Limit"), q4 = j5.get("GitVerse-RateLimit-User-Remaining") || j5.get("GitVerse-RateLimit-Remaining"), z2 = j5.get("GitVerse-RateLimit-Retry-After"), B2 = j5.get("Gitverse-Ratelimit-Reset");
627
+ if (!(x2 && z2))
620
628
  return;
621
- return { limit: Number.parseInt(x2, 10), remaining: Number.parseInt(q4, 10), reset: Number.parseInt(B2, 10), retryAfter: Number.parseInt(z2, 10) };
629
+ let K = Number.parseInt(z2, 10), D = B2 ? Number.parseInt(B2, 10) : Math.floor(Date.now() / 1000) + K, U = q4 ? Number.parseInt(q4, 10) : 0;
630
+ return { limit: Number.parseInt(x2, 10), remaining: U, reset: D, retryAfter: K };
622
631
  }
623
632
  extractApiVersionInfo(j5) {
624
633
  let x2 = j5.get("Gitverse-Api-Version"), q4 = j5.get("Gitverse-Api-Latest-Version"), z2 = j5.get("Gitverse-Api-Deprecation") === "true", B2 = j5.get("Gitverse-Api-Decommissioning");
@@ -635,37 +644,37 @@ class _ {
635
644
  return { apiVersion: q4, rateLimit: x2 };
636
645
  }
637
646
  async request(j5, x2, q4, z2) {
638
- let B2 = j5.startsWith("/") ? j5.slice(1) : j5, Y = `${this.baseUrl}/${B2}`, J2 = new Headers;
639
- if (J2.set("Content-Type", "application/json"), J2.set("Accept", `application/vnd.gitverse.object+json; version=${this.apiVersion}`), this.token)
640
- J2.set("Authorization", `Bearer ${this.token}`);
641
- let Z = { body: q4 ? JSON.stringify(q4) : undefined, headers: J2, method: x2, signal: z2?.signal }, D = await fetch(Y, Z), K = this.extractMetadata(D.headers), N;
647
+ let B2 = j5.startsWith("/") ? j5.slice(1) : j5, K = `${this.baseUrl}/${B2}`, D = new Headers;
648
+ if (D.set("Content-Type", "application/json"), D.set("Accept", `application/vnd.gitverse.object+json; version=${this.apiVersion}`), this.token)
649
+ D.set("Authorization", `Bearer ${this.token}`);
650
+ let U = { body: q4 ? JSON.stringify(q4) : undefined, headers: D, method: x2, signal: z2?.signal }, F = await fetch(K, U), Q = this.extractMetadata(F.headers), S;
642
651
  try {
643
- N = await D.json();
652
+ S = await F.json();
644
653
  } catch {
645
- N = undefined;
654
+ S = undefined;
646
655
  }
647
- if (!D.ok) {
648
- let Q = N?.message || D.statusText;
649
- if (D.status === 429 && K.rateLimit)
650
- throw new k2(Q || "Превышен лимит запросов. Попробуйте позже.", K.rateLimit, K);
651
- throw new j2(D.status, Q, K);
656
+ if (!F.ok) {
657
+ let X = S?.message || F.statusText;
658
+ if (F.status === 429 && Q.rateLimit)
659
+ throw new k2(X || "Превышен лимит запросов. Попробуйте позже.", Q.rateLimit, Q);
660
+ throw new j2(F.status, X, Q);
652
661
  }
653
- return N;
662
+ return S;
654
663
  }
655
664
  get(j5, x2) {
656
- return this.request(j5, F.GET, undefined, x2);
665
+ return this.request(j5, J2.GET, undefined, x2);
657
666
  }
658
667
  post(j5, x2, q4) {
659
- return this.request(j5, F.POST, x2, q4);
668
+ return this.request(j5, J2.POST, x2, q4);
660
669
  }
661
670
  put(j5, x2, q4) {
662
- return this.request(j5, F.PUT, x2, q4);
671
+ return this.request(j5, J2.PUT, x2, q4);
663
672
  }
664
673
  delete(j5, x2, q4) {
665
- return this.request(j5, F.DELETE, x2, q4);
674
+ return this.request(j5, J2.DELETE, x2, q4);
666
675
  }
667
676
  patch(j5, x2, q4) {
668
- return this.request(j5, F.PATCH, x2, q4);
677
+ return this.request(j5, J2.PATCH, x2, q4);
669
678
  }
670
679
  }
671
680
 
@@ -720,7 +729,7 @@ class Z {
720
729
  git;
721
730
  actions;
722
731
  constructor(d2 = {}) {
723
- this.client = new _(d2), this.users = new f(this.client), this.repos = new A(this.client), this.contents = new k4(this.client), this.pulls = new y(this.client), this.forks = new q3(this.client), this.emails = new d(this.client), this.issues = new B(this.client), this.stars = new k3(this.client), this.branches = new g(this.client), this.commits = new j(this.client), this.collaborators = new j3(this.client), this.organizations = new k(this.client), this.teams = new k5(this.client), this.releases = new q2(this.client), this.git = new j4(this.client), this.actions = new x(this.client);
732
+ this.client = new $(d2), this.users = new f(this.client), this.repos = new A(this.client), this.contents = new k4(this.client), this.pulls = new y(this.client), this.forks = new q3(this.client), this.emails = new d(this.client), this.issues = new B(this.client), this.stars = new k3(this.client), this.branches = new g(this.client), this.commits = new j(this.client), this.collaborators = new j3(this.client), this.organizations = new k(this.client), this.teams = new k5(this.client), this.releases = new q2(this.client), this.git = new j4(this.client), this.actions = new x(this.client);
724
733
  }
725
734
  setToken(d2) {
726
735
  return this.client.setToken(d2), this;
@@ -843,6 +852,12 @@ function groupCommitsByType(commits) {
843
852
  }
844
853
  return groups;
845
854
  }
855
+ function filterCommitsForPackage(commits, packageName, isMonorepo) {
856
+ if (!isMonorepo) {
857
+ return commits;
858
+ }
859
+ return commits.filter((commit) => !commit.scope || commit.scope === packageName);
860
+ }
846
861
  function hasBreakingChanges(commits) {
847
862
  return commits.some((commit) => commit.breaking);
848
863
  }
@@ -1378,13 +1393,13 @@ async function updatePackageFiles(pkg, newVersion, changelogEntry) {
1378
1393
  await updateChangelogFile(changelogPath, changelogEntry);
1379
1394
  return changelogPath;
1380
1395
  }
1381
- async function collectCommits(pkg, options, warnings) {
1396
+ async function collectCommits(pkg, options, warnings, isMonorepo) {
1382
1397
  const rawCommits = await getCommitsSinceTag(pkg.tagPrefix, pkg.path);
1383
1398
  if (rawCommits.length === 0 && !options.version) {
1384
1399
  throw new Error(`No commits found since last release for ${pkg.packageName}`);
1385
1400
  }
1386
1401
  const commits = parseCommits(rawCommits);
1387
- const filteredCommits = commits.filter((commit) => !commit.scope || commit.scope === pkg.name);
1402
+ const filteredCommits = filterCommitsForPackage(commits, pkg.name, isMonorepo);
1388
1403
  if (filteredCommits.length === 0 && !options.version) {
1389
1404
  warnings.push("No conventional commits found, but will proceed with patch bump");
1390
1405
  }
@@ -1457,7 +1472,7 @@ async function release(packageName, options = {}) {
1457
1472
  }
1458
1473
  const currentVersion = await getCurrentVersion(pkg.path);
1459
1474
  result.oldVersion = currentVersion;
1460
- const commits = await collectCommits(pkg, options, result.warnings);
1475
+ const commits = await collectCommits(pkg, options, result.warnings, config.monorepo.enabled);
1461
1476
  const prereleaseTag = resolvePrereleaseTag(options, config);
1462
1477
  const versionBump = calculateVersionBump(currentVersion, commits, options.version, prereleaseTag, config.versioning.preMajorMode);
1463
1478
  result.newVersion = versionBump.newVersion;
@@ -1587,38 +1602,86 @@ import { parseArgs } from "node:util";
1587
1602
  // src/utils/commitlint-generator.ts
1588
1603
  import { writeFile as writeFile2 } from "node:fs/promises";
1589
1604
  async function generateCommitlint(config, options = {}) {
1605
+ const generatorOptions = parseGeneratorOptions(options);
1606
+ const rules = buildCommitlintRules(config, options);
1607
+ const configContent = generateConfigContent(rules, generatorOptions.format, generatorOptions.comments);
1608
+ if (generatorOptions.verbose) {
1609
+ printVerboseOutput(rules, options);
1610
+ }
1611
+ if (generatorOptions.dryRun) {
1612
+ printDryRunOutput(configContent, generatorOptions.output);
1613
+ return;
1614
+ }
1615
+ await writeFile2(generatorOptions.output, configContent);
1616
+ console.log(`✅ Generated commitlint config: ${generatorOptions.output}`);
1617
+ }
1618
+ function parseGeneratorOptions(options) {
1619
+ return {
1620
+ comments: options.comments ?? true,
1621
+ dryRun: options.dryRun ?? false,
1622
+ format: options.format ?? "ts",
1623
+ output: options.output ?? "commitlint.config.ts",
1624
+ verbose: options.verbose ?? false
1625
+ };
1626
+ }
1627
+ function buildCommitlintRules(config, options) {
1590
1628
  const {
1591
- output = "commitlint.config.ts",
1592
- format = "ts",
1593
- scopes,
1594
- scopeRequired = false,
1629
+ bodyMaxLineLength = null,
1630
+ footerMaxLineLength = null,
1595
1631
  headerMaxLength = 100,
1596
- comments = true,
1597
- dryRun = false,
1598
- verbose = false
1632
+ headerMinLength = null,
1633
+ scopeRequired = false,
1634
+ scopes,
1635
+ strictMode = false,
1636
+ subjectCase = null,
1637
+ subjectFullStop = false,
1638
+ warningRules = ["header-max-length"]
1599
1639
  } = options;
1600
1640
  const commitTypes = extractCommitTypes(config);
1601
1641
  const commitScopes = extractCommitScopes(config, scopes);
1602
- const configContent = generateConfigContent(commitTypes, commitScopes, { headerMaxLength, scopeRequired }, format, comments);
1603
- if (verbose) {
1604
- console.log(`
1642
+ return {
1643
+ bodyMaxLineLength: strictMode ? bodyMaxLineLength ?? 100 : bodyMaxLineLength,
1644
+ footerMaxLineLength: strictMode ? footerMaxLineLength ?? 100 : footerMaxLineLength,
1645
+ headerMaxLength,
1646
+ headerMinLength,
1647
+ scopeRequired,
1648
+ scopes: commitScopes,
1649
+ strictMode,
1650
+ subjectCase: strictMode ? "lower-case" : subjectCase,
1651
+ subjectFullStop,
1652
+ types: commitTypes,
1653
+ warningRules: strictMode ? [] : warningRules
1654
+ };
1655
+ }
1656
+ function printVerboseOutput(rules, options) {
1657
+ console.log(`
1605
1658
  \uD83D\uDCCA Configuration:`);
1606
- console.log(` Types: ${commitTypes.join(", ")}`);
1607
- console.log(` Scopes: ${commitScopes.join(", ")}`);
1608
- console.log(` Scope required: ${scopeRequired}`);
1609
- console.log(` Header max length: ${headerMaxLength}`);
1610
- }
1611
- if (dryRun) {
1612
- console.log(`
1659
+ console.log(` Types: ${rules.types.join(", ")}`);
1660
+ console.log(` Scopes: ${rules.scopes.join(", ")}`);
1661
+ console.log(` Scope required: ${rules.scopeRequired}`);
1662
+ console.log(` Header max length: ${rules.headerMaxLength}`);
1663
+ if (rules.headerMinLength)
1664
+ console.log(` Header min length: ${rules.headerMinLength}`);
1665
+ if (rules.subjectCase)
1666
+ console.log(` Subject case: ${rules.subjectCase}`);
1667
+ if (options.subjectFullStop)
1668
+ console.log(" Subject full stop: forbidden");
1669
+ if (rules.bodyMaxLineLength)
1670
+ console.log(` Body max line length: ${rules.bodyMaxLineLength}`);
1671
+ if (rules.footerMaxLineLength)
1672
+ console.log(` Footer max line length: ${rules.footerMaxLineLength}`);
1673
+ if (options.strictMode)
1674
+ console.log(" Strict mode: enabled");
1675
+ if (rules.warningRules.length > 0)
1676
+ console.log(` Warning rules: ${rules.warningRules.join(", ")}`);
1677
+ }
1678
+ function printDryRunOutput(configContent, output) {
1679
+ console.log(`
1613
1680
  \uD83D\uDD0D Dry-run mode - Preview of generated config:
1614
1681
  `);
1615
- console.log(configContent);
1616
- console.log(`
1682
+ console.log(configContent);
1683
+ console.log(`
1617
1684
  \uD83D\uDCDD Would write to: ${output}`);
1618
- return;
1619
- }
1620
- await writeFile2(output, configContent);
1621
- console.log(`✅ Generated commitlint config: ${output}`);
1622
1685
  }
1623
1686
  function extractCommitTypes(config) {
1624
1687
  return Object.keys(config.changelog.types);
@@ -1635,12 +1698,99 @@ function extractCommitScopes(config, additionalScopes) {
1635
1698
  }
1636
1699
  return [...new Set(scopes)].sort();
1637
1700
  }
1638
- function generateConfigContent(types2, scopes, rules, format, comments) {
1701
+ function getRuleLevel(ruleName, warningRules, strictMode) {
1702
+ if (strictMode)
1703
+ return 2;
1704
+ return warningRules.includes(ruleName) ? 1 : 2;
1705
+ }
1706
+ function buildRulesObject(rules) {
1707
+ const { strictMode, warningRules } = rules;
1708
+ const result = {};
1709
+ result["type-enum"] = [2, "always", rules.types];
1710
+ result["type-empty"] = [2, "never"];
1711
+ if (rules.scopes.length > 0) {
1712
+ result["scope-enum"] = [2, "always", rules.scopes];
1713
+ }
1714
+ result["scope-empty"] = rules.scopeRequired ? [2, "never"] : [0];
1715
+ result["subject-case"] = rules.subjectCase ? [getRuleLevel("subject-case", warningRules, strictMode), "always", rules.subjectCase] : [0];
1716
+ result["subject-empty"] = [2, "never"];
1717
+ if (rules.subjectFullStop) {
1718
+ result["subject-full-stop"] = [getRuleLevel("subject-full-stop", warningRules, strictMode), "never", "."];
1719
+ }
1720
+ result["header-max-length"] = [
1721
+ getRuleLevel("header-max-length", warningRules, strictMode),
1722
+ "always",
1723
+ rules.headerMaxLength
1724
+ ];
1725
+ if (rules.headerMinLength) {
1726
+ result["header-min-length"] = [
1727
+ getRuleLevel("header-min-length", warningRules, strictMode),
1728
+ "always",
1729
+ rules.headerMinLength
1730
+ ];
1731
+ }
1732
+ result["body-leading-blank"] = [2, "always"];
1733
+ result["footer-leading-blank"] = [2, "always"];
1734
+ if (rules.bodyMaxLineLength) {
1735
+ result["body-max-line-length"] = [
1736
+ getRuleLevel("body-max-line-length", warningRules, strictMode),
1737
+ "always",
1738
+ rules.bodyMaxLineLength
1739
+ ];
1740
+ }
1741
+ if (rules.footerMaxLineLength) {
1742
+ result["footer-max-line-length"] = [
1743
+ getRuleLevel("footer-max-line-length", warningRules, strictMode),
1744
+ "always",
1745
+ rules.footerMaxLineLength
1746
+ ];
1747
+ }
1748
+ return result;
1749
+ }
1750
+ function formatRuleValue(value) {
1751
+ if (value.length === 1) {
1752
+ return `[${value[0]}]`;
1753
+ }
1754
+ if (value.length === 2) {
1755
+ return `[${value[0]}, "${value[1]}"]`;
1756
+ }
1757
+ const thirdArg = typeof value[2] === "string" ? `"${value[2]}"` : JSON.stringify(value[2]);
1758
+ return `[${value[0]}, "${value[1]}", ${thirdArg}]`;
1759
+ }
1760
+ function generateRuleComment(ruleName, rules) {
1761
+ const { strictMode, warningRules } = rules;
1762
+ if (ruleName === "scope-empty") {
1763
+ return rules.scopeRequired ? " // scope required" : " // scope optional";
1764
+ }
1765
+ if (ruleName === "subject-case" && !rules.subjectCase) {
1766
+ return " // disabled - any case allowed";
1767
+ }
1768
+ if (!strictMode && warningRules.includes(ruleName)) {
1769
+ return " // warning";
1770
+ }
1771
+ return "";
1772
+ }
1773
+ var RULE_ORDER = [
1774
+ "type-enum",
1775
+ "type-empty",
1776
+ "scope-enum",
1777
+ "scope-empty",
1778
+ "subject-case",
1779
+ "subject-empty",
1780
+ "subject-full-stop",
1781
+ "header-max-length",
1782
+ "header-min-length",
1783
+ "body-leading-blank",
1784
+ "body-max-line-length",
1785
+ "footer-leading-blank",
1786
+ "footer-max-line-length"
1787
+ ];
1788
+ function generateConfigContent(rules, format, comments) {
1789
+ const rulesObject = buildRulesObject(rules);
1639
1790
  if (format === "json") {
1640
- return generateJSONConfig(types2, scopes, rules);
1791
+ return generateJSONConfig(rulesObject);
1641
1792
  }
1642
1793
  const isTS = format === "ts";
1643
- const _ext = isTS ? "ts" : "js";
1644
1794
  const header = comments ? `// AUTO-GENERATED by gitverse-release
1645
1795
  // Run: gitverse-release generate-commitlint
1646
1796
  // DO NOT EDIT MANUALLY - Changes will be overwritten
@@ -1650,26 +1800,20 @@ function generateConfigContent(types2, scopes, rules, format, comments) {
1650
1800
 
1651
1801
  ` : "";
1652
1802
  const configDeclaration = isTS ? "const config: UserConfig = " : "const config = ";
1653
- const typesComment = comments ? ` // Types from release config
1654
- ` : "";
1655
- const scopesComment = comments ? ` // Scopes from release config
1656
- ` : "";
1657
- const scopeEmptyRule = rules.scopeRequired ? ` "scope-empty": [2, "never"], // scope required
1658
- ` : ` "scope-empty": [0], // scope optional
1659
- `;
1803
+ const rulesLines = [];
1804
+ for (const ruleName of RULE_ORDER) {
1805
+ const value = rulesObject[ruleName];
1806
+ if (!value)
1807
+ continue;
1808
+ const comment = comments ? generateRuleComment(ruleName, rules) : "";
1809
+ rulesLines.push(` "${ruleName}": ${formatRuleValue(value)},${comment}`);
1810
+ }
1660
1811
  const content = `${header}${typeImport}${configDeclaration}{
1661
1812
  extends: ["@commitlint/config-conventional"],
1662
1813
 
1663
1814
  rules: {
1664
- ${typesComment} "type-enum": [2, "always", ${JSON.stringify(types2)}],
1665
-
1666
- ${scopesComment} "scope-enum": [2, "always", ${JSON.stringify(scopes)}],
1667
- ${scopeEmptyRule}
1668
- "subject-case": [2, "always", "lower-case"],
1669
- "subject-empty": [2, "never"],
1670
- "header-max-length": [2, "always", ${rules.headerMaxLength}],
1671
- "body-leading-blank": [2, "always"],
1672
- "footer-leading-blank": [2, "always"],
1815
+ ${rulesLines.join(`
1816
+ `)}
1673
1817
  },
1674
1818
  };
1675
1819
 
@@ -1677,19 +1821,10 @@ ${isTS ? "export default config;" : "module.exports = config;"}
1677
1821
  `;
1678
1822
  return content;
1679
1823
  }
1680
- function generateJSONConfig(types2, scopes, rules) {
1824
+ function generateJSONConfig(rulesObject) {
1681
1825
  const config = {
1682
1826
  extends: ["@commitlint/config-conventional"],
1683
- rules: {
1684
- "body-leading-blank": [2, "always"],
1685
- "footer-leading-blank": [2, "always"],
1686
- "header-max-length": [2, "always", rules.headerMaxLength],
1687
- "scope-empty": rules.scopeRequired ? [2, "never"] : [0],
1688
- "scope-enum": [2, "always", scopes],
1689
- "subject-case": [2, "always", "lower-case"],
1690
- "subject-empty": [2, "never"],
1691
- "type-enum": [2, "always", types2]
1692
- }
1827
+ rules: rulesObject
1693
1828
  };
1694
1829
  return JSON.stringify(config, null, 2);
1695
1830
  }
@@ -1881,4 +2016,4 @@ Usage: gitverse-release create-only --tag <tag> [--package <name>]`);
1881
2016
  }
1882
2017
  main();
1883
2018
 
1884
- //# debugId=CBF028718EBEA1DE64756E2164756E21
2019
+ //# debugId=9B8009A65470B6BB64756E2164756E21