CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
utils.js6415 linesDownload Raw Back to drizzle-kit
1#!/usr/bin/env node2"use strict";3var __create = Object.create;4var __defProp = Object.defineProperty;5var __getOwnPropDesc = Object.getOwnPropertyDescriptor;6var __getOwnPropNames = Object.getOwnPropertyNames;7var __getProtoOf = Object.getPrototypeOf;8var __hasOwnProp = Object.prototype.hasOwnProperty;9var __commonJS = (cb, mod) => function __require() {10  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;11};12var __export = (target, all) => {13  for (var name in all)14    __defProp(target, name, { get: all[name], enumerable: true });15};16var __copyProps = (to, from, except, desc) => {17  if (from && typeof from === "object" || typeof from === "function") {18    for (let key of __getOwnPropNames(from))19      if (!__hasOwnProp.call(to, key) && key !== except)20        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });21  }22  return to;23};24var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(25  // If the importer is in node compatibility mode or this is not an ESM26  // file that has been converted to a CommonJS file using a Babel-27  // compatible transform (i.e. "__esModule" has not been set), then set28  // "default" to the CommonJS "module.exports" for node compatibility.29  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,30  mod31));32var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);33 34// ../node_modules/.pnpm/hanji@0.0.8/node_modules/hanji/readline.js35var require_readline = __commonJS({36  "../node_modules/.pnpm/hanji@0.0.8/node_modules/hanji/readline.js"(exports2) {37    "use strict";38    var __importDefault = exports2 && exports2.__importDefault || function(mod) {39      return mod && mod.__esModule ? mod : { "default": mod };40    };41    Object.defineProperty(exports2, "__esModule", { value: true });42    exports2.createClosable = exports2.stdout = exports2.stdin = void 0;43    var readline_1 = __importDefault(require("readline"));44    exports2.stdin = process.stdin;45    exports2.stdout = process.stdout;46    readline_1.default.emitKeypressEvents(exports2.stdin);47    var createClosable = () => {48      return readline_1.default.createInterface({49        input: exports2.stdin,50        escapeCodeTimeout: 5051      });52    };53    exports2.createClosable = createClosable;54  }55});56 57// ../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js58var require_src = __commonJS({59  "../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports2, module2) {60    "use strict";61    var ESC = "\x1B";62    var CSI = `${ESC}[`;63    var beep = "\x07";64    var cursor = {65      to(x, y) {66        if (!y) return `${CSI}${x + 1}G`;67        return `${CSI}${y + 1};${x + 1}H`;68      },69      move(x, y) {70        let ret = "";71        if (x < 0) ret += `${CSI}${-x}D`;72        else if (x > 0) ret += `${CSI}${x}C`;73        if (y < 0) ret += `${CSI}${-y}A`;74        else if (y > 0) ret += `${CSI}${y}B`;75        return ret;76      },77      up: (count = 1) => `${CSI}${count}A`,78      down: (count = 1) => `${CSI}${count}B`,79      forward: (count = 1) => `${CSI}${count}C`,80      backward: (count = 1) => `${CSI}${count}D`,81      nextLine: (count = 1) => `${CSI}E`.repeat(count),82      prevLine: (count = 1) => `${CSI}F`.repeat(count),83      left: `${CSI}G`,84      hide: `${CSI}?25l`,85      show: `${CSI}?25h`,86      save: `${ESC}7`,87      restore: `${ESC}8`88    };89    var scroll = {90      up: (count = 1) => `${CSI}S`.repeat(count),91      down: (count = 1) => `${CSI}T`.repeat(count)92    };93    var erase = {94      screen: `${CSI}2J`,95      up: (count = 1) => `${CSI}1J`.repeat(count),96      down: (count = 1) => `${CSI}J`.repeat(count),97      line: `${CSI}2K`,98      lineEnd: `${CSI}K`,99      lineStart: `${CSI}1K`,100      lines(count) {101        let clear = "";102        for (let i = 0; i < count; i++)103          clear += this.line + (i < count - 1 ? cursor.up() : "");104        if (count)105          clear += cursor.left;106        return clear;107      }108    };109    module2.exports = { cursor, scroll, erase, beep };110  }111});112 113// ../node_modules/.pnpm/hanji@0.0.8/node_modules/hanji/utils.js114var require_utils = __commonJS({115  "../node_modules/.pnpm/hanji@0.0.8/node_modules/hanji/utils.js"(exports2) {116    "use strict";117    Object.defineProperty(exports2, "__esModule", { value: true });118    exports2.clear = exports2.stringWidth = exports2.fallbackStringWidth = exports2.stripAnsi = exports2.strip = void 0;119    var sisteransi_1 = require_src();120    var strip = (str) => {121      const pattern = [122        "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",123        "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"124      ].join("|");125      const RGX = new RegExp(pattern, "g");126      return typeof str === "string" ? str.replace(RGX, "") : str;127    };128    exports2.strip = strip;129    var stripAnsi = (str) => {130      if (typeof Bun !== "undefined" && Bun.stripANSI) {131        return Bun.stripANSI(str);132      }133      return (0, exports2.strip)(str);134    };135    exports2.stripAnsi = stripAnsi;136    var fallbackStringWidth = (str) => {137      let len = 0;138      const stripped = (0, exports2.stripAnsi)(str);139      for (const _ of stripped)140        len++;141      return len;142    };143    exports2.fallbackStringWidth = fallbackStringWidth;144    var stringWidth = (str) => {145      if (typeof Bun !== "undefined" && Bun.stringWidth)146        return Bun.stringWidth(str);147      return (0, exports2.fallbackStringWidth)(str);148    };149    exports2.stringWidth = stringWidth;150    var clear = function(prompt, perLine) {151      if (!perLine)152        return sisteransi_1.erase.line + sisteransi_1.cursor.to(0);153      let rows = 0;154      const lines = prompt.split(/\r?\n/);155      for (let line of lines) {156        rows += 1 + Math.floor(Math.max((0, exports2.stringWidth)(line) - 1, 0) / perLine);157      }158      return sisteransi_1.erase.lines(rows);159    };160    exports2.clear = clear;161  }162});163 164// ../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js165var require_lodash = __commonJS({166  "../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports2, module2) {167    var FUNC_ERROR_TEXT = "Expected a function";168    var NAN = 0 / 0;169    var symbolTag = "[object Symbol]";170    var reTrim = /^\s+|\s+$/g;171    var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;172    var reIsBinary = /^0b[01]+$/i;173    var reIsOctal = /^0o[0-7]+$/i;174    var freeParseInt = parseInt;175    var freeGlobal = typeof global == "object" && global && global.Object === Object && global;176    var freeSelf = typeof self == "object" && self && self.Object === Object && self;177    var root = freeGlobal || freeSelf || Function("return this")();178    var objectProto = Object.prototype;179    var objectToString = objectProto.toString;180    var nativeMax = Math.max;181    var nativeMin = Math.min;182    var now = function() {183      return root.Date.now();184    };185    function debounce(func, wait, options) {186      var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;187      if (typeof func != "function") {188        throw new TypeError(FUNC_ERROR_TEXT);189      }190      wait = toNumber(wait) || 0;191      if (isObject(options)) {192        leading = !!options.leading;193        maxing = "maxWait" in options;194        maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;195        trailing = "trailing" in options ? !!options.trailing : trailing;196      }197      function invokeFunc(time) {198        var args = lastArgs, thisArg = lastThis;199        lastArgs = lastThis = void 0;200        lastInvokeTime = time;201        result = func.apply(thisArg, args);202        return result;203      }204      function leadingEdge(time) {205        lastInvokeTime = time;206        timerId = setTimeout(timerExpired, wait);207        return leading ? invokeFunc(time) : result;208      }209      function remainingWait(time) {210        var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;211        return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;212      }213      function shouldInvoke(time) {214        var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;215        return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;216      }217      function timerExpired() {218        var time = now();219        if (shouldInvoke(time)) {220          return trailingEdge(time);221        }222        timerId = setTimeout(timerExpired, remainingWait(time));223      }224      function trailingEdge(time) {225        timerId = void 0;226        if (trailing && lastArgs) {227          return invokeFunc(time);228        }229        lastArgs = lastThis = void 0;230        return result;231      }232      function cancel() {233        if (timerId !== void 0) {234          clearTimeout(timerId);235        }236        lastInvokeTime = 0;237        lastArgs = lastCallTime = lastThis = timerId = void 0;238      }239      function flush() {240        return timerId === void 0 ? result : trailingEdge(now());241      }242      function debounced() {243        var time = now(), isInvoking = shouldInvoke(time);244        lastArgs = arguments;245        lastThis = this;246        lastCallTime = time;247        if (isInvoking) {248          if (timerId === void 0) {249            return leadingEdge(lastCallTime);250          }251          if (maxing) {252            timerId = setTimeout(timerExpired, wait);253            return invokeFunc(lastCallTime);254          }255        }256        if (timerId === void 0) {257          timerId = setTimeout(timerExpired, wait);258        }259        return result;260      }261      debounced.cancel = cancel;262      debounced.flush = flush;263      return debounced;264    }265    function throttle(func, wait, options) {266      var leading = true, trailing = true;267      if (typeof func != "function") {268        throw new TypeError(FUNC_ERROR_TEXT);269      }270      if (isObject(options)) {271        leading = "leading" in options ? !!options.leading : leading;272        trailing = "trailing" in options ? !!options.trailing : trailing;273      }274      return debounce(func, wait, {275        "leading": leading,276        "maxWait": wait,277        "trailing": trailing278      });279    }280    function isObject(value) {281      var type = typeof value;282      return !!value && (type == "object" || type == "function");283    }284    function isObjectLike(value) {285      return !!value && typeof value == "object";286    }287    function isSymbol(value) {288      return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;289    }290    function toNumber(value) {291      if (typeof value == "number") {292        return value;293      }294      if (isSymbol(value)) {295        return NAN;296      }297      if (isObject(value)) {298        var other = typeof value.valueOf == "function" ? value.valueOf() : value;299        value = isObject(other) ? other + "" : other;300      }301      if (typeof value != "string") {302        return value === 0 ? value : +value;303      }304      value = value.replace(reTrim, "");305      var isBinary = reIsBinary.test(value);306      return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;307    }308    module2.exports = throttle;309  }310});311 312// ../node_modules/.pnpm/hanji@0.0.8/node_modules/hanji/index.js313var require_hanji = __commonJS({314  "../node_modules/.pnpm/hanji@0.0.8/node_modules/hanji/index.js"(exports2) {315    "use strict";316    var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {317      function adopt(value) {318        return value instanceof P ? value : new P(function(resolve) {319          resolve(value);320        });321      }322      return new (P || (P = Promise))(function(resolve, reject) {323        function fulfilled(value) {324          try {325            step(generator.next(value));326          } catch (e) {327            reject(e);328          }329        }330        function rejected(value) {331          try {332            step(generator["throw"](value));333          } catch (e) {334            reject(e);335          }336        }337        function step(result) {338          result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);339        }340        step((generator = generator.apply(thisArg, _arguments || [])).next());341      });342    };343    var __importDefault = exports2 && exports2.__importDefault || function(mod) {344      return mod && mod.__esModule ? mod : { "default": mod };345    };346    Object.defineProperty(exports2, "__esModule", { value: true });347    exports2.TaskTerminal = exports2.TaskView = exports2.Terminal = exports2.deferred = exports2.SelectState = exports2.Prompt = void 0;348    exports2.render = render2;349    exports2.renderWithTask = renderWithTask;350    exports2.onTerminate = onTerminate;351    var readline_1 = require_readline();352    var sisteransi_1 = require_src();353    var utils_1 = require_utils();354    var lodash_throttle_1 = __importDefault(require_lodash());355    var Prompt2 = class {356      constructor() {357        this.attachCallbacks = [];358        this.detachCallbacks = [];359        this.inputCallbacks = [];360      }361      requestLayout() {362        this.terminal.requestLayout();363      }364      on(type, callback) {365        if (type === "attach") {366          this.attachCallbacks.push(callback);367        } else if (type === "detach") {368          this.detachCallbacks.push(callback);369        } else if (type === "input") {370          this.inputCallbacks.push(callback);371        }372      }373      attach(terminal) {374        this.terminal = terminal;375        this.attachCallbacks.forEach((it) => it(terminal));376      }377      detach(terminal) {378        this.detachCallbacks.forEach((it) => it(terminal));379        this.terminal = void 0;380      }381      input(str, key) {382        this.inputCallbacks.forEach((it) => it(str, key));383      }384    };385    exports2.Prompt = Prompt2;386    var SelectState2 = class {387      constructor(items) {388        this.items = items;389        this.selectedIdx = 0;390      }391      bind(prompt) {392        prompt.on("input", (str, key) => {393          const invalidate = this.consume(str, key);394          if (invalidate)395            prompt.requestLayout();396        });397      }398      consume(str, key) {399        if (!key)400          return false;401        if (key.name === "down") {402          this.selectedIdx = (this.selectedIdx + 1) % this.items.length;403          return true;404        }405        if (key.name === "up") {406          this.selectedIdx -= 1;407          this.selectedIdx = this.selectedIdx < 0 ? this.items.length - 1 : this.selectedIdx;408          return true;409        }410        return false;411      }412    };413    exports2.SelectState = SelectState2;414    var deferred = () => {415      let resolve;416      let reject;417      const promise = new Promise((res, rej) => {418        resolve = res;419        reject = rej;420      });421      return {422        resolve,423        reject,424        promise425      };426    };427    exports2.deferred = deferred;428    var Terminal = class {429      constructor(view5, stdin, stdout, closable) {430        this.view = view5;431        this.stdin = stdin;432        this.stdout = stdout;433        this.closable = closable;434        this.text = "";435        this.status = "idle";436        if (this.stdin.isTTY)437          this.stdin.setRawMode(true);438        const keypress = (str, key) => {439          if (key.name === "c" && key.ctrl === true) {440            this.requestLayout();441            this.view.detach(this);442            this.tearDown(keypress);443            if (terminateHandler) {444              terminateHandler(this.stdin, this.stdout);445              return;446            }447            this.stdout.write(`448^C449`);450            process.exit(1);451          }452          if (key.name === "escape") {453            this.status = "aborted";454            this.requestLayout();455            this.view.detach(this);456            this.tearDown(keypress);457            this.resolve({ status: "aborted", data: void 0 });458            return;459          }460          if (key.name === "return") {461            this.status = "submitted";462            this.requestLayout();463            this.view.detach(this);464            this.tearDown(keypress);465            this.resolve({ status: "submitted", data: this.view.result() });466            return;467          }468          view5.input(str, key);469        };470        this.stdin.on("keypress", keypress);471        this.view.attach(this);472        const { resolve, promise } = (0, exports2.deferred)();473        this.resolve = resolve;474        this.promise = promise;475        this.renderFunc = (0, lodash_throttle_1.default)((str) => {476          this.stdout.write(str);477        });478      }479      tearDown(keypress) {480        this.stdout.write(sisteransi_1.cursor.show);481        this.stdin.removeListener("keypress", keypress);482        if (this.stdin.isTTY)483          this.stdin.setRawMode(false);484        this.closable.close();485      }486      result() {487        return this.promise;488      }489      toggleCursor(state) {490        if (state === "hide") {491          this.stdout.write(sisteransi_1.cursor.hide);492        } else {493          this.stdout.write(sisteransi_1.cursor.show);494        }495      }496      requestLayout() {497        const string = this.view.render(this.status);498        const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";499        this.text = string;500        this.renderFunc(`${clearPrefix}${string}`);501      }502    };503    exports2.Terminal = Terminal;504    var TaskView2 = class {505      constructor() {506        this.attachCallbacks = [];507        this.detachCallbacks = [];508      }509      requestLayout() {510        this.terminal.requestLayout();511      }512      attach(terminal) {513        this.terminal = terminal;514        this.attachCallbacks.forEach((it) => it(terminal));515      }516      detach(terminal) {517        this.detachCallbacks.forEach((it) => it(terminal));518        this.terminal = void 0;519      }520      on(type, callback) {521        if (type === "attach") {522          this.attachCallbacks.push(callback);523        } else if (type === "detach") {524          this.detachCallbacks.push(callback);525        }526      }527    };528    exports2.TaskView = TaskView2;529    var TaskTerminal = class {530      constructor(view5, stdout) {531        this.view = view5;532        this.stdout = stdout;533        this.text = "";534        this.view.attach(this);535      }536      requestLayout() {537        const string = this.view.render("pending");538        const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";539        this.text = string;540        this.stdout.write(`${clearPrefix}${string}`);541      }542      clear() {543        const string = this.view.render("done");544        this.view.detach(this);545        const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";546        this.stdout.write(`${clearPrefix}${string}`);547      }548      reject(err) {549        const string = this.view.render("rejected", err);550        this.view.detach(this);551        const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";552        this.stdout.write(`${clearPrefix}${string}`);553      }554    };555    exports2.TaskTerminal = TaskTerminal;556    function render2(view5) {557      if (typeof view5 === "string") {558        process.stdout.write(`${view5}559`);560        return;561      }562      if (!process.stdin.isTTY || !process.stdout.isTTY) {563        return Promise.reject(new Error("Interactive prompts require a TTY terminal (process.stdin.isTTY or process.stdout.isTTY is false). This can happen when running in CI, piped input, or non-interactive shells."));564      }565      const closable = (0, readline_1.createClosable)();566      const terminal = new Terminal(view5, readline_1.stdin, readline_1.stdout, closable);567      terminal.requestLayout();568      return terminal.result();569    }570    function renderWithTask(view5, task) {571      return __awaiter(this, void 0, void 0, function* () {572        const terminal = new TaskTerminal(view5, process.stdout);573        terminal.requestLayout();574        try {575          const result = yield task;576          terminal.clear();577          return result;578        } catch (err) {579          terminal.reject(err);580          process.exit(1);581        }582      });583    }584    var terminateHandler;585    function onTerminate(callback) {586      terminateHandler = callback;587    }588  }589});590 591// src/utils.ts592var utils_exports = {};593__export(utils_exports, {594  assertV1OutFolder: () => assertV1OutFolder,595  columnRenameKey: () => columnRenameKey,596  copy: () => copy,597  dryJournal: () => dryJournal,598  escapeSingleQuotes: () => escapeSingleQuotes,599  findAddedAndRemoved: () => findAddedAndRemoved,600  isPgArrayType: () => isPgArrayType,601  kloudMeta: () => kloudMeta,602  normalisePGliteUrl: () => normalisePGliteUrl,603  normaliseSQLiteUrl: () => normaliseSQLiteUrl,604  objectValues: () => objectValues,605  prepareMigrationFolder: () => prepareMigrationFolder,606  prepareMigrationMeta: () => prepareMigrationMeta,607  prepareOutFolder: () => prepareOutFolder,608  schemaRenameKey: () => schemaRenameKey,609  tableRenameKey: () => tableRenameKey,610  unescapeSingleQuotes: () => unescapeSingleQuotes,611  validateWithReport: () => validateWithReport612});613module.exports = __toCommonJS(utils_exports);614 615// ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/ansi-styles/index.js616var ANSI_BACKGROUND_OFFSET = 10;617var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;618var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;619var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;620var styles = {621  modifier: {622    reset: [0, 0],623    // 21 isn't widely supported and 22 does the same thing624    bold: [1, 22],625    dim: [2, 22],626    italic: [3, 23],627    underline: [4, 24],628    overline: [53, 55],629    inverse: [7, 27],630    hidden: [8, 28],631    strikethrough: [9, 29]632  },633  color: {634    black: [30, 39],635    red: [31, 39],636    green: [32, 39],637    yellow: [33, 39],638    blue: [34, 39],639    magenta: [35, 39],640    cyan: [36, 39],641    white: [37, 39],642    // Bright color643    blackBright: [90, 39],644    gray: [90, 39],645    // Alias of `blackBright`646    grey: [90, 39],647    // Alias of `blackBright`648    redBright: [91, 39],649    greenBright: [92, 39],650    yellowBright: [93, 39],651    blueBright: [94, 39],652    magentaBright: [95, 39],653    cyanBright: [96, 39],654    whiteBright: [97, 39]655  },656  bgColor: {657    bgBlack: [40, 49],658    bgRed: [41, 49],659    bgGreen: [42, 49],660    bgYellow: [43, 49],661    bgBlue: [44, 49],662    bgMagenta: [45, 49],663    bgCyan: [46, 49],664    bgWhite: [47, 49],665    // Bright color666    bgBlackBright: [100, 49],667    bgGray: [100, 49],668    // Alias of `bgBlackBright`669    bgGrey: [100, 49],670    // Alias of `bgBlackBright`671    bgRedBright: [101, 49],672    bgGreenBright: [102, 49],673    bgYellowBright: [103, 49],674    bgBlueBright: [104, 49],675    bgMagentaBright: [105, 49],676    bgCyanBright: [106, 49],677    bgWhiteBright: [107, 49]678  }679};680var modifierNames = Object.keys(styles.modifier);681var foregroundColorNames = Object.keys(styles.color);682var backgroundColorNames = Object.keys(styles.bgColor);683var colorNames = [...foregroundColorNames, ...backgroundColorNames];684function assembleStyles() {685  const codes = /* @__PURE__ */ new Map();686  for (const [groupName, group] of Object.entries(styles)) {687    for (const [styleName, style] of Object.entries(group)) {688      styles[styleName] = {689        open: `\x1B[${style[0]}m`,690        close: `\x1B[${style[1]}m`691      };692      group[styleName] = styles[styleName];693      codes.set(style[0], style[1]);694    }695    Object.defineProperty(styles, groupName, {696      value: group,697      enumerable: false698    });699  }700  Object.defineProperty(styles, "codes", {701    value: codes,702    enumerable: false703  });704  styles.color.close = "\x1B[39m";705  styles.bgColor.close = "\x1B[49m";706  styles.color.ansi = wrapAnsi16();707  styles.color.ansi256 = wrapAnsi256();708  styles.color.ansi16m = wrapAnsi16m();709  styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);710  styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);711  styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);712  Object.defineProperties(styles, {713    rgbToAnsi256: {714      value(red, green, blue) {715        if (red === green && green === blue) {716          if (red < 8) {717            return 16;718          }719          if (red > 248) {720            return 231;721          }722          return Math.round((red - 8) / 247 * 24) + 232;723        }724        return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);725      },726      enumerable: false727    },728    hexToRgb: {729      value(hex) {730        const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));731        if (!matches) {732          return [0, 0, 0];733        }734        let [colorString] = matches;735        if (colorString.length === 3) {736          colorString = [...colorString].map((character) => character + character).join("");737        }738        const integer = Number.parseInt(colorString, 16);739        return [740          /* eslint-disable no-bitwise */741          integer >> 16 & 255,742          integer >> 8 & 255,743          integer & 255744          /* eslint-enable no-bitwise */745        ];746      },747      enumerable: false748    },749    hexToAnsi256: {750      value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),751      enumerable: false752    },753    ansi256ToAnsi: {754      value(code) {755        if (code < 8) {756          return 30 + code;757        }758        if (code < 16) {759          return 90 + (code - 8);760        }761        let red;762        let green;763        let blue;764        if (code >= 232) {765          red = ((code - 232) * 10 + 8) / 255;766          green = red;767          blue = red;768        } else {769          code -= 16;770          const remainder = code % 36;771          red = Math.floor(code / 36) / 5;772          green = Math.floor(remainder / 6) / 5;773          blue = remainder % 6 / 5;774        }775        const value = Math.max(red, green, blue) * 2;776        if (value === 0) {777          return 30;778        }779        let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));780        if (value === 2) {781          result += 60;782        }783        return result;784      },785      enumerable: false786    },787    rgbToAnsi: {788      value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),789      enumerable: false790    },791    hexToAnsi: {792      value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),793      enumerable: false794    }795  });796  return styles;797}798var ansiStyles = assembleStyles();799var ansi_styles_default = ansiStyles;800 801// ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/supports-color/index.js802var import_node_process = __toESM(require("node:process"), 1);803var import_node_os = __toESM(require("node:os"), 1);804var import_node_tty = __toESM(require("node:tty"), 1);805function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {806  const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";807  const position = argv.indexOf(prefix + flag);808  const terminatorPosition = argv.indexOf("--");809  return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);810}811var { env } = import_node_process.default;812var flagForceColor;813if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {814  flagForceColor = 0;815} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {816  flagForceColor = 1;817}818function envForceColor() {819  if ("FORCE_COLOR" in env) {820    if (env.FORCE_COLOR === "true") {821      return 1;822    }823    if (env.FORCE_COLOR === "false") {824      return 0;825    }826    return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);827  }828}829function translateLevel(level) {830  if (level === 0) {831    return false;832  }833  return {834    level,835    hasBasic: true,836    has256: level >= 2,837    has16m: level >= 3838  };839}840function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {841  const noFlagForceColor = envForceColor();842  if (noFlagForceColor !== void 0) {843    flagForceColor = noFlagForceColor;844  }845  const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;846  if (forceColor === 0) {847    return 0;848  }849  if (sniffFlags) {850    if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {851      return 3;852    }853    if (hasFlag("color=256")) {854      return 2;855    }856  }857  if ("TF_BUILD" in env && "AGENT_NAME" in env) {858    return 1;859  }860  if (haveStream && !streamIsTTY && forceColor === void 0) {861    return 0;862  }863  const min = forceColor || 0;864  if (env.TERM === "dumb") {865    return min;866  }867  if (import_node_process.default.platform === "win32") {868    const osRelease = import_node_os.default.release().split(".");869    if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {870      return Number(osRelease[2]) >= 14931 ? 3 : 2;871    }872    return 1;873  }874  if ("CI" in env) {875    if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {876      return 3;877    }878    if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {879      return 1;880    }881    return min;882  }883  if ("TEAMCITY_VERSION" in env) {884    return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;885  }886  if (env.COLORTERM === "truecolor") {887    return 3;888  }889  if (env.TERM === "xterm-kitty") {890    return 3;891  }892  if ("TERM_PROGRAM" in env) {893    const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);894    switch (env.TERM_PROGRAM) {895      case "iTerm.app": {896        return version >= 3 ? 3 : 2;897      }898      case "Apple_Terminal": {899        return 2;900      }901    }902  }903  if (/-256(color)?$/i.test(env.TERM)) {904    return 2;905  }906  if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {907    return 1;908  }909  if ("COLORTERM" in env) {910    return 1;911  }912  return min;913}914function createSupportsColor(stream, options = {}) {915  const level = _supportsColor(stream, {916    streamIsTTY: stream && stream.isTTY,917    ...options918  });919  return translateLevel(level);920}921var supportsColor = {922  stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),923  stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })924};925var supports_color_default = supportsColor;926 927// ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/utilities.js928function stringReplaceAll(string, substring, replacer) {929  let index6 = string.indexOf(substring);930  if (index6 === -1) {931    return string;932  }933  const substringLength = substring.length;934  let endIndex = 0;935  let returnValue = "";936  do {937    returnValue += string.slice(endIndex, index6) + substring + replacer;938    endIndex = index6 + substringLength;939    index6 = string.indexOf(substring, endIndex);940  } while (index6 !== -1);941  returnValue += string.slice(endIndex);942  return returnValue;943}944function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index6) {945  let endIndex = 0;946  let returnValue = "";947  do {948    const gotCR = string[index6 - 1] === "\r";949    returnValue += string.slice(endIndex, gotCR ? index6 - 1 : index6) + prefix + (gotCR ? "\r\n" : "\n") + postfix;950    endIndex = index6 + 1;951    index6 = string.indexOf("\n", endIndex);952  } while (index6 !== -1);953  returnValue += string.slice(endIndex);954  return returnValue;955}956 957// ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/index.js958var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;959var GENERATOR = Symbol("GENERATOR");960var STYLER = Symbol("STYLER");961var IS_EMPTY = Symbol("IS_EMPTY");962var levelMapping = [963  "ansi",964  "ansi",965  "ansi256",966  "ansi16m"967];968var styles2 = /* @__PURE__ */ Object.create(null);969var applyOptions = (object, options = {}) => {970  if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {971    throw new Error("The `level` option should be an integer from 0 to 3");972  }973  const colorLevel = stdoutColor ? stdoutColor.level : 0;974  object.level = options.level === void 0 ? colorLevel : options.level;975};976var chalkFactory = (options) => {977  const chalk2 = (...strings) => strings.join(" ");978  applyOptions(chalk2, options);979  Object.setPrototypeOf(chalk2, createChalk.prototype);980  return chalk2;981};982function createChalk(options) {983  return chalkFactory(options);984}985Object.setPrototypeOf(createChalk.prototype, Function.prototype);986for (const [styleName, style] of Object.entries(ansi_styles_default)) {987  styles2[styleName] = {988    get() {989      const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);990      Object.defineProperty(this, styleName, { value: builder });991      return builder;992    }993  };994}995styles2.visible = {996  get() {997    const builder = createBuilder(this, this[STYLER], true);998    Object.defineProperty(this, "visible", { value: builder });999    return builder;1000  }1001};1002var getModelAnsi = (model, level, type, ...arguments_) => {1003  if (model === "rgb") {1004    if (level === "ansi16m") {1005      return ansi_styles_default[type].ansi16m(...arguments_);1006    }1007    if (level === "ansi256") {1008      return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));1009    }1010    return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));1011  }1012  if (model === "hex") {1013    return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));1014  }1015  return ansi_styles_default[type][model](...arguments_);1016};1017var usedModels = ["rgb", "hex", "ansi256"];1018for (const model of usedModels) {1019  styles2[model] = {1020    get() {1021      const { level } = this;1022      return function(...arguments_) {1023        const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);1024        return createBuilder(this, styler, this[IS_EMPTY]);1025      };1026    }1027  };1028  const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);1029  styles2[bgModel] = {1030    get() {1031      const { level } = this;1032      return function(...arguments_) {1033        const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);1034        return createBuilder(this, styler, this[IS_EMPTY]);1035      };1036    }1037  };1038}1039var proto = Object.defineProperties(() => {1040}, {1041  ...styles2,1042  level: {1043    enumerable: true,1044    get() {1045      return this[GENERATOR].level;1046    },1047    set(level) {1048      this[GENERATOR].level = level;1049    }1050  }1051});1052var createStyler = (open, close, parent) => {1053  let openAll;1054  let closeAll;1055  if (parent === void 0) {1056    openAll = open;1057    closeAll = close;1058  } else {1059    openAll = parent.openAll + open;1060    closeAll = close + parent.closeAll;1061  }1062  return {1063    open,1064    close,1065    openAll,1066    closeAll,1067    parent1068  };1069};1070var createBuilder = (self2, _styler, _isEmpty) => {1071  const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));1072  Object.setPrototypeOf(builder, proto);1073  builder[GENERATOR] = self2;1074  builder[STYLER] = _styler;1075  builder[IS_EMPTY] = _isEmpty;1076  return builder;1077};1078var applyStyle = (self2, string) => {1079  if (self2.level <= 0 || !string) {1080    return self2[IS_EMPTY] ? "" : string;1081  }1082  let styler = self2[STYLER];1083  if (styler === void 0) {1084    return string;1085  }1086  const { openAll, closeAll } = styler;1087  if (string.includes("\x1B")) {1088    while (styler !== void 0) {1089      string = stringReplaceAll(string, styler.close, styler.open);1090      styler = styler.parent;1091    }1092  }1093  const lfIndex = string.indexOf("\n");1094  if (lfIndex !== -1) {1095    string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);1096  }1097  return openAll + string + closeAll;1098};1099Object.defineProperties(createChalk.prototype, styles2);1100var chalk = createChalk();1101var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });1102var source_default = chalk;1103 1104// src/utils.ts1105var import_fs = require("fs");1106var import_path = require("path");1107var import_url = require("url");1108 1109// src/cli/views.ts1110var import_hanji = __toESM(require_hanji());1111var info = (msg, greyMsg = "") => {1112  return `${source_default.blue.bold("Info:")} ${msg} ${greyMsg ? source_default.grey(greyMsg) : ""}`.trim();1113};1114 1115// src/global.ts1116var originUUID = "00000000-0000-0000-0000-000000000000";1117var snapshotVersion = "7";1118function assertUnreachable(x) {1119  throw new Error("Didn't expect to get here");1120}1121 1122// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/helpers/util.js1123var util;1124(function(util2) {1125  util2.assertEqual = (_) => {1126  };1127  function assertIs(_arg) {1128  }1129  util2.assertIs = assertIs;1130  function assertNever(_x) {1131    throw new Error();1132  }1133  util2.assertNever = assertNever;1134  util2.arrayToEnum = (items) => {1135    const obj = {};1136    for (const item of items) {1137      obj[item] = item;1138    }1139    return obj;1140  };1141  util2.getValidEnumValues = (obj) => {1142    const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");1143    const filtered = {};1144    for (const k of validKeys) {1145      filtered[k] = obj[k];1146    }1147    return util2.objectValues(filtered);1148  };1149  util2.objectValues = (obj) => {1150    return util2.objectKeys(obj).map(function(e) {1151      return obj[e];1152    });1153  };1154  util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {1155    const keys = [];1156    for (const key in object) {1157      if (Object.prototype.hasOwnProperty.call(object, key)) {1158        keys.push(key);1159      }1160    }1161    return keys;1162  };1163  util2.find = (arr, checker) => {1164    for (const item of arr) {1165      if (checker(item))1166        return item;1167    }1168    return void 0;1169  };1170  util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;1171  function joinValues(array, separator = " | ") {1172    return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);1173  }1174  util2.joinValues = joinValues;1175  util2.jsonStringifyReplacer = (_, value) => {1176    if (typeof value === "bigint") {1177      return value.toString();1178    }1179    return value;1180  };1181})(util || (util = {}));1182var objectUtil;1183(function(objectUtil2) {1184  objectUtil2.mergeShapes = (first, second) => {1185    return {1186      ...first,1187      ...second1188      // second overwrites first1189    };1190  };1191})(objectUtil || (objectUtil = {}));1192var ZodParsedType = util.arrayToEnum([1193  "string",1194  "nan",1195  "number",1196  "integer",1197  "float",1198  "boolean",1199  "date",1200  "bigint",

Showing the first 1,200 of 6415 lines. Download the file for the rest.