@fern-api/generator-cli 0.10.3 → 0.10.4

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 +90 -54
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -18618,10 +18618,10 @@ var require_resolve_block_map = __commonJS({
18618
18618
  let offset = bm.offset;
18619
18619
  let commentEnd = null;
18620
18620
  for (const collItem of bm.items) {
18621
- const { start, key, sep: sep3, value } = collItem;
18621
+ const { start, key, sep: sep4, value } = collItem;
18622
18622
  const keyProps = resolveProps.resolveProps(start, {
18623
18623
  indicator: "explicit-key-ind",
18624
- next: key ?? sep3?.[0],
18624
+ next: key ?? sep4?.[0],
18625
18625
  offset,
18626
18626
  onError: onError2,
18627
18627
  parentIndent: bm.indent,
@@ -18635,7 +18635,7 @@ var require_resolve_block_map = __commonJS({
18635
18635
  else if ("indent" in key && key.indent !== bm.indent)
18636
18636
  onError2(offset, "BAD_INDENT", startColMsg);
18637
18637
  }
18638
- if (!keyProps.anchor && !keyProps.tag && !sep3) {
18638
+ if (!keyProps.anchor && !keyProps.tag && !sep4) {
18639
18639
  commentEnd = keyProps.end;
18640
18640
  if (keyProps.comment) {
18641
18641
  if (map.comment)
@@ -18659,7 +18659,7 @@ var require_resolve_block_map = __commonJS({
18659
18659
  ctx.atKey = false;
18660
18660
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
18661
18661
  onError2(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
18662
- const valueProps = resolveProps.resolveProps(sep3 ?? [], {
18662
+ const valueProps = resolveProps.resolveProps(sep4 ?? [], {
18663
18663
  indicator: "map-value-ind",
18664
18664
  next: value,
18665
18665
  offset: keyNode.range[2],
@@ -18675,7 +18675,7 @@ var require_resolve_block_map = __commonJS({
18675
18675
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
18676
18676
  onError2(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
18677
18677
  }
18678
- const valueNode = value ? composeNode(ctx, value, valueProps, onError2) : composeEmptyNode(ctx, offset, sep3, null, valueProps, onError2);
18678
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError2) : composeEmptyNode(ctx, offset, sep4, null, valueProps, onError2);
18679
18679
  if (ctx.schema.compat)
18680
18680
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError2);
18681
18681
  offset = valueNode.range[2];
@@ -18766,7 +18766,7 @@ var require_resolve_end = __commonJS({
18766
18766
  let comment = "";
18767
18767
  if (end) {
18768
18768
  let hasSpace = false;
18769
- let sep3 = "";
18769
+ let sep4 = "";
18770
18770
  for (const token of end) {
18771
18771
  const { source, type } = token;
18772
18772
  switch (type) {
@@ -18780,13 +18780,13 @@ var require_resolve_end = __commonJS({
18780
18780
  if (!comment)
18781
18781
  comment = cb;
18782
18782
  else
18783
- comment += sep3 + cb;
18784
- sep3 = "";
18783
+ comment += sep4 + cb;
18784
+ sep4 = "";
18785
18785
  break;
18786
18786
  }
18787
18787
  case "newline":
18788
18788
  if (comment)
18789
- sep3 += source;
18789
+ sep4 += source;
18790
18790
  hasSpace = true;
18791
18791
  break;
18792
18792
  default:
@@ -18829,18 +18829,18 @@ var require_resolve_flow_collection = __commonJS({
18829
18829
  let offset = fc.offset + fc.start.source.length;
18830
18830
  for (let i2 = 0; i2 < fc.items.length; ++i2) {
18831
18831
  const collItem = fc.items[i2];
18832
- const { start, key, sep: sep3, value } = collItem;
18832
+ const { start, key, sep: sep4, value } = collItem;
18833
18833
  const props = resolveProps.resolveProps(start, {
18834
18834
  flow: fcName,
18835
18835
  indicator: "explicit-key-ind",
18836
- next: key ?? sep3?.[0],
18836
+ next: key ?? sep4?.[0],
18837
18837
  offset,
18838
18838
  onError: onError2,
18839
18839
  parentIndent: fc.indent,
18840
18840
  startOnNewline: false
18841
18841
  });
18842
18842
  if (!props.found) {
18843
- if (!props.anchor && !props.tag && !sep3 && !value) {
18843
+ if (!props.anchor && !props.tag && !sep4 && !value) {
18844
18844
  if (i2 === 0 && props.comma)
18845
18845
  onError2(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
18846
18846
  else if (i2 < fc.items.length - 1)
@@ -18894,8 +18894,8 @@ var require_resolve_flow_collection = __commonJS({
18894
18894
  }
18895
18895
  }
18896
18896
  }
18897
- if (!isMap && !sep3 && !props.found) {
18898
- const valueNode = value ? composeNode(ctx, value, props, onError2) : composeEmptyNode(ctx, props.end, sep3, null, props, onError2);
18897
+ if (!isMap && !sep4 && !props.found) {
18898
+ const valueNode = value ? composeNode(ctx, value, props, onError2) : composeEmptyNode(ctx, props.end, sep4, null, props, onError2);
18899
18899
  coll.items.push(valueNode);
18900
18900
  offset = valueNode.range[2];
18901
18901
  if (isBlock(value))
@@ -18907,7 +18907,7 @@ var require_resolve_flow_collection = __commonJS({
18907
18907
  if (isBlock(key))
18908
18908
  onError2(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
18909
18909
  ctx.atKey = false;
18910
- const valueProps = resolveProps.resolveProps(sep3 ?? [], {
18910
+ const valueProps = resolveProps.resolveProps(sep4 ?? [], {
18911
18911
  flow: fcName,
18912
18912
  indicator: "map-value-ind",
18913
18913
  next: value,
@@ -18918,8 +18918,8 @@ var require_resolve_flow_collection = __commonJS({
18918
18918
  });
18919
18919
  if (valueProps.found) {
18920
18920
  if (!isMap && !props.found && ctx.options.strict) {
18921
- if (sep3)
18922
- for (const st of sep3) {
18921
+ if (sep4)
18922
+ for (const st of sep4) {
18923
18923
  if (st === valueProps.found)
18924
18924
  break;
18925
18925
  if (st.type === "newline") {
@@ -18936,7 +18936,7 @@ var require_resolve_flow_collection = __commonJS({
18936
18936
  else
18937
18937
  onError2(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
18938
18938
  }
18939
- const valueNode = value ? composeNode(ctx, value, valueProps, onError2) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep3, null, valueProps, onError2) : null;
18939
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError2) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep4, null, valueProps, onError2) : null;
18940
18940
  if (valueNode) {
18941
18941
  if (isBlock(value))
18942
18942
  onError2(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -19116,7 +19116,7 @@ var require_resolve_block_scalar = __commonJS({
19116
19116
  chompStart = i2 + 1;
19117
19117
  }
19118
19118
  let value = "";
19119
- let sep3 = "";
19119
+ let sep4 = "";
19120
19120
  let prevMoreIndented = false;
19121
19121
  for (let i2 = 0; i2 < contentStart; ++i2)
19122
19122
  value += lines[i2][0].slice(trimIndent) + "\n";
@@ -19133,24 +19133,24 @@ var require_resolve_block_scalar = __commonJS({
19133
19133
  indent = "";
19134
19134
  }
19135
19135
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
19136
- value += sep3 + indent.slice(trimIndent) + content;
19137
- sep3 = "\n";
19136
+ value += sep4 + indent.slice(trimIndent) + content;
19137
+ sep4 = "\n";
19138
19138
  } else if (indent.length > trimIndent || content[0] === " ") {
19139
- if (sep3 === " ")
19140
- sep3 = "\n";
19141
- else if (!prevMoreIndented && sep3 === "\n")
19142
- sep3 = "\n\n";
19143
- value += sep3 + indent.slice(trimIndent) + content;
19144
- sep3 = "\n";
19139
+ if (sep4 === " ")
19140
+ sep4 = "\n";
19141
+ else if (!prevMoreIndented && sep4 === "\n")
19142
+ sep4 = "\n\n";
19143
+ value += sep4 + indent.slice(trimIndent) + content;
19144
+ sep4 = "\n";
19145
19145
  prevMoreIndented = true;
19146
19146
  } else if (content === "") {
19147
- if (sep3 === "\n")
19147
+ if (sep4 === "\n")
19148
19148
  value += "\n";
19149
19149
  else
19150
- sep3 = "\n";
19150
+ sep4 = "\n";
19151
19151
  } else {
19152
- value += sep3 + content;
19153
- sep3 = " ";
19152
+ value += sep4 + content;
19153
+ sep4 = " ";
19154
19154
  prevMoreIndented = false;
19155
19155
  }
19156
19156
  }
@@ -19332,25 +19332,25 @@ var require_resolve_flow_scalar = __commonJS({
19332
19332
  if (!match2)
19333
19333
  return source;
19334
19334
  let res = match2[1];
19335
- let sep3 = " ";
19335
+ let sep4 = " ";
19336
19336
  let pos = first2.lastIndex;
19337
19337
  line.lastIndex = pos;
19338
19338
  while (match2 = line.exec(source)) {
19339
19339
  if (match2[1] === "") {
19340
- if (sep3 === "\n")
19341
- res += sep3;
19340
+ if (sep4 === "\n")
19341
+ res += sep4;
19342
19342
  else
19343
- sep3 = "\n";
19343
+ sep4 = "\n";
19344
19344
  } else {
19345
- res += sep3 + match2[1];
19346
- sep3 = " ";
19345
+ res += sep4 + match2[1];
19346
+ sep4 = " ";
19347
19347
  }
19348
19348
  pos = line.lastIndex;
19349
19349
  }
19350
19350
  const last2 = /[ \t]*(.*)/sy;
19351
19351
  last2.lastIndex = pos;
19352
19352
  match2 = last2.exec(source);
19353
- return res + sep3 + (match2?.[1] ?? "");
19353
+ return res + sep4 + (match2?.[1] ?? "");
19354
19354
  }
19355
19355
  function doubleQuotedValue(source, onError2) {
19356
19356
  let res = "";
@@ -20157,14 +20157,14 @@ var require_cst_stringify = __commonJS({
20157
20157
  }
20158
20158
  }
20159
20159
  }
20160
- function stringifyItem({ start, key, sep: sep3, value }) {
20160
+ function stringifyItem({ start, key, sep: sep4, value }) {
20161
20161
  let res = "";
20162
20162
  for (const st of start)
20163
20163
  res += st.source;
20164
20164
  if (key)
20165
20165
  res += stringifyToken(key);
20166
- if (sep3)
20167
- for (const st of sep3)
20166
+ if (sep4)
20167
+ for (const st of sep4)
20168
20168
  res += st.source;
20169
20169
  if (value)
20170
20170
  res += stringifyToken(value);
@@ -21314,18 +21314,18 @@ var require_parser = __commonJS({
21314
21314
  if (this.type === "map-value-ind") {
21315
21315
  const prev = getPrevProps(this.peek(2));
21316
21316
  const start = getFirstKeyStartProps(prev);
21317
- let sep3;
21317
+ let sep4;
21318
21318
  if (scalar.end) {
21319
- sep3 = scalar.end;
21320
- sep3.push(this.sourceToken);
21319
+ sep4 = scalar.end;
21320
+ sep4.push(this.sourceToken);
21321
21321
  delete scalar.end;
21322
21322
  } else
21323
- sep3 = [this.sourceToken];
21323
+ sep4 = [this.sourceToken];
21324
21324
  const map = {
21325
21325
  type: "block-map",
21326
21326
  offset: scalar.offset,
21327
21327
  indent: scalar.indent,
21328
- items: [{ start, key: scalar, sep: sep3 }]
21328
+ items: [{ start, key: scalar, sep: sep4 }]
21329
21329
  };
21330
21330
  this.onKeyLine = true;
21331
21331
  this.stack[this.stack.length - 1] = map;
@@ -21478,15 +21478,15 @@ var require_parser = __commonJS({
21478
21478
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
21479
21479
  const start2 = getFirstKeyStartProps(it.start);
21480
21480
  const key = it.key;
21481
- const sep3 = it.sep;
21482
- sep3.push(this.sourceToken);
21481
+ const sep4 = it.sep;
21482
+ sep4.push(this.sourceToken);
21483
21483
  delete it.key;
21484
21484
  delete it.sep;
21485
21485
  this.stack.push({
21486
21486
  type: "block-map",
21487
21487
  offset: this.offset,
21488
21488
  indent: this.indent,
21489
- items: [{ start: start2, key, sep: sep3 }]
21489
+ items: [{ start: start2, key, sep: sep4 }]
21490
21490
  });
21491
21491
  } else if (start.length > 0) {
21492
21492
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -21680,13 +21680,13 @@ var require_parser = __commonJS({
21680
21680
  const prev = getPrevProps(parent);
21681
21681
  const start = getFirstKeyStartProps(prev);
21682
21682
  fixFlowSeqItems(fc);
21683
- const sep3 = fc.end.splice(1, fc.end.length);
21684
- sep3.push(this.sourceToken);
21683
+ const sep4 = fc.end.splice(1, fc.end.length);
21684
+ sep4.push(this.sourceToken);
21685
21685
  const map = {
21686
21686
  type: "block-map",
21687
21687
  offset: fc.offset,
21688
21688
  indent: fc.indent,
21689
- items: [{ start, key: fc, sep: sep3 }]
21689
+ items: [{ start, key: fc, sep: sep4 }]
21690
21690
  };
21691
21691
  this.onKeyLine = true;
21692
21692
  this.stack[this.stack.length - 1] = map;
@@ -36523,6 +36523,11 @@ function escape3(string2) {
36523
36523
  return escape2(toString(string2));
36524
36524
  }
36525
36525
 
36526
+ // ../../node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/escapeRegExp.mjs
36527
+ function escapeRegExp(str) {
36528
+ return str.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
36529
+ }
36530
+
36526
36531
  // ../../node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/snakeCase.mjs
36527
36532
  function snakeCase(str) {
36528
36533
  const words$1 = words(str);
@@ -40740,6 +40745,9 @@ function countFilesInDiff(diffContent) {
40740
40745
  function formatSizeKB(charLength) {
40741
40746
  return (charLength / 1024).toFixed(1);
40742
40747
  }
40748
+ function magicVersionRegExp(mappedMagicVersion) {
40749
+ return new RegExp(`(?<![0-9.])${escapeRegExp(mappedMagicVersion)}(?![0-9A-Za-z-]|\\.[0-9A-Za-z])`, "g");
40750
+ }
40743
40751
  var EXCLUDED_DIRECTORIES = /* @__PURE__ */ new Set([
40744
40752
  // Version control
40745
40753
  ".git",
@@ -41524,7 +41532,10 @@ var AutoVersioningService = class _AutoVersioningService {
41524
41532
  */
41525
41533
  async replaceMagicVersion(workingDirectory, mappedMagicVersion, finalVersion) {
41526
41534
  this.logger.debug(`Replacing placeholder version ${mappedMagicVersion} with final version: ${finalVersion}`);
41527
- const files = await this.walkDirectory(workingDirectory, () => true);
41535
+ const allFiles = await this.walkDirectory(workingDirectory, () => true);
41536
+ const fernignoredFiles = await this.getFernignoredFiles(workingDirectory, allFiles);
41537
+ const files = allFiles.filter((filePath) => !fernignoredFiles.has(filePath));
41538
+ const magicVersionPattern = magicVersionRegExp(mappedMagicVersion);
41528
41539
  const replaceInFile = async (filePath) => {
41529
41540
  if (await this.isBinaryFile(filePath)) {
41530
41541
  return false;
@@ -41533,7 +41544,10 @@ var AutoVersioningService = class _AutoVersioningService {
41533
41544
  if (!content.includes(mappedMagicVersion)) {
41534
41545
  return false;
41535
41546
  }
41536
- const updated = content.split(mappedMagicVersion).join(finalVersion);
41547
+ const updated = content.replace(magicVersionPattern, () => finalVersion);
41548
+ if (updated === content) {
41549
+ return false;
41550
+ }
41537
41551
  await (0, import_promises15.writeFile)(filePath, updated, "utf-8");
41538
41552
  return true;
41539
41553
  };
@@ -41638,6 +41652,28 @@ var AutoVersioningService = class _AutoVersioningService {
41638
41652
  this.logger.debug(`Updated go.mod: added ${suffix} to module path`);
41639
41653
  }
41640
41654
  }
41655
+ /**
41656
+ * Files protected by `.fernignore` hold customer-owned content, so the placeholder
41657
+ * must never be rewritten inside them (e.g. docs that mention `0.0.0-fern-placeholder`).
41658
+ */
41659
+ async getFernignoredFiles(workingDirectory, files) {
41660
+ const fernignorePath = (0, import_path23.join)(workingDirectory, ".fernignore");
41661
+ let fernignoreContent;
41662
+ try {
41663
+ fernignoreContent = await (0, import_promises15.readFile)(fernignorePath, "utf-8");
41664
+ } catch {
41665
+ return /* @__PURE__ */ new Set();
41666
+ }
41667
+ const relativePaths = new Map(
41668
+ files.map((filePath) => [(0, import_path23.relative)(workingDirectory, filePath).split(import_path23.sep).join("/"), filePath])
41669
+ );
41670
+ return /* @__PURE__ */ new Set([
41671
+ fernignorePath,
41672
+ ...expandFernignorePatterns(fernignoreContent, [...relativePaths.keys()]).map(
41673
+ (relativePath) => relativePaths.get(relativePath) ?? relativePath
41674
+ )
41675
+ ]);
41676
+ }
41641
41677
  /**
41642
41678
  * Recursively walks a directory and returns all file paths matching a filter.
41643
41679
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fern-api/generator-cli",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/fern-api/fern.git",