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/cli.cjs CHANGED
@@ -6259,7 +6259,7 @@ var require_package = __commonJS({
6259
6259
  "package.json"(exports$1, module) {
6260
6260
  module.exports = {
6261
6261
  name: "create-nextly-app",
6262
- version: "0.0.2-alpha.12",
6262
+ version: "0.0.2-alpha.13",
6263
6263
  description: "CLI to scaffold Nextly in your Next.js project",
6264
6264
  license: "MIT",
6265
6265
  type: "module",
@@ -21811,22 +21811,42 @@ async function generateMediaRoutes(cwd, projectInfo) {
21811
21811
 
21812
21812
  // src/generators/next-config.ts
21813
21813
  var import_fs_extra5 = __toESM(require_lib());
21814
- var SERVER_EXTERNAL_PACKAGES = [
21814
+ var COMMON_SERVER_EXTERNAL_PACKAGES = [
21815
21815
  "nextly",
21816
21816
  "@nextlyhq/adapter-drizzle",
21817
- "@nextlyhq/adapter-postgres",
21818
- "@nextlyhq/adapter-mysql",
21819
- "@nextlyhq/adapter-sqlite",
21820
21817
  "drizzle-orm",
21821
21818
  "drizzle-kit",
21822
- "pg",
21823
- "mysql2",
21824
- "better-sqlite3",
21825
21819
  "bcryptjs",
21826
21820
  "sharp",
21827
21821
  "esbuild"
21828
21822
  ];
21829
- async function patchNextConfig(cwd) {
21823
+ var DATABASE_SERVER_EXTERNAL_PACKAGES = {
21824
+ postgresql: ["@nextlyhq/adapter-postgres", "pg"],
21825
+ mysql: ["@nextlyhq/adapter-mysql", "mysql2"],
21826
+ sqlite: ["@nextlyhq/adapter-sqlite", "better-sqlite3"]
21827
+ };
21828
+ function getServerExternalPackages(database) {
21829
+ return [
21830
+ ...COMMON_SERVER_EXTERNAL_PACKAGES,
21831
+ ...DATABASE_SERVER_EXTERNAL_PACKAGES[database.type]
21832
+ ];
21833
+ }
21834
+ function buildNextConfigTemplate(database) {
21835
+ const packagesArray = JSON.stringify(
21836
+ getServerExternalPackages(database),
21837
+ null,
21838
+ 2
21839
+ ).replace(/\n/g, "\n ");
21840
+ return `import type { NextConfig } from "next";
21841
+
21842
+ const nextConfig: NextConfig = {
21843
+ serverExternalPackages: ${packagesArray},
21844
+ };
21845
+
21846
+ export default nextConfig;
21847
+ `;
21848
+ }
21849
+ async function patchNextConfig(cwd, database) {
21830
21850
  const candidates = ["next.config.ts", "next.config.mjs", "next.config.js"];
21831
21851
  let configPath = null;
21832
21852
  for (const name of candidates) {
@@ -21843,7 +21863,11 @@ async function patchNextConfig(cwd) {
21843
21863
  if (content.includes("serverExternalPackages")) {
21844
21864
  return;
21845
21865
  }
21846
- const packagesArray = JSON.stringify(SERVER_EXTERNAL_PACKAGES, null, 4).replace(/\n/g, "\n ");
21866
+ const packagesArray = JSON.stringify(
21867
+ getServerExternalPackages(database),
21868
+ null,
21869
+ 2
21870
+ ).replace(/\n/g, "\n ");
21847
21871
  const configObjectPattern = /(const\s+\w+\s*(?::\s*NextConfig\s*)?=\s*\{)/;
21848
21872
  if (configObjectPattern.test(content)) {
21849
21873
  const patched = content.replace(
@@ -28756,6 +28780,11 @@ async function copyTemplate(options) {
28756
28780
  if (database.type === "sqlite") {
28757
28781
  await import_fs_extra8.default.ensureDir(path__default.default.join(targetDir, "data"));
28758
28782
  }
28783
+ await import_fs_extra8.default.writeFile(
28784
+ path__default.default.join(targetDir, "next.config.ts"),
28785
+ buildNextConfigTemplate(database),
28786
+ "utf-8"
28787
+ );
28759
28788
  const placeholders = buildPlaceholderMap({ database, databaseUrl });
28760
28789
  if (approach) {
28761
28790
  placeholders["{{approach}}"] = approach;
@@ -32065,11 +32094,7 @@ function cwdProjectName(cwd) {
32065
32094
  return basename;
32066
32095
  }
32067
32096
  async function createNextly(options = {}) {
32068
- const {
32069
- defaults = false,
32070
- skipInstall = false,
32071
- useYalc = false
32072
- } = options;
32097
+ const { defaults = false, skipInstall = false, useYalc = false } = options;
32073
32098
  let installInCwd = options.installInCwd ?? false;
32074
32099
  let { cwd = process.cwd() } = options;
32075
32100
  let isFreshProject = false;
@@ -32337,7 +32362,7 @@ async function createNextly(options = {}) {
32337
32362
  await generateAdminPage(cwd, projectInfo);
32338
32363
  await generateMediaRoutes(cwd, projectInfo);
32339
32364
  await generateTypesDirectory(cwd, projectInfo);
32340
- await patchNextConfig(cwd);
32365
+ await patchNextConfig(cwd, database);
32341
32366
  }
32342
32367
  const envDatabase = databaseUrl ? { ...database, connectionUrl: databaseUrl, envExample: databaseUrl } : database;
32343
32368
  await generateEnv(cwd, envDatabase);