create-lumen 1.0.0
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/LICENSE +21 -0
- package/README.md +115 -0
- package/bin/cli.js +17 -0
- package/package.json +42 -0
- package/src/cleanup.js +7 -0
- package/src/config-cache.js +27 -0
- package/src/configure.js +161 -0
- package/src/confirm-empty-folder.js +45 -0
- package/src/css.js +59 -0
- package/src/dependencies.js +101 -0
- package/src/injector.js +276 -0
- package/src/main.js +197 -0
- package/src/prompts.js +232 -0
- package/src/readme.js +178 -0
- package/src/scaffold.js +29 -0
- package/src/utils/dev-server.js +34 -0
- package/src/utils/fs.js +74 -0
- package/src/utils/pkg-manager.js +17 -0
- package/src/utils/yarn-v1.js +10 -0
- package/templates/architectures/component-based/main.jsx +10 -0
- package/templates/architectures/component-based/main.tsx +10 -0
- package/templates/architectures/component-based/src/App.jsx +11 -0
- package/templates/architectures/component-based/src/App.tsx +11 -0
- package/templates/architectures/component-based/src/components/common/Button.jsx +30 -0
- package/templates/architectures/component-based/src/components/common/Button.tsx +35 -0
- package/templates/architectures/component-based/src/components/common/index.js +1 -0
- package/templates/architectures/component-based/src/components/common/index.ts +1 -0
- package/templates/architectures/component-based/src/components/form/.gitkeep +0 -0
- package/templates/architectures/component-based/src/components/layout/.gitkeep +0 -0
- package/templates/architectures/component-based/src/config/constants.js +2 -0
- package/templates/architectures/component-based/src/config/constants.ts +2 -0
- package/templates/architectures/component-based/src/config/routes.js +7 -0
- package/templates/architectures/component-based/src/config/routes.ts +7 -0
- package/templates/architectures/component-based/src/context/AppContext.jsx +13 -0
- package/templates/architectures/component-based/src/context/AppContext.tsx +13 -0
- package/templates/architectures/component-based/src/hooks/index.js +1 -0
- package/templates/architectures/component-based/src/hooks/index.ts +1 -0
- package/templates/architectures/component-based/src/hooks/useLocalStorage.jsx +28 -0
- package/templates/architectures/component-based/src/hooks/useLocalStorage.ts +28 -0
- package/templates/architectures/component-based/src/layouts/MainLayout.jsx +29 -0
- package/templates/architectures/component-based/src/layouts/MainLayout.tsx +33 -0
- package/templates/architectures/component-based/src/layouts/index.js +1 -0
- package/templates/architectures/component-based/src/layouts/index.ts +1 -0
- package/templates/architectures/component-based/src/pages/Home/Home.jsx +16 -0
- package/templates/architectures/component-based/src/pages/Home/Home.tsx +16 -0
- package/templates/architectures/component-based/src/pages/Home/index.js +1 -0
- package/templates/architectures/component-based/src/pages/Home/index.ts +1 -0
- package/templates/architectures/component-based/src/routes/index.jsx +11 -0
- package/templates/architectures/component-based/src/routes/index.tsx +11 -0
- package/templates/architectures/component-based/src/services/.gitkeep +0 -0
- package/templates/architectures/component-based/src/store/.gitkeep +0 -0
- package/templates/architectures/component-based/src/styles/globals.css +7 -0
- package/templates/architectures/component-based/src/utils/cn.jsx +3 -0
- package/templates/architectures/component-based/src/utils/cn.ts +3 -0
- package/templates/architectures/component-based/src/utils/index.js +1 -0
- package/templates/architectures/component-based/src/utils/index.ts +1 -0
- package/templates/architectures/feature-based/main.jsx +10 -0
- package/templates/architectures/feature-based/main.tsx +10 -0
- package/templates/architectures/feature-based/scripts/create-feature.mjs +65 -0
- package/templates/architectures/feature-based/src/app/App.jsx +10 -0
- package/templates/architectures/feature-based/src/app/App.tsx +10 -0
- package/templates/architectures/feature-based/src/app/providers/ThemeProvider.jsx +5 -0
- package/templates/architectures/feature-based/src/app/providers/ThemeProvider.tsx +5 -0
- package/templates/architectures/feature-based/src/components/ui/Button.jsx +23 -0
- package/templates/architectures/feature-based/src/components/ui/Button.tsx +28 -0
- package/templates/architectures/feature-based/src/components/ui/index.js +1 -0
- package/templates/architectures/feature-based/src/components/ui/index.ts +1 -0
- package/templates/architectures/feature-based/src/config/constants.js +2 -0
- package/templates/architectures/feature-based/src/config/constants.ts +2 -0
- package/templates/architectures/feature-based/src/features/home/components/.gitkeep +0 -0
- package/templates/architectures/feature-based/src/features/home/hooks/.gitkeep +0 -0
- package/templates/architectures/feature-based/src/features/home/index.js +1 -0
- package/templates/architectures/feature-based/src/features/home/index.ts +1 -0
- package/templates/architectures/feature-based/src/features/home/interfaces/.gitkeep +0 -0
- package/templates/architectures/feature-based/src/features/home/layouts/.gitkeep +0 -0
- package/templates/architectures/feature-based/src/features/home/pages/HomePage.jsx +14 -0
- package/templates/architectures/feature-based/src/features/home/pages/HomePage.tsx +14 -0
- package/templates/architectures/feature-based/src/features/home/services/.gitkeep +0 -0
- package/templates/architectures/feature-based/src/features/home/store/.gitkeep +0 -0
- package/templates/architectures/feature-based/src/hooks/index.js +1 -0
- package/templates/architectures/feature-based/src/hooks/index.ts +1 -0
- package/templates/architectures/feature-based/src/hooks/useLocalStorage.jsx +28 -0
- package/templates/architectures/feature-based/src/hooks/useLocalStorage.ts +28 -0
- package/templates/architectures/feature-based/src/lib/.gitkeep +0 -0
- package/templates/architectures/feature-based/src/stores/.gitkeep +0 -0
- package/templates/architectures/feature-based/src/styles/globals.css +1 -0
- package/templates/architectures/feature-based/src/types/index.js +13 -0
- package/templates/architectures/feature-based/src/types/index.ts +11 -0
- package/templates/architectures/feature-based/src/utils/cn.jsx +3 -0
- package/templates/architectures/feature-based/src/utils/cn.ts +6 -0
- package/templates/architectures/feature-based/src/utils/index.js +1 -0
- package/templates/architectures/feature-based/src/utils/index.ts +1 -0
- package/templates/conditional/axios/component-based/src/services/axios.jsx +19 -0
- package/templates/conditional/axios/component-based/src/services/axios.ts +19 -0
- package/templates/conditional/axios/component-based/src/services/index.js +1 -0
- package/templates/conditional/axios/component-based/src/services/index.ts +1 -0
- package/templates/conditional/axios/feature-based/src/lib/axios.jsx +19 -0
- package/templates/conditional/axios/feature-based/src/lib/axios.ts +19 -0
- package/templates/conditional/axios/feature-based/src/lib/index.js +1 -0
- package/templates/conditional/axios/feature-based/src/lib/index.ts +1 -0
- package/templates/conditional/icons/huge/component-based/src/pages/Home/Home.jsx +20 -0
- package/templates/conditional/icons/huge/component-based/src/pages/Home/Home.tsx +20 -0
- package/templates/conditional/icons/huge/feature-based/src/features/home/pages/HomePage.jsx +20 -0
- package/templates/conditional/icons/huge/feature-based/src/features/home/pages/HomePage.tsx +20 -0
- package/templates/conditional/icons/lucide/component-based/src/pages/Home/Home.jsx +20 -0
- package/templates/conditional/icons/lucide/component-based/src/pages/Home/Home.tsx +20 -0
- package/templates/conditional/icons/lucide/feature-based/src/features/home/pages/HomePage.jsx +20 -0
- package/templates/conditional/icons/lucide/feature-based/src/features/home/pages/HomePage.tsx +20 -0
- package/templates/conditional/linting/eslint/eslint.config.js +31 -0
- package/templates/conditional/linting/eslint/eslint.config.ts +28 -0
- package/templates/conditional/linting/oxlint/oxlintrc.json +9 -0
- package/templates/conditional/router/component-based/src/App.jsx +11 -0
- package/templates/conditional/router/component-based/src/App.tsx +11 -0
- package/templates/conditional/router/component-based/src/routes/index.jsx +13 -0
- package/templates/conditional/router/component-based/src/routes/index.tsx +13 -0
- package/templates/conditional/router/feature-based/src/app/App.jsx +6 -0
- package/templates/conditional/router/feature-based/src/app/App.tsx +6 -0
- package/templates/conditional/router/feature-based/src/app/router.jsx +13 -0
- package/templates/conditional/router/feature-based/src/app/router.tsx +13 -0
- package/templates/conditional/state/redux/component-based/src/context/StoreProvider.jsx +7 -0
- package/templates/conditional/state/redux/component-based/src/context/StoreProvider.tsx +7 -0
- package/templates/conditional/state/redux/component-based/src/pages/Home/counterSlice.jsx +20 -0
- package/templates/conditional/state/redux/component-based/src/pages/Home/counterSlice.ts +20 -0
- package/templates/conditional/state/redux/component-based/src/store/hooks.js +4 -0
- package/templates/conditional/state/redux/component-based/src/store/hooks.ts +4 -0
- package/templates/conditional/state/redux/component-based/src/store/index.js +8 -0
- package/templates/conditional/state/redux/component-based/src/store/index.ts +11 -0
- package/templates/conditional/state/redux/feature-based/src/app/providers/StoreProvider.jsx +7 -0
- package/templates/conditional/state/redux/feature-based/src/app/providers/StoreProvider.tsx +7 -0
- package/templates/conditional/state/redux/feature-based/src/features/home/store/counterSlice.jsx +20 -0
- package/templates/conditional/state/redux/feature-based/src/features/home/store/counterSlice.ts +20 -0
- package/templates/conditional/state/redux/feature-based/src/stores/hooks.js +4 -0
- package/templates/conditional/state/redux/feature-based/src/stores/hooks.ts +4 -0
- package/templates/conditional/state/redux/feature-based/src/stores/index.js +8 -0
- package/templates/conditional/state/redux/feature-based/src/stores/index.ts +11 -0
- package/templates/conditional/state/zustand/component-based/src/store/useCounterStore.jsx +9 -0
- package/templates/conditional/state/zustand/component-based/src/store/useCounterStore.ts +9 -0
- package/templates/conditional/state/zustand/feature-based/src/stores/useCounterStore.jsx +9 -0
- package/templates/conditional/state/zustand/feature-based/src/stores/useCounterStore.ts +9 -0
- package/templates/conditional/testing/jest/jest.config.js +12 -0
- package/templates/conditional/testing/jest/jest.config.ts +13 -0
- package/templates/conditional/testing/jest/jest.setup.js +1 -0
- package/templates/conditional/testing/jest/jest.setup.ts +1 -0
- package/templates/conditional/testing/jest/src/__tests__/App.test.jsx +9 -0
- package/templates/conditional/testing/jest/src/__tests__/App.test.tsx +9 -0
- package/templates/conditional/testing/vitest/src/__tests__/App.test.jsx +10 -0
- package/templates/conditional/testing/vitest/src/__tests__/App.test.tsx +10 -0
- package/templates/conditional/testing/vitest/src/test/setup.js +1 -0
- package/templates/conditional/testing/vitest/src/test/setup.ts +1 -0
- package/templates/conditional/testing/vitest/vitest.config.js +18 -0
- package/templates/conditional/testing/vitest/vitest.config.ts +18 -0
- package/templates/css/bootstrap/src/index.css +1 -0
- package/templates/css/none/src/index.css +18 -0
- package/templates/css/tailwind/src/index.css +1 -0
- package/templates/css/tailwind/vite.config.js +15 -0
- package/templates/css/tailwind/vite.config.ts +15 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Sun, Moon, Github } from "lucide-react";
|
|
3
|
+
import { Button } from "@/components/common";
|
|
4
|
+
|
|
5
|
+
export function HomePage() {
|
|
6
|
+
return (
|
|
7
|
+
<div className="text-center">
|
|
8
|
+
<div className="flex justify-center gap-4 mb-6">
|
|
9
|
+
<Sun className="w-8 h-8 text-yellow-500" />
|
|
10
|
+
<Moon className="w-8 h-8 text-blue-500" />
|
|
11
|
+
<Github className="w-8 h-8 text-gray-800" />
|
|
12
|
+
</div>
|
|
13
|
+
<h1 className="text-4xl font-bold text-gray-900 mb-4">Welcome to Lumen</h1>
|
|
14
|
+
<p className="text-gray-600 mb-8">
|
|
15
|
+
Your React + Vite project is ready. Start building!
|
|
16
|
+
</p>
|
|
17
|
+
<Button>Get Started</Button>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Sun, Moon, Github } from "lucide-react";
|
|
3
|
+
import { Button } from "@/components/common";
|
|
4
|
+
|
|
5
|
+
export function HomePage() {
|
|
6
|
+
return (
|
|
7
|
+
<div className="text-center">
|
|
8
|
+
<div className="flex justify-center gap-4 mb-6">
|
|
9
|
+
<Sun className="w-8 h-8 text-yellow-500" />
|
|
10
|
+
<Moon className="w-8 h-8 text-blue-500" />
|
|
11
|
+
<Github className="w-8 h-8 text-gray-800" />
|
|
12
|
+
</div>
|
|
13
|
+
<h1 className="text-4xl font-bold text-gray-900 mb-4">Welcome to Lumen</h1>
|
|
14
|
+
<p className="text-gray-600 mb-8">
|
|
15
|
+
Your React + Vite project is ready. Start building!
|
|
16
|
+
</p>
|
|
17
|
+
<Button>Get Started</Button>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Sun, Moon, Github } from "lucide-react";
|
|
3
|
+
import { Button } from "@/components/ui";
|
|
4
|
+
|
|
5
|
+
export function HomePage() {
|
|
6
|
+
return (
|
|
7
|
+
<div className="text-center">
|
|
8
|
+
<div className="flex justify-center gap-4 mb-6">
|
|
9
|
+
<Sun className="w-8 h-8 text-yellow-500" />
|
|
10
|
+
<Moon className="w-8 h-8 text-blue-500" />
|
|
11
|
+
<Github className="w-8 h-8 text-gray-800" />
|
|
12
|
+
</div>
|
|
13
|
+
<h1 className="text-4xl font-bold text-gray-900 mb-4">Welcome to Lumen</h1>
|
|
14
|
+
<p className="text-gray-600 mb-8">
|
|
15
|
+
Your React + Vite project is ready. Start building!
|
|
16
|
+
</p>
|
|
17
|
+
<Button>Get Started</Button>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Sun, Moon, Github } from "lucide-react";
|
|
3
|
+
import { Button } from "@/components/ui";
|
|
4
|
+
|
|
5
|
+
export function HomePage() {
|
|
6
|
+
return (
|
|
7
|
+
<div className="text-center">
|
|
8
|
+
<div className="flex justify-center gap-4 mb-6">
|
|
9
|
+
<Sun className="w-8 h-8 text-yellow-500" />
|
|
10
|
+
<Moon className="w-8 h-8 text-blue-500" />
|
|
11
|
+
<Github className="w-8 h-8 text-gray-800" />
|
|
12
|
+
</div>
|
|
13
|
+
<h1 className="text-4xl font-bold text-gray-900 mb-4">Welcome to Lumen</h1>
|
|
14
|
+
<p className="text-gray-600 mb-8">
|
|
15
|
+
Your React + Vite project is ready. Start building!
|
|
16
|
+
</p>
|
|
17
|
+
<Button>Get Started</Button>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import reactHooks from "eslint-plugin-react-hooks";
|
|
4
|
+
import reactRefresh from "eslint-plugin-react-refresh";
|
|
5
|
+
|
|
6
|
+
export default [
|
|
7
|
+
{ ignores: ["dist"] },
|
|
8
|
+
{
|
|
9
|
+
files: ["**/*.{js,jsx}"],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
ecmaVersion: 2020,
|
|
12
|
+
globals: globals.browser,
|
|
13
|
+
parserOptions: {
|
|
14
|
+
ecmaVersion: "latest",
|
|
15
|
+
ecmaFeatures: { jsx: true },
|
|
16
|
+
sourceType: "module",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
plugins: {
|
|
20
|
+
"react-hooks": reactHooks,
|
|
21
|
+
"react-refresh": reactRefresh,
|
|
22
|
+
},
|
|
23
|
+
rules: {
|
|
24
|
+
...reactHooks.configs.recommended.rules,
|
|
25
|
+
"react-refresh/only-export-components": [
|
|
26
|
+
"warn",
|
|
27
|
+
{ allowConstantExport: true },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import reactHooks from "eslint-plugin-react-hooks";
|
|
4
|
+
import reactRefresh from "eslint-plugin-react-refresh";
|
|
5
|
+
import tseslint from "typescript-eslint";
|
|
6
|
+
|
|
7
|
+
export default tseslint.config(
|
|
8
|
+
{ ignores: ["dist"] },
|
|
9
|
+
{
|
|
10
|
+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
|
11
|
+
files: ["**/*.{ts,tsx}"],
|
|
12
|
+
languageOptions: {
|
|
13
|
+
ecmaVersion: 2020,
|
|
14
|
+
globals: globals.browser,
|
|
15
|
+
},
|
|
16
|
+
plugins: {
|
|
17
|
+
"react-hooks": reactHooks,
|
|
18
|
+
"react-refresh": reactRefresh,
|
|
19
|
+
},
|
|
20
|
+
rules: {
|
|
21
|
+
...reactHooks.configs.recommended.rules,
|
|
22
|
+
"react-refresh/only-export-components": [
|
|
23
|
+
"warn",
|
|
24
|
+
{ allowConstantExport: true },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
|
3
|
+
import { HomePage } from "@/pages/Home";
|
|
4
|
+
|
|
5
|
+
export function AppRoutes() {
|
|
6
|
+
return (
|
|
7
|
+
<BrowserRouter>
|
|
8
|
+
<Routes>
|
|
9
|
+
<Route path="/" element={<HomePage />} />
|
|
10
|
+
</Routes>
|
|
11
|
+
</BrowserRouter>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
|
3
|
+
import { HomePage } from "@/pages/Home";
|
|
4
|
+
|
|
5
|
+
export function AppRoutes() {
|
|
6
|
+
return (
|
|
7
|
+
<BrowserRouter>
|
|
8
|
+
<Routes>
|
|
9
|
+
<Route path="/" element={<HomePage />} />
|
|
10
|
+
</Routes>
|
|
11
|
+
</BrowserRouter>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
|
2
|
+
import { HomePage } from "@/features/home/pages/HomePage";
|
|
3
|
+
|
|
4
|
+
const router = createBrowserRouter([
|
|
5
|
+
{
|
|
6
|
+
path: "/",
|
|
7
|
+
element: <HomePage />,
|
|
8
|
+
},
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
export function AppRouter() {
|
|
12
|
+
return <RouterProvider router={router} />;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
|
2
|
+
import { HomePage } from "@/features/home/pages/HomePage";
|
|
3
|
+
|
|
4
|
+
const router = createBrowserRouter([
|
|
5
|
+
{
|
|
6
|
+
path: "/",
|
|
7
|
+
element: <HomePage />,
|
|
8
|
+
},
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
export function AppRouter() {
|
|
12
|
+
return <RouterProvider router={router} />;
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
2
|
+
|
|
3
|
+
const counterSlice = createSlice({
|
|
4
|
+
name: "counter",
|
|
5
|
+
initialState: { value: 0 },
|
|
6
|
+
reducers: {
|
|
7
|
+
increment: (state) => {
|
|
8
|
+
state.value += 1;
|
|
9
|
+
},
|
|
10
|
+
decrement: (state) => {
|
|
11
|
+
state.value -= 1;
|
|
12
|
+
},
|
|
13
|
+
incrementByAmount: (state, action) => {
|
|
14
|
+
state.value += action.payload;
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const { increment, decrement, incrementByAmount } = counterSlice.actions;
|
|
20
|
+
export default counterSlice.reducer;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
2
|
+
|
|
3
|
+
const counterSlice = createSlice({
|
|
4
|
+
name: "counter",
|
|
5
|
+
initialState: { value: 0 },
|
|
6
|
+
reducers: {
|
|
7
|
+
increment: (state) => {
|
|
8
|
+
state.value += 1;
|
|
9
|
+
},
|
|
10
|
+
decrement: (state) => {
|
|
11
|
+
state.value -= 1;
|
|
12
|
+
},
|
|
13
|
+
incrementByAmount: (state, action) => {
|
|
14
|
+
state.value += action.payload;
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const { increment, decrement, incrementByAmount } = counterSlice.actions;
|
|
20
|
+
export default counterSlice.reducer;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { configureStore } from "@reduxjs/toolkit";
|
|
2
|
+
import counterReducer from "@/pages/Home/counterSlice";
|
|
3
|
+
|
|
4
|
+
export const store = configureStore({
|
|
5
|
+
reducer: {
|
|
6
|
+
counter: counterReducer,
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const RootState = store.getState;
|
|
11
|
+
export const AppDispatch = store.dispatch;
|
package/templates/conditional/state/redux/feature-based/src/features/home/store/counterSlice.jsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
2
|
+
|
|
3
|
+
const counterSlice = createSlice({
|
|
4
|
+
name: "counter",
|
|
5
|
+
initialState: { value: 0 },
|
|
6
|
+
reducers: {
|
|
7
|
+
increment: (state) => {
|
|
8
|
+
state.value += 1;
|
|
9
|
+
},
|
|
10
|
+
decrement: (state) => {
|
|
11
|
+
state.value -= 1;
|
|
12
|
+
},
|
|
13
|
+
incrementByAmount: (state, action) => {
|
|
14
|
+
state.value += action.payload;
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const { increment, decrement, incrementByAmount } = counterSlice.actions;
|
|
20
|
+
export default counterSlice.reducer;
|
package/templates/conditional/state/redux/feature-based/src/features/home/store/counterSlice.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
2
|
+
|
|
3
|
+
const counterSlice = createSlice({
|
|
4
|
+
name: "counter",
|
|
5
|
+
initialState: { value: 0 },
|
|
6
|
+
reducers: {
|
|
7
|
+
increment: (state) => {
|
|
8
|
+
state.value += 1;
|
|
9
|
+
},
|
|
10
|
+
decrement: (state) => {
|
|
11
|
+
state.value -= 1;
|
|
12
|
+
},
|
|
13
|
+
incrementByAmount: (state, action) => {
|
|
14
|
+
state.value += action.payload;
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const { increment, decrement, incrementByAmount } = counterSlice.actions;
|
|
20
|
+
export default counterSlice.reducer;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { configureStore } from "@reduxjs/toolkit";
|
|
2
|
+
import counterReducer from "@/features/home/store/counterSlice";
|
|
3
|
+
|
|
4
|
+
export const store = configureStore({
|
|
5
|
+
reducer: {
|
|
6
|
+
counter: counterReducer,
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const RootState = store.getState;
|
|
11
|
+
export const AppDispatch = store.dispatch;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
|
|
3
|
+
export const useCounterStore = create((set) => ({
|
|
4
|
+
count: 0,
|
|
5
|
+
increment: () => set((state) => ({ count: state.count + 1 })),
|
|
6
|
+
decrement: () => set((state) => ({ count: state.count - 1 })),
|
|
7
|
+
incrementByAmount: (amount) =>
|
|
8
|
+
set((state) => ({ count: state.count + amount })),
|
|
9
|
+
}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
|
|
3
|
+
export const useCounterStore = create((set) => ({
|
|
4
|
+
count: 0,
|
|
5
|
+
increment: () => set((state) => ({ count: state.count + 1 })),
|
|
6
|
+
decrement: () => set((state) => ({ count: state.count - 1 })),
|
|
7
|
+
incrementByAmount: (amount) =>
|
|
8
|
+
set((state) => ({ count: state.count + amount })),
|
|
9
|
+
}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
|
|
3
|
+
export const useCounterStore = create((set) => ({
|
|
4
|
+
count: 0,
|
|
5
|
+
increment: () => set((state) => ({ count: state.count + 1 })),
|
|
6
|
+
decrement: () => set((state) => ({ count: state.count - 1 })),
|
|
7
|
+
incrementByAmount: (amount) =>
|
|
8
|
+
set((state) => ({ count: state.count + amount })),
|
|
9
|
+
}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
|
|
3
|
+
export const useCounterStore = create((set) => ({
|
|
4
|
+
count: 0,
|
|
5
|
+
increment: () => set((state) => ({ count: state.count + 1 })),
|
|
6
|
+
decrement: () => set((state) => ({ count: state.count - 1 })),
|
|
7
|
+
incrementByAmount: (amount) =>
|
|
8
|
+
set((state) => ({ count: state.count + amount })),
|
|
9
|
+
}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @type {import('jest').Config} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
testEnvironment: "jsdom",
|
|
4
|
+
roots: ["<rootDir>/src"],
|
|
5
|
+
setupFilesAfterSetup: ["<rootDir>/jest.setup.js"],
|
|
6
|
+
moduleNameMapper: {
|
|
7
|
+
"^@/(.*)$": "<rootDir>/src/$1",
|
|
8
|
+
},
|
|
9
|
+
transform: {
|
|
10
|
+
"^.+\\.jsx?$": "babel-jest",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
preset: "ts-jest",
|
|
4
|
+
testEnvironment: "jsdom",
|
|
5
|
+
roots: ["<rootDir>/src"],
|
|
6
|
+
setupFilesAfterSetup: ["<rootDir>/jest.setup.ts"],
|
|
7
|
+
moduleNameMapper: {
|
|
8
|
+
"^@/(.*)$": "<rootDir>/src/$1",
|
|
9
|
+
},
|
|
10
|
+
transform: {
|
|
11
|
+
"^.+\\.tsx?$": "ts-jest",
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import { describe, it, expect } from "vitest";
|
|
3
|
+
import App from "@/app/App";
|
|
4
|
+
|
|
5
|
+
describe("App", () => {
|
|
6
|
+
it("renders without crashing", () => {
|
|
7
|
+
render(<App />);
|
|
8
|
+
expect(screen.getByText(/Welcome/i)).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import { describe, it, expect } from "vitest";
|
|
3
|
+
import App from "@/app/App";
|
|
4
|
+
|
|
5
|
+
describe("App", () => {
|
|
6
|
+
it("renders without crashing", () => {
|
|
7
|
+
render(<App />);
|
|
8
|
+
expect(screen.getByText(/Welcome/i)).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom/vitest";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom/vitest";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [react()],
|
|
7
|
+
resolve: {
|
|
8
|
+
alias: {
|
|
9
|
+
"@": path.resolve(__dirname, "./src"),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
test: {
|
|
13
|
+
globals: true,
|
|
14
|
+
environment: "jsdom",
|
|
15
|
+
setupFiles: "./src/test/setup.js",
|
|
16
|
+
css: true,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [react()],
|
|
7
|
+
resolve: {
|
|
8
|
+
alias: {
|
|
9
|
+
"@": path.resolve(__dirname, "./src"),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
test: {
|
|
13
|
+
globals: true,
|
|
14
|
+
environment: "jsdom",
|
|
15
|
+
setupFiles: "./src/test/setup.ts",
|
|
16
|
+
css: true,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
*,
|
|
2
|
+
*::before,
|
|
3
|
+
*::after {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
html {
|
|
10
|
+
-webkit-font-smoothing: antialiased;
|
|
11
|
+
-moz-osx-font-smoothing: grayscale;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
body {
|
|
15
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
16
|
+
sans-serif;
|
|
17
|
+
line-height: 1.5;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "tailwindcss";
|