create-vue-workspace 0.1.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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -0
  3. package/dist/index.mjs +910 -0
  4. package/package.json +41 -0
  5. package/templates/app-web/_env.development +2 -0
  6. package/templates/app-web/_env.production +2 -0
  7. package/templates/app-web/index.html +12 -0
  8. package/templates/app-web/package.json +25 -0
  9. package/templates/app-web/src/App.vue +18 -0
  10. package/templates/app-web/src/api/request.ts +15 -0
  11. package/templates/app-web/src/main.ts +7 -0
  12. package/templates/app-web/src/router/index.ts +16 -0
  13. package/templates/app-web/src/stores/app.ts +7 -0
  14. package/templates/app-web/src/styles/index.scss +8 -0
  15. package/templates/app-web/src/views/home-view.vue +16 -0
  16. package/templates/app-web/src/vite-env.d.ts +12 -0
  17. package/templates/app-web/tsconfig.json +7 -0
  18. package/templates/app-web/vite.config.ts +17 -0
  19. package/templates/base/README.md +53 -0
  20. package/templates/base/_changeset/config.json +11 -0
  21. package/templates/base/_editorconfig +12 -0
  22. package/templates/base/_gitignore +12 -0
  23. package/templates/base/eslint.config.mjs +25 -0
  24. package/templates/base/package.json +38 -0
  25. package/templates/base/pnpm-workspace.yaml +3 -0
  26. package/templates/base/prettier.config.mjs +8 -0
  27. package/templates/base/stylelint.config.mjs +8 -0
  28. package/templates/base/tsconfig.base.json +17 -0
  29. package/templates/base/tsconfig.json +4 -0
  30. package/templates/base/vitest.config.ts +10 -0
  31. package/templates/component/__tests__/{{fileName}}.component.spec.tsx +17 -0
  32. package/templates/component/components/{{fileName}}-sub.component.tsx +9 -0
  33. package/templates/component/composition/use-{{fileName}}.ts +46 -0
  34. package/templates/component/index.ts +12 -0
  35. package/templates/component/package.json +31 -0
  36. package/templates/component/tsconfig.json +5 -0
  37. package/templates/component/types.ts +5 -0
  38. package/templates/component/vite.config.ts +17 -0
  39. package/templates/component/{{fileName}}.component.tsx +22 -0
  40. package/templates/component/{{fileName}}.props.ts +12 -0
  41. package/templates/component/{{fileName}}.scss +11 -0
  42. package/templates/hook/use-{{kebab}}.ts +26 -0
  43. package/templates/pkg-lib/package.json +24 -0
  44. package/templates/pkg-lib/src/index.ts +5 -0
  45. package/templates/pkg-lib/tsconfig.json +4 -0
  46. package/templates/pkg-lib/vite.config.ts +17 -0
  47. package/templates/pkg-ui/package.json +31 -0
  48. package/templates/pkg-ui/src/index.ts +7 -0
  49. package/templates/pkg-ui/src/styles/index.scss +6 -0
  50. package/templates/pkg-ui/tsconfig.json +4 -0
  51. package/templates/pkg-ui/vite.config.ts +17 -0
  52. package/templates/pkg-utils/package.json +24 -0
  53. package/templates/pkg-utils/src/index.ts +20 -0
  54. package/templates/pkg-utils/tsconfig.json +4 -0
  55. package/templates/pkg-utils/vite.config.ts +13 -0
  56. package/templates/util/{{kebab}}.ts +4 -0
  57. package/templates/view/{{fileName}}.vue +15 -0
@@ -0,0 +1,26 @@
1
+ import { computed, ref, type ComputedRef, type Ref } from 'vue';
2
+
3
+ export interface Use{{pascal}}Result {
4
+ /** 当前值 */
5
+ value: Ref<boolean>;
6
+ /** 取反后的值 */
7
+ negated: ComputedRef<boolean>;
8
+ /** 切换当前值 */
9
+ toggle: () => void;
10
+ }
11
+
12
+ /**
13
+ * TODO: 替换为 use{{pascal}} 的真实实现。
14
+ * 约定:入参为配置对象,返回 Ref / ComputedRef 与操作函数,便于在组件间复用。
15
+ */
16
+ export function use{{pascal}}(initialValue = false): Use{{pascal}}Result {
17
+ const value = ref(initialValue);
18
+
19
+ const negated = computed(() => !value.value);
20
+
21
+ function toggle(): void {
22
+ value.value = !value.value;
23
+ }
24
+
25
+ return { value, negated, toggle };
26
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "{{packageName}}",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.mjs",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs"
12
+ }
13
+ },
14
+ "files": ["dist"],
15
+ "scripts": {
16
+ "build": "vite build",
17
+ "typecheck": "tsc --noEmit"
18
+ },
19
+ "devDependencies": {
20
+ "typescript": "^5.7.2",
21
+ "vite": "^6.0.7",
22
+ "vite-plugin-dts": "^4.4.0"{{vueDevDependency}}
23
+ }{{vuePeerDependencies}}
24
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * {{packageName}} 的出口。
3
+ * 执行 `cvw g util <name>` 会自动在此追加 re-export。
4
+ */
5
+ export const PACKAGE_NAME = '{{packageName}}';
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "include": ["src/**/*.ts", "src/**/*.tsx", "vite.config.ts"]
4
+ }
@@ -0,0 +1,17 @@
1
+ import { defineConfig } from 'vite';
2
+ import dts from 'vite-plugin-dts';
3
+
4
+ export default defineConfig({
5
+ plugins: [dts({ rollupTypes: true })],
6
+ build: {
7
+ lib: {
8
+ entry: 'src/index.ts',
9
+ formats: ['es'],
10
+ fileName: () => 'index.mjs',
11
+ },
12
+ rollupOptions: {
13
+ // vue 只可能被可选依赖,标记为外部依赖无副作用
14
+ external: ['vue'],
15
+ },
16
+ },
17
+ });
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "{{scope}}/ui",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "sideEffects": ["**/*.css", "**/*.scss"],
6
+ "main": "./dist/index.mjs",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs"
13
+ },
14
+ "./style": "./dist/style.css"
15
+ },
16
+ "files": ["dist"],
17
+ "scripts": {
18
+ "build": "vite build",
19
+ "typecheck": "vue-tsc --noEmit"
20
+ },
21
+ "peerDependencies": {
22
+ "vue": "^3.5.0"
23
+ },
24
+ "devDependencies": {
25
+ "@vitejs/plugin-vue-jsx": "^4.1.1",
26
+ "sass": "^1.83.0",
27
+ "vite": "^6.0.7",
28
+ "vite-plugin-dts": "^4.4.0",
29
+ "vue-tsc": "^2.2.0"
30
+ }
31
+ }
@@ -0,0 +1,7 @@
1
+ import './styles/index.scss';
2
+
3
+ /**
4
+ * 组件聚合包出口。
5
+ * 执行 `cvw g c <name>` 后,脚手架会自动在此追加 `export * from '@<scope>/<name>'`。
6
+ */
7
+ export const UI_PACKAGE_NAME = '{{scope}}/ui';
@@ -0,0 +1,6 @@
1
+ // 组件库共享样式与 Design Token
2
+ :root {
3
+ --f-color-primary: #4a7dff;
4
+ --f-color-text: #252b3a;
5
+ --f-border-radius: 4px;
6
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "include": ["src/**/*.ts", "src/**/*.tsx", "vite.config.ts"]
4
+ }
@@ -0,0 +1,17 @@
1
+ import vueJsx from '@vitejs/plugin-vue-jsx';
2
+ import { defineConfig } from 'vite';
3
+ import dts from 'vite-plugin-dts';
4
+
5
+ export default defineConfig({
6
+ plugins: [vueJsx(), dts({ rollupTypes: true })],
7
+ build: {
8
+ lib: {
9
+ entry: 'src/index.ts',
10
+ formats: ['es'],
11
+ fileName: () => 'index.mjs',
12
+ },
13
+ rollupOptions: {
14
+ external: ['vue'],
15
+ },
16
+ },
17
+ });
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "{{scope}}/utils",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.mjs",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs"
12
+ }
13
+ },
14
+ "files": ["dist"],
15
+ "scripts": {
16
+ "build": "vite build",
17
+ "typecheck": "tsc --noEmit"
18
+ },
19
+ "devDependencies": {
20
+ "typescript": "^5.7.2",
21
+ "vite": "^6.0.7",
22
+ "vite-plugin-dts": "^4.4.0"
23
+ }
24
+ }
@@ -0,0 +1,20 @@
1
+ /** 判断值是否为空(null / undefined / 空字符串) */
2
+ export function isEmpty(value: unknown): boolean {
3
+ return value === null || value === undefined || value === '';
4
+ }
5
+
6
+ /** 数组去重(按自定义 key) */
7
+ export function uniqueBy<T>(items: T[], getKey: (item: T) => string | number): T[] {
8
+ const seen = new Set<string | number>();
9
+
10
+ return items.filter((item) => {
11
+ const key = getKey(item);
12
+
13
+ if (seen.has(key)) {
14
+ return false;
15
+ }
16
+
17
+ seen.add(key);
18
+ return true;
19
+ });
20
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "include": ["src/**/*.ts", "vite.config.ts"]
4
+ }
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from 'vite';
2
+ import dts from 'vite-plugin-dts';
3
+
4
+ export default defineConfig({
5
+ plugins: [dts({ rollupTypes: true })],
6
+ build: {
7
+ lib: {
8
+ entry: 'src/index.ts',
9
+ formats: ['es'],
10
+ fileName: () => 'index.mjs',
11
+ },
12
+ },
13
+ });
@@ -0,0 +1,4 @@
1
+ /** TODO: 替换为 {{pascal}} 的真实实现与说明 */
2
+ export function {{camel}}<T>(input: T): T {
3
+ return input;
4
+ }
@@ -0,0 +1,15 @@
1
+ <script setup lang="ts">
2
+ const title = '{{pascal}}';
3
+ </script>
4
+
5
+ <template>
6
+ <section class="{{kebab}}">
7
+ <h2>{{ title }}</h2>
8
+ </section>
9
+ </template>
10
+
11
+ <style scoped>
12
+ .{{kebab}} {
13
+ padding: 16px;
14
+ }
15
+ </style>