@oorabona/release-it-preset 0.10.1 → 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 {
@@ -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
  */
@@ -180,9 +181,20 @@ export function populateChangelog(deps) {
180
181
  deps.log('ℹ️ No tags found, using all commits');
181
182
  latestTag = '';
182
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
+ }
183
195
  const gitLogCommand = latestTag
184
- ? `git log --pretty=format:"%H|%B|||END|||" ${latestTag}..HEAD`
185
- : `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}`;
186
198
  let gitOutput;
187
199
  try {
188
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.1",
3
+ "version": "0.11.0",
4
4
  "description": "Shared release-it configuration and scripts for the organisation",
5
5
  "type": "module",
6
6
  "keywords": [