@varlet/cli 2.1.0 → 2.2.0-alpha.1667668287880
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.en-US.md +7 -5
- package/README.md +7 -5
- package/lib/client/appType.d.ts +4 -4
- package/lib/client/appType.js +7 -7
- package/lib/client/index.d.ts +17 -17
- package/lib/client/index.js +106 -106
- package/lib/node/bin.d.ts +2 -2
- package/lib/node/bin.js +122 -122
- package/lib/node/commands/build.d.ts +1 -1
- package/lib/node/commands/build.js +15 -15
- package/lib/node/commands/changelog.d.ts +6 -6
- package/lib/node/commands/changelog.js +20 -20
- package/lib/node/commands/commitLint.d.ts +1 -1
- package/lib/node/commands/commitLint.js +16 -16
- package/lib/node/commands/compile.d.ts +7 -7
- package/lib/node/commands/compile.js +35 -35
- package/lib/node/commands/create.d.ts +8 -8
- package/lib/node/commands/create.js +91 -91
- package/lib/node/commands/dev.d.ts +5 -5
- package/lib/node/commands/dev.js +38 -38
- package/lib/node/commands/gen.d.ts +8 -8
- package/lib/node/commands/gen.js +68 -68
- package/lib/node/commands/jest.d.ts +8 -8
- 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 +146 -146
- package/lib/node/commands/vite.d.ts +3 -3
- package/lib/node/commands/vite.js +13 -13
- package/lib/node/compiler/compileModule.d.ts +5 -5
- package/lib/node/compiler/compileModule.js +74 -74
- package/lib/node/compiler/compileSFC.d.ts +2 -2
- package/lib/node/compiler/compileSFC.js +74 -74
- package/lib/node/compiler/compileScript.d.ts +17 -17
- package/lib/node/compiler/compileScript.js +95 -95
- package/lib/node/compiler/compileSiteEntry.d.ts +13 -13
- package/lib/node/compiler/compileSiteEntry.js +95 -95
- package/lib/node/compiler/compileStyle.d.ts +11 -11
- package/lib/node/compiler/compileStyle.js +39 -39
- package/lib/node/compiler/compileTemplateHighlight.d.ts +10 -10
- package/lib/node/compiler/compileTemplateHighlight.js +133 -133
- package/lib/node/compiler/compileTypes.d.ts +2 -2
- package/lib/node/compiler/compileTypes.js +30 -30
- package/lib/node/config/varlet.config.d.ts +45 -45
- 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 +264 -264
- package/lib/node/config/vite.config.d.ts +6 -6
- package/lib/node/config/vite.config.js +142 -142
- package/lib/node/index.d.ts +1 -1
- package/lib/node/index.js +1 -1
- package/lib/node/shared/constant.d.ts +42 -42
- package/lib/node/shared/constant.js +47 -47
- package/lib/node/shared/fsUtils.d.ts +13 -13
- package/lib/node/shared/fsUtils.js +48 -48
- package/lib/node/shared/logger.d.ts +8 -8
- package/lib/node/shared/logger.js +18 -18
- package/package.json +7 -7
- package/site/components/button/index.ts +10 -10
- package/site/components/cell/index.ts +10 -10
- package/site/components/code-example/codeExample.less +41 -41
- package/site/components/code-example/index.ts +10 -10
- package/site/components/context/zIndex.ts +20 -20
- package/site/components/icon/icon.less +26 -26
- package/site/components/icon/index.ts +10 -10
- package/site/components/icon/props.ts +24 -24
- package/site/components/loading/index.ts +10 -10
- package/site/components/progress/index.ts +10 -10
- package/site/components/snackbar/snackbar.less +135 -135
- package/site/components/styles/common.less +64 -64
- package/site/components/styles/elevation.less +126 -126
- package/site/components/styles/var.less +27 -27
- package/site/index.html +49 -49
- package/site/mobile/components/app-bar/index.ts +10 -10
- package/site/mobile/components/app-bar/props.ts +25 -25
- package/site/mobile.html +41 -41
- package/site/module.d.ts +5 -5
- package/site/tsconfig.json +11 -11
|
@@ -1,144 +1,144 @@
|
|
|
1
|
-
import vue from '@vitejs/plugin-vue';
|
|
2
|
-
import md from '@varlet/markdown-vite-plugin';
|
|
3
|
-
import jsx from '@vitejs/plugin-vue-jsx';
|
|
4
|
-
import fse from 'fs-extra';
|
|
5
|
-
import { injectHtml } from 'vite-plugin-html';
|
|
6
|
-
import { CWD, ES_DIR, LIB_DIR, SITE_CONFIG, SITE_DIR, SITE_MOBILE_ROUTES, SITE_OUTPUT_PATH, SITE_PC_ROUTES, SITE_PUBLIC_PATH, UMD_DIR, VITE_RESOLVE_EXTENSIONS, } from '../shared/constant.js';
|
|
7
|
-
import { get } from 'lodash-es';
|
|
8
|
-
import { kebabCase } from '@varlet/shared';
|
|
9
|
-
import { resolve } from 'path';
|
|
10
|
-
const { copyFileSync, pathExistsSync, readFileSync, removeSync, writeFileSync } = fse;
|
|
11
|
-
export function getDevConfig(varletConfig) {
|
|
12
|
-
const defaultLanguage = get(varletConfig, 'defaultLanguage');
|
|
13
|
-
const host = get(varletConfig, 'host');
|
|
14
|
-
return {
|
|
15
|
-
root: SITE_DIR,
|
|
16
|
-
resolve: {
|
|
17
|
-
extensions: VITE_RESOLVE_EXTENSIONS,
|
|
18
|
-
alias: {
|
|
19
|
-
'@config': SITE_CONFIG,
|
|
20
|
-
'@pc-routes': SITE_PC_ROUTES,
|
|
21
|
-
'@mobile-routes': SITE_MOBILE_ROUTES,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
server: {
|
|
25
|
-
port: get(varletConfig, 'port'),
|
|
26
|
-
host: host === 'localhost' ? '0.0.0.0' : host,
|
|
27
|
-
},
|
|
28
|
-
publicDir: SITE_PUBLIC_PATH,
|
|
29
|
-
plugins: [
|
|
30
|
-
vue({
|
|
31
|
-
include: [/\.vue$/, /\.md$/],
|
|
32
|
-
}),
|
|
33
|
-
md({ style: get(varletConfig, 'highlight.style') }),
|
|
34
|
-
jsx(),
|
|
35
|
-
injectHtml({
|
|
36
|
-
data: {
|
|
37
|
-
pcTitle: get(varletConfig, `pc.title['${defaultLanguage}']`),
|
|
38
|
-
mobileTitle: get(varletConfig, `mobile.title['${defaultLanguage}']`),
|
|
39
|
-
logo: get(varletConfig, `logo`),
|
|
40
|
-
baidu: get(varletConfig, `analysis.baidu`, ''),
|
|
41
|
-
},
|
|
42
|
-
}),
|
|
43
|
-
],
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export function getBuildConfig(varletConfig) {
|
|
47
|
-
const devConfig = getDevConfig(varletConfig);
|
|
48
|
-
return Object.assign(Object.assign({}, devConfig), { base: './', build: {
|
|
49
|
-
outDir: SITE_OUTPUT_PATH,
|
|
50
|
-
reportCompressedSize: false,
|
|
51
|
-
emptyOutDir: true,
|
|
52
|
-
cssTarget: 'chrome61',
|
|
53
|
-
rollupOptions: {
|
|
54
|
-
input: {
|
|
55
|
-
main: resolve(SITE_DIR, 'index.html'),
|
|
56
|
-
mobile: resolve(SITE_DIR, 'mobile.html'),
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
} });
|
|
60
|
-
}
|
|
61
|
-
function inlineCSS(fileName, dir) {
|
|
62
|
-
return {
|
|
63
|
-
name: 'varlet-inline-css-vite-plugin',
|
|
64
|
-
apply: 'build',
|
|
65
|
-
closeBundle() {
|
|
66
|
-
const cssFile = resolve(dir, 'style.css');
|
|
67
|
-
if (!pathExistsSync(cssFile)) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const jsFile = resolve(dir, fileName);
|
|
71
|
-
const cssCode = readFileSync(cssFile, 'utf-8');
|
|
72
|
-
const jsCode = readFileSync(jsFile, 'utf-8');
|
|
1
|
+
import vue from '@vitejs/plugin-vue';
|
|
2
|
+
import md from '@varlet/markdown-vite-plugin';
|
|
3
|
+
import jsx from '@vitejs/plugin-vue-jsx';
|
|
4
|
+
import fse from 'fs-extra';
|
|
5
|
+
import { injectHtml } from 'vite-plugin-html';
|
|
6
|
+
import { CWD, ES_DIR, LIB_DIR, SITE_CONFIG, SITE_DIR, SITE_MOBILE_ROUTES, SITE_OUTPUT_PATH, SITE_PC_ROUTES, SITE_PUBLIC_PATH, UMD_DIR, VITE_RESOLVE_EXTENSIONS, } from '../shared/constant.js';
|
|
7
|
+
import { get } from 'lodash-es';
|
|
8
|
+
import { kebabCase } from '@varlet/shared';
|
|
9
|
+
import { resolve } from 'path';
|
|
10
|
+
const { copyFileSync, pathExistsSync, readFileSync, removeSync, writeFileSync } = fse;
|
|
11
|
+
export function getDevConfig(varletConfig) {
|
|
12
|
+
const defaultLanguage = get(varletConfig, 'defaultLanguage');
|
|
13
|
+
const host = get(varletConfig, 'host');
|
|
14
|
+
return {
|
|
15
|
+
root: SITE_DIR,
|
|
16
|
+
resolve: {
|
|
17
|
+
extensions: VITE_RESOLVE_EXTENSIONS,
|
|
18
|
+
alias: {
|
|
19
|
+
'@config': SITE_CONFIG,
|
|
20
|
+
'@pc-routes': SITE_PC_ROUTES,
|
|
21
|
+
'@mobile-routes': SITE_MOBILE_ROUTES,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
server: {
|
|
25
|
+
port: get(varletConfig, 'port'),
|
|
26
|
+
host: host === 'localhost' ? '0.0.0.0' : host,
|
|
27
|
+
},
|
|
28
|
+
publicDir: SITE_PUBLIC_PATH,
|
|
29
|
+
plugins: [
|
|
30
|
+
vue({
|
|
31
|
+
include: [/\.vue$/, /\.md$/],
|
|
32
|
+
}),
|
|
33
|
+
md({ style: get(varletConfig, 'highlight.style') }),
|
|
34
|
+
jsx(),
|
|
35
|
+
injectHtml({
|
|
36
|
+
data: {
|
|
37
|
+
pcTitle: get(varletConfig, `pc.title['${defaultLanguage}']`),
|
|
38
|
+
mobileTitle: get(varletConfig, `mobile.title['${defaultLanguage}']`),
|
|
39
|
+
logo: get(varletConfig, `logo`),
|
|
40
|
+
baidu: get(varletConfig, `analysis.baidu`, ''),
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function getBuildConfig(varletConfig) {
|
|
47
|
+
const devConfig = getDevConfig(varletConfig);
|
|
48
|
+
return Object.assign(Object.assign({}, devConfig), { base: './', build: {
|
|
49
|
+
outDir: SITE_OUTPUT_PATH,
|
|
50
|
+
reportCompressedSize: false,
|
|
51
|
+
emptyOutDir: true,
|
|
52
|
+
cssTarget: 'chrome61',
|
|
53
|
+
rollupOptions: {
|
|
54
|
+
input: {
|
|
55
|
+
main: resolve(SITE_DIR, 'index.html'),
|
|
56
|
+
mobile: resolve(SITE_DIR, 'mobile.html'),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
} });
|
|
60
|
+
}
|
|
61
|
+
function inlineCSS(fileName, dir) {
|
|
62
|
+
return {
|
|
63
|
+
name: 'varlet-inline-css-vite-plugin',
|
|
64
|
+
apply: 'build',
|
|
65
|
+
closeBundle() {
|
|
66
|
+
const cssFile = resolve(dir, 'style.css');
|
|
67
|
+
if (!pathExistsSync(cssFile)) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const jsFile = resolve(dir, fileName);
|
|
71
|
+
const cssCode = readFileSync(cssFile, 'utf-8');
|
|
72
|
+
const jsCode = readFileSync(jsFile, 'utf-8');
|
|
73
73
|
const injectCode = `;(function(){var style=document.createElement('style');style.type='text/css';\
|
|
74
74
|
style.rel='stylesheet';style.appendChild(document.createTextNode(\`${cssCode.replace(/\\/g, '\\\\')}\`));\
|
|
75
|
-
var head=document.querySelector('head');head.appendChild(style)})();`;
|
|
76
|
-
writeFileSync(jsFile, `${injectCode}${jsCode}`);
|
|
77
|
-
copyFileSync(cssFile, resolve(LIB_DIR, 'style.css'));
|
|
78
|
-
removeSync(cssFile);
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
function clear() {
|
|
83
|
-
return {
|
|
84
|
-
name: 'varlet-clear-vite-plugin',
|
|
85
|
-
apply: 'build',
|
|
86
|
-
closeBundle() {
|
|
87
|
-
removeSync(resolve(CWD, 'dist'));
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
export function getESMBundleConfig(varletConfig) {
|
|
92
|
-
const name = get(varletConfig, 'name');
|
|
93
|
-
const fileName = `${kebabCase(name)}.esm.js`;
|
|
94
|
-
return {
|
|
95
|
-
logLevel: 'silent',
|
|
96
|
-
build: {
|
|
97
|
-
emptyOutDir: true,
|
|
98
|
-
lib: {
|
|
99
|
-
name,
|
|
100
|
-
formats: ['es'],
|
|
101
|
-
fileName: () => fileName,
|
|
102
|
-
entry: resolve(ES_DIR, 'umdIndex.js'),
|
|
103
|
-
},
|
|
104
|
-
rollupOptions: {
|
|
105
|
-
external: ['vue'],
|
|
106
|
-
output: {
|
|
107
|
-
dir: ES_DIR,
|
|
108
|
-
exports: 'named',
|
|
109
|
-
globals: {
|
|
110
|
-
vue: 'Vue',
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
plugins: [clear()],
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
export function getUMDConfig(varletConfig) {
|
|
119
|
-
const name = get(varletConfig, 'name');
|
|
120
|
-
const fileName = `${kebabCase(name)}.js`;
|
|
121
|
-
return {
|
|
122
|
-
logLevel: 'silent',
|
|
123
|
-
build: {
|
|
124
|
-
emptyOutDir: true,
|
|
125
|
-
lib: {
|
|
126
|
-
name,
|
|
127
|
-
formats: ['umd'],
|
|
128
|
-
fileName: () => fileName,
|
|
129
|
-
entry: resolve(ES_DIR, 'umdIndex.js'),
|
|
130
|
-
},
|
|
131
|
-
rollupOptions: {
|
|
132
|
-
external: ['vue'],
|
|
133
|
-
output: {
|
|
134
|
-
dir: UMD_DIR,
|
|
135
|
-
exports: 'named',
|
|
136
|
-
globals: {
|
|
137
|
-
vue: 'Vue',
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
plugins: [inlineCSS(fileName, UMD_DIR), clear()],
|
|
143
|
-
};
|
|
144
|
-
}
|
|
75
|
+
var head=document.querySelector('head');head.appendChild(style)})();`;
|
|
76
|
+
writeFileSync(jsFile, `${injectCode}${jsCode}`);
|
|
77
|
+
copyFileSync(cssFile, resolve(LIB_DIR, 'style.css'));
|
|
78
|
+
removeSync(cssFile);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function clear() {
|
|
83
|
+
return {
|
|
84
|
+
name: 'varlet-clear-vite-plugin',
|
|
85
|
+
apply: 'build',
|
|
86
|
+
closeBundle() {
|
|
87
|
+
removeSync(resolve(CWD, 'dist'));
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export function getESMBundleConfig(varletConfig) {
|
|
92
|
+
const name = get(varletConfig, 'name');
|
|
93
|
+
const fileName = `${kebabCase(name)}.esm.js`;
|
|
94
|
+
return {
|
|
95
|
+
logLevel: 'silent',
|
|
96
|
+
build: {
|
|
97
|
+
emptyOutDir: true,
|
|
98
|
+
lib: {
|
|
99
|
+
name,
|
|
100
|
+
formats: ['es'],
|
|
101
|
+
fileName: () => fileName,
|
|
102
|
+
entry: resolve(ES_DIR, 'umdIndex.js'),
|
|
103
|
+
},
|
|
104
|
+
rollupOptions: {
|
|
105
|
+
external: ['vue'],
|
|
106
|
+
output: {
|
|
107
|
+
dir: ES_DIR,
|
|
108
|
+
exports: 'named',
|
|
109
|
+
globals: {
|
|
110
|
+
vue: 'Vue',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
plugins: [clear()],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export function getUMDConfig(varletConfig) {
|
|
119
|
+
const name = get(varletConfig, 'name');
|
|
120
|
+
const fileName = `${kebabCase(name)}.js`;
|
|
121
|
+
return {
|
|
122
|
+
logLevel: 'silent',
|
|
123
|
+
build: {
|
|
124
|
+
emptyOutDir: true,
|
|
125
|
+
lib: {
|
|
126
|
+
name,
|
|
127
|
+
formats: ['umd'],
|
|
128
|
+
fileName: () => fileName,
|
|
129
|
+
entry: resolve(ES_DIR, 'umdIndex.js'),
|
|
130
|
+
},
|
|
131
|
+
rollupOptions: {
|
|
132
|
+
external: ['vue'],
|
|
133
|
+
output: {
|
|
134
|
+
dir: UMD_DIR,
|
|
135
|
+
exports: 'named',
|
|
136
|
+
globals: {
|
|
137
|
+
vue: 'Vue',
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
plugins: [inlineCSS(fileName, UMD_DIR), clear()],
|
|
143
|
+
};
|
|
144
|
+
}
|
package/lib/node/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { defineConfig } from './config/varlet.config.js';
|
|
1
|
+
export { defineConfig } from './config/varlet.config.js';
|
package/lib/node/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { defineConfig } from './config/varlet.config.js';
|
|
1
|
+
export { defineConfig } from './config/varlet.config.js';
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
export declare const dirname: string;
|
|
2
|
-
export declare const CWD: string;
|
|
3
|
-
export declare const VARLET_CONFIG: string;
|
|
4
|
-
export declare const SRC_DIR: string;
|
|
5
|
-
export declare const ES_DIR: string;
|
|
6
|
-
export declare const LIB_DIR: string;
|
|
7
|
-
export declare const UMD_DIR: string;
|
|
8
|
-
export declare const TYPES_DIR: string;
|
|
9
|
-
export declare const ROOT_DOCS_DIR: string;
|
|
10
|
-
export declare const ROOT_PAGES_DIR: string;
|
|
11
|
-
export declare const ESLINT_EXTENSIONS: string[];
|
|
12
|
-
export declare const VITE_RESOLVE_EXTENSIONS: string[];
|
|
13
|
-
export declare const SCRIPTS_EXTENSIONS: string[];
|
|
14
|
-
export declare const PUBLIC_DIR_INDEXES: string[];
|
|
15
|
-
export declare const STYLE_DIR_NAME = "style";
|
|
16
|
-
export declare const EXAMPLE_DIR_NAME = "example";
|
|
17
|
-
export declare const LOCALE_DIR_NAME = "locale";
|
|
18
|
-
export declare const DOCS_DIR_NAME = "docs";
|
|
19
|
-
export declare const DIR_INDEX = "index.vue";
|
|
20
|
-
export declare const TESTS_DIR_NAME = "__tests__";
|
|
21
|
-
export declare const GENERATORS_DIR: string;
|
|
22
|
-
export declare const UI_PACKAGE_JSON: string;
|
|
23
|
-
export declare const CLI_PACKAGE_JSON: string;
|
|
24
|
-
export declare const SITE: string;
|
|
25
|
-
export declare const SITE_OUTPUT_PATH: string;
|
|
26
|
-
export declare const SITE_PUBLIC_PATH: string;
|
|
27
|
-
export declare const SITE_DIR: string;
|
|
28
|
-
export declare const SITE_PC_DIR: string;
|
|
29
|
-
export declare const SITE_PC_ROUTES: string;
|
|
30
|
-
export declare const SITE_MOBILE_ROUTES: string;
|
|
31
|
-
export declare const SITE_CONFIG: string;
|
|
32
|
-
export declare const HL_COMPONENT_NAME_RE: RegExp;
|
|
33
|
-
export declare const HL_API_RE: RegExp;
|
|
34
|
-
export declare const HL_TITLE_ATTRIBUTES_RE: RegExp;
|
|
35
|
-
export declare const HL_TITLE_EVENTS_RE: RegExp;
|
|
36
|
-
export declare const HL_TITLE_SLOTS_RE: RegExp;
|
|
37
|
-
export declare const HL_MD = "zh-CN.md";
|
|
38
|
-
export declare const HL_DIR: string;
|
|
39
|
-
export declare const HL_TAGS_JSON: string;
|
|
40
|
-
export declare const HL_ATTRIBUTES_JSON: string;
|
|
41
|
-
export declare const HL_WEB_TYPES_JSON: string;
|
|
42
|
-
export declare const JEST_CONFIG: string;
|
|
1
|
+
export declare const dirname: string;
|
|
2
|
+
export declare const CWD: string;
|
|
3
|
+
export declare const VARLET_CONFIG: string;
|
|
4
|
+
export declare const SRC_DIR: string;
|
|
5
|
+
export declare const ES_DIR: string;
|
|
6
|
+
export declare const LIB_DIR: string;
|
|
7
|
+
export declare const UMD_DIR: string;
|
|
8
|
+
export declare const TYPES_DIR: string;
|
|
9
|
+
export declare const ROOT_DOCS_DIR: string;
|
|
10
|
+
export declare const ROOT_PAGES_DIR: string;
|
|
11
|
+
export declare const ESLINT_EXTENSIONS: string[];
|
|
12
|
+
export declare const VITE_RESOLVE_EXTENSIONS: string[];
|
|
13
|
+
export declare const SCRIPTS_EXTENSIONS: string[];
|
|
14
|
+
export declare const PUBLIC_DIR_INDEXES: string[];
|
|
15
|
+
export declare const STYLE_DIR_NAME = "style";
|
|
16
|
+
export declare const EXAMPLE_DIR_NAME = "example";
|
|
17
|
+
export declare const LOCALE_DIR_NAME = "locale";
|
|
18
|
+
export declare const DOCS_DIR_NAME = "docs";
|
|
19
|
+
export declare const DIR_INDEX = "index.vue";
|
|
20
|
+
export declare const TESTS_DIR_NAME = "__tests__";
|
|
21
|
+
export declare const GENERATORS_DIR: string;
|
|
22
|
+
export declare const UI_PACKAGE_JSON: string;
|
|
23
|
+
export declare const CLI_PACKAGE_JSON: string;
|
|
24
|
+
export declare const SITE: string;
|
|
25
|
+
export declare const SITE_OUTPUT_PATH: string;
|
|
26
|
+
export declare const SITE_PUBLIC_PATH: string;
|
|
27
|
+
export declare const SITE_DIR: string;
|
|
28
|
+
export declare const SITE_PC_DIR: string;
|
|
29
|
+
export declare const SITE_PC_ROUTES: string;
|
|
30
|
+
export declare const SITE_MOBILE_ROUTES: string;
|
|
31
|
+
export declare const SITE_CONFIG: string;
|
|
32
|
+
export declare const HL_COMPONENT_NAME_RE: RegExp;
|
|
33
|
+
export declare const HL_API_RE: RegExp;
|
|
34
|
+
export declare const HL_TITLE_ATTRIBUTES_RE: RegExp;
|
|
35
|
+
export declare const HL_TITLE_EVENTS_RE: RegExp;
|
|
36
|
+
export declare const HL_TITLE_SLOTS_RE: RegExp;
|
|
37
|
+
export declare const HL_MD = "zh-CN.md";
|
|
38
|
+
export declare const HL_DIR: string;
|
|
39
|
+
export declare const HL_TAGS_JSON: string;
|
|
40
|
+
export declare const HL_ATTRIBUTES_JSON: string;
|
|
41
|
+
export declare const HL_WEB_TYPES_JSON: string;
|
|
42
|
+
export declare const JEST_CONFIG: string;
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { resolve } from 'path';
|
|
2
|
-
import { getDirname } from './fsUtils.js';
|
|
3
|
-
export const dirname = getDirname(import.meta.url);
|
|
4
|
-
export const CWD = process.cwd();
|
|
5
|
-
export const VARLET_CONFIG = resolve(CWD, 'varlet.config.mjs');
|
|
6
|
-
export const SRC_DIR = resolve(CWD, 'src');
|
|
7
|
-
export const ES_DIR = resolve(CWD, 'es');
|
|
8
|
-
export const LIB_DIR = resolve(CWD, 'lib');
|
|
9
|
-
export const UMD_DIR = resolve(CWD, 'umd');
|
|
10
|
-
export const TYPES_DIR = resolve(CWD, 'types');
|
|
11
|
-
export const ROOT_DOCS_DIR = resolve(CWD, 'docs');
|
|
12
|
-
export const ROOT_PAGES_DIR = resolve(CWD, 'pages');
|
|
13
|
-
export const ESLINT_EXTENSIONS = ['.vue', '.ts', '.js', '.mjs', '.tsx', '.jsx'];
|
|
14
|
-
export const VITE_RESOLVE_EXTENSIONS = ['.vue', '.tsx', '.ts', '.jsx', '.js', '.less', '.css'];
|
|
15
|
-
export const SCRIPTS_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js'];
|
|
16
|
-
export const PUBLIC_DIR_INDEXES = ['index.vue', 'index.tsx', 'index.ts', 'index.jsx', 'index.js'];
|
|
17
|
-
export const STYLE_DIR_NAME = 'style';
|
|
18
|
-
export const EXAMPLE_DIR_NAME = 'example';
|
|
19
|
-
export const LOCALE_DIR_NAME = 'locale';
|
|
20
|
-
export const DOCS_DIR_NAME = 'docs';
|
|
21
|
-
export const DIR_INDEX = 'index.vue';
|
|
22
|
-
export const TESTS_DIR_NAME = '__tests__';
|
|
23
|
-
export const GENERATORS_DIR = resolve(dirname, '../../../template/generators');
|
|
24
|
-
export const UI_PACKAGE_JSON = resolve(CWD, 'package.json');
|
|
25
|
-
export const CLI_PACKAGE_JSON = resolve(dirname, '../../../package.json');
|
|
26
|
-
// site
|
|
27
|
-
export const SITE = resolve(dirname, '../../../site');
|
|
28
|
-
export const SITE_OUTPUT_PATH = resolve(CWD, 'site');
|
|
29
|
-
export const SITE_PUBLIC_PATH = resolve(CWD, 'public');
|
|
30
|
-
export const SITE_DIR = resolve(CWD, '.varlet/site');
|
|
31
|
-
export const SITE_PC_DIR = resolve(CWD, '.varlet/site/pc');
|
|
32
|
-
export const SITE_PC_ROUTES = resolve(CWD, '.varlet/pc.routes.ts');
|
|
33
|
-
export const SITE_MOBILE_ROUTES = resolve(CWD, '.varlet/mobile.routes.ts');
|
|
34
|
-
export const SITE_CONFIG = resolve(CWD, '.varlet/site.config.json');
|
|
35
|
-
// template highlight
|
|
36
|
-
export const HL_COMPONENT_NAME_RE = /.*(\/|\\)(.+)(\/|\\)docs(\/|\\)/;
|
|
37
|
-
export const HL_API_RE = /##\s*API\n+/;
|
|
38
|
-
export const HL_TITLE_ATTRIBUTES_RE = /###\s*属性\s*\n+/;
|
|
39
|
-
export const HL_TITLE_EVENTS_RE = /###\s*事件\s*\n+/;
|
|
40
|
-
export const HL_TITLE_SLOTS_RE = /###\s*插槽\s*\n+/;
|
|
41
|
-
export const HL_MD = 'zh-CN.md';
|
|
42
|
-
export const HL_DIR = resolve(CWD, 'highlight');
|
|
43
|
-
export const HL_TAGS_JSON = resolve(HL_DIR, 'tags.json');
|
|
44
|
-
export const HL_ATTRIBUTES_JSON = resolve(HL_DIR, 'attributes.json');
|
|
45
|
-
export const HL_WEB_TYPES_JSON = resolve(HL_DIR, 'web-types.json');
|
|
46
|
-
// jest
|
|
47
|
-
export const JEST_CONFIG = resolve(dirname, '../../../cjs/jest.config.cjs');
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { getDirname } from './fsUtils.js';
|
|
3
|
+
export const dirname = getDirname(import.meta.url);
|
|
4
|
+
export const CWD = process.cwd();
|
|
5
|
+
export const VARLET_CONFIG = resolve(CWD, 'varlet.config.mjs');
|
|
6
|
+
export const SRC_DIR = resolve(CWD, 'src');
|
|
7
|
+
export const ES_DIR = resolve(CWD, 'es');
|
|
8
|
+
export const LIB_DIR = resolve(CWD, 'lib');
|
|
9
|
+
export const UMD_DIR = resolve(CWD, 'umd');
|
|
10
|
+
export const TYPES_DIR = resolve(CWD, 'types');
|
|
11
|
+
export const ROOT_DOCS_DIR = resolve(CWD, 'docs');
|
|
12
|
+
export const ROOT_PAGES_DIR = resolve(CWD, 'pages');
|
|
13
|
+
export const ESLINT_EXTENSIONS = ['.vue', '.ts', '.js', '.mjs', '.tsx', '.jsx'];
|
|
14
|
+
export const VITE_RESOLVE_EXTENSIONS = ['.vue', '.tsx', '.ts', '.jsx', '.js', '.less', '.css'];
|
|
15
|
+
export const SCRIPTS_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js'];
|
|
16
|
+
export const PUBLIC_DIR_INDEXES = ['index.vue', 'index.tsx', 'index.ts', 'index.jsx', 'index.js'];
|
|
17
|
+
export const STYLE_DIR_NAME = 'style';
|
|
18
|
+
export const EXAMPLE_DIR_NAME = 'example';
|
|
19
|
+
export const LOCALE_DIR_NAME = 'locale';
|
|
20
|
+
export const DOCS_DIR_NAME = 'docs';
|
|
21
|
+
export const DIR_INDEX = 'index.vue';
|
|
22
|
+
export const TESTS_DIR_NAME = '__tests__';
|
|
23
|
+
export const GENERATORS_DIR = resolve(dirname, '../../../template/generators');
|
|
24
|
+
export const UI_PACKAGE_JSON = resolve(CWD, 'package.json');
|
|
25
|
+
export const CLI_PACKAGE_JSON = resolve(dirname, '../../../package.json');
|
|
26
|
+
// site
|
|
27
|
+
export const SITE = resolve(dirname, '../../../site');
|
|
28
|
+
export const SITE_OUTPUT_PATH = resolve(CWD, 'site');
|
|
29
|
+
export const SITE_PUBLIC_PATH = resolve(CWD, 'public');
|
|
30
|
+
export const SITE_DIR = resolve(CWD, '.varlet/site');
|
|
31
|
+
export const SITE_PC_DIR = resolve(CWD, '.varlet/site/pc');
|
|
32
|
+
export const SITE_PC_ROUTES = resolve(CWD, '.varlet/pc.routes.ts');
|
|
33
|
+
export const SITE_MOBILE_ROUTES = resolve(CWD, '.varlet/mobile.routes.ts');
|
|
34
|
+
export const SITE_CONFIG = resolve(CWD, '.varlet/site.config.json');
|
|
35
|
+
// template highlight
|
|
36
|
+
export const HL_COMPONENT_NAME_RE = /.*(\/|\\)(.+)(\/|\\)docs(\/|\\)/;
|
|
37
|
+
export const HL_API_RE = /##\s*API\n+/;
|
|
38
|
+
export const HL_TITLE_ATTRIBUTES_RE = /###\s*属性\s*\n+/;
|
|
39
|
+
export const HL_TITLE_EVENTS_RE = /###\s*事件\s*\n+/;
|
|
40
|
+
export const HL_TITLE_SLOTS_RE = /###\s*插槽\s*\n+/;
|
|
41
|
+
export const HL_MD = 'zh-CN.md';
|
|
42
|
+
export const HL_DIR = resolve(CWD, 'highlight');
|
|
43
|
+
export const HL_TAGS_JSON = resolve(HL_DIR, 'tags.json');
|
|
44
|
+
export const HL_ATTRIBUTES_JSON = resolve(HL_DIR, 'attributes.json');
|
|
45
|
+
export const HL_WEB_TYPES_JSON = resolve(HL_DIR, 'web-types.json');
|
|
46
|
+
// jest
|
|
47
|
+
export const JEST_CONFIG = resolve(dirname, '../../../cjs/jest.config.cjs');
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export declare function getPublicDirs(): Promise<string[]>;
|
|
2
|
-
export declare const isMD: (file: string) => boolean;
|
|
3
|
-
export declare const isDir: (file: string) => boolean;
|
|
4
|
-
export declare const isSFC: (file: string) => boolean;
|
|
5
|
-
export declare const isDTS: (file: string) => boolean;
|
|
6
|
-
export declare const isScript: (file: string) => boolean;
|
|
7
|
-
export declare const isLess: (file: string) => boolean;
|
|
8
|
-
export declare const isPublicDir: (dir: string) => boolean;
|
|
9
|
-
export declare const replaceExt: (file: string, ext: string) => string;
|
|
10
|
-
export declare function smartAppendFileSync(file: string, code: string): void;
|
|
11
|
-
export declare function outputFileSyncOnChange(path: string, code: string): void;
|
|
12
|
-
export declare function glob(pattern: string): Promise<string[]>;
|
|
13
|
-
export declare function getDirname(url: string): string;
|
|
1
|
+
export declare function getPublicDirs(): Promise<string[]>;
|
|
2
|
+
export declare const isMD: (file: string) => boolean;
|
|
3
|
+
export declare const isDir: (file: string) => boolean;
|
|
4
|
+
export declare const isSFC: (file: string) => boolean;
|
|
5
|
+
export declare const isDTS: (file: string) => boolean;
|
|
6
|
+
export declare const isScript: (file: string) => boolean;
|
|
7
|
+
export declare const isLess: (file: string) => boolean;
|
|
8
|
+
export declare const isPublicDir: (dir: string) => boolean;
|
|
9
|
+
export declare const replaceExt: (file: string, ext: string) => string;
|
|
10
|
+
export declare function smartAppendFileSync(file: string, code: string): void;
|
|
11
|
+
export declare function outputFileSyncOnChange(path: string, code: string): void;
|
|
12
|
+
export declare function glob(pattern: string): Promise<string[]>;
|
|
13
|
+
export declare function getDirname(url: string): string;
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import globSync from 'glob';
|
|
2
|
-
import fse from 'fs-extra';
|
|
3
|
-
import { extname, resolve } from 'path';
|
|
4
|
-
import { PUBLIC_DIR_INDEXES, SCRIPTS_EXTENSIONS, SRC_DIR } from './constant.js';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
const { appendFileSync, ensureFileSync, lstatSync, outputFileSync, pathExistsSync, readdir, readFileSync } = fse;
|
|
7
|
-
export async function getPublicDirs() {
|
|
8
|
-
const srcDir = await readdir(SRC_DIR);
|
|
9
|
-
return srcDir.filter((filename) => isPublicDir(resolve(SRC_DIR, filename)));
|
|
10
|
-
}
|
|
11
|
-
export const isMD = (file) => pathExistsSync(file) && extname(file) === '.md';
|
|
12
|
-
export const isDir = (file) => pathExistsSync(file) && lstatSync(file).isDirectory();
|
|
13
|
-
export const isSFC = (file) => pathExistsSync(file) && extname(file) === '.vue';
|
|
14
|
-
export const isDTS = (file) => pathExistsSync(file) && file.endsWith('.d.ts');
|
|
15
|
-
export const isScript = (file) => pathExistsSync(file) && SCRIPTS_EXTENSIONS.includes(extname(file));
|
|
16
|
-
export const isLess = (file) => pathExistsSync(file) && extname(file) === '.less';
|
|
17
|
-
export const isPublicDir = (dir) => PUBLIC_DIR_INDEXES.some((index) => pathExistsSync(resolve(dir, index)));
|
|
18
|
-
export const replaceExt = (file, ext) => file.replace(extname(file), ext);
|
|
19
|
-
export function smartAppendFileSync(file, code) {
|
|
20
|
-
if (pathExistsSync(file)) {
|
|
21
|
-
const content = readFileSync(file, 'utf-8');
|
|
22
|
-
if (!content.includes(code)) {
|
|
23
|
-
appendFileSync(file, code);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export function outputFileSyncOnChange(path, code) {
|
|
28
|
-
ensureFileSync(path);
|
|
29
|
-
const content = readFileSync(path, 'utf-8');
|
|
30
|
-
if (content !== code) {
|
|
31
|
-
outputFileSync(path, code);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export function glob(pattern) {
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
globSync(pattern, (err, files) => {
|
|
37
|
-
if (err) {
|
|
38
|
-
reject(err);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
resolve(files);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
export function getDirname(url) {
|
|
47
|
-
return fileURLToPath(new URL('.', url));
|
|
48
|
-
}
|
|
1
|
+
import globSync from 'glob';
|
|
2
|
+
import fse from 'fs-extra';
|
|
3
|
+
import { extname, resolve } from 'path';
|
|
4
|
+
import { PUBLIC_DIR_INDEXES, SCRIPTS_EXTENSIONS, SRC_DIR } from './constant.js';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
const { appendFileSync, ensureFileSync, lstatSync, outputFileSync, pathExistsSync, readdir, readFileSync } = fse;
|
|
7
|
+
export async function getPublicDirs() {
|
|
8
|
+
const srcDir = await readdir(SRC_DIR);
|
|
9
|
+
return srcDir.filter((filename) => isPublicDir(resolve(SRC_DIR, filename)));
|
|
10
|
+
}
|
|
11
|
+
export const isMD = (file) => pathExistsSync(file) && extname(file) === '.md';
|
|
12
|
+
export const isDir = (file) => pathExistsSync(file) && lstatSync(file).isDirectory();
|
|
13
|
+
export const isSFC = (file) => pathExistsSync(file) && extname(file) === '.vue';
|
|
14
|
+
export const isDTS = (file) => pathExistsSync(file) && file.endsWith('.d.ts');
|
|
15
|
+
export const isScript = (file) => pathExistsSync(file) && SCRIPTS_EXTENSIONS.includes(extname(file));
|
|
16
|
+
export const isLess = (file) => pathExistsSync(file) && extname(file) === '.less';
|
|
17
|
+
export const isPublicDir = (dir) => PUBLIC_DIR_INDEXES.some((index) => pathExistsSync(resolve(dir, index)));
|
|
18
|
+
export const replaceExt = (file, ext) => file.replace(extname(file), ext);
|
|
19
|
+
export function smartAppendFileSync(file, code) {
|
|
20
|
+
if (pathExistsSync(file)) {
|
|
21
|
+
const content = readFileSync(file, 'utf-8');
|
|
22
|
+
if (!content.includes(code)) {
|
|
23
|
+
appendFileSync(file, code);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function outputFileSyncOnChange(path, code) {
|
|
28
|
+
ensureFileSync(path);
|
|
29
|
+
const content = readFileSync(path, 'utf-8');
|
|
30
|
+
if (content !== code) {
|
|
31
|
+
outputFileSync(path, code);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function glob(pattern) {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
globSync(pattern, (err, files) => {
|
|
37
|
+
if (err) {
|
|
38
|
+
reject(err);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
resolve(files);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export function getDirname(url) {
|
|
47
|
+
return fileURLToPath(new URL('.', url));
|
|
48
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
info(text: string): void;
|
|
3
|
-
success(text: string): void;
|
|
4
|
-
warning(text: string): void;
|
|
5
|
-
error(text: string): void;
|
|
6
|
-
title(text: string): void;
|
|
7
|
-
};
|
|
8
|
-
export default _default;
|
|
1
|
+
declare const _default: {
|
|
2
|
+
info(text: string): void;
|
|
3
|
+
success(text: string): void;
|
|
4
|
+
warning(text: string): void;
|
|
5
|
+
error(text: string): void;
|
|
6
|
+
title(text: string): void;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|