create-nextly-app 0.0.2-alpha.11 → 0.0.2-alpha.13
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/dist/{chunk-RPGFJSDP.mjs → chunk-AATWR2UA.mjs} +50 -18
- package/dist/chunk-AATWR2UA.mjs.map +1 -0
- package/dist/cli.cjs +49 -17
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +48 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
- package/templates/base/next.config.ts +11 -17
- package/dist/chunk-RPGFJSDP.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -14266,22 +14266,42 @@ async function generateMediaRoutes(cwd, projectInfo) {
|
|
|
14266
14266
|
|
|
14267
14267
|
// src/generators/next-config.ts
|
|
14268
14268
|
var import_fs_extra5 = __toESM(require_lib());
|
|
14269
|
-
var
|
|
14269
|
+
var COMMON_SERVER_EXTERNAL_PACKAGES = [
|
|
14270
14270
|
"nextly",
|
|
14271
14271
|
"@nextlyhq/adapter-drizzle",
|
|
14272
|
-
"@nextlyhq/adapter-postgres",
|
|
14273
|
-
"@nextlyhq/adapter-mysql",
|
|
14274
|
-
"@nextlyhq/adapter-sqlite",
|
|
14275
14272
|
"drizzle-orm",
|
|
14276
14273
|
"drizzle-kit",
|
|
14277
|
-
"pg",
|
|
14278
|
-
"mysql2",
|
|
14279
|
-
"better-sqlite3",
|
|
14280
14274
|
"bcryptjs",
|
|
14281
14275
|
"sharp",
|
|
14282
14276
|
"esbuild"
|
|
14283
14277
|
];
|
|
14284
|
-
|
|
14278
|
+
var DATABASE_SERVER_EXTERNAL_PACKAGES = {
|
|
14279
|
+
postgresql: ["@nextlyhq/adapter-postgres", "pg"],
|
|
14280
|
+
mysql: ["@nextlyhq/adapter-mysql", "mysql2"],
|
|
14281
|
+
sqlite: ["@nextlyhq/adapter-sqlite", "better-sqlite3"]
|
|
14282
|
+
};
|
|
14283
|
+
function getServerExternalPackages(database) {
|
|
14284
|
+
return [
|
|
14285
|
+
...COMMON_SERVER_EXTERNAL_PACKAGES,
|
|
14286
|
+
...DATABASE_SERVER_EXTERNAL_PACKAGES[database.type]
|
|
14287
|
+
];
|
|
14288
|
+
}
|
|
14289
|
+
function buildNextConfigTemplate(database) {
|
|
14290
|
+
const packagesArray = JSON.stringify(
|
|
14291
|
+
getServerExternalPackages(database),
|
|
14292
|
+
null,
|
|
14293
|
+
2
|
|
14294
|
+
).replace(/\n/g, "\n ");
|
|
14295
|
+
return `import type { NextConfig } from "next";
|
|
14296
|
+
|
|
14297
|
+
const nextConfig: NextConfig = {
|
|
14298
|
+
serverExternalPackages: ${packagesArray},
|
|
14299
|
+
};
|
|
14300
|
+
|
|
14301
|
+
export default nextConfig;
|
|
14302
|
+
`;
|
|
14303
|
+
}
|
|
14304
|
+
async function patchNextConfig(cwd, database) {
|
|
14285
14305
|
const candidates = ["next.config.ts", "next.config.mjs", "next.config.js"];
|
|
14286
14306
|
let configPath = null;
|
|
14287
14307
|
for (const name of candidates) {
|
|
@@ -14298,7 +14318,11 @@ async function patchNextConfig(cwd) {
|
|
|
14298
14318
|
if (content.includes("serverExternalPackages")) {
|
|
14299
14319
|
return;
|
|
14300
14320
|
}
|
|
14301
|
-
const packagesArray = JSON.stringify(
|
|
14321
|
+
const packagesArray = JSON.stringify(
|
|
14322
|
+
getServerExternalPackages(database),
|
|
14323
|
+
null,
|
|
14324
|
+
2
|
|
14325
|
+
).replace(/\n/g, "\n ");
|
|
14302
14326
|
const configObjectPattern = /(const\s+\w+\s*(?::\s*NextConfig\s*)?=\s*\{)/;
|
|
14303
14327
|
if (configObjectPattern.test(content)) {
|
|
14304
14328
|
const patched = content.replace(
|
|
@@ -21068,6 +21092,10 @@ async function generatePackageJson(projectName, database, useYalc = false, proje
|
|
|
21068
21092
|
// don't ship a /search page simply won't invoke it.
|
|
21069
21093
|
pagefind: "^1.1.0"
|
|
21070
21094
|
};
|
|
21095
|
+
const onlyBuiltDependencies = ["sharp", "esbuild", "unrs-resolver"];
|
|
21096
|
+
if (database.type === "sqlite") {
|
|
21097
|
+
onlyBuiltDependencies.push("better-sqlite3");
|
|
21098
|
+
}
|
|
21071
21099
|
const pkg = {
|
|
21072
21100
|
name: projectName,
|
|
21073
21101
|
version: "0.1.0",
|
|
@@ -21098,7 +21126,10 @@ async function generatePackageJson(projectName, database, useYalc = false, proje
|
|
|
21098
21126
|
"types:generate": "nextly generate:types"
|
|
21099
21127
|
},
|
|
21100
21128
|
dependencies,
|
|
21101
|
-
devDependencies
|
|
21129
|
+
devDependencies,
|
|
21130
|
+
pnpm: {
|
|
21131
|
+
onlyBuiltDependencies
|
|
21132
|
+
}
|
|
21102
21133
|
};
|
|
21103
21134
|
return JSON.stringify(pkg, null, 2) + "\n";
|
|
21104
21135
|
}
|
|
@@ -21204,6 +21235,11 @@ async function copyTemplate(options) {
|
|
|
21204
21235
|
if (database.type === "sqlite") {
|
|
21205
21236
|
await import_fs_extra8.default.ensureDir(path14__default.default.join(targetDir, "data"));
|
|
21206
21237
|
}
|
|
21238
|
+
await import_fs_extra8.default.writeFile(
|
|
21239
|
+
path14__default.default.join(targetDir, "next.config.ts"),
|
|
21240
|
+
buildNextConfigTemplate(database),
|
|
21241
|
+
"utf-8"
|
|
21242
|
+
);
|
|
21207
21243
|
const placeholders = buildPlaceholderMap({ database, databaseUrl });
|
|
21208
21244
|
if (approach) {
|
|
21209
21245
|
placeholders["{{approach}}"] = approach;
|
|
@@ -24538,11 +24574,7 @@ function cwdProjectName(cwd) {
|
|
|
24538
24574
|
return basename;
|
|
24539
24575
|
}
|
|
24540
24576
|
async function createNextly(options = {}) {
|
|
24541
|
-
const {
|
|
24542
|
-
defaults = false,
|
|
24543
|
-
skipInstall = false,
|
|
24544
|
-
useYalc = false
|
|
24545
|
-
} = options;
|
|
24577
|
+
const { defaults = false, skipInstall = false, useYalc = false } = options;
|
|
24546
24578
|
let installInCwd = options.installInCwd ?? false;
|
|
24547
24579
|
let { cwd = process.cwd() } = options;
|
|
24548
24580
|
let isFreshProject = false;
|
|
@@ -24796,7 +24828,7 @@ async function createNextly(options = {}) {
|
|
|
24796
24828
|
await generateAdminPage(cwd, projectInfo);
|
|
24797
24829
|
await generateMediaRoutes(cwd, projectInfo);
|
|
24798
24830
|
await generateTypesDirectory(cwd, projectInfo);
|
|
24799
|
-
await patchNextConfig(cwd);
|
|
24831
|
+
await patchNextConfig(cwd, database);
|
|
24800
24832
|
}
|
|
24801
24833
|
const envDatabase = databaseUrl ? { ...database, connectionUrl: databaseUrl, envExample: databaseUrl } : database;
|
|
24802
24834
|
await generateEnv(cwd, envDatabase);
|