@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.
- package/dependencies-matrix.json +51 -27
- package/dist/bin/commands/agent-setup.js +28 -18
- package/dist/bin/commands/build.js +1086 -58
- package/dist/bin/commands/bump.js +337 -53
- package/dist/bin/commands/cacheout.js +28 -18
- package/dist/bin/commands/coach.js +33 -25
- package/dist/bin/commands/create-app.js +597 -244
- package/dist/bin/commands/create-project.js +607 -254
- package/dist/bin/commands/db-check.js +37 -28
- package/dist/bin/commands/db.js +37 -28
- package/dist/bin/commands/deploy.js +13758 -11807
- package/dist/bin/commands/dev.js +50 -34
- package/dist/bin/commands/doctor.js +33 -25
- package/dist/bin/commands/emu.js +65 -43
- package/dist/bin/commands/format.js +28 -18
- package/dist/bin/commands/get-demo.js +81 -46
- package/dist/bin/commands/make-admin.js +966 -905
- package/dist/bin/commands/preview.js +50 -34
- package/dist/bin/commands/seed.js +37 -28
- package/dist/bin/commands/setup-cicd.js +1286 -87
- package/dist/bin/commands/setup.js +152 -138
- package/dist/bin/commands/staging.js +13758 -11807
- package/dist/bin/commands/sync-secrets.js +152 -132
- package/dist/bin/commands/type-check.js +1086 -39
- package/dist/bin/commands/wai.js +28 -18
- package/dist/bin/dndev.js +501 -27
- package/dist/index.js +14568 -12497
- package/package.json +1 -1
- package/templates/app-demo/index.html.example +0 -1
- package/templates/app-demo/src/pages/ConditionalFormPage.tsx.example +2 -2
- package/templates/app-demo/src/pages/ShowcaseDetailPage.tsx.example +1 -0
- package/templates/app-demo/tsconfig.json.example +1 -1
- package/templates/app-dndev/index.html.example +1 -3
- package/templates/app-expo/app/_layout.tsx.example +1 -1
- package/templates/app-expo/app/form.tsx.example +10 -3
- package/templates/app-expo/app/index.tsx.example +3 -3
- package/templates/app-expo/app/list.tsx.example +2 -2
- package/templates/app-expo/app/profile.tsx.example +4 -3
- package/templates/app-expo/app/signin.tsx.example +2 -2
- package/templates/app-expo/babel.config.js.example +23 -6
- package/templates/app-expo/metro.config.js.example +7 -17
- package/templates/app-expo/tsconfig.json.example +2 -1
- package/templates/app-next/src/app/AppDocument.tsx.example +2 -3
- package/templates/app-vite/index.html.example +1 -3
- package/templates/app-vite/src/locales/home_en.json.example +6 -6
- package/templates/app-vite/src/pages/FormPageExample.tsx.example +1 -1
- package/templates/app-vite/src/pages/HomePage.tsx.example +3 -3
- package/templates/deploy-config/firebase.json.example +6 -5
- package/templates/deploy-config/tsconfig.functions.json.example +2 -7
- package/templates/deploy-config/vercel.json.example +5 -56
- package/templates/functions-firebase/README.md.example +8 -8
- package/templates/functions-firebase/functions.config.js.example +2 -1
- package/templates/functions-firebase/src/index.ts.example +4 -3
- package/templates/functions-firebase/src/oauth/exchangeToken.ts.example +8 -6
- package/templates/functions-firebase/src/oauth/refreshToken.ts.example +8 -6
- package/templates/functions-firebase/tsconfig.json.example +3 -5
- package/templates/functions-supabase/supabase/config.toml.example +2 -1
- package/templates/functions-supabase/supabase/functions/change-plan/index.ts.example +2 -3
- package/templates/functions-supabase/supabase/functions/create-checkout-session/index.ts.example +2 -3
- package/templates/functions-supabase/supabase/functions/stripe-webhook/index.ts.example +2 -3
- package/templates/functions-vercel/README.md.example +15 -25
- package/templates/functions-vercel/build.mjs.example +4 -46
- package/templates/functions-vercel/src/api/auth/setCustomClaims.ts.example +6 -11
- package/templates/functions-vercel/src/api/billing/handleStripeWebhook.ts.example +2 -3
- package/templates/functions-vercel/src/api/oauth/checkGitHubAccess.ts.example +5 -11
- package/templates/functions-vercel/src/api/oauth/exchangeToken.ts.example +5 -11
- package/templates/functions-vercel/src/api/oauth/grantGitHubAccess.ts.example +5 -11
- package/templates/functions-vercel/tsconfig.json.example +5 -6
- package/templates/github/workflows/firebase-deploy.yml.example +1 -1
- package/templates/preset-admin/src/pages/DashboardPage.tsx.example +3 -2
- package/templates/preset-admin/src/pages/ReportsPage.tsx.example +13 -12
- package/templates/preset-admin/src/pages/SettingsPage.tsx.example +5 -5
- package/templates/preset-admin/src/pages/UsersPage.tsx.example +13 -12
- package/templates/preset-ecommerce/src/pages/CartPage.tsx.example +5 -5
- package/templates/preset-ecommerce/src/pages/CatalogPage.tsx.example +1 -4
- package/templates/preset-ecommerce/src/pages/CheckoutPage.tsx.example +10 -12
- package/templates/preset-ecommerce/src/pages/ProductPage.tsx.example +7 -4
- package/templates/preset-landing/src/pages/AboutPage.tsx.example +11 -9
- package/templates/preset-landing/src/pages/ContactPage.tsx.example +13 -7
- package/templates/preset-landing/src/pages/HomePage.tsx.example +50 -32
- package/templates/preset-saas/src/pages/DashboardPage.tsx.example +1 -1
- package/templates/preset-saas/src/pages/HomePage.tsx.example +3 -2
- package/templates/preset-saas/src/pages/PricingPage.tsx.example +4 -3
- package/templates/preset-saas/src/pages/ProfilePage.tsx.example +7 -7
- package/templates/preset-saas/src/pages/SettingsPage.tsx.example +3 -3
- package/templates/root-consumer/.claude/hooks/guard-bash.sh.example +101 -10
- package/templates/root-consumer/.claude/rules/definition-of-done.md.example +2 -2
- package/templates/root-consumer/.claude/rules/framework.md.example +1 -1
- package/templates/root-consumer/.claude/settings.json.example +0 -11
- package/templates/root-consumer/.claude/skills/build/SKILL.md.example +1 -1
- package/templates/root-consumer/.dndev/args.json.example +2 -2
- package/templates/root-consumer/.env.example +1 -1
- package/templates/root-consumer/AGENTS.md.example +3 -3
- package/templates/root-consumer/README.md.example +1 -1
- package/templates/functions-vercel/src/api/oauth/disconnect.ts.example +0 -20
- package/templates/functions-vercel/src/api/oauth/getConnections.ts.example +0 -20
- package/templates/functions-vercel/src/api/oauth/refreshToken.ts.example +0 -20
- package/templates/functions-vercel/vercel.json.example +0 -14
- package/templates/root-consumer/.claude/hooks/typecheck-stop.sh.example +0 -18
|
@@ -7519,11 +7519,12 @@ function getPatternsFor(type, repoRoot = null) {
|
|
|
7519
7519
|
function getGlobOptionsFor(type) {
|
|
7520
7520
|
return GLOB_OPTIONS[type] || GLOB_OPTIONS.base;
|
|
7521
7521
|
}
|
|
7522
|
-
var I18N_PATHS, SCAN_PATTERNS, GLOB_OPTIONS;
|
|
7522
|
+
var DEFAULT_OG_IMAGE, I18N_PATHS, SCAN_PATTERNS, GLOB_OPTIONS;
|
|
7523
7523
|
var init_constants = __esm({
|
|
7524
7524
|
"packages/core/config/constants.js"() {
|
|
7525
7525
|
"use strict";
|
|
7526
7526
|
init_utils2();
|
|
7527
|
+
DEFAULT_OG_IMAGE = "/og-image.png";
|
|
7527
7528
|
I18N_PATHS = {
|
|
7528
7529
|
// Monorepo source structure (locales at root, not in src/)
|
|
7529
7530
|
SOURCE_ROOT: "packages/core/i18n",
|
|
@@ -7534,7 +7535,9 @@ var init_constants = __esm({
|
|
|
7534
7535
|
PUBLISHED_ROOT: "i18n",
|
|
7535
7536
|
PUBLISHED_LOCALES: "i18n/locales",
|
|
7536
7537
|
PUBLISHED_EAGER: "i18n/locales/eager",
|
|
7537
|
-
PUBLISHED_LAZY: "i18n/locales/lazy"
|
|
7538
|
+
PUBLISHED_LAZY: "i18n/locales/lazy",
|
|
7539
|
+
// Flag artwork: one SVG per flag code (flagFileName), copied to public/flags/ (AssetDiscovery)
|
|
7540
|
+
PUBLISHED_FLAGS: "i18n/flags"
|
|
7538
7541
|
};
|
|
7539
7542
|
SCAN_PATTERNS = {
|
|
7540
7543
|
routes: {
|
|
@@ -7596,7 +7599,12 @@ var init_constants = __esm({
|
|
|
7596
7599
|
"logo.avif",
|
|
7597
7600
|
"apple-touch-icon*.png",
|
|
7598
7601
|
"android-chrome-*.png",
|
|
7599
|
-
|
|
7602
|
+
// Generated from logo.svg (AssetDiscovery._generateMissingAssets) or the app's own
|
|
7603
|
+
"icon-*x*.png",
|
|
7604
|
+
DEFAULT_OG_IMAGE.slice(1)
|
|
7605
|
+
// Not manifest.json: the web app manifest is a build output on Next (the PWA step
|
|
7606
|
+
// rewrites it after this scan), so its scanned size would differ between a clean
|
|
7607
|
+
// build and a rebuild. The asset manifest's `manifest` reads it from disk instead.
|
|
7600
7608
|
],
|
|
7601
7609
|
fonts: ["fonts/**/*.woff2", "fonts/**/*.woff", "fonts/**/*.ttf"],
|
|
7602
7610
|
framework: ["packages/ui/assets/**/*"]
|
|
@@ -7673,7 +7681,6 @@ import {
|
|
|
7673
7681
|
sep,
|
|
7674
7682
|
extname
|
|
7675
7683
|
} from "node:path";
|
|
7676
|
-
import { fileURLToPath } from "node:url";
|
|
7677
7684
|
function isEexistError(error2) {
|
|
7678
7685
|
return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "EEXIST";
|
|
7679
7686
|
}
|
|
@@ -8495,7 +8502,10 @@ var init_PathResolver = __esm({
|
|
|
8495
8502
|
return resolvedPath;
|
|
8496
8503
|
}
|
|
8497
8504
|
/**
|
|
8498
|
-
* Execute fast-glob with normalized results
|
|
8505
|
+
* Execute fast-glob with normalized results, sorted. fast-glob returns files in
|
|
8506
|
+
* filesystem completion order, which varies between runs: every discovery (routes,
|
|
8507
|
+
* themes, i18n, assets) and what it generates (route manifest, sitemap, llms.txt,
|
|
8508
|
+
* proxy) must list the same sources in the same order on every build.
|
|
8499
8509
|
* @private
|
|
8500
8510
|
*/
|
|
8501
8511
|
async _globWithNormalization(patterns, options) {
|
|
@@ -8503,7 +8513,7 @@ var init_PathResolver = __esm({
|
|
|
8503
8513
|
return results.map((path) => {
|
|
8504
8514
|
const pathStr = typeof path === "string" ? path : path.path;
|
|
8505
8515
|
return this.normalizePath(pathStr);
|
|
8506
|
-
});
|
|
8516
|
+
}).sort();
|
|
8507
8517
|
}
|
|
8508
8518
|
/**
|
|
8509
8519
|
* Resolve files using patterns with cross-platform support
|
|
@@ -8658,15 +8668,6 @@ var init_PathResolver = __esm({
|
|
|
8658
8668
|
const cjsPath = this.getEmptyCjsModulePath();
|
|
8659
8669
|
return cjsPath.replace(/\.cjs$/, ".js");
|
|
8660
8670
|
}
|
|
8661
|
-
/**
|
|
8662
|
-
* Get absolute path to empty flag component module.
|
|
8663
|
-
* Returns `export default () => null;` — used by flag filtering plugins
|
|
8664
|
-
* to replace unused flag files at build time.
|
|
8665
|
-
*/
|
|
8666
|
-
getEmptyFlagModulePath() {
|
|
8667
|
-
const __dirname3 = dirname2(fileURLToPath(import.meta.url));
|
|
8668
|
-
return this.normalizePath(resolve(__dirname3, "emptyFlag.js"));
|
|
8669
|
-
}
|
|
8670
8671
|
/**
|
|
8671
8672
|
* Get absolute path to empty CJS module for esbuild pre-bundling.
|
|
8672
8673
|
* CJS because esbuild statically analyzes ESM exports — CJS has dynamic
|
|
@@ -8739,7 +8740,7 @@ import {
|
|
|
8739
8740
|
parse,
|
|
8740
8741
|
isAbsolute as pathIsAbsolute
|
|
8741
8742
|
} from "node:path";
|
|
8742
|
-
import { fileURLToPath
|
|
8743
|
+
import { fileURLToPath } from "node:url";
|
|
8743
8744
|
function readdirSync3(dirPath, options) {
|
|
8744
8745
|
if (options !== null && typeof options === "object" && options.withFileTypes === true) {
|
|
8745
8746
|
return pathResolverInstance.readdirSync(dirPath, options);
|
|
@@ -8747,10 +8748,10 @@ function readdirSync3(dirPath, options) {
|
|
|
8747
8748
|
return pathResolverInstance.readdirSync(dirPath, options);
|
|
8748
8749
|
}
|
|
8749
8750
|
function getDirnameFromUrl(importMetaUrl) {
|
|
8750
|
-
return dirname3(
|
|
8751
|
+
return dirname3(fileURLToPath(importMetaUrl));
|
|
8751
8752
|
}
|
|
8752
8753
|
function detectExecutionMode() {
|
|
8753
|
-
const fileUrlPath =
|
|
8754
|
+
const fileUrlPath = fileURLToPath(import.meta.url);
|
|
8754
8755
|
if (fileUrlPath.includes("node_modules")) {
|
|
8755
8756
|
return "published";
|
|
8756
8757
|
}
|
|
@@ -8762,7 +8763,7 @@ function detectExecutionMode() {
|
|
|
8762
8763
|
function getTemplatesRoot() {
|
|
8763
8764
|
const mode = detectExecutionMode();
|
|
8764
8765
|
if (mode === "development") {
|
|
8765
|
-
const fileUrlPath =
|
|
8766
|
+
const fileUrlPath = fileURLToPath(import.meta.url);
|
|
8766
8767
|
const frameworkRoot = normalizePath(dirname3(fileUrlPath), "../../../..");
|
|
8767
8768
|
return normalizePath(frameworkRoot, PACKAGE_PATHS.CLI, "templates");
|
|
8768
8769
|
} else {
|
|
@@ -8960,13 +8961,13 @@ import { copyFileSync as copyFileSync2, readFileSync as readFileSync2, writeFile
|
|
|
8960
8961
|
import { createRequire as createRequire3 } from "node:module";
|
|
8961
8962
|
import { dirname as dirname4, resolve as resolve3 } from "node:path";
|
|
8962
8963
|
import process from "node:process";
|
|
8963
|
-
import { fileURLToPath as
|
|
8964
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8964
8965
|
var require2, __filename, __dirname;
|
|
8965
8966
|
var init_utils2 = __esm({
|
|
8966
8967
|
"packages/tooling/src/bundler/utils.ts"() {
|
|
8967
8968
|
"use strict";
|
|
8968
8969
|
require2 = createRequire3(import.meta.url);
|
|
8969
|
-
__filename =
|
|
8970
|
+
__filename = fileURLToPath2(import.meta.url);
|
|
8970
8971
|
__dirname = dirname4(__filename);
|
|
8971
8972
|
if (typeof globalThis !== "undefined") {
|
|
8972
8973
|
globalThis.require = require2;
|
|
@@ -8982,6 +8983,9 @@ var init_utils2 = __esm({
|
|
|
8982
8983
|
});
|
|
8983
8984
|
|
|
8984
8985
|
// packages/tooling/src/utils/app-detection.ts
|
|
8986
|
+
function isVercelFunctionsDir(functionsDir) {
|
|
8987
|
+
return statSync2(joinPath(functionsDir, "src", "api"))?.isDirectory() ?? false;
|
|
8988
|
+
}
|
|
8985
8989
|
function createRootAppInfo(projectRoot) {
|
|
8986
8990
|
return {
|
|
8987
8991
|
name: "root",
|
|
@@ -9130,13 +9134,8 @@ function analyzeApp(appPath, appName) {
|
|
|
9130
9134
|
functions = "supabase";
|
|
9131
9135
|
}
|
|
9132
9136
|
}
|
|
9133
|
-
if (!functions) {
|
|
9134
|
-
|
|
9135
|
-
const apiDir = joinPath(appPath, "api");
|
|
9136
|
-
const apiDirStat = statSync2(apiDir);
|
|
9137
|
-
if (pathExists(vercelJsonPath) && pathExists(apiDir) && (apiDirStat?.isDirectory() ?? false)) {
|
|
9138
|
-
functions = "vercel";
|
|
9139
|
-
}
|
|
9137
|
+
if (!functions && isVercelFunctionsDir(joinPath(appPath, "functions"))) {
|
|
9138
|
+
functions = "vercel";
|
|
9140
9139
|
}
|
|
9141
9140
|
let hosting;
|
|
9142
9141
|
if (hasFirebase && firebaseConfig?.hasHosting) {
|
|
@@ -9263,16 +9262,17 @@ var init_app_selector = __esm({
|
|
|
9263
9262
|
});
|
|
9264
9263
|
|
|
9265
9264
|
// packages/tooling/src/utils/cli-input.ts
|
|
9265
|
+
function exitCancelled() {
|
|
9266
|
+
cancel("Cancelled");
|
|
9267
|
+
process.exit(CANCELLED_EXIT_CODE);
|
|
9268
|
+
}
|
|
9266
9269
|
async function askForInput(message, defaultValue = "") {
|
|
9267
9270
|
const result = await text({
|
|
9268
9271
|
message,
|
|
9269
9272
|
placeholder: defaultValue || void 0,
|
|
9270
9273
|
defaultValue: defaultValue || void 0
|
|
9271
9274
|
});
|
|
9272
|
-
if (isCancel(result))
|
|
9273
|
-
cancel("Operation cancelled.");
|
|
9274
|
-
process.exit(0);
|
|
9275
|
-
}
|
|
9275
|
+
if (isCancel(result)) exitCancelled();
|
|
9276
9276
|
return result;
|
|
9277
9277
|
}
|
|
9278
9278
|
async function askForConfirmation(message, defaultValue = false) {
|
|
@@ -9280,10 +9280,7 @@ async function askForConfirmation(message, defaultValue = false) {
|
|
|
9280
9280
|
message,
|
|
9281
9281
|
initialValue: defaultValue
|
|
9282
9282
|
});
|
|
9283
|
-
if (isCancel(result))
|
|
9284
|
-
cancel("Operation cancelled.");
|
|
9285
|
-
process.exit(0);
|
|
9286
|
-
}
|
|
9283
|
+
if (isCancel(result)) exitCancelled();
|
|
9287
9284
|
return result;
|
|
9288
9285
|
}
|
|
9289
9286
|
async function askForSelection(message, choices, defaultValue = 0) {
|
|
@@ -9297,21 +9294,20 @@ async function askForSelection(message, choices, defaultValue = 0) {
|
|
|
9297
9294
|
options,
|
|
9298
9295
|
initialValue
|
|
9299
9296
|
});
|
|
9300
|
-
if (isCancel(result))
|
|
9301
|
-
cancel("Operation cancelled.");
|
|
9302
|
-
process.exit(0);
|
|
9303
|
-
}
|
|
9297
|
+
if (isCancel(result)) exitCancelled();
|
|
9304
9298
|
const picked = choices.find((choice) => choice.value === result);
|
|
9305
9299
|
if (!picked) {
|
|
9306
9300
|
throw new Error(`Unknown selection: ${result}`);
|
|
9307
9301
|
}
|
|
9308
9302
|
return picked.value;
|
|
9309
9303
|
}
|
|
9304
|
+
var CANCELLED_EXIT_CODE;
|
|
9310
9305
|
var init_cli_input = __esm({
|
|
9311
9306
|
"packages/tooling/src/utils/cli-input.ts"() {
|
|
9312
9307
|
"use strict";
|
|
9313
9308
|
init_utils2();
|
|
9314
9309
|
init_dist5();
|
|
9310
|
+
CANCELLED_EXIT_CODE = 130;
|
|
9315
9311
|
}
|
|
9316
9312
|
});
|
|
9317
9313
|
|
|
@@ -9338,105 +9334,11 @@ var init_error_handling = __esm({
|
|
|
9338
9334
|
}
|
|
9339
9335
|
});
|
|
9340
9336
|
|
|
9341
|
-
// packages/tooling/src/
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
let vercelMessage;
|
|
9345
|
-
try {
|
|
9346
|
-
const parsed = JSON.parse(body);
|
|
9347
|
-
const err = parsed.error ?? parsed;
|
|
9348
|
-
vercelCode = err.code;
|
|
9349
|
-
vercelMessage = err.message;
|
|
9350
|
-
} catch {
|
|
9351
|
-
}
|
|
9352
|
-
let message;
|
|
9353
|
-
switch (status) {
|
|
9354
|
-
case 401:
|
|
9355
|
-
message = "Vercel token is invalid or expired. Generate a new one at https://vercel.com/account/tokens and update .dndev.secrets";
|
|
9356
|
-
break;
|
|
9357
|
-
case 403:
|
|
9358
|
-
if (vercelCode === "team_unauthorized" || body.includes("teamId")) {
|
|
9359
|
-
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.";
|
|
9360
|
-
} else {
|
|
9361
|
-
message = `Vercel access denied: ${vercelMessage ?? "check token scope and permissions"}`;
|
|
9362
|
-
}
|
|
9363
|
-
break;
|
|
9364
|
-
case 404:
|
|
9365
|
-
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.";
|
|
9366
|
-
break;
|
|
9367
|
-
case 400:
|
|
9368
|
-
if (vercelCode === "invalid_project_name") {
|
|
9369
|
-
message = "Vercel rejected the project name. This is a framework bug \u2014 please report it.";
|
|
9370
|
-
} else {
|
|
9371
|
-
message = `Vercel rejected the request: ${vercelMessage ?? body}`;
|
|
9372
|
-
}
|
|
9373
|
-
break;
|
|
9374
|
-
case 429:
|
|
9375
|
-
message = "Vercel rate limit hit. Wait a few minutes and try again.";
|
|
9376
|
-
break;
|
|
9377
|
-
default:
|
|
9378
|
-
message = `Vercel API error during ${context} (${status}): ${vercelMessage ?? body}`;
|
|
9379
|
-
}
|
|
9380
|
-
return new DoNotDevError(message, DO_NOT_DEV_ERROR_CODES.VERCEL_API_ERROR, {
|
|
9381
|
-
context: { status, vercelCode, context }
|
|
9382
|
-
});
|
|
9383
|
-
}
|
|
9384
|
-
async function validateToken(token) {
|
|
9385
|
-
const res = await fetch(`${VERCEL_API}/v2/user`, {
|
|
9386
|
-
headers: { Authorization: `Bearer ${token}` }
|
|
9387
|
-
});
|
|
9388
|
-
if (!res.ok) {
|
|
9389
|
-
const body = await res.text();
|
|
9390
|
-
throw formatVercelError(res.status, body, "validate token");
|
|
9391
|
-
}
|
|
9392
|
-
const data = await res.json();
|
|
9393
|
-
return { username: data.user.username, email: data.user.email };
|
|
9394
|
-
}
|
|
9395
|
-
async function fetchProjectDetails(token, projectId, orgId) {
|
|
9396
|
-
const q = orgId ? `?teamId=${encodeURIComponent(orgId)}` : "";
|
|
9397
|
-
const res = await fetch(
|
|
9398
|
-
`${VERCEL_API}/v9/projects/${encodeURIComponent(projectId)}${q}`,
|
|
9399
|
-
{
|
|
9400
|
-
headers: { Authorization: `Bearer ${token}` }
|
|
9401
|
-
}
|
|
9402
|
-
);
|
|
9403
|
-
if (!res.ok) {
|
|
9404
|
-
const body = await res.text();
|
|
9405
|
-
throw formatVercelError(res.status, body, "validate project");
|
|
9406
|
-
}
|
|
9407
|
-
const data = await res.json();
|
|
9408
|
-
return {
|
|
9409
|
-
projectName: data.name,
|
|
9410
|
-
link: data.link ?? null
|
|
9411
|
-
};
|
|
9412
|
-
}
|
|
9413
|
-
async function validateProject(token, projectId, orgId) {
|
|
9414
|
-
const details = await fetchProjectDetails(token, projectId, orgId);
|
|
9415
|
-
return { projectName: details.projectName };
|
|
9416
|
-
}
|
|
9417
|
-
async function detectAccountType(token) {
|
|
9418
|
-
const res = await fetch(`${VERCEL_API}/v2/teams`, {
|
|
9419
|
-
headers: { Authorization: `Bearer ${token}` }
|
|
9420
|
-
});
|
|
9421
|
-
if (!res.ok) {
|
|
9422
|
-
const body = await res.text();
|
|
9423
|
-
throw formatVercelError(res.status, body, "detect account type");
|
|
9424
|
-
}
|
|
9425
|
-
const data = await res.json();
|
|
9426
|
-
const teams = data.teams.map((t2) => ({
|
|
9427
|
-
id: t2.id,
|
|
9428
|
-
name: t2.name,
|
|
9429
|
-
slug: t2.slug
|
|
9430
|
-
}));
|
|
9431
|
-
return { hasTeams: teams.length > 0, teams };
|
|
9432
|
-
}
|
|
9433
|
-
var VERCEL_API;
|
|
9434
|
-
var init_vercel_api = __esm({
|
|
9435
|
-
"packages/tooling/src/apps/vercel-api.ts"() {
|
|
9337
|
+
// packages/tooling/src/utils/create-utils.ts
|
|
9338
|
+
var init_create_utils = __esm({
|
|
9339
|
+
"packages/tooling/src/utils/create-utils.ts"() {
|
|
9436
9340
|
"use strict";
|
|
9437
9341
|
init_utils2();
|
|
9438
|
-
init_errors();
|
|
9439
|
-
VERCEL_API = "https://api.vercel.com";
|
|
9440
9342
|
}
|
|
9441
9343
|
});
|
|
9442
9344
|
|
|
@@ -9555,6 +9457,108 @@ var init_secrets_resolver = __esm({
|
|
|
9555
9457
|
}
|
|
9556
9458
|
});
|
|
9557
9459
|
|
|
9460
|
+
// packages/tooling/src/apps/vercel-api.ts
|
|
9461
|
+
function formatVercelError(status, body, context) {
|
|
9462
|
+
let vercelCode;
|
|
9463
|
+
let vercelMessage;
|
|
9464
|
+
try {
|
|
9465
|
+
const parsed = JSON.parse(body);
|
|
9466
|
+
const err = parsed.error ?? parsed;
|
|
9467
|
+
vercelCode = err.code;
|
|
9468
|
+
vercelMessage = err.message;
|
|
9469
|
+
} catch {
|
|
9470
|
+
}
|
|
9471
|
+
let message;
|
|
9472
|
+
switch (status) {
|
|
9473
|
+
case 401:
|
|
9474
|
+
message = "Vercel token is invalid or expired. Generate a new one at https://vercel.com/account/tokens and update .dndev.secrets";
|
|
9475
|
+
break;
|
|
9476
|
+
case 403:
|
|
9477
|
+
if (vercelCode === "team_unauthorized" || body.includes("teamId")) {
|
|
9478
|
+
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.";
|
|
9479
|
+
} else {
|
|
9480
|
+
message = `Vercel access denied: ${vercelMessage ?? "check token scope and permissions"}`;
|
|
9481
|
+
}
|
|
9482
|
+
break;
|
|
9483
|
+
case 404:
|
|
9484
|
+
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.";
|
|
9485
|
+
break;
|
|
9486
|
+
case 400:
|
|
9487
|
+
if (vercelCode === "invalid_project_name") {
|
|
9488
|
+
message = "Vercel rejected the project name. This is a framework bug \u2014 please report it.";
|
|
9489
|
+
} else {
|
|
9490
|
+
message = `Vercel rejected the request: ${vercelMessage ?? body}`;
|
|
9491
|
+
}
|
|
9492
|
+
break;
|
|
9493
|
+
case 429:
|
|
9494
|
+
message = "Vercel rate limit hit. Wait a few minutes and try again.";
|
|
9495
|
+
break;
|
|
9496
|
+
default:
|
|
9497
|
+
message = `Vercel API error during ${context} (${status}): ${vercelMessage ?? body}`;
|
|
9498
|
+
}
|
|
9499
|
+
return new DoNotDevError(message, DO_NOT_DEV_ERROR_CODES.VERCEL_API_ERROR, {
|
|
9500
|
+
context: { status, vercelCode, context }
|
|
9501
|
+
});
|
|
9502
|
+
}
|
|
9503
|
+
async function validateToken(token) {
|
|
9504
|
+
const res = await fetch(`${VERCEL_API}/v2/user`, {
|
|
9505
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
9506
|
+
});
|
|
9507
|
+
if (!res.ok) {
|
|
9508
|
+
const body = await res.text();
|
|
9509
|
+
throw formatVercelError(res.status, body, "validate token");
|
|
9510
|
+
}
|
|
9511
|
+
const data = await res.json();
|
|
9512
|
+
return { username: data.user.username, email: data.user.email };
|
|
9513
|
+
}
|
|
9514
|
+
async function fetchProjectDetails(token, projectId, orgId) {
|
|
9515
|
+
const q = orgId ? `?teamId=${encodeURIComponent(orgId)}` : "";
|
|
9516
|
+
const res = await fetch(
|
|
9517
|
+
`${VERCEL_API}/v9/projects/${encodeURIComponent(projectId)}${q}`,
|
|
9518
|
+
{
|
|
9519
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
9520
|
+
}
|
|
9521
|
+
);
|
|
9522
|
+
if (!res.ok) {
|
|
9523
|
+
const body = await res.text();
|
|
9524
|
+
throw formatVercelError(res.status, body, "validate project");
|
|
9525
|
+
}
|
|
9526
|
+
const data = await res.json();
|
|
9527
|
+
return {
|
|
9528
|
+
projectName: data.name,
|
|
9529
|
+
link: data.link ?? null
|
|
9530
|
+
};
|
|
9531
|
+
}
|
|
9532
|
+
async function validateProject(token, projectId, orgId) {
|
|
9533
|
+
const details = await fetchProjectDetails(token, projectId, orgId);
|
|
9534
|
+
return { projectName: details.projectName };
|
|
9535
|
+
}
|
|
9536
|
+
async function detectAccountType(token) {
|
|
9537
|
+
const res = await fetch(`${VERCEL_API}/v2/teams`, {
|
|
9538
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
9539
|
+
});
|
|
9540
|
+
if (!res.ok) {
|
|
9541
|
+
const body = await res.text();
|
|
9542
|
+
throw formatVercelError(res.status, body, "detect account type");
|
|
9543
|
+
}
|
|
9544
|
+
const data = await res.json();
|
|
9545
|
+
const teams = data.teams.map((t2) => ({
|
|
9546
|
+
id: t2.id,
|
|
9547
|
+
name: t2.name,
|
|
9548
|
+
slug: t2.slug
|
|
9549
|
+
}));
|
|
9550
|
+
return { hasTeams: teams.length > 0, teams };
|
|
9551
|
+
}
|
|
9552
|
+
var VERCEL_API;
|
|
9553
|
+
var init_vercel_api = __esm({
|
|
9554
|
+
"packages/tooling/src/apps/vercel-api.ts"() {
|
|
9555
|
+
"use strict";
|
|
9556
|
+
init_utils2();
|
|
9557
|
+
init_errors();
|
|
9558
|
+
VERCEL_API = "https://api.vercel.com";
|
|
9559
|
+
}
|
|
9560
|
+
});
|
|
9561
|
+
|
|
9558
9562
|
// packages/tooling/src/cli/setup/vercel-token.ts
|
|
9559
9563
|
function resolvePerAppVar(appDir, varName) {
|
|
9560
9564
|
const fromLocal = readEnvVar(joinPath(appDir, ".env.local"), varName);
|
|
@@ -9564,9 +9568,17 @@ function resolvePerAppVar(appDir, varName) {
|
|
|
9564
9568
|
if (process.env[varName]) return process.env[varName];
|
|
9565
9569
|
return null;
|
|
9566
9570
|
}
|
|
9571
|
+
function describeTokenSource(resolved, projectRoot, appDir) {
|
|
9572
|
+
if (resolved.source === "process.env") return "env var VERCEL_TOKEN";
|
|
9573
|
+
if (resolved.source === ".dndev.secrets") {
|
|
9574
|
+
return joinPath(projectRoot, ".dndev.secrets");
|
|
9575
|
+
}
|
|
9576
|
+
return joinPath(appDir, resolved.legacyPath);
|
|
9577
|
+
}
|
|
9567
9578
|
function resolveVercelCredentials(appDir, projectRoot) {
|
|
9568
9579
|
const root = projectRoot ?? getRepoRoot();
|
|
9569
|
-
const
|
|
9580
|
+
const resolvedToken = resolveSecret("VERCEL_TOKEN", root, { appDir });
|
|
9581
|
+
const token = resolvedToken?.value ?? null;
|
|
9570
9582
|
const orgId = resolvePerAppVar(appDir, "VERCEL_ORG_ID");
|
|
9571
9583
|
const projectId = resolvePerAppVar(appDir, "VERCEL_PROJECT_ID");
|
|
9572
9584
|
const missing = [];
|
|
@@ -9576,6 +9588,7 @@ function resolveVercelCredentials(appDir, projectRoot) {
|
|
|
9576
9588
|
return {
|
|
9577
9589
|
credentials: {
|
|
9578
9590
|
token,
|
|
9591
|
+
tokenSource: describeTokenSource(resolvedToken, root, appDir),
|
|
9579
9592
|
orgId: orgId ?? void 0,
|
|
9580
9593
|
projectId
|
|
9581
9594
|
}
|
|
@@ -12348,6 +12361,7 @@ init_utils2();
|
|
|
12348
12361
|
|
|
12349
12362
|
// packages/tooling/src/cli/index.ts
|
|
12350
12363
|
init_utils2();
|
|
12364
|
+
init_create_utils();
|
|
12351
12365
|
|
|
12352
12366
|
// packages/tooling/src/cli/setup/setup.ts
|
|
12353
12367
|
init_utils2();
|