@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
@@ -2489,14 +2489,15 @@ var require_braces = __commonJS({
2489
2489
  }
2490
2490
  });
2491
2491
 
2492
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/constants.js
2492
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/constants.js
2493
2493
  var require_constants2 = __commonJS({
2494
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/constants.js"(exports, module) {
2494
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/constants.js"(exports, module) {
2495
2495
  "use strict";
2496
2496
  init_utils();
2497
2497
  var path = __require("path");
2498
2498
  var WIN_SLASH = "\\\\/";
2499
2499
  var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
2500
+ var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
2500
2501
  var DOT_LITERAL = "\\.";
2501
2502
  var PLUS_LITERAL = "\\+";
2502
2503
  var QMARK_LITERAL = "\\?";
@@ -2544,6 +2545,7 @@ var require_constants2 = __commonJS({
2544
2545
  END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
2545
2546
  };
2546
2547
  var POSIX_REGEX_SOURCE = {
2548
+ __proto__: null,
2547
2549
  alnum: "a-zA-Z0-9",
2548
2550
  alpha: "a-zA-Z",
2549
2551
  ascii: "\\x00-\\x7F",
@@ -2560,6 +2562,7 @@ var require_constants2 = __commonJS({
2560
2562
  xdigit: "A-Fa-f0-9"
2561
2563
  };
2562
2564
  module.exports = {
2565
+ DEFAULT_MAX_EXTGLOB_RECURSION,
2563
2566
  MAX_LENGTH: 1024 * 64,
2564
2567
  POSIX_REGEX_SOURCE,
2565
2568
  // regular expressions
@@ -2571,6 +2574,7 @@ var require_constants2 = __commonJS({
2571
2574
  REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
2572
2575
  // Replace globs with equivalent patterns to reduce parsing time.
2573
2576
  REPLACEMENTS: {
2577
+ __proto__: null,
2574
2578
  "***": "*",
2575
2579
  "**/**": "**",
2576
2580
  "**/**/**": "**"
@@ -2687,9 +2691,9 @@ var require_constants2 = __commonJS({
2687
2691
  }
2688
2692
  });
2689
2693
 
2690
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/utils.js
2694
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/utils.js
2691
2695
  var require_utils2 = __commonJS({
2692
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/utils.js"(exports) {
2696
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/utils.js"(exports) {
2693
2697
  "use strict";
2694
2698
  init_utils();
2695
2699
  var path = __require("path");
@@ -2749,9 +2753,9 @@ var require_utils2 = __commonJS({
2749
2753
  }
2750
2754
  });
2751
2755
 
2752
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/scan.js
2756
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/scan.js
2753
2757
  var require_scan = __commonJS({
2754
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/scan.js"(exports, module) {
2758
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/scan.js"(exports, module) {
2755
2759
  "use strict";
2756
2760
  init_utils();
2757
2761
  var utils = require_utils2();
@@ -3080,9 +3084,9 @@ var require_scan = __commonJS({
3080
3084
  }
3081
3085
  });
3082
3086
 
3083
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/parse.js
3087
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/parse.js
3084
3088
  var require_parse2 = __commonJS({
3085
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/parse.js"(exports, module) {
3089
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/parse.js"(exports, module) {
3086
3090
  "use strict";
3087
3091
  init_utils();
3088
3092
  var constants2 = require_constants2();
@@ -3110,6 +3114,213 @@ var require_parse2 = __commonJS({
3110
3114
  var syntaxError = (type, char) => {
3111
3115
  return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
3112
3116
  };
3117
+ var splitTopLevel = (input) => {
3118
+ const parts = [];
3119
+ let bracket = 0;
3120
+ let paren = 0;
3121
+ let quote = 0;
3122
+ let value = "";
3123
+ let escaped = false;
3124
+ for (const ch of input) {
3125
+ if (escaped === true) {
3126
+ value += ch;
3127
+ escaped = false;
3128
+ continue;
3129
+ }
3130
+ if (ch === "\\") {
3131
+ value += ch;
3132
+ escaped = true;
3133
+ continue;
3134
+ }
3135
+ if (ch === '"') {
3136
+ quote = quote === 1 ? 0 : 1;
3137
+ value += ch;
3138
+ continue;
3139
+ }
3140
+ if (quote === 0) {
3141
+ if (ch === "[") {
3142
+ bracket++;
3143
+ } else if (ch === "]" && bracket > 0) {
3144
+ bracket--;
3145
+ } else if (bracket === 0) {
3146
+ if (ch === "(") {
3147
+ paren++;
3148
+ } else if (ch === ")" && paren > 0) {
3149
+ paren--;
3150
+ } else if (ch === "|" && paren === 0) {
3151
+ parts.push(value);
3152
+ value = "";
3153
+ continue;
3154
+ }
3155
+ }
3156
+ }
3157
+ value += ch;
3158
+ }
3159
+ parts.push(value);
3160
+ return parts;
3161
+ };
3162
+ var isPlainBranch = (branch) => {
3163
+ let escaped = false;
3164
+ for (const ch of branch) {
3165
+ if (escaped === true) {
3166
+ escaped = false;
3167
+ continue;
3168
+ }
3169
+ if (ch === "\\") {
3170
+ escaped = true;
3171
+ continue;
3172
+ }
3173
+ if (/[?*+@!()[\]{}]/.test(ch)) {
3174
+ return false;
3175
+ }
3176
+ }
3177
+ return true;
3178
+ };
3179
+ var normalizeSimpleBranch = (branch) => {
3180
+ let value = branch.trim();
3181
+ let changed = true;
3182
+ while (changed === true) {
3183
+ changed = false;
3184
+ if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
3185
+ value = value.slice(2, -1);
3186
+ changed = true;
3187
+ }
3188
+ }
3189
+ if (!isPlainBranch(value)) {
3190
+ return;
3191
+ }
3192
+ return value.replace(/\\(.)/g, "$1");
3193
+ };
3194
+ var hasRepeatedCharPrefixOverlap = (branches) => {
3195
+ const values = branches.map(normalizeSimpleBranch).filter(Boolean);
3196
+ for (let i = 0; i < values.length; i++) {
3197
+ for (let j2 = i + 1; j2 < values.length; j2++) {
3198
+ const a = values[i];
3199
+ const b3 = values[j2];
3200
+ const char = a[0];
3201
+ if (!char || a !== char.repeat(a.length) || b3 !== char.repeat(b3.length)) {
3202
+ continue;
3203
+ }
3204
+ if (a === b3 || a.startsWith(b3) || b3.startsWith(a)) {
3205
+ return true;
3206
+ }
3207
+ }
3208
+ }
3209
+ return false;
3210
+ };
3211
+ var parseRepeatedExtglob = (pattern, requireEnd = true) => {
3212
+ if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
3213
+ return;
3214
+ }
3215
+ let bracket = 0;
3216
+ let paren = 0;
3217
+ let quote = 0;
3218
+ let escaped = false;
3219
+ for (let i = 1; i < pattern.length; i++) {
3220
+ const ch = pattern[i];
3221
+ if (escaped === true) {
3222
+ escaped = false;
3223
+ continue;
3224
+ }
3225
+ if (ch === "\\") {
3226
+ escaped = true;
3227
+ continue;
3228
+ }
3229
+ if (ch === '"') {
3230
+ quote = quote === 1 ? 0 : 1;
3231
+ continue;
3232
+ }
3233
+ if (quote === 1) {
3234
+ continue;
3235
+ }
3236
+ if (ch === "[") {
3237
+ bracket++;
3238
+ continue;
3239
+ }
3240
+ if (ch === "]" && bracket > 0) {
3241
+ bracket--;
3242
+ continue;
3243
+ }
3244
+ if (bracket > 0) {
3245
+ continue;
3246
+ }
3247
+ if (ch === "(") {
3248
+ paren++;
3249
+ continue;
3250
+ }
3251
+ if (ch === ")") {
3252
+ paren--;
3253
+ if (paren === 0) {
3254
+ if (requireEnd === true && i !== pattern.length - 1) {
3255
+ return;
3256
+ }
3257
+ return {
3258
+ type: pattern[0],
3259
+ body: pattern.slice(2, i),
3260
+ end: i
3261
+ };
3262
+ }
3263
+ }
3264
+ }
3265
+ };
3266
+ var getStarExtglobSequenceOutput = (pattern) => {
3267
+ let index = 0;
3268
+ const chars = [];
3269
+ while (index < pattern.length) {
3270
+ const match = parseRepeatedExtglob(pattern.slice(index), false);
3271
+ if (!match || match.type !== "*") {
3272
+ return;
3273
+ }
3274
+ const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
3275
+ if (branches.length !== 1) {
3276
+ return;
3277
+ }
3278
+ const branch = normalizeSimpleBranch(branches[0]);
3279
+ if (!branch || branch.length !== 1) {
3280
+ return;
3281
+ }
3282
+ chars.push(branch);
3283
+ index += match.end + 1;
3284
+ }
3285
+ if (chars.length < 1) {
3286
+ return;
3287
+ }
3288
+ const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
3289
+ return `${source}*`;
3290
+ };
3291
+ var repeatedExtglobRecursion = (pattern) => {
3292
+ let depth = 0;
3293
+ let value = pattern.trim();
3294
+ let match = parseRepeatedExtglob(value);
3295
+ while (match) {
3296
+ depth++;
3297
+ value = match.body.trim();
3298
+ match = parseRepeatedExtglob(value);
3299
+ }
3300
+ return depth;
3301
+ };
3302
+ var analyzeRepeatedExtglob = (body, options) => {
3303
+ if (options.maxExtglobRecursion === false) {
3304
+ return { risky: false };
3305
+ }
3306
+ const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants2.DEFAULT_MAX_EXTGLOB_RECURSION;
3307
+ const branches = splitTopLevel(body).map((branch) => branch.trim());
3308
+ if (branches.length > 1) {
3309
+ if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
3310
+ return { risky: true };
3311
+ }
3312
+ }
3313
+ for (const branch of branches) {
3314
+ const safeOutput = getStarExtglobSequenceOutput(branch);
3315
+ if (safeOutput) {
3316
+ return { risky: true, safeOutput };
3317
+ }
3318
+ if (repeatedExtglobRecursion(branch) > max) {
3319
+ return { risky: true };
3320
+ }
3321
+ }
3322
+ return { risky: false };
3323
+ };
3113
3324
  var parse2 = (input, options) => {
3114
3325
  if (typeof input !== "string") {
3115
3326
  throw new TypeError("Expected a string");
@@ -3241,6 +3452,8 @@ var require_parse2 = __commonJS({
3241
3452
  token.prev = prev;
3242
3453
  token.parens = state.parens;
3243
3454
  token.output = state.output;
3455
+ token.startIndex = state.index;
3456
+ token.tokensIndex = tokens.length;
3244
3457
  const output = (opts.capture ? "(" : "") + token.open;
3245
3458
  increment("parens");
3246
3459
  push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
@@ -3248,6 +3461,26 @@ var require_parse2 = __commonJS({
3248
3461
  extglobs.push(token);
3249
3462
  };
3250
3463
  const extglobClose = (token) => {
3464
+ const literal = input.slice(token.startIndex, state.index + 1);
3465
+ const body = input.slice(token.startIndex + 2, state.index);
3466
+ const analysis = analyzeRepeatedExtglob(body, opts);
3467
+ if ((token.type === "plus" || token.type === "star") && analysis.risky) {
3468
+ const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
3469
+ const open = tokens[token.tokensIndex];
3470
+ open.type = "text";
3471
+ open.value = literal;
3472
+ open.output = safeOutput || utils.escapeRegex(literal);
3473
+ for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
3474
+ tokens[i].value = "";
3475
+ tokens[i].output = "";
3476
+ delete tokens[i].suffix;
3477
+ }
3478
+ state.output = token.output + open.output;
3479
+ state.backtrack = true;
3480
+ push({ type: "paren", extglob: true, value, output: "" });
3481
+ decrement("parens");
3482
+ return;
3483
+ }
3251
3484
  let output = token.close + (opts.capture ? ")" : "");
3252
3485
  let rest;
3253
3486
  if (token.type === "negate") {
@@ -3854,9 +4087,9 @@ var require_parse2 = __commonJS({
3854
4087
  }
3855
4088
  });
3856
4089
 
3857
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js
4090
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js
3858
4091
  var require_picomatch = __commonJS({
3859
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js"(exports, module) {
4092
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js"(exports, module) {
3860
4093
  "use strict";
3861
4094
  init_utils();
3862
4095
  var path = __require("path");
@@ -3996,9 +4229,9 @@ var require_picomatch = __commonJS({
3996
4229
  }
3997
4230
  });
3998
4231
 
3999
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/index.js
4232
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/index.js
4000
4233
  var require_picomatch2 = __commonJS({
4001
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/index.js"(exports, module) {
4234
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/index.js"(exports, module) {
4002
4235
  "use strict";
4003
4236
  init_utils();
4004
4237
  module.exports = require_picomatch();
@@ -8070,6 +8303,14 @@ var init_utils = __esm({
8070
8303
  });
8071
8304
 
8072
8305
  // packages/tooling/src/utils/app-detection.ts
8306
+ function createRootAppInfo(projectRoot) {
8307
+ return {
8308
+ name: "root",
8309
+ packageName: "root",
8310
+ path: projectRoot,
8311
+ framework: "vite"
8312
+ };
8313
+ }
8073
8314
  function detectApps(projectRoot) {
8074
8315
  const apps = [];
8075
8316
  const appsDir = joinPath(projectRoot, "apps");
@@ -8125,45 +8366,175 @@ function analyzeApp(appPath, appName) {
8125
8366
  } 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) {
8126
8367
  framework = "vite";
8127
8368
  }
8128
- const functionsPath = joinPath(appPath, "functions");
8129
- const functionsStat = statSync2(functionsPath);
8130
- const hasFunctions = pathExists(functionsPath) && (functionsStat?.isDirectory() ?? false);
8131
- let platform;
8132
- const firebaseJsonInFunctions = hasFunctions && pathExists(joinPath(functionsPath, "firebase.json"));
8133
- const firebaseJsonInApp = pathExists(joinPath(appPath, "firebase.json"));
8134
- if (firebaseJsonInFunctions || firebaseJsonInApp) {
8135
- platform = "firebase";
8369
+ const firebaseJsonPath = joinPath(appPath, "firebase.json");
8370
+ const hasFirebase = pathExists(firebaseJsonPath);
8371
+ const supabaseDir = joinPath(appPath, "supabase");
8372
+ const supabaseConfigPath = joinPath(supabaseDir, "config.toml");
8373
+ const hasSupabaseDep = !!(packageJson.dependencies?.["@donotdev/supabase"] || packageJson.dependencies?.["@supabase/supabase-js"]);
8374
+ let hasSupabase = pathExists(supabaseDir) || pathExists(supabaseConfigPath) || hasSupabaseDep;
8375
+ if (!hasSupabase) {
8376
+ try {
8377
+ const envPath = joinPath(appPath, ".env");
8378
+ if (pathExists(envPath)) {
8379
+ const envContent = readSync(envPath);
8380
+ if (envContent.match(/VITE_SUPABASE_URL=.+/)) {
8381
+ hasSupabase = true;
8382
+ }
8383
+ }
8384
+ } catch {
8385
+ }
8386
+ }
8387
+ let provider = "unknown";
8388
+ if (hasFirebase && hasSupabase) {
8389
+ provider = "both";
8390
+ } else if (hasFirebase) {
8391
+ provider = "firebase";
8392
+ } else if (hasSupabase) {
8393
+ provider = "supabase";
8394
+ }
8395
+ let firebaseConfig;
8396
+ if (hasFirebase) {
8397
+ try {
8398
+ const config = readSync(firebaseJsonPath, { format: "json" });
8399
+ if (config && typeof config === "object") {
8400
+ const fb = config;
8401
+ firebaseConfig = {
8402
+ projectId: fb.projectId,
8403
+ hasHosting: !!fb.hosting,
8404
+ hasFunctions: !!fb.functions,
8405
+ hasFirestoreRules: !!fb.firestore?.rules,
8406
+ hasStorageRules: !!fb.storage?.rules
8407
+ };
8408
+ }
8409
+ } catch {
8410
+ firebaseConfig = {
8411
+ hasHosting: false,
8412
+ hasFunctions: false,
8413
+ hasFirestoreRules: false,
8414
+ hasStorageRules: false
8415
+ };
8416
+ }
8417
+ }
8418
+ const supabaseFunctionsDir = joinPath(supabaseDir, "functions");
8419
+ const supabaseMigrationsDir = joinPath(supabaseDir, "migrations");
8420
+ let supabaseConfig;
8421
+ if (hasSupabase) {
8422
+ let url;
8423
+ try {
8424
+ const envPath = joinPath(appPath, ".env");
8425
+ if (pathExists(envPath)) {
8426
+ const envContent = readSync(envPath);
8427
+ const urlMatch = envContent.match(/VITE_SUPABASE_URL=(.+)/);
8428
+ if (urlMatch && urlMatch[1]) {
8429
+ url = urlMatch[1].trim();
8430
+ }
8431
+ }
8432
+ } catch {
8433
+ }
8434
+ supabaseConfig = {
8435
+ url,
8436
+ hasFunctions: pathExists(supabaseFunctionsDir),
8437
+ hasMigrations: pathExists(supabaseMigrationsDir)
8438
+ };
8439
+ }
8440
+ let functions;
8441
+ if (hasFirebase && firebaseConfig?.hasFunctions) {
8442
+ const firebaseFunctionsDir = joinPath(appPath, "functions");
8443
+ const firebaseFunctionsStat = statSync2(firebaseFunctionsDir);
8444
+ if (pathExists(firebaseFunctionsDir) && (firebaseFunctionsStat?.isDirectory() ?? false)) {
8445
+ functions = "firebase";
8446
+ }
8136
8447
  }
8137
- if (!platform) {
8138
- const supabaseConfigPath = joinPath(appPath, "supabase", "config.toml");
8139
- const hasSupabaseDep = !!(packageJson.dependencies?.["@donotdev/supabase"] || packageJson.dependencies?.["@supabase/supabase-js"]);
8140
- if (pathExists(supabaseConfigPath) || hasSupabaseDep) {
8141
- platform = "supabase";
8448
+ if (!functions && hasSupabase) {
8449
+ const sbFunctionsStat = statSync2(supabaseFunctionsDir);
8450
+ if (pathExists(supabaseFunctionsDir) && (sbFunctionsStat?.isDirectory() ?? false)) {
8451
+ functions = "supabase";
8142
8452
  }
8143
8453
  }
8144
- if (!platform) {
8454
+ if (!functions) {
8145
8455
  const vercelJsonPath = joinPath(appPath, "vercel.json");
8146
- if (pathExists(vercelJsonPath)) {
8147
- platform = "vercel";
8456
+ const apiDir = joinPath(appPath, "api");
8457
+ const apiDirStat = statSync2(apiDir);
8458
+ if (pathExists(vercelJsonPath) && pathExists(apiDir) && (apiDirStat?.isDirectory() ?? false)) {
8459
+ functions = "vercel";
8460
+ }
8461
+ }
8462
+ let hosting;
8463
+ if (hasFirebase && firebaseConfig?.hasHosting) {
8464
+ hosting = "firebase";
8465
+ }
8466
+ if (!hosting) {
8467
+ if (pathExists(joinPath(appPath, "vercel.json")) || pathExists(joinPath(appPath, ".vercel"))) {
8468
+ hosting = "vercel";
8148
8469
  }
8149
8470
  }
8150
8471
  return {
8151
8472
  name: appName,
8152
8473
  packageName: packageJson.name || appName,
8153
8474
  path: appPath,
8154
- packageJsonPath,
8155
8475
  framework,
8156
- hasFunctions,
8157
- functionsPath: hasFunctions ? functionsPath : void 0,
8158
- platform
8476
+ provider,
8477
+ functions,
8478
+ hosting,
8479
+ firebaseConfig,
8480
+ supabaseConfig
8159
8481
  };
8160
8482
  }
8483
+ function detectBackendFromProviders(appDir) {
8484
+ for (const candidate of PROVIDERS_CANDIDATES) {
8485
+ const filePath = joinPath(appDir, candidate);
8486
+ if (!pathExists(filePath)) continue;
8487
+ const content = readSync(filePath, { format: "text" });
8488
+ if (typeof content !== "string") continue;
8489
+ if (content.includes("@donotdev/firebase") || content.includes("FirebaseAuth") || content.includes("firebaseAuth")) {
8490
+ return "firebase";
8491
+ }
8492
+ if (content.includes("@donotdev/supabase") || content.includes("SupabaseAuth") || content.includes("supabaseAuth")) {
8493
+ return "supabase";
8494
+ }
8495
+ break;
8496
+ }
8497
+ return null;
8498
+ }
8499
+ function analyzeProjectTopology(projectRoot) {
8500
+ const apps = detectApps(projectRoot);
8501
+ const appBackends = /* @__PURE__ */ new Map();
8502
+ const backendOwners = /* @__PURE__ */ new Map();
8503
+ for (const app of apps) {
8504
+ let backend = app.provider === "firebase" || app.provider === "supabase" ? app.provider : null;
8505
+ if (!backend) {
8506
+ backend = detectBackendFromProviders(app.path);
8507
+ }
8508
+ appBackends.set(app.name, backend);
8509
+ if (pathExists(joinPath(app.path, "supabase", "config.toml"))) {
8510
+ backendOwners.set("supabase", app);
8511
+ }
8512
+ if (pathExists(joinPath(app.path, "firebase.json")) || pathExists(joinPath(app.path, "functions", "firebase.json"))) {
8513
+ backendOwners.set("firebase", app);
8514
+ }
8515
+ }
8516
+ return { apps, appBackends, backendOwners };
8517
+ }
8518
+ function findBackendApp(topology, appName) {
8519
+ const backend = topology.appBackends.get(appName);
8520
+ if (!backend) return void 0;
8521
+ return topology.backendOwners.get(backend);
8522
+ }
8523
+ var PROVIDERS_CANDIDATES;
8161
8524
  var init_app_detection = __esm({
8162
8525
  "packages/tooling/src/utils/app-detection.ts"() {
8163
8526
  "use strict";
8164
8527
  init_utils();
8165
8528
  init_pathResolver();
8166
8529
  init_typed_file_operations();
8530
+ PROVIDERS_CANDIDATES = [
8531
+ "src/config/providers.ts",
8532
+ "src/config/providers.tsx",
8533
+ "src/providers.ts",
8534
+ "src/providers.tsx",
8535
+ "src/lib/providers.ts",
8536
+ "src/lib/providers.tsx"
8537
+ ];
8167
8538
  }
8168
8539
  });
8169
8540
 
@@ -8193,7 +8564,7 @@ async function selectApp(projectRoot, appName) {
8193
8564
  message: "Select app:",
8194
8565
  options: apps.map((app) => ({
8195
8566
  value: app.name,
8196
- label: `${app.name} (${app.framework === "nextjs" ? "Next.js" : "Vite"}${app.hasFunctions ? ` + ${app.platform || "functions"}` : ""})`
8567
+ label: `${app.name} (${app.framework === "nextjs" ? "Next.js" : "Vite"}${app.functions ? ` + ${app.functions} functions` : ""})`
8197
8568
  }))
8198
8569
  });
8199
8570
  if (typeof selected !== "string") {
@@ -8528,67 +8899,6 @@ var init_vercel_token = __esm({
8528
8899
  }
8529
8900
  });
8530
8901
 
8531
- // packages/tooling/src/utils/cross-app-detection.ts
8532
- function detectBackendFromProviders(appDir) {
8533
- for (const candidate of PROVIDERS_CANDIDATES) {
8534
- const filePath = joinPath(appDir, candidate);
8535
- if (!pathExists(filePath)) continue;
8536
- const content = readSync(filePath, { format: "text" });
8537
- if (typeof content !== "string") continue;
8538
- if (content.includes("@donotdev/firebase") || content.includes("FirebaseAuth") || content.includes("firebaseAuth")) {
8539
- return "firebase";
8540
- }
8541
- if (content.includes("@donotdev/supabase") || content.includes("SupabaseAuth") || content.includes("supabaseAuth")) {
8542
- return "supabase";
8543
- }
8544
- break;
8545
- }
8546
- return null;
8547
- }
8548
- function analyzeProjectTopology(projectRoot) {
8549
- const apps = detectApps(projectRoot);
8550
- const appBackends = /* @__PURE__ */ new Map();
8551
- const backendOwners = /* @__PURE__ */ new Map();
8552
- for (const app of apps) {
8553
- let backend = app.platform === "firebase" || app.platform === "supabase" ? app.platform : null;
8554
- if (!backend) {
8555
- backend = detectBackendFromProviders(app.path);
8556
- }
8557
- appBackends.set(app.name, backend);
8558
- if (pathExists(joinPath(app.path, "supabase", "config.toml"))) {
8559
- backendOwners.set("supabase", app);
8560
- }
8561
- if (pathExists(joinPath(app.path, "firebase.json")) || pathExists(joinPath(app.path, "functions", "firebase.json"))) {
8562
- backendOwners.set("firebase", app);
8563
- }
8564
- }
8565
- if (!backendOwners.has("firebase") && (pathExists(joinPath(projectRoot, "firebase.json")) || pathExists(joinPath(projectRoot, ".firebaserc")))) {
8566
- }
8567
- return { apps, appBackends, backendOwners };
8568
- }
8569
- function findBackendApp(topology, appName) {
8570
- const backend = topology.appBackends.get(appName);
8571
- if (!backend) return void 0;
8572
- return topology.backendOwners.get(backend);
8573
- }
8574
- var PROVIDERS_CANDIDATES;
8575
- var init_cross_app_detection = __esm({
8576
- "packages/tooling/src/utils/cross-app-detection.ts"() {
8577
- "use strict";
8578
- init_utils();
8579
- init_app_detection();
8580
- init_pathResolver();
8581
- PROVIDERS_CANDIDATES = [
8582
- "src/config/providers.ts",
8583
- "src/config/providers.tsx",
8584
- "src/providers.ts",
8585
- "src/providers.tsx",
8586
- "src/lib/providers.ts",
8587
- "src/lib/providers.tsx"
8588
- ];
8589
- }
8590
- });
8591
-
8592
8902
  // packages/tooling/src/cli/setup/types.ts
8593
8903
  function computeOverallStatus(steps) {
8594
8904
  const hasFailure = steps.some((s) => s.status === "failed");
@@ -9117,7 +9427,6 @@ var init_firebase = __esm({
9117
9427
  });
9118
9428
 
9119
9429
  // packages/tooling/src/utils/supabase-management.ts
9120
- import { execSync, spawnSync as spawnSync2 } from "node:child_process";
9121
9430
  function extractProjectRef(supabaseUrl) {
9122
9431
  const match = supabaseUrl.match(/https?:\/\/([a-z0-9]+)\.supabase\.co/);
9123
9432
  if (!match?.[1]) {
@@ -11023,8 +11332,8 @@ function printAllValidationResults(results, multiApp) {
11023
11332
 
11024
11333
  // packages/tooling/src/cli/setup/setup.ts
11025
11334
  init_cli_output();
11026
- init_cross_app_detection();
11027
- init_pathResolver();
11335
+ init_app_detection();
11336
+ init_app_detection();
11028
11337
  var WIZARD_REGISTRY = {
11029
11338
  firebase: async () => (await Promise.resolve().then(() => (init_firebase(), firebase_exports))).firebaseWizard,
11030
11339
  supabase: async () => (await Promise.resolve().then(() => (init_supabase(), supabase_exports))).supabaseWizard,
@@ -11067,16 +11376,7 @@ async function main4(options = {}) {
11067
11376
  const topology = analyzeProjectTopology(projectRoot);
11068
11377
  let apps = topology.apps;
11069
11378
  if (apps.length === 0) {
11070
- apps = [
11071
- {
11072
- name: "root",
11073
- packageName: "root",
11074
- path: projectRoot,
11075
- packageJsonPath: joinPath(projectRoot, "package.json"),
11076
- framework: "vite",
11077
- hasFunctions: false
11078
- }
11079
- ];
11379
+ apps = [createRootAppInfo(projectRoot)];
11080
11380
  }
11081
11381
  const multiApp = apps.length > 1;
11082
11382
  const validationResults = validateAllApps(apps, topology, projectRoot);