create-template-project 1.5.7 → 1.5.9
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/config/dependencies.json +17 -17
- package/dist/templates/base/files/_oxc.config.ts +1 -0
- package/dist/templates/web-fullstack/files/client/src/components/ProtectedRoute.tsx +2 -2
- package/dist/templates/web-fullstack/files/client/src/contexts/AuthContext.tsx +5 -14
- package/dist/templates/web-fullstack/files/tests/e2e/basic.e2e-test.ts +3 -3
- package/package.json +7 -7
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"description": "The default Vite plugin for React projects."
|
|
10
10
|
},
|
|
11
11
|
"@vitest/browser": {
|
|
12
|
-
"version": "4.1.
|
|
12
|
+
"version": "4.1.9",
|
|
13
13
|
"description": "Run Vitest in the browser."
|
|
14
14
|
},
|
|
15
15
|
"@vitest/browser-playwright": {
|
|
16
|
-
"version": "4.1.
|
|
16
|
+
"version": "4.1.9",
|
|
17
17
|
"description": "Playwright provider for Vitest browser mode."
|
|
18
18
|
},
|
|
19
19
|
"playwright": {
|
|
20
|
-
"version": "1.
|
|
20
|
+
"version": "1.61.0",
|
|
21
21
|
"description": "Framework for Web-browser automation."
|
|
22
22
|
},
|
|
23
23
|
"debug": {
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"description": "TypeScript definitions for debug."
|
|
38
38
|
},
|
|
39
39
|
"@types/node": {
|
|
40
|
-
"version": "
|
|
40
|
+
"version": "26.0.0",
|
|
41
41
|
"description": "TypeScript definitions for Node.js."
|
|
42
42
|
},
|
|
43
43
|
"@vitest/coverage-v8": {
|
|
44
|
-
"version": "4.1.
|
|
44
|
+
"version": "4.1.9",
|
|
45
45
|
"description": "V8 coverage provider for Vitest."
|
|
46
46
|
},
|
|
47
47
|
"conventional-changelog": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"description": "Modern native git hooks made easy."
|
|
54
54
|
},
|
|
55
55
|
"oxlint": {
|
|
56
|
-
"version": "1.
|
|
56
|
+
"version": "1.70.0",
|
|
57
57
|
"description": "A JavaScript linter written in Rust."
|
|
58
58
|
},
|
|
59
59
|
"oxlint-tsgolint": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"description": "TypeScript-specific rules for oxlint."
|
|
62
62
|
},
|
|
63
63
|
"oxfmt": {
|
|
64
|
-
"version": "0.
|
|
64
|
+
"version": "0.55.0",
|
|
65
65
|
"description": "High performance JavaScript / TypeScript formatter."
|
|
66
66
|
},
|
|
67
67
|
"typescript": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"description": "A superset of JavaScript that compiles to clean JavaScript output."
|
|
70
70
|
},
|
|
71
71
|
"vitest": {
|
|
72
|
-
"version": "4.1.
|
|
72
|
+
"version": "4.1.9",
|
|
73
73
|
"description": "A Vite-native unit test framework."
|
|
74
74
|
},
|
|
75
75
|
"commander": {
|
|
@@ -101,11 +101,11 @@
|
|
|
101
101
|
"description": "React package for working with the DOM."
|
|
102
102
|
},
|
|
103
103
|
"@mui/material": {
|
|
104
|
-
"version": "9.
|
|
104
|
+
"version": "9.1.1",
|
|
105
105
|
"description": "Material UI components."
|
|
106
106
|
},
|
|
107
107
|
"@mui/icons-material": {
|
|
108
|
-
"version": "9.
|
|
108
|
+
"version": "9.1.1",
|
|
109
109
|
"description": "Material Design icons distributed as SVG React components."
|
|
110
110
|
},
|
|
111
111
|
"@emotion/react": {
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"description": "Styled components for Emotion."
|
|
118
118
|
},
|
|
119
119
|
"@types/react": {
|
|
120
|
-
"version": "19.2.
|
|
120
|
+
"version": "19.2.17",
|
|
121
121
|
"description": "TypeScript definitions for React."
|
|
122
122
|
},
|
|
123
123
|
"@types/react-dom": {
|
|
@@ -125,23 +125,23 @@
|
|
|
125
125
|
"description": "TypeScript definitions for React DOM."
|
|
126
126
|
},
|
|
127
127
|
"@playwright/test": {
|
|
128
|
-
"version": "1.
|
|
128
|
+
"version": "1.61.0",
|
|
129
129
|
"description": "End-to-end testing framework."
|
|
130
130
|
},
|
|
131
131
|
"@trpc/server": {
|
|
132
|
-
"version": "11.
|
|
132
|
+
"version": "11.18.0",
|
|
133
133
|
"description": "tRPC server library."
|
|
134
134
|
},
|
|
135
135
|
"@trpc/client": {
|
|
136
|
-
"version": "11.
|
|
136
|
+
"version": "11.18.0",
|
|
137
137
|
"description": "tRPC client library."
|
|
138
138
|
},
|
|
139
139
|
"@trpc/react-query": {
|
|
140
|
-
"version": "11.
|
|
140
|
+
"version": "11.18.0",
|
|
141
141
|
"description": "tRPC integration for React Query."
|
|
142
142
|
},
|
|
143
143
|
"@tanstack/react-query": {
|
|
144
|
-
"version": "5.
|
|
144
|
+
"version": "5.101.0",
|
|
145
145
|
"description": "Powerful asynchronous state management for TS/JS."
|
|
146
146
|
},
|
|
147
147
|
"zod": {
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
"description": "TypeScript-first schema validation with static type inference."
|
|
150
150
|
},
|
|
151
151
|
"react-router-dom": {
|
|
152
|
-
"version": "7.
|
|
152
|
+
"version": "7.18.0",
|
|
153
153
|
"description": "Declarative routing for React web applications."
|
|
154
154
|
},
|
|
155
155
|
"release-it": {
|
|
@@ -161,6 +161,7 @@ export const linter = defineConfig({
|
|
|
161
161
|
'unicorn/prefer-module': 'off', // TODO: consider enabling
|
|
162
162
|
'react/jsx-filename-extension': ['error', {extensions: ['.tsx']}],
|
|
163
163
|
'react/jsx-max-depth': ['error', {max: 5}],
|
|
164
|
+
'react/jsx-no-literals': 'off',
|
|
164
165
|
'react/react-in-jsx-scope': 'off',
|
|
165
166
|
'vitest/max-expects': 'off',
|
|
166
167
|
'vitest/no-conditional-in-test': 'off',
|
|
@@ -5,7 +5,7 @@ import {useAuth} from '../contexts/AuthContext.js';
|
|
|
5
5
|
import {CircularProgress, Box} from '@mui/material';
|
|
6
6
|
|
|
7
7
|
export const ProtectedRoute = (): ReactNode => {
|
|
8
|
-
const {token, isLoading} = useAuth();
|
|
8
|
+
const {token, user, isLoading} = useAuth();
|
|
9
9
|
|
|
10
10
|
if (isLoading) {
|
|
11
11
|
return (
|
|
@@ -15,7 +15,7 @@ export const ProtectedRoute = (): ReactNode => {
|
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
if (token === null || token === '') {
|
|
18
|
+
if (token === null || token === '' || user === null) {
|
|
19
19
|
return <Navigate to="/login" replace />;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/* eslint-disable import/no-relative-parent-imports */
|
|
2
2
|
/* eslint-disable react/only-export-components */
|
|
3
3
|
/* eslint-disable react/jsx-no-constructed-context-values */
|
|
4
|
-
|
|
5
|
-
import {createContext, useContext, useState, useEffect, type ReactNode} from 'react';
|
|
4
|
+
import {createContext, useContext, useState, type ReactNode} from 'react';
|
|
6
5
|
import {trpc} from '../trpc.js';
|
|
7
6
|
|
|
8
7
|
type User = {
|
|
@@ -23,32 +22,24 @@ const AuthContext = createContext<AuthContextType | undefined>(undefined);
|
|
|
23
22
|
|
|
24
23
|
export const AuthProvider = ({children}: {children: ReactNode}): ReactNode => {
|
|
25
24
|
const [token, setToken] = useState(localStorage.getItem('token'));
|
|
26
|
-
const [
|
|
25
|
+
const [loggedInUser, setLoggedInUser] = useState<User | null>(null);
|
|
27
26
|
|
|
28
27
|
const {data: me, isLoading} = trpc.auth.me.useQuery(undefined, {
|
|
29
28
|
enabled: Boolean(token),
|
|
30
29
|
retry: false,
|
|
31
30
|
});
|
|
31
|
+
const user = me ?? loggedInUser;
|
|
32
32
|
|
|
33
33
|
const logout = (): void => {
|
|
34
34
|
localStorage.removeItem('token');
|
|
35
35
|
setToken(null);
|
|
36
|
-
|
|
36
|
+
setLoggedInUser(null);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (me !== undefined && me !== null) {
|
|
41
|
-
setUser(me);
|
|
42
|
-
} else if (!isLoading && token !== null && token !== '') {
|
|
43
|
-
// Token might be invalid
|
|
44
|
-
logout();
|
|
45
|
-
}
|
|
46
|
-
}, [me, isLoading, token]);
|
|
47
|
-
|
|
48
39
|
const login = (newToken: string, newUser: User): void => {
|
|
49
40
|
localStorage.setItem('token', newToken);
|
|
50
41
|
setToken(newToken);
|
|
51
|
-
|
|
42
|
+
setLoggedInUser(newUser);
|
|
52
43
|
};
|
|
53
44
|
|
|
54
45
|
return <AuthContext.Provider value={{user, token, isLoading, login, logout}}>{children}</AuthContext.Provider>;
|
|
@@ -7,8 +7,8 @@ test('has title', async ({page}) => {
|
|
|
7
7
|
|
|
8
8
|
test('can login', async ({page}) => {
|
|
9
9
|
await page.goto('/login');
|
|
10
|
-
await page.fill('input[
|
|
11
|
-
await page.fill('input[
|
|
10
|
+
await page.fill('input[type="email"]', 'demo@example.com');
|
|
11
|
+
await page.fill('input[type="password"]', 'password');
|
|
12
12
|
await page.click('button[type="submit"]');
|
|
13
|
-
await expect(page).toHaveURL('/');
|
|
13
|
+
await expect(page).toHaveURL('/dashboard');
|
|
14
14
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-template-project",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "An ultra-modular, type-safe Node.js CLI tool used to scaffold new project templates (CLI, Webpage, Webapp, Fullstack) with best-practice configurations pre-installed.",
|
|
6
6
|
"keywords": [
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"./package.json": "./package.json"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@clack/prompts": "1.
|
|
55
|
+
"@clack/prompts": "1.6.0",
|
|
56
56
|
"commander": "15.0.0",
|
|
57
57
|
"debug": "4.4.3",
|
|
58
58
|
"execa": "9.6.1",
|
|
@@ -63,20 +63,20 @@
|
|
|
63
63
|
"@commitlint/config-conventional": "21.0.2",
|
|
64
64
|
"@types/cli-progress": "3.11.6",
|
|
65
65
|
"@types/debug": "4.1.13",
|
|
66
|
-
"@types/node": "
|
|
67
|
-
"@vitest/coverage-v8": "4.1.
|
|
66
|
+
"@types/node": "26.0.0",
|
|
67
|
+
"@vitest/coverage-v8": "4.1.9",
|
|
68
68
|
"conventional-changelog": "7.2.0",
|
|
69
69
|
"conventional-changelog-angular": "8.3.1",
|
|
70
70
|
"eslint-plugin-regexp": "3.1.0",
|
|
71
71
|
"husky": "9.1.7",
|
|
72
|
-
"oxfmt": "0.
|
|
73
|
-
"oxlint": "1.
|
|
72
|
+
"oxfmt": "0.55.0",
|
|
73
|
+
"oxlint": "1.70.0",
|
|
74
74
|
"oxlint-tsgolint": "0.23.0",
|
|
75
75
|
"release-it": "20.2.0",
|
|
76
76
|
"rimraf": "6.1.3",
|
|
77
77
|
"typescript": "6.0.3",
|
|
78
78
|
"vite": "8.0.16",
|
|
79
|
-
"vitest": "4.1.
|
|
79
|
+
"vitest": "4.1.9"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": ">=22"
|