versionary 1.5.0 → 1.6.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.
@@ -0,0 +1 @@
1
+ export declare function redactCredentials(message: string): string;
@@ -0,0 +1,14 @@
1
+ export function redactCredentials(message) {
2
+ let redacted = message.replace(/([a-z][a-z\d+.-]*:\/\/)[^\s/]*@/giu, "$1[REDACTED]@");
3
+ const tokens = [
4
+ process.env.VERSIONARY_PR_TOKEN,
5
+ process.env.GH_TOKEN,
6
+ process.env.GITHUB_TOKEN,
7
+ ].filter((token) => Boolean(token));
8
+ const secrets = new Set(tokens.flatMap((token) => [token, encodeURIComponent(token)]));
9
+ // Replace longer secrets first so an overlapping token cannot leave a suffix.
10
+ for (const secret of [...secrets].sort((a, b) => b.length - a.length)) {
11
+ redacted = redacted.replaceAll(secret, "[REDACTED]");
12
+ }
13
+ return redacted;
14
+ }
@@ -162,25 +162,25 @@ export function renderReleaseNotesSection(input, options = {}) {
162
162
  sections.push(trimmedHighlights, "");
163
163
  }
164
164
  if (grouped.breaking.length > 0) {
165
- sections.push("### Breaking changes", ...grouped.breaking, "");
165
+ sections.push("### Breaking changes", "", ...grouped.breaking, "");
166
166
  }
167
167
  if (grouped.features.length > 0) {
168
- sections.push("### Features", ...grouped.features, "");
168
+ sections.push("### Features", "", ...grouped.features, "");
169
169
  }
170
170
  if (grouped.fixes.length > 0) {
171
- sections.push("### Bug Fixes", ...grouped.fixes, "");
171
+ sections.push("### Bug Fixes", "", ...grouped.fixes, "");
172
172
  }
173
173
  if (grouped.performance.length > 0) {
174
- sections.push("### Performance Improvements", ...grouped.performance, "");
174
+ sections.push("### Performance Improvements", "", ...grouped.performance, "");
175
175
  }
176
176
  if (grouped.reverts.length > 0) {
177
- sections.push("### Reverts", ...grouped.reverts, "");
177
+ sections.push("### Reverts", "", ...grouped.reverts, "");
178
178
  }
179
179
  if (input.dependencies && input.dependencies.length > 0) {
180
- sections.push("### Dependencies", ...input.dependencies.map((dependency) => `- updated ${dependency.name} to v${dependency.version}`), "");
180
+ sections.push("### Dependencies", "", ...input.dependencies.map((dependency) => `- updated ${dependency.name} to v${dependency.version}`), "");
181
181
  }
182
182
  if (needsOtherChangesFallback(grouped, trimmedHighlights.length > 0, input.dependencies?.length ?? 0)) {
183
- sections.push("### Other changes", ...grouped.other, "");
183
+ sections.push("### Other changes", "", ...grouped.other, "");
184
184
  }
185
185
  const body = [header, "", ...sections].join("\n").trimEnd();
186
186
  if (options.includeFooter) {
@@ -4,6 +4,7 @@ import os from "node:os";
4
4
  import path from "node:path";
5
5
  import { loadConfig } from "../config/load-config.js";
6
6
  import { ensureGitIdentity } from "../git/identity.js";
7
+ import { redactCredentials } from "../git/redact.js";
7
8
  import { getScmClient } from "../scm/client.js";
8
9
  import { resolvePackageStrategyContext, resolveReleaseName, } from "../strategy/package-context.js";
9
10
  import { applyConfiguredArtifactRules } from "./artifact-rules.js";
@@ -189,7 +190,8 @@ function buildPackageReleaseMetadata(cwd, plan, loadedConfig) {
189
190
  const packageContext = resolvePackageStrategyContext(loadedConfig, pkg.path, packageConfig);
190
191
  const releaseName = resolveReleaseName(cwd, pkg.path, packageConfig, packageContext.strategy, packageContext.config);
191
192
  metadataByPath[pkg.path] = {
192
- releaseName,
193
+ packageName: packageContext.strategy.readPackageName?.(cwd, packageContext.config) ??
194
+ releaseName,
193
195
  tagPrefix: normalizeReleaseNameForTag(releaseName),
194
196
  };
195
197
  }
@@ -447,7 +449,7 @@ export function prepareReleasePr(cwd = process.cwd(), options = {}) {
447
449
  const packageHighlights = readChangelogHighlights(cwd, packageChangelogPath, packageChangelogFormat);
448
450
  const packageSection = packageChangelogFormat === "r-news"
449
451
  ? renderRNewsReleaseNotes({
450
- packageName: packageMetadata.releaseName,
452
+ packageName: packageMetadata.packageName,
451
453
  nextVersion: packagePlan.nextVersion,
452
454
  commits: packagePlan.commits,
453
455
  cwd,
@@ -605,7 +607,7 @@ function materializeCandidateChanges(cwd, plan, options) {
605
607
  const packageHighlights = readChangelogHighlights(cwd, packageChangelogPath, packageChangelogFormat);
606
608
  const section = packageChangelogFormat === "r-news"
607
609
  ? renderRNewsReleaseNotes({
608
- packageName: metadata.releaseName,
610
+ packageName: metadata.packageName,
609
611
  nextVersion: packagePlan.nextVersion,
610
612
  commits: packagePlan.commits,
611
613
  cwd,
@@ -985,10 +987,18 @@ export async function closeStaleReviewRequestIfExists(cwd = process.cwd(), optio
985
987
  return result;
986
988
  }
987
989
  export function pushReleaseBranch(cwd, branch) {
988
- execFileSync("git", ["push", "--force-with-lease", "origin", branch], {
989
- cwd,
990
- stdio: ["ignore", "pipe", "ignore"],
991
- });
990
+ try {
991
+ execFileSync("git", ["push", "--force-with-lease", "origin", branch], {
992
+ cwd,
993
+ stdio: ["ignore", "pipe", "pipe"],
994
+ });
995
+ }
996
+ catch (error) {
997
+ const message = error instanceof Error ? error.message : String(error);
998
+ // Captured stderr is included in the message. Do not retain the original
999
+ // error as a cause: its output buffers may contain credentials.
1000
+ throw new Error(redactCredentials(message));
1001
+ }
992
1002
  }
993
1003
  export function isReleaseCommitMessage(commitMessage) {
994
1004
  if (/^Versionary-Release:\s*true$/imu.test(commitMessage)) {
@@ -178,13 +178,13 @@ function findNearestLockfileDirectory(cwd, packageDirectory, lockfile) {
178
178
  current = parent;
179
179
  }
180
180
  }
181
- function readPyProjectFromCwd(cwd) {
182
- const target = path.join(cwd, "pyproject.toml");
181
+ function readPyProjectFromCwd(cwd, versionFile) {
182
+ const target = path.join(cwd, versionFile);
183
183
  if (!fs.existsSync(target)) {
184
184
  return null;
185
185
  }
186
186
  const content = fs.readFileSync(target, "utf8");
187
- return { parsed: parsePyProject(content, "pyproject.toml"), rawPath: target };
187
+ return { parsed: parsePyProject(content, versionFile), rawPath: target };
188
188
  }
189
189
  function packageNameFromParsed(parsed) {
190
190
  const projectName = parsed.project?.name;
@@ -312,20 +312,13 @@ export const pythonVersionStrategy = {
312
312
  }
313
313
  return written;
314
314
  },
315
- readPackageName(cwd, _config) {
316
- const found = readPyProjectFromCwd(cwd);
315
+ readPackageName(cwd, config) {
316
+ const versionFile = this.getVersionFile(config);
317
+ const found = readPyProjectFromCwd(cwd, isSourceFileMode(versionFile) ? "pyproject.toml" : versionFile);
317
318
  if (!found) {
318
319
  return null;
319
320
  }
320
- const projectName = found.parsed.project?.name;
321
- if (typeof projectName === "string" && projectName.trim().length > 0) {
322
- return projectName.trim();
323
- }
324
- const poetryName = found.parsed.toolPoetry?.name;
325
- if (typeof poetryName === "string" && poetryName.trim().length > 0) {
326
- return poetryName.trim();
327
- }
328
- return null;
321
+ return packageNameFromParsed(found.parsed);
329
322
  },
330
323
  finalizeVersionWrites(cwd, writes, _context) {
331
324
  const packageDirectories = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "versionary",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "description": "Automatic release framework based on conventional commits and semantic versioning",
5
5
  "keywords": [
6
6
  "releasing",