Skip to content

Commit

Permalink
feat: Add pages router
Browse files Browse the repository at this point in the history
  • Loading branch information
pawanpaudel93 committed Oct 22, 2023
1 parent b68d7aa commit bd9243e
Show file tree
Hide file tree
Showing 18 changed files with 215 additions and 714 deletions.
4 changes: 2 additions & 2 deletions cli/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const defaultOptions: CliResults = {
default: false,
language: "typescript",
importAlias: "@/",
appRouter: false,
appRouter: true,
},
};

Expand Down Expand Up @@ -90,7 +90,7 @@ export const runCli = async (): Promise<CliResults> => {
appRouter: () => {
return p.confirm({
message: "Would you like to use Next.js App Router?",
initialValue: false,
initialValue: true,
});
},
...(!cliResults.flags.noGit && {
Expand Down
10 changes: 4 additions & 6 deletions cli/src/helpers/createProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ export const createProject = async ({
language,
});

// Select necessary _app,index / layout,page files
// Remove pages/app depending upon appRouter
if (appRouter) {
// Replace next.config
// fs.copyFileSync(
// path.join(PKG_ROOT, "template/extras/config/next-config-appdir.mjs"),
// path.join(projectDir, "next.config.mjs")
// );
fs.rmSync(path.join(projectDir, "pages"), { recursive: true, force: true });
} else {
fs.rmSync(path.join(projectDir, "app"), { recursive: true, force: true });
}

return projectDir;
Expand Down
12 changes: 12 additions & 0 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ const main = async () => {
pkgJson.packageManager = `${pkgManager}@${stdout.trim()}`;
}

if (language === "javascript" && pkgJson.devDependencies !== undefined) {
pkgJson.devDependencies = Object.keys(pkgJson.devDependencies)
.filter((key) => !key.startsWith("@types/"))
.reduce(
(result, key) => {
result[key] = pkgJson.devDependencies?.[key];
return result;
},
{} as Partial<Record<string, string>>
);
}

fs.writeJSONSync(path.join(projectDir, "package.json"), pkgJson, {
spaces: 2,
});
Expand Down
4 changes: 2 additions & 2 deletions cli/template/next/common/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "app/globals.css",
"css": "styles/globals.css",
"baseColor": "slate",
"cssVariables": true
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cli/template/next/javascript/app/layout.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./globals.css";
import "@/styles/globals.css";

import { siteConfig } from "@/config/site";
import { fontSans } from "@/lib/fonts";
Expand Down
303 changes: 0 additions & 303 deletions cli/template/next/javascript/app/page.module.css

This file was deleted.

Loading

0 comments on commit bd9243e

Please sign in to comment.