bun-query-builder 0.2.26 → 0.2.27

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.
package/dist/bin/cli.js CHANGED
@@ -3049,25 +3049,27 @@ var init_dynamodb = __esm(() => {
3049
3049
 
3050
3050
  // ../../node_modules/bunfig/dist/index.js
3051
3051
  import { existsSync, statSync } from "fs";
3052
+ import { resolve } from "path";
3053
+ import process2 from "process";
3052
3054
  import { existsSync as existsSync13, mkdirSync as mkdirSync4, readdirSync as readdirSync4, readFileSync, writeFileSync as writeFileSync7 } from "fs";
3053
3055
  import { homedir as homedir3 } from "os";
3054
3056
  import { dirname as dirname4, resolve as resolve12 } from "path";
3055
3057
  import process20 from "process";
3056
- import { existsSync as existsSync2, statSync as statSync2 } from "fs";
3058
+ import { existsSync as existsSync3, statSync as statSync2 } from "fs";
3057
3059
  import { existsSync as existsSync8, mkdirSync as mkdirSync3, readdirSync as readdirSync3, writeFileSync as writeFileSync5 } from "fs";
3058
3060
  import { homedir as homedir2 } from "os";
3059
3061
  import { dirname as dirname3, resolve as resolve7 } from "path";
3060
3062
  import process12 from "process";
3061
3063
  import { join as join3, relative as relative2, resolve as resolve4 } from "path";
3062
3064
  import process7 from "process";
3063
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync3 } from "fs";
3065
+ import { existsSync as existsSync32, mkdirSync as mkdirSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync3 } from "fs";
3064
3066
  import { homedir } from "os";
3065
3067
  import { dirname as dirname2, resolve as resolve3 } from "path";
3066
3068
  import process6 from "process";
3067
3069
  import { join, relative, resolve as resolve2 } from "path";
3068
- import process2 from "process";
3070
+ import process22 from "process";
3069
3071
  import { existsSync as existsSync22, mkdirSync, readdirSync, writeFileSync } from "fs";
3070
- import { dirname, resolve } from "path";
3072
+ import { dirname, resolve as resolve5 } from "path";
3071
3073
  import process3 from "process";
3072
3074
  import { Buffer as Buffer2 } from "buffer";
3073
3075
  import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
@@ -3091,7 +3093,7 @@ import process10 from "process";
3091
3093
  import process9 from "process";
3092
3094
  import process8 from "process";
3093
3095
  import { existsSync as existsSync5 } from "fs";
3094
- import { resolve as resolve5 } from "path";
3096
+ import { resolve as resolve52 } from "path";
3095
3097
  import { existsSync as existsSync7 } from "fs";
3096
3098
  import { existsSync as existsSync9, readdirSync as readdirSync5 } from "fs";
3097
3099
  import { extname, resolve as resolve8 } from "path";
@@ -3351,6 +3353,34 @@ class PerformanceMonitor {
3351
3353
  return this.metrics.filter((m) => m.duration > threshold);
3352
3354
  }
3353
3355
  }
3356
+ function getConfigNamePatterns(options = {}) {
3357
+ const { name = "", alias } = options;
3358
+ const patterns = ["config", ".config"];
3359
+ if (name)
3360
+ patterns.push(name, `.${name}.config`, `${name}.config`, `.${name}`);
3361
+ const aliases = alias === undefined ? [] : Array.isArray(alias) ? alias : [alias];
3362
+ for (const alternative of aliases) {
3363
+ if (!alternative)
3364
+ continue;
3365
+ patterns.push(alternative, `.${alternative}.config`, `${alternative}.config`, `.${alternative}`);
3366
+ if (name)
3367
+ patterns.push(`${name}.${alternative}.config`, `.${name}.${alternative}.config`);
3368
+ }
3369
+ return Array.from(new Set(patterns.filter(Boolean)));
3370
+ }
3371
+ function getConfigPaths(options) {
3372
+ const patterns = getConfigNamePatterns(options);
3373
+ return patterns.flatMap((pattern) => CONFIG_FILE_EXTENSIONS.map((extension) => resolve(options.directory, `${pattern}${extension}`)));
3374
+ }
3375
+ function getLocalConfigDirectories(options = {}) {
3376
+ const cwd = resolve(options.cwd || process2.cwd());
3377
+ return Array.from(new Set([
3378
+ cwd,
3379
+ resolve(cwd, "config"),
3380
+ resolve(cwd, ".config"),
3381
+ options.configDir ? resolve(cwd, options.configDir) : undefined
3382
+ ].filter((directory) => Boolean(directory))));
3383
+ }
3354
3384
  function __exportSetter2(name, newValue) {
3355
3385
  this[name] = __returnValue2.bind(null, newValue);
3356
3386
  }
@@ -3434,7 +3464,7 @@ class ConfigCache2 {
3434
3464
  }
3435
3465
  isFileModified(configPath, cachedTimestamp) {
3436
3466
  try {
3437
- if (!existsSync2(configPath)) {
3467
+ if (!existsSync3(configPath)) {
3438
3468
  return true;
3439
3469
  }
3440
3470
  const stats = statSync2(configPath);
@@ -3456,7 +3486,7 @@ class ConfigCache2 {
3456
3486
  }
3457
3487
  setWithFileCheck(configName, value, configPath, customTtl) {
3458
3488
  try {
3459
- const stats = existsSync2(configPath) ? statSync2(configPath) : null;
3489
+ const stats = existsSync3(configPath) ? statSync2(configPath) : null;
3460
3490
  const fileTimestamp = stats ? stats.mtime : new Date;
3461
3491
  this.set(configName, { value, fileTimestamp }, configPath, customTtl);
3462
3492
  } catch {
@@ -3766,7 +3796,7 @@ async function loadConfig({
3766
3796
  ];
3767
3797
  for (const configPath of configPaths) {
3768
3798
  for (const ext of extensions) {
3769
- const fullPath = resolve(baseDir, `${configPath}${ext}`);
3799
+ const fullPath = resolve5(baseDir, `${configPath}${ext}`);
3770
3800
  const config2 = await tryLoadConfig(fullPath, defaultConfig);
3771
3801
  if (config2 !== null) {
3772
3802
  return config2;
@@ -3774,7 +3804,7 @@ async function loadConfig({
3774
3804
  }
3775
3805
  }
3776
3806
  try {
3777
- const pkgPath = resolve(baseDir, "package.json");
3807
+ const pkgPath = resolve5(baseDir, "package.json");
3778
3808
  if (existsSync22(pkgPath)) {
3779
3809
  const pkg = await import(pkgPath);
3780
3810
  const pkgConfig = pkg[name];
@@ -3788,12 +3818,12 @@ async function loadConfig({
3788
3818
  return defaultConfig;
3789
3819
  }
3790
3820
  function getProjectRoot(filePath, options = {}) {
3791
- let path = process2.cwd();
3821
+ let path = process22.cwd();
3792
3822
  while (path.includes("storage"))
3793
3823
  path = resolve2(path, "..");
3794
3824
  const finalPath = resolve2(path, filePath || "");
3795
3825
  if (options?.relative)
3796
- return relative(process2.cwd(), finalPath);
3826
+ return relative(process22.cwd(), finalPath);
3797
3827
  return finalPath;
3798
3828
  }
3799
3829
  async function loadConfig2() {
@@ -3801,7 +3831,7 @@ async function loadConfig2() {
3801
3831
  const loadedConfig = await loadConfig({
3802
3832
  name: "clarity",
3803
3833
  defaultConfig,
3804
- cwd: process2.cwd(),
3834
+ cwd: process22.cwd(),
3805
3835
  endpoint: "",
3806
3836
  headers: {}
3807
3837
  });
@@ -5143,7 +5173,7 @@ function isObject2(item) {
5143
5173
  return Boolean(item && typeof item === "object" && !Array.isArray(item));
5144
5174
  }
5145
5175
  async function tryLoadConfig2(configPath, defaultConfig2, arrayStrategy = "replace") {
5146
- if (!existsSync3(configPath))
5176
+ if (!existsSync32(configPath))
5147
5177
  return null;
5148
5178
  try {
5149
5179
  const importedConfig = await import(configPath);
@@ -5314,7 +5344,7 @@ async function loadConfig3({
5314
5344
  }
5315
5345
  try {
5316
5346
  const pkgPath = resolve3(baseDir, "package.json");
5317
- if (existsSync3(pkgPath)) {
5347
+ if (existsSync32(pkgPath)) {
5318
5348
  const pkg = await import(pkgPath);
5319
5349
  let pkgConfig = pkg[name];
5320
5350
  if (!pkgConfig && alias) {
@@ -5605,7 +5635,7 @@ class Logger2 {
5605
5635
  const errorMessage = typeof error.message === "string" ? error.message : "Unknown error";
5606
5636
  console.error(`Network error during write attempt ${retries + 1}/${maxRetries}:`, errorMessage);
5607
5637
  const delay = backoffDelay * 2 ** retries;
5608
- await new Promise((resolve52) => setTimeout(resolve52, delay));
5638
+ await new Promise((resolve522) => setTimeout(resolve522, delay));
5609
5639
  retries++;
5610
5640
  continue;
5611
5641
  }
@@ -5633,7 +5663,7 @@ class Logger2 {
5633
5663
  }
5634
5664
  retries++;
5635
5665
  const delay = backoffDelay * 2 ** (retries - 1);
5636
- await new Promise((resolve52) => setTimeout(resolve52, delay));
5666
+ await new Promise((resolve522) => setTimeout(resolve522, delay));
5637
5667
  }
5638
5668
  }
5639
5669
  })();
@@ -5763,11 +5793,11 @@ class Logger2 {
5763
5793
  };
5764
5794
  }
5765
5795
  async compressData(data) {
5766
- return new Promise((resolve52, reject) => {
5796
+ return new Promise((resolve522, reject) => {
5767
5797
  const gzip = createGzip2();
5768
5798
  const chunks = [];
5769
5799
  gzip.on("data", (chunk2) => chunks.push(chunk2));
5770
- gzip.on("end", () => resolve52(Buffer22.from(Buffer22.concat(chunks))));
5800
+ gzip.on("end", () => resolve522(Buffer22.from(Buffer22.concat(chunks))));
5771
5801
  gzip.on("error", reject);
5772
5802
  gzip.write(data);
5773
5803
  gzip.end();
@@ -6456,7 +6486,7 @@ class Logger2 {
6456
6486
  if (isBrowserProcess2()) {
6457
6487
  return Promise.resolve(true);
6458
6488
  }
6459
- return new Promise((resolve52) => {
6489
+ return new Promise((resolve522) => {
6460
6490
  console.error(`${styles2.cyan("?")} ${message} (y/n) `);
6461
6491
  const onData = (data) => {
6462
6492
  const input = data.toString().trim().toLowerCase();
@@ -6468,7 +6498,7 @@ class Logger2 {
6468
6498
  } catch {}
6469
6499
  process11.stdin.pause();
6470
6500
  console.error("");
6471
- resolve52(input === "y" || input === "yes");
6501
+ resolve522(input === "y" || input === "yes");
6472
6502
  };
6473
6503
  try {
6474
6504
  if (typeof process11.stdin.setRawMode === "function") {
@@ -6634,7 +6664,7 @@ async function withErrorRecovery(fn, options = {}) {
6634
6664
  break;
6635
6665
  }
6636
6666
  if (retryDelay > 0) {
6637
- await new Promise((resolve52) => setTimeout(resolve52, retryDelay));
6667
+ await new Promise((resolve522) => setTimeout(resolve522, retryDelay));
6638
6668
  }
6639
6669
  }
6640
6670
  }
@@ -7162,7 +7192,7 @@ class ConfigFileLoader {
7162
7192
  const paths = [];
7163
7193
  for (const pattern of patterns) {
7164
7194
  for (const ext of this.extensions) {
7165
- paths.push(resolve5(directory, `${pattern}${ext}`));
7195
+ paths.push(resolve52(directory, `${pattern}${ext}`));
7166
7196
  }
7167
7197
  }
7168
7198
  return paths;
@@ -7199,7 +7229,7 @@ class ConfigFileLoader {
7199
7229
  const patterns = this.generateNamePatterns(configName || "", alias);
7200
7230
  for (const pattern of patterns) {
7201
7231
  for (const ext of this.extensions) {
7202
- const filePath = resolve5(directory, `${pattern}${ext}`);
7232
+ const filePath = resolve52(directory, `${pattern}${ext}`);
7203
7233
  if (await this.checkFileAccess(filePath)) {
7204
7234
  discoveredFiles.push(filePath);
7205
7235
  }
@@ -7211,7 +7241,7 @@ class ConfigFileLoader {
7211
7241
  const files = readdirSync32(directory);
7212
7242
  for (const file of files) {
7213
7243
  if (this.looksLikeConfigFile(file)) {
7214
- const filePath = resolve5(directory, file);
7244
+ const filePath = resolve52(directory, file);
7215
7245
  if (await this.checkFileAccess(filePath)) {
7216
7246
  discoveredFiles.push(filePath);
7217
7247
  }
@@ -9936,7 +9966,7 @@ function isObject4(item) {
9936
9966
  }
9937
9967
 
9938
9968
  class ConfigFileLoader2 {
9939
- extensions = [".ts", ".js", ".mjs", ".cjs", ".json", ".mts", ".cts"];
9969
+ extensions = CONFIG_FILE_EXTENSIONS;
9940
9970
  async loadFromPath(configPath, defaultConfig4, options = {}) {
9941
9971
  const {
9942
9972
  arrayStrategy = "replace",
@@ -10011,37 +10041,10 @@ class ConfigFileLoader2 {
10011
10041
  return null;
10012
10042
  }
10013
10043
  generateConfigPaths(configName, directory, alias) {
10014
- const patterns = this.generateNamePatterns(configName, alias);
10015
- const paths = [];
10016
- for (const pattern of patterns) {
10017
- for (const ext of this.extensions) {
10018
- paths.push(resolve10(directory, `${pattern}${ext}`));
10019
- }
10020
- }
10021
- return paths;
10044
+ return getConfigPaths({ name: configName, directory, alias });
10022
10045
  }
10023
10046
  generateNamePatterns(configName, alias) {
10024
- const patterns = [];
10025
- patterns.push("config", ".config");
10026
- if (configName) {
10027
- patterns.push(configName, `.${configName}.config`, `${configName}.config`, `.${configName}`);
10028
- }
10029
- const aliases = alias === undefined ? [] : Array.isArray(alias) ? alias : [alias];
10030
- for (const a of aliases) {
10031
- if (!a)
10032
- continue;
10033
- patterns.push(a, `.${a}.config`, `${a}.config`, `.${a}`);
10034
- if (configName) {
10035
- patterns.push(`${configName}.${a}.config`, `.${configName}.${a}.config`);
10036
- }
10037
- }
10038
- const seen = new Set;
10039
- return patterns.filter((p) => {
10040
- if (!p || seen.has(p))
10041
- return false;
10042
- seen.add(p);
10043
- return true;
10044
- });
10047
+ return getConfigNamePatterns({ name: configName, alias });
10045
10048
  }
10046
10049
  checkFileAccess(filePath) {
10047
10050
  return withErrorRecovery2(async () => {
@@ -10552,6 +10555,8 @@ class ConfigLoader2 {
10552
10555
  try {
10553
10556
  result = await this.loadConfigurationStrategies(baseOptions, true, cache);
10554
10557
  } catch (error) {
10558
+ if (baseOptions.configFile)
10559
+ throw error;
10555
10560
  const isStrictMode = baseOptions.__strictErrorHandling;
10556
10561
  if (error instanceof Error && error.name === "ConfigNotFoundError") {
10557
10562
  if (isStrictMode) {
@@ -10626,6 +10631,7 @@ class ConfigLoader2 {
10626
10631
  const {
10627
10632
  name = "",
10628
10633
  alias,
10634
+ configFile,
10629
10635
  cwd,
10630
10636
  configDir,
10631
10637
  defaultConfig: defaultConfig4,
@@ -10635,6 +10641,17 @@ class ConfigLoader2 {
10635
10641
  } = options;
10636
10642
  const baseDir = cwd || process20.cwd();
10637
10643
  const searchPaths = [];
10644
+ if (configFile) {
10645
+ const explicitPath = resolve12(baseDir, configFile);
10646
+ searchPaths.push(explicitPath);
10647
+ const envDefaults = checkEnv ? applyEnvVarsToConfig3(name, defaultConfig4, verbose) : defaultConfig4;
10648
+ const explicitResult = await this.fileLoader.tryLoadFromPaths([explicitPath], envDefaults, { arrayStrategy, verbose, cacheTtl: cacheOptions?.ttl, useCache: !cacheOptions?.ttl || cacheOptions.ttl > 100 });
10649
+ if (!explicitResult)
10650
+ throw ErrorFactory2.configNotFound(name || configFile, searchPaths, alias);
10651
+ if (verbose)
10652
+ log3.success(`Configuration loaded from explicit path: ${explicitPath}`);
10653
+ return this.finalizeResult(explicitResult, searchPaths, checkEnv, name, verbose);
10654
+ }
10638
10655
  const localResult = await this.loadLocalConfiguration(name, alias, baseDir, configDir, defaultConfig4, arrayStrategy, verbose, checkEnv, cacheOptions);
10639
10656
  if (localResult) {
10640
10657
  searchPaths.push(...this.getLocalSearchPaths(name, alias, baseDir, configDir));
@@ -10822,6 +10839,8 @@ class ConfigLoader2 {
10822
10839
  }
10823
10840
  if (options.cwd)
10824
10841
  keyParts.push(`cwd:${options.cwd}`);
10842
+ if (options.configFile)
10843
+ keyParts.push(`configFile:${options.configFile}`);
10825
10844
  if (options.configDir)
10826
10845
  keyParts.push(`configDir:${options.configDir}`);
10827
10846
  if ("checkEnv" in options)
@@ -10829,12 +10848,7 @@ class ConfigLoader2 {
10829
10848
  return keyParts.join("|");
10830
10849
  }
10831
10850
  getLocalDirectories(baseDir, configDir) {
10832
- return Array.from(new Set([
10833
- baseDir,
10834
- resolve12(baseDir, "config"),
10835
- resolve12(baseDir, ".config"),
10836
- configDir ? resolve12(baseDir, configDir) : undefined
10837
- ].filter(Boolean)));
10851
+ return getLocalConfigDirectories({ cwd: baseDir, configDir });
10838
10852
  }
10839
10853
  getAllSearchPaths(name, alias, baseDir, configDir) {
10840
10854
  const paths = [];
@@ -10886,6 +10900,8 @@ async function loadConfig6(options) {
10886
10900
  }
10887
10901
  return result?.config ?? defaultConfig4;
10888
10902
  } catch (error) {
10903
+ if (options.configFile)
10904
+ throw error;
10889
10905
  const errorName = error instanceof Error ? error.name : "UnknownError";
10890
10906
  const errorMessage = error instanceof Error ? error.message : String(error);
10891
10907
  const isConfigError = errorName === "ConfigNotFoundError" || errorName === "ConfigLoadError" || errorName === "ConfigValidationError" || errorMessage.includes("config");
@@ -10953,7 +10969,7 @@ function applyEnvVarsToConfig3(name, config6, verbose = false) {
10953
10969
  }
10954
10970
  return processConfigLevel(config6);
10955
10971
  }
10956
- var globalCache, globalPerformanceMonitor, __defProp2, __returnValue2 = (v) => v, __export2 = (target, all) => {
10972
+ var globalCache, globalPerformanceMonitor, CONFIG_FILE_EXTENSIONS, __defProp2, __returnValue2 = (v) => v, __export2 = (target, all) => {
10957
10973
  for (var name in all)
10958
10974
  __defProp2(target, name, {
10959
10975
  get: all[name],
@@ -10965,6 +10981,15 @@ var globalCache, globalPerformanceMonitor, __defProp2, __returnValue2 = (v) => v
10965
10981
  var init_dist = __esm(() => {
10966
10982
  globalCache = new ConfigCache;
10967
10983
  globalPerformanceMonitor = new PerformanceMonitor;
10984
+ CONFIG_FILE_EXTENSIONS = [
10985
+ ".ts",
10986
+ ".js",
10987
+ ".mjs",
10988
+ ".cjs",
10989
+ ".json",
10990
+ ".mts",
10991
+ ".cts"
10992
+ ];
10968
10993
  __defProp2 = Object.defineProperty;
10969
10994
  exports_dist = {};
10970
10995
  __export2(exports_dist, {
@@ -11017,9 +11042,9 @@ var init_dist = __esm(() => {
11017
11042
  isEquivalent: isEquivalent2,
11018
11043
  estimateMemoryUsage: estimateMemoryUsage2
11019
11044
  };
11020
- defaultConfigDir = resolve(process3.cwd(), "config");
11021
- defaultGeneratedDir = resolve(process3.cwd(), "src/generated");
11022
- defaultLogDirectory = process2.env.CLARITY_LOG_DIR || join(getProjectRoot(), "logs");
11045
+ defaultConfigDir = resolve5(process3.cwd(), "config");
11046
+ defaultGeneratedDir = resolve5(process3.cwd(), "src/generated");
11047
+ defaultLogDirectory = process22.env.CLARITY_LOG_DIR || join(getProjectRoot(), "logs");
11023
11048
  defaultConfig = {
11024
11049
  level: "info",
11025
11050
  defaultName: "clarity",
@@ -11636,8 +11661,8 @@ var init_dist = __esm(() => {
11636
11661
  showTags: true
11637
11662
  });
11638
11663
  globalConfigLoader2 = new ConfigLoader2;
11639
- defaultConfigDir4 = resolve12(process20.cwd(), "config");
11640
- defaultGeneratedDir4 = resolve12(process20.cwd(), "src/generated");
11664
+ defaultConfigDir4 = /* @__PURE__ */ resolve12(process20.cwd(), "config");
11665
+ defaultGeneratedDir4 = /* @__PURE__ */ resolve12(process20.cwd(), "src/generated");
11641
11666
  });
11642
11667
 
11643
11668
  // src/config.ts
@@ -11961,12 +11986,12 @@ function createSQLiteSQL(filename) {
11961
11986
  const params = [];
11962
11987
  for (let i = 0;i < values.length; i++) {
11963
11988
  const value = values[i];
11964
- if (value && typeof value === "object" && (value.__raw || value.raw)) {
11965
- const rawValue = value.__raw ? value.value : typeof value.raw === "string" ? value.raw : value.raw();
11966
- sql += rawValue + (strings[i + 1] || "");
11967
- } else if (value && typeof value === "object" && "sql" in value && "values" in value) {
11989
+ if (value && typeof value === "object" && typeof value.sql === "string" && Array.isArray(value.values)) {
11968
11990
  sql += value.sql + (strings[i + 1] || "");
11969
11991
  params.push(...value.values);
11992
+ } else if (value && typeof value === "object" && (value.__raw || value.raw)) {
11993
+ const rawValue = value.__raw ? value.value : typeof value.raw === "string" ? value.raw : value.raw();
11994
+ sql += rawValue + (strings[i + 1] || "");
11970
11995
  } else if (Array.isArray(value)) {
11971
11996
  const placeholders = value.map(() => "?").join(", ");
11972
11997
  sql += placeholders + (strings[i + 1] || "");
@@ -12601,6 +12626,11 @@ function renderSelectColumn(col) {
12601
12626
  }
12602
12627
  throw new TypeError(`[query-builder] select(): unsupported column ${String(col)} \u2014 pass a column name, a string[], or a SQL fragment (e.g. sql\`count(*) as c\`)`);
12603
12628
  }
12629
+ function renderInPredicate(column, values, negated, placeholders) {
12630
+ if (values.length === 0)
12631
+ return negated ? TRUE_PREDICATE : FALSE_PREDICATE;
12632
+ return `${column} ${negated ? "NOT IN" : "IN"} (${placeholders})`;
12633
+ }
12604
12634
  function validateIdentifier(name, context) {
12605
12635
  if (!SQL_PATTERNS.IDENTIFIER.test(name)) {
12606
12636
  const contextMsg = context ? ` in ${context}` : "";
@@ -14318,8 +14348,12 @@ function createQueryBuilder(state) {
14318
14348
  return this;
14319
14349
  },
14320
14350
  whereAny(cols, op, value) {
14321
- if (cols.length === 0)
14351
+ if (cols.length === 0) {
14352
+ const kw = SQL_PATTERNS.WHERE.test(text) ? "AND" : "WHERE";
14353
+ text += ` ${kw} (${FALSE_PREDICATE})`;
14354
+ built = null;
14322
14355
  return this;
14356
+ }
14323
14357
  const keyword = SQL_PATTERNS.WHERE.test(text) ? "AND" : "WHERE";
14324
14358
  const idx = whereParams.length + 1;
14325
14359
  const conds = cols.map((c, i) => `${c} ${op} ${getPlaceholder(idx + i)}`);
@@ -14401,7 +14435,7 @@ function createQueryBuilder(state) {
14401
14435
  const keyword = SQL_PATTERNS.WHERE.test(text) ? "AND" : "WHERE";
14402
14436
  if (Array.isArray(values)) {
14403
14437
  const placeholders = getPlaceholders(values.length, whereParams.length + 1);
14404
- text += ` ${keyword} ${column} IN (${placeholders})`;
14438
+ text += ` ${keyword} ${renderInPredicate(column, values, false, placeholders)}`;
14405
14439
  whereParams.push(...values);
14406
14440
  } else {
14407
14441
  text += ` ${keyword} ${column} IN (${String(values.toSQL())})`;
@@ -14413,7 +14447,7 @@ function createQueryBuilder(state) {
14413
14447
  validateIdentifier(String(column), "orWhereIn(column)");
14414
14448
  if (Array.isArray(values)) {
14415
14449
  const placeholders = getPlaceholders(values.length, whereParams.length + 1);
14416
- text += ` OR ${column} IN (${placeholders})`;
14450
+ text += ` OR ${renderInPredicate(column, values, false, placeholders)}`;
14417
14451
  whereParams.push(...values);
14418
14452
  } else {
14419
14453
  text += ` OR ${column} IN (${String(values.toSQL())})`;
@@ -14426,7 +14460,7 @@ function createQueryBuilder(state) {
14426
14460
  const keyword = SQL_PATTERNS.WHERE.test(text) ? "AND" : "WHERE";
14427
14461
  if (Array.isArray(values)) {
14428
14462
  const placeholders = getPlaceholders(values.length, whereParams.length + 1);
14429
- text += ` ${keyword} ${column} NOT IN (${placeholders})`;
14463
+ text += ` ${keyword} ${renderInPredicate(column, values, true, placeholders)}`;
14430
14464
  whereParams.push(...values);
14431
14465
  } else {
14432
14466
  text += ` ${keyword} ${column} NOT IN (${String(values.toSQL())})`;
@@ -14438,7 +14472,7 @@ function createQueryBuilder(state) {
14438
14472
  validateIdentifier(String(column), "orWhereNotIn(column)");
14439
14473
  if (Array.isArray(values)) {
14440
14474
  const placeholders = getPlaceholders(values.length, whereParams.length + 1);
14441
- text += ` OR ${column} NOT IN (${placeholders})`;
14475
+ text += ` OR ${renderInPredicate(column, values, true, placeholders)}`;
14442
14476
  whereParams.push(...values);
14443
14477
  } else {
14444
14478
  text += ` OR ${column} NOT IN (${String(values.toSQL())})`;
@@ -16697,7 +16731,7 @@ function clearQueryCache() {
16697
16731
  function setQueryCacheMaxSize(size) {
16698
16732
  queryCache.setMaxSize(size);
16699
16733
  }
16700
- var SQL_PATTERNS, SAFE_WHERE_OPERATORS, warnedSqlFragmentContexts, queryCache, reorderCache, REORDER_CACHE_MAX = 500;
16734
+ var FALSE_PREDICATE = "1 = 0", TRUE_PREDICATE = "1 = 1", SQL_PATTERNS, SAFE_WHERE_OPERATORS, warnedSqlFragmentContexts, queryCache, reorderCache, REORDER_CACHE_MAX = 500;
16701
16735
  var init_client = __esm(() => {
16702
16736
  init_config();
16703
16737
  init_db();
@@ -16790,7 +16824,7 @@ var init_cache = __esm(() => {
16790
16824
  });
16791
16825
 
16792
16826
  // src/actions/console.ts
16793
- import process22 from "process";
16827
+ import process23 from "process";
16794
16828
  import { createInterface } from "readline";
16795
16829
  async function startConsole() {
16796
16830
  console.log("-- Query Builder Interactive Console");
@@ -16799,8 +16833,8 @@ async function startConsole() {
16799
16833
  console.log();
16800
16834
  const qb = createQueryBuilder();
16801
16835
  const rl = createInterface({
16802
- input: process22.stdin,
16803
- output: process22.stdout,
16836
+ input: process23.stdin,
16837
+ output: process23.stdout,
16804
16838
  prompt: "qb> "
16805
16839
  });
16806
16840
  let multilineBuffer = "";
@@ -16851,7 +16885,7 @@ Tips:
16851
16885
  if (cmd === ".exit" || cmd === ".quit") {
16852
16886
  console.log("Goodbye!");
16853
16887
  rl.close();
16854
- process22.exit(0);
16888
+ process23.exit(0);
16855
16889
  } else if (cmd === ".help") {
16856
16890
  console.log(helpText);
16857
16891
  } else if (cmd === ".clear") {
@@ -16922,7 +16956,7 @@ Tips:
16922
16956
  rl.on("close", () => {
16923
16957
  console.log(`
16924
16958
  Goodbye!`);
16925
- process22.exit(0);
16959
+ process23.exit(0);
16926
16960
  });
16927
16961
  rl.prompt();
16928
16962
  }
@@ -16934,7 +16968,7 @@ var init_console = __esm(() => {
16934
16968
  });
16935
16969
 
16936
16970
  // src/actions/data.ts
16937
- import { existsSync as existsSync11, readFileSync as readFileSync2, writeFileSync as writeFileSync8 } from "fs";
16971
+ import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync8 } from "fs";
16938
16972
  async function exportData(tableName, options = {}) {
16939
16973
  const format = options.format || "json";
16940
16974
  const output = options.output || `${tableName}.${format}`;
@@ -17009,7 +17043,7 @@ async function exportData(tableName, options = {}) {
17009
17043
  }
17010
17044
  }
17011
17045
  async function importData(tableName, filePath, options = {}) {
17012
- if (!existsSync11(filePath)) {
17046
+ if (!existsSync2(filePath)) {
17013
17047
  console.error(`-- File not found: ${filePath}`);
17014
17048
  throw new Error(`File not found: ${filePath}`);
17015
17049
  }
@@ -18155,23 +18189,23 @@ var init_introspect_db = __esm(() => {
18155
18189
  });
18156
18190
 
18157
18191
  // src/actions/make-model.ts
18158
- import { existsSync as existsSync14, mkdirSync as mkdirSync7, writeFileSync as writeFileSync10 } from "fs";
18192
+ import { existsSync as existsSync11, mkdirSync as mkdirSync7, writeFileSync as writeFileSync10 } from "fs";
18159
18193
  import { dirname as dirname7, join as join7 } from "path";
18160
- import process23 from "process";
18194
+ import process25 from "process";
18161
18195
  function findWorkspaceRoot(startPath) {
18162
18196
  let currentPath = startPath;
18163
18197
  while (currentPath !== dirname7(currentPath)) {
18164
- if (existsSync14(join7(currentPath, "package.json"))) {
18198
+ if (existsSync11(join7(currentPath, "package.json"))) {
18165
18199
  return currentPath;
18166
18200
  }
18167
18201
  currentPath = dirname7(currentPath);
18168
18202
  }
18169
- return process23.cwd();
18203
+ return process25.cwd();
18170
18204
  }
18171
18205
  async function makeModel(name, options = {}) {
18172
- const workspaceRoot = findWorkspaceRoot(process23.cwd());
18206
+ const workspaceRoot = findWorkspaceRoot(process25.cwd());
18173
18207
  const modelsDir = options.dir || join7(workspaceRoot, "app/Models");
18174
- if (!existsSync14(modelsDir)) {
18208
+ if (!existsSync11(modelsDir)) {
18175
18209
  mkdirSync7(modelsDir, { recursive: true });
18176
18210
  console.log(`-- Created models directory: ${modelsDir}`);
18177
18211
  }
@@ -18179,7 +18213,7 @@ async function makeModel(name, options = {}) {
18179
18213
  const tableName = options.table || `${name.toLowerCase()}s`;
18180
18214
  const fileName = `${className}.ts`;
18181
18215
  const filePath = join7(modelsDir, fileName);
18182
- if (existsSync14(filePath)) {
18216
+ if (existsSync11(filePath)) {
18183
18217
  console.error(`-- Model already exists: ${filePath}`);
18184
18218
  throw new Error(`Model already exists: ${filePath}`);
18185
18219
  }
@@ -18939,17 +18973,17 @@ var init_drivers = __esm(() => {
18939
18973
  });
18940
18974
 
18941
18975
  // src/workspace.ts
18942
- import { existsSync as existsSync16 } from "fs";
18976
+ import { existsSync as existsSync14 } from "fs";
18943
18977
  import { dirname as dirname8, isAbsolute as isAbsolute3, join as join9 } from "path";
18944
- import process24 from "process";
18945
- function findWorkspaceRoot2(startPath = process24.cwd()) {
18978
+ import process26 from "process";
18979
+ function findWorkspaceRoot2(startPath = process26.cwd()) {
18946
18980
  let currentPath = startPath;
18947
18981
  while (currentPath !== dirname8(currentPath)) {
18948
- if (existsSync16(join9(currentPath, "package.json")))
18982
+ if (existsSync14(join9(currentPath, "package.json")))
18949
18983
  return currentPath;
18950
18984
  currentPath = dirname8(currentPath);
18951
18985
  }
18952
- return process24.cwd();
18986
+ return process26.cwd();
18953
18987
  }
18954
18988
  function getSqlDirectory(workspaceRoot, migrationDir = "database/migrations") {
18955
18989
  const configured = migrationDir || "database/migrations";
@@ -18968,10 +19002,10 @@ __export(exports_migrate, {
18968
19002
  copyModelsToGenerated: () => copyModelsToGenerated,
18969
19003
  clearGeneratedDirectory: () => clearGeneratedDirectory
18970
19004
  });
18971
- import { existsSync as existsSync17, mkdirSync as mkdirSync8, mkdtempSync, readdirSync as readdirSync6, readFileSync as readFileSync3, rmSync, unlinkSync, writeFileSync as writeFileSync11 } from "fs";
19005
+ import { existsSync as existsSync16, mkdirSync as mkdirSync8, mkdtempSync, readdirSync as readdirSync6, readFileSync as readFileSync3, rmSync, unlinkSync, writeFileSync as writeFileSync11 } from "fs";
18972
19006
  import { tmpdir } from "os";
18973
19007
  import { join as join10 } from "path";
18974
- import process25 from "process";
19008
+ import process27 from "process";
18975
19009
  async function settleAppliedFiles(qb, dialect, files) {
18976
19010
  if (files.length === 0)
18977
19011
  return;
@@ -19009,7 +19043,7 @@ function getSnapshotPath(workspaceRoot, dialect) {
19009
19043
  }
19010
19044
  function loadPlanSnapshot(workspaceRoot, dialect) {
19011
19045
  const snapshotPath = getSnapshotPath(workspaceRoot, dialect);
19012
- if (!existsSync17(snapshotPath)) {
19046
+ if (!existsSync16(snapshotPath)) {
19013
19047
  return;
19014
19048
  }
19015
19049
  try {
@@ -19032,7 +19066,7 @@ function savePlanSnapshot(workspaceRoot, dialect, plan) {
19032
19066
  const snapshotPath = getSnapshotPath(workspaceRoot, dialect);
19033
19067
  const snapshotDir = getSnapshotDir(workspaceRoot);
19034
19068
  const hash = hashMigrationPlan(plan);
19035
- if (existsSync17(snapshotPath)) {
19069
+ if (existsSync16(snapshotPath)) {
19036
19070
  try {
19037
19071
  const current = JSON.parse(readFileSync3(snapshotPath, "utf8"));
19038
19072
  if (current?.hash === hash && current?.dialect === dialect && current?.plan) {
@@ -19041,7 +19075,7 @@ function savePlanSnapshot(workspaceRoot, dialect, plan) {
19041
19075
  }
19042
19076
  } catch {}
19043
19077
  }
19044
- if (!existsSync17(snapshotDir)) {
19078
+ if (!existsSync16(snapshotDir)) {
19045
19079
  mkdirSync8(snapshotDir, { recursive: true });
19046
19080
  info(`-- Created snapshot directory: ${snapshotDir}`);
19047
19081
  }
@@ -19063,7 +19097,7 @@ function getWorkspaceRoot() {
19063
19097
  }
19064
19098
  function ensureSqlDirectory(workspaceRoot) {
19065
19099
  const sqlDir = getSqlDirectory(workspaceRoot, config5.migrationDir);
19066
- if (!existsSync17(sqlDir)) {
19100
+ if (!existsSync16(sqlDir)) {
19067
19101
  mkdirSync8(sqlDir, { recursive: true });
19068
19102
  info(`-- Created SQL directory: ${sqlDir}`);
19069
19103
  }
@@ -19072,7 +19106,7 @@ function ensureSqlDirectory(workspaceRoot) {
19072
19106
  async function generateMigration(dir, opts = {}) {
19073
19107
  await getConfig();
19074
19108
  if (!dir) {
19075
- dir = join10(process25.cwd(), "app/Models");
19109
+ dir = join10(process27.cwd(), "app/Models");
19076
19110
  }
19077
19111
  const dialect = opts.dialect || config5.dialect || "postgres";
19078
19112
  const workspaceRoot = getWorkspaceRoot();
@@ -19087,7 +19121,7 @@ async function generateMigration(dir, opts = {}) {
19087
19121
  } else {
19088
19122
  const defaultStatePath = join10(dir, `.qb-migrations.${dialect}.json`);
19089
19123
  const statePath = String(opts.state || defaultStatePath);
19090
- if (existsSync17(statePath)) {
19124
+ if (existsSync16(statePath)) {
19091
19125
  try {
19092
19126
  const raw2 = readFileSync3(statePath, "utf8");
19093
19127
  const parsed = JSON.parse(raw2);
@@ -19193,8 +19227,8 @@ async function executeMigration(dir) {
19193
19227
  info(`-- Found ${scriptFiles.length} script files to execute`);
19194
19228
  try {
19195
19229
  const qb = createQueryBuilder();
19196
- await createMigrationsTable(qb, dialect);
19197
19230
  return await withMigrationLock(dialect, async () => {
19231
+ await createMigrationsTable(qb, dialect);
19198
19232
  const executedMigrations = await getExecutedMigrations(qb, dialect);
19199
19233
  const pending = scriptFiles.filter((file2) => !executedMigrations.includes(file2));
19200
19234
  if (pending.length === 0) {
@@ -19243,7 +19277,7 @@ async function executeMigration(dir) {
19243
19277
  async function resetDatabase(dir, opts = {}) {
19244
19278
  await getConfig();
19245
19279
  if (!dir) {
19246
- dir = join10(process25.cwd(), "app/Models");
19280
+ dir = join10(process27.cwd(), "app/Models");
19247
19281
  }
19248
19282
  const dialect = opts.dialect || config5.dialect || "postgres";
19249
19283
  const driver = getDialectDriver(dialect);
@@ -19340,27 +19374,27 @@ async function resetDatabase(dir, opts = {}) {
19340
19374
  }
19341
19375
  async function deleteMigrationFiles(dir, workspaceRoot, opts = {}) {
19342
19376
  if (!dir) {
19343
- dir = join10(process25.cwd(), "app/Models");
19377
+ dir = join10(process27.cwd(), "app/Models");
19344
19378
  }
19345
19379
  if (!workspaceRoot) {
19346
19380
  workspaceRoot = getWorkspaceRoot();
19347
19381
  }
19348
19382
  const dialect = String(opts.dialect || config5.dialect || "postgres");
19349
19383
  const snapshotPath = getSnapshotPath(workspaceRoot, dialect);
19350
- if (existsSync17(snapshotPath)) {
19384
+ if (existsSync16(snapshotPath)) {
19351
19385
  unlinkSync(snapshotPath);
19352
19386
  info(`-- Removed model snapshot file: ${snapshotPath}`);
19353
19387
  }
19354
19388
  const defaultStatePath = join10(dir, `.qb-migrations.${dialect}.json`);
19355
19389
  const statePath = String(opts.state || defaultStatePath);
19356
- if (existsSync17(statePath)) {
19390
+ if (existsSync16(statePath)) {
19357
19391
  unlinkSync(statePath);
19358
19392
  info(`-- Removed legacy migration state file: ${statePath}`);
19359
19393
  }
19360
19394
  removeGeneratedMigrationFiles(getSqlDirectory(workspaceRoot, config5.migrationDir));
19361
19395
  }
19362
19396
  function removeGeneratedMigrationFiles(sqlDir) {
19363
- if (!existsSync17(sqlDir))
19397
+ if (!existsSync16(sqlDir))
19364
19398
  return;
19365
19399
  let removed = 0;
19366
19400
  const kept = [];
@@ -19383,7 +19417,7 @@ async function clearGeneratedDirectory(workspaceRoot) {
19383
19417
  workspaceRoot = getWorkspaceRoot();
19384
19418
  }
19385
19419
  const generatedDir = join10(workspaceRoot, "generated");
19386
- if (existsSync17(generatedDir)) {
19420
+ if (existsSync16(generatedDir)) {
19387
19421
  try {
19388
19422
  rmSync(generatedDir, { recursive: true, force: true });
19389
19423
  info("-- Cleared generated directory");
@@ -19444,7 +19478,7 @@ var init_migrate_generate = __esm(() => {
19444
19478
  });
19445
19479
 
19446
19480
  // src/actions/migrate-rollback.ts
19447
- import { existsSync as existsSync18, readFileSync as readFileSync4, unlinkSync as unlinkSync2 } from "fs";
19481
+ import { existsSync as existsSync17, readFileSync as readFileSync4, unlinkSync as unlinkSync2 } from "fs";
19448
19482
  import { join as join11 } from "path";
19449
19483
  function splitSqlStatements2(sql) {
19450
19484
  const out = [];
@@ -19559,7 +19593,7 @@ async function migrateRollback(options = {}) {
19559
19593
  for (const migration of migrationsToRollback) {
19560
19594
  try {
19561
19595
  const filePath = join11(sqlDir, migration.migration);
19562
- if (reverseSchema && existsSync18(filePath)) {
19596
+ if (reverseSchema && existsSync17(filePath)) {
19563
19597
  const forwardSql = readFileSync4(filePath, "utf8");
19564
19598
  const { down, skipped } = deriveDownStatements(forwardSql);
19565
19599
  for (const stmt of down) {
@@ -19573,7 +19607,7 @@ async function migrateRollback(options = {}) {
19573
19607
  const deleteSql = `DELETE FROM migrations WHERE migration = ${getPlaceholder(1)}`;
19574
19608
  await qb.unsafe(deleteSql, [migration.migration]);
19575
19609
  console.log(`-- \u2713 Removed migration record: ${migration.migration}`);
19576
- if (options.deleteFiles && existsSync18(filePath)) {
19610
+ if (options.deleteFiles && existsSync17(filePath)) {
19577
19611
  unlinkSync2(filePath);
19578
19612
  console.log(`-- \uD83D\uDDD1\uFE0F Deleted migration file: ${migration.migration}`);
19579
19613
  }
@@ -19600,7 +19634,7 @@ var init_migrate_rollback = __esm(() => {
19600
19634
  });
19601
19635
 
19602
19636
  // src/actions/migrate-status.ts
19603
- import { existsSync as existsSync19, readdirSync as readdirSync8 } from "fs";
19637
+ import { existsSync as existsSync18, readdirSync as readdirSync8 } from "fs";
19604
19638
  async function migrateStatus() {
19605
19639
  const dialect = config5.dialect || "postgres";
19606
19640
  const driver = getDialectDriver(dialect);
@@ -19609,7 +19643,7 @@ async function migrateStatus() {
19609
19643
  console.log(`-- Dialect: ${dialect}`);
19610
19644
  console.log(`-- SQL directory: ${sqlDir}`);
19611
19645
  console.log();
19612
- if (!existsSync19(sqlDir)) {
19646
+ if (!existsSync18(sqlDir)) {
19613
19647
  console.log("-- No SQL directory found. No migrations have been created yet.");
19614
19648
  return [];
19615
19649
  }
@@ -19674,9 +19708,9 @@ var init_migrate_status = __esm(() => {
19674
19708
  // src/actions/model-show.ts
19675
19709
  import { readdirSync as readdirSync9 } from "fs";
19676
19710
  import { extname as extname2, join as join12 } from "path";
19677
- import process26 from "process";
19711
+ import process28 from "process";
19678
19712
  async function modelShow(modelName, options = {}) {
19679
- const dir = options.dir || join12(process26.cwd(), "app/Models");
19713
+ const dir = options.dir || join12(process28.cwd(), "app/Models");
19680
19714
  try {
19681
19715
  const files = readdirSync9(dir);
19682
19716
  const modelFile = files.find((f) => {
@@ -19890,9 +19924,9 @@ var init_query_explain_all = __esm(() => {
19890
19924
  // src/actions/relation-diagram.ts
19891
19925
  import { writeFileSync as writeFileSync12 } from "fs";
19892
19926
  import { join as join14 } from "path";
19893
- import process27 from "process";
19927
+ import process29 from "process";
19894
19928
  async function relationDiagram(options = {}) {
19895
- const dir = options.dir || join14(process27.cwd(), "app/Models");
19929
+ const dir = options.dir || join14(process29.cwd(), "app/Models");
19896
19930
  const format = options.format || "mermaid";
19897
19931
  try {
19898
19932
  const models = await loadModels({ modelsDir: dir });
@@ -20012,21 +20046,21 @@ var init_relation_diagram = __esm(() => {
20012
20046
  });
20013
20047
 
20014
20048
  // src/actions/seed.ts
20015
- import { existsSync as existsSync20, mkdirSync as mkdirSync9, readdirSync as readdirSync11, writeFileSync as writeFileSync13 } from "fs";
20049
+ import { existsSync as existsSync19, mkdirSync as mkdirSync9, readdirSync as readdirSync11, writeFileSync as writeFileSync13 } from "fs";
20016
20050
  import { dirname as dirname10, join as join15 } from "path";
20017
- import process28 from "process";
20051
+ import process30 from "process";
20018
20052
  function findWorkspaceRoot3(startPath) {
20019
20053
  let currentPath = startPath;
20020
20054
  while (currentPath !== dirname10(currentPath)) {
20021
- if (existsSync20(join15(currentPath, "package.json"))) {
20055
+ if (existsSync19(join15(currentPath, "package.json"))) {
20022
20056
  return currentPath;
20023
20057
  }
20024
20058
  currentPath = dirname10(currentPath);
20025
20059
  }
20026
- return process28.cwd();
20060
+ return process30.cwd();
20027
20061
  }
20028
20062
  async function loadSeeders(seedersDir) {
20029
- if (!existsSync20(seedersDir)) {
20063
+ if (!existsSync19(seedersDir)) {
20030
20064
  console.log(`-- Seeders directory not found: ${seedersDir}`);
20031
20065
  return [];
20032
20066
  }
@@ -20056,7 +20090,7 @@ async function loadSeeders(seedersDir) {
20056
20090
  return seeders;
20057
20091
  }
20058
20092
  async function runSeeders(config6 = {}) {
20059
- const workspaceRoot = findWorkspaceRoot3(process28.cwd());
20093
+ const workspaceRoot = findWorkspaceRoot3(process30.cwd());
20060
20094
  const seedersDir = config6.seedersDir || join15(workspaceRoot, "database/seeders");
20061
20095
  const verbose = config6.verbose ?? true;
20062
20096
  if (verbose) {
@@ -20091,7 +20125,7 @@ async function runSeeders(config6 = {}) {
20091
20125
  }
20092
20126
  }
20093
20127
  async function runSeeder(className, options = {}) {
20094
- const workspaceRoot = findWorkspaceRoot3(process28.cwd());
20128
+ const workspaceRoot = findWorkspaceRoot3(process30.cwd());
20095
20129
  const seedersDir = join15(workspaceRoot, "database/seeders");
20096
20130
  const verbose = options.verbose ?? true;
20097
20131
  if (verbose) {
@@ -20116,9 +20150,9 @@ async function runSeeder(className, options = {}) {
20116
20150
  }
20117
20151
  }
20118
20152
  async function makeSeeder(name) {
20119
- const workspaceRoot = findWorkspaceRoot3(process28.cwd());
20153
+ const workspaceRoot = findWorkspaceRoot3(process30.cwd());
20120
20154
  const seedersDir = join15(workspaceRoot, "database/seeders");
20121
- if (!existsSync20(seedersDir)) {
20155
+ if (!existsSync19(seedersDir)) {
20122
20156
  mkdirSync9(seedersDir, { recursive: true });
20123
20157
  console.log(`-- Created seeders directory: ${seedersDir}`);
20124
20158
  }
@@ -20126,7 +20160,7 @@ async function makeSeeder(name) {
20126
20160
  const className = `${baseName}Seeder`;
20127
20161
  const fileName = `${className}.ts`;
20128
20162
  const filePath = join15(seedersDir, fileName);
20129
- if (existsSync20(filePath)) {
20163
+ if (existsSync19(filePath)) {
20130
20164
  console.error(`-- Seeder already exists: ${filePath}`);
20131
20165
  throw new Error(`Seeder already exists: ${filePath}`);
20132
20166
  }
@@ -20180,7 +20214,7 @@ export default class ${className} extends Seeder {
20180
20214
  console.log(`-- \u2713 Created seeder: ${filePath}`);
20181
20215
  }
20182
20216
  async function freshDatabase(options = {}) {
20183
- const workspaceRoot = findWorkspaceRoot3(process28.cwd());
20217
+ const workspaceRoot = findWorkspaceRoot3(process30.cwd());
20184
20218
  const modelsDir = options.modelsDir || join15(workspaceRoot, "app/Models");
20185
20219
  const seedersDir = options.seedersDir || join15(workspaceRoot, "database/seeders");
20186
20220
  const verbose = options.verbose ?? true;
@@ -20240,22 +20274,22 @@ var init_unsafe = __esm(() => {
20240
20274
  });
20241
20275
 
20242
20276
  // src/actions/validate.ts
20243
- import { existsSync as existsSync21 } from "fs";
20277
+ import { existsSync as existsSync20 } from "fs";
20244
20278
  import { dirname as dirname11, join as join16 } from "path";
20245
- import process29 from "process";
20279
+ import process31 from "process";
20246
20280
  function findWorkspaceRoot4(startPath) {
20247
20281
  let currentPath = startPath;
20248
20282
  while (currentPath !== dirname11(currentPath)) {
20249
- if (existsSync21(join16(currentPath, "package.json"))) {
20283
+ if (existsSync20(join16(currentPath, "package.json"))) {
20250
20284
  return currentPath;
20251
20285
  }
20252
20286
  currentPath = dirname11(currentPath);
20253
20287
  }
20254
- return process29.cwd();
20288
+ return process31.cwd();
20255
20289
  }
20256
20290
  async function validateSchema(dir) {
20257
20291
  if (!dir) {
20258
- dir = join16(findWorkspaceRoot4(process29.cwd()), "app/Models");
20292
+ dir = join16(findWorkspaceRoot4(process31.cwd()), "app/Models");
20259
20293
  }
20260
20294
  const dialect = config5.dialect || "postgres";
20261
20295
  console.log("-- Validating Schema");
@@ -28333,7 +28367,7 @@ var init_factory = () => {};
28333
28367
  // src/loader.ts
28334
28368
  import { readdirSync as readdirSync12 } from "fs";
28335
28369
  import { basename, extname as extname4, isAbsolute as isAbsolute5, join as join17 } from "path";
28336
- import process30 from "process";
28370
+ import process33 from "process";
28337
28371
  function isModelFile(name) {
28338
28372
  const ext = extname4(name);
28339
28373
  if (!MODEL_EXTENSIONS.has(ext))
@@ -28364,7 +28398,7 @@ function collectModelFiles(dir) {
28364
28398
  return files;
28365
28399
  }
28366
28400
  async function loadModels(options) {
28367
- const cwd = options.cwd ?? process30.cwd();
28401
+ const cwd = options.cwd ?? process33.cwd();
28368
28402
  const dir = isAbsolute5(options.modelsDir) ? options.modelsDir : join17(cwd, options.modelsDir);
28369
28403
  const result = {};
28370
28404
  for (const full of collectModelFiles(dir)) {
@@ -28471,9 +28505,9 @@ function buildSchemaMeta(models) {
28471
28505
  var init_meta = () => {};
28472
28506
 
28473
28507
  // src/migrations.ts
28474
- import { existsSync as existsSync23, mkdirSync as mkdirSync10, readdirSync as readdirSync13, readFileSync as readFileSync6, writeFileSync as writeFileSync14 } from "fs";
28508
+ import { existsSync as existsSync21, mkdirSync as mkdirSync10, readdirSync as readdirSync13, readFileSync as readFileSync6, writeFileSync as writeFileSync14 } from "fs";
28475
28509
  import { dirname as dirname12, join as join18 } from "path";
28476
- import process31 from "process";
28510
+ import process35 from "process";
28477
28511
  function info2(message) {
28478
28512
  if (config5.verbose)
28479
28513
  console.log(message);
@@ -28490,17 +28524,17 @@ function lastCreatedMigrationFiles() {
28490
28524
  function findWorkspaceRoot5(startPath) {
28491
28525
  let currentPath = startPath;
28492
28526
  while (currentPath !== dirname12(currentPath)) {
28493
- if (existsSync23(join18(currentPath, "package.json"))) {
28527
+ if (existsSync21(join18(currentPath, "package.json"))) {
28494
28528
  return currentPath;
28495
28529
  }
28496
28530
  currentPath = dirname12(currentPath);
28497
28531
  }
28498
- return process31.cwd();
28532
+ return process35.cwd();
28499
28533
  }
28500
28534
  function ensureSqlDirectory2() {
28501
- const workspaceRoot = findWorkspaceRoot5(process31.cwd());
28535
+ const workspaceRoot = findWorkspaceRoot5(process35.cwd());
28502
28536
  const sqlDir = getSqlDirectory(workspaceRoot, config5.migrationDir);
28503
- if (!existsSync23(sqlDir)) {
28537
+ if (!existsSync21(sqlDir)) {
28504
28538
  mkdirSync10(sqlDir, { recursive: true });
28505
28539
  info2(`-- Created SQL directory: ${sqlDir}`);
28506
28540
  }
@@ -28545,7 +28579,7 @@ function createMigrationFile(statement, fileName) {
28545
28579
  let fullFileName = `${sequence}-${fileName}.sql`;
28546
28580
  if (!useDeterministicNames) {
28547
28581
  let next = Number(sequence);
28548
- while (existsSync23(join18(sqlDir, fullFileName))) {
28582
+ while (existsSync21(join18(sqlDir, fullFileName))) {
28549
28583
  next += 1;
28550
28584
  sequence = String(next);
28551
28585
  fullFileName = `${sequence}-${fileName}.sql`;
@@ -29767,14 +29801,14 @@ var init_src2 = __esm(() => {
29767
29801
  });
29768
29802
 
29769
29803
  // ../../node_modules/@stacksjs/clapp/dist/index.js
29770
- import { existsSync as existsSync25 } from "fs";
29804
+ import { existsSync as existsSync23 } from "fs";
29771
29805
  import fs from "fs/promises";
29772
29806
  import os from "os";
29773
29807
  import path from "path";
29774
- import process33 from "process";
29808
+ import process36 from "process";
29775
29809
  import { EventEmitter } from "events";
29776
29810
  import process52 from "process";
29777
- import process210 from "process";
29811
+ import process24 from "process";
29778
29812
  import process34 from "process";
29779
29813
  import process42 from "process";
29780
29814
  import process72 from "process";
@@ -29795,10 +29829,10 @@ class Telemetry {
29795
29829
  this.configPath = path.join(configDir, "telemetry.json");
29796
29830
  }
29797
29831
  async isEnabled() {
29798
- if (process33.env.DO_NOT_TRACK === "1" || process33.env.DO_NOT_TRACK === "true") {
29832
+ if (process36.env.DO_NOT_TRACK === "1" || process36.env.DO_NOT_TRACK === "true") {
29799
29833
  return false;
29800
29834
  }
29801
- if (process33.env.NO_TELEMETRY === "1" || process33.env.NO_TELEMETRY === "true") {
29835
+ if (process36.env.NO_TELEMETRY === "1" || process36.env.NO_TELEMETRY === "true") {
29802
29836
  return false;
29803
29837
  }
29804
29838
  const config6 = await this.loadConfig();
@@ -29827,7 +29861,7 @@ class Telemetry {
29827
29861
  ...data,
29828
29862
  timestamp: Date.now(),
29829
29863
  platform: os.platform(),
29830
- nodeVersion: process33.version
29864
+ nodeVersion: process36.version
29831
29865
  };
29832
29866
  this.events.push(telemetryEvent);
29833
29867
  if (this.events.length >= 10) {
@@ -29883,7 +29917,7 @@ class Telemetry {
29883
29917
  const config6 = await this.loadConfig();
29884
29918
  return {
29885
29919
  enabled: config6.enabled,
29886
- doNotTrack: process33.env.DO_NOT_TRACK === "1" || process33.env.DO_NOT_TRACK === "true",
29920
+ doNotTrack: process36.env.DO_NOT_TRACK === "1" || process36.env.DO_NOT_TRACK === "true",
29887
29921
  eventsQueued: this.events.length,
29888
29922
  lastSent: config6.lastSent
29889
29923
  };
@@ -29893,7 +29927,7 @@ class Telemetry {
29893
29927
  return this.config;
29894
29928
  }
29895
29929
  try {
29896
- if (existsSync25(this.configPath)) {
29930
+ if (existsSync23(this.configPath)) {
29897
29931
  const data = await fs.readFile(this.configPath, "utf-8");
29898
29932
  this.config = JSON.parse(data);
29899
29933
  return this.config;
@@ -29919,90 +29953,6 @@ class Telemetry {
29919
29953
  }
29920
29954
  }
29921
29955
  var telemetry = new Telemetry;
29922
- function parseArgv(argv, opts = {}) {
29923
- const result = { _: [] };
29924
- const alias = opts.alias || {};
29925
- const booleans = new Set(opts.boolean || []);
29926
- const aliasOf = {};
29927
- for (const key of Object.keys(alias)) {
29928
- for (const a2 of alias[key]) {
29929
- aliasOf[a2] = key;
29930
- }
29931
- }
29932
- for (const b2 of booleans) {
29933
- if (alias[b2]) {
29934
- for (const a2 of alias[b2])
29935
- booleans.add(a2);
29936
- }
29937
- }
29938
- function setKey(key, value) {
29939
- const canonical = aliasOf[key] || key;
29940
- result[canonical] = value;
29941
- if (alias[canonical]) {
29942
- for (const a2 of alias[canonical])
29943
- result[a2] = value;
29944
- }
29945
- if (aliasOf[key] && alias[aliasOf[key]]) {
29946
- for (const a2 of alias[aliasOf[key]])
29947
- result[a2] = value;
29948
- }
29949
- result[key] = value;
29950
- }
29951
- for (let i2 = 0;i2 < argv.length; i2++) {
29952
- const arg = argv[i2];
29953
- if (arg === "--") {
29954
- result._.push(...argv.slice(i2 + 1));
29955
- break;
29956
- }
29957
- if (arg.startsWith("--")) {
29958
- const eqIdx = arg.indexOf("=");
29959
- if (eqIdx !== -1) {
29960
- const key = arg.slice(2, eqIdx);
29961
- const value = arg.slice(eqIdx + 1);
29962
- setKey(key, value);
29963
- } else {
29964
- const key = arg.slice(2);
29965
- if (key.startsWith("no-")) {
29966
- const actualKey = key.slice(3);
29967
- setKey(actualKey, false);
29968
- continue;
29969
- }
29970
- const canonical = aliasOf[key] || key;
29971
- if (booleans.has(canonical) || booleans.has(key)) {
29972
- setKey(key, true);
29973
- } else {
29974
- const next = argv[i2 + 1];
29975
- if (next !== undefined && !next.startsWith("-")) {
29976
- setKey(key, next);
29977
- i2++;
29978
- } else {
29979
- setKey(key, true);
29980
- }
29981
- }
29982
- }
29983
- } else if (arg.startsWith("-") && arg.length > 1) {
29984
- const chars = arg.slice(1);
29985
- for (let j = 0;j < chars.length; j++) {
29986
- const ch = chars[j];
29987
- const canonical = aliasOf[ch] || ch;
29988
- if (j === chars.length - 1 && !booleans.has(canonical) && !booleans.has(ch)) {
29989
- const next = argv[i2 + 1];
29990
- if (next !== undefined && !next.startsWith("-")) {
29991
- setKey(ch, next);
29992
- i2++;
29993
- } else {
29994
- setKey(ch, true);
29995
- }
29996
- } else {
29997
- setKey(ch, true);
29998
- }
29999
- }
30000
- } else {
30001
- result._.push(arg);
30002
- }
30003
- }
30004
- return result;
30005
- }
30006
29956
  function removeBrackets(v2) {
30007
29957
  return v2.replace(/[<[].+/, "").trim();
30008
29958
  }
@@ -30099,9 +30049,13 @@ function camelcaseOptionName(name) {
30099
30049
  class ClappError extends Error {
30100
30050
  exitCode = 2;
30101
30051
  isUsageError = true;
30102
- constructor(message) {
30052
+ usage;
30053
+ constructor(message, usage) {
30103
30054
  super(message);
30104
30055
  this.name = this.constructor.name;
30056
+ if (usage !== undefined) {
30057
+ this.usage = usage;
30058
+ }
30105
30059
  if (typeof Error.captureStackTrace === "function") {
30106
30060
  Error.captureStackTrace(this, this.constructor);
30107
30061
  } else {
@@ -30118,10 +30072,16 @@ ${this.stack}`;
30118
30072
  return this.message;
30119
30073
  }
30120
30074
  }
30075
+ function isClappError(err) {
30076
+ if (err instanceof ClappError) {
30077
+ return true;
30078
+ }
30079
+ return !!err && typeof err === "object" && err.name === "ClappError" && typeof err.message === "string";
30080
+ }
30121
30081
  function isUnicodeSupported() {
30122
- const { env } = process210;
30082
+ const { env } = process24;
30123
30083
  const { TERM, TERM_PROGRAM } = env;
30124
- if (process210.platform !== "win32") {
30084
+ if (process24.platform !== "win32") {
30125
30085
  return TERM !== "linux";
30126
30086
  }
30127
30087
  return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
@@ -30199,6 +30159,91 @@ function levenshteinDistance(a2, b2) {
30199
30159
  function findSimilarCommands(input, commands, maxDistance = 2, maxSuggestions = 3) {
30200
30160
  return commands.map((cmd) => ({ cmd, distance: levenshteinDistance(input, cmd) })).filter(({ distance }) => distance <= maxDistance).sort((a2, b2) => a2.distance - b2.distance).slice(0, maxSuggestions).map(({ cmd }) => cmd);
30201
30161
  }
30162
+ function parseArgv(argv, opts = {}) {
30163
+ const result = { _: [] };
30164
+ const alias = opts.alias || {};
30165
+ const booleans = new Set(opts.boolean || []);
30166
+ const aliasOf = {};
30167
+ for (const key of Object.keys(alias)) {
30168
+ for (const a2 of alias[key]) {
30169
+ aliasOf[a2] = key;
30170
+ }
30171
+ }
30172
+ for (const b2 of booleans) {
30173
+ if (alias[b2]) {
30174
+ for (const a2 of alias[b2])
30175
+ booleans.add(a2);
30176
+ }
30177
+ }
30178
+ function setKey(key, value) {
30179
+ const canonical = aliasOf[key] || key;
30180
+ result[canonical] = value;
30181
+ if (alias[canonical]) {
30182
+ for (const a2 of alias[canonical])
30183
+ result[a2] = value;
30184
+ }
30185
+ if (aliasOf[key] && alias[aliasOf[key]]) {
30186
+ for (const a2 of alias[aliasOf[key]])
30187
+ result[a2] = value;
30188
+ }
30189
+ result[key] = value;
30190
+ }
30191
+ for (let i2 = 0;i2 < argv.length; i2++) {
30192
+ const arg = argv[i2];
30193
+ if (arg === "--") {
30194
+ result._.push(...argv.slice(i2 + 1));
30195
+ break;
30196
+ }
30197
+ if (arg.startsWith("--")) {
30198
+ const eqIdx = arg.indexOf("=");
30199
+ if (eqIdx !== -1) {
30200
+ const key = camelcase(arg.slice(2, eqIdx));
30201
+ const value = arg.slice(eqIdx + 1);
30202
+ setKey(key, value);
30203
+ } else {
30204
+ const rawKey = arg.slice(2);
30205
+ if (rawKey.startsWith("no-")) {
30206
+ const actualKey = camelcase(rawKey.slice(3));
30207
+ setKey(actualKey, false);
30208
+ continue;
30209
+ }
30210
+ const key = camelcase(rawKey);
30211
+ const canonical = aliasOf[key] || key;
30212
+ if (booleans.has(canonical) || booleans.has(key)) {
30213
+ setKey(key, true);
30214
+ } else {
30215
+ const next = argv[i2 + 1];
30216
+ if (next !== undefined && !next.startsWith("-")) {
30217
+ setKey(key, next);
30218
+ i2++;
30219
+ } else {
30220
+ setKey(key, true);
30221
+ }
30222
+ }
30223
+ }
30224
+ } else if (arg.startsWith("-") && arg.length > 1) {
30225
+ const chars = arg.slice(1);
30226
+ for (let j = 0;j < chars.length; j++) {
30227
+ const ch = chars[j];
30228
+ const canonical = aliasOf[ch] || ch;
30229
+ if (j === chars.length - 1 && !booleans.has(canonical) && !booleans.has(ch)) {
30230
+ const next = argv[i2 + 1];
30231
+ if (next !== undefined && !next.startsWith("-")) {
30232
+ setKey(ch, next);
30233
+ i2++;
30234
+ } else {
30235
+ setKey(ch, true);
30236
+ }
30237
+ } else {
30238
+ setKey(ch, true);
30239
+ }
30240
+ }
30241
+ } else {
30242
+ result._.push(arg);
30243
+ }
30244
+ }
30245
+ return result;
30246
+ }
30202
30247
 
30203
30248
  class Option {
30204
30249
  rawName;
@@ -30346,9 +30391,9 @@ class Command {
30346
30391
  return this.namespace ? `${this.namespace}:${this.name}` : this.name;
30347
30392
  }
30348
30393
  hasOption(name) {
30349
- name = name.split(".")[0];
30394
+ const normalized = camelcaseOptionName(name.split(".")[0]);
30350
30395
  return !!this.options.find((option) => {
30351
- return option.names.includes(name);
30396
+ return option.names.some((optionName) => camelcaseOptionName(optionName) === normalized);
30352
30397
  });
30353
30398
  }
30354
30399
  outputHelp() {
@@ -30383,6 +30428,7 @@ class Command {
30383
30428
  }
30384
30429
  }
30385
30430
  let commandBody = "";
30431
+ noNamespaceCommands.sort((a2, b2) => a2.rawName < b2.rawName ? -1 : a2.rawName > b2.rawName ? 1 : 0);
30386
30432
  if (noNamespaceCommands.length > 0) {
30387
30433
  commandBody += noNamespaceCommands.map((command) => {
30388
30434
  return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
@@ -30409,12 +30455,14 @@ class Command {
30409
30455
  body: commandBody
30410
30456
  });
30411
30457
  sections.push({
30412
- title: `For more info, run any command with the \`--help\` flag`,
30413
- body: commands.map((command) => ` $ ${name}${command.displayName === "" ? "" : ` ${command.displayName}`} --help`).join(`
30414
- `)
30458
+ body: `Run \`${name} <command> --help\` for command details.`
30415
30459
  });
30416
30460
  }
30417
- let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
30461
+ const localOptionNames = new Set(this.options.flatMap((option) => option.names));
30462
+ let options = this.isGlobalCommand ? globalOptions : [
30463
+ ...this.options,
30464
+ ...(globalOptions || []).filter((option) => !option.names.some((name2) => localOptionNames.has(name2)))
30465
+ ];
30418
30466
  if (!this.isGlobalCommand && !this.isDefaultCommand) {
30419
30467
  options = options.filter((option) => option.name !== "version");
30420
30468
  }
@@ -30458,6 +30506,9 @@ ${section.body}` : section.body;
30458
30506
  console.log(`${name}/${versionNumber} ${platformInfo3}`);
30459
30507
  }
30460
30508
  }
30509
+ get usageLine() {
30510
+ return `$ ${this.cli.name} ${this.usageText || this.rawName}`;
30511
+ }
30461
30512
  checkRequiredArgs() {
30462
30513
  const minimalArgsCount = this.args.filter((arg) => arg.required).length;
30463
30514
  if (this.cli.args.length < minimalArgsCount) {
@@ -30466,7 +30517,7 @@ ${section.body}` : section.body;
30466
30517
  const argNames = missingArgs.map((arg) => `<${arg.value}>`).join(" ");
30467
30518
  throw new ClappError(`Missing required argument${missingArgs.length > 1 ? "s" : ""}: ${argNames}
30468
30519
 
30469
- ` + `Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`);
30520
+ ` + `Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`, this.usageLine);
30470
30521
  }
30471
30522
  }
30472
30523
  checkUnknownOptions() {
@@ -30476,8 +30527,9 @@ ${section.body}` : section.body;
30476
30527
  if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) {
30477
30528
  const allOptions = [...globalCommand.options, ...this.options];
30478
30529
  const allOptionNames = allOptions.flatMap((opt) => opt.names);
30530
+ const normalizedName = camelcaseOptionName(name.split(".")[0]);
30479
30531
  const optionFlag = name.length > 1 ? `--${name}` : `-${name}`;
30480
- const suggestions = findSimilarCommands(name, allOptionNames);
30532
+ const suggestions = findSimilarCommands(normalizedName, allOptionNames);
30481
30533
  let errorMsg = `Unknown option \`${optionFlag}\``;
30482
30534
  if (suggestions.length > 0) {
30483
30535
  errorMsg += `
@@ -30492,7 +30544,7 @@ Did you mean one of these?`;
30492
30544
  errorMsg += `
30493
30545
 
30494
30546
  Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`;
30495
- throw new ClappError(errorMsg);
30547
+ throw new ClappError(errorMsg, this.usageLine);
30496
30548
  }
30497
30549
  }
30498
30550
  }
@@ -30507,7 +30559,7 @@ Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`;
30507
30559
  if (value === true || value === false && !hasNegated) {
30508
30560
  throw new ClappError(`Option \`${option.rawName}\` requires a value.
30509
30561
 
30510
- ` + `Example: ${this.cli.name} ${this.rawName} ${option.rawName} <value>`);
30562
+ ` + `Example: ${this.cli.name} ${this.rawName} ${option.rawName} <value>`, this.usageLine);
30511
30563
  }
30512
30564
  }
30513
30565
  }
@@ -30813,6 +30865,25 @@ Received ${signal}, cleaning up...`);
30813
30865
  break;
30814
30866
  }
30815
30867
  }
30868
+ if (shouldParse) {
30869
+ const nextToken = slicedArgv[1];
30870
+ if (nextToken && !nextToken.startsWith("-")) {
30871
+ const joinedName = `${candidateName}:${nextToken}`;
30872
+ for (const command of this.commands) {
30873
+ if (command.isMatched(joinedName)) {
30874
+ const parsed = this.mri(slicedArgv, command);
30875
+ shouldParse = false;
30876
+ const parsedInfo = {
30877
+ ...parsed,
30878
+ args: parsed.args.slice(2)
30879
+ };
30880
+ this.setParsedInfo(parsedInfo, command, joinedName);
30881
+ this.emit(`command:${joinedName}`, command);
30882
+ break;
30883
+ }
30884
+ }
30885
+ }
30886
+ }
30816
30887
  }
30817
30888
  if (shouldParse) {
30818
30889
  for (const command of this.commands) {
@@ -30838,7 +30909,7 @@ Received ${signal}, cleaning up...`);
30838
30909
  if (this.options.debug) {
30839
30910
  this.isDebug = true;
30840
30911
  }
30841
- if (this.options.noInteraction) {
30912
+ if (this.options.noInteraction || this.options.interaction === false) {
30842
30913
  this.isNoInteraction = true;
30843
30914
  }
30844
30915
  if (this.options.env) {
@@ -30850,14 +30921,14 @@ Received ${signal}, cleaning up...`);
30850
30921
  if (this.options.force) {
30851
30922
  this.isForce = true;
30852
30923
  }
30853
- if (this.options.noEmoji !== undefined) {
30854
- this.useEmoji = !this.options.noEmoji;
30924
+ if (this.options.noEmoji || this.options.emoji === false) {
30925
+ this.useEmoji = false;
30855
30926
  }
30856
30927
  if (this.options.theme) {
30857
30928
  this.theme = String(this.options.theme);
30858
30929
  }
30859
- if (this.options.noCache !== undefined) {
30860
- this.isNoCache = Boolean(this.options.noCache);
30930
+ if (this.options.noCache || this.options.cache === false) {
30931
+ this.isNoCache = true;
30861
30932
  }
30862
30933
  if (this.options.help && this.showHelpOnExit) {
30863
30934
  this.outputHelp();
@@ -30938,18 +31009,16 @@ Received ${signal}, cleaning up...`);
30938
31009
  return this.parse(argv, { run: true, exitOnError: true });
30939
31010
  }
30940
31011
  handleUsageError(err) {
30941
- const isClappError = !!err && typeof err === "object" && err.name === "ClappError";
30942
- const isUsage = isClappError && err.isUsageError !== false;
30943
- if (!isUsage)
31012
+ if (!isClappError(err) || err.isUsageError === false)
30944
31013
  return;
30945
- const e2 = err;
30946
- const raw2 = e2.message ?? "command-line error";
31014
+ const raw2 = err.message || "command-line error";
30947
31015
  const label = this.name ? `${this.name}: ` : "";
30948
- const suffix = /--help/.test(raw2) ? "" : `
31016
+ const suffix = /--help/.test(raw2) ? "" : err.usage ? `
31017
+ Usage: ${err.usage}` : `
30949
31018
  Run \`${this.name ?? "cli"} --help\` for usage.`;
30950
31019
  process52.stderr.write(`${label}${raw2}${suffix}
30951
31020
  `);
30952
- process52.exit(e2.exitCode ?? 2);
31021
+ process52.exit(err.exitCode ?? 2);
30953
31022
  }
30954
31023
  async runMatchedCommand() {
30955
31024
  const { args, options, matchedCommand: command } = this;
@@ -31805,7 +31874,7 @@ function getPrefix() {
31805
31874
  }
31806
31875
  var prefix = getPrefix();
31807
31876
  // package.json
31808
- var version2 = "0.2.26";
31877
+ var version2 = "0.2.27";
31809
31878
 
31810
31879
  // bin/cli.ts
31811
31880
  init_actions();