@donotdev/cli 0.1.0 → 0.1.1

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 (93) hide show
  1. package/dependencies-matrix.json +100 -50
  2. package/dist/bin/commands/agent-setup.js +245 -12
  3. package/dist/bin/commands/build.js +3339 -208
  4. package/dist/bin/commands/bump.js +245 -12
  5. package/dist/bin/commands/cacheout.js +245 -12
  6. package/dist/bin/commands/coach.js +361 -60
  7. package/dist/bin/commands/create-app.js +245 -12
  8. package/dist/bin/commands/create-project.js +253 -12
  9. package/dist/bin/commands/db.js +9114 -2327
  10. package/dist/bin/commands/deploy.js +4074 -694
  11. package/dist/bin/commands/dev.js +347 -33
  12. package/dist/bin/commands/doctor.js +408 -107
  13. package/dist/bin/commands/emu.js +386 -52
  14. package/dist/bin/commands/format.js +245 -12
  15. package/dist/bin/commands/get-demo.js +245 -12
  16. package/dist/bin/commands/make-admin.js +8356 -1516
  17. package/dist/bin/commands/preview.js +347 -33
  18. package/dist/bin/commands/seed.js +9114 -2327
  19. package/dist/bin/commands/setup-cicd.js +452 -132
  20. package/dist/bin/commands/setup.js +407 -107
  21. package/dist/bin/commands/staging.js +4074 -694
  22. package/dist/bin/commands/sync-secrets.js +246 -13
  23. package/dist/bin/commands/type-check.js +245 -12
  24. package/dist/bin/commands/wai.js +245 -12
  25. package/dist/bin/dndev.js +13 -4
  26. package/dist/bin/donotdev.js +13 -4
  27. package/dist/index.js +4169 -812
  28. package/{templates/root-consumer/guides/dndev/advanced/VERSION_CONTROL.md.example → guidelines/VERSION_CONTROL.md} +7 -11
  29. package/package.json +2 -1
  30. package/templates/app-demo/src/themes.css.example +21 -0
  31. package/templates/app-dndev/index.html.example +0 -3
  32. package/templates/app-dndev/src/themes.css.example +21 -0
  33. package/templates/app-next/src/app/layout.tsx.example +13 -4
  34. package/templates/app-next/src/themes.css.example +21 -0
  35. package/templates/app-vite/csp.example.json +44 -0
  36. package/templates/app-vite/index.html.example +0 -3
  37. package/templates/app-vite/src/themes.css.example +21 -0
  38. package/templates/functions-supabase/supabase/migrations/20250101000000_idempotency.sql +3 -0
  39. package/templates/functions-supabase/supabase/migrations/20250101000001_rate_limits.sql +3 -0
  40. package/templates/functions-supabase/supabase/migrations/20250101000003_operation_metrics.sql +3 -0
  41. package/templates/root-consumer/.claude/hooks/framework-compliance.sh.example +56 -0
  42. package/templates/root-consumer/.claude/hooks/guard-bash.sh.example +61 -0
  43. package/templates/root-consumer/.claude/hooks/guard-files.sh.example +46 -0
  44. package/templates/root-consumer/.claude/hooks/guard-mcp.sh.example +91 -0
  45. package/templates/root-consumer/.claude/hooks/guard-secrets.sh.example +67 -0
  46. package/templates/root-consumer/.claude/hooks/guard-write.sh.example +89 -0
  47. package/templates/root-consumer/.claude/hooks/session-start.sh.example +50 -0
  48. package/templates/root-consumer/.claude/hooks/track-mcp-lookup.sh.example +20 -0
  49. package/templates/root-consumer/.claude/hooks/typecheck-stop.sh.example +18 -0
  50. package/templates/root-consumer/.claude/rules/consumer-ux.md.example +32 -0
  51. package/templates/root-consumer/.claude/rules/definition-of-done.md.example +32 -0
  52. package/templates/root-consumer/.claude/rules/framework.md.example +39 -0
  53. package/templates/root-consumer/.claude/rules/git.md.example +14 -0
  54. package/templates/root-consumer/.claude/rules/security.md.example +13 -0
  55. package/templates/root-consumer/.claude/settings.json.example +123 -1
  56. package/templates/root-consumer/.claude/skills/build/SKILL.md.example +103 -25
  57. package/templates/root-consumer/.claude/skills/grill/SKILL.md.example +26 -15
  58. package/templates/root-consumer/.claude/skills/polish/SKILL.md.example +50 -37
  59. package/templates/root-consumer/AI.md.example +2 -2
  60. package/templates/root-consumer/CLAUDE.md.example +33 -1
  61. package/templates/root-consumer/guides/dndev/INDEX.md.example +23 -27
  62. package/templates/root-consumer/guides/dndev/SETUP_AUTH.md.example +3 -2
  63. package/templates/root-consumer/guides/dndev/SETUP_OAUTH.md.example +10 -5
  64. package/templates/root-consumer/guides/dndev/SETUP_SUPABASE.md.example +50 -3
  65. package/templates/root-consumer/guides/wai-way/blueprints/3_compose.md.example +13 -15
  66. package/templates/app-demo/public/manifest.json.example +0 -10
  67. package/templates/app-dndev/public/manifest.json.example +0 -10
  68. package/templates/root-consumer/.claude/commands/brainstorm.md.example +0 -175
  69. package/templates/root-consumer/.claude/commands/build.md.example +0 -131
  70. package/templates/root-consumer/.claude/commands/design.md.example +0 -184
  71. package/templates/root-consumer/.claude/commands/grill.md.example +0 -135
  72. package/templates/root-consumer/.claude/commands/polish.md.example +0 -146
  73. package/templates/root-consumer/.claude/commands/techdebt.md.example +0 -28
  74. package/templates/root-consumer/guides/dndev/COMPONENTS_ATOMIC.md.example +0 -180
  75. package/templates/root-consumer/guides/dndev/COMPONENTS_CRUD.md.example +0 -234
  76. package/templates/root-consumer/guides/dndev/COMPONENTS_UI.md.example +0 -136
  77. package/templates/root-consumer/guides/dndev/COMPONENT_API.md.example +0 -195
  78. package/templates/root-consumer/guides/dndev/ENV_SETUP.md.example +0 -219
  79. package/templates/root-consumer/guides/dndev/GOTCHAS.md.example +0 -197
  80. package/templates/root-consumer/guides/dndev/SETUP_APP_CONFIG.md.example +0 -132
  81. package/templates/root-consumer/guides/dndev/SETUP_BLOG.md.example +0 -280
  82. package/templates/root-consumer/guides/dndev/SETUP_CICD.md.example +0 -115
  83. package/templates/root-consumer/guides/dndev/SETUP_CRUD.md.example +0 -334
  84. package/templates/root-consumer/guides/dndev/SETUP_FUNCTIONS.md.example +0 -9
  85. package/templates/root-consumer/guides/dndev/SETUP_I18N.md.example +0 -233
  86. package/templates/root-consumer/guides/dndev/SETUP_LAYOUTS.md.example +0 -158
  87. package/templates/root-consumer/guides/dndev/SETUP_PAGES.md.example +0 -205
  88. package/templates/root-consumer/guides/dndev/SETUP_PWA.md.example +0 -213
  89. package/templates/root-consumer/guides/dndev/SETUP_TESTING.md.example +0 -184
  90. package/templates/root-consumer/guides/dndev/SETUP_THEMES.md.example +0 -111
  91. package/templates/root-consumer/guides/dndev/SETUP_VERCEL.md.example +0 -260
  92. package/templates/root-consumer/guides/dndev/USE_ROUTING.md.example +0 -499
  93. package/templates/root-consumer/guides/dndev/essences_reference.css.example +0 -288
@@ -2035,14 +2035,15 @@ var require_braces = __commonJS({
2035
2035
  }
2036
2036
  });
2037
2037
 
2038
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/constants.js
2038
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/constants.js
2039
2039
  var require_constants2 = __commonJS({
2040
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/constants.js"(exports, module) {
2040
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/constants.js"(exports, module) {
2041
2041
  "use strict";
2042
2042
  init_utils();
2043
2043
  var path = __require("path");
2044
2044
  var WIN_SLASH = "\\\\/";
2045
2045
  var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
2046
+ var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
2046
2047
  var DOT_LITERAL = "\\.";
2047
2048
  var PLUS_LITERAL = "\\+";
2048
2049
  var QMARK_LITERAL = "\\?";
@@ -2090,6 +2091,7 @@ var require_constants2 = __commonJS({
2090
2091
  END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
2091
2092
  };
2092
2093
  var POSIX_REGEX_SOURCE = {
2094
+ __proto__: null,
2093
2095
  alnum: "a-zA-Z0-9",
2094
2096
  alpha: "a-zA-Z",
2095
2097
  ascii: "\\x00-\\x7F",
@@ -2106,6 +2108,7 @@ var require_constants2 = __commonJS({
2106
2108
  xdigit: "A-Fa-f0-9"
2107
2109
  };
2108
2110
  module.exports = {
2111
+ DEFAULT_MAX_EXTGLOB_RECURSION,
2109
2112
  MAX_LENGTH: 1024 * 64,
2110
2113
  POSIX_REGEX_SOURCE,
2111
2114
  // regular expressions
@@ -2117,6 +2120,7 @@ var require_constants2 = __commonJS({
2117
2120
  REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
2118
2121
  // Replace globs with equivalent patterns to reduce parsing time.
2119
2122
  REPLACEMENTS: {
2123
+ __proto__: null,
2120
2124
  "***": "*",
2121
2125
  "**/**": "**",
2122
2126
  "**/**/**": "**"
@@ -2233,9 +2237,9 @@ var require_constants2 = __commonJS({
2233
2237
  }
2234
2238
  });
2235
2239
 
2236
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/utils.js
2240
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/utils.js
2237
2241
  var require_utils2 = __commonJS({
2238
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/utils.js"(exports) {
2242
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/utils.js"(exports) {
2239
2243
  "use strict";
2240
2244
  init_utils();
2241
2245
  var path = __require("path");
@@ -2295,9 +2299,9 @@ var require_utils2 = __commonJS({
2295
2299
  }
2296
2300
  });
2297
2301
 
2298
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/scan.js
2302
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/scan.js
2299
2303
  var require_scan = __commonJS({
2300
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/scan.js"(exports, module) {
2304
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/scan.js"(exports, module) {
2301
2305
  "use strict";
2302
2306
  init_utils();
2303
2307
  var utils = require_utils2();
@@ -2626,9 +2630,9 @@ var require_scan = __commonJS({
2626
2630
  }
2627
2631
  });
2628
2632
 
2629
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/parse.js
2633
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/parse.js
2630
2634
  var require_parse2 = __commonJS({
2631
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/parse.js"(exports, module) {
2635
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/parse.js"(exports, module) {
2632
2636
  "use strict";
2633
2637
  init_utils();
2634
2638
  var constants2 = require_constants2();
@@ -2656,6 +2660,213 @@ var require_parse2 = __commonJS({
2656
2660
  var syntaxError = (type, char) => {
2657
2661
  return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
2658
2662
  };
2663
+ var splitTopLevel = (input) => {
2664
+ const parts = [];
2665
+ let bracket = 0;
2666
+ let paren = 0;
2667
+ let quote = 0;
2668
+ let value = "";
2669
+ let escaped = false;
2670
+ for (const ch of input) {
2671
+ if (escaped === true) {
2672
+ value += ch;
2673
+ escaped = false;
2674
+ continue;
2675
+ }
2676
+ if (ch === "\\") {
2677
+ value += ch;
2678
+ escaped = true;
2679
+ continue;
2680
+ }
2681
+ if (ch === '"') {
2682
+ quote = quote === 1 ? 0 : 1;
2683
+ value += ch;
2684
+ continue;
2685
+ }
2686
+ if (quote === 0) {
2687
+ if (ch === "[") {
2688
+ bracket++;
2689
+ } else if (ch === "]" && bracket > 0) {
2690
+ bracket--;
2691
+ } else if (bracket === 0) {
2692
+ if (ch === "(") {
2693
+ paren++;
2694
+ } else if (ch === ")" && paren > 0) {
2695
+ paren--;
2696
+ } else if (ch === "|" && paren === 0) {
2697
+ parts.push(value);
2698
+ value = "";
2699
+ continue;
2700
+ }
2701
+ }
2702
+ }
2703
+ value += ch;
2704
+ }
2705
+ parts.push(value);
2706
+ return parts;
2707
+ };
2708
+ var isPlainBranch = (branch) => {
2709
+ let escaped = false;
2710
+ for (const ch of branch) {
2711
+ if (escaped === true) {
2712
+ escaped = false;
2713
+ continue;
2714
+ }
2715
+ if (ch === "\\") {
2716
+ escaped = true;
2717
+ continue;
2718
+ }
2719
+ if (/[?*+@!()[\]{}]/.test(ch)) {
2720
+ return false;
2721
+ }
2722
+ }
2723
+ return true;
2724
+ };
2725
+ var normalizeSimpleBranch = (branch) => {
2726
+ let value = branch.trim();
2727
+ let changed = true;
2728
+ while (changed === true) {
2729
+ changed = false;
2730
+ if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
2731
+ value = value.slice(2, -1);
2732
+ changed = true;
2733
+ }
2734
+ }
2735
+ if (!isPlainBranch(value)) {
2736
+ return;
2737
+ }
2738
+ return value.replace(/\\(.)/g, "$1");
2739
+ };
2740
+ var hasRepeatedCharPrefixOverlap = (branches) => {
2741
+ const values = branches.map(normalizeSimpleBranch).filter(Boolean);
2742
+ for (let i = 0; i < values.length; i++) {
2743
+ for (let j2 = i + 1; j2 < values.length; j2++) {
2744
+ const a = values[i];
2745
+ const b2 = values[j2];
2746
+ const char = a[0];
2747
+ if (!char || a !== char.repeat(a.length) || b2 !== char.repeat(b2.length)) {
2748
+ continue;
2749
+ }
2750
+ if (a === b2 || a.startsWith(b2) || b2.startsWith(a)) {
2751
+ return true;
2752
+ }
2753
+ }
2754
+ }
2755
+ return false;
2756
+ };
2757
+ var parseRepeatedExtglob = (pattern, requireEnd = true) => {
2758
+ if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
2759
+ return;
2760
+ }
2761
+ let bracket = 0;
2762
+ let paren = 0;
2763
+ let quote = 0;
2764
+ let escaped = false;
2765
+ for (let i = 1; i < pattern.length; i++) {
2766
+ const ch = pattern[i];
2767
+ if (escaped === true) {
2768
+ escaped = false;
2769
+ continue;
2770
+ }
2771
+ if (ch === "\\") {
2772
+ escaped = true;
2773
+ continue;
2774
+ }
2775
+ if (ch === '"') {
2776
+ quote = quote === 1 ? 0 : 1;
2777
+ continue;
2778
+ }
2779
+ if (quote === 1) {
2780
+ continue;
2781
+ }
2782
+ if (ch === "[") {
2783
+ bracket++;
2784
+ continue;
2785
+ }
2786
+ if (ch === "]" && bracket > 0) {
2787
+ bracket--;
2788
+ continue;
2789
+ }
2790
+ if (bracket > 0) {
2791
+ continue;
2792
+ }
2793
+ if (ch === "(") {
2794
+ paren++;
2795
+ continue;
2796
+ }
2797
+ if (ch === ")") {
2798
+ paren--;
2799
+ if (paren === 0) {
2800
+ if (requireEnd === true && i !== pattern.length - 1) {
2801
+ return;
2802
+ }
2803
+ return {
2804
+ type: pattern[0],
2805
+ body: pattern.slice(2, i),
2806
+ end: i
2807
+ };
2808
+ }
2809
+ }
2810
+ }
2811
+ };
2812
+ var getStarExtglobSequenceOutput = (pattern) => {
2813
+ let index = 0;
2814
+ const chars = [];
2815
+ while (index < pattern.length) {
2816
+ const match = parseRepeatedExtglob(pattern.slice(index), false);
2817
+ if (!match || match.type !== "*") {
2818
+ return;
2819
+ }
2820
+ const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
2821
+ if (branches.length !== 1) {
2822
+ return;
2823
+ }
2824
+ const branch = normalizeSimpleBranch(branches[0]);
2825
+ if (!branch || branch.length !== 1) {
2826
+ return;
2827
+ }
2828
+ chars.push(branch);
2829
+ index += match.end + 1;
2830
+ }
2831
+ if (chars.length < 1) {
2832
+ return;
2833
+ }
2834
+ const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
2835
+ return `${source}*`;
2836
+ };
2837
+ var repeatedExtglobRecursion = (pattern) => {
2838
+ let depth = 0;
2839
+ let value = pattern.trim();
2840
+ let match = parseRepeatedExtglob(value);
2841
+ while (match) {
2842
+ depth++;
2843
+ value = match.body.trim();
2844
+ match = parseRepeatedExtglob(value);
2845
+ }
2846
+ return depth;
2847
+ };
2848
+ var analyzeRepeatedExtglob = (body, options) => {
2849
+ if (options.maxExtglobRecursion === false) {
2850
+ return { risky: false };
2851
+ }
2852
+ const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants2.DEFAULT_MAX_EXTGLOB_RECURSION;
2853
+ const branches = splitTopLevel(body).map((branch) => branch.trim());
2854
+ if (branches.length > 1) {
2855
+ if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
2856
+ return { risky: true };
2857
+ }
2858
+ }
2859
+ for (const branch of branches) {
2860
+ const safeOutput = getStarExtglobSequenceOutput(branch);
2861
+ if (safeOutput) {
2862
+ return { risky: true, safeOutput };
2863
+ }
2864
+ if (repeatedExtglobRecursion(branch) > max) {
2865
+ return { risky: true };
2866
+ }
2867
+ }
2868
+ return { risky: false };
2869
+ };
2659
2870
  var parse2 = (input, options) => {
2660
2871
  if (typeof input !== "string") {
2661
2872
  throw new TypeError("Expected a string");
@@ -2787,6 +2998,8 @@ var require_parse2 = __commonJS({
2787
2998
  token.prev = prev;
2788
2999
  token.parens = state.parens;
2789
3000
  token.output = state.output;
3001
+ token.startIndex = state.index;
3002
+ token.tokensIndex = tokens.length;
2790
3003
  const output = (opts.capture ? "(" : "") + token.open;
2791
3004
  increment("parens");
2792
3005
  push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
@@ -2794,6 +3007,26 @@ var require_parse2 = __commonJS({
2794
3007
  extglobs.push(token);
2795
3008
  };
2796
3009
  const extglobClose = (token) => {
3010
+ const literal = input.slice(token.startIndex, state.index + 1);
3011
+ const body = input.slice(token.startIndex + 2, state.index);
3012
+ const analysis = analyzeRepeatedExtglob(body, opts);
3013
+ if ((token.type === "plus" || token.type === "star") && analysis.risky) {
3014
+ const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
3015
+ const open = tokens[token.tokensIndex];
3016
+ open.type = "text";
3017
+ open.value = literal;
3018
+ open.output = safeOutput || utils.escapeRegex(literal);
3019
+ for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
3020
+ tokens[i].value = "";
3021
+ tokens[i].output = "";
3022
+ delete tokens[i].suffix;
3023
+ }
3024
+ state.output = token.output + open.output;
3025
+ state.backtrack = true;
3026
+ push({ type: "paren", extglob: true, value, output: "" });
3027
+ decrement("parens");
3028
+ return;
3029
+ }
2797
3030
  let output = token.close + (opts.capture ? ")" : "");
2798
3031
  let rest;
2799
3032
  if (token.type === "negate") {
@@ -3400,9 +3633,9 @@ var require_parse2 = __commonJS({
3400
3633
  }
3401
3634
  });
3402
3635
 
3403
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js
3636
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js
3404
3637
  var require_picomatch = __commonJS({
3405
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js"(exports, module) {
3638
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js"(exports, module) {
3406
3639
  "use strict";
3407
3640
  init_utils();
3408
3641
  var path = __require("path");
@@ -3542,9 +3775,9 @@ var require_picomatch = __commonJS({
3542
3775
  }
3543
3776
  });
3544
3777
 
3545
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/index.js
3778
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/index.js
3546
3779
  var require_picomatch2 = __commonJS({
3547
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/index.js"(exports, module) {
3780
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/index.js"(exports, module) {
3548
3781
  "use strict";
3549
3782
  init_utils();
3550
3783
  module.exports = require_picomatch();
@@ -7484,6 +7717,14 @@ var init_utils = __esm({
7484
7717
  });
7485
7718
 
7486
7719
  // packages/tooling/src/utils/app-detection.ts
7720
+ function createRootAppInfo(projectRoot) {
7721
+ return {
7722
+ name: "root",
7723
+ packageName: "root",
7724
+ path: projectRoot,
7725
+ framework: "vite"
7726
+ };
7727
+ }
7487
7728
  function detectApps(projectRoot) {
7488
7729
  const apps = [];
7489
7730
  const appsDir = joinPath(projectRoot, "apps");
@@ -7539,45 +7780,175 @@ function analyzeApp(appPath, appName) {
7539
7780
  } else if (pathExists(joinPath(appPath, "vite.config.ts")) || pathExists(joinPath(appPath, "vite.config.js")) || pathExists(joinPath(appPath, "vite.config.mjs")) || packageJson.dependencies?.vite || packageJson.devDependencies?.vite) {
7540
7781
  framework = "vite";
7541
7782
  }
7542
- const functionsPath = joinPath(appPath, "functions");
7543
- const functionsStat = statSync2(functionsPath);
7544
- const hasFunctions = pathExists(functionsPath) && (functionsStat?.isDirectory() ?? false);
7545
- let platform;
7546
- const firebaseJsonInFunctions = hasFunctions && pathExists(joinPath(functionsPath, "firebase.json"));
7547
- const firebaseJsonInApp = pathExists(joinPath(appPath, "firebase.json"));
7548
- if (firebaseJsonInFunctions || firebaseJsonInApp) {
7549
- platform = "firebase";
7783
+ const firebaseJsonPath = joinPath(appPath, "firebase.json");
7784
+ const hasFirebase = pathExists(firebaseJsonPath);
7785
+ const supabaseDir = joinPath(appPath, "supabase");
7786
+ const supabaseConfigPath = joinPath(supabaseDir, "config.toml");
7787
+ const hasSupabaseDep = !!(packageJson.dependencies?.["@donotdev/supabase"] || packageJson.dependencies?.["@supabase/supabase-js"]);
7788
+ let hasSupabase = pathExists(supabaseDir) || pathExists(supabaseConfigPath) || hasSupabaseDep;
7789
+ if (!hasSupabase) {
7790
+ try {
7791
+ const envPath = joinPath(appPath, ".env");
7792
+ if (pathExists(envPath)) {
7793
+ const envContent = readSync(envPath);
7794
+ if (envContent.match(/VITE_SUPABASE_URL=.+/)) {
7795
+ hasSupabase = true;
7796
+ }
7797
+ }
7798
+ } catch {
7799
+ }
7800
+ }
7801
+ let provider = "unknown";
7802
+ if (hasFirebase && hasSupabase) {
7803
+ provider = "both";
7804
+ } else if (hasFirebase) {
7805
+ provider = "firebase";
7806
+ } else if (hasSupabase) {
7807
+ provider = "supabase";
7808
+ }
7809
+ let firebaseConfig;
7810
+ if (hasFirebase) {
7811
+ try {
7812
+ const config = readSync(firebaseJsonPath, { format: "json" });
7813
+ if (config && typeof config === "object") {
7814
+ const fb = config;
7815
+ firebaseConfig = {
7816
+ projectId: fb.projectId,
7817
+ hasHosting: !!fb.hosting,
7818
+ hasFunctions: !!fb.functions,
7819
+ hasFirestoreRules: !!fb.firestore?.rules,
7820
+ hasStorageRules: !!fb.storage?.rules
7821
+ };
7822
+ }
7823
+ } catch {
7824
+ firebaseConfig = {
7825
+ hasHosting: false,
7826
+ hasFunctions: false,
7827
+ hasFirestoreRules: false,
7828
+ hasStorageRules: false
7829
+ };
7830
+ }
7550
7831
  }
7551
- if (!platform) {
7552
- const supabaseConfigPath = joinPath(appPath, "supabase", "config.toml");
7553
- const hasSupabaseDep = !!(packageJson.dependencies?.["@donotdev/supabase"] || packageJson.dependencies?.["@supabase/supabase-js"]);
7554
- if (pathExists(supabaseConfigPath) || hasSupabaseDep) {
7555
- platform = "supabase";
7832
+ const supabaseFunctionsDir = joinPath(supabaseDir, "functions");
7833
+ const supabaseMigrationsDir = joinPath(supabaseDir, "migrations");
7834
+ let supabaseConfig;
7835
+ if (hasSupabase) {
7836
+ let url;
7837
+ try {
7838
+ const envPath = joinPath(appPath, ".env");
7839
+ if (pathExists(envPath)) {
7840
+ const envContent = readSync(envPath);
7841
+ const urlMatch = envContent.match(/VITE_SUPABASE_URL=(.+)/);
7842
+ if (urlMatch && urlMatch[1]) {
7843
+ url = urlMatch[1].trim();
7844
+ }
7845
+ }
7846
+ } catch {
7847
+ }
7848
+ supabaseConfig = {
7849
+ url,
7850
+ hasFunctions: pathExists(supabaseFunctionsDir),
7851
+ hasMigrations: pathExists(supabaseMigrationsDir)
7852
+ };
7853
+ }
7854
+ let functions;
7855
+ if (hasFirebase && firebaseConfig?.hasFunctions) {
7856
+ const firebaseFunctionsDir = joinPath(appPath, "functions");
7857
+ const firebaseFunctionsStat = statSync2(firebaseFunctionsDir);
7858
+ if (pathExists(firebaseFunctionsDir) && (firebaseFunctionsStat?.isDirectory() ?? false)) {
7859
+ functions = "firebase";
7556
7860
  }
7557
7861
  }
7558
- if (!platform) {
7862
+ if (!functions && hasSupabase) {
7863
+ const sbFunctionsStat = statSync2(supabaseFunctionsDir);
7864
+ if (pathExists(supabaseFunctionsDir) && (sbFunctionsStat?.isDirectory() ?? false)) {
7865
+ functions = "supabase";
7866
+ }
7867
+ }
7868
+ if (!functions) {
7559
7869
  const vercelJsonPath = joinPath(appPath, "vercel.json");
7560
- if (pathExists(vercelJsonPath)) {
7561
- platform = "vercel";
7870
+ const apiDir = joinPath(appPath, "api");
7871
+ const apiDirStat = statSync2(apiDir);
7872
+ if (pathExists(vercelJsonPath) && pathExists(apiDir) && (apiDirStat?.isDirectory() ?? false)) {
7873
+ functions = "vercel";
7874
+ }
7875
+ }
7876
+ let hosting;
7877
+ if (hasFirebase && firebaseConfig?.hasHosting) {
7878
+ hosting = "firebase";
7879
+ }
7880
+ if (!hosting) {
7881
+ if (pathExists(joinPath(appPath, "vercel.json")) || pathExists(joinPath(appPath, ".vercel"))) {
7882
+ hosting = "vercel";
7562
7883
  }
7563
7884
  }
7564
7885
  return {
7565
7886
  name: appName,
7566
7887
  packageName: packageJson.name || appName,
7567
7888
  path: appPath,
7568
- packageJsonPath,
7569
7889
  framework,
7570
- hasFunctions,
7571
- functionsPath: hasFunctions ? functionsPath : void 0,
7572
- platform
7890
+ provider,
7891
+ functions,
7892
+ hosting,
7893
+ firebaseConfig,
7894
+ supabaseConfig
7573
7895
  };
7574
7896
  }
7897
+ function detectBackendFromProviders(appDir) {
7898
+ for (const candidate of PROVIDERS_CANDIDATES) {
7899
+ const filePath = joinPath(appDir, candidate);
7900
+ if (!pathExists(filePath)) continue;
7901
+ const content = readSync(filePath, { format: "text" });
7902
+ if (typeof content !== "string") continue;
7903
+ if (content.includes("@donotdev/firebase") || content.includes("FirebaseAuth") || content.includes("firebaseAuth")) {
7904
+ return "firebase";
7905
+ }
7906
+ if (content.includes("@donotdev/supabase") || content.includes("SupabaseAuth") || content.includes("supabaseAuth")) {
7907
+ return "supabase";
7908
+ }
7909
+ break;
7910
+ }
7911
+ return null;
7912
+ }
7913
+ function analyzeProjectTopology(projectRoot) {
7914
+ const apps = detectApps(projectRoot);
7915
+ const appBackends = /* @__PURE__ */ new Map();
7916
+ const backendOwners = /* @__PURE__ */ new Map();
7917
+ for (const app of apps) {
7918
+ let backend = app.provider === "firebase" || app.provider === "supabase" ? app.provider : null;
7919
+ if (!backend) {
7920
+ backend = detectBackendFromProviders(app.path);
7921
+ }
7922
+ appBackends.set(app.name, backend);
7923
+ if (pathExists(joinPath(app.path, "supabase", "config.toml"))) {
7924
+ backendOwners.set("supabase", app);
7925
+ }
7926
+ if (pathExists(joinPath(app.path, "firebase.json")) || pathExists(joinPath(app.path, "functions", "firebase.json"))) {
7927
+ backendOwners.set("firebase", app);
7928
+ }
7929
+ }
7930
+ return { apps, appBackends, backendOwners };
7931
+ }
7932
+ function findBackendApp(topology, appName) {
7933
+ const backend = topology.appBackends.get(appName);
7934
+ if (!backend) return void 0;
7935
+ return topology.backendOwners.get(backend);
7936
+ }
7937
+ var PROVIDERS_CANDIDATES;
7575
7938
  var init_app_detection = __esm({
7576
7939
  "packages/tooling/src/utils/app-detection.ts"() {
7577
7940
  "use strict";
7578
7941
  init_utils();
7579
7942
  init_pathResolver();
7580
7943
  init_typed_file_operations();
7944
+ PROVIDERS_CANDIDATES = [
7945
+ "src/config/providers.ts",
7946
+ "src/config/providers.tsx",
7947
+ "src/providers.ts",
7948
+ "src/providers.tsx",
7949
+ "src/lib/providers.ts",
7950
+ "src/lib/providers.tsx"
7951
+ ];
7581
7952
  }
7582
7953
  });
7583
7954
 
@@ -7696,67 +8067,6 @@ var init_secrets_resolver = __esm({
7696
8067
  }
7697
8068
  });
7698
8069
 
7699
- // packages/tooling/src/utils/cross-app-detection.ts
7700
- function detectBackendFromProviders(appDir) {
7701
- for (const candidate of PROVIDERS_CANDIDATES) {
7702
- const filePath = joinPath(appDir, candidate);
7703
- if (!pathExists(filePath)) continue;
7704
- const content = readSync(filePath, { format: "text" });
7705
- if (typeof content !== "string") continue;
7706
- if (content.includes("@donotdev/firebase") || content.includes("FirebaseAuth") || content.includes("firebaseAuth")) {
7707
- return "firebase";
7708
- }
7709
- if (content.includes("@donotdev/supabase") || content.includes("SupabaseAuth") || content.includes("supabaseAuth")) {
7710
- return "supabase";
7711
- }
7712
- break;
7713
- }
7714
- return null;
7715
- }
7716
- function analyzeProjectTopology(projectRoot) {
7717
- const apps = detectApps(projectRoot);
7718
- const appBackends = /* @__PURE__ */ new Map();
7719
- const backendOwners = /* @__PURE__ */ new Map();
7720
- for (const app of apps) {
7721
- let backend = app.platform === "firebase" || app.platform === "supabase" ? app.platform : null;
7722
- if (!backend) {
7723
- backend = detectBackendFromProviders(app.path);
7724
- }
7725
- appBackends.set(app.name, backend);
7726
- if (pathExists(joinPath(app.path, "supabase", "config.toml"))) {
7727
- backendOwners.set("supabase", app);
7728
- }
7729
- if (pathExists(joinPath(app.path, "firebase.json")) || pathExists(joinPath(app.path, "functions", "firebase.json"))) {
7730
- backendOwners.set("firebase", app);
7731
- }
7732
- }
7733
- if (!backendOwners.has("firebase") && (pathExists(joinPath(projectRoot, "firebase.json")) || pathExists(joinPath(projectRoot, ".firebaserc")))) {
7734
- }
7735
- return { apps, appBackends, backendOwners };
7736
- }
7737
- function findBackendApp(topology, appName) {
7738
- const backend = topology.appBackends.get(appName);
7739
- if (!backend) return void 0;
7740
- return topology.backendOwners.get(backend);
7741
- }
7742
- var PROVIDERS_CANDIDATES;
7743
- var init_cross_app_detection = __esm({
7744
- "packages/tooling/src/utils/cross-app-detection.ts"() {
7745
- "use strict";
7746
- init_utils();
7747
- init_app_detection();
7748
- init_pathResolver();
7749
- PROVIDERS_CANDIDATES = [
7750
- "src/config/providers.ts",
7751
- "src/config/providers.tsx",
7752
- "src/providers.ts",
7753
- "src/providers.tsx",
7754
- "src/lib/providers.ts",
7755
- "src/lib/providers.tsx"
7756
- ];
7757
- }
7758
- });
7759
-
7760
8070
  // packages/tooling/src/cli/doctor/check-env.ts
7761
8071
  var check_env_exports = {};
7762
8072
  __export(check_env_exports, {
@@ -7879,7 +8189,7 @@ var init_check_firebase = __esm({
7879
8189
  "packages/tooling/src/cli/doctor/check-firebase.ts"() {
7880
8190
  "use strict";
7881
8191
  init_utils();
7882
- init_cross_app_detection();
8192
+ init_app_detection();
7883
8193
  init_pathResolver();
7884
8194
  firebaseCheck = {
7885
8195
  id: "firebase",
@@ -8039,7 +8349,7 @@ var init_check_supabase = __esm({
8039
8349
  "packages/tooling/src/cli/doctor/check-supabase.ts"() {
8040
8350
  "use strict";
8041
8351
  init_utils();
8042
- init_cross_app_detection();
8352
+ init_app_detection();
8043
8353
  init_pathResolver();
8044
8354
  init_secrets_resolver();
8045
8355
  init_supabase();
@@ -8251,9 +8561,9 @@ init_utils();
8251
8561
 
8252
8562
  // packages/tooling/src/cli/doctor/doctor.ts
8253
8563
  init_utils();
8564
+ init_app_detection();
8254
8565
  init_cli_output();
8255
- init_cross_app_detection();
8256
- init_pathResolver();
8566
+ init_app_detection();
8257
8567
  var CHECK_REGISTRY = [
8258
8568
  { id: "env", load: async () => (await Promise.resolve().then(() => (init_check_env(), check_env_exports))).envCheck },
8259
8569
  {
@@ -8308,16 +8618,7 @@ async function main(options = {}) {
8308
8618
  const topology = analyzeProjectTopology(projectRoot);
8309
8619
  let apps = topology.apps;
8310
8620
  if (apps.length === 0) {
8311
- apps = [
8312
- {
8313
- name: "root",
8314
- packageName: "root",
8315
- path: projectRoot,
8316
- packageJsonPath: joinPath(projectRoot, "package.json"),
8317
- framework: "vite",
8318
- hasFunctions: false
8319
- }
8320
- ];
8621
+ apps = [createRootAppInfo(projectRoot)];
8321
8622
  }
8322
8623
  const multiApp = apps.length > 1;
8323
8624
  const registry = options.check ? CHECK_REGISTRY.filter((e2) => e2.id === options.check) : CHECK_REGISTRY;