@donotdev/cli 0.3.1 → 0.3.2

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 (99) hide show
  1. package/dependencies-matrix.json +51 -27
  2. package/dist/bin/commands/agent-setup.js +28 -18
  3. package/dist/bin/commands/build.js +1086 -58
  4. package/dist/bin/commands/bump.js +337 -53
  5. package/dist/bin/commands/cacheout.js +28 -18
  6. package/dist/bin/commands/coach.js +33 -25
  7. package/dist/bin/commands/create-app.js +597 -244
  8. package/dist/bin/commands/create-project.js +607 -254
  9. package/dist/bin/commands/db-check.js +37 -28
  10. package/dist/bin/commands/db.js +37 -28
  11. package/dist/bin/commands/deploy.js +13758 -11807
  12. package/dist/bin/commands/dev.js +50 -34
  13. package/dist/bin/commands/doctor.js +33 -25
  14. package/dist/bin/commands/emu.js +65 -43
  15. package/dist/bin/commands/format.js +28 -18
  16. package/dist/bin/commands/get-demo.js +81 -46
  17. package/dist/bin/commands/make-admin.js +966 -905
  18. package/dist/bin/commands/preview.js +50 -34
  19. package/dist/bin/commands/seed.js +37 -28
  20. package/dist/bin/commands/setup-cicd.js +1286 -87
  21. package/dist/bin/commands/setup.js +152 -138
  22. package/dist/bin/commands/staging.js +13758 -11807
  23. package/dist/bin/commands/sync-secrets.js +152 -132
  24. package/dist/bin/commands/type-check.js +1086 -39
  25. package/dist/bin/commands/wai.js +28 -18
  26. package/dist/bin/dndev.js +501 -27
  27. package/dist/index.js +14568 -12497
  28. package/package.json +1 -1
  29. package/templates/app-demo/index.html.example +0 -1
  30. package/templates/app-demo/src/pages/ConditionalFormPage.tsx.example +2 -2
  31. package/templates/app-demo/src/pages/ShowcaseDetailPage.tsx.example +1 -0
  32. package/templates/app-demo/tsconfig.json.example +1 -1
  33. package/templates/app-dndev/index.html.example +1 -3
  34. package/templates/app-expo/app/_layout.tsx.example +1 -1
  35. package/templates/app-expo/app/form.tsx.example +10 -3
  36. package/templates/app-expo/app/index.tsx.example +3 -3
  37. package/templates/app-expo/app/list.tsx.example +2 -2
  38. package/templates/app-expo/app/profile.tsx.example +4 -3
  39. package/templates/app-expo/app/signin.tsx.example +2 -2
  40. package/templates/app-expo/babel.config.js.example +23 -6
  41. package/templates/app-expo/metro.config.js.example +7 -17
  42. package/templates/app-expo/tsconfig.json.example +2 -1
  43. package/templates/app-next/src/app/AppDocument.tsx.example +2 -3
  44. package/templates/app-vite/index.html.example +1 -3
  45. package/templates/app-vite/src/locales/home_en.json.example +6 -6
  46. package/templates/app-vite/src/pages/FormPageExample.tsx.example +1 -1
  47. package/templates/app-vite/src/pages/HomePage.tsx.example +3 -3
  48. package/templates/deploy-config/firebase.json.example +6 -5
  49. package/templates/deploy-config/tsconfig.functions.json.example +2 -7
  50. package/templates/deploy-config/vercel.json.example +5 -56
  51. package/templates/functions-firebase/README.md.example +8 -8
  52. package/templates/functions-firebase/functions.config.js.example +2 -1
  53. package/templates/functions-firebase/src/index.ts.example +4 -3
  54. package/templates/functions-firebase/src/oauth/exchangeToken.ts.example +8 -6
  55. package/templates/functions-firebase/src/oauth/refreshToken.ts.example +8 -6
  56. package/templates/functions-firebase/tsconfig.json.example +3 -5
  57. package/templates/functions-supabase/supabase/config.toml.example +2 -1
  58. package/templates/functions-supabase/supabase/functions/change-plan/index.ts.example +2 -3
  59. package/templates/functions-supabase/supabase/functions/create-checkout-session/index.ts.example +2 -3
  60. package/templates/functions-supabase/supabase/functions/stripe-webhook/index.ts.example +2 -3
  61. package/templates/functions-vercel/README.md.example +15 -25
  62. package/templates/functions-vercel/build.mjs.example +4 -46
  63. package/templates/functions-vercel/src/api/auth/setCustomClaims.ts.example +6 -11
  64. package/templates/functions-vercel/src/api/billing/handleStripeWebhook.ts.example +2 -3
  65. package/templates/functions-vercel/src/api/oauth/checkGitHubAccess.ts.example +5 -11
  66. package/templates/functions-vercel/src/api/oauth/exchangeToken.ts.example +5 -11
  67. package/templates/functions-vercel/src/api/oauth/grantGitHubAccess.ts.example +5 -11
  68. package/templates/functions-vercel/tsconfig.json.example +5 -6
  69. package/templates/github/workflows/firebase-deploy.yml.example +1 -1
  70. package/templates/preset-admin/src/pages/DashboardPage.tsx.example +3 -2
  71. package/templates/preset-admin/src/pages/ReportsPage.tsx.example +13 -12
  72. package/templates/preset-admin/src/pages/SettingsPage.tsx.example +5 -5
  73. package/templates/preset-admin/src/pages/UsersPage.tsx.example +13 -12
  74. package/templates/preset-ecommerce/src/pages/CartPage.tsx.example +5 -5
  75. package/templates/preset-ecommerce/src/pages/CatalogPage.tsx.example +1 -4
  76. package/templates/preset-ecommerce/src/pages/CheckoutPage.tsx.example +10 -12
  77. package/templates/preset-ecommerce/src/pages/ProductPage.tsx.example +7 -4
  78. package/templates/preset-landing/src/pages/AboutPage.tsx.example +11 -9
  79. package/templates/preset-landing/src/pages/ContactPage.tsx.example +13 -7
  80. package/templates/preset-landing/src/pages/HomePage.tsx.example +50 -32
  81. package/templates/preset-saas/src/pages/DashboardPage.tsx.example +1 -1
  82. package/templates/preset-saas/src/pages/HomePage.tsx.example +3 -2
  83. package/templates/preset-saas/src/pages/PricingPage.tsx.example +4 -3
  84. package/templates/preset-saas/src/pages/ProfilePage.tsx.example +7 -7
  85. package/templates/preset-saas/src/pages/SettingsPage.tsx.example +3 -3
  86. package/templates/root-consumer/.claude/hooks/guard-bash.sh.example +101 -10
  87. package/templates/root-consumer/.claude/rules/definition-of-done.md.example +2 -2
  88. package/templates/root-consumer/.claude/rules/framework.md.example +1 -1
  89. package/templates/root-consumer/.claude/settings.json.example +0 -11
  90. package/templates/root-consumer/.claude/skills/build/SKILL.md.example +1 -1
  91. package/templates/root-consumer/.dndev/args.json.example +2 -2
  92. package/templates/root-consumer/.env.example +1 -1
  93. package/templates/root-consumer/AGENTS.md.example +3 -3
  94. package/templates/root-consumer/README.md.example +1 -1
  95. package/templates/functions-vercel/src/api/oauth/disconnect.ts.example +0 -20
  96. package/templates/functions-vercel/src/api/oauth/getConnections.ts.example +0 -20
  97. package/templates/functions-vercel/src/api/oauth/refreshToken.ts.example +0 -20
  98. package/templates/functions-vercel/vercel.json.example +0 -14
  99. package/templates/root-consumer/.claude/hooks/typecheck-stop.sh.example +0 -18
@@ -7236,11 +7236,12 @@ function getPatternsFor(type, repoRoot = null) {
7236
7236
  function getGlobOptionsFor(type) {
7237
7237
  return GLOB_OPTIONS[type] || GLOB_OPTIONS.base;
7238
7238
  }
7239
- var I18N_PATHS, SCAN_PATTERNS, GLOB_OPTIONS;
7239
+ var DEFAULT_OG_IMAGE, I18N_PATHS, SCAN_PATTERNS, GLOB_OPTIONS;
7240
7240
  var init_constants = __esm({
7241
7241
  "packages/core/config/constants.js"() {
7242
7242
  "use strict";
7243
7243
  init_utils2();
7244
+ DEFAULT_OG_IMAGE = "/og-image.png";
7244
7245
  I18N_PATHS = {
7245
7246
  // Monorepo source structure (locales at root, not in src/)
7246
7247
  SOURCE_ROOT: "packages/core/i18n",
@@ -7251,7 +7252,9 @@ var init_constants = __esm({
7251
7252
  PUBLISHED_ROOT: "i18n",
7252
7253
  PUBLISHED_LOCALES: "i18n/locales",
7253
7254
  PUBLISHED_EAGER: "i18n/locales/eager",
7254
- PUBLISHED_LAZY: "i18n/locales/lazy"
7255
+ PUBLISHED_LAZY: "i18n/locales/lazy",
7256
+ // Flag artwork: one SVG per flag code (flagFileName), copied to public/flags/ (AssetDiscovery)
7257
+ PUBLISHED_FLAGS: "i18n/flags"
7255
7258
  };
7256
7259
  SCAN_PATTERNS = {
7257
7260
  routes: {
@@ -7313,7 +7316,12 @@ var init_constants = __esm({
7313
7316
  "logo.avif",
7314
7317
  "apple-touch-icon*.png",
7315
7318
  "android-chrome-*.png",
7316
- "manifest.json"
7319
+ // Generated from logo.svg (AssetDiscovery._generateMissingAssets) or the app's own
7320
+ "icon-*x*.png",
7321
+ DEFAULT_OG_IMAGE.slice(1)
7322
+ // Not manifest.json: the web app manifest is a build output on Next (the PWA step
7323
+ // rewrites it after this scan), so its scanned size would differ between a clean
7324
+ // build and a rebuild. The asset manifest's `manifest` reads it from disk instead.
7317
7325
  ],
7318
7326
  fonts: ["fonts/**/*.woff2", "fonts/**/*.woff", "fonts/**/*.ttf"],
7319
7327
  framework: ["packages/ui/assets/**/*"]
@@ -7390,7 +7398,6 @@ import {
7390
7398
  sep,
7391
7399
  extname
7392
7400
  } from "node:path";
7393
- import { fileURLToPath } from "node:url";
7394
7401
  function isEexistError(error2) {
7395
7402
  return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "EEXIST";
7396
7403
  }
@@ -8212,7 +8219,10 @@ var init_PathResolver = __esm({
8212
8219
  return resolvedPath;
8213
8220
  }
8214
8221
  /**
8215
- * Execute fast-glob with normalized results
8222
+ * Execute fast-glob with normalized results, sorted. fast-glob returns files in
8223
+ * filesystem completion order, which varies between runs: every discovery (routes,
8224
+ * themes, i18n, assets) and what it generates (route manifest, sitemap, llms.txt,
8225
+ * proxy) must list the same sources in the same order on every build.
8216
8226
  * @private
8217
8227
  */
8218
8228
  async _globWithNormalization(patterns, options) {
@@ -8220,7 +8230,7 @@ var init_PathResolver = __esm({
8220
8230
  return results.map((path) => {
8221
8231
  const pathStr = typeof path === "string" ? path : path.path;
8222
8232
  return this.normalizePath(pathStr);
8223
- });
8233
+ }).sort();
8224
8234
  }
8225
8235
  /**
8226
8236
  * Resolve files using patterns with cross-platform support
@@ -8375,15 +8385,6 @@ var init_PathResolver = __esm({
8375
8385
  const cjsPath = this.getEmptyCjsModulePath();
8376
8386
  return cjsPath.replace(/\.cjs$/, ".js");
8377
8387
  }
8378
- /**
8379
- * Get absolute path to empty flag component module.
8380
- * Returns `export default () => null;` — used by flag filtering plugins
8381
- * to replace unused flag files at build time.
8382
- */
8383
- getEmptyFlagModulePath() {
8384
- const __dirname2 = dirname2(fileURLToPath(import.meta.url));
8385
- return this.normalizePath(resolve(__dirname2, "emptyFlag.js"));
8386
- }
8387
8388
  /**
8388
8389
  * Get absolute path to empty CJS module for esbuild pre-bundling.
8389
8390
  * CJS because esbuild statically analyzes ESM exports — CJS has dynamic
@@ -8456,7 +8457,7 @@ import {
8456
8457
  parse,
8457
8458
  isAbsolute as pathIsAbsolute
8458
8459
  } from "node:path";
8459
- import { fileURLToPath as fileURLToPath2 } from "node:url";
8460
+ import { fileURLToPath } from "node:url";
8460
8461
  function readdirSync3(dirPath, options) {
8461
8462
  if (options !== null && typeof options === "object" && options.withFileTypes === true) {
8462
8463
  return pathResolverInstance.readdirSync(dirPath, options);
@@ -8545,13 +8546,13 @@ import { copyFileSync as copyFileSync2, readFileSync as readFileSync2, writeFile
8545
8546
  import { createRequire as createRequire3 } from "node:module";
8546
8547
  import { dirname as dirname4, resolve as resolve3 } from "node:path";
8547
8548
  import process from "node:process";
8548
- import { fileURLToPath as fileURLToPath3 } from "node:url";
8549
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
8549
8550
  var require2, __filename, __dirname;
8550
8551
  var init_utils2 = __esm({
8551
8552
  "packages/tooling/src/bundler/utils.ts"() {
8552
8553
  "use strict";
8553
8554
  require2 = createRequire3(import.meta.url);
8554
- __filename = fileURLToPath3(import.meta.url);
8555
+ __filename = fileURLToPath2(import.meta.url);
8555
8556
  __dirname = dirname4(__filename);
8556
8557
  if (typeof globalThis !== "undefined") {
8557
8558
  globalThis.require = require2;
@@ -8570,6 +8571,9 @@ var init_utils2 = __esm({
8570
8571
  function usesVercel(app) {
8571
8572
  return app.hosting === "vercel" || app.functions === "vercel";
8572
8573
  }
8574
+ function isVercelFunctionsDir(functionsDir) {
8575
+ return statSync2(joinPath(functionsDir, "src", "api"))?.isDirectory() ?? false;
8576
+ }
8573
8577
  function detectApps(projectRoot) {
8574
8578
  const apps = [];
8575
8579
  const appsDir = joinPath(projectRoot, "apps");
@@ -8710,13 +8714,8 @@ function analyzeApp(appPath, appName) {
8710
8714
  functions = "supabase";
8711
8715
  }
8712
8716
  }
8713
- if (!functions) {
8714
- const vercelJsonPath = joinPath(appPath, "vercel.json");
8715
- const apiDir = joinPath(appPath, "api");
8716
- const apiDirStat = statSync2(apiDir);
8717
- if (pathExists(vercelJsonPath) && pathExists(apiDir) && (apiDirStat?.isDirectory() ?? false)) {
8718
- functions = "vercel";
8719
- }
8717
+ if (!functions && isVercelFunctionsDir(joinPath(appPath, "functions"))) {
8718
+ functions = "vercel";
8720
8719
  }
8721
8720
  let hosting;
8722
8721
  if (hasFirebase && firebaseConfig?.hasHosting) {
@@ -8750,6 +8749,10 @@ var init_app_detection = __esm({
8750
8749
  });
8751
8750
 
8752
8751
  // packages/tooling/src/utils/cli-input.ts
8752
+ function exitCancelled() {
8753
+ cancel("Cancelled");
8754
+ process.exit(CANCELLED_EXIT_CODE);
8755
+ }
8753
8756
  async function askForSelection(message, choices, defaultValue = 0) {
8754
8757
  const options = choices.map((choice) => {
8755
8758
  const value = choice.value;
@@ -8761,107 +8764,28 @@ async function askForSelection(message, choices, defaultValue = 0) {
8761
8764
  options,
8762
8765
  initialValue
8763
8766
  });
8764
- if (isCancel(result)) {
8765
- cancel("Operation cancelled.");
8766
- process.exit(0);
8767
- }
8767
+ if (isCancel(result)) exitCancelled();
8768
8768
  const picked = choices.find((choice) => choice.value === result);
8769
8769
  if (!picked) {
8770
8770
  throw new Error(`Unknown selection: ${result}`);
8771
8771
  }
8772
8772
  return picked.value;
8773
8773
  }
8774
+ var CANCELLED_EXIT_CODE;
8774
8775
  var init_cli_input = __esm({
8775
8776
  "packages/tooling/src/utils/cli-input.ts"() {
8776
8777
  "use strict";
8777
8778
  init_utils2();
8778
8779
  init_dist5();
8780
+ CANCELLED_EXIT_CODE = 130;
8779
8781
  }
8780
8782
  });
8781
8783
 
8782
- // packages/tooling/src/apps/vercel-api.ts
8783
- function formatVercelError(status, body, context) {
8784
- let vercelCode;
8785
- let vercelMessage;
8786
- try {
8787
- const parsed = JSON.parse(body);
8788
- const err = parsed.error ?? parsed;
8789
- vercelCode = err.code;
8790
- vercelMessage = err.message;
8791
- } catch {
8792
- }
8793
- let message;
8794
- switch (status) {
8795
- case 401:
8796
- message = "Vercel token is invalid or expired. Generate a new one at https://vercel.com/account/tokens and update .dndev.secrets";
8797
- break;
8798
- case 403:
8799
- if (vercelCode === "team_unauthorized" || body.includes("teamId")) {
8800
- message = "Vercel token does not have access to this team. Hobby/free accounts: remove VERCEL_ORG_ID from your .env (it causes 403). Team accounts: ensure the token is scoped to the correct team.";
8801
- } else {
8802
- message = `Vercel access denied: ${vercelMessage ?? "check token scope and permissions"}`;
8803
- }
8804
- break;
8805
- case 404:
8806
- message = "Vercel project not found. Check VERCEL_PROJECT_ID in apps/<app>/.env \u2014 it should match the Project ID from Vercel Dashboard > Project > Settings > General.";
8807
- break;
8808
- case 400:
8809
- if (vercelCode === "invalid_project_name") {
8810
- message = "Vercel rejected the project name. This is a framework bug \u2014 please report it.";
8811
- } else {
8812
- message = `Vercel rejected the request: ${vercelMessage ?? body}`;
8813
- }
8814
- break;
8815
- case 429:
8816
- message = "Vercel rate limit hit. Wait a few minutes and try again.";
8817
- break;
8818
- default:
8819
- message = `Vercel API error during ${context} (${status}): ${vercelMessage ?? body}`;
8820
- }
8821
- return new DoNotDevError(message, DO_NOT_DEV_ERROR_CODES.VERCEL_API_ERROR, {
8822
- context: { status, vercelCode, context }
8823
- });
8824
- }
8825
- async function validateToken(token) {
8826
- const res = await fetch(`${VERCEL_API}/v2/user`, {
8827
- headers: { Authorization: `Bearer ${token}` }
8828
- });
8829
- if (!res.ok) {
8830
- const body = await res.text();
8831
- throw formatVercelError(res.status, body, "validate token");
8832
- }
8833
- const data = await res.json();
8834
- return { username: data.user.username, email: data.user.email };
8835
- }
8836
- async function fetchProjectDetails(token, projectId, orgId) {
8837
- const q = orgId ? `?teamId=${encodeURIComponent(orgId)}` : "";
8838
- const res = await fetch(
8839
- `${VERCEL_API}/v9/projects/${encodeURIComponent(projectId)}${q}`,
8840
- {
8841
- headers: { Authorization: `Bearer ${token}` }
8842
- }
8843
- );
8844
- if (!res.ok) {
8845
- const body = await res.text();
8846
- throw formatVercelError(res.status, body, "validate project");
8847
- }
8848
- const data = await res.json();
8849
- return {
8850
- projectName: data.name,
8851
- link: data.link ?? null
8852
- };
8853
- }
8854
- async function validateProject(token, projectId, orgId) {
8855
- const details = await fetchProjectDetails(token, projectId, orgId);
8856
- return { projectName: details.projectName };
8857
- }
8858
- var VERCEL_API;
8859
- var init_vercel_api = __esm({
8860
- "packages/tooling/src/apps/vercel-api.ts"() {
8784
+ // packages/tooling/src/utils/create-utils.ts
8785
+ var init_create_utils = __esm({
8786
+ "packages/tooling/src/utils/create-utils.ts"() {
8861
8787
  "use strict";
8862
8788
  init_utils2();
8863
- init_errors();
8864
- VERCEL_API = "https://api.vercel.com";
8865
8789
  }
8866
8790
  });
8867
8791
 
@@ -8980,6 +8904,92 @@ var init_secrets_resolver = __esm({
8980
8904
  }
8981
8905
  });
8982
8906
 
8907
+ // packages/tooling/src/apps/vercel-api.ts
8908
+ function formatVercelError(status, body, context) {
8909
+ let vercelCode;
8910
+ let vercelMessage;
8911
+ try {
8912
+ const parsed = JSON.parse(body);
8913
+ const err = parsed.error ?? parsed;
8914
+ vercelCode = err.code;
8915
+ vercelMessage = err.message;
8916
+ } catch {
8917
+ }
8918
+ let message;
8919
+ switch (status) {
8920
+ case 401:
8921
+ message = "Vercel token is invalid or expired. Generate a new one at https://vercel.com/account/tokens and update .dndev.secrets";
8922
+ break;
8923
+ case 403:
8924
+ if (vercelCode === "team_unauthorized" || body.includes("teamId")) {
8925
+ message = "Vercel token does not have access to this team. Hobby/free accounts: remove VERCEL_ORG_ID from your .env (it causes 403). Team accounts: ensure the token is scoped to the correct team.";
8926
+ } else {
8927
+ message = `Vercel access denied: ${vercelMessage ?? "check token scope and permissions"}`;
8928
+ }
8929
+ break;
8930
+ case 404:
8931
+ message = "Vercel project not found. Check VERCEL_PROJECT_ID in apps/<app>/.env \u2014 it should match the Project ID from Vercel Dashboard > Project > Settings > General.";
8932
+ break;
8933
+ case 400:
8934
+ if (vercelCode === "invalid_project_name") {
8935
+ message = "Vercel rejected the project name. This is a framework bug \u2014 please report it.";
8936
+ } else {
8937
+ message = `Vercel rejected the request: ${vercelMessage ?? body}`;
8938
+ }
8939
+ break;
8940
+ case 429:
8941
+ message = "Vercel rate limit hit. Wait a few minutes and try again.";
8942
+ break;
8943
+ default:
8944
+ message = `Vercel API error during ${context} (${status}): ${vercelMessage ?? body}`;
8945
+ }
8946
+ return new DoNotDevError(message, DO_NOT_DEV_ERROR_CODES.VERCEL_API_ERROR, {
8947
+ context: { status, vercelCode, context }
8948
+ });
8949
+ }
8950
+ async function validateToken(token) {
8951
+ const res = await fetch(`${VERCEL_API}/v2/user`, {
8952
+ headers: { Authorization: `Bearer ${token}` }
8953
+ });
8954
+ if (!res.ok) {
8955
+ const body = await res.text();
8956
+ throw formatVercelError(res.status, body, "validate token");
8957
+ }
8958
+ const data = await res.json();
8959
+ return { username: data.user.username, email: data.user.email };
8960
+ }
8961
+ async function fetchProjectDetails(token, projectId, orgId) {
8962
+ const q = orgId ? `?teamId=${encodeURIComponent(orgId)}` : "";
8963
+ const res = await fetch(
8964
+ `${VERCEL_API}/v9/projects/${encodeURIComponent(projectId)}${q}`,
8965
+ {
8966
+ headers: { Authorization: `Bearer ${token}` }
8967
+ }
8968
+ );
8969
+ if (!res.ok) {
8970
+ const body = await res.text();
8971
+ throw formatVercelError(res.status, body, "validate project");
8972
+ }
8973
+ const data = await res.json();
8974
+ return {
8975
+ projectName: data.name,
8976
+ link: data.link ?? null
8977
+ };
8978
+ }
8979
+ async function validateProject(token, projectId, orgId) {
8980
+ const details = await fetchProjectDetails(token, projectId, orgId);
8981
+ return { projectName: details.projectName };
8982
+ }
8983
+ var VERCEL_API;
8984
+ var init_vercel_api = __esm({
8985
+ "packages/tooling/src/apps/vercel-api.ts"() {
8986
+ "use strict";
8987
+ init_utils2();
8988
+ init_errors();
8989
+ VERCEL_API = "https://api.vercel.com";
8990
+ }
8991
+ });
8992
+
8983
8993
  // packages/tooling/src/cli/setup/vercel-token.ts
8984
8994
  function resolvePerAppVar(appDir, varName) {
8985
8995
  const fromLocal = readEnvVar(joinPath(appDir, ".env.local"), varName);
@@ -8989,9 +8999,17 @@ function resolvePerAppVar(appDir, varName) {
8989
8999
  if (process.env[varName]) return process.env[varName];
8990
9000
  return null;
8991
9001
  }
9002
+ function describeTokenSource(resolved, projectRoot, appDir) {
9003
+ if (resolved.source === "process.env") return "env var VERCEL_TOKEN";
9004
+ if (resolved.source === ".dndev.secrets") {
9005
+ return joinPath(projectRoot, ".dndev.secrets");
9006
+ }
9007
+ return joinPath(appDir, resolved.legacyPath);
9008
+ }
8992
9009
  function resolveVercelCredentials(appDir, projectRoot) {
8993
9010
  const root = projectRoot ?? getRepoRoot();
8994
- const token = resolveSecret("VERCEL_TOKEN", root, { appDir })?.value ?? null;
9011
+ const resolvedToken = resolveSecret("VERCEL_TOKEN", root, { appDir });
9012
+ const token = resolvedToken?.value ?? null;
8995
9013
  const orgId = resolvePerAppVar(appDir, "VERCEL_ORG_ID");
8996
9014
  const projectId = resolvePerAppVar(appDir, "VERCEL_PROJECT_ID");
8997
9015
  const missing = [];
@@ -9001,6 +9019,7 @@ function resolveVercelCredentials(appDir, projectRoot) {
9001
9019
  return {
9002
9020
  credentials: {
9003
9021
  token,
9022
+ tokenSource: describeTokenSource(resolvedToken, root, appDir),
9004
9023
  orgId: orgId ?? void 0,
9005
9024
  projectId
9006
9025
  }
@@ -9177,7 +9196,7 @@ async function setFirebaseSecret(key, value, projectId, dryRun = false, cwd) {
9177
9196
  const finalProjectId = projectId || detectFirebaseProjectId(cwd);
9178
9197
  if (dryRun) {
9179
9198
  log2.info(
9180
- `[DRY RUN] Would set Firebase secret: ${key}${finalProjectId ? ` (project: ${finalProjectId})` : ""}`
9199
+ `[DRY RUN] Would set Firebase secret: ${key} \u2014 firebase functions:secrets:set ${key} --project ${finalProjectId ?? "<missing: pass --project>"}`
9181
9200
  );
9182
9201
  return;
9183
9202
  }
@@ -9389,31 +9408,31 @@ async function syncVercelPublicEnv(appDir, options = {}) {
9389
9408
  }
9390
9409
  }
9391
9410
  async function setVercelSecret(key, value, credentials, dryRun = false) {
9411
+ const { token, orgId, projectId } = credentials;
9412
+ const params = ["upsert=true"];
9413
+ if (orgId) params.push(`teamId=${encodeURIComponent(orgId)}`);
9414
+ const url = `${VERCEL_API}/v10/projects/${encodeURIComponent(projectId)}/env?${params.join("&")}`;
9392
9415
  if (dryRun) {
9393
- log2.info(`[DRY RUN] Would set Vercel environment variable: ${key}`);
9416
+ log2.info(
9417
+ `[DRY RUN] Would set Vercel environment variable: ${key} \u2014 POST ${url}`
9418
+ );
9394
9419
  return;
9395
9420
  }
9396
9421
  log2.info(`Setting Vercel environment variable: ${key}`);
9397
9422
  try {
9398
- const { token, orgId, projectId } = credentials;
9399
- const params = ["upsert=true"];
9400
- if (orgId) params.push(`teamId=${encodeURIComponent(orgId)}`);
9401
- const res = await fetch(
9402
- `${VERCEL_API}/v10/projects/${encodeURIComponent(projectId)}/env?${params.join("&")}`,
9403
- {
9404
- method: "POST",
9405
- headers: {
9406
- Authorization: `Bearer ${token}`,
9407
- "Content-Type": "application/json"
9408
- },
9409
- body: JSON.stringify({
9410
- key,
9411
- value,
9412
- type: "encrypted",
9413
- target: ["production", "preview", "development"]
9414
- })
9415
- }
9416
- );
9423
+ const res = await fetch(url, {
9424
+ method: "POST",
9425
+ headers: {
9426
+ Authorization: `Bearer ${token}`,
9427
+ "Content-Type": "application/json"
9428
+ },
9429
+ body: JSON.stringify({
9430
+ key,
9431
+ value,
9432
+ type: "encrypted",
9433
+ target: ["production", "preview", "development"]
9434
+ })
9435
+ });
9417
9436
  if (!res.ok) {
9418
9437
  const body = await res.text();
9419
9438
  throw formatVercelError(res.status, body, `set env var ${key}`);
@@ -9735,6 +9754,7 @@ init_utils2();
9735
9754
  // packages/tooling/src/cli/index.ts
9736
9755
  init_utils2();
9737
9756
  init_sync_secrets();
9757
+ init_create_utils();
9738
9758
  export {
9739
9759
  main
9740
9760
  };