create-react-starter-kit 1.0.5 → 1.0.7
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/cli-args.d.ts.map +1 -1
- package/dist/cli-args.js +2 -1
- package/dist/cli-args.js.map +1 -1
- package/dist/generator/dependencies.d.ts.map +1 -1
- package/dist/generator/dependencies.js +5 -0
- package/dist/generator/dependencies.js.map +1 -1
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +5 -0
- package/dist/generator/index.js.map +1 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +8 -0
- package/dist/prompts/index.js.map +1 -1
- package/dist/templates/README.md.ejs +1 -1
- package/dist/templates/__when_apiLayer_axios__/src/services/api.ts.ejs +23 -0
- package/dist/templates/__when_apiLayer_axios__/src/services/http/client.ts.ejs +174 -0
- package/dist/templates/__when_apiLayer_axios__/src/services/http/errors.ts.ejs +81 -0
- package/dist/templates/__when_apiLayer_axios__/src/services/http/index.ts.ejs +5 -0
- package/dist/templates/__when_apiLayer_fetch__/src/services/api.ts.ejs +22 -0
- package/dist/templates/__when_apiLayer_fetch__/src/services/http/client.ts.ejs +195 -0
- package/dist/templates/__when_apiLayer_fetch__/src/services/http/errors.ts.ejs +81 -0
- package/dist/templates/__when_apiLayer_fetch__/src/services/http/index.ts.ejs +5 -0
- package/dist/templates/__when_buildTool_vite__/vite.config.ts.ejs +9 -1
- package/dist/templates/__when_buildTool_webpack__/webpack.config.js.ejs +1 -1
- package/dist/templates/__when_e2eTesting_cypress__/cypress.config.ts.ejs +2 -1
- package/dist/templates/__when_e2eTesting_playwright__/playwright.config.ts.ejs +4 -3
- package/dist/templates/__when_serverState_rtk-query__/src/store/postsApi.ts.ejs +28 -5
- package/dist/templates/__when_unitTesting_jest__/jest.config.json.ejs +8 -0
- package/dist/templates/__when_unitTesting_vitest__/tests/feedback.test.tsx.ejs +16 -0
- package/dist/templates/__when_unitTesting_vitest__/tests/posts.test.tsx.ejs +1 -3
- package/dist/templates/__when_unitTesting_vitest__/vitest.config.ts.ejs +31 -0
- package/dist/templates/docs/architecture.md.ejs +44 -25
- package/dist/templates/docs/best-practices.md.ejs +39 -3
- package/dist/templates/docs/examples/README.md.ejs +10 -10
- package/dist/templates/docs/examples/api.md.ejs +165 -8
- package/dist/templates/docs/examples/data-fetching.md.ejs +107 -6
- package/dist/templates/docs/examples/forms.md.ejs +66 -6
- package/dist/templates/docs/examples/state.md.ejs +50 -6
- package/dist/templates/docs/examples/styling.md.ejs +56 -8
- package/dist/templates/docs/examples/testing.md.ejs +63 -9
- package/dist/templates/docs/getting-started.md.ejs +63 -15
- package/dist/templates/docs/selected-stack.md.ejs +110 -8
- package/dist/templates/src/features/feedback/FeedbackForm.tsx.ejs +10 -0
- package/dist/templates/src/features/posts/PostsPanel.tsx.ejs +1 -1
- package/dist/templates/src/routes/PostsPage.tsx.ejs +7 -2
- package/dist/templates/src/types/index.ts.ejs +1 -1
- package/dist/templates/src/types/models.ts.ejs +18 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/templates/README.md.ejs +1 -1
- package/templates/__when_apiLayer_axios__/src/services/api.ts.ejs +23 -0
- package/templates/__when_apiLayer_axios__/src/services/http/client.ts.ejs +174 -0
- package/templates/__when_apiLayer_axios__/src/services/http/errors.ts.ejs +81 -0
- package/templates/__when_apiLayer_axios__/src/services/http/index.ts.ejs +5 -0
- package/templates/__when_apiLayer_fetch__/src/services/api.ts.ejs +22 -0
- package/templates/__when_apiLayer_fetch__/src/services/http/client.ts.ejs +195 -0
- package/templates/__when_apiLayer_fetch__/src/services/http/errors.ts.ejs +81 -0
- package/templates/__when_apiLayer_fetch__/src/services/http/index.ts.ejs +5 -0
- package/templates/__when_buildTool_vite__/vite.config.ts.ejs +9 -1
- package/templates/__when_buildTool_webpack__/webpack.config.js.ejs +1 -1
- package/templates/__when_e2eTesting_cypress__/cypress.config.ts.ejs +2 -1
- package/templates/__when_e2eTesting_playwright__/playwright.config.ts.ejs +4 -3
- package/templates/__when_serverState_rtk-query__/src/store/postsApi.ts.ejs +28 -5
- package/templates/__when_unitTesting_jest__/jest.config.json.ejs +8 -0
- package/templates/__when_unitTesting_vitest__/tests/feedback.test.tsx.ejs +16 -0
- package/templates/__when_unitTesting_vitest__/tests/posts.test.tsx.ejs +1 -3
- package/templates/__when_unitTesting_vitest__/vitest.config.ts.ejs +31 -0
- package/templates/docs/architecture.md.ejs +44 -25
- package/templates/docs/best-practices.md.ejs +39 -3
- package/templates/docs/examples/README.md.ejs +10 -10
- package/templates/docs/examples/api.md.ejs +165 -8
- package/templates/docs/examples/data-fetching.md.ejs +107 -6
- package/templates/docs/examples/forms.md.ejs +66 -6
- package/templates/docs/examples/state.md.ejs +50 -6
- package/templates/docs/examples/styling.md.ejs +56 -8
- package/templates/docs/examples/testing.md.ejs +63 -9
- package/templates/docs/getting-started.md.ejs +63 -15
- package/templates/docs/selected-stack.md.ejs +110 -8
- package/templates/src/features/feedback/FeedbackForm.tsx.ejs +10 -0
- package/templates/src/features/posts/PostsPanel.tsx.ejs +1 -1
- package/templates/src/routes/PostsPage.tsx.ejs +7 -2
- package/templates/src/types/index.ts.ejs +1 -1
- package/templates/src/types/models.ts.ejs +18 -0
- package/dist/templates/src/services/api.ts.ejs +0 -84
- package/templates/src/services/api.ts.ejs +0 -84
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
<% if (apiLayer === 'axios') { -%>
|
|
2
|
-
import axios from 'axios';
|
|
3
|
-
import { env } from '@/config/env';
|
|
4
|
-
|
|
5
|
-
const baseURL = env.apiBaseUrl;
|
|
6
|
-
|
|
7
|
-
export const apiClient = axios.create({
|
|
8
|
-
baseURL,
|
|
9
|
-
headers: { 'Content-Type': 'application/json' },
|
|
10
|
-
timeout: 10_000,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
apiClient.interceptors.response.use(
|
|
14
|
-
(response) => response,
|
|
15
|
-
(error) => {
|
|
16
|
-
console.error('[api]', error);
|
|
17
|
-
return Promise.reject(error);
|
|
18
|
-
},
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export async function apiGet<% if (isTypeScript) { %><T = unknown><% } %>(path<% if (isTypeScript) { %>: string<% } %>)<% if (isTypeScript) { %>: Promise<T><% } %> {
|
|
22
|
-
const { data } = await apiClient.get<% if (isTypeScript) { %><T><% } %>(path);
|
|
23
|
-
return data;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function apiPost<% if (isTypeScript) { %><T = unknown, B = unknown><% } %>(
|
|
27
|
-
path<% if (isTypeScript) { %>: string<% } %>,
|
|
28
|
-
body<% if (isTypeScript) { %>: B<% } %>,
|
|
29
|
-
)<% if (isTypeScript) { %>: Promise<T><% } %> {
|
|
30
|
-
const { data } = await apiClient.post<% if (isTypeScript) { %><T><% } %>(path, body);
|
|
31
|
-
return data;
|
|
32
|
-
}
|
|
33
|
-
<% } else { -%>
|
|
34
|
-
import { env } from '@/config/env';
|
|
35
|
-
|
|
36
|
-
const baseURL = env.apiBaseUrl;
|
|
37
|
-
|
|
38
|
-
async function request<% if (isTypeScript) { %><T = unknown><% } %>(
|
|
39
|
-
path<% if (isTypeScript) { %>: string<% } %>,
|
|
40
|
-
init<% if (isTypeScript) { %>?: RequestInit<% } %>,
|
|
41
|
-
)<% if (isTypeScript) { %>: Promise<T><% } %> {
|
|
42
|
-
const response = await fetch(`${baseURL}${path}`, {
|
|
43
|
-
headers: { 'Content-Type': 'application/json', ...(init?.headers ?? {}) },
|
|
44
|
-
...init,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
if (!response.ok) {
|
|
48
|
-
throw new Error(`Request failed: ${response.status}`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return response.json();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export async function apiGet<% if (isTypeScript) { %><T = unknown><% } %>(path<% if (isTypeScript) { %>: string<% } %>)<% if (isTypeScript) { %>: Promise<T><% } %> {
|
|
55
|
-
return request<% if (isTypeScript) { %><T><% } %>(path);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export async function apiPost<% if (isTypeScript) { %><T = unknown, B = unknown><% } %>(
|
|
59
|
-
path<% if (isTypeScript) { %>: string<% } %>,
|
|
60
|
-
body<% if (isTypeScript) { %>: B<% } %>,
|
|
61
|
-
)<% if (isTypeScript) { %>: Promise<T><% } %> {
|
|
62
|
-
return request<% if (isTypeScript) { %><T><% } %>(path, {
|
|
63
|
-
method: 'POST',
|
|
64
|
-
body: JSON.stringify(body),
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
<% } -%>
|
|
68
|
-
|
|
69
|
-
<% if (isTypeScript) { -%>
|
|
70
|
-
export interface Post {
|
|
71
|
-
userId: number;
|
|
72
|
-
id: number;
|
|
73
|
-
title: string;
|
|
74
|
-
body: string;
|
|
75
|
-
}
|
|
76
|
-
<% } -%>
|
|
77
|
-
|
|
78
|
-
export async function fetchPosts() {
|
|
79
|
-
return apiGet<% if (isTypeScript) { %><Post[]><% } %>('/posts?_limit=5');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export async function createFeedback(payload<% if (isTypeScript) { %>: { name: string; email: string; message: string }<% } %>) {
|
|
83
|
-
return apiPost('/posts', payload);
|
|
84
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
<% if (apiLayer === 'axios') { -%>
|
|
2
|
-
import axios from 'axios';
|
|
3
|
-
import { env } from '@/config/env';
|
|
4
|
-
|
|
5
|
-
const baseURL = env.apiBaseUrl;
|
|
6
|
-
|
|
7
|
-
export const apiClient = axios.create({
|
|
8
|
-
baseURL,
|
|
9
|
-
headers: { 'Content-Type': 'application/json' },
|
|
10
|
-
timeout: 10_000,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
apiClient.interceptors.response.use(
|
|
14
|
-
(response) => response,
|
|
15
|
-
(error) => {
|
|
16
|
-
console.error('[api]', error);
|
|
17
|
-
return Promise.reject(error);
|
|
18
|
-
},
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export async function apiGet<% if (isTypeScript) { %><T = unknown><% } %>(path<% if (isTypeScript) { %>: string<% } %>)<% if (isTypeScript) { %>: Promise<T><% } %> {
|
|
22
|
-
const { data } = await apiClient.get<% if (isTypeScript) { %><T><% } %>(path);
|
|
23
|
-
return data;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function apiPost<% if (isTypeScript) { %><T = unknown, B = unknown><% } %>(
|
|
27
|
-
path<% if (isTypeScript) { %>: string<% } %>,
|
|
28
|
-
body<% if (isTypeScript) { %>: B<% } %>,
|
|
29
|
-
)<% if (isTypeScript) { %>: Promise<T><% } %> {
|
|
30
|
-
const { data } = await apiClient.post<% if (isTypeScript) { %><T><% } %>(path, body);
|
|
31
|
-
return data;
|
|
32
|
-
}
|
|
33
|
-
<% } else { -%>
|
|
34
|
-
import { env } from '@/config/env';
|
|
35
|
-
|
|
36
|
-
const baseURL = env.apiBaseUrl;
|
|
37
|
-
|
|
38
|
-
async function request<% if (isTypeScript) { %><T = unknown><% } %>(
|
|
39
|
-
path<% if (isTypeScript) { %>: string<% } %>,
|
|
40
|
-
init<% if (isTypeScript) { %>?: RequestInit<% } %>,
|
|
41
|
-
)<% if (isTypeScript) { %>: Promise<T><% } %> {
|
|
42
|
-
const response = await fetch(`${baseURL}${path}`, {
|
|
43
|
-
headers: { 'Content-Type': 'application/json', ...(init?.headers ?? {}) },
|
|
44
|
-
...init,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
if (!response.ok) {
|
|
48
|
-
throw new Error(`Request failed: ${response.status}`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return response.json();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export async function apiGet<% if (isTypeScript) { %><T = unknown><% } %>(path<% if (isTypeScript) { %>: string<% } %>)<% if (isTypeScript) { %>: Promise<T><% } %> {
|
|
55
|
-
return request<% if (isTypeScript) { %><T><% } %>(path);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export async function apiPost<% if (isTypeScript) { %><T = unknown, B = unknown><% } %>(
|
|
59
|
-
path<% if (isTypeScript) { %>: string<% } %>,
|
|
60
|
-
body<% if (isTypeScript) { %>: B<% } %>,
|
|
61
|
-
)<% if (isTypeScript) { %>: Promise<T><% } %> {
|
|
62
|
-
return request<% if (isTypeScript) { %><T><% } %>(path, {
|
|
63
|
-
method: 'POST',
|
|
64
|
-
body: JSON.stringify(body),
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
<% } -%>
|
|
68
|
-
|
|
69
|
-
<% if (isTypeScript) { -%>
|
|
70
|
-
export interface Post {
|
|
71
|
-
userId: number;
|
|
72
|
-
id: number;
|
|
73
|
-
title: string;
|
|
74
|
-
body: string;
|
|
75
|
-
}
|
|
76
|
-
<% } -%>
|
|
77
|
-
|
|
78
|
-
export async function fetchPosts() {
|
|
79
|
-
return apiGet<% if (isTypeScript) { %><Post[]><% } %>('/posts?_limit=5');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export async function createFeedback(payload<% if (isTypeScript) { %>: { name: string; email: string; message: string }<% } %>) {
|
|
83
|
-
return apiPost('/posts', payload);
|
|
84
|
-
}
|