create-packer 1.32.0 → 1.32.2

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 (25) hide show
  1. package/package.json +1 -1
  2. package/template/web-app/react/README.md +1 -1
  3. package/template/web-app/react/domain/app/components/app-context.tsx +6 -3
  4. package/template/web-app/react/package.json +2 -1
  5. package/template/web-app/react/pages/home/home.mock.ts +12 -9
  6. package/template/web-app/react/pages/home/home.tsx +4 -7
  7. package/template/web-app/react/shared/service/home.ts +10 -0
  8. package/template/web-app/react/shared/service/index.ts +2 -1
  9. package/template/web-app/react/shared/service/request.ts +1 -3
  10. package/template/web-app/react-webpack/domain/app/components/app-context.tsx +6 -3
  11. package/template/web-app/react-webpack/global.d.ts +4 -2
  12. package/template/web-app/react-webpack/package.json +1 -0
  13. package/template/web-app/react-webpack/pages/home/home.tsx +5 -0
  14. package/template/web-app/react-webpack/shared/service/home.ts +8 -0
  15. package/template/web-app/react-webpack/shared/service/index.ts +2 -1
  16. package/template/web-app/react-webpack/shared/service/request.ts +1 -3
  17. package/template/web-app/vue/main.ts +2 -1
  18. package/template/web-app/vue/package.json +71 -70
  19. package/template/web-app/vue/pages/home/home.mock.ts +12 -9
  20. package/template/web-app/vue/pages/home/home.vue +10 -7
  21. package/template/web-app/vue/shared/service/home.ts +10 -0
  22. package/template/web-app/vue/shared/service/index.ts +2 -1
  23. package/template/web-app/vue/shared/service/request.ts +1 -3
  24. package/template/web-extension/package.json +1 -0
  25. package/template/web-extension/shared/components/app-context.tsx +8 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.32.0",
3
+ "version": "1.32.2",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -7,7 +7,7 @@
7
7
  - Typescript
8
8
  - react-router
9
9
  - Zustand
10
- - Tailwindcss
10
+ - styled-components
11
11
  - Eslint
12
12
  - Prettier
13
13
  - axios
@@ -1,14 +1,17 @@
1
- import { FunctionComponent, StrictMode } from 'react'
1
+ import { FunctionComponent } from 'react'
2
2
  import { ThemeProvider } from 'styled-components'
3
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
3
4
  import { theme } from '@/shared/theme'
4
5
 
6
+ const queryClient = new QueryClient()
7
+
5
8
  export interface propsType {
6
9
  children: React.ReactNode
7
10
  }
8
11
  export const Root: FunctionComponent<propsType> = props => {
9
12
  return (
10
- <StrictMode>
13
+ <QueryClientProvider client={queryClient}>
11
14
  <ThemeProvider theme={theme}>{props.children}</ThemeProvider>
12
- </StrictMode>
15
+ </QueryClientProvider>
13
16
  )
14
17
  }
@@ -19,6 +19,7 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "1k-types": "1.2.0",
22
+ "@tanstack/react-query": "5.51.15",
22
23
  "axios": "1.3.6",
23
24
  "define-zustand": "3.1.1",
24
25
  "immer": "10.0.1",
@@ -35,6 +36,7 @@
35
36
  "@commitlint/cli": "17.6.1",
36
37
  "@commitlint/config-conventional": "17.6.1",
37
38
  "@commitlint/cz-commitlint": "17.5.0",
39
+ "@faker-js/faker": "8.4.1",
38
40
  "@rollup/plugin-eslint": "9.0.5",
39
41
  "@types/lodash-es": "4.17.7",
40
42
  "@types/mockjs": "1.0.7",
@@ -56,7 +58,6 @@
56
58
  "eslint-plugin-react-hooks": "4.6.0",
57
59
  "husky": "8.0.3",
58
60
  "inquirer": "^8.1.2",
59
- "mockjs": "1.1.0",
60
61
  "postcss": "8.4.35",
61
62
  "postcss-import": "16.0.1",
62
63
  "postcss-nesting": "12.0.3",
@@ -1,16 +1,19 @@
1
- import Mock from 'mockjs'
1
+ import { faker } from '@faker-js/faker'
2
2
  import { defineMock } from '@/mockUtils'
3
3
  import { API } from '@/shared/service'
4
+
4
5
  export default defineMock([
5
6
  {
6
7
  url: API.HOME_DATA,
7
- body: Mock.mock({
8
- 'data|10': [
9
- {
10
- name: '@string',
11
- age: '@natural'
12
- }
13
- ]
14
- })
8
+ body: faker.helpers.multiple(
9
+ () => ({
10
+ id: faker.string.uuid(),
11
+ name: faker.person.fullName(),
12
+ age: faker.number.int({ max: 110 })
13
+ }),
14
+ {
15
+ count: 10
16
+ }
17
+ )
15
18
  }
16
19
  ])
@@ -1,13 +1,10 @@
1
- import { useEffect } from 'react'
2
- import { request, API } from '@/shared/service'
1
+ import { useHomeQuery } from '@/shared/service'
3
2
  import { StyledRoot } from './home.styled'
4
3
 
5
4
  export default function Home() {
6
- useEffect(() => {
7
- request.post(API.HOME_DATA).then(({ data }) => {
8
- console.log('data', data)
9
- })
10
- }, [])
5
+ const query = useHomeQuery()
6
+
7
+ console.log('data', query.data)
11
8
 
12
9
  return <StyledRoot>sdfs</StyledRoot>
13
10
  }
@@ -0,0 +1,10 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+ import { request } from './request'
3
+ import { HOME_DATA } from './api'
4
+
5
+ export function useHomeQuery() {
6
+ return useQuery({
7
+ queryKey: ['home_data'],
8
+ queryFn: () => request.post(HOME_DATA)
9
+ })
10
+ }
@@ -1,2 +1,3 @@
1
- export { default as request } from './request'
1
+ export * from './request'
2
2
  export * as API from './api'
3
+ export * from './home'
@@ -1,7 +1,5 @@
1
1
  import axios from 'axios'
2
2
 
3
- const request = axios.create({
3
+ export const request = axios.create({
4
4
  baseURL: import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_HOST
5
5
  })
6
-
7
- export default request
@@ -1,14 +1,17 @@
1
- import { FunctionComponent, StrictMode } from 'react'
1
+ import { FunctionComponent } from 'react'
2
2
  import { ThemeProvider } from 'styled-components'
3
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
3
4
  import { theme } from '@/shared/theme'
4
5
 
6
+ const queryClient = new QueryClient()
7
+
5
8
  export interface propsType {
6
9
  children: React.ReactNode
7
10
  }
8
11
  export const Root: FunctionComponent<propsType> = props => {
9
12
  return (
10
- <StrictMode>
13
+ <QueryClientProvider client={queryClient}>
11
14
  <ThemeProvider theme={theme}>{props.children}</ThemeProvider>
12
- </StrictMode>
15
+ </QueryClientProvider>
13
16
  )
14
17
  }
@@ -1,8 +1,10 @@
1
1
  import 'styled-components'
2
2
  import { themeType } from './shared/theme'
3
3
 
4
- declare const ENV_BASE_URL: string
5
- declare const ENV_API_HOST: string
4
+ declare global {
5
+ const ENV_BASE_URL: string
6
+ const ENV_API_HOST: string
7
+ }
6
8
 
7
9
  declare module '*.css'
8
10
  declare module '*.less'
@@ -20,6 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "1k-types": "1.2.0",
23
+ "@tanstack/react-query": "5.51.15",
23
24
  "axios": "1.6.7",
24
25
  "define-zustand": "3.1.1",
25
26
  "immer": "10.0.3",
@@ -1,5 +1,10 @@
1
+ import { useHomeQuery } from '@/shared/service'
1
2
  import { StyledRoot } from './home.styled'
2
3
 
3
4
  export default function Home() {
5
+ const homeQuery = useHomeQuery()
6
+
7
+ console.log('data', homeQuery.data?.data)
8
+
4
9
  return <StyledRoot>sdsddds</StyledRoot>
5
10
  }
@@ -0,0 +1,8 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+
3
+ export function useHomeQuery() {
4
+ return useQuery({
5
+ queryKey: ['home_data'],
6
+ queryFn: () => Promise.resolve({ data: { data: [] } })
7
+ })
8
+ }
@@ -1 +1,2 @@
1
- export { default as request } from './request'
1
+ export * from './request'
2
+ export * from './home'
@@ -1,7 +1,5 @@
1
1
  import axios from 'axios'
2
2
 
3
- const request = axios.create({
3
+ export const request = axios.create({
4
4
  baseURL: ENV_BASE_URL + ENV_API_HOST
5
5
  })
6
-
7
- export default request
@@ -1,6 +1,7 @@
1
1
  import { createPinia } from 'pinia'
2
+ import { VueQueryPlugin } from '@tanstack/vue-query'
2
3
  import { router } from '@/router'
3
4
  import { app } from '@/domain/app'
4
5
  import './style.css'
5
6
 
6
- app.use(createPinia()).use(router).mount('#app')
7
+ app.use(VueQueryPlugin).use(createPinia()).use(router).mount('#app')
@@ -1,70 +1,71 @@
1
- {
2
- "name": "vue-vite",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "prepare": "husky install",
8
- "dev": "vite",
9
- "build": "vue-tsc --noEmit && vite build",
10
- "build:analyse": "tsc --noEmit && vite build --mode analyse",
11
- "preview": "vite preview",
12
- "format": "prettier --write \"**/*.{ts,js,tsx,jsx,json,vue,css,scss,less}\"",
13
- "lint": "vue-tsc --noEmit && eslint **/*.{ts,tsx,js,jsx,vue} --no-error-on-unmatched-pattern && stylelint **/*.{css,scss,less}",
14
- "lint:fix": "eslint **/*.{ts,tsx,js,jsx,vue} --fix && stylelint **/*.{css,scss,less} --fix",
15
- "cz": "cz",
16
- "push": "npm run commit && git push",
17
- "commit": "git add . && npm run cz",
18
- "up:vite": "pnpm up vite @vitejs/* vite-plugin-* -L"
19
- },
20
- "dependencies": {
21
- "1k-types": "1.2.0",
22
- "axios": "1.3.6",
23
- "lodash-es": "4.17.21",
24
- "pinia": "2.1.7",
25
- "vue": "3.4.21",
26
- "vue-router": "4.3.0"
27
- },
28
- "devDependencies": {
29
- "@commitlint/cli": "17.6.1",
30
- "@commitlint/config-conventional": "17.6.1",
31
- "@commitlint/cz-commitlint": "17.5.0",
32
- "@rollup/plugin-eslint": "9.0.5",
33
- "@types/lodash-es": "4.17.12",
34
- "@types/mockjs": "1.0.10",
35
- "@typescript-eslint/eslint-plugin": "7.6.0",
36
- "@typescript-eslint/parser": "7.6.0",
37
- "@vitejs/plugin-vue": "5.0.5",
38
- "@vitejs/plugin-vue-jsx": "4.0.0",
39
- "autoprefixer": "10.4.14",
40
- "commitizen": "4.3.0",
41
- "cssnano": "6.0.0",
42
- "eslint": "8.56.0",
43
- "eslint-import-resolver-typescript": "3.6.1",
44
- "eslint-plugin-import": "2.29.1",
45
- "eslint-plugin-prettier": "5.1.3",
46
- "eslint-plugin-vue": "9.21.1",
47
- "husky": "8.0.3",
48
- "inquirer": "^8.1.2",
49
- "mockjs": "1.1.0",
50
- "postcss": "8.4.38",
51
- "postcss-import": "16.1.0",
52
- "postcss-nesting": "12.1.1",
53
- "prettier": "3.2.5",
54
- "rollup-plugin-visualizer": "5.12.0",
55
- "stylelint": "16.3.1",
56
- "stylelint-config-standard-scss": "13.1.0",
57
- "tailwindcss": "3.4.3",
58
- "typescript": "5.5.2",
59
- "vite": "5.3.3",
60
- "vite-plugin-mock-dev-server": "1.5.1",
61
- "vite-plugin-stylelint": "5.3.1",
62
- "vite-svg-loader": "5.1.0",
63
- "vue-tsc": "2.0.11"
64
- },
65
- "config": {
66
- "commitizen": {
67
- "path": "@commitlint/cz-commitlint"
68
- }
69
- }
70
- }
1
+ {
2
+ "name": "vue-vite",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "prepare": "husky install",
8
+ "dev": "vite",
9
+ "build": "vue-tsc --noEmit && vite build",
10
+ "build:analyse": "tsc --noEmit && vite build --mode analyse",
11
+ "preview": "vite preview",
12
+ "format": "prettier --write \"**/*.{ts,js,tsx,jsx,json,vue,css,scss,less}\"",
13
+ "lint": "vue-tsc --noEmit && eslint **/*.{ts,tsx,js,jsx,vue} --no-error-on-unmatched-pattern && stylelint **/*.{css,scss,less}",
14
+ "lint:fix": "eslint **/*.{ts,tsx,js,jsx,vue} --fix && stylelint **/*.{css,scss,less} --fix",
15
+ "cz": "cz",
16
+ "push": "npm run commit && git push",
17
+ "commit": "git add . && npm run cz",
18
+ "up:vite": "pnpm up vite @vitejs/* vite-plugin-* -L"
19
+ },
20
+ "dependencies": {
21
+ "1k-types": "1.2.0",
22
+ "@tanstack/vue-query": "5.51.15",
23
+ "axios": "1.3.6",
24
+ "lodash-es": "4.17.21",
25
+ "pinia": "2.1.7",
26
+ "vue": "3.4.21",
27
+ "vue-router": "4.3.0"
28
+ },
29
+ "devDependencies": {
30
+ "@commitlint/cli": "17.6.1",
31
+ "@commitlint/config-conventional": "17.6.1",
32
+ "@commitlint/cz-commitlint": "17.5.0",
33
+ "@faker-js/faker": "8.4.1",
34
+ "@rollup/plugin-eslint": "9.0.5",
35
+ "@types/lodash-es": "4.17.12",
36
+ "@types/mockjs": "1.0.10",
37
+ "@typescript-eslint/eslint-plugin": "7.6.0",
38
+ "@typescript-eslint/parser": "7.6.0",
39
+ "@vitejs/plugin-vue": "5.0.5",
40
+ "@vitejs/plugin-vue-jsx": "4.0.0",
41
+ "autoprefixer": "10.4.14",
42
+ "commitizen": "4.3.0",
43
+ "cssnano": "6.0.0",
44
+ "eslint": "8.56.0",
45
+ "eslint-import-resolver-typescript": "3.6.1",
46
+ "eslint-plugin-import": "2.29.1",
47
+ "eslint-plugin-prettier": "5.1.3",
48
+ "eslint-plugin-vue": "9.21.1",
49
+ "husky": "8.0.3",
50
+ "inquirer": "8.1.2",
51
+ "postcss": "8.4.38",
52
+ "postcss-import": "16.1.0",
53
+ "postcss-nesting": "12.1.1",
54
+ "prettier": "3.2.5",
55
+ "rollup-plugin-visualizer": "5.12.0",
56
+ "stylelint": "16.3.1",
57
+ "stylelint-config-standard-scss": "13.1.0",
58
+ "tailwindcss": "3.4.3",
59
+ "typescript": "5.5.2",
60
+ "vite": "5.3.3",
61
+ "vite-plugin-mock-dev-server": "1.5.1",
62
+ "vite-plugin-stylelint": "5.3.1",
63
+ "vite-svg-loader": "5.1.0",
64
+ "vue-tsc": "2.0.11"
65
+ },
66
+ "config": {
67
+ "commitizen": {
68
+ "path": "@commitlint/cz-commitlint"
69
+ }
70
+ }
71
+ }
@@ -1,16 +1,19 @@
1
- import Mock from 'mockjs'
1
+ import { faker } from '@faker-js/faker'
2
2
  import { defineMock } from '@/mockUtils'
3
3
  import { API } from '@/shared/service'
4
+
4
5
  export default defineMock([
5
6
  {
6
7
  url: API.HOME_DATA,
7
- body: Mock.mock({
8
- 'data|10': [
9
- {
10
- name: '@string',
11
- age: '@natural'
12
- }
13
- ]
14
- })
8
+ body: faker.helpers.multiple(
9
+ () => ({
10
+ id: faker.string.uuid(),
11
+ name: faker.person.fullName(),
12
+ age: faker.number.int({ max: 110 })
13
+ }),
14
+ {
15
+ count: 10
16
+ }
17
+ )
15
18
  }
16
19
  ])
@@ -1,13 +1,16 @@
1
- <template>
2
- <div>Home</div>
3
- </template>
4
-
5
1
  <script setup lang="ts">
6
- import { request, API } from '@/shared/service'
2
+ import { watch } from 'vue'
3
+ import { useHomeQuery } from '@/shared/service'
4
+
5
+ const { data } = useHomeQuery()
7
6
 
8
- request.post(API.HOME_DATA).then(({ data }) => {
9
- console.log('data', data)
7
+ watch(data, data => {
8
+ console.log('data', data?.data)
10
9
  })
11
10
  </script>
12
11
 
12
+ <template>
13
+ <div>Home</div>
14
+ </template>
15
+
13
16
  <style scoped></style>
@@ -0,0 +1,10 @@
1
+ import { useQuery } from '@tanstack/vue-query'
2
+ import { request } from './request'
3
+ import { HOME_DATA } from './api'
4
+
5
+ export function useHomeQuery() {
6
+ return useQuery({
7
+ queryKey: ['home_data'],
8
+ queryFn: () => request.post(HOME_DATA)
9
+ })
10
+ }
@@ -1,2 +1,3 @@
1
- export { default as request } from './request'
1
+ export * from './request'
2
2
  export * as API from './api'
3
+ export * from './home'
@@ -1,7 +1,5 @@
1
1
  import axios from 'axios'
2
2
 
3
- const request = axios.create({
3
+ export const request = axios.create({
4
4
  baseURL: import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_HOST
5
5
  })
6
-
7
- export default request
@@ -17,6 +17,7 @@
17
17
  "commit": "git add . && npm run cz"
18
18
  },
19
19
  "dependencies": {
20
+ "@tanstack/react-query": "5.51.15",
20
21
  "axios": "^1.7.2",
21
22
  "define-zustand": "3.1.1",
22
23
  "immer": "10.0.1",
@@ -1,7 +1,14 @@
1
1
  import { FunctionComponent, ReactNode } from 'react'
2
2
  import { ThemeProvider } from 'styled-components'
3
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
3
4
  import { theme } from 'shared/styles'
4
5
 
6
+ const queryClient = new QueryClient()
7
+
5
8
  export const AppContext: FunctionComponent<{ children: ReactNode }> = props => {
6
- return <ThemeProvider theme={theme}>{props.children}</ThemeProvider>
9
+ return (
10
+ <QueryClientProvider client={queryClient}>
11
+ <ThemeProvider theme={theme}>{props.children}</ThemeProvider>
12
+ </QueryClientProvider>
13
+ )
7
14
  }