@varlet/cli 2.19.3 → 2.20.0-alpha.1701880061001

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/node/bin.js CHANGED
@@ -78,6 +78,7 @@ program
78
78
  program
79
79
  .command('create')
80
80
  .description('Create a component directory')
81
+ .option('-i, --internal', 'varlet internal mode')
81
82
  .option('-n, --name <componentName>', 'Component name')
82
83
  .option('-s, --sfc', 'Generate files in sfc format')
83
84
  .option('-t, --tsx', 'Generate files in tsx format')
@@ -1,4 +1,5 @@
1
1
  export interface CreateCommandOptions {
2
+ internal?: boolean;
2
3
  name?: string;
3
4
  locale?: boolean;
4
5
  sfc?: boolean;
@@ -8,7 +8,7 @@ import { resolve } from 'path';
8
8
  import { glob } from '../shared/fsUtils.js';
9
9
  import { getVarletConfig } from '../config/varlet.config.js';
10
10
  import { SRC_DIR, dirname } from '../shared/constant.js';
11
- const { removeSync, readFileSync, copySync, pathExistsSync, writeFileSync } = fse;
11
+ const { removeSync, readFileSync, copySync, pathExistsSync, writeFileSync, renameSync } = fse;
12
12
  const { prompt } = inquirer;
13
13
  async function renderTemplates(componentFolder, componentFolderName, renderData) {
14
14
  const templates = await glob(`${componentFolder}/**/*.ejs`);
@@ -78,6 +78,13 @@ export async function create(options) {
78
78
  }
79
79
  copySync(resolve(dirname, '../../../template/create'), componentFolder);
80
80
  await renderTemplates(componentFolder, componentFolderName, renderData);
81
+ if (options.internal) {
82
+ removeSync(resolve(componentFolder, './example/locale/index.ts'));
83
+ renameSync(resolve(componentFolder, './example/locale/_index.ts'), resolve(componentFolder, './example/locale/index.ts'));
84
+ }
85
+ else {
86
+ removeSync(resolve(componentFolder, './example/locale/_index.ts'));
87
+ }
81
88
  if (!renderData.locale) {
82
89
  removeSync(resolve(componentFolder, '/example/locale'));
83
90
  }
@@ -53,7 +53,7 @@ export async function icons() {
53
53
  const varletConfig = await getVarletConfig();
54
54
  const { name, namespace, base64, publicPath, fontFamilyClassName, fontWeight, fontStyle } = get(varletConfig, 'icons');
55
55
  await removeDir();
56
- const svgFiles = readdirSync(ICONS_SVG_DIR);
56
+ const svgFiles = readdirSync(ICONS_SVG_DIR).filter((svgFile) => svgFile.startsWith('u') && svgFile.endsWith('.svg'));
57
57
  const [{ ttf }] = await Promise.all([buildWebFont(name), buildPNG(svgFiles)]);
58
58
  const icons = svgFiles.map((svgName) => {
59
59
  const i = svgName.indexOf('-');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "2.19.3",
3
+ "version": "2.20.0-alpha.1701880061001",
4
4
  "type": "module",
5
5
  "description": "cli of varlet",
6
6
  "bin": {
@@ -64,8 +64,8 @@
64
64
  "vite": "4.3.5",
65
65
  "vue": "3.3.4",
66
66
  "webfont": "^9.0.0",
67
- "@varlet/shared": "2.19.3",
68
- "@varlet/vite-plugins": "2.19.3"
67
+ "@varlet/shared": "2.20.0-alpha.1701880061001",
68
+ "@varlet/vite-plugins": "2.20.0-alpha.1701880061001"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/babel__core": "^7.20.1",
@@ -80,9 +80,9 @@
80
80
  "@types/semver": "^7.3.9",
81
81
  "@types/sharp": "0.31.1",
82
82
  "rimraf": "^5.0.1",
83
- "@varlet/icons": "2.19.3",
84
- "@varlet/ui": "2.19.3",
85
- "@varlet/touch-emulator": "2.19.3"
83
+ "@varlet/icons": "2.20.0-alpha.1701880061001",
84
+ "@varlet/ui": "2.20.0-alpha.1701880061001",
85
+ "@varlet/touch-emulator": "2.20.0-alpha.1701880061001"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "@vue/runtime-core": "3.3.4",
@@ -95,9 +95,9 @@
95
95
  "lodash-es": "^4.17.21",
96
96
  "vue": "3.3.4",
97
97
  "vue-router": "4.2.0",
98
- "@varlet/ui": "2.19.3",
99
- "@varlet/icons": "2.19.3",
100
- "@varlet/touch-emulator": "2.19.3"
98
+ "@varlet/icons": "2.20.0-alpha.1701880061001",
99
+ "@varlet/ui": "2.20.0-alpha.1701880061001",
100
+ "@varlet/touch-emulator": "2.20.0-alpha.1701880061001"
101
101
  },
102
102
  "scripts": {
103
103
  "dev": "tsc --watch",
@@ -0,0 +1,17 @@
1
+ import { Locale } from '@varlet/ui'
2
+ import zhCN from './zh-CN'
3
+ import enUS from './en-US'
4
+
5
+ const { add, use: exampleUse, pack, packs, merge } = Locale.useLocale()
6
+
7
+ const use = (lang: string) => {
8
+ Locale.use(lang)
9
+ exampleUse(lang)
10
+ }
11
+
12
+ Locale.add('zh-CN', Locale.zhCN)
13
+ Locale.add('en-US', Locale.enUS)
14
+ add('zh-CN', zhCN as any)
15
+ add('en-US', enUS as any)
16
+
17
+ export { add, pack, packs, merge, use }
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  // lib
2
3
  import _zhCN from '../../../locale/zh-CN'
3
4
  import _enCN from '../../../locale/en-US'