create-nextly-app 0.0.2-alpha.12 → 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/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 SERVER_EXTERNAL_PACKAGES = [
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
- async function patchNextConfig(cwd) {
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(SERVER_EXTERNAL_PACKAGES, null, 4).replace(/\n/g, "\n ");
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(
@@ -21211,6 +21235,11 @@ async function copyTemplate(options) {
21211
21235
  if (database.type === "sqlite") {
21212
21236
  await import_fs_extra8.default.ensureDir(path14__default.default.join(targetDir, "data"));
21213
21237
  }
21238
+ await import_fs_extra8.default.writeFile(
21239
+ path14__default.default.join(targetDir, "next.config.ts"),
21240
+ buildNextConfigTemplate(database),
21241
+ "utf-8"
21242
+ );
21214
21243
  const placeholders = buildPlaceholderMap({ database, databaseUrl });
21215
21244
  if (approach) {
21216
21245
  placeholders["{{approach}}"] = approach;
@@ -24545,11 +24574,7 @@ function cwdProjectName(cwd) {
24545
24574
  return basename;
24546
24575
  }
24547
24576
  async function createNextly(options = {}) {
24548
- const {
24549
- defaults = false,
24550
- skipInstall = false,
24551
- useYalc = false
24552
- } = options;
24577
+ const { defaults = false, skipInstall = false, useYalc = false } = options;
24553
24578
  let installInCwd = options.installInCwd ?? false;
24554
24579
  let { cwd = process.cwd() } = options;
24555
24580
  let isFreshProject = false;
@@ -24803,7 +24828,7 @@ async function createNextly(options = {}) {
24803
24828
  await generateAdminPage(cwd, projectInfo);
24804
24829
  await generateMediaRoutes(cwd, projectInfo);
24805
24830
  await generateTypesDirectory(cwd, projectInfo);
24806
- await patchNextConfig(cwd);
24831
+ await patchNextConfig(cwd, database);
24807
24832
  }
24808
24833
  const envDatabase = databaseUrl ? { ...database, connectionUrl: databaseUrl, envExample: databaseUrl } : database;
24809
24834
  await generateEnv(cwd, envDatabase);