@varlet/cli 2.0.6 → 2.1.0-alpha.1667210582672
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 +2 -2
- package/README.md +2 -2
- package/cjs/babel.config.cjs +29 -0
- package/cjs/babel.sfc.transform.cjs +18 -0
- package/cjs/jest.config.cjs +33 -0
- package/cjs/jest.media.mock.cjs +1 -0
- package/cjs/jest.style.mock.cjs +1 -0
- package/client.d.ts +1 -0
- package/client.js +1 -0
- package/lib/client/appType.d.ts +4 -0
- package/lib/client/appType.js +7 -0
- package/lib/client/index.d.ts +17 -0
- package/lib/client/index.js +106 -0
- package/lib/{bin.d.ts → node/bin.d.ts} +0 -0
- package/lib/node/bin.js +122 -0
- package/lib/{commands → node/commands}/build.d.ts +0 -0
- package/lib/node/commands/build.js +15 -0
- package/lib/{commands → node/commands}/changelog.d.ts +0 -0
- package/lib/node/commands/changelog.js +20 -0
- package/lib/{commands → node/commands}/commitLint.d.ts +0 -0
- package/lib/node/commands/commitLint.js +45 -0
- package/lib/{commands → node/commands}/compile.d.ts +0 -0
- package/lib/node/commands/compile.js +35 -0
- package/lib/{commands → node/commands}/create.d.ts +0 -0
- package/lib/node/commands/create.js +91 -0
- package/lib/{commands → node/commands}/dev.d.ts +0 -0
- package/lib/node/commands/dev.js +38 -0
- package/lib/{commands → node/commands}/gen.d.ts +0 -0
- package/lib/node/commands/gen.js +75 -0
- package/lib/{commands → node/commands}/jest.d.ts +0 -0
- package/lib/node/commands/jest.js +27 -0
- package/lib/{commands → node/commands}/lint.d.ts +0 -0
- package/lib/node/commands/lint.js +42 -0
- package/lib/{commands → node/commands}/preview.d.ts +0 -0
- package/lib/node/commands/preview.js +18 -0
- package/lib/{commands → node/commands}/release.d.ts +0 -0
- package/lib/node/commands/release.js +146 -0
- package/lib/{commands → node/commands}/vite.d.ts +0 -0
- package/lib/node/commands/vite.js +13 -0
- package/lib/{compiler → node/compiler}/compileModule.d.ts +0 -0
- package/lib/node/compiler/compileModule.js +74 -0
- package/lib/{compiler → node/compiler}/compileSFC.d.ts +0 -0
- package/lib/node/compiler/compileSFC.js +79 -0
- package/lib/{compiler → node/compiler}/compileScript.d.ts +1 -1
- package/lib/node/compiler/compileScript.js +141 -0
- package/lib/{compiler → node/compiler}/compileSiteEntry.d.ts +0 -0
- package/lib/node/compiler/compileSiteEntry.js +128 -0
- package/lib/{compiler → node/compiler}/compileStyle.d.ts +0 -0
- package/lib/node/compiler/compileStyle.js +39 -0
- package/lib/{compiler → node/compiler}/compileTemplateHighlight.d.ts +0 -0
- package/lib/node/compiler/compileTemplateHighlight.js +133 -0
- package/lib/{compiler → node/compiler}/compileTypes.d.ts +0 -0
- package/lib/node/compiler/compileTypes.js +45 -0
- package/lib/{config → node/config}/varlet.config.d.ts +5 -4
- package/lib/node/config/varlet.config.js +27 -0
- package/lib/node/config/varlet.default.config.d.ts +2 -0
- package/lib/node/config/varlet.default.config.js +264 -0
- package/lib/node/config/vite.config.d.ts +6 -0
- package/lib/node/config/vite.config.js +144 -0
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.js +1 -0
- package/lib/{shared → node/shared}/constant.d.ts +1 -2
- package/lib/node/shared/constant.js +47 -0
- package/lib/{shared → node/shared}/fsUtils.d.ts +1 -0
- package/lib/node/shared/fsUtils.js +48 -0
- package/lib/{shared → node/shared}/logger.d.ts +0 -0
- package/lib/node/shared/logger.js +18 -0
- package/package.json +22 -20
- package/{preset.js → preset.cjs} +1 -1
- package/site/components/code-example/CodeExample.vue +2 -1
- package/site/components/utils/components.ts +1 -4
- package/site/components/utils/elements.ts +1 -1
- package/site/mobile/App.vue +27 -26
- package/site/mobile/components/AppHome.vue +2 -1
- package/site/pc/App.vue +2 -1
- package/site/pc/Layout.vue +4 -3
- package/site/pc/components/AppHeader.vue +4 -2
- package/site/pc/pages/index/index.vue +8 -4
- package/site/useProgress.ts +2 -1
- package/site/utils.ts +6 -137
- package/template/create/index.ts.ejs +1 -1
- package/template/generators/config/default/base/{varlet.config.js → varlet.config.mjs} +2 -2
- package/template/generators/config/i18n/base/{varlet.config.js → varlet.config.mjs} +2 -2
- package/tsconfig.json +2 -9
- package/lib/bin.js +0 -102
- package/lib/commands/build.js +0 -67
- package/lib/commands/changelog.js +0 -27
- package/lib/commands/commitLint.js +0 -21
- package/lib/commands/compile.js +0 -119
- package/lib/commands/create.js +0 -166
- package/lib/commands/dev.js +0 -123
- package/lib/commands/gen.js +0 -138
- package/lib/commands/jest.js +0 -85
- package/lib/commands/lint.js +0 -123
- package/lib/commands/preview.js +0 -74
- package/lib/commands/release.js +0 -305
- package/lib/commands/vite.js +0 -69
- package/lib/compiler/compileModule.js +0 -190
- package/lib/compiler/compileSFC.js +0 -135
- package/lib/compiler/compileScript.js +0 -194
- package/lib/compiler/compileSiteEntry.js +0 -237
- package/lib/compiler/compileStyle.js +0 -91
- package/lib/compiler/compileTemplateHighlight.js +0 -193
- package/lib/compiler/compileTypes.js +0 -85
- package/lib/config/babel.config.d.ts +0 -2
- package/lib/config/babel.config.js +0 -31
- package/lib/config/babel.sfc.transform.d.ts +0 -1
- package/lib/config/babel.sfc.transform.js +0 -18
- package/lib/config/jest.config.d.ts +0 -1
- package/lib/config/jest.config.js +0 -37
- package/lib/config/jest.media.mock.d.ts +0 -0
- package/lib/config/jest.media.mock.js +0 -2
- package/lib/config/jest.style.mock.d.ts +0 -0
- package/lib/config/jest.style.mock.js +0 -2
- package/lib/config/varlet.config.js +0 -35
- package/lib/config/vite.config.d.ts +0 -5
- package/lib/config/vite.config.js +0 -162
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -5
- package/lib/shared/constant.js +0 -50
- package/lib/shared/fsUtils.js +0 -108
- package/lib/shared/logger.js +0 -23
- package/site/mobile/components/AppType.vue +0 -22
- package/varlet.default.config.js +0 -267
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InlineConfig } from 'vite';
|
|
2
|
+
import { VarletConfig } from './varlet.config';
|
|
3
|
+
export declare function getDevConfig(varletConfig: Required<VarletConfig>): InlineConfig;
|
|
4
|
+
export declare function getBuildConfig(varletConfig: Required<VarletConfig>): InlineConfig;
|
|
5
|
+
export declare function getESMBundleConfig(varletConfig: Required<VarletConfig>): InlineConfig;
|
|
6
|
+
export declare function getUMDConfig(varletConfig: Required<VarletConfig>): InlineConfig;
|
|
@@ -0,0 +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');
|
|
73
|
+
const injectCode = `;(function(){var style=document.createElement('style');style.type='text/css';\
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineConfig } from './config/varlet.config.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineConfig } from './config/varlet.config.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const dirname: string;
|
|
1
2
|
export declare const CWD: string;
|
|
2
3
|
export declare const VARLET_CONFIG: string;
|
|
3
4
|
export declare const SRC_DIR: string;
|
|
@@ -39,5 +40,3 @@ export declare const HL_TAGS_JSON: string;
|
|
|
39
40
|
export declare const HL_ATTRIBUTES_JSON: string;
|
|
40
41
|
export declare const HL_WEB_TYPES_JSON: string;
|
|
41
42
|
export declare const JEST_CONFIG: string;
|
|
42
|
-
export declare const JEST_MEDIA_MOCK: string;
|
|
43
|
-
export declare const JEST_STYLE_MOCK: string;
|
|
@@ -0,0 +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');
|
|
@@ -10,3 +10,4 @@ export declare const replaceExt: (file: string, ext: string) => string;
|
|
|
10
10
|
export declare function smartAppendFileSync(file: string, code: string): void;
|
|
11
11
|
export declare function outputFileSyncOnChange(path: string, code: string): void;
|
|
12
12
|
export declare function glob(pattern: string): Promise<string[]>;
|
|
13
|
+
export declare function getDirname(url: string): string;
|
|
@@ -0,0 +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
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
export default {
|
|
3
|
+
info(text) {
|
|
4
|
+
console.log(text);
|
|
5
|
+
},
|
|
6
|
+
success(text) {
|
|
7
|
+
console.log(chalk.hex('#00c48f')(text));
|
|
8
|
+
},
|
|
9
|
+
warning(text) {
|
|
10
|
+
console.log(chalk.hex('#ff9800')(text));
|
|
11
|
+
},
|
|
12
|
+
error(text) {
|
|
13
|
+
console.log(chalk.hex('#f44336')(text));
|
|
14
|
+
},
|
|
15
|
+
title(text) {
|
|
16
|
+
console.log(chalk.cyan(text));
|
|
17
|
+
},
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.1.0-alpha.1667210582672",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "cli of varlet",
|
|
5
6
|
"bin": {
|
|
6
|
-
"varlet-cli": "./lib/bin.js"
|
|
7
|
+
"varlet-cli": "./lib/node/bin.js"
|
|
7
8
|
},
|
|
8
|
-
"main": "./lib/index.js",
|
|
9
|
-
"module": "./lib/index.js",
|
|
9
|
+
"main": "./lib/node/index.js",
|
|
10
|
+
"module": "./lib/node/index.js",
|
|
10
11
|
"keywords": [
|
|
11
12
|
"cli",
|
|
12
13
|
"varlet"
|
|
@@ -15,13 +16,17 @@
|
|
|
15
16
|
"license": "MIT",
|
|
16
17
|
"files": [
|
|
17
18
|
"lib",
|
|
19
|
+
"cjs",
|
|
20
|
+
"client.js",
|
|
21
|
+
"client.d.ts",
|
|
18
22
|
"template",
|
|
19
23
|
"site",
|
|
20
24
|
"tsconfig.json",
|
|
21
|
-
"
|
|
22
|
-
"preset.js",
|
|
23
|
-
"CHANGELOG.md"
|
|
25
|
+
"preset.cjs"
|
|
24
26
|
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": "^14.18.0 || >=16.0.0"
|
|
29
|
+
},
|
|
25
30
|
"repository": {
|
|
26
31
|
"type": "git",
|
|
27
32
|
"url": "https://github.com/varletjs/varlet.git"
|
|
@@ -34,8 +39,9 @@
|
|
|
34
39
|
"@babel/helper-plugin-utils": "^7.14.5",
|
|
35
40
|
"@babel/preset-env": "^7.14.8",
|
|
36
41
|
"@babel/preset-typescript": "^7.14.5",
|
|
37
|
-
"@
|
|
38
|
-
"@varlet/
|
|
42
|
+
"@types/inquirer": "^9.0.2",
|
|
43
|
+
"@varlet/markdown-vite-plugin": "2.1.0-alpha.1667210582672",
|
|
44
|
+
"@varlet/shared": "2.1.0-alpha.1667210582672",
|
|
39
45
|
"@vitejs/plugin-vue": "3.0.1",
|
|
40
46
|
"@vitejs/plugin-vue-jsx": "2.0.0",
|
|
41
47
|
"@vue/babel-plugin-jsx": "1.1.1",
|
|
@@ -51,10 +57,9 @@
|
|
|
51
57
|
"fs-extra": "^9.0.1",
|
|
52
58
|
"glob": "^7.2.0",
|
|
53
59
|
"hash-sum": "^2.0.0",
|
|
54
|
-
"inquirer": "^
|
|
60
|
+
"inquirer": "^9.1.4",
|
|
55
61
|
"jest": "^26.6.3",
|
|
56
62
|
"less": "^3.12.2",
|
|
57
|
-
"lodash": "^4.17.21",
|
|
58
63
|
"lodash-es": "^4.17.21",
|
|
59
64
|
"ora": "^5.4.0",
|
|
60
65
|
"semver": "^7.3.5",
|
|
@@ -67,23 +72,20 @@
|
|
|
67
72
|
"vue-jest": "^5.0.0-alpha.8"
|
|
68
73
|
},
|
|
69
74
|
"devDependencies": {
|
|
70
|
-
"@varlet/icons": "2.0.6",
|
|
71
|
-
"@varlet/touch-emulator": "2.0.6",
|
|
72
|
-
"@types/node": "^18.7.20",
|
|
73
75
|
"@types/babel__core": "^7.1.12",
|
|
74
76
|
"@types/ejs": "^3.1.1",
|
|
75
77
|
"@types/fs-extra": "^9.0.2",
|
|
76
78
|
"@types/glob": "^7.1.3",
|
|
77
79
|
"@types/hash-sum": "^1.0.0",
|
|
78
|
-
"@types/inquirer": "8.1.2",
|
|
79
|
-
"@types/jest": "^26.0.15",
|
|
80
|
-
"@types/lodash": "^4.14.174",
|
|
81
80
|
"@types/lodash-es": "^4.17.5",
|
|
82
|
-
"@types/
|
|
81
|
+
"@types/node": "^18.7.20",
|
|
82
|
+
"@types/semver": "^7.3.9",
|
|
83
|
+
"@varlet/icons": "2.1.0-alpha.1667210582672",
|
|
84
|
+
"@varlet/touch-emulator": "2.1.0-alpha.1667210582672"
|
|
83
85
|
},
|
|
84
86
|
"peerDependencies": {
|
|
85
|
-
"@varlet/icons": "2.0.
|
|
86
|
-
"@varlet/touch-emulator": "2.0.
|
|
87
|
+
"@varlet/icons": "2.1.0-alpha.1667210582672",
|
|
88
|
+
"@varlet/touch-emulator": "2.1.0-alpha.1667210582672",
|
|
87
89
|
"@vue/runtime-core": "3.2.16",
|
|
88
90
|
"@vue/test-utils": "^2.0.2",
|
|
89
91
|
"clipboard": "^2.0.6",
|
package/{preset.js → preset.cjs}
RENAMED
|
@@ -43,7 +43,8 @@ import config from '@config'
|
|
|
43
43
|
import { defineComponent, nextTick, ref, onMounted } from 'vue'
|
|
44
44
|
import { doubleRaf } from '../utils/elements'
|
|
45
45
|
import { get } from 'lodash-es'
|
|
46
|
-
import { getBrowserTheme, getPCLocationInfo
|
|
46
|
+
import { getBrowserTheme, getPCLocationInfo } from '@varlet/cli/client'
|
|
47
|
+
import { utoa } from '../../utils'
|
|
47
48
|
import type { Ref } from 'vue'
|
|
48
49
|
|
|
49
50
|
let clipId = 0
|
|
@@ -98,10 +98,7 @@ export function createNamespace(name: string) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
export function call<
|
|
102
|
-
fn?: F | null,
|
|
103
|
-
...arg: P
|
|
104
|
-
): ReturnType<F> | undefined {
|
|
101
|
+
export function call<P extends any[], R>(fn?: ((...arg: P) => R) | null, ...arg: P): R | undefined {
|
|
105
102
|
if (fn) return fn(...arg)
|
|
106
103
|
}
|
|
107
104
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNumber, isString, toNumber, kebabCase } from '@varlet/shared'
|
|
2
|
-
import type { StyleVars } from '
|
|
2
|
+
import type { StyleVars } from '@varlet/cli/client'
|
|
3
3
|
|
|
4
4
|
export function getLeft(element: HTMLElement): number {
|
|
5
5
|
const { left } = element.getBoundingClientRect()
|
package/site/mobile/App.vue
CHANGED
|
@@ -77,14 +77,11 @@ import { computed, ComputedRef, defineComponent, ref, Ref, watch } from 'vue'
|
|
|
77
77
|
import { useRoute } from 'vue-router'
|
|
78
78
|
import {
|
|
79
79
|
getBrowserTheme,
|
|
80
|
-
|
|
81
|
-
isPhone,
|
|
82
|
-
removeEmpty,
|
|
83
|
-
setTheme,
|
|
84
|
-
Theme,
|
|
80
|
+
type Theme,
|
|
85
81
|
watchLang,
|
|
86
82
|
watchTheme
|
|
87
|
-
} from '
|
|
83
|
+
} from '@varlet/cli/client'
|
|
84
|
+
import { removeEmpty, setTheme, inIframe, isPhone } from '../utils'
|
|
88
85
|
import { bigCamelize } from '@varlet/shared'
|
|
89
86
|
import { get } from 'lodash-es'
|
|
90
87
|
|
|
@@ -151,13 +148,13 @@ export default defineComponent({
|
|
|
151
148
|
}
|
|
152
149
|
|
|
153
150
|
const toggleTheme = () => {
|
|
154
|
-
|
|
155
|
-
|
|
151
|
+
setCurrentTheme(currentTheme.value === 'darkTheme' ? 'lightTheme' : 'darkTheme')
|
|
152
|
+
window.postMessage(getThemeMessage(), '*')
|
|
156
153
|
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
if (!isPhone() && inIframe()) {
|
|
155
|
+
;(window.top as any).postMessage(getThemeMessage(), '*')
|
|
156
|
+
}
|
|
159
157
|
}
|
|
160
|
-
}
|
|
161
158
|
|
|
162
159
|
;(window as any).toggleTheme = toggleTheme
|
|
163
160
|
|
|
@@ -194,6 +191,7 @@ export default defineComponent({
|
|
|
194
191
|
<style lang="less">
|
|
195
192
|
* {
|
|
196
193
|
-webkit-font-smoothing: antialiased;
|
|
194
|
+
box-sizing: border-box;
|
|
197
195
|
}
|
|
198
196
|
|
|
199
197
|
body {
|
|
@@ -208,6 +206,13 @@ body {
|
|
|
208
206
|
transition: background-color 0.25s, color 0.25s;
|
|
209
207
|
}
|
|
210
208
|
|
|
209
|
+
header {
|
|
210
|
+
position: fixed;
|
|
211
|
+
z-index: 99;
|
|
212
|
+
width: 100%;
|
|
213
|
+
font-weight: bold;
|
|
214
|
+
}
|
|
215
|
+
|
|
211
216
|
::-webkit-scrollbar {
|
|
212
217
|
display: none;
|
|
213
218
|
width: 0;
|
|
@@ -228,17 +233,6 @@ body {
|
|
|
228
233
|
}
|
|
229
234
|
}
|
|
230
235
|
|
|
231
|
-
header {
|
|
232
|
-
position: fixed;
|
|
233
|
-
z-index: 99;
|
|
234
|
-
width: 100%;
|
|
235
|
-
font-weight: bold;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
.app-bar {
|
|
239
|
-
background: var(--site-config-color-app-bar) !important;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
236
|
.settings {
|
|
243
237
|
position: fixed;
|
|
244
238
|
z-index: 200;
|
|
@@ -251,10 +245,6 @@ header {
|
|
|
251
245
|
padding: 55px 15px 15px;
|
|
252
246
|
}
|
|
253
247
|
|
|
254
|
-
* {
|
|
255
|
-
box-sizing: border-box;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
248
|
.mobile-language-cell {
|
|
259
249
|
color: var(--site-config-color-text) !important;
|
|
260
250
|
background: var(--site-config-color-bar) !important;
|
|
@@ -289,4 +279,15 @@ header {
|
|
|
289
279
|
.i18n-button {
|
|
290
280
|
padding-right: 6px !important;
|
|
291
281
|
}
|
|
282
|
+
|
|
283
|
+
.app-type {
|
|
284
|
+
width: 100%;
|
|
285
|
+
padding: 15px 0;
|
|
286
|
+
color: var(--site-config-color-sub-text);
|
|
287
|
+
font-size: 14px;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.app-bar {
|
|
291
|
+
background: var(--site-config-color-app-bar) !important;
|
|
292
|
+
}
|
|
292
293
|
</style>
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
import config from '@config'
|
|
24
24
|
import { useRouter } from 'vue-router'
|
|
25
25
|
import { reactive, ref } from 'vue'
|
|
26
|
-
import {
|
|
26
|
+
import { watchLang, watchPlatform } from '@varlet/cli/client'
|
|
27
|
+
import { inIframe, isPhone } from '../../utils'
|
|
27
28
|
|
|
28
29
|
export default {
|
|
29
30
|
name: 'AppHome',
|
package/site/pc/App.vue
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import config from '@config'
|
|
3
3
|
import LogoAnimation from './components/LogoAnimation.vue'
|
|
4
4
|
import { defineComponent, onMounted, ref } from 'vue'
|
|
5
|
-
import { getPCLocationInfo
|
|
5
|
+
import { getPCLocationInfo } from '@varlet/cli/client'
|
|
6
|
+
import { isPhone } from '../utils'
|
|
6
7
|
import { get } from 'lodash-es'
|
|
7
8
|
|
|
8
9
|
export default defineComponent({
|
package/site/pc/Layout.vue
CHANGED
|
@@ -7,7 +7,8 @@ import context from '../components/context'
|
|
|
7
7
|
import { nextTick, onMounted, ref, watch } from 'vue'
|
|
8
8
|
import { useRoute } from 'vue-router'
|
|
9
9
|
import { get } from 'lodash-es'
|
|
10
|
-
import { getPCLocationInfo
|
|
10
|
+
import { getPCLocationInfo } from '@varlet/cli/client'
|
|
11
|
+
import { MenuTypes, type Menu } from '../utils'
|
|
11
12
|
import type { Ref } from 'vue'
|
|
12
13
|
|
|
13
14
|
const menu: Ref<Menu[]> = ref(get(config, 'pc.menu', []))
|
|
@@ -127,8 +128,8 @@ watch(
|
|
|
127
128
|
@click-overlay="confirmClose"
|
|
128
129
|
>
|
|
129
130
|
<div class="varlet-site-playground-container">
|
|
130
|
-
<iframe id="playground" class="varlet-site-playground-iframe" :src="context.playgroundURL"
|
|
131
|
-
|
|
131
|
+
<iframe id="playground" class="varlet-site-playground-iframe" :src="context.playgroundURL" allow="clipboard-write">
|
|
132
|
+
</iframe>
|
|
132
133
|
</div>
|
|
133
134
|
</var-popup>
|
|
134
135
|
</template>
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import config from '@config'
|
|
3
|
+
import AnimationBox from './AnimationBox.vue'
|
|
3
4
|
import { ref, computed, defineComponent } from 'vue'
|
|
4
5
|
import { get } from 'lodash-es'
|
|
5
|
-
import { getBrowserTheme, getPCLocationInfo,
|
|
6
|
+
import { getBrowserTheme, getPCLocationInfo, Theme, watchTheme } from '@varlet/cli/client'
|
|
7
|
+
import { setTheme } from '../../utils'
|
|
8
|
+
import { removeEmpty } from '../../utils'
|
|
6
9
|
import { useRouter } from 'vue-router'
|
|
7
|
-
import AnimationBox from './AnimationBox.vue'
|
|
8
10
|
import type { Ref, ComputedRef } from 'vue'
|
|
9
11
|
|
|
10
12
|
export default defineComponent({
|
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
import AnimationBox from '../../components/AnimationBox.vue'
|
|
3
3
|
import config from '@config'
|
|
4
4
|
import { get } from 'lodash-es'
|
|
5
|
-
import { ref, watch } from 'vue'
|
|
5
|
+
import { ref, watch, type Ref } from 'vue'
|
|
6
6
|
import { useRoute, useRouter } from 'vue-router'
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import {
|
|
8
|
+
getPCLocationInfo,
|
|
9
|
+
watchTheme,
|
|
10
|
+
getBrowserTheme,
|
|
11
|
+
type Theme
|
|
12
|
+
} from '@varlet/cli/client'
|
|
13
|
+
import { setTheme } from '../../../utils'
|
|
10
14
|
|
|
11
15
|
const route = useRoute()
|
|
12
16
|
const router = useRouter()
|
package/site/useProgress.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import Progress from './components/progress'
|
|
2
2
|
import config from '@config'
|
|
3
3
|
import { reactive } from 'vue'
|
|
4
|
-
import { getBrowserTheme,
|
|
4
|
+
import { getBrowserTheme, Theme, watchTheme } from '@varlet/cli/client'
|
|
5
|
+
import { mountInstance } from './components/utils/components'
|
|
5
6
|
import { get } from 'lodash-es'
|
|
6
7
|
|
|
7
8
|
function getColor(theme?: Theme) {
|