@donotdev/cli 0.0.37 → 0.1.0

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 (59) hide show
  1. package/LICENSE.md +21 -48
  2. package/dependencies-matrix.json +24 -24
  3. package/dist/bin/commands/agent-setup.js +6963 -123
  4. package/dist/bin/commands/build.js +4 -1
  5. package/dist/bin/commands/bump.js +23 -12
  6. package/dist/bin/commands/cacheout.js +17 -1
  7. package/dist/bin/commands/coach.js +4 -1
  8. package/dist/bin/commands/create-app.js +16 -2
  9. package/dist/bin/commands/create-project.js +17 -3
  10. package/dist/bin/commands/db.js +1708 -98
  11. package/dist/bin/commands/deploy.js +142 -96
  12. package/dist/bin/commands/dev.js +6 -5
  13. package/dist/bin/commands/doctor.js +4 -1
  14. package/dist/bin/commands/emu.js +6 -5
  15. package/dist/bin/commands/format.js +5 -3
  16. package/dist/bin/commands/get-demo.js +16 -2
  17. package/dist/bin/commands/make-admin.js +1717 -87
  18. package/dist/bin/commands/preview.js +6 -5
  19. package/dist/bin/commands/seed.js +1708 -98
  20. package/dist/bin/commands/setup-cicd.js +4 -1
  21. package/dist/bin/commands/setup.js +21 -18
  22. package/dist/bin/commands/staging.js +142 -96
  23. package/dist/bin/commands/sync-secrets.js +4 -1
  24. package/dist/bin/commands/type-check.js +4 -1
  25. package/dist/bin/commands/wai.js +4 -1
  26. package/dist/bin/dndev.js +21 -1
  27. package/dist/bin/donotdev.js +21 -1
  28. package/dist/index.js +170 -105
  29. package/package.json +2 -2
  30. package/templates/functions-supabase/supabase/functions/.env.example +12 -0
  31. package/templates/functions-supabase/supabase/functions/disconnect-oauth/index.ts.example +7 -0
  32. package/templates/functions-supabase/supabase/functions/exchange-token/index.ts.example +7 -0
  33. package/templates/functions-supabase/supabase/functions/get-connections/index.ts.example +7 -0
  34. package/templates/functions-supabase/supabase/functions/refresh-token/index.ts.example +7 -0
  35. package/templates/preset-admin/src/pages/DashboardPage.tsx.example +189 -0
  36. package/templates/preset-admin/src/pages/EntityPage.tsx.example +84 -0
  37. package/templates/preset-admin/src/pages/ReportsPage.tsx.example +243 -0
  38. package/templates/preset-admin/src/pages/SettingsPage.tsx.example +283 -0
  39. package/templates/preset-admin/src/pages/UsersPage.tsx.example +128 -0
  40. package/templates/preset-ecommerce/src/pages/CartPage.tsx.example +167 -0
  41. package/templates/preset-ecommerce/src/pages/CatalogPage.tsx.example +187 -0
  42. package/templates/preset-ecommerce/src/pages/CheckoutPage.tsx.example +244 -0
  43. package/templates/preset-ecommerce/src/pages/HomePage.tsx.example +268 -0
  44. package/templates/preset-ecommerce/src/pages/ProductPage.tsx.example +228 -0
  45. package/templates/preset-landing/src/pages/AboutPage.tsx.example +237 -0
  46. package/templates/preset-landing/src/pages/ContactPage.tsx.example +192 -0
  47. package/templates/preset-landing/src/pages/HomePage.tsx.example +399 -0
  48. package/templates/preset-saas/src/pages/DashboardPage.tsx.example +195 -0
  49. package/templates/preset-saas/src/pages/HomePage.tsx.example +270 -0
  50. package/templates/preset-saas/src/pages/PricingPage.tsx.example +204 -0
  51. package/templates/preset-saas/src/pages/ProfilePage.tsx.example +191 -0
  52. package/templates/preset-saas/src/pages/SettingsPage.tsx.example +292 -0
  53. package/templates/root-consumer/.claude/commands/brainstorm.md.example +28 -0
  54. package/templates/root-consumer/.claude/commands/design.md.example +31 -0
  55. package/templates/root-consumer/.claude/commands/grill.md.example +33 -6
  56. package/templates/root-consumer/.claude/skills/brainstorm/SKILL.md.example +16 -0
  57. package/templates/root-consumer/.claude/skills/design/SKILL.md.example +17 -0
  58. package/templates/root-consumer/.claude/skills/grill/SKILL.md.example +11 -5
  59. package/templates/root-consumer/guides/dndev/SETUP_OAUTH.md.example +2 -1
@@ -3351,9 +3351,9 @@ var require_parse2 = __commonJS({
3351
3351
  const idx = prev.value.lastIndexOf("[");
3352
3352
  const pre = prev.value.slice(0, idx);
3353
3353
  const rest2 = prev.value.slice(idx + 2);
3354
- const posix2 = POSIX_REGEX_SOURCE[rest2];
3355
- if (posix2) {
3356
- prev.value = pre + posix2;
3354
+ const posix = POSIX_REGEX_SOURCE[rest2];
3355
+ if (posix) {
3356
+ prev.value = pre + posix;
3357
3357
  state.backtrack = true;
3358
3358
  advance();
3359
3359
  if (!bos.output && tokens.indexOf(prev) === 1) {
@@ -3875,7 +3875,7 @@ var require_picomatch = __commonJS({
3875
3875
  throw new TypeError("Expected pattern to be a non-empty string");
3876
3876
  }
3877
3877
  const opts = options || {};
3878
- const posix2 = utils.isWindows(options);
3878
+ const posix = utils.isWindows(options);
3879
3879
  const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
3880
3880
  const state = regex.state;
3881
3881
  delete regex.state;
@@ -3885,8 +3885,8 @@ var require_picomatch = __commonJS({
3885
3885
  isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
3886
3886
  }
3887
3887
  const matcher = (input, returnObject = false) => {
3888
- const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix: posix2 });
3889
- const result = { glob, state, regex, posix: posix2, input, output, match, isMatch };
3888
+ const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
3889
+ const result = { glob, state, regex, posix, input, output, match, isMatch };
3890
3890
  if (typeof opts.onResult === "function") {
3891
3891
  opts.onResult(result);
3892
3892
  }
@@ -3911,7 +3911,7 @@ var require_picomatch = __commonJS({
3911
3911
  }
3912
3912
  return matcher;
3913
3913
  };
3914
- picomatch.test = (input, regex, options, { glob, posix: posix2 } = {}) => {
3914
+ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
3915
3915
  if (typeof input !== "string") {
3916
3916
  throw new TypeError("Expected input to be a string");
3917
3917
  }
@@ -3919,7 +3919,7 @@ var require_picomatch = __commonJS({
3919
3919
  return { isMatch: false, output: "" };
3920
3920
  }
3921
3921
  const opts = options || {};
3922
- const format = opts.format || (posix2 ? utils.toPosixSlashes : null);
3922
+ const format = opts.format || (posix ? utils.toPosixSlashes : null);
3923
3923
  let match = input === glob;
3924
3924
  let output = match && format ? format(input) : input;
3925
3925
  if (match === false) {
@@ -3928,14 +3928,14 @@ var require_picomatch = __commonJS({
3928
3928
  }
3929
3929
  if (match === false || opts.capture === true) {
3930
3930
  if (opts.matchBase === true || opts.basename === true) {
3931
- match = picomatch.matchBase(input, regex, options, posix2);
3931
+ match = picomatch.matchBase(input, regex, options, posix);
3932
3932
  } else {
3933
3933
  match = regex.exec(output);
3934
3934
  }
3935
3935
  }
3936
3936
  return { isMatch: Boolean(match), match, output };
3937
3937
  };
3938
- picomatch.matchBase = (input, glob, options, posix2 = utils.isWindows(options)) => {
3938
+ picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
3939
3939
  const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
3940
3940
  return regex.test(path.basename(input));
3941
3941
  };
@@ -4126,9 +4126,9 @@ var require_micromatch = __commonJS({
4126
4126
  return [].concat(patterns).every((p2) => picomatch(p2, options)(str));
4127
4127
  };
4128
4128
  micromatch.capture = (glob, input, options) => {
4129
- let posix2 = utils.isWindows(options);
4129
+ let posix = utils.isWindows(options);
4130
4130
  let regex = picomatch.makeRe(String(glob), { ...options, capture: true });
4131
- let match = regex.exec(posix2 ? utils.toPosixSlashes(input) : input);
4131
+ let match = regex.exec(posix ? utils.toPosixSlashes(input) : input);
4132
4132
  if (match) {
4133
4133
  return match.slice(1).map((v2) => v2 === void 0 ? "" : v2);
4134
4134
  }
@@ -4308,15 +4308,15 @@ var require_pattern = __commonJS({
4308
4308
  exports.removeDuplicateSlashes = removeDuplicateSlashes;
4309
4309
  function partitionAbsoluteAndRelative(patterns) {
4310
4310
  const absolute = [];
4311
- const relative4 = [];
4311
+ const relative3 = [];
4312
4312
  for (const pattern of patterns) {
4313
4313
  if (isAbsolute(pattern)) {
4314
4314
  absolute.push(pattern);
4315
4315
  } else {
4316
- relative4.push(pattern);
4316
+ relative3.push(pattern);
4317
4317
  }
4318
4318
  }
4319
- return [absolute, relative4];
4319
+ return [absolute, relative3];
4320
4320
  }
4321
4321
  exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
4322
4322
  function isAbsolute(pattern) {
@@ -4616,7 +4616,7 @@ var require_async = __commonJS({
4616
4616
  init_utils();
4617
4617
  Object.defineProperty(exports, "__esModule", { value: true });
4618
4618
  exports.read = void 0;
4619
- function read(path, settings, callback) {
4619
+ function read2(path, settings, callback) {
4620
4620
  settings.fs.lstat(path, (lstatError, lstat) => {
4621
4621
  if (lstatError !== null) {
4622
4622
  callFailureCallback(callback, lstatError);
@@ -4626,7 +4626,7 @@ var require_async = __commonJS({
4626
4626
  callSuccessCallback(callback, lstat);
4627
4627
  return;
4628
4628
  }
4629
- settings.fs.stat(path, (statError, stat2) => {
4629
+ settings.fs.stat(path, (statError, stat) => {
4630
4630
  if (statError !== null) {
4631
4631
  if (settings.throwErrorOnBrokenSymbolicLink) {
4632
4632
  callFailureCallback(callback, statError);
@@ -4636,13 +4636,13 @@ var require_async = __commonJS({
4636
4636
  return;
4637
4637
  }
4638
4638
  if (settings.markSymbolicLink) {
4639
- stat2.isSymbolicLink = () => true;
4639
+ stat.isSymbolicLink = () => true;
4640
4640
  }
4641
- callSuccessCallback(callback, stat2);
4641
+ callSuccessCallback(callback, stat);
4642
4642
  });
4643
4643
  });
4644
4644
  }
4645
- exports.read = read;
4645
+ exports.read = read2;
4646
4646
  function callFailureCallback(callback, error2) {
4647
4647
  callback(error2);
4648
4648
  }
@@ -4659,17 +4659,17 @@ var require_sync = __commonJS({
4659
4659
  init_utils();
4660
4660
  Object.defineProperty(exports, "__esModule", { value: true });
4661
4661
  exports.read = void 0;
4662
- function read(path, settings) {
4662
+ function read2(path, settings) {
4663
4663
  const lstat = settings.fs.lstatSync(path);
4664
4664
  if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
4665
4665
  return lstat;
4666
4666
  }
4667
4667
  try {
4668
- const stat2 = settings.fs.statSync(path);
4668
+ const stat = settings.fs.statSync(path);
4669
4669
  if (settings.markSymbolicLink) {
4670
- stat2.isSymbolicLink = () => true;
4670
+ stat.isSymbolicLink = () => true;
4671
4671
  }
4672
- return stat2;
4672
+ return stat;
4673
4673
  } catch (error2) {
4674
4674
  if (!settings.throwErrorOnBrokenSymbolicLink) {
4675
4675
  return lstat;
@@ -4677,7 +4677,7 @@ var require_sync = __commonJS({
4677
4677
  throw error2;
4678
4678
  }
4679
4679
  }
4680
- exports.read = read;
4680
+ exports.read = read2;
4681
4681
  }
4682
4682
  });
4683
4683
 
@@ -4739,14 +4739,14 @@ var require_out = __commonJS({
4739
4739
  var sync = require_sync();
4740
4740
  var settings_1 = require_settings();
4741
4741
  exports.Settings = settings_1.default;
4742
- function stat2(path, optionsOrSettingsOrCallback, callback) {
4742
+ function stat(path, optionsOrSettingsOrCallback, callback) {
4743
4743
  if (typeof optionsOrSettingsOrCallback === "function") {
4744
4744
  async.read(path, getSettings(), optionsOrSettingsOrCallback);
4745
4745
  return;
4746
4746
  }
4747
4747
  async.read(path, getSettings(optionsOrSettingsOrCallback), callback);
4748
4748
  }
4749
- exports.stat = stat2;
4749
+ exports.stat = stat;
4750
4750
  function statSync3(path, optionsOrSettings) {
4751
4751
  const settings = getSettings(optionsOrSettings);
4752
4752
  return sync.read(path, settings);
@@ -4911,14 +4911,14 @@ var require_async2 = __commonJS({
4911
4911
  var constants_1 = require_constants3();
4912
4912
  var utils = require_utils4();
4913
4913
  var common = require_common();
4914
- function read(directory, settings, callback) {
4914
+ function read2(directory, settings, callback) {
4915
4915
  if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
4916
4916
  readdirWithFileTypes(directory, settings, callback);
4917
4917
  return;
4918
4918
  }
4919
4919
  readdir2(directory, settings, callback);
4920
4920
  }
4921
- exports.read = read;
4921
+ exports.read = read2;
4922
4922
  function readdirWithFileTypes(directory, settings, callback) {
4923
4923
  settings.fs.readdir(directory, { withFileTypes: true }, (readdirError, dirents) => {
4924
4924
  if (readdirError !== null) {
@@ -5021,13 +5021,13 @@ var require_sync2 = __commonJS({
5021
5021
  var constants_1 = require_constants3();
5022
5022
  var utils = require_utils4();
5023
5023
  var common = require_common();
5024
- function read(directory, settings) {
5024
+ function read2(directory, settings) {
5025
5025
  if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
5026
5026
  return readdirWithFileTypes(directory, settings);
5027
5027
  }
5028
5028
  return readdir2(directory, settings);
5029
5029
  }
5030
- exports.read = read;
5030
+ exports.read = read2;
5031
5031
  function readdirWithFileTypes(directory, settings) {
5032
5032
  const dirents = settings.fs.readdirSync(directory, { withFileTypes: true });
5033
5033
  return dirents.map((dirent) => {
@@ -6628,19 +6628,19 @@ var require_out4 = __commonJS({
6628
6628
  return utils.path.convertPathToPattern(source);
6629
6629
  }
6630
6630
  FastGlob2.convertPathToPattern = convertPathToPattern;
6631
- let posix2;
6632
- (function(posix3) {
6631
+ let posix;
6632
+ (function(posix2) {
6633
6633
  function escapePath2(source) {
6634
6634
  assertPatternsInput(source);
6635
6635
  return utils.path.escapePosixPath(source);
6636
6636
  }
6637
- posix3.escapePath = escapePath2;
6637
+ posix2.escapePath = escapePath2;
6638
6638
  function convertPathToPattern2(source) {
6639
6639
  assertPatternsInput(source);
6640
6640
  return utils.path.convertPosixPathToPattern(source);
6641
6641
  }
6642
- posix3.convertPathToPattern = convertPathToPattern2;
6643
- })(posix2 = FastGlob2.posix || (FastGlob2.posix = {}));
6642
+ posix2.convertPathToPattern = convertPathToPattern2;
6643
+ })(posix = FastGlob2.posix || (FastGlob2.posix = {}));
6644
6644
  let win32;
6645
6645
  (function(win322) {
6646
6646
  function escapePath2(source) {
@@ -7787,7 +7787,10 @@ var init_PathResolver = __esm({
7787
7787
  */
7788
7788
  getEmptyCjsModulePath() {
7789
7789
  const resolved = this.resolvePackage("@donotdev/core/empty");
7790
- if (!resolved) throw new Error("Cannot resolve @donotdev/core/empty \u2014 package setup is broken");
7790
+ if (!resolved)
7791
+ throw new Error(
7792
+ "Cannot resolve @donotdev/core/empty \u2014 package setup is broken"
7793
+ );
7791
7794
  return resolved;
7792
7795
  }
7793
7796
  // === PRIVATE METHODS ===
@@ -7853,7 +7856,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
7853
7856
  function readdirSync2(dirPath, options) {
7854
7857
  return pathResolverInstance.readdirSync(dirPath, options);
7855
7858
  }
7856
- var pathResolverInstance, resolvePackage, normalizePath, pathExists, readSync, writeSync, removeSync, statSync2, ensureDirSync, getRelativePathBetween, getDirname, joinPath;
7859
+ var pathResolverInstance, resolvePackage, normalizePath, pathExists, read, readSync, writeSync, removeSync, statSync2, ensureDirSync, readdir, getRelativePathBetween, getDirname, joinPath;
7857
7860
  var init_pathResolver = __esm({
7858
7861
  "packages/tooling/src/utils/pathResolver.ts"() {
7859
7862
  "use strict";
@@ -7865,11 +7868,13 @@ var init_pathResolver = __esm({
7865
7868
  return pathResolverInstance.normalizePath(join2(...pathSegments));
7866
7869
  };
7867
7870
  pathExists = (filePath, silent = false) => pathResolverInstance.pathExists(filePath, silent);
7871
+ read = async (filePath, options) => pathResolverInstance.read(filePath, options);
7868
7872
  readSync = (filePath, options) => pathResolverInstance.readSync(filePath, options);
7869
7873
  writeSync = (filePath, content, options) => pathResolverInstance.writeSync(filePath, content, options);
7870
7874
  removeSync = (path) => pathResolverInstance.removeSync(path);
7871
7875
  statSync2 = (filePath) => pathResolverInstance.statSync(filePath);
7872
7876
  ensureDirSync = (dirPath) => pathResolverInstance.ensureDirSync(dirPath);
7877
+ readdir = async (dirPath, options) => pathResolverInstance.readdir(dirPath, options);
7873
7878
  getRelativePathBetween = (from, to) => {
7874
7879
  return normalizePath(relative2(from, to));
7875
7880
  };
@@ -8083,7 +8088,7 @@ function checkCLI(command, args = ["--version"], useCache = true) {
8083
8088
  "-ExecutionPolicy",
8084
8089
  "Bypass",
8085
8090
  "-Command",
8086
- `& '${fullPath}' ${args.join(" ")}`
8091
+ `& '${fullPath}' ${args.map((a) => `'${a}'`).join(" ")}`
8087
8092
  ],
8088
8093
  {
8089
8094
  stdio: "pipe",
@@ -8105,7 +8110,7 @@ function checkCLI(command, args = ["--version"], useCache = true) {
8105
8110
  "-ExecutionPolicy",
8106
8111
  "Bypass",
8107
8112
  "-Command",
8108
- `${command} ${args.join(" ")}`
8113
+ `& '${command}' ${args.map((a) => `'${a}'`).join(" ")}`
8109
8114
  ],
8110
8115
  {
8111
8116
  stdio: "pipe",
@@ -8113,9 +8118,8 @@ function checkCLI(command, args = ["--version"], useCache = true) {
8113
8118
  }
8114
8119
  );
8115
8120
  } else {
8116
- result = spawnSync(`${command} ${args.join(" ")}`, {
8117
- stdio: "pipe",
8118
- shell: true
8121
+ result = spawnSync(command, args, {
8122
+ stdio: "pipe"
8119
8123
  });
8120
8124
  }
8121
8125
  const isAvailable = result.status === 0;
@@ -16079,8 +16083,8 @@ function detectAppsWithFunctions() {
16079
16083
  try {
16080
16084
  const appsList = readdirSync2(appsDir).filter((item) => {
16081
16085
  const itemPath = joinPath(appsDir, item);
16082
- const stat2 = statSync2(itemPath);
16083
- return stat2?.isDirectory() === true;
16086
+ const stat = statSync2(itemPath);
16087
+ return stat?.isDirectory() === true;
16084
16088
  });
16085
16089
  for (const app of appsList) {
16086
16090
  const functionsEnvFile = joinPath(appsDir, app, "functions", ".env");
@@ -16564,8 +16568,8 @@ async function deploySupabaseFunctions(appDir, config) {
16564
16568
  );
16565
16569
  const functionDirs = readdirSync2(functionsDir).filter((item) => {
16566
16570
  const itemPath = joinPath(functionsDir, item);
16567
- const stat2 = statSync2(itemPath);
16568
- return stat2?.isDirectory() === true;
16571
+ const stat = statSync2(itemPath);
16572
+ return stat?.isDirectory() === true;
16569
16573
  }).filter((dir) => {
16570
16574
  const indexPath = joinPath(functionsDir, dir, "index.ts");
16571
16575
  return pathExists(indexPath);
@@ -16583,14 +16587,18 @@ async function deploySupabaseFunctions(appDir, config) {
16583
16587
  for (const functionName of functionDirs) {
16584
16588
  s.start(`Deploying Edge Function: ${functionName}...`);
16585
16589
  try {
16586
- const result = spawnSync6("supabase", ["functions", "deploy", functionName], {
16587
- cwd: supabaseDir,
16588
- stdio: config.verbose ? "inherit" : "pipe",
16589
- env: {
16590
- ...process.env,
16591
- DNDEV_APP_ROOT: appDir
16590
+ const result = spawnSync6(
16591
+ "supabase",
16592
+ ["functions", "deploy", functionName],
16593
+ {
16594
+ cwd: supabaseDir,
16595
+ stdio: config.verbose ? "inherit" : "pipe",
16596
+ env: {
16597
+ ...process.env,
16598
+ DNDEV_APP_ROOT: appDir
16599
+ }
16592
16600
  }
16593
- });
16601
+ );
16594
16602
  if (result.status !== 0) {
16595
16603
  throw new Error(result.stderr?.toString() || "Deploy failed");
16596
16604
  }
@@ -16668,10 +16676,12 @@ function executeFirebaseCommand(args, options) {
16668
16676
  env: deployEnv
16669
16677
  };
16670
16678
  let result;
16671
- result = spawnSync2(`firebase ${args.join(" ")}`, {
16672
- ...spawnOptions,
16673
- shell: true
16674
- });
16679
+ const isWindows = platform() === "win32";
16680
+ if (isWindows) {
16681
+ result = spawnSync2("firebase", args, { ...spawnOptions, shell: true });
16682
+ } else {
16683
+ result = spawnSync2("firebase", args, spawnOptions);
16684
+ }
16675
16685
  if (result.error) {
16676
16686
  return {
16677
16687
  success: false,
@@ -16774,8 +16784,8 @@ function detectAvailableApps() {
16774
16784
  }
16775
16785
  return readdirSync2(appsDir).filter((item) => {
16776
16786
  const itemPath = joinPath(appsDir, item);
16777
- const stat2 = statSync2(itemPath);
16778
- return stat2?.isDirectory() === true;
16787
+ const stat = statSync2(itemPath);
16788
+ return stat?.isDirectory() === true;
16779
16789
  }).filter((app) => {
16780
16790
  const appDir = joinPath(appsDir, app);
16781
16791
  const firebaseJsonPath = joinPath(appDir, "firebase.json");
@@ -17552,8 +17562,6 @@ init_vercel_token();
17552
17562
  init_cli_output();
17553
17563
  init_pathResolver();
17554
17564
  import { createHash } from "node:crypto";
17555
- import { readFile, readdir } from "node:fs/promises";
17556
- import { join as join3, relative as relative3 } from "node:path";
17557
17565
  var VERCEL_API2 = "https://api.vercel.com";
17558
17566
  var UPLOAD_BATCH_SIZE = 10;
17559
17567
  var POLL_INTERVAL_MS = 3e3;
@@ -17568,17 +17576,18 @@ function teamQuery(orgId) {
17568
17576
  async function collectDistFiles(distDir) {
17569
17577
  const files = [];
17570
17578
  async function walk(dir) {
17571
- const entries = await readdir(dir, { withFileTypes: true });
17579
+ const entries = await readdir(dir, {
17580
+ withFileTypes: true
17581
+ });
17572
17582
  for (const entry of entries) {
17573
- const fullPath = join3(dir, entry.name);
17583
+ const fullPath = joinPath(dir, entry.name);
17574
17584
  if (entry.isDirectory()) {
17575
17585
  await walk(fullPath);
17576
17586
  } else {
17577
- const content = await readFile(fullPath);
17587
+ const content = await read(fullPath, { format: "buffer" });
17578
17588
  const sha = createHash("sha1").update(content).digest("hex");
17579
- const rel = relative3(distDir, fullPath).split("\\").join("/");
17580
17589
  files.push({
17581
- relativePath: rel,
17590
+ relativePath: getRelativePathBetween(distDir, fullPath),
17582
17591
  content,
17583
17592
  sha,
17584
17593
  size: content.byteLength
@@ -17616,13 +17625,19 @@ async function uploadFiles(files, token, orgId) {
17616
17625
  );
17617
17626
  }
17618
17627
  }
17619
- function loadVercelConfig(appDir) {
17628
+ function sourceToRegex(source) {
17629
+ if (source.includes("(")) return source;
17630
+ let result = source.replace(/\./g, "\\.");
17631
+ result = result.replace(/:(\w+)\*/g, "(.+)");
17632
+ result = result.replace(/:(\w+)/g, "([^/]+)");
17633
+ return result;
17634
+ }
17635
+ function buildRoutes(appDir) {
17620
17636
  const configPath = joinPath(appDir, "vercel.json");
17621
- if (!pathExists(configPath)) return {};
17637
+ if (!pathExists(configPath)) return [];
17622
17638
  try {
17623
- const raw = readSync(configPath);
17624
- const config = JSON.parse(raw);
17625
- const result = {};
17639
+ const config = readSync(configPath);
17640
+ if (!config || typeof config !== "object") return [];
17626
17641
  const routes = [];
17627
17642
  if (Array.isArray(config.headers)) {
17628
17643
  for (const h2 of config.headers) {
@@ -17631,7 +17646,7 @@ function loadVercelConfig(appDir) {
17631
17646
  headersMap[entry.key] = entry.value;
17632
17647
  }
17633
17648
  routes.push({
17634
- src: h2.source,
17649
+ src: sourceToRegex(h2.source),
17635
17650
  headers: headersMap,
17636
17651
  continue: true
17637
17652
  });
@@ -17640,31 +17655,55 @@ function loadVercelConfig(appDir) {
17640
17655
  if (Array.isArray(config.redirects)) {
17641
17656
  for (const r2 of config.redirects) {
17642
17657
  routes.push({
17643
- src: r2.source,
17658
+ src: sourceToRegex(r2.source),
17644
17659
  dest: r2.destination,
17645
17660
  status: r2.statusCode ?? (r2.permanent ? 308 : 307)
17646
17661
  });
17647
17662
  }
17648
17663
  }
17649
- if (Array.isArray(config.rewrites)) {
17664
+ if (Array.isArray(config.rewrites) && config.rewrites.length > 0) {
17665
+ routes.push({ handle: "filesystem" });
17650
17666
  for (const rw of config.rewrites) {
17651
17667
  routes.push({
17652
- src: rw.source,
17668
+ src: sourceToRegex(rw.source),
17653
17669
  dest: rw.destination
17654
17670
  });
17655
17671
  }
17656
17672
  }
17657
- if (routes.length > 0) result.routes = routes;
17658
- if (config.cleanUrls != null) result.cleanUrls = config.cleanUrls;
17659
- if (config.trailingSlash != null) result.trailingSlash = config.trailingSlash;
17660
- return result;
17661
- } catch {
17662
- return {};
17673
+ return routes;
17674
+ } catch (err) {
17675
+ log.warn(
17676
+ `Failed to parse vercel.json: ${err instanceof Error ? err.message : String(err)}`
17677
+ );
17678
+ return [];
17663
17679
  }
17664
17680
  }
17665
- async function createDeployment(files, token, orgId, projectId, projectName, appDir) {
17681
+ function buildOutputConfig(appDir) {
17682
+ let routes = buildRoutes(appDir);
17683
+ const hasFilesystemHandle = routes.some(
17684
+ (r2) => "handle" in r2 && r2.handle === "filesystem"
17685
+ );
17686
+ if (!hasFilesystemHandle) {
17687
+ routes = [
17688
+ ...routes,
17689
+ { handle: "filesystem" },
17690
+ { src: "/(.*)", dest: "/index.html" }
17691
+ ];
17692
+ }
17693
+ const config = { version: 3, routes };
17694
+ const json = JSON.stringify(config, null, 2);
17695
+ const content = Buffer.from(json);
17696
+ const sha = createHash("sha1").update(content).digest("hex");
17697
+ log.debug(`Build Output config.json: ${routes.length} routes`);
17698
+ return {
17699
+ relativePath: ".vercel/output/config.json",
17700
+ content,
17701
+ sha,
17702
+ size: content.byteLength
17703
+ };
17704
+ }
17705
+ async function createDeployment(files, token, orgId, projectId, projectName) {
17666
17706
  const q2 = teamQuery(orgId);
17667
- const vercelConfig = loadVercelConfig(appDir);
17668
17707
  const body = {
17669
17708
  name: projectName,
17670
17709
  project: projectId,
@@ -17678,8 +17717,7 @@ async function createDeployment(files, token, orgId, projectId, projectName, app
17678
17717
  buildCommand: "",
17679
17718
  installCommand: "",
17680
17719
  outputDirectory: "."
17681
- },
17682
- ...vercelConfig
17720
+ }
17683
17721
  };
17684
17722
  const res = await fetch(`${VERCEL_API2}/v13/deployments${q2}`, {
17685
17723
  method: "POST",
@@ -17749,22 +17787,30 @@ async function deployVercelFrontend(appDir, _config) {
17749
17787
  const project = await validateProject(token, projectId, orgId);
17750
17788
  log.success(`Project accessible (${project.projectName})`);
17751
17789
  log.info("Collecting dist/ files...");
17752
- const files = await collectDistFiles(distDir);
17753
- if (files.length === 0) {
17754
- throw new Error("dist/ is empty \u2014 nothing to deploy.");
17755
- }
17756
- log.info(`Found ${files.length} files`);
17790
+ const distFiles = await collectDistFiles(distDir);
17791
+ if (distFiles.length === 0) {
17792
+ throw new Error("dist/ is empty - nothing to deploy.");
17793
+ }
17794
+ log.info(`Found ${distFiles.length} files`);
17795
+ const configFile = buildOutputConfig(appDir);
17796
+ const outputFiles = [
17797
+ configFile,
17798
+ ...distFiles.map((f) => ({
17799
+ ...f,
17800
+ relativePath: `.vercel/output/static/${f.relativePath}`
17801
+ }))
17802
+ ];
17803
+ log.debug(`Build Output: 1 config.json + ${distFiles.length} static files`);
17757
17804
  log.info("Uploading files to Vercel...");
17758
- await uploadFiles(files, token, orgId);
17759
- log.success(`${files.length} files uploaded`);
17805
+ await uploadFiles(outputFiles, token, orgId);
17806
+ log.success(`${outputFiles.length} files uploaded`);
17760
17807
  log.info("Creating production deployment...");
17761
17808
  const deployment = await createDeployment(
17762
- files,
17809
+ outputFiles,
17763
17810
  token,
17764
17811
  orgId,
17765
17812
  projectId,
17766
- project.projectName,
17767
- appDir
17813
+ project.projectName
17768
17814
  );
17769
17815
  log.info(`Deployment ${deployment.id} created, waiting...`);
17770
17816
  const ready = await waitForReady(deployment.id, token, orgId);
@@ -7607,7 +7607,10 @@ var init_PathResolver = __esm({
7607
7607
  */
7608
7608
  getEmptyCjsModulePath() {
7609
7609
  const resolved = this.resolvePackage("@donotdev/core/empty");
7610
- if (!resolved) throw new Error("Cannot resolve @donotdev/core/empty \u2014 package setup is broken");
7610
+ if (!resolved)
7611
+ throw new Error(
7612
+ "Cannot resolve @donotdev/core/empty \u2014 package setup is broken"
7613
+ );
7611
7614
  return resolved;
7612
7615
  }
7613
7616
  // === PRIVATE METHODS ===
@@ -7916,12 +7919,10 @@ function createAppEnv(appPath) {
7916
7919
  function spawnCrossPlatform(command, args, options) {
7917
7920
  const isWindows = platform() === "win32";
7918
7921
  const useShell = options.shell ?? isWindows;
7922
+ const { shell: _3, ...rest } = options;
7919
7923
  if (useShell) {
7920
- const fullCommand = `${command} ${args.join(" ")}`;
7921
- const { shell: _4, ...rest2 } = options;
7922
- return spawn(fullCommand, [], { ...rest2, shell: true });
7924
+ return spawn(command, args, { ...rest, shell: true });
7923
7925
  }
7924
- const { shell: _3, ...rest } = options;
7925
7926
  return spawn(command, args, rest);
7926
7927
  }
7927
7928
 
@@ -7340,7 +7340,10 @@ var init_PathResolver = __esm({
7340
7340
  */
7341
7341
  getEmptyCjsModulePath() {
7342
7342
  const resolved = this.resolvePackage("@donotdev/core/empty");
7343
- if (!resolved) throw new Error("Cannot resolve @donotdev/core/empty \u2014 package setup is broken");
7343
+ if (!resolved)
7344
+ throw new Error(
7345
+ "Cannot resolve @donotdev/core/empty \u2014 package setup is broken"
7346
+ );
7344
7347
  return resolved;
7345
7348
  }
7346
7349
  // === PRIVATE METHODS ===
@@ -7690,7 +7690,10 @@ var init_PathResolver = __esm({
7690
7690
  */
7691
7691
  getEmptyCjsModulePath() {
7692
7692
  const resolved = this.resolvePackage("@donotdev/core/empty");
7693
- if (!resolved) throw new Error("Cannot resolve @donotdev/core/empty \u2014 package setup is broken");
7693
+ if (!resolved)
7694
+ throw new Error(
7695
+ "Cannot resolve @donotdev/core/empty \u2014 package setup is broken"
7696
+ );
7694
7697
  return resolved;
7695
7698
  }
7696
7699
  // === PRIVATE METHODS ===
@@ -8045,12 +8048,10 @@ function createAppEnv(appPath) {
8045
8048
  function spawnCrossPlatform(command, args, options) {
8046
8049
  const isWindows = platform() === "win32";
8047
8050
  const useShell = options.shell ?? isWindows;
8051
+ const { shell: _3, ...rest } = options;
8048
8052
  if (useShell) {
8049
- const fullCommand = `${command} ${args.join(" ")}`;
8050
- const { shell: _4, ...rest2 } = options;
8051
- return spawn(fullCommand, [], { ...rest2, shell: true });
8053
+ return spawn(command, args, { ...rest, shell: true });
8052
8054
  }
8053
- const { shell: _3, ...rest } = options;
8054
8055
  return spawn(command, args, rest);
8055
8056
  }
8056
8057
  function createEmulatorEnv(appPath, framework = "vite", options) {
@@ -7311,7 +7311,10 @@ var init_PathResolver = __esm({
7311
7311
  */
7312
7312
  getEmptyCjsModulePath() {
7313
7313
  const resolved = this.resolvePackage("@donotdev/core/empty");
7314
- if (!resolved) throw new Error("Cannot resolve @donotdev/core/empty \u2014 package setup is broken");
7314
+ if (!resolved)
7315
+ throw new Error(
7316
+ "Cannot resolve @donotdev/core/empty \u2014 package setup is broken"
7317
+ );
7315
7318
  return resolved;
7316
7319
  }
7317
7320
  // === PRIVATE METHODS ===
@@ -7924,10 +7927,9 @@ async function runPrettier(rootDir, dryRun, verbose) {
7924
7927
  log.info("DRY RUN: Would run Prettier");
7925
7928
  return stats;
7926
7929
  }
7927
- const result = spawnSync(`bunx ${prettierArgs.join(" ")}`, {
7930
+ const result = spawnSync("bunx", prettierArgs, {
7928
7931
  cwd: rootDir,
7929
7932
  stdio: "pipe",
7930
- shell: true,
7931
7933
  encoding: "utf-8",
7932
7934
  env: { ...process.env }
7933
7935
  });