drizzle-kit 0.17.1-6d783c6 → 0.17.1-8e07fce

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +14 -0
  2. package/index.js +277 -324
  3. package/package.json +4 -3
package/index.js CHANGED
@@ -619,7 +619,7 @@ var require_command = __commonJS({
619
619
  var EventEmitter = require("events").EventEmitter;
620
620
  var childProcess = require("child_process");
621
621
  var path3 = require("path");
622
- var fs7 = require("fs");
622
+ var fs6 = require("fs");
623
623
  var process3 = require("process");
624
624
  var { Argument: Argument2, humanReadableArgName } = require_argument();
625
625
  var { CommanderError: CommanderError2 } = require_error();
@@ -1059,11 +1059,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1059
1059
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1060
1060
  function findFile(baseDir, baseName) {
1061
1061
  const localBin = path3.resolve(baseDir, baseName);
1062
- if (fs7.existsSync(localBin))
1062
+ if (fs6.existsSync(localBin))
1063
1063
  return localBin;
1064
1064
  if (sourceExt.includes(path3.extname(baseName)))
1065
1065
  return void 0;
1066
- const foundExt = sourceExt.find((ext2) => fs7.existsSync(`${localBin}${ext2}`));
1066
+ const foundExt = sourceExt.find((ext2) => fs6.existsSync(`${localBin}${ext2}`));
1067
1067
  if (foundExt)
1068
1068
  return `${localBin}${foundExt}`;
1069
1069
  return void 0;
@@ -1075,7 +1075,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1075
1075
  if (this._scriptPath) {
1076
1076
  let resolvedScriptPath;
1077
1077
  try {
1078
- resolvedScriptPath = fs7.realpathSync(this._scriptPath);
1078
+ resolvedScriptPath = fs6.realpathSync(this._scriptPath);
1079
1079
  } catch (err2) {
1080
1080
  resolvedScriptPath = this._scriptPath;
1081
1081
  }
@@ -5756,11 +5756,11 @@ var require_hanji = __commonJS({
5756
5756
  "use strict";
5757
5757
  var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
5758
5758
  function adopt(value) {
5759
- return value instanceof P ? value : new P(function(resolve) {
5760
- resolve(value);
5759
+ return value instanceof P ? value : new P(function(resolve2) {
5760
+ resolve2(value);
5761
5761
  });
5762
5762
  }
5763
- return new (P || (P = Promise))(function(resolve, reject) {
5763
+ return new (P || (P = Promise))(function(resolve2, reject) {
5764
5764
  function fulfilled(value) {
5765
5765
  try {
5766
5766
  step(generator.next(value));
@@ -5776,7 +5776,7 @@ var require_hanji = __commonJS({
5776
5776
  }
5777
5777
  }
5778
5778
  function step(result) {
5779
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
5779
+ result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
5780
5780
  }
5781
5781
  step((generator = generator.apply(thisArg, _arguments || [])).next());
5782
5782
  });
@@ -5850,14 +5850,14 @@ var require_hanji = __commonJS({
5850
5850
  };
5851
5851
  exports.SelectState = SelectState2;
5852
5852
  var deferred = () => {
5853
- let resolve;
5853
+ let resolve2;
5854
5854
  let reject;
5855
5855
  const promise = new Promise((res, rej) => {
5856
- resolve = res;
5856
+ resolve2 = res;
5857
5857
  reject = rej;
5858
5858
  });
5859
5859
  return {
5860
- resolve,
5860
+ resolve: resolve2,
5861
5861
  reject,
5862
5862
  promise
5863
5863
  };
@@ -5907,8 +5907,8 @@ var require_hanji = __commonJS({
5907
5907
  };
5908
5908
  this.stdin.on("keypress", keypress);
5909
5909
  this.view.attach(this);
5910
- const { resolve, promise } = (0, exports.deferred)();
5911
- this.resolve = resolve;
5910
+ const { resolve: resolve2, promise } = (0, exports.deferred)();
5911
+ this.resolve = resolve2;
5912
5912
  this.promise = promise;
5913
5913
  this.renderFunc = (0, lodash_throttle_1.default)((str) => {
5914
5914
  this.stdout.write(str);
@@ -9579,15 +9579,15 @@ var require_resolve_resolve = __commonJS({
9579
9579
  var slice = Array.prototype.slice;
9580
9580
  var resolveArgs;
9581
9581
  resolveArgs = function(args) {
9582
- return this.map(function(resolve, i) {
9583
- return resolve ? resolve(args[i]) : args[i];
9582
+ return this.map(function(resolve2, i) {
9583
+ return resolve2 ? resolve2(args[i]) : args[i];
9584
9584
  }).concat(slice.call(args, this.length));
9585
9585
  };
9586
9586
  module2.exports = function(resolvers) {
9587
9587
  resolvers = toArray(resolvers);
9588
- resolvers.forEach(function(resolve) {
9589
- if (isValue(resolve))
9590
- callable(resolve);
9588
+ resolvers.forEach(function(resolve2) {
9589
+ if (isValue(resolve2))
9590
+ callable(resolve2);
9591
9591
  });
9592
9592
  return resolveArgs.bind(resolvers);
9593
9593
  };
@@ -9635,7 +9635,7 @@ var require_configure_map = __commonJS({
9635
9635
  var on = ee.on;
9636
9636
  var emit = ee.emit;
9637
9637
  module2.exports = function(original, length, options) {
9638
- var cache = create(null), conf, memLength, get, set, del, clear, extDel, extGet, extHas, normalizer, getListeners, setListeners, deleteListeners, memoized, resolve;
9638
+ var cache = create(null), conf, memLength, get, set, del, clear, extDel, extGet, extHas, normalizer, getListeners, setListeners, deleteListeners, memoized, resolve2;
9639
9639
  if (length !== false)
9640
9640
  memLength = length;
9641
9641
  else if (isNaN(original.length))
@@ -9650,12 +9650,12 @@ var require_configure_map = __commonJS({
9650
9650
  clear = normalizer.clear;
9651
9651
  }
9652
9652
  if (options.resolvers != null)
9653
- resolve = resolveResolve(options.resolvers);
9653
+ resolve2 = resolveResolve(options.resolvers);
9654
9654
  if (get) {
9655
9655
  memoized = defineLength(function(arg) {
9656
9656
  var id, result, args = arguments;
9657
- if (resolve)
9658
- args = resolve(args);
9657
+ if (resolve2)
9658
+ args = resolve2(args);
9659
9659
  id = get(args);
9660
9660
  if (id !== null) {
9661
9661
  if (hasOwnProperty.call(cache, id)) {
@@ -9704,8 +9704,8 @@ var require_configure_map = __commonJS({
9704
9704
  } else {
9705
9705
  memoized = function(arg) {
9706
9706
  var result, args = arguments, id;
9707
- if (resolve)
9708
- args = resolve(arguments);
9707
+ if (resolve2)
9708
+ args = resolve2(arguments);
9709
9709
  id = String(args[0]);
9710
9710
  if (hasOwnProperty.call(cache, id)) {
9711
9711
  if (getListeners)
@@ -9730,8 +9730,8 @@ var require_configure_map = __commonJS({
9730
9730
  memoized,
9731
9731
  profileName: options.profileName,
9732
9732
  get: function(args) {
9733
- if (resolve)
9734
- args = resolve(args);
9733
+ if (resolve2)
9734
+ args = resolve2(args);
9735
9735
  if (get)
9736
9736
  return get(args);
9737
9737
  return String(args[0]);
@@ -9774,8 +9774,8 @@ var require_configure_map = __commonJS({
9774
9774
  if (get) {
9775
9775
  extDel = defineLength(function(arg) {
9776
9776
  var id, args = arguments;
9777
- if (resolve)
9778
- args = resolve(args);
9777
+ if (resolve2)
9778
+ args = resolve2(args);
9779
9779
  id = get(args);
9780
9780
  if (id === null)
9781
9781
  return;
@@ -9787,8 +9787,8 @@ var require_configure_map = __commonJS({
9787
9787
  };
9788
9788
  } else {
9789
9789
  extDel = function(arg) {
9790
- if (resolve)
9791
- arg = resolve(arguments)[0];
9790
+ if (resolve2)
9791
+ arg = resolve2(arguments)[0];
9792
9792
  return conf.delete(arg);
9793
9793
  };
9794
9794
  }
@@ -9796,8 +9796,8 @@ var require_configure_map = __commonJS({
9796
9796
  var id, args = arguments;
9797
9797
  if (length === 0)
9798
9798
  return cache.data;
9799
- if (resolve)
9800
- args = resolve(args);
9799
+ if (resolve2)
9800
+ args = resolve2(args);
9801
9801
  if (get)
9802
9802
  id = get(args);
9803
9803
  else
@@ -9808,8 +9808,8 @@ var require_configure_map = __commonJS({
9808
9808
  var id, args = arguments;
9809
9809
  if (length === 0)
9810
9810
  return conf.has("data");
9811
- if (resolve)
9812
- args = resolve(args);
9811
+ if (resolve2)
9812
+ args = resolve2(args);
9813
9813
  if (get)
9814
9814
  id = get(args);
9815
9815
  else
@@ -11719,7 +11719,7 @@ var require_bare = __commonJS({
11719
11719
  var sgr = require_sgr();
11720
11720
  var supportsColor2 = require_supports_color();
11721
11721
  var mods = sgr.mods;
11722
- var join5 = Array.prototype.join;
11722
+ var join6 = Array.prototype.join;
11723
11723
  var defineProperty = Object.defineProperty;
11724
11724
  var max = Math.max;
11725
11725
  var min = Math.min;
@@ -11773,7 +11773,7 @@ var require_bare = __commonJS({
11773
11773
  getFn = function() {
11774
11774
  return setPrototypeOf(
11775
11775
  function self2() {
11776
- var start = "", end = "", msg = join5.call(arguments, " "), conf = self2._cliColorData, hasAnsi = sgr.hasCSI(msg);
11776
+ var start = "", end = "", msg = join6.call(arguments, " "), conf = self2._cliColorData, hasAnsi = sgr.hasCSI(msg);
11777
11777
  forEach(
11778
11778
  conf,
11779
11779
  function(mod, key) {
@@ -20902,7 +20902,7 @@ var require_node2 = __commonJS({
20902
20902
  function _interopRequireDefault(obj) {
20903
20903
  return obj && obj.__esModule ? obj : { default: obj };
20904
20904
  }
20905
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
20905
+ function asyncGeneratorStep(gen, resolve2, reject, _next, _throw, key, arg) {
20906
20906
  try {
20907
20907
  var info2 = gen[key](arg);
20908
20908
  var value = info2.value;
@@ -20911,7 +20911,7 @@ var require_node2 = __commonJS({
20911
20911
  return;
20912
20912
  }
20913
20913
  if (info2.done) {
20914
- resolve(value);
20914
+ resolve2(value);
20915
20915
  } else {
20916
20916
  Promise.resolve(value).then(_next, _throw);
20917
20917
  }
@@ -20919,31 +20919,31 @@ var require_node2 = __commonJS({
20919
20919
  function _asyncToGenerator(fn) {
20920
20920
  return function() {
20921
20921
  var self2 = this, args = arguments;
20922
- return new Promise(function(resolve, reject) {
20922
+ return new Promise(function(resolve2, reject) {
20923
20923
  var gen = fn.apply(self2, args);
20924
20924
  function _next(value) {
20925
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
20925
+ asyncGeneratorStep(gen, resolve2, reject, _next, _throw, "next", value);
20926
20926
  }
20927
20927
  function _throw(err2) {
20928
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err2);
20928
+ asyncGeneratorStep(gen, resolve2, reject, _next, _throw, "throw", err2);
20929
20929
  }
20930
20930
  _next(void 0);
20931
20931
  });
20932
20932
  };
20933
20933
  }
20934
- var readFile = (fp) => new Promise((resolve, reject) => {
20934
+ var readFile = (fp) => new Promise((resolve2, reject) => {
20935
20935
  _fs.default.readFile(fp, "utf8", (err2, data) => {
20936
20936
  if (err2)
20937
20937
  return reject(err2);
20938
- resolve(data);
20938
+ resolve2(data);
20939
20939
  });
20940
20940
  });
20941
20941
  var readFileSync4 = (fp) => {
20942
20942
  return _fs.default.readFileSync(fp, "utf8");
20943
20943
  };
20944
- var pathExists = (fp) => new Promise((resolve) => {
20944
+ var pathExists = (fp) => new Promise((resolve2) => {
20945
20945
  _fs.default.access(fp, (err2) => {
20946
- resolve(!err2);
20946
+ resolve2(!err2);
20947
20947
  });
20948
20948
  });
20949
20949
  var pathExistsSync = _fs.default.existsSync;
@@ -23466,7 +23466,7 @@ var require_old = __commonJS({
23466
23466
  "node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/old.js"(exports) {
23467
23467
  var pathModule = require("path");
23468
23468
  var isWindows = process.platform === "win32";
23469
- var fs7 = require("fs");
23469
+ var fs6 = require("fs");
23470
23470
  var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
23471
23471
  function rethrow() {
23472
23472
  var callback;
@@ -23531,7 +23531,7 @@ var require_old = __commonJS({
23531
23531
  base = m[0];
23532
23532
  previous = "";
23533
23533
  if (isWindows && !knownHard[base]) {
23534
- fs7.lstatSync(base);
23534
+ fs6.lstatSync(base);
23535
23535
  knownHard[base] = true;
23536
23536
  }
23537
23537
  }
@@ -23549,7 +23549,7 @@ var require_old = __commonJS({
23549
23549
  if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
23550
23550
  resolvedLink = cache[base];
23551
23551
  } else {
23552
- var stat = fs7.lstatSync(base);
23552
+ var stat = fs6.lstatSync(base);
23553
23553
  if (!stat.isSymbolicLink()) {
23554
23554
  knownHard[base] = true;
23555
23555
  if (cache)
@@ -23564,8 +23564,8 @@ var require_old = __commonJS({
23564
23564
  }
23565
23565
  }
23566
23566
  if (linkTarget === null) {
23567
- fs7.statSync(base);
23568
- linkTarget = fs7.readlinkSync(base);
23567
+ fs6.statSync(base);
23568
+ linkTarget = fs6.readlinkSync(base);
23569
23569
  }
23570
23570
  resolvedLink = pathModule.resolve(previous, linkTarget);
23571
23571
  if (cache)
@@ -23602,7 +23602,7 @@ var require_old = __commonJS({
23602
23602
  base = m[0];
23603
23603
  previous = "";
23604
23604
  if (isWindows && !knownHard[base]) {
23605
- fs7.lstat(base, function(err2) {
23605
+ fs6.lstat(base, function(err2) {
23606
23606
  if (err2)
23607
23607
  return cb(err2);
23608
23608
  knownHard[base] = true;
@@ -23630,7 +23630,7 @@ var require_old = __commonJS({
23630
23630
  if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
23631
23631
  return gotResolvedLink(cache[base]);
23632
23632
  }
23633
- return fs7.lstat(base, gotStat);
23633
+ return fs6.lstat(base, gotStat);
23634
23634
  }
23635
23635
  function gotStat(err2, stat) {
23636
23636
  if (err2)
@@ -23647,10 +23647,10 @@ var require_old = __commonJS({
23647
23647
  return gotTarget(null, seenLinks[id], base);
23648
23648
  }
23649
23649
  }
23650
- fs7.stat(base, function(err3) {
23650
+ fs6.stat(base, function(err3) {
23651
23651
  if (err3)
23652
23652
  return cb(err3);
23653
- fs7.readlink(base, function(err4, target) {
23653
+ fs6.readlink(base, function(err4, target) {
23654
23654
  if (!isWindows)
23655
23655
  seenLinks[id] = target;
23656
23656
  gotTarget(err4, target);
@@ -23682,9 +23682,9 @@ var require_fs = __commonJS({
23682
23682
  realpath.realpathSync = realpathSync;
23683
23683
  realpath.monkeypatch = monkeypatch;
23684
23684
  realpath.unmonkeypatch = unmonkeypatch;
23685
- var fs7 = require("fs");
23686
- var origRealpath = fs7.realpath;
23687
- var origRealpathSync = fs7.realpathSync;
23685
+ var fs6 = require("fs");
23686
+ var origRealpath = fs6.realpath;
23687
+ var origRealpathSync = fs6.realpathSync;
23688
23688
  var version = process.version;
23689
23689
  var ok = /^v[0-5]\./.test(version);
23690
23690
  var old = require_old();
@@ -23722,12 +23722,12 @@ var require_fs = __commonJS({
23722
23722
  }
23723
23723
  }
23724
23724
  function monkeypatch() {
23725
- fs7.realpath = realpath;
23726
- fs7.realpathSync = realpathSync;
23725
+ fs6.realpath = realpath;
23726
+ fs6.realpathSync = realpathSync;
23727
23727
  }
23728
23728
  function unmonkeypatch() {
23729
- fs7.realpath = origRealpath;
23730
- fs7.realpathSync = origRealpathSync;
23729
+ fs6.realpath = origRealpath;
23730
+ fs6.realpathSync = origRealpathSync;
23731
23731
  }
23732
23732
  }
23733
23733
  });
@@ -24577,7 +24577,7 @@ var require_common2 = __commonJS({
24577
24577
  function ownProp(obj, field) {
24578
24578
  return Object.prototype.hasOwnProperty.call(obj, field);
24579
24579
  }
24580
- var fs7 = require("fs");
24580
+ var fs6 = require("fs");
24581
24581
  var path3 = require("path");
24582
24582
  var minimatch2 = require_minimatch();
24583
24583
  var isAbsolute = require("path").isAbsolute;
@@ -24636,7 +24636,7 @@ var require_common2 = __commonJS({
24636
24636
  self2.stat = !!options.stat;
24637
24637
  self2.noprocess = !!options.noprocess;
24638
24638
  self2.absolute = !!options.absolute;
24639
- self2.fs = options.fs || fs7;
24639
+ self2.fs = options.fs || fs6;
24640
24640
  self2.maxLength = options.maxLength || Infinity;
24641
24641
  self2.cache = options.cache || /* @__PURE__ */ Object.create(null);
24642
24642
  self2.statCache = options.statCache || /* @__PURE__ */ Object.create(null);
@@ -26915,6 +26915,7 @@ var init_serializer = __esm({
26915
26915
  return generateSqliteSnapshot2(tables, enums);
26916
26916
  };
26917
26917
  prepareFilenames = (path3) => {
26918
+ console.log("path: " + path3);
26918
26919
  if (typeof path3 === "string") {
26919
26920
  path3 = [path3];
26920
26921
  }
@@ -26927,6 +26928,7 @@ var init_serializer = __esm({
26927
26928
  });
26928
26929
  return result2;
26929
26930
  }, /* @__PURE__ */ new Set());
26931
+ console.log("result path: " + [...result]);
26930
26932
  return [...result];
26931
26933
  };
26932
26934
  }
@@ -42014,7 +42016,7 @@ var require_named_placeholders = __commonJS({
42014
42016
  }
42015
42017
  return s;
42016
42018
  }
42017
- function join5(tree) {
42019
+ function join6(tree) {
42018
42020
  if (tree.length == 1) {
42019
42021
  return tree;
42020
42022
  }
@@ -42040,7 +42042,7 @@ var require_named_placeholders = __commonJS({
42040
42042
  if (cache && (tree = cache.get(query))) {
42041
42043
  return toArrayParams(tree, paramsObj);
42042
42044
  }
42043
- tree = join5(parse(query));
42045
+ tree = join6(parse(query));
42044
42046
  if (cache) {
42045
42047
  cache.set(query, tree);
42046
42048
  }
@@ -43460,7 +43462,7 @@ var require_promise2 = __commonJS({
43460
43462
  "use strict";
43461
43463
  var core = require_mysql2();
43462
43464
  var EventEmitter = require("events").EventEmitter;
43463
- function makeDoneCb(resolve, reject, localErr) {
43465
+ function makeDoneCb(resolve2, reject, localErr) {
43464
43466
  return function(err2, rows, fields) {
43465
43467
  if (err2) {
43466
43468
  localErr.message = err2.message;
@@ -43471,7 +43473,7 @@ var require_promise2 = __commonJS({
43471
43473
  localErr.sqlMessage = err2.sqlMessage;
43472
43474
  reject(localErr);
43473
43475
  } else {
43474
- resolve([rows, fields]);
43476
+ resolve2([rows, fields]);
43475
43477
  }
43476
43478
  };
43477
43479
  }
@@ -43503,8 +43505,8 @@ var require_promise2 = __commonJS({
43503
43505
  execute(parameters) {
43504
43506
  const s = this.statement;
43505
43507
  const localErr = new Error();
43506
- return new this.Promise((resolve, reject) => {
43507
- const done = makeDoneCb(resolve, reject, localErr);
43508
+ return new this.Promise((resolve2, reject) => {
43509
+ const done = makeDoneCb(resolve2, reject, localErr);
43508
43510
  if (parameters) {
43509
43511
  s.execute(parameters, done);
43510
43512
  } else {
@@ -43513,9 +43515,9 @@ var require_promise2 = __commonJS({
43513
43515
  });
43514
43516
  }
43515
43517
  close() {
43516
- return new this.Promise((resolve) => {
43518
+ return new this.Promise((resolve2) => {
43517
43519
  this.statement.close();
43518
- resolve();
43520
+ resolve2();
43519
43521
  });
43520
43522
  }
43521
43523
  };
@@ -43543,8 +43545,8 @@ var require_promise2 = __commonJS({
43543
43545
  "Callback function is not available with promise clients."
43544
43546
  );
43545
43547
  }
43546
- return new this.Promise((resolve, reject) => {
43547
- const done = makeDoneCb(resolve, reject, localErr);
43548
+ return new this.Promise((resolve2, reject) => {
43549
+ const done = makeDoneCb(resolve2, reject, localErr);
43548
43550
  if (params !== void 0) {
43549
43551
  c.query(query, params, done);
43550
43552
  } else {
@@ -43560,8 +43562,8 @@ var require_promise2 = __commonJS({
43560
43562
  "Callback function is not available with promise clients."
43561
43563
  );
43562
43564
  }
43563
- return new this.Promise((resolve, reject) => {
43564
- const done = makeDoneCb(resolve, reject, localErr);
43565
+ return new this.Promise((resolve2, reject) => {
43566
+ const done = makeDoneCb(resolve2, reject, localErr);
43565
43567
  if (params !== void 0) {
43566
43568
  c.execute(query, params, done);
43567
43569
  } else {
@@ -43570,46 +43572,46 @@ var require_promise2 = __commonJS({
43570
43572
  });
43571
43573
  }
43572
43574
  end() {
43573
- return new this.Promise((resolve) => {
43574
- this.connection.end(resolve);
43575
+ return new this.Promise((resolve2) => {
43576
+ this.connection.end(resolve2);
43575
43577
  });
43576
43578
  }
43577
43579
  beginTransaction() {
43578
43580
  const c = this.connection;
43579
43581
  const localErr = new Error();
43580
- return new this.Promise((resolve, reject) => {
43581
- const done = makeDoneCb(resolve, reject, localErr);
43582
+ return new this.Promise((resolve2, reject) => {
43583
+ const done = makeDoneCb(resolve2, reject, localErr);
43582
43584
  c.beginTransaction(done);
43583
43585
  });
43584
43586
  }
43585
43587
  commit() {
43586
43588
  const c = this.connection;
43587
43589
  const localErr = new Error();
43588
- return new this.Promise((resolve, reject) => {
43589
- const done = makeDoneCb(resolve, reject, localErr);
43590
+ return new this.Promise((resolve2, reject) => {
43591
+ const done = makeDoneCb(resolve2, reject, localErr);
43590
43592
  c.commit(done);
43591
43593
  });
43592
43594
  }
43593
43595
  rollback() {
43594
43596
  const c = this.connection;
43595
43597
  const localErr = new Error();
43596
- return new this.Promise((resolve, reject) => {
43597
- const done = makeDoneCb(resolve, reject, localErr);
43598
+ return new this.Promise((resolve2, reject) => {
43599
+ const done = makeDoneCb(resolve2, reject, localErr);
43598
43600
  c.rollback(done);
43599
43601
  });
43600
43602
  }
43601
43603
  ping() {
43602
43604
  const c = this.connection;
43603
43605
  const localErr = new Error();
43604
- return new this.Promise((resolve, reject) => {
43605
- const done = makeDoneCb(resolve, reject, localErr);
43606
+ return new this.Promise((resolve2, reject) => {
43607
+ const done = makeDoneCb(resolve2, reject, localErr);
43606
43608
  c.ping(done);
43607
43609
  });
43608
43610
  }
43609
43611
  connect() {
43610
43612
  const c = this.connection;
43611
43613
  const localErr = new Error();
43612
- return new this.Promise((resolve, reject) => {
43614
+ return new this.Promise((resolve2, reject) => {
43613
43615
  c.connect((err2, param) => {
43614
43616
  if (err2) {
43615
43617
  localErr.message = err2.message;
@@ -43619,7 +43621,7 @@ var require_promise2 = __commonJS({
43619
43621
  localErr.sqlMessage = err2.sqlMessage;
43620
43622
  reject(localErr);
43621
43623
  } else {
43622
- resolve(param);
43624
+ resolve2(param);
43623
43625
  }
43624
43626
  });
43625
43627
  });
@@ -43628,7 +43630,7 @@ var require_promise2 = __commonJS({
43628
43630
  const c = this.connection;
43629
43631
  const promiseImpl = this.Promise;
43630
43632
  const localErr = new Error();
43631
- return new this.Promise((resolve, reject) => {
43633
+ return new this.Promise((resolve2, reject) => {
43632
43634
  c.prepare(options, (err2, statement) => {
43633
43635
  if (err2) {
43634
43636
  localErr.message = err2.message;
@@ -43642,7 +43644,7 @@ var require_promise2 = __commonJS({
43642
43644
  statement,
43643
43645
  promiseImpl
43644
43646
  );
43645
- resolve(wrappedStatement);
43647
+ resolve2(wrappedStatement);
43646
43648
  }
43647
43649
  });
43648
43650
  });
@@ -43650,7 +43652,7 @@ var require_promise2 = __commonJS({
43650
43652
  changeUser(options) {
43651
43653
  const c = this.connection;
43652
43654
  const localErr = new Error();
43653
- return new this.Promise((resolve, reject) => {
43655
+ return new this.Promise((resolve2, reject) => {
43654
43656
  c.changeUser(options, (err2) => {
43655
43657
  if (err2) {
43656
43658
  localErr.message = err2.message;
@@ -43660,7 +43662,7 @@ var require_promise2 = __commonJS({
43660
43662
  localErr.sqlMessage = err2.sqlMessage;
43661
43663
  reject(localErr);
43662
43664
  } else {
43663
- resolve();
43665
+ resolve2();
43664
43666
  }
43665
43667
  });
43666
43668
  });
@@ -43681,9 +43683,9 @@ var require_promise2 = __commonJS({
43681
43683
  "no Promise implementation available.Use promise-enabled node version or pass userland Promise implementation as parameter, for example: { Promise: require('bluebird') }"
43682
43684
  );
43683
43685
  }
43684
- return new thePromise((resolve, reject) => {
43686
+ return new thePromise((resolve2, reject) => {
43685
43687
  coreConnection.once("connect", () => {
43686
- resolve(new PromiseConnection(coreConnection, thePromise));
43688
+ resolve2(new PromiseConnection(coreConnection, thePromise));
43687
43689
  });
43688
43690
  coreConnection.once("error", (err2) => {
43689
43691
  createConnectionErr.message = err2.message;
@@ -43740,12 +43742,12 @@ var require_promise2 = __commonJS({
43740
43742
  }
43741
43743
  getConnection() {
43742
43744
  const corePool = this.pool;
43743
- return new this.Promise((resolve, reject) => {
43745
+ return new this.Promise((resolve2, reject) => {
43744
43746
  corePool.getConnection((err2, coreConnection) => {
43745
43747
  if (err2) {
43746
43748
  reject(err2);
43747
43749
  } else {
43748
- resolve(new PromisePoolConnection(coreConnection, this.Promise));
43750
+ resolve2(new PromisePoolConnection(coreConnection, this.Promise));
43749
43751
  }
43750
43752
  });
43751
43753
  });
@@ -43758,8 +43760,8 @@ var require_promise2 = __commonJS({
43758
43760
  "Callback function is not available with promise clients."
43759
43761
  );
43760
43762
  }
43761
- return new this.Promise((resolve, reject) => {
43762
- const done = makeDoneCb(resolve, reject, localErr);
43763
+ return new this.Promise((resolve2, reject) => {
43764
+ const done = makeDoneCb(resolve2, reject, localErr);
43763
43765
  if (args !== void 0) {
43764
43766
  corePool.query(sql, args, done);
43765
43767
  } else {
@@ -43775,8 +43777,8 @@ var require_promise2 = __commonJS({
43775
43777
  "Callback function is not available with promise clients."
43776
43778
  );
43777
43779
  }
43778
- return new this.Promise((resolve, reject) => {
43779
- const done = makeDoneCb(resolve, reject, localErr);
43780
+ return new this.Promise((resolve2, reject) => {
43781
+ const done = makeDoneCb(resolve2, reject, localErr);
43780
43782
  if (args) {
43781
43783
  corePool.execute(sql, args, done);
43782
43784
  } else {
@@ -43787,7 +43789,7 @@ var require_promise2 = __commonJS({
43787
43789
  end() {
43788
43790
  const corePool = this.pool;
43789
43791
  const localErr = new Error();
43790
- return new this.Promise((resolve, reject) => {
43792
+ return new this.Promise((resolve2, reject) => {
43791
43793
  corePool.end((err2) => {
43792
43794
  if (err2) {
43793
43795
  localErr.message = err2.message;
@@ -43797,7 +43799,7 @@ var require_promise2 = __commonJS({
43797
43799
  localErr.sqlMessage = err2.sqlMessage;
43798
43800
  reject(localErr);
43799
43801
  } else {
43800
- resolve();
43802
+ resolve2();
43801
43803
  }
43802
43804
  });
43803
43805
  });
@@ -43838,12 +43840,12 @@ var require_promise2 = __commonJS({
43838
43840
  }
43839
43841
  getConnection() {
43840
43842
  const corePoolCluster = this.poolCluster;
43841
- return new this.Promise((resolve, reject) => {
43843
+ return new this.Promise((resolve2, reject) => {
43842
43844
  corePoolCluster.getConnection((err2, coreConnection) => {
43843
43845
  if (err2) {
43844
43846
  reject(err2);
43845
43847
  } else {
43846
- resolve(new PromisePoolConnection(coreConnection, this.Promise));
43848
+ resolve2(new PromisePoolConnection(coreConnection, this.Promise));
43847
43849
  }
43848
43850
  });
43849
43851
  });
@@ -43856,8 +43858,8 @@ var require_promise2 = __commonJS({
43856
43858
  "Callback function is not available with promise clients."
43857
43859
  );
43858
43860
  }
43859
- return new this.Promise((resolve, reject) => {
43860
- const done = makeDoneCb(resolve, reject, localErr);
43861
+ return new this.Promise((resolve2, reject) => {
43862
+ const done = makeDoneCb(resolve2, reject, localErr);
43861
43863
  corePoolCluster.query(sql, args, done);
43862
43864
  });
43863
43865
  }
@@ -43869,8 +43871,8 @@ var require_promise2 = __commonJS({
43869
43871
  "Callback function is not available with promise clients."
43870
43872
  );
43871
43873
  }
43872
- return new this.Promise((resolve, reject) => {
43873
- const done = makeDoneCb(resolve, reject, localErr);
43874
+ return new this.Promise((resolve2, reject) => {
43875
+ const done = makeDoneCb(resolve2, reject, localErr);
43874
43876
  corePoolCluster.execute(sql, args, done);
43875
43877
  });
43876
43878
  }
@@ -43883,7 +43885,7 @@ var require_promise2 = __commonJS({
43883
43885
  end() {
43884
43886
  const corePoolCluster = this.poolCluster;
43885
43887
  const localErr = new Error();
43886
- return new this.Promise((resolve, reject) => {
43888
+ return new this.Promise((resolve2, reject) => {
43887
43889
  corePoolCluster.end((err2) => {
43888
43890
  if (err2) {
43889
43891
  localErr.message = err2.message;
@@ -43893,7 +43895,7 @@ var require_promise2 = __commonJS({
43893
43895
  localErr.sqlMessage = err2.sqlMessage;
43894
43896
  reject(localErr);
43895
43897
  } else {
43896
- resolve();
43898
+ resolve2();
43897
43899
  }
43898
43900
  });
43899
43901
  });
@@ -45435,80 +45437,36 @@ var init_mjs = __esm({
45435
45437
  // src/cli/commands/mysqlIntrospect.ts
45436
45438
  var mysqlIntrospect_exports = {};
45437
45439
  __export(mysqlIntrospect_exports, {
45438
- MySQLConfig1: () => MySQLConfig1,
45439
- MySQLConfig2: () => MySQLConfig2,
45440
- configIntrospectSchema: () => configIntrospectSchema,
45441
- configPushSchema: () => configPushSchema,
45442
45440
  connectToMySQL: () => connectToMySQL,
45443
45441
  mysqlIntrospect: () => mysqlIntrospect,
45444
45442
  mysqlPushIntrospect: () => mysqlPushIntrospect
45445
45443
  });
45446
- var import_hanji4, import_promise, MySQLConfig1, MySQLConfig2, Conf, configPushSchema, configIntrospectSchema, connectToMySQL, mysqlIntrospect, mysqlPushIntrospect;
45444
+ var import_hanji4, import_promise, connectToMySQL, mysqlIntrospect, mysqlPushIntrospect;
45447
45445
  var init_mysqlIntrospect = __esm({
45448
45446
  "src/cli/commands/mysqlIntrospect.ts"() {
45449
45447
  import_hanji4 = __toESM(require_hanji());
45450
- init_lib();
45451
45448
  init_views();
45452
45449
  import_promise = __toESM(require_promise2());
45453
45450
  init_mysqlSerializer();
45454
45451
  init_mysql_introspect();
45455
45452
  init_global();
45456
45453
  init_mjs();
45457
- MySQLConfig1 = objectType({
45458
- host: stringType(),
45459
- port: coerce.number().optional(),
45460
- user: stringType().default("mysql"),
45461
- password: stringType().optional(),
45462
- database: stringType()
45463
- }).strict();
45464
- MySQLConfig2 = objectType({
45465
- connectionString: stringType()
45466
- }).strict();
45467
- Conf = unionType([MySQLConfig1, MySQLConfig2]);
45468
- configPushSchema = unionType([
45469
- objectType({
45470
- host: stringType(),
45471
- port: coerce.number().optional(),
45472
- user: stringType().default("mysql"),
45473
- password: stringType().optional(),
45474
- database: stringType(),
45475
- schema: unionType([stringType(), stringType().array()]),
45476
- tablesFilter: unionType([stringType(), stringType().array()]).optional()
45477
- }),
45478
- objectType({
45479
- connectionString: stringType(),
45480
- schema: unionType([stringType(), stringType().array()]),
45481
- tablesFilter: unionType([stringType(), stringType().array()]).optional()
45482
- })
45483
- ]);
45484
- configIntrospectSchema = unionType([
45485
- objectType({
45486
- host: stringType(),
45487
- port: coerce.number().optional(),
45488
- user: stringType().default("mysql"),
45489
- password: stringType().optional(),
45490
- database: stringType(),
45491
- out: stringType(),
45492
- breakpoints: booleanType().optional().default(false)
45493
- }),
45494
- objectType({
45495
- connectionString: stringType(),
45496
- out: stringType(),
45497
- breakpoints: booleanType().optional().default(false)
45498
- })
45499
- ]);
45500
45454
  connectToMySQL = async (config) => {
45501
45455
  let client;
45502
45456
  let databaseName;
45503
- if (typeof config.connectionString !== "undefined") {
45457
+ if ("connectionString" in config) {
45504
45458
  const connection = config.connectionString;
45505
45459
  client = await (0, import_promise.createConnection)(connection);
45506
45460
  const connectionUrl = new URL(connection);
45507
45461
  const pathname = connectionUrl.pathname;
45508
45462
  databaseName = pathname.split("/")[pathname.split("/").length - 1];
45509
- } else {
45463
+ } else if ("host" in config) {
45510
45464
  client = await (0, import_promise.createConnection)(config);
45511
45465
  databaseName = config.database;
45466
+ } else {
45467
+ throw Error(
45468
+ "Either `connectionString` or `host, port, etc.` params be provided in config file"
45469
+ );
45512
45470
  }
45513
45471
  await client.connect();
45514
45472
  return { client, databaseName };
@@ -47106,15 +47064,15 @@ var require_lib3 = __commonJS({
47106
47064
  "node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js"(exports, module2) {
47107
47065
  "use strict";
47108
47066
  var path3 = require("path");
47109
- var fs7 = require("fs");
47067
+ var fs6 = require("fs");
47110
47068
  var helper = require_helper();
47111
47069
  module2.exports = function(connInfo, cb) {
47112
47070
  var file = helper.getFileName();
47113
- fs7.stat(file, function(err2, stat) {
47071
+ fs6.stat(file, function(err2, stat) {
47114
47072
  if (err2 || !helper.usePgPass(stat, file)) {
47115
47073
  return cb(void 0);
47116
47074
  }
47117
- var st = fs7.createReadStream(file);
47075
+ var st = fs6.createReadStream(file);
47118
47076
  helper.getPassword(connInfo, st, cb);
47119
47077
  });
47120
47078
  };
@@ -47162,7 +47120,7 @@ var require_pg_connection_string = __commonJS({
47162
47120
  "node_modules/.pnpm/pg-connection-string@2.5.0/node_modules/pg-connection-string/index.js"(exports, module2) {
47163
47121
  "use strict";
47164
47122
  var url = require("url");
47165
- var fs7 = require("fs");
47123
+ var fs6 = require("fs");
47166
47124
  function parse(str) {
47167
47125
  if (str.charAt(0) === "/") {
47168
47126
  var config = str.split(" ");
@@ -47211,13 +47169,13 @@ var require_pg_connection_string = __commonJS({
47211
47169
  config.ssl = {};
47212
47170
  }
47213
47171
  if (config.sslcert) {
47214
- config.ssl.cert = fs7.readFileSync(config.sslcert).toString();
47172
+ config.ssl.cert = fs6.readFileSync(config.sslcert).toString();
47215
47173
  }
47216
47174
  if (config.sslkey) {
47217
- config.ssl.key = fs7.readFileSync(config.sslkey).toString();
47175
+ config.ssl.key = fs6.readFileSync(config.sslkey).toString();
47218
47176
  }
47219
47177
  if (config.sslrootcert) {
47220
- config.ssl.ca = fs7.readFileSync(config.sslrootcert).toString();
47178
+ config.ssl.ca = fs6.readFileSync(config.sslrootcert).toString();
47221
47179
  }
47222
47180
  switch (config.sslmode) {
47223
47181
  case "disable": {
@@ -48428,7 +48386,7 @@ var require_dist = __commonJS({
48428
48386
  function parse(stream, callback) {
48429
48387
  const parser = new parser_1.Parser();
48430
48388
  stream.on("data", (buffer) => parser.parse(buffer, callback));
48431
- return new Promise((resolve) => stream.on("end", () => resolve()));
48389
+ return new Promise((resolve2) => stream.on("end", () => resolve2()));
48432
48390
  }
48433
48391
  exports.parse = parse;
48434
48392
  }
@@ -48746,12 +48704,12 @@ var require_client2 = __commonJS({
48746
48704
  this._connect(callback);
48747
48705
  return;
48748
48706
  }
48749
- return new this._Promise((resolve, reject) => {
48707
+ return new this._Promise((resolve2, reject) => {
48750
48708
  this._connect((error2) => {
48751
48709
  if (error2) {
48752
48710
  reject(error2);
48753
48711
  } else {
48754
- resolve();
48712
+ resolve2();
48755
48713
  }
48756
48714
  });
48757
48715
  });
@@ -49037,8 +48995,8 @@ var require_client2 = __commonJS({
49037
48995
  readTimeout = this.connectionParameters.query_timeout;
49038
48996
  query = new Query(config, values, callback);
49039
48997
  if (!query.callback) {
49040
- result = new this._Promise((resolve, reject) => {
49041
- query.callback = (err2, res) => err2 ? reject(err2) : resolve(res);
48998
+ result = new this._Promise((resolve2, reject) => {
48999
+ query.callback = (err2, res) => err2 ? reject(err2) : resolve2(res);
49042
49000
  });
49043
49001
  }
49044
49002
  }
@@ -49108,8 +49066,8 @@ var require_client2 = __commonJS({
49108
49066
  if (cb) {
49109
49067
  this.connection.once("end", cb);
49110
49068
  } else {
49111
- return new this._Promise((resolve) => {
49112
- this.connection.once("end", resolve);
49069
+ return new this._Promise((resolve2) => {
49070
+ this.connection.once("end", resolve2);
49113
49071
  });
49114
49072
  }
49115
49073
  }
@@ -49154,8 +49112,8 @@ var require_pg_pool = __commonJS({
49154
49112
  const cb = function(err2, client) {
49155
49113
  err2 ? rej(err2) : res(client);
49156
49114
  };
49157
- const result = new Promise2(function(resolve, reject) {
49158
- res = resolve;
49115
+ const result = new Promise2(function(resolve2, reject) {
49116
+ res = resolve2;
49159
49117
  rej = reject;
49160
49118
  });
49161
49119
  return { callback: cb, result };
@@ -49559,8 +49517,8 @@ var require_query4 = __commonJS({
49559
49517
  if (this._promise)
49560
49518
  return this._promise;
49561
49519
  this._promise = new Promise(
49562
- function(resolve, reject) {
49563
- this._once("end", resolve);
49520
+ function(resolve2, reject) {
49521
+ this._once("end", resolve2);
49564
49522
  this._once("error", reject);
49565
49523
  }.bind(this)
49566
49524
  );
@@ -49725,12 +49683,12 @@ var require_client3 = __commonJS({
49725
49683
  this._connect(callback);
49726
49684
  return;
49727
49685
  }
49728
- return new this._Promise((resolve, reject) => {
49686
+ return new this._Promise((resolve2, reject) => {
49729
49687
  this._connect((error2) => {
49730
49688
  if (error2) {
49731
49689
  reject(error2);
49732
49690
  } else {
49733
- resolve();
49691
+ resolve2();
49734
49692
  }
49735
49693
  });
49736
49694
  });
@@ -49754,8 +49712,8 @@ var require_client3 = __commonJS({
49754
49712
  query = new NativeQuery(config, values, callback);
49755
49713
  if (!query.callback) {
49756
49714
  let resolveOut, rejectOut;
49757
- result = new this._Promise((resolve, reject) => {
49758
- resolveOut = resolve;
49715
+ result = new this._Promise((resolve2, reject) => {
49716
+ resolveOut = resolve2;
49759
49717
  rejectOut = reject;
49760
49718
  });
49761
49719
  query.callback = (err2, res) => err2 ? rejectOut(err2) : resolveOut(res);
@@ -49808,8 +49766,8 @@ var require_client3 = __commonJS({
49808
49766
  }
49809
49767
  var result;
49810
49768
  if (!cb) {
49811
- result = new this._Promise(function(resolve, reject) {
49812
- cb = (err2) => err2 ? reject(err2) : resolve();
49769
+ result = new this._Promise(function(resolve2, reject) {
49770
+ cb = (err2) => err2 ? reject(err2) : resolve2();
49813
49771
  });
49814
49772
  }
49815
49773
  this.native.end(function() {
@@ -50428,7 +50386,7 @@ __export(pgIntrospect_exports, {
50428
50386
  PgConfig2: () => PgConfig2,
50429
50387
  pgIntrospect: () => pgIntrospect
50430
50388
  });
50431
- var import_hanji5, import_pg, PgConfig1, PgConfig2, Conf2, pgIntrospect;
50389
+ var import_hanji5, import_pg, PgConfig1, PgConfig2, Conf, pgIntrospect;
50432
50390
  var init_pgIntrospect = __esm({
50433
50391
  "src/cli/commands/pgIntrospect.ts"() {
50434
50392
  import_hanji5 = __toESM(require_hanji());
@@ -50449,7 +50407,7 @@ var init_pgIntrospect = __esm({
50449
50407
  PgConfig2 = objectType({
50450
50408
  connectionString: stringType()
50451
50409
  }).strict();
50452
- Conf2 = unionType([PgConfig1, PgConfig2]);
50410
+ Conf = unionType([PgConfig1, PgConfig2]);
50453
50411
  pgIntrospect = async (config) => {
50454
50412
  const pool = new import_pg.Pool(config);
50455
50413
  const progress = new IntrospectProgress();
@@ -50469,8 +50427,7 @@ var init_pgIntrospect = __esm({
50469
50427
  // src/cli/index.ts
50470
50428
  var cli_exports = {};
50471
50429
  __export(cli_exports, {
50472
- checkSchema: () => checkSchema,
50473
- configSchema: () => configSchema
50430
+ checkSchema: () => checkSchema
50474
50431
  });
50475
50432
  module.exports = __toCommonJS(cli_exports);
50476
50433
 
@@ -50491,7 +50448,7 @@ var {
50491
50448
  } = import_index.default;
50492
50449
 
50493
50450
  // src/cli/index.ts
50494
- var import_fs10 = __toESM(require("fs"));
50451
+ var import_fs11 = require("fs");
50495
50452
  init_lib();
50496
50453
 
50497
50454
  // src/cli/commands/check.ts
@@ -50533,8 +50490,7 @@ var checkHandler = (out, dialect6) => {
50533
50490
 
50534
50491
  // src/cli/index.ts
50535
50492
  var import_hanji6 = __toESM(require_hanji());
50536
- init_views();
50537
- var import_path6 = __toESM(require("path"));
50493
+ var import_path7 = __toESM(require("path"));
50538
50494
 
50539
50495
  // src/cli/utils.ts
50540
50496
  init_views();
@@ -50610,9 +50566,10 @@ var package_default = {
50610
50566
  sim: "node -r esbuild-register ./dev/simulate.ts",
50611
50567
  "sim:sqlite": "node -r esbuild-register ./dev/sqlite/index.ts",
50612
50568
  test: "ava test --timeout=60s",
50613
- build: "pnpm build:cli && pnpm build:utils",
50569
+ build: "pnpm build:cli && pnpm build:utils && pnpm build:cli-types",
50614
50570
  "build:cli": "esbuild ./src/cli/index.ts --bundle --platform=node --target=node10.4 --outfile=./dist/index.js --external:esbuild --external:drizzle-orm-pg --external:drizzle-orm-sqlite --external:drizzle-orm-mysql --external:drizzle-orm --external:pg-native",
50615
50571
  "build:utils": "esbuild ./src/utils.ts --bundle --platform=node --target=node10.4 --outfile=./dist/utils.js",
50572
+ "build:cli-types": "tsc -p tsconfig.cli-types.json",
50616
50573
  pack: "build && package",
50617
50574
  tsc: "tsc -p tsconfig.build.json",
50618
50575
  pub: "cp package.json readme.md dist/ && cd dist && npm publish"
@@ -50652,7 +50609,7 @@ var package_default = {
50652
50609
  dockerode: "^3.3.4",
50653
50610
  dotenv: "^16.0.3",
50654
50611
  "drizzle-kit": "^0.16.8",
50655
- "drizzle-orm": "0.23.2-e17a5ba",
50612
+ "drizzle-orm": "0.23.2",
50656
50613
  esbuild: "^0.15.7",
50657
50614
  "esbuild-register": "^3.3.3",
50658
50615
  eslint: "^8.29.0",
@@ -50751,24 +50708,107 @@ var dropMigration = async (out) => {
50751
50708
  console.log(`[${source_default.green("\u2713")}] ${source_default.bold(result.data.tag)} migration successfully dropped`);
50752
50709
  };
50753
50710
 
50711
+ // src/cli/commands/utils.ts
50712
+ init_serializer();
50713
+ init_lib();
50714
+ var import_path6 = require("path");
50715
+ init_source();
50716
+ var import_fs10 = require("fs");
50717
+ init_views();
50718
+ var prepareGenerateConfig = (options) => {
50719
+ var _a;
50720
+ const { schema: schema4, out, config, breakpoints, custom } = options;
50721
+ if (!(schema4 || out)) {
50722
+ const drizzleConfig = drizzleConfigFromFile(config);
50723
+ if (!drizzleConfig.out) {
50724
+ console.log("You must specify 'out' param in config file");
50725
+ process.exit(1);
50726
+ }
50727
+ return {
50728
+ custom,
50729
+ breakpoints: (_a = drizzleConfig.breakpoints) != null ? _a : false,
50730
+ schema: drizzleConfig.schema,
50731
+ out: drizzleConfig.out
50732
+ };
50733
+ }
50734
+ if (!schema4) {
50735
+ console.error(`'schema' param must be set`);
50736
+ process.exit(1);
50737
+ }
50738
+ if (!out) {
50739
+ console.error(`'out' param must be set`);
50740
+ process.exit(1);
50741
+ }
50742
+ return { schema: schema4, out, breakpoints, custom };
50743
+ };
50744
+ var assertOutFolder = (it) => {
50745
+ if ("out" in it)
50746
+ return it.out;
50747
+ const cliConfig = drizzleConfigFromFile(it.config);
50748
+ if (!cliConfig.out) {
50749
+ console.log(
50750
+ error(
50751
+ `'out' folder param must be set through '--out' param or in config file`
50752
+ )
50753
+ );
50754
+ process.exit(0);
50755
+ }
50756
+ return cliConfig.out;
50757
+ };
50758
+ var configCommonSchema = objectType({
50759
+ schema: unionType([stringType(), stringType().array()]),
50760
+ out: stringType().optional(),
50761
+ breakpoints: booleanType().optional(),
50762
+ tablesFilter: unionType([stringType(), stringType().array()]).optional()
50763
+ });
50764
+ var mysqlConnectionSchema = unionType([
50765
+ objectType({
50766
+ host: stringType(),
50767
+ port: coerce.number().optional(),
50768
+ user: stringType().default("mysql"),
50769
+ password: stringType().optional(),
50770
+ database: stringType()
50771
+ }),
50772
+ objectType({
50773
+ connectionString: stringType()
50774
+ }),
50775
+ objectType({})
50776
+ ]);
50777
+ var mySqlCliConfigSchema = intersectionType(
50778
+ configCommonSchema,
50779
+ mysqlConnectionSchema
50780
+ );
50781
+ var drizzleConfigFromFile = (configPath) => {
50782
+ var _a;
50783
+ if (!configPath) {
50784
+ console.log(
50785
+ source_default.gray("No config path provided, using default 'drizzle.config.json'")
50786
+ );
50787
+ }
50788
+ const path3 = (0, import_path6.join)((0, import_path6.resolve)(configPath != null ? configPath : "drizzle.config.json"));
50789
+ if (!(0, import_fs10.existsSync)(path3)) {
50790
+ console.log(`${path3} file does not exist`);
50791
+ process.exit(1);
50792
+ }
50793
+ console.log(source_default.grey(`Reading config file '${path3}'`));
50794
+ const { unregister } = safeRegister();
50795
+ const required = require(path3);
50796
+ const content = (_a = required.default) != null ? _a : required;
50797
+ unregister();
50798
+ const res = mySqlCliConfigSchema.safeParse(content);
50799
+ if (!res.success) {
50800
+ console.error(res.error);
50801
+ console.log("Missing required params");
50802
+ process.exit(1);
50803
+ }
50804
+ return res.data;
50805
+ };
50806
+
50754
50807
  // src/cli/index.ts
50755
50808
  var printVersions = () => {
50756
50809
  console.log(`${source_default.gray(versions())}
50757
50810
  `);
50758
50811
  };
50759
- var assertEitherConfigOrOut = (config, out) => {
50760
- if (out)
50761
- return out;
50762
- if (!(0, import_fs10.existsSync)(import_path6.default.join(import_path6.default.resolve(config)))) {
50763
- console.log(`${config} file does not exist`);
50764
- process.exit(1);
50765
- }
50766
- console.log(`Reading ${config}`);
50767
- const drizzleConfig = JSON.parse(
50768
- import_fs10.default.readFileSync(import_path6.default.join(import_path6.default.resolve(config))).toString()
50769
- );
50770
- return drizzleConfig.out;
50771
- };
50772
50812
  var versions = () => {
50773
50813
  const { npmVersion } = ormCoreVersions();
50774
50814
  const ormVersion = npmVersion ? `
@@ -50776,12 +50816,6 @@ drizzle-orm: v${npmVersion}` : "";
50776
50816
  const versions2 = `drizzle-kit: v${package_default.version}${ormVersion}`;
50777
50817
  return versions2;
50778
50818
  };
50779
- var configSchema = objectType({
50780
- schema: unionType([stringType(), stringType().array()]),
50781
- out: stringType().default("drizzle"),
50782
- breakpoints: booleanType(),
50783
- custom: booleanType()
50784
- }).strict();
50785
50819
  var optionsSchema = objectType({
50786
50820
  schema: unionType([stringType(), stringType().array()]).optional(),
50787
50821
  out: stringType().optional(),
@@ -50789,9 +50823,6 @@ var optionsSchema = objectType({
50789
50823
  breakpoints: booleanType().optional().default(false),
50790
50824
  custom: booleanType().optional().default(false)
50791
50825
  }).strict();
50792
- var pushOptionsSchema = objectType({
50793
- config: stringType().optional()
50794
- }).strict();
50795
50826
  var generatePgCommand = new Command("generate:pg").option("--schema <schema...>", "Path to a schema file or folder").option("--out <out>", `Output folder, 'drizzle' by default`).option("--breakpoints", `Prepare SQL statements with breakpoints`).option("--custom", "Prepare empty migration file for custom SQL").option(
50796
50827
  "--config <config>",
50797
50828
  "Path to a config.json file, drizzle.config.json by default"
@@ -50800,10 +50831,6 @@ var generatePgCommand = new Command("generate:pg").option("--schema <schema...>"
50800
50831
  assertOrmCoreVersion();
50801
50832
  const oprtionsParsed = optionsSchema.parse(options);
50802
50833
  const result = prepareGenerateConfig(oprtionsParsed);
50803
- if (result instanceof Error) {
50804
- console.error(result);
50805
- return;
50806
- }
50807
50834
  assertPackages("drizzle-orm");
50808
50835
  const { prepareAndMigratePg: prepareAndMigratePg2 } = (init_migrate(), __toCommonJS(migrate_exports));
50809
50836
  await prepareAndMigratePg2(result);
@@ -50816,10 +50843,6 @@ var generateMysqlCommand = new Command("generate:mysql").option("--schema <schem
50816
50843
  assertOrmCoreVersion();
50817
50844
  const oprtionsParsed = optionsSchema.parse(options);
50818
50845
  const result = prepareGenerateConfig(oprtionsParsed);
50819
- if (result instanceof Error) {
50820
- console.error(result);
50821
- return;
50822
- }
50823
50846
  assertPackages("drizzle-orm");
50824
50847
  const { prepareAndMigrateMySql: prepareAndMigrateMySql2 } = (init_migrate(), __toCommonJS(migrate_exports));
50825
50848
  await prepareAndMigrateMySql2(result);
@@ -50828,30 +50851,18 @@ var dbPushMysqlCommand = new Command("push:mysql").option(
50828
50851
  "--config <config>",
50829
50852
  "Path to a config.json file, drizzle.config.json by default"
50830
50853
  ).action(async (options) => {
50831
- var _a;
50832
50854
  printVersions();
50833
50855
  assertPackages("drizzle-orm");
50834
50856
  assertOrmCoreVersion();
50835
- const { mysqlPushIntrospect: mysqlPushIntrospect2, connectToMySQL: connectToMySQL2, configPushSchema: configPushSchema2 } = (init_mysqlIntrospect(), __toCommonJS(mysqlIntrospect_exports));
50836
- const path3 = (_a = options.config) != null ? _a : "drizzle.config.json";
50837
- const drizzleConfig = JSON.parse(
50838
- import_fs10.default.readFileSync(import_path6.default.join(import_path6.default.resolve(path3))).toString()
50839
- );
50840
- const res = configPushSchema2.safeParse(drizzleConfig);
50841
- if (!res.success) {
50842
- console.log("Missing required params");
50843
- return;
50844
- }
50845
- const connection = await connectToMySQL2(res.data);
50846
- const filterConfig = res.data.tablesFilter;
50857
+ const { mysqlPushIntrospect: mysqlPushIntrospect2, connectToMySQL: connectToMySQL2 } = (init_mysqlIntrospect(), __toCommonJS(mysqlIntrospect_exports));
50858
+ const drizzleConfig = drizzleConfigFromFile(options.config);
50859
+ const connection = await connectToMySQL2(drizzleConfig);
50860
+ const filterConfig = drizzleConfig.tablesFilter;
50847
50861
  const tablesFilter = filterConfig ? typeof filterConfig === "string" ? [filterConfig] : filterConfig : [];
50848
- const { schema: schema4 } = await mysqlPushIntrospect2(
50849
- connection,
50850
- tablesFilter
50851
- );
50862
+ const { schema: schema4 } = await mysqlPushIntrospect2(connection, tablesFilter);
50852
50863
  const { prepareMySQLPush: prepareMySQLPush2 } = (init_migrate(), __toCommonJS(migrate_exports));
50853
50864
  const statements = await prepareMySQLPush2(
50854
- { schema: res.data.schema },
50865
+ { schema: drizzleConfig.schema },
50855
50866
  schema4
50856
50867
  );
50857
50868
  try {
@@ -50878,41 +50889,19 @@ var generateSqliteCommand = new Command("generate:sqlite").option("--schema <sch
50878
50889
  assertOrmCoreVersion();
50879
50890
  const oprtionsParsed = optionsSchema.parse(options);
50880
50891
  const result = prepareGenerateConfig(oprtionsParsed);
50881
- if (result instanceof Error) {
50882
- console.error(result);
50883
- return;
50884
- }
50885
50892
  assertPackages("drizzle-orm");
50886
50893
  const { prepareAndMigrateSqlite: prepareAndMigrateSqlite2 } = (init_migrate(), __toCommonJS(migrate_exports));
50887
50894
  await prepareAndMigrateSqlite2(result);
50888
50895
  });
50889
- var prepareGenerateConfig = (options) => {
50890
- const { schema: schema4, out, config, breakpoints, custom } = options;
50891
- if (!(schema4 || out)) {
50892
- const path3 = config != null ? config : "drizzle.config.json";
50893
- const drizzleConfig = JSON.parse(
50894
- import_fs10.default.readFileSync(import_path6.default.join(import_path6.default.resolve(path3))).toString()
50895
- );
50896
- return drizzleConfig;
50897
- }
50898
- if (!schema4) {
50899
- return new Error(`'schema' param must be set`);
50900
- }
50901
- return configSchema.parse({ schema: schema4, out, breakpoints, custom });
50902
- };
50903
- var checkSchema = objectType({
50904
- out: stringType().optional(),
50905
- config: stringType().default("drizzle.config.json")
50906
- }).strict();
50896
+ var checkSchema = unionType([
50897
+ objectType({ out: stringType() }),
50898
+ objectType({ config: stringType().optional() })
50899
+ ]);
50907
50900
  var checkPgCommand = new Command("check:pg").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.json]`).action((options) => {
50908
50901
  printVersions();
50909
50902
  assertOrmCoreVersion();
50910
50903
  const params = checkSchema.parse(options);
50911
- const out = assertEitherConfigOrOut(params.config, params.out);
50912
- if (!out) {
50913
- console.log(error(`'out' folder param must be set`));
50914
- process.exit(0);
50915
- }
50904
+ const out = assertOutFolder(params);
50916
50905
  checkHandler(out, "pg");
50917
50906
  console.log("Everything's fine \u{1F436}\u{1F525}");
50918
50907
  });
@@ -50920,11 +50909,7 @@ var checkSqliteCommand = new Command("check:sqlite").option("--out <out>", `Outp
50920
50909
  printVersions();
50921
50910
  assertOrmCoreVersion();
50922
50911
  const params = checkSchema.parse(options);
50923
- const out = assertEitherConfigOrOut(params.config, params.out);
50924
- if (!out) {
50925
- console.log(error(`'out' folder param must be set`));
50926
- process.exit(0);
50927
- }
50912
+ const out = assertOutFolder(params);
50928
50913
  checkHandler(out, "sqlite");
50929
50914
  console.log("Everything's fine \u{1F436}\u{1F525}");
50930
50915
  });
@@ -50932,15 +50917,7 @@ var upPgCommand = new Command("up:pg").option("--out <out>", `Output folder`).op
50932
50917
  printVersions();
50933
50918
  assertOrmCoreVersion();
50934
50919
  const params = checkSchema.parse(options);
50935
- const out = assertEitherConfigOrOut(params.config, params.out);
50936
- if (!out) {
50937
- console.log(
50938
- error(
50939
- `'out' folder param must be set through '--out' param or in config file`
50940
- )
50941
- );
50942
- process.exit(0);
50943
- }
50920
+ const out = assertOutFolder(params);
50944
50921
  assertPackages("drizzle-orm");
50945
50922
  upPgHandlerV4(out);
50946
50923
  upgradeFolders("pg", out);
@@ -50950,19 +50927,7 @@ var upMysqlCommand = new Command("up:mysql").option("--out <out>", `Output folde
50950
50927
  printVersions();
50951
50928
  assertOrmCoreVersion();
50952
50929
  const params = checkSchema.parse(options);
50953
- const out = assertEitherConfigOrOut(params.config, params.out);
50954
- if (!out) {
50955
- console.log(
50956
- error(
50957
- `'out' folder param must be set through '--out' param or in config file`
50958
- )
50959
- );
50960
- process.exit(0);
50961
- }
50962
- if (!out) {
50963
- console.log(error(`'out' folder param must be set`));
50964
- process.exit(0);
50965
- }
50930
+ const out = assertOutFolder(params);
50966
50931
  assertPackages("drizzle-orm");
50967
50932
  upMysqlHandlerV4(out);
50968
50933
  upgradeFolders("mysql", out);
@@ -50972,11 +50937,7 @@ var upSqliteCommand = new Command("up:sqlite").option("--out <out>", `Output fol
50972
50937
  printVersions();
50973
50938
  assertOrmCoreVersion();
50974
50939
  const params = checkSchema.parse(options);
50975
- const out = assertEitherConfigOrOut(params.config, params.out);
50976
- if (!out) {
50977
- console.log(error(`'out' folder param must be set`));
50978
- process.exit(0);
50979
- }
50940
+ const out = assertOutFolder(params);
50980
50941
  upSqliteHandlerV4(out);
50981
50942
  upgradeFolders("sqlite", out);
50982
50943
  upSqliteHandler(out);
@@ -51001,8 +50962,8 @@ var introspectPgCommand = new Command("introspect:pg").option("--out <out>", `Mi
51001
50962
  }
51002
50963
  const { snapshots, journal } = prepareOutFolder2(res.data.out, "pg");
51003
50964
  const { schema: schema4, ts } = await pgIntrospect2(res.data);
51004
- const schemaFile = import_path6.default.join(res.data.out, "schema.ts");
51005
- (0, import_fs10.writeFileSync)(schemaFile, ts);
50965
+ const schemaFile = import_path7.default.join(res.data.out, "schema.ts");
50966
+ (0, import_fs11.writeFileSync)(schemaFile, ts);
51006
50967
  console.log();
51007
50968
  if (snapshots.length === 0) {
51008
50969
  const { sqlStatements, _meta } = await prepareSQL(
@@ -51045,20 +51006,17 @@ var introspectMySqlCommand = new Command("introspect:mysql").option(
51045
51006
  printVersions();
51046
51007
  assertPackages("drizzle-orm");
51047
51008
  assertOrmCoreVersion();
51048
- const { mysqlIntrospect: mysqlIntrospect2, configIntrospectSchema: configIntrospectSchema2 } = (init_mysqlIntrospect(), __toCommonJS(mysqlIntrospect_exports));
51049
- const path3 = (_a = options.config) != null ? _a : "drizzle.config.json";
51050
- const drizzleConfig = JSON.parse(
51051
- import_fs10.default.readFileSync(import_path6.default.join(import_path6.default.resolve(path3))).toString()
51052
- );
51053
- const res = configIntrospectSchema2.safeParse(drizzleConfig);
51054
- if (!res.success) {
51055
- console.log("Missing required params");
51056
- return;
51009
+ const { mysqlIntrospect: mysqlIntrospect2 } = (init_mysqlIntrospect(), __toCommonJS(mysqlIntrospect_exports));
51010
+ const drizzleConfig = drizzleConfigFromFile(options.config);
51011
+ if (!drizzleConfig.out) {
51012
+ console.log("You must specify 'out' path in your config file");
51013
+ process.exit(1);
51057
51014
  }
51058
- const { snapshots, journal } = prepareOutFolder2(res.data.out, "mysql");
51059
- const { schema: schema4, ts } = await mysqlIntrospect2(res.data);
51060
- const schemaFile = import_path6.default.join(res.data.out, "schema.ts");
51061
- (0, import_fs10.writeFileSync)(schemaFile, ts);
51015
+ const out = drizzleConfig.out;
51016
+ const { snapshots, journal } = prepareOutFolder2(out, "mysql");
51017
+ const { schema: schema4, ts } = await mysqlIntrospect2(drizzleConfig);
51018
+ const schemaFile = import_path7.default.join(out, "schema.ts");
51019
+ (0, import_fs11.writeFileSync)(schemaFile, ts);
51062
51020
  console.log();
51063
51021
  if (snapshots.length === 0) {
51064
51022
  const { sqlStatements, _meta } = await prepareSQL(
@@ -51073,8 +51031,8 @@ var introspectMySqlCommand = new Command("introspect:mysql").option(
51073
51031
  sqlStatements,
51074
51032
  journal,
51075
51033
  _meta,
51076
- res.data.out,
51077
- res.data.breakpoints,
51034
+ out,
51035
+ (_a = drizzleConfig.breakpoints) != null ? _a : false,
51078
51036
  "introspect"
51079
51037
  );
51080
51038
  } else {
@@ -51097,11 +51055,7 @@ var dropCommand = new Command("drop").option("--out <out>", `Output folder`).opt
51097
51055
  printVersions();
51098
51056
  assertOrmCoreVersion();
51099
51057
  const params = checkSchema.parse(options);
51100
- const out = assertEitherConfigOrOut(params.config, params.out);
51101
- if (!out) {
51102
- console.log(error(`'out' folder param must be set`));
51103
- process.exit(0);
51104
- }
51058
+ const out = assertOutFolder(params);
51105
51059
  assertV1OutFolder(out, "{dialect}");
51106
51060
  dropMigration(out);
51107
51061
  });
@@ -51121,6 +51075,5 @@ program.addCommand(dbPushMysqlCommand);
51121
51075
  program.parse();
51122
51076
  // Annotate the CommonJS export names for ESM import in node:
51123
51077
  0 && (module.exports = {
51124
- checkSchema,
51125
- configSchema
51078
+ checkSchema
51126
51079
  });