@fern-api/generator-cli 0.9.46 → 0.9.47

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.
Files changed (2) hide show
  1. package/dist/cli.js +46 -8
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -41355,7 +41355,8 @@ var AutoVersioningService = class _AutoVersioningService {
41355
41355
  }
41356
41356
  await this.addSuffixToGoMod(goModPath, modulePath, suffix);
41357
41357
  await this.addSuffixToGoFiles(workingDirectory, modulePath, suffix);
41358
- this.logger.info(`Added ${suffix} to Go module path ${modulePath} and all import paths`);
41358
+ await this.addSuffixToMarkdownFiles(workingDirectory, modulePath, suffix);
41359
+ this.logger.info(`Added ${suffix} to Go module path ${modulePath} across imports, headers, and docs`);
41359
41360
  }
41360
41361
  /**
41361
41362
  * Extracts the major version number from a version string.
@@ -41436,15 +41437,16 @@ var AutoVersioningService = class _AutoVersioningService {
41436
41437
  return results;
41437
41438
  }
41438
41439
  /**
41439
- * Adds a version suffix to import paths in all .go files in the repository.
41440
+ * Adds a version suffix to import paths and embedded module-path string
41441
+ * literals (e.g. the X-Fern-SDK-Name header value) in all .go files.
41440
41442
  */
41441
41443
  async addSuffixToGoFiles(repoRoot, modulePath, suffix) {
41442
41444
  const goFiles = await this.walkDirectory(repoRoot, (filePath) => (0, import_path22.extname)(filePath) === ".go");
41443
41445
  await this.processInParallel(goFiles, (filePath) => this.addSuffixToGoFile(filePath, modulePath, suffix));
41444
41446
  }
41445
41447
  /**
41446
- * Adds a version suffix to import paths in a single .go file.
41447
- * Replaces occurrences of the module path with modulePath + suffix in import statements.
41448
+ * Adds a version suffix to import paths and embedded module-path string
41449
+ * literals in a single .go file.
41448
41450
  */
41449
41451
  async addSuffixToGoFile(filePath, modulePath, suffix) {
41450
41452
  const content = await (0, import_promises14.readFile)(filePath, "utf-8");
@@ -41463,13 +41465,10 @@ var AutoVersioningService = class _AutoVersioningService {
41463
41465
  inImportBlock = false;
41464
41466
  }
41465
41467
  const isImportLine = inImportBlock || trimmed2.startsWith('import "') || trimmed2.startsWith('import "') || /^import\s+\w+\s+"/.test(trimmed2);
41466
- if (!isImportLine) {
41467
- continue;
41468
- }
41469
41468
  if (!line.includes(modulePath)) {
41470
41469
  continue;
41471
41470
  }
41472
- const newLine = line.replace(`"${modulePath}/`, `"${modulePath}${suffix}/`).replace(`"${modulePath}"`, `"${modulePath}${suffix}"`);
41471
+ const newLine = isImportLine ? line.split(`"${modulePath}/`).join(`"${modulePath}${suffix}/`).split(`"${modulePath}"`).join(`"${modulePath}${suffix}"`) : line.split(`"${modulePath}"`).join(`"${modulePath}${suffix}"`);
41473
41472
  if (newLine !== line) {
41474
41473
  lines[i2] = newLine;
41475
41474
  changed = true;
@@ -41480,6 +41479,45 @@ var AutoVersioningService = class _AutoVersioningService {
41480
41479
  this.logger.debug(`Updated Go imports in ${filePath}`);
41481
41480
  }
41482
41481
  }
41482
+ /**
41483
+ * Adds a version suffix to Go module references in all Markdown files
41484
+ * (e.g. README.md) in the repository, so documented install commands and
41485
+ * import samples resolve to the correct /vN module path when copy-pasted.
41486
+ */
41487
+ async addSuffixToMarkdownFiles(repoRoot, modulePath, suffix) {
41488
+ const markdownFiles = await this.walkDirectory(
41489
+ repoRoot,
41490
+ (filePath) => (0, import_path22.extname)(filePath).toLowerCase() === ".md"
41491
+ );
41492
+ await this.processInParallel(
41493
+ markdownFiles,
41494
+ (filePath) => this.addSuffixToMarkdownFile(filePath, modulePath, suffix)
41495
+ );
41496
+ }
41497
+ /**
41498
+ * Adds a version suffix to Go module references in a single Markdown file.
41499
+ * Rewrites `go get`/`go install` install commands and quoted import paths in
41500
+ * code samples. Web URLs (e.g. `https://pkg.go.dev/<modulePath>`) are left
41501
+ * untouched because the module path there is neither quote-anchored nor
41502
+ * preceded by an install command.
41503
+ */
41504
+ async addSuffixToMarkdownFile(filePath, modulePath, suffix) {
41505
+ const content = await (0, import_promises14.readFile)(filePath, "utf-8");
41506
+ if (!content.includes(modulePath)) {
41507
+ return;
41508
+ }
41509
+ let updated = content.split(`"${modulePath}/`).join(`"${modulePath}${suffix}/`).split(`"${modulePath}"`).join(`"${modulePath}${suffix}"`);
41510
+ const escapedModulePath = modulePath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
41511
+ const installCommandPattern = new RegExp(
41512
+ `(go (?:get|install)(?:\\s+-\\S+)*\\s+)${escapedModulePath}(?![\\w./-])`,
41513
+ "g"
41514
+ );
41515
+ updated = updated.replace(installCommandPattern, `$1${modulePath}${suffix}`);
41516
+ if (updated !== content) {
41517
+ await (0, import_promises14.writeFile)(filePath, updated, "utf-8");
41518
+ this.logger.debug(`Updated Go module path in ${filePath}`);
41519
+ }
41520
+ }
41483
41521
  /**
41484
41522
  * Extracts the file path from a diff file section.
41485
41523
  * Parses the "diff --git a/path b/path" header line.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fern-api/generator-cli",
3
- "version": "0.9.46",
3
+ "version": "0.9.47",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/fern-api/fern.git",