@varlet/cli 2.10.1-alpha.1682608027166 → 2.10.1-alpha.1682649094981

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 (67) 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 +18 -18
  4. package/lib/client/index.js +109 -109
  5. package/lib/node/bin.d.ts +2 -2
  6. package/lib/node/bin.js +148 -148
  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 +5 -5
  10. package/lib/node/commands/changelog.js +20 -20
  11. package/lib/node/commands/checklist.d.ts +6 -6
  12. package/lib/node/commands/checklist.js +64 -64
  13. package/lib/node/commands/commitLint.d.ts +4 -4
  14. package/lib/node/commands/commitLint.js +19 -19
  15. package/lib/node/commands/compile.d.ts +3 -3
  16. package/lib/node/commands/compile.js +31 -31
  17. package/lib/node/commands/create.d.ts +7 -7
  18. package/lib/node/commands/create.js +91 -91
  19. package/lib/node/commands/dev.d.ts +6 -6
  20. package/lib/node/commands/dev.js +42 -42
  21. package/lib/node/commands/extension.d.ts +3 -3
  22. package/lib/node/commands/extension.js +5 -5
  23. package/lib/node/commands/gen.d.ts +7 -7
  24. package/lib/node/commands/gen.js +68 -68
  25. package/lib/node/commands/icons.d.ts +1 -1
  26. package/lib/node/commands/icons.js +82 -82
  27. package/lib/node/commands/jest.d.ts +7 -7
  28. package/lib/node/commands/jest.js +27 -27
  29. package/lib/node/commands/lint.d.ts +1 -1
  30. package/lib/node/commands/lint.js +42 -42
  31. package/lib/node/commands/preview.d.ts +1 -1
  32. package/lib/node/commands/preview.js +18 -18
  33. package/lib/node/commands/release.d.ts +5 -5
  34. package/lib/node/commands/release.js +150 -150
  35. package/lib/node/commands/vite.d.ts +2 -2
  36. package/lib/node/commands/vite.js +14 -14
  37. package/lib/node/compiler/compileModule.d.ts +4 -4
  38. package/lib/node/compiler/compileModule.js +71 -71
  39. package/lib/node/compiler/compileSFC.d.ts +6 -6
  40. package/lib/node/compiler/compileSFC.js +98 -97
  41. package/lib/node/compiler/compileScript.d.ts +13 -13
  42. package/lib/node/compiler/compileScript.js +126 -126
  43. package/lib/node/compiler/compileSiteEntry.d.ts +18 -18
  44. package/lib/node/compiler/compileSiteEntry.js +121 -121
  45. package/lib/node/compiler/compileStyle.d.ts +10 -10
  46. package/lib/node/compiler/compileStyle.js +41 -41
  47. package/lib/node/compiler/compileTemplateHighlight.d.ts +18 -18
  48. package/lib/node/compiler/compileTemplateHighlight.js +128 -128
  49. package/lib/node/compiler/compileTypes.d.ts +2 -2
  50. package/lib/node/compiler/compileTypes.js +40 -40
  51. package/lib/node/config/varlet.config.d.ts +73 -73
  52. package/lib/node/config/varlet.config.js +27 -27
  53. package/lib/node/config/varlet.default.config.d.ts +2 -2
  54. package/lib/node/config/varlet.default.config.js +278 -271
  55. package/lib/node/config/vite.config.d.ts +13 -13
  56. package/lib/node/config/vite.config.js +119 -115
  57. package/lib/node/index.d.ts +15 -15
  58. package/lib/node/index.js +15 -15
  59. package/lib/node/shared/constant.d.ts +51 -51
  60. package/lib/node/shared/constant.js +58 -58
  61. package/lib/node/shared/fsUtils.d.ts +15 -15
  62. package/lib/node/shared/fsUtils.js +54 -54
  63. package/lib/node/shared/logger.d.ts +8 -8
  64. package/lib/node/shared/logger.js +18 -18
  65. package/package.json +7 -7
  66. package/site/index.html +3 -0
  67. package/site/mobile.html +3 -0
@@ -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,18 +1,18 @@
1
- import AppType from './appType';
2
- interface PCLocationInfo {
3
- language: string;
4
- menuName: string;
5
- hash: string;
6
- }
7
- export declare type Theme = 'lightTheme' | 'darkTheme';
8
- export declare type StyleVars = Record<string, string>;
9
- export declare function StyleProvider(styleVars?: StyleVars | null): void;
10
- export declare function getPCLocationInfo(): PCLocationInfo;
11
- export declare function getBrowserTheme(): Theme;
12
- export declare function watchLang(cb: (lang: string) => void, platform?: 'pc' | 'mobile'): void;
13
- export declare function withSiteConfigNamespace(styleVars: Record<string, any>): StyleVars;
14
- export declare function watchPlatform(cb: (platform: string) => void): void;
15
- export declare function useRouteListener(cb: () => void): void;
16
- export declare function watchDarkMode(dark: StyleVars, cb?: (theme: Theme) => void): void;
17
- export declare function watchTheme(cb: (theme: Theme, from: 'pc' | 'mobile' | 'default' | 'playground') => void, shouldUnmount?: boolean): void;
18
- export { AppType };
1
+ import AppType from './appType';
2
+ interface PCLocationInfo {
3
+ language: string;
4
+ menuName: string;
5
+ hash: string;
6
+ }
7
+ export declare type Theme = 'lightTheme' | 'darkTheme';
8
+ export declare type StyleVars = Record<string, string>;
9
+ export declare function StyleProvider(styleVars?: StyleVars | null): void;
10
+ export declare function getPCLocationInfo(): PCLocationInfo;
11
+ export declare function getBrowserTheme(): Theme;
12
+ export declare function watchLang(cb: (lang: string) => void, platform?: 'pc' | 'mobile'): void;
13
+ export declare function withSiteConfigNamespace(styleVars: Record<string, any>): StyleVars;
14
+ export declare function watchPlatform(cb: (platform: string) => void): void;
15
+ export declare function useRouteListener(cb: () => void): void;
16
+ export declare function watchDarkMode(dark: StyleVars, cb?: (theme: Theme) => void): void;
17
+ export declare function watchTheme(cb: (theme: Theme, from: 'pc' | 'mobile' | 'default' | 'playground') => void, shouldUnmount?: boolean): void;
18
+ export { AppType };
@@ -1,109 +1,109 @@
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
- var _a;
25
- const [, language, path] = window.location.hash.split('/');
26
- const [menuName, hash = ''] = (_a = path === null || path === void 0 ? void 0 : path.split('#')) !== null && _a !== void 0 ? _a : [];
27
- return {
28
- language,
29
- menuName,
30
- hash,
31
- };
32
- }
33
- function getHashSearch() {
34
- const { href } = window.location;
35
- const hashSearch = href.slice(href.indexOf('?'));
36
- return new URLSearchParams(hashSearch);
37
- }
38
- export function getBrowserTheme() {
39
- var _a;
40
- const themeKey = get(config, 'themeKey');
41
- const darkThemeConfig = get(config, 'darkTheme');
42
- if (!darkThemeConfig) {
43
- return 'lightTheme';
44
- }
45
- const storageTheme = window.localStorage.getItem(themeKey);
46
- if (!storageTheme) {
47
- const preferTheme = ((_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, '(prefers-color-scheme: dark)').matches) ? 'darkTheme' : 'lightTheme';
48
- window.localStorage.setItem(themeKey, preferTheme);
49
- return preferTheme;
50
- }
51
- return storageTheme;
52
- }
53
- export function watchLang(cb, platform = 'mobile') {
54
- const handleHashchange = () => {
55
- var _a;
56
- const language = platform === 'mobile' ? (_a = getHashSearch().get('language')) !== null && _a !== void 0 ? _a : 'zh-CN' : getPCLocationInfo().language;
57
- cb(language);
58
- };
59
- useRouteListener(handleHashchange);
60
- handleHashchange();
61
- }
62
- export function withSiteConfigNamespace(styleVars) {
63
- return Object.entries(styleVars).reduce((styleVars, [key, value]) => {
64
- styleVars[`--site-config-${key}`] = value;
65
- return styleVars;
66
- }, {});
67
- }
68
- export function watchPlatform(cb) {
69
- const handleHashchange = () => {
70
- var _a;
71
- const platform = (_a = getHashSearch().get('platform')) !== null && _a !== void 0 ? _a : 'mobile';
72
- cb(platform);
73
- };
74
- useRouteListener(handleHashchange);
75
- handleHashchange();
76
- }
77
- export function useRouteListener(cb) {
78
- onMounted(() => {
79
- window.addEventListener('hashchange', cb);
80
- window.addEventListener('popstate', cb);
81
- });
82
- onUnmounted(() => {
83
- window.removeEventListener('hashchange', cb);
84
- window.removeEventListener('popstate', cb);
85
- });
86
- }
87
- export function watchDarkMode(dark, cb) {
88
- watchTheme((theme) => {
89
- const siteStyleVars = withSiteConfigNamespace(get(config, theme, {}));
90
- StyleProvider(theme === 'darkTheme' ? Object.assign(Object.assign({}, siteStyleVars), dark) : siteStyleVars);
91
- cb === null || cb === void 0 ? void 0 : cb(theme);
92
- });
93
- }
94
- export function watchTheme(cb, shouldUnmount = true) {
95
- const handleThemeChange = (event) => {
96
- const { data } = event;
97
- if (data.action === 'theme-change') {
98
- cb(data.data, data.from);
99
- }
100
- };
101
- window.addEventListener('message', handleThemeChange);
102
- if (shouldUnmount) {
103
- onUnmounted(() => {
104
- window.removeEventListener('message', handleThemeChange);
105
- });
106
- }
107
- cb(getBrowserTheme(), 'default');
108
- }
109
- 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
+ var _a;
25
+ const [, language, path] = window.location.hash.split('/');
26
+ const [menuName, hash = ''] = (_a = path === null || path === void 0 ? void 0 : path.split('#')) !== null && _a !== void 0 ? _a : [];
27
+ return {
28
+ language,
29
+ menuName,
30
+ hash,
31
+ };
32
+ }
33
+ function getHashSearch() {
34
+ const { href } = window.location;
35
+ const hashSearch = href.slice(href.indexOf('?'));
36
+ return new URLSearchParams(hashSearch);
37
+ }
38
+ export function getBrowserTheme() {
39
+ var _a;
40
+ const themeKey = get(config, 'themeKey');
41
+ const darkThemeConfig = get(config, 'darkTheme');
42
+ if (!darkThemeConfig) {
43
+ return 'lightTheme';
44
+ }
45
+ const storageTheme = window.localStorage.getItem(themeKey);
46
+ if (!storageTheme) {
47
+ const preferTheme = ((_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, '(prefers-color-scheme: dark)').matches) ? 'darkTheme' : 'lightTheme';
48
+ window.localStorage.setItem(themeKey, preferTheme);
49
+ return preferTheme;
50
+ }
51
+ return storageTheme;
52
+ }
53
+ export function watchLang(cb, platform = 'mobile') {
54
+ const handleHashchange = () => {
55
+ var _a;
56
+ const language = platform === 'mobile' ? (_a = getHashSearch().get('language')) !== null && _a !== void 0 ? _a : 'zh-CN' : getPCLocationInfo().language;
57
+ cb(language);
58
+ };
59
+ useRouteListener(handleHashchange);
60
+ handleHashchange();
61
+ }
62
+ export function withSiteConfigNamespace(styleVars) {
63
+ return Object.entries(styleVars).reduce((styleVars, [key, value]) => {
64
+ styleVars[`--site-config-${key}`] = value;
65
+ return styleVars;
66
+ }, {});
67
+ }
68
+ export function watchPlatform(cb) {
69
+ const handleHashchange = () => {
70
+ var _a;
71
+ const platform = (_a = getHashSearch().get('platform')) !== null && _a !== void 0 ? _a : 'mobile';
72
+ cb(platform);
73
+ };
74
+ useRouteListener(handleHashchange);
75
+ handleHashchange();
76
+ }
77
+ export function useRouteListener(cb) {
78
+ onMounted(() => {
79
+ window.addEventListener('hashchange', cb);
80
+ window.addEventListener('popstate', cb);
81
+ });
82
+ onUnmounted(() => {
83
+ window.removeEventListener('hashchange', cb);
84
+ window.removeEventListener('popstate', cb);
85
+ });
86
+ }
87
+ export function watchDarkMode(dark, cb) {
88
+ watchTheme((theme) => {
89
+ const siteStyleVars = withSiteConfigNamespace(get(config, theme, {}));
90
+ StyleProvider(theme === 'darkTheme' ? Object.assign(Object.assign({}, siteStyleVars), dark) : siteStyleVars);
91
+ cb === null || cb === void 0 ? void 0 : cb(theme);
92
+ });
93
+ }
94
+ export function watchTheme(cb, shouldUnmount = true) {
95
+ const handleThemeChange = (event) => {
96
+ const { data } = event;
97
+ if (data.action === 'theme-change') {
98
+ cb(data.data, data.from);
99
+ }
100
+ };
101
+ window.addEventListener('message', handleThemeChange);
102
+ if (shouldUnmount) {
103
+ onUnmounted(() => {
104
+ window.removeEventListener('message', handleThemeChange);
105
+ });
106
+ }
107
+ cb(getBrowserTheme(), 'default');
108
+ }
109
+ 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,148 +1,148 @@
1
- #!/usr/bin/env node
2
- import { Command } from 'commander';
3
- import { getCliVersion } from './shared/fsUtils.js';
4
- const program = new Command();
5
- program.version(`varlet-cli ${getCliVersion()}`).usage('<command> [options]');
6
- program
7
- .command('dev')
8
- .option('-f --force', 'Force dep pre-optimization regardless of whether deps have changed')
9
- .option('-d --draft', 'Start the service in draft mode')
10
- .description('Run varlet development environment')
11
- .action(async (options) => {
12
- const { dev } = await import('./commands/dev.js');
13
- return dev(options);
14
- });
15
- program
16
- .command('build')
17
- .description('Build varlet site for production')
18
- .action(async () => {
19
- const { build } = await import('./commands/build.js');
20
- return build();
21
- });
22
- program
23
- .command('dev:vite')
24
- .description('Use vite start server for development')
25
- .action(async () => {
26
- const { vite } = await import('./commands/vite.js');
27
- return vite('dev');
28
- });
29
- program
30
- .command('build:vite')
31
- .description('Use vite build app for production')
32
- .action(async () => {
33
- const { vite } = await import('./commands/vite.js');
34
- return vite('build');
35
- });
36
- program
37
- .command('dev:extension')
38
- .description('Run VSCode extension development environment')
39
- .action(async () => {
40
- const { extension } = await import('./commands/extension.js');
41
- return extension('dev');
42
- });
43
- program
44
- .command('build:extension')
45
- .description('Build VSCode extension for production')
46
- .action(async () => {
47
- const { extension } = await import('./commands/extension.js');
48
- return extension('build');
49
- });
50
- program
51
- .command('build:icons')
52
- .description('Build icons')
53
- .action(async () => {
54
- const { icons } = await import('./commands/icons.js');
55
- return icons();
56
- });
57
- program
58
- .command('preview')
59
- .description('Preview varlet site for production')
60
- .action(async () => {
61
- const { preview } = await import('./commands/preview.js');
62
- return preview();
63
- });
64
- program
65
- .command('compile')
66
- .description('Compile varlet components library code')
67
- .action(async () => {
68
- const { compile } = await import('./commands/compile.js');
69
- return compile();
70
- });
71
- program
72
- .command('lint')
73
- .description('Lint code')
74
- .action(async () => {
75
- const { lint } = await import('./commands/lint.js');
76
- return lint();
77
- });
78
- program
79
- .command('create')
80
- .description('Create a component directory')
81
- .option('-n, --name <componentName>', 'Component name')
82
- .option('-s, --sfc', 'Generate files in sfc format')
83
- .option('-t, --tsx', 'Generate files in tsx format')
84
- .option('-l, --locale', 'Generator internationalized files')
85
- .action(async (options) => {
86
- const { create } = await import('./commands/create.js');
87
- return create(options);
88
- });
89
- program
90
- .command('jest')
91
- .description('Run Jest in work directory')
92
- .option('-w, --watch', 'Watch files for changes and rerun tests related to changed files')
93
- .option('-wa, --watchAll', 'Watch files for changes and rerun all tests when something changes')
94
- .option('-c, --component <componentName>', 'Test a specific component')
95
- .option('-cc --clearCache', 'Clear test cache')
96
- .action(async (option) => {
97
- const { jest } = await import('./commands/jest.js');
98
- return jest(option);
99
- });
100
- program
101
- .command('gen')
102
- .description('Generate cli application')
103
- .option('-n, --name <applicationName>', 'Application name')
104
- .option('-s, --sfc', 'Generate files in sfc format')
105
- .option('-t, --tsx', 'Generate files in tsx format')
106
- .option('-l, --locale', 'Generator internationalized files')
107
- .action(async (option) => {
108
- const { gen } = await import('./commands/gen.js');
109
- return gen(option);
110
- });
111
- program
112
- .command('changelog')
113
- .option('-rc --releaseCount <releaseCount>', 'Release count')
114
- .option('-f --file <file>', 'Changelog filename')
115
- .description('Generate changelog')
116
- .action(async (option) => {
117
- const { changelog } = await import('./commands/changelog.js');
118
- return changelog(option);
119
- });
120
- program
121
- .command('release')
122
- .option('-r --remote <remote>', 'Remote name')
123
- .description('Release all packages and generate changelogs')
124
- .action(async (option) => {
125
- const { release } = await import('./commands/release.js');
126
- return release(option);
127
- });
128
- program
129
- .command('commit-lint <gitParams>')
130
- .description('Lint commit message')
131
- .action(async (option) => {
132
- const { commitLint } = await import('./commands/commitLint.js');
133
- return commitLint(option);
134
- });
135
- program
136
- .command('checklist <gitParams>')
137
- .description('Display a checklist for confirmation')
138
- .action(async (option) => {
139
- const { checklist } = await import('./commands/checklist.js');
140
- return checklist(option);
141
- });
142
- program.on('command:*', async ([cmd]) => {
143
- const { default: logger } = await import('./shared/logger.js');
144
- program.outputHelp();
145
- logger.error(`\nUnknown command ${cmd}.\n`);
146
- process.exitCode = 1;
147
- });
148
- program.parse();
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { getCliVersion } from './shared/fsUtils.js';
4
+ const program = new Command();
5
+ program.version(`varlet-cli ${getCliVersion()}`).usage('<command> [options]');
6
+ program
7
+ .command('dev')
8
+ .option('-f --force', 'Force dep pre-optimization regardless of whether deps have changed')
9
+ .option('-d --draft', 'Start the service in draft mode')
10
+ .description('Run varlet development environment')
11
+ .action(async (options) => {
12
+ const { dev } = await import('./commands/dev.js');
13
+ return dev(options);
14
+ });
15
+ program
16
+ .command('build')
17
+ .description('Build varlet site for production')
18
+ .action(async () => {
19
+ const { build } = await import('./commands/build.js');
20
+ return build();
21
+ });
22
+ program
23
+ .command('dev:vite')
24
+ .description('Use vite start server for development')
25
+ .action(async () => {
26
+ const { vite } = await import('./commands/vite.js');
27
+ return vite('dev');
28
+ });
29
+ program
30
+ .command('build:vite')
31
+ .description('Use vite build app for production')
32
+ .action(async () => {
33
+ const { vite } = await import('./commands/vite.js');
34
+ return vite('build');
35
+ });
36
+ program
37
+ .command('dev:extension')
38
+ .description('Run VSCode extension development environment')
39
+ .action(async () => {
40
+ const { extension } = await import('./commands/extension.js');
41
+ return extension('dev');
42
+ });
43
+ program
44
+ .command('build:extension')
45
+ .description('Build VSCode extension for production')
46
+ .action(async () => {
47
+ const { extension } = await import('./commands/extension.js');
48
+ return extension('build');
49
+ });
50
+ program
51
+ .command('build:icons')
52
+ .description('Build icons')
53
+ .action(async () => {
54
+ const { icons } = await import('./commands/icons.js');
55
+ return icons();
56
+ });
57
+ program
58
+ .command('preview')
59
+ .description('Preview varlet site for production')
60
+ .action(async () => {
61
+ const { preview } = await import('./commands/preview.js');
62
+ return preview();
63
+ });
64
+ program
65
+ .command('compile')
66
+ .description('Compile varlet components library code')
67
+ .action(async () => {
68
+ const { compile } = await import('./commands/compile.js');
69
+ return compile();
70
+ });
71
+ program
72
+ .command('lint')
73
+ .description('Lint code')
74
+ .action(async () => {
75
+ const { lint } = await import('./commands/lint.js');
76
+ return lint();
77
+ });
78
+ program
79
+ .command('create')
80
+ .description('Create a component directory')
81
+ .option('-n, --name <componentName>', 'Component name')
82
+ .option('-s, --sfc', 'Generate files in sfc format')
83
+ .option('-t, --tsx', 'Generate files in tsx format')
84
+ .option('-l, --locale', 'Generator internationalized files')
85
+ .action(async (options) => {
86
+ const { create } = await import('./commands/create.js');
87
+ return create(options);
88
+ });
89
+ program
90
+ .command('jest')
91
+ .description('Run Jest in work directory')
92
+ .option('-w, --watch', 'Watch files for changes and rerun tests related to changed files')
93
+ .option('-wa, --watchAll', 'Watch files for changes and rerun all tests when something changes')
94
+ .option('-c, --component <componentName>', 'Test a specific component')
95
+ .option('-cc --clearCache', 'Clear test cache')
96
+ .action(async (option) => {
97
+ const { jest } = await import('./commands/jest.js');
98
+ return jest(option);
99
+ });
100
+ program
101
+ .command('gen')
102
+ .description('Generate cli application')
103
+ .option('-n, --name <applicationName>', 'Application name')
104
+ .option('-s, --sfc', 'Generate files in sfc format')
105
+ .option('-t, --tsx', 'Generate files in tsx format')
106
+ .option('-l, --locale', 'Generator internationalized files')
107
+ .action(async (option) => {
108
+ const { gen } = await import('./commands/gen.js');
109
+ return gen(option);
110
+ });
111
+ program
112
+ .command('changelog')
113
+ .option('-rc --releaseCount <releaseCount>', 'Release count')
114
+ .option('-f --file <file>', 'Changelog filename')
115
+ .description('Generate changelog')
116
+ .action(async (option) => {
117
+ const { changelog } = await import('./commands/changelog.js');
118
+ return changelog(option);
119
+ });
120
+ program
121
+ .command('release')
122
+ .option('-r --remote <remote>', 'Remote name')
123
+ .description('Release all packages and generate changelogs')
124
+ .action(async (option) => {
125
+ const { release } = await import('./commands/release.js');
126
+ return release(option);
127
+ });
128
+ program
129
+ .command('commit-lint <gitParams>')
130
+ .description('Lint commit message')
131
+ .action(async (option) => {
132
+ const { commitLint } = await import('./commands/commitLint.js');
133
+ return commitLint(option);
134
+ });
135
+ program
136
+ .command('checklist <gitParams>')
137
+ .description('Display a checklist for confirmation')
138
+ .action(async (option) => {
139
+ const { checklist } = await import('./commands/checklist.js');
140
+ return checklist(option);
141
+ });
142
+ program.on('command:*', async ([cmd]) => {
143
+ const { default: logger } = await import('./shared/logger.js');
144
+ program.outputHelp();
145
+ logger.error(`\nUnknown command ${cmd}.\n`);
146
+ process.exitCode = 1;
147
+ });
148
+ 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(false);
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(false);
12
+ const varletConfig = await getVarletConfig();
13
+ const buildConfig = getBuildConfig(varletConfig);
14
+ await buildVite(buildConfig);
15
+ }
@@ -1,5 +1,5 @@
1
- export interface ChangelogCommandOptions {
2
- file?: string;
3
- releaseCount?: number;
4
- }
5
- export declare function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>;
1
+ export interface ChangelogCommandOptions {
2
+ file?: string;
3
+ releaseCount?: number;
4
+ }
5
+ export declare function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>;