@varlet/cli 2.9.3-alpha.1679304010895 → 2.9.3-alpha.1679397001839

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
@@ -55,6 +55,7 @@ Also refer to `@varlet/ui` [varlet.config.mjs](https://github.com/varletjs/varle
55
55
  | `analysis` | Document statistics related | _{ baidu: string }_ | `-` |
56
56
  | `pc` | PC-side document structure configuration | _Record<string, any>_ | `-` |
57
57
  | `mobile` | Mobile side document structure configuration | _Record<string, any>_ | `-` |
58
+ | `directives` | Directive folder names | _string[]_ | `[]` |
58
59
  | `copy` | Copy file options | _[CopyPath[]](https://github.com/varletjs/varlet/blob/dev/packages/varlet-vite-plugins/src/copy.ts)_ | `-` |
59
60
  | `icons` | Font icon packaging related configuration | _[VarletConfigIcons](https://github.com/varletjs/varlet/blob/dev/packages/varlet-cli/src/node/config/varlet.config.ts)_ | `-` |
60
61
 
package/README.zh-CN.md CHANGED
@@ -55,6 +55,7 @@ varlet-cli gen
55
55
  | `analysis` | 文档统计相关 | _{ baidu: string }_ | `-` |
56
56
  | `pc` | pc 端文档结构配置 | _Record<string, any>_ | `-` |
57
57
  | `mobile` | mobile 端文档结构配置 | _Record<string, any>_ | `-` |
58
+ | `directives` | 组件库指令文件夹名称 | _string[]_ | `[]` |
58
59
  | `copy` | 复制文件配置 | _[CopyPath[]](https://github.com/varletjs/varlet/blob/dev/packages/varlet-vite-plugins/src/copy.ts)_ | `-` |
59
60
  | `icons` | 字体图标打包相关配置 | _[VarletConfigIcons](https://github.com/varletjs/varlet/blob/dev/packages/varlet-cli/src/node/config/varlet.config.ts)_ | `-` |
60
61
 
@@ -11,25 +11,39 @@ export * from '${relative(moduleDir, TYPES_DIR)}'
11
11
  `);
12
12
  }
13
13
  export async function compileTypes() {
14
+ await ensureDir(TYPES_DIR);
14
15
  const varletConfig = await getVarletConfig();
15
16
  const namespace = get(varletConfig, 'namespace');
16
- const { name } = readJSONSync(UI_PACKAGE_JSON);
17
- await ensureDir(TYPES_DIR);
18
- const dir = await readdir(TYPES_DIR);
19
- const ignoreEntryDir = dir.filter((filename) => filename !== 'index.d.ts' && filename !== 'global.d.ts');
17
+ const directives = get(varletConfig, 'directives');
18
+ const { name: libraryName } = readJSONSync(UI_PACKAGE_JSON);
19
+ const filenames = await readdir(TYPES_DIR);
20
+ const includeFilenames = filenames.filter((filename) => filename !== 'index.d.ts' && filename !== 'global.d.ts');
20
21
  const exports = [];
21
- const declares = [];
22
- ignoreEntryDir.forEach((filename) => {
23
- const componentName = filename.slice(0, filename.indexOf('.d.ts'));
24
- exports.push(`export * from './${componentName}'`);
25
- if (!componentName.startsWith(namespace)) {
26
- declares.push(`${bigCamelize(namespace)}${bigCamelize(componentName)}: typeof import('${name}')['_${bigCamelize(componentName)}Component']`);
22
+ const componentDeclares = [];
23
+ const directiveDeclares = [];
24
+ includeFilenames.forEach((filename) => {
25
+ const folder = filename.slice(0, filename.indexOf('.d.ts'));
26
+ const name = bigCamelize(folder);
27
+ exports.push(`export * from './${filename}'`);
28
+ if (filename.startsWith(namespace)) {
29
+ // ignore prefix with namespace e.g. varComponent
30
+ return;
31
+ }
32
+ if (directives.includes(folder)) {
33
+ directiveDeclares.push(`v${name}: typeof import('${libraryName}')['_${name}Component']`);
34
+ }
35
+ else {
36
+ componentDeclares.push(`${bigCamelize(namespace)}${name}: typeof import('${libraryName}')['_${name}Component']`);
27
37
  }
28
38
  });
29
- const globalDeclares = `\
39
+ const vueDeclares = `\
30
40
  declare module 'vue' {
31
41
  export interface GlobalComponents {
32
- ${declares.join('\n ')}
42
+ ${componentDeclares.join('\n ')}
43
+ }
44
+
45
+ export interface ComponentCustomProperties {
46
+ ${directiveDeclares.join('\n ')}
33
47
  }
34
48
  }`;
35
49
  const template = `\
@@ -40,7 +54,7 @@ export const install: (app: App) => void
40
54
 
41
55
  ${exports.join('\n')}
42
56
 
43
- ${globalDeclares}
57
+ ${vueDeclares}
44
58
  `;
45
- await Promise.all([writeFile(resolve(TYPES_DIR, 'index.d.ts'), template)]);
59
+ await writeFile(resolve(TYPES_DIR, 'index.d.ts'), template);
46
60
  }
@@ -62,6 +62,11 @@ export interface VarletConfig {
62
62
  mobile?: Record<string, any>;
63
63
  copy?: CopyOptions['paths'];
64
64
  icons?: VarletConfigIcons;
65
+ /**
66
+ * @default `[]`
67
+ * Directive folder name for component library.
68
+ */
69
+ directives?: string[];
65
70
  }
66
71
  export declare function defineConfig(config: VarletConfig): VarletConfig;
67
72
  export declare function mergeStrategy(value: any, srcValue: any, key: string): any[] | undefined;
@@ -267,4 +267,5 @@ export default defineConfig({
267
267
  fontFamilyClassName: 'var-icon--set',
268
268
  base64: true,
269
269
  },
270
+ directives: [],
270
271
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "2.9.3-alpha.1679304010895",
3
+ "version": "2.9.3-alpha.1679397001839",
4
4
  "type": "module",
5
5
  "description": "cli of varlet",
6
6
  "bin": {
@@ -37,18 +37,15 @@
37
37
  "dependencies": {
38
38
  "@babel/core": "^7.14.8",
39
39
  "@babel/helper-plugin-utils": "^7.14.5",
40
+ "@babel/plugin-transform-typescript": "^7.14.5",
40
41
  "@babel/preset-env": "^7.14.8",
41
42
  "@babel/preset-typescript": "^7.14.5",
42
- "@babel/plugin-transform-typescript": "^7.14.5",
43
43
  "@vitejs/plugin-vue": "4.0.0",
44
44
  "@vitejs/plugin-vue-jsx": "3.0.0",
45
45
  "@vue/babel-plugin-jsx": "1.1.1",
46
46
  "@vue/compiler-sfc": "3.2.25",
47
47
  "@vue/runtime-core": "3.2.25",
48
- "webfont": "^9.0.0",
49
- "sharp": "0.31.3",
50
48
  "babel-jest": "26.6.3",
51
- "picocolors": "^1.0.0",
52
49
  "chokidar": "^3.5.2",
53
50
  "commander": "^8.3.0",
54
51
  "conventional-changelog": "^3.1.25",
@@ -62,15 +59,18 @@
62
59
  "less": "^3.12.2",
63
60
  "lodash-es": "^4.17.21",
64
61
  "nanospinner": "^1.1.0",
62
+ "picocolors": "^1.0.0",
65
63
  "semver": "^7.3.5",
64
+ "sharp": "0.31.1",
66
65
  "slash": "^3.0.0",
67
66
  "ts-jest": "^26.5.1",
68
67
  "typescript": "^4.4.4",
69
68
  "vite": "4.0.4",
70
69
  "vue": "3.2.25",
71
70
  "vue-jest": "^5.0.0-alpha.8",
72
- "@varlet/shared": "2.9.3-alpha.1679304010895",
73
- "@varlet/vite-plugins": "2.9.3-alpha.1679304010895"
71
+ "webfont": "^9.0.0",
72
+ "@varlet/shared": "2.9.3-alpha.1679397001839",
73
+ "@varlet/vite-plugins": "2.9.3-alpha.1679397001839"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/babel__core": "^7.1.12",
@@ -78,13 +78,13 @@
78
78
  "@types/fs-extra": "^9.0.2",
79
79
  "@types/glob": "^7.1.3",
80
80
  "@types/hash-sum": "^1.0.0",
81
+ "@types/inquirer": "^9.0.2",
81
82
  "@types/lodash-es": "^4.17.5",
82
83
  "@types/node": "^18.7.20",
83
84
  "@types/semver": "^7.3.9",
84
- "@types/inquirer": "^9.0.2",
85
85
  "@types/sharp": "0.31.1",
86
- "@varlet/icons": "2.9.3-alpha.1679304010895",
87
- "@varlet/touch-emulator": "2.9.3-alpha.1679304010895"
86
+ "@varlet/icons": "2.9.3-alpha.1679397001839",
87
+ "@varlet/touch-emulator": "2.9.3-alpha.1679397001839"
88
88
  },
89
89
  "peerDependencies": {
90
90
  "@vue/runtime-core": "3.2.16",
@@ -94,8 +94,8 @@
94
94
  "lodash-es": "^4.17.21",
95
95
  "vue": "3.2.25",
96
96
  "vue-router": "4.0.12",
97
- "@varlet/icons": "2.9.3-alpha.1679304010895",
98
- "@varlet/touch-emulator": "2.9.3-alpha.1679304010895"
97
+ "@varlet/icons": "2.9.3-alpha.1679397001839",
98
+ "@varlet/touch-emulator": "2.9.3-alpha.1679397001839"
99
99
  },
100
100
  "scripts": {
101
101
  "dev": "tsc --watch",