版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1289 lines
43 KiB

  1. var __create = Object.create;
  2. var __defProp = Object.defineProperty;
  3. var __defProps = Object.defineProperties;
  4. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  5. var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
  6. var __getOwnPropNames = Object.getOwnPropertyNames;
  7. var __getOwnPropSymbols = Object.getOwnPropertySymbols;
  8. var __getProtoOf = Object.getPrototypeOf;
  9. var __hasOwnProp = Object.prototype.hasOwnProperty;
  10. var __propIsEnum = Object.prototype.propertyIsEnumerable;
  11. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  12. var __spreadValues = (a, b) => {
  13. for (var prop in b || (b = {}))
  14. if (__hasOwnProp.call(b, prop))
  15. __defNormalProp(a, prop, b[prop]);
  16. if (__getOwnPropSymbols)
  17. for (var prop of __getOwnPropSymbols(b)) {
  18. if (__propIsEnum.call(b, prop))
  19. __defNormalProp(a, prop, b[prop]);
  20. }
  21. return a;
  22. };
  23. var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
  24. var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
  25. get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
  26. }) : x)(function(x) {
  27. if (typeof require !== "undefined")
  28. return require.apply(this, arguments);
  29. throw new Error('Dynamic require of "' + x + '" is not supported');
  30. });
  31. var __objRest = (source, exclude) => {
  32. var target = {};
  33. for (var prop in source)
  34. if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
  35. target[prop] = source[prop];
  36. if (source != null && __getOwnPropSymbols)
  37. for (var prop of __getOwnPropSymbols(source)) {
  38. if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
  39. target[prop] = source[prop];
  40. }
  41. return target;
  42. };
  43. var __commonJS = (cb, mod) => function __require2() {
  44. return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  45. };
  46. var __copyProps = (to, from, except, desc) => {
  47. if (from && typeof from === "object" || typeof from === "function") {
  48. for (let key of __getOwnPropNames(from))
  49. if (!__hasOwnProp.call(to, key) && key !== except)
  50. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  51. }
  52. return to;
  53. };
  54. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  55. // If the importer is in node compatibility mode or this is not an ESM
  56. // file that has been converted to a CommonJS file using a Babel-
  57. // compatible transform (i.e. "__esModule" has not been set), then set
  58. // "default" to the CommonJS "module.exports" for node compatibility.
  59. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  60. mod
  61. ));
  62. // node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js
  63. var require_picocolors = __commonJS({
  64. "node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js"(exports, module) {
  65. var tty2 = __require("tty");
  66. var isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty2.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env);
  67. var formatter = (open, close, replace = open) => (input) => {
  68. let string = "" + input;
  69. let index = string.indexOf(close, open.length);
  70. return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
  71. };
  72. var replaceClose = (string, close, replace, index) => {
  73. let start = string.substring(0, index) + replace;
  74. let end = string.substring(index + close.length);
  75. let nextIndex = end.indexOf(close);
  76. return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
  77. };
  78. var createColors = (enabled = isColorSupported) => ({
  79. isColorSupported: enabled,
  80. reset: enabled ? (s) => `\x1B[0m${s}\x1B[0m` : String,
  81. bold: enabled ? formatter("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m") : String,
  82. dim: enabled ? formatter("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m") : String,
  83. italic: enabled ? formatter("\x1B[3m", "\x1B[23m") : String,
  84. underline: enabled ? formatter("\x1B[4m", "\x1B[24m") : String,
  85. inverse: enabled ? formatter("\x1B[7m", "\x1B[27m") : String,
  86. hidden: enabled ? formatter("\x1B[8m", "\x1B[28m") : String,
  87. strikethrough: enabled ? formatter("\x1B[9m", "\x1B[29m") : String,
  88. black: enabled ? formatter("\x1B[30m", "\x1B[39m") : String,
  89. red: enabled ? formatter("\x1B[31m", "\x1B[39m") : String,
  90. green: enabled ? formatter("\x1B[32m", "\x1B[39m") : String,
  91. yellow: enabled ? formatter("\x1B[33m", "\x1B[39m") : String,
  92. blue: enabled ? formatter("\x1B[34m", "\x1B[39m") : String,
  93. magenta: enabled ? formatter("\x1B[35m", "\x1B[39m") : String,
  94. cyan: enabled ? formatter("\x1B[36m", "\x1B[39m") : String,
  95. white: enabled ? formatter("\x1B[37m", "\x1B[39m") : String,
  96. gray: enabled ? formatter("\x1B[90m", "\x1B[39m") : String,
  97. bgBlack: enabled ? formatter("\x1B[40m", "\x1B[49m") : String,
  98. bgRed: enabled ? formatter("\x1B[41m", "\x1B[49m") : String,
  99. bgGreen: enabled ? formatter("\x1B[42m", "\x1B[49m") : String,
  100. bgYellow: enabled ? formatter("\x1B[43m", "\x1B[49m") : String,
  101. bgBlue: enabled ? formatter("\x1B[44m", "\x1B[49m") : String,
  102. bgMagenta: enabled ? formatter("\x1B[45m", "\x1B[49m") : String,
  103. bgCyan: enabled ? formatter("\x1B[46m", "\x1B[49m") : String,
  104. bgWhite: enabled ? formatter("\x1B[47m", "\x1B[49m") : String
  105. });
  106. module.exports = createColors();
  107. module.exports.createColors = createColors;
  108. }
  109. });
  110. // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js
  111. var ANSI_BACKGROUND_OFFSET = 10;
  112. var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
  113. var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
  114. var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
  115. var styles = {
  116. modifier: {
  117. reset: [0, 0],
  118. // 21 isn't widely supported and 22 does the same thing
  119. bold: [1, 22],
  120. dim: [2, 22],
  121. italic: [3, 23],
  122. underline: [4, 24],
  123. overline: [53, 55],
  124. inverse: [7, 27],
  125. hidden: [8, 28],
  126. strikethrough: [9, 29]
  127. },
  128. color: {
  129. black: [30, 39],
  130. red: [31, 39],
  131. green: [32, 39],
  132. yellow: [33, 39],
  133. blue: [34, 39],
  134. magenta: [35, 39],
  135. cyan: [36, 39],
  136. white: [37, 39],
  137. // Bright color
  138. blackBright: [90, 39],
  139. gray: [90, 39],
  140. // Alias of `blackBright`
  141. grey: [90, 39],
  142. // Alias of `blackBright`
  143. redBright: [91, 39],
  144. greenBright: [92, 39],
  145. yellowBright: [93, 39],
  146. blueBright: [94, 39],
  147. magentaBright: [95, 39],
  148. cyanBright: [96, 39],
  149. whiteBright: [97, 39]
  150. },
  151. bgColor: {
  152. bgBlack: [40, 49],
  153. bgRed: [41, 49],
  154. bgGreen: [42, 49],
  155. bgYellow: [43, 49],
  156. bgBlue: [44, 49],
  157. bgMagenta: [45, 49],
  158. bgCyan: [46, 49],
  159. bgWhite: [47, 49],
  160. // Bright color
  161. bgBlackBright: [100, 49],
  162. bgGray: [100, 49],
  163. // Alias of `bgBlackBright`
  164. bgGrey: [100, 49],
  165. // Alias of `bgBlackBright`
  166. bgRedBright: [101, 49],
  167. bgGreenBright: [102, 49],
  168. bgYellowBright: [103, 49],
  169. bgBlueBright: [104, 49],
  170. bgMagentaBright: [105, 49],
  171. bgCyanBright: [106, 49],
  172. bgWhiteBright: [107, 49]
  173. }
  174. };
  175. var modifierNames = Object.keys(styles.modifier);
  176. var foregroundColorNames = Object.keys(styles.color);
  177. var backgroundColorNames = Object.keys(styles.bgColor);
  178. var colorNames = [...foregroundColorNames, ...backgroundColorNames];
  179. function assembleStyles() {
  180. const codes = /* @__PURE__ */ new Map();
  181. for (const [groupName, group] of Object.entries(styles)) {
  182. for (const [styleName, style] of Object.entries(group)) {
  183. styles[styleName] = {
  184. open: `\x1B[${style[0]}m`,
  185. close: `\x1B[${style[1]}m`
  186. };
  187. group[styleName] = styles[styleName];
  188. codes.set(style[0], style[1]);
  189. }
  190. Object.defineProperty(styles, groupName, {
  191. value: group,
  192. enumerable: false
  193. });
  194. }
  195. Object.defineProperty(styles, "codes", {
  196. value: codes,
  197. enumerable: false
  198. });
  199. styles.color.close = "\x1B[39m";
  200. styles.bgColor.close = "\x1B[49m";
  201. styles.color.ansi = wrapAnsi16();
  202. styles.color.ansi256 = wrapAnsi256();
  203. styles.color.ansi16m = wrapAnsi16m();
  204. styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
  205. styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
  206. styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
  207. Object.defineProperties(styles, {
  208. rgbToAnsi256: {
  209. value(red, green, blue) {
  210. if (red === green && green === blue) {
  211. if (red < 8) {
  212. return 16;
  213. }
  214. if (red > 248) {
  215. return 231;
  216. }
  217. return Math.round((red - 8) / 247 * 24) + 232;
  218. }
  219. return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
  220. },
  221. enumerable: false
  222. },
  223. hexToRgb: {
  224. value(hex) {
  225. const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
  226. if (!matches) {
  227. return [0, 0, 0];
  228. }
  229. let [colorString] = matches;
  230. if (colorString.length === 3) {
  231. colorString = [...colorString].map((character) => character + character).join("");
  232. }
  233. const integer = Number.parseInt(colorString, 16);
  234. return [
  235. /* eslint-disable no-bitwise */
  236. integer >> 16 & 255,
  237. integer >> 8 & 255,
  238. integer & 255
  239. /* eslint-enable no-bitwise */
  240. ];
  241. },
  242. enumerable: false
  243. },
  244. hexToAnsi256: {
  245. value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
  246. enumerable: false
  247. },
  248. ansi256ToAnsi: {
  249. value(code) {
  250. if (code < 8) {
  251. return 30 + code;
  252. }
  253. if (code < 16) {
  254. return 90 + (code - 8);
  255. }
  256. let red;
  257. let green;
  258. let blue;
  259. if (code >= 232) {
  260. red = ((code - 232) * 10 + 8) / 255;
  261. green = red;
  262. blue = red;
  263. } else {
  264. code -= 16;
  265. const remainder = code % 36;
  266. red = Math.floor(code / 36) / 5;
  267. green = Math.floor(remainder / 6) / 5;
  268. blue = remainder % 6 / 5;
  269. }
  270. const value = Math.max(red, green, blue) * 2;
  271. if (value === 0) {
  272. return 30;
  273. }
  274. let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
  275. if (value === 2) {
  276. result += 60;
  277. }
  278. return result;
  279. },
  280. enumerable: false
  281. },
  282. rgbToAnsi: {
  283. value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
  284. enumerable: false
  285. },
  286. hexToAnsi: {
  287. value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
  288. enumerable: false
  289. }
  290. });
  291. return styles;
  292. }
  293. var ansiStyles = assembleStyles();
  294. var ansi_styles_default = ansiStyles;
  295. // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js
  296. import process2 from "process";
  297. import os from "os";
  298. import tty from "tty";
  299. function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
  300. const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
  301. const position = argv.indexOf(prefix + flag);
  302. const terminatorPosition = argv.indexOf("--");
  303. return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
  304. }
  305. var { env } = process2;
  306. var flagForceColor;
  307. if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
  308. flagForceColor = 0;
  309. } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
  310. flagForceColor = 1;
  311. }
  312. function envForceColor() {
  313. if ("FORCE_COLOR" in env) {
  314. if (env.FORCE_COLOR === "true") {
  315. return 1;
  316. }
  317. if (env.FORCE_COLOR === "false") {
  318. return 0;
  319. }
  320. return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
  321. }
  322. }
  323. function translateLevel(level) {
  324. if (level === 0) {
  325. return false;
  326. }
  327. return {
  328. level,
  329. hasBasic: true,
  330. has256: level >= 2,
  331. has16m: level >= 3
  332. };
  333. }
  334. function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
  335. const noFlagForceColor = envForceColor();
  336. if (noFlagForceColor !== void 0) {
  337. flagForceColor = noFlagForceColor;
  338. }
  339. const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
  340. if (forceColor === 0) {
  341. return 0;
  342. }
  343. if (sniffFlags) {
  344. if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
  345. return 3;
  346. }
  347. if (hasFlag("color=256")) {
  348. return 2;
  349. }
  350. }
  351. if ("TF_BUILD" in env && "AGENT_NAME" in env) {
  352. return 1;
  353. }
  354. if (haveStream && !streamIsTTY && forceColor === void 0) {
  355. return 0;
  356. }
  357. const min = forceColor || 0;
  358. if (env.TERM === "dumb") {
  359. return min;
  360. }
  361. if (process2.platform === "win32") {
  362. const osRelease = os.release().split(".");
  363. if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  364. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  365. }
  366. return 1;
  367. }
  368. if ("CI" in env) {
  369. if ("GITHUB_ACTIONS" in env) {
  370. return 3;
  371. }
  372. if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
  373. return 1;
  374. }
  375. return min;
  376. }
  377. if ("TEAMCITY_VERSION" in env) {
  378. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
  379. }
  380. if (env.COLORTERM === "truecolor") {
  381. return 3;
  382. }
  383. if (env.TERM === "xterm-kitty") {
  384. return 3;
  385. }
  386. if ("TERM_PROGRAM" in env) {
  387. const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
  388. switch (env.TERM_PROGRAM) {
  389. case "iTerm.app": {
  390. return version >= 3 ? 3 : 2;
  391. }
  392. case "Apple_Terminal": {
  393. return 2;
  394. }
  395. }
  396. }
  397. if (/-256(color)?$/i.test(env.TERM)) {
  398. return 2;
  399. }
  400. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
  401. return 1;
  402. }
  403. if ("COLORTERM" in env) {
  404. return 1;
  405. }
  406. return min;
  407. }
  408. function createSupportsColor(stream, options = {}) {
  409. const level = _supportsColor(stream, __spreadValues({
  410. streamIsTTY: stream && stream.isTTY
  411. }, options));
  412. return translateLevel(level);
  413. }
  414. var supportsColor = {
  415. stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
  416. stderr: createSupportsColor({ isTTY: tty.isatty(2) })
  417. };
  418. var supports_color_default = supportsColor;
  419. // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
  420. function stringReplaceAll(string, substring, replacer) {
  421. let index = string.indexOf(substring);
  422. if (index === -1) {
  423. return string;
  424. }
  425. const substringLength = substring.length;
  426. let endIndex = 0;
  427. let returnValue = "";
  428. do {
  429. returnValue += string.slice(endIndex, index) + substring + replacer;
  430. endIndex = index + substringLength;
  431. index = string.indexOf(substring, endIndex);
  432. } while (index !== -1);
  433. returnValue += string.slice(endIndex);
  434. return returnValue;
  435. }
  436. function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
  437. let endIndex = 0;
  438. let returnValue = "";
  439. do {
  440. const gotCR = string[index - 1] === "\r";
  441. returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
  442. endIndex = index + 1;
  443. index = string.indexOf("\n", endIndex);
  444. } while (index !== -1);
  445. returnValue += string.slice(endIndex);
  446. return returnValue;
  447. }
  448. // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js
  449. var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
  450. var GENERATOR = Symbol("GENERATOR");
  451. var STYLER = Symbol("STYLER");
  452. var IS_EMPTY = Symbol("IS_EMPTY");
  453. var levelMapping = [
  454. "ansi",
  455. "ansi",
  456. "ansi256",
  457. "ansi16m"
  458. ];
  459. var styles2 = /* @__PURE__ */ Object.create(null);
  460. var applyOptions = (object, options = {}) => {
  461. if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
  462. throw new Error("The `level` option should be an integer from 0 to 3");
  463. }
  464. const colorLevel = stdoutColor ? stdoutColor.level : 0;
  465. object.level = options.level === void 0 ? colorLevel : options.level;
  466. };
  467. var chalkFactory = (options) => {
  468. const chalk2 = (...strings) => strings.join(" ");
  469. applyOptions(chalk2, options);
  470. Object.setPrototypeOf(chalk2, createChalk.prototype);
  471. return chalk2;
  472. };
  473. function createChalk(options) {
  474. return chalkFactory(options);
  475. }
  476. Object.setPrototypeOf(createChalk.prototype, Function.prototype);
  477. for (const [styleName, style] of Object.entries(ansi_styles_default)) {
  478. styles2[styleName] = {
  479. get() {
  480. const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
  481. Object.defineProperty(this, styleName, { value: builder });
  482. return builder;
  483. }
  484. };
  485. }
  486. styles2.visible = {
  487. get() {
  488. const builder = createBuilder(this, this[STYLER], true);
  489. Object.defineProperty(this, "visible", { value: builder });
  490. return builder;
  491. }
  492. };
  493. var getModelAnsi = (model, level, type, ...arguments_) => {
  494. if (model === "rgb") {
  495. if (level === "ansi16m") {
  496. return ansi_styles_default[type].ansi16m(...arguments_);
  497. }
  498. if (level === "ansi256") {
  499. return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
  500. }
  501. return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
  502. }
  503. if (model === "hex") {
  504. return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
  505. }
  506. return ansi_styles_default[type][model](...arguments_);
  507. };
  508. var usedModels = ["rgb", "hex", "ansi256"];
  509. for (const model of usedModels) {
  510. styles2[model] = {
  511. get() {
  512. const { level } = this;
  513. return function(...arguments_) {
  514. const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
  515. return createBuilder(this, styler, this[IS_EMPTY]);
  516. };
  517. }
  518. };
  519. const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
  520. styles2[bgModel] = {
  521. get() {
  522. const { level } = this;
  523. return function(...arguments_) {
  524. const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
  525. return createBuilder(this, styler, this[IS_EMPTY]);
  526. };
  527. }
  528. };
  529. }
  530. var proto = Object.defineProperties(() => {
  531. }, __spreadProps(__spreadValues({}, styles2), {
  532. level: {
  533. enumerable: true,
  534. get() {
  535. return this[GENERATOR].level;
  536. },
  537. set(level) {
  538. this[GENERATOR].level = level;
  539. }
  540. }
  541. }));
  542. var createStyler = (open, close, parent) => {
  543. let openAll;
  544. let closeAll;
  545. if (parent === void 0) {
  546. openAll = open;
  547. closeAll = close;
  548. } else {
  549. openAll = parent.openAll + open;
  550. closeAll = close + parent.closeAll;
  551. }
  552. return {
  553. open,
  554. close,
  555. openAll,
  556. closeAll,
  557. parent
  558. };
  559. };
  560. var createBuilder = (self, _styler, _isEmpty) => {
  561. const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
  562. Object.setPrototypeOf(builder, proto);
  563. builder[GENERATOR] = self;
  564. builder[STYLER] = _styler;
  565. builder[IS_EMPTY] = _isEmpty;
  566. return builder;
  567. };
  568. var applyStyle = (self, string) => {
  569. if (self.level <= 0 || !string) {
  570. return self[IS_EMPTY] ? "" : string;
  571. }
  572. let styler = self[STYLER];
  573. if (styler === void 0) {
  574. return string;
  575. }
  576. const { openAll, closeAll } = styler;
  577. if (string.includes("\x1B")) {
  578. while (styler !== void 0) {
  579. string = stringReplaceAll(string, styler.close, styler.open);
  580. styler = styler.parent;
  581. }
  582. }
  583. const lfIndex = string.indexOf("\n");
  584. if (lfIndex !== -1) {
  585. string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
  586. }
  587. return openAll + string + closeAll;
  588. };
  589. Object.defineProperties(createChalk.prototype, styles2);
  590. var chalk = createChalk();
  591. var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
  592. var source_default = chalk;
  593. // node_modules/.pnpm/is-unicode-supported@1.3.0/node_modules/is-unicode-supported/index.js
  594. import process3 from "process";
  595. function isUnicodeSupported() {
  596. if (process3.platform !== "win32") {
  597. return process3.env.TERM !== "linux";
  598. }
  599. return Boolean(process3.env.CI) || Boolean(process3.env.WT_SESSION) || Boolean(process3.env.TERMINUS_SUBLIME) || process3.env.ConEmuTask === "{cmd::Cmder}" || process3.env.TERM_PROGRAM === "Terminus-Sublime" || process3.env.TERM_PROGRAM === "vscode" || process3.env.TERM === "xterm-256color" || process3.env.TERM === "alacritty" || process3.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
  600. }
  601. // node_modules/.pnpm/log-symbols@5.1.0/node_modules/log-symbols/index.js
  602. var main = {
  603. info: source_default.blue("\u2139"),
  604. success: source_default.green("\u2714"),
  605. warning: source_default.yellow("\u26A0"),
  606. error: source_default.red("\u2716")
  607. };
  608. var fallback = {
  609. info: source_default.blue("i"),
  610. success: source_default.green("\u221A"),
  611. warning: source_default.yellow("\u203C"),
  612. error: source_default.red("\xD7")
  613. };
  614. var logSymbols = isUnicodeSupported() ? main : fallback;
  615. var log_symbols_default = logSymbols;
  616. // src/release-type.ts
  617. import { ReleaseType } from "semver";
  618. var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
  619. var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch"]);
  620. function isPrerelease(value) {
  621. return prereleaseTypes.includes(value);
  622. }
  623. function isReleaseType(value) {
  624. return releaseTypes.includes(value);
  625. }
  626. // src/types/version-bump-progress.ts
  627. var ProgressEvent = /* @__PURE__ */ ((ProgressEvent2) => {
  628. ProgressEvent2["FileUpdated"] = "file updated";
  629. ProgressEvent2["FileSkipped"] = "file skipped";
  630. ProgressEvent2["GitCommit"] = "git commit";
  631. ProgressEvent2["GitTag"] = "git tag";
  632. ProgressEvent2["GitPush"] = "git push";
  633. ProgressEvent2["NpmScript"] = "npm script";
  634. return ProgressEvent2;
  635. })(ProgressEvent || {});
  636. var NpmScript = /* @__PURE__ */ ((NpmScript2) => {
  637. NpmScript2["PreVersion"] = "preversion";
  638. NpmScript2["Version"] = "version";
  639. NpmScript2["PostVersion"] = "postversion";
  640. return NpmScript2;
  641. })(NpmScript || {});
  642. // src/version-bump.ts
  643. var import_picocolors2 = __toESM(require_picocolors());
  644. import * as ezSpawn3 from "@jsdevtools/ez-spawn";
  645. import prompts2 from "prompts";
  646. // src/get-new-version.ts
  647. var import_picocolors = __toESM(require_picocolors());
  648. import prompts from "prompts";
  649. import semver, { SemVer, clean as cleanVersion, valid as isValidVersion } from "semver";
  650. async function getNewVersion(operation) {
  651. const { release } = operation.options;
  652. const { oldVersion } = operation.state;
  653. switch (release.type) {
  654. case "prompt":
  655. return promptForNewVersion(operation);
  656. case "version":
  657. return operation.update({
  658. newVersion: new SemVer(release.version, true).version
  659. });
  660. default:
  661. return operation.update({
  662. release: release.type,
  663. newVersion: getNextVersion(oldVersion, release)
  664. });
  665. }
  666. }
  667. function getNextVersion(oldVersion, bump) {
  668. const oldSemVer = new SemVer(oldVersion);
  669. const newSemVer = oldSemVer.inc(bump.type, bump.preid);
  670. if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") {
  671. newSemVer.prerelease[1] = "1";
  672. newSemVer.format();
  673. }
  674. return newSemVer.version;
  675. }
  676. function getNextVersions(oldVersion, preid) {
  677. var _a;
  678. const next = {};
  679. const parse = semver.parse(oldVersion);
  680. if (typeof (parse == null ? void 0 : parse.prerelease[0]) === "string")
  681. preid = (parse == null ? void 0 : parse.prerelease[0]) || "preid";
  682. for (const type of releaseTypes)
  683. next[type] = semver.inc(oldVersion, type, preid);
  684. next.next = ((_a = parse == null ? void 0 : parse.prerelease) == null ? void 0 : _a.length) ? semver.inc(oldVersion, "prerelease", preid) : semver.inc(oldVersion, "patch");
  685. return next;
  686. }
  687. async function promptForNewVersion(operation) {
  688. const { oldVersion } = operation.state;
  689. const release = operation.options.release;
  690. const next = getNextVersions(oldVersion, release.preid);
  691. const PADDING = 13;
  692. const answers = await prompts([
  693. {
  694. type: "autocomplete",
  695. name: "release",
  696. message: `Current version ${import_picocolors.default.green(oldVersion)}`,
  697. initial: "next",
  698. choices: [
  699. { value: "major", title: `${"major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.major)}` },
  700. { value: "minor", title: `${"minor".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.minor)}` },
  701. { value: "patch", title: `${"patch".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.patch)}` },
  702. { value: "next", title: `${"next".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.next)}` },
  703. { value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.prepatch)}` },
  704. { value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.preminor)}` },
  705. { value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.premajor)}` },
  706. { value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(oldVersion)}` },
  707. { value: "custom", title: "custom ...".padStart(PADDING + 4, " ") }
  708. ]
  709. },
  710. {
  711. type: (prev) => prev === "custom" ? "text" : null,
  712. name: "custom",
  713. message: "Enter the new version number:",
  714. initial: oldVersion,
  715. validate: (custom) => {
  716. return isValidVersion(custom) ? true : "That's not a valid version number";
  717. }
  718. }
  719. ]);
  720. const newVersion = answers.release === "none" ? oldVersion : answers.release === "custom" ? cleanVersion(answers.custom) : next[answers.release];
  721. if (!newVersion)
  722. process.exit(1);
  723. switch (answers.release) {
  724. case "custom":
  725. case "next":
  726. case "none":
  727. return operation.update({ newVersion });
  728. default:
  729. return operation.update({ release: answers.release, newVersion });
  730. }
  731. }
  732. // src/get-old-version.ts
  733. import { valid as isValidVersion2 } from "semver";
  734. // src/fs.ts
  735. import fs from "fs";
  736. import path from "path";
  737. // node_modules/.pnpm/detect-indent@7.0.1/node_modules/detect-indent/index.js
  738. var INDENT_REGEX = /^(?:( )+|\t+)/;
  739. var INDENT_TYPE_SPACE = "space";
  740. var INDENT_TYPE_TAB = "tab";
  741. function makeIndentsMap(string, ignoreSingleSpaces) {
  742. const indents = /* @__PURE__ */ new Map();
  743. let previousSize = 0;
  744. let previousIndentType;
  745. let key;
  746. for (const line of string.split(/\n/g)) {
  747. if (!line) {
  748. continue;
  749. }
  750. let indent;
  751. let indentType;
  752. let use;
  753. let weight;
  754. let entry;
  755. const matches = line.match(INDENT_REGEX);
  756. if (matches === null) {
  757. previousSize = 0;
  758. previousIndentType = "";
  759. } else {
  760. indent = matches[0].length;
  761. indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
  762. if (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {
  763. continue;
  764. }
  765. if (indentType !== previousIndentType) {
  766. previousSize = 0;
  767. }
  768. previousIndentType = indentType;
  769. use = 1;
  770. weight = 0;
  771. const indentDifference = indent - previousSize;
  772. previousSize = indent;
  773. if (indentDifference === 0) {
  774. use = 0;
  775. weight = 1;
  776. } else {
  777. const absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
  778. key = encodeIndentsKey(indentType, absoluteIndentDifference);
  779. }
  780. entry = indents.get(key);
  781. entry = entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight];
  782. indents.set(key, entry);
  783. }
  784. }
  785. return indents;
  786. }
  787. function encodeIndentsKey(indentType, indentAmount) {
  788. const typeCharacter = indentType === INDENT_TYPE_SPACE ? "s" : "t";
  789. return typeCharacter + String(indentAmount);
  790. }
  791. function decodeIndentsKey(indentsKey) {
  792. const keyHasTypeSpace = indentsKey[0] === "s";
  793. const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
  794. const amount = Number(indentsKey.slice(1));
  795. return { type, amount };
  796. }
  797. function getMostUsedKey(indents) {
  798. let result;
  799. let maxUsed = 0;
  800. let maxWeight = 0;
  801. for (const [key, [usedCount, weight]] of indents) {
  802. if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
  803. maxUsed = usedCount;
  804. maxWeight = weight;
  805. result = key;
  806. }
  807. }
  808. return result;
  809. }
  810. function makeIndentString(type, amount) {
  811. const indentCharacter = type === INDENT_TYPE_SPACE ? " " : " ";
  812. return indentCharacter.repeat(amount);
  813. }
  814. function detectIndent(string) {
  815. if (typeof string !== "string") {
  816. throw new TypeError("Expected a string");
  817. }
  818. let indents = makeIndentsMap(string, true);
  819. if (indents.size === 0) {
  820. indents = makeIndentsMap(string, false);
  821. }
  822. const keyOfMostUsedIndent = getMostUsedKey(indents);
  823. let type;
  824. let amount = 0;
  825. let indent = "";
  826. if (keyOfMostUsedIndent !== void 0) {
  827. ({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
  828. indent = makeIndentString(type, amount);
  829. }
  830. return {
  831. amount,
  832. type,
  833. indent
  834. };
  835. }
  836. // node_modules/.pnpm/detect-newline@4.0.0/node_modules/detect-newline/index.js
  837. function detectNewline(string) {
  838. if (typeof string !== "string") {
  839. throw new TypeError("Expected a string");
  840. }
  841. const newlines = string.match(/(?:\r?\n)/g) || [];
  842. if (newlines.length === 0) {
  843. return;
  844. }
  845. const crlf = newlines.filter((newline) => newline === "\r\n").length;
  846. const lf = newlines.length - crlf;
  847. return crlf > lf ? "\r\n" : "\n";
  848. }
  849. // src/fs.ts
  850. async function readJsonFile(name, cwd) {
  851. const file = await readTextFile(name, cwd);
  852. const data = JSON.parse(file.data);
  853. const indent = detectIndent(file.data).indent;
  854. const newline = detectNewline(file.data);
  855. return __spreadProps(__spreadValues({}, file), { data, indent, newline });
  856. }
  857. async function writeJsonFile(file) {
  858. let json = JSON.stringify(file.data, void 0, file.indent);
  859. if (file.newline)
  860. json += file.newline;
  861. return writeTextFile(__spreadProps(__spreadValues({}, file), { data: json }));
  862. }
  863. function readTextFile(name, cwd) {
  864. return new Promise((resolve, reject) => {
  865. const filePath = path.join(cwd, name);
  866. fs.readFile(filePath, "utf8", (err, text) => {
  867. if (err) {
  868. reject(err);
  869. } else {
  870. resolve({
  871. path: filePath,
  872. data: text
  873. });
  874. }
  875. });
  876. });
  877. }
  878. function writeTextFile(file) {
  879. return new Promise((resolve, reject) => {
  880. fs.writeFile(file.path, file.data, (err) => {
  881. if (err)
  882. reject(err);
  883. else
  884. resolve();
  885. });
  886. });
  887. }
  888. // src/manifest.ts
  889. function isManifest(obj) {
  890. return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
  891. }
  892. function isOptionalString(value) {
  893. const type = typeof value;
  894. return value === null || type === "undefined" || type === "string";
  895. }
  896. // src/get-old-version.ts
  897. async function getOldVersion(operation) {
  898. const { cwd, files } = operation.options;
  899. const filesToCheck = files.filter((file) => file.endsWith(".json"));
  900. if (!filesToCheck.includes("package.json"))
  901. filesToCheck.push("package.json");
  902. for (const file of filesToCheck) {
  903. const version = await readVersion(file, cwd);
  904. if (version) {
  905. return operation.update({
  906. oldVersionSource: file,
  907. oldVersion: version
  908. });
  909. }
  910. }
  911. throw new Error(
  912. `Unable to determine the current version number. Checked ${filesToCheck.join(", ")}.`
  913. );
  914. }
  915. async function readVersion(file, cwd) {
  916. try {
  917. const { data: manifest } = await readJsonFile(file, cwd);
  918. if (isManifest(manifest)) {
  919. if (isValidVersion2(manifest.version))
  920. return manifest.version;
  921. }
  922. } catch (error) {
  923. return void 0;
  924. }
  925. }
  926. // src/git.ts
  927. import * as ezSpawn from "@jsdevtools/ez-spawn";
  928. async function gitCommit(operation) {
  929. if (!operation.options.commit)
  930. return operation;
  931. const { all, noVerify, message } = operation.options.commit;
  932. const { updatedFiles, newVersion } = operation.state;
  933. let args = [];
  934. if (all) {
  935. args.push("--all");
  936. }
  937. if (noVerify) {
  938. args.push("--no-verify");
  939. }
  940. const commitMessage = formatVersionString(message, newVersion);
  941. args.push("--message", commitMessage);
  942. if (!all)
  943. args = args.concat(updatedFiles);
  944. await ezSpawn.async("git", ["commit", ...args]);
  945. return operation.update({ event: "git commit" /* GitCommit */, commitMessage });
  946. }
  947. async function gitTag(operation) {
  948. if (!operation.options.tag)
  949. return operation;
  950. const { commit, tag } = operation.options;
  951. const { newVersion } = operation.state;
  952. const args = [
  953. // Create an annotated tag, which is recommended for releases.
  954. // See https://git-scm.com/docs/git-tag
  955. "--annotate",
  956. // Use the same commit message for the tag
  957. "--message",
  958. formatVersionString(commit.message, newVersion)
  959. ];
  960. const tagName = formatVersionString(tag.name, newVersion);
  961. args.push(tagName);
  962. await ezSpawn.async("git", ["tag", ...args]);
  963. return operation.update({ event: "git tag" /* GitTag */, tagName });
  964. }
  965. async function gitPush(operation) {
  966. if (!operation.options.push)
  967. return operation;
  968. await ezSpawn.async("git", "push");
  969. if (operation.options.tag) {
  970. await ezSpawn.async("git", ["push", "--tags"]);
  971. }
  972. return operation.update({ event: "git push" /* GitPush */ });
  973. }
  974. function formatVersionString(template, newVersion) {
  975. if (template.includes("%s"))
  976. return template.replace(/%s/g, newVersion);
  977. else
  978. return template + newVersion;
  979. }
  980. // src/normalize-options.ts
  981. import fg from "fast-glob";
  982. async function normalizeOptions(raw) {
  983. var _a;
  984. const preid = typeof raw.preid === "string" ? raw.preid : "beta";
  985. const push = Boolean(raw.push);
  986. const all = Boolean(raw.all);
  987. const noVerify = Boolean(raw.noVerify);
  988. const cwd = raw.cwd || process.cwd();
  989. const ignoreScripts = Boolean(raw.ignoreScripts);
  990. const execute = raw.execute;
  991. let release;
  992. if (!raw.release || raw.release === "prompt")
  993. release = { type: "prompt", preid };
  994. else if (isReleaseType(raw.release))
  995. release = { type: raw.release, preid };
  996. else
  997. release = { type: "version", version: raw.release };
  998. let tag;
  999. if (typeof raw.tag === "string")
  1000. tag = { name: raw.tag };
  1001. else if (raw.tag)
  1002. tag = { name: "v" };
  1003. let commit;
  1004. if (typeof raw.commit === "string")
  1005. commit = { all, noVerify, message: raw.commit };
  1006. else if (raw.commit || tag || push)
  1007. commit = { all, noVerify, message: "chore: release v" };
  1008. const files = await fg(
  1009. ((_a = raw.files) == null ? void 0 : _a.length) ? raw.files : ["package.json", "package-lock.json"],
  1010. {
  1011. cwd,
  1012. onlyFiles: true,
  1013. ignore: [
  1014. "**/{.git,node_modules,bower_components,__tests__,fixtures,fixture}/**"
  1015. ]
  1016. }
  1017. );
  1018. let ui;
  1019. if (raw.interface === false) {
  1020. ui = { input: false, output: false };
  1021. } else if (raw.interface === true || !raw.interface) {
  1022. ui = { input: process.stdin, output: process.stdout };
  1023. } else {
  1024. let _b = raw.interface, { input, output } = _b, other = __objRest(_b, ["input", "output"]);
  1025. if (input === true || input !== false && !input)
  1026. input = process.stdin;
  1027. if (output === true || output !== false && !output)
  1028. output = process.stdout;
  1029. ui = __spreadValues({ input, output }, other);
  1030. }
  1031. if (release.type === "prompt" && !(ui.input && ui.output))
  1032. throw new Error("Cannot prompt for the version number because input or output has been disabled.");
  1033. return { release, commit, tag, push, files, cwd, interface: ui, ignoreScripts, execute };
  1034. }
  1035. // src/operation.ts
  1036. var Operation = class {
  1037. /**
  1038. * Private constructor. Use the `Operation.start()` static method instead.
  1039. */
  1040. constructor(options, progress) {
  1041. /**
  1042. * The current state of the operation.
  1043. */
  1044. this.state = {
  1045. release: void 0,
  1046. oldVersion: "",
  1047. oldVersionSource: "",
  1048. newVersion: "",
  1049. commitMessage: "",
  1050. tagName: "",
  1051. updatedFiles: [],
  1052. skippedFiles: []
  1053. };
  1054. this.options = options;
  1055. this._progress = progress;
  1056. }
  1057. /**
  1058. * The results of the operation.
  1059. */
  1060. get results() {
  1061. const options = this.options;
  1062. const state = this.state;
  1063. return {
  1064. release: state.release,
  1065. oldVersion: state.oldVersion,
  1066. newVersion: state.newVersion,
  1067. commit: options.commit ? state.commitMessage : false,
  1068. tag: options.tag ? state.tagName : false,
  1069. updatedFiles: state.updatedFiles.slice(),
  1070. skippedFiles: state.skippedFiles.slice()
  1071. };
  1072. }
  1073. /**
  1074. * Starts a new `versionBump()` operation.
  1075. */
  1076. static async start(input) {
  1077. const options = await normalizeOptions(input);
  1078. return new Operation(options, input.progress);
  1079. }
  1080. /**
  1081. * Updates the operation state and results, and reports the updated progress to the user.
  1082. */
  1083. update(_a) {
  1084. var _b = _a, { event, script } = _b, newState = __objRest(_b, ["event", "script"]);
  1085. Object.assign(this.state, newState);
  1086. if (event && this._progress) {
  1087. this._progress(__spreadValues({ event, script }, this.results));
  1088. }
  1089. return this;
  1090. }
  1091. };
  1092. // src/run-npm-script.ts
  1093. import * as ezSpawn2 from "@jsdevtools/ez-spawn";
  1094. async function runNpmScript(script, operation) {
  1095. const { cwd, ignoreScripts } = operation.options;
  1096. if (!ignoreScripts) {
  1097. const { data: manifest } = await readJsonFile("package.json", cwd);
  1098. if (isManifest(manifest) && hasScript(manifest, script)) {
  1099. await ezSpawn2.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
  1100. operation.update({ event: "npm script" /* NpmScript */, script });
  1101. }
  1102. }
  1103. return operation;
  1104. }
  1105. function hasScript(manifest, script) {
  1106. const scripts = manifest.scripts;
  1107. if (scripts && typeof scripts === "object")
  1108. return Boolean(scripts[script]);
  1109. return false;
  1110. }
  1111. // src/update-files.ts
  1112. import * as path2 from "path";
  1113. async function updateFiles(operation) {
  1114. const { files } = operation.options;
  1115. for (const relPath of files) {
  1116. const modified = await updateFile(relPath, operation);
  1117. if (modified) {
  1118. operation.update({
  1119. event: "file updated" /* FileUpdated */,
  1120. updatedFiles: operation.state.updatedFiles.concat(relPath)
  1121. });
  1122. } else {
  1123. operation.update({
  1124. event: "file skipped" /* FileSkipped */,
  1125. skippedFiles: operation.state.skippedFiles.concat(relPath)
  1126. });
  1127. }
  1128. }
  1129. return operation;
  1130. }
  1131. async function updateFile(relPath, operation) {
  1132. const name = path2.basename(relPath).trim().toLowerCase();
  1133. switch (name) {
  1134. case "package.json":
  1135. case "package-lock.json":
  1136. case "bower.json":
  1137. case "component.json":
  1138. return updateManifestFile(relPath, operation);
  1139. default:
  1140. return updateTextFile(relPath, operation);
  1141. }
  1142. }
  1143. async function updateManifestFile(relPath, operation) {
  1144. const { cwd } = operation.options;
  1145. const { newVersion } = operation.state;
  1146. let modified = false;
  1147. const file = await readJsonFile(relPath, cwd);
  1148. if (isManifest(file.data) && file.data.version !== newVersion) {
  1149. file.data.version = newVersion;
  1150. await writeJsonFile(file);
  1151. modified = true;
  1152. }
  1153. return modified;
  1154. }
  1155. async function updateTextFile(relPath, operation) {
  1156. const { cwd } = operation.options;
  1157. const { oldVersion, newVersion } = operation.state;
  1158. const modified = false;
  1159. const file = await readTextFile(relPath, cwd);
  1160. if (file.data.includes(oldVersion)) {
  1161. const sanitizedVersion = oldVersion.replace(/(\W)/g, "\\$1");
  1162. const replacePattern = new RegExp(`(\\b|v)${sanitizedVersion}\\b`, "g");
  1163. file.data = file.data.replace(replacePattern, `$1${newVersion}`);
  1164. await writeTextFile(file);
  1165. return true;
  1166. }
  1167. return modified;
  1168. }
  1169. // src/version-bump.ts
  1170. async function versionBump(arg = {}) {
  1171. if (typeof arg === "string")
  1172. arg = { release: arg };
  1173. const operation = await Operation.start(arg);
  1174. await getOldVersion(operation);
  1175. await getNewVersion(operation);
  1176. if (arg.confirm) {
  1177. printSummary(operation);
  1178. if (!await prompts2({
  1179. name: "yes",
  1180. type: "confirm",
  1181. message: "Bump?",
  1182. initial: true
  1183. }).then((r) => r.yes))
  1184. process.exit(1);
  1185. }
  1186. await runNpmScript("preversion" /* PreVersion */, operation);
  1187. await updateFiles(operation);
  1188. if (operation.options.execute) {
  1189. console.log(log_symbols_default.info, "Executing script", operation.options.execute);
  1190. await ezSpawn3.async(operation.options.execute, { stdio: "inherit" });
  1191. console.log(log_symbols_default.success, "Script finished");
  1192. }
  1193. await runNpmScript("version" /* Version */, operation);
  1194. await gitCommit(operation);
  1195. await gitTag(operation);
  1196. await runNpmScript("postversion" /* PostVersion */, operation);
  1197. await gitPush(operation);
  1198. return operation.results;
  1199. }
  1200. function printSummary(operation) {
  1201. console.log();
  1202. console.log(` files ${operation.options.files.map((i) => import_picocolors2.default.bold(i)).join("\n ")}`);
  1203. if (operation.options.commit)
  1204. console.log(` commit ${import_picocolors2.default.bold(formatVersionString(operation.options.commit.message, operation.state.newVersion))}`);
  1205. if (operation.options.tag)
  1206. console.log(` tag ${import_picocolors2.default.bold(formatVersionString(operation.options.tag.name, operation.state.newVersion))}`);
  1207. if (operation.options.execute)
  1208. console.log(` execute ${import_picocolors2.default.bold(operation.options.execute)}`);
  1209. if (operation.options.push)
  1210. console.log(` push ${import_picocolors2.default.cyan(import_picocolors2.default.bold("yes"))}`);
  1211. console.log();
  1212. console.log(` from ${import_picocolors2.default.bold(operation.state.oldVersion)}`);
  1213. console.log(` to ${import_picocolors2.default.green(import_picocolors2.default.bold(operation.state.newVersion))}`);
  1214. console.log();
  1215. }
  1216. async function versionBumpInfo(arg = {}) {
  1217. if (typeof arg === "string")
  1218. arg = { release: arg };
  1219. const operation = await Operation.start(arg);
  1220. await getOldVersion(operation);
  1221. await getNewVersion(operation);
  1222. return operation;
  1223. }
  1224. // src/config.ts
  1225. import { loadConfig } from "c12";
  1226. var bumpConfigDefaults = {
  1227. commit: true,
  1228. push: true,
  1229. tag: true,
  1230. recursive: false,
  1231. noVerify: false,
  1232. confirm: true,
  1233. ignoreScripts: false,
  1234. all: false,
  1235. files: []
  1236. };
  1237. async function loadBumpConfig(overrides, cwd = process.cwd()) {
  1238. const { config } = await loadConfig({
  1239. name: "bump",
  1240. defaults: bumpConfigDefaults,
  1241. overrides: __spreadValues({}, overrides),
  1242. cwd
  1243. });
  1244. return config;
  1245. }
  1246. function defineConfig(config) {
  1247. return config;
  1248. }
  1249. export {
  1250. __toESM,
  1251. require_picocolors,
  1252. log_symbols_default,
  1253. ReleaseType,
  1254. isReleaseType,
  1255. ProgressEvent,
  1256. NpmScript,
  1257. versionBump,
  1258. versionBumpInfo,
  1259. bumpConfigDefaults,
  1260. loadBumpConfig,
  1261. defineConfig
  1262. };