create-next-pro-cli 0.1.14 → 0.1.16

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 (64) hide show
  1. package/README.md +3 -2
  2. package/create-next-pro-completion.sh +9 -1
  3. package/dist/{bin.js → bin.bun.js} +124 -9
  4. package/dist/bin.node.js +681 -0
  5. package/dist/bin.node.js.map +1 -0
  6. package/dist/create-next-pro +9 -0
  7. package/package.json +24 -8
  8. package/templates/Projects/default/README.md +36 -0
  9. package/templates/Projects/default/src/app/[locale]/(public)/Login/page.tsx +6 -0
  10. package/templates/Projects/default/src/app/[locale]/(public)/Register/page.tsx +6 -0
  11. package/templates/Projects/default/src/app/[locale]/(public)/_home/loading.tsx +5 -0
  12. package/templates/Projects/default/src/app/[locale]/(public)/_home/page.tsx +6 -0
  13. package/templates/Projects/default/src/app/[locale]/(public)/layout.tsx +9 -0
  14. package/templates/Projects/default/src/app/[locale]/(user)/Dashboard/error.tsx +38 -0
  15. package/templates/Projects/default/src/app/[locale]/(user)/Dashboard/loading.tsx +10 -0
  16. package/templates/Projects/default/src/app/[locale]/(user)/Dashboard/page.tsx +5 -0
  17. package/templates/Projects/default/src/app/[locale]/(user)/Settings/loading.tsx +17 -0
  18. package/templates/Projects/default/src/app/[locale]/(user)/Settings/page.tsx +6 -0
  19. package/templates/Projects/default/src/app/[locale]/(user)/UserInfo/loading.tsx +17 -0
  20. package/templates/Projects/default/src/app/[locale]/(user)/UserInfo/page.tsx +6 -0
  21. package/templates/Projects/default/src/app/[locale]/(user)/layout.tsx +9 -0
  22. package/templates/Projects/default/src/app/[locale]/layout.tsx +31 -0
  23. package/templates/Projects/default/src/app/[locale]/loading.tsx +14 -0
  24. package/templates/Projects/default/src/app/[locale]/not-found.tsx +22 -0
  25. package/templates/Projects/default/src/app/[locale]/page.tsx +6 -0
  26. package/templates/Projects/default/src/app/api/auth/[...nextauth]/route.ts +62 -0
  27. package/templates/Projects/default/src/app/api/auth/post-login/route.ts +26 -0
  28. package/templates/Projects/default/src/app/favicon.ico +0 -0
  29. package/templates/Projects/default/src/app/layout.tsx +11 -0
  30. package/templates/Projects/default/src/app/not-found.tsx +17 -0
  31. package/templates/Projects/default/src/app/page.tsx +6 -0
  32. package/templates/Projects/default/src/app/sitemap.ts +27 -0
  33. package/templates/Projects/default/src/app/styles/globals.css +305 -0
  34. package/templates/Projects/default/src/auth.config.ts +0 -0
  35. package/templates/Projects/default/src/config.ts +4 -0
  36. package/templates/Projects/default/src/lib/auth/disconnect.ts +11 -0
  37. package/templates/Projects/default/src/lib/auth/isConnected.ts +18 -0
  38. package/templates/Projects/default/src/lib/i18n/navigation.ts +19 -0
  39. package/templates/Projects/default/src/lib/i18n/request.ts +31 -0
  40. package/templates/Projects/default/src/lib/i18n/routing.ts +20 -0
  41. package/templates/Projects/default/src/lib/utils.ts +6 -0
  42. package/templates/Projects/default/src/ui/Dashboard/LogoutButton.tsx +27 -0
  43. package/templates/Projects/default/src/ui/Dashboard/StatsCard.tsx +14 -0
  44. package/templates/Projects/default/src/ui/Dashboard/WelcomeCard.tsx +10 -0
  45. package/templates/Projects/default/src/ui/Dashboard/page-ui.tsx +23 -0
  46. package/templates/Projects/default/src/ui/Login/page-ui.tsx +22 -0
  47. package/templates/Projects/default/src/ui/Register/page-ui.tsx +26 -0
  48. package/templates/Projects/default/src/ui/Settings/page-ui.tsx +17 -0
  49. package/templates/Projects/default/src/ui/UserInfo/page-ui.tsx +17 -0
  50. package/templates/Projects/default/src/ui/_global/BackButton.tsx +17 -0
  51. package/templates/Projects/default/src/ui/_global/Button.tsx +75 -0
  52. package/templates/Projects/default/src/ui/_global/GlobalHeader.tsx +55 -0
  53. package/templates/Projects/default/src/ui/_global/GlobalMain.tsx +15 -0
  54. package/templates/Projects/default/src/ui/_global/Loading.tsx +13 -0
  55. package/templates/Projects/default/src/ui/_global/LocaleSwitcher.tsx +38 -0
  56. package/templates/Projects/default/src/ui/_global/PublicNav.tsx +91 -0
  57. package/templates/Projects/default/src/ui/_global/ThemeToggle.tsx +53 -0
  58. package/templates/Projects/default/src/ui/_global/UserNav.tsx +35 -0
  59. package/templates/Projects/default/src/ui/_home/page-ui.tsx +27 -0
  60. package/.github/workflows/ci.yml +0 -38
  61. package/bin.ts +0 -3
  62. package/commitlint.config.cjs +0 -12
  63. package/install.sh +0 -74
  64. package/tsconfig.json +0 -27
@@ -0,0 +1,55 @@
1
+ "use client";
2
+ import Image from "next/image";
3
+ import UserNav from "@/ui/_global/UserNav";
4
+ import LocaleSwitcher from "@/ui/_global/LocaleSwitcher";
5
+ import PublicNav from "@/ui/_global/PublicNav";
6
+ import { useEffect, useState } from "react";
7
+ import { Link } from "@/lib/i18n/navigation";
8
+ import { isConnected } from "@/lib/auth/isConnected";
9
+
10
+ type GlobalHeaderProps = {
11
+ isConnectedInitial: boolean;
12
+ };
13
+
14
+ export default function GlobalHeader({
15
+ isConnectedInitial,
16
+ }: GlobalHeaderProps) {
17
+ const [isConnectedState, setIsConnectedState] = useState(isConnectedInitial);
18
+
19
+ // Vérification dynamique côté client (exemple via /api/me)
20
+ useEffect(() => {
21
+ async function checkConnection() {
22
+ setIsConnectedState(await isConnected());
23
+ }
24
+ checkConnection();
25
+ // Optionnel : timer pour rafraîchir périodiquement
26
+ // const interval = setInterval(checkConnection, 60000);
27
+ // return () => clearInterval(interval);
28
+ }, []);
29
+
30
+ return (
31
+ <header className="fixed top-0 w-full z-50 glass-effect border-b">
32
+ <div className="mx-auto flex h-16 max-w-6xl items-center justify-between px-6">
33
+ <Link href="/" className="">
34
+ <div className="flex items-center h-16">
35
+ <Image
36
+ src="/cnp-logo.svg"
37
+ alt="Logo"
38
+ width={63}
39
+ height={63}
40
+ className="mr-2"
41
+ />
42
+ <h1 className="text-lg font-semibold tracking-tight select-none">
43
+ Create Next Pro
44
+ </h1>
45
+ </div>
46
+ </Link>
47
+
48
+ {isConnectedState ? <UserNav /> : <PublicNav />}
49
+ <div className="flex items-center h-16">
50
+ <LocaleSwitcher />
51
+ </div>
52
+ </div>
53
+ </header>
54
+ );
55
+ }
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+
3
+ export default function GlobalMain({
4
+ children,
5
+ }: {
6
+ children: React.ReactNode;
7
+ }) {
8
+ return (
9
+ <main className="mt-0 min-h-screen bg-neutral-50 font-sans text-gray-900 flex flex-col">
10
+ <div className="flex-1 flex flex-col justify-center items-stretch mx-auto w-full px-6 self-stretch">
11
+ {children}
12
+ </div>
13
+ </main>
14
+ );
15
+ }
@@ -0,0 +1,13 @@
1
+ "use client"; // DO NOT FORGET , this is a client component.
2
+ import { useTranslations } from "next-intl";
3
+
4
+ const Loading = () => {
5
+ const t = useTranslations("_global_ui");
6
+ return (
7
+ <div className="rounded border bg-white p-6 shadow-sm">
8
+ <h2 className="text-lg font-semibold mb-2">{t("Loading.title")}</h2>
9
+ <p className="text-gray-600">{t("Loading.description")}</p>
10
+ </div>
11
+ );
12
+ };
13
+ export default Loading;
@@ -0,0 +1,38 @@
1
+ "use client"; // DO NOT FORGET , this is a client component.
2
+ import { useRouter, usePathname } from "next/navigation";
3
+ import { useParams } from "next/navigation";
4
+
5
+ const locales = [
6
+ { code: "fr", label: "Français" },
7
+ { code: "en", label: "English" },
8
+ ];
9
+
10
+ export default function LocaleSwitcher() {
11
+ const router = useRouter();
12
+ const pathname = usePathname();
13
+ const params = useParams();
14
+ const currentLocale = params?.locale || "fr";
15
+
16
+ const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
17
+ const newLocale = e.target.value;
18
+ if (newLocale === currentLocale) return;
19
+ // Replace locale in pathname
20
+ const newPath = pathname.replace(`/${currentLocale}`, `/${newLocale}`);
21
+ router.push(newPath);
22
+ };
23
+
24
+ return (
25
+ <select
26
+ className="ml-2 ring rounded px-2 py-1 text-sm dark:bg-gray-800 dark:text-gray-200"
27
+ value={currentLocale}
28
+ onChange={handleChange}
29
+ aria-label="Select language"
30
+ >
31
+ {locales.map((l) => (
32
+ <option key={l.code} value={l.code}>
33
+ {l.label}
34
+ </option>
35
+ ))}
36
+ </select>
37
+ );
38
+ }
@@ -0,0 +1,91 @@
1
+ "use client"; // DO NOT FORGET , this is a client component.
2
+ import { Link } from "@/lib/i18n/navigation";
3
+ import { useTranslations } from "next-intl";
4
+ import { useEffect, useState, useRef } from "react";
5
+ import { Button } from "@/ui/_global/Button";
6
+ import ThemeToggle from "@/ui/_global/ThemeToggle";
7
+ import { Menu, X } from "lucide-react";
8
+
9
+ const navLinks = [
10
+ { href: "/", labelKey: "public_nav.links.home" },
11
+ { href: "/Login", labelKey: "public_nav.links.login" },
12
+ { href: "/Register", labelKey: "public_nav.links.register" },
13
+ ];
14
+
15
+ const PublicNav = () => {
16
+ const t = useTranslations("_global_ui");
17
+ const [open, setOpen] = useState(false);
18
+ const menuRef = useRef<HTMLDivElement>(null);
19
+ useEffect(() => {
20
+ const handleClickOutside = (event: MouseEvent) => {
21
+ if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
22
+ setOpen(false);
23
+ }
24
+ };
25
+
26
+ if (open) {
27
+ document.addEventListener("mousedown", handleClickOutside);
28
+ }
29
+
30
+ return () => {
31
+ document.removeEventListener("mousedown", handleClickOutside);
32
+ };
33
+ }, [open]);
34
+
35
+ return (
36
+ <nav aria-label="Public navigation">
37
+ <div className="flex justify-between items-center h-16">
38
+ <ul className="flex gap-2 md:gap-4 hidden md:flex items-center space-x-4">
39
+ {navLinks.map((link) => (
40
+ <li key={link.href}>
41
+ <Link
42
+ href={link.href}
43
+ className="inline-block rounded px-3 py-1.5 text-sm font-medium dark:text-gray-400 light:text-gray-700 hover:text-blue-600 hover:bg-blue-50 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500"
44
+ >
45
+ {t(link.labelKey)}
46
+ </Link>
47
+ </li>
48
+ ))}
49
+ </ul>
50
+ <div className="flex items-center space-x-4">
51
+ <ThemeToggle />
52
+ </div>
53
+ <div className="md:hidden flex items-center">
54
+ <Button
55
+ variant="default"
56
+ onClick={() => setOpen((o) => !o)}
57
+ className="focus:outline-none"
58
+ aria-label="Menu"
59
+ >
60
+ {open ? <X className="h-7 w-7" /> : <Menu className="h-7 w-7" />}
61
+ </Button>
62
+ </div>
63
+ </div>
64
+
65
+ {open && (
66
+ <div className="fixed inset-0 z-40 md:hidden">
67
+ <div className="absolute inset-0 bg-black/40" aria-hidden="true" />
68
+ <div
69
+ ref={menuRef}
70
+ className="mobil-menu absolute top-4 left-1/2 -translate-x-1/2 flex flex-col gap-2 rounded-xl p-4 shadow-lg animate-fade-in z-50 w-11/12 max-w-xs"
71
+ >
72
+ <Link href="/Login" onClick={() => setOpen(false)}>
73
+ <Button
74
+ variant="ghost"
75
+ className="w-full text-white justify-center hover:text-blue-300 cursor-pointer glass-effect"
76
+ >
77
+ {t("public_nav.links.login")}
78
+ </Button>
79
+ </Link>
80
+ <Link href="/Register" onClick={() => setOpen(false)}>
81
+ <Button className="w-full bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 justify-center cursor-pointer">
82
+ {t("public_nav.links.register")}
83
+ </Button>
84
+ </Link>
85
+ </div>
86
+ </div>
87
+ )}
88
+ </nav>
89
+ );
90
+ };
91
+ export default PublicNav;
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ import { useEffect, useState } from "react";
3
+ import { Moon, Sun } from "lucide-react";
4
+ import { Button } from "./Button";
5
+
6
+ export default function ThemeToggle() {
7
+ const [isDark, setIsDark] = useState(false);
8
+
9
+ useEffect(() => {
10
+ // Initial state from html class
11
+ setIsDark(document.documentElement.classList.contains("dark"));
12
+ }, []);
13
+
14
+ const toggleTheme = () => {
15
+ const html = document.documentElement;
16
+ if (html.classList.contains("dark")) {
17
+ html.classList.add("light");
18
+ html.classList.remove("dark");
19
+ setIsDark(false);
20
+ localStorage.setItem("theme", "light");
21
+ } else {
22
+ html.classList.add("dark");
23
+ html.classList.remove("light");
24
+ setIsDark(true);
25
+ localStorage.setItem("theme", "dark");
26
+ }
27
+ };
28
+
29
+ useEffect(() => {
30
+ // On mount, set theme from localStorage
31
+ const theme = localStorage.getItem("theme");
32
+ if (theme === "dark") {
33
+ document.documentElement.classList.add("dark");
34
+ document.documentElement.classList.remove("light");
35
+ setIsDark(true);
36
+ } else if (theme === "light") {
37
+ document.documentElement.classList.add("light");
38
+ document.documentElement.classList.remove("dark");
39
+ setIsDark(false);
40
+ }
41
+ }, []);
42
+
43
+ return (
44
+ <Button
45
+ onClick={toggleTheme}
46
+ className="ml-2 p-2 rounded-full hover:bg-white/10 transition-colors "
47
+ aria-label="Toggle theme"
48
+ type="button"
49
+ >
50
+ {isDark ? <Sun className="h-5 w-5" /> : <Moon className="h-5 w-5" />}
51
+ </Button>
52
+ );
53
+ }
@@ -0,0 +1,35 @@
1
+ "use client"; // DO NOT FORGET , this is a client component.
2
+ import { Link } from "@/lib/i18n/navigation";
3
+ import { useTranslations } from "next-intl";
4
+ import LogoutButton from "../Dashboard/LogoutButton";
5
+
6
+ const navLinks = [
7
+ { href: "/Dashboard", labelKey: "user_nav.links.dashboard" },
8
+ { href: "/Settings", labelKey: "user_nav.links.settings" },
9
+ { href: "/UserInfo", labelKey: "user_nav.links.user_info" },
10
+ ];
11
+
12
+ const UserNav = () => {
13
+ const t = useTranslations("_global_ui");
14
+ return (
15
+ <nav aria-label="User navigation">
16
+ <ul className="flex gap-2 md:gap-4 h-16 items-center">
17
+ {navLinks.map((link) => (
18
+ <li key={link.href}>
19
+ <Link
20
+ href={link.href}
21
+ className="inline-block rounded px-3 py-1.5 text-sm font-medium text-gray-700 hover:text-blue-600 hover:bg-blue-50 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500"
22
+ >
23
+ {t(link.labelKey)}
24
+ </Link>
25
+ </li>
26
+ ))}
27
+ <li>
28
+ <LogoutButton />
29
+ </li>
30
+ </ul>
31
+ </nav>
32
+ );
33
+ };
34
+
35
+ export default UserNav;
@@ -0,0 +1,27 @@
1
+ // src/ui/_home/page-ui.tsx
2
+ "use client";
3
+
4
+ import { useTranslations } from "next-intl";
5
+
6
+ export default function HomePageUI() {
7
+ const t = useTranslations("_home");
8
+
9
+ return (
10
+ <>
11
+ <section className="pt-32 pb-20 px-4 sm:px-6 lg:px-8 hero-pattern">
12
+ <div className="max-w-7xl mx-auto">
13
+ <div className="grid lg:grid-cols-2 gap-12 items-center">
14
+ <h1 className="text-5xl lg:text-6xl font-bold mb-6 leading-tight">
15
+ {t.rich("title", {
16
+ span: (chunks) => (
17
+ <span className="gradient-text">{chunks}</span>
18
+ ),
19
+ })}
20
+ </h1>
21
+ <p className="text-lg text-gray-400">{t("description")}</p>
22
+ </div>
23
+ </div>
24
+ </section>
25
+ </>
26
+ );
27
+ }
@@ -1,38 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches: ["master"]
6
- pull_request:
7
-
8
- jobs:
9
- test-build:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - uses: actions/checkout@v4
13
- - uses: oven-sh/setup-bun@v1
14
- - run: bun install
15
- - run: bun test
16
- - run: bun run build
17
- publish:
18
- needs: test-build
19
- if: github.ref == 'refs/heads/master' && github.event_name == 'push'
20
- runs-on: ubuntu-latest
21
- environment:
22
- name: ENV
23
- steps:
24
- - uses: actions/checkout@v4
25
- - uses: oven-sh/setup-bun@v2
26
- with:
27
- bun-version: latest
28
- - name: Configure Git
29
- run: |
30
- git config user.name "GitHub Actions"
31
- git config user.email "actions@github.com"
32
- - run: bun install
33
- - run: bun run version-patch
34
- - run: bun run build
35
- - name: Set up .npmrc
36
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
37
- - name: Publish package
38
- run: npm publish
package/bin.ts DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env bun
2
- import { main } from "./src/index";
3
- main();
@@ -1,12 +0,0 @@
1
- /** @type {import('@commitlint/types').UserConfig} */
2
- module.exports = {
3
- extends: ["@commitlint/config-conventional"],
4
- rules: {
5
- // subject free (no Upper/Start/Pascal)
6
- "subject-case": [
7
- 2,
8
- "never",
9
- ["sentence-case", "start-case", "pascal-case", "upper-case"],
10
- ],
11
- },
12
- };
package/install.sh DELETED
@@ -1,74 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Installation script for create-next-pro
4
-
5
- # Detect runtimes
6
- bun_path=$(command -v bun)
7
- deno_path=$(command -v deno)
8
- node_path=$(command -v node)
9
-
10
- if [ -n "$bun_path" ]; then
11
- echo "Bun detected at $bun_path. Using Bun shebang."
12
- sed -i '1s|.*|#!/usr/bin/env bun|' dist/bin.js
13
- elif [ -n "$deno_path" ]; then
14
- echo "Deno detected at $deno_path. Using Deno shebang."
15
- sed -i '1s|.*|#!/usr/bin/env deno|' dist/bin.js
16
- elif [ -n "$node_path" ]; then
17
- echo "Node.js detected at $node_path. Using Node shebang."
18
- sed -i '1s|.*|#!/usr/bin/env node|' dist/bin.js
19
- else
20
- echo "No compatible runtime (Bun, Deno, Node.js) found."
21
- read -p "Do you want to install Bun? [Y/n] " yn
22
- case $yn in
23
- [Nn]*)
24
- echo "Installation cancelled. Do you want to delete the parent folder? [Y/n] "
25
- read delyn
26
- case $delyn in
27
- [Nn]*) echo "Folder kept."; exit 1;;
28
- *)
29
- parent_dir="$(dirname $(pwd))"
30
- echo "Deleting folder $parent_dir..."
31
- rm -rf "$parent_dir"
32
- echo "Folder deleted."
33
- exit 1
34
- ;;
35
- esac
36
- ;;
37
- *)
38
- echo "Please install Bun, node or Deno!"
39
- echo "Installation instructions:"
40
- echo "Bun: https://bun.com/"
41
- echo "Node.js: https://nodejs.org/"
42
- echo "Deno: https://deno.land/"
43
- exit 1
44
- ;;
45
- esac
46
- fi
47
-
48
- COMPLETION_SCRIPT="$(pwd)/create-next-pro-completion.sh"
49
-
50
- # Choose shell for autocompletion
51
- read -p "Which shell do you use? [1] zsh, [2] bash (default: bash): " shell_choice
52
- case $shell_choice in
53
- 1|zsh|Zsh)
54
- RC_FILE="$HOME/.zshrc"
55
- SHELL_NAME="zsh"
56
- ;;
57
- *)
58
- RC_FILE="$HOME/.bashrc"
59
- SHELL_NAME="bash"
60
- ;;
61
- esac
62
-
63
- read -p "Do you want to add create-next-pro autocompletion to your $SHELL_NAME rc file? [Y/n] " yn
64
- case $yn in
65
- [Nn]*) echo "ℹ️ Autocompletion not added"; exit;;
66
- *)
67
- if ! grep -q "$COMPLETION_SCRIPT" "$RC_FILE"; then
68
- echo "source $COMPLETION_SCRIPT" >> "$RC_FILE"
69
- echo "✅ Autocompletion script added to $RC_FILE"
70
- else
71
- echo "ℹ️ Script already present in $RC_FILE"
72
- fi
73
- ;;
74
- esac
package/tsconfig.json DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2017",
4
- "lib": ["dom", "dom.iterable", "esnext"],
5
- "allowJs": true,
6
- "skipLibCheck": true,
7
- "strict": true,
8
- "noEmit": true,
9
- "esModuleInterop": true,
10
- "module": "esnext",
11
- "moduleResolution": "bundler",
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "jsx": "preserve",
15
- "incremental": true,
16
- "plugins": [
17
- {
18
- "name": "next"
19
- }
20
- ],
21
- "paths": {
22
- "@/*": ["./src/*"]
23
- }
24
- },
25
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
26
- "exclude": ["node_modules"]
27
- }