create-mohit-next 0.0.0-stage → 2.0.0
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/README.md +139 -2
- package/index.js +399 -0
- package/lib/features.js +358 -0
- package/lib/scaffold.js +471 -0
- package/package.json +40 -4
- package/templates/common/_editorconfig +12 -0
- package/templates/common/_gitattributes +5 -0
- package/templates/common/_github/dependabot.yml +14 -0
- package/templates/common/_github/workflows/ci.yml +66 -0
- package/templates/common/_husky/commit-msg +1 -0
- package/templates/common/_husky/pre-commit +1 -0
- package/templates/common/_nvmrc +1 -0
- package/templates/common/_prettierignore +15 -0
- package/templates/common/commitlint.config.mjs +10 -0
- package/templates/next/AGENTS.md +9 -0
- package/templates/next/Dockerfile +48 -0
- package/templates/next/README.md +328 -0
- package/templates/next/_dockerignore +13 -0
- package/templates/next/_env.example +20 -0
- package/templates/next/_gitignore +50 -0
- package/templates/next/docker-compose.yml +33 -0
- package/templates/next/e2e/rbac.spec.ts +69 -0
- package/templates/next/e2e/server.mjs +35 -0
- package/templates/next/eslint.config.mjs +33 -0
- package/templates/next/next.config.ts +47 -0
- package/templates/next/package.json +68 -0
- package/templates/next/playwright.config.ts +30 -0
- package/templates/next/public/robots.txt +6 -0
- package/templates/next/scripts/seed.ts +111 -0
- package/templates/next/src/app/(app)/admin/audit/page.tsx +99 -0
- package/templates/next/src/app/(app)/admin/page.tsx +92 -0
- package/templates/next/src/app/(app)/dashboard/page.tsx +120 -0
- package/templates/next/src/app/(app)/error.tsx +28 -0
- package/templates/next/src/app/(app)/layout.tsx +58 -0
- package/templates/next/src/app/(app)/loading.tsx +5 -0
- package/templates/next/src/app/(app)/reports/page.tsx +128 -0
- package/templates/next/src/app/(app)/settings/page.tsx +66 -0
- package/templates/next/src/app/(auth)/forgot-password/page.tsx +17 -0
- package/templates/next/src/app/(auth)/layout.tsx +18 -0
- package/templates/next/src/app/(auth)/login/page.tsx +18 -0
- package/templates/next/src/app/(auth)/register/page.tsx +18 -0
- package/templates/next/src/app/(auth)/reset-password/page.tsx +18 -0
- package/templates/next/src/app/api/account/password/route.ts +45 -0
- package/templates/next/src/app/api/account/route.ts +25 -0
- package/templates/next/src/app/api/account/sessions/route.ts +12 -0
- package/templates/next/src/app/api/admin/audit/route.ts +13 -0
- package/templates/next/src/app/api/admin/users/[id]/route.ts +61 -0
- package/templates/next/src/app/api/admin/users/route.ts +18 -0
- package/templates/next/src/app/api/auth/forgot-password/route.ts +47 -0
- package/templates/next/src/app/api/auth/login/route.ts +43 -0
- package/templates/next/src/app/api/auth/logout/route.ts +21 -0
- package/templates/next/src/app/api/auth/me/route.ts +21 -0
- package/templates/next/src/app/api/auth/register/route.ts +74 -0
- package/templates/next/src/app/api/auth/resend-verification/route.ts +25 -0
- package/templates/next/src/app/api/auth/reset-password/route.ts +43 -0
- package/templates/next/src/app/api/auth/verify-email/route.ts +29 -0
- package/templates/next/src/app/api/health/route.ts +27 -0
- package/templates/next/src/app/favicon.ico +0 -0
- package/templates/next/src/app/forbidden/page.tsx +47 -0
- package/templates/next/src/app/layout.tsx +55 -0
- package/templates/next/src/app/not-found.tsx +20 -0
- package/templates/next/src/app/opengraph-image.tsx +49 -0
- package/templates/next/src/app/page.tsx +165 -0
- package/templates/next/src/app/robots.ts +15 -0
- package/templates/next/src/app/sitemap.ts +13 -0
- package/templates/next/src/app/verify-email/page.tsx +23 -0
- package/templates/next/src/components/admin/user-actions.tsx +124 -0
- package/templates/next/src/components/admin/users-data-table.tsx +221 -0
- package/templates/next/src/components/admin/users-table.tsx +67 -0
- package/templates/next/src/components/auth/auth-card.tsx +41 -0
- package/templates/next/src/components/auth/can.tsx +34 -0
- package/templates/next/src/components/auth/forgot-password-form.tsx +76 -0
- package/templates/next/src/components/auth/form-field.tsx +40 -0
- package/templates/next/src/components/auth/login-form.tsx +87 -0
- package/templates/next/src/components/auth/password-input.tsx +43 -0
- package/templates/next/src/components/auth/register-form.tsx +117 -0
- package/templates/next/src/components/auth/reset-password-form.tsx +80 -0
- package/templates/next/src/components/auth/session-refresher.tsx +44 -0
- package/templates/next/src/components/auth/verify-email-banner.tsx +43 -0
- package/templates/next/src/components/auth/verify-email-status.tsx +44 -0
- package/templates/next/src/components/layout/nav-links.tsx +37 -0
- package/templates/next/src/components/layout/navbar.tsx +27 -0
- package/templates/next/src/components/layout/page-header.tsx +21 -0
- package/templates/next/src/components/layout/sidebar.tsx +83 -0
- package/templates/next/src/components/layout/skeletons.tsx +57 -0
- package/templates/next/src/components/layout/user-menu.tsx +118 -0
- package/templates/next/src/components/logo.tsx +16 -0
- package/templates/next/src/components/motion/fade-in.tsx +19 -0
- package/templates/next/src/components/providers/user-provider.tsx +60 -0
- package/templates/next/src/components/reports/animated-bar.tsx +24 -0
- package/templates/next/src/components/reports/role-chart.tsx +61 -0
- package/templates/next/src/components/reports/signups-chart.tsx +64 -0
- package/templates/next/src/components/role-badge.tsx +11 -0
- package/templates/next/src/components/settings/password-form.tsx +80 -0
- package/templates/next/src/components/settings/profile-form.tsx +63 -0
- package/templates/next/src/components/settings/sessions-card.tsx +70 -0
- package/templates/next/src/components/theme-toggle.tsx +61 -0
- package/templates/next/src/config/rbac.test.ts +89 -0
- package/templates/next/src/config/rbac.ts +170 -0
- package/templates/next/src/config/site.ts +4 -0
- package/templates/next/src/lib/api.ts +179 -0
- package/templates/next/src/lib/audit.ts +66 -0
- package/templates/next/src/lib/auth.ts +50 -0
- package/templates/next/src/lib/dal.ts +63 -0
- package/templates/next/src/lib/db.ts +35 -0
- package/templates/next/src/lib/email-templates.ts +55 -0
- package/templates/next/src/lib/email.ts +53 -0
- package/templates/next/src/lib/env.ts +90 -0
- package/templates/next/src/lib/http.ts +57 -0
- package/templates/next/src/lib/password-strength.test.ts +20 -0
- package/templates/next/src/lib/password-strength.ts +24 -0
- package/templates/next/src/lib/rate-limit.test.ts +47 -0
- package/templates/next/src/lib/rate-limit.ts +70 -0
- package/templates/next/src/lib/redirect.test.ts +23 -0
- package/templates/next/src/lib/redirect.ts +21 -0
- package/templates/next/src/lib/session.ts +71 -0
- package/templates/next/src/lib/theme.ts +32 -0
- package/templates/next/src/lib/tokens.ts +63 -0
- package/templates/next/src/lib/users.ts +196 -0
- package/templates/next/src/lib/validations/account.ts +20 -0
- package/templates/next/src/lib/validations/auth.test.ts +39 -0
- package/templates/next/src/lib/validations/auth.ts +66 -0
- package/templates/next/src/lib/validations/user.ts +13 -0
- package/templates/next/src/models/audit-log.ts +33 -0
- package/templates/next/src/models/auth-token.ts +26 -0
- package/templates/next/src/models/user.ts +35 -0
- package/templates/next/src/proxy.ts +57 -0
- package/templates/next/src/styles/app.css +1092 -0
- package/templates/next/src/types/user.ts +13 -0
- package/templates/next/tsconfig.json +34 -0
- package/templates/next/vitest.config.mts +13 -0
- package/templates/styles/css.css +580 -0
- package/templates/styles/shadcn.css +142 -0
- package/templates/styles/tailwind.css +140 -0
- package/templates/ui/css/components/alert-dialog.tsx +172 -0
- package/templates/ui/css/components/avatar.tsx +17 -0
- package/templates/ui/css/components/badge.tsx +18 -0
- package/templates/ui/css/components/button.tsx +41 -0
- package/templates/ui/css/components/card.tsx +33 -0
- package/templates/ui/css/components/dropdown-menu.tsx +230 -0
- package/templates/ui/css/components/input.tsx +7 -0
- package/templates/ui/css/components/label.tsx +7 -0
- package/templates/ui/css/components/native-select.tsx +23 -0
- package/templates/ui/css/components/skeleton.tsx +7 -0
- package/templates/ui/css/components/slot.tsx +30 -0
- package/templates/ui/css/components/table.tsx +31 -0
- package/templates/ui/css/utils.ts +16 -0
- package/templates/ui/shadcn/components/alert-dialog.tsx +199 -0
- package/templates/ui/shadcn/components/avatar.tsx +111 -0
- package/templates/ui/shadcn/components/badge.tsx +44 -0
- package/templates/ui/shadcn/components/button.tsx +66 -0
- package/templates/ui/shadcn/components/card.tsx +87 -0
- package/templates/ui/shadcn/components/dropdown-menu.tsx +268 -0
- package/templates/ui/shadcn/components/input.tsx +18 -0
- package/templates/ui/shadcn/components/label.tsx +20 -0
- package/templates/ui/shadcn/components/native-select.tsx +54 -0
- package/templates/ui/shadcn/components/skeleton.tsx +13 -0
- package/templates/ui/shadcn/components/table.tsx +115 -0
- package/templates/ui/shadcn/utils.ts +1 -0
- package/templates/ui/tailwind/components/alert-dialog.tsx +177 -0
- package/templates/ui/tailwind/components/avatar.tsx +36 -0
- package/templates/ui/tailwind/components/badge.tsx +29 -0
- package/templates/ui/tailwind/components/button.tsx +65 -0
- package/templates/ui/tailwind/components/card.tsx +70 -0
- package/templates/ui/tailwind/components/dropdown-menu.tsx +236 -0
- package/templates/ui/tailwind/components/input.tsx +17 -0
- package/templates/ui/tailwind/components/label.tsx +16 -0
- package/templates/ui/tailwind/components/native-select.tsx +32 -0
- package/templates/ui/tailwind/components/skeleton.tsx +13 -0
- package/templates/ui/tailwind/components/slot.tsx +34 -0
- package/templates/ui/tailwind/components/table.tsx +56 -0
- package/templates/ui/tailwind/utils.ts +1 -0
- package/templates/vite/Dockerfile +29 -0
- package/templates/vite/README.md +142 -0
- package/templates/vite/_dockerignore +14 -0
- package/templates/vite/_env.example +8 -0
- package/templates/vite/_gitignore +37 -0
- package/templates/vite/e2e/app.spec.ts +41 -0
- package/templates/vite/index.html +32 -0
- package/templates/vite/nginx.conf +26 -0
- package/templates/vite/package.json +61 -0
- package/templates/vite/playwright.config.ts +27 -0
- package/templates/vite/public/favicon.svg +1 -0
- package/templates/vite/src/App.test.tsx +28 -0
- package/templates/vite/src/App.tsx +26 -0
- package/templates/vite/src/components/home.tsx +121 -0
- package/templates/vite/src/components/layout/root-layout.tsx +18 -0
- package/templates/vite/src/components/layout/site-footer.tsx +10 -0
- package/templates/vite/src/components/layout/site-header.tsx +49 -0
- package/templates/vite/src/components/theme-toggle.tsx +90 -0
- package/templates/vite/src/env.ts +36 -0
- package/templates/vite/src/lib/theme.ts +26 -0
- package/templates/vite/src/main.tsx +13 -0
- package/templates/vite/src/pages/about.tsx +52 -0
- package/templates/vite/src/pages/not-found.tsx +33 -0
- package/templates/vite/src/router.ts +24 -0
- package/templates/vite/src/styles/app.css +281 -0
- package/templates/vite/src/test/setup.ts +21 -0
- package/templates/vite/tsconfig.app.json +31 -0
- package/templates/vite/tsconfig.json +7 -0
- package/templates/vite/tsconfig.node.json +23 -0
- package/templates/vite/vite.config.ts +30 -0
package/lib/scaffold.js
ADDED
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
import * as prettier from "prettier";
|
|
7
|
+
import { transform } from "sucrase";
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
FILE_RULES,
|
|
11
|
+
KNOWN_KEYS,
|
|
12
|
+
PACKAGE_KEY_RULES,
|
|
13
|
+
PACKAGE_RULES,
|
|
14
|
+
SCRIPT_RULES,
|
|
15
|
+
} from "./features.js";
|
|
16
|
+
|
|
17
|
+
const TEMPLATES = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "templates");
|
|
18
|
+
|
|
19
|
+
/** Formatting used for generated code (and written to .prettierrc). */
|
|
20
|
+
export const PRETTIER_OPTIONS = {
|
|
21
|
+
semi: true,
|
|
22
|
+
singleQuote: false,
|
|
23
|
+
trailingComma: "all",
|
|
24
|
+
printWidth: 100,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const TEXT_EXTENSIONS = new Set([
|
|
28
|
+
".ts", ".tsx", ".mts", ".js", ".jsx", ".mjs", ".cjs", ".css", ".md", ".yml", ".yaml",
|
|
29
|
+
".json", ".html", ".conf", ".example", ".txt",
|
|
30
|
+
]);
|
|
31
|
+
const TEXT_NAMES = new Set([
|
|
32
|
+
".gitignore", ".dockerignore", ".prettierignore", ".editorconfig", ".gitattributes", ".nvmrc",
|
|
33
|
+
"Dockerfile", "pre-commit", "commit-msg",
|
|
34
|
+
]);
|
|
35
|
+
const FORMAT_EXTENSIONS = new Set([
|
|
36
|
+
".ts", ".tsx", ".mts", ".js", ".jsx", ".mjs", ".cjs", ".css", ".json", ".yml", ".yaml",
|
|
37
|
+
]);
|
|
38
|
+
const SKIP_DIRS = new Set(["node_modules", ".git", ".next", "dist"]);
|
|
39
|
+
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Conditions
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
/** Evaluates "key", "!key", "a|b" or an array (AND) against the enabled keys. */
|
|
45
|
+
export function evaluate(condition, keys) {
|
|
46
|
+
if (Array.isArray(condition)) return condition.every((c) => evaluate(c, keys));
|
|
47
|
+
if (condition.includes("|")) return condition.split("|").some((c) => evaluate(c, keys));
|
|
48
|
+
if (condition.startsWith("!")) return !keys.has(condition.slice(1));
|
|
49
|
+
return keys.has(condition);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function assertKnown(condition, where) {
|
|
53
|
+
const parts = condition.split("|").map((p) => p.replace(/^!/, ""));
|
|
54
|
+
for (const part of parts) {
|
|
55
|
+
if (!KNOWN_KEYS.has(part)) throw new Error(`Unknown feature key "${part}" in ${where}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// Markers: // @feature key ... // @end key (also #, {/* */}, /* */, <!-- -->)
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
const MARKER =
|
|
64
|
+
/^\s*(?:\/\/|#|\{\s*\/\*|\/\*|<!--)\s*@(feature|end)\s+(!?[a-z0-9-]+(?:\|!?[a-z0-9-]+)*)\s*(?:\*\/\s*\}|\*\/|-->)?\s*$/;
|
|
65
|
+
|
|
66
|
+
export function applyMarkers(text, keys, file = "file") {
|
|
67
|
+
if (!text.includes("@feature")) return text;
|
|
68
|
+
const lines = text.split(/\r?\n/);
|
|
69
|
+
const out = [];
|
|
70
|
+
const stack = [];
|
|
71
|
+
lines.forEach((line, i) => {
|
|
72
|
+
const m = MARKER.exec(line);
|
|
73
|
+
if (m) {
|
|
74
|
+
const [, kind, condition] = m;
|
|
75
|
+
if (kind === "feature") {
|
|
76
|
+
assertKnown(condition, `${file}:${i + 1}`);
|
|
77
|
+
stack.push({ condition, active: evaluate(condition, keys) });
|
|
78
|
+
} else {
|
|
79
|
+
const top = stack.pop();
|
|
80
|
+
if (!top || top.condition !== condition) {
|
|
81
|
+
throw new Error(`Mismatched "@end ${condition}" in ${file}:${i + 1}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (stack.every((s) => s.active)) out.push(line);
|
|
87
|
+
});
|
|
88
|
+
if (stack.length) throw new Error(`Unclosed "@feature ${stack.at(-1).condition}" in ${file}`);
|
|
89
|
+
// Removing blocks can leave runs of blank lines behind.
|
|
90
|
+
return out.join("\n").replace(/\n{3,}/g, "\n\n");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
// File helpers
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
|
|
97
|
+
function walk(dir, files = []) {
|
|
98
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
99
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
100
|
+
const full = path.join(dir, entry.name);
|
|
101
|
+
if (entry.isDirectory()) walk(full, files);
|
|
102
|
+
else files.push(full);
|
|
103
|
+
}
|
|
104
|
+
return files;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function isTextFile(file) {
|
|
108
|
+
const base = path.basename(file);
|
|
109
|
+
return TEXT_NAMES.has(base) || TEXT_EXTENSIONS.has(path.extname(base));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function copyInto(src, dest) {
|
|
113
|
+
if (!fs.existsSync(src)) return;
|
|
114
|
+
fs.cpSync(src, dest, { recursive: true, force: true });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function readJson(file) {
|
|
118
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function writeJson(file, data) {
|
|
122
|
+
fs.writeFileSync(file, JSON.stringify(data, null, 2) + "\n");
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** npm strips/renames dotfiles on publish, so templates store them as `_name`. */
|
|
126
|
+
function restoreDotfiles(dir) {
|
|
127
|
+
for (const entry of fs.readdirSync(dir)) {
|
|
128
|
+
if (entry.startsWith("_")) {
|
|
129
|
+
fs.renameSync(path.join(dir, entry), path.join(dir, `.${entry.slice(1)}`));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ---------------------------------------------------------------------------
|
|
135
|
+
// Steps
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
|
|
138
|
+
function copyTemplates(target, ctx) {
|
|
139
|
+
fs.mkdirSync(target, { recursive: true });
|
|
140
|
+
copyInto(path.join(TEMPLATES, ctx.framework), target);
|
|
141
|
+
copyInto(path.join(TEMPLATES, "common"), target);
|
|
142
|
+
|
|
143
|
+
const uiDir = path.join(TEMPLATES, "ui", ctx.style);
|
|
144
|
+
fs.mkdirSync(path.join(target, "src", "lib"), { recursive: true });
|
|
145
|
+
fs.copyFileSync(path.join(uiDir, "utils.ts"), path.join(target, "src", "lib", "utils.ts"));
|
|
146
|
+
if (ctx.keys.has("ui")) {
|
|
147
|
+
copyInto(path.join(uiDir, "components"), path.join(target, "src", "components", "ui"));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const cssTarget =
|
|
151
|
+
ctx.framework === "next"
|
|
152
|
+
? path.join(target, "src", "app", "globals.css")
|
|
153
|
+
: path.join(target, "src", "index.css");
|
|
154
|
+
fs.copyFileSync(path.join(TEMPLATES, "styles", `${ctx.style}.css`), cssTarget);
|
|
155
|
+
|
|
156
|
+
restoreDotfiles(target);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function applyFileRules(target, keys) {
|
|
160
|
+
for (const rule of FILE_RULES) {
|
|
161
|
+
if (!evaluate(rule.when, keys)) {
|
|
162
|
+
fs.rmSync(path.join(target, rule.path), { recursive: true, force: true });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function processTextFiles(target, ctx) {
|
|
168
|
+
for (const file of walk(target)) {
|
|
169
|
+
if (!isTextFile(file)) continue;
|
|
170
|
+
const original = fs.readFileSync(file, "utf8");
|
|
171
|
+
let text = applyMarkers(original, ctx.keys, path.relative(target, file));
|
|
172
|
+
text = text
|
|
173
|
+
.replaceAll("{{PROJECT_TITLE}}", ctx.projectTitle)
|
|
174
|
+
.replaceAll("{{PACKAGE_NAME}}", ctx.packageName);
|
|
175
|
+
// React Server Component directives mean nothing in a Vite SPA.
|
|
176
|
+
if (ctx.framework === "vite") text = text.replace(/^(["'])use client\1;?\r?\n(\r?\n)?/, "");
|
|
177
|
+
if (text !== original) fs.writeFileSync(file, text);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function buildLintStaged(keys) {
|
|
182
|
+
const code = [];
|
|
183
|
+
if (keys.has("eslint")) code.push("eslint --fix");
|
|
184
|
+
if (keys.has("oxlint")) code.push("oxlint --fix");
|
|
185
|
+
if (keys.has("prettier")) code.push("prettier --write");
|
|
186
|
+
const config = {};
|
|
187
|
+
if (code.length) config["*.{ts,tsx,js,jsx,mjs,cjs}"] = code;
|
|
188
|
+
if (keys.has("prettier")) config["*.{json,css,md,yml,yaml}"] = ["prettier --write"];
|
|
189
|
+
return config;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function updatePackageJson(target, ctx) {
|
|
193
|
+
const file = path.join(target, "package.json");
|
|
194
|
+
const pkg = readJson(file);
|
|
195
|
+
pkg.name = ctx.packageName;
|
|
196
|
+
|
|
197
|
+
for (const field of ["dependencies", "devDependencies"]) {
|
|
198
|
+
for (const dep of Object.keys(pkg[field] ?? {})) {
|
|
199
|
+
const rule = PACKAGE_RULES[dep];
|
|
200
|
+
if (rule && !evaluate(rule, ctx.keys)) delete pkg[field][dep];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
for (const script of Object.keys(pkg.scripts ?? {})) {
|
|
204
|
+
const rule = SCRIPT_RULES[script];
|
|
205
|
+
if (rule && !evaluate(rule, ctx.keys)) delete pkg.scripts[script];
|
|
206
|
+
}
|
|
207
|
+
for (const key of Object.keys(PACKAGE_KEY_RULES)) {
|
|
208
|
+
if (!evaluate(PACKAGE_KEY_RULES[key], ctx.keys)) delete pkg[key];
|
|
209
|
+
}
|
|
210
|
+
if (ctx.keys.has("git-hooks")) pkg["lint-staged"] = buildLintStaged(ctx.keys);
|
|
211
|
+
|
|
212
|
+
// npm 11+ asks you to review dependency install scripts; pre-approve the ones we ship.
|
|
213
|
+
const devDeps = pkg.devDependencies ?? {};
|
|
214
|
+
const allowScripts = {};
|
|
215
|
+
if (devDeps.vitest || devDeps.tsx) allowScripts.esbuild = true;
|
|
216
|
+
if (devDeps["mongodb-memory-server"]) allowScripts["mongodb-memory-server"] = true;
|
|
217
|
+
if (Object.keys(allowScripts).length) pkg.allowScripts = allowScripts;
|
|
218
|
+
|
|
219
|
+
if (ctx.lang === "js") {
|
|
220
|
+
for (const [name, cmd] of Object.entries(pkg.scripts ?? {})) {
|
|
221
|
+
pkg.scripts[name] = cmd
|
|
222
|
+
.replace("tsc -b && ", "")
|
|
223
|
+
.replace("tsx scripts/seed.ts", "node scripts/seed.mjs");
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
writeJson(file, pkg);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function writeGeneratedConfigs(target, ctx) {
|
|
230
|
+
const tailwind = ctx.keys.has("tailwind");
|
|
231
|
+
const globalsCss = ctx.framework === "next" ? "src/app/globals.css" : "src/index.css";
|
|
232
|
+
|
|
233
|
+
if (ctx.keys.has("prettier")) {
|
|
234
|
+
const config = { ...PRETTIER_OPTIONS };
|
|
235
|
+
if (tailwind) {
|
|
236
|
+
config.plugins = ["prettier-plugin-tailwindcss"];
|
|
237
|
+
config.tailwindStylesheet = `./${globalsCss}`;
|
|
238
|
+
config.tailwindFunctions = ["cn", "cva"];
|
|
239
|
+
}
|
|
240
|
+
writeJson(path.join(target, ".prettierrc"), config);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (ctx.keys.has("shadcn")) {
|
|
244
|
+
writeJson(path.join(target, "components.json"), {
|
|
245
|
+
$schema: "https://ui.shadcn.com/schema.json",
|
|
246
|
+
style: "radix-nova",
|
|
247
|
+
rsc: ctx.framework === "next",
|
|
248
|
+
tsx: ctx.lang === "ts",
|
|
249
|
+
tailwind: {
|
|
250
|
+
config: "",
|
|
251
|
+
css: globalsCss,
|
|
252
|
+
baseColor: "neutral",
|
|
253
|
+
cssVariables: true,
|
|
254
|
+
prefix: "",
|
|
255
|
+
},
|
|
256
|
+
iconLibrary: "lucide",
|
|
257
|
+
rtl: false,
|
|
258
|
+
aliases: {
|
|
259
|
+
components: "@/components",
|
|
260
|
+
utils: "@/lib/utils",
|
|
261
|
+
ui: "@/components/ui",
|
|
262
|
+
lib: "@/lib",
|
|
263
|
+
hooks: "@/hooks",
|
|
264
|
+
},
|
|
265
|
+
menuColor: "default",
|
|
266
|
+
menuAccent: "subtle",
|
|
267
|
+
registries: {},
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (ctx.keys.has("oxlint")) {
|
|
272
|
+
writeJson(path.join(target, ".oxlintrc.json"), {
|
|
273
|
+
$schema: "./node_modules/oxlint/configuration_schema.json",
|
|
274
|
+
plugins: ["react", ...(ctx.lang === "ts" ? ["typescript"] : []), "oxc"],
|
|
275
|
+
rules: {
|
|
276
|
+
"react/rules-of-hooks": "error",
|
|
277
|
+
"react/only-export-components": ["warn", { allowConstantExport: true }],
|
|
278
|
+
},
|
|
279
|
+
ignorePatterns: ["dist", "playwright-report", "test-results"],
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (ctx.keys.has("editor")) {
|
|
284
|
+
const recommendations = [
|
|
285
|
+
ctx.keys.has("eslint") && "dbaeumer.vscode-eslint",
|
|
286
|
+
ctx.keys.has("oxlint") && "oxc.oxc-vscode",
|
|
287
|
+
ctx.keys.has("prettier") && "esbenp.prettier-vscode",
|
|
288
|
+
tailwind && "bradlc.vscode-tailwindcss",
|
|
289
|
+
ctx.keys.has("playwright") && "ms-playwright.playwright",
|
|
290
|
+
ctx.keys.has("vitest") && "vitest.explorer",
|
|
291
|
+
ctx.framework === "next" && "mongodb.mongodb-vscode",
|
|
292
|
+
"editorconfig.editorconfig",
|
|
293
|
+
].filter(Boolean);
|
|
294
|
+
const settings = {
|
|
295
|
+
...(ctx.keys.has("prettier") && {
|
|
296
|
+
"editor.formatOnSave": true,
|
|
297
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
298
|
+
}),
|
|
299
|
+
...(ctx.keys.has("eslint") && {
|
|
300
|
+
"editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" },
|
|
301
|
+
}),
|
|
302
|
+
...(ctx.keys.has("oxlint") && {
|
|
303
|
+
"editor.codeActionsOnSave": { "source.fixAll.oxc": "explicit" },
|
|
304
|
+
}),
|
|
305
|
+
...(ctx.lang === "ts" && {
|
|
306
|
+
"typescript.tsdk": "node_modules/typescript/lib",
|
|
307
|
+
"typescript.enablePromptUseWorkspaceTsdk": true,
|
|
308
|
+
}),
|
|
309
|
+
...(tailwind && {
|
|
310
|
+
"tailwindCSS.classFunctions": ["cn", "cva"],
|
|
311
|
+
"files.associations": { "*.css": "tailwindcss" },
|
|
312
|
+
}),
|
|
313
|
+
"search.exclude": { "**/.next": true, "**/dist": true, "**/node_modules": true },
|
|
314
|
+
};
|
|
315
|
+
fs.mkdirSync(path.join(target, ".vscode"), { recursive: true });
|
|
316
|
+
writeJson(path.join(target, ".vscode", "extensions.json"), { recommendations });
|
|
317
|
+
writeJson(path.join(target, ".vscode", "settings.json"), settings);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (ctx.lang === "js") {
|
|
321
|
+
writeJson(path.join(target, "jsconfig.json"), {
|
|
322
|
+
compilerOptions: { baseUrl: ".", paths: { "@/*": ["./src/*"] } },
|
|
323
|
+
include: ["src"],
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** True when nothing but whitespace, comments and directives remain (type-only modules). */
|
|
329
|
+
function isEffectivelyEmpty(code) {
|
|
330
|
+
const stripped = code
|
|
331
|
+
.replace(/\/\*[\s\S]*?\*\//g, "")
|
|
332
|
+
.replace(/^\s*\/\/.*$/gm, "")
|
|
333
|
+
.replace(/^\s*(["'])use (client|server)\1;?\s*$/gm, "")
|
|
334
|
+
.replace(/^\s*import\s+(["'])[^"']+\1;?\s*$/gm, "") // bare side-effect imports like "server-only"
|
|
335
|
+
.trim();
|
|
336
|
+
return stripped.length === 0;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function jsTargetPath(file, target, ctx) {
|
|
340
|
+
const rel = path.relative(target, file).replaceAll("\\", "/");
|
|
341
|
+
const ext = path.extname(file);
|
|
342
|
+
const base = file.slice(0, -ext.length);
|
|
343
|
+
if (ext === ".tsx") return `${base}.jsx`;
|
|
344
|
+
if (ext === ".mts") return `${base}.mjs`;
|
|
345
|
+
// Next.js projects aren't "type": "module", so standalone ESM files need .mjs.
|
|
346
|
+
const standalone =
|
|
347
|
+
rel === "next.config.ts" ||
|
|
348
|
+
rel === "playwright.config.ts" ||
|
|
349
|
+
rel.startsWith("scripts/") ||
|
|
350
|
+
rel.startsWith("e2e/");
|
|
351
|
+
if (ctx.framework === "next" && standalone) return `${base}.mjs`;
|
|
352
|
+
return `${base}.js`;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function convertToJavaScript(target, ctx) {
|
|
356
|
+
for (const file of walk(target)) {
|
|
357
|
+
const ext = path.extname(file);
|
|
358
|
+
if (file.endsWith(".d.ts")) {
|
|
359
|
+
fs.rmSync(file);
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
if (![".ts", ".tsx", ".mts"].includes(ext)) continue;
|
|
363
|
+
const source = fs.readFileSync(file, "utf8");
|
|
364
|
+
const { code } = transform(source, {
|
|
365
|
+
transforms: ext === ".tsx" ? ["typescript", "jsx"] : ["typescript"],
|
|
366
|
+
jsxRuntime: "preserve",
|
|
367
|
+
disableESTransforms: true,
|
|
368
|
+
filePath: file,
|
|
369
|
+
});
|
|
370
|
+
fs.rmSync(file);
|
|
371
|
+
if (!isEffectivelyEmpty(code)) fs.writeFileSync(jsTargetPath(file, target, ctx), code);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const html = path.join(target, "index.html");
|
|
375
|
+
if (fs.existsSync(html)) {
|
|
376
|
+
fs.writeFileSync(html, fs.readFileSync(html, "utf8").replace("/src/main.tsx", "/src/main.jsx"));
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function commandsFor(pm) {
|
|
381
|
+
return {
|
|
382
|
+
install: { npm: "npm ci", pnpm: "pnpm install --frozen-lockfile", yarn: "yarn install --immutable", bun: "bun install --frozen-lockfile" }[pm],
|
|
383
|
+
run: { npm: "npm run ", pnpm: "pnpm ", yarn: "yarn ", bun: "bun run " }[pm],
|
|
384
|
+
exec: { npm: "npx ", pnpm: "pnpm exec ", yarn: "yarn ", bun: "bunx " }[pm],
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const PM_SETUP = {
|
|
389
|
+
npm: "",
|
|
390
|
+
pnpm: " - uses: pnpm/action-setup@v6\n",
|
|
391
|
+
yarn: " - run: corepack enable\n",
|
|
392
|
+
bun: " - uses: oven-sh/setup-bun@v2\n",
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
/** Rewrites npm commands in docs/CI for the package manager the user scaffolded with. */
|
|
396
|
+
function adaptToPackageManager(target, pm) {
|
|
397
|
+
const cmd = commandsFor(pm);
|
|
398
|
+
const readme = path.join(target, "README.md");
|
|
399
|
+
if (fs.existsSync(readme) && pm !== "npm") {
|
|
400
|
+
const text = fs.readFileSync(readme, "utf8")
|
|
401
|
+
.replaceAll("npm run ", cmd.run)
|
|
402
|
+
.replaceAll("npm install", `${pm} install`)
|
|
403
|
+
.replaceAll("npm test", `${pm} test`);
|
|
404
|
+
fs.writeFileSync(readme, text);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
const ci = path.join(target, ".github", "workflows", "ci.yml");
|
|
408
|
+
if (fs.existsSync(ci)) {
|
|
409
|
+
let text = fs.readFileSync(ci, "utf8").replace(/^\s*# \{\{PM_SETUP\}\}\r?\n/gm, PM_SETUP[pm]);
|
|
410
|
+
if (pm !== "npm") {
|
|
411
|
+
text = text
|
|
412
|
+
.replaceAll("npm ci", cmd.install)
|
|
413
|
+
.replaceAll("npm run ", cmd.run)
|
|
414
|
+
.replaceAll("npm test", `${pm} test`)
|
|
415
|
+
.replaceAll("npx ", cmd.exec)
|
|
416
|
+
.replace(/cache: npm/g, pm === "bun" ? "" : `cache: ${pm}`);
|
|
417
|
+
}
|
|
418
|
+
fs.writeFileSync(ci, text);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
async function formatProject(target) {
|
|
423
|
+
const failures = [];
|
|
424
|
+
for (const file of walk(target)) {
|
|
425
|
+
const base = path.basename(file);
|
|
426
|
+
const isRc = base === ".prettierrc";
|
|
427
|
+
if ((!FORMAT_EXTENSIONS.has(path.extname(base)) && !isRc) || base === "package-lock.json") continue;
|
|
428
|
+
const source = fs.readFileSync(file, "utf8");
|
|
429
|
+
try {
|
|
430
|
+
const formatted = await prettier.format(source, {
|
|
431
|
+
...PRETTIER_OPTIONS,
|
|
432
|
+
filepath: file,
|
|
433
|
+
...(isRc && { parser: "json" }),
|
|
434
|
+
});
|
|
435
|
+
if (formatted !== source) fs.writeFileSync(file, formatted);
|
|
436
|
+
} catch (error) {
|
|
437
|
+
failures.push(`${path.relative(target, file)}: ${error.message.split("\n")[0]}`);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return failures;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
function createEnvLocal(target, ctx) {
|
|
444
|
+
const example = path.join(target, ".env.example");
|
|
445
|
+
const local = path.join(target, ".env.local");
|
|
446
|
+
if (!fs.existsSync(example) || fs.existsSync(local)) return;
|
|
447
|
+
const dbName = ctx.packageName.replace(/^@[^/]+\//, "").replace(/[^a-z0-9_-]/g, "_") || "app";
|
|
448
|
+
const content = fs
|
|
449
|
+
.readFileSync(example, "utf8")
|
|
450
|
+
.replace(/^JWT_SECRET=.*$/m, `JWT_SECRET=${crypto.randomBytes(48).toString("base64url")}`)
|
|
451
|
+
.replace(/^(MONGODB_URI=mongodb:\/\/[^/\s]+)\/[^\s?]*/m, `$1/${dbName}`);
|
|
452
|
+
fs.writeFileSync(local, content);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Generates the project in `target`.
|
|
457
|
+
* ctx: { framework, lang, style, keys: Set<string>, packageName, projectTitle, pm }
|
|
458
|
+
* Returns a list of non-fatal warnings.
|
|
459
|
+
*/
|
|
460
|
+
export async function scaffold(target, ctx) {
|
|
461
|
+
copyTemplates(target, ctx);
|
|
462
|
+
applyFileRules(target, ctx.keys);
|
|
463
|
+
processTextFiles(target, ctx);
|
|
464
|
+
updatePackageJson(target, ctx);
|
|
465
|
+
writeGeneratedConfigs(target, ctx);
|
|
466
|
+
if (ctx.lang === "js") convertToJavaScript(target, ctx);
|
|
467
|
+
adaptToPackageManager(target, ctx.pm);
|
|
468
|
+
const failures = await formatProject(target);
|
|
469
|
+
createEnvLocal(target, ctx);
|
|
470
|
+
return failures.map((f) => `Could not format ${f}`);
|
|
471
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-mohit-next",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Scaffold a production-ready React app: Next.js full-stack (MongoDB, auth, RBAC) or Vite SPA, in TypeScript or JavaScript, with Tailwind + shadcn/ui, Tailwind only, or plain CSS.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-mohit-next": "index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"index.js",
|
|
11
|
+
"lib",
|
|
12
|
+
"templates"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"start": "node index.js"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"create",
|
|
19
|
+
"next",
|
|
20
|
+
"nextjs",
|
|
21
|
+
"vite",
|
|
22
|
+
"react",
|
|
23
|
+
"starter",
|
|
24
|
+
"template",
|
|
25
|
+
"boilerplate",
|
|
26
|
+
"mongodb",
|
|
27
|
+
"rbac",
|
|
28
|
+
"auth",
|
|
29
|
+
"shadcn",
|
|
30
|
+
"tailwind"
|
|
31
|
+
],
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=22.12.0"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@clack/prompts": "^1.9.0",
|
|
38
|
+
"picocolors": "^1.1.1",
|
|
39
|
+
"prettier": "^3.10.1",
|
|
40
|
+
"sucrase": "^3.35.1"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: npm
|
|
4
|
+
directory: /
|
|
5
|
+
schedule:
|
|
6
|
+
interval: weekly
|
|
7
|
+
groups:
|
|
8
|
+
minor-and-patch:
|
|
9
|
+
update-types: [minor, patch]
|
|
10
|
+
open-pull-requests-limit: 10
|
|
11
|
+
- package-ecosystem: github-actions
|
|
12
|
+
directory: /
|
|
13
|
+
schedule:
|
|
14
|
+
interval: weekly
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: ci-${{ github.ref }}
|
|
10
|
+
cancel-in-progress: true
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
check:
|
|
14
|
+
name: Lint, typecheck, test & build
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v7
|
|
18
|
+
# {{PM_SETUP}}
|
|
19
|
+
- uses: actions/setup-node@v7
|
|
20
|
+
with:
|
|
21
|
+
node-version-file: .nvmrc
|
|
22
|
+
cache: npm
|
|
23
|
+
- run: npm ci
|
|
24
|
+
# @feature eslint|oxlint
|
|
25
|
+
- run: npm run lint
|
|
26
|
+
# @end eslint|oxlint
|
|
27
|
+
# @feature ts
|
|
28
|
+
- run: npm run typecheck
|
|
29
|
+
# @end ts
|
|
30
|
+
# @feature prettier
|
|
31
|
+
- run: npm run format:check
|
|
32
|
+
# @end prettier
|
|
33
|
+
# @feature vitest
|
|
34
|
+
- run: npm test
|
|
35
|
+
# @end vitest
|
|
36
|
+
- run: npm run build
|
|
37
|
+
# @feature playwright
|
|
38
|
+
|
|
39
|
+
e2e:
|
|
40
|
+
name: End-to-end tests
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@v7
|
|
44
|
+
# {{PM_SETUP}}
|
|
45
|
+
- uses: actions/setup-node@v7
|
|
46
|
+
with:
|
|
47
|
+
node-version-file: .nvmrc
|
|
48
|
+
cache: npm
|
|
49
|
+
- run: npm ci
|
|
50
|
+
- run: npx playwright install --with-deps chromium
|
|
51
|
+
- run: npm run build
|
|
52
|
+
# @feature next
|
|
53
|
+
- run: npm run test:e2e
|
|
54
|
+
env:
|
|
55
|
+
E2E_PROD: "1"
|
|
56
|
+
# @end next
|
|
57
|
+
# @feature vite
|
|
58
|
+
- run: npm run test:e2e
|
|
59
|
+
# @end vite
|
|
60
|
+
- uses: actions/upload-artifact@v7
|
|
61
|
+
if: failure()
|
|
62
|
+
with:
|
|
63
|
+
name: playwright-report
|
|
64
|
+
path: playwright-report
|
|
65
|
+
retention-days: 7
|
|
66
|
+
# @end playwright
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx --no -- commitlint --edit "$1"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx lint-staged
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
24
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.next
|
|
2
|
+
out
|
|
3
|
+
build
|
|
4
|
+
dist
|
|
5
|
+
coverage
|
|
6
|
+
node_modules
|
|
7
|
+
package-lock.json
|
|
8
|
+
pnpm-lock.yaml
|
|
9
|
+
yarn.lock
|
|
10
|
+
bun.lock
|
|
11
|
+
next-env.d.ts
|
|
12
|
+
playwright-report
|
|
13
|
+
test-results
|
|
14
|
+
# Rewritten by create-mohit-next for your package manager; format manually if you like.
|
|
15
|
+
README.md
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commit messages follow Conventional Commits: "feat: add billing page",
|
|
3
|
+
* "fix(auth): handle expired tokens", "chore: bump deps", ...
|
|
4
|
+
* https://www.conventionalcommits.org
|
|
5
|
+
*/
|
|
6
|
+
const config = {
|
|
7
|
+
extends: ["@commitlint/config-conventional"],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default config;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<!-- BEGIN:nextjs-agent-rules -->
|
|
2
|
+
|
|
3
|
+
## This is NOT the Next.js you know
|
|
4
|
+
|
|
5
|
+
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices.
|
|
6
|
+
|
|
7
|
+
This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean.
|
|
8
|
+
|
|
9
|
+
<!-- END:nextjs-agent-rules -->
|