create-packer 1.10.2 → 1.10.5

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 (34) hide show
  1. package/package.json +1 -1
  2. package/template/react-vite/.eslintrc +2 -3
  3. package/template/react-vite/.vscode/extensions.json +3 -0
  4. package/template/react-vite/README.md +13 -0
  5. package/template/react-vite/package.json +4 -1
  6. package/template/react-vite/src/app/app.container.tsx +8 -0
  7. package/template/react-vite/src/app/app.controller.ts +7 -0
  8. package/template/react-vite/src/app/app.store.ts +8 -0
  9. package/template/react-vite/src/app/index.ts +3 -0
  10. package/template/react-vite/src/main.tsx +6 -10
  11. package/template/react-vite/src/pages/404/View.tsx +3 -0
  12. package/template/react-vite/src/pages/404/index.ts +1 -0
  13. package/template/react-vite/src/router/View.tsx +6 -0
  14. package/template/react-vite/src/router/index.ts +2 -0
  15. package/template/react-vite/src/router/routes.tsx +16 -0
  16. package/template/vue-vite/.eslintrc +45 -0
  17. package/template/vue-vite/.vscode/extensions.json +1 -1
  18. package/template/vue-vite/READEME.md +12 -0
  19. package/template/vue-vite/package.json +8 -2
  20. package/template/vue-vite/src/App/app.container.vue +10 -0
  21. package/template/vue-vite/src/App/app.controller.ts +7 -0
  22. package/template/vue-vite/src/App/app.store.ts +14 -0
  23. package/template/vue-vite/src/App/index.ts +3 -2
  24. package/template/vue-vite/src/pages/404/View.vue +3 -0
  25. package/template/vue-vite/src/pages/404/index.ts +1 -0
  26. package/template/vue-vite/src/routes/index.ts +16 -3
  27. package/template/vue-vite/src/routes/routeNames.ts +4 -0
  28. package/template/react-vite/src/Layout/View.tsx +0 -8
  29. package/template/react-vite/src/Layout/index.ts +0 -2
  30. package/template/react-vite/src/Layout/typings.ts +0 -1
  31. package/template/react-vite/src/routes/index.ts +0 -16
  32. package/template/vue-vite/src/App/View.vue +0 -7
  33. package/template/vue-vite/src/App/controllers/index.ts +0 -1
  34. package/template/vue-vite/src/App/controllers/useApp.ts +0 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.10.2",
3
+ "version": "1.10.5",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "root": true,
3
3
  "parser": "@typescript-eslint/parser",
4
- "plugins": ["@typescript-eslint"],
4
+ "plugins": ["@typescript-eslint", "prettier"],
5
5
  "extends": ["eslint:recommended", "plugin:react/recommended", "plugin:react-hooks/recommended"],
6
6
  "settings": {
7
7
  "react": {
@@ -42,7 +42,6 @@
42
42
  "react-hooks/exhaustive-deps": "warn",
43
43
  "react/display-name": "off",
44
44
  "react/react-in-jsx-scope": "off",
45
- "semi": ["error", "never"],
46
- "quotes": "off"
45
+ "prettier/prettier": "error"
47
46
  }
48
47
  }
@@ -0,0 +1,3 @@
1
+ {
2
+ "recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
3
+ }
@@ -0,0 +1,13 @@
1
+ ## Vite + react18 + Typescript
2
+
3
+ ### Features
4
+ - Vite 3.x
5
+ - React 18.x
6
+ - Typescript 4.x
7
+ - react-router 6.x
8
+ - Zustand 4.x
9
+ - Tailwindcss 3.x
10
+ - Jest 28.x
11
+ - Eslint
12
+ - Prettier
13
+ - Alias @ to <project_root>/src
@@ -22,9 +22,11 @@
22
22
  "dependencies": {
23
23
  "react": "18.2.0",
24
24
  "react-dom": "18.2.0",
25
- "react-router-dom": "6.3.0"
25
+ "react-router-dom": "6.3.0",
26
+ "zustand": "4.0.0"
26
27
  },
27
28
  "devDependencies": {
29
+ "@testing-library/dom": "8.14.0",
28
30
  "@testing-library/jest-dom": "5.16.5",
29
31
  "@testing-library/react": "13.3.0",
30
32
  "@testing-library/user-event": "14.4.2",
@@ -40,6 +42,7 @@
40
42
  "cssnano": "5.1.12",
41
43
  "cz-adapter-eslint": "0.3.0",
42
44
  "eslint": "8.21.0",
45
+ "eslint-plugin-prettier": "4.0.0",
43
46
  "eslint-plugin-react": "7.30.1",
44
47
  "eslint-plugin-react-hooks": "4.6.0",
45
48
  "husky": "8.0.1",
@@ -0,0 +1,8 @@
1
+ import { PropsWithChildren } from 'react'
2
+
3
+ export interface AppPropsType {}
4
+ function App({ children }: PropsWithChildren<AppPropsType>) {
5
+ return <div>{children}</div>
6
+ }
7
+
8
+ export default App
@@ -0,0 +1,7 @@
1
+ import { useEffect } from 'react'
2
+
3
+ export function useInit() {
4
+ useEffect(() => {
5
+ console.log('init')
6
+ }, [])
7
+ }
@@ -0,0 +1,8 @@
1
+ import create from 'zustand'
2
+ import { combine } from 'zustand/middleware'
3
+
4
+ export default create(
5
+ combine({}, setState => {
6
+ return {}
7
+ })
8
+ )
@@ -0,0 +1,3 @@
1
+ export { default } from './app.container'
2
+ export { default as useAppStore } from './app.store'
3
+ export * from './app.controller'
@@ -1,20 +1,16 @@
1
1
  import React from 'react'
2
2
  import ReactDOM from 'react-dom/client'
3
- import { BrowserRouter, Routes, Route } from 'react-router-dom'
4
- import Layout from './Layout'
5
- import routes from './routes'
3
+ import { BrowserRouter } from 'react-router-dom'
4
+ import App from './app'
5
+ import Route from './router'
6
6
  import './index.css'
7
7
 
8
8
  ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
9
9
  <React.StrictMode>
10
10
  <BrowserRouter>
11
- <Layout>
12
- <Routes>
13
- {routes.map(({ path, Component }) => {
14
- return <Route key={path} path={path} element={<Component />} />
15
- })}
16
- </Routes>
17
- </Layout>
11
+ <App>
12
+ <Route />
13
+ </App>
18
14
  </BrowserRouter>
19
15
  </React.StrictMode>
20
16
  )
@@ -0,0 +1,3 @@
1
+ export default function CannotAccess() {
2
+ return <div>404</div>
3
+ }
@@ -0,0 +1 @@
1
+ export { default } from './View'
@@ -0,0 +1,6 @@
1
+ import { useRoutes } from 'react-router-dom'
2
+ import routes from './routes'
3
+
4
+ export default function Route() {
5
+ return useRoutes(routes)
6
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './View'
2
+ export { default as routes } from './routes'
@@ -0,0 +1,16 @@
1
+ import { RouteObject } from 'react-router-dom'
2
+ import Home from '@/pages/Home'
3
+ import CannotAccess from '@/pages/404'
4
+
5
+ const routes: RouteObject[] = [
6
+ {
7
+ path: '/',
8
+ element: <Home />
9
+ },
10
+ {
11
+ path: '*',
12
+ element: <CannotAccess />
13
+ }
14
+ ]
15
+
16
+ export default routes
@@ -0,0 +1,45 @@
1
+ {
2
+ "root": true,
3
+ "env": {
4
+ "browser": true,
5
+ "node": true,
6
+ "es6": true,
7
+ "jest": true
8
+ },
9
+ "globals": {
10
+ "defineProps": "readonly",
11
+ "defineEmits": "readonly",
12
+ "defineExpose": "readonly",
13
+ "withDefaults": "readonly"
14
+ },
15
+ "plugins": ["prettier"],
16
+ "extends": [
17
+ "plugin:vue/vue3-recommended",
18
+ "eslint:recommended",
19
+ "plugin:@typescript-eslint/recommended"
20
+ ],
21
+ "parser": "vue-eslint-parser",
22
+ "parserOptions": {
23
+ "parser": "@typescript-eslint/parser",
24
+ "ecmaVersion": 2021
25
+ },
26
+ "rules": {
27
+ "@typescript-eslint/no-var-requires": 0,
28
+ "@typescript-eslint/explicit-function-return-type": "off",
29
+ "@typescript-eslint/no-explicit-any": 0,
30
+ "@typescript-eslint/no-inferrable-types": [
31
+ "warn",
32
+ {
33
+ "ignoreParameters": true
34
+ }
35
+ ],
36
+ "@typescript-eslint/no-unused-vars": "warn",
37
+ "@typescript-eslint/member-delimiter-style": 0,
38
+ "@typescript-eslint/class-name-casing": 0,
39
+ "@typescript-eslint/explicit-module-boundary-types": "off",
40
+ "@typescript-eslint/ban-ts-comment": "off",
41
+ "prettier/prettier": "error",
42
+ "vue/multi-word-component-names": 0,
43
+ "vue/html-indent": ["error", 4]
44
+ }
45
+ }
@@ -1,3 +1,3 @@
1
1
  {
2
- "recommendations": ["Vue.volar"]
2
+ "recommendations": ["Vue.volar", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
3
3
  }
@@ -0,0 +1,12 @@
1
+ ## Vite + Vue3.x + Typescript
2
+
3
+ ### Features
4
+ - Vite 3.x
5
+ - Vue 3.x
6
+ - Typescript 4.x
7
+ - vue-router 4.x
8
+ - pinia 2.x
9
+ - Tailwindcss 3.x
10
+ - Eslint
11
+ - Prettier
12
+ - Alias @ to <project_root>/src
@@ -4,12 +4,13 @@
4
4
  "version": "0.0.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
+ "prepare": "husky install",
7
8
  "dev": "vite",
8
9
  "build": "vue-tsc --noEmit && vite build",
9
10
  "preview": "vite preview",
10
11
  "format": "prettier --write \"src/**/*.{ts,js,tsx,jsx,vue,css,scss,less}\" \"./package.json\"",
11
- "lint": "eslint ./src/**/*.{tsx,ts,vue} && stylelint ./src/**/*.{css,scss,less}",
12
- "lint:fix": "eslint ./src/**/*.{tsx,ts,vue} --fix && stylelint ./src/**/*.{css,scss,less} --fix",
12
+ "lint": "eslint ./src/**/*.{ts,vue} && stylelint ./src/**/*.{css,scss,less}",
13
+ "lint:fix": "eslint ./src/**/*.{ts,vue} --fix && stylelint ./src/**/*.{css,scss,less} --fix",
13
14
  "cz": "cz",
14
15
  "push": "npm run commit && git push",
15
16
  "commit": "git add . && npm run cz"
@@ -20,11 +21,16 @@
20
21
  "vue-router": "4.1.3"
21
22
  },
22
23
  "devDependencies": {
24
+ "@typescript-eslint/eslint-plugin": "5.33.0",
25
+ "@typescript-eslint/parser": "5.33.0",
23
26
  "@vitejs/plugin-vue": "3.0.3",
24
27
  "autoprefixer": "10.4.8",
25
28
  "commitizen": "4.2.5",
26
29
  "cssnano": "5.1.12",
27
30
  "cz-adapter-eslint": "0.3.0",
31
+ "eslint": "8.22.0",
32
+ "eslint-plugin-prettier": "4.0.0",
33
+ "eslint-plugin-vue": "9.3.0",
28
34
  "husky": "8.0.1",
29
35
  "postcss": "8.4.14",
30
36
  "postcss-import": "14.1.0",
@@ -0,0 +1,10 @@
1
+ <template>
2
+ <router-view />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import { useInit } from './app.controller'
7
+ useInit()
8
+ </script>
9
+
10
+ <style scoped></style>
@@ -0,0 +1,7 @@
1
+ import { onMounted } from 'vue'
2
+
3
+ export function useInit() {
4
+ onMounted(() => {
5
+ console.log('init')
6
+ })
7
+ }
@@ -0,0 +1,14 @@
1
+ import { defineStore } from 'pinia'
2
+
3
+ export default defineStore('app', {
4
+ state: () => {
5
+ return {
6
+ appName: ''
7
+ }
8
+ },
9
+ actions: {
10
+ setAppName(appName: string) {
11
+ this.appName = appName
12
+ }
13
+ }
14
+ })
@@ -1,2 +1,3 @@
1
- export * from './controllers'
2
- export { default } from './View.vue'
1
+ export { default } from './app.container.vue'
2
+ export { default as useAppStore } from './app.store'
3
+ export * from './app.controller'
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <div>404</div>
3
+ </template>
@@ -0,0 +1 @@
1
+ export { default } from './View.vue'
@@ -1,9 +1,22 @@
1
1
  import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
2
2
  import Home from '@/pages/Home'
3
+ import CannotAccess from '@/pages/404'
4
+ import routeNames from './routeNames'
3
5
 
4
- const routes: RouteRecordRaw[] = [{ path: '/', component: Home }]
5
-
6
- export default createRouter({
6
+ const routes: (RouteRecordRaw & { name: string })[] = [
7
+ { path: '/', name: routeNames.home, component: Home },
8
+ { path: '/404', name: routeNames.cannotAccess, component: CannotAccess }
9
+ ]
10
+ const router = createRouter({
7
11
  history: createWebHashHistory(),
8
12
  routes
9
13
  })
14
+ router.beforeEach(async to => {
15
+ if (!Object.values(routeNames).includes(to.name! as string)) {
16
+ return {
17
+ replace: true,
18
+ name: routeNames.cannotAccess
19
+ }
20
+ }
21
+ })
22
+ export default router
@@ -0,0 +1,4 @@
1
+ export default {
2
+ home: 'home',
3
+ cannotAccess: '404'
4
+ }
@@ -1,8 +0,0 @@
1
- import React, { PropsWithChildren } from 'react'
2
- import { LayoutPropsType } from './typings'
3
-
4
- function Layout({ children }: PropsWithChildren<LayoutPropsType>) {
5
- return <div>{children}</div>
6
- }
7
-
8
- export default Layout
@@ -1,2 +0,0 @@
1
- export { default } from './View'
2
- export * as LayoutTypes from './typings'
@@ -1 +0,0 @@
1
- export interface LayoutPropsType {}
@@ -1,16 +0,0 @@
1
- import type { FunctionComponent } from 'react'
2
- import Home from '@/pages/Home'
3
-
4
- export interface routeType {
5
- path: string
6
- Component: FunctionComponent<any>
7
- }
8
-
9
- const routes: routeType[] = [
10
- {
11
- path: '/',
12
- Component: Home
13
- }
14
- ]
15
-
16
- export default routes
@@ -1,7 +0,0 @@
1
- <template>
2
- <router-view />
3
- </template>
4
-
5
- <script setup lang="ts"></script>
6
-
7
- <style scoped></style>
@@ -1 +0,0 @@
1
- export * from './useApp'
@@ -1,9 +0,0 @@
1
- import { defineStore } from 'pinia'
2
-
3
- export const useApp = defineStore('app', {
4
- state: () => {
5
- return {
6
- appName: ''
7
- }
8
- }
9
- })