create-next-pro-cli 0.1.13 → 0.1.14

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.
Files changed (65) hide show
  1. package/README.md +1 -0
  2. package/bin.ts +0 -0
  3. package/install.sh +1 -0
  4. package/package.json +6 -4
  5. package/src/index.ts +0 -67
  6. package/src/lib/addComponent.ts +0 -139
  7. package/src/lib/addPage.ts +0 -201
  8. package/src/lib/createProject.ts +0 -18
  9. package/src/lib/createProjectWithPrompt.ts +0 -79
  10. package/src/lib/rmPage.ts +0 -52
  11. package/src/lib/utils.test.ts +0 -23
  12. package/src/lib/utils.ts +0 -60
  13. package/src/scaffold-dev.ts +0 -89
  14. package/src/scaffold.ts +0 -86
  15. package/templates/Projects/default/src/app/[locale]/(public)/Login/page.tsx +0 -6
  16. package/templates/Projects/default/src/app/[locale]/(public)/Register/page.tsx +0 -6
  17. package/templates/Projects/default/src/app/[locale]/(public)/_home/loading.tsx +0 -5
  18. package/templates/Projects/default/src/app/[locale]/(public)/_home/page.tsx +0 -6
  19. package/templates/Projects/default/src/app/[locale]/(public)/layout.tsx +0 -9
  20. package/templates/Projects/default/src/app/[locale]/(user)/Dashboard/error.tsx +0 -38
  21. package/templates/Projects/default/src/app/[locale]/(user)/Dashboard/loading.tsx +0 -10
  22. package/templates/Projects/default/src/app/[locale]/(user)/Dashboard/page.tsx +0 -5
  23. package/templates/Projects/default/src/app/[locale]/(user)/Settings/loading.tsx +0 -17
  24. package/templates/Projects/default/src/app/[locale]/(user)/Settings/page.tsx +0 -6
  25. package/templates/Projects/default/src/app/[locale]/(user)/UserInfo/loading.tsx +0 -17
  26. package/templates/Projects/default/src/app/[locale]/(user)/UserInfo/page.tsx +0 -6
  27. package/templates/Projects/default/src/app/[locale]/(user)/layout.tsx +0 -9
  28. package/templates/Projects/default/src/app/[locale]/layout.tsx +0 -31
  29. package/templates/Projects/default/src/app/[locale]/loading.tsx +0 -14
  30. package/templates/Projects/default/src/app/[locale]/not-found.tsx +0 -22
  31. package/templates/Projects/default/src/app/[locale]/page.tsx +0 -6
  32. package/templates/Projects/default/src/app/api/auth/[...nextauth]/route.ts +0 -62
  33. package/templates/Projects/default/src/app/api/auth/post-login/route.ts +0 -26
  34. package/templates/Projects/default/src/app/favicon.ico +0 -0
  35. package/templates/Projects/default/src/app/layout.tsx +0 -11
  36. package/templates/Projects/default/src/app/not-found.tsx +0 -17
  37. package/templates/Projects/default/src/app/page.tsx +0 -6
  38. package/templates/Projects/default/src/app/sitemap.ts +0 -27
  39. package/templates/Projects/default/src/app/styles/globals.css +0 -305
  40. package/templates/Projects/default/src/auth.config.ts +0 -0
  41. package/templates/Projects/default/src/config.ts +0 -4
  42. package/templates/Projects/default/src/lib/auth/disconnect.ts +0 -11
  43. package/templates/Projects/default/src/lib/auth/isConnected.ts +0 -18
  44. package/templates/Projects/default/src/lib/i18n/navigation.ts +0 -19
  45. package/templates/Projects/default/src/lib/i18n/request.ts +0 -31
  46. package/templates/Projects/default/src/lib/i18n/routing.ts +0 -20
  47. package/templates/Projects/default/src/lib/utils.ts +0 -6
  48. package/templates/Projects/default/src/ui/Dashboard/LogoutButton.tsx +0 -27
  49. package/templates/Projects/default/src/ui/Dashboard/StatsCard.tsx +0 -14
  50. package/templates/Projects/default/src/ui/Dashboard/WelcomeCard.tsx +0 -10
  51. package/templates/Projects/default/src/ui/Dashboard/page-ui.tsx +0 -23
  52. package/templates/Projects/default/src/ui/Login/page-ui.tsx +0 -22
  53. package/templates/Projects/default/src/ui/Register/page-ui.tsx +0 -26
  54. package/templates/Projects/default/src/ui/Settings/page-ui.tsx +0 -17
  55. package/templates/Projects/default/src/ui/UserInfo/page-ui.tsx +0 -17
  56. package/templates/Projects/default/src/ui/_global/BackButton.tsx +0 -17
  57. package/templates/Projects/default/src/ui/_global/Button.tsx +0 -75
  58. package/templates/Projects/default/src/ui/_global/GlobalHeader.tsx +0 -55
  59. package/templates/Projects/default/src/ui/_global/GlobalMain.tsx +0 -15
  60. package/templates/Projects/default/src/ui/_global/Loading.tsx +0 -13
  61. package/templates/Projects/default/src/ui/_global/LocaleSwitcher.tsx +0 -38
  62. package/templates/Projects/default/src/ui/_global/PublicNav.tsx +0 -91
  63. package/templates/Projects/default/src/ui/_global/ThemeToggle.tsx +0 -53
  64. package/templates/Projects/default/src/ui/_global/UserNav.tsx +0 -35
  65. package/templates/Projects/default/src/ui/_home/page-ui.tsx +0 -27
@@ -1,89 +0,0 @@
1
- // src/scaffold-dev.ts
2
-
3
- import { mkdir, writeFile } from "node:fs/promises";
4
- import { join } from "node:path";
5
-
6
- /**
7
- * Experimental tool for generating a Next.js project template structure.
8
- * This script is under development and will evolve to allow creation of new project templates in the future.
9
- *
10
- * @param options Object containing the project name
11
- */
12
- async function scaffoldTemplate(options: { projectName: string }) {
13
- const base = options.projectName;
14
- console.log(`\nšŸ“ Creating template directory: ${base}`);
15
-
16
- // List of folders to create for the template
17
- const folders = [
18
- "app/[locale]/_main",
19
- "app/[locale]/dashboard",
20
- "lib/i18n",
21
- "messages/en",
22
- "messages/fr",
23
- "public",
24
- "styles",
25
- ];
26
-
27
- // List of files to create for the template
28
- const files = [
29
- "app/[locale]/layout.tsx",
30
- "app/[locale]/page.tsx",
31
- "app/[locale]/not-found.tsx",
32
- "app/[locale]/error.tsx",
33
-
34
- "app/[locale]/_main/page.tsx",
35
- "app/[locale]/_main/layout.tsx",
36
- "app/[locale]/_main/loading.tsx",
37
- "app/[locale]/_main/template.tsx",
38
-
39
- "app/[locale]/dashboard/page.tsx",
40
- "app/[locale]/dashboard/layout.tsx",
41
- "app/[locale]/dashboard/loading.tsx",
42
- "app/[locale]/dashboard/template.tsx",
43
-
44
- "lib/i18n/routing.ts",
45
- "lib/i18n/request.ts",
46
- "lib/i18n/navigation.ts",
47
-
48
- "messages/en/home.json",
49
- "messages/en/dashboard.json",
50
- "messages/en/navbar.json",
51
-
52
- "messages/fr/home.json",
53
- "messages/fr/dashboard.json",
54
- "messages/fr/navbar.json",
55
-
56
- "styles/globals.css",
57
- "middleware.ts",
58
- "next.config.ts",
59
- "postcss.config.mjs",
60
- "eslint.config.mjs",
61
- "tailwind.config.ts",
62
- "tsconfig.json",
63
- "next-env.d.ts",
64
- "package.json",
65
- "README.md",
66
- ];
67
-
68
- // Create all folders
69
- for (const folder of folders) {
70
- await mkdir(join(base, folder), { recursive: true });
71
- }
72
-
73
- // Create all files with a placeholder comment
74
- for (const file of files) {
75
- const fullPath = join(base, file);
76
- await writeFile(fullPath, `// ${file}`);
77
- }
78
-
79
- console.log("āœ… Full template generated.");
80
- }
81
-
82
- // Direct execution if this file is run as a script
83
- if (require.main === module) {
84
- const projectName = process.argv[2] || "template-next-app";
85
- scaffoldTemplate({ projectName }).catch((err) => {
86
- console.error("Error during template generation:", err);
87
- process.exit(1);
88
- });
89
- }
package/src/scaffold.ts DELETED
@@ -1,86 +0,0 @@
1
- // src/scaffold.ts
2
-
3
- import { cp, mkdir, rm, writeFile, readFile } from "node:fs/promises";
4
- import { join } from "node:path";
5
- import { existsSync } from "node:fs";
6
-
7
- /**
8
- * Options for scaffolding a Next.js project.
9
- */
10
- interface ScaffoldOptions {
11
- projectName: string;
12
- useTypescript: boolean;
13
- useEslint: boolean;
14
- useTailwind: boolean;
15
- useSrcDir: boolean;
16
- useTurbopack: boolean;
17
- useI18n: boolean;
18
- customAlias: boolean;
19
- importAlias: string;
20
- force?: boolean;
21
- }
22
-
23
- /**
24
- * Scaffold a new Next.js project based on provided options.
25
- *
26
- * - Copies the default template to the target directory
27
- * - Removes the target directory if it exists and --force is set
28
- * - Optionally customizes the structure in future (e.g. remove unused files)
29
- *
30
- * @param options ScaffoldOptions for the project
31
- */
32
- export async function scaffoldProject(options: ScaffoldOptions) {
33
- const targetPath = join(process.cwd(), options.projectName);
34
- const templatePath = join(
35
- import.meta.dir,
36
- "..",
37
- "templates",
38
- "Projects",
39
- "default",
40
- );
41
-
42
- // Check if target directory exists
43
- if (existsSync(targetPath)) {
44
- if (options.force) {
45
- console.warn("āš ļø Target directory already exists, removing...");
46
- await rm(targetPath, { recursive: true, force: true });
47
- } else {
48
- console.error(
49
- "āŒ Target directory already exists. Use --force to overwrite.",
50
- );
51
- process.exit(1);
52
- }
53
- }
54
-
55
- try {
56
- console.log("šŸ“ Creating project directory...");
57
- await mkdir(targetPath, { recursive: true });
58
-
59
- console.log("šŸ“¦ Copying files from template...");
60
- await cp(templatePath, targetPath, { recursive: true });
61
-
62
- // Apply configuration: add dependencies or files based on prompt choices
63
- const pkgPath = join(targetPath, "package.json");
64
- if (existsSync(pkgPath)) {
65
- const pkg = JSON.parse(await readFile(pkgPath, "utf-8"));
66
- pkg.dependencies = pkg.dependencies || {};
67
- if (options.useI18n) {
68
- pkg.dependencies["next-intl"] =
69
- pkg.dependencies["next-intl"] || "^4.3.5";
70
- }
71
- await writeFile(pkgPath, JSON.stringify(pkg, null, 2));
72
- }
73
-
74
- // Write CLI configuration to project root
75
- await writeFile(
76
- join(targetPath, "cnp.config.json"),
77
- JSON.stringify(options, null, 2),
78
- );
79
-
80
- console.log("āœ… Project scaffolded successfully!");
81
- console.log(`āž”ļø cd ${options.projectName} && bun install && bun dev`);
82
- } catch (err) {
83
- console.error("āŒ Error during scaffolding:", err);
84
- process.exit(1);
85
- }
86
- }
@@ -1,6 +0,0 @@
1
- // src/app/[locale]/(public)/Login/page.tsx
2
- import LoginPageUI from "@/ui/Login/page-ui";
3
-
4
- export default function LoginPage() {
5
- return <LoginPageUI />;
6
- }
@@ -1,6 +0,0 @@
1
- // src/app/[locale]/(public)/Register/page.tsx
2
- import RegisterPageUI from "@/ui/Register/page-ui";
3
-
4
- export default function RegisterPage() {
5
- return <RegisterPageUI />;
6
- }
@@ -1,5 +0,0 @@
1
- // app/[locale]/_main/loading.tsx
2
- import LoadingUI from "@/ui/_global/Loading";
3
- export default function Loading() {
4
- return <LoadingUI />;
5
- }
@@ -1,6 +0,0 @@
1
- // src/app/[locale]/(public)/_home/page.tsx
2
- import HomePageUI from "@/ui/_home/page-ui";
3
-
4
- export default function HomePage() {
5
- return <HomePageUI />;
6
- }
@@ -1,9 +0,0 @@
1
- import React from "react";
2
-
3
- export default function PublicLayout({
4
- children,
5
- }: {
6
- children: React.ReactNode;
7
- }) {
8
- return children;
9
- }
@@ -1,38 +0,0 @@
1
- // app/[locale]/error.tsx
2
- "use client"; // Error boundaries must be Client Components
3
-
4
- import { useEffect } from "react";
5
-
6
- export default function Error({
7
- error,
8
- reset,
9
- }: {
10
- error: Error & { digest?: string };
11
- reset: () => void;
12
- }) {
13
- useEffect(() => {
14
- // Log the error to an error reporting service
15
- console.error(error);
16
- }, [error]);
17
-
18
- return (
19
- <div>
20
- <h2>Something went wrong!</h2>
21
- <button
22
- onClick={
23
- // Attempt to recover by trying to re-render the segment
24
- () => reset()
25
- }
26
- >
27
- Try again
28
- </button>
29
- </div>
30
- );
31
- }
32
- // This page is used to handle errors in the application
33
- // You can customize this page to display a user-friendly error message
34
- // or redirect to a different page if needed
35
- // This is part of the Next.js app directory structure and will be automatically used by Next.js
36
- // when an error occurs in the application
37
- // Make sure to handle errors gracefully to improve user experience
38
- // You can also log errors or send them to an error tracking service
@@ -1,10 +0,0 @@
1
- // app/[locale]/dashboard/loading.tsx
2
- "use client";
3
-
4
- export default function Loading() {
5
- return (
6
- <div className="flex flex-col flex-1 items-center justify-center">
7
- <p className="text-gray-500">Loading dashboard...</p>
8
- </div>
9
- );
10
- }
@@ -1,5 +0,0 @@
1
- import Dashboard from "@/ui/Dashboard/page-ui";
2
-
3
- export default function DashboardPage() {
4
- return <Dashboard />;
5
- }
@@ -1,17 +0,0 @@
1
- // app/[locale]/dashboard/loading.tsx
2
- "use client";
3
-
4
- export default function Loading() {
5
- return (
6
- <div className="flex flex-col flex-1 items-center justify-center">
7
- <p className="text-gray-500">Loading user info...</p>
8
- </div>
9
- );
10
- }
11
- // This component is used to show a loading state while the dashboard is being prepared
12
- // You can customize it with a spinner, skeletons, or any loading UI you prefer
13
- // It will be displayed when the dashboard is loading, for example during data fetching or component rendering
14
- // This is useful for providing feedback to users that something is happening in the background
15
- // You can also use this to implement a more complex loading state with animations or placeholders
16
- // Make sure to keep it lightweight to avoid blocking the main thread
17
- // This component is part of the Next.js app directory structure and will be automatically used by Next.js
@@ -1,6 +0,0 @@
1
- "use client";
2
- import SettingsPageUI from "@/ui/Settings/page-ui";
3
-
4
- export default function UserInfoPage() {
5
- return <SettingsPageUI />;
6
- }
@@ -1,17 +0,0 @@
1
- // app/[locale]/dashboard/loading.tsx
2
- "use client";
3
-
4
- export default function Loading() {
5
- return (
6
- <div className="flex flex-col flex-1 items-center justify-center">
7
- <p className="text-gray-500">Loading user info...</p>
8
- </div>
9
- );
10
- }
11
- // This component is used to show a loading state while the dashboard is being prepared
12
- // You can customize it with a spinner, skeletons, or any loading UI you prefer
13
- // It will be displayed when the dashboard is loading, for example during data fetching or component rendering
14
- // This is useful for providing feedback to users that something is happening in the background
15
- // You can also use this to implement a more complex loading state with animations or placeholders
16
- // Make sure to keep it lightweight to avoid blocking the main thread
17
- // This component is part of the Next.js app directory structure and will be automatically used by Next.js
@@ -1,6 +0,0 @@
1
- "use client";
2
- import UserInfoPageUI from "@/ui/UserInfo/page-ui";
3
-
4
- export default function UserInfoPage() {
5
- return <UserInfoPageUI />;
6
- }
@@ -1,9 +0,0 @@
1
- // app/[locale]/(user)/layout.tsx
2
-
3
- export default function UserLayout({
4
- children,
5
- }: {
6
- children: React.ReactNode;
7
- }) {
8
- return children;
9
- }
@@ -1,31 +0,0 @@
1
- // app/[locale]/layout.tsx
2
- import { NextIntlClientProvider } from "next-intl";
3
- import { setRequestLocale } from "next-intl/server";
4
- import React from "react";
5
- import "@/app/styles/globals.css"; // Import global styles
6
- import GlobalHeader from "@/ui/_global/GlobalHeader";
7
- import GlobalMain from "@/ui/_global/GlobalMain";
8
- import { isConnected } from "@/lib/auth/isConnected";
9
-
10
- export default async function LocaleLayout({
11
- children,
12
- params,
13
- }: {
14
- children: React.ReactNode;
15
- params: Promise<{ locale: string }>;
16
- }) {
17
- const { locale } = await params;
18
- setRequestLocale(locale);
19
- const isConnectedInitial = await isConnected();
20
-
21
- return (
22
- <html lang={locale}>
23
- <body>
24
- <NextIntlClientProvider>
25
- <GlobalHeader isConnectedInitial={isConnectedInitial} />
26
- <GlobalMain>{children}</GlobalMain>
27
- </NextIntlClientProvider>
28
- </body>
29
- </html>
30
- );
31
- }
@@ -1,14 +0,0 @@
1
- // app/[locale]/dashboard/loading.tsx
2
-
3
- import LoadingUI from "@/ui/_global/Loading";
4
-
5
- export default function Loading() {
6
- return <LoadingUI />;
7
- }
8
- // This component is used to show a loading state while the dashboard is being prepared
9
- // You can customize it with a spinner, skeletons, or any loading UI you prefer
10
- // It will be displayed when the dashboard is loading, for example during data fetching or component rendering
11
- // This is useful for providing feedback to users that something is happening in the background
12
- // You can also use this to implement a more complex loading state with animations or placeholders
13
- // Make sure to keep it lightweight to avoid blocking the main thread
14
- // This component is part of the Next.js app directory structure and will be automatically used by Next.js
@@ -1,22 +0,0 @@
1
- // app/[locale]/not-found.tsx
2
- import { Link } from "@/lib/i18n/navigation";
3
-
4
- export default function NotFound() {
5
- return (
6
- <div>
7
- <h2>Not Found</h2>
8
- <p>Could not find requested resource</p>
9
- <Link href="/">Return Home</Link>
10
- </div>
11
- );
12
- }
13
- // This page is used to handle 404 errors in the application
14
- // You can customize this page to display a user-friendly error message
15
- // or redirect to a different page if needed
16
- // This is part of the Next.js app directory structure and will be automatically used by Next.js
17
- // when a requested page is not found
18
- // Make sure to handle 404 errors gracefully to improve user experience
19
- // You can also log errors or send them to an error tracking service
20
- // This component can be styled with CSS or Tailwind CSS to match your application's design
21
- // You can also add additional links or actions for the user to take, such as searching or navigating to other parts of the site
22
- // This component is lightweight and does not block the main thread
@@ -1,6 +0,0 @@
1
- import React from "react";
2
- import HomePage from "@/app/[locale]/(public)/_home/page";
3
-
4
- export default async function FallbackPage() {
5
- return <HomePage />;
6
- }
@@ -1,62 +0,0 @@
1
- import NextAuth from "next-auth";
2
- import type {
3
- NextAuthOptions,
4
- Session,
5
- User,
6
- Account,
7
- Profile,
8
- } from "next-auth";
9
- import GoogleProvider from "next-auth/providers/google";
10
- import type { JWT } from "next-auth/jwt";
11
-
12
- const authOptions: NextAuthOptions = {
13
- providers: [
14
- GoogleProvider({
15
- clientId: process.env.GOOGLE_CLIENT_ID!,
16
- clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
17
- }),
18
- ],
19
- callbacks: {
20
- async jwt({ token, user }: { token: JWT; user?: User }) {
21
- if (user) {
22
- token.id = user.id;
23
- token.email = user.email;
24
- token.name = user.name;
25
- }
26
- console.log("JWT Callback:", token);
27
-
28
- return token;
29
- },
30
- async session({ session, token }: { session: Session; token: JWT }) {
31
- if (session.user) {
32
- session.user.email = token.email;
33
- session.user.name = token.name;
34
- }
35
- return session;
36
- },
37
- async signIn({
38
- user,
39
- account,
40
- profile,
41
- email,
42
- credentials,
43
- }: {
44
- user: User;
45
- account: Account | null;
46
- profile?: Profile;
47
- email?: string | { verificationRequest?: boolean };
48
- credentials?: Record<string, unknown>;
49
- }) {
50
- return true;
51
- },
52
- async redirect({ url, baseUrl }: { url: string; baseUrl: string }) {
53
- const customCallbackRoute = "/api/auth/post-login";
54
-
55
- return baseUrl + customCallbackRoute;
56
- },
57
- },
58
- };
59
-
60
- const handler = NextAuth(authOptions);
61
-
62
- export { handler as GET, handler as POST };
@@ -1,26 +0,0 @@
1
- import { getToken } from "next-auth/jwt";
2
- import { sign } from "jsonwebtoken";
3
- import { NextResponse, NextRequest } from "next/server";
4
- import { redirect } from "@/lib/i18n/navigation";
5
-
6
- export async function GET(req: NextRequest) {
7
- const token = await getToken({ req, secret: process.env.NEXTAUTH_SECRET });
8
- if (token) {
9
- const appJwt = sign(
10
- { id: token.id, email: token.email, name: token.name },
11
- process.env.APP_JWT_SECRET!,
12
- { expiresIn: "7d" }
13
- );
14
- const res = NextResponse.redirect(req.nextUrl.origin + "/");
15
- res.cookies.set("access_token", appJwt, {
16
- httpOnly: true,
17
- secure: process.env.NODE_ENV === "production",
18
- sameSite: "strict",
19
- path: "/",
20
- maxAge: 60 * 60 * 24 * 7,
21
- });
22
- return res;
23
- }
24
- // Si pas de token, redirige vers login
25
- return redirect({ href: "/login", locale: "en" });
26
- }
@@ -1,11 +0,0 @@
1
- import { ReactNode } from "react";
2
-
3
- type Props = {
4
- children: ReactNode;
5
- };
6
-
7
- // Since we have a `not-found.tsx` page on the root, a layout file
8
- // is required, even if it's just passing children through.
9
- export default function RootLayout({ children }: Props) {
10
- return children;
11
- }
@@ -1,17 +0,0 @@
1
- "use client";
2
-
3
- import Error from "next/error";
4
-
5
- // This page renders when a route like `/unknown.txt` is requested.
6
- // In this case, the layout at `app/[locale]/layout.tsx` receives
7
- // an invalid value as the `[locale]` param and calls `notFound()`.
8
-
9
- export default function GlobalNotFound() {
10
- return (
11
- <html lang="en">
12
- <body>
13
- <Error statusCode={404} />;
14
- </body>
15
- </html>
16
- );
17
- }
@@ -1,6 +0,0 @@
1
- import { redirect } from "next/navigation";
2
-
3
- // This page only renders when the app is built statically (output: 'export')
4
- export default function RootPage() {
5
- redirect("/en");
6
- }
@@ -1,27 +0,0 @@
1
- import { MetadataRoute } from "next";
2
- import { Locale } from "next-intl";
3
- import { host } from "@/config";
4
- import { routing } from "@/lib/i18n/routing";
5
- import { getPathname } from "@/lib/i18n/navigation";
6
-
7
- export default function sitemap(): MetadataRoute.Sitemap {
8
- return [...getEntries("/"), ...getEntries("/pathnames")];
9
- }
10
-
11
- type Href = Parameters<typeof getPathname>[0]["href"];
12
-
13
- function getEntries(href: Href) {
14
- return routing.locales.map((locale) => ({
15
- url: getUrl(href, locale),
16
- alternates: {
17
- languages: Object.fromEntries(
18
- routing.locales.map((cur) => [cur, getUrl(href, cur)])
19
- ),
20
- },
21
- }));
22
- }
23
-
24
- function getUrl(href: Href, locale: Locale) {
25
- const pathname = getPathname({ locale, href });
26
- return host + pathname;
27
- }