@varlet/cli 2.19.1 → 2.19.2-alpha.1700638874586

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.
@@ -0,0 +1,3 @@
1
+ export declare function compileMD(path: string, keys: Set<string>): void;
2
+ export declare function compileDir(path: string, keys: Set<string>): void;
3
+ export declare function compileStyleVars(): void;
@@ -0,0 +1,32 @@
1
+ import fse from 'fs-extra';
2
+ import { SRC_DIR, TYPES_DIR } from '../shared/constant.js';
3
+ import { resolve } from 'path';
4
+ import { isDir, isMD } from '../shared/fsUtils.js';
5
+ import { camelize } from '@varlet/shared';
6
+ const { ensureDirSync, readdirSync, readFileSync, writeFileSync } = fse;
7
+ export function compileMD(path, keys) {
8
+ const content = readFileSync(path, 'utf-8');
9
+ const result = content.match(/`--[\w-]+`/g) ?? [];
10
+ result.forEach((key) => {
11
+ keys.add(key.replace(/`/g, ''));
12
+ });
13
+ }
14
+ export function compileDir(path, keys) {
15
+ const dir = readdirSync(path);
16
+ dir.forEach((filename) => {
17
+ const filePath = resolve(path, filename);
18
+ isDir(filePath) && compileDir(filePath, keys);
19
+ isMD(filePath) && compileMD(filePath, keys);
20
+ });
21
+ }
22
+ export function compileStyleVars() {
23
+ ensureDirSync(TYPES_DIR);
24
+ const keys = new Set();
25
+ compileDir(SRC_DIR, keys);
26
+ const template = [...keys].reduce((template, key) => {
27
+ template += ` '${key}'?: string;\n`;
28
+ template += ` ${camelize(key.slice(2))}?: string;\n`;
29
+ return template;
30
+ }, 'export interface StyleVars {\n');
31
+ writeFileSync(resolve(TYPES_DIR, 'styleVars.d.ts'), template + '}');
32
+ }
@@ -4,6 +4,7 @@ import { bigCamelize } from '@varlet/shared';
4
4
  import { resolve, relative } from 'path';
5
5
  import { getVarletConfig } from '../config/varlet.config.js';
6
6
  import { get } from 'lodash-es';
7
+ import { compileStyleVars } from './compileStyleVars.js';
7
8
  const { ensureDir, writeFileSync, readdir, writeFile, readJSONSync } = fse;
8
9
  export function generateReference(moduleDir) {
9
10
  writeFileSync(resolve(moduleDir, 'index.d.ts'), `\
@@ -12,6 +13,7 @@ export * from '${relative(moduleDir, TYPES_DIR)}'
12
13
  }
13
14
  export async function compileTypes() {
14
15
  await ensureDir(TYPES_DIR);
16
+ compileStyleVars();
15
17
  const varletConfig = await getVarletConfig();
16
18
  const namespace = get(varletConfig, 'namespace');
17
19
  const directives = get(varletConfig, 'directives');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "2.19.1",
3
+ "version": "2.19.2-alpha.1700638874586",
4
4
  "type": "module",
5
5
  "description": "cli of varlet",
6
6
  "bin": {
@@ -64,8 +64,8 @@
64
64
  "vite": "4.3.5",
65
65
  "vue": "3.3.4",
66
66
  "webfont": "^9.0.0",
67
- "@varlet/shared": "2.19.1",
68
- "@varlet/vite-plugins": "2.19.1"
67
+ "@varlet/shared": "2.19.2-alpha.1700638874586",
68
+ "@varlet/vite-plugins": "2.19.2-alpha.1700638874586"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/babel__core": "^7.20.1",
@@ -80,9 +80,9 @@
80
80
  "@types/semver": "^7.3.9",
81
81
  "@types/sharp": "0.31.1",
82
82
  "rimraf": "^5.0.1",
83
- "@varlet/icons": "2.19.1",
84
- "@varlet/touch-emulator": "2.19.1",
85
- "@varlet/ui": "2.19.1"
83
+ "@varlet/icons": "2.19.2-alpha.1700638874586",
84
+ "@varlet/ui": "2.19.2-alpha.1700638874586",
85
+ "@varlet/touch-emulator": "2.19.2-alpha.1700638874586"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "@vue/runtime-core": "3.3.4",
@@ -95,9 +95,9 @@
95
95
  "lodash-es": "^4.17.21",
96
96
  "vue": "3.3.4",
97
97
  "vue-router": "4.2.0",
98
- "@varlet/icons": "2.19.1",
99
- "@varlet/touch-emulator": "2.19.1",
100
- "@varlet/ui": "2.19.1"
98
+ "@varlet/icons": "2.19.2-alpha.1700638874586",
99
+ "@varlet/ui": "2.19.2-alpha.1700638874586",
100
+ "@varlet/touch-emulator": "2.19.2-alpha.1700638874586"
101
101
  },
102
102
  "scripts": {
103
103
  "dev": "tsc --watch",