@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
@@ -2385,14 +2385,15 @@ var require_braces = __commonJS({
2385
2385
  }
2386
2386
  });
2387
2387
 
2388
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/constants.js
2388
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/constants.js
2389
2389
  var require_constants2 = __commonJS({
2390
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/constants.js"(exports, module) {
2390
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/constants.js"(exports, module) {
2391
2391
  "use strict";
2392
2392
  init_utils();
2393
2393
  var path = __require("path");
2394
2394
  var WIN_SLASH = "\\\\/";
2395
2395
  var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
2396
+ var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
2396
2397
  var DOT_LITERAL = "\\.";
2397
2398
  var PLUS_LITERAL = "\\+";
2398
2399
  var QMARK_LITERAL = "\\?";
@@ -2440,6 +2441,7 @@ var require_constants2 = __commonJS({
2440
2441
  END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
2441
2442
  };
2442
2443
  var POSIX_REGEX_SOURCE = {
2444
+ __proto__: null,
2443
2445
  alnum: "a-zA-Z0-9",
2444
2446
  alpha: "a-zA-Z",
2445
2447
  ascii: "\\x00-\\x7F",
@@ -2456,6 +2458,7 @@ var require_constants2 = __commonJS({
2456
2458
  xdigit: "A-Fa-f0-9"
2457
2459
  };
2458
2460
  module.exports = {
2461
+ DEFAULT_MAX_EXTGLOB_RECURSION,
2459
2462
  MAX_LENGTH: 1024 * 64,
2460
2463
  POSIX_REGEX_SOURCE,
2461
2464
  // regular expressions
@@ -2467,6 +2470,7 @@ var require_constants2 = __commonJS({
2467
2470
  REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
2468
2471
  // Replace globs with equivalent patterns to reduce parsing time.
2469
2472
  REPLACEMENTS: {
2473
+ __proto__: null,
2470
2474
  "***": "*",
2471
2475
  "**/**": "**",
2472
2476
  "**/**/**": "**"
@@ -2583,9 +2587,9 @@ var require_constants2 = __commonJS({
2583
2587
  }
2584
2588
  });
2585
2589
 
2586
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/utils.js
2590
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/utils.js
2587
2591
  var require_utils2 = __commonJS({
2588
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/utils.js"(exports) {
2592
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/utils.js"(exports) {
2589
2593
  "use strict";
2590
2594
  init_utils();
2591
2595
  var path = __require("path");
@@ -2645,9 +2649,9 @@ var require_utils2 = __commonJS({
2645
2649
  }
2646
2650
  });
2647
2651
 
2648
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/scan.js
2652
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/scan.js
2649
2653
  var require_scan = __commonJS({
2650
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/scan.js"(exports, module) {
2654
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/scan.js"(exports, module) {
2651
2655
  "use strict";
2652
2656
  init_utils();
2653
2657
  var utils = require_utils2();
@@ -2976,9 +2980,9 @@ var require_scan = __commonJS({
2976
2980
  }
2977
2981
  });
2978
2982
 
2979
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/parse.js
2983
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/parse.js
2980
2984
  var require_parse2 = __commonJS({
2981
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/parse.js"(exports, module) {
2985
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/parse.js"(exports, module) {
2982
2986
  "use strict";
2983
2987
  init_utils();
2984
2988
  var constants2 = require_constants2();
@@ -3006,6 +3010,213 @@ var require_parse2 = __commonJS({
3006
3010
  var syntaxError = (type, char) => {
3007
3011
  return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
3008
3012
  };
3013
+ var splitTopLevel = (input) => {
3014
+ const parts = [];
3015
+ let bracket = 0;
3016
+ let paren = 0;
3017
+ let quote = 0;
3018
+ let value = "";
3019
+ let escaped = false;
3020
+ for (const ch of input) {
3021
+ if (escaped === true) {
3022
+ value += ch;
3023
+ escaped = false;
3024
+ continue;
3025
+ }
3026
+ if (ch === "\\") {
3027
+ value += ch;
3028
+ escaped = true;
3029
+ continue;
3030
+ }
3031
+ if (ch === '"') {
3032
+ quote = quote === 1 ? 0 : 1;
3033
+ value += ch;
3034
+ continue;
3035
+ }
3036
+ if (quote === 0) {
3037
+ if (ch === "[") {
3038
+ bracket++;
3039
+ } else if (ch === "]" && bracket > 0) {
3040
+ bracket--;
3041
+ } else if (bracket === 0) {
3042
+ if (ch === "(") {
3043
+ paren++;
3044
+ } else if (ch === ")" && paren > 0) {
3045
+ paren--;
3046
+ } else if (ch === "|" && paren === 0) {
3047
+ parts.push(value);
3048
+ value = "";
3049
+ continue;
3050
+ }
3051
+ }
3052
+ }
3053
+ value += ch;
3054
+ }
3055
+ parts.push(value);
3056
+ return parts;
3057
+ };
3058
+ var isPlainBranch = (branch) => {
3059
+ let escaped = false;
3060
+ for (const ch of branch) {
3061
+ if (escaped === true) {
3062
+ escaped = false;
3063
+ continue;
3064
+ }
3065
+ if (ch === "\\") {
3066
+ escaped = true;
3067
+ continue;
3068
+ }
3069
+ if (/[?*+@!()[\]{}]/.test(ch)) {
3070
+ return false;
3071
+ }
3072
+ }
3073
+ return true;
3074
+ };
3075
+ var normalizeSimpleBranch = (branch) => {
3076
+ let value = branch.trim();
3077
+ let changed = true;
3078
+ while (changed === true) {
3079
+ changed = false;
3080
+ if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
3081
+ value = value.slice(2, -1);
3082
+ changed = true;
3083
+ }
3084
+ }
3085
+ if (!isPlainBranch(value)) {
3086
+ return;
3087
+ }
3088
+ return value.replace(/\\(.)/g, "$1");
3089
+ };
3090
+ var hasRepeatedCharPrefixOverlap = (branches) => {
3091
+ const values = branches.map(normalizeSimpleBranch).filter(Boolean);
3092
+ for (let i = 0; i < values.length; i++) {
3093
+ for (let j2 = i + 1; j2 < values.length; j2++) {
3094
+ const a = values[i];
3095
+ const b3 = values[j2];
3096
+ const char = a[0];
3097
+ if (!char || a !== char.repeat(a.length) || b3 !== char.repeat(b3.length)) {
3098
+ continue;
3099
+ }
3100
+ if (a === b3 || a.startsWith(b3) || b3.startsWith(a)) {
3101
+ return true;
3102
+ }
3103
+ }
3104
+ }
3105
+ return false;
3106
+ };
3107
+ var parseRepeatedExtglob = (pattern, requireEnd = true) => {
3108
+ if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
3109
+ return;
3110
+ }
3111
+ let bracket = 0;
3112
+ let paren = 0;
3113
+ let quote = 0;
3114
+ let escaped = false;
3115
+ for (let i = 1; i < pattern.length; i++) {
3116
+ const ch = pattern[i];
3117
+ if (escaped === true) {
3118
+ escaped = false;
3119
+ continue;
3120
+ }
3121
+ if (ch === "\\") {
3122
+ escaped = true;
3123
+ continue;
3124
+ }
3125
+ if (ch === '"') {
3126
+ quote = quote === 1 ? 0 : 1;
3127
+ continue;
3128
+ }
3129
+ if (quote === 1) {
3130
+ continue;
3131
+ }
3132
+ if (ch === "[") {
3133
+ bracket++;
3134
+ continue;
3135
+ }
3136
+ if (ch === "]" && bracket > 0) {
3137
+ bracket--;
3138
+ continue;
3139
+ }
3140
+ if (bracket > 0) {
3141
+ continue;
3142
+ }
3143
+ if (ch === "(") {
3144
+ paren++;
3145
+ continue;
3146
+ }
3147
+ if (ch === ")") {
3148
+ paren--;
3149
+ if (paren === 0) {
3150
+ if (requireEnd === true && i !== pattern.length - 1) {
3151
+ return;
3152
+ }
3153
+ return {
3154
+ type: pattern[0],
3155
+ body: pattern.slice(2, i),
3156
+ end: i
3157
+ };
3158
+ }
3159
+ }
3160
+ }
3161
+ };
3162
+ var getStarExtglobSequenceOutput = (pattern) => {
3163
+ let index = 0;
3164
+ const chars = [];
3165
+ while (index < pattern.length) {
3166
+ const match = parseRepeatedExtglob(pattern.slice(index), false);
3167
+ if (!match || match.type !== "*") {
3168
+ return;
3169
+ }
3170
+ const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
3171
+ if (branches.length !== 1) {
3172
+ return;
3173
+ }
3174
+ const branch = normalizeSimpleBranch(branches[0]);
3175
+ if (!branch || branch.length !== 1) {
3176
+ return;
3177
+ }
3178
+ chars.push(branch);
3179
+ index += match.end + 1;
3180
+ }
3181
+ if (chars.length < 1) {
3182
+ return;
3183
+ }
3184
+ const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
3185
+ return `${source}*`;
3186
+ };
3187
+ var repeatedExtglobRecursion = (pattern) => {
3188
+ let depth = 0;
3189
+ let value = pattern.trim();
3190
+ let match = parseRepeatedExtglob(value);
3191
+ while (match) {
3192
+ depth++;
3193
+ value = match.body.trim();
3194
+ match = parseRepeatedExtglob(value);
3195
+ }
3196
+ return depth;
3197
+ };
3198
+ var analyzeRepeatedExtglob = (body, options) => {
3199
+ if (options.maxExtglobRecursion === false) {
3200
+ return { risky: false };
3201
+ }
3202
+ const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants2.DEFAULT_MAX_EXTGLOB_RECURSION;
3203
+ const branches = splitTopLevel(body).map((branch) => branch.trim());
3204
+ if (branches.length > 1) {
3205
+ if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
3206
+ return { risky: true };
3207
+ }
3208
+ }
3209
+ for (const branch of branches) {
3210
+ const safeOutput = getStarExtglobSequenceOutput(branch);
3211
+ if (safeOutput) {
3212
+ return { risky: true, safeOutput };
3213
+ }
3214
+ if (repeatedExtglobRecursion(branch) > max) {
3215
+ return { risky: true };
3216
+ }
3217
+ }
3218
+ return { risky: false };
3219
+ };
3009
3220
  var parse2 = (input, options) => {
3010
3221
  if (typeof input !== "string") {
3011
3222
  throw new TypeError("Expected a string");
@@ -3137,6 +3348,8 @@ var require_parse2 = __commonJS({
3137
3348
  token.prev = prev;
3138
3349
  token.parens = state.parens;
3139
3350
  token.output = state.output;
3351
+ token.startIndex = state.index;
3352
+ token.tokensIndex = tokens.length;
3140
3353
  const output = (opts.capture ? "(" : "") + token.open;
3141
3354
  increment("parens");
3142
3355
  push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
@@ -3144,6 +3357,26 @@ var require_parse2 = __commonJS({
3144
3357
  extglobs.push(token);
3145
3358
  };
3146
3359
  const extglobClose = (token) => {
3360
+ const literal = input.slice(token.startIndex, state.index + 1);
3361
+ const body = input.slice(token.startIndex + 2, state.index);
3362
+ const analysis = analyzeRepeatedExtglob(body, opts);
3363
+ if ((token.type === "plus" || token.type === "star") && analysis.risky) {
3364
+ const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
3365
+ const open = tokens[token.tokensIndex];
3366
+ open.type = "text";
3367
+ open.value = literal;
3368
+ open.output = safeOutput || utils.escapeRegex(literal);
3369
+ for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
3370
+ tokens[i].value = "";
3371
+ tokens[i].output = "";
3372
+ delete tokens[i].suffix;
3373
+ }
3374
+ state.output = token.output + open.output;
3375
+ state.backtrack = true;
3376
+ push({ type: "paren", extglob: true, value, output: "" });
3377
+ decrement("parens");
3378
+ return;
3379
+ }
3147
3380
  let output = token.close + (opts.capture ? ")" : "");
3148
3381
  let rest;
3149
3382
  if (token.type === "negate") {
@@ -3750,9 +3983,9 @@ var require_parse2 = __commonJS({
3750
3983
  }
3751
3984
  });
3752
3985
 
3753
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js
3986
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js
3754
3987
  var require_picomatch = __commonJS({
3755
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js"(exports, module) {
3988
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js"(exports, module) {
3756
3989
  "use strict";
3757
3990
  init_utils();
3758
3991
  var path = __require("path");
@@ -3892,9 +4125,9 @@ var require_picomatch = __commonJS({
3892
4125
  }
3893
4126
  });
3894
4127
 
3895
- // node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/index.js
4128
+ // node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/index.js
3896
4129
  var require_picomatch2 = __commonJS({
3897
- "node_modules/.bun/picomatch@2.3.1/node_modules/picomatch/index.js"(exports, module) {
4130
+ "node_modules/.bun/picomatch@2.3.2/node_modules/picomatch/index.js"(exports, module) {
3898
4131
  "use strict";
3899
4132
  init_utils();
3900
4133
  module.exports = require_picomatch();
@@ -7854,6 +8087,18 @@ var init_utils = __esm({
7854
8087
  });
7855
8088
 
7856
8089
  // packages/tooling/src/utils/app-detection.ts
8090
+ function getFunctionsPath(app) {
8091
+ switch (app.functions) {
8092
+ case "firebase":
8093
+ return joinPath(app.path, "functions");
8094
+ case "supabase":
8095
+ return joinPath(app.path, "supabase", "functions");
8096
+ case "vercel":
8097
+ return joinPath(app.path, "api");
8098
+ default:
8099
+ return null;
8100
+ }
8101
+ }
7857
8102
  function detectApps(projectRoot) {
7858
8103
  const apps = [];
7859
8104
  const appsDir = joinPath(projectRoot, "apps");
@@ -7909,37 +8154,118 @@ function analyzeApp(appPath, appName) {
7909
8154
  } 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) {
7910
8155
  framework = "vite";
7911
8156
  }
7912
- const functionsPath = joinPath(appPath, "functions");
7913
- const functionsStat = statSync2(functionsPath);
7914
- const hasFunctions = pathExists(functionsPath) && (functionsStat?.isDirectory() ?? false);
7915
- let platform5;
7916
- const firebaseJsonInFunctions = hasFunctions && pathExists(joinPath(functionsPath, "firebase.json"));
7917
- const firebaseJsonInApp = pathExists(joinPath(appPath, "firebase.json"));
7918
- if (firebaseJsonInFunctions || firebaseJsonInApp) {
7919
- platform5 = "firebase";
8157
+ const firebaseJsonPath = joinPath(appPath, "firebase.json");
8158
+ const hasFirebase = pathExists(firebaseJsonPath);
8159
+ const supabaseDir = joinPath(appPath, "supabase");
8160
+ const supabaseConfigPath = joinPath(supabaseDir, "config.toml");
8161
+ const hasSupabaseDep = !!(packageJson.dependencies?.["@donotdev/supabase"] || packageJson.dependencies?.["@supabase/supabase-js"]);
8162
+ let hasSupabase = pathExists(supabaseDir) || pathExists(supabaseConfigPath) || hasSupabaseDep;
8163
+ if (!hasSupabase) {
8164
+ try {
8165
+ const envPath = joinPath(appPath, ".env");
8166
+ if (pathExists(envPath)) {
8167
+ const envContent = readSync(envPath);
8168
+ if (envContent.match(/VITE_SUPABASE_URL=.+/)) {
8169
+ hasSupabase = true;
8170
+ }
8171
+ }
8172
+ } catch {
8173
+ }
8174
+ }
8175
+ let provider = "unknown";
8176
+ if (hasFirebase && hasSupabase) {
8177
+ provider = "both";
8178
+ } else if (hasFirebase) {
8179
+ provider = "firebase";
8180
+ } else if (hasSupabase) {
8181
+ provider = "supabase";
8182
+ }
8183
+ let firebaseConfig;
8184
+ if (hasFirebase) {
8185
+ try {
8186
+ const config = readSync(firebaseJsonPath, { format: "json" });
8187
+ if (config && typeof config === "object") {
8188
+ const fb = config;
8189
+ firebaseConfig = {
8190
+ projectId: fb.projectId,
8191
+ hasHosting: !!fb.hosting,
8192
+ hasFunctions: !!fb.functions,
8193
+ hasFirestoreRules: !!fb.firestore?.rules,
8194
+ hasStorageRules: !!fb.storage?.rules
8195
+ };
8196
+ }
8197
+ } catch {
8198
+ firebaseConfig = {
8199
+ hasHosting: false,
8200
+ hasFunctions: false,
8201
+ hasFirestoreRules: false,
8202
+ hasStorageRules: false
8203
+ };
8204
+ }
8205
+ }
8206
+ const supabaseFunctionsDir = joinPath(supabaseDir, "functions");
8207
+ const supabaseMigrationsDir = joinPath(supabaseDir, "migrations");
8208
+ let supabaseConfig;
8209
+ if (hasSupabase) {
8210
+ let url;
8211
+ try {
8212
+ const envPath = joinPath(appPath, ".env");
8213
+ if (pathExists(envPath)) {
8214
+ const envContent = readSync(envPath);
8215
+ const urlMatch = envContent.match(/VITE_SUPABASE_URL=(.+)/);
8216
+ if (urlMatch && urlMatch[1]) {
8217
+ url = urlMatch[1].trim();
8218
+ }
8219
+ }
8220
+ } catch {
8221
+ }
8222
+ supabaseConfig = {
8223
+ url,
8224
+ hasFunctions: pathExists(supabaseFunctionsDir),
8225
+ hasMigrations: pathExists(supabaseMigrationsDir)
8226
+ };
7920
8227
  }
7921
- if (!platform5) {
7922
- const supabaseConfigPath = joinPath(appPath, "supabase", "config.toml");
7923
- const hasSupabaseDep = !!(packageJson.dependencies?.["@donotdev/supabase"] || packageJson.dependencies?.["@supabase/supabase-js"]);
7924
- if (pathExists(supabaseConfigPath) || hasSupabaseDep) {
7925
- platform5 = "supabase";
8228
+ let functions;
8229
+ if (hasFirebase && firebaseConfig?.hasFunctions) {
8230
+ const firebaseFunctionsDir = joinPath(appPath, "functions");
8231
+ const firebaseFunctionsStat = statSync2(firebaseFunctionsDir);
8232
+ if (pathExists(firebaseFunctionsDir) && (firebaseFunctionsStat?.isDirectory() ?? false)) {
8233
+ functions = "firebase";
7926
8234
  }
7927
8235
  }
7928
- if (!platform5) {
8236
+ if (!functions && hasSupabase) {
8237
+ const sbFunctionsStat = statSync2(supabaseFunctionsDir);
8238
+ if (pathExists(supabaseFunctionsDir) && (sbFunctionsStat?.isDirectory() ?? false)) {
8239
+ functions = "supabase";
8240
+ }
8241
+ }
8242
+ if (!functions) {
7929
8243
  const vercelJsonPath = joinPath(appPath, "vercel.json");
7930
- if (pathExists(vercelJsonPath)) {
7931
- platform5 = "vercel";
8244
+ const apiDir = joinPath(appPath, "api");
8245
+ const apiDirStat = statSync2(apiDir);
8246
+ if (pathExists(vercelJsonPath) && pathExists(apiDir) && (apiDirStat?.isDirectory() ?? false)) {
8247
+ functions = "vercel";
8248
+ }
8249
+ }
8250
+ let hosting;
8251
+ if (hasFirebase && firebaseConfig?.hasHosting) {
8252
+ hosting = "firebase";
8253
+ }
8254
+ if (!hosting) {
8255
+ if (pathExists(joinPath(appPath, "vercel.json")) || pathExists(joinPath(appPath, ".vercel"))) {
8256
+ hosting = "vercel";
7932
8257
  }
7933
8258
  }
7934
8259
  return {
7935
8260
  name: appName,
7936
8261
  packageName: packageJson.name || appName,
7937
8262
  path: appPath,
7938
- packageJsonPath,
7939
8263
  framework,
7940
- hasFunctions,
7941
- functionsPath: hasFunctions ? functionsPath : void 0,
7942
- platform: platform5
8264
+ provider,
8265
+ functions,
8266
+ hosting,
8267
+ firebaseConfig,
8268
+ supabaseConfig
7943
8269
  };
7944
8270
  }
7945
8271
  var init_app_detection = __esm({
@@ -7977,7 +8303,7 @@ async function selectApp(projectRoot, appName) {
7977
8303
  message: "Select app:",
7978
8304
  options: apps.map((app) => ({
7979
8305
  value: app.name,
7980
- label: `${app.name} (${app.framework === "nextjs" ? "Next.js" : "Vite"}${app.hasFunctions ? ` + ${app.platform || "functions"}` : ""})`
8306
+ label: `${app.name} (${app.framework === "nextjs" ? "Next.js" : "Vite"}${app.functions ? ` + ${app.functions} functions` : ""})`
7981
8307
  }))
7982
8308
  });
7983
8309
  if (typeof selected !== "string") {
@@ -8095,9 +8421,10 @@ init_utils();
8095
8421
  init_cli_input();
8096
8422
  init_cli_output();
8097
8423
  init_pathResolver();
8098
- import { spawnSync as spawnSync2, execSync as execSync2 } from "node:child_process";
8424
+ import { spawnSync as spawnSync2, execFileSync } from "node:child_process";
8099
8425
  import { platform as platform2 } from "node:os";
8100
8426
  init_typed_file_operations();
8427
+ init_app_detection();
8101
8428
  function discoverFirebaseProjectId(appPath) {
8102
8429
  const firebasercPath = joinPath(appPath, ".firebaserc");
8103
8430
  if (pathExists(firebasercPath)) {
@@ -8112,16 +8439,22 @@ function discoverFirebaseProjectId(appPath) {
8112
8439
  }
8113
8440
  return process.env.FIREBASE_PROJECT_ID || null;
8114
8441
  }
8442
+ function validatePort(port) {
8443
+ if (!Number.isInteger(port) || port < 1 || port > 65535) {
8444
+ throw new Error(`Invalid port number: ${port}`);
8445
+ }
8446
+ }
8115
8447
  function killPorts(ports) {
8116
8448
  if (ports.length === 0) return;
8117
8449
  const isWindows = process.platform === "win32";
8118
8450
  for (const port of ports) {
8451
+ validatePort(port);
8119
8452
  try {
8120
8453
  if (isWindows) {
8121
- const findPort = execSync2(`netstat -ano | findstr :${port}`, {
8454
+ const findPort = execFileSync("netstat", ["-ano"], {
8122
8455
  encoding: "utf-8"
8123
8456
  });
8124
- const lines = findPort.trim().split("\n");
8457
+ const lines = findPort.trim().split("\n").filter((l2) => l2.includes(`:${port}`));
8125
8458
  const pids = /* @__PURE__ */ new Set();
8126
8459
  for (const line of lines) {
8127
8460
  const match = line.match(/\s+(\d+)\s*$/);
@@ -8131,21 +8464,21 @@ function killPorts(ports) {
8131
8464
  }
8132
8465
  for (const pid of Array.from(pids)) {
8133
8466
  try {
8134
- execSync2(`taskkill /F /PID ${pid}`, { stdio: "ignore" });
8467
+ execFileSync("taskkill", ["/F", "/PID", pid], { stdio: "ignore" });
8135
8468
  log.debug(`Killed process ${pid} on port ${port}`);
8136
8469
  } catch {
8137
8470
  }
8138
8471
  }
8139
8472
  } else {
8140
8473
  try {
8141
- const output = execSync2(`lsof -ti:${port}`, {
8474
+ const output = execFileSync("lsof", ["-ti:" + port], {
8142
8475
  encoding: "utf-8"
8143
8476
  }).trim();
8144
8477
  if (output) {
8145
8478
  const pids = output.split("\n").filter(Boolean);
8146
8479
  for (const pid of pids) {
8147
8480
  try {
8148
- execSync2(`kill -9 ${pid}`, { stdio: "ignore" });
8481
+ process.kill(Number(pid), "SIGKILL");
8149
8482
  log.debug(`Killed process ${pid} on port ${port}`);
8150
8483
  } catch {
8151
8484
  }
@@ -8237,7 +8570,7 @@ async function startFirebase(app, projectRoot, options = {}) {
8237
8570
  log.error("Functions emulator is required for Firebase apps.");
8238
8571
  return 1;
8239
8572
  }
8240
- const functionsDir = app.functionsPath;
8573
+ const functionsDir = getFunctionsPath(app);
8241
8574
  const envLocalPath = joinPath(functionsDir, ".env.local");
8242
8575
  if (pathExists(envLocalPath)) {
8243
8576
  loadEnvFile(envLocalPath);
@@ -8375,7 +8708,7 @@ FIREBASE_AUTH_EMULATOR_HOST=${authEmulatorHost}
8375
8708
  log.debug(`Received ${signal}, cleaning up processes...`);
8376
8709
  if (isWindows) {
8377
8710
  try {
8378
- execSync2(`taskkill /F /T /PID ${childProcess.pid}`, {
8711
+ execFileSync("taskkill", ["/F", "/T", "/PID", String(childProcess.pid)], {
8379
8712
  stdio: "ignore",
8380
8713
  timeout: 2e3
8381
8714
  });
@@ -8387,7 +8720,7 @@ FIREBASE_AUTH_EMULATOR_HOST=${authEmulatorHost}
8387
8720
  } catch {
8388
8721
  }
8389
8722
  try {
8390
- execSync2(`pkill -P ${childProcess.pid}`, {
8723
+ execFileSync("pkill", ["-P", String(childProcess.pid)], {
8391
8724
  stdio: "ignore",
8392
8725
  timeout: 1e3
8393
8726
  });
@@ -8427,11 +8760,11 @@ FIREBASE_AUTH_EMULATOR_HOST=${authEmulatorHost}
8427
8760
  // packages/tooling/src/apps/emu-supabase.ts
8428
8761
  init_utils();
8429
8762
  init_cli_output();
8430
- import { execSync as execSync3 } from "node:child_process";
8763
+ import { execFileSync as execFileSync2, execSync as execSync2 } from "node:child_process";
8431
8764
  import { platform as platform3 } from "node:os";
8432
8765
  function isDockerRunning() {
8433
8766
  try {
8434
- execSync3("docker info", { stdio: "pipe", timeout: 5e3 });
8767
+ execSync2("docker info", { stdio: "pipe", timeout: 5e3 });
8435
8768
  return true;
8436
8769
  } catch {
8437
8770
  return false;
@@ -8446,7 +8779,7 @@ async function startSupabase(app, _projectRoot) {
8446
8779
  return 1;
8447
8780
  }
8448
8781
  try {
8449
- execSync3("supabase --version", { stdio: "pipe" });
8782
+ execSync2("supabase --version", { stdio: "pipe" });
8450
8783
  } catch {
8451
8784
  log.error("Supabase CLI not found. Install it:");
8452
8785
  log.error(" bun install -g supabase\n");
@@ -8476,7 +8809,7 @@ async function startSupabase(app, _projectRoot) {
8476
8809
  if (!childProcess.pid) return;
8477
8810
  if (isWindows) {
8478
8811
  try {
8479
- execSync3(`taskkill /F /T /PID ${childProcess.pid}`, {
8812
+ execFileSync2("taskkill", ["/F", "/T", "/PID", String(childProcess.pid)], {
8480
8813
  stdio: "ignore",
8481
8814
  timeout: 2e3
8482
8815
  });
@@ -8509,13 +8842,13 @@ async function startSupabase(app, _projectRoot) {
8509
8842
  // packages/tooling/src/apps/emu-vercel.ts
8510
8843
  init_utils();
8511
8844
  init_cli_output();
8512
- import { execSync as execSync4 } from "node:child_process";
8845
+ import { execFileSync as execFileSync3, execSync as execSync3 } from "node:child_process";
8513
8846
  import { platform as platform4 } from "node:os";
8514
8847
  async function startVercel(app, _projectRoot) {
8515
8848
  log.info(`Starting Vercel dev server for ${app.name}...
8516
8849
  `);
8517
8850
  try {
8518
- execSync4("vercel --version", { stdio: "pipe" });
8851
+ execSync3("vercel --version", { stdio: "pipe" });
8519
8852
  } catch {
8520
8853
  log.error("Vercel CLI not found. Install it:");
8521
8854
  log.error(" bun install -g vercel\n");
@@ -8530,7 +8863,7 @@ async function startVercel(app, _projectRoot) {
8530
8863
  if (!childProcess.pid) return;
8531
8864
  if (isWindows) {
8532
8865
  try {
8533
- execSync4(`taskkill /F /T /PID ${childProcess.pid}`, {
8866
+ execFileSync3("taskkill", ["/F", "/T", "/PID", String(childProcess.pid)], {
8534
8867
  stdio: "ignore",
8535
8868
  timeout: 2e3
8536
8869
  });
@@ -8581,9 +8914,10 @@ async function main(options) {
8581
8914
  if (!app) {
8582
8915
  return 1;
8583
8916
  }
8584
- switch (app.platform) {
8917
+ const emuTarget = app.functions || app.provider;
8918
+ switch (emuTarget) {
8585
8919
  case "firebase": {
8586
- if (!app.hasFunctions) {
8920
+ if (!app.functions) {
8587
8921
  log.error(
8588
8922
  `App "${app.name}" has Firebase config but no functions directory.`
8589
8923
  );
@@ -8601,7 +8935,7 @@ async function main(options) {
8601
8935
  case "vercel":
8602
8936
  return startVercel(app, projectRoot);
8603
8937
  default:
8604
- log.error(`App "${app.name}" does not have a detected backend platform.`);
8938
+ log.error(`App "${app.name}" does not have a detected backend.`);
8605
8939
  log.error(
8606
8940
  "Expected: firebase.json (Firebase), supabase/config.toml or @donotdev/supabase (Supabase), or vercel.json (Vercel)."
8607
8941
  );