@djangocfg/nextjs 2.1.6 → 2.1.8
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 +3 -3
- package/dist/ai/cli.d.mts +1 -0
- package/dist/ai/cli.mjs +173 -0
- package/dist/ai/cli.mjs.map +1 -0
- package/dist/ai/index.d.mts +81 -0
- package/dist/ai/index.mjs +139 -0
- package/dist/ai/index.mjs.map +1 -0
- package/dist/config/index.d.mts +360 -0
- package/dist/config/index.mjs +1363 -0
- package/dist/config/index.mjs.map +1 -0
- package/dist/constants-HezbftFb.d.mts +10 -0
- package/dist/contact/index.d.mts +47 -0
- package/dist/contact/index.mjs +98 -0
- package/dist/contact/index.mjs.map +1 -0
- package/dist/contact/route.d.mts +35 -0
- package/dist/contact/route.mjs +99 -0
- package/dist/contact/route.mjs.map +1 -0
- package/dist/health/index.d.mts +43 -0
- package/dist/health/index.mjs +38 -0
- package/dist/health/index.mjs.map +1 -0
- package/dist/index.d.mts +19 -0
- package/dist/index.mjs +2565 -0
- package/dist/index.mjs.map +1 -0
- package/dist/navigation/index.d.mts +89 -0
- package/dist/navigation/index.mjs +63 -0
- package/dist/navigation/index.mjs.map +1 -0
- package/dist/og-image/components/index.d.mts +59 -0
- package/dist/og-image/components/index.mjs +325 -0
- package/dist/og-image/components/index.mjs.map +1 -0
- package/dist/og-image/index.d.mts +112 -0
- package/dist/og-image/index.mjs +823 -0
- package/dist/og-image/index.mjs.map +1 -0
- package/dist/og-image/utils/index.d.mts +302 -0
- package/dist/og-image/utils/index.mjs +317 -0
- package/dist/og-image/utils/index.mjs.map +1 -0
- package/dist/sitemap/index.d.mts +66 -0
- package/dist/sitemap/index.mjs +76 -0
- package/dist/sitemap/index.mjs.map +1 -0
- package/dist/types-CwhXnEbK.d.mts +30 -0
- package/package.json +7 -6
- package/src/ai/cli.ts +29 -29
|
@@ -0,0 +1,1363 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// package.json
|
|
13
|
+
var require_package = __commonJS({
|
|
14
|
+
"package.json"(exports, module) {
|
|
15
|
+
module.exports = {
|
|
16
|
+
name: "@djangocfg/nextjs",
|
|
17
|
+
version: "2.1.8",
|
|
18
|
+
description: "Next.js server utilities: sitemap, health, OG images, contact forms, navigation, config",
|
|
19
|
+
keywords: [
|
|
20
|
+
"nextjs",
|
|
21
|
+
"sitemap",
|
|
22
|
+
"health",
|
|
23
|
+
"og-image",
|
|
24
|
+
"contact",
|
|
25
|
+
"navigation",
|
|
26
|
+
"config",
|
|
27
|
+
"react",
|
|
28
|
+
"typescript"
|
|
29
|
+
],
|
|
30
|
+
author: {
|
|
31
|
+
name: "DjangoCFG",
|
|
32
|
+
url: "https://djangocfg.com"
|
|
33
|
+
},
|
|
34
|
+
homepage: "https://djangocfg.com",
|
|
35
|
+
repository: {
|
|
36
|
+
type: "git",
|
|
37
|
+
url: "https://github.com/markolofsen/django-cfg.git",
|
|
38
|
+
directory: "packages/nextjs"
|
|
39
|
+
},
|
|
40
|
+
bugs: {
|
|
41
|
+
url: "https://github.com/markolofsen/django-cfg/issues"
|
|
42
|
+
},
|
|
43
|
+
license: "MIT",
|
|
44
|
+
main: "./src/index.ts",
|
|
45
|
+
types: "./src/index.ts",
|
|
46
|
+
exports: {
|
|
47
|
+
".": {
|
|
48
|
+
types: "./src/index.ts",
|
|
49
|
+
import: "./src/index.ts",
|
|
50
|
+
default: "./src/index.ts"
|
|
51
|
+
},
|
|
52
|
+
"./sitemap": {
|
|
53
|
+
types: "./src/sitemap/index.ts",
|
|
54
|
+
import: "./src/sitemap/index.ts",
|
|
55
|
+
default: "./src/sitemap/index.ts"
|
|
56
|
+
},
|
|
57
|
+
"./health": {
|
|
58
|
+
types: "./src/health/index.ts",
|
|
59
|
+
import: "./src/health/index.ts",
|
|
60
|
+
default: "./src/health/index.ts"
|
|
61
|
+
},
|
|
62
|
+
"./og-image": {
|
|
63
|
+
types: "./src/og-image/index.ts",
|
|
64
|
+
import: "./src/og-image/index.ts",
|
|
65
|
+
default: "./src/og-image/index.ts"
|
|
66
|
+
},
|
|
67
|
+
"./og-image/utils": {
|
|
68
|
+
types: "./src/og-image/utils/index.ts",
|
|
69
|
+
import: "./src/og-image/utils/index.ts",
|
|
70
|
+
default: "./src/og-image/utils/index.ts"
|
|
71
|
+
},
|
|
72
|
+
"./og-image/components": {
|
|
73
|
+
types: "./src/og-image/components/index.ts",
|
|
74
|
+
import: "./src/og-image/components/index.ts",
|
|
75
|
+
default: "./src/og-image/components/index.ts"
|
|
76
|
+
},
|
|
77
|
+
"./contact": {
|
|
78
|
+
types: "./src/contact/index.ts",
|
|
79
|
+
import: "./src/contact/index.ts",
|
|
80
|
+
default: "./src/contact/index.ts"
|
|
81
|
+
},
|
|
82
|
+
"./navigation": {
|
|
83
|
+
types: "./src/navigation/index.ts",
|
|
84
|
+
import: "./src/navigation/index.ts",
|
|
85
|
+
default: "./src/navigation/index.ts"
|
|
86
|
+
},
|
|
87
|
+
"./config": {
|
|
88
|
+
types: "./src/config/index.ts",
|
|
89
|
+
import: "./src/config/index.ts",
|
|
90
|
+
default: "./src/config/index.ts"
|
|
91
|
+
},
|
|
92
|
+
"./scripts": {
|
|
93
|
+
types: "./src/scripts/index.ts",
|
|
94
|
+
import: "./src/scripts/index.ts",
|
|
95
|
+
default: "./src/scripts/index.ts"
|
|
96
|
+
},
|
|
97
|
+
"./ai": {
|
|
98
|
+
types: "./src/ai/index.ts",
|
|
99
|
+
import: "./src/ai/index.ts",
|
|
100
|
+
default: "./src/ai/index.ts"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
files: [
|
|
104
|
+
"dist",
|
|
105
|
+
"src",
|
|
106
|
+
"README.md",
|
|
107
|
+
"LICENSE"
|
|
108
|
+
],
|
|
109
|
+
bin: {
|
|
110
|
+
"djangocfg-docs": "./dist/ai/cli.mjs"
|
|
111
|
+
},
|
|
112
|
+
scripts: {
|
|
113
|
+
build: "tsup",
|
|
114
|
+
dev: "tsup --watch",
|
|
115
|
+
clean: "rm -rf dist",
|
|
116
|
+
lint: "eslint .",
|
|
117
|
+
check: "tsc --noEmit",
|
|
118
|
+
"check-links": "tsx src/scripts/check-links.ts",
|
|
119
|
+
"ai-docs": "tsx src/ai/cli.ts"
|
|
120
|
+
},
|
|
121
|
+
peerDependencies: {
|
|
122
|
+
"@djangocfg/api": "workspace:*",
|
|
123
|
+
next: "^15.5.7"
|
|
124
|
+
},
|
|
125
|
+
devDependencies: {
|
|
126
|
+
"@djangocfg/imgai": "workspace:*",
|
|
127
|
+
"@djangocfg/layouts": "workspace:*",
|
|
128
|
+
"@djangocfg/typescript-config": "workspace:*",
|
|
129
|
+
"@types/node": "^24.7.2",
|
|
130
|
+
"@types/react": "19.2.2",
|
|
131
|
+
"@types/react-dom": "19.2.1",
|
|
132
|
+
"@types/semver": "^7.7.1",
|
|
133
|
+
"@types/webpack": "^5.28.5",
|
|
134
|
+
"@vercel/og": "^0.8.5",
|
|
135
|
+
eslint: "^9.37.0",
|
|
136
|
+
linkinator: "^7.5.0",
|
|
137
|
+
"lucide-react": "^0.545.0",
|
|
138
|
+
picocolors: "^1.1.1",
|
|
139
|
+
prompts: "^2.4.2",
|
|
140
|
+
tsup: "^8.0.1",
|
|
141
|
+
tsx: "^4.19.2",
|
|
142
|
+
typescript: "^5.9.3"
|
|
143
|
+
},
|
|
144
|
+
publishConfig: {
|
|
145
|
+
access: "public"
|
|
146
|
+
},
|
|
147
|
+
dependencies: {
|
|
148
|
+
chalk: "^5.3.0",
|
|
149
|
+
conf: "^15.0.2",
|
|
150
|
+
consola: "^3.4.2",
|
|
151
|
+
semver: "^7.7.3"
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// src/config/constants.ts
|
|
158
|
+
var PACKAGE_NAME = "@djangocfg/nextjs";
|
|
159
|
+
var VERSION_CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
160
|
+
var DJANGO_CFG_BANNER = `
|
|
161
|
+
\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
162
|
+
\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D
|
|
163
|
+
\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2588\u2557
|
|
164
|
+
\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551
|
|
165
|
+
\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D
|
|
166
|
+
\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D
|
|
167
|
+
`;
|
|
168
|
+
var DJANGOCFG_PACKAGES = [
|
|
169
|
+
"@djangocfg/ui-core",
|
|
170
|
+
"@djangocfg/ui-nextjs",
|
|
171
|
+
"@djangocfg/layouts",
|
|
172
|
+
"@djangocfg/nextjs",
|
|
173
|
+
"@djangocfg/api",
|
|
174
|
+
"@djangocfg/centrifugo",
|
|
175
|
+
"@djangocfg/eslint-config",
|
|
176
|
+
"@djangocfg/typescript-config"
|
|
177
|
+
];
|
|
178
|
+
var DEFAULT_TRANSPILE_PACKAGES = [
|
|
179
|
+
"@djangocfg/ui-core",
|
|
180
|
+
"@djangocfg/ui-nextjs",
|
|
181
|
+
"@djangocfg/layouts",
|
|
182
|
+
"@djangocfg/nextjs",
|
|
183
|
+
"@djangocfg/api",
|
|
184
|
+
"@djangocfg/centrifugo"
|
|
185
|
+
];
|
|
186
|
+
var DEFAULT_OPTIMIZE_PACKAGES = [
|
|
187
|
+
"@djangocfg/ui-core",
|
|
188
|
+
"@djangocfg/ui-nextjs",
|
|
189
|
+
"@djangocfg/layouts",
|
|
190
|
+
"lucide-react",
|
|
191
|
+
"recharts"
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
// src/config/utils/deepMerge.ts
|
|
195
|
+
function deepMerge(target, source) {
|
|
196
|
+
const output = { ...target };
|
|
197
|
+
for (const key in source) {
|
|
198
|
+
if (source[key] === void 0) continue;
|
|
199
|
+
if (Array.isArray(source[key])) {
|
|
200
|
+
output[key] = source[key];
|
|
201
|
+
} else if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
202
|
+
const targetValue = output[key];
|
|
203
|
+
if (targetValue && typeof targetValue === "object" && !Array.isArray(targetValue)) {
|
|
204
|
+
output[key] = deepMerge(targetValue, source[key]);
|
|
205
|
+
} else {
|
|
206
|
+
output[key] = source[key];
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
output[key] = source[key];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return output;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// src/config/utils/env.ts
|
|
216
|
+
var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
|
|
217
|
+
var isDev = process.env.NODE_ENV === "development";
|
|
218
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
219
|
+
var isCI = process.env.CI === "true";
|
|
220
|
+
function getBasePath(isDefaultCfgAdmin) {
|
|
221
|
+
if (!isStaticBuild) return "";
|
|
222
|
+
return isDefaultCfgAdmin ? "/cfg/admin" : "/cfg/nextjs-admin";
|
|
223
|
+
}
|
|
224
|
+
function getApiUrl() {
|
|
225
|
+
return isStaticBuild ? "" : process.env.NEXT_PUBLIC_API_URL || "";
|
|
226
|
+
}
|
|
227
|
+
function getSiteUrl() {
|
|
228
|
+
return isStaticBuild ? "" : process.env.NEXT_PUBLIC_SITE_URL || "";
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// src/config/plugins/devStartup.ts
|
|
232
|
+
import chalk4 from "chalk";
|
|
233
|
+
|
|
234
|
+
// src/ai/constants.ts
|
|
235
|
+
var MCP_BASE_URL = "https://mcp.djangocfg.com";
|
|
236
|
+
var MCP_SERVER_URL = `${MCP_BASE_URL}/mcp`;
|
|
237
|
+
var MCP_API_URL = `${MCP_BASE_URL}/api/search`;
|
|
238
|
+
var AI_DOCS_HINT = `\u{1F916} AI Docs: ${MCP_SERVER_URL} | pnpm ai-docs search "query"`;
|
|
239
|
+
var AI_HINT = `
|
|
240
|
+
DjangoCFG Documentation is available via MCP server.
|
|
241
|
+
|
|
242
|
+
To get help with DjangoCFG configuration:
|
|
243
|
+
1. Use the MCP server: ${MCP_SERVER_URL}
|
|
244
|
+
2. Or search directly: ${MCP_API_URL}?q=YOUR_QUERY&limit=5
|
|
245
|
+
|
|
246
|
+
Example queries:
|
|
247
|
+
- "How to configure PostgreSQL database?"
|
|
248
|
+
- "What is DatabaseConfig?"
|
|
249
|
+
- "How to setup Redis cache?"
|
|
250
|
+
- "Email configuration with SMTP"
|
|
251
|
+
`;
|
|
252
|
+
|
|
253
|
+
// src/config/utils/version.ts
|
|
254
|
+
import chalk from "chalk";
|
|
255
|
+
import semver from "semver";
|
|
256
|
+
import consola from "consola";
|
|
257
|
+
import Conf from "conf";
|
|
258
|
+
var versionCache = new Conf({
|
|
259
|
+
projectName: "djangocfg-nextjs",
|
|
260
|
+
projectVersion: "1.0.0"
|
|
261
|
+
});
|
|
262
|
+
function getCurrentVersion() {
|
|
263
|
+
try {
|
|
264
|
+
const packageJson = require_package();
|
|
265
|
+
return packageJson.version || null;
|
|
266
|
+
} catch {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
async function fetchLatestVersion() {
|
|
271
|
+
const lastCheck = versionCache.get("lastCheck") || 0;
|
|
272
|
+
const cachedVersion = versionCache.get("latestVersion");
|
|
273
|
+
if (cachedVersion && Date.now() - lastCheck < VERSION_CACHE_TTL_MS) {
|
|
274
|
+
return cachedVersion;
|
|
275
|
+
}
|
|
276
|
+
try {
|
|
277
|
+
const https = await import("https");
|
|
278
|
+
return new Promise((resolve) => {
|
|
279
|
+
const req = https.get(
|
|
280
|
+
`https://registry.npmjs.org/${PACKAGE_NAME}/latest`,
|
|
281
|
+
{ timeout: 5e3 },
|
|
282
|
+
(res) => {
|
|
283
|
+
let data = "";
|
|
284
|
+
res.on("data", (chunk) => {
|
|
285
|
+
data += chunk;
|
|
286
|
+
});
|
|
287
|
+
res.on("end", () => {
|
|
288
|
+
try {
|
|
289
|
+
const json = JSON.parse(data);
|
|
290
|
+
const version = json.version || null;
|
|
291
|
+
if (version) {
|
|
292
|
+
versionCache.set("latestVersion", version);
|
|
293
|
+
versionCache.set("lastCheck", Date.now());
|
|
294
|
+
}
|
|
295
|
+
resolve(version);
|
|
296
|
+
} catch {
|
|
297
|
+
resolve(cachedVersion || null);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
req.on("error", () => resolve(cachedVersion || null));
|
|
303
|
+
req.on("timeout", () => {
|
|
304
|
+
req.destroy();
|
|
305
|
+
resolve(cachedVersion || null);
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
} catch {
|
|
309
|
+
return cachedVersion || null;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
async function checkForUpdate() {
|
|
313
|
+
const currentVersion = getCurrentVersion();
|
|
314
|
+
if (!currentVersion) {
|
|
315
|
+
return { hasUpdate: false, currentVersion: null, latestVersion: null };
|
|
316
|
+
}
|
|
317
|
+
const latestVersion = await fetchLatestVersion();
|
|
318
|
+
const hasUpdate = !!(latestVersion && semver.gt(latestVersion, currentVersion));
|
|
319
|
+
return { hasUpdate, currentVersion, latestVersion };
|
|
320
|
+
}
|
|
321
|
+
function getUpdateCommand() {
|
|
322
|
+
return `pnpm add ${DJANGOCFG_PACKAGES.map((p) => `${p}@latest`).join(" ")}`;
|
|
323
|
+
}
|
|
324
|
+
async function printVersionInfo() {
|
|
325
|
+
const { hasUpdate, currentVersion, latestVersion } = await checkForUpdate();
|
|
326
|
+
if (!currentVersion) return;
|
|
327
|
+
consola.box(`\u{1F4E6} @djangocfg/nextjs v${currentVersion}`);
|
|
328
|
+
if (hasUpdate && latestVersion) {
|
|
329
|
+
consola.warn(`Update Available! ${chalk.red(currentVersion)} \u2192 ${chalk.green(latestVersion)}`);
|
|
330
|
+
consola.info(`Run: ${chalk.cyan(getUpdateCommand())}`);
|
|
331
|
+
console.log("");
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// src/config/packages/installer.ts
|
|
336
|
+
import { execSync, spawn } from "child_process";
|
|
337
|
+
import { createInterface } from "readline";
|
|
338
|
+
import chalk2 from "chalk";
|
|
339
|
+
import consola2 from "consola";
|
|
340
|
+
import Conf2 from "conf";
|
|
341
|
+
|
|
342
|
+
// src/config/packages/checker.ts
|
|
343
|
+
import { createRequire } from "module";
|
|
344
|
+
import { join } from "path";
|
|
345
|
+
|
|
346
|
+
// src/config/packages/definitions.ts
|
|
347
|
+
var OPTIONAL_PACKAGES = [
|
|
348
|
+
{
|
|
349
|
+
name: "compression-webpack-plugin",
|
|
350
|
+
description: "Gzip and Brotli compression for static builds",
|
|
351
|
+
condition: "static-build",
|
|
352
|
+
devDependency: true
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: "@next/bundle-analyzer",
|
|
356
|
+
description: "Bundle analyzer for analyzing build output",
|
|
357
|
+
condition: "dev",
|
|
358
|
+
devDependency: true,
|
|
359
|
+
featureFlag: "ANALYZE"
|
|
360
|
+
}
|
|
361
|
+
];
|
|
362
|
+
var PEER_DEPENDENCIES = [
|
|
363
|
+
"next",
|
|
364
|
+
"react",
|
|
365
|
+
"react-dom"
|
|
366
|
+
];
|
|
367
|
+
function getPackagesForContext(options) {
|
|
368
|
+
return OPTIONAL_PACKAGES.filter((pkg) => {
|
|
369
|
+
switch (pkg.condition) {
|
|
370
|
+
case "static-build":
|
|
371
|
+
return options.isStaticBuild;
|
|
372
|
+
case "dev":
|
|
373
|
+
return options.isDev;
|
|
374
|
+
case "always":
|
|
375
|
+
return true;
|
|
376
|
+
default:
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// src/config/packages/checker.ts
|
|
383
|
+
function isPackageInstalled(packageName) {
|
|
384
|
+
try {
|
|
385
|
+
const consumerRequire = createRequire(join(process.cwd(), "package.json"));
|
|
386
|
+
consumerRequire.resolve(packageName);
|
|
387
|
+
return true;
|
|
388
|
+
} catch {
|
|
389
|
+
try {
|
|
390
|
+
__require.resolve(packageName);
|
|
391
|
+
return true;
|
|
392
|
+
} catch {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
function getMissingPackages() {
|
|
398
|
+
const neededPackages = getPackagesForContext({ isStaticBuild, isDev });
|
|
399
|
+
const missing = [];
|
|
400
|
+
for (const pkg of neededPackages) {
|
|
401
|
+
if (!isPackageInstalled(pkg.name)) {
|
|
402
|
+
missing.push({
|
|
403
|
+
...pkg,
|
|
404
|
+
reason: getReasonText(pkg)
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return missing;
|
|
409
|
+
}
|
|
410
|
+
function checkPackages(packageNames) {
|
|
411
|
+
const missing = [];
|
|
412
|
+
for (const name of packageNames) {
|
|
413
|
+
if (!isPackageInstalled(name)) {
|
|
414
|
+
const definition = OPTIONAL_PACKAGES.find((p) => p.name === name);
|
|
415
|
+
missing.push({
|
|
416
|
+
name,
|
|
417
|
+
description: definition?.description || "Optional package",
|
|
418
|
+
condition: definition?.condition || "always",
|
|
419
|
+
devDependency: definition?.devDependency ?? true,
|
|
420
|
+
reason: definition ? getReasonText(definition) : "Requested by configuration"
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return missing;
|
|
425
|
+
}
|
|
426
|
+
function getReasonText(pkg) {
|
|
427
|
+
switch (pkg.condition) {
|
|
428
|
+
case "static-build":
|
|
429
|
+
return "Required for static build (NEXT_PUBLIC_STATIC_BUILD=true)";
|
|
430
|
+
case "dev":
|
|
431
|
+
return "Required for development mode";
|
|
432
|
+
case "always":
|
|
433
|
+
return "Required for all builds";
|
|
434
|
+
default:
|
|
435
|
+
return "Optional feature";
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// src/config/packages/installer.ts
|
|
440
|
+
var installerCache = new Conf2({
|
|
441
|
+
projectName: "djangocfg-nextjs-installer",
|
|
442
|
+
projectVersion: "1.0.0"
|
|
443
|
+
});
|
|
444
|
+
var PROMPT_COOLDOWN_MS = 60 * 60 * 1e3;
|
|
445
|
+
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
446
|
+
function detectPackageManager() {
|
|
447
|
+
try {
|
|
448
|
+
const fs = __require("fs");
|
|
449
|
+
const path = __require("path");
|
|
450
|
+
const cwd = process.cwd();
|
|
451
|
+
if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
452
|
+
if (fs.existsSync(path.join(cwd, "yarn.lock"))) return "yarn";
|
|
453
|
+
if (fs.existsSync(path.join(cwd, "package-lock.json"))) return "npm";
|
|
454
|
+
try {
|
|
455
|
+
execSync("pnpm --version", { stdio: "ignore" });
|
|
456
|
+
return "pnpm";
|
|
457
|
+
} catch {
|
|
458
|
+
try {
|
|
459
|
+
execSync("yarn --version", { stdio: "ignore" });
|
|
460
|
+
return "yarn";
|
|
461
|
+
} catch {
|
|
462
|
+
return "npm";
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
} catch {
|
|
466
|
+
return "npm";
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
function buildSingleInstallCommand(packageName, isDev2, pm) {
|
|
470
|
+
const devFlag = isDev2 ? "-D " : "";
|
|
471
|
+
switch (pm) {
|
|
472
|
+
case "pnpm":
|
|
473
|
+
return `pnpm add ${devFlag}${packageName}`;
|
|
474
|
+
case "yarn":
|
|
475
|
+
return `yarn add ${devFlag}${packageName}`;
|
|
476
|
+
case "npm":
|
|
477
|
+
return `npm install ${devFlag}${packageName}`;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
function buildInstallCommand(packages, pm) {
|
|
481
|
+
const devPackages = packages.filter((p) => p.devDependency).map((p) => p.name);
|
|
482
|
+
const prodPackages = packages.filter((p) => !p.devDependency).map((p) => p.name);
|
|
483
|
+
const commands = [];
|
|
484
|
+
if (devPackages.length > 0) {
|
|
485
|
+
switch (pm) {
|
|
486
|
+
case "pnpm":
|
|
487
|
+
commands.push(`pnpm add -D ${devPackages.join(" ")}`);
|
|
488
|
+
break;
|
|
489
|
+
case "yarn":
|
|
490
|
+
commands.push(`yarn add -D ${devPackages.join(" ")}`);
|
|
491
|
+
break;
|
|
492
|
+
case "npm":
|
|
493
|
+
commands.push(`npm install -D ${devPackages.join(" ")}`);
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
if (prodPackages.length > 0) {
|
|
498
|
+
switch (pm) {
|
|
499
|
+
case "pnpm":
|
|
500
|
+
commands.push(`pnpm add ${prodPackages.join(" ")}`);
|
|
501
|
+
break;
|
|
502
|
+
case "yarn":
|
|
503
|
+
commands.push(`yarn add ${prodPackages.join(" ")}`);
|
|
504
|
+
break;
|
|
505
|
+
case "npm":
|
|
506
|
+
commands.push(`npm install ${prodPackages.join(" ")}`);
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return commands.join(" && ");
|
|
511
|
+
}
|
|
512
|
+
async function askConfirmation(question) {
|
|
513
|
+
if (isCI || !process.stdin.isTTY) {
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
return new Promise((resolve) => {
|
|
517
|
+
const rl = createInterface({
|
|
518
|
+
input: process.stdin,
|
|
519
|
+
output: process.stdout
|
|
520
|
+
});
|
|
521
|
+
rl.question(question, (answer) => {
|
|
522
|
+
rl.close();
|
|
523
|
+
const normalized = answer.toLowerCase().trim();
|
|
524
|
+
resolve(normalized === "" || normalized === "y" || normalized === "yes");
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
function createSpinner(text) {
|
|
529
|
+
let frameIndex = 0;
|
|
530
|
+
let interval = null;
|
|
531
|
+
let currentText = text;
|
|
532
|
+
const render = () => {
|
|
533
|
+
const frame = SPINNER_FRAMES[frameIndex];
|
|
534
|
+
process.stdout.write(`\r${chalk2.cyan(frame)} ${currentText}`);
|
|
535
|
+
frameIndex = (frameIndex + 1) % SPINNER_FRAMES.length;
|
|
536
|
+
};
|
|
537
|
+
return {
|
|
538
|
+
start() {
|
|
539
|
+
if (process.stdout.isTTY) {
|
|
540
|
+
interval = setInterval(render, 80);
|
|
541
|
+
render();
|
|
542
|
+
} else {
|
|
543
|
+
console.log(` ${currentText}`);
|
|
544
|
+
}
|
|
545
|
+
return this;
|
|
546
|
+
},
|
|
547
|
+
text(newText) {
|
|
548
|
+
currentText = newText;
|
|
549
|
+
if (!process.stdout.isTTY) {
|
|
550
|
+
console.log(` ${newText}`);
|
|
551
|
+
}
|
|
552
|
+
return this;
|
|
553
|
+
},
|
|
554
|
+
succeed(text2) {
|
|
555
|
+
if (interval) clearInterval(interval);
|
|
556
|
+
if (process.stdout.isTTY) {
|
|
557
|
+
process.stdout.write(`\r${chalk2.green("\u2713")} ${text2 || currentText}
|
|
558
|
+
`);
|
|
559
|
+
} else {
|
|
560
|
+
console.log(` ${chalk2.green("\u2713")} ${text2 || currentText}`);
|
|
561
|
+
}
|
|
562
|
+
return this;
|
|
563
|
+
},
|
|
564
|
+
fail(text2) {
|
|
565
|
+
if (interval) clearInterval(interval);
|
|
566
|
+
if (process.stdout.isTTY) {
|
|
567
|
+
process.stdout.write(`\r${chalk2.red("\u2717")} ${text2 || currentText}
|
|
568
|
+
`);
|
|
569
|
+
} else {
|
|
570
|
+
console.log(` ${chalk2.red("\u2717")} ${text2 || currentText}`);
|
|
571
|
+
}
|
|
572
|
+
return this;
|
|
573
|
+
},
|
|
574
|
+
stop() {
|
|
575
|
+
if (interval) clearInterval(interval);
|
|
576
|
+
if (process.stdout.isTTY) {
|
|
577
|
+
process.stdout.write("\r\x1B[K");
|
|
578
|
+
}
|
|
579
|
+
return this;
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
async function installSinglePackage(pkg, pm, index, total) {
|
|
584
|
+
const command = buildSingleInstallCommand(pkg.name, pkg.devDependency, pm);
|
|
585
|
+
const progress = `[${index + 1}/${total}]`;
|
|
586
|
+
const spinner = createSpinner(`${chalk2.dim(progress)} Installing ${chalk2.cyan(pkg.name)}...`);
|
|
587
|
+
spinner.start();
|
|
588
|
+
return new Promise((resolve) => {
|
|
589
|
+
const [cmd, ...args] = command.split(" ");
|
|
590
|
+
const proc = spawn(cmd, args, {
|
|
591
|
+
shell: true,
|
|
592
|
+
cwd: process.cwd(),
|
|
593
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
594
|
+
});
|
|
595
|
+
let stderr = "";
|
|
596
|
+
proc.stderr?.on("data", (data) => {
|
|
597
|
+
stderr += data.toString();
|
|
598
|
+
});
|
|
599
|
+
proc.on("close", (code) => {
|
|
600
|
+
if (code === 0) {
|
|
601
|
+
spinner.succeed(`${chalk2.dim(progress)} ${chalk2.cyan(pkg.name)} ${chalk2.green("installed")}`);
|
|
602
|
+
resolve(true);
|
|
603
|
+
} else {
|
|
604
|
+
spinner.fail(`${chalk2.dim(progress)} ${chalk2.cyan(pkg.name)} ${chalk2.red("failed")}`);
|
|
605
|
+
if (stderr) {
|
|
606
|
+
console.log(chalk2.dim(` ${stderr.split("\n")[0]}`));
|
|
607
|
+
}
|
|
608
|
+
resolve(false);
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
proc.on("error", () => {
|
|
612
|
+
spinner.fail(`${chalk2.dim(progress)} ${chalk2.cyan(pkg.name)} ${chalk2.red("failed")}`);
|
|
613
|
+
resolve(false);
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
async function installPackagesWithProgress(packages) {
|
|
618
|
+
if (packages.length === 0) return true;
|
|
619
|
+
const pm = detectPackageManager();
|
|
620
|
+
const total = packages.length;
|
|
621
|
+
console.log("");
|
|
622
|
+
console.log(chalk2.bold(` Installing ${total} package${total > 1 ? "s" : ""}...`));
|
|
623
|
+
console.log("");
|
|
624
|
+
let successCount = 0;
|
|
625
|
+
let failedPackages = [];
|
|
626
|
+
for (let i = 0; i < packages.length; i++) {
|
|
627
|
+
const success = await installSinglePackage(packages[i], pm, i, total);
|
|
628
|
+
if (success) {
|
|
629
|
+
successCount++;
|
|
630
|
+
} else {
|
|
631
|
+
failedPackages.push(packages[i].name);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
console.log("");
|
|
635
|
+
if (failedPackages.length === 0) {
|
|
636
|
+
consola2.success(`All ${total} packages installed successfully!`);
|
|
637
|
+
return true;
|
|
638
|
+
} else if (successCount > 0) {
|
|
639
|
+
consola2.warn(`${successCount}/${total} packages installed. Failed: ${failedPackages.join(", ")}`);
|
|
640
|
+
return false;
|
|
641
|
+
} else {
|
|
642
|
+
consola2.error(`Failed to install packages: ${failedPackages.join(", ")}`);
|
|
643
|
+
return false;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
async function installPackages(packages) {
|
|
647
|
+
if (packages.length > 1 && process.stdout.isTTY) {
|
|
648
|
+
return installPackagesWithProgress(packages);
|
|
649
|
+
}
|
|
650
|
+
if (packages.length === 0) return true;
|
|
651
|
+
const pm = detectPackageManager();
|
|
652
|
+
const command = buildInstallCommand(packages, pm);
|
|
653
|
+
consola2.info(`Installing: ${chalk2.cyan(packages.map((p) => p.name).join(", "))}`);
|
|
654
|
+
const spinner = createSpinner("Installing packages...");
|
|
655
|
+
spinner.start();
|
|
656
|
+
return new Promise((resolve) => {
|
|
657
|
+
const proc = spawn(command, {
|
|
658
|
+
shell: true,
|
|
659
|
+
cwd: process.cwd(),
|
|
660
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
661
|
+
});
|
|
662
|
+
proc.on("close", (code) => {
|
|
663
|
+
if (code === 0) {
|
|
664
|
+
spinner.succeed("Packages installed successfully!");
|
|
665
|
+
resolve(true);
|
|
666
|
+
} else {
|
|
667
|
+
spinner.fail("Failed to install packages");
|
|
668
|
+
resolve(false);
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
proc.on("error", () => {
|
|
672
|
+
spinner.fail("Installation failed");
|
|
673
|
+
resolve(false);
|
|
674
|
+
});
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
async function checkAndInstallPackages(options = {}) {
|
|
678
|
+
const missing = getMissingPackages();
|
|
679
|
+
const skipList = options.skipPackages || installerCache.get("skipPackages") || [];
|
|
680
|
+
const toInstall = missing.filter((p) => !skipList.includes(p.name));
|
|
681
|
+
if (toInstall.length === 0) {
|
|
682
|
+
return true;
|
|
683
|
+
}
|
|
684
|
+
const lastPrompt = installerCache.get("lastPrompt") || 0;
|
|
685
|
+
if (!options.force && Date.now() - lastPrompt < PROMPT_COOLDOWN_MS) {
|
|
686
|
+
printMissingPackagesInfo(toInstall);
|
|
687
|
+
return false;
|
|
688
|
+
}
|
|
689
|
+
if (options.autoInstall || installerCache.get("autoInstall")) {
|
|
690
|
+
return installPackages(toInstall);
|
|
691
|
+
}
|
|
692
|
+
console.log("");
|
|
693
|
+
consola2.box("\u{1F4E6} Missing Optional Packages");
|
|
694
|
+
console.log("");
|
|
695
|
+
for (const pkg of toInstall) {
|
|
696
|
+
console.log(` ${chalk2.yellow("\u2022")} ${chalk2.bold(pkg.name)}`);
|
|
697
|
+
console.log(` ${chalk2.dim(pkg.description)}`);
|
|
698
|
+
console.log(` ${chalk2.dim(pkg.reason)}`);
|
|
699
|
+
console.log("");
|
|
700
|
+
}
|
|
701
|
+
const pm = detectPackageManager();
|
|
702
|
+
const command = buildInstallCommand(toInstall, pm);
|
|
703
|
+
console.log(` ${chalk2.cyan("Command:")} ${command}`);
|
|
704
|
+
console.log("");
|
|
705
|
+
installerCache.set("lastPrompt", Date.now());
|
|
706
|
+
const shouldInstall = await askConfirmation(
|
|
707
|
+
`${chalk2.green("?")} Install these packages now? ${chalk2.dim("[Y/n]")} `
|
|
708
|
+
);
|
|
709
|
+
if (shouldInstall) {
|
|
710
|
+
const success = await installPackages(toInstall);
|
|
711
|
+
if (success) {
|
|
712
|
+
const enableAuto = await askConfirmation(
|
|
713
|
+
`${chalk2.green("?")} Enable auto-install for future? ${chalk2.dim("[y/N]")} `
|
|
714
|
+
);
|
|
715
|
+
if (enableAuto) {
|
|
716
|
+
installerCache.set("autoInstall", true);
|
|
717
|
+
consola2.info("Auto-install enabled. Run with --no-auto-install to disable.");
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
return success;
|
|
721
|
+
}
|
|
722
|
+
const skipPermanently = await askConfirmation(
|
|
723
|
+
`${chalk2.green("?")} Skip these packages in future prompts? ${chalk2.dim("[y/N]")} `
|
|
724
|
+
);
|
|
725
|
+
if (skipPermanently) {
|
|
726
|
+
const currentSkip = installerCache.get("skipPackages") || [];
|
|
727
|
+
installerCache.set("skipPackages", [...currentSkip, ...toInstall.map((p) => p.name)]);
|
|
728
|
+
consola2.info("Packages added to skip list.");
|
|
729
|
+
}
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
function printMissingPackagesInfo(packages) {
|
|
733
|
+
if (packages.length === 0) return;
|
|
734
|
+
const pm = detectPackageManager();
|
|
735
|
+
const command = buildInstallCommand(packages, pm);
|
|
736
|
+
consola2.warn(`Missing optional packages: ${packages.map((p) => p.name).join(", ")}`);
|
|
737
|
+
consola2.info(`Install with: ${chalk2.cyan(command)}`);
|
|
738
|
+
}
|
|
739
|
+
function resetInstallerPreferences() {
|
|
740
|
+
installerCache.clear();
|
|
741
|
+
consola2.success("Installer preferences reset");
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// src/config/packages/updater.ts
|
|
745
|
+
import { spawn as spawn2 } from "child_process";
|
|
746
|
+
import { createInterface as createInterface2 } from "readline";
|
|
747
|
+
import { createRequire as createRequire2 } from "module";
|
|
748
|
+
import { join as join2 } from "path";
|
|
749
|
+
import chalk3 from "chalk";
|
|
750
|
+
import consola3 from "consola";
|
|
751
|
+
import Conf3 from "conf";
|
|
752
|
+
import semver2 from "semver";
|
|
753
|
+
var updaterCache = new Conf3({
|
|
754
|
+
projectName: "djangocfg-nextjs-updater",
|
|
755
|
+
projectVersion: "1.0.0"
|
|
756
|
+
});
|
|
757
|
+
var UPDATE_CHECK_COOLDOWN_MS = 60 * 60 * 1e3;
|
|
758
|
+
var SPINNER_FRAMES2 = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
759
|
+
function isWorkspacePackage(packageName) {
|
|
760
|
+
try {
|
|
761
|
+
const fs = __require("fs");
|
|
762
|
+
const pkgJsonPath = join2(process.cwd(), "package.json");
|
|
763
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
764
|
+
const deps = { ...pkgJson.dependencies, ...pkgJson.devDependencies };
|
|
765
|
+
const version = deps[packageName];
|
|
766
|
+
return version?.startsWith("workspace:") || false;
|
|
767
|
+
} catch {
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
function getInstalledVersion(packageName) {
|
|
772
|
+
const fs = __require("fs");
|
|
773
|
+
const cwd = process.cwd();
|
|
774
|
+
try {
|
|
775
|
+
const directPath = join2(cwd, "node_modules", packageName, "package.json");
|
|
776
|
+
if (fs.existsSync(directPath)) {
|
|
777
|
+
const pkg = JSON.parse(fs.readFileSync(directPath, "utf-8"));
|
|
778
|
+
return pkg.version || null;
|
|
779
|
+
}
|
|
780
|
+
} catch {
|
|
781
|
+
}
|
|
782
|
+
try {
|
|
783
|
+
const consumerRequire = createRequire2(join2(cwd, "package.json"));
|
|
784
|
+
const pkgPath = consumerRequire.resolve(`${packageName}/package.json`);
|
|
785
|
+
const pkg = __require(pkgPath);
|
|
786
|
+
return pkg.version || null;
|
|
787
|
+
} catch {
|
|
788
|
+
}
|
|
789
|
+
try {
|
|
790
|
+
const pkgPath = __require.resolve(`${packageName}/package.json`);
|
|
791
|
+
const pkg = __require(pkgPath);
|
|
792
|
+
return pkg.version || null;
|
|
793
|
+
} catch {
|
|
794
|
+
return null;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
function shouldCheckUpdates(packageName) {
|
|
798
|
+
return !isWorkspacePackage(packageName);
|
|
799
|
+
}
|
|
800
|
+
async function fetchLatestVersion2(packageName) {
|
|
801
|
+
try {
|
|
802
|
+
const https = await import("https");
|
|
803
|
+
return new Promise((resolve) => {
|
|
804
|
+
const req = https.get(
|
|
805
|
+
`https://registry.npmjs.org/${packageName}/latest`,
|
|
806
|
+
{ timeout: 5e3 },
|
|
807
|
+
(res) => {
|
|
808
|
+
let data = "";
|
|
809
|
+
res.on("data", (chunk) => {
|
|
810
|
+
data += chunk;
|
|
811
|
+
});
|
|
812
|
+
res.on("end", () => {
|
|
813
|
+
try {
|
|
814
|
+
const json = JSON.parse(data);
|
|
815
|
+
resolve(json.version || null);
|
|
816
|
+
} catch {
|
|
817
|
+
resolve(null);
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
);
|
|
822
|
+
req.on("error", () => resolve(null));
|
|
823
|
+
req.on("timeout", () => {
|
|
824
|
+
req.destroy();
|
|
825
|
+
resolve(null);
|
|
826
|
+
});
|
|
827
|
+
});
|
|
828
|
+
} catch {
|
|
829
|
+
return null;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
async function checkForUpdates(options = {}) {
|
|
833
|
+
const results = [];
|
|
834
|
+
const masterLatest = await fetchLatestVersion2(PACKAGE_NAME);
|
|
835
|
+
if (!masterLatest) {
|
|
836
|
+
return results;
|
|
837
|
+
}
|
|
838
|
+
const checks = DJANGOCFG_PACKAGES.map(async (name) => {
|
|
839
|
+
const isWorkspace = !shouldCheckUpdates(name);
|
|
840
|
+
if (!options.forceCheckWorkspace && isWorkspace) {
|
|
841
|
+
return null;
|
|
842
|
+
}
|
|
843
|
+
const current = getInstalledVersion(name);
|
|
844
|
+
if (!current) {
|
|
845
|
+
return null;
|
|
846
|
+
}
|
|
847
|
+
const hasUpdate = !!(masterLatest && current && semver2.gt(masterLatest, current));
|
|
848
|
+
return { name, current, latest: masterLatest, hasUpdate };
|
|
849
|
+
});
|
|
850
|
+
const checkResults = await Promise.all(checks);
|
|
851
|
+
for (const result of checkResults) {
|
|
852
|
+
if (result) {
|
|
853
|
+
results.push(result);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
return results;
|
|
857
|
+
}
|
|
858
|
+
async function getOutdatedPackages(options = {}) {
|
|
859
|
+
const all = await checkForUpdates(options);
|
|
860
|
+
const skipped = updaterCache.get("skippedVersions") || {};
|
|
861
|
+
return all.filter((pkg) => {
|
|
862
|
+
if (!pkg.hasUpdate) return false;
|
|
863
|
+
if (skipped[pkg.name] === pkg.latest) return false;
|
|
864
|
+
return true;
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
function createSpinner2(text) {
|
|
868
|
+
let frameIndex = 0;
|
|
869
|
+
let interval = null;
|
|
870
|
+
let currentText = text;
|
|
871
|
+
const render = () => {
|
|
872
|
+
const frame = SPINNER_FRAMES2[frameIndex];
|
|
873
|
+
process.stdout.write(`\r${chalk3.cyan(frame)} ${currentText}`);
|
|
874
|
+
frameIndex = (frameIndex + 1) % SPINNER_FRAMES2.length;
|
|
875
|
+
};
|
|
876
|
+
return {
|
|
877
|
+
start() {
|
|
878
|
+
if (process.stdout.isTTY) {
|
|
879
|
+
interval = setInterval(render, 80);
|
|
880
|
+
render();
|
|
881
|
+
} else {
|
|
882
|
+
console.log(` ${currentText}`);
|
|
883
|
+
}
|
|
884
|
+
return this;
|
|
885
|
+
},
|
|
886
|
+
text(newText) {
|
|
887
|
+
currentText = newText;
|
|
888
|
+
return this;
|
|
889
|
+
},
|
|
890
|
+
succeed(text2) {
|
|
891
|
+
if (interval) clearInterval(interval);
|
|
892
|
+
if (process.stdout.isTTY) {
|
|
893
|
+
process.stdout.write(`\r${chalk3.green("\u2713")} ${text2 || currentText}
|
|
894
|
+
`);
|
|
895
|
+
} else {
|
|
896
|
+
console.log(` ${chalk3.green("\u2713")} ${text2 || currentText}`);
|
|
897
|
+
}
|
|
898
|
+
return this;
|
|
899
|
+
},
|
|
900
|
+
fail(text2) {
|
|
901
|
+
if (interval) clearInterval(interval);
|
|
902
|
+
if (process.stdout.isTTY) {
|
|
903
|
+
process.stdout.write(`\r${chalk3.red("\u2717")} ${text2 || currentText}
|
|
904
|
+
`);
|
|
905
|
+
} else {
|
|
906
|
+
console.log(` ${chalk3.red("\u2717")} ${text2 || currentText}`);
|
|
907
|
+
}
|
|
908
|
+
return this;
|
|
909
|
+
},
|
|
910
|
+
stop() {
|
|
911
|
+
if (interval) clearInterval(interval);
|
|
912
|
+
if (process.stdout.isTTY) {
|
|
913
|
+
process.stdout.write("\r\x1B[K");
|
|
914
|
+
}
|
|
915
|
+
return this;
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
async function askConfirmation2(question) {
|
|
920
|
+
if (isCI || !process.stdin.isTTY) {
|
|
921
|
+
return false;
|
|
922
|
+
}
|
|
923
|
+
return new Promise((resolve) => {
|
|
924
|
+
const rl = createInterface2({
|
|
925
|
+
input: process.stdin,
|
|
926
|
+
output: process.stdout
|
|
927
|
+
});
|
|
928
|
+
rl.question(question, (answer) => {
|
|
929
|
+
rl.close();
|
|
930
|
+
const normalized = answer.toLowerCase().trim();
|
|
931
|
+
resolve(normalized === "" || normalized === "y" || normalized === "yes");
|
|
932
|
+
});
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
async function updateSinglePackage(pkg, pm, index, total) {
|
|
936
|
+
const progress = `[${index + 1}/${total}]`;
|
|
937
|
+
const versionInfo = `${chalk3.red(pkg.current)} \u2192 ${chalk3.green(pkg.latest)}`;
|
|
938
|
+
const spinner = createSpinner2(
|
|
939
|
+
`${chalk3.dim(progress)} Updating ${chalk3.cyan(pkg.name)} ${versionInfo}`
|
|
940
|
+
);
|
|
941
|
+
spinner.start();
|
|
942
|
+
const command = pm === "pnpm" ? `pnpm add ${pkg.name}@latest` : pm === "yarn" ? `yarn add ${pkg.name}@latest` : `npm install ${pkg.name}@latest`;
|
|
943
|
+
return new Promise((resolve) => {
|
|
944
|
+
const proc = spawn2(command, {
|
|
945
|
+
shell: true,
|
|
946
|
+
cwd: process.cwd(),
|
|
947
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
948
|
+
});
|
|
949
|
+
proc.on("close", (code) => {
|
|
950
|
+
if (code === 0) {
|
|
951
|
+
spinner.succeed(
|
|
952
|
+
`${chalk3.dim(progress)} ${chalk3.cyan(pkg.name)} ${chalk3.green(pkg.latest)}`
|
|
953
|
+
);
|
|
954
|
+
resolve(true);
|
|
955
|
+
} else {
|
|
956
|
+
spinner.fail(
|
|
957
|
+
`${chalk3.dim(progress)} ${chalk3.cyan(pkg.name)} ${chalk3.red("failed")}`
|
|
958
|
+
);
|
|
959
|
+
resolve(false);
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
proc.on("error", () => {
|
|
963
|
+
spinner.fail(`${chalk3.dim(progress)} ${chalk3.cyan(pkg.name)} ${chalk3.red("failed")}`);
|
|
964
|
+
resolve(false);
|
|
965
|
+
});
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
async function updatePackagesWithProgress(packages) {
|
|
969
|
+
if (packages.length === 0) return true;
|
|
970
|
+
const pm = detectPackageManager();
|
|
971
|
+
const total = packages.length;
|
|
972
|
+
console.log("");
|
|
973
|
+
console.log(chalk3.bold(` Updating ${total} package${total > 1 ? "s" : ""}...`));
|
|
974
|
+
console.log("");
|
|
975
|
+
let successCount = 0;
|
|
976
|
+
const failedPackages = [];
|
|
977
|
+
for (let i = 0; i < packages.length; i++) {
|
|
978
|
+
const success = await updateSinglePackage(packages[i], pm, i, total);
|
|
979
|
+
if (success) {
|
|
980
|
+
successCount++;
|
|
981
|
+
} else {
|
|
982
|
+
failedPackages.push(packages[i].name);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
console.log("");
|
|
986
|
+
if (failedPackages.length === 0) {
|
|
987
|
+
consola3.success(`All ${total} packages updated successfully!`);
|
|
988
|
+
return true;
|
|
989
|
+
} else if (successCount > 0) {
|
|
990
|
+
consola3.warn(`${successCount}/${total} packages updated. Failed: ${failedPackages.join(", ")}`);
|
|
991
|
+
return false;
|
|
992
|
+
} else {
|
|
993
|
+
consola3.error(`Failed to update packages: ${failedPackages.join(", ")}`);
|
|
994
|
+
return false;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
async function checkAndUpdatePackages(options = {}) {
|
|
998
|
+
const lastCheck = updaterCache.get("lastCheck") || 0;
|
|
999
|
+
if (!options.force && Date.now() - lastCheck < UPDATE_CHECK_COOLDOWN_MS) {
|
|
1000
|
+
return true;
|
|
1001
|
+
}
|
|
1002
|
+
updaterCache.set("lastCheck", Date.now());
|
|
1003
|
+
const spinner = createSpinner2("Checking for updates...");
|
|
1004
|
+
spinner.start();
|
|
1005
|
+
const outdated = await getOutdatedPackages({
|
|
1006
|
+
forceCheckWorkspace: options.forceCheckWorkspace
|
|
1007
|
+
});
|
|
1008
|
+
spinner.stop();
|
|
1009
|
+
console.log(chalk3.dim(` Found ${outdated.length} outdated package(s)`));
|
|
1010
|
+
if (outdated.length === 0) {
|
|
1011
|
+
console.log(chalk3.green(" \u2713 All packages are up to date"));
|
|
1012
|
+
return true;
|
|
1013
|
+
}
|
|
1014
|
+
if (options.autoUpdate || updaterCache.get("autoUpdate")) {
|
|
1015
|
+
return updatePackagesWithProgress(outdated);
|
|
1016
|
+
}
|
|
1017
|
+
console.log("");
|
|
1018
|
+
consola3.box("\u{1F4E6} Updates Available");
|
|
1019
|
+
console.log("");
|
|
1020
|
+
for (const pkg of outdated) {
|
|
1021
|
+
console.log(
|
|
1022
|
+
` ${chalk3.yellow("\u2022")} ${chalk3.bold(pkg.name)} ${chalk3.red(pkg.current)} \u2192 ${chalk3.green(pkg.latest)}`
|
|
1023
|
+
);
|
|
1024
|
+
}
|
|
1025
|
+
console.log("");
|
|
1026
|
+
const shouldUpdate = await askConfirmation2(
|
|
1027
|
+
`${chalk3.green("?")} Update these packages now? ${chalk3.dim("[Y/n]")} `
|
|
1028
|
+
);
|
|
1029
|
+
if (shouldUpdate) {
|
|
1030
|
+
const success = await updatePackagesWithProgress(outdated);
|
|
1031
|
+
if (success) {
|
|
1032
|
+
const enableAuto = await askConfirmation2(
|
|
1033
|
+
`${chalk3.green("?")} Enable auto-update for future? ${chalk3.dim("[y/N]")} `
|
|
1034
|
+
);
|
|
1035
|
+
if (enableAuto) {
|
|
1036
|
+
updaterCache.set("autoUpdate", true);
|
|
1037
|
+
consola3.info("Auto-update enabled.");
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
return success;
|
|
1041
|
+
}
|
|
1042
|
+
const skipVersions = await askConfirmation2(
|
|
1043
|
+
`${chalk3.green("?")} Skip these versions in future? ${chalk3.dim("[y/N]")} `
|
|
1044
|
+
);
|
|
1045
|
+
if (skipVersions) {
|
|
1046
|
+
const skipped = updaterCache.get("skippedVersions") || {};
|
|
1047
|
+
for (const pkg of outdated) {
|
|
1048
|
+
if (pkg.latest) {
|
|
1049
|
+
skipped[pkg.name] = pkg.latest;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
updaterCache.set("skippedVersions", skipped);
|
|
1053
|
+
consola3.info("Versions skipped. Will prompt again for newer versions.");
|
|
1054
|
+
}
|
|
1055
|
+
return false;
|
|
1056
|
+
}
|
|
1057
|
+
function resetUpdaterPreferences() {
|
|
1058
|
+
updaterCache.clear();
|
|
1059
|
+
consola3.success("Updater preferences reset");
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
// src/config/plugins/devStartup.ts
|
|
1063
|
+
var startupDone = false;
|
|
1064
|
+
var browserOpened = false;
|
|
1065
|
+
var DevStartupPlugin = class {
|
|
1066
|
+
constructor(options = {}) {
|
|
1067
|
+
this.options = options;
|
|
1068
|
+
}
|
|
1069
|
+
apply(compiler) {
|
|
1070
|
+
compiler.hooks.done.tapPromise("DevStartupPlugin", async () => {
|
|
1071
|
+
if (!startupDone) {
|
|
1072
|
+
startupDone = true;
|
|
1073
|
+
await this.runStartupTasks();
|
|
1074
|
+
}
|
|
1075
|
+
if (this.options.openBrowser && !browserOpened) {
|
|
1076
|
+
browserOpened = true;
|
|
1077
|
+
this.openBrowser();
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
async runStartupTasks() {
|
|
1082
|
+
console.log("\n" + chalk4.yellowBright.bold(DJANGO_CFG_BANNER));
|
|
1083
|
+
const version = getCurrentVersion();
|
|
1084
|
+
if (version) {
|
|
1085
|
+
console.log(chalk4.dim(` \u{1F4E6} @djangocfg/nextjs v${version}`));
|
|
1086
|
+
}
|
|
1087
|
+
console.log(chalk4.magenta(` ${AI_DOCS_HINT}
|
|
1088
|
+
`));
|
|
1089
|
+
if (this.options.checkUpdates !== false) {
|
|
1090
|
+
try {
|
|
1091
|
+
await checkAndUpdatePackages({
|
|
1092
|
+
autoUpdate: this.options.autoUpdate,
|
|
1093
|
+
forceCheckWorkspace: this.options.forceCheckWorkspace,
|
|
1094
|
+
force: true
|
|
1095
|
+
// Force check ignoring cooldown
|
|
1096
|
+
});
|
|
1097
|
+
} catch (err) {
|
|
1098
|
+
console.log(chalk4.red(" Update check failed:"), err);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
if (this.options.checkPackages !== false) {
|
|
1102
|
+
await checkAndInstallPackages({
|
|
1103
|
+
autoInstall: this.options.autoInstall
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
openBrowser() {
|
|
1108
|
+
setTimeout(async () => {
|
|
1109
|
+
try {
|
|
1110
|
+
const { exec } = await import("child_process");
|
|
1111
|
+
const port = process.env.PORT || "3000";
|
|
1112
|
+
const url = `http://localhost:${port}`;
|
|
1113
|
+
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
1114
|
+
exec(`${command} ${url}`, (error) => {
|
|
1115
|
+
if (error) {
|
|
1116
|
+
console.warn(`Failed to open browser: ${error.message}`);
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
} catch (error) {
|
|
1120
|
+
console.warn("Failed to open browser");
|
|
1121
|
+
}
|
|
1122
|
+
}, 2e3);
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
function resetDevStartupState() {
|
|
1126
|
+
startupDone = false;
|
|
1127
|
+
browserOpened = false;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
// src/config/plugins/compression.ts
|
|
1131
|
+
var DEFAULT_OPTIONS = {
|
|
1132
|
+
gzip: true,
|
|
1133
|
+
brotli: true,
|
|
1134
|
+
threshold: 8192,
|
|
1135
|
+
minRatio: 0.8,
|
|
1136
|
+
brotliLevel: 8
|
|
1137
|
+
};
|
|
1138
|
+
function addCompressionPlugins(config, options = {}) {
|
|
1139
|
+
if (!isPackageInstalled("compression-webpack-plugin")) {
|
|
1140
|
+
return false;
|
|
1141
|
+
}
|
|
1142
|
+
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
1143
|
+
try {
|
|
1144
|
+
const CompressionPlugin = __require("compression-webpack-plugin");
|
|
1145
|
+
if (!config.plugins) {
|
|
1146
|
+
config.plugins = [];
|
|
1147
|
+
}
|
|
1148
|
+
if (opts.gzip) {
|
|
1149
|
+
config.plugins.push(
|
|
1150
|
+
new CompressionPlugin({
|
|
1151
|
+
filename: "[path][base].gz",
|
|
1152
|
+
algorithm: "gzip",
|
|
1153
|
+
test: /\.(js|css|html|svg|json)$/,
|
|
1154
|
+
threshold: opts.threshold,
|
|
1155
|
+
minRatio: opts.minRatio
|
|
1156
|
+
})
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
1159
|
+
if (opts.brotli) {
|
|
1160
|
+
config.plugins.push(
|
|
1161
|
+
new CompressionPlugin({
|
|
1162
|
+
filename: "[path][base].br",
|
|
1163
|
+
algorithm: "brotliCompress",
|
|
1164
|
+
test: /\.(js|css|html|svg|json)$/,
|
|
1165
|
+
threshold: opts.threshold,
|
|
1166
|
+
minRatio: opts.minRatio,
|
|
1167
|
+
compressionOptions: {
|
|
1168
|
+
level: opts.brotliLevel
|
|
1169
|
+
}
|
|
1170
|
+
})
|
|
1171
|
+
);
|
|
1172
|
+
}
|
|
1173
|
+
return true;
|
|
1174
|
+
} catch (error) {
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
function isCompressionAvailable() {
|
|
1179
|
+
return isPackageInstalled("compression-webpack-plugin");
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
// src/config/createNextConfig.ts
|
|
1183
|
+
function createBaseNextConfig(options = {}) {
|
|
1184
|
+
const basePath = getBasePath(options.isDefaultCfgAdmin);
|
|
1185
|
+
const apiUrl = getApiUrl();
|
|
1186
|
+
const siteUrl = getSiteUrl();
|
|
1187
|
+
const baseConfig = {
|
|
1188
|
+
reactStrictMode: true,
|
|
1189
|
+
trailingSlash: true,
|
|
1190
|
+
// Static export configuration
|
|
1191
|
+
...isStaticBuild && {
|
|
1192
|
+
output: "export",
|
|
1193
|
+
distDir: "out",
|
|
1194
|
+
basePath,
|
|
1195
|
+
// Fix for Next.js 15.5.4: prevent 500.html generation issue
|
|
1196
|
+
generateBuildId: async () => {
|
|
1197
|
+
return "static-build";
|
|
1198
|
+
}
|
|
1199
|
+
},
|
|
1200
|
+
// Standalone output for Docker (only in production, not dev)
|
|
1201
|
+
...!isStaticBuild && !isDev && {
|
|
1202
|
+
output: "standalone"
|
|
1203
|
+
},
|
|
1204
|
+
// Environment variables
|
|
1205
|
+
env: {
|
|
1206
|
+
NEXT_PUBLIC_BASE_PATH: basePath,
|
|
1207
|
+
NEXT_PUBLIC_API_URL: apiUrl,
|
|
1208
|
+
NEXT_PUBLIC_SITE_URL: siteUrl,
|
|
1209
|
+
...options.env
|
|
1210
|
+
},
|
|
1211
|
+
// Images configuration
|
|
1212
|
+
images: {
|
|
1213
|
+
unoptimized: true
|
|
1214
|
+
},
|
|
1215
|
+
// CORS headers for static files and iframe embedding
|
|
1216
|
+
async headers() {
|
|
1217
|
+
const headers = [
|
|
1218
|
+
{
|
|
1219
|
+
source: "/static/:path*",
|
|
1220
|
+
headers: [
|
|
1221
|
+
{ key: "Access-Control-Allow-Origin", value: "*" },
|
|
1222
|
+
{ key: "Access-Control-Allow-Methods", value: "GET, OPTIONS" },
|
|
1223
|
+
{ key: "Access-Control-Allow-Headers", value: "Origin, Content-Type, Accept" }
|
|
1224
|
+
]
|
|
1225
|
+
}
|
|
1226
|
+
];
|
|
1227
|
+
if (options.allowIframeFrom && options.allowIframeFrom.length > 0) {
|
|
1228
|
+
const frameAncestors = options.allowIframeFrom.includes("*") ? "*" : `'self' ${options.allowIframeFrom.join(" ")}`;
|
|
1229
|
+
headers.push({
|
|
1230
|
+
source: "/:path*",
|
|
1231
|
+
headers: [
|
|
1232
|
+
// Content-Security-Policy frame-ancestors directive
|
|
1233
|
+
{ key: "Content-Security-Policy", value: `frame-ancestors ${frameAncestors}` },
|
|
1234
|
+
// X-Frame-Options for older browsers (ALLOW-FROM is deprecated, use CSP instead)
|
|
1235
|
+
// Only set SAMEORIGIN if allowing all, otherwise browsers will use CSP
|
|
1236
|
+
...options.allowIframeFrom.includes("*") ? [] : [{ key: "X-Frame-Options", value: "SAMEORIGIN" }]
|
|
1237
|
+
]
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
return headers;
|
|
1241
|
+
},
|
|
1242
|
+
// Transpile packages (merge with user-provided)
|
|
1243
|
+
transpilePackages: [
|
|
1244
|
+
...DEFAULT_TRANSPILE_PACKAGES,
|
|
1245
|
+
...options.transpilePackages || []
|
|
1246
|
+
],
|
|
1247
|
+
// Experimental features
|
|
1248
|
+
experimental: {
|
|
1249
|
+
// Optimize package imports (only in production)
|
|
1250
|
+
...!isDev && {
|
|
1251
|
+
optimizePackageImports: [
|
|
1252
|
+
...DEFAULT_OPTIMIZE_PACKAGES,
|
|
1253
|
+
...options.optimizePackageImports || []
|
|
1254
|
+
]
|
|
1255
|
+
},
|
|
1256
|
+
// Dev mode optimizations
|
|
1257
|
+
...isDev && {
|
|
1258
|
+
optimizeCss: false
|
|
1259
|
+
},
|
|
1260
|
+
// User experimental options applied last (can override base settings)
|
|
1261
|
+
...options.experimental
|
|
1262
|
+
},
|
|
1263
|
+
// Webpack configuration
|
|
1264
|
+
webpack: (config, webpackOptions) => {
|
|
1265
|
+
const { isServer, dev } = webpackOptions;
|
|
1266
|
+
if (dev && !isServer) {
|
|
1267
|
+
if (!config.plugins) {
|
|
1268
|
+
config.plugins = [];
|
|
1269
|
+
}
|
|
1270
|
+
config.plugins.push(
|
|
1271
|
+
new DevStartupPlugin({
|
|
1272
|
+
openBrowser: options.openBrowser,
|
|
1273
|
+
checkUpdates: options.checkUpdates,
|
|
1274
|
+
autoUpdate: options.autoUpdate,
|
|
1275
|
+
forceCheckWorkspace: options.forceCheckWorkspace,
|
|
1276
|
+
checkPackages: options.checkPackages,
|
|
1277
|
+
autoInstall: options.autoInstall
|
|
1278
|
+
})
|
|
1279
|
+
);
|
|
1280
|
+
}
|
|
1281
|
+
if (dev) {
|
|
1282
|
+
config.optimization = {
|
|
1283
|
+
...config.optimization,
|
|
1284
|
+
removeAvailableModules: false,
|
|
1285
|
+
removeEmptyChunks: false,
|
|
1286
|
+
splitChunks: false
|
|
1287
|
+
// Disable code splitting in dev for faster compilation
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
config.cache = {
|
|
1291
|
+
type: "filesystem",
|
|
1292
|
+
buildDependencies: {}
|
|
1293
|
+
};
|
|
1294
|
+
if (!isServer && isStaticBuild && !dev) {
|
|
1295
|
+
addCompressionPlugins(config);
|
|
1296
|
+
}
|
|
1297
|
+
if (options.webpack) {
|
|
1298
|
+
return options.webpack(config, webpackOptions);
|
|
1299
|
+
}
|
|
1300
|
+
return config;
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
const finalConfig = deepMerge(baseConfig, options);
|
|
1304
|
+
delete finalConfig.optimizePackageImports;
|
|
1305
|
+
delete finalConfig.isDefaultCfgAdmin;
|
|
1306
|
+
delete finalConfig.openBrowser;
|
|
1307
|
+
delete finalConfig.checkUpdates;
|
|
1308
|
+
delete finalConfig.autoUpdate;
|
|
1309
|
+
delete finalConfig.forceCheckWorkspace;
|
|
1310
|
+
delete finalConfig.checkPackages;
|
|
1311
|
+
delete finalConfig.autoInstall;
|
|
1312
|
+
delete finalConfig.allowIframeFrom;
|
|
1313
|
+
return finalConfig;
|
|
1314
|
+
}
|
|
1315
|
+
export {
|
|
1316
|
+
AI_DOCS_HINT,
|
|
1317
|
+
DEFAULT_OPTIMIZE_PACKAGES,
|
|
1318
|
+
DEFAULT_TRANSPILE_PACKAGES,
|
|
1319
|
+
DJANGOCFG_PACKAGES,
|
|
1320
|
+
DJANGO_CFG_BANNER,
|
|
1321
|
+
DevStartupPlugin,
|
|
1322
|
+
MCP_API_URL,
|
|
1323
|
+
MCP_BASE_URL,
|
|
1324
|
+
MCP_SERVER_URL,
|
|
1325
|
+
OPTIONAL_PACKAGES,
|
|
1326
|
+
PACKAGE_NAME,
|
|
1327
|
+
PEER_DEPENDENCIES,
|
|
1328
|
+
addCompressionPlugins,
|
|
1329
|
+
buildInstallCommand,
|
|
1330
|
+
buildSingleInstallCommand,
|
|
1331
|
+
checkAndInstallPackages,
|
|
1332
|
+
checkAndUpdatePackages,
|
|
1333
|
+
checkForUpdate,
|
|
1334
|
+
checkForUpdates,
|
|
1335
|
+
checkPackages,
|
|
1336
|
+
createBaseNextConfig,
|
|
1337
|
+
deepMerge,
|
|
1338
|
+
detectPackageManager,
|
|
1339
|
+
fetchLatestVersion,
|
|
1340
|
+
getApiUrl,
|
|
1341
|
+
getBasePath,
|
|
1342
|
+
getCurrentVersion,
|
|
1343
|
+
getInstalledVersion,
|
|
1344
|
+
getMissingPackages,
|
|
1345
|
+
getOutdatedPackages,
|
|
1346
|
+
getPackagesForContext,
|
|
1347
|
+
getSiteUrl,
|
|
1348
|
+
getUpdateCommand,
|
|
1349
|
+
installPackages,
|
|
1350
|
+
installPackagesWithProgress,
|
|
1351
|
+
isCI,
|
|
1352
|
+
isCompressionAvailable,
|
|
1353
|
+
isDev,
|
|
1354
|
+
isPackageInstalled,
|
|
1355
|
+
isProduction,
|
|
1356
|
+
isStaticBuild,
|
|
1357
|
+
printVersionInfo,
|
|
1358
|
+
resetDevStartupState,
|
|
1359
|
+
resetInstallerPreferences,
|
|
1360
|
+
resetUpdaterPreferences,
|
|
1361
|
+
updatePackagesWithProgress
|
|
1362
|
+
};
|
|
1363
|
+
//# sourceMappingURL=index.mjs.map
|