@varlet/cli 2.10.0 → 2.10.1-alpha.1682608027166
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/lib/client/appType.d.ts +4 -4
- package/lib/client/appType.js +7 -7
- package/lib/client/index.d.ts +18 -18
- package/lib/client/index.js +109 -109
- package/lib/node/bin.d.ts +2 -2
- package/lib/node/bin.js +148 -148
- package/lib/node/commands/build.d.ts +1 -1
- package/lib/node/commands/build.js +15 -15
- package/lib/node/commands/changelog.d.ts +5 -5
- package/lib/node/commands/changelog.js +20 -20
- package/lib/node/commands/checklist.d.ts +6 -6
- package/lib/node/commands/checklist.js +64 -64
- package/lib/node/commands/commitLint.d.ts +4 -4
- package/lib/node/commands/commitLint.js +19 -19
- package/lib/node/commands/compile.d.ts +3 -3
- package/lib/node/commands/compile.js +31 -31
- package/lib/node/commands/create.d.ts +7 -7
- package/lib/node/commands/create.js +91 -91
- package/lib/node/commands/dev.d.ts +6 -6
- package/lib/node/commands/dev.js +42 -42
- package/lib/node/commands/extension.d.ts +3 -3
- package/lib/node/commands/extension.js +5 -5
- package/lib/node/commands/gen.d.ts +7 -7
- package/lib/node/commands/gen.js +68 -68
- package/lib/node/commands/icons.d.ts +1 -1
- package/lib/node/commands/icons.js +82 -82
- package/lib/node/commands/jest.d.ts +7 -7
- package/lib/node/commands/jest.js +27 -27
- package/lib/node/commands/lint.d.ts +1 -1
- package/lib/node/commands/lint.js +42 -42
- package/lib/node/commands/preview.d.ts +1 -1
- package/lib/node/commands/preview.js +18 -18
- package/lib/node/commands/release.d.ts +5 -5
- package/lib/node/commands/release.js +150 -150
- package/lib/node/commands/vite.d.ts +2 -2
- package/lib/node/commands/vite.js +14 -14
- package/lib/node/compiler/compileModule.d.ts +4 -4
- package/lib/node/compiler/compileModule.js +71 -71
- package/lib/node/compiler/compileSFC.d.ts +6 -6
- package/lib/node/compiler/compileSFC.js +97 -96
- package/lib/node/compiler/compileScript.d.ts +13 -13
- package/lib/node/compiler/compileScript.js +126 -126
- package/lib/node/compiler/compileSiteEntry.d.ts +18 -18
- package/lib/node/compiler/compileSiteEntry.js +121 -121
- package/lib/node/compiler/compileStyle.d.ts +10 -10
- package/lib/node/compiler/compileStyle.js +41 -41
- package/lib/node/compiler/compileTemplateHighlight.d.ts +18 -18
- package/lib/node/compiler/compileTemplateHighlight.js +128 -128
- package/lib/node/compiler/compileTypes.d.ts +2 -2
- package/lib/node/compiler/compileTypes.js +40 -40
- package/lib/node/config/varlet.config.d.ts +73 -73
- package/lib/node/config/varlet.config.js +27 -27
- package/lib/node/config/varlet.default.config.d.ts +2 -2
- package/lib/node/config/varlet.default.config.js +271 -271
- package/lib/node/config/vite.config.d.ts +13 -13
- package/lib/node/config/vite.config.js +115 -115
- package/lib/node/index.d.ts +15 -15
- package/lib/node/index.js +15 -15
- package/lib/node/shared/constant.d.ts +51 -51
- package/lib/node/shared/constant.js +58 -58
- package/lib/node/shared/fsUtils.d.ts +15 -15
- package/lib/node/shared/fsUtils.js +54 -54
- package/lib/node/shared/logger.d.ts +8 -8
- package/lib/node/shared/logger.js +18 -18
- package/package.json +7 -7
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
import fse from 'fs-extra';
|
|
2
|
-
import { SRC_DIR, HL_DIR, HL_API_RE, HL_COMPONENT_NAME_RE, HL_EN_MD, HL_EN_TITLE_ATTRIBUTES_RE, HL_EN_TITLE_EVENTS_RE, HL_EN_TITLE_SLOTS_RE, HL_EN_WEB_TYPES_JSON, HL_ZH_MD, HL_ZH_TITLE_ATTRIBUTES_RE, HL_ZH_TITLE_EVENTS_RE, HL_ZH_TITLE_SLOTS_RE, HL_ZH_WEB_TYPES_JSON, } from '../shared/constant.js';
|
|
3
|
-
import { resolve } from 'path';
|
|
4
|
-
import { getCliVersion, isDir, isMD } from '../shared/fsUtils.js';
|
|
5
|
-
import { get } from 'lodash-es';
|
|
6
|
-
import { getVarletConfig } from '../config/varlet.config.js';
|
|
7
|
-
const { ensureDir, readdirSync, readFileSync, writeFileSync } = fse;
|
|
8
|
-
const TABLE_HEAD_RE = /\s*\|.*\|\s*\n\s*\|.*---+\s*\|\s*\n+/;
|
|
9
|
-
const TABLE_FOOT_RE = /(\|\s*$)|(\|\s*\n(?!\s*\|))/;
|
|
10
|
-
export const replaceDot = (s) => s.replace(/`/g, '');
|
|
11
|
-
export const replaceVersion = (s) => s.replace(/\*\*\*.+\*\*\*/g, '').trim();
|
|
12
|
-
export const replaceUnderline = (s) => s.replace(/_/g, '');
|
|
13
|
-
export function parseTable(table) {
|
|
14
|
-
const rows = table.split('\n').filter(Boolean);
|
|
15
|
-
return rows.map((row) => {
|
|
16
|
-
const cols = row.split('|');
|
|
17
|
-
cols.shift();
|
|
18
|
-
cols.pop();
|
|
19
|
-
return cols.map((col) => col.replace(/__varlet_axis__/g, '|').trim());
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
export function compileTable(md, titleRe) {
|
|
23
|
-
const apiMatched = md.match(HL_API_RE);
|
|
24
|
-
if (!apiMatched) {
|
|
25
|
-
return '';
|
|
26
|
-
}
|
|
27
|
-
md = md.slice(apiMatched.index + apiMatched[0].length);
|
|
28
|
-
const titleMatched = md.match(titleRe);
|
|
29
|
-
if (!titleMatched) {
|
|
30
|
-
return '';
|
|
31
|
-
}
|
|
32
|
-
md = md.slice(titleMatched.index + titleMatched[0].length);
|
|
33
|
-
const tableHeadMatched = md.match(TABLE_HEAD_RE);
|
|
34
|
-
if (!tableHeadMatched) {
|
|
35
|
-
return '';
|
|
36
|
-
}
|
|
37
|
-
md = md.slice(tableHeadMatched.index + tableHeadMatched[0].length);
|
|
38
|
-
const tableFootMatched = md.match(TABLE_FOOT_RE);
|
|
39
|
-
if (!tableFootMatched) {
|
|
40
|
-
return '';
|
|
41
|
-
}
|
|
42
|
-
md = md.slice(0, tableFootMatched.index + tableFootMatched[0].length);
|
|
43
|
-
return md.replace(/\\\|/g, '__varlet_axis__').trim();
|
|
44
|
-
}
|
|
45
|
-
export function compileWebTypes(table, webTypes, componentName, varletConfig) {
|
|
46
|
-
const { attributesTable, eventsTable, slotsTable } = table;
|
|
47
|
-
const attributes = attributesTable.map((row) => ({
|
|
48
|
-
name: replaceVersion(replaceDot(row[0])),
|
|
49
|
-
description: row[1],
|
|
50
|
-
default: replaceDot(row[3]),
|
|
51
|
-
value: {
|
|
52
|
-
type: replaceUnderline(row[2]),
|
|
53
|
-
kind: 'expression',
|
|
54
|
-
},
|
|
55
|
-
}));
|
|
56
|
-
const events = eventsTable.map((row) => ({
|
|
57
|
-
name: replaceVersion(replaceDot(row[0])),
|
|
58
|
-
description: row[1],
|
|
59
|
-
}));
|
|
60
|
-
const slots = slotsTable.map((row) => ({
|
|
61
|
-
name: replaceVersion(replaceDot(row[0])),
|
|
62
|
-
description: row[1],
|
|
63
|
-
}));
|
|
64
|
-
webTypes.contributions.html.tags.push({
|
|
65
|
-
name: `${get(varletConfig, 'namespace')}-${componentName}`,
|
|
66
|
-
attributes,
|
|
67
|
-
events,
|
|
68
|
-
slots,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
export function compileMD(path, webTypes, varletConfig, options) {
|
|
72
|
-
if (!path.endsWith(options.md)) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const md = readFileSync(path, 'utf-8');
|
|
76
|
-
const componentName = path.match(HL_COMPONENT_NAME_RE)[2];
|
|
77
|
-
const attributesTable = parseTable(compileTable(md, options.titleAttributes));
|
|
78
|
-
const eventsTable = parseTable(compileTable(md, options.titleEvents));
|
|
79
|
-
const slotsTable = parseTable(compileTable(md, options.titleSlots));
|
|
80
|
-
const table = {
|
|
81
|
-
attributesTable,
|
|
82
|
-
eventsTable,
|
|
83
|
-
slotsTable,
|
|
84
|
-
};
|
|
85
|
-
compileWebTypes(table, webTypes, componentName, varletConfig);
|
|
86
|
-
}
|
|
87
|
-
export function compileDir(path, webTypes, varletConfig, options) {
|
|
88
|
-
const dir = readdirSync(path);
|
|
89
|
-
dir.forEach((filename) => {
|
|
90
|
-
const filePath = resolve(path, filename);
|
|
91
|
-
isDir(filePath) && compileDir(filePath, webTypes, varletConfig, options);
|
|
92
|
-
isMD(filePath) && compileMD(filePath, webTypes, varletConfig, options);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
export function compileLanguageMD(varletConfig, options) {
|
|
96
|
-
const webTypes = {
|
|
97
|
-
$schema: 'https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json',
|
|
98
|
-
framework: 'vue',
|
|
99
|
-
version: getCliVersion(),
|
|
100
|
-
name: get(varletConfig, 'title'),
|
|
101
|
-
contributions: {
|
|
102
|
-
html: {
|
|
103
|
-
tags: [],
|
|
104
|
-
'types-syntax': 'typescript',
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
compileDir(SRC_DIR, webTypes, varletConfig, options);
|
|
109
|
-
writeFileSync(options.json, JSON.stringify(webTypes, null, 2));
|
|
110
|
-
}
|
|
111
|
-
export async function compileTemplateHighlight() {
|
|
112
|
-
await ensureDir(HL_DIR);
|
|
113
|
-
const varletConfig = await getVarletConfig();
|
|
114
|
-
compileLanguageMD(varletConfig, {
|
|
115
|
-
md: HL_EN_MD,
|
|
116
|
-
json: HL_EN_WEB_TYPES_JSON,
|
|
117
|
-
titleAttributes: HL_EN_TITLE_ATTRIBUTES_RE,
|
|
118
|
-
titleEvents: HL_EN_TITLE_EVENTS_RE,
|
|
119
|
-
titleSlots: HL_EN_TITLE_SLOTS_RE,
|
|
120
|
-
});
|
|
121
|
-
compileLanguageMD(varletConfig, {
|
|
122
|
-
md: HL_ZH_MD,
|
|
123
|
-
json: HL_ZH_WEB_TYPES_JSON,
|
|
124
|
-
titleAttributes: HL_ZH_TITLE_ATTRIBUTES_RE,
|
|
125
|
-
titleEvents: HL_ZH_TITLE_EVENTS_RE,
|
|
126
|
-
titleSlots: HL_ZH_TITLE_SLOTS_RE,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
1
|
+
import fse from 'fs-extra';
|
|
2
|
+
import { SRC_DIR, HL_DIR, HL_API_RE, HL_COMPONENT_NAME_RE, HL_EN_MD, HL_EN_TITLE_ATTRIBUTES_RE, HL_EN_TITLE_EVENTS_RE, HL_EN_TITLE_SLOTS_RE, HL_EN_WEB_TYPES_JSON, HL_ZH_MD, HL_ZH_TITLE_ATTRIBUTES_RE, HL_ZH_TITLE_EVENTS_RE, HL_ZH_TITLE_SLOTS_RE, HL_ZH_WEB_TYPES_JSON, } from '../shared/constant.js';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
import { getCliVersion, isDir, isMD } from '../shared/fsUtils.js';
|
|
5
|
+
import { get } from 'lodash-es';
|
|
6
|
+
import { getVarletConfig } from '../config/varlet.config.js';
|
|
7
|
+
const { ensureDir, readdirSync, readFileSync, writeFileSync } = fse;
|
|
8
|
+
const TABLE_HEAD_RE = /\s*\|.*\|\s*\n\s*\|.*---+\s*\|\s*\n+/;
|
|
9
|
+
const TABLE_FOOT_RE = /(\|\s*$)|(\|\s*\n(?!\s*\|))/;
|
|
10
|
+
export const replaceDot = (s) => s.replace(/`/g, '');
|
|
11
|
+
export const replaceVersion = (s) => s.replace(/\*\*\*.+\*\*\*/g, '').trim();
|
|
12
|
+
export const replaceUnderline = (s) => s.replace(/_/g, '');
|
|
13
|
+
export function parseTable(table) {
|
|
14
|
+
const rows = table.split('\n').filter(Boolean);
|
|
15
|
+
return rows.map((row) => {
|
|
16
|
+
const cols = row.split('|');
|
|
17
|
+
cols.shift();
|
|
18
|
+
cols.pop();
|
|
19
|
+
return cols.map((col) => col.replace(/__varlet_axis__/g, '|').trim());
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function compileTable(md, titleRe) {
|
|
23
|
+
const apiMatched = md.match(HL_API_RE);
|
|
24
|
+
if (!apiMatched) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
md = md.slice(apiMatched.index + apiMatched[0].length);
|
|
28
|
+
const titleMatched = md.match(titleRe);
|
|
29
|
+
if (!titleMatched) {
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
md = md.slice(titleMatched.index + titleMatched[0].length);
|
|
33
|
+
const tableHeadMatched = md.match(TABLE_HEAD_RE);
|
|
34
|
+
if (!tableHeadMatched) {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
md = md.slice(tableHeadMatched.index + tableHeadMatched[0].length);
|
|
38
|
+
const tableFootMatched = md.match(TABLE_FOOT_RE);
|
|
39
|
+
if (!tableFootMatched) {
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
md = md.slice(0, tableFootMatched.index + tableFootMatched[0].length);
|
|
43
|
+
return md.replace(/\\\|/g, '__varlet_axis__').trim();
|
|
44
|
+
}
|
|
45
|
+
export function compileWebTypes(table, webTypes, componentName, varletConfig) {
|
|
46
|
+
const { attributesTable, eventsTable, slotsTable } = table;
|
|
47
|
+
const attributes = attributesTable.map((row) => ({
|
|
48
|
+
name: replaceVersion(replaceDot(row[0])),
|
|
49
|
+
description: row[1],
|
|
50
|
+
default: replaceDot(row[3]),
|
|
51
|
+
value: {
|
|
52
|
+
type: replaceUnderline(row[2]),
|
|
53
|
+
kind: 'expression',
|
|
54
|
+
},
|
|
55
|
+
}));
|
|
56
|
+
const events = eventsTable.map((row) => ({
|
|
57
|
+
name: replaceVersion(replaceDot(row[0])),
|
|
58
|
+
description: row[1],
|
|
59
|
+
}));
|
|
60
|
+
const slots = slotsTable.map((row) => ({
|
|
61
|
+
name: replaceVersion(replaceDot(row[0])),
|
|
62
|
+
description: row[1],
|
|
63
|
+
}));
|
|
64
|
+
webTypes.contributions.html.tags.push({
|
|
65
|
+
name: `${get(varletConfig, 'namespace')}-${componentName}`,
|
|
66
|
+
attributes,
|
|
67
|
+
events,
|
|
68
|
+
slots,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export function compileMD(path, webTypes, varletConfig, options) {
|
|
72
|
+
if (!path.endsWith(options.md)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const md = readFileSync(path, 'utf-8');
|
|
76
|
+
const componentName = path.match(HL_COMPONENT_NAME_RE)[2];
|
|
77
|
+
const attributesTable = parseTable(compileTable(md, options.titleAttributes));
|
|
78
|
+
const eventsTable = parseTable(compileTable(md, options.titleEvents));
|
|
79
|
+
const slotsTable = parseTable(compileTable(md, options.titleSlots));
|
|
80
|
+
const table = {
|
|
81
|
+
attributesTable,
|
|
82
|
+
eventsTable,
|
|
83
|
+
slotsTable,
|
|
84
|
+
};
|
|
85
|
+
compileWebTypes(table, webTypes, componentName, varletConfig);
|
|
86
|
+
}
|
|
87
|
+
export function compileDir(path, webTypes, varletConfig, options) {
|
|
88
|
+
const dir = readdirSync(path);
|
|
89
|
+
dir.forEach((filename) => {
|
|
90
|
+
const filePath = resolve(path, filename);
|
|
91
|
+
isDir(filePath) && compileDir(filePath, webTypes, varletConfig, options);
|
|
92
|
+
isMD(filePath) && compileMD(filePath, webTypes, varletConfig, options);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
export function compileLanguageMD(varletConfig, options) {
|
|
96
|
+
const webTypes = {
|
|
97
|
+
$schema: 'https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json',
|
|
98
|
+
framework: 'vue',
|
|
99
|
+
version: getCliVersion(),
|
|
100
|
+
name: get(varletConfig, 'title'),
|
|
101
|
+
contributions: {
|
|
102
|
+
html: {
|
|
103
|
+
tags: [],
|
|
104
|
+
'types-syntax': 'typescript',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
compileDir(SRC_DIR, webTypes, varletConfig, options);
|
|
109
|
+
writeFileSync(options.json, JSON.stringify(webTypes, null, 2));
|
|
110
|
+
}
|
|
111
|
+
export async function compileTemplateHighlight() {
|
|
112
|
+
await ensureDir(HL_DIR);
|
|
113
|
+
const varletConfig = await getVarletConfig();
|
|
114
|
+
compileLanguageMD(varletConfig, {
|
|
115
|
+
md: HL_EN_MD,
|
|
116
|
+
json: HL_EN_WEB_TYPES_JSON,
|
|
117
|
+
titleAttributes: HL_EN_TITLE_ATTRIBUTES_RE,
|
|
118
|
+
titleEvents: HL_EN_TITLE_EVENTS_RE,
|
|
119
|
+
titleSlots: HL_EN_TITLE_SLOTS_RE,
|
|
120
|
+
});
|
|
121
|
+
compileLanguageMD(varletConfig, {
|
|
122
|
+
md: HL_ZH_MD,
|
|
123
|
+
json: HL_ZH_WEB_TYPES_JSON,
|
|
124
|
+
titleAttributes: HL_ZH_TITLE_ATTRIBUTES_RE,
|
|
125
|
+
titleEvents: HL_ZH_TITLE_EVENTS_RE,
|
|
126
|
+
titleSlots: HL_ZH_TITLE_SLOTS_RE,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function generateReference(moduleDir: string): void;
|
|
2
|
-
export declare function compileTypes(): Promise<void>;
|
|
1
|
+
export declare function generateReference(moduleDir: string): void;
|
|
2
|
+
export declare function compileTypes(): Promise<void>;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import fse from 'fs-extra';
|
|
2
|
-
import { TYPES_DIR, UI_PACKAGE_JSON } from '../shared/constant.js';
|
|
3
|
-
import { bigCamelize } from '@varlet/shared';
|
|
4
|
-
import { resolve, relative } from 'path';
|
|
5
|
-
import { getVarletConfig } from '../config/varlet.config.js';
|
|
6
|
-
import { get } from 'lodash-es';
|
|
7
|
-
const { ensureDir, writeFileSync, readdir, writeFile, readJSONSync } = fse;
|
|
8
|
-
export function generateReference(moduleDir) {
|
|
1
|
+
import fse from 'fs-extra';
|
|
2
|
+
import { TYPES_DIR, UI_PACKAGE_JSON } from '../shared/constant.js';
|
|
3
|
+
import { bigCamelize } from '@varlet/shared';
|
|
4
|
+
import { resolve, relative } from 'path';
|
|
5
|
+
import { getVarletConfig } from '../config/varlet.config.js';
|
|
6
|
+
import { get } from 'lodash-es';
|
|
7
|
+
const { ensureDir, writeFileSync, readdir, writeFile, readJSONSync } = fse;
|
|
8
|
+
export function generateReference(moduleDir) {
|
|
9
9
|
writeFileSync(resolve(moduleDir, 'index.d.ts'), `\
|
|
10
10
|
export * from '${relative(moduleDir, TYPES_DIR)}'
|
|
11
|
-
`);
|
|
12
|
-
}
|
|
13
|
-
export async function compileTypes() {
|
|
14
|
-
await ensureDir(TYPES_DIR);
|
|
15
|
-
const varletConfig = await getVarletConfig();
|
|
16
|
-
const namespace = get(varletConfig, 'namespace');
|
|
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');
|
|
21
|
-
const exports = [];
|
|
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 './${folder}'`);
|
|
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']`);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
11
|
+
`);
|
|
12
|
+
}
|
|
13
|
+
export async function compileTypes() {
|
|
14
|
+
await ensureDir(TYPES_DIR);
|
|
15
|
+
const varletConfig = await getVarletConfig();
|
|
16
|
+
const namespace = get(varletConfig, 'namespace');
|
|
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');
|
|
21
|
+
const exports = [];
|
|
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 './${folder}'`);
|
|
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']`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
39
|
const vueDeclares = `\
|
|
40
40
|
declare module 'vue' {
|
|
41
41
|
export interface GlobalComponents {
|
|
@@ -45,7 +45,7 @@ declare module 'vue' {
|
|
|
45
45
|
export interface ComponentCustomProperties {
|
|
46
46
|
${directiveDeclares.join('\n ')}
|
|
47
47
|
}
|
|
48
|
-
}`;
|
|
48
|
+
}`;
|
|
49
49
|
const template = `\
|
|
50
50
|
import type { App } from 'vue'
|
|
51
51
|
|
|
@@ -55,6 +55,6 @@ export const install: (app: App) => void
|
|
|
55
55
|
${exports.join('\n')}
|
|
56
56
|
|
|
57
57
|
${vueDeclares}
|
|
58
|
-
`;
|
|
59
|
-
await writeFile(resolve(TYPES_DIR, 'index.d.ts'), template);
|
|
60
|
-
}
|
|
58
|
+
`;
|
|
59
|
+
await writeFile(resolve(TYPES_DIR, 'index.d.ts'), template);
|
|
60
|
+
}
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import { type CopyOptions } from '@varlet/vite-plugins';
|
|
2
|
-
export interface VarletConfigIcons {
|
|
3
|
-
/**
|
|
4
|
-
* @default `varlet-icons`
|
|
5
|
-
* Font name.
|
|
6
|
-
*/
|
|
7
|
-
name?: string;
|
|
8
|
-
/**
|
|
9
|
-
* @default `var-icon`
|
|
10
|
-
* Font name prefix.
|
|
11
|
-
*/
|
|
12
|
-
namespace?: string;
|
|
13
|
-
/**
|
|
14
|
-
* @default `true`
|
|
15
|
-
* Output base64
|
|
16
|
-
*/
|
|
17
|
-
base64?: boolean;
|
|
18
|
-
publicPath?: string;
|
|
19
|
-
fontFamilyClassName?: string;
|
|
20
|
-
fontWeight?: string;
|
|
21
|
-
fontStyle?: string;
|
|
22
|
-
}
|
|
23
|
-
export interface VarletConfig {
|
|
24
|
-
/**
|
|
25
|
-
* @default `Varlet`
|
|
26
|
-
* UI library name.
|
|
27
|
-
*/
|
|
28
|
-
name?: string;
|
|
29
|
-
/**
|
|
30
|
-
* @default `var`
|
|
31
|
-
* Component name prefix
|
|
32
|
-
*/
|
|
33
|
-
namespace?: string;
|
|
34
|
-
/**
|
|
35
|
-
* @default `localhost`
|
|
36
|
-
* Local dev server host
|
|
37
|
-
*/
|
|
38
|
-
host?: string;
|
|
39
|
-
/**
|
|
40
|
-
* @default `8080`
|
|
41
|
-
* Local dev server port
|
|
42
|
-
*/
|
|
43
|
-
port?: number;
|
|
44
|
-
title?: string;
|
|
45
|
-
logo?: string;
|
|
46
|
-
themeKey?: string;
|
|
47
|
-
defaultLanguage?: 'zh-CN' | 'en-US';
|
|
48
|
-
/**
|
|
49
|
-
* @default `false`
|
|
50
|
-
* Show mobile component on the right.
|
|
51
|
-
*/
|
|
52
|
-
useMobile?: boolean;
|
|
53
|
-
lightTheme?: Record<string, string>;
|
|
54
|
-
darkTheme?: Record<string, string>;
|
|
55
|
-
highlight?: {
|
|
56
|
-
style: string;
|
|
57
|
-
};
|
|
58
|
-
analysis?: {
|
|
59
|
-
baidu: string;
|
|
60
|
-
};
|
|
61
|
-
pc?: Record<string, any>;
|
|
62
|
-
mobile?: Record<string, any>;
|
|
63
|
-
copy?: CopyOptions['paths'];
|
|
64
|
-
icons?: VarletConfigIcons;
|
|
65
|
-
/**
|
|
66
|
-
* @default `[]`
|
|
67
|
-
* Directive folder name for component library.
|
|
68
|
-
*/
|
|
69
|
-
directives?: string[];
|
|
70
|
-
}
|
|
71
|
-
export declare function defineConfig(config: VarletConfig): VarletConfig;
|
|
72
|
-
export declare function mergeStrategy(value: any, srcValue: any, key: string): any[] | undefined;
|
|
73
|
-
export declare function getVarletConfig(emit?: boolean): Promise<Required<VarletConfig>>;
|
|
1
|
+
import { type CopyOptions } from '@varlet/vite-plugins';
|
|
2
|
+
export interface VarletConfigIcons {
|
|
3
|
+
/**
|
|
4
|
+
* @default `varlet-icons`
|
|
5
|
+
* Font name.
|
|
6
|
+
*/
|
|
7
|
+
name?: string;
|
|
8
|
+
/**
|
|
9
|
+
* @default `var-icon`
|
|
10
|
+
* Font name prefix.
|
|
11
|
+
*/
|
|
12
|
+
namespace?: string;
|
|
13
|
+
/**
|
|
14
|
+
* @default `true`
|
|
15
|
+
* Output base64
|
|
16
|
+
*/
|
|
17
|
+
base64?: boolean;
|
|
18
|
+
publicPath?: string;
|
|
19
|
+
fontFamilyClassName?: string;
|
|
20
|
+
fontWeight?: string;
|
|
21
|
+
fontStyle?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface VarletConfig {
|
|
24
|
+
/**
|
|
25
|
+
* @default `Varlet`
|
|
26
|
+
* UI library name.
|
|
27
|
+
*/
|
|
28
|
+
name?: string;
|
|
29
|
+
/**
|
|
30
|
+
* @default `var`
|
|
31
|
+
* Component name prefix
|
|
32
|
+
*/
|
|
33
|
+
namespace?: string;
|
|
34
|
+
/**
|
|
35
|
+
* @default `localhost`
|
|
36
|
+
* Local dev server host
|
|
37
|
+
*/
|
|
38
|
+
host?: string;
|
|
39
|
+
/**
|
|
40
|
+
* @default `8080`
|
|
41
|
+
* Local dev server port
|
|
42
|
+
*/
|
|
43
|
+
port?: number;
|
|
44
|
+
title?: string;
|
|
45
|
+
logo?: string;
|
|
46
|
+
themeKey?: string;
|
|
47
|
+
defaultLanguage?: 'zh-CN' | 'en-US';
|
|
48
|
+
/**
|
|
49
|
+
* @default `false`
|
|
50
|
+
* Show mobile component on the right.
|
|
51
|
+
*/
|
|
52
|
+
useMobile?: boolean;
|
|
53
|
+
lightTheme?: Record<string, string>;
|
|
54
|
+
darkTheme?: Record<string, string>;
|
|
55
|
+
highlight?: {
|
|
56
|
+
style: string;
|
|
57
|
+
};
|
|
58
|
+
analysis?: {
|
|
59
|
+
baidu: string;
|
|
60
|
+
};
|
|
61
|
+
pc?: Record<string, any>;
|
|
62
|
+
mobile?: Record<string, any>;
|
|
63
|
+
copy?: CopyOptions['paths'];
|
|
64
|
+
icons?: VarletConfigIcons;
|
|
65
|
+
/**
|
|
66
|
+
* @default `[]`
|
|
67
|
+
* Directive folder name for component library.
|
|
68
|
+
*/
|
|
69
|
+
directives?: string[];
|
|
70
|
+
}
|
|
71
|
+
export declare function defineConfig(config: VarletConfig): VarletConfig;
|
|
72
|
+
export declare function mergeStrategy(value: any, srcValue: any, key: string): any[] | undefined;
|
|
73
|
+
export declare function getVarletConfig(emit?: boolean): Promise<Required<VarletConfig>>;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import fse from 'fs-extra';
|
|
2
|
-
import { mergeWith } from 'lodash-es';
|
|
3
|
-
import { VARLET_CONFIG, SITE_CONFIG } from '../shared/constant.js';
|
|
4
|
-
import { outputFileSyncOnChange } from '../shared/fsUtils.js';
|
|
5
|
-
import { isArray } from '@varlet/shared';
|
|
6
|
-
import { pathToFileURL } from 'url';
|
|
7
|
-
const { pathExistsSync, statSync } = fse;
|
|
8
|
-
export function defineConfig(config) {
|
|
9
|
-
return config;
|
|
10
|
-
}
|
|
11
|
-
export function mergeStrategy(value, srcValue, key) {
|
|
12
|
-
if (key === 'features' && isArray(srcValue)) {
|
|
13
|
-
return srcValue;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export async function getVarletConfig(emit = false) {
|
|
17
|
-
const defaultConfig = (await import('./varlet.default.config.js')).default;
|
|
18
|
-
const config = pathExistsSync(VARLET_CONFIG)
|
|
19
|
-
? (await import(`${pathToFileURL(VARLET_CONFIG).href}?_t=${statSync(VARLET_CONFIG).mtimeMs}`)).default
|
|
20
|
-
: {};
|
|
21
|
-
const mergedConfig = mergeWith(defaultConfig, config, mergeStrategy);
|
|
22
|
-
if (emit) {
|
|
23
|
-
const source = JSON.stringify(mergedConfig, null, 2);
|
|
24
|
-
outputFileSyncOnChange(SITE_CONFIG, source);
|
|
25
|
-
}
|
|
26
|
-
return mergedConfig;
|
|
27
|
-
}
|
|
1
|
+
import fse from 'fs-extra';
|
|
2
|
+
import { mergeWith } from 'lodash-es';
|
|
3
|
+
import { VARLET_CONFIG, SITE_CONFIG } from '../shared/constant.js';
|
|
4
|
+
import { outputFileSyncOnChange } from '../shared/fsUtils.js';
|
|
5
|
+
import { isArray } from '@varlet/shared';
|
|
6
|
+
import { pathToFileURL } from 'url';
|
|
7
|
+
const { pathExistsSync, statSync } = fse;
|
|
8
|
+
export function defineConfig(config) {
|
|
9
|
+
return config;
|
|
10
|
+
}
|
|
11
|
+
export function mergeStrategy(value, srcValue, key) {
|
|
12
|
+
if (key === 'features' && isArray(srcValue)) {
|
|
13
|
+
return srcValue;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export async function getVarletConfig(emit = false) {
|
|
17
|
+
const defaultConfig = (await import('./varlet.default.config.js')).default;
|
|
18
|
+
const config = pathExistsSync(VARLET_CONFIG)
|
|
19
|
+
? (await import(`${pathToFileURL(VARLET_CONFIG).href}?_t=${statSync(VARLET_CONFIG).mtimeMs}`)).default
|
|
20
|
+
: {};
|
|
21
|
+
const mergedConfig = mergeWith(defaultConfig, config, mergeStrategy);
|
|
22
|
+
if (emit) {
|
|
23
|
+
const source = JSON.stringify(mergedConfig, null, 2);
|
|
24
|
+
outputFileSyncOnChange(SITE_CONFIG, source);
|
|
25
|
+
}
|
|
26
|
+
return mergedConfig;
|
|
27
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("./varlet.config.js").VarletConfig;
|
|
2
|
-
export default _default;
|
|
1
|
+
declare const _default: import("./varlet.config.js").VarletConfig;
|
|
2
|
+
export default _default;
|