@oorabona/release-it-preset 0.10.0 → 0.11.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 CHANGED
@@ -660,6 +660,7 @@ Customize behavior with environment variables:
660
660
 
661
661
  ### Changelog
662
662
  - `CHANGELOG_FILE` - Changelog file path (default: `CHANGELOG.md`)
663
+ - `GIT_CHANGELOG_PATH` - Optional. When set to a repository-relative path (e.g. `packages/tar-xz`), restrict changelog generation to commits touching that path. Useful for monorepo per-package CHANGELOG files. Empty / unset = repository-wide (default).
663
664
 
664
665
  ### Git
665
666
  - `GIT_COMMIT_MESSAGE` - Commit message template (default: `release: bump v${version}`)
@@ -678,6 +679,7 @@ Customize behavior with environment variables:
678
679
  - `NPM_PUBLISH` - Enable npm publishing (default: `false`)
679
680
  - `NPM_SKIP_CHECKS` - Skip npm checks (default: `false`)
680
681
  - `NPM_ACCESS` - npm access level (default: `public`)
682
+ - `NPM_TAG` - Optional. When set, the npm publish step appends `--tag <value>` (e.g. `legacy-v0.10.0`). Used to assign version-named dist-tags when republishing older versions so `latest` is not overwritten. Empty / unset = npm uses `latest`.
681
683
 
682
684
  > ℹ️ By default, the presets skip GitHub releases and npm publishing. Set `GITHUB_RELEASE=true` and/or `NPM_PUBLISH=true` in the environment (typically in CI) when you are ready to perform those steps.
683
685
 
@@ -41,15 +41,24 @@ export function createBaseGitConfig(overrides = {}) {
41
41
  * @returns {Object} Npm configuration object
42
42
  */
43
43
  export function createBaseNpmConfig(overrides = {}) {
44
+ const publishArgs = [
45
+ ...NPM_DEFAULTS.PUBLISH_ARGS_BASE,
46
+ '--access',
47
+ process.env.NPM_ACCESS || NPM_DEFAULTS.ACCESS,
48
+ ];
49
+
50
+ // Optional --tag <name> for npm dist-tag control (e.g. republishing an older
51
+ // version without overwriting `latest`). When unset, npm uses `latest`.
52
+ const npmTag = process.env.NPM_TAG;
53
+ if (npmTag) {
54
+ publishArgs.push('--tag', npmTag);
55
+ }
56
+
44
57
  const defaults = {
45
58
  skipChecks: process.env.NPM_SKIP_CHECKS === 'true',
46
59
  publish: process.env.NPM_PUBLISH === 'true',
47
60
  versionArgs: NPM_DEFAULTS.VERSION_ARGS,
48
- publishArgs: [
49
- ...NPM_DEFAULTS.PUBLISH_ARGS_BASE,
50
- '--access',
51
- process.env.NPM_ACCESS || NPM_DEFAULTS.ACCESS,
52
- ],
61
+ publishArgs,
53
62
  };
54
63
 
55
64
  return {
@@ -13,8 +13,8 @@
13
13
  * Git configuration defaults
14
14
  */
15
15
  export const GIT_DEFAULTS = {
16
- COMMIT_MESSAGE: 'release: bump v${version}',
17
- HOTFIX_COMMIT_MESSAGE: 'hotfix: bump v${version}',
16
+ COMMIT_MESSAGE: 'chore(release): v${version}',
17
+ HOTFIX_COMMIT_MESSAGE: 'chore(hotfix): v${version}',
18
18
  TAG_NAME: 'v${version}',
19
19
  REQUIRE_BRANCH: 'main',
20
20
  REMOTE: 'origin',
@@ -22,7 +22,9 @@ export const GIT_DEFAULTS = {
22
22
 
23
23
  /**
24
24
  * Default git changelog command
25
- * Filters out commits matching release/hotfix/ci patterns
25
+ * Filters out commits matching release/hotfix/ci patterns, in both
26
+ * legacy form (`release: bump ...`) and Conventional Commits form
27
+ * (`chore(release): ...`, `chore(hotfix): ...`).
26
28
  */
27
29
  export const DEFAULT_CHANGELOG_COMMAND = [
28
30
  'git log',
@@ -36,6 +38,9 @@ export const DEFAULT_CHANGELOG_COMMAND = [
36
38
  '--grep="^Hotfix"',
37
39
  '--grep="^ci"',
38
40
  '--grep="^CI"',
41
+ '--grep="^chore(release)"',
42
+ '--grep="^chore(hotfix)"',
43
+ '--grep="^chore(ci)"',
39
44
  '--invert-grep',
40
45
  ].join(' ');
41
46
 
@@ -22,6 +22,7 @@ import { readFileSync, writeFileSync } from 'node:fs';
22
22
  import { getGitHubRepoUrl } from './lib/git-utils.js';
23
23
  import { CONVENTIONAL_COMMIT_REGEX } from './lib/commit-parser.js';
24
24
  import { runScript } from './lib/run-script.js';
25
+ import { ValidationError } from './lib/errors.js';
25
26
  /**
26
27
  * Extract all conventional commit patterns from a commit body
27
28
  */
@@ -99,7 +100,14 @@ export function parseCommitsWithMultiplePrefixes(gitOutput, repoUrl) {
99
100
  const firstLine = body.split('\n')[0].trim();
100
101
  if (firstLine) {
101
102
  const lowerFirstLine = firstLine.toLowerCase();
102
- const ignoredPatterns = [/^release\b/, /^hotfix\b/, /^ci\b/];
103
+ const ignoredPatterns = [
104
+ /^release\b/,
105
+ /^hotfix\b/,
106
+ /^ci\b/,
107
+ /^chore\(release\)/i,
108
+ /^chore\(hotfix\)/i,
109
+ /^chore\(ci\)/i,
110
+ ];
103
111
  const shouldSkip = ignoredPatterns.some((pattern) => pattern.test(lowerFirstLine));
104
112
  if (shouldSkip) {
105
113
  continue;
@@ -173,9 +181,20 @@ export function populateChangelog(deps) {
173
181
  deps.log('ℹ️ No tags found, using all commits');
174
182
  latestTag = '';
175
183
  }
184
+ const gitChangelogPath = deps.getEnv('GIT_CHANGELOG_PATH');
185
+ let pathFilter = '';
186
+ if (gitChangelogPath !== undefined && gitChangelogPath !== '') {
187
+ // Validate: must be a relative path — no leading slash, no ".." segments, no shell metacharacters
188
+ if (gitChangelogPath.startsWith('/') ||
189
+ /(^|[/\\])\.\.([/\\]|$)/.test(gitChangelogPath) ||
190
+ /[`$;&|<>{}()\\*?!#"']/.test(gitChangelogPath)) {
191
+ throw new ValidationError(`GIT_CHANGELOG_PATH must be a relative path under the repository (got: ${gitChangelogPath})`);
192
+ }
193
+ pathFilter = ` -- ${gitChangelogPath}`;
194
+ }
176
195
  const gitLogCommand = latestTag
177
- ? `git log --pretty=format:"%H|%B|||END|||" ${latestTag}..HEAD`
178
- : `git log --pretty=format:"%H|%B|||END|||"`;
196
+ ? `git log --pretty=format:"%H|%B|||END|||" ${latestTag}..HEAD${pathFilter}`
197
+ : `git log --pretty=format:"%H|%B|||END|||"${pathFilter}`;
179
198
  let gitOutput;
180
199
  try {
181
200
  gitOutput = deps.execSync(gitLogCommand, { encoding: 'utf8' }).trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oorabona/release-it-preset",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Shared release-it configuration and scripts for the organisation",
5
5
  "type": "module",
6
6
  "keywords": [