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

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 +275 -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);
@@ -42014,7 +42014,7 @@ var require_named_placeholders = __commonJS({
42014
42014
  }
42015
42015
  return s;
42016
42016
  }
42017
- function join5(tree) {
42017
+ function join6(tree) {
42018
42018
  if (tree.length == 1) {
42019
42019
  return tree;
42020
42020
  }
@@ -42040,7 +42040,7 @@ var require_named_placeholders = __commonJS({
42040
42040
  if (cache && (tree = cache.get(query))) {
42041
42041
  return toArrayParams(tree, paramsObj);
42042
42042
  }
42043
- tree = join5(parse(query));
42043
+ tree = join6(parse(query));
42044
42044
  if (cache) {
42045
42045
  cache.set(query, tree);
42046
42046
  }
@@ -43460,7 +43460,7 @@ var require_promise2 = __commonJS({
43460
43460
  "use strict";
43461
43461
  var core = require_mysql2();
43462
43462
  var EventEmitter = require("events").EventEmitter;
43463
- function makeDoneCb(resolve, reject, localErr) {
43463
+ function makeDoneCb(resolve2, reject, localErr) {
43464
43464
  return function(err2, rows, fields) {
43465
43465
  if (err2) {
43466
43466
  localErr.message = err2.message;
@@ -43471,7 +43471,7 @@ var require_promise2 = __commonJS({
43471
43471
  localErr.sqlMessage = err2.sqlMessage;
43472
43472
  reject(localErr);
43473
43473
  } else {
43474
- resolve([rows, fields]);
43474
+ resolve2([rows, fields]);
43475
43475
  }
43476
43476
  };
43477
43477
  }
@@ -43503,8 +43503,8 @@ var require_promise2 = __commonJS({
43503
43503
  execute(parameters) {
43504
43504
  const s = this.statement;
43505
43505
  const localErr = new Error();
43506
- return new this.Promise((resolve, reject) => {
43507
- const done = makeDoneCb(resolve, reject, localErr);
43506
+ return new this.Promise((resolve2, reject) => {
43507
+ const done = makeDoneCb(resolve2, reject, localErr);
43508
43508
  if (parameters) {
43509
43509
  s.execute(parameters, done);
43510
43510
  } else {
@@ -43513,9 +43513,9 @@ var require_promise2 = __commonJS({
43513
43513
  });
43514
43514
  }
43515
43515
  close() {
43516
- return new this.Promise((resolve) => {
43516
+ return new this.Promise((resolve2) => {
43517
43517
  this.statement.close();
43518
- resolve();
43518
+ resolve2();
43519
43519
  });
43520
43520
  }
43521
43521
  };
@@ -43543,8 +43543,8 @@ var require_promise2 = __commonJS({
43543
43543
  "Callback function is not available with promise clients."
43544
43544
  );
43545
43545
  }
43546
- return new this.Promise((resolve, reject) => {
43547
- const done = makeDoneCb(resolve, reject, localErr);
43546
+ return new this.Promise((resolve2, reject) => {
43547
+ const done = makeDoneCb(resolve2, reject, localErr);
43548
43548
  if (params !== void 0) {
43549
43549
  c.query(query, params, done);
43550
43550
  } else {
@@ -43560,8 +43560,8 @@ var require_promise2 = __commonJS({
43560
43560
  "Callback function is not available with promise clients."
43561
43561
  );
43562
43562
  }
43563
- return new this.Promise((resolve, reject) => {
43564
- const done = makeDoneCb(resolve, reject, localErr);
43563
+ return new this.Promise((resolve2, reject) => {
43564
+ const done = makeDoneCb(resolve2, reject, localErr);
43565
43565
  if (params !== void 0) {
43566
43566
  c.execute(query, params, done);
43567
43567
  } else {
@@ -43570,46 +43570,46 @@ var require_promise2 = __commonJS({
43570
43570
  });
43571
43571
  }
43572
43572
  end() {
43573
- return new this.Promise((resolve) => {
43574
- this.connection.end(resolve);
43573
+ return new this.Promise((resolve2) => {
43574
+ this.connection.end(resolve2);
43575
43575
  });
43576
43576
  }
43577
43577
  beginTransaction() {
43578
43578
  const c = this.connection;
43579
43579
  const localErr = new Error();
43580
- return new this.Promise((resolve, reject) => {
43581
- const done = makeDoneCb(resolve, reject, localErr);
43580
+ return new this.Promise((resolve2, reject) => {
43581
+ const done = makeDoneCb(resolve2, reject, localErr);
43582
43582
  c.beginTransaction(done);
43583
43583
  });
43584
43584
  }
43585
43585
  commit() {
43586
43586
  const c = this.connection;
43587
43587
  const localErr = new Error();
43588
- return new this.Promise((resolve, reject) => {
43589
- const done = makeDoneCb(resolve, reject, localErr);
43588
+ return new this.Promise((resolve2, reject) => {
43589
+ const done = makeDoneCb(resolve2, reject, localErr);
43590
43590
  c.commit(done);
43591
43591
  });
43592
43592
  }
43593
43593
  rollback() {
43594
43594
  const c = this.connection;
43595
43595
  const localErr = new Error();
43596
- return new this.Promise((resolve, reject) => {
43597
- const done = makeDoneCb(resolve, reject, localErr);
43596
+ return new this.Promise((resolve2, reject) => {
43597
+ const done = makeDoneCb(resolve2, reject, localErr);
43598
43598
  c.rollback(done);
43599
43599
  });
43600
43600
  }
43601
43601
  ping() {
43602
43602
  const c = this.connection;
43603
43603
  const localErr = new Error();
43604
- return new this.Promise((resolve, reject) => {
43605
- const done = makeDoneCb(resolve, reject, localErr);
43604
+ return new this.Promise((resolve2, reject) => {
43605
+ const done = makeDoneCb(resolve2, reject, localErr);
43606
43606
  c.ping(done);
43607
43607
  });
43608
43608
  }
43609
43609
  connect() {
43610
43610
  const c = this.connection;
43611
43611
  const localErr = new Error();
43612
- return new this.Promise((resolve, reject) => {
43612
+ return new this.Promise((resolve2, reject) => {
43613
43613
  c.connect((err2, param) => {
43614
43614
  if (err2) {
43615
43615
  localErr.message = err2.message;
@@ -43619,7 +43619,7 @@ var require_promise2 = __commonJS({
43619
43619
  localErr.sqlMessage = err2.sqlMessage;
43620
43620
  reject(localErr);
43621
43621
  } else {
43622
- resolve(param);
43622
+ resolve2(param);
43623
43623
  }
43624
43624
  });
43625
43625
  });
@@ -43628,7 +43628,7 @@ var require_promise2 = __commonJS({
43628
43628
  const c = this.connection;
43629
43629
  const promiseImpl = this.Promise;
43630
43630
  const localErr = new Error();
43631
- return new this.Promise((resolve, reject) => {
43631
+ return new this.Promise((resolve2, reject) => {
43632
43632
  c.prepare(options, (err2, statement) => {
43633
43633
  if (err2) {
43634
43634
  localErr.message = err2.message;
@@ -43642,7 +43642,7 @@ var require_promise2 = __commonJS({
43642
43642
  statement,
43643
43643
  promiseImpl
43644
43644
  );
43645
- resolve(wrappedStatement);
43645
+ resolve2(wrappedStatement);
43646
43646
  }
43647
43647
  });
43648
43648
  });
@@ -43650,7 +43650,7 @@ var require_promise2 = __commonJS({
43650
43650
  changeUser(options) {
43651
43651
  const c = this.connection;
43652
43652
  const localErr = new Error();
43653
- return new this.Promise((resolve, reject) => {
43653
+ return new this.Promise((resolve2, reject) => {
43654
43654
  c.changeUser(options, (err2) => {
43655
43655
  if (err2) {
43656
43656
  localErr.message = err2.message;
@@ -43660,7 +43660,7 @@ var require_promise2 = __commonJS({
43660
43660
  localErr.sqlMessage = err2.sqlMessage;
43661
43661
  reject(localErr);
43662
43662
  } else {
43663
- resolve();
43663
+ resolve2();
43664
43664
  }
43665
43665
  });
43666
43666
  });
@@ -43681,9 +43681,9 @@ var require_promise2 = __commonJS({
43681
43681
  "no Promise implementation available.Use promise-enabled node version or pass userland Promise implementation as parameter, for example: { Promise: require('bluebird') }"
43682
43682
  );
43683
43683
  }
43684
- return new thePromise((resolve, reject) => {
43684
+ return new thePromise((resolve2, reject) => {
43685
43685
  coreConnection.once("connect", () => {
43686
- resolve(new PromiseConnection(coreConnection, thePromise));
43686
+ resolve2(new PromiseConnection(coreConnection, thePromise));
43687
43687
  });
43688
43688
  coreConnection.once("error", (err2) => {
43689
43689
  createConnectionErr.message = err2.message;
@@ -43740,12 +43740,12 @@ var require_promise2 = __commonJS({
43740
43740
  }
43741
43741
  getConnection() {
43742
43742
  const corePool = this.pool;
43743
- return new this.Promise((resolve, reject) => {
43743
+ return new this.Promise((resolve2, reject) => {
43744
43744
  corePool.getConnection((err2, coreConnection) => {
43745
43745
  if (err2) {
43746
43746
  reject(err2);
43747
43747
  } else {
43748
- resolve(new PromisePoolConnection(coreConnection, this.Promise));
43748
+ resolve2(new PromisePoolConnection(coreConnection, this.Promise));
43749
43749
  }
43750
43750
  });
43751
43751
  });
@@ -43758,8 +43758,8 @@ var require_promise2 = __commonJS({
43758
43758
  "Callback function is not available with promise clients."
43759
43759
  );
43760
43760
  }
43761
- return new this.Promise((resolve, reject) => {
43762
- const done = makeDoneCb(resolve, reject, localErr);
43761
+ return new this.Promise((resolve2, reject) => {
43762
+ const done = makeDoneCb(resolve2, reject, localErr);
43763
43763
  if (args !== void 0) {
43764
43764
  corePool.query(sql, args, done);
43765
43765
  } else {
@@ -43775,8 +43775,8 @@ var require_promise2 = __commonJS({
43775
43775
  "Callback function is not available with promise clients."
43776
43776
  );
43777
43777
  }
43778
- return new this.Promise((resolve, reject) => {
43779
- const done = makeDoneCb(resolve, reject, localErr);
43778
+ return new this.Promise((resolve2, reject) => {
43779
+ const done = makeDoneCb(resolve2, reject, localErr);
43780
43780
  if (args) {
43781
43781
  corePool.execute(sql, args, done);
43782
43782
  } else {
@@ -43787,7 +43787,7 @@ var require_promise2 = __commonJS({
43787
43787
  end() {
43788
43788
  const corePool = this.pool;
43789
43789
  const localErr = new Error();
43790
- return new this.Promise((resolve, reject) => {
43790
+ return new this.Promise((resolve2, reject) => {
43791
43791
  corePool.end((err2) => {
43792
43792
  if (err2) {
43793
43793
  localErr.message = err2.message;
@@ -43797,7 +43797,7 @@ var require_promise2 = __commonJS({
43797
43797
  localErr.sqlMessage = err2.sqlMessage;
43798
43798
  reject(localErr);
43799
43799
  } else {
43800
- resolve();
43800
+ resolve2();
43801
43801
  }
43802
43802
  });
43803
43803
  });
@@ -43838,12 +43838,12 @@ var require_promise2 = __commonJS({
43838
43838
  }
43839
43839
  getConnection() {
43840
43840
  const corePoolCluster = this.poolCluster;
43841
- return new this.Promise((resolve, reject) => {
43841
+ return new this.Promise((resolve2, reject) => {
43842
43842
  corePoolCluster.getConnection((err2, coreConnection) => {
43843
43843
  if (err2) {
43844
43844
  reject(err2);
43845
43845
  } else {
43846
- resolve(new PromisePoolConnection(coreConnection, this.Promise));
43846
+ resolve2(new PromisePoolConnection(coreConnection, this.Promise));
43847
43847
  }
43848
43848
  });
43849
43849
  });
@@ -43856,8 +43856,8 @@ var require_promise2 = __commonJS({
43856
43856
  "Callback function is not available with promise clients."
43857
43857
  );
43858
43858
  }
43859
- return new this.Promise((resolve, reject) => {
43860
- const done = makeDoneCb(resolve, reject, localErr);
43859
+ return new this.Promise((resolve2, reject) => {
43860
+ const done = makeDoneCb(resolve2, reject, localErr);
43861
43861
  corePoolCluster.query(sql, args, done);
43862
43862
  });
43863
43863
  }
@@ -43869,8 +43869,8 @@ var require_promise2 = __commonJS({
43869
43869
  "Callback function is not available with promise clients."
43870
43870
  );
43871
43871
  }
43872
- return new this.Promise((resolve, reject) => {
43873
- const done = makeDoneCb(resolve, reject, localErr);
43872
+ return new this.Promise((resolve2, reject) => {
43873
+ const done = makeDoneCb(resolve2, reject, localErr);
43874
43874
  corePoolCluster.execute(sql, args, done);
43875
43875
  });
43876
43876
  }
@@ -43883,7 +43883,7 @@ var require_promise2 = __commonJS({
43883
43883
  end() {
43884
43884
  const corePoolCluster = this.poolCluster;
43885
43885
  const localErr = new Error();
43886
- return new this.Promise((resolve, reject) => {
43886
+ return new this.Promise((resolve2, reject) => {
43887
43887
  corePoolCluster.end((err2) => {
43888
43888
  if (err2) {
43889
43889
  localErr.message = err2.message;
@@ -43893,7 +43893,7 @@ var require_promise2 = __commonJS({
43893
43893
  localErr.sqlMessage = err2.sqlMessage;
43894
43894
  reject(localErr);
43895
43895
  } else {
43896
- resolve();
43896
+ resolve2();
43897
43897
  }
43898
43898
  });
43899
43899
  });
@@ -45435,80 +45435,36 @@ var init_mjs = __esm({
45435
45435
  // src/cli/commands/mysqlIntrospect.ts
45436
45436
  var mysqlIntrospect_exports = {};
45437
45437
  __export(mysqlIntrospect_exports, {
45438
- MySQLConfig1: () => MySQLConfig1,
45439
- MySQLConfig2: () => MySQLConfig2,
45440
- configIntrospectSchema: () => configIntrospectSchema,
45441
- configPushSchema: () => configPushSchema,
45442
45438
  connectToMySQL: () => connectToMySQL,
45443
45439
  mysqlIntrospect: () => mysqlIntrospect,
45444
45440
  mysqlPushIntrospect: () => mysqlPushIntrospect
45445
45441
  });
45446
- var import_hanji4, import_promise, MySQLConfig1, MySQLConfig2, Conf, configPushSchema, configIntrospectSchema, connectToMySQL, mysqlIntrospect, mysqlPushIntrospect;
45442
+ var import_hanji4, import_promise, connectToMySQL, mysqlIntrospect, mysqlPushIntrospect;
45447
45443
  var init_mysqlIntrospect = __esm({
45448
45444
  "src/cli/commands/mysqlIntrospect.ts"() {
45449
45445
  import_hanji4 = __toESM(require_hanji());
45450
- init_lib();
45451
45446
  init_views();
45452
45447
  import_promise = __toESM(require_promise2());
45453
45448
  init_mysqlSerializer();
45454
45449
  init_mysql_introspect();
45455
45450
  init_global();
45456
45451
  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
45452
  connectToMySQL = async (config) => {
45501
45453
  let client;
45502
45454
  let databaseName;
45503
- if (typeof config.connectionString !== "undefined") {
45455
+ if ("connectionString" in config) {
45504
45456
  const connection = config.connectionString;
45505
45457
  client = await (0, import_promise.createConnection)(connection);
45506
45458
  const connectionUrl = new URL(connection);
45507
45459
  const pathname = connectionUrl.pathname;
45508
45460
  databaseName = pathname.split("/")[pathname.split("/").length - 1];
45509
- } else {
45461
+ } else if ("host" in config) {
45510
45462
  client = await (0, import_promise.createConnection)(config);
45511
45463
  databaseName = config.database;
45464
+ } else {
45465
+ throw Error(
45466
+ "Either `connectionString` or `host, port, etc.` params be provided in config file"
45467
+ );
45512
45468
  }
45513
45469
  await client.connect();
45514
45470
  return { client, databaseName };
@@ -47106,15 +47062,15 @@ var require_lib3 = __commonJS({
47106
47062
  "node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js"(exports, module2) {
47107
47063
  "use strict";
47108
47064
  var path3 = require("path");
47109
- var fs7 = require("fs");
47065
+ var fs6 = require("fs");
47110
47066
  var helper = require_helper();
47111
47067
  module2.exports = function(connInfo, cb) {
47112
47068
  var file = helper.getFileName();
47113
- fs7.stat(file, function(err2, stat) {
47069
+ fs6.stat(file, function(err2, stat) {
47114
47070
  if (err2 || !helper.usePgPass(stat, file)) {
47115
47071
  return cb(void 0);
47116
47072
  }
47117
- var st = fs7.createReadStream(file);
47073
+ var st = fs6.createReadStream(file);
47118
47074
  helper.getPassword(connInfo, st, cb);
47119
47075
  });
47120
47076
  };
@@ -47162,7 +47118,7 @@ var require_pg_connection_string = __commonJS({
47162
47118
  "node_modules/.pnpm/pg-connection-string@2.5.0/node_modules/pg-connection-string/index.js"(exports, module2) {
47163
47119
  "use strict";
47164
47120
  var url = require("url");
47165
- var fs7 = require("fs");
47121
+ var fs6 = require("fs");
47166
47122
  function parse(str) {
47167
47123
  if (str.charAt(0) === "/") {
47168
47124
  var config = str.split(" ");
@@ -47211,13 +47167,13 @@ var require_pg_connection_string = __commonJS({
47211
47167
  config.ssl = {};
47212
47168
  }
47213
47169
  if (config.sslcert) {
47214
- config.ssl.cert = fs7.readFileSync(config.sslcert).toString();
47170
+ config.ssl.cert = fs6.readFileSync(config.sslcert).toString();
47215
47171
  }
47216
47172
  if (config.sslkey) {
47217
- config.ssl.key = fs7.readFileSync(config.sslkey).toString();
47173
+ config.ssl.key = fs6.readFileSync(config.sslkey).toString();
47218
47174
  }
47219
47175
  if (config.sslrootcert) {
47220
- config.ssl.ca = fs7.readFileSync(config.sslrootcert).toString();
47176
+ config.ssl.ca = fs6.readFileSync(config.sslrootcert).toString();
47221
47177
  }
47222
47178
  switch (config.sslmode) {
47223
47179
  case "disable": {
@@ -48428,7 +48384,7 @@ var require_dist = __commonJS({
48428
48384
  function parse(stream, callback) {
48429
48385
  const parser = new parser_1.Parser();
48430
48386
  stream.on("data", (buffer) => parser.parse(buffer, callback));
48431
- return new Promise((resolve) => stream.on("end", () => resolve()));
48387
+ return new Promise((resolve2) => stream.on("end", () => resolve2()));
48432
48388
  }
48433
48389
  exports.parse = parse;
48434
48390
  }
@@ -48746,12 +48702,12 @@ var require_client2 = __commonJS({
48746
48702
  this._connect(callback);
48747
48703
  return;
48748
48704
  }
48749
- return new this._Promise((resolve, reject) => {
48705
+ return new this._Promise((resolve2, reject) => {
48750
48706
  this._connect((error2) => {
48751
48707
  if (error2) {
48752
48708
  reject(error2);
48753
48709
  } else {
48754
- resolve();
48710
+ resolve2();
48755
48711
  }
48756
48712
  });
48757
48713
  });
@@ -49037,8 +48993,8 @@ var require_client2 = __commonJS({
49037
48993
  readTimeout = this.connectionParameters.query_timeout;
49038
48994
  query = new Query(config, values, callback);
49039
48995
  if (!query.callback) {
49040
- result = new this._Promise((resolve, reject) => {
49041
- query.callback = (err2, res) => err2 ? reject(err2) : resolve(res);
48996
+ result = new this._Promise((resolve2, reject) => {
48997
+ query.callback = (err2, res) => err2 ? reject(err2) : resolve2(res);
49042
48998
  });
49043
48999
  }
49044
49000
  }
@@ -49108,8 +49064,8 @@ var require_client2 = __commonJS({
49108
49064
  if (cb) {
49109
49065
  this.connection.once("end", cb);
49110
49066
  } else {
49111
- return new this._Promise((resolve) => {
49112
- this.connection.once("end", resolve);
49067
+ return new this._Promise((resolve2) => {
49068
+ this.connection.once("end", resolve2);
49113
49069
  });
49114
49070
  }
49115
49071
  }
@@ -49154,8 +49110,8 @@ var require_pg_pool = __commonJS({
49154
49110
  const cb = function(err2, client) {
49155
49111
  err2 ? rej(err2) : res(client);
49156
49112
  };
49157
- const result = new Promise2(function(resolve, reject) {
49158
- res = resolve;
49113
+ const result = new Promise2(function(resolve2, reject) {
49114
+ res = resolve2;
49159
49115
  rej = reject;
49160
49116
  });
49161
49117
  return { callback: cb, result };
@@ -49559,8 +49515,8 @@ var require_query4 = __commonJS({
49559
49515
  if (this._promise)
49560
49516
  return this._promise;
49561
49517
  this._promise = new Promise(
49562
- function(resolve, reject) {
49563
- this._once("end", resolve);
49518
+ function(resolve2, reject) {
49519
+ this._once("end", resolve2);
49564
49520
  this._once("error", reject);
49565
49521
  }.bind(this)
49566
49522
  );
@@ -49725,12 +49681,12 @@ var require_client3 = __commonJS({
49725
49681
  this._connect(callback);
49726
49682
  return;
49727
49683
  }
49728
- return new this._Promise((resolve, reject) => {
49684
+ return new this._Promise((resolve2, reject) => {
49729
49685
  this._connect((error2) => {
49730
49686
  if (error2) {
49731
49687
  reject(error2);
49732
49688
  } else {
49733
- resolve();
49689
+ resolve2();
49734
49690
  }
49735
49691
  });
49736
49692
  });
@@ -49754,8 +49710,8 @@ var require_client3 = __commonJS({
49754
49710
  query = new NativeQuery(config, values, callback);
49755
49711
  if (!query.callback) {
49756
49712
  let resolveOut, rejectOut;
49757
- result = new this._Promise((resolve, reject) => {
49758
- resolveOut = resolve;
49713
+ result = new this._Promise((resolve2, reject) => {
49714
+ resolveOut = resolve2;
49759
49715
  rejectOut = reject;
49760
49716
  });
49761
49717
  query.callback = (err2, res) => err2 ? rejectOut(err2) : resolveOut(res);
@@ -49808,8 +49764,8 @@ var require_client3 = __commonJS({
49808
49764
  }
49809
49765
  var result;
49810
49766
  if (!cb) {
49811
- result = new this._Promise(function(resolve, reject) {
49812
- cb = (err2) => err2 ? reject(err2) : resolve();
49767
+ result = new this._Promise(function(resolve2, reject) {
49768
+ cb = (err2) => err2 ? reject(err2) : resolve2();
49813
49769
  });
49814
49770
  }
49815
49771
  this.native.end(function() {
@@ -50428,7 +50384,7 @@ __export(pgIntrospect_exports, {
50428
50384
  PgConfig2: () => PgConfig2,
50429
50385
  pgIntrospect: () => pgIntrospect
50430
50386
  });
50431
- var import_hanji5, import_pg, PgConfig1, PgConfig2, Conf2, pgIntrospect;
50387
+ var import_hanji5, import_pg, PgConfig1, PgConfig2, Conf, pgIntrospect;
50432
50388
  var init_pgIntrospect = __esm({
50433
50389
  "src/cli/commands/pgIntrospect.ts"() {
50434
50390
  import_hanji5 = __toESM(require_hanji());
@@ -50449,7 +50405,7 @@ var init_pgIntrospect = __esm({
50449
50405
  PgConfig2 = objectType({
50450
50406
  connectionString: stringType()
50451
50407
  }).strict();
50452
- Conf2 = unionType([PgConfig1, PgConfig2]);
50408
+ Conf = unionType([PgConfig1, PgConfig2]);
50453
50409
  pgIntrospect = async (config) => {
50454
50410
  const pool = new import_pg.Pool(config);
50455
50411
  const progress = new IntrospectProgress();
@@ -50469,8 +50425,7 @@ var init_pgIntrospect = __esm({
50469
50425
  // src/cli/index.ts
50470
50426
  var cli_exports = {};
50471
50427
  __export(cli_exports, {
50472
- checkSchema: () => checkSchema,
50473
- configSchema: () => configSchema
50428
+ checkSchema: () => checkSchema
50474
50429
  });
50475
50430
  module.exports = __toCommonJS(cli_exports);
50476
50431
 
@@ -50491,7 +50446,7 @@ var {
50491
50446
  } = import_index.default;
50492
50447
 
50493
50448
  // src/cli/index.ts
50494
- var import_fs10 = __toESM(require("fs"));
50449
+ var import_fs11 = require("fs");
50495
50450
  init_lib();
50496
50451
 
50497
50452
  // src/cli/commands/check.ts
@@ -50533,8 +50488,7 @@ var checkHandler = (out, dialect6) => {
50533
50488
 
50534
50489
  // src/cli/index.ts
50535
50490
  var import_hanji6 = __toESM(require_hanji());
50536
- init_views();
50537
- var import_path6 = __toESM(require("path"));
50491
+ var import_path7 = __toESM(require("path"));
50538
50492
 
50539
50493
  // src/cli/utils.ts
50540
50494
  init_views();
@@ -50610,9 +50564,10 @@ var package_default = {
50610
50564
  sim: "node -r esbuild-register ./dev/simulate.ts",
50611
50565
  "sim:sqlite": "node -r esbuild-register ./dev/sqlite/index.ts",
50612
50566
  test: "ava test --timeout=60s",
50613
- build: "pnpm build:cli && pnpm build:utils",
50567
+ build: "pnpm build:cli && pnpm build:utils && pnpm build:cli-types",
50614
50568
  "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
50569
  "build:utils": "esbuild ./src/utils.ts --bundle --platform=node --target=node10.4 --outfile=./dist/utils.js",
50570
+ "build:cli-types": "tsc -p tsconfig.cli-types.json",
50616
50571
  pack: "build && package",
50617
50572
  tsc: "tsc -p tsconfig.build.json",
50618
50573
  pub: "cp package.json readme.md dist/ && cd dist && npm publish"
@@ -50652,7 +50607,7 @@ var package_default = {
50652
50607
  dockerode: "^3.3.4",
50653
50608
  dotenv: "^16.0.3",
50654
50609
  "drizzle-kit": "^0.16.8",
50655
- "drizzle-orm": "0.23.2-e17a5ba",
50610
+ "drizzle-orm": "0.23.2",
50656
50611
  esbuild: "^0.15.7",
50657
50612
  "esbuild-register": "^3.3.3",
50658
50613
  eslint: "^8.29.0",
@@ -50751,24 +50706,107 @@ var dropMigration = async (out) => {
50751
50706
  console.log(`[${source_default.green("\u2713")}] ${source_default.bold(result.data.tag)} migration successfully dropped`);
50752
50707
  };
50753
50708
 
50709
+ // src/cli/commands/utils.ts
50710
+ init_serializer();
50711
+ init_lib();
50712
+ var import_path6 = require("path");
50713
+ init_source();
50714
+ var import_fs10 = require("fs");
50715
+ init_views();
50716
+ var prepareGenerateConfig = (options) => {
50717
+ var _a;
50718
+ const { schema: schema4, out, config, breakpoints, custom } = options;
50719
+ if (!(schema4 || out)) {
50720
+ const drizzleConfig = drizzleConfigFromFile(config);
50721
+ if (!drizzleConfig.out) {
50722
+ console.log("You must specify 'out' param in config file");
50723
+ process.exit(1);
50724
+ }
50725
+ return {
50726
+ custom,
50727
+ breakpoints: (_a = drizzleConfig.breakpoints) != null ? _a : false,
50728
+ schema: drizzleConfig.schema,
50729
+ out: drizzleConfig.out
50730
+ };
50731
+ }
50732
+ if (!schema4) {
50733
+ console.error(`'schema' param must be set`);
50734
+ process.exit(1);
50735
+ }
50736
+ if (!out) {
50737
+ console.error(`'out' param must be set`);
50738
+ process.exit(1);
50739
+ }
50740
+ return { schema: schema4, out, breakpoints, custom };
50741
+ };
50742
+ var assertOutFolder = (it) => {
50743
+ if ("out" in it)
50744
+ return it.out;
50745
+ const cliConfig = drizzleConfigFromFile(it.config);
50746
+ if (!cliConfig.out) {
50747
+ console.log(
50748
+ error(
50749
+ `'out' folder param must be set through '--out' param or in config file`
50750
+ )
50751
+ );
50752
+ process.exit(0);
50753
+ }
50754
+ return cliConfig.out;
50755
+ };
50756
+ var configCommonSchema = objectType({
50757
+ schema: unionType([stringType(), stringType().array()]),
50758
+ out: stringType().optional(),
50759
+ breakpoints: booleanType().optional(),
50760
+ tablesFilter: unionType([stringType(), stringType().array()]).optional()
50761
+ });
50762
+ var mysqlConnectionSchema = unionType([
50763
+ objectType({
50764
+ host: stringType(),
50765
+ port: coerce.number().optional(),
50766
+ user: stringType().default("mysql"),
50767
+ password: stringType().optional(),
50768
+ database: stringType()
50769
+ }),
50770
+ objectType({
50771
+ connectionString: stringType()
50772
+ }),
50773
+ objectType({})
50774
+ ]);
50775
+ var mySqlCliConfigSchema = intersectionType(
50776
+ configCommonSchema,
50777
+ mysqlConnectionSchema
50778
+ );
50779
+ var drizzleConfigFromFile = (configPath) => {
50780
+ var _a;
50781
+ if (!configPath) {
50782
+ console.log(
50783
+ source_default.gray("No config path provided, using default 'drizzle.config.json'")
50784
+ );
50785
+ }
50786
+ const path3 = (0, import_path6.join)((0, import_path6.resolve)(configPath != null ? configPath : "drizzle.config.json"));
50787
+ if (!(0, import_fs10.existsSync)(path3)) {
50788
+ console.log(`${path3} file does not exist`);
50789
+ process.exit(1);
50790
+ }
50791
+ console.log(source_default.grey(`Reading config file '${path3}'`));
50792
+ const { unregister } = safeRegister();
50793
+ const required = require(path3);
50794
+ const content = (_a = required.default) != null ? _a : required;
50795
+ unregister();
50796
+ const res = mySqlCliConfigSchema.safeParse(content);
50797
+ if (!res.success) {
50798
+ console.error(res.error);
50799
+ console.log("Missing required params");
50800
+ process.exit(1);
50801
+ }
50802
+ return res.data;
50803
+ };
50804
+
50754
50805
  // src/cli/index.ts
50755
50806
  var printVersions = () => {
50756
50807
  console.log(`${source_default.gray(versions())}
50757
50808
  `);
50758
50809
  };
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
50810
  var versions = () => {
50773
50811
  const { npmVersion } = ormCoreVersions();
50774
50812
  const ormVersion = npmVersion ? `
@@ -50776,12 +50814,6 @@ drizzle-orm: v${npmVersion}` : "";
50776
50814
  const versions2 = `drizzle-kit: v${package_default.version}${ormVersion}`;
50777
50815
  return versions2;
50778
50816
  };
50779
- var configSchema = objectType({
50780
- schema: unionType([stringType(), stringType().array()]),
50781
- out: stringType().default("drizzle"),
50782
- breakpoints: booleanType(),
50783
- custom: booleanType()
50784
- }).strict();
50785
50817
  var optionsSchema = objectType({
50786
50818
  schema: unionType([stringType(), stringType().array()]).optional(),
50787
50819
  out: stringType().optional(),
@@ -50789,9 +50821,6 @@ var optionsSchema = objectType({
50789
50821
  breakpoints: booleanType().optional().default(false),
50790
50822
  custom: booleanType().optional().default(false)
50791
50823
  }).strict();
50792
- var pushOptionsSchema = objectType({
50793
- config: stringType().optional()
50794
- }).strict();
50795
50824
  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
50825
  "--config <config>",
50797
50826
  "Path to a config.json file, drizzle.config.json by default"
@@ -50800,10 +50829,6 @@ var generatePgCommand = new Command("generate:pg").option("--schema <schema...>"
50800
50829
  assertOrmCoreVersion();
50801
50830
  const oprtionsParsed = optionsSchema.parse(options);
50802
50831
  const result = prepareGenerateConfig(oprtionsParsed);
50803
- if (result instanceof Error) {
50804
- console.error(result);
50805
- return;
50806
- }
50807
50832
  assertPackages("drizzle-orm");
50808
50833
  const { prepareAndMigratePg: prepareAndMigratePg2 } = (init_migrate(), __toCommonJS(migrate_exports));
50809
50834
  await prepareAndMigratePg2(result);
@@ -50816,10 +50841,6 @@ var generateMysqlCommand = new Command("generate:mysql").option("--schema <schem
50816
50841
  assertOrmCoreVersion();
50817
50842
  const oprtionsParsed = optionsSchema.parse(options);
50818
50843
  const result = prepareGenerateConfig(oprtionsParsed);
50819
- if (result instanceof Error) {
50820
- console.error(result);
50821
- return;
50822
- }
50823
50844
  assertPackages("drizzle-orm");
50824
50845
  const { prepareAndMigrateMySql: prepareAndMigrateMySql2 } = (init_migrate(), __toCommonJS(migrate_exports));
50825
50846
  await prepareAndMigrateMySql2(result);
@@ -50828,30 +50849,18 @@ var dbPushMysqlCommand = new Command("push:mysql").option(
50828
50849
  "--config <config>",
50829
50850
  "Path to a config.json file, drizzle.config.json by default"
50830
50851
  ).action(async (options) => {
50831
- var _a;
50832
50852
  printVersions();
50833
50853
  assertPackages("drizzle-orm");
50834
50854
  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;
50855
+ const { mysqlPushIntrospect: mysqlPushIntrospect2, connectToMySQL: connectToMySQL2 } = (init_mysqlIntrospect(), __toCommonJS(mysqlIntrospect_exports));
50856
+ const drizzleConfig = drizzleConfigFromFile(options.config);
50857
+ const connection = await connectToMySQL2(drizzleConfig);
50858
+ const filterConfig = drizzleConfig.tablesFilter;
50847
50859
  const tablesFilter = filterConfig ? typeof filterConfig === "string" ? [filterConfig] : filterConfig : [];
50848
- const { schema: schema4 } = await mysqlPushIntrospect2(
50849
- connection,
50850
- tablesFilter
50851
- );
50860
+ const { schema: schema4 } = await mysqlPushIntrospect2(connection, tablesFilter);
50852
50861
  const { prepareMySQLPush: prepareMySQLPush2 } = (init_migrate(), __toCommonJS(migrate_exports));
50853
50862
  const statements = await prepareMySQLPush2(
50854
- { schema: res.data.schema },
50863
+ { schema: drizzleConfig.schema },
50855
50864
  schema4
50856
50865
  );
50857
50866
  try {
@@ -50878,41 +50887,19 @@ var generateSqliteCommand = new Command("generate:sqlite").option("--schema <sch
50878
50887
  assertOrmCoreVersion();
50879
50888
  const oprtionsParsed = optionsSchema.parse(options);
50880
50889
  const result = prepareGenerateConfig(oprtionsParsed);
50881
- if (result instanceof Error) {
50882
- console.error(result);
50883
- return;
50884
- }
50885
50890
  assertPackages("drizzle-orm");
50886
50891
  const { prepareAndMigrateSqlite: prepareAndMigrateSqlite2 } = (init_migrate(), __toCommonJS(migrate_exports));
50887
50892
  await prepareAndMigrateSqlite2(result);
50888
50893
  });
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();
50894
+ var checkSchema = unionType([
50895
+ objectType({ out: stringType() }),
50896
+ objectType({ config: stringType().optional() })
50897
+ ]);
50907
50898
  var checkPgCommand = new Command("check:pg").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.json]`).action((options) => {
50908
50899
  printVersions();
50909
50900
  assertOrmCoreVersion();
50910
50901
  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
- }
50902
+ const out = assertOutFolder(params);
50916
50903
  checkHandler(out, "pg");
50917
50904
  console.log("Everything's fine \u{1F436}\u{1F525}");
50918
50905
  });
@@ -50920,11 +50907,7 @@ var checkSqliteCommand = new Command("check:sqlite").option("--out <out>", `Outp
50920
50907
  printVersions();
50921
50908
  assertOrmCoreVersion();
50922
50909
  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
- }
50910
+ const out = assertOutFolder(params);
50928
50911
  checkHandler(out, "sqlite");
50929
50912
  console.log("Everything's fine \u{1F436}\u{1F525}");
50930
50913
  });
@@ -50932,15 +50915,7 @@ var upPgCommand = new Command("up:pg").option("--out <out>", `Output folder`).op
50932
50915
  printVersions();
50933
50916
  assertOrmCoreVersion();
50934
50917
  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
- }
50918
+ const out = assertOutFolder(params);
50944
50919
  assertPackages("drizzle-orm");
50945
50920
  upPgHandlerV4(out);
50946
50921
  upgradeFolders("pg", out);
@@ -50950,19 +50925,7 @@ var upMysqlCommand = new Command("up:mysql").option("--out <out>", `Output folde
50950
50925
  printVersions();
50951
50926
  assertOrmCoreVersion();
50952
50927
  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
- }
50928
+ const out = assertOutFolder(params);
50966
50929
  assertPackages("drizzle-orm");
50967
50930
  upMysqlHandlerV4(out);
50968
50931
  upgradeFolders("mysql", out);
@@ -50972,11 +50935,7 @@ var upSqliteCommand = new Command("up:sqlite").option("--out <out>", `Output fol
50972
50935
  printVersions();
50973
50936
  assertOrmCoreVersion();
50974
50937
  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
- }
50938
+ const out = assertOutFolder(params);
50980
50939
  upSqliteHandlerV4(out);
50981
50940
  upgradeFolders("sqlite", out);
50982
50941
  upSqliteHandler(out);
@@ -51001,8 +50960,8 @@ var introspectPgCommand = new Command("introspect:pg").option("--out <out>", `Mi
51001
50960
  }
51002
50961
  const { snapshots, journal } = prepareOutFolder2(res.data.out, "pg");
51003
50962
  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);
50963
+ const schemaFile = import_path7.default.join(res.data.out, "schema.ts");
50964
+ (0, import_fs11.writeFileSync)(schemaFile, ts);
51006
50965
  console.log();
51007
50966
  if (snapshots.length === 0) {
51008
50967
  const { sqlStatements, _meta } = await prepareSQL(
@@ -51045,20 +51004,17 @@ var introspectMySqlCommand = new Command("introspect:mysql").option(
51045
51004
  printVersions();
51046
51005
  assertPackages("drizzle-orm");
51047
51006
  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;
51007
+ const { mysqlIntrospect: mysqlIntrospect2 } = (init_mysqlIntrospect(), __toCommonJS(mysqlIntrospect_exports));
51008
+ const drizzleConfig = drizzleConfigFromFile(options.config);
51009
+ if (!drizzleConfig.out) {
51010
+ console.log("You must specify 'out' path in your config file");
51011
+ process.exit(1);
51057
51012
  }
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);
51013
+ const out = drizzleConfig.out;
51014
+ const { snapshots, journal } = prepareOutFolder2(out, "mysql");
51015
+ const { schema: schema4, ts } = await mysqlIntrospect2(drizzleConfig);
51016
+ const schemaFile = import_path7.default.join(out, "schema.ts");
51017
+ (0, import_fs11.writeFileSync)(schemaFile, ts);
51062
51018
  console.log();
51063
51019
  if (snapshots.length === 0) {
51064
51020
  const { sqlStatements, _meta } = await prepareSQL(
@@ -51073,8 +51029,8 @@ var introspectMySqlCommand = new Command("introspect:mysql").option(
51073
51029
  sqlStatements,
51074
51030
  journal,
51075
51031
  _meta,
51076
- res.data.out,
51077
- res.data.breakpoints,
51032
+ out,
51033
+ (_a = drizzleConfig.breakpoints) != null ? _a : false,
51078
51034
  "introspect"
51079
51035
  );
51080
51036
  } else {
@@ -51097,11 +51053,7 @@ var dropCommand = new Command("drop").option("--out <out>", `Output folder`).opt
51097
51053
  printVersions();
51098
51054
  assertOrmCoreVersion();
51099
51055
  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
- }
51056
+ const out = assertOutFolder(params);
51105
51057
  assertV1OutFolder(out, "{dialect}");
51106
51058
  dropMigration(out);
51107
51059
  });
@@ -51121,6 +51073,5 @@ program.addCommand(dbPushMysqlCommand);
51121
51073
  program.parse();
51122
51074
  // Annotate the CommonJS export names for ESM import in node:
51123
51075
  0 && (module.exports = {
51124
- checkSchema,
51125
- configSchema
51076
+ checkSchema
51126
51077
  });