@varlet/cli 2.1.0-alpha.1667210582672 → 2.1.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.
Files changed (90) hide show
  1. package/lib/client/appType.d.ts +4 -4
  2. package/lib/client/appType.js +7 -7
  3. package/lib/client/index.d.ts +17 -17
  4. package/lib/client/index.js +106 -106
  5. package/lib/node/bin.d.ts +2 -2
  6. package/lib/node/bin.js +122 -122
  7. package/lib/node/commands/build.d.ts +1 -1
  8. package/lib/node/commands/build.js +15 -15
  9. package/lib/node/commands/changelog.d.ts +6 -6
  10. package/lib/node/commands/changelog.js +20 -20
  11. package/lib/node/commands/commitLint.d.ts +1 -1
  12. package/lib/node/commands/commitLint.js +16 -16
  13. package/lib/node/commands/compile.d.ts +7 -7
  14. package/lib/node/commands/compile.js +35 -35
  15. package/lib/node/commands/create.d.ts +8 -8
  16. package/lib/node/commands/create.js +91 -91
  17. package/lib/node/commands/dev.d.ts +5 -5
  18. package/lib/node/commands/dev.js +38 -38
  19. package/lib/node/commands/gen.d.ts +8 -8
  20. package/lib/node/commands/gen.js +69 -68
  21. package/lib/node/commands/jest.d.ts +8 -8
  22. package/lib/node/commands/jest.js +27 -27
  23. package/lib/node/commands/lint.d.ts +1 -1
  24. package/lib/node/commands/lint.js +42 -42
  25. package/lib/node/commands/preview.d.ts +1 -1
  26. package/lib/node/commands/preview.js +18 -18
  27. package/lib/node/commands/release.d.ts +5 -5
  28. package/lib/node/commands/release.js +146 -146
  29. package/lib/node/commands/vite.d.ts +3 -3
  30. package/lib/node/commands/vite.js +13 -13
  31. package/lib/node/compiler/compileModule.d.ts +5 -5
  32. package/lib/node/compiler/compileModule.js +74 -74
  33. package/lib/node/compiler/compileSFC.d.ts +2 -2
  34. package/lib/node/compiler/compileSFC.js +74 -74
  35. package/lib/node/compiler/compileScript.d.ts +17 -17
  36. package/lib/node/compiler/compileScript.js +95 -95
  37. package/lib/node/compiler/compileSiteEntry.d.ts +13 -13
  38. package/lib/node/compiler/compileSiteEntry.js +95 -95
  39. package/lib/node/compiler/compileStyle.d.ts +11 -11
  40. package/lib/node/compiler/compileStyle.js +39 -39
  41. package/lib/node/compiler/compileTemplateHighlight.d.ts +10 -10
  42. package/lib/node/compiler/compileTemplateHighlight.js +133 -133
  43. package/lib/node/compiler/compileTypes.d.ts +2 -2
  44. package/lib/node/compiler/compileTypes.js +30 -30
  45. package/lib/node/config/varlet.config.d.ts +45 -45
  46. package/lib/node/config/varlet.config.js +27 -27
  47. package/lib/node/config/varlet.default.config.d.ts +2 -2
  48. package/lib/node/config/varlet.default.config.js +264 -264
  49. package/lib/node/config/vite.config.d.ts +6 -6
  50. package/lib/node/config/vite.config.js +142 -142
  51. package/lib/node/index.d.ts +1 -1
  52. package/lib/node/index.js +1 -1
  53. package/lib/node/shared/constant.d.ts +42 -42
  54. package/lib/node/shared/constant.js +47 -47
  55. package/lib/node/shared/fsUtils.d.ts +13 -13
  56. package/lib/node/shared/fsUtils.js +48 -48
  57. package/lib/node/shared/logger.d.ts +8 -8
  58. package/lib/node/shared/logger.js +18 -18
  59. package/package.json +7 -7
  60. package/site/components/button/index.ts +10 -10
  61. package/site/components/cell/index.ts +10 -10
  62. package/site/components/code-example/codeExample.less +41 -41
  63. package/site/components/code-example/index.ts +10 -10
  64. package/site/components/context/zIndex.ts +20 -20
  65. package/site/components/icon/icon.less +26 -26
  66. package/site/components/icon/index.ts +10 -10
  67. package/site/components/icon/props.ts +24 -24
  68. package/site/components/loading/index.ts +10 -10
  69. package/site/components/progress/index.ts +10 -10
  70. package/site/components/snackbar/snackbar.less +135 -135
  71. package/site/components/styles/common.less +64 -64
  72. package/site/components/styles/elevation.less +126 -126
  73. package/site/components/styles/var.less +27 -27
  74. package/site/index.html +49 -49
  75. package/site/mobile/components/app-bar/index.ts +10 -10
  76. package/site/mobile/components/app-bar/props.ts +25 -25
  77. package/site/mobile.html +41 -41
  78. package/site/module.d.ts +5 -5
  79. package/site/tsconfig.json +11 -11
  80. package/template/create/example/index.vue.ejs +4 -2
  81. package/template/generators/base/_gitignore +5 -1
  82. package/template/generators/base/babel.config.js +1 -1
  83. package/template/generators/config/default/sfc/src/button/example/index.vue +1 -1
  84. package/template/generators/config/default/tsx/src/button/example/index.vue +1 -1
  85. package/template/generators/config/i18n/sfc/src/button/example/BasicUse.vue +1 -1
  86. package/template/generators/config/i18n/sfc/src/button/example/ModifyColor.vue +1 -1
  87. package/template/generators/config/i18n/sfc/src/button/example/index.vue +1 -2
  88. package/template/generators/config/i18n/tsx/src/button/example/BasicUse.vue +1 -1
  89. package/template/generators/config/i18n/tsx/src/button/example/ModifyColor.vue +1 -1
  90. package/template/generators/config/i18n/tsx/src/button/example/index.vue +1 -2
@@ -1,4 +1,4 @@
1
- declare const _default: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
2
- [key: string]: any;
3
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{} & {} & {}>, {}>;
4
- export default _default;
1
+ declare const _default: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
2
+ [key: string]: any;
3
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{} & {} & {}>, {}>;
4
+ export default _default;
@@ -1,7 +1,7 @@
1
- import { defineComponent, h } from 'vue';
2
- export default defineComponent({
3
- name: 'AppType',
4
- setup(props, { slots }) {
5
- return () => { var _a; return h('div', { class: 'app-type' }, [(_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)]); };
6
- },
7
- });
1
+ import { defineComponent, h } from 'vue';
2
+ export default defineComponent({
3
+ name: 'AppType',
4
+ setup(props, { slots }) {
5
+ return () => { var _a; return h('div', { class: 'app-type' }, [(_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)]); };
6
+ },
7
+ });
@@ -1,17 +1,17 @@
1
- import AppType from './appType';
2
- interface PCLocationInfo {
3
- language: string;
4
- menuName: string;
5
- }
6
- export declare type Theme = 'lightTheme' | 'darkTheme';
7
- export declare type StyleVars = Record<string, string>;
8
- export declare function StyleProvider(styleVars?: StyleVars | null): void;
9
- export declare function getPCLocationInfo(): PCLocationInfo;
10
- export declare function getBrowserTheme(): Theme;
11
- export declare function watchLang(cb: (lang: string) => void, platform?: 'pc' | 'mobile'): void;
12
- export declare function withSiteConfigNamespace(styleVars: Record<string, any>): StyleVars;
13
- export declare function watchPlatform(cb: (platform: string) => void): void;
14
- export declare function useRouteListener(cb: () => void): void;
15
- export declare function watchDarkMode(dark: StyleVars, cb?: (theme: Theme) => void): void;
16
- export declare function watchTheme(cb: (theme: Theme, from: 'pc' | 'mobile' | 'default' | 'playground') => void, shouldUnmount?: boolean): void;
17
- export { AppType };
1
+ import AppType from './appType';
2
+ interface PCLocationInfo {
3
+ language: string;
4
+ menuName: string;
5
+ }
6
+ export declare type Theme = 'lightTheme' | 'darkTheme';
7
+ export declare type StyleVars = Record<string, string>;
8
+ export declare function StyleProvider(styleVars?: StyleVars | null): void;
9
+ export declare function getPCLocationInfo(): PCLocationInfo;
10
+ export declare function getBrowserTheme(): Theme;
11
+ export declare function watchLang(cb: (lang: string) => void, platform?: 'pc' | 'mobile'): void;
12
+ export declare function withSiteConfigNamespace(styleVars: Record<string, any>): StyleVars;
13
+ export declare function watchPlatform(cb: (platform: string) => void): void;
14
+ export declare function useRouteListener(cb: () => void): void;
15
+ export declare function watchDarkMode(dark: StyleVars, cb?: (theme: Theme) => void): void;
16
+ export declare function watchTheme(cb: (theme: Theme, from: 'pc' | 'mobile' | 'default' | 'playground') => void, shouldUnmount?: boolean): void;
17
+ export { AppType };
@@ -1,106 +1,106 @@
1
- import config from '@config';
2
- import AppType from './appType';
3
- import { onMounted, onUnmounted } from 'vue';
4
- import { kebabCase } from '@varlet/shared';
5
- import { get } from 'lodash-es';
6
- const mountedVarKeys = [];
7
- function formatStyleVars(styleVars) {
8
- return Object.entries(styleVars !== null && styleVars !== void 0 ? styleVars : {}).reduce((styles, [key, value]) => {
9
- const cssVar = key.startsWith('--') ? key : `--${kebabCase(key)}`;
10
- styles[cssVar] = value;
11
- return styles;
12
- }, {});
13
- }
14
- export function StyleProvider(styleVars = {}) {
15
- mountedVarKeys.forEach((key) => document.documentElement.style.removeProperty(key));
16
- mountedVarKeys.length = 0;
17
- const styles = formatStyleVars(styleVars);
18
- Object.entries(styles).forEach(([key, value]) => {
19
- document.documentElement.style.setProperty(key, value);
20
- mountedVarKeys.push(key);
21
- });
22
- }
23
- export function getPCLocationInfo() {
24
- const [, language, menuName] = window.location.hash.split('/');
25
- return {
26
- language,
27
- menuName,
28
- };
29
- }
30
- function getHashSearch() {
31
- const { href } = window.location;
32
- const hashSearch = href.slice(href.indexOf('?'));
33
- return new URLSearchParams(hashSearch);
34
- }
35
- export function getBrowserTheme() {
36
- var _a;
37
- const themeKey = get(config, 'themeKey');
38
- const darkThemeConfig = get(config, 'darkTheme');
39
- if (!darkThemeConfig) {
40
- return 'lightTheme';
41
- }
42
- const storageTheme = window.localStorage.getItem(themeKey);
43
- if (!storageTheme) {
44
- const preferTheme = ((_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, '(prefers-color-scheme: dark)').matches) ? 'darkTheme' : 'lightTheme';
45
- window.localStorage.setItem(themeKey, preferTheme);
46
- return preferTheme;
47
- }
48
- return storageTheme;
49
- }
50
- export function watchLang(cb, platform = 'mobile') {
51
- const handleHashchange = () => {
52
- var _a;
53
- const language = platform === 'mobile' ? (_a = getHashSearch().get('language')) !== null && _a !== void 0 ? _a : 'zh-CN' : getPCLocationInfo().language;
54
- cb(language);
55
- };
56
- useRouteListener(handleHashchange);
57
- handleHashchange();
58
- }
59
- export function withSiteConfigNamespace(styleVars) {
60
- return Object.entries(styleVars).reduce((styleVars, [key, value]) => {
61
- styleVars[`--site-config-${key}`] = value;
62
- return styleVars;
63
- }, {});
64
- }
65
- export function watchPlatform(cb) {
66
- const handleHashchange = () => {
67
- var _a;
68
- const platform = (_a = getHashSearch().get('platform')) !== null && _a !== void 0 ? _a : 'mobile';
69
- cb(platform);
70
- };
71
- useRouteListener(handleHashchange);
72
- handleHashchange();
73
- }
74
- export function useRouteListener(cb) {
75
- onMounted(() => {
76
- window.addEventListener('hashchange', cb);
77
- window.addEventListener('popstate', cb);
78
- });
79
- onUnmounted(() => {
80
- window.removeEventListener('hashchange', cb);
81
- window.removeEventListener('popstate', cb);
82
- });
83
- }
84
- export function watchDarkMode(dark, cb) {
85
- watchTheme((theme) => {
86
- const siteStyleVars = withSiteConfigNamespace(get(config, theme, {}));
87
- StyleProvider(theme === 'darkTheme' ? Object.assign(Object.assign({}, siteStyleVars), dark) : siteStyleVars);
88
- cb === null || cb === void 0 ? void 0 : cb(theme);
89
- });
90
- }
91
- export function watchTheme(cb, shouldUnmount = true) {
92
- const handleThemeChange = (event) => {
93
- const { data } = event;
94
- if (data.action === 'theme-change') {
95
- cb(data.data, data.from);
96
- }
97
- };
98
- window.addEventListener('message', handleThemeChange);
99
- if (shouldUnmount) {
100
- onUnmounted(() => {
101
- window.removeEventListener('message', handleThemeChange);
102
- });
103
- }
104
- cb(getBrowserTheme(), 'default');
105
- }
106
- export { AppType };
1
+ import config from '@config';
2
+ import AppType from './appType';
3
+ import { onMounted, onUnmounted } from 'vue';
4
+ import { kebabCase } from '@varlet/shared';
5
+ import { get } from 'lodash-es';
6
+ const mountedVarKeys = [];
7
+ function formatStyleVars(styleVars) {
8
+ return Object.entries(styleVars !== null && styleVars !== void 0 ? styleVars : {}).reduce((styles, [key, value]) => {
9
+ const cssVar = key.startsWith('--') ? key : `--${kebabCase(key)}`;
10
+ styles[cssVar] = value;
11
+ return styles;
12
+ }, {});
13
+ }
14
+ export function StyleProvider(styleVars = {}) {
15
+ mountedVarKeys.forEach((key) => document.documentElement.style.removeProperty(key));
16
+ mountedVarKeys.length = 0;
17
+ const styles = formatStyleVars(styleVars);
18
+ Object.entries(styles).forEach(([key, value]) => {
19
+ document.documentElement.style.setProperty(key, value);
20
+ mountedVarKeys.push(key);
21
+ });
22
+ }
23
+ export function getPCLocationInfo() {
24
+ const [, language, menuName] = window.location.hash.split('/');
25
+ return {
26
+ language,
27
+ menuName,
28
+ };
29
+ }
30
+ function getHashSearch() {
31
+ const { href } = window.location;
32
+ const hashSearch = href.slice(href.indexOf('?'));
33
+ return new URLSearchParams(hashSearch);
34
+ }
35
+ export function getBrowserTheme() {
36
+ var _a;
37
+ const themeKey = get(config, 'themeKey');
38
+ const darkThemeConfig = get(config, 'darkTheme');
39
+ if (!darkThemeConfig) {
40
+ return 'lightTheme';
41
+ }
42
+ const storageTheme = window.localStorage.getItem(themeKey);
43
+ if (!storageTheme) {
44
+ const preferTheme = ((_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, '(prefers-color-scheme: dark)').matches) ? 'darkTheme' : 'lightTheme';
45
+ window.localStorage.setItem(themeKey, preferTheme);
46
+ return preferTheme;
47
+ }
48
+ return storageTheme;
49
+ }
50
+ export function watchLang(cb, platform = 'mobile') {
51
+ const handleHashchange = () => {
52
+ var _a;
53
+ const language = platform === 'mobile' ? (_a = getHashSearch().get('language')) !== null && _a !== void 0 ? _a : 'zh-CN' : getPCLocationInfo().language;
54
+ cb(language);
55
+ };
56
+ useRouteListener(handleHashchange);
57
+ handleHashchange();
58
+ }
59
+ export function withSiteConfigNamespace(styleVars) {
60
+ return Object.entries(styleVars).reduce((styleVars, [key, value]) => {
61
+ styleVars[`--site-config-${key}`] = value;
62
+ return styleVars;
63
+ }, {});
64
+ }
65
+ export function watchPlatform(cb) {
66
+ const handleHashchange = () => {
67
+ var _a;
68
+ const platform = (_a = getHashSearch().get('platform')) !== null && _a !== void 0 ? _a : 'mobile';
69
+ cb(platform);
70
+ };
71
+ useRouteListener(handleHashchange);
72
+ handleHashchange();
73
+ }
74
+ export function useRouteListener(cb) {
75
+ onMounted(() => {
76
+ window.addEventListener('hashchange', cb);
77
+ window.addEventListener('popstate', cb);
78
+ });
79
+ onUnmounted(() => {
80
+ window.removeEventListener('hashchange', cb);
81
+ window.removeEventListener('popstate', cb);
82
+ });
83
+ }
84
+ export function watchDarkMode(dark, cb) {
85
+ watchTheme((theme) => {
86
+ const siteStyleVars = withSiteConfigNamespace(get(config, theme, {}));
87
+ StyleProvider(theme === 'darkTheme' ? Object.assign(Object.assign({}, siteStyleVars), dark) : siteStyleVars);
88
+ cb === null || cb === void 0 ? void 0 : cb(theme);
89
+ });
90
+ }
91
+ export function watchTheme(cb, shouldUnmount = true) {
92
+ const handleThemeChange = (event) => {
93
+ const { data } = event;
94
+ if (data.action === 'theme-change') {
95
+ cb(data.data, data.from);
96
+ }
97
+ };
98
+ window.addEventListener('message', handleThemeChange);
99
+ if (shouldUnmount) {
100
+ onUnmounted(() => {
101
+ window.removeEventListener('message', handleThemeChange);
102
+ });
103
+ }
104
+ cb(getBrowserTheme(), 'default');
105
+ }
106
+ export { AppType };
package/lib/node/bin.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ #!/usr/bin/env node
2
+ export {};
package/lib/node/bin.js CHANGED
@@ -1,122 +1,122 @@
1
- #!/usr/bin/env node
2
- import fse from 'fs-extra';
3
- import { Command } from 'commander';
4
- import { CLI_PACKAGE_JSON } from './shared/constant.js';
5
- const { readJSONSync } = fse;
6
- const program = new Command();
7
- program.version(`varlet-cli ${readJSONSync(CLI_PACKAGE_JSON).version}`).usage('<command> [options]');
8
- program
9
- .command('dev')
10
- .option('-f --force', 'Force dep pre-optimization regardless of whether deps have changed')
11
- .description('Run varlet development environment')
12
- .action(async (options) => {
13
- const { dev } = await import('./commands/dev.js');
14
- return dev(options);
15
- });
16
- program
17
- .command('build')
18
- .description('Build varlet site for production')
19
- .action(async () => {
20
- const { build } = await import('./commands/build.js');
21
- return build();
22
- });
23
- program
24
- .command('build:vite')
25
- .description('Use vite build app for production')
26
- .action(async () => {
27
- const { vite } = await import('./commands/vite.js');
28
- return vite('build');
29
- });
30
- program
31
- .command('dev:vite')
32
- .description('Use vite start server for development')
33
- .action(async () => {
34
- const { vite } = await import('./commands/vite.js');
35
- return vite('dev');
36
- });
37
- program
38
- .command('preview')
39
- .description('Preview varlet site for production')
40
- .action(async () => {
41
- const { preview } = await import('./commands/preview.js');
42
- return preview();
43
- });
44
- program
45
- .command('compile')
46
- .description('Compile varlet components library code')
47
- .option('-nu, --noUmd', 'Do not compile umd target code')
48
- .action(async (options) => {
49
- const { compile } = await import('./commands/compile.js');
50
- return compile(options);
51
- });
52
- program
53
- .command('lint')
54
- .description('Lint code')
55
- .action(async () => {
56
- const { lint } = await import('./commands/lint.js');
57
- return lint();
58
- });
59
- program
60
- .command('create')
61
- .description('Create a component directory')
62
- .option('-n, --name <componentName>', 'Component name')
63
- .option('-s, --sfc', 'Generate files in sfc format')
64
- .option('-t, --tsx', 'Generate files in tsx format')
65
- .option('-l, --locale', 'Generator internationalized files')
66
- .action(async (options) => {
67
- const { create } = await import('./commands/create.js');
68
- return create(options);
69
- });
70
- program
71
- .command('jest')
72
- .description('Run Jest in work directory')
73
- .option('-w, --watch', 'Watch files for changes and rerun tests related to changed files')
74
- .option('-wa, --watchAll', 'Watch files for changes and rerun all tests when something changes')
75
- .option('-c, --component <componentName>', 'Test a specific component')
76
- .option('-cc --clearCache', 'Clear test cache')
77
- .action(async (option) => {
78
- const { jest } = await import('./commands/jest.js');
79
- return jest(option);
80
- });
81
- program
82
- .command('gen')
83
- .description('Generate cli application')
84
- .option('-n, --name <applicationName>', 'Application name')
85
- .option('-s, --sfc', 'Generate files in sfc format')
86
- .option('-t, --tsx', 'Generate files in tsx format')
87
- .option('-l, --locale', 'Generator internationalized files')
88
- .action(async (option) => {
89
- const { gen } = await import('./commands/gen.js');
90
- return gen(option);
91
- });
92
- program
93
- .command('changelog')
94
- .option('-rc --releaseCount <releaseCount>', 'Release count')
95
- .option('-f --file <file>', 'Changelog filename')
96
- .description('Generate changelog')
97
- .action(async (option) => {
98
- const { changelog } = await import('./commands/changelog.js');
99
- return changelog(option);
100
- });
101
- program
102
- .command('release')
103
- .option('-r --remote <remote>', 'Remote name')
104
- .description('Release all packages and generate changelogs')
105
- .action(async (option) => {
106
- const { release } = await import('./commands/release.js');
107
- return release(option);
108
- });
109
- program
110
- .command('commit-lint <gitParams>')
111
- .description('Lint commit message')
112
- .action(async (option) => {
113
- const { commitLint } = await import('./commands/commitLint.js');
114
- return commitLint(option);
115
- });
116
- program.on('command:*', async ([cmd]) => {
117
- const { default: logger } = await import('./shared/logger.js');
118
- program.outputHelp();
119
- logger.error(`\nUnknown command ${cmd}.\n`);
120
- process.exitCode = 1;
121
- });
122
- program.parse();
1
+ #!/usr/bin/env node
2
+ import fse from 'fs-extra';
3
+ import { Command } from 'commander';
4
+ import { CLI_PACKAGE_JSON } from './shared/constant.js';
5
+ const { readJSONSync } = fse;
6
+ const program = new Command();
7
+ program.version(`varlet-cli ${readJSONSync(CLI_PACKAGE_JSON).version}`).usage('<command> [options]');
8
+ program
9
+ .command('dev')
10
+ .option('-f --force', 'Force dep pre-optimization regardless of whether deps have changed')
11
+ .description('Run varlet development environment')
12
+ .action(async (options) => {
13
+ const { dev } = await import('./commands/dev.js');
14
+ return dev(options);
15
+ });
16
+ program
17
+ .command('build')
18
+ .description('Build varlet site for production')
19
+ .action(async () => {
20
+ const { build } = await import('./commands/build.js');
21
+ return build();
22
+ });
23
+ program
24
+ .command('build:vite')
25
+ .description('Use vite build app for production')
26
+ .action(async () => {
27
+ const { vite } = await import('./commands/vite.js');
28
+ return vite('build');
29
+ });
30
+ program
31
+ .command('dev:vite')
32
+ .description('Use vite start server for development')
33
+ .action(async () => {
34
+ const { vite } = await import('./commands/vite.js');
35
+ return vite('dev');
36
+ });
37
+ program
38
+ .command('preview')
39
+ .description('Preview varlet site for production')
40
+ .action(async () => {
41
+ const { preview } = await import('./commands/preview.js');
42
+ return preview();
43
+ });
44
+ program
45
+ .command('compile')
46
+ .description('Compile varlet components library code')
47
+ .option('-nu, --noUmd', 'Do not compile umd target code')
48
+ .action(async (options) => {
49
+ const { compile } = await import('./commands/compile.js');
50
+ return compile(options);
51
+ });
52
+ program
53
+ .command('lint')
54
+ .description('Lint code')
55
+ .action(async () => {
56
+ const { lint } = await import('./commands/lint.js');
57
+ return lint();
58
+ });
59
+ program
60
+ .command('create')
61
+ .description('Create a component directory')
62
+ .option('-n, --name <componentName>', 'Component name')
63
+ .option('-s, --sfc', 'Generate files in sfc format')
64
+ .option('-t, --tsx', 'Generate files in tsx format')
65
+ .option('-l, --locale', 'Generator internationalized files')
66
+ .action(async (options) => {
67
+ const { create } = await import('./commands/create.js');
68
+ return create(options);
69
+ });
70
+ program
71
+ .command('jest')
72
+ .description('Run Jest in work directory')
73
+ .option('-w, --watch', 'Watch files for changes and rerun tests related to changed files')
74
+ .option('-wa, --watchAll', 'Watch files for changes and rerun all tests when something changes')
75
+ .option('-c, --component <componentName>', 'Test a specific component')
76
+ .option('-cc --clearCache', 'Clear test cache')
77
+ .action(async (option) => {
78
+ const { jest } = await import('./commands/jest.js');
79
+ return jest(option);
80
+ });
81
+ program
82
+ .command('gen')
83
+ .description('Generate cli application')
84
+ .option('-n, --name <applicationName>', 'Application name')
85
+ .option('-s, --sfc', 'Generate files in sfc format')
86
+ .option('-t, --tsx', 'Generate files in tsx format')
87
+ .option('-l, --locale', 'Generator internationalized files')
88
+ .action(async (option) => {
89
+ const { gen } = await import('./commands/gen.js');
90
+ return gen(option);
91
+ });
92
+ program
93
+ .command('changelog')
94
+ .option('-rc --releaseCount <releaseCount>', 'Release count')
95
+ .option('-f --file <file>', 'Changelog filename')
96
+ .description('Generate changelog')
97
+ .action(async (option) => {
98
+ const { changelog } = await import('./commands/changelog.js');
99
+ return changelog(option);
100
+ });
101
+ program
102
+ .command('release')
103
+ .option('-r --remote <remote>', 'Remote name')
104
+ .description('Release all packages and generate changelogs')
105
+ .action(async (option) => {
106
+ const { release } = await import('./commands/release.js');
107
+ return release(option);
108
+ });
109
+ program
110
+ .command('commit-lint <gitParams>')
111
+ .description('Lint commit message')
112
+ .action(async (option) => {
113
+ const { commitLint } = await import('./commands/commitLint.js');
114
+ return commitLint(option);
115
+ });
116
+ program.on('command:*', async ([cmd]) => {
117
+ const { default: logger } = await import('./shared/logger.js');
118
+ program.outputHelp();
119
+ logger.error(`\nUnknown command ${cmd}.\n`);
120
+ process.exitCode = 1;
121
+ });
122
+ program.parse();
@@ -1 +1 @@
1
- export declare function build(): Promise<void>;
1
+ export declare function build(): Promise<void>;
@@ -1,15 +1,15 @@
1
- import fse from 'fs-extra';
2
- import { SRC_DIR } from '../shared/constant.js';
3
- import { build as buildVite } from 'vite';
4
- import { getBuildConfig } from '../config/vite.config.js';
5
- import { getVarletConfig } from '../config/varlet.config.js';
6
- import { buildSiteEntry } from '../compiler/compileSiteEntry.js';
7
- const { ensureDirSync } = fse;
8
- export async function build() {
9
- process.env.NODE_ENV = 'production';
10
- ensureDirSync(SRC_DIR);
11
- await buildSiteEntry();
12
- const varletConfig = await getVarletConfig();
13
- const buildConfig = getBuildConfig(varletConfig);
14
- await buildVite(buildConfig);
15
- }
1
+ import fse from 'fs-extra';
2
+ import { SRC_DIR } from '../shared/constant.js';
3
+ import { build as buildVite } from 'vite';
4
+ import { getBuildConfig } from '../config/vite.config.js';
5
+ import { getVarletConfig } from '../config/varlet.config.js';
6
+ import { buildSiteEntry } from '../compiler/compileSiteEntry.js';
7
+ const { ensureDirSync } = fse;
8
+ export async function build() {
9
+ process.env.NODE_ENV = 'production';
10
+ ensureDirSync(SRC_DIR);
11
+ await buildSiteEntry();
12
+ const varletConfig = await getVarletConfig();
13
+ const buildConfig = getBuildConfig(varletConfig);
14
+ await buildVite(buildConfig);
15
+ }
@@ -1,6 +1,6 @@
1
- interface ChangelogCommandOptions {
2
- file?: string;
3
- releaseCount?: number;
4
- }
5
- export declare function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>;
6
- export {};
1
+ interface ChangelogCommandOptions {
2
+ file?: string;
3
+ releaseCount?: number;
4
+ }
5
+ export declare function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>;
6
+ export {};
@@ -1,20 +1,20 @@
1
- import ora from 'ora';
2
- import conventionalChangelog from 'conventional-changelog';
3
- import fse from 'fs-extra';
4
- import { resolve as resolvePath } from 'path';
5
- import { CWD } from '../shared/constant.js';
6
- const { createWriteStream } = fse;
7
- export function changelog({ releaseCount = 0, file = 'CHANGELOG.md' } = {}) {
8
- const s = ora().start(`Generating changelog`);
9
- return new Promise((resolve) => {
10
- conventionalChangelog({
11
- preset: 'angular',
12
- releaseCount,
13
- })
14
- .pipe(createWriteStream(resolvePath(CWD, file)))
15
- .on('close', () => {
16
- s.succeed(`Changelog generated success!`);
17
- resolve();
18
- });
19
- });
20
- }
1
+ import ora from 'ora';
2
+ import conventionalChangelog from 'conventional-changelog';
3
+ import fse from 'fs-extra';
4
+ import { resolve as resolvePath } from 'path';
5
+ import { CWD } from '../shared/constant.js';
6
+ const { createWriteStream } = fse;
7
+ export function changelog({ releaseCount = 0, file = 'CHANGELOG.md' } = {}) {
8
+ const s = ora().start(`Generating changelog`);
9
+ return new Promise((resolve) => {
10
+ conventionalChangelog({
11
+ preset: 'angular',
12
+ releaseCount,
13
+ })
14
+ .pipe(createWriteStream(resolvePath(CWD, file)))
15
+ .on('close', () => {
16
+ s.succeed(`Changelog generated success!`);
17
+ resolve();
18
+ });
19
+ });
20
+ }
@@ -1 +1 @@
1
- export declare function commitLint(gitParams: string): void;
1
+ export declare function commitLint(gitParams: string): void;