@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
|
@@ -5546,11 +5546,11 @@ var require_out = __commonJS({
|
|
|
5546
5546
|
async.read(path, getSettings(optionsOrSettingsOrCallback), callback);
|
|
5547
5547
|
}
|
|
5548
5548
|
exports.stat = stat;
|
|
5549
|
-
function
|
|
5549
|
+
function statSync3(path, optionsOrSettings) {
|
|
5550
5550
|
const settings2 = getSettings(optionsOrSettings);
|
|
5551
5551
|
return sync.read(path, settings2);
|
|
5552
5552
|
}
|
|
5553
|
-
exports.statSync =
|
|
5553
|
+
exports.statSync = statSync3;
|
|
5554
5554
|
function getSettings(settingsOrOptions = {}) {
|
|
5555
5555
|
if (settingsOrOptions instanceof settings_1.default) {
|
|
5556
5556
|
return settingsOrOptions;
|
|
@@ -7490,11 +7490,12 @@ function getPatternsFor(type, repoRoot = null) {
|
|
|
7490
7490
|
function getGlobOptionsFor(type) {
|
|
7491
7491
|
return GLOB_OPTIONS[type] || GLOB_OPTIONS.base;
|
|
7492
7492
|
}
|
|
7493
|
-
var I18N_PATHS, SCAN_PATTERNS, GLOB_OPTIONS;
|
|
7493
|
+
var DEFAULT_OG_IMAGE, I18N_PATHS, SCAN_PATTERNS, GLOB_OPTIONS;
|
|
7494
7494
|
var init_constants = __esm({
|
|
7495
7495
|
"packages/core/config/constants.js"() {
|
|
7496
7496
|
"use strict";
|
|
7497
7497
|
init_utils2();
|
|
7498
|
+
DEFAULT_OG_IMAGE = "/og-image.png";
|
|
7498
7499
|
I18N_PATHS = {
|
|
7499
7500
|
// Monorepo source structure (locales at root, not in src/)
|
|
7500
7501
|
SOURCE_ROOT: "packages/core/i18n",
|
|
@@ -7505,7 +7506,9 @@ var init_constants = __esm({
|
|
|
7505
7506
|
PUBLISHED_ROOT: "i18n",
|
|
7506
7507
|
PUBLISHED_LOCALES: "i18n/locales",
|
|
7507
7508
|
PUBLISHED_EAGER: "i18n/locales/eager",
|
|
7508
|
-
PUBLISHED_LAZY: "i18n/locales/lazy"
|
|
7509
|
+
PUBLISHED_LAZY: "i18n/locales/lazy",
|
|
7510
|
+
// Flag artwork: one SVG per flag code (flagFileName), copied to public/flags/ (AssetDiscovery)
|
|
7511
|
+
PUBLISHED_FLAGS: "i18n/flags"
|
|
7509
7512
|
};
|
|
7510
7513
|
SCAN_PATTERNS = {
|
|
7511
7514
|
routes: {
|
|
@@ -7567,7 +7570,12 @@ var init_constants = __esm({
|
|
|
7567
7570
|
"logo.avif",
|
|
7568
7571
|
"apple-touch-icon*.png",
|
|
7569
7572
|
"android-chrome-*.png",
|
|
7570
|
-
|
|
7573
|
+
// Generated from logo.svg (AssetDiscovery._generateMissingAssets) or the app's own
|
|
7574
|
+
"icon-*x*.png",
|
|
7575
|
+
DEFAULT_OG_IMAGE.slice(1)
|
|
7576
|
+
// Not manifest.json: the web app manifest is a build output on Next (the PWA step
|
|
7577
|
+
// rewrites it after this scan), so its scanned size would differ between a clean
|
|
7578
|
+
// build and a rebuild. The asset manifest's `manifest` reads it from disk instead.
|
|
7571
7579
|
],
|
|
7572
7580
|
fonts: ["fonts/**/*.woff2", "fonts/**/*.woff", "fonts/**/*.ttf"],
|
|
7573
7581
|
framework: ["packages/ui/assets/**/*"]
|
|
@@ -7644,7 +7652,6 @@ import {
|
|
|
7644
7652
|
sep,
|
|
7645
7653
|
extname
|
|
7646
7654
|
} from "node:path";
|
|
7647
|
-
import { fileURLToPath } from "node:url";
|
|
7648
7655
|
function isEexistError(error2) {
|
|
7649
7656
|
return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "EEXIST";
|
|
7650
7657
|
}
|
|
@@ -8466,7 +8473,10 @@ var init_PathResolver = __esm({
|
|
|
8466
8473
|
return resolvedPath;
|
|
8467
8474
|
}
|
|
8468
8475
|
/**
|
|
8469
|
-
* Execute fast-glob with normalized results
|
|
8476
|
+
* Execute fast-glob with normalized results, sorted. fast-glob returns files in
|
|
8477
|
+
* filesystem completion order, which varies between runs: every discovery (routes,
|
|
8478
|
+
* themes, i18n, assets) and what it generates (route manifest, sitemap, llms.txt,
|
|
8479
|
+
* proxy) must list the same sources in the same order on every build.
|
|
8470
8480
|
* @private
|
|
8471
8481
|
*/
|
|
8472
8482
|
async _globWithNormalization(patterns, options) {
|
|
@@ -8474,7 +8484,7 @@ var init_PathResolver = __esm({
|
|
|
8474
8484
|
return results.map((path) => {
|
|
8475
8485
|
const pathStr = typeof path === "string" ? path : path.path;
|
|
8476
8486
|
return this.normalizePath(pathStr);
|
|
8477
|
-
});
|
|
8487
|
+
}).sort();
|
|
8478
8488
|
}
|
|
8479
8489
|
/**
|
|
8480
8490
|
* Resolve files using patterns with cross-platform support
|
|
@@ -8629,15 +8639,6 @@ var init_PathResolver = __esm({
|
|
|
8629
8639
|
const cjsPath = this.getEmptyCjsModulePath();
|
|
8630
8640
|
return cjsPath.replace(/\.cjs$/, ".js");
|
|
8631
8641
|
}
|
|
8632
|
-
/**
|
|
8633
|
-
* Get absolute path to empty flag component module.
|
|
8634
|
-
* Returns `export default () => null;` — used by flag filtering plugins
|
|
8635
|
-
* to replace unused flag files at build time.
|
|
8636
|
-
*/
|
|
8637
|
-
getEmptyFlagModulePath() {
|
|
8638
|
-
const __dirname2 = dirname2(fileURLToPath(import.meta.url));
|
|
8639
|
-
return this.normalizePath(resolve(__dirname2, "emptyFlag.js"));
|
|
8640
|
-
}
|
|
8641
8642
|
/**
|
|
8642
8643
|
* Get absolute path to empty CJS module for esbuild pre-bundling.
|
|
8643
8644
|
* CJS because esbuild statically analyzes ESM exports — CJS has dynamic
|
|
@@ -8710,12 +8711,18 @@ import {
|
|
|
8710
8711
|
parse,
|
|
8711
8712
|
isAbsolute as pathIsAbsolute
|
|
8712
8713
|
} from "node:path";
|
|
8713
|
-
import { fileURLToPath
|
|
8714
|
+
import { fileURLToPath } from "node:url";
|
|
8715
|
+
function readdirSync3(dirPath, options) {
|
|
8716
|
+
if (options !== null && typeof options === "object" && options.withFileTypes === true) {
|
|
8717
|
+
return pathResolverInstance.readdirSync(dirPath, options);
|
|
8718
|
+
}
|
|
8719
|
+
return pathResolverInstance.readdirSync(dirPath, options);
|
|
8720
|
+
}
|
|
8714
8721
|
function getDirnameFromUrl(importMetaUrl) {
|
|
8715
|
-
return dirname3(
|
|
8722
|
+
return dirname3(fileURLToPath(importMetaUrl));
|
|
8716
8723
|
}
|
|
8717
8724
|
function detectExecutionMode() {
|
|
8718
|
-
const fileUrlPath =
|
|
8725
|
+
const fileUrlPath = fileURLToPath(import.meta.url);
|
|
8719
8726
|
if (fileUrlPath.includes("node_modules")) {
|
|
8720
8727
|
return "published";
|
|
8721
8728
|
}
|
|
@@ -8727,7 +8734,7 @@ function detectExecutionMode() {
|
|
|
8727
8734
|
function getTemplatesRoot() {
|
|
8728
8735
|
const mode = detectExecutionMode();
|
|
8729
8736
|
if (mode === "development") {
|
|
8730
|
-
const fileUrlPath =
|
|
8737
|
+
const fileUrlPath = fileURLToPath(import.meta.url);
|
|
8731
8738
|
const frameworkRoot = normalizePath(dirname3(fileUrlPath), "../../../..");
|
|
8732
8739
|
return normalizePath(frameworkRoot, PACKAGE_PATHS.CLI, "templates");
|
|
8733
8740
|
} else {
|
|
@@ -8850,7 +8857,7 @@ function globSync(pattern, options = {}) {
|
|
|
8850
8857
|
});
|
|
8851
8858
|
return results.map((p) => pathResolverInstance.normalizePath(p));
|
|
8852
8859
|
}
|
|
8853
|
-
var pathResolverInstance, getRepoRoot, getAppRoot, resolveFrameworkPackage, normalizePath, pathExists, read, readSync, write, writeSync, removeSync, ensureDir, getRelativePathBetween, getDirname, getBasename, joinPath;
|
|
8860
|
+
var pathResolverInstance, getRepoRoot, getAppRoot, resolveFrameworkPackage, normalizePath, pathExists, read, readSync, write, writeSync, removeSync, statSync2, ensureDir, getRelativePathBetween, getDirname, getBasename, joinPath;
|
|
8854
8861
|
var init_pathResolver = __esm({
|
|
8855
8862
|
"packages/tooling/src/utils/pathResolver.ts"() {
|
|
8856
8863
|
"use strict";
|
|
@@ -8869,6 +8876,7 @@ var init_pathResolver = __esm({
|
|
|
8869
8876
|
write = async (filePath, content, options) => pathResolverInstance.write(filePath, content, options);
|
|
8870
8877
|
writeSync = (filePath, content, options) => pathResolverInstance.writeSync(filePath, content, options);
|
|
8871
8878
|
removeSync = (path) => pathResolverInstance.removeSync(path);
|
|
8879
|
+
statSync2 = (filePath) => pathResolverInstance.statSync(filePath);
|
|
8872
8880
|
ensureDir = async (dirPath) => pathResolverInstance.ensureDir(dirPath);
|
|
8873
8881
|
getRelativePathBetween = (from, to) => {
|
|
8874
8882
|
return normalizePath(relative2(from, to));
|
|
@@ -8885,6 +8893,34 @@ var init_pathResolver = __esm({
|
|
|
8885
8893
|
}
|
|
8886
8894
|
});
|
|
8887
8895
|
|
|
8896
|
+
// packages/tooling/src/utils/typed-file-operations.ts
|
|
8897
|
+
function readPackageJson(filePath) {
|
|
8898
|
+
if (!pathExists(filePath)) {
|
|
8899
|
+
throw new DoNotDevError(
|
|
8900
|
+
`package.json not found: ${filePath}`,
|
|
8901
|
+
DO_NOT_DEV_ERROR_CODES.FILE_NOT_FOUND,
|
|
8902
|
+
{ context: { filePath } }
|
|
8903
|
+
);
|
|
8904
|
+
}
|
|
8905
|
+
const content = readSync(filePath, { format: "json" });
|
|
8906
|
+
if (!content || typeof content !== "object" || !("name" in content)) {
|
|
8907
|
+
throw new DoNotDevError(
|
|
8908
|
+
`Invalid package.json: ${filePath}`,
|
|
8909
|
+
DO_NOT_DEV_ERROR_CODES.CONFIG_INVALID,
|
|
8910
|
+
{ context: { filePath } }
|
|
8911
|
+
);
|
|
8912
|
+
}
|
|
8913
|
+
return content;
|
|
8914
|
+
}
|
|
8915
|
+
var init_typed_file_operations = __esm({
|
|
8916
|
+
"packages/tooling/src/utils/typed-file-operations.ts"() {
|
|
8917
|
+
"use strict";
|
|
8918
|
+
init_utils2();
|
|
8919
|
+
init_errors();
|
|
8920
|
+
init_pathResolver();
|
|
8921
|
+
}
|
|
8922
|
+
});
|
|
8923
|
+
|
|
8888
8924
|
// packages/tooling/src/utils/type-guards.ts
|
|
8889
8925
|
function isRecord(value) {
|
|
8890
8926
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -8892,10 +8928,21 @@ function isRecord(value) {
|
|
|
8892
8928
|
function asText(value) {
|
|
8893
8929
|
return typeof value === "string" ? value : null;
|
|
8894
8930
|
}
|
|
8931
|
+
function requireText(value, filePath) {
|
|
8932
|
+
if (typeof value !== "string") {
|
|
8933
|
+
throw new DoNotDevError(
|
|
8934
|
+
`Cannot read text file: ${filePath}`,
|
|
8935
|
+
DO_NOT_DEV_ERROR_CODES.FILE_NOT_FOUND,
|
|
8936
|
+
{ context: { filePath } }
|
|
8937
|
+
);
|
|
8938
|
+
}
|
|
8939
|
+
return value;
|
|
8940
|
+
}
|
|
8895
8941
|
var init_type_guards = __esm({
|
|
8896
8942
|
"packages/tooling/src/utils/type-guards.ts"() {
|
|
8897
8943
|
"use strict";
|
|
8898
8944
|
init_utils2();
|
|
8945
|
+
init_errors();
|
|
8899
8946
|
}
|
|
8900
8947
|
});
|
|
8901
8948
|
|
|
@@ -8905,13 +8952,13 @@ import { copyFileSync as copyFileSync2, readFileSync as readFileSync2, writeFile
|
|
|
8905
8952
|
import { createRequire as createRequire3 } from "node:module";
|
|
8906
8953
|
import { dirname as dirname4, resolve as resolve3 } from "node:path";
|
|
8907
8954
|
import process from "node:process";
|
|
8908
|
-
import { fileURLToPath as
|
|
8955
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8909
8956
|
var require2, __filename, __dirname;
|
|
8910
8957
|
var init_utils2 = __esm({
|
|
8911
8958
|
"packages/tooling/src/bundler/utils.ts"() {
|
|
8912
8959
|
"use strict";
|
|
8913
8960
|
require2 = createRequire3(import.meta.url);
|
|
8914
|
-
__filename =
|
|
8961
|
+
__filename = fileURLToPath2(import.meta.url);
|
|
8915
8962
|
__dirname = dirname4(__filename);
|
|
8916
8963
|
if (typeof globalThis !== "undefined") {
|
|
8917
8964
|
globalThis.require = require2;
|
|
@@ -8926,19 +8973,198 @@ var init_utils2 = __esm({
|
|
|
8926
8973
|
}
|
|
8927
8974
|
});
|
|
8928
8975
|
|
|
8976
|
+
// packages/tooling/src/utils/app-detection.ts
|
|
8977
|
+
function isVercelFunctionsDir(functionsDir) {
|
|
8978
|
+
return statSync2(joinPath(functionsDir, "src", "api"))?.isDirectory() ?? false;
|
|
8979
|
+
}
|
|
8980
|
+
function detectApps(projectRoot) {
|
|
8981
|
+
const apps = [];
|
|
8982
|
+
const appsDir = joinPath(projectRoot, "apps");
|
|
8983
|
+
const appsDirStat = statSync2(appsDir);
|
|
8984
|
+
if (pathExists(appsDir) && appsDirStat?.isDirectory()) {
|
|
8985
|
+
const appDirs = readdirSync3(appsDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name).sort();
|
|
8986
|
+
for (const appDir of appDirs) {
|
|
8987
|
+
const appPath = joinPath(appsDir, appDir);
|
|
8988
|
+
const packageJsonPath = joinPath(appPath, "package.json");
|
|
8989
|
+
if (pathExists(packageJsonPath)) {
|
|
8990
|
+
const appInfo = analyzeApp(appPath, appDir);
|
|
8991
|
+
if (appInfo) {
|
|
8992
|
+
apps.push(appInfo);
|
|
8993
|
+
}
|
|
8994
|
+
}
|
|
8995
|
+
}
|
|
8996
|
+
} else {
|
|
8997
|
+
const packageJsonPath = joinPath(projectRoot, "package.json");
|
|
8998
|
+
if (pathExists(packageJsonPath)) {
|
|
8999
|
+
try {
|
|
9000
|
+
const packageJson = readPackageJson(packageJsonPath);
|
|
9001
|
+
if (packageJson && (packageJson.dependencies?.vite || packageJson.devDependencies?.vite || packageJson.dependencies?.next || packageJson.devDependencies?.next)) {
|
|
9002
|
+
const pathParts = projectRoot.split(/[/\\]/);
|
|
9003
|
+
const appName = pathParts[pathParts.length - 1] || "app";
|
|
9004
|
+
const appInfo = analyzeApp(projectRoot, appName);
|
|
9005
|
+
if (appInfo) {
|
|
9006
|
+
apps.push(appInfo);
|
|
9007
|
+
}
|
|
9008
|
+
}
|
|
9009
|
+
} catch {
|
|
9010
|
+
}
|
|
9011
|
+
}
|
|
9012
|
+
}
|
|
9013
|
+
return apps;
|
|
9014
|
+
}
|
|
9015
|
+
function analyzeApp(appPath, appName) {
|
|
9016
|
+
const packageJsonPath = joinPath(appPath, "package.json");
|
|
9017
|
+
if (!pathExists(packageJsonPath)) {
|
|
9018
|
+
return null;
|
|
9019
|
+
}
|
|
9020
|
+
let packageJson = null;
|
|
9021
|
+
try {
|
|
9022
|
+
packageJson = readPackageJson(packageJsonPath);
|
|
9023
|
+
if (!packageJson.name) {
|
|
9024
|
+
return null;
|
|
9025
|
+
}
|
|
9026
|
+
} catch {
|
|
9027
|
+
return null;
|
|
9028
|
+
}
|
|
9029
|
+
let framework = "unknown";
|
|
9030
|
+
if (pathExists(joinPath(appPath, "next.config.js")) || pathExists(joinPath(appPath, "next.config.ts")) || pathExists(joinPath(appPath, "next.config.mjs")) || packageJson.dependencies?.next || packageJson.devDependencies?.next) {
|
|
9031
|
+
framework = "nextjs";
|
|
9032
|
+
} 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) {
|
|
9033
|
+
framework = "vite";
|
|
9034
|
+
}
|
|
9035
|
+
const firebaseJsonPath = joinPath(appPath, "firebase.json");
|
|
9036
|
+
const hasFirebase = pathExists(firebaseJsonPath);
|
|
9037
|
+
const supabaseDir = joinPath(appPath, "supabase");
|
|
9038
|
+
const supabaseConfigPath = joinPath(supabaseDir, "config.toml");
|
|
9039
|
+
const hasSupabaseDep = !!(packageJson.dependencies?.["@donotdev/supabase"] || packageJson.dependencies?.["@supabase/supabase-js"]);
|
|
9040
|
+
let hasSupabase = pathExists(supabaseDir) || pathExists(supabaseConfigPath) || hasSupabaseDep;
|
|
9041
|
+
if (!hasSupabase) {
|
|
9042
|
+
try {
|
|
9043
|
+
const envPath = joinPath(appPath, ".env");
|
|
9044
|
+
if (pathExists(envPath)) {
|
|
9045
|
+
const envContent = requireText(readSync(envPath), envPath);
|
|
9046
|
+
if (envContent.match(/VITE_SUPABASE_URL=.+/)) {
|
|
9047
|
+
hasSupabase = true;
|
|
9048
|
+
}
|
|
9049
|
+
}
|
|
9050
|
+
} catch {
|
|
9051
|
+
}
|
|
9052
|
+
}
|
|
9053
|
+
let provider = "unknown";
|
|
9054
|
+
if (hasFirebase && hasSupabase) {
|
|
9055
|
+
provider = "both";
|
|
9056
|
+
} else if (hasFirebase) {
|
|
9057
|
+
provider = "firebase";
|
|
9058
|
+
} else if (hasSupabase) {
|
|
9059
|
+
provider = "supabase";
|
|
9060
|
+
}
|
|
9061
|
+
let firebaseConfig;
|
|
9062
|
+
if (hasFirebase) {
|
|
9063
|
+
try {
|
|
9064
|
+
const config = readSync(firebaseJsonPath, { format: "json" });
|
|
9065
|
+
if (config && typeof config === "object") {
|
|
9066
|
+
const fb = config;
|
|
9067
|
+
firebaseConfig = {
|
|
9068
|
+
projectId: fb.projectId,
|
|
9069
|
+
hasHosting: !!fb.hosting,
|
|
9070
|
+
hasFunctions: !!fb.functions,
|
|
9071
|
+
hasFirestoreRules: !!fb.firestore?.rules,
|
|
9072
|
+
hasStorageRules: !!fb.storage?.rules
|
|
9073
|
+
};
|
|
9074
|
+
}
|
|
9075
|
+
} catch {
|
|
9076
|
+
firebaseConfig = {
|
|
9077
|
+
hasHosting: false,
|
|
9078
|
+
hasFunctions: false,
|
|
9079
|
+
hasFirestoreRules: false,
|
|
9080
|
+
hasStorageRules: false
|
|
9081
|
+
};
|
|
9082
|
+
}
|
|
9083
|
+
}
|
|
9084
|
+
const supabaseFunctionsDir = joinPath(supabaseDir, "functions");
|
|
9085
|
+
const supabaseMigrationsDir = joinPath(supabaseDir, "migrations");
|
|
9086
|
+
let supabaseConfig;
|
|
9087
|
+
if (hasSupabase) {
|
|
9088
|
+
let url;
|
|
9089
|
+
try {
|
|
9090
|
+
const envPath = joinPath(appPath, ".env");
|
|
9091
|
+
if (pathExists(envPath)) {
|
|
9092
|
+
const envContent = requireText(readSync(envPath), envPath);
|
|
9093
|
+
const urlMatch = envContent.match(/VITE_SUPABASE_URL=(.+)/);
|
|
9094
|
+
if (urlMatch && urlMatch[1]) {
|
|
9095
|
+
url = urlMatch[1].trim();
|
|
9096
|
+
}
|
|
9097
|
+
}
|
|
9098
|
+
} catch {
|
|
9099
|
+
}
|
|
9100
|
+
supabaseConfig = {
|
|
9101
|
+
url,
|
|
9102
|
+
hasFunctions: pathExists(supabaseFunctionsDir),
|
|
9103
|
+
hasMigrations: pathExists(supabaseMigrationsDir)
|
|
9104
|
+
};
|
|
9105
|
+
}
|
|
9106
|
+
let functions;
|
|
9107
|
+
if (hasFirebase && firebaseConfig?.hasFunctions) {
|
|
9108
|
+
const firebaseFunctionsDir = joinPath(appPath, "functions");
|
|
9109
|
+
const firebaseFunctionsStat = statSync2(firebaseFunctionsDir);
|
|
9110
|
+
if (pathExists(firebaseFunctionsDir) && (firebaseFunctionsStat?.isDirectory() ?? false)) {
|
|
9111
|
+
functions = "firebase";
|
|
9112
|
+
}
|
|
9113
|
+
}
|
|
9114
|
+
if (!functions && hasSupabase) {
|
|
9115
|
+
const sbFunctionsStat = statSync2(supabaseFunctionsDir);
|
|
9116
|
+
if (pathExists(supabaseFunctionsDir) && (sbFunctionsStat?.isDirectory() ?? false)) {
|
|
9117
|
+
functions = "supabase";
|
|
9118
|
+
}
|
|
9119
|
+
}
|
|
9120
|
+
if (!functions && isVercelFunctionsDir(joinPath(appPath, "functions"))) {
|
|
9121
|
+
functions = "vercel";
|
|
9122
|
+
}
|
|
9123
|
+
let hosting;
|
|
9124
|
+
if (hasFirebase && firebaseConfig?.hasHosting) {
|
|
9125
|
+
hosting = "firebase";
|
|
9126
|
+
}
|
|
9127
|
+
if (!hosting) {
|
|
9128
|
+
if (pathExists(joinPath(appPath, "vercel.json")) || pathExists(joinPath(appPath, ".vercel"))) {
|
|
9129
|
+
hosting = "vercel";
|
|
9130
|
+
}
|
|
9131
|
+
}
|
|
9132
|
+
return {
|
|
9133
|
+
name: appName,
|
|
9134
|
+
packageName: packageJson.name || appName,
|
|
9135
|
+
path: appPath,
|
|
9136
|
+
framework,
|
|
9137
|
+
provider,
|
|
9138
|
+
functions,
|
|
9139
|
+
hosting,
|
|
9140
|
+
firebaseConfig,
|
|
9141
|
+
supabaseConfig
|
|
9142
|
+
};
|
|
9143
|
+
}
|
|
9144
|
+
var init_app_detection = __esm({
|
|
9145
|
+
"packages/tooling/src/utils/app-detection.ts"() {
|
|
9146
|
+
"use strict";
|
|
9147
|
+
init_utils2();
|
|
9148
|
+
init_pathResolver();
|
|
9149
|
+
init_typed_file_operations();
|
|
9150
|
+
init_type_guards();
|
|
9151
|
+
}
|
|
9152
|
+
});
|
|
9153
|
+
|
|
8929
9154
|
// packages/tooling/src/utils/cli-input.ts
|
|
9155
|
+
function exitCancelled() {
|
|
9156
|
+
cancel("Cancelled");
|
|
9157
|
+
process.exit(CANCELLED_EXIT_CODE);
|
|
9158
|
+
}
|
|
8930
9159
|
async function askForConfirmation(message, defaultValue = false) {
|
|
8931
9160
|
const result = await confirm({
|
|
8932
9161
|
message,
|
|
8933
9162
|
initialValue: defaultValue
|
|
8934
9163
|
});
|
|
8935
|
-
if (isCancel(result))
|
|
8936
|
-
cancel("Operation cancelled.");
|
|
8937
|
-
process.exit(0);
|
|
8938
|
-
}
|
|
9164
|
+
if (isCancel(result)) exitCancelled();
|
|
8939
9165
|
return result;
|
|
8940
9166
|
}
|
|
8941
|
-
async function askForMultiSelection(message, choices, defaultIndices = []) {
|
|
9167
|
+
async function askForMultiSelection(message, choices, defaultIndices = [], required = true) {
|
|
8942
9168
|
const options = choices.map((choice) => ({
|
|
8943
9169
|
value: choice.value,
|
|
8944
9170
|
label: choice.title,
|
|
@@ -8948,36 +9174,32 @@ async function askForMultiSelection(message, choices, defaultIndices = []) {
|
|
|
8948
9174
|
const result = await multiselect({
|
|
8949
9175
|
message,
|
|
8950
9176
|
options,
|
|
8951
|
-
initialValues: initialValues.length > 0 ? initialValues : void 0
|
|
9177
|
+
initialValues: initialValues.length > 0 ? initialValues : void 0,
|
|
9178
|
+
required
|
|
8952
9179
|
});
|
|
8953
|
-
if (isCancel(result))
|
|
8954
|
-
cancel("Operation cancelled.");
|
|
8955
|
-
process.exit(0);
|
|
8956
|
-
}
|
|
9180
|
+
if (isCancel(result)) exitCancelled();
|
|
8957
9181
|
return result;
|
|
8958
9182
|
}
|
|
9183
|
+
var CANCELLED_EXIT_CODE;
|
|
8959
9184
|
var init_cli_input = __esm({
|
|
8960
9185
|
"packages/tooling/src/utils/cli-input.ts"() {
|
|
8961
9186
|
"use strict";
|
|
8962
9187
|
init_utils2();
|
|
8963
9188
|
init_dist5();
|
|
9189
|
+
CANCELLED_EXIT_CODE = 130;
|
|
8964
9190
|
}
|
|
8965
9191
|
});
|
|
8966
9192
|
|
|
8967
|
-
// packages/
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
init_utils2();
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
init_utils2();
|
|
9193
|
+
// packages/tooling/src/utils/create-utils.ts
|
|
9194
|
+
var init_create_utils = __esm({
|
|
9195
|
+
"packages/tooling/src/utils/create-utils.ts"() {
|
|
9196
|
+
"use strict";
|
|
9197
|
+
init_utils2();
|
|
9198
|
+
}
|
|
9199
|
+
});
|
|
8975
9200
|
|
|
8976
9201
|
// packages/tooling/src/utils/matrix.ts
|
|
8977
|
-
init_utils2();
|
|
8978
|
-
init_pathResolver();
|
|
8979
9202
|
import { createRequire as createRequire4 } from "node:module";
|
|
8980
|
-
var cachedMatrix = null;
|
|
8981
9203
|
function getMatrixPath(mode) {
|
|
8982
9204
|
try {
|
|
8983
9205
|
const require3 = createRequire4(import.meta.url);
|
|
@@ -9036,6 +9258,15 @@ function loadMatrix(mode) {
|
|
|
9036
9258
|
};
|
|
9037
9259
|
return cachedMatrix;
|
|
9038
9260
|
}
|
|
9261
|
+
function getNodePolicy(mode) {
|
|
9262
|
+
const matrix = loadMatrix(mode)?.matrix;
|
|
9263
|
+
if (!matrix?.nodePolicy) {
|
|
9264
|
+
throw new Error(
|
|
9265
|
+
'dependencies-matrix.json has no "nodePolicy" (Node version policy).'
|
|
9266
|
+
);
|
|
9267
|
+
}
|
|
9268
|
+
return matrix.nodePolicy;
|
|
9269
|
+
}
|
|
9039
9270
|
function clearMatrixCache() {
|
|
9040
9271
|
cachedMatrix = null;
|
|
9041
9272
|
}
|
|
@@ -9076,10 +9307,17 @@ function getMigrationGuide(currentMajor, targetMajor, mode) {
|
|
|
9076
9307
|
const key = `${currentMajor}.0\u2192${targetMajor}.0`;
|
|
9077
9308
|
return matrixResult.matrix.migrationGuides?.[key];
|
|
9078
9309
|
}
|
|
9310
|
+
var cachedMatrix;
|
|
9311
|
+
var init_matrix = __esm({
|
|
9312
|
+
"packages/tooling/src/utils/matrix.ts"() {
|
|
9313
|
+
"use strict";
|
|
9314
|
+
init_utils2();
|
|
9315
|
+
init_pathResolver();
|
|
9316
|
+
cachedMatrix = null;
|
|
9317
|
+
}
|
|
9318
|
+
});
|
|
9079
9319
|
|
|
9080
9320
|
// packages/tooling/src/utils/package-deps.ts
|
|
9081
|
-
init_utils2();
|
|
9082
|
-
init_pathResolver();
|
|
9083
9321
|
function parsePackageJson(filePath) {
|
|
9084
9322
|
try {
|
|
9085
9323
|
return readSync(filePath, { format: "json" });
|
|
@@ -9157,11 +9395,28 @@ function compareVersions(current, expected) {
|
|
|
9157
9395
|
}
|
|
9158
9396
|
return { behind: false, ahead: false, equal: true, isMajor: false };
|
|
9159
9397
|
}
|
|
9398
|
+
var init_package_deps = __esm({
|
|
9399
|
+
"packages/tooling/src/utils/package-deps.ts"() {
|
|
9400
|
+
"use strict";
|
|
9401
|
+
init_utils2();
|
|
9402
|
+
init_pathResolver();
|
|
9403
|
+
}
|
|
9404
|
+
});
|
|
9405
|
+
|
|
9406
|
+
// packages/cli/src/bin/commands/bump.ts
|
|
9407
|
+
init_utils2();
|
|
9408
|
+
|
|
9409
|
+
// packages/tooling/src/index.ts
|
|
9410
|
+
init_utils2();
|
|
9411
|
+
|
|
9412
|
+
// packages/tooling/src/cli/index.ts
|
|
9413
|
+
init_utils2();
|
|
9160
9414
|
|
|
9161
9415
|
// packages/tooling/src/bundler/sync-dependencies.ts
|
|
9162
9416
|
init_utils2();
|
|
9163
9417
|
import { execSync } from "node:child_process";
|
|
9164
9418
|
import { createRequire as createRequire5 } from "node:module";
|
|
9419
|
+
init_matrix();
|
|
9165
9420
|
init_pathResolver();
|
|
9166
9421
|
var INTERNAL_BUNDLED_PACKAGES = /* @__PURE__ */ new Set([
|
|
9167
9422
|
"@donotdev/types",
|
|
@@ -9227,6 +9482,7 @@ function syncDonotdevToMatrix(matrix, donotdevVersions, dryRun) {
|
|
|
9227
9482
|
|
|
9228
9483
|
// packages/tooling/src/utils/dependency-resolver.ts
|
|
9229
9484
|
init_utils2();
|
|
9485
|
+
init_matrix();
|
|
9230
9486
|
function applyConditionals(template, options) {
|
|
9231
9487
|
if (!template.conditional) return [];
|
|
9232
9488
|
const groups = [];
|
|
@@ -9266,13 +9522,13 @@ function generateScripts(templateName, options) {
|
|
|
9266
9522
|
scripts.lint = "eslint .";
|
|
9267
9523
|
scripts["type-check"] = "tsc --noEmit";
|
|
9268
9524
|
} else if (templateName === "consumer-root") {
|
|
9269
|
-
scripts.dev = "
|
|
9525
|
+
scripts.dev = "turbo run dev";
|
|
9270
9526
|
scripts.build = "turbo run build";
|
|
9271
9527
|
scripts.lint = "turbo run lint";
|
|
9272
|
-
scripts["type-check"] = "
|
|
9528
|
+
scripts["type-check"] = "turbo run type-check";
|
|
9273
9529
|
} else if (templateName.includes("functions")) {
|
|
9274
9530
|
scripts.build = "node build.mjs";
|
|
9275
|
-
scripts["
|
|
9531
|
+
scripts["type-check"] = "tsc --noEmit";
|
|
9276
9532
|
if (templateName.includes("firebase") || options.platform === "firebase") {
|
|
9277
9533
|
scripts.serve = "firebase emulators:start --only functions";
|
|
9278
9534
|
scripts.dev = "firebase emulators:start --only functions --inspect-functions";
|
|
@@ -9351,13 +9607,19 @@ function generatePackageJson(templateName, mode, options = {}) {
|
|
|
9351
9607
|
}
|
|
9352
9608
|
if (templateName === "consumer-root") {
|
|
9353
9609
|
result.packageManager = "bun@1.3.5";
|
|
9354
|
-
result.engines = {
|
|
9610
|
+
result.engines = {
|
|
9611
|
+
node: getNodePolicy(mode).enginesMin,
|
|
9612
|
+
bun: ">=1.3.0"
|
|
9613
|
+
};
|
|
9355
9614
|
result.workspaces = ["apps/*", "entities"];
|
|
9356
9615
|
}
|
|
9357
9616
|
if (templateName === "entities") {
|
|
9358
9617
|
result.main = "./index.ts";
|
|
9359
9618
|
result.types = "./index.ts";
|
|
9360
9619
|
}
|
|
9620
|
+
if (templateName.includes("expo")) {
|
|
9621
|
+
result.main = "expo-router/entry";
|
|
9622
|
+
}
|
|
9361
9623
|
if (templateName.includes("nextjs")) {
|
|
9362
9624
|
result.browserslist = [
|
|
9363
9625
|
"chrome >= 64",
|
|
@@ -9414,6 +9676,9 @@ function generatePackageJson(templateName, mode, options = {}) {
|
|
|
9414
9676
|
return result;
|
|
9415
9677
|
}
|
|
9416
9678
|
|
|
9679
|
+
// packages/tooling/src/cli/index.ts
|
|
9680
|
+
init_create_utils();
|
|
9681
|
+
|
|
9417
9682
|
// packages/tooling/src/maintenance/bump.ts
|
|
9418
9683
|
init_utils2();
|
|
9419
9684
|
import { execSync as execSync2 } from "node:child_process";
|
|
@@ -9422,6 +9687,7 @@ import { execSync as execSync2 } from "node:child_process";
|
|
|
9422
9687
|
init_utils2();
|
|
9423
9688
|
init_cli_output();
|
|
9424
9689
|
init_errors();
|
|
9690
|
+
init_package_deps();
|
|
9425
9691
|
init_pathResolver();
|
|
9426
9692
|
init_type_guards();
|
|
9427
9693
|
var PRESERVE_MAP = {
|
|
@@ -9610,6 +9876,7 @@ init_utils2();
|
|
|
9610
9876
|
init_cli_output();
|
|
9611
9877
|
init_errors();
|
|
9612
9878
|
init_pathResolver();
|
|
9879
|
+
init_app_detection();
|
|
9613
9880
|
init_type_guards();
|
|
9614
9881
|
var SYNC_PATHS = [
|
|
9615
9882
|
// Documentation
|
|
@@ -9647,6 +9914,16 @@ var PRESERVE_IF_EXISTS = [
|
|
|
9647
9914
|
// User/agent may have customized features
|
|
9648
9915
|
];
|
|
9649
9916
|
var PROJECT_SECTION_MARKER = "<!-- dndev:project-specific -->";
|
|
9917
|
+
function detectProjectPlatform(projectRoot) {
|
|
9918
|
+
const apps = detectApps(projectRoot);
|
|
9919
|
+
const withProvider = apps.find(
|
|
9920
|
+
(app) => app.provider === "firebase" || app.provider === "supabase"
|
|
9921
|
+
);
|
|
9922
|
+
if (withProvider?.provider === "firebase") return "firebase";
|
|
9923
|
+
if (withProvider?.provider === "supabase") return "supabase";
|
|
9924
|
+
if (apps.some((app) => app.functions === "vercel")) return "vercel";
|
|
9925
|
+
return "none";
|
|
9926
|
+
}
|
|
9650
9927
|
function mergeProjectSection(template, existing) {
|
|
9651
9928
|
const templateIndex = template.indexOf(PROJECT_SECTION_MARKER);
|
|
9652
9929
|
if (templateIndex === -1 || existing === null) return template;
|
|
@@ -9773,6 +10050,11 @@ async function syncFile(sourcePath, destPath, preserveIfExists, appRoot) {
|
|
|
9773
10050
|
content = mergeMcpConfig(templateContent, existingContent);
|
|
9774
10051
|
} else if (relativeDest === ".claude/settings.json") {
|
|
9775
10052
|
content = mergeClaudeSettings(templateContent, existingContent);
|
|
10053
|
+
} else if (relativeDest === ".dndev/args.json") {
|
|
10054
|
+
content = templateContent.replace(
|
|
10055
|
+
"{{platform}}",
|
|
10056
|
+
detectProjectPlatform(appRoot)
|
|
10057
|
+
);
|
|
9776
10058
|
} else {
|
|
9777
10059
|
content = mergeProjectSection(templateContent, existingContent);
|
|
9778
10060
|
}
|
|
@@ -9873,11 +10155,11 @@ async function syncDocumentation(options = {}) {
|
|
|
9873
10155
|
log2.error("Could not find framework templates. Documentation sync failed.");
|
|
9874
10156
|
log2.info("");
|
|
9875
10157
|
log2.info(" Templates are looked up the same way as create-project:");
|
|
9876
|
-
log2.info(" \u2022 Published mode:
|
|
10158
|
+
log2.info(" \u2022 Published mode: the templates shipped with the running CLI");
|
|
9877
10159
|
log2.info(" \u2022 Dev mode: packages/cli/templates (from monorepo)");
|
|
9878
10160
|
log2.info("");
|
|
9879
10161
|
log2.info(" To enable docs sync:");
|
|
9880
|
-
log2.info(" \u2022
|
|
10162
|
+
log2.info(" \u2022 Run the global CLI (dndev), not a copy inside the project");
|
|
9881
10163
|
log2.info(" \u2022 Or run from framework monorepo (dev mode)");
|
|
9882
10164
|
return 1;
|
|
9883
10165
|
}
|
|
@@ -9914,6 +10196,8 @@ async function syncDocumentation(options = {}) {
|
|
|
9914
10196
|
// packages/tooling/src/maintenance/bump.ts
|
|
9915
10197
|
init_cli_input();
|
|
9916
10198
|
init_cli_output();
|
|
10199
|
+
init_matrix();
|
|
10200
|
+
init_package_deps();
|
|
9917
10201
|
init_pathResolver();
|
|
9918
10202
|
async function queryNpmPackage(packageName) {
|
|
9919
10203
|
try {
|