@varlet/cli 2.19.3 → 2.20.0

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')
@@ -128,7 +129,7 @@ program
128
129
  .command('commit-lint <gitParams>')
129
130
  .description('Lint commit message')
130
131
  .action(async (options) => {
131
- const { commitLint } = await import('./commands/commitLint.js');
132
+ const { commitLint } = await import('@varlet/release');
132
133
  return commitLint(options);
133
134
  });
134
135
  program
@@ -2,7 +2,7 @@ import fse from 'fs-extra';
2
2
  import markdownIt from 'markdown-it';
3
3
  import logger from '../shared/logger.js';
4
4
  import { CHECKLIST_FILE } from '../shared/constant.js';
5
- import { COMMIT_MESSAGE_RE, isVersionCommitMessage, getCommitMessage } from './commitLint.js';
5
+ import { COMMIT_MESSAGE_RE, isVersionCommitMessage, getCommitMessage } from '@varlet/release';
6
6
  const { readFileSync, existsSync } = fse;
7
7
  const blockRE = /<h3>(.|\n|\r)+?<\/ul>/g;
8
8
  const typeRE = /<h3>(.+)<\/h3>/;
@@ -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('-');
@@ -3,7 +3,6 @@ export * from '@varlet/release';
3
3
  export * from './commands/dev.js';
4
4
  export * from './commands/build.js';
5
5
  export * from './commands/compile.js';
6
- export * from './commands/commitLint.js';
7
6
  export * from './commands/gen.js';
8
7
  export * from './commands/test.js';
9
8
  export * from './commands/create.js';
package/lib/node/index.js CHANGED
@@ -3,7 +3,6 @@ export * from '@varlet/release';
3
3
  export * from './commands/dev.js';
4
4
  export * from './commands/build.js';
5
5
  export * from './commands/compile.js';
6
- export * from './commands/commitLint.js';
7
6
  export * from './commands/gen.js';
8
7
  export * from './commands/test.js';
9
8
  export * from './commands/create.js';
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",
4
4
  "type": "module",
5
5
  "description": "cli of varlet",
6
6
  "bin": {
@@ -34,7 +34,7 @@
34
34
  "url": "https://github.com/varletjs/varlet/issues"
35
35
  },
36
36
  "dependencies": {
37
- "@varlet/release": "0.0.3",
37
+ "@varlet/release": "^0.0.5",
38
38
  "@babel/core": "^7.22.5",
39
39
  "@babel/preset-typescript": "^7.22.5",
40
40
  "@vitejs/plugin-vue": "4.2.3",
@@ -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/vite-plugins": "2.20.0",
68
+ "@varlet/shared": "2.20.0"
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/ui": "2.20.0",
84
+ "@varlet/icons": "2.20.0",
85
+ "@varlet/touch-emulator": "2.20.0"
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",
99
+ "@varlet/ui": "2.20.0",
100
+ "@varlet/touch-emulator": "2.20.0"
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'
@@ -1,4 +0,0 @@
1
- export declare const COMMIT_MESSAGE_RE: RegExp;
2
- export declare function isVersionCommitMessage(message: string): string | false | null;
3
- export declare function getCommitMessage(gitParams: string): string;
4
- export declare function commitLint(gitParams: string): void;
@@ -1,48 +0,0 @@
1
- import logger from '../shared/logger.js';
2
- import semver from 'semver';
3
- import fse from 'fs-extra';
4
- const { readFileSync } = fse;
5
- export const COMMIT_MESSAGE_RE = /^(revert|fix|feat|docs|perf|test|types|style|build|chore|release|refactor)(\(.+\))?!?: (.|\n)+/;
6
- export function isVersionCommitMessage(message) {
7
- return message.startsWith('v') && semver.valid(message.slice(1));
8
- }
9
- export function getCommitMessage(gitParams) {
10
- return readFileSync(gitParams, 'utf-8').trim();
11
- }
12
- export function commitLint(gitParams) {
13
- const commitMessage = getCommitMessage(gitParams);
14
- if (!isVersionCommitMessage(commitMessage) && !COMMIT_MESSAGE_RE.test(commitMessage)) {
15
- logger.error(`Commit message invalid`);
16
- logger.warning(`\
17
- The rules for commit messages are as follows
18
-
19
- Example:
20
-
21
- feat: add a new feature
22
- feat(ui/button): add a new feature in the ui/button scope
23
-
24
- fix: fix a bug
25
- fix(ui/button): fix a bug in the ui/button scope
26
-
27
- docs: fix an error in the documentation
28
- docs(ui/button): fix a documentation error in the ui/button scope
29
-
30
- Allowed types:
31
- - fix
32
- - feat
33
- - docs
34
- - perf
35
- - test
36
- - types
37
- - style
38
- - build
39
- - chore
40
- - release
41
- - refactor
42
- - revert
43
-
44
- Commit message reference: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y
45
- 参考阮一峰Commit message编写指南: https://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html`);
46
- process.exit(1);
47
- }
48
- }