@varlet/cli 2.16.2 → 2.16.3-alpha.1694267513697
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.js +1 -1
- package/lib/client/index.js +6 -10
- package/lib/node/commands/checklist.js +6 -9
- package/lib/node/commands/dev.js +1 -2
- package/lib/node/commands/preview.js +1 -2
- package/lib/node/commands/release.js +2 -3
- package/lib/node/compiler/compileSFC.js +1 -2
- package/lib/node/compiler/compileSiteEntry.js +6 -12
- package/lib/node/compiler/compileStyle.js +1 -2
- package/lib/node/config/vite.config.js +6 -2
- package/package.json +9 -9
- package/tsconfig.json +1 -0
package/lib/client/appType.js
CHANGED
|
@@ -2,6 +2,6 @@ import { defineComponent, h } from 'vue';
|
|
|
2
2
|
export default defineComponent({
|
|
3
3
|
name: 'AppType',
|
|
4
4
|
setup(props, { slots }) {
|
|
5
|
-
return () =>
|
|
5
|
+
return () => h('div', { class: 'app-type' }, [slots.default?.()]);
|
|
6
6
|
},
|
|
7
7
|
});
|
package/lib/client/index.js
CHANGED
|
@@ -4,9 +4,8 @@ import { Themes, StyleProvider } from '@varlet/ui';
|
|
|
4
4
|
import { onMounted, onUnmounted } from 'vue';
|
|
5
5
|
import { get } from 'lodash-es';
|
|
6
6
|
export function getPCLocationInfo() {
|
|
7
|
-
var _a;
|
|
8
7
|
const [, language, path] = window.location.hash.split('/');
|
|
9
|
-
const [menuName, hash = ''] =
|
|
8
|
+
const [menuName, hash = ''] = path?.split('#') ?? [];
|
|
10
9
|
return {
|
|
11
10
|
language,
|
|
12
11
|
menuName,
|
|
@@ -19,7 +18,6 @@ function getHashSearch() {
|
|
|
19
18
|
return new URLSearchParams(hashSearch);
|
|
20
19
|
}
|
|
21
20
|
export function getBrowserTheme() {
|
|
22
|
-
var _a;
|
|
23
21
|
const themeKey = get(config, 'themeKey');
|
|
24
22
|
const darkThemeConfig = get(config, 'darkTheme');
|
|
25
23
|
if (!darkThemeConfig) {
|
|
@@ -27,7 +25,7 @@ export function getBrowserTheme() {
|
|
|
27
25
|
}
|
|
28
26
|
const storageTheme = window.localStorage.getItem(themeKey);
|
|
29
27
|
if (!storageTheme) {
|
|
30
|
-
const preferTheme =
|
|
28
|
+
const preferTheme = window.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'darkTheme' : 'lightTheme';
|
|
31
29
|
window.localStorage.setItem(themeKey, preferTheme);
|
|
32
30
|
return preferTheme;
|
|
33
31
|
}
|
|
@@ -35,8 +33,7 @@ export function getBrowserTheme() {
|
|
|
35
33
|
}
|
|
36
34
|
export function watchLang(cb, platform = 'mobile') {
|
|
37
35
|
const handleHashchange = () => {
|
|
38
|
-
|
|
39
|
-
const language = platform === 'mobile' ? (_a = getHashSearch().get('language')) !== null && _a !== void 0 ? _a : 'zh-CN' : getPCLocationInfo().language;
|
|
36
|
+
const language = platform === 'mobile' ? getHashSearch().get('language') ?? 'zh-CN' : getPCLocationInfo().language;
|
|
40
37
|
cb(language);
|
|
41
38
|
};
|
|
42
39
|
useRouteListener(handleHashchange);
|
|
@@ -50,8 +47,7 @@ export function withSiteConfigNamespace(styleVars) {
|
|
|
50
47
|
}
|
|
51
48
|
export function watchPlatform(cb) {
|
|
52
49
|
const handleHashchange = () => {
|
|
53
|
-
|
|
54
|
-
const platform = (_a = getHashSearch().get('platform')) !== null && _a !== void 0 ? _a : 'mobile';
|
|
50
|
+
const platform = getHashSearch().get('platform') ?? 'mobile';
|
|
55
51
|
cb(platform);
|
|
56
52
|
};
|
|
57
53
|
useRouteListener(handleHashchange);
|
|
@@ -70,10 +66,10 @@ export function useRouteListener(cb) {
|
|
|
70
66
|
export function watchDarkMode(dark, cb) {
|
|
71
67
|
watchTheme((theme) => {
|
|
72
68
|
const siteStyleVars = withSiteConfigNamespace(get(config, theme, {}));
|
|
73
|
-
const darkStyleVars =
|
|
69
|
+
const darkStyleVars = { ...siteStyleVars, ...Themes.dark, ...dark };
|
|
74
70
|
StyleProvider(theme === 'darkTheme' ? darkStyleVars : siteStyleVars);
|
|
75
71
|
setColorScheme(theme);
|
|
76
|
-
cb
|
|
72
|
+
cb?.(theme);
|
|
77
73
|
});
|
|
78
74
|
}
|
|
79
75
|
export function setColorScheme(theme) {
|
|
@@ -9,13 +9,11 @@ const typeRE = /<h3>(.+)<\/h3>/;
|
|
|
9
9
|
const childrenRE = /<ul>(.|\n|\r)+<\/ul>/;
|
|
10
10
|
const childRE = /<li>(.|\n|\r)+?<\/li>/g;
|
|
11
11
|
export function getCheckBlocks(html) {
|
|
12
|
-
|
|
13
|
-
const blocks = (_a = html.match(blockRE)) !== null && _a !== void 0 ? _a : [];
|
|
12
|
+
const blocks = html.match(blockRE) ?? [];
|
|
14
13
|
const checkBlocks = [];
|
|
15
14
|
blocks.forEach((block) => {
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const childrenBlock = (_b = block.match(childrenRE)) === null || _b === void 0 ? void 0 : _b[0];
|
|
15
|
+
const type = block.match(typeRE)?.[1];
|
|
16
|
+
const childrenBlock = block.match(childrenRE)?.[0];
|
|
19
17
|
if (!type || !childrenBlock) {
|
|
20
18
|
return;
|
|
21
19
|
}
|
|
@@ -37,7 +35,6 @@ export function getCheckBlocks(html) {
|
|
|
37
35
|
return checkBlocks;
|
|
38
36
|
}
|
|
39
37
|
export async function checklist(gitParams) {
|
|
40
|
-
var _a, _b, _c, _d, _e;
|
|
41
38
|
const commitMessage = getCommitMessage(gitParams);
|
|
42
39
|
if (isVersionCommitMessage(commitMessage) || !existsSync(CHECKLIST_FILE)) {
|
|
43
40
|
return;
|
|
@@ -49,9 +46,9 @@ export async function checklist(gitParams) {
|
|
|
49
46
|
logger.warning('Cannot find anything need to checked');
|
|
50
47
|
return;
|
|
51
48
|
}
|
|
52
|
-
const type =
|
|
53
|
-
const typeChildren =
|
|
54
|
-
const commonChildren =
|
|
49
|
+
const type = commitMessage.match(COMMIT_MESSAGE_RE)?.[1];
|
|
50
|
+
const typeChildren = checkBlocks.find((checkBlock) => checkBlock.type === type)?.list ?? [];
|
|
51
|
+
const commonChildren = checkBlocks.find((checkBlock) => checkBlock.type === 'common')?.list ?? [];
|
|
55
52
|
const list = [...commonChildren, ...typeChildren];
|
|
56
53
|
if (!list.length) {
|
|
57
54
|
return;
|
package/lib/node/commands/dev.js
CHANGED
|
@@ -11,14 +11,13 @@ const { ensureDirSync, pathExistsSync } = fse;
|
|
|
11
11
|
let server;
|
|
12
12
|
let watcher;
|
|
13
13
|
async function startServer(options) {
|
|
14
|
-
var _a;
|
|
15
14
|
const isRestart = Boolean(server);
|
|
16
15
|
logger.info(`${isRestart ? 'Res' : 'S'}tarting server...`);
|
|
17
16
|
// close all instance
|
|
18
17
|
server && (await server.close());
|
|
19
18
|
watcher && (await watcher.close());
|
|
20
19
|
// build all config
|
|
21
|
-
await buildSiteEntry(
|
|
20
|
+
await buildSiteEntry(options.draft ?? false);
|
|
22
21
|
const varletConfig = await getVarletConfig();
|
|
23
22
|
const devConfig = getDevConfig(varletConfig);
|
|
24
23
|
const inlineConfig = merge(devConfig, options.force ? { optimizeDeps: { force: true } } : {});
|
|
@@ -4,13 +4,12 @@ import execa from 'execa';
|
|
|
4
4
|
import { SITE_OUTPUT_PATH } from '../shared/constant.js';
|
|
5
5
|
const { pathExistsSync } = fse;
|
|
6
6
|
export async function preview() {
|
|
7
|
-
var _a;
|
|
8
7
|
if (!pathExistsSync(SITE_OUTPUT_PATH)) {
|
|
9
8
|
logger.warning('Cannot find the site folder, you must first run the build command to build the document site');
|
|
10
9
|
return;
|
|
11
10
|
}
|
|
12
11
|
try {
|
|
13
|
-
await
|
|
12
|
+
await execa.command('live-server --port=5500', { cwd: SITE_OUTPUT_PATH }).stdout?.pipe(process.stdout);
|
|
14
13
|
}
|
|
15
14
|
catch (e) {
|
|
16
15
|
logger.error(e.toString());
|
|
@@ -73,10 +73,9 @@ async function confirmVersion(currentVersion, expectVersion) {
|
|
|
73
73
|
return ret[name];
|
|
74
74
|
}
|
|
75
75
|
async function confirmRefs(remote = 'origin') {
|
|
76
|
-
var _a;
|
|
77
76
|
const { stdout } = await execa('git', ['remote', '-v']);
|
|
78
77
|
const reg = new RegExp(`${remote}\t(.*) \\(push`);
|
|
79
|
-
const repo =
|
|
78
|
+
const repo = stdout.match(reg)?.[1];
|
|
80
79
|
const { stdout: branch } = await execa('git', ['branch', '--show-current']);
|
|
81
80
|
const name = 'Refs confirm';
|
|
82
81
|
const ret = await prompt([
|
|
@@ -138,7 +137,7 @@ export async function release(options) {
|
|
|
138
137
|
await execa('git', ['restore', '**/package.json']);
|
|
139
138
|
await execa('git', ['restore', 'package.json']);
|
|
140
139
|
}
|
|
141
|
-
catch
|
|
140
|
+
catch {
|
|
142
141
|
logger.error('Restore package.json has failed, please restore manually');
|
|
143
142
|
}
|
|
144
143
|
}
|
|
@@ -32,7 +32,6 @@ export function injectRender(script, render) {
|
|
|
32
32
|
return script;
|
|
33
33
|
}
|
|
34
34
|
export async function compileSFC(sfc) {
|
|
35
|
-
var _a;
|
|
36
35
|
const sources = await readFile(sfc, 'utf-8');
|
|
37
36
|
const id = hash(sources);
|
|
38
37
|
const { descriptor } = parseSFC(sources, { sourceMap: false });
|
|
@@ -63,7 +62,7 @@ export async function compileSFC(sfc) {
|
|
|
63
62
|
source: template.content,
|
|
64
63
|
filename: sfc,
|
|
65
64
|
compilerOptions: {
|
|
66
|
-
expressionPlugins:
|
|
65
|
+
expressionPlugins: descriptor.script?.lang === 'ts' ? ['typescript'] : undefined,
|
|
67
66
|
scopeId,
|
|
68
67
|
bindingMetadata,
|
|
69
68
|
},
|
|
@@ -10,22 +10,18 @@ const PAGE_LOCALE_RE = /\/pages\/([-\w]+)\/locale\/([-\w]+)\.ts/;
|
|
|
10
10
|
const EXAMPLE_INDEX_RE = /\/([-\w]+)\/example\/index(?:.draft)?\.vue/;
|
|
11
11
|
const COMPONENT_DOCS_RE = /\/([-\w]+)\/docs\/([-\w]+)(?:.draft)?\.md/;
|
|
12
12
|
export function getExampleRoutePath(examplePath) {
|
|
13
|
-
|
|
14
|
-
return '/' + ((_a = examplePath.match(EXAMPLE_INDEX_RE)) === null || _a === void 0 ? void 0 : _a[1]); // eslint-disable-line
|
|
13
|
+
return '/' + examplePath.match(EXAMPLE_INDEX_RE)?.[1]; // eslint-disable-line
|
|
15
14
|
}
|
|
16
15
|
export function getComponentDocRoutePath(componentDocsPath) {
|
|
17
|
-
|
|
18
|
-
const [, routePath, language] = (_a = componentDocsPath.match(COMPONENT_DOCS_RE)) !== null && _a !== void 0 ? _a : [];
|
|
16
|
+
const [, routePath, language] = componentDocsPath.match(COMPONENT_DOCS_RE) ?? [];
|
|
19
17
|
return `/${language}/${routePath}`;
|
|
20
18
|
}
|
|
21
19
|
export function getRootDocRoutePath(rootDocsPath) {
|
|
22
|
-
|
|
23
|
-
const [, routePath, language] = (_a = rootDocsPath.match(ROOT_DOCS_RE)) !== null && _a !== void 0 ? _a : [];
|
|
20
|
+
const [, routePath, language] = rootDocsPath.match(ROOT_DOCS_RE) ?? [];
|
|
24
21
|
return `/${language}/${routePath}`;
|
|
25
22
|
}
|
|
26
23
|
export function getPageRoutePath(rootLocalePath) {
|
|
27
|
-
|
|
28
|
-
const [, routePath, language] = (_a = rootLocalePath.match(PAGE_LOCALE_RE)) !== null && _a !== void 0 ? _a : [];
|
|
24
|
+
const [, routePath, language] = rootLocalePath.match(PAGE_LOCALE_RE) ?? [];
|
|
29
25
|
return `/${language}/${routePath}`;
|
|
30
26
|
}
|
|
31
27
|
export function getPageFilePath(rootLocalePath) {
|
|
@@ -78,13 +74,11 @@ export async function findPageLocales() {
|
|
|
78
74
|
// filter
|
|
79
75
|
const filterMap = new Map();
|
|
80
76
|
baseLocales.forEach((locale) => {
|
|
81
|
-
|
|
82
|
-
const [, routePath, language] = (_a = locale.match(PAGE_LOCALE_RE)) !== null && _a !== void 0 ? _a : [];
|
|
77
|
+
const [, routePath, language] = locale.match(PAGE_LOCALE_RE) ?? [];
|
|
83
78
|
filterMap.set(routePath + language, slash(`${SITE_PC_DIR}/pages/${routePath}/locale/${language}.ts`));
|
|
84
79
|
});
|
|
85
80
|
userLocales.forEach((locale) => {
|
|
86
|
-
|
|
87
|
-
const [, routePath, language] = (_a = locale.match(PAGE_LOCALE_RE)) !== null && _a !== void 0 ? _a : [];
|
|
81
|
+
const [, routePath, language] = locale.match(PAGE_LOCALE_RE) ?? [];
|
|
88
82
|
filterMap.set(routePath + language, locale);
|
|
89
83
|
});
|
|
90
84
|
return Promise.resolve(Array.from(filterMap.values()));
|
|
@@ -22,8 +22,7 @@ export function normalizeStyleDependency(styleImport, reg) {
|
|
|
22
22
|
return '../' + relativePath;
|
|
23
23
|
}
|
|
24
24
|
export function extractStyleDependencies(file, code, styleReg) {
|
|
25
|
-
|
|
26
|
-
const styleImports = (_a = code.match(styleReg)) !== null && _a !== void 0 ? _a : [];
|
|
25
|
+
const styleImports = code.match(styleReg) ?? [];
|
|
27
26
|
const cssFile = resolve(parse(file).dir, `./style/index${getScriptExtname()}`);
|
|
28
27
|
styleImports.forEach((styleImport) => {
|
|
29
28
|
const normalizedPath = normalizeStyleDependency(styleImport, styleReg);
|
|
@@ -46,7 +46,10 @@ export function getDevConfig(varletConfig) {
|
|
|
46
46
|
}
|
|
47
47
|
export function getBuildConfig(varletConfig) {
|
|
48
48
|
const devConfig = getDevConfig(varletConfig);
|
|
49
|
-
return
|
|
49
|
+
return {
|
|
50
|
+
...devConfig,
|
|
51
|
+
base: './',
|
|
52
|
+
build: {
|
|
50
53
|
outDir: SITE_OUTPUT_PATH,
|
|
51
54
|
reportCompressedSize: false,
|
|
52
55
|
emptyOutDir: true,
|
|
@@ -57,7 +60,8 @@ export function getBuildConfig(varletConfig) {
|
|
|
57
60
|
mobile: resolve(SITE_DIR, 'mobile.html'),
|
|
58
61
|
},
|
|
59
62
|
},
|
|
60
|
-
}
|
|
63
|
+
},
|
|
64
|
+
};
|
|
61
65
|
}
|
|
62
66
|
export function getBundleConfig(varletConfig, buildOptions) {
|
|
63
67
|
const plugins = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "2.16.
|
|
3
|
+
"version": "2.16.3-alpha.1694267513697",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"vite": "4.3.5",
|
|
68
68
|
"vue": "3.3.4",
|
|
69
69
|
"webfont": "^9.0.0",
|
|
70
|
-
"@varlet/
|
|
71
|
-
"@varlet/
|
|
70
|
+
"@varlet/vite-plugins": "2.16.3-alpha.1694267513697",
|
|
71
|
+
"@varlet/shared": "2.16.3-alpha.1694267513697"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/babel__core": "^7.20.1",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"@types/semver": "^7.3.9",
|
|
84
84
|
"@types/sharp": "0.31.1",
|
|
85
85
|
"rimraf": "^5.0.1",
|
|
86
|
-
"@varlet/
|
|
87
|
-
"@varlet/
|
|
88
|
-
"@varlet/
|
|
86
|
+
"@varlet/touch-emulator": "2.16.3-alpha.1694267513697",
|
|
87
|
+
"@varlet/icons": "2.16.3-alpha.1694267513697",
|
|
88
|
+
"@varlet/ui": "2.16.3-alpha.1694267513697"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"@vue/runtime-core": "3.3.4",
|
|
@@ -98,9 +98,9 @@
|
|
|
98
98
|
"lodash-es": "^4.17.21",
|
|
99
99
|
"vue": "3.3.4",
|
|
100
100
|
"vue-router": "4.2.0",
|
|
101
|
-
"@varlet/
|
|
102
|
-
"@varlet/
|
|
103
|
-
"@varlet/
|
|
101
|
+
"@varlet/icons": "2.16.3-alpha.1694267513697",
|
|
102
|
+
"@varlet/touch-emulator": "2.16.3-alpha.1694267513697",
|
|
103
|
+
"@varlet/ui": "2.16.3-alpha.1694267513697"
|
|
104
104
|
},
|
|
105
105
|
"scripts": {
|
|
106
106
|
"dev": "tsc --watch",
|