@fern-api/generator-cli 0.3.0 → 0.4.3

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 (3) hide show
  1. package/dist/api.cjs +500 -350
  2. package/dist/cli.cjs +519 -397
  3. package/package.json +12 -18
package/dist/cli.cjs CHANGED
@@ -1565,7 +1565,7 @@ var require_build2 = __commonJS({
1565
1565
  }
1566
1566
  }
1567
1567
  var env2 = process ? process.env : {};
1568
- var parser3 = new YargsParser2({
1568
+ var parser4 = new YargsParser2({
1569
1569
  cwd: process.cwd,
1570
1570
  env: () => {
1571
1571
  return env2;
@@ -1584,11 +1584,11 @@ var require_build2 = __commonJS({
1584
1584
  }
1585
1585
  });
1586
1586
  var yargsParser2 = function Parser3(args, opts) {
1587
- const result = parser3.parse(args.slice(), opts);
1587
+ const result = parser4.parse(args.slice(), opts);
1588
1588
  return result.argv;
1589
1589
  };
1590
1590
  yargsParser2.detailed = function(args, opts) {
1591
- return parser3.parse(args.slice(), opts);
1591
+ return parser4.parse(args.slice(), opts);
1592
1592
  };
1593
1593
  yargsParser2.camelCase = camelCase3;
1594
1594
  yargsParser2.decamelize = decamelize2;
@@ -5079,9 +5079,9 @@ var require_ms = __commonJS({
5079
5079
  }
5080
5080
  });
5081
5081
 
5082
- // ../../node_modules/.pnpm/debug@4.4.1_supports-color@5.5.0/node_modules/debug/src/common.js
5082
+ // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
5083
5083
  var require_common = __commonJS({
5084
- "../../node_modules/.pnpm/debug@4.4.1_supports-color@5.5.0/node_modules/debug/src/common.js"(exports2, module2) {
5084
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports2, module2) {
5085
5085
  "use strict";
5086
5086
  function setup(env2) {
5087
5087
  createDebug.debug = createDebug;
@@ -5257,9 +5257,9 @@ var require_common = __commonJS({
5257
5257
  }
5258
5258
  });
5259
5259
 
5260
- // ../../node_modules/.pnpm/debug@4.4.1_supports-color@5.5.0/node_modules/debug/src/browser.js
5260
+ // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
5261
5261
  var require_browser = __commonJS({
5262
- "../../node_modules/.pnpm/debug@4.4.1_supports-color@5.5.0/node_modules/debug/src/browser.js"(exports2, module2) {
5262
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports2, module2) {
5263
5263
  "use strict";
5264
5264
  exports2.formatArgs = formatArgs;
5265
5265
  exports2.save = save;
@@ -5428,37 +5428,28 @@ var require_browser = __commonJS({
5428
5428
  }
5429
5429
  });
5430
5430
 
5431
- // ../../node_modules/.pnpm/has-flag@3.0.0/node_modules/has-flag/index.js
5431
+ // ../../node_modules/.pnpm/has-flag@2.0.0/node_modules/has-flag/index.js
5432
5432
  var require_has_flag = __commonJS({
5433
- "../../node_modules/.pnpm/has-flag@3.0.0/node_modules/has-flag/index.js"(exports2, module2) {
5433
+ "../../node_modules/.pnpm/has-flag@2.0.0/node_modules/has-flag/index.js"(exports2, module2) {
5434
5434
  "use strict";
5435
- module2.exports = (flag, argv) => {
5435
+ module2.exports = function(flag, argv) {
5436
5436
  argv = argv || process.argv;
5437
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
5438
- const pos = argv.indexOf(prefix + flag);
5439
- const terminatorPos = argv.indexOf("--");
5437
+ var terminatorPos = argv.indexOf("--");
5438
+ var prefix = /^-{1,2}/.test(flag) ? "" : "--";
5439
+ var pos = argv.indexOf(prefix + flag);
5440
5440
  return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
5441
5441
  };
5442
5442
  }
5443
5443
  });
5444
5444
 
5445
- // ../../node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js
5445
+ // ../../node_modules/.pnpm/supports-color@4.5.0/node_modules/supports-color/index.js
5446
5446
  var require_supports_color = __commonJS({
5447
- "../../node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js"(exports2, module2) {
5447
+ "../../node_modules/.pnpm/supports-color@4.5.0/node_modules/supports-color/index.js"(exports2, module2) {
5448
5448
  "use strict";
5449
5449
  var os = require("os");
5450
5450
  var hasFlag = require_has_flag();
5451
5451
  var env2 = process.env;
5452
- var forceColor;
5453
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false")) {
5454
- forceColor = false;
5455
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
5456
- forceColor = true;
5457
- }
5458
- if ("FORCE_COLOR" in env2) {
5459
- forceColor = env2.FORCE_COLOR.length === 0 || parseInt(env2.FORCE_COLOR, 10) !== 0;
5460
- }
5461
- function translateLevel(level) {
5452
+ var support = (level) => {
5462
5453
  if (level === 0) {
5463
5454
  return false;
5464
5455
  }
@@ -5468,9 +5459,9 @@ var require_supports_color = __commonJS({
5468
5459
  has256: level >= 2,
5469
5460
  has16m: level >= 3
5470
5461
  };
5471
- }
5472
- function supportsColor(stream) {
5473
- if (forceColor === false) {
5462
+ };
5463
+ var supportLevel = (() => {
5464
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false")) {
5474
5465
  return 0;
5475
5466
  }
5476
5467
  if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
@@ -5479,14 +5470,16 @@ var require_supports_color = __commonJS({
5479
5470
  if (hasFlag("color=256")) {
5480
5471
  return 2;
5481
5472
  }
5482
- if (stream && !stream.isTTY && forceColor !== true) {
5473
+ if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
5474
+ return 1;
5475
+ }
5476
+ if (process.stdout && !process.stdout.isTTY) {
5483
5477
  return 0;
5484
5478
  }
5485
- const min = forceColor ? 1 : 0;
5486
5479
  if (process.platform === "win32") {
5487
5480
  const osRelease = os.release().split(".");
5488
5481
  if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
5489
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
5482
+ return 2;
5490
5483
  }
5491
5484
  return 1;
5492
5485
  }
@@ -5494,19 +5487,18 @@ var require_supports_color = __commonJS({
5494
5487
  if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI"].some((sign) => sign in env2) || env2.CI_NAME === "codeship") {
5495
5488
  return 1;
5496
5489
  }
5497
- return min;
5490
+ return 0;
5498
5491
  }
5499
5492
  if ("TEAMCITY_VERSION" in env2) {
5500
5493
  return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env2.TEAMCITY_VERSION) ? 1 : 0;
5501
5494
  }
5502
- if (env2.COLORTERM === "truecolor") {
5503
- return 3;
5504
- }
5505
5495
  if ("TERM_PROGRAM" in env2) {
5506
5496
  const version = parseInt((env2.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
5507
5497
  switch (env2.TERM_PROGRAM) {
5508
5498
  case "iTerm.app":
5509
5499
  return version >= 3 ? 3 : 2;
5500
+ case "Hyper":
5501
+ return 3;
5510
5502
  case "Apple_Terminal":
5511
5503
  return 2;
5512
5504
  }
@@ -5514,32 +5506,27 @@ var require_supports_color = __commonJS({
5514
5506
  if (/-256(color)?$/i.test(env2.TERM)) {
5515
5507
  return 2;
5516
5508
  }
5517
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env2.TERM)) {
5509
+ if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env2.TERM)) {
5518
5510
  return 1;
5519
5511
  }
5520
5512
  if ("COLORTERM" in env2) {
5521
5513
  return 1;
5522
5514
  }
5523
5515
  if (env2.TERM === "dumb") {
5524
- return min;
5516
+ return 0;
5525
5517
  }
5526
- return min;
5527
- }
5528
- function getSupportLevel(stream) {
5529
- const level = supportsColor(stream);
5530
- return translateLevel(level);
5518
+ return 0;
5519
+ })();
5520
+ if ("FORCE_COLOR" in env2) {
5521
+ supportLevel = parseInt(env2.FORCE_COLOR, 10) === 0 ? 0 : supportLevel || 1;
5531
5522
  }
5532
- module2.exports = {
5533
- supportsColor: getSupportLevel,
5534
- stdout: getSupportLevel(process.stdout),
5535
- stderr: getSupportLevel(process.stderr)
5536
- };
5523
+ module2.exports = process && support(supportLevel);
5537
5524
  }
5538
5525
  });
5539
5526
 
5540
- // ../../node_modules/.pnpm/debug@4.4.1_supports-color@5.5.0/node_modules/debug/src/node.js
5527
+ // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
5541
5528
  var require_node = __commonJS({
5542
- "../../node_modules/.pnpm/debug@4.4.1_supports-color@5.5.0/node_modules/debug/src/node.js"(exports2, module2) {
5529
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports2, module2) {
5543
5530
  "use strict";
5544
5531
  var tty = require("tty");
5545
5532
  var util = require("util");
@@ -5712,9 +5699,9 @@ var require_node = __commonJS({
5712
5699
  }
5713
5700
  });
5714
5701
 
5715
- // ../../node_modules/.pnpm/debug@4.4.1_supports-color@5.5.0/node_modules/debug/src/index.js
5702
+ // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
5716
5703
  var require_src = __commonJS({
5717
- "../../node_modules/.pnpm/debug@4.4.1_supports-color@5.5.0/node_modules/debug/src/index.js"(exports2, module2) {
5704
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports2, module2) {
5718
5705
  "use strict";
5719
5706
  if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
5720
5707
  module2.exports = require_browser();
@@ -5822,31 +5809,42 @@ var require_dist2 = __commonJS({
5822
5809
  }
5823
5810
  });
5824
5811
 
5825
- // ../../node_modules/.pnpm/@fern-api+fs-utils@0.15.0-rc63/node_modules/@fern-api/fs-utils/lib/cwd.js
5812
+ // ../commons/path-utils/lib/convertToOsPath.js
5813
+ function convertToOsPath(path4) {
5814
+ return path4.replace(/\\/g, "/");
5815
+ }
5816
+
5817
+ // ../commons/fs-utils/lib/cwd.js
5826
5818
  function cwd() {
5827
5819
  return process.cwd();
5828
5820
  }
5829
5821
 
5830
- // ../../node_modules/.pnpm/@fern-api+fs-utils@0.15.0-rc63/node_modules/@fern-api/fs-utils/lib/doesPathExist.js
5822
+ // ../commons/fs-utils/lib/doesPathExist.js
5831
5823
  var import_promises = require("fs/promises");
5832
- async function doesPathExist(filepath) {
5824
+ async function doesPathExist(filepath, mode) {
5833
5825
  try {
5834
- await (0, import_promises.lstat)(filepath);
5826
+ const stat = await (0, import_promises.lstat)(filepath);
5827
+ if (mode === "file" && !stat.isFile()) {
5828
+ return false;
5829
+ }
5830
+ if (mode === "directory" && !stat.isDirectory()) {
5831
+ return false;
5832
+ }
5835
5833
  return true;
5836
5834
  } catch {
5837
5835
  return false;
5838
5836
  }
5839
5837
  }
5840
5838
 
5841
- // ../../node_modules/.pnpm/@fern-api+fs-utils@0.15.0-rc63/node_modules/@fern-api/fs-utils/lib/resolve.js
5839
+ // ../commons/fs-utils/lib/resolve.js
5842
5840
  var import_path = __toESM(require("path"), 1);
5843
5841
  function resolve(...paths) {
5844
- return import_path.default.resolve(...paths);
5842
+ return import_path.default.resolve(...paths.map(convertToOsPath));
5845
5843
  }
5846
5844
 
5847
5845
  // src/cli.ts
5848
5846
  var import_fs6 = __toESM(require("fs"), 1);
5849
- var import_promises7 = require("fs/promises");
5847
+ var import_promises6 = require("fs/promises");
5850
5848
  var import_path7 = __toESM(require("path"), 1);
5851
5849
 
5852
5850
  // ../../node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/build/lib/yerror.js
@@ -7438,34 +7436,19 @@ var yargs_default = Yargs;
7438
7436
  // src/api/generate-readme.ts
7439
7437
  var import_node_stream = require("stream");
7440
7438
 
7441
- // ../../node_modules/.pnpm/simple-git@3.24.0/node_modules/simple-git/dist/esm/index.js
7439
+ // ../../node_modules/.pnpm/simple-git@3.30.0/node_modules/simple-git/dist/esm/index.js
7440
+ var import_node_buffer = require("buffer");
7442
7441
  var import_file_exists = __toESM(require_dist(), 1);
7443
7442
  var import_debug = __toESM(require_src(), 1);
7444
7443
  var import_child_process = require("child_process");
7445
7444
  var import_promise_deferred = __toESM(require_dist2(), 1);
7445
+ var import_node_path = require("path");
7446
7446
  var import_promise_deferred2 = __toESM(require_dist2(), 1);
7447
7447
  var import_node_events = require("events");
7448
7448
  var __defProp2 = Object.defineProperty;
7449
- var __defProps = Object.defineProperties;
7450
7449
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
7451
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7452
7450
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
7453
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7454
7451
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
7455
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7456
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7457
- var __spreadValues = (a, b) => {
7458
- for (var prop in b || (b = {}))
7459
- if (__hasOwnProp2.call(b, prop))
7460
- __defNormalProp(a, prop, b[prop]);
7461
- if (__getOwnPropSymbols)
7462
- for (var prop of __getOwnPropSymbols(b)) {
7463
- if (__propIsEnum.call(b, prop))
7464
- __defNormalProp(a, prop, b[prop]);
7465
- }
7466
- return a;
7467
- };
7468
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7469
7452
  var __esm = (fn, res) => function __init() {
7470
7453
  return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
7471
7454
  };
@@ -7485,26 +7468,6 @@ var __copyProps2 = (to, from, except, desc) => {
7485
7468
  return to;
7486
7469
  };
7487
7470
  var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
7488
- var __async = (__this, __arguments, generator) => {
7489
- return new Promise((resolve7, reject) => {
7490
- var fulfilled = (value) => {
7491
- try {
7492
- step(generator.next(value));
7493
- } catch (e) {
7494
- reject(e);
7495
- }
7496
- };
7497
- var rejected = (value) => {
7498
- try {
7499
- step(generator.throw(value));
7500
- } catch (e) {
7501
- reject(e);
7502
- }
7503
- };
7504
- var step = (x) => x.done ? resolve7(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
7505
- step((generator = generator.apply(__this, __arguments)).next());
7506
- });
7507
- };
7508
7471
  function pathspec(...paths) {
7509
7472
  const key = new String(paths);
7510
7473
  cache.set(key, paths);
@@ -7562,7 +7525,10 @@ var init_task_configuration_error = __esm({
7562
7525
  }
7563
7526
  });
7564
7527
  function asFunction(source) {
7565
- return typeof source === "function" ? source : NOOP;
7528
+ if (typeof source !== "function") {
7529
+ return NOOP;
7530
+ }
7531
+ return source;
7566
7532
  }
7567
7533
  function isUserFunction(source) {
7568
7534
  return typeof source === "function" && source !== NOOP;
@@ -7583,7 +7549,7 @@ function last(input, offset = 0) {
7583
7549
  }
7584
7550
  }
7585
7551
  function isArrayLike(input) {
7586
- return !!(input && typeof input.length === "number");
7552
+ return filterHasLength(input);
7587
7553
  }
7588
7554
  function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
7589
7555
  return input.split(separator).reduce((output, line) => {
@@ -7630,15 +7596,22 @@ function remove(target, item) {
7630
7596
  function asArray(source) {
7631
7597
  return Array.isArray(source) ? source : [source];
7632
7598
  }
7599
+ function asCamelCase(str) {
7600
+ return str.replace(/[\s-]+(.)/g, (_all, chr) => {
7601
+ return chr.toUpperCase();
7602
+ });
7603
+ }
7633
7604
  function asStringArray(source) {
7634
- return asArray(source).map(String);
7605
+ return asArray(source).map((item) => {
7606
+ return item instanceof String ? item : String(item);
7607
+ });
7635
7608
  }
7636
7609
  function asNumber(source, onNaN = 0) {
7637
7610
  if (source == null) {
7638
7611
  return onNaN;
7639
7612
  }
7640
7613
  const num = parseInt(source, 10);
7641
- return isNaN(num) ? onNaN : num;
7614
+ return Number.isNaN(num) ? onNaN : num;
7642
7615
  }
7643
7616
  function prefixedArray(input, prefix) {
7644
7617
  const output = [];
@@ -7648,13 +7621,16 @@ function prefixedArray(input, prefix) {
7648
7621
  return output;
7649
7622
  }
7650
7623
  function bufferToString(input) {
7651
- return (Array.isArray(input) ? Buffer.concat(input) : input).toString("utf-8");
7624
+ return (Array.isArray(input) ? import_node_buffer.Buffer.concat(input) : input).toString("utf-8");
7652
7625
  }
7653
7626
  function pick(source, properties) {
7654
- return Object.assign(
7655
- {},
7656
- ...properties.map((property) => property in source ? { [property]: source[property] } : {})
7657
- );
7627
+ const out = {};
7628
+ properties.forEach((key) => {
7629
+ if (source[key] !== void 0) {
7630
+ out[key] = source[key];
7631
+ }
7632
+ });
7633
+ return out;
7658
7634
  }
7659
7635
  function delay(duration = 0) {
7660
7636
  return new Promise((done) => setTimeout(done, duration));
@@ -7671,6 +7647,7 @@ var objectToString;
7671
7647
  var init_util = __esm({
7672
7648
  "src/lib/utils/util.ts"() {
7673
7649
  "use strict";
7650
+ init_argument_filters();
7674
7651
  NULL = "\0";
7675
7652
  NOOP = () => {
7676
7653
  };
@@ -7694,24 +7671,24 @@ function filterFunction(input) {
7694
7671
  return typeof input === "function";
7695
7672
  }
7696
7673
  var filterArray;
7674
+ var filterNumber;
7697
7675
  var filterString;
7698
- var filterStringArray;
7699
7676
  var filterStringOrStringArray;
7700
7677
  var filterHasLength;
7701
7678
  var init_argument_filters = __esm({
7702
7679
  "src/lib/utils/argument-filters.ts"() {
7703
7680
  "use strict";
7704
- init_util();
7705
7681
  init_pathspec();
7682
+ init_util();
7706
7683
  filterArray = (input) => {
7707
7684
  return Array.isArray(input);
7708
7685
  };
7686
+ filterNumber = (input) => {
7687
+ return typeof input === "number";
7688
+ };
7709
7689
  filterString = (input) => {
7710
7690
  return typeof input === "string";
7711
7691
  };
7712
- filterStringArray = (input) => {
7713
- return Array.isArray(input) && input.every(filterString);
7714
- };
7715
7692
  filterStringOrStringArray = (input) => {
7716
7693
  return filterString(input) || Array.isArray(input) && input.every(filterString);
7717
7694
  };
@@ -7719,7 +7696,7 @@ var init_argument_filters = __esm({
7719
7696
  if (input == null || "number|boolean|function".includes(typeof input)) {
7720
7697
  return false;
7721
7698
  }
7722
- return Array.isArray(input) || typeof input === "string" || typeof input.length === "number";
7699
+ return typeof input.length === "number";
7723
7700
  };
7724
7701
  }
7725
7702
  });
@@ -7740,17 +7717,20 @@ var GitOutputStreams;
7740
7717
  var init_git_output_streams = __esm({
7741
7718
  "src/lib/utils/git-output-streams.ts"() {
7742
7719
  "use strict";
7743
- GitOutputStreams = class {
7720
+ GitOutputStreams = class _GitOutputStreams {
7744
7721
  constructor(stdOut, stdErr) {
7745
7722
  this.stdOut = stdOut;
7746
7723
  this.stdErr = stdErr;
7747
7724
  }
7748
7725
  asStrings() {
7749
- return new GitOutputStreams(this.stdOut.toString("utf8"), this.stdErr.toString("utf8"));
7726
+ return new _GitOutputStreams(this.stdOut.toString("utf8"), this.stdErr.toString("utf8"));
7750
7727
  }
7751
7728
  };
7752
7729
  }
7753
7730
  });
7731
+ function useMatchesDefault() {
7732
+ throw new Error(`LineParser:useMatches not implemented`);
7733
+ }
7754
7734
  var LineParser;
7755
7735
  var RemoteLineParser;
7756
7736
  var init_line_parser = __esm({
@@ -7759,6 +7739,7 @@ var init_line_parser = __esm({
7759
7739
  LineParser = class {
7760
7740
  constructor(regExp, useMatches) {
7761
7741
  this.matches = [];
7742
+ this.useMatches = useMatchesDefault;
7762
7743
  this.parse = (line, target) => {
7763
7744
  this.resetMatches();
7764
7745
  if (!this._regExp.every((reg, index) => this.addMatch(reg, index, line(index)))) {
@@ -7771,9 +7752,6 @@ var init_line_parser = __esm({
7771
7752
  this.useMatches = useMatches;
7772
7753
  }
7773
7754
  }
7774
- useMatches(target, match) {
7775
- throw new Error(`LineParser:useMatches not implemented`);
7776
- }
7777
7755
  resetMatches() {
7778
7756
  this.matches.length = 0;
7779
7757
  }
@@ -7806,7 +7784,7 @@ var init_line_parser = __esm({
7806
7784
  function createInstanceConfig(...options) {
7807
7785
  const baseDir = process.cwd();
7808
7786
  const config = Object.assign(
7809
- __spreadValues({ baseDir }, defaultOptions),
7787
+ { baseDir, ...defaultOptions },
7810
7788
  ...options.filter((o) => typeof o === "object" && o)
7811
7789
  );
7812
7790
  config.baseDir = config.baseDir || baseDir;
@@ -7835,6 +7813,12 @@ function appendTaskOptions(options, commands = []) {
7835
7813
  commands2.push(value);
7836
7814
  } else if (filterPrimitives(value, ["boolean"])) {
7837
7815
  commands2.push(key + "=" + value);
7816
+ } else if (Array.isArray(value)) {
7817
+ for (const v of value) {
7818
+ if (!filterPrimitives(v, ["string", "number"])) {
7819
+ commands2.push(key + "=" + v);
7820
+ }
7821
+ }
7838
7822
  } else {
7839
7823
  commands2.push(key);
7840
7824
  }
@@ -7856,7 +7840,7 @@ function getTrailingOptions(args, initialPrimitive = 0, objectOnly = false) {
7856
7840
  }
7857
7841
  function trailingArrayArgument(args) {
7858
7842
  const hasTrailingCallback = typeof last(args) === "function";
7859
- return filterType(last(args, hasTrailingCallback ? 1 : 0), filterArray, []);
7843
+ return asStringArray(filterType(last(args, hasTrailingCallback ? 1 : 0), filterArray, []));
7860
7844
  }
7861
7845
  function trailingOptionsArgument(args) {
7862
7846
  const hasTrailingCallback = filterFunction(last(args));
@@ -7874,8 +7858,8 @@ var init_task_options = __esm({
7874
7858
  init_pathspec();
7875
7859
  }
7876
7860
  });
7877
- function callTaskParser(parser3, streams) {
7878
- return parser3(streams.stdOut, streams.stdErr);
7861
+ function callTaskParser(parser4, streams) {
7862
+ return parser4(streams.stdOut, streams.stdErr);
7879
7863
  }
7880
7864
  function parseStringResponse(result, parsers12, texts, trim = true) {
7881
7865
  asArray(texts).forEach((text) => {
@@ -7908,6 +7892,7 @@ __export2(utils_exports, {
7908
7892
  append: () => append,
7909
7893
  appendTaskOptions: () => appendTaskOptions,
7910
7894
  asArray: () => asArray,
7895
+ asCamelCase: () => asCamelCase,
7911
7896
  asFunction: () => asFunction,
7912
7897
  asNumber: () => asNumber,
7913
7898
  asStringArray: () => asStringArray,
@@ -7918,10 +7903,10 @@ __export2(utils_exports, {
7918
7903
  filterArray: () => filterArray,
7919
7904
  filterFunction: () => filterFunction,
7920
7905
  filterHasLength: () => filterHasLength,
7906
+ filterNumber: () => filterNumber,
7921
7907
  filterPlainObject: () => filterPlainObject,
7922
7908
  filterPrimitives: () => filterPrimitives,
7923
7909
  filterString: () => filterString,
7924
- filterStringArray: () => filterStringArray,
7925
7910
  filterStringOrStringArray: () => filterStringOrStringArray,
7926
7911
  filterType: () => filterType,
7927
7912
  first: () => first,
@@ -8065,11 +8050,11 @@ __export2(task_exports, {
8065
8050
  straightThroughBufferTask: () => straightThroughBufferTask,
8066
8051
  straightThroughStringTask: () => straightThroughStringTask
8067
8052
  });
8068
- function adhocExecTask(parser3) {
8053
+ function adhocExecTask(parser4) {
8069
8054
  return {
8070
8055
  commands: EMPTY_COMMANDS,
8071
8056
  format: "empty",
8072
- parser: parser3
8057
+ parser: parser4
8073
8058
  };
8074
8059
  }
8075
8060
  function configurationErrorTask(error) {
@@ -8284,7 +8269,7 @@ var init_ConfigList = __esm({
8284
8269
  }
8285
8270
  addValue(file, key, value) {
8286
8271
  const values = this.addFile(file);
8287
- if (!values.hasOwnProperty(key)) {
8272
+ if (!Object.hasOwn(values, key)) {
8288
8273
  values[key] = value;
8289
8274
  } else if (Array.isArray(values[key])) {
8290
8275
  values[key].push(value);
@@ -8297,7 +8282,7 @@ var init_ConfigList = __esm({
8297
8282
  }
8298
8283
  });
8299
8284
  function asConfigScope(scope, fallback) {
8300
- if (typeof scope === "string" && GitConfigScope.hasOwnProperty(scope)) {
8285
+ if (typeof scope === "string" && Object.hasOwn(GitConfigScope, scope)) {
8301
8286
  return scope;
8302
8287
  }
8303
8288
  return fallback;
@@ -8518,13 +8503,14 @@ function getResetMode(mode) {
8518
8503
  return;
8519
8504
  }
8520
8505
  function isValidResetMode(mode) {
8521
- return ResetModes.includes(mode);
8506
+ return typeof mode === "string" && validResetModes.includes(mode);
8522
8507
  }
8523
8508
  var ResetMode;
8524
- var ResetModes;
8509
+ var validResetModes;
8525
8510
  var init_reset = __esm({
8526
8511
  "src/lib/tasks/reset.ts"() {
8527
8512
  "use strict";
8513
+ init_utils();
8528
8514
  init_task();
8529
8515
  ResetMode = /* @__PURE__ */ ((ResetMode2) => {
8530
8516
  ResetMode2["MIXED"] = "mixed";
@@ -8534,7 +8520,7 @@ var init_reset = __esm({
8534
8520
  ResetMode2["KEEP"] = "keep";
8535
8521
  return ResetMode2;
8536
8522
  })(ResetMode || {});
8537
- ResetModes = Array.from(Object.values(ResetMode));
8523
+ validResetModes = asStringArray(Object.values(ResetMode));
8538
8524
  }
8539
8525
  });
8540
8526
  function createLog() {
@@ -8601,14 +8587,13 @@ var init_git_logger = __esm({
8601
8587
  };
8602
8588
  }
8603
8589
  });
8604
- var _TasksPendingQueue;
8605
8590
  var TasksPendingQueue;
8606
8591
  var init_tasks_pending_queue = __esm({
8607
8592
  "src/lib/runners/tasks-pending-queue.ts"() {
8608
8593
  "use strict";
8609
8594
  init_git_error();
8610
8595
  init_git_logger();
8611
- _TasksPendingQueue = class {
8596
+ TasksPendingQueue = class _TasksPendingQueue {
8612
8597
  constructor(logLabel = "GitExecutor") {
8613
8598
  this.logLabel = logLabel;
8614
8599
  this._queue = /* @__PURE__ */ new Map();
@@ -8667,9 +8652,10 @@ var init_tasks_pending_queue = __esm({
8667
8652
  static getName(name = "empty") {
8668
8653
  return `task:${name}:${++_TasksPendingQueue.counter}`;
8669
8654
  }
8655
+ static {
8656
+ this.counter = 0;
8657
+ }
8670
8658
  };
8671
- TasksPendingQueue = _TasksPendingQueue;
8672
- TasksPendingQueue.counter = 0;
8673
8659
  }
8674
8660
  });
8675
8661
  function pluginContext(task, commands) {
@@ -8726,20 +8712,18 @@ var init_git_executor_chain = __esm({
8726
8712
  this._queue.push(task);
8727
8713
  return this._chain = this._chain.then(() => this.attemptTask(task));
8728
8714
  }
8729
- attemptTask(task) {
8730
- return __async(this, null, function* () {
8731
- const onScheduleComplete = yield this._scheduler.next();
8732
- const onQueueComplete = () => this._queue.complete(task);
8733
- try {
8734
- const { logger } = this._queue.attempt(task);
8735
- return yield isEmptyTask(task) ? this.attemptEmptyTask(task, logger) : this.attemptRemoteTask(task, logger);
8736
- } catch (e) {
8737
- throw this.onFatalException(task, e);
8738
- } finally {
8739
- onQueueComplete();
8740
- onScheduleComplete();
8741
- }
8742
- });
8715
+ async attemptTask(task) {
8716
+ const onScheduleComplete = await this._scheduler.next();
8717
+ const onQueueComplete = () => this._queue.complete(task);
8718
+ try {
8719
+ const { logger } = this._queue.attempt(task);
8720
+ return await (isEmptyTask(task) ? this.attemptEmptyTask(task, logger) : this.attemptRemoteTask(task, logger));
8721
+ } catch (e) {
8722
+ throw this.onFatalException(task, e);
8723
+ } finally {
8724
+ onQueueComplete();
8725
+ onScheduleComplete();
8726
+ }
8743
8727
  }
8744
8728
  onFatalException(task, e) {
8745
8729
  const gitError = e instanceof GitError ? Object.assign(e, { task }) : new GitError(task, e && String(e));
@@ -8747,34 +8731,30 @@ var init_git_executor_chain = __esm({
8747
8731
  this._queue.fatal(gitError);
8748
8732
  return gitError;
8749
8733
  }
8750
- attemptRemoteTask(task, logger) {
8751
- return __async(this, null, function* () {
8752
- const binary = this._plugins.exec("spawn.binary", "", pluginContext(task, task.commands));
8753
- const args = this._plugins.exec(
8754
- "spawn.args",
8755
- [...task.commands],
8756
- pluginContext(task, task.commands)
8757
- );
8758
- const raw = yield this.gitResponse(
8759
- task,
8760
- binary,
8761
- args,
8762
- this.outputHandler,
8763
- logger.step("SPAWN")
8764
- );
8765
- const outputStreams = yield this.handleTaskData(task, args, raw, logger.step("HANDLE"));
8766
- logger(`passing response to task's parser as a %s`, task.format);
8767
- if (isBufferTask(task)) {
8768
- return callTaskParser(task.parser, outputStreams);
8769
- }
8770
- return callTaskParser(task.parser, outputStreams.asStrings());
8771
- });
8734
+ async attemptRemoteTask(task, logger) {
8735
+ const binary = this._plugins.exec("spawn.binary", "", pluginContext(task, task.commands));
8736
+ const args = this._plugins.exec(
8737
+ "spawn.args",
8738
+ [...task.commands],
8739
+ pluginContext(task, task.commands)
8740
+ );
8741
+ const raw = await this.gitResponse(
8742
+ task,
8743
+ binary,
8744
+ args,
8745
+ this.outputHandler,
8746
+ logger.step("SPAWN")
8747
+ );
8748
+ const outputStreams = await this.handleTaskData(task, args, raw, logger.step("HANDLE"));
8749
+ logger(`passing response to task's parser as a %s`, task.format);
8750
+ if (isBufferTask(task)) {
8751
+ return callTaskParser(task.parser, outputStreams);
8752
+ }
8753
+ return callTaskParser(task.parser, outputStreams.asStrings());
8772
8754
  }
8773
- attemptEmptyTask(task, logger) {
8774
- return __async(this, null, function* () {
8775
- logger(`empty task bypassing child process to call to task's parser`);
8776
- return task.parser(this);
8777
- });
8755
+ async attemptEmptyTask(task, logger) {
8756
+ logger(`empty task bypassing child process to call to task's parser`);
8757
+ return task.parser(this);
8778
8758
  }
8779
8759
  handleTaskData(task, args, result, logger) {
8780
8760
  const { exitCode, rejection, stdOut, stdErr } = result;
@@ -8783,7 +8763,10 @@ var init_git_executor_chain = __esm({
8783
8763
  const { error } = this._plugins.exec(
8784
8764
  "task.error",
8785
8765
  { error: rejection },
8786
- __spreadValues(__spreadValues({}, pluginContext(task, args)), result)
8766
+ {
8767
+ ...pluginContext(task, args),
8768
+ ...result
8769
+ }
8787
8770
  );
8788
8771
  if (error && task.onError) {
8789
8772
  logger.info(`exitCode=%s handling with custom error handler`);
@@ -8816,79 +8799,80 @@ var init_git_executor_chain = __esm({
8816
8799
  done(new GitOutputStreams(Buffer.concat(stdOut), Buffer.concat(stdErr)));
8817
8800
  });
8818
8801
  }
8819
- gitResponse(task, command, args, outputHandler, logger) {
8820
- return __async(this, null, function* () {
8821
- const outputLogger = logger.sibling("output");
8822
- const spawnOptions = this._plugins.exec(
8823
- "spawn.options",
8824
- {
8825
- cwd: this.cwd,
8826
- env: this.env,
8827
- windowsHide: true
8828
- },
8829
- pluginContext(task, task.commands)
8802
+ async gitResponse(task, command, args, outputHandler, logger) {
8803
+ const outputLogger = logger.sibling("output");
8804
+ const spawnOptions = this._plugins.exec(
8805
+ "spawn.options",
8806
+ {
8807
+ cwd: this.cwd,
8808
+ env: this.env,
8809
+ windowsHide: true
8810
+ },
8811
+ pluginContext(task, task.commands)
8812
+ );
8813
+ return new Promise((done) => {
8814
+ const stdOut = [];
8815
+ const stdErr = [];
8816
+ logger.info(`%s %o`, command, args);
8817
+ logger("%O", spawnOptions);
8818
+ let rejection = this._beforeSpawn(task, args);
8819
+ if (rejection) {
8820
+ return done({
8821
+ stdOut,
8822
+ stdErr,
8823
+ exitCode: 9901,
8824
+ rejection
8825
+ });
8826
+ }
8827
+ this._plugins.exec("spawn.before", void 0, {
8828
+ ...pluginContext(task, args),
8829
+ kill(reason) {
8830
+ rejection = reason || rejection;
8831
+ }
8832
+ });
8833
+ const spawned = (0, import_child_process.spawn)(command, args, spawnOptions);
8834
+ spawned.stdout.on(
8835
+ "data",
8836
+ onDataReceived(stdOut, "stdOut", logger, outputLogger.step("stdOut"))
8830
8837
  );
8831
- return new Promise((done) => {
8832
- const stdOut = [];
8833
- const stdErr = [];
8834
- logger.info(`%s %o`, command, args);
8835
- logger("%O", spawnOptions);
8836
- let rejection = this._beforeSpawn(task, args);
8837
- if (rejection) {
8838
- return done({
8838
+ spawned.stderr.on(
8839
+ "data",
8840
+ onDataReceived(stdErr, "stdErr", logger, outputLogger.step("stdErr"))
8841
+ );
8842
+ spawned.on("error", onErrorReceived(stdErr, logger));
8843
+ if (outputHandler) {
8844
+ logger(`Passing child process stdOut/stdErr to custom outputHandler`);
8845
+ outputHandler(command, spawned.stdout, spawned.stderr, [...args]);
8846
+ }
8847
+ this._plugins.exec("spawn.after", void 0, {
8848
+ ...pluginContext(task, args),
8849
+ spawned,
8850
+ close(exitCode, reason) {
8851
+ done({
8839
8852
  stdOut,
8840
8853
  stdErr,
8841
- exitCode: 9901,
8842
- rejection
8854
+ exitCode,
8855
+ rejection: rejection || reason
8843
8856
  });
8844
- }
8845
- this._plugins.exec("spawn.before", void 0, __spreadProps(__spreadValues({}, pluginContext(task, args)), {
8846
- kill(reason) {
8847
- rejection = reason || rejection;
8857
+ },
8858
+ kill(reason) {
8859
+ if (spawned.killed) {
8860
+ return;
8848
8861
  }
8849
- }));
8850
- const spawned = (0, import_child_process.spawn)(command, args, spawnOptions);
8851
- spawned.stdout.on(
8852
- "data",
8853
- onDataReceived(stdOut, "stdOut", logger, outputLogger.step("stdOut"))
8854
- );
8855
- spawned.stderr.on(
8856
- "data",
8857
- onDataReceived(stdErr, "stdErr", logger, outputLogger.step("stdErr"))
8858
- );
8859
- spawned.on("error", onErrorReceived(stdErr, logger));
8860
- if (outputHandler) {
8861
- logger(`Passing child process stdOut/stdErr to custom outputHandler`);
8862
- outputHandler(command, spawned.stdout, spawned.stderr, [...args]);
8862
+ rejection = reason;
8863
+ spawned.kill("SIGINT");
8863
8864
  }
8864
- this._plugins.exec("spawn.after", void 0, __spreadProps(__spreadValues({}, pluginContext(task, args)), {
8865
- spawned,
8866
- close(exitCode, reason) {
8867
- done({
8868
- stdOut,
8869
- stdErr,
8870
- exitCode,
8871
- rejection: rejection || reason
8872
- });
8873
- },
8874
- kill(reason) {
8875
- if (spawned.killed) {
8876
- return;
8877
- }
8878
- rejection = reason;
8879
- spawned.kill("SIGINT");
8880
- }
8881
- }));
8882
8865
  });
8883
8866
  });
8884
8867
  }
8885
8868
  _beforeSpawn(task, args) {
8886
8869
  let rejection;
8887
- this._plugins.exec("spawn.before", void 0, __spreadProps(__spreadValues({}, pluginContext(task, args)), {
8870
+ this._plugins.exec("spawn.before", void 0, {
8871
+ ...pluginContext(task, args),
8888
8872
  kill(reason) {
8889
8873
  rejection = reason || rejection;
8890
8874
  }
8891
- }));
8875
+ });
8892
8876
  return rejection;
8893
8877
  }
8894
8878
  };
@@ -8924,7 +8908,7 @@ function taskCallback(task, response, callback = NOOP) {
8924
8908
  callback(null, data);
8925
8909
  };
8926
8910
  const onError2 = (err) => {
8927
- if ((err == null ? void 0 : err.task) === task) {
8911
+ if (err?.task === task) {
8928
8912
  callback(
8929
8913
  err instanceof GitResponseError ? addDeprecationNoticeToError(err) : err,
8930
8914
  void 0
@@ -9014,6 +8998,47 @@ var init_checkout = __esm({
9014
8998
  init_task();
9015
8999
  }
9016
9000
  });
9001
+ function countObjectsResponse() {
9002
+ return {
9003
+ count: 0,
9004
+ garbage: 0,
9005
+ inPack: 0,
9006
+ packs: 0,
9007
+ prunePackable: 0,
9008
+ size: 0,
9009
+ sizeGarbage: 0,
9010
+ sizePack: 0
9011
+ };
9012
+ }
9013
+ function count_objects_default() {
9014
+ return {
9015
+ countObjects() {
9016
+ return this._runTask({
9017
+ commands: ["count-objects", "--verbose"],
9018
+ format: "utf-8",
9019
+ parser(stdOut) {
9020
+ return parseStringResponse(countObjectsResponse(), [parser22], stdOut);
9021
+ }
9022
+ });
9023
+ }
9024
+ };
9025
+ }
9026
+ var parser22;
9027
+ var init_count_objects = __esm({
9028
+ "src/lib/tasks/count-objects.ts"() {
9029
+ "use strict";
9030
+ init_utils();
9031
+ parser22 = new LineParser(
9032
+ /([a-z-]+): (\d+)$/,
9033
+ (result, [key, value]) => {
9034
+ const property = asCamelCase(key);
9035
+ if (Object.hasOwn(result, property)) {
9036
+ result[property] = asNumber(value);
9037
+ }
9038
+ }
9039
+ );
9040
+ }
9041
+ });
9017
9042
  function parseCommitResult(stdOut) {
9018
9043
  const result = {
9019
9044
  author: null,
@@ -9095,7 +9120,10 @@ function commit_default() {
9095
9120
  const task = rejectDeprecatedSignatures(message) || commitTask(
9096
9121
  asArray(message),
9097
9122
  asArray(filterType(rest[0], filterStringOrStringArray, [])),
9098
- [...filterType(rest[1], filterArray, []), ...getTrailingOptions(arguments, 0, true)]
9123
+ [
9124
+ ...asStringArray(filterType(rest[1], filterArray, [])),
9125
+ ...getTrailingOptions(arguments, 0, true)
9126
+ ]
9099
9127
  );
9100
9128
  return this._runTask(task, next);
9101
9129
  }
@@ -9240,8 +9268,8 @@ var init_DiffSummary = __esm({
9240
9268
  }
9241
9269
  });
9242
9270
  function getDiffParser(format3 = "") {
9243
- const parser3 = diffSummaryParsers[format3];
9244
- return (stdOut) => parseStringResponse(new DiffSummary(), parser3, stdOut, false);
9271
+ const parser4 = diffSummaryParsers[format3];
9272
+ return (stdOut) => parseStringResponse(new DiffSummary(), parser4, stdOut, false);
9245
9273
  }
9246
9274
  var statParser;
9247
9275
  var numStatParser;
@@ -9285,8 +9313,8 @@ var init_parse_diff_summary = __esm({
9285
9313
  const inserted = /(\d+) i/.exec(summary);
9286
9314
  const deleted = /(\d+) d/.exec(summary);
9287
9315
  result.changed = asNumber(changed);
9288
- result.insertions = asNumber(inserted == null ? void 0 : inserted[1]);
9289
- result.deletions = asNumber(deleted == null ? void 0 : deleted[1]);
9316
+ result.insertions = asNumber(inserted?.[1]);
9317
+ result.deletions = asNumber(deleted?.[1]);
9290
9318
  }
9291
9319
  )
9292
9320
  ];
@@ -9333,15 +9361,17 @@ var init_parse_diff_summary = __esm({
9333
9361
  nameStatusParser = [
9334
9362
  new LineParser(
9335
9363
  /([ACDMRTUXB])([0-9]{0,3})\t(.[^\t]*)(\t(.[^\t]*))?$/,
9336
- (result, [status, _similarity, from, _to, to]) => {
9364
+ (result, [status, similarity, from, _to, to]) => {
9337
9365
  result.changed++;
9338
9366
  result.files.push({
9339
- file: to != null ? to : from,
9367
+ file: to ?? from,
9340
9368
  changes: 0,
9341
- status: orVoid(isDiffNameStatus(status) && status),
9342
9369
  insertions: 0,
9343
9370
  deletions: 0,
9344
- binary: false
9371
+ binary: false,
9372
+ status: orVoid(isDiffNameStatus(status) && status),
9373
+ from: orVoid(!!to && from !== to && from),
9374
+ similarity: asNumber(similarity)
9345
9375
  });
9346
9376
  }
9347
9377
  )
@@ -9383,15 +9413,12 @@ function createListLogSummaryParser(splitter = SPLITTER, fields = defaultFieldNa
9383
9413
  const parseDiffResult = getDiffParser(logFormat);
9384
9414
  return function(stdOut) {
9385
9415
  const all = toLinesWithContent(
9386
- stdOut,
9387
- true,
9416
+ stdOut.trim(),
9417
+ false,
9388
9418
  START_BOUNDARY
9389
9419
  ).map(function(item) {
9390
- const lineDetail = item.trim().split(COMMIT_BOUNDARY);
9391
- const listLogLine = lineBuilder(
9392
- lineDetail[0].trim().split(splitter),
9393
- fields
9394
- );
9420
+ const lineDetail = item.split(COMMIT_BOUNDARY);
9421
+ const listLogLine = lineBuilder(lineDetail[0].split(splitter), fields);
9395
9422
  if (lineDetail.length > 1 && !!lineDetail[1].trim()) {
9396
9423
  listLogLine.diff = parseDiffResult(lineDetail[1]);
9397
9424
  }
@@ -9479,7 +9506,7 @@ function userOptions(input) {
9479
9506
  }
9480
9507
  function parseLogOptions(opt = {}, customArgs = []) {
9481
9508
  const splitter = filterType(opt.splitter, filterString, SPLITTER);
9482
- const format3 = !filterPrimitives(opt.format) && opt.format ? opt.format : {
9509
+ const format3 = filterPlainObject(opt.format) ? opt.format : {
9483
9510
  hash: "%H",
9484
9511
  date: opt.strictDate === false ? "%ai" : "%aI",
9485
9512
  message: "%s",
@@ -9513,11 +9540,11 @@ function parseLogOptions(opt = {}, customArgs = []) {
9513
9540
  };
9514
9541
  }
9515
9542
  function logTask(splitter, fields, customArgs) {
9516
- const parser3 = createListLogSummaryParser(splitter, fields, logFormatFromCommand(customArgs));
9543
+ const parser4 = createListLogSummaryParser(splitter, fields, logFormatFromCommand(customArgs));
9517
9544
  return {
9518
9545
  commands: ["log", ...customArgs],
9519
9546
  format: "utf-8",
9520
- parser: parser3
9547
+ parser: parser4
9521
9548
  };
9522
9549
  }
9523
9550
  function log_default() {
@@ -9526,7 +9553,7 @@ function log_default() {
9526
9553
  const next = trailingFunctionArgument(arguments);
9527
9554
  const options = parseLogOptions(
9528
9555
  trailingOptionsArgument(arguments),
9529
- filterType(arguments[0], filterArray)
9556
+ asStringArray(filterType(arguments[0], filterArray, []))
9530
9557
  );
9531
9558
  const task = rejectDeprecatedSignatures(...rest) || validateLogFormatConfig(options.commands) || createLogTask(options);
9532
9559
  return this._runTask(task, next);
@@ -9895,9 +9922,10 @@ var init_parse_push = __esm({
9895
9922
  result.repo = repo;
9896
9923
  }),
9897
9924
  new LineParser(/^updating local tracking ref '(.+)'/, (result, [local]) => {
9898
- result.ref = __spreadProps(__spreadValues({}, result.ref || {}), {
9925
+ result.ref = {
9926
+ ...result.ref || {},
9899
9927
  local
9900
- });
9928
+ };
9901
9929
  }),
9902
9930
  new LineParser(/^[=*-]\s+([^:]+):(\S+)\s+\[(.+)]$/, (result, [local, remote, type]) => {
9903
9931
  result.pushed.push(pushResultPushedItem(local, remote, type));
@@ -9905,11 +9933,12 @@ var init_parse_push = __esm({
9905
9933
  new LineParser(
9906
9934
  /^Branch '([^']+)' set up to track remote branch '([^']+)' from '([^']+)'/,
9907
9935
  (result, [local, remote, remoteName]) => {
9908
- result.branch = __spreadProps(__spreadValues({}, result.branch || {}), {
9936
+ result.branch = {
9937
+ ...result.branch || {},
9909
9938
  local,
9910
9939
  remote,
9911
9940
  remoteName
9912
- });
9941
+ };
9913
9942
  }
9914
9943
  ),
9915
9944
  new LineParser(
@@ -9931,7 +9960,10 @@ var init_parse_push = __esm({
9931
9960
  parsePushResult = (stdOut, stdErr) => {
9932
9961
  const pushDetail = parsePushDetail(stdOut, stdErr);
9933
9962
  const responseDetail = parseRemoteMessages(stdOut, stdErr);
9934
- return __spreadValues(__spreadValues({}, pushDetail), responseDetail);
9963
+ return {
9964
+ ...pushDetail,
9965
+ ...responseDetail
9966
+ };
9935
9967
  };
9936
9968
  parsePushDetail = (stdOut, stdErr) => {
9937
9969
  return parseStringResponse({ pushed: [] }, parsers5, [stdOut, stdErr]);
@@ -10004,16 +10036,16 @@ var FileStatusSummary;
10004
10036
  var init_FileStatusSummary = __esm({
10005
10037
  "src/lib/responses/FileStatusSummary.ts"() {
10006
10038
  "use strict";
10007
- fromPathRegex = /^(.+) -> (.+)$/;
10039
+ fromPathRegex = /^(.+)\0(.+)$/;
10008
10040
  FileStatusSummary = class {
10009
10041
  constructor(path4, index, working_dir) {
10010
10042
  this.path = path4;
10011
10043
  this.index = index;
10012
10044
  this.working_dir = working_dir;
10013
- if ("R" === index + working_dir) {
10045
+ if (index === "R" || working_dir === "R") {
10014
10046
  const detail = fromPathRegex.exec(path4) || [null, path4, path4];
10015
- this.from = detail[1] || "";
10016
- this.path = detail[2] || "";
10047
+ this.from = detail[2] || "";
10048
+ this.path = detail[1] || "";
10017
10049
  }
10018
10050
  }
10019
10051
  };
@@ -10026,11 +10058,11 @@ function renamedFile(line) {
10026
10058
  to
10027
10059
  };
10028
10060
  }
10029
- function parser22(indexX, indexY, handler) {
10061
+ function parser3(indexX, indexY, handler) {
10030
10062
  return [`${indexX}${indexY}`, handler];
10031
10063
  }
10032
10064
  function conflicts(indexX, ...indexY) {
10033
- return indexY.map((y) => parser22(indexX, y, (result, file) => append(result.conflicted, file)));
10065
+ return indexY.map((y) => parser3(indexX, y, (result, file) => append(result.conflicted, file)));
10034
10066
  }
10035
10067
  function splitLine(result, lineStr) {
10036
10068
  const trimmed2 = lineStr.trim();
@@ -10049,7 +10081,7 @@ function splitLine(result, lineStr) {
10049
10081
  handler(result, path4);
10050
10082
  }
10051
10083
  if (raw !== "##" && raw !== "!!") {
10052
- result.files.push(new FileStatusSummary(path4.replace(/\0.+$/, ""), index, workingDir));
10084
+ result.files.push(new FileStatusSummary(path4, index, workingDir));
10053
10085
  }
10054
10086
  }
10055
10087
  }
@@ -10083,58 +10115,58 @@ var init_StatusSummary = __esm({
10083
10115
  }
10084
10116
  };
10085
10117
  parsers6 = new Map([
10086
- parser22(
10118
+ parser3(
10087
10119
  " ",
10088
10120
  "A",
10089
10121
  (result, file) => append(result.created, file)
10090
10122
  ),
10091
- parser22(
10123
+ parser3(
10092
10124
  " ",
10093
10125
  "D",
10094
10126
  (result, file) => append(result.deleted, file)
10095
10127
  ),
10096
- parser22(
10128
+ parser3(
10097
10129
  " ",
10098
10130
  "M",
10099
10131
  (result, file) => append(result.modified, file)
10100
10132
  ),
10101
- parser22(
10133
+ parser3(
10102
10134
  "A",
10103
10135
  " ",
10104
10136
  (result, file) => append(result.created, file) && append(result.staged, file)
10105
10137
  ),
10106
- parser22(
10138
+ parser3(
10107
10139
  "A",
10108
10140
  "M",
10109
10141
  (result, file) => append(result.created, file) && append(result.staged, file) && append(result.modified, file)
10110
10142
  ),
10111
- parser22(
10143
+ parser3(
10112
10144
  "D",
10113
10145
  " ",
10114
10146
  (result, file) => append(result.deleted, file) && append(result.staged, file)
10115
10147
  ),
10116
- parser22(
10148
+ parser3(
10117
10149
  "M",
10118
10150
  " ",
10119
10151
  (result, file) => append(result.modified, file) && append(result.staged, file)
10120
10152
  ),
10121
- parser22(
10153
+ parser3(
10122
10154
  "M",
10123
10155
  "M",
10124
10156
  (result, file) => append(result.modified, file) && append(result.staged, file)
10125
10157
  ),
10126
- parser22("R", " ", (result, file) => {
10158
+ parser3("R", " ", (result, file) => {
10127
10159
  append(result.renamed, renamedFile(file));
10128
10160
  }),
10129
- parser22("R", "M", (result, file) => {
10161
+ parser3("R", "M", (result, file) => {
10130
10162
  const renamed = renamedFile(file);
10131
10163
  append(result.renamed, renamed);
10132
10164
  append(result.modified, renamed.to);
10133
10165
  }),
10134
- parser22("!", "!", (_result, _file) => {
10166
+ parser3("!", "!", (_result, _file) => {
10135
10167
  append(_result.ignored = _result.ignored || [], _file);
10136
10168
  }),
10137
- parser22(
10169
+ parser3(
10138
10170
  "?",
10139
10171
  "?",
10140
10172
  (result, file) => append(result.not_added, file)
@@ -10165,18 +10197,19 @@ var init_StatusSummary = __esm({
10165
10197
  const behindReg = /behind (\d+)/;
10166
10198
  const currentReg = /^(.+?(?=(?:\.{3}|\s|$)))/;
10167
10199
  const trackingReg = /\.{3}(\S*)/;
10168
- const onEmptyBranchReg = /\son\s([\S]+)$/;
10169
- let regexResult;
10170
- regexResult = aheadReg.exec(line);
10200
+ const onEmptyBranchReg = /\son\s(\S+?)(?=\.{3}|$)/;
10201
+ let regexResult = aheadReg.exec(line);
10171
10202
  result.ahead = regexResult && +regexResult[1] || 0;
10172
10203
  regexResult = behindReg.exec(line);
10173
10204
  result.behind = regexResult && +regexResult[1] || 0;
10174
10205
  regexResult = currentReg.exec(line);
10175
- result.current = regexResult && regexResult[1];
10206
+ result.current = filterType(regexResult?.[1], filterString, null);
10176
10207
  regexResult = trackingReg.exec(line);
10177
- result.tracking = regexResult && regexResult[1];
10208
+ result.tracking = filterType(regexResult?.[1], filterString, null);
10178
10209
  regexResult = onEmptyBranchReg.exec(line);
10179
- result.current = regexResult && regexResult[1] || result.current;
10210
+ if (regexResult) {
10211
+ result.current = filterType(regexResult?.[1], filterString, result.current);
10212
+ }
10180
10213
  result.detached = /\(no branch\)/.test(line);
10181
10214
  }
10182
10215
  ]
@@ -10305,6 +10338,7 @@ var init_simple_git_api = __esm({
10305
10338
  init_task_callback();
10306
10339
  init_change_working_directory();
10307
10340
  init_checkout();
10341
+ init_count_objects();
10308
10342
  init_commit();
10309
10343
  init_config();
10310
10344
  init_first_commit();
@@ -10346,7 +10380,7 @@ var init_simple_git_api = __esm({
10346
10380
  if (typeof directory === "string") {
10347
10381
  return this._runTask(changeWorkingDirectoryTask(directory, this._executor), next);
10348
10382
  }
10349
- if (typeof (directory == null ? void 0 : directory.path) === "string") {
10383
+ if (typeof directory?.path === "string") {
10350
10384
  return this._runTask(
10351
10385
  changeWorkingDirectoryTask(
10352
10386
  directory.path,
@@ -10423,6 +10457,7 @@ var init_simple_git_api = __esm({
10423
10457
  checkout_default(),
10424
10458
  commit_default(),
10425
10459
  config_default(),
10460
+ count_objects_default(),
10426
10461
  first_commit_default(),
10427
10462
  grep_default(),
10428
10463
  log_default(),
@@ -10595,10 +10630,15 @@ var init_BranchSummary = __esm({
10595
10630
  function branchStatus(input) {
10596
10631
  return input ? input.charAt(0) : "";
10597
10632
  }
10598
- function parseBranchSummary(stdOut) {
10599
- return parseStringResponse(new BranchSummaryResult(), parsers9, stdOut);
10633
+ function parseBranchSummary(stdOut, currentOnly = false) {
10634
+ return parseStringResponse(
10635
+ new BranchSummaryResult(),
10636
+ currentOnly ? [currentBranchParser] : parsers9,
10637
+ stdOut
10638
+ );
10600
10639
  }
10601
10640
  var parsers9;
10641
+ var currentBranchParser;
10602
10642
  var init_parse_branch = __esm({
10603
10643
  "src/lib/parsers/parse-branch.ts"() {
10604
10644
  "use strict";
@@ -10612,12 +10652,15 @@ var init_parse_branch = __esm({
10612
10652
  }
10613
10653
  ),
10614
10654
  new LineParser(
10615
- new RegExp("^([*+]\\s)?(\\S+)\\s+([a-z0-9]+)\\s?(.*)$", "s"),
10655
+ /^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s,
10616
10656
  (result, [current, name, commit, label]) => {
10617
10657
  result.push(branchStatus(current), false, name, commit, label);
10618
10658
  }
10619
10659
  )
10620
10660
  ];
10661
+ currentBranchParser = new LineParser(/^(\S+)$/s, (result, [name]) => {
10662
+ result.push("*", false, name, "", "");
10663
+ });
10621
10664
  }
10622
10665
  });
10623
10666
  var branch_exports = {};
@@ -10634,6 +10677,7 @@ function containsDeleteBranchCommand(commands) {
10634
10677
  }
10635
10678
  function branchTask(customArgs) {
10636
10679
  const isDelete = containsDeleteBranchCommand(customArgs);
10680
+ const isCurrentOnly = customArgs.includes("--show-current");
10637
10681
  const commands = ["branch", ...customArgs];
10638
10682
  if (commands.length === 1) {
10639
10683
  commands.push("-a");
@@ -10648,16 +10692,17 @@ function branchTask(customArgs) {
10648
10692
  if (isDelete) {
10649
10693
  return parseBranchDeletions(stdOut, stdErr).all[0];
10650
10694
  }
10651
- return parseBranchSummary(stdOut);
10695
+ return parseBranchSummary(stdOut, isCurrentOnly);
10652
10696
  }
10653
10697
  };
10654
10698
  }
10655
10699
  function branchLocalTask() {
10656
- const parser3 = parseBranchSummary;
10657
10700
  return {
10658
10701
  format: "utf-8",
10659
10702
  commands: ["branch", "-v"],
10660
- parser: parser3
10703
+ parser(stdOut) {
10704
+ return parseBranchSummary(stdOut);
10705
+ }
10661
10706
  };
10662
10707
  }
10663
10708
  function deleteBranchesTask(branches, forceDelete = false) {
@@ -10703,12 +10748,16 @@ var init_branch = __esm({
10703
10748
  init_utils();
10704
10749
  }
10705
10750
  });
10751
+ function toPath(input) {
10752
+ const path4 = input.trim().replace(/^["']|["']$/g, "");
10753
+ return path4 && (0, import_node_path.normalize)(path4);
10754
+ }
10706
10755
  var parseCheckIgnore;
10707
10756
  var init_CheckIgnore = __esm({
10708
10757
  "src/lib/responses/CheckIgnore.ts"() {
10709
10758
  "use strict";
10710
10759
  parseCheckIgnore = (text) => {
10711
- return text.split(/\n/g).map((line) => line.trim()).filter((file) => !!file);
10760
+ return text.split(/\n/g).map(toPath).filter(Boolean);
10712
10761
  };
10713
10762
  }
10714
10763
  });
@@ -10914,7 +10963,7 @@ function parseGetRemotes(text) {
10914
10963
  function parseGetRemotesVerbose(text) {
10915
10964
  const remotes = {};
10916
10965
  forEach(text, ([name, url, purpose]) => {
10917
- if (!remotes.hasOwnProperty(name)) {
10966
+ if (!Object.hasOwn(remotes, name)) {
10918
10967
  remotes[name] = {
10919
10968
  name,
10920
10969
  refs: { fetch: "", push: "" }
@@ -10988,7 +11037,7 @@ __export2(stash_list_exports, {
10988
11037
  function stashListTask(opt = {}, customArgs) {
10989
11038
  const options = parseLogOptions(opt);
10990
11039
  const commands = ["stash", "list", ...options.commands, ...customArgs];
10991
- const parser3 = createListLogSummaryParser(
11040
+ const parser4 = createListLogSummaryParser(
10992
11041
  options.splitter,
10993
11042
  options.fields,
10994
11043
  logFormatFromCommand(commands)
@@ -10996,7 +11045,7 @@ function stashListTask(opt = {}, customArgs) {
10996
11045
  return validateLogFormatConfig(commands) || {
10997
11046
  commands,
10998
11047
  format: "utf-8",
10999
- parser: parser3
11048
+ parser: parser4
11000
11049
  };
11001
11050
  }
11002
11051
  var init_stash_list = __esm({
@@ -11038,8 +11087,8 @@ var init_sub_module = __esm({
11038
11087
  }
11039
11088
  });
11040
11089
  function singleSorted(a, b) {
11041
- const aIsNum = isNaN(a);
11042
- const bIsNum = isNaN(b);
11090
+ const aIsNum = Number.isNaN(a);
11091
+ const bIsNum = Number.isNaN(b);
11043
11092
  if (aIsNum !== bIsNum) {
11044
11093
  return aIsNum ? 1 : -1;
11045
11094
  }
@@ -11667,27 +11716,24 @@ function completionDetectionPlugin({
11667
11716
  }
11668
11717
  return {
11669
11718
  type: "spawn.after",
11670
- action(_0, _1) {
11671
- return __async(this, arguments, function* (_data, { spawned, close }) {
11672
- var _a3, _b2;
11673
- const events = createEvents();
11674
- let deferClose = true;
11675
- let quickClose = () => void (deferClose = false);
11676
- (_a3 = spawned.stdout) == null ? void 0 : _a3.on("data", quickClose);
11677
- (_b2 = spawned.stderr) == null ? void 0 : _b2.on("data", quickClose);
11678
- spawned.on("error", quickClose);
11679
- spawned.on("close", (code) => events.close(code));
11680
- spawned.on("exit", (code) => events.exit(code));
11681
- try {
11682
- yield events.result;
11683
- if (deferClose) {
11684
- yield delay(50);
11685
- }
11686
- close(events.exitCode);
11687
- } catch (err) {
11688
- close(events.exitCode, err);
11719
+ async action(_data, { spawned, close }) {
11720
+ const events = createEvents();
11721
+ let deferClose = true;
11722
+ let quickClose = () => void (deferClose = false);
11723
+ spawned.stdout?.on("data", quickClose);
11724
+ spawned.stderr?.on("data", quickClose);
11725
+ spawned.on("error", quickClose);
11726
+ spawned.on("close", (code) => events.close(code));
11727
+ spawned.on("exit", (code) => events.exit(code));
11728
+ try {
11729
+ await events.result;
11730
+ if (deferClose) {
11731
+ await delay(50);
11689
11732
  }
11690
- });
11733
+ close(events.exitCode);
11734
+ } catch (err) {
11735
+ close(events.exitCode, err);
11736
+ }
11691
11737
  }
11692
11738
  };
11693
11739
  }
@@ -11801,11 +11847,10 @@ function progressMonitorPlugin(progress) {
11801
11847
  const onProgress = {
11802
11848
  type: "spawn.after",
11803
11849
  action(_data, context) {
11804
- var _a22;
11805
11850
  if (!context.commands.includes(progressCommand)) {
11806
11851
  return;
11807
11852
  }
11808
- (_a22 = context.spawned.stderr) == null ? void 0 : _a22.on("data", (chunk) => {
11853
+ context.spawned.stderr?.on("data", (chunk) => {
11809
11854
  const message = /^([\s\S]+?):\s*(\d+)% \((\d+)\/(\d+)\)/.exec(chunk.toString("utf8"));
11810
11855
  if (!message) {
11811
11856
  return;
@@ -11840,7 +11885,7 @@ function spawnOptionsPlugin(spawnOptions) {
11840
11885
  return {
11841
11886
  type: "spawn.options",
11842
11887
  action(data) {
11843
- return __spreadValues(__spreadValues({}, options), data);
11888
+ return { ...options, ...data };
11844
11889
  }
11845
11890
  };
11846
11891
  }
@@ -11853,16 +11898,14 @@ function timeoutPlugin({
11853
11898
  return {
11854
11899
  type: "spawn.after",
11855
11900
  action(_data, context) {
11856
- var _a22, _b2;
11857
11901
  let timeout;
11858
11902
  function wait() {
11859
11903
  timeout && clearTimeout(timeout);
11860
11904
  timeout = setTimeout(kill, block);
11861
11905
  }
11862
11906
  function stop() {
11863
- var _a3, _b22;
11864
- (_a3 = context.spawned.stdout) == null ? void 0 : _a3.off("data", wait);
11865
- (_b22 = context.spawned.stderr) == null ? void 0 : _b22.off("data", wait);
11907
+ context.spawned.stdout?.off("data", wait);
11908
+ context.spawned.stderr?.off("data", wait);
11866
11909
  context.spawned.off("exit", stop);
11867
11910
  context.spawned.off("close", stop);
11868
11911
  timeout && clearTimeout(timeout);
@@ -11871,8 +11914,8 @@ function timeoutPlugin({
11871
11914
  stop();
11872
11915
  context.kill(new GitPluginError(void 0, "timeout", `block timeout reached`));
11873
11916
  }
11874
- stdOut && ((_a22 = context.spawned.stdout) == null ? void 0 : _a22.on("data", wait));
11875
- stdErr && ((_b2 = context.spawned.stderr) == null ? void 0 : _b2.on("data", wait));
11917
+ stdOut && context.spawned.stdout?.on("data", wait);
11918
+ stdErr && context.spawned.stderr?.on("data", wait);
11876
11919
  context.spawned.on("exit", stop);
11877
11920
  context.spawned.on("close", stop);
11878
11921
  wait();
@@ -11911,7 +11954,6 @@ function suffixPathsPlugin() {
11911
11954
  init_utils();
11912
11955
  var Git = require_git();
11913
11956
  function gitInstanceFactory(baseDir, options) {
11914
- var _a22;
11915
11957
  const plugins = new PluginStore();
11916
11958
  const config = createInstanceConfig(
11917
11959
  baseDir && (typeof baseDir === "string" ? { baseDir } : baseDir) || {},
@@ -11935,27 +11977,27 @@ function gitInstanceFactory(baseDir, options) {
11935
11977
  config.spawnOptions && plugins.add(spawnOptionsPlugin(config.spawnOptions));
11936
11978
  plugins.add(errorDetectionPlugin(errorDetectionHandler(true)));
11937
11979
  config.errors && plugins.add(errorDetectionPlugin(config.errors));
11938
- customBinaryPlugin(plugins, config.binary, (_a22 = config.unsafe) == null ? void 0 : _a22.allowUnsafeCustomBinary);
11980
+ customBinaryPlugin(plugins, config.binary, config.unsafe?.allowUnsafeCustomBinary);
11939
11981
  return new Git(config, plugins);
11940
11982
  }
11941
11983
  init_git_response_error();
11942
11984
  var esm_default2 = gitInstanceFactory;
11943
11985
 
11944
- // ../commons/github/dist/cloneRepository.js
11986
+ // ../commons/github/lib/cloneRepository.js
11945
11987
  var import_tmp_promise = __toESM(require_tmp_promise(), 1);
11946
11988
 
11947
- // ../commons/github/dist/ClonedRepository.js
11989
+ // ../commons/github/lib/ClonedRepository.js
11948
11990
  var import_promises2 = require("fs/promises");
11949
11991
  var import_path6 = __toESM(require("path"), 1);
11950
11992
 
11951
- // ../commons/github/dist/constants.js
11993
+ // ../commons/github/lib/constants.js
11952
11994
  var DEFAULT_REMOTE = "github.com";
11953
11995
  var README_FILEPATH = "README.md";
11954
11996
  var FERNIGNORE = ".fernignore";
11955
11997
  var GITIGNORE = ".gitignore";
11956
11998
  var GIT_DIR = ".git";
11957
11999
 
11958
- // ../commons/github/dist/ClonedRepository.js
12000
+ // ../commons/github/lib/ClonedRepository.js
11959
12001
  var DEFAULT_IGNORED_FILES = [FERNIGNORE, GITIGNORE, GIT_DIR];
11960
12002
  var ClonedRepository = class {
11961
12003
  clonePath;
@@ -12020,6 +12062,27 @@ var ClonedRepository = class {
12020
12062
  await this.git.cwd(this.clonePath);
12021
12063
  await this.git.push();
12022
12064
  }
12065
+ async isRemoteEmpty() {
12066
+ await this.git.cwd(this.clonePath);
12067
+ try {
12068
+ const result = await this.git.raw(["ls-remote", "--heads", "origin"]);
12069
+ return result.trim().length === 0;
12070
+ } catch (_error) {
12071
+ return true;
12072
+ }
12073
+ }
12074
+ async checkoutOrCreateLocal(branch) {
12075
+ await this.git.cwd(this.clonePath);
12076
+ try {
12077
+ await this.git.checkout(branch);
12078
+ } catch (_error) {
12079
+ await this.git.checkoutLocalBranch(branch);
12080
+ }
12081
+ }
12082
+ async pushUpstream(branch) {
12083
+ await this.git.cwd(this.clonePath);
12084
+ await this.git.push("origin", branch, { "--set-upstream": null });
12085
+ }
12023
12086
  async overwriteLocalContents(sourceDirectoryPath) {
12024
12087
  const [sourceContents, destContents] = await Promise.all([
12025
12088
  (0, import_promises2.readdir)(sourceDirectoryPath),
@@ -12053,7 +12116,7 @@ async function doesPathExist2(filepath) {
12053
12116
  }
12054
12117
  }
12055
12118
 
12056
- // ../commons/github/dist/parseRepository.js
12119
+ // ../commons/github/lib/parseRepository.js
12057
12120
  function parseRepository(githubRepository) {
12058
12121
  let remote = DEFAULT_REMOTE;
12059
12122
  let owner;
@@ -12095,7 +12158,7 @@ function getCloneUrl({ remote, owner, repo }) {
12095
12158
  return `https://${remote}/${owner}/${repo}.git`;
12096
12159
  }
12097
12160
 
12098
- // ../commons/github/dist/cloneRepository.js
12161
+ // ../commons/github/lib/cloneRepository.js
12099
12162
  async function cloneRepository({ githubRepository, installationToken }) {
12100
12163
  const repositoryReference = parseRepository(githubRepository);
12101
12164
  const cloneUrl = installationToken != null ? repositoryReference.getAuthedCloneUrl(installationToken) : repositoryReference.cloneUrl;
@@ -12113,7 +12176,7 @@ async function cloneRepository({ githubRepository, installationToken }) {
12113
12176
  var import_compat = require("es-toolkit/compat");
12114
12177
  var import_string = require("es-toolkit/string");
12115
12178
 
12116
- // src/configuration/generated/api/index.ts
12179
+ // src/configuration/sdk/api/index.ts
12117
12180
  var api_exports = {};
12118
12181
  __export(api_exports, {
12119
12182
  ExampleStyle: () => ExampleStyle,
@@ -12127,13 +12190,13 @@ __export(api_exports, {
12127
12190
  reference: () => reference_exports
12128
12191
  });
12129
12192
 
12130
- // src/configuration/generated/api/resources/feature/index.ts
12193
+ // src/configuration/sdk/api/resources/feature/index.ts
12131
12194
  var feature_exports = {};
12132
12195
  __export(feature_exports, {
12133
12196
  StructuredFeatureId: () => StructuredFeatureId
12134
12197
  });
12135
12198
 
12136
- // src/configuration/generated/api/resources/feature/types/StructuredFeatureId.ts
12199
+ // src/configuration/sdk/api/resources/feature/types/StructuredFeatureId.ts
12137
12200
  var StructuredFeatureId = {
12138
12201
  Authentication: "AUTHENTICATION",
12139
12202
  Errors: "ERRORS",
@@ -12173,10 +12236,10 @@ var StructuredFeatureId = {
12173
12236
  }
12174
12237
  };
12175
12238
 
12176
- // src/configuration/generated/api/resources/github/index.ts
12239
+ // src/configuration/sdk/api/resources/github/index.ts
12177
12240
  var github_exports = {};
12178
12241
 
12179
- // src/configuration/generated/api/resources/readme/index.ts
12242
+ // src/configuration/sdk/api/resources/readme/index.ts
12180
12243
  var readme_exports = {};
12181
12244
  __export(readme_exports, {
12182
12245
  ExampleStyle: () => ExampleStyle,
@@ -12184,7 +12247,7 @@ __export(readme_exports, {
12184
12247
  Remote: () => Remote
12185
12248
  });
12186
12249
 
12187
- // src/configuration/generated/api/resources/readme/types/Remote.ts
12250
+ // src/configuration/sdk/api/resources/readme/types/Remote.ts
12188
12251
  var Remote = {
12189
12252
  github: (value) => {
12190
12253
  return {
@@ -12205,7 +12268,7 @@ var Remote = {
12205
12268
  }
12206
12269
  };
12207
12270
 
12208
- // src/configuration/generated/api/resources/readme/types/LanguageInfo.ts
12271
+ // src/configuration/sdk/api/resources/readme/types/LanguageInfo.ts
12209
12272
  var LanguageInfo = {
12210
12273
  typescript: (value) => {
12211
12274
  return {
@@ -12314,7 +12377,7 @@ var LanguageInfo = {
12314
12377
  }
12315
12378
  };
12316
12379
 
12317
- // src/configuration/generated/api/resources/readme/types/ExampleStyle.ts
12380
+ // src/configuration/sdk/api/resources/readme/types/ExampleStyle.ts
12318
12381
  var ExampleStyle = {
12319
12382
  Minimal: "minimal",
12320
12383
  Comprehensive: "comprehensive",
@@ -12330,13 +12393,13 @@ var ExampleStyle = {
12330
12393
  }
12331
12394
  };
12332
12395
 
12333
- // src/configuration/generated/api/resources/reference/index.ts
12396
+ // src/configuration/sdk/api/resources/reference/index.ts
12334
12397
  var reference_exports = {};
12335
12398
  __export(reference_exports, {
12336
12399
  Language: () => Language
12337
12400
  });
12338
12401
 
12339
- // src/configuration/generated/api/resources/reference/types/Language.ts
12402
+ // src/configuration/sdk/api/resources/reference/types/Language.ts
12340
12403
  var Language = {
12341
12404
  Java: "JAVA",
12342
12405
  Python: "PYTHON",
@@ -12595,11 +12658,13 @@ var ReadmeGenerator = class {
12595
12658
  }
12596
12659
  async generateReadme({ output }) {
12597
12660
  const blocks = await this.generateBlocks();
12661
+ const mergedBlocks = await this.mergeBlocks({ blocks });
12598
12662
  const writer = new StreamWriter(output);
12599
12663
  await this.writeHeader({ writer });
12664
+ await this.writeTableOfContents({ writer, blocks: mergedBlocks });
12600
12665
  await this.writeBlocks({
12601
12666
  writer,
12602
- blocks: await this.mergeBlocks({ blocks })
12667
+ blocks: mergedBlocks
12603
12668
  });
12604
12669
  await writer.end();
12605
12670
  }
@@ -12804,6 +12869,54 @@ var ReadmeGenerator = class {
12804
12869
  );
12805
12870
  await writer.writeLine();
12806
12871
  }
12872
+ async writeTableOfContents({ writer, blocks }) {
12873
+ if (blocks.length === 0) {
12874
+ return;
12875
+ }
12876
+ await writer.writeLine("## Table of Contents");
12877
+ await writer.writeLine();
12878
+ for (const block of blocks) {
12879
+ const title = this.getBlockTitle(block.id);
12880
+ const anchor = this.getBlockAnchor(title);
12881
+ if (block.id === this.ADVANCED_FEATURE_ID) {
12882
+ await writer.writeLine(`- [${title}](#${anchor})`);
12883
+ const advancedFeatures = this.readmeConfig.features?.filter((feat) => this.isAdvanced(feat)) ?? [];
12884
+ for (const feature of advancedFeatures) {
12885
+ if (this.shouldSkipFeature({ feature })) {
12886
+ continue;
12887
+ }
12888
+ const featureTitle = featureIDToTitle(feature.id);
12889
+ const featureAnchor = this.getBlockAnchor(featureTitle);
12890
+ await writer.writeLine(` - [${featureTitle}](#${featureAnchor})`);
12891
+ }
12892
+ } else {
12893
+ await writer.writeLine(`- [${title}](#${anchor})`);
12894
+ }
12895
+ }
12896
+ await writer.writeLine();
12897
+ }
12898
+ getBlockTitle(blockId) {
12899
+ if (blockId === this.ADVANCED_FEATURE_ID) {
12900
+ return featureIDToTitle(blockId);
12901
+ }
12902
+ switch (blockId.toUpperCase()) {
12903
+ case "DOCUMENTATION":
12904
+ return "Documentation";
12905
+ case "REFERENCE":
12906
+ return "Reference";
12907
+ case "REQUIREMENTS":
12908
+ return "Requirements";
12909
+ case "INSTALLATION":
12910
+ return "Installation";
12911
+ case "CONTRIBUTING":
12912
+ return "Contributing";
12913
+ default:
12914
+ return featureIDToTitle(blockId);
12915
+ }
12916
+ }
12917
+ getBlockAnchor(title) {
12918
+ return title.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").trim();
12919
+ }
12807
12920
  async generateDocumentation({ docsLink }) {
12808
12921
  const writer = new StringWriter();
12809
12922
  await writer.writeLine("## Documentation");
@@ -13297,7 +13410,32 @@ function languageToTitle(language) {
13297
13410
  }
13298
13411
  }
13299
13412
  function featureIDToTitle(featureID) {
13300
- return featureID.split("_").map((s) => pascalCase(s)).join(" ");
13413
+ const words = featureID.split("_").map((s) => pascalCase(s));
13414
+ const lowercaseWords = /* @__PURE__ */ new Set([
13415
+ "And",
13416
+ "Or",
13417
+ "Nor",
13418
+ "But",
13419
+ "For",
13420
+ "Yet",
13421
+ "So",
13422
+ "At",
13423
+ "By",
13424
+ "In",
13425
+ "Of",
13426
+ "On",
13427
+ "To",
13428
+ "As"
13429
+ ]);
13430
+ return words.map((word, index) => {
13431
+ if (index === 0 || index === words.length - 1) {
13432
+ return word;
13433
+ }
13434
+ if (lowercaseWords.has(word)) {
13435
+ return word.toLowerCase();
13436
+ }
13437
+ return word;
13438
+ }).join(" ");
13301
13439
  }
13302
13440
  function pascalCase(s) {
13303
13441
  return (0, import_string.upperFirst)((0, import_string.camelCase)(s));
@@ -13506,15 +13644,26 @@ var GitHub = class {
13506
13644
  githubRepository: this.githubConfig.uri,
13507
13645
  installationToken: this.githubConfig.token
13508
13646
  });
13509
- const branch = this.githubConfig.branch ?? await repository.getDefaultBranch();
13510
- await repository.checkout(branch);
13511
- await repository.pull(branch);
13647
+ const isEmptyRepo = await repository.isRemoteEmpty();
13648
+ let branch;
13649
+ if (isEmptyRepo) {
13650
+ branch = this.githubConfig.branch ?? "main";
13651
+ await repository.checkoutOrCreateLocal(branch);
13652
+ } else {
13653
+ branch = this.githubConfig.branch ?? await repository.getDefaultBranch();
13654
+ await repository.checkout(branch);
13655
+ await repository.pull(branch);
13656
+ }
13512
13657
  const fernIgnoreFiles = await this.getFernignoreFiles(repository);
13513
13658
  await repository.overwriteLocalContents(sourceDirectory);
13514
13659
  await repository.add(".");
13515
13660
  await this.restoreFiles(repository, fernIgnoreFiles);
13516
13661
  await repository.commit("SDK Generation");
13517
- await repository.push();
13662
+ if (isEmptyRepo) {
13663
+ await repository.pushUpstream(branch);
13664
+ } else {
13665
+ await repository.push();
13666
+ }
13518
13667
  } catch (error) {
13519
13668
  console.error("Error during GitHub push:", error);
13520
13669
  throw error;
@@ -13528,12 +13677,21 @@ var GitHub = class {
13528
13677
  githubRepository: this.githubConfig.uri,
13529
13678
  installationToken: this.githubConfig.token
13530
13679
  });
13531
- const baseBranch = this.githubConfig.branch ?? await repository.getDefaultBranch();
13680
+ const isEmptyRepo = await repository.isRemoteEmpty();
13681
+ let baseBranch;
13682
+ if (isEmptyRepo) {
13683
+ baseBranch = this.githubConfig.branch ?? "main";
13684
+ await repository.checkoutOrCreateLocal(baseBranch);
13685
+ await repository.commit("Initial commit");
13686
+ await repository.pushUpstream(baseBranch);
13687
+ } else {
13688
+ baseBranch = this.githubConfig.branch ?? await repository.getDefaultBranch();
13689
+ await repository.checkout(baseBranch);
13690
+ await repository.pull(baseBranch);
13691
+ }
13532
13692
  const now = /* @__PURE__ */ new Date();
13533
13693
  const formattedDate = now.toISOString().replace("T", "_").replace(/:/g, "-").replace(/\..+/, "");
13534
13694
  const prBranch = `fern-bot/${formattedDate}`;
13535
- await repository.checkout(baseBranch);
13536
- await repository.pull(baseBranch);
13537
13695
  await repository.checkout(prBranch);
13538
13696
  const fernIgnoreFiles = await this.getFernignoreFiles(repository);
13539
13697
  await repository.overwriteLocalContents(sourceDirectory);
@@ -13544,10 +13702,8 @@ var GitHub = class {
13544
13702
  const octokit = new import_rest.Octokit({
13545
13703
  auth: this.githubConfig.token
13546
13704
  });
13547
- const [owner, repo] = this.githubConfig.uri.split("/");
13548
- if (!owner || !repo) {
13549
- throw new Error(`Invalid repository URI: ${this.githubConfig.uri}`);
13550
- }
13705
+ const parsedRepo = parseRepository(this.githubConfig.uri);
13706
+ const { owner, repo } = parsedRepo;
13551
13707
  const head = `${owner}:${prBranch}`;
13552
13708
  try {
13553
13709
  await octokit.pulls.create({
@@ -13628,30 +13784,21 @@ async function loadGitHubConfig({
13628
13784
  return JSON.parse(rawContents);
13629
13785
  }
13630
13786
 
13631
- // src/configuration/loadMetadataConfig.ts
13632
- var import_promises4 = require("fs/promises");
13633
- async function loadMetadataConfig({
13634
- absolutePathToConfig
13635
- }) {
13636
- const rawContents = await (0, import_promises4.readFile)(absolutePathToConfig, "utf8");
13637
- return JSON.parse(rawContents);
13638
- }
13639
-
13640
13787
  // src/configuration/loadReadmeConfig.ts
13641
- var import_promises5 = require("fs/promises");
13788
+ var import_promises4 = require("fs/promises");
13642
13789
  async function loadReadmeConfig({
13643
13790
  absolutePathToConfig
13644
13791
  }) {
13645
- const rawContents = await (0, import_promises5.readFile)(absolutePathToConfig, "utf8");
13792
+ const rawContents = await (0, import_promises4.readFile)(absolutePathToConfig, "utf8");
13646
13793
  return JSON.parse(rawContents);
13647
13794
  }
13648
13795
 
13649
13796
  // src/configuration/loadReferenceConfig.ts
13650
- var import_promises6 = require("fs/promises");
13797
+ var import_promises5 = require("fs/promises");
13651
13798
  async function loadReferenceConfig({
13652
13799
  absolutePathToConfig
13653
13800
  }) {
13654
- const rawContents = await (0, import_promises6.readFile)(absolutePathToConfig, "utf8");
13801
+ const rawContents = await (0, import_promises5.readFile)(absolutePathToConfig, "utf8");
13655
13802
  return JSON.parse(rawContents);
13656
13803
  }
13657
13804
 
@@ -13678,7 +13825,7 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
13678
13825
  const readmeConfig = await loadReadmeConfig({
13679
13826
  absolutePathToConfig: resolve(wd, argv.config)
13680
13827
  });
13681
- const originalReadmeContent = argv.originalReadme != null ? await (0, import_promises7.readFile)(argv.originalReadme, "utf8") : void 0;
13828
+ const originalReadmeContent = argv.originalReadme != null ? await (0, import_promises6.readFile)(argv.originalReadme, "utf8") : void 0;
13682
13829
  await generateReadmeToStream({
13683
13830
  originalReadmeContent,
13684
13831
  readmeConfig,
@@ -13711,31 +13858,6 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
13711
13858
  });
13712
13859
  process.exit(0);
13713
13860
  }
13714
- ).command(
13715
- "write-metadata",
13716
- "Write metadata to the output directory using the provided configuration file.",
13717
- (argv) => argv.option("config", {
13718
- string: true,
13719
- required: true
13720
- }).option("output", {
13721
- string: true,
13722
- required: false
13723
- }),
13724
- async (argv) => {
13725
- if (argv.config == null) {
13726
- process.stderr.write("missing required arguments; please specify the --config flag\n");
13727
- process.exit(1);
13728
- }
13729
- const wd = cwd();
13730
- const metadata = await loadMetadataConfig({
13731
- absolutePathToConfig: resolve(wd, argv.config)
13732
- });
13733
- const outputPath = argv.output != null ? resolve(wd, argv.output) : resolve(wd, ".fern/metadata.json");
13734
- const formattedMetadata = JSON.stringify(metadata, null, 2);
13735
- await (0, import_promises7.mkdir)(import_path7.default.dirname(outputPath), { recursive: true });
13736
- await (0, import_promises7.writeFile)(outputPath, formattedMetadata, "utf8");
13737
- process.exit(0);
13738
- }
13739
13861
  ).command("github", "GitHub operations", (yargs) => {
13740
13862
  return yargs.command(
13741
13863
  "push",
@@ -13815,7 +13937,7 @@ async function createWriteStream(outputPath) {
13815
13937
  }
13816
13938
  async function createWriteStreamFromFile(filepath) {
13817
13939
  if (!await doesPathExist(filepath)) {
13818
- await (0, import_promises7.mkdir)(import_path7.default.dirname(filepath), { recursive: true });
13940
+ await (0, import_promises6.mkdir)(import_path7.default.dirname(filepath), { recursive: true });
13819
13941
  }
13820
13942
  return import_fs6.default.createWriteStream(filepath);
13821
13943
  }