@varlet/cli 3.2.14-alpha.1717685185218 → 3.2.14
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.
|
@@ -2,7 +2,6 @@ import fse from 'fs-extra';
|
|
|
2
2
|
import { SRC_DIR, TYPES_DIR } from '../shared/constant.js';
|
|
3
3
|
import { resolve } from 'path';
|
|
4
4
|
import { isDir, isMD } from '../shared/fsUtils.js';
|
|
5
|
-
import { camelize } from '@varlet/shared';
|
|
6
5
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
7
6
|
import { get } from 'lodash-es';
|
|
8
7
|
const { ensureDirSync, readdirSync, readFileSync, writeFileSync } = fse;
|
|
@@ -28,11 +27,21 @@ export async function compileStyleVars() {
|
|
|
28
27
|
const defaultLanguage = get(await getVarletConfig(), 'defaultLanguage');
|
|
29
28
|
const keys = new Set();
|
|
30
29
|
compileDir(SRC_DIR, keys, defaultLanguage);
|
|
31
|
-
|
|
30
|
+
const assistanceType = `type RemoveTwoDashes<T extends string> = T extends \`--$\{infer Rest}\` ? Rest : T
|
|
31
|
+
|
|
32
|
+
type CamelCase<S extends string> =
|
|
33
|
+
S extends \`$\{infer P1}-$\{infer P2}\`
|
|
34
|
+
? \`$\{P1}$\{CamelCase<Capitalize<P2>>}\`
|
|
35
|
+
: S
|
|
36
|
+
|
|
37
|
+
type FormatStyleVars<T> = {
|
|
38
|
+
[K in keyof T as CamelCase<RemoveTwoDashes<K & string>>]?: T[K];
|
|
39
|
+
} & T`;
|
|
40
|
+
let baseStyleVars = [...keys].reduce((template, key) => {
|
|
32
41
|
template += ` '${key}'?: string\n`;
|
|
33
|
-
template += ` ${camelize(key.slice(2))}?: string\n`;
|
|
34
42
|
return template;
|
|
35
|
-
}, '
|
|
36
|
-
|
|
37
|
-
writeFileSync(resolve(TYPES_DIR, 'styleVars.d.ts'),
|
|
43
|
+
}, '\n\ninterface BaseStyleVars {\n');
|
|
44
|
+
baseStyleVars += ' [key: PropertyKey]: string\n}\n';
|
|
45
|
+
writeFileSync(resolve(TYPES_DIR, 'styleVars.d.ts'), `${assistanceType}${baseStyleVars}
|
|
46
|
+
export interface StyleVars extends FormatStyleVars<BaseStyleVars> {}`);
|
|
38
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "3.2.14
|
|
3
|
+
"version": "3.2.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"semver": "^7.3.5",
|
|
65
65
|
"sharp": "0.31.1",
|
|
66
66
|
"typescript": "^5.1.5",
|
|
67
|
-
"@varlet/shared": "3.2.14
|
|
68
|
-
"@varlet/vite-plugins": "3.2.14
|
|
67
|
+
"@varlet/shared": "3.2.14",
|
|
68
|
+
"@varlet/vite-plugins": "3.2.14"
|
|
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/ui": "3.2.14
|
|
84
|
-
"@varlet/icons": "3.2.14
|
|
85
|
-
"@varlet/touch-emulator": "3.2.14
|
|
83
|
+
"@varlet/ui": "3.2.14",
|
|
84
|
+
"@varlet/icons": "3.2.14",
|
|
85
|
+
"@varlet/touch-emulator": "3.2.14"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"@vue/runtime-core": "3.4.21",
|
|
@@ -95,9 +95,9 @@
|
|
|
95
95
|
"lodash-es": "^4.17.21",
|
|
96
96
|
"vue": "3.4.21",
|
|
97
97
|
"vue-router": "4.2.0",
|
|
98
|
-
"@varlet/ui": "3.2.14
|
|
99
|
-
"@varlet/icons": "3.2.14
|
|
100
|
-
"@varlet/touch-emulator": "3.2.14
|
|
98
|
+
"@varlet/ui": "3.2.14",
|
|
99
|
+
"@varlet/icons": "3.2.14",
|
|
100
|
+
"@varlet/touch-emulator": "3.2.14"
|
|
101
101
|
},
|
|
102
102
|
"scripts": {
|
|
103
103
|
"dev": "tsc --watch",
|