@varlet/cli 2.7.2 → 2.7.3-alpha.1675189320554
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 +26 -2
- package/README.zh-CN.md +26 -2
- package/lib/node/bin.js +25 -4
- package/lib/node/commands/changelog.d.ts +1 -2
- package/lib/node/commands/create.d.ts +1 -2
- package/lib/node/commands/extension.d.ts +3 -0
- package/lib/node/commands/extension.js +5 -0
- package/lib/node/commands/gen.d.ts +1 -2
- package/lib/node/commands/icons.d.ts +1 -0
- package/lib/node/commands/icons.js +105 -0
- package/lib/node/commands/jest.d.ts +1 -2
- package/lib/node/commands/release.d.ts +1 -2
- package/lib/node/commands/vite.d.ts +1 -2
- package/lib/node/compiler/compileSFC.d.ts +3 -0
- package/lib/node/compiler/compileSFC.js +47 -34
- package/lib/node/config/varlet.config.d.ts +22 -0
- package/lib/node/config/varlet.default.config.js +8 -0
- package/lib/node/config/vite.config.d.ts +2 -0
- package/lib/node/config/vite.config.js +17 -1
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.js +1 -0
- package/lib/node/shared/constant.d.ts +6 -0
- package/lib/node/shared/constant.js +8 -0
- package/package.json +10 -7
- package/lib/varlet-cli/src/node/config/varlet.config.d.ts +0 -44
- package/lib/varlet-cli/src/node/config/varlet.config.js +0 -27
- package/lib/varlet-vite-plugins/src/copy.d.ts +0 -9
- package/lib/varlet-vite-plugins/src/copy.js +0 -17
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Components Library Tools
|
|
1
|
+
# Components Library Tools
|
|
2
2
|
|
|
3
3
|
### Intro
|
|
4
4
|
|
|
@@ -13,6 +13,8 @@ The out-of-the-box `Vue3 component library` rapid prototyping tool provides a se
|
|
|
13
13
|
- 📦 Out-of-the-box code inspection tool
|
|
14
14
|
- 📦 Out-of-the-box unit testing tools
|
|
15
15
|
- 📦 Out-of-the-box code publishing tool, publishes to both `npm` and `github`, and automatically generates changelogs
|
|
16
|
+
- 💪 Support for `VSCode` extension development
|
|
17
|
+
- 💪 Support `build svg to web fonts`
|
|
16
18
|
- 💪 Support for `Typescript`
|
|
17
19
|
- 💪 Support `Dark Mode`
|
|
18
20
|
- 🌍 Support `Internationalization`
|
|
@@ -53,7 +55,8 @@ Also refer to `@varlet/ui` [varlet.config.mjs](https://github.com/varletjs/varle
|
|
|
53
55
|
| `analysis` | Document statistics related | _{ baidu: string }_ | `-` |
|
|
54
56
|
| `pc` | PC-side document structure configuration | _Record<string, any>_ | `-` |
|
|
55
57
|
| `mobile` | Mobile side document structure configuration | _Record<string, any>_ | `-` |
|
|
56
|
-
| `copy` | Copy file options | _
|
|
58
|
+
| `copy` | Copy file options | _[CopyPath[]](https://github.com/varletjs/varlet/blob/dev/packages/varlet-vite-plugins/src/copy.ts)_ | `-` |
|
|
59
|
+
| `icons` | Font icon packaging related configuration | _[VarletConfigIcons](https://github.com/varletjs/varlet/blob/dev/packages/varlet-cli/src/node/config/varlet.config.ts)_ | `-` |
|
|
57
60
|
|
|
58
61
|
### Custom pages
|
|
59
62
|
|
|
@@ -120,6 +123,27 @@ varlet-cli preview
|
|
|
120
123
|
varlet-cli compile
|
|
121
124
|
```
|
|
122
125
|
|
|
126
|
+
#### Run VSCode extension development environment
|
|
127
|
+
|
|
128
|
+
```shell
|
|
129
|
+
# playground-ignore
|
|
130
|
+
varlet-cli dev:extension
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### Build VSCode extension for production
|
|
134
|
+
|
|
135
|
+
```shell
|
|
136
|
+
# playground-ignore
|
|
137
|
+
varlet-cli build:extension
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### Build svg to web fonts
|
|
141
|
+
|
|
142
|
+
```shell
|
|
143
|
+
# playground-ignore
|
|
144
|
+
varlet-cli build:icons
|
|
145
|
+
```
|
|
146
|
+
|
|
123
147
|
#### Execute all unit tests
|
|
124
148
|
|
|
125
149
|
```shell
|
package/README.zh-CN.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# 组件库快速成型工具
|
|
1
|
+
# 组件库快速成型工具
|
|
2
2
|
|
|
3
3
|
### 介绍
|
|
4
4
|
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
- 📦 开箱即用的代码检查工具
|
|
14
14
|
- 📦 开箱即用的单元测试工具
|
|
15
15
|
- 📦 开箱即用的代码发布工具,同时发布到 `npm` 和 `github`, 并自动生成更新日志
|
|
16
|
+
- 💪 支持 `VSCode` 插件开发
|
|
17
|
+
- 💪 支持 `字体图标打包`
|
|
16
18
|
- 💪 支持 `Typescript`
|
|
17
19
|
- 💪 支持 `暗黑模式`
|
|
18
20
|
- 🌍 支持 `国际化`
|
|
@@ -53,7 +55,8 @@ varlet-cli gen
|
|
|
53
55
|
| `analysis` | 文档统计相关 | _{ baidu: string }_ | `-` |
|
|
54
56
|
| `pc` | pc 端文档结构配置 | _Record<string, any>_ | `-` |
|
|
55
57
|
| `mobile` | mobile 端文档结构配置 | _Record<string, any>_ | `-` |
|
|
56
|
-
| `copy` | 复制文件配置 | _
|
|
58
|
+
| `copy` | 复制文件配置 | _[CopyPath[]](https://github.com/varletjs/varlet/blob/dev/packages/varlet-vite-plugins/src/copy.ts)_ | `-` |
|
|
59
|
+
| `icons` | 字体图标打包相关配置 | _[VarletConfigIcons](https://github.com/varletjs/varlet/blob/dev/packages/varlet-cli/src/node/config/varlet.config.ts)_ | `-` |
|
|
57
60
|
|
|
58
61
|
### 自定义页面
|
|
59
62
|
|
|
@@ -119,6 +122,27 @@ varlet-cli preview
|
|
|
119
122
|
varlet-cli compile
|
|
120
123
|
```
|
|
121
124
|
|
|
125
|
+
#### 启动 VSCode 插件开发环境
|
|
126
|
+
|
|
127
|
+
```shell
|
|
128
|
+
# playground-ignore
|
|
129
|
+
varlet-cli dev:extension
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### 构建 VSCode 插件
|
|
133
|
+
|
|
134
|
+
```shell
|
|
135
|
+
# playground-ignore
|
|
136
|
+
varlet-cli build:extension
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### 打包字体图标
|
|
140
|
+
|
|
141
|
+
```shell
|
|
142
|
+
# playground-ignore
|
|
143
|
+
varlet-cli build:icons
|
|
144
|
+
```
|
|
145
|
+
|
|
122
146
|
#### 执行所有的单元测试
|
|
123
147
|
|
|
124
148
|
```shell
|
package/lib/node/bin.js
CHANGED
|
@@ -18,6 +18,13 @@ program
|
|
|
18
18
|
const { build } = await import('./commands/build.js');
|
|
19
19
|
return build();
|
|
20
20
|
});
|
|
21
|
+
program
|
|
22
|
+
.command('dev:vite')
|
|
23
|
+
.description('Use vite start server for development')
|
|
24
|
+
.action(async () => {
|
|
25
|
+
const { vite } = await import('./commands/vite.js');
|
|
26
|
+
return vite('dev');
|
|
27
|
+
});
|
|
21
28
|
program
|
|
22
29
|
.command('build:vite')
|
|
23
30
|
.description('Use vite build app for production')
|
|
@@ -26,11 +33,25 @@ program
|
|
|
26
33
|
return vite('build');
|
|
27
34
|
});
|
|
28
35
|
program
|
|
29
|
-
.command('dev:
|
|
30
|
-
.description('
|
|
36
|
+
.command('dev:extension')
|
|
37
|
+
.description('Run VSCode extension development environment')
|
|
31
38
|
.action(async () => {
|
|
32
|
-
const {
|
|
33
|
-
return
|
|
39
|
+
const { extension } = await import('./commands/extension.js');
|
|
40
|
+
return extension('dev');
|
|
41
|
+
});
|
|
42
|
+
program
|
|
43
|
+
.command('build:extension')
|
|
44
|
+
.description('Build VSCode extension for production')
|
|
45
|
+
.action(async () => {
|
|
46
|
+
const { extension } = await import('./commands/extension.js');
|
|
47
|
+
return extension('build');
|
|
48
|
+
});
|
|
49
|
+
program
|
|
50
|
+
.command('build:icons')
|
|
51
|
+
.description('Build icons')
|
|
52
|
+
.action(async () => {
|
|
53
|
+
const { icons } = await import('./commands/icons.js');
|
|
54
|
+
return icons();
|
|
34
55
|
});
|
|
35
56
|
program
|
|
36
57
|
.command('preview')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function icons(): Promise<void>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import fse from 'fs-extra';
|
|
2
|
+
import sharp from 'sharp';
|
|
3
|
+
import webfont from 'webfont';
|
|
4
|
+
import logger from '../shared/logger.js';
|
|
5
|
+
import { parse, resolve } from 'path';
|
|
6
|
+
import { ICONS_DIST_DIR, ICONS_CSS_DIR, ICONS_PNG_DIR, ICONS_FONTS_DIR, ICONS_SVG_DIR } from '../shared/constant.js';
|
|
7
|
+
import { getVarletConfig } from '../config/varlet.config.js';
|
|
8
|
+
import { get } from 'lodash-es';
|
|
9
|
+
const { removeSync, ensureDir, writeFile, readdirSync } = fse;
|
|
10
|
+
async function removeDir() {
|
|
11
|
+
removeSync(ICONS_DIST_DIR);
|
|
12
|
+
await Promise.all([ensureDir(ICONS_FONTS_DIR), ensureDir(ICONS_CSS_DIR), ensureDir(ICONS_PNG_DIR)]);
|
|
13
|
+
}
|
|
14
|
+
async function buildPNG(svgFiles) {
|
|
15
|
+
await Promise.all(svgFiles.map((svg) => {
|
|
16
|
+
return new Promise((done) => {
|
|
17
|
+
const { name } = parse(svg);
|
|
18
|
+
sharp(resolve(ICONS_SVG_DIR, svg))
|
|
19
|
+
.resize({ height: 100 })
|
|
20
|
+
.toBuffer()
|
|
21
|
+
.then((buffer) => {
|
|
22
|
+
sharp({
|
|
23
|
+
create: {
|
|
24
|
+
width: 100,
|
|
25
|
+
height: 100,
|
|
26
|
+
channels: 4,
|
|
27
|
+
background: '#4a7afe',
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
.composite([
|
|
31
|
+
{
|
|
32
|
+
input: buffer,
|
|
33
|
+
blend: 'dest-in',
|
|
34
|
+
},
|
|
35
|
+
])
|
|
36
|
+
.png()
|
|
37
|
+
.toFile(resolve(ICONS_PNG_DIR, `${name}.png`))
|
|
38
|
+
.then(() => {
|
|
39
|
+
done();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
function buildWebFont(name) {
|
|
46
|
+
return webfont.default({
|
|
47
|
+
files: `${ICONS_SVG_DIR}/*.svg`,
|
|
48
|
+
fontName: name,
|
|
49
|
+
formats: ['ttf'],
|
|
50
|
+
fontHeight: 512,
|
|
51
|
+
descent: 64,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export async function icons() {
|
|
55
|
+
const varletConfig = await getVarletConfig();
|
|
56
|
+
const { name, namespace, base64, publicPath, fontFamilyClassName, fontWeight, fontStyle } = get(varletConfig, 'icons');
|
|
57
|
+
await removeDir();
|
|
58
|
+
const svgFiles = readdirSync(ICONS_SVG_DIR);
|
|
59
|
+
const [{ ttf }] = await Promise.all([buildWebFont(name), buildPNG(svgFiles)]);
|
|
60
|
+
const icons = svgFiles.map((svgName) => {
|
|
61
|
+
const i = svgName.indexOf('-');
|
|
62
|
+
const extIndex = svgName.lastIndexOf('.');
|
|
63
|
+
return {
|
|
64
|
+
name: svgName.slice(i + 1, extIndex),
|
|
65
|
+
pointCode: svgName.slice(1, i),
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
const iconNames = icons.map((iconName) => ` '${iconName.name}'`);
|
|
69
|
+
const indexTemplate = `\
|
|
70
|
+
export const pointCodes = {
|
|
71
|
+
${icons.map(({ pointCode, name }) => `'${name}': '${pointCode}'`).join(',\n ')}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default [
|
|
75
|
+
${iconNames.join(',\n')}
|
|
76
|
+
]
|
|
77
|
+
`;
|
|
78
|
+
const cssTemplate = `\
|
|
79
|
+
@font-face {
|
|
80
|
+
font-family: "${name}";
|
|
81
|
+
src: url("${base64 ? `data:font/truetype;charset=utf-8;base64,${ttf.toString('base64')}` : `${publicPath}${name}-webfont.ttf`}") format("truetype");
|
|
82
|
+
font-weight: ${fontWeight};
|
|
83
|
+
font-style: ${fontStyle};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.${fontFamilyClassName} {
|
|
87
|
+
font-family: "${name}";
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
${icons
|
|
91
|
+
.map((icon) => {
|
|
92
|
+
return `.${namespace}-${icon.name}::before {
|
|
93
|
+
content: "\\${icon.pointCode}";
|
|
94
|
+
}`;
|
|
95
|
+
})
|
|
96
|
+
.join('\n\n')}
|
|
97
|
+
`;
|
|
98
|
+
await Promise.all([
|
|
99
|
+
writeFile(resolve(ICONS_FONTS_DIR, `${name}-webfont.ttf`), ttf),
|
|
100
|
+
writeFile(resolve(ICONS_CSS_DIR, `${name}.css`), cssTemplate),
|
|
101
|
+
writeFile(resolve(ICONS_CSS_DIR, `${name}.less`), cssTemplate),
|
|
102
|
+
writeFile(resolve(ICONS_DIST_DIR, 'index.js'), indexTemplate),
|
|
103
|
+
]);
|
|
104
|
+
logger.success('build success!');
|
|
105
|
+
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
export declare function replaceExportToDeclare(script: string): string;
|
|
2
|
+
export declare function injectExport(script: string): string;
|
|
3
|
+
export declare function injectScopeId(script: string, scopeId: string): string;
|
|
1
4
|
export declare function injectRender(script: string, render: string): string;
|
|
2
5
|
export declare function compileSFC(sfc: string): Promise<void>;
|
|
@@ -1,58 +1,71 @@
|
|
|
1
1
|
import fse from 'fs-extra';
|
|
2
2
|
import hash from 'hash-sum';
|
|
3
3
|
import { parse, resolve } from 'path';
|
|
4
|
-
import { parse as parseSFC, compileTemplate, compileStyle } from '@vue/compiler-sfc';
|
|
4
|
+
import { parse as parseSFC, compileTemplate, compileStyle, compileScript as compileScriptSFC } from '@vue/compiler-sfc';
|
|
5
5
|
import { replaceExt, smartAppendFileSync } from '../shared/fsUtils.js';
|
|
6
6
|
import { compileScript, getScriptExtname } from './compileScript.js';
|
|
7
7
|
import { clearEmptyLine, compileLess, extractStyleDependencies, normalizeStyleDependency, STYLE_IMPORT_RE, } from './compileStyle.js';
|
|
8
|
-
import logger from '../shared/logger.js';
|
|
9
8
|
const { readFile, writeFileSync } = fse;
|
|
10
|
-
const
|
|
11
|
-
const
|
|
9
|
+
const EXPORT = 'export default';
|
|
10
|
+
const SFC = '__sfc__';
|
|
11
|
+
const SFC_DECLARE = `const ${SFC} = `;
|
|
12
|
+
const RENDER = '__render__';
|
|
13
|
+
export function replaceExportToDeclare(script) {
|
|
14
|
+
return script.replace(EXPORT, SFC_DECLARE);
|
|
15
|
+
}
|
|
16
|
+
export function injectExport(script) {
|
|
17
|
+
script += `\n${EXPORT} ${SFC}`;
|
|
18
|
+
return script;
|
|
19
|
+
}
|
|
20
|
+
export function injectScopeId(script, scopeId) {
|
|
21
|
+
script += `\n${SFC}.__scopeId = '${scopeId}'`;
|
|
22
|
+
return script;
|
|
23
|
+
}
|
|
12
24
|
export function injectRender(script, render) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
if (NORMAL_EXPORT_START_RE.test(script.trim())) {
|
|
19
|
-
return script.trim().replace(NORMAL_EXPORT_START_RE, `${render}\nexport default {
|
|
20
|
-
render,\
|
|
21
|
-
`);
|
|
22
|
-
}
|
|
25
|
+
script = script.trim();
|
|
26
|
+
render = render.replace('export function render', `function ${RENDER}`);
|
|
27
|
+
script = script.replace(SFC_DECLARE, `${render}\n${SFC_DECLARE}`);
|
|
28
|
+
script += `\n${SFC}.render = ${RENDER}`;
|
|
23
29
|
return script;
|
|
24
30
|
}
|
|
25
31
|
export async function compileSFC(sfc) {
|
|
26
32
|
const sources = await readFile(sfc, 'utf-8');
|
|
33
|
+
const id = hash(sources);
|
|
27
34
|
const { descriptor } = parseSFC(sources, { sourceMap: false });
|
|
28
35
|
const { script, scriptSetup, template, styles } = descriptor;
|
|
29
|
-
if (scriptSetup) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
if (script || scriptSetup) {
|
|
37
|
+
let scriptContent;
|
|
38
|
+
let bindingMetadata;
|
|
39
|
+
if (scriptSetup) {
|
|
40
|
+
const { content, bindings } = compileScriptSFC(descriptor, { id });
|
|
41
|
+
scriptContent = content;
|
|
42
|
+
bindingMetadata = bindings;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// script only
|
|
46
|
+
scriptContent = script.content;
|
|
47
|
+
}
|
|
48
|
+
scriptContent = replaceExportToDeclare(scriptContent);
|
|
49
|
+
// scoped
|
|
50
|
+
const hasScope = styles.some((style) => style.scoped);
|
|
51
|
+
const scopeId = hasScope ? `data-v-${id}` : '';
|
|
52
|
+
if (template) {
|
|
53
|
+
const render = compileTemplate({
|
|
42
54
|
id,
|
|
43
55
|
source: template.content,
|
|
44
56
|
filename: sfc,
|
|
45
57
|
compilerOptions: {
|
|
46
58
|
scopeId,
|
|
59
|
+
bindingMetadata,
|
|
47
60
|
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
}).code;
|
|
62
|
+
scriptContent = injectRender(scriptContent, render);
|
|
63
|
+
}
|
|
64
|
+
if (scopeId) {
|
|
65
|
+
scriptContent = injectScopeId(scriptContent, scopeId);
|
|
53
66
|
}
|
|
54
|
-
|
|
55
|
-
await compileScript(
|
|
67
|
+
scriptContent = injectExport(scriptContent);
|
|
68
|
+
await compileScript(scriptContent, sfc);
|
|
56
69
|
// style
|
|
57
70
|
for (let index = 0; index < styles.length; index++) {
|
|
58
71
|
const style = styles[index];
|
|
@@ -1,4 +1,25 @@
|
|
|
1
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
|
+
}
|
|
2
23
|
export interface VarletConfig {
|
|
3
24
|
/**
|
|
4
25
|
* @default `Varlet`
|
|
@@ -40,6 +61,7 @@ export interface VarletConfig {
|
|
|
40
61
|
pc?: Record<string, any>;
|
|
41
62
|
mobile?: Record<string, any>;
|
|
42
63
|
copy?: CopyOptions['paths'];
|
|
64
|
+
icons?: VarletConfigIcons;
|
|
43
65
|
}
|
|
44
66
|
export declare function defineConfig(config: VarletConfig): VarletConfig;
|
|
45
67
|
export declare function mergeStrategy(value: any, srcValue: any, key: string): any[] | undefined;
|
|
@@ -259,4 +259,12 @@ export default defineConfig({
|
|
|
259
259
|
'color-hl-group-h': '#14a6e9',
|
|
260
260
|
'color-hl-group-i': '#ed4648',
|
|
261
261
|
},
|
|
262
|
+
icons: {
|
|
263
|
+
name: 'varlet-icons',
|
|
264
|
+
namespace: 'var-icon',
|
|
265
|
+
fontStyle: 'normal',
|
|
266
|
+
fontWeight: 'normal',
|
|
267
|
+
fontFamilyClassName: 'var-icon--set',
|
|
268
|
+
base64: true,
|
|
269
|
+
},
|
|
262
270
|
});
|
|
@@ -9,3 +9,5 @@ export interface BundleBuildOptions {
|
|
|
9
9
|
emptyOutDir: boolean;
|
|
10
10
|
}
|
|
11
11
|
export declare function getBundleConfig(varletConfig: Required<VarletConfig>, buildOptions: BundleBuildOptions): InlineConfig;
|
|
12
|
+
export declare type ExtensionMode = 'dev' | 'build';
|
|
13
|
+
export declare function getExtensionConfig(mode: ExtensionMode): InlineConfig;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import vue from '@vitejs/plugin-vue';
|
|
2
2
|
import jsx from '@vitejs/plugin-vue-jsx';
|
|
3
3
|
import { markdown, html, inlineCss, copy } from '@varlet/vite-plugins';
|
|
4
|
-
import { ES_DIR, SITE_CONFIG, SITE_DIR, SITE_MOBILE_ROUTES, SITE_OUTPUT_PATH, SITE_PC_ROUTES, SITE_PUBLIC_PATH, VITE_RESOLVE_EXTENSIONS, } from '../shared/constant.js';
|
|
4
|
+
import { ES_DIR, SITE_CONFIG, SITE_DIR, SITE_MOBILE_ROUTES, SITE_OUTPUT_PATH, SITE_PC_ROUTES, SITE_PUBLIC_PATH, VITE_RESOLVE_EXTENSIONS, EXTENSION_ENTRY, } from '../shared/constant.js';
|
|
5
5
|
import { get } from 'lodash-es';
|
|
6
6
|
import { resolve } from 'path';
|
|
7
7
|
export function getDevConfig(varletConfig) {
|
|
@@ -90,3 +90,19 @@ export function getBundleConfig(varletConfig, buildOptions) {
|
|
|
90
90
|
},
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
+
export function getExtensionConfig(mode) {
|
|
94
|
+
return {
|
|
95
|
+
build: {
|
|
96
|
+
sourcemap: mode === 'dev' ? 'inline' : false,
|
|
97
|
+
watch: mode === 'dev' ? {} : null,
|
|
98
|
+
lib: {
|
|
99
|
+
entry: EXTENSION_ENTRY,
|
|
100
|
+
fileName: 'extension',
|
|
101
|
+
formats: ['cjs'],
|
|
102
|
+
},
|
|
103
|
+
rollupOptions: {
|
|
104
|
+
external: ['vscode'],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
package/lib/node/index.d.ts
CHANGED
package/lib/node/index.js
CHANGED
|
@@ -39,4 +39,10 @@ export declare const HL_DIR: string;
|
|
|
39
39
|
export declare const HL_TAGS_JSON: string;
|
|
40
40
|
export declare const HL_ATTRIBUTES_JSON: string;
|
|
41
41
|
export declare const HL_WEB_TYPES_JSON: string;
|
|
42
|
+
export declare const ICONS_DIST_DIR: string;
|
|
43
|
+
export declare const ICONS_CSS_DIR: string;
|
|
44
|
+
export declare const ICONS_PNG_DIR: string;
|
|
45
|
+
export declare const ICONS_FONTS_DIR: string;
|
|
46
|
+
export declare const ICONS_SVG_DIR: string;
|
|
47
|
+
export declare const EXTENSION_ENTRY: string;
|
|
42
48
|
export declare const JEST_CONFIG: string;
|
|
@@ -43,5 +43,13 @@ export const HL_DIR = resolve(CWD, 'highlight');
|
|
|
43
43
|
export const HL_TAGS_JSON = resolve(HL_DIR, 'tags.json');
|
|
44
44
|
export const HL_ATTRIBUTES_JSON = resolve(HL_DIR, 'attributes.json');
|
|
45
45
|
export const HL_WEB_TYPES_JSON = resolve(HL_DIR, 'web-types.json');
|
|
46
|
+
// icons
|
|
47
|
+
export const ICONS_DIST_DIR = resolve(CWD, 'dist');
|
|
48
|
+
export const ICONS_CSS_DIR = resolve(ICONS_DIST_DIR, 'css');
|
|
49
|
+
export const ICONS_PNG_DIR = resolve(ICONS_DIST_DIR, 'png');
|
|
50
|
+
export const ICONS_FONTS_DIR = resolve(ICONS_DIST_DIR, 'fonts');
|
|
51
|
+
export const ICONS_SVG_DIR = resolve(CWD, 'svg');
|
|
52
|
+
// extension
|
|
53
|
+
export const EXTENSION_ENTRY = resolve(CWD, 'src/extension.ts');
|
|
46
54
|
// jest
|
|
47
55
|
export const JEST_CONFIG = resolve(dirname, '../../../cjs/jest.config.cjs');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.3-alpha.1675189320554",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -44,6 +44,8 @@
|
|
|
44
44
|
"@vue/babel-plugin-jsx": "1.1.1",
|
|
45
45
|
"@vue/compiler-sfc": "3.2.25",
|
|
46
46
|
"@vue/runtime-core": "3.2.25",
|
|
47
|
+
"webfont": "^9.0.0",
|
|
48
|
+
"sharp": "0.31.3",
|
|
47
49
|
"babel-jest": "26.6.3",
|
|
48
50
|
"chalk": "^4.1.0",
|
|
49
51
|
"chokidar": "^3.5.2",
|
|
@@ -66,8 +68,8 @@
|
|
|
66
68
|
"vite": "4.0.4",
|
|
67
69
|
"vue": "3.2.25",
|
|
68
70
|
"vue-jest": "^5.0.0-alpha.8",
|
|
69
|
-
"@varlet/vite-plugins": "2.7.
|
|
70
|
-
"@varlet/shared": "2.7.
|
|
71
|
+
"@varlet/vite-plugins": "2.7.3-alpha.1675189320554",
|
|
72
|
+
"@varlet/shared": "2.7.3-alpha.1675189320554"
|
|
71
73
|
},
|
|
72
74
|
"devDependencies": {
|
|
73
75
|
"@types/babel__core": "^7.1.12",
|
|
@@ -79,8 +81,9 @@
|
|
|
79
81
|
"@types/node": "^18.7.20",
|
|
80
82
|
"@types/semver": "^7.3.9",
|
|
81
83
|
"@types/inquirer": "^9.0.2",
|
|
82
|
-
"@
|
|
83
|
-
"@varlet/icons": "2.7.
|
|
84
|
+
"@types/sharp": "0.31.1",
|
|
85
|
+
"@varlet/icons": "2.7.3-alpha.1675189320554",
|
|
86
|
+
"@varlet/touch-emulator": "2.7.3-alpha.1675189320554"
|
|
84
87
|
},
|
|
85
88
|
"peerDependencies": {
|
|
86
89
|
"@vue/runtime-core": "3.2.16",
|
|
@@ -90,8 +93,8 @@
|
|
|
90
93
|
"lodash-es": "^4.17.21",
|
|
91
94
|
"vue": "3.2.25",
|
|
92
95
|
"vue-router": "4.0.12",
|
|
93
|
-
"@varlet/icons": "2.7.
|
|
94
|
-
"@varlet/touch-emulator": "2.7.
|
|
96
|
+
"@varlet/icons": "2.7.3-alpha.1675189320554",
|
|
97
|
+
"@varlet/touch-emulator": "2.7.3-alpha.1675189320554"
|
|
95
98
|
},
|
|
96
99
|
"scripts": {
|
|
97
100
|
"dev": "tsc --watch",
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export interface VarletConfig {
|
|
2
|
-
/**
|
|
3
|
-
* @default `Varlet`
|
|
4
|
-
* UI library name.
|
|
5
|
-
*/
|
|
6
|
-
name?: string;
|
|
7
|
-
/**
|
|
8
|
-
* @default `var`
|
|
9
|
-
* Component name prefix
|
|
10
|
-
*/
|
|
11
|
-
namespace?: string;
|
|
12
|
-
/**
|
|
13
|
-
* @default `localhost`
|
|
14
|
-
* Local dev server host
|
|
15
|
-
*/
|
|
16
|
-
host?: string;
|
|
17
|
-
/**
|
|
18
|
-
* @default `8080`
|
|
19
|
-
* Local dev server port
|
|
20
|
-
*/
|
|
21
|
-
port?: number;
|
|
22
|
-
title?: string;
|
|
23
|
-
logo?: string;
|
|
24
|
-
themeKey?: string;
|
|
25
|
-
defaultLanguage?: 'zh-CN' | 'en-US';
|
|
26
|
-
/**
|
|
27
|
-
* @default `false`
|
|
28
|
-
* Show mobile component on the right.
|
|
29
|
-
*/
|
|
30
|
-
useMobile?: boolean;
|
|
31
|
-
lightTheme?: Record<string, string>;
|
|
32
|
-
darkTheme?: Record<string, string>;
|
|
33
|
-
highlight?: {
|
|
34
|
-
style: string;
|
|
35
|
-
};
|
|
36
|
-
analysis?: {
|
|
37
|
-
baidu: string;
|
|
38
|
-
};
|
|
39
|
-
pc?: Record<string, any>;
|
|
40
|
-
mobile?: Record<string, any>;
|
|
41
|
-
}
|
|
42
|
-
export declare function defineConfig(config: VarletConfig): VarletConfig;
|
|
43
|
-
export declare function mergeStrategy(value: any, srcValue: any, key: string): any[] | undefined;
|
|
44
|
-
export declare function getVarletConfig(emit?: boolean): Promise<Required<VarletConfig>>;
|
|
@@ -1,27 +0,0 @@
|
|
|
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,17 +0,0 @@
|
|
|
1
|
-
import fse from 'fs-extra';
|
|
2
|
-
const { copyFileSync } = fse;
|
|
3
|
-
export function copy(options) {
|
|
4
|
-
return {
|
|
5
|
-
name: 'vite-plugin-varlet-copy',
|
|
6
|
-
buildStart() {
|
|
7
|
-
options.paths.forEach((copyPath) => {
|
|
8
|
-
try {
|
|
9
|
-
copyFileSync(copyPath.from, copyPath.to);
|
|
10
|
-
}
|
|
11
|
-
catch (e) {
|
|
12
|
-
this.warn(e);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|