@farris/cli 2.2.6 → 2.3.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 (113) hide show
  1. package/lib/commands/add-app.js +6 -0
  2. package/lib/commands/add-app.js.map +1 -0
  3. package/lib/commands/add-lib.js +6 -0
  4. package/lib/commands/add-lib.js.map +1 -0
  5. package/lib/commands/add-project.js +194 -0
  6. package/lib/commands/add-project.js.map +1 -0
  7. package/lib/commands/build-components.js +8 -1
  8. package/lib/commands/build-components.js.map +1 -1
  9. package/lib/commands/build-lib.js +5 -0
  10. package/lib/commands/build-lib.js.map +1 -1
  11. package/lib/commands/build.js +7 -2
  12. package/lib/commands/build.js.map +1 -1
  13. package/lib/commands/create-app-options.js +0 -2
  14. package/lib/commands/create-app-options.js.map +1 -1
  15. package/lib/commands/create-app.js +6 -1
  16. package/lib/commands/create-app.js.map +1 -1
  17. package/lib/commands/create-options.js +3 -0
  18. package/lib/commands/create-options.js.map +1 -1
  19. package/lib/commands/create.js +95 -42
  20. package/lib/commands/create.js.map +1 -1
  21. package/lib/commands/generate/common.js +13 -12
  22. package/lib/commands/generate/common.js.map +1 -1
  23. package/lib/commands/workspace/add-app.js +10 -175
  24. package/lib/commands/workspace/add-app.js.map +1 -1
  25. package/lib/commands/workspace/create.js +29 -346
  26. package/lib/commands/workspace/create.js.map +1 -1
  27. package/lib/common/agents-doc.js +34 -0
  28. package/lib/common/agents-doc.js.map +1 -0
  29. package/lib/common/generate-app.js +48 -24
  30. package/lib/common/generate-app.js.map +1 -1
  31. package/lib/common/output.js +72 -2
  32. package/lib/common/output.js.map +1 -1
  33. package/lib/common/project-layout.js +143 -0
  34. package/lib/common/project-layout.js.map +1 -0
  35. package/lib/common/safety.js +4 -2
  36. package/lib/common/safety.js.map +1 -1
  37. package/lib/common/template-manifest.js +2 -4
  38. package/lib/common/template-manifest.js.map +1 -1
  39. package/lib/common/verifier.js +143 -99
  40. package/lib/common/verifier.js.map +1 -1
  41. package/lib/common/workspace-contract.js +86 -0
  42. package/lib/common/workspace-contract.js.map +1 -0
  43. package/lib/index.js +31 -2
  44. package/lib/index.js.map +1 -1
  45. package/lib/plugins/create-app-package-json.js +24 -0
  46. package/lib/plugins/create-app-package-json.js.map +1 -0
  47. package/package.json +53 -52
  48. package/templates/create/.gitignore.tpl +12 -0
  49. package/templates/create/AGENTS.md +62 -0
  50. package/templates/create/CLAUDE.md +1 -0
  51. package/templates/create/README.md +14 -1
  52. package/templates/create/package.json +11 -3
  53. package/templates/create/pnpm-workspace.yaml +2 -1
  54. package/templates/lib/.eslintrc.cjs +15 -0
  55. package/templates/lib/.gitignore.tpl +3 -0
  56. package/templates/lib/.prettierrc.json +8 -0
  57. package/templates/lib/index.html +1 -1
  58. package/templates/lib/package.json +38 -3
  59. package/templates/lib/{components → test/components}/button/button.spec.ts +3 -2
  60. package/templates/lib/test/components/button/button.spec.tsx +11 -0
  61. package/templates/lib/tsconfig.json +5 -1
  62. package/templates/lib/vitest.config.ts +1 -1
  63. package/templates/mobile/.gitignore.tpl +31 -0
  64. package/templates/mobile/.gitlab-ci.yml +3 -9
  65. package/templates/mobile/index.html +1 -1
  66. package/templates/mobile/package.json +14 -10
  67. package/templates/mobile/src/main.ts +5 -4
  68. package/templates/mobile/src/router/index.ts +17 -17
  69. package/templates/mobile/test/src/components/TheButton.spec.ts +15 -0
  70. package/templates/mobile/test/src/components/TheButton.spec.tsx +15 -0
  71. package/templates/mobile/tsconfig.json +3 -2
  72. package/templates/mobile/vitest.config.ts +2 -1
  73. package/templates/web/.gitignore.tpl +31 -0
  74. package/templates/web/.gitlab-ci.yml +3 -9
  75. package/templates/web/index.html +1 -1
  76. package/templates/web/package.json +14 -10
  77. package/templates/web/src/locales/index.ts +5 -0
  78. package/templates/web/src/locales/zh-CN.json +1 -0
  79. package/templates/web/src/main.ts +5 -2
  80. package/templates/web/src/router/index.ts +17 -17
  81. package/templates/web/src/styles/index.css +0 -0
  82. package/templates/web/src/styles/index.scss +0 -0
  83. package/templates/web/test/src/components/TheButton.spec.ts +15 -0
  84. package/templates/web/test/src/components/TheButton.spec.tsx +15 -0
  85. package/templates/web/tsconfig.json +3 -2
  86. package/templates/web/vitest.config.ts +2 -1
  87. package/lib/common/project-package-name.js +0 -5
  88. package/lib/common/project-package-name.js.map +0 -1
  89. package/templates/mobile/.changeset/README.md +0 -4
  90. package/templates/mobile/.changeset/config.json +0 -11
  91. package/templates/mobile/project.json +0 -4
  92. package/templates/mobile/src/components/TheButton.spec.ts +0 -8
  93. package/templates/web/.changeset/README.md +0 -4
  94. package/templates/web/.changeset/config.json +0 -11
  95. package/templates/web/project.json +0 -4
  96. package/templates/web/src/components/TheButton.spec.ts +0 -8
  97. package/templates/workspace/app/farris.config.mjs +0 -13
  98. package/templates/workspace/app/index.html +0 -12
  99. package/templates/workspace/app/package.json +0 -22
  100. package/templates/workspace/app/src/App.tsx +0 -11
  101. package/templates/workspace/app/src/main.ts +0 -12
  102. package/templates/workspace/app/src/router/index.ts +0 -16
  103. package/templates/workspace/app/src/views/home/composables/use-home.ts +0 -7
  104. package/templates/workspace/app/src/views/home/home.component.tsx +0 -15
  105. package/templates/workspace/app/src/views/home/index.ts +0 -4
  106. package/templates/workspace/app/tsconfig.json +0 -21
  107. package/templates/workspace/root/README.md +0 -28
  108. package/templates/workspace/root/package.json +0 -13
  109. package/templates/workspace/root/pnpm-workspace.yaml +0 -12
  110. /package/templates/{workspace/app → mobile}/src/locales/index.ts +0 -0
  111. /package/templates/{workspace/app → mobile}/src/locales/zh-CN.json +0 -0
  112. /package/templates/{workspace/app → mobile}/src/styles/index.css +0 -0
  113. /package/templates/{workspace/app → mobile}/src/styles/index.scss +0 -0
@@ -3,11 +3,37 @@
3
3
  "version": "1.0.0",
4
4
  "private": false,
5
5
  "type": "module",
6
+ "license": "Apache-2.0",
7
+ "description": "<%= name %>,基于 Farris Vue 的 Vue3 组件库。",
8
+ "keywords": [
9
+ "farris",
10
+ "vue3",
11
+ "components"
12
+ ],
13
+ "homepage": "https://farris-design.gitee.io/farris-vue/",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git@gitee.com:ubml/farris-vue.git"
17
+ },
18
+ "files": [
19
+ "lib"
20
+ ],
21
+ "sideEffects": [
22
+ "**/*.css",
23
+ "**/*.scss"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
6
28
  "scripts": {
7
29
  "dev": "farris-cli dev",
8
30
  "build": "farris-cli build-lib -ep && farris-cli build-components",
31
+ "preview": "farris-cli preview",
9
32
  "test": "vitest run",
10
33
  "test:watch": "vitest",
34
+ "typecheck": "vue-tsc --noEmit",
35
+ "lint": "eslint . --ext .vue,.ts,.tsx --fix",
36
+ "format": "prettier --write components/ src/",
11
37
  "changeset": "changeset",
12
38
  "version": "changeset version"
13
39
  },
@@ -17,12 +43,21 @@
17
43
  "devDependencies": {
18
44
  "@changesets/cli": "^2.29.5",
19
45
  "@farris/cli": "<%= cliVersion %>",
20
- "@vue/tsconfig": "^0.5.1",
21
- "@vue/test-utils": "^2.4.6",
46
+ "@rushstack/eslint-patch": "^1.8.0",
22
47
  "@vitejs/plugin-vue": "^5.2.4",
48
+ "@vue/eslint-config-prettier": "^9.0.0",
49
+ "@vue/eslint-config-typescript": "^13.0.0",
50
+ "@vue/test-utils": "^2.4.6",
51
+ "@vue/tsconfig": "^0.5.1",
52
+ "eslint": "^8.57.0",
53
+ "eslint-plugin-vue": "^9.23.0",
23
54
  "jsdom": "^25.0.1",
55
+ "prettier": "^3.2.5",
56
+ "sass": "^1.90.0",
24
57
  "typescript": "~5.4.0",
58
+ "vite": "^5.4.19",
59
+ "vitest": "^3.2.4",
25
60
  "vue": "^3.4.29",
26
- "vitest": "^3.2.4"
61
+ "vue-tsc": "^2.2.0"
27
62
  }
28
63
  }
@@ -1,10 +1,11 @@
1
1
  import { mount } from '@vue/test-utils';
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Button } from './index';
3
+ import { Button } from '../../../../components/button/index';
4
4
 
5
5
  describe('Button', () => {
6
- it('renders a button', () => {
6
+ it('renders its default slot', () => {
7
7
  const wrapper = mount(Button, { slots: { default: 'OK' } });
8
+
8
9
  expect(wrapper.text()).toContain('OK');
9
10
  });
10
11
  });
@@ -0,0 +1,11 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { describe, expect, it } from 'vitest';
3
+ import { Button } from '../../../../components/button/index';
4
+
5
+ describe('Button (tsx collection)', () => {
6
+ it('is collected by the unified vitest include', () => {
7
+ const wrapper = mount(Button, { slots: { default: 'OK' } });
8
+
9
+ expect(wrapper.text()).toContain('OK');
10
+ });
11
+ });
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "extends": "@vue/tsconfig/tsconfig.dom.json",
3
- "include": ["components/**/*"],
3
+ "include": [
4
+ "components/**/*",
5
+ "src/**/*",
6
+ "test/**/*"
7
+ ],
4
8
  "compilerOptions": {
5
9
  "strict": true
6
10
  }
@@ -5,6 +5,6 @@ export default defineConfig({
5
5
  plugins: [vue()],
6
6
  test: {
7
7
  environment: 'jsdom',
8
- include: ['components/**/*.spec.ts']
8
+ include: ['test/**/*.spec.{ts,tsx}']
9
9
  }
10
10
  });
@@ -0,0 +1,31 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ package-lock.json
12
+ .DS_Store
13
+ dist
14
+ dist-ssr
15
+ coverage
16
+ *.local
17
+
18
+ /cypress/videos/
19
+ /cypress/screenshots/
20
+
21
+ # Editor directories and files
22
+ .vscode/*
23
+ !.vscode/extensions.json
24
+ .idea
25
+ *.suo
26
+ *.ntvs*
27
+ *.njsproj
28
+ *.sln
29
+ *.sw?
30
+
31
+ *.tsbuildinfo
@@ -39,11 +39,8 @@ publish-project:
39
39
  stage: publishproject
40
40
  tags:
41
41
  - environment:cloud
42
- only:
43
- refs:
44
- - cicd
45
- changes:
46
- - project.json
42
+ rules:
43
+ - if: $CI_COMMIT_TAG =~ /^v\d/
47
44
  before_script:
48
45
  - |
49
46
  if [ -z "${ARTIFACTS_REPO_USERNAME}" ] || [ -z "${ARTIFACTS_REPO_PASSWORD}" ]; then
@@ -59,7 +56,4 @@ publish-project:
59
56
  - npm config fix
60
57
  script:
61
58
  - npm config set //repos.iec.io/repository/npm-igix-release/:_auth=$(echo -n ${ARTIFACTS_REPO_USERNAME}:${ARTIFACTS_REPO_PASSWORD} | base64)
62
- - cp ./project.json ./dist
63
- - cd ./dist
64
- - mv ./project.json ./package.json
65
- - npm publish
59
+ - cd dist && npm publish
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Vite App</title>
6
+ <title><%= title %></title>
7
7
  </head>
8
8
  <body>
9
9
  <div id="app"></div>
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "<%= name %>",
3
- "version": "1.0.0",
3
+ "version": "0.1.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "farris-cli dev",
8
- "build": "farris-cli build",
8
+ "build": "farris-cli build -ep",
9
9
  "preview": "farris-cli preview",
10
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
11
- "format": "prettier --write src/",
12
10
  "test": "vitest run",
13
11
  "test:watch": "vitest",
14
- "changeset": "changeset",
15
- "version": "changeset version"
12
+ "typecheck": "vue-tsc --noEmit",
13
+ "lint": "eslint . --ext .vue,.ts,.tsx --fix",
14
+ "format": "prettier --write src/",
15
+ "i18n": "farris-cli extract-i18n"
16
16
  },
17
17
  "dependencies": {
18
18
  "@farris/mobile-ui-vue": "latest",
@@ -20,17 +20,21 @@
20
20
  "vue-router": "^4.3.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@changesets/cli": "^2.29.5",
24
23
  "@farris/cli": "<%= cliVersion %>",
25
24
  "@rushstack/eslint-patch": "^1.8.0",
25
+ "@vitejs/plugin-vue": "^5.2.4",
26
26
  "@vue/eslint-config-prettier": "^9.0.0",
27
27
  "@vue/eslint-config-typescript": "^13.0.0",
28
+ "@vue/test-utils": "^2.4.6",
28
29
  "@vue/tsconfig": "^0.5.1",
29
- "@vitejs/plugin-vue": "^5.2.4",
30
30
  "eslint": "^8.57.0",
31
31
  "eslint-plugin-vue": "^9.23.0",
32
+ "jsdom": "^25.0.1",
32
33
  "prettier": "^3.2.5",
33
34
  "typescript": "~5.4.0",
34
- "vitest": "^3.2.4"
35
+ "vite": "^5.4.19",
36
+ "vitest": "^3.2.4",
37
+ "vue-tsc": "^2.2.0",
38
+ "sass": "^1.90.0"
35
39
  }
36
- }
40
+ }
@@ -1,12 +1,13 @@
1
1
  import { createApp } from 'vue';
2
2
  import FarrisVue from '@farris/mobile-ui-vue';
3
- import App from './App.vue';
4
- import router from './router';
5
-
6
3
  import '@farris/mobile-ui-vue/style.css';
4
+ import App from './App.vue';
5
+ import router from './router';<%= styleImport %>
6
+ import { localResources } from './locales';
7
7
 
8
8
  const app = createApp(App);
9
9
 
10
- app.use(router).use(FarrisVue);
10
+ app.use(FarrisVue, { basePath: '', locale: 'zh-CN', localResources });
11
+ app.use(router);
11
12
 
12
13
  app.mount('#app');
@@ -1,23 +1,23 @@
1
- import { createRouter, createWebHistory } from 'vue-router';
2
- import HomeView from '../views/HomeView.vue';
1
+ import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router';
2
+
3
+ // 生成器(farris-cli generate view --with-route)依赖下面的 routes 数组赋值形式;
4
+ // 改动结构会导致路由无法自动注册。
5
+ export const routes: RouteRecordRaw[] = [
6
+ {
7
+ path: '/',
8
+ name: 'Home',
9
+ component: () => import('../views/HomeView.vue')
10
+ },
11
+ {
12
+ path: '/about',
13
+ name: 'About',
14
+ component: () => import('../views/AboutView.vue')
15
+ }
16
+ ];
3
17
 
4
18
  const router = createRouter({
5
19
  history: createWebHistory(import.meta.env.BASE_URL),
6
- routes: [
7
- {
8
- path: '/',
9
- name: 'home',
10
- component: HomeView
11
- },
12
- {
13
- path: '/about',
14
- name: 'about',
15
- // route level code-splitting
16
- // this generates a separate chunk (About.[hash].js) for this route
17
- // which is lazy-loaded when the route is visited.
18
- component: () => import('../views/AboutView.vue')
19
- }
20
- ]
20
+ routes
21
21
  });
22
22
 
23
23
  export default router;
@@ -0,0 +1,15 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { describe, expect, it } from 'vitest';
3
+ import TheButton from '../../../src/components/TheButton.vue';
4
+
5
+ describe('TheButton', () => {
6
+ it('mounts and renders its default slot', () => {
7
+ const wrapper = mount(TheButton, {
8
+ global: {
9
+ stubs: { 'fm-button': { template: '<button><slot /></button>' } }
10
+ }
11
+ });
12
+
13
+ expect(wrapper.text()).toContain('按钮');
14
+ });
15
+ });
@@ -0,0 +1,15 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { describe, expect, it } from 'vitest';
3
+ import TheButton from '../../../src/components/TheButton.vue';
4
+
5
+ describe('TheButton (tsx collection)', () => {
6
+ it('is collected by the unified vitest include', () => {
7
+ const wrapper = mount(TheButton, {
8
+ global: {
9
+ stubs: { 'fm-button': { template: '<button><slot /></button>' } }
10
+ }
11
+ });
12
+
13
+ expect(wrapper.text()).toContain('按钮');
14
+ });
15
+ });
@@ -3,7 +3,8 @@
3
3
  "include": [
4
4
  "env.d.ts",
5
5
  "src/**/*",
6
- "src/**/*.vue"
6
+ "src/**/*.vue",
7
+ "test/**/*"
7
8
  ],
8
9
  "compilerOptions": {
9
10
  "composite": true,
@@ -15,4 +16,4 @@
15
16
  ]
16
17
  }
17
18
  }
18
- }
19
+ }
@@ -4,6 +4,7 @@ import { defineConfig } from 'vitest/config';
4
4
  export default defineConfig({
5
5
  plugins: [vue()],
6
6
  test: {
7
- include: ['src/**/*.spec.ts']
7
+ environment: 'jsdom',
8
+ include: ['test/**/*.spec.{ts,tsx}']
8
9
  }
9
10
  });
@@ -0,0 +1,31 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ package-lock.json
12
+ .DS_Store
13
+ dist
14
+ dist-ssr
15
+ coverage
16
+ *.local
17
+
18
+ /cypress/videos/
19
+ /cypress/screenshots/
20
+
21
+ # Editor directories and files
22
+ .vscode/*
23
+ !.vscode/extensions.json
24
+ .idea
25
+ *.suo
26
+ *.ntvs*
27
+ *.njsproj
28
+ *.sln
29
+ *.sw?
30
+
31
+ *.tsbuildinfo
@@ -39,11 +39,8 @@ publish-project:
39
39
  stage: publishproject
40
40
  tags:
41
41
  - environment:cloud
42
- only:
43
- refs:
44
- - cicd
45
- changes:
46
- - project.json
42
+ rules:
43
+ - if: $CI_COMMIT_TAG =~ /^v\d/
47
44
  before_script:
48
45
  - |
49
46
  if [ -z "${ARTIFACTS_REPO_USERNAME}" ] || [ -z "${ARTIFACTS_REPO_PASSWORD}" ]; then
@@ -59,7 +56,4 @@ publish-project:
59
56
  - npm config fix
60
57
  script:
61
58
  - npm config set //repos.iec.io/repository/npm-igix-release/:_auth=$(echo -n ${ARTIFACTS_REPO_USERNAME}:${ARTIFACTS_REPO_PASSWORD} | base64)
62
- - cp ./project.json ./dist
63
- - cd ./dist
64
- - mv ./project.json ./package.json
65
- - npm publish
59
+ - cd dist && npm publish
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Vite App</title>
6
+ <title><%= title %></title>
7
7
  </head>
8
8
  <body>
9
9
  <div id="app"></div>
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "<%= name %>",
3
- "version": "1.0.0",
3
+ "version": "0.1.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "farris-cli dev",
8
- "build": "farris-cli build",
8
+ "build": "farris-cli build -ep",
9
9
  "preview": "farris-cli preview",
10
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
11
- "format": "prettier --write src/",
12
10
  "test": "vitest run",
13
11
  "test:watch": "vitest",
14
- "changeset": "changeset",
15
- "version": "changeset version"
12
+ "typecheck": "vue-tsc --noEmit",
13
+ "lint": "eslint . --ext .vue,.ts,.tsx --fix",
14
+ "format": "prettier --write src/",
15
+ "i18n": "farris-cli extract-i18n"
16
16
  },
17
17
  "dependencies": {
18
18
  "@farris/ui-vue": "latest",
@@ -20,17 +20,21 @@
20
20
  "vue-router": "^4.3.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@changesets/cli": "^2.29.5",
24
23
  "@farris/cli": "<%= cliVersion %>",
25
24
  "@rushstack/eslint-patch": "^1.8.0",
25
+ "@vitejs/plugin-vue": "^5.2.4",
26
26
  "@vue/eslint-config-prettier": "^9.0.0",
27
27
  "@vue/eslint-config-typescript": "^13.0.0",
28
+ "@vue/test-utils": "^2.4.6",
28
29
  "@vue/tsconfig": "^0.5.1",
29
- "@vitejs/plugin-vue": "^5.2.4",
30
30
  "eslint": "^8.57.0",
31
31
  "eslint-plugin-vue": "^9.23.0",
32
+ "jsdom": "^25.0.1",
32
33
  "prettier": "^3.2.5",
33
34
  "typescript": "~5.4.0",
34
- "vitest": "^3.2.4"
35
+ "vite": "^5.4.19",
36
+ "vitest": "^3.2.4",
37
+ "vue-tsc": "^2.2.0",
38
+ "sass": "^1.90.0"
35
39
  }
36
- }
40
+ }
@@ -0,0 +1,5 @@
1
+ import zhCN from './zh-CN.json';
2
+
3
+ export const localResources = {
4
+ 'zh-CN': zhCN
5
+ };
@@ -0,0 +1 @@
1
+ {}
@@ -1,10 +1,13 @@
1
1
  import { createApp } from 'vue';
2
2
  import FarrisVue from '@farris/ui-vue';
3
+ import '@farris/ui-vue/index.css';
3
4
  import App from './App.vue';
4
- import router from './router';
5
+ import router from './router';<%= styleImport %>
6
+ import { localResources } from './locales';
5
7
 
6
8
  const app = createApp(App);
7
9
 
8
- app.use(router).use(FarrisVue);
10
+ app.use(FarrisVue, { basePath: '', locale: 'zh-CN', localResources });
11
+ app.use(router);
9
12
 
10
13
  app.mount('#app');
@@ -1,23 +1,23 @@
1
- import { createRouter, createWebHistory } from 'vue-router';
2
- import HomeView from '../views/HomeView.vue';
1
+ import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router';
2
+
3
+ // 生成器(farris-cli generate view --with-route)依赖下面的 routes 数组赋值形式;
4
+ // 改动结构会导致路由无法自动注册。
5
+ export const routes: RouteRecordRaw[] = [
6
+ {
7
+ path: '/',
8
+ name: 'Home',
9
+ component: () => import('../views/HomeView.vue')
10
+ },
11
+ {
12
+ path: '/about',
13
+ name: 'About',
14
+ component: () => import('../views/AboutView.vue')
15
+ }
16
+ ];
3
17
 
4
18
  const router = createRouter({
5
19
  history: createWebHistory(import.meta.env.BASE_URL),
6
- routes: [
7
- {
8
- path: '/',
9
- name: 'home',
10
- component: HomeView
11
- },
12
- {
13
- path: '/about',
14
- name: 'about',
15
- // route level code-splitting
16
- // this generates a separate chunk (About.[hash].js) for this route
17
- // which is lazy-loaded when the route is visited.
18
- component: () => import('../views/AboutView.vue')
19
- }
20
- ]
20
+ routes
21
21
  });
22
22
 
23
23
  export default router;
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { describe, expect, it } from 'vitest';
3
+ import TheButton from '../../../src/components/TheButton.vue';
4
+
5
+ describe('TheButton', () => {
6
+ it('mounts and renders its default slot', () => {
7
+ const wrapper = mount(TheButton, {
8
+ global: {
9
+ stubs: { 'f-button': { template: '<button><slot /></button>' } }
10
+ }
11
+ });
12
+
13
+ expect(wrapper.text()).toContain('按钮');
14
+ });
15
+ });
@@ -0,0 +1,15 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { describe, expect, it } from 'vitest';
3
+ import TheButton from '../../../src/components/TheButton.vue';
4
+
5
+ describe('TheButton (tsx collection)', () => {
6
+ it('is collected by the unified vitest include', () => {
7
+ const wrapper = mount(TheButton, {
8
+ global: {
9
+ stubs: { 'f-button': { template: '<button><slot /></button>' } }
10
+ }
11
+ });
12
+
13
+ expect(wrapper.text()).toContain('按钮');
14
+ });
15
+ });
@@ -3,7 +3,8 @@
3
3
  "include": [
4
4
  "env.d.ts",
5
5
  "src/**/*",
6
- "src/**/*.vue"
6
+ "src/**/*.vue",
7
+ "test/**/*"
7
8
  ],
8
9
  "compilerOptions": {
9
10
  "composite": true,
@@ -15,4 +16,4 @@
15
16
  ]
16
17
  }
17
18
  }
18
- }
19
+ }
@@ -4,6 +4,7 @@ import { defineConfig } from 'vitest/config';
4
4
  export default defineConfig({
5
5
  plugins: [vue()],
6
6
  test: {
7
- include: ['src/**/*.spec.ts']
7
+ environment: 'jsdom',
8
+ include: ['test/**/*.spec.{ts,tsx}']
8
9
  }
9
10
  });
@@ -1,5 +0,0 @@
1
- export function toProjectPackageName(name) {
2
- const unscoped = name.replace(/^@[^/]+\//, '');
3
- return `@farris/project-${unscoped}`;
4
- }
5
- //# sourceMappingURL=project-package-name.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"project-package-name.js","sourceRoot":"","sources":["../../src/common/project-package-name.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO,mBAAmB,QAAQ,EAAE,CAAC;AACvC,CAAC"}
@@ -1,4 +0,0 @@
1
- Use `npm run changeset` then `npm run version` to write CHANGELOG.md.
2
-
3
- This app template is `private` and is not meant for `npm publish`.
4
- If the default branch is not `main`, edit `baseBranch` in `config.json`.
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://unpkg.com/@changesets/config@3.0.2/schema.json",
3
- "changelog": "@changesets/cli/changelog",
4
- "commit": false,
5
- "fixed": [],
6
- "linked": [],
7
- "access": "restricted",
8
- "baseBranch": "main",
9
- "updateInternalDependencies": "patch",
10
- "ignore": []
11
- }
@@ -1,4 +0,0 @@
1
- {
2
- "name": "<%= projectPackageName %>",
3
- "version": "1.0.0"
4
- }
@@ -1,8 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import TheButton from './TheButton.vue';
3
-
4
- describe('TheButton', () => {
5
- it('exports a component', () => {
6
- expect(TheButton).toBeTruthy();
7
- });
8
- });
@@ -1,4 +0,0 @@
1
- Use `npm run changeset` then `npm run version` to write CHANGELOG.md.
2
-
3
- This app template is `private` and is not meant for `npm publish`.
4
- If the default branch is not `main`, edit `baseBranch` in `config.json`.