@varlet/cli 3.5.3 → 3.5.4

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/README.md CHANGED
@@ -183,6 +183,13 @@ varlet-cli build:icons
183
183
  varlet-cli test
184
184
  ```
185
185
 
186
+ #### Execute a unit test
187
+
188
+ ```shell
189
+ # playground-ignore
190
+ varlet-cli test -c <componentName>
191
+ ```
192
+
186
193
  #### Execute unit tests in watch mode
187
194
 
188
195
  ```shell
package/README.zh-CN.md CHANGED
@@ -182,6 +182,13 @@ varlet-cli build:icons
182
182
  varlet-cli test
183
183
  ```
184
184
 
185
+ #### 执行单个组件的单元测试
186
+
187
+ ```shell
188
+ # playground-ignore
189
+ varlet-cli test -c <componentName>
190
+ ```
191
+
185
192
  #### 以 watch 模式执行单元测试
186
193
 
187
194
  ```shell
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "3.5.3",
3
+ "version": "3.5.4",
4
4
  "type": "module",
5
5
  "description": "cli of varlet",
6
6
  "bin": {
@@ -61,8 +61,8 @@
61
61
  "vite": "5.4.6",
62
62
  "vitest": "2.1.1",
63
63
  "vue": "3.4.21",
64
- "@varlet/shared": "3.5.3",
65
- "@varlet/vite-plugins": "3.5.3"
64
+ "@varlet/shared": "3.5.4",
65
+ "@varlet/vite-plugins": "3.5.4"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/babel__core": "^7.20.1",
@@ -74,9 +74,9 @@
74
74
  "@types/node": "^18.7.20",
75
75
  "@types/sharp": "0.31.1",
76
76
  "rimraf": "^5.0.1",
77
- "@varlet/touch-emulator": "3.5.3",
78
- "@varlet/ui": "3.5.3",
79
- "@varlet/icons": "3.5.3"
77
+ "@varlet/ui": "3.5.4",
78
+ "@varlet/touch-emulator": "3.5.4",
79
+ "@varlet/icons": "3.5.4"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "@vitest/coverage-istanbul": "2.0.5",
@@ -87,9 +87,9 @@
87
87
  "live-server": "^1.2.1",
88
88
  "vue": "3.4.21",
89
89
  "vue-router": "4.2.0",
90
- "@varlet/icons": "3.5.3",
91
- "@varlet/touch-emulator": "3.5.3",
92
- "@varlet/ui": "3.5.3"
90
+ "@varlet/touch-emulator": "3.5.4",
91
+ "@varlet/ui": "3.5.4",
92
+ "@varlet/icons": "3.5.4"
93
93
  },
94
94
  "scripts": {
95
95
  "dev": "tsc --watch",
@@ -1,9 +1,13 @@
1
1
  import { defineComponent } from 'vue'
2
2
  import { props } from './props'
3
+ import { createNamespace } from '../utils/components'
4
+
3
5
  import './<%- camelizeName %>.less'
4
6
 
7
+ const { name, n, classes } = createNamespace('<%- kebabCaseName %>')
8
+
5
9
  export default defineComponent({
6
- name: '<%- bigCamelizeNamespace + bigCamelizeName %>',
10
+ name,
7
11
  props,
8
12
  setup(props, { slots }) {
9
13
  return () => {
@@ -5,13 +5,16 @@
5
5
  <script lang="ts">
6
6
  import { defineComponent } from 'vue'
7
7
  import { props } from './props'
8
+ import { createNamespace } from '../utils/components'
9
+
10
+ const { name, n, classes } = createNamespace('<%- kebabCaseName %>')
8
11
 
9
12
  export default defineComponent({
10
- name: '<%- bigCamelizeNamespace + bigCamelizeName %>',
13
+ name,
11
14
  props
12
15
  })
13
16
  </script>
14
17
 
15
18
  <style lang="less">
16
- @import './<%- camelizeName %>.less';
19
+ @import './<%- camelizeName %>';
17
20
  </style>
@@ -1,4 +1,5 @@
1
1
  import <%- bigCamelizeName %> from '..'
2
+ import <%- bigCamelizeNamespace + bigCamelizeName %> from '../<%- bigCamelizeName %>'
2
3
  import { createApp } from 'vue'
3
4
  import { mount } from '@vue/test-utils'
4
5
  import { expect, test } from 'vitest'
@@ -14,4 +14,4 @@ Locale.add('en-US', Locale.enUS)
14
14
  add('zh-CN', zhCN)
15
15
  add('en-US', enUS)
16
16
 
17
- export { add, t, merge, use }
17
+ export { add, t, merge, use }
@@ -12,7 +12,5 @@
12
12
  "types/index.d.ts",
13
13
  ".varlet/**"
14
14
  ],
15
- "extends": [
16
- "@varlet"
17
- ]
18
- }
15
+ "extends": ["@varlet"]
16
+ }
@@ -8,7 +8,7 @@ export default defineConfig({
8
8
  darkMode: null,
9
9
  i18n: null,
10
10
  playground: null,
11
- versions: null
11
+ versions: null,
12
12
  },
13
13
  menu: [
14
14
  {
@@ -44,5 +44,5 @@ export default defineConfig({
44
44
  i18n: null,
45
45
  darkMode: null,
46
46
  },
47
- }
47
+ },
48
48
  })
@@ -1,14 +1,17 @@
1
1
  <template>
2
- <button class="va-button" :style="{ background: color }" @click="handleClick">
2
+ <button :class="n()" :style="{ background: color }" @click="handleClick">
3
3
  <slot />
4
4
  </button>
5
5
  </template>
6
6
 
7
7
  <script lang="ts">
8
8
  import { defineComponent, PropType } from 'vue'
9
+ import { createNamespace } from '../utils/components'
10
+
11
+ const { name, n, classes } = createNamespace('button')
9
12
 
10
13
  export default defineComponent({
11
- name: 'VaButton',
14
+ name,
12
15
  props: {
13
16
  color: {
14
17
  type: String,
@@ -21,8 +24,9 @@ export default defineComponent({
21
24
  const handleClick = (e: Event) => {
22
25
  props.onClick?.(e)
23
26
  }
24
-
27
+
25
28
  return {
29
+ n,
26
30
  handleClick,
27
31
  }
28
32
  },
@@ -1,4 +1,5 @@
1
1
  import type { Component, Plugin, App } from 'vue'
2
+ import { createNamespaceFn } from '@varlet/shared'
2
3
 
3
4
  export type ComponentWithInstall<T> = T & Plugin
4
5
 
@@ -14,4 +15,6 @@ export function withInstall<T = Component>(component: Component, target?: T): Co
14
15
  }
15
16
 
16
17
  return componentWithInstall as ComponentWithInstall<T>
17
- }
18
+ }
19
+
20
+ export const createNamespace = createNamespaceFn('va')
@@ -1,8 +1,12 @@
1
1
  import { defineComponent, PropType } from 'vue'
2
+ import { createNamespace } from '../utils/components'
3
+
2
4
  import './button.less'
3
5
 
6
+ const { name, n, classes } = createNamespace('button')
7
+
4
8
  export default defineComponent({
5
- name: 'VaButton',
9
+ name,
6
10
  props: {
7
11
  color: {
8
12
  type: String,
@@ -18,7 +22,7 @@ export default defineComponent({
18
22
  const { color } = props
19
23
 
20
24
  return (
21
- <button class="va-button" style={{ background: color }} onClick={handleClick}>
25
+ <button class={n()} style={{ background: color }} onClick={handleClick}>
22
26
  {slots.default?.()}
23
27
  </button>
24
28
  )
@@ -5,4 +5,4 @@ withInstall(Button)
5
5
 
6
6
  export const _ButtonComponent = Button
7
7
 
8
- export default Button
8
+ export default Button
@@ -1,4 +1,5 @@
1
1
  import type { Component, Plugin, App } from 'vue'
2
+ import { createNamespaceFn } from '@varlet/shared'
2
3
 
3
4
  export type ComponentWithInstall<T> = T & Plugin
4
5
 
@@ -14,4 +15,6 @@ export function withInstall<T = Component>(component: Component, target?: T): Co
14
15
  }
15
16
 
16
17
  return componentWithInstall as ComponentWithInstall<T>
17
- }
18
+ }
19
+
20
+ export const createNamespace = createNamespaceFn('va')
@@ -7,7 +7,7 @@ export default defineConfig({
7
7
  header: {
8
8
  darkMode: null,
9
9
  playground: null,
10
- versions: null
10
+ versions: null,
11
11
  },
12
12
  menu: [
13
13
  {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <button class="va-button" :style="{ background: color }" @click="handleClick">
2
+ <button :class="n()" :style="{ background: color }" @click="handleClick">
3
3
  {{ t('button') }}
4
4
  <slot />
5
5
  </button>
@@ -7,12 +7,15 @@
7
7
 
8
8
  <script lang="ts">
9
9
  import { defineComponent, PropType } from 'vue'
10
+ import { createNamespace } from '../utils/components'
10
11
 
11
12
  // i18n for component's internal
12
13
  import { t } from '../locale'
13
14
 
15
+ const { name, n, classes } = createNamespace('button')
16
+
14
17
  export default defineComponent({
15
- name: 'VaButton',
18
+ name,
16
19
  props: {
17
20
  color: {
18
21
  type: String,
@@ -28,6 +31,7 @@ export default defineComponent({
28
31
 
29
32
  return {
30
33
  t,
34
+ n,
31
35
  handleClick,
32
36
  }
33
37
  },
@@ -58,7 +58,7 @@ function useLocale<T = Message>() {
58
58
  add,
59
59
  use,
60
60
  merge,
61
- t
61
+ t,
62
62
  }
63
63
  }
64
64
 
@@ -1,4 +1,5 @@
1
1
  import type { Component, Plugin, App } from 'vue'
2
+ import { createNamespaceFn } from '@varlet/shared'
2
3
 
3
4
  export type ComponentWithInstall<T> = T & Plugin
4
5
 
@@ -14,4 +15,6 @@ export function withInstall<T = Component>(component: Component, target?: T): Co
14
15
  }
15
16
 
16
17
  return componentWithInstall as ComponentWithInstall<T>
17
- }
18
+ }
19
+
20
+ export const createNamespace = createNamespaceFn('va')
@@ -1,11 +1,15 @@
1
1
  import { defineComponent, PropType } from 'vue'
2
+ import { createNamespace } from '../utils/components'
3
+
2
4
  import './button.less'
3
5
 
4
6
  // i18n for component's internal
5
7
  import { t } from '../locale'
6
8
 
9
+ const { name, n, classes } = createNamespace('button')
10
+
7
11
  export default defineComponent({
8
- name: 'VaButton',
12
+ name,
9
13
  props: {
10
14
  color: {
11
15
  type: String,
@@ -23,7 +27,7 @@ export default defineComponent({
23
27
  const { color } = props
24
28
 
25
29
  return (
26
- <button class="va-button" style={{ background: color }} onClick={handleClick}>
30
+ <button class={n()} style={{ background: color }} onClick={handleClick}>
27
31
  {t('button')}
28
32
  {slots.default?.()}
29
33
  </button>
@@ -58,7 +58,7 @@ function useLocale<T = Message>() {
58
58
  add,
59
59
  use,
60
60
  merge,
61
- t
61
+ t,
62
62
  }
63
63
  }
64
64
 
@@ -1,4 +1,5 @@
1
1
  import type { Component, Plugin, App } from 'vue'
2
+ import { createNamespaceFn } from '@varlet/shared'
2
3
 
3
4
  export type ComponentWithInstall<T> = T & Plugin
4
5
 
@@ -14,4 +15,6 @@ export function withInstall<T = Component>(component: Component, target?: T): Co
14
15
  }
15
16
 
16
17
  return componentWithInstall as ComponentWithInstall<T>
17
- }
18
+ }
19
+
20
+ export const createNamespace = createNamespaceFn('va')