@varlet/cli 3.2.13 → 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.
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function compileMD(path: string, keys: Set<string>): void;
|
|
2
|
-
export declare function compileDir(path: string, keys: Set<string
|
|
3
|
-
export declare function compileStyleVars(): void
|
|
2
|
+
export declare function compileDir(path: string, keys: Set<string>, defaultLanguage: 'zh-CN' | 'en-US'): void;
|
|
3
|
+
export declare function compileStyleVars(): Promise<void>;
|
|
@@ -2,7 +2,8 @@ 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 {
|
|
5
|
+
import { getVarletConfig } from '../config/varlet.config.js';
|
|
6
|
+
import { get } from 'lodash-es';
|
|
6
7
|
const { ensureDirSync, readdirSync, readFileSync, writeFileSync } = fse;
|
|
7
8
|
export function compileMD(path, keys) {
|
|
8
9
|
const content = readFileSync(path, 'utf-8');
|
|
@@ -11,23 +12,36 @@ export function compileMD(path, keys) {
|
|
|
11
12
|
keys.add(key.replace(/`/g, ''));
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
|
-
export function compileDir(path, keys) {
|
|
15
|
+
export function compileDir(path, keys, defaultLanguage) {
|
|
15
16
|
const dir = readdirSync(path);
|
|
16
17
|
dir.forEach((filename) => {
|
|
17
18
|
const filePath = resolve(path, filename);
|
|
18
|
-
isDir(filePath) && compileDir(filePath, keys);
|
|
19
|
-
isMD(filePath) &&
|
|
19
|
+
isDir(filePath) && compileDir(filePath, keys, defaultLanguage);
|
|
20
|
+
if (isMD(filePath) && filename.includes(defaultLanguage)) {
|
|
21
|
+
compileMD(filePath, keys);
|
|
22
|
+
}
|
|
20
23
|
});
|
|
21
24
|
}
|
|
22
|
-
export function compileStyleVars() {
|
|
25
|
+
export async function compileStyleVars() {
|
|
23
26
|
ensureDirSync(TYPES_DIR);
|
|
27
|
+
const defaultLanguage = get(await getVarletConfig(), 'defaultLanguage');
|
|
24
28
|
const keys = new Set();
|
|
25
|
-
compileDir(SRC_DIR, keys);
|
|
26
|
-
|
|
29
|
+
compileDir(SRC_DIR, keys, defaultLanguage);
|
|
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) => {
|
|
27
41
|
template += ` '${key}'?: string\n`;
|
|
28
|
-
template += ` ${camelize(key.slice(2))}?: string\n`;
|
|
29
42
|
return template;
|
|
30
|
-
}, '
|
|
31
|
-
|
|
32
|
-
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> {}`);
|
|
33
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "3.2.
|
|
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.
|
|
68
|
-
"@varlet/vite-plugins": "3.2.
|
|
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.
|
|
84
|
-
"@varlet/
|
|
85
|
-
"@varlet/
|
|
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/
|
|
99
|
-
"@varlet/
|
|
100
|
-
"@varlet/
|
|
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",
|
package/site/mobile/AppHome.vue
CHANGED
|
@@ -53,7 +53,7 @@ export default {
|
|
|
53
53
|
query: {
|
|
54
54
|
language: lang.value,
|
|
55
55
|
platform: platform.value,
|
|
56
|
-
replace: component.doc
|
|
56
|
+
replace: component.doc,
|
|
57
57
|
},
|
|
58
58
|
})
|
|
59
59
|
|
|
@@ -77,9 +77,7 @@ export default {
|
|
|
77
77
|
|
|
78
78
|
<style lang="less">
|
|
79
79
|
.varlet-logo {
|
|
80
|
-
height: 100px;
|
|
81
80
|
padding-top: 30px;
|
|
82
|
-
margin-bottom: 20px;
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
.varlet-home__title {
|
|
@@ -96,9 +94,9 @@ export default {
|
|
|
96
94
|
}
|
|
97
95
|
|
|
98
96
|
.varlet-home__desc {
|
|
99
|
-
margin: 0 0 40px;
|
|
100
97
|
color: var(--site-config-color-sub-text);
|
|
101
98
|
font-size: 14px;
|
|
99
|
+
line-height: 22px;
|
|
102
100
|
}
|
|
103
101
|
|
|
104
102
|
.varlet-home__image {
|