create-packer 1.12.7 → 1.13.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.
Files changed (48) hide show
  1. package/.gitignore +2 -0
  2. package/package.json +1 -1
  3. package/template/react/.editorconfig +14 -0
  4. package/template/react/.env +1 -0
  5. package/template/react/.env.development +1 -0
  6. package/template/react/.eslintrc +55 -52
  7. package/template/react/.stylelintrc +23 -22
  8. package/template/react/README.md +14 -13
  9. package/template/react/package.json +1 -0
  10. package/template/react/src/providers/index.ts +1 -0
  11. package/template/react/src/providers/request.ts +7 -0
  12. package/template/react/src/router/{router.config.tsx → config.tsx} +1 -1
  13. package/template/react/src/router/home/index.ts +2 -2
  14. package/template/react/src/router/index.ts +2 -2
  15. package/template/react/src/vite-env.d.ts +15 -0
  16. package/template/vue/.editorconfig +14 -0
  17. package/template/vue/.env +1 -0
  18. package/template/vue/.env.development +1 -0
  19. package/template/vue/.eslintrc +24 -4
  20. package/template/vue/.stylelintrc +23 -22
  21. package/template/vue/README.md +13 -12
  22. package/template/vue/package.json +1 -0
  23. package/template/vue/src/layout/index.ts +1 -0
  24. package/template/vue/src/layout/layout.vue +3 -0
  25. package/template/vue/src/main.ts +1 -1
  26. package/template/vue/src/pages/home/index.ts +1 -1
  27. package/template/vue/src/pages/not-found/index.ts +1 -0
  28. package/template/vue/src/{app/index.ts → providers/app.ts} +1 -1
  29. package/template/vue/src/providers/createApiComponent.ts +22 -0
  30. package/template/vue/src/providers/index.ts +3 -1
  31. package/template/vue/src/providers/request.ts +7 -0
  32. package/template/vue/src/providers/useVisible.ts +2 -1
  33. package/template/vue/src/router/home/index.ts +2 -0
  34. package/template/vue/src/router/home/names.ts +3 -0
  35. package/template/vue/src/router/home/routes.ts +8 -0
  36. package/template/vue/src/router/index.ts +12 -5
  37. package/template/vue/src/router/names.ts +5 -0
  38. package/template/vue/src/vite-env.d.ts +9 -0
  39. package/template/vue/src/app/app.store.ts +0 -8
  40. package/template/vue/src/pages/notFound/index.ts +0 -1
  41. package/template/vue/src/providers/renderToDom.ts +0 -16
  42. package/template/vue/src/router/router.names.ts +0 -4
  43. /package/template/react/src/router/home/{home.paths.ts → paths.ts} +0 -0
  44. /package/template/react/src/router/home/{home.routes.tsx → routes.tsx} +0 -0
  45. /package/template/react/src/router/{router.paths.ts → paths.ts} +0 -0
  46. /package/template/vue/src/{app/app.container.vue → app.vue} +0 -0
  47. /package/template/vue/src/pages/home/{home.container.vue → home.vue} +0 -0
  48. /package/template/vue/src/pages/{notFound/notFound.container.vue → not-found/not-found.vue} +0 -0
package/.gitignore CHANGED
@@ -11,6 +11,8 @@ coverage/
11
11
  # production
12
12
  build/
13
13
  dist/
14
+ .vscode/*
15
+ !.vscode/extensions.json
14
16
  .idea
15
17
  .history
16
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.12.7",
3
+ "version": "1.13.0",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -0,0 +1,14 @@
1
+ # editorconfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ charset = utf-8
7
+ indent_size = 4
8
+ indent_style = space
9
+ insert_final_newline = true
10
+ trim_trailing_whitespace = true
11
+
12
+
13
+ [*.md]
14
+ trim_trailing_whitespace = false
@@ -0,0 +1 @@
1
+ VITE_API_HOST=https://127.0.0.1
@@ -0,0 +1 @@
1
+ VITE_API_HOST=https://127.0.0.1
@@ -1,52 +1,55 @@
1
- {
2
- "root": true,
3
- "parser": "@typescript-eslint/parser",
4
- "plugins": ["@typescript-eslint", "prettier"],
5
- "extends": ["eslint:recommended", "plugin:react/recommended", "plugin:react-hooks/recommended"],
6
- "settings": {
7
- "react": {
8
- "version": "18"
9
- }
10
- },
11
- "env": {
12
- "browser": true,
13
- "node": true,
14
- "es6": true,
15
- "jest": true
16
- },
17
- "parserOptions": {
18
- "ecmaVersion": 2018,
19
- "sourceType": "module",
20
- "ecmaFeatures": {
21
- "jsx": true
22
- },
23
- "useJSXTextNode": true
24
- },
25
- "rules": {
26
- "@typescript-eslint/no-var-requires": 0,
27
- "@typescript-eslint/explicit-function-return-type": "off",
28
- "@typescript-eslint/no-explicit-any": 0,
29
- "@typescript-eslint/no-inferrable-types": [
30
- "warn",
31
- {
32
- "ignoreParameters": true
33
- }
34
- ],
35
- "@typescript-eslint/no-unused-vars": "warn",
36
- "@typescript-eslint/member-delimiter-style": 0,
37
- "@typescript-eslint/class-name-casing": 0,
38
- "@typescript-eslint/explicit-module-boundary-types": "off",
39
- "@typescript-eslint/ban-ts-comment": "off",
40
- "react/prop-types": "off",
41
- "react/no-find-dom-node": "off",
42
- "react-hooks/exhaustive-deps": "warn",
43
- "react/display-name": "off",
44
- "react/react-in-jsx-scope": "off",
45
- "prettier/prettier": [
46
- "error",
47
- {
48
- "endOfLine": "auto"
49
- }
50
- ]
51
- }
52
- }
1
+ {
2
+ "root": true,
3
+ "parser": "@typescript-eslint/parser",
4
+ "plugins": ["@typescript-eslint", "prettier"],
5
+ "extends": ["eslint:recommended", "plugin:react/recommended", "plugin:react-hooks/recommended"],
6
+ "settings": {
7
+ "react": {
8
+ "version": "18"
9
+ }
10
+ },
11
+ "env": {
12
+ "browser": true,
13
+ "node": true,
14
+ "es6": true,
15
+ "jest": true
16
+ },
17
+ "parserOptions": {
18
+ "ecmaVersion": 2018,
19
+ "sourceType": "module",
20
+ "ecmaFeatures": {
21
+ "jsx": true
22
+ },
23
+ "useJSXTextNode": true
24
+ },
25
+ "rules": {
26
+ "@typescript-eslint/no-var-requires": 0,
27
+ "@typescript-eslint/explicit-function-return-type": "off",
28
+ "@typescript-eslint/no-explicit-any": 0,
29
+ "@typescript-eslint/no-non-null-assertion": "off",
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
+ "@typescript-eslint/no-empty-interface": "off",
42
+ "react/prop-types": "off",
43
+ "react/no-find-dom-node": "off",
44
+ "react-hooks/exhaustive-deps": "warn",
45
+ "react/display-name": "off",
46
+ "react/react-in-jsx-scope": "off",
47
+ "prettier/prettier": [
48
+ "error",
49
+ {
50
+ "endOfLine": "auto"
51
+ }
52
+ ],
53
+ "no-constant-condition": "off"
54
+ }
55
+ }
@@ -1,22 +1,23 @@
1
- {
2
- "extends": "stylelint-config-standard",
3
- "rules": {
4
- "indentation": 4,
5
- "comment-empty-line-before": "never",
6
- "no-empty-source": null,
7
- "no-descending-specificity": null,
8
- "string-quotes": "single",
9
- "at-rule-no-unknown": [
10
- true,
11
- {
12
- "ignoreAtRules": ["tailwind", "apply"]
13
- }
14
- ],
15
- "selector-pseudo-class-no-unknown": [
16
- true,
17
- {
18
- "ignorePseudoClasses": ["global"]
19
- }
20
- ]
21
- }
22
- }
1
+ {
2
+ "extends": "stylelint-config-standard",
3
+ "rules": {
4
+ "indentation": 4,
5
+ "comment-empty-line-before": "never",
6
+ "no-empty-source": null,
7
+ "no-descending-specificity": null,
8
+ "string-quotes": "single",
9
+ "at-rule-no-unknown": [
10
+ true,
11
+ {
12
+ "ignoreAtRules": ["tailwind", "apply", "use"]
13
+ }
14
+ ],
15
+ "selector-pseudo-class-no-unknown": [
16
+ true,
17
+ {
18
+ "ignorePseudoClasses": ["global"]
19
+ }
20
+ ],
21
+ "selector-class-pattern": null
22
+ }
23
+ }
@@ -1,13 +1,14 @@
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
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
+ - axios 1.x
14
+ - Alias @ to <project_root>/src
@@ -20,6 +20,7 @@
20
20
  "commit": "git add . && npm run cz"
21
21
  },
22
22
  "dependencies": {
23
+ "axios": "1.3.3",
23
24
  "immer": "9.0.19",
24
25
  "lodash-es": "4.17.21",
25
26
  "react": "18.2.0",
@@ -1,2 +1,3 @@
1
1
  export * from './defineStore'
2
2
  export { default as useVisible } from './useVisible'
3
+ export { default as request } from './request'
@@ -0,0 +1,7 @@
1
+ import axios from 'axios'
2
+
3
+ const request = axios.create({
4
+ baseURL: import.meta.env.VITE_API_HOST
5
+ })
6
+
7
+ export default request
@@ -1,7 +1,7 @@
1
1
  import { lazy } from 'react'
2
2
  import { createBrowserRouter } from 'react-router-dom'
3
3
  import * as home from './home'
4
- import paths from './router.paths'
4
+ import paths from './paths'
5
5
 
6
6
  const Layout = lazy(() => import('@/layout'))
7
7
  const NotFound = lazy(() => import('@/pages/notFound'))
@@ -1,2 +1,2 @@
1
- export { default as routes } from './home.routes'
2
- export { default as paths } from './home.paths'
1
+ export { default as routes } from './routes'
2
+ export { default as paths } from './paths'
@@ -1,2 +1,2 @@
1
- export { default as routePaths } from '././router.paths'
2
- export { default as router } from './router.config'
1
+ export { default as routePaths } from './paths'
2
+ export { default as router } from './config'
@@ -1 +1,16 @@
1
1
  /// <reference types="vite/client" />
2
+
3
+ declare module '*.vue' {
4
+ import type { DefineComponent } from 'vue'
5
+ const component: DefineComponent<{}, {}, any>
6
+ export default component
7
+ }
8
+
9
+ interface ImportMetaEnv {
10
+ readonly VITE_API_HOST: string
11
+ // 更多环境变量...
12
+ }
13
+
14
+ interface ImportMeta {
15
+ readonly env: ImportMetaEnv
16
+ }
@@ -0,0 +1,14 @@
1
+ # editorconfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ charset = utf-8
7
+ indent_size = 4
8
+ indent_style = space
9
+ insert_final_newline = true
10
+ trim_trailing_whitespace = true
11
+
12
+
13
+ [*.md]
14
+ trim_trailing_whitespace = false
@@ -0,0 +1 @@
1
+ VITE_API_HOST=https://127.0.0.1
@@ -0,0 +1 @@
1
+ VITE_API_HOST=https://127.0.0.1
@@ -14,19 +14,23 @@
14
14
  },
15
15
  "plugins": ["prettier"],
16
16
  "extends": [
17
- "plugin:vue/vue3-recommended",
18
17
  "eslint:recommended",
19
- "plugin:@typescript-eslint/recommended"
18
+ "plugin:@typescript-eslint/recommended",
19
+ "plugin:vue/vue3-recommended"
20
20
  ],
21
21
  "parser": "vue-eslint-parser",
22
22
  "parserOptions": {
23
23
  "parser": "@typescript-eslint/parser",
24
- "ecmaVersion": 2021
24
+ "ecmaVersion": 2021,
25
+ "ecmaFeatures": {
26
+ "jsx": true
27
+ }
25
28
  },
26
29
  "rules": {
27
30
  "@typescript-eslint/no-var-requires": 0,
28
31
  "@typescript-eslint/explicit-function-return-type": "off",
29
32
  "@typescript-eslint/no-explicit-any": 0,
33
+ "@typescript-eslint/no-non-null-assertion": "off",
30
34
  "@typescript-eslint/no-inferrable-types": [
31
35
  "warn",
32
36
  {
@@ -38,6 +42,7 @@
38
42
  "@typescript-eslint/class-name-casing": 0,
39
43
  "@typescript-eslint/explicit-module-boundary-types": "off",
40
44
  "@typescript-eslint/ban-ts-comment": "off",
45
+ "@typescript-eslint/no-empty-interface": "off",
41
46
  "prettier/prettier": [
42
47
  "error",
43
48
  {
@@ -45,6 +50,21 @@
45
50
  }
46
51
  ],
47
52
  "vue/multi-word-component-names": 0,
48
- "vue/html-indent": ["error", 4]
53
+ "vue/html-indent": ["error", 4],
54
+ "vue/html-self-closing": [
55
+ "error",
56
+ {
57
+ "html": {
58
+ "void": "always",
59
+ "normal": "always",
60
+ "component": "always"
61
+ },
62
+ "svg": "always",
63
+ "math": "always"
64
+ }
65
+ ],
66
+ "vue/max-attributes-per-line": "off",
67
+ "vue/singleline-html-element-content-newline": "off",
68
+ "no-constant-condition": "off"
49
69
  }
50
70
  }
@@ -1,22 +1,23 @@
1
- {
2
- "extends": "stylelint-config-standard",
3
- "rules": {
4
- "indentation": 4,
5
- "comment-empty-line-before": "never",
6
- "no-empty-source": null,
7
- "no-descending-specificity": null,
8
- "string-quotes": "single",
9
- "at-rule-no-unknown": [
10
- true,
11
- {
12
- "ignoreAtRules": ["tailwind", "apply"]
13
- }
14
- ],
15
- "selector-pseudo-class-no-unknown": [
16
- true,
17
- {
18
- "ignorePseudoClasses": ["global"]
19
- }
20
- ]
21
- }
22
- }
1
+ {
2
+ "extends": "stylelint-config-standard",
3
+ "rules": {
4
+ "indentation": 4,
5
+ "comment-empty-line-before": "never",
6
+ "no-empty-source": null,
7
+ "no-descending-specificity": null,
8
+ "string-quotes": "single",
9
+ "at-rule-no-unknown": [
10
+ true,
11
+ {
12
+ "ignoreAtRules": ["tailwind", "apply", "use"]
13
+ }
14
+ ],
15
+ "selector-pseudo-class-no-unknown": [
16
+ true,
17
+ {
18
+ "ignorePseudoClasses": ["global"]
19
+ }
20
+ ],
21
+ "selector-class-pattern": null
22
+ }
23
+ }
@@ -1,12 +1,13 @@
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
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
+ - axios 1.x
13
+ - Alias @ to <project_root>/src
@@ -16,6 +16,7 @@
16
16
  "commit": "git add . && npm run cz"
17
17
  },
18
18
  "dependencies": {
19
+ "axios": "1.3.3",
19
20
  "lodash-es": "4.17.21",
20
21
  "pinia": "2.0.30",
21
22
  "vite-plugin-eslint": "1.8.1",
@@ -0,0 +1 @@
1
+ export { default } from './layout.vue'
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <div><router-view /></div>
3
+ </template>
@@ -1,4 +1,4 @@
1
- import app from './app'
1
+ import app from './providers/app'
2
2
  import { createPinia } from 'pinia'
3
3
  import router from '@/router'
4
4
  import './style.css'
@@ -1 +1 @@
1
- export { default } from './home.container.vue'
1
+ export { default } from './home.vue'
@@ -0,0 +1 @@
1
+ export { default } from './not-found.vue'
@@ -1,4 +1,4 @@
1
1
  import { createApp } from 'vue'
2
- import App from './app.container.vue'
2
+ import App from '../app.vue'
3
3
 
4
4
  export default createApp(App)
@@ -0,0 +1,22 @@
1
+ import app from '@/providers/app'
2
+ import { createVNode, render } from 'vue'
3
+ import { assign } from 'lodash-es'
4
+
5
+ const store = new Map()
6
+ export default function createApiComponent(component: any, props?: Record<string, any>) {
7
+ const container = document.createElement('div')
8
+ let vNode = store.get(component)
9
+ if (!vNode) {
10
+ vNode = createVNode(component)
11
+ vNode.appContext = app._context || {}
12
+ store.set(component, vNode)
13
+ }
14
+ assign(vNode.component.props, props)
15
+ render(vNode, container)
16
+
17
+ return {
18
+ instance: vNode,
19
+ el: container.firstElementChild,
20
+ ...vNode.component?.exposed
21
+ }
22
+ }
@@ -1,2 +1,4 @@
1
+ export { default as app } from './app'
1
2
  export { default as useVisible } from './useVisible'
2
- export { default as renderToDom } from './renderToDom'
3
+ export { default as createApiComponent } from './createApiComponent'
4
+ export { default as request } from './request'
@@ -0,0 +1,7 @@
1
+ import axios from 'axios'
2
+
3
+ const request = axios.create({
4
+ baseURL: import.meta.env.VITE_API_HOST
5
+ })
6
+
7
+ export default request
@@ -2,11 +2,12 @@ import { ref } from 'vue'
2
2
  import { isFunction } from 'lodash-es'
3
3
 
4
4
  export interface useVisibleConfigType {
5
+ defaultVisible?: boolean
5
6
  onBeforeShow?: () => Promise<boolean | void>
6
7
  onBeforeHide?: () => Promise<boolean | void>
7
8
  }
8
9
  export default function useVisible(config?: useVisibleConfigType) {
9
- const visible = ref(false)
10
+ const visible = ref(config?.defaultVisible ?? false)
10
11
  const onShow = async () => {
11
12
  let isShow: boolean | void = true
12
13
  if (isFunction(config?.onBeforeShow)) {
@@ -0,0 +1,2 @@
1
+ export { default as names } from './names'
2
+ export { default as routes } from './routes'
@@ -0,0 +1,3 @@
1
+ export default {
2
+ home: 'home'
3
+ }
@@ -0,0 +1,8 @@
1
+ import { RouteRecordRaw } from 'vue-router'
2
+ import names from './names'
3
+
4
+ const routes: RouteRecordRaw[] = [
5
+ { path: '/home', name: names.home, component: () => import('@/pages/home') }
6
+ ]
7
+
8
+ export default routes
@@ -1,16 +1,23 @@
1
1
  import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
2
- import names from './router.names'
2
+ import names from './names'
3
+ import * as homeRouter from './home'
4
+ import Layout from '@/layout'
3
5
 
4
- const routes: (RouteRecordRaw & { name: string })[] = [
5
- { path: '/', name: names.home, component: () => import('@/pages/home') },
6
- { path: '/404', name: names.notFound, component: () => import('@/pages/notFound') }
6
+ const routes: RouteRecordRaw[] = [
7
+ {
8
+ path: '/',
9
+ component: Layout,
10
+ redirect: { name: names.home },
11
+ children: [...homeRouter.routes]
12
+ },
13
+ { path: '/404', name: names.notFound, component: () => import('@/pages/not-found') }
7
14
  ]
8
15
  const router = createRouter({
9
16
  history: createWebHashHistory(),
10
17
  routes
11
18
  })
12
19
  router.beforeEach(async to => {
13
- if (!Object.values(names).includes(to.name! as string)) {
20
+ if (!Object.values(names).includes(to.name as string)) {
14
21
  return {
15
22
  replace: true,
16
23
  name: names.notFound
@@ -0,0 +1,5 @@
1
+ import * as homeRouter from './home'
2
+ export default {
3
+ ...homeRouter.names,
4
+ notFound: '404'
5
+ }
@@ -5,3 +5,12 @@ declare module '*.vue' {
5
5
  const component: DefineComponent<{}, {}, any>
6
6
  export default component
7
7
  }
8
+
9
+ interface ImportMetaEnv {
10
+ readonly VITE_API_HOST: string
11
+ // 更多环境变量...
12
+ }
13
+
14
+ interface ImportMeta {
15
+ readonly env: ImportMetaEnv
16
+ }
@@ -1,8 +0,0 @@
1
- import { defineStore } from 'pinia'
2
-
3
- export default defineStore('app', {
4
- state: () => {
5
- return {}
6
- },
7
- actions: {}
8
- })
@@ -1 +0,0 @@
1
- export { default } from './notFound.container.vue'
@@ -1,16 +0,0 @@
1
- import { createVNode, render } from 'vue'
2
- import { merge } from 'lodash-es'
3
-
4
- export default function renderToDom(component: any, props?: Record<string, any>) {
5
- const container = document.createElement('div')
6
- const instance = createVNode(component)
7
- merge(instance.props, props)
8
- render(instance, container)
9
- document.body.appendChild(container)
10
-
11
- return {
12
- context: instance,
13
- destroy: () => render(null, container),
14
- ...instance.component?.exposed
15
- }
16
- }
@@ -1,4 +0,0 @@
1
- export default {
2
- home: 'home',
3
- notFound: '404'
4
- }