@oss-ma/tpl 1.0.30 → 1.0.32
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/engine/prompt.js +23 -52
- package/package.json +3 -4
- package/resources/templates/react-next/files/env.example +10 -0
- package/resources/templates/react-next/files/gitignore +19 -0
- package/resources/templates/react-next/files/jest.config.ts +15 -0
- package/resources/templates/react-next/files/next.config.ts +7 -0
- package/resources/templates/react-next/files/package.json +52 -0
- package/resources/templates/react-next/files/src/app/globals.css +18 -0
- package/resources/templates/react-next/files/src/app/layout.tsx +32 -0
- package/resources/templates/react-next/files/src/app/loading.tsx +7 -0
- package/resources/templates/react-next/files/src/app/not-found.tsx +13 -0
- package/resources/templates/react-next/files/src/app/page.tsx +13 -0
- package/resources/templates/react-next/files/src/features/example/ExampleFeature.tsx +74 -0
- package/resources/templates/react-next/files/src/features/example/store.ts +15 -0
- package/resources/templates/react-next/files/src/lib/QueryProvider.tsx +26 -0
- package/resources/templates/react-next/files/src/shared/ui/Button.test.tsx +21 -0
- package/resources/templates/react-next/files/src/shared/ui/Button.tsx +34 -0
- package/resources/templates/react-next/files/src/tests/setup.ts +1 -0
- package/resources/templates/react-next/files/tsconfig.json +24 -0
- package/resources/templates/react-next/template.yaml +37 -0
- package/resources/templates/react-ts/files/src/pages/HomePage.tsx +0 -6
package/dist/engine/prompt.js
CHANGED
|
@@ -1,67 +1,38 @@
|
|
|
1
1
|
// cli/src/engine/prompt.ts
|
|
2
|
-
import
|
|
2
|
+
import { input, select } from "@inquirer/prompts";
|
|
3
3
|
export async function askQuestions(questions, opts = {}) {
|
|
4
4
|
if (!questions?.length)
|
|
5
5
|
return {};
|
|
6
|
-
// --yes :
|
|
6
|
+
// --yes : no interaction, use defaults
|
|
7
7
|
if (opts.yes) {
|
|
8
8
|
const answers = {};
|
|
9
9
|
for (const q of questions)
|
|
10
10
|
answers[q.name] = String(q.default ?? "");
|
|
11
11
|
return answers;
|
|
12
12
|
}
|
|
13
|
-
const defs = questions.map((q) => {
|
|
14
|
-
const base = {
|
|
15
|
-
name: q.name,
|
|
16
|
-
message: q.message,
|
|
17
|
-
initial: q.default
|
|
18
|
-
};
|
|
19
|
-
if (q.choices?.length) {
|
|
20
|
-
return { type: "select", ...base, choices: q.choices.map((c) => ({ title: c, value: c })) };
|
|
21
|
-
}
|
|
22
|
-
return { type: "text", ...base };
|
|
23
|
-
});
|
|
24
|
-
// Sur certains terminaux Windows, prompts peut déclencher onCancel inopinément.
|
|
25
|
-
// Stratégie: si cancel -> fallback sur defaults au lieu de crash.
|
|
26
|
-
const res = (await prompts(defs, {
|
|
27
|
-
onCancel: () => true
|
|
28
|
-
}));
|
|
29
13
|
const out = {};
|
|
30
14
|
for (const q of questions) {
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
try {
|
|
16
|
+
if (q.choices?.length) {
|
|
17
|
+
const answer = await select({
|
|
18
|
+
message: q.message,
|
|
19
|
+
default: q.default,
|
|
20
|
+
choices: q.choices.map((c) => ({ name: c, value: c })),
|
|
21
|
+
});
|
|
22
|
+
out[q.name] = String(answer);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const answer = await input({
|
|
26
|
+
message: q.message,
|
|
27
|
+
default: String(q.default ?? ""),
|
|
28
|
+
});
|
|
29
|
+
out[q.name] = answer.trim() || String(q.default ?? "");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// User cancelled (Ctrl+C) → fallback to default
|
|
34
|
+
out[q.name] = String(q.default ?? "");
|
|
35
|
+
}
|
|
33
36
|
}
|
|
34
37
|
return out;
|
|
35
38
|
}
|
|
36
|
-
// import prompts from "prompts";
|
|
37
|
-
// import type { TemplateQuestion } from "./loadTemplate.js";
|
|
38
|
-
// export async function askQuestions(
|
|
39
|
-
// questions: TemplateQuestion[] | undefined,
|
|
40
|
-
// opts: { yes?: boolean } = {}
|
|
41
|
-
// ): Promise<Record<string, string>> {
|
|
42
|
-
// if (!questions?.length) return {};
|
|
43
|
-
// if (opts.yes) {
|
|
44
|
-
// const answers: Record<string, string> = {};
|
|
45
|
-
// for (const q of questions) {
|
|
46
|
-
// answers[q.name] = String(q.default ?? "");
|
|
47
|
-
// }
|
|
48
|
-
// return answers;
|
|
49
|
-
// }
|
|
50
|
-
// const defs = questions.map((q) => {
|
|
51
|
-
// const base: any = {
|
|
52
|
-
// name: q.name,
|
|
53
|
-
// message: q.message,
|
|
54
|
-
// initial: q.default
|
|
55
|
-
// };
|
|
56
|
-
// if (q.choices?.length) {
|
|
57
|
-
// return { type: "select", ...base, choices: q.choices.map((c) => ({ title: c, value: c })) };
|
|
58
|
-
// }
|
|
59
|
-
// return { type: "text", ...base };
|
|
60
|
-
// });
|
|
61
|
-
// const res = await prompts(defs, {
|
|
62
|
-
// onCancel: () => {
|
|
63
|
-
// throw new Error("Cancelled by user.");
|
|
64
|
-
// }
|
|
65
|
-
// });
|
|
66
|
-
// return res as Record<string, string>;
|
|
67
|
-
// }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oss-ma/tpl",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"description": "Generate, enforce and maintain clean project architectures",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -27,18 +27,17 @@
|
|
|
27
27
|
"test:smoke": "node --test dist/tests/smoke.test.js"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
+
"@inquirer/prompts": "^8.2.1",
|
|
30
31
|
"commander": "^12.1.0",
|
|
31
32
|
"execa": "^9.3.0",
|
|
32
33
|
"fs-extra": "^11.2.0",
|
|
33
34
|
"picocolors": "^1.0.0",
|
|
34
|
-
"prompts": "^2.4.2",
|
|
35
35
|
"yaml": "^2.5.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/fs-extra": "^11.0.4",
|
|
39
39
|
"@types/node": "^22.7.0",
|
|
40
|
-
"@types/prompts": "^2.4.9",
|
|
41
40
|
"tsx": "^4.16.2",
|
|
42
41
|
"typescript": "^5.5.4"
|
|
43
42
|
}
|
|
44
|
-
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Application
|
|
2
|
+
NEXT_PUBLIC_APP_NAME={{appName}}
|
|
3
|
+
NEXT_PUBLIC_APP_VERSION=0.1.0
|
|
4
|
+
|
|
5
|
+
# API
|
|
6
|
+
NEXT_PUBLIC_API_BASE_URL=https://api.example.com
|
|
7
|
+
|
|
8
|
+
# Server-side only (never exposed to browser)
|
|
9
|
+
# DATABASE_URL=postgresql://user:password@localhost:5432/mydb
|
|
10
|
+
# SECRET_KEY=your-secret-key
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Config } from "jest";
|
|
2
|
+
import nextJest from "next/jest.js";
|
|
3
|
+
|
|
4
|
+
const createJestConfig = nextJest({ dir: "./" });
|
|
5
|
+
|
|
6
|
+
const config: Config = {
|
|
7
|
+
coverageProvider: "v8",
|
|
8
|
+
testEnvironment: "jsdom",
|
|
9
|
+
setupFilesAfterFramework: ["<rootDir>/src/tests/setup.ts"],
|
|
10
|
+
moduleNameMapper: {
|
|
11
|
+
"^@/(.*)$": "<rootDir>/src/$1",
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default createJestConfig(config);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{appName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "next dev",
|
|
7
|
+
"build": "next build",
|
|
8
|
+
"start": "next start",
|
|
9
|
+
"lint": "next lint",
|
|
10
|
+
"lint:fix": "next lint --fix",
|
|
11
|
+
"format": "prettier -w .",
|
|
12
|
+
"typecheck": "tsc --noEmit",
|
|
13
|
+
"test": "jest --passWithNoTests",
|
|
14
|
+
"test:watch": "jest --watch",
|
|
15
|
+
"test:coverage": "jest --coverage",
|
|
16
|
+
"prepare": "husky",
|
|
17
|
+
"audit": "npm audit --audit-level=high"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"next": "^14.2.0",
|
|
21
|
+
"react": "^18.3.0",
|
|
22
|
+
"react-dom": "^18.3.0"{{#if state}},
|
|
23
|
+
"zustand": "^4.5.0"{{/if}}{{#if fetching}},
|
|
24
|
+
"@tanstack/react-query": "^5.56.0"{{/if}}
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@commitlint/cli": "^19.3.0",
|
|
28
|
+
"@commitlint/config-conventional": "^19.2.0",
|
|
29
|
+
"@eslint/js": "^9.0.0",{{#if fetching}}
|
|
30
|
+
"@tanstack/react-query-devtools": "^5.56.0",{{/if}}
|
|
31
|
+
"@testing-library/jest-dom": "^6.5.0",
|
|
32
|
+
"@testing-library/react": "^16.0.0",
|
|
33
|
+
"@testing-library/user-event": "^14.5.0",
|
|
34
|
+
"@types/jest": "^29.5.0",
|
|
35
|
+
"@types/node": "^20.0.0",
|
|
36
|
+
"@types/react": "^18.3.0",
|
|
37
|
+
"@types/react-dom": "^18.3.0",
|
|
38
|
+
"eslint": "^9.0.0",
|
|
39
|
+
"eslint-config-next": "^14.2.0",
|
|
40
|
+
"husky": "^9.0.0",
|
|
41
|
+
"jest": "^29.7.0",
|
|
42
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
43
|
+
"lint-staged": "^15.2.0",
|
|
44
|
+
"prettier": "^3.3.0",
|
|
45
|
+
"ts-jest": "^29.2.0",
|
|
46
|
+
"typescript": "^5.5.0"
|
|
47
|
+
},
|
|
48
|
+
"lint-staged": {
|
|
49
|
+
"*.{ts,tsx,js,jsx,json,md,yml,yaml}": ["prettier -w"],
|
|
50
|
+
"*.{ts,tsx,js,jsx}": ["eslint --fix"]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
*,
|
|
2
|
+
*::before,
|
|
3
|
+
*::after {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
:root {
|
|
10
|
+
font-family: Inter, system-ui, sans-serif;
|
|
11
|
+
line-height: 1.5;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
body {
|
|
15
|
+
min-height: 100vh;
|
|
16
|
+
background: #0a0a0a;
|
|
17
|
+
color: #ededed;
|
|
18
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
import { Inter } from "next/font/google";
|
|
3
|
+
{{#if fetching}}
|
|
4
|
+
import { QueryProvider } from "@/lib/QueryProvider";
|
|
5
|
+
{{/if}}
|
|
6
|
+
import "./globals.css";
|
|
7
|
+
|
|
8
|
+
const inter = Inter({ subsets: ["latin"] });
|
|
9
|
+
|
|
10
|
+
export const metadata: Metadata = {
|
|
11
|
+
title: "{{appName}}",
|
|
12
|
+
description: "Generated by @oss-ma/tpl",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default function RootLayout({
|
|
16
|
+
children,
|
|
17
|
+
}: {
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
}) {
|
|
20
|
+
return (
|
|
21
|
+
<html lang="en">
|
|
22
|
+
<body className={inter.className}>
|
|
23
|
+
{{#if fetching}}
|
|
24
|
+
<QueryProvider>{children}</QueryProvider>
|
|
25
|
+
{{/if}}
|
|
26
|
+
{{#unless fetching}}
|
|
27
|
+
{children}
|
|
28
|
+
{{/unless}}
|
|
29
|
+
</body>
|
|
30
|
+
</html>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Link from "next/link";
|
|
2
|
+
|
|
3
|
+
export default function NotFound() {
|
|
4
|
+
return (
|
|
5
|
+
<main style={{ padding: "2rem", textAlign: "center" }}>
|
|
6
|
+
<h1>404</h1>
|
|
7
|
+
<p>Page not found.</p>
|
|
8
|
+
<Link href="/" style={{ marginTop: "1rem", display: "inline-block" }}>
|
|
9
|
+
Go home
|
|
10
|
+
</Link>
|
|
11
|
+
</main>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExampleFeature } from "@/features/example/ExampleFeature";
|
|
2
|
+
|
|
3
|
+
export default function HomePage() {
|
|
4
|
+
return (
|
|
5
|
+
<main style={{ padding: "2rem", maxWidth: 800, margin: "0 auto" }}>
|
|
6
|
+
<h1>{{appName}}</h1>
|
|
7
|
+
<p style={{ marginTop: "0.5rem", opacity: 0.7 }}>
|
|
8
|
+
Next.js 14 · App Router · TypeScript
|
|
9
|
+
</p>
|
|
10
|
+
<ExampleFeature />
|
|
11
|
+
</main>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
{{#if fetching}}
|
|
4
|
+
import { useQuery } from "@tanstack/react-query";
|
|
5
|
+
{{/if}}
|
|
6
|
+
{{#if state}}
|
|
7
|
+
import { useCounterStore } from "./store";
|
|
8
|
+
{{/if}}
|
|
9
|
+
import { Button } from "@/shared/ui/Button";
|
|
10
|
+
{{#if fetching}}
|
|
11
|
+
|
|
12
|
+
interface Post {
|
|
13
|
+
id: number;
|
|
14
|
+
title: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function fetchPosts(): Promise<Post[]> {
|
|
18
|
+
const res = await fetch(
|
|
19
|
+
"https://jsonplaceholder.typicode.com/posts?_limit=3",
|
|
20
|
+
{ cache: "no-store" }
|
|
21
|
+
);
|
|
22
|
+
if (!res.ok) throw new Error("Failed to fetch posts");
|
|
23
|
+
return res.json();
|
|
24
|
+
}
|
|
25
|
+
{{/if}}
|
|
26
|
+
|
|
27
|
+
export function ExampleFeature() {
|
|
28
|
+
{{#if state}}
|
|
29
|
+
const { count, increment, decrement, reset } = useCounterStore();
|
|
30
|
+
{{/if}}
|
|
31
|
+
{{#if fetching}}
|
|
32
|
+
const { data: posts, isLoading, isError } = useQuery({
|
|
33
|
+
queryKey: ["posts"],
|
|
34
|
+
queryFn: fetchPosts,
|
|
35
|
+
});
|
|
36
|
+
{{/if}}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<section style={{ marginTop: "2rem" }}>
|
|
40
|
+
{{#if state}}
|
|
41
|
+
<div style={{ marginBottom: "2rem" }}>
|
|
42
|
+
<h2>Counter (Zustand)</h2>
|
|
43
|
+
<p style={{ fontSize: "2rem", margin: "0.5rem 0" }}>{count}</p>
|
|
44
|
+
<div style={{ display: "flex", gap: "0.5rem" }}>
|
|
45
|
+
<Button onClick={decrement}>−</Button>
|
|
46
|
+
<Button onClick={increment}>+</Button>
|
|
47
|
+
<Button onClick={reset} variant="secondary">Reset</Button>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
{{/if}}
|
|
51
|
+
{{#if fetching}}
|
|
52
|
+
<div>
|
|
53
|
+
<h2>Posts (TanStack Query)</h2>
|
|
54
|
+
{isLoading && <p>Loading...</p>}
|
|
55
|
+
{isError && <p>Error loading posts.</p>}
|
|
56
|
+
{posts && (
|
|
57
|
+
<ul style={{ marginTop: "0.5rem", paddingLeft: "1.2rem" }}>
|
|
58
|
+
{posts.map((post) => (
|
|
59
|
+
<li key={post.id} style={{ marginBottom: "0.25rem" }}>
|
|
60
|
+
{post.title}
|
|
61
|
+
</li>
|
|
62
|
+
))}
|
|
63
|
+
</ul>
|
|
64
|
+
)}
|
|
65
|
+
</div>
|
|
66
|
+
{{/if}}
|
|
67
|
+
{{#unless state}}
|
|
68
|
+
{{#unless fetching}}
|
|
69
|
+
<p>Feature module — add your components here.</p>
|
|
70
|
+
{{/unless}}
|
|
71
|
+
{{/unless}}
|
|
72
|
+
</section>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
|
|
3
|
+
interface CounterState {
|
|
4
|
+
count: number;
|
|
5
|
+
increment: () => void;
|
|
6
|
+
decrement: () => void;
|
|
7
|
+
reset: () => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const useCounterStore = create<CounterState>((set) => ({
|
|
11
|
+
count: 0,
|
|
12
|
+
increment: () => set((state) => ({ count: state.count + 1 })),
|
|
13
|
+
decrement: () => set((state) => ({ count: state.count - 1 })),
|
|
14
|
+
reset: () => set({ count: 0 }),
|
|
15
|
+
}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
+
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
|
|
7
|
+
export function QueryProvider({ children }: { children: React.ReactNode }) {
|
|
8
|
+
const [queryClient] = useState(
|
|
9
|
+
() =>
|
|
10
|
+
new QueryClient({
|
|
11
|
+
defaultOptions: {
|
|
12
|
+
queries: {
|
|
13
|
+
staleTime: 1000 * 60 * 5,
|
|
14
|
+
retry: 1,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<QueryClientProvider client={queryClient}>
|
|
22
|
+
{children}
|
|
23
|
+
<ReactQueryDevtools initialIsOpen={false} />
|
|
24
|
+
</QueryClientProvider>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from "@testing-library/react";
|
|
2
|
+
import { Button } from "@/shared/ui/Button";
|
|
3
|
+
|
|
4
|
+
describe("Button", () => {
|
|
5
|
+
it("renders children", () => {
|
|
6
|
+
render(<Button>Click me</Button>);
|
|
7
|
+
expect(screen.getByRole("button", { name: /click me/i })).toBeInTheDocument();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("calls onClick when clicked", () => {
|
|
11
|
+
const handler = jest.fn();
|
|
12
|
+
render(<Button onClick={handler}>Click</Button>);
|
|
13
|
+
fireEvent.click(screen.getByRole("button"));
|
|
14
|
+
expect(handler).toHaveBeenCalledTimes(1);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("is disabled when disabled prop is set", () => {
|
|
18
|
+
render(<Button disabled>Disabled</Button>);
|
|
19
|
+
expect(screen.getByRole("button")).toBeDisabled();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ButtonHTMLAttributes } from "react";
|
|
4
|
+
|
|
5
|
+
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
|
+
variant?: "primary" | "secondary";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function Button({
|
|
10
|
+
variant = "primary",
|
|
11
|
+
children,
|
|
12
|
+
style,
|
|
13
|
+
...props
|
|
14
|
+
}: ButtonProps) {
|
|
15
|
+
const base: React.CSSProperties = {
|
|
16
|
+
padding: "0.4rem 1rem",
|
|
17
|
+
borderRadius: 6,
|
|
18
|
+
border: "none",
|
|
19
|
+
cursor: "pointer",
|
|
20
|
+
fontWeight: 500,
|
|
21
|
+
fontSize: "0.9rem",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const variants: Record<string, React.CSSProperties> = {
|
|
25
|
+
primary: { background: "#646cff", color: "#fff" },
|
|
26
|
+
secondary: { background: "#3a3a3a", color: "#fff" },
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<button style={{ ...base, ...variants[variant], ...style }} {...props}>
|
|
31
|
+
{children}
|
|
32
|
+
</button>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -0,0 +1,24 @@
|
|
|
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": [{ "name": "next" }],
|
|
17
|
+
"baseUrl": ".",
|
|
18
|
+
"paths": {
|
|
19
|
+
"@/*": ["./src/*"]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
23
|
+
"exclude": ["node_modules"]
|
|
24
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: react-next
|
|
2
|
+
version: 1.0.0
|
|
3
|
+
description: "Next.js 14 App Router + TypeScript with optional state and fetching"
|
|
4
|
+
engine: "v1"
|
|
5
|
+
|
|
6
|
+
questions:
|
|
7
|
+
- name: appName
|
|
8
|
+
message: "Nom du projet ?"
|
|
9
|
+
default: "my-next-app"
|
|
10
|
+
|
|
11
|
+
- name: packageManager
|
|
12
|
+
message: "Package manager ?"
|
|
13
|
+
choices: ["npm", "pnpm", "yarn"]
|
|
14
|
+
default: "npm"
|
|
15
|
+
|
|
16
|
+
- name: state
|
|
17
|
+
message: "State management ?"
|
|
18
|
+
choices: ["zustand", "none"]
|
|
19
|
+
default: "zustand"
|
|
20
|
+
|
|
21
|
+
- name: fetching
|
|
22
|
+
message: "Data fetching ?"
|
|
23
|
+
choices: ["tanstack-query", "none"]
|
|
24
|
+
default: "tanstack-query"
|
|
25
|
+
|
|
26
|
+
hooks:
|
|
27
|
+
postGenerate:
|
|
28
|
+
- run: "git init"
|
|
29
|
+
|
|
30
|
+
- run: "npm install --ignore-scripts"
|
|
31
|
+
when: "{{packageManager}} == npm"
|
|
32
|
+
|
|
33
|
+
- run: "pnpm install --ignore-scripts"
|
|
34
|
+
when: "{{packageManager}} == pnpm"
|
|
35
|
+
|
|
36
|
+
- run: "yarn install --ignore-scripts"
|
|
37
|
+
when: "{{packageManager}} == yarn"
|
|
@@ -2,18 +2,14 @@
|
|
|
2
2
|
import { ExampleFeature } from "@/features/example/ExampleFeature";
|
|
3
3
|
{{/if}}
|
|
4
4
|
{{#unless state}}
|
|
5
|
-
{{#unless fetching}}
|
|
6
5
|
import { Button } from "@/shared/ui/Button";
|
|
7
6
|
import { useState } from "react";
|
|
8
7
|
{{/unless}}
|
|
9
|
-
{{/unless}}
|
|
10
8
|
|
|
11
9
|
export function HomePage() {
|
|
12
10
|
{{#unless state}}
|
|
13
|
-
{{#unless fetching}}
|
|
14
11
|
const [msg, setMsg] = useState<string | null>(null);
|
|
15
12
|
{{/unless}}
|
|
16
|
-
{{/unless}}
|
|
17
13
|
|
|
18
14
|
return (
|
|
19
15
|
<main style={{ padding: "2rem", maxWidth: 800, margin: "0 auto" }}>
|
|
@@ -25,13 +21,11 @@ export function HomePage() {
|
|
|
25
21
|
<ExampleFeature />
|
|
26
22
|
{{/if}}
|
|
27
23
|
{{#unless state}}
|
|
28
|
-
{{#unless fetching}}
|
|
29
24
|
<section style={{ marginTop: "2rem" }}>
|
|
30
25
|
<Button onClick={() => setMsg("Hello!")}>Click me</Button>
|
|
31
26
|
{msg && <p style={{ marginTop: "0.5rem" }}>{msg}</p>}
|
|
32
27
|
</section>
|
|
33
28
|
{{/unless}}
|
|
34
|
-
{{/unless}}
|
|
35
29
|
</main>
|
|
36
30
|
);
|
|
37
31
|
}
|