@varlet/cli 1.27.14 → 1.27.17-alpha.1656907860130

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 (211) hide show
  1. package/LICENCE +21 -21
  2. package/README.en-US.md +401 -401
  3. package/README.md +396 -396
  4. package/generators/base/.prettierignore +9 -9
  5. package/generators/base/.prettierrc +5 -5
  6. package/generators/base/README.md +82 -82
  7. package/generators/base/babel.config.js +10 -10
  8. package/generators/base/public/highlight.css +1 -1
  9. package/generators/base/public/logo.svg +1 -1
  10. package/generators/base/shims/shims-md.d.ts +4 -4
  11. package/generators/base/shims/shims-vue.d.ts +6 -6
  12. package/generators/base/tsconfig.json +13 -13
  13. package/generators/config/default/base/docs/home.zh-CN.md +10 -10
  14. package/generators/config/default/base/package.json +1 -0
  15. package/generators/config/default/base/types/basicComponent.d.ts +7 -7
  16. package/generators/config/default/base/types/button.d.ts +12 -12
  17. package/generators/config/default/base/types/index.d.ts +6 -6
  18. package/generators/config/default/base/varlet.config.js +110 -110
  19. package/generators/config/default/sfc/src/button/Button.vue +30 -30
  20. package/generators/config/default/sfc/src/button/__tests__/index.spec.js +7 -7
  21. package/generators/config/default/sfc/src/button/button.less +14 -14
  22. package/generators/config/default/sfc/src/button/docs/zh-CN.md +47 -47
  23. package/generators/config/default/sfc/src/button/example/BasicUse.vue +7 -7
  24. package/generators/config/default/sfc/src/button/example/ModifyColor.vue +7 -7
  25. package/generators/config/default/sfc/src/button/example/index.vue +13 -13
  26. package/generators/config/default/sfc/src/button/index.ts +10 -10
  27. package/generators/config/default/tsx/src/button/Button.tsx +31 -31
  28. package/generators/config/default/tsx/src/button/__tests__/index.spec.js +7 -7
  29. package/generators/config/default/tsx/src/button/button.less +14 -14
  30. package/generators/config/default/tsx/src/button/docs/zh-CN.md +47 -47
  31. package/generators/config/default/tsx/src/button/example/BasicUse.vue +7 -7
  32. package/generators/config/default/tsx/src/button/example/ModifyColor.vue +7 -7
  33. package/generators/config/default/tsx/src/button/example/index.vue +13 -13
  34. package/generators/config/default/tsx/src/button/index.ts +10 -10
  35. package/generators/config/i18n/base/docs/home.en-US.md +11 -11
  36. package/generators/config/i18n/base/docs/home.zh-CN.md +10 -10
  37. package/generators/config/i18n/base/package.json +1 -0
  38. package/generators/config/i18n/base/types/basicComponent.d.ts +7 -7
  39. package/generators/config/i18n/base/types/button.d.ts +12 -12
  40. package/generators/config/i18n/base/types/index.d.ts +7 -7
  41. package/generators/config/i18n/base/types/locale.d.ts +24 -24
  42. package/generators/config/i18n/base/varlet.config.js +122 -122
  43. package/generators/config/i18n/sfc/src/button/Button.vue +36 -36
  44. package/generators/config/i18n/sfc/src/button/__tests__/index.spec.js +7 -7
  45. package/generators/config/i18n/sfc/src/button/button.less +14 -14
  46. package/generators/config/i18n/sfc/src/button/docs/en-US.md +34 -34
  47. package/generators/config/i18n/sfc/src/button/docs/zh-CN.md +34 -34
  48. package/generators/config/i18n/sfc/src/button/example/BasicUse.vue +11 -11
  49. package/generators/config/i18n/sfc/src/button/example/ModifyColor.vue +11 -11
  50. package/generators/config/i18n/sfc/src/button/example/index.vue +13 -13
  51. package/generators/config/i18n/sfc/src/button/example/locale/en-US.ts +5 -5
  52. package/generators/config/i18n/sfc/src/button/example/locale/index.ts +23 -23
  53. package/generators/config/i18n/sfc/src/button/example/locale/zh-CN.ts +5 -5
  54. package/generators/config/i18n/sfc/src/button/index.ts +10 -10
  55. package/generators/config/i18n/sfc/src/locale/__tests__/index.spec.js +51 -51
  56. package/generators/config/i18n/sfc/src/locale/docs/en-US.md +26 -26
  57. package/generators/config/i18n/sfc/src/locale/docs/zh-CN.md +25 -25
  58. package/generators/config/i18n/sfc/src/locale/en-US.d.ts +5 -5
  59. package/generators/config/i18n/sfc/src/locale/en-US.ts +7 -7
  60. package/generators/config/i18n/sfc/src/locale/index.ts +67 -67
  61. package/generators/config/i18n/sfc/src/locale/zh-CN.d.ts +5 -5
  62. package/generators/config/i18n/sfc/src/locale/zh-CN.ts +7 -7
  63. package/generators/config/i18n/tsx/src/button/Button.tsx +35 -35
  64. package/generators/config/i18n/tsx/src/button/__tests__/index.spec.js +7 -7
  65. package/generators/config/i18n/tsx/src/button/button.less +14 -14
  66. package/generators/config/i18n/tsx/src/button/docs/en-US.md +34 -34
  67. package/generators/config/i18n/tsx/src/button/docs/zh-CN.md +34 -34
  68. package/generators/config/i18n/tsx/src/button/example/BasicUse.vue +11 -11
  69. package/generators/config/i18n/tsx/src/button/example/ModifyColor.vue +11 -11
  70. package/generators/config/i18n/tsx/src/button/example/index.vue +13 -13
  71. package/generators/config/i18n/tsx/src/button/example/locale/en-US.ts +5 -5
  72. package/generators/config/i18n/tsx/src/button/example/locale/index.ts +23 -23
  73. package/generators/config/i18n/tsx/src/button/example/locale/zh-CN.ts +5 -5
  74. package/generators/config/i18n/tsx/src/button/index.ts +10 -10
  75. package/generators/config/i18n/tsx/src/locale/__tests__/index.spec.js +51 -51
  76. package/generators/config/i18n/tsx/src/locale/docs/en-US.md +26 -26
  77. package/generators/config/i18n/tsx/src/locale/docs/zh-CN.md +25 -25
  78. package/generators/config/i18n/tsx/src/locale/en-US.d.ts +5 -5
  79. package/generators/config/i18n/tsx/src/locale/en-US.ts +7 -7
  80. package/generators/config/i18n/tsx/src/locale/index.ts +67 -67
  81. package/generators/config/i18n/tsx/src/locale/zh-CN.d.ts +5 -5
  82. package/generators/config/i18n/tsx/src/locale/zh-CN.ts +7 -7
  83. package/lib/commands/build.d.ts +1 -1
  84. package/lib/commands/build.js +67 -67
  85. package/lib/commands/changelog.d.ts +6 -6
  86. package/lib/commands/changelog.js +27 -27
  87. package/lib/commands/commitLint.d.ts +1 -1
  88. package/lib/commands/commitLint.js +21 -21
  89. package/lib/commands/compile.d.ts +5 -5
  90. package/lib/commands/compile.js +119 -119
  91. package/lib/commands/create.d.ts +3 -3
  92. package/lib/commands/create.js +132 -132
  93. package/lib/commands/dev.d.ts +3 -3
  94. package/lib/commands/dev.js +123 -123
  95. package/lib/commands/gen.d.ts +1 -1
  96. package/lib/commands/gen.js +112 -112
  97. package/lib/commands/jest.d.ts +8 -8
  98. package/lib/commands/jest.js +81 -81
  99. package/lib/commands/lint.d.ts +1 -1
  100. package/lib/commands/lint.js +123 -123
  101. package/lib/commands/preview.d.ts +1 -1
  102. package/lib/commands/preview.js +74 -74
  103. package/lib/commands/release.d.ts +3 -3
  104. package/lib/commands/release.js +267 -269
  105. package/lib/compiler/compileModule.d.ts +5 -5
  106. package/lib/compiler/compileModule.js +186 -186
  107. package/lib/compiler/compileSFC.d.ts +2 -2
  108. package/lib/compiler/compileSFC.js +132 -132
  109. package/lib/compiler/compileScript.d.ts +17 -17
  110. package/lib/compiler/compileScript.js +202 -201
  111. package/lib/compiler/compileSiteEntry.d.ts +13 -13
  112. package/lib/compiler/compileSiteEntry.js +237 -237
  113. package/lib/compiler/compileStyle.d.ts +11 -11
  114. package/lib/compiler/compileStyle.js +101 -101
  115. package/lib/compiler/compileTemplateHighlight.d.ts +10 -10
  116. package/lib/compiler/compileTemplateHighlight.js +193 -193
  117. package/lib/compiler/compileTypes.d.ts +2 -2
  118. package/lib/compiler/compileTypes.js +88 -88
  119. package/lib/config/babel.config.d.ts +2 -2
  120. package/lib/config/babel.config.js +31 -31
  121. package/lib/config/babel.sfc.transform.d.ts +1 -1
  122. package/lib/config/babel.sfc.transform.js +18 -18
  123. package/lib/config/jest.config.d.ts +1 -1
  124. package/lib/config/jest.config.js +36 -36
  125. package/lib/config/jest.media.mock.js +2 -2
  126. package/lib/config/jest.style.mock.js +2 -2
  127. package/lib/config/varlet.config.d.ts +1 -1
  128. package/lib/config/varlet.config.js +24 -24
  129. package/lib/config/vite.config.d.ts +5 -5
  130. package/lib/config/vite.config.js +162 -162
  131. package/lib/index.d.ts +2 -2
  132. package/lib/index.js +83 -83
  133. package/lib/shared/constant.d.ts +43 -43
  134. package/lib/shared/constant.js +50 -50
  135. package/lib/shared/fsUtils.d.ts +12 -16
  136. package/lib/shared/fsUtils.js +108 -116
  137. package/lib/shared/logger.d.ts +7 -7
  138. package/lib/shared/logger.js +20 -20
  139. package/package.json +7 -8
  140. package/preset.js +3 -3
  141. package/site/components/button/Button.vue +84 -84
  142. package/site/components/button/button.less +183 -183
  143. package/site/components/button/index.ts +10 -10
  144. package/site/components/button/props.ts +70 -70
  145. package/site/components/cell/Cell.vue +42 -42
  146. package/site/components/cell/cell.less +74 -74
  147. package/site/components/cell/index.ts +10 -10
  148. package/site/components/cell/props.ts +27 -27
  149. package/site/components/code-example/CodeExample.vue +143 -143
  150. package/site/components/code-example/codeExample.less +41 -41
  151. package/site/components/code-example/index.ts +10 -10
  152. package/site/components/context/index.ts +17 -17
  153. package/site/components/context/lock.ts +103 -103
  154. package/site/components/context/zIndex.ts +20 -20
  155. package/site/components/icon/Icon.vue +68 -68
  156. package/site/components/icon/icon.less +26 -26
  157. package/site/components/icon/index.ts +10 -10
  158. package/site/components/icon/props.ts +24 -24
  159. package/site/components/loading/Loading.vue +55 -55
  160. package/site/components/loading/index.ts +10 -10
  161. package/site/components/loading/loading.less +420 -420
  162. package/site/components/loading/props.ts +37 -37
  163. package/site/components/progress/Progress.vue +108 -108
  164. package/site/components/progress/index.ts +10 -10
  165. package/site/components/progress/progress.less +98 -98
  166. package/site/components/progress/props.ts +55 -55
  167. package/site/components/ripple/index.ts +167 -167
  168. package/site/components/ripple/ripple.less +17 -17
  169. package/site/components/snackbar/Snackbar.vue +38 -38
  170. package/site/components/snackbar/core.vue +117 -117
  171. package/site/components/snackbar/index.tsx +270 -270
  172. package/site/components/snackbar/props.ts +94 -94
  173. package/site/components/snackbar/snackbar.less +135 -135
  174. package/site/components/styles/common.less +64 -64
  175. package/site/components/styles/elevation.less +126 -126
  176. package/site/components/styles/var.less +27 -27
  177. package/site/components/utils/components.ts +69 -69
  178. package/site/components/utils/elements.ts +85 -85
  179. package/site/index.html +49 -49
  180. package/site/mobile/App.vue +291 -291
  181. package/site/mobile/components/AppHome.vue +134 -134
  182. package/site/mobile/components/AppType.vue +22 -22
  183. package/site/mobile/components/app-bar/AppBar.vue +69 -69
  184. package/site/mobile/components/app-bar/appBar.less +56 -56
  185. package/site/mobile/components/app-bar/index.ts +10 -10
  186. package/site/mobile/components/app-bar/props.ts +25 -25
  187. package/site/mobile/components/styles/common.less +64 -64
  188. package/site/mobile/components/styles/elevation.less +126 -126
  189. package/site/mobile/components/styles/var.less +27 -27
  190. package/site/mobile/main.ts +74 -74
  191. package/site/mobile.html +41 -41
  192. package/site/module.d.ts +5 -5
  193. package/site/pc/App.vue +43 -43
  194. package/site/pc/Layout.vue +397 -397
  195. package/site/pc/components/AnimationBox.vue +45 -45
  196. package/site/pc/components/AppHeader.vue +355 -355
  197. package/site/pc/components/AppMobile.vue +54 -54
  198. package/site/pc/components/AppSidebar.vue +134 -134
  199. package/site/pc/components/LogoAnimation.vue +119 -119
  200. package/site/pc/floating.ts +9 -9
  201. package/site/pc/main.ts +94 -94
  202. package/site/pc/pages/index/index.less +194 -194
  203. package/site/pc/pages/index/index.vue +128 -125
  204. package/site/pc/pages/index/locale/en-US.ts +3 -5
  205. package/site/pc/pages/index/locale/zh-CN.ts +3 -5
  206. package/site/tsconfig.json +11 -11
  207. package/site/useProgress.ts +75 -75
  208. package/site/utils.ts +153 -162
  209. package/tsconfig.json +14 -14
  210. package/varlet.default.config.js +151 -145
  211. package/site/components/utils/shared.ts +0 -29
@@ -1,162 +1,162 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getUMDConfig = exports.getESMBundleConfig = exports.getBuildConfig = exports.getDevConfig = void 0;
18
- var plugin_vue_1 = __importDefault(require("@vitejs/plugin-vue"));
19
- var markdown_vite_plugin_1 = __importDefault(require("@varlet/markdown-vite-plugin"));
20
- var plugin_vue_jsx_1 = __importDefault(require("@vitejs/plugin-vue-jsx"));
21
- var vite_plugin_html_1 = require("vite-plugin-html");
22
- var constant_1 = require("../shared/constant");
23
- var lodash_1 = require("lodash");
24
- var shared_1 = require("@varlet/shared");
25
- var path_1 = require("path");
26
- var fs_extra_1 = require("fs-extra");
27
- function getDevConfig(varletConfig) {
28
- var defaultLanguage = (0, lodash_1.get)(varletConfig, 'defaultLanguage');
29
- var host = (0, lodash_1.get)(varletConfig, 'host');
30
- return {
31
- root: constant_1.SITE_DIR,
32
- resolve: {
33
- extensions: constant_1.VITE_RESOLVE_EXTENSIONS,
34
- alias: {
35
- '@config': constant_1.SITE_CONFIG,
36
- '@pc-routes': constant_1.SITE_PC_ROUTES,
37
- '@mobile-routes': constant_1.SITE_MOBILE_ROUTES,
38
- },
39
- },
40
- server: {
41
- port: (0, lodash_1.get)(varletConfig, 'port'),
42
- host: host === 'localhost' ? '0.0.0.0' : host,
43
- },
44
- publicDir: constant_1.SITE_PUBLIC_PATH,
45
- plugins: [
46
- (0, plugin_vue_1.default)({
47
- include: [/\.vue$/, /\.md$/],
48
- }),
49
- (0, markdown_vite_plugin_1.default)({ style: (0, lodash_1.get)(varletConfig, 'highlight.style') }),
50
- (0, plugin_vue_jsx_1.default)(),
51
- (0, vite_plugin_html_1.injectHtml)({
52
- data: {
53
- pcTitle: (0, lodash_1.get)(varletConfig, "pc.title['".concat(defaultLanguage, "']")),
54
- mobileTitle: (0, lodash_1.get)(varletConfig, "mobile.title['".concat(defaultLanguage, "']")),
55
- logo: (0, lodash_1.get)(varletConfig, "logo"),
56
- baidu: (0, lodash_1.get)(varletConfig, "analysis.baidu", ''),
57
- },
58
- }),
59
- ],
60
- };
61
- }
62
- exports.getDevConfig = getDevConfig;
63
- function getBuildConfig(varletConfig) {
64
- var devConfig = getDevConfig(varletConfig);
65
- return __assign(__assign({}, devConfig), { base: './', build: {
66
- outDir: constant_1.SITE_OUTPUT_PATH,
67
- brotliSize: false,
68
- emptyOutDir: true,
69
- cssTarget: 'chrome61',
70
- rollupOptions: {
71
- input: {
72
- main: (0, path_1.resolve)(constant_1.SITE_DIR, 'index.html'),
73
- mobile: (0, path_1.resolve)(constant_1.SITE_DIR, 'mobile.html'),
74
- },
75
- },
76
- } });
77
- }
78
- exports.getBuildConfig = getBuildConfig;
79
- function inlineCSS(fileName, dir) {
80
- return {
81
- name: 'varlet-inline-css-vite-plugin',
82
- apply: 'build',
83
- closeBundle: function () {
84
- var cssFile = (0, path_1.resolve)(dir, 'style.css');
85
- if (!(0, fs_extra_1.pathExistsSync)(cssFile)) {
86
- return;
87
- }
88
- var jsFile = (0, path_1.resolve)(dir, fileName);
89
- var cssCode = (0, fs_extra_1.readFileSync)(cssFile, 'utf-8');
90
- var jsCode = (0, fs_extra_1.readFileSync)(jsFile, 'utf-8');
91
- var injectCode = ";(function(){var style=document.createElement('style');style.type='text/css';style.rel='stylesheet';style.appendChild(document.createTextNode(`".concat(cssCode.replace(/\\/g, '\\\\'), "`));var head=document.querySelector('head');head.appendChild(style)})();");
92
- (0, fs_extra_1.writeFileSync)(jsFile, "".concat(injectCode).concat(jsCode));
93
- (0, fs_extra_1.copyFileSync)(cssFile, (0, path_1.resolve)(constant_1.LIB_DIR, 'style.css'));
94
- (0, fs_extra_1.removeSync)(cssFile);
95
- },
96
- };
97
- }
98
- function clear() {
99
- return {
100
- name: 'varlet-clear-vite-plugin',
101
- apply: 'build',
102
- closeBundle: function () {
103
- (0, fs_extra_1.removeSync)((0, path_1.resolve)(constant_1.CWD, 'dist'));
104
- },
105
- };
106
- }
107
- function getESMBundleConfig(varletConfig) {
108
- var name = (0, lodash_1.get)(varletConfig, 'name');
109
- var fileName = "".concat((0, shared_1.kebabCase)(name), ".esm.js");
110
- return {
111
- logLevel: 'silent',
112
- build: {
113
- emptyOutDir: true,
114
- lib: {
115
- name: name,
116
- formats: ['es'],
117
- fileName: function () { return fileName; },
118
- entry: (0, path_1.resolve)(constant_1.ES_DIR, 'umdIndex.js'),
119
- },
120
- rollupOptions: {
121
- external: ['vue'],
122
- output: {
123
- dir: constant_1.ES_DIR,
124
- exports: 'named',
125
- globals: {
126
- vue: 'Vue',
127
- },
128
- },
129
- },
130
- },
131
- plugins: [clear()],
132
- };
133
- }
134
- exports.getESMBundleConfig = getESMBundleConfig;
135
- function getUMDConfig(varletConfig) {
136
- var name = (0, lodash_1.get)(varletConfig, 'name');
137
- var fileName = "".concat((0, shared_1.kebabCase)(name), ".js");
138
- return {
139
- logLevel: 'silent',
140
- build: {
141
- emptyOutDir: true,
142
- lib: {
143
- name: name,
144
- formats: ['umd'],
145
- fileName: function () { return fileName; },
146
- entry: (0, path_1.resolve)(constant_1.ES_DIR, 'umdIndex.js'),
147
- },
148
- rollupOptions: {
149
- external: ['vue'],
150
- output: {
151
- dir: constant_1.UMD_DIR,
152
- exports: 'named',
153
- globals: {
154
- vue: 'Vue',
155
- },
156
- },
157
- },
158
- },
159
- plugins: [inlineCSS(fileName, constant_1.UMD_DIR), clear()],
160
- };
161
- }
162
- exports.getUMDConfig = getUMDConfig;
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.getUMDConfig = exports.getESMBundleConfig = exports.getBuildConfig = exports.getDevConfig = void 0;
18
+ var plugin_vue_1 = __importDefault(require("@vitejs/plugin-vue"));
19
+ var markdown_vite_plugin_1 = __importDefault(require("@varlet/markdown-vite-plugin"));
20
+ var plugin_vue_jsx_1 = __importDefault(require("@vitejs/plugin-vue-jsx"));
21
+ var vite_plugin_html_1 = require("vite-plugin-html");
22
+ var constant_1 = require("../shared/constant");
23
+ var lodash_1 = require("lodash");
24
+ var shared_1 = require("@varlet/shared");
25
+ var path_1 = require("path");
26
+ var fs_extra_1 = require("fs-extra");
27
+ function getDevConfig(varletConfig) {
28
+ var defaultLanguage = (0, lodash_1.get)(varletConfig, 'defaultLanguage');
29
+ var host = (0, lodash_1.get)(varletConfig, 'host');
30
+ return {
31
+ root: constant_1.SITE_DIR,
32
+ resolve: {
33
+ extensions: constant_1.VITE_RESOLVE_EXTENSIONS,
34
+ alias: {
35
+ '@config': constant_1.SITE_CONFIG,
36
+ '@pc-routes': constant_1.SITE_PC_ROUTES,
37
+ '@mobile-routes': constant_1.SITE_MOBILE_ROUTES,
38
+ },
39
+ },
40
+ server: {
41
+ port: (0, lodash_1.get)(varletConfig, 'port'),
42
+ host: host === 'localhost' ? '0.0.0.0' : host,
43
+ },
44
+ publicDir: constant_1.SITE_PUBLIC_PATH,
45
+ plugins: [
46
+ (0, plugin_vue_1.default)({
47
+ include: [/\.vue$/, /\.md$/],
48
+ }),
49
+ (0, markdown_vite_plugin_1.default)({ style: (0, lodash_1.get)(varletConfig, 'highlight.style') }),
50
+ (0, plugin_vue_jsx_1.default)(),
51
+ (0, vite_plugin_html_1.injectHtml)({
52
+ data: {
53
+ pcTitle: (0, lodash_1.get)(varletConfig, "pc.title['".concat(defaultLanguage, "']")),
54
+ mobileTitle: (0, lodash_1.get)(varletConfig, "mobile.title['".concat(defaultLanguage, "']")),
55
+ logo: (0, lodash_1.get)(varletConfig, "logo"),
56
+ baidu: (0, lodash_1.get)(varletConfig, "analysis.baidu", ''),
57
+ },
58
+ }),
59
+ ],
60
+ };
61
+ }
62
+ exports.getDevConfig = getDevConfig;
63
+ function getBuildConfig(varletConfig) {
64
+ var devConfig = getDevConfig(varletConfig);
65
+ return __assign(__assign({}, devConfig), { base: './', build: {
66
+ outDir: constant_1.SITE_OUTPUT_PATH,
67
+ brotliSize: false,
68
+ emptyOutDir: true,
69
+ cssTarget: 'chrome61',
70
+ rollupOptions: {
71
+ input: {
72
+ main: (0, path_1.resolve)(constant_1.SITE_DIR, 'index.html'),
73
+ mobile: (0, path_1.resolve)(constant_1.SITE_DIR, 'mobile.html'),
74
+ },
75
+ },
76
+ } });
77
+ }
78
+ exports.getBuildConfig = getBuildConfig;
79
+ function inlineCSS(fileName, dir) {
80
+ return {
81
+ name: 'varlet-inline-css-vite-plugin',
82
+ apply: 'build',
83
+ closeBundle: function () {
84
+ var cssFile = (0, path_1.resolve)(dir, 'style.css');
85
+ if (!(0, fs_extra_1.pathExistsSync)(cssFile)) {
86
+ return;
87
+ }
88
+ var jsFile = (0, path_1.resolve)(dir, fileName);
89
+ var cssCode = (0, fs_extra_1.readFileSync)(cssFile, 'utf-8');
90
+ var jsCode = (0, fs_extra_1.readFileSync)(jsFile, 'utf-8');
91
+ var injectCode = ";(function(){var style=document.createElement('style');style.type='text/css';style.rel='stylesheet';style.appendChild(document.createTextNode(`".concat(cssCode.replace(/\\/g, '\\\\'), "`));var head=document.querySelector('head');head.appendChild(style)})();");
92
+ (0, fs_extra_1.writeFileSync)(jsFile, "".concat(injectCode).concat(jsCode));
93
+ (0, fs_extra_1.copyFileSync)(cssFile, (0, path_1.resolve)(constant_1.LIB_DIR, 'style.css'));
94
+ (0, fs_extra_1.removeSync)(cssFile);
95
+ },
96
+ };
97
+ }
98
+ function clear() {
99
+ return {
100
+ name: 'varlet-clear-vite-plugin',
101
+ apply: 'build',
102
+ closeBundle: function () {
103
+ (0, fs_extra_1.removeSync)((0, path_1.resolve)(constant_1.CWD, 'dist'));
104
+ },
105
+ };
106
+ }
107
+ function getESMBundleConfig(varletConfig) {
108
+ var name = (0, lodash_1.get)(varletConfig, 'name');
109
+ var fileName = "".concat((0, shared_1.kebabCase)(name), ".esm.js");
110
+ return {
111
+ logLevel: 'silent',
112
+ build: {
113
+ emptyOutDir: true,
114
+ lib: {
115
+ name: name,
116
+ formats: ['es'],
117
+ fileName: function () { return fileName; },
118
+ entry: (0, path_1.resolve)(constant_1.ES_DIR, 'umdIndex.js'),
119
+ },
120
+ rollupOptions: {
121
+ external: ['vue'],
122
+ output: {
123
+ dir: constant_1.ES_DIR,
124
+ exports: 'named',
125
+ globals: {
126
+ vue: 'Vue',
127
+ },
128
+ },
129
+ },
130
+ },
131
+ plugins: [clear()],
132
+ };
133
+ }
134
+ exports.getESMBundleConfig = getESMBundleConfig;
135
+ function getUMDConfig(varletConfig) {
136
+ var name = (0, lodash_1.get)(varletConfig, 'name');
137
+ var fileName = "".concat((0, shared_1.kebabCase)(name), ".js");
138
+ return {
139
+ logLevel: 'silent',
140
+ build: {
141
+ emptyOutDir: true,
142
+ lib: {
143
+ name: name,
144
+ formats: ['umd'],
145
+ fileName: function () { return fileName; },
146
+ entry: (0, path_1.resolve)(constant_1.ES_DIR, 'umdIndex.js'),
147
+ },
148
+ rollupOptions: {
149
+ external: ['vue'],
150
+ output: {
151
+ dir: constant_1.UMD_DIR,
152
+ exports: 'named',
153
+ globals: {
154
+ vue: 'Vue',
155
+ },
156
+ },
157
+ },
158
+ },
159
+ plugins: [inlineCSS(fileName, constant_1.UMD_DIR), clear()],
160
+ };
161
+ }
162
+ exports.getUMDConfig = getUMDConfig;
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ #!/usr/bin/env node
2
+ export {};
package/lib/index.js CHANGED
@@ -1,83 +1,83 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __read = (this && this.__read) || function (o, n) {
4
- var m = typeof Symbol === "function" && o[Symbol.iterator];
5
- if (!m) return o;
6
- var i = m.call(o), r, ar = [], e;
7
- try {
8
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
9
- }
10
- catch (error) { e = { error: error }; }
11
- finally {
12
- try {
13
- if (r && !r.done && (m = i["return"])) m.call(i);
14
- }
15
- finally { if (e) throw e.error; }
16
- }
17
- return ar;
18
- };
19
- var __importDefault = (this && this.__importDefault) || function (mod) {
20
- return (mod && mod.__esModule) ? mod : { "default": mod };
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- var logger_1 = __importDefault(require("./shared/logger"));
24
- var commander_1 = require("commander");
25
- var dev_1 = require("./commands/dev");
26
- var build_1 = require("./commands/build");
27
- var compile_1 = require("./commands/compile");
28
- var create_1 = require("./commands/create");
29
- var jest_1 = require("./commands/jest");
30
- var lint_1 = require("./commands/lint");
31
- var gen_1 = require("./commands/gen");
32
- var preview_1 = require("./commands/preview");
33
- var changelog_1 = require("./commands/changelog");
34
- var release_1 = require("./commands/release");
35
- var commitLint_1 = require("./commands/commitLint");
36
- var program = new commander_1.Command();
37
- program.version("varlet-cli ".concat(require('../package.json').version)).usage('<command> [options]');
38
- program
39
- .command('dev')
40
- .option('-f --force', 'Force dep pre-optimization regardless of whether deps have changed')
41
- .description('Run varlet development environment')
42
- .action(dev_1.dev);
43
- program.command('build').description('Build varlet site for production').action(build_1.build);
44
- program.command('preview').description('Preview varlet site for production').action(preview_1.preview);
45
- program
46
- .command('compile')
47
- .description('Compile varlet components library code')
48
- .option('-nu, --noUmd', 'Do not compile umd target code')
49
- .action(compile_1.compile);
50
- program.command('lint').description('Lint code').action(lint_1.lint);
51
- program
52
- .command('create <name>')
53
- .description('Create a component directory')
54
- .option('-d, --disableI18n', 'Disable to generator i18n files')
55
- .action(create_1.create);
56
- program
57
- .command('jest')
58
- .description('Run Jest in work directory')
59
- .option('-w, --watch', 'Watch files for changes and rerun tests related to changed files')
60
- .option('-wa, --watchAll', 'Watch files for changes and rerun all tests when something changes')
61
- .option('-c, --component <componentName>', 'Test a specific component')
62
- .option('-cc --clearCache', 'Clear test cache')
63
- .action(jest_1.jest);
64
- program.command('gen <name>').description('Generate cli application').action(gen_1.gen);
65
- program
66
- .command('changelog')
67
- .option('-rc --releaseCount <releaseCount>', 'Release count')
68
- .option('-f --file <file>', 'Changelog filename')
69
- .description('Generate changelog')
70
- .action(changelog_1.changelog);
71
- program
72
- .command('release')
73
- .option('-r --remote <remote>', 'Remote name')
74
- .description('Release all packages and generate changelogs')
75
- .action(release_1.release);
76
- program.command('commit-lint <gitParams>').description('Lint commit message').action(commitLint_1.commitLint);
77
- program.on('command:*', function (_a) {
78
- var _b = __read(_a, 1), cmd = _b[0];
79
- program.outputHelp();
80
- logger_1.default.error("\nUnknown command ".concat(cmd, ".\n"));
81
- process.exitCode = 1;
82
- });
83
- program.parse();
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __read = (this && this.__read) || function (o, n) {
4
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
5
+ if (!m) return o;
6
+ var i = m.call(o), r, ar = [], e;
7
+ try {
8
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
9
+ }
10
+ catch (error) { e = { error: error }; }
11
+ finally {
12
+ try {
13
+ if (r && !r.done && (m = i["return"])) m.call(i);
14
+ }
15
+ finally { if (e) throw e.error; }
16
+ }
17
+ return ar;
18
+ };
19
+ var __importDefault = (this && this.__importDefault) || function (mod) {
20
+ return (mod && mod.__esModule) ? mod : { "default": mod };
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ var logger_1 = __importDefault(require("./shared/logger"));
24
+ var commander_1 = require("commander");
25
+ var dev_1 = require("./commands/dev");
26
+ var build_1 = require("./commands/build");
27
+ var compile_1 = require("./commands/compile");
28
+ var create_1 = require("./commands/create");
29
+ var jest_1 = require("./commands/jest");
30
+ var lint_1 = require("./commands/lint");
31
+ var gen_1 = require("./commands/gen");
32
+ var preview_1 = require("./commands/preview");
33
+ var changelog_1 = require("./commands/changelog");
34
+ var release_1 = require("./commands/release");
35
+ var commitLint_1 = require("./commands/commitLint");
36
+ var program = new commander_1.Command();
37
+ program.version("varlet-cli ".concat(require('../package.json').version)).usage('<command> [options]');
38
+ program
39
+ .command('dev')
40
+ .option('-f --force', 'Force dep pre-optimization regardless of whether deps have changed')
41
+ .description('Run varlet development environment')
42
+ .action(dev_1.dev);
43
+ program.command('build').description('Build varlet site for production').action(build_1.build);
44
+ program.command('preview').description('Preview varlet site for production').action(preview_1.preview);
45
+ program
46
+ .command('compile')
47
+ .description('Compile varlet components library code')
48
+ .option('-nu, --noUmd', 'Do not compile umd target code')
49
+ .action(compile_1.compile);
50
+ program.command('lint').description('Lint code').action(lint_1.lint);
51
+ program
52
+ .command('create <name>')
53
+ .description('Create a component directory')
54
+ .option('-d, --disableI18n', 'Disable to generator i18n files')
55
+ .action(create_1.create);
56
+ program
57
+ .command('jest')
58
+ .description('Run Jest in work directory')
59
+ .option('-w, --watch', 'Watch files for changes and rerun tests related to changed files')
60
+ .option('-wa, --watchAll', 'Watch files for changes and rerun all tests when something changes')
61
+ .option('-c, --component <componentName>', 'Test a specific component')
62
+ .option('-cc --clearCache', 'Clear test cache')
63
+ .action(jest_1.jest);
64
+ program.command('gen <name>').description('Generate cli application').action(gen_1.gen);
65
+ program
66
+ .command('changelog')
67
+ .option('-rc --releaseCount <releaseCount>', 'Release count')
68
+ .option('-f --file <file>', 'Changelog filename')
69
+ .description('Generate changelog')
70
+ .action(changelog_1.changelog);
71
+ program
72
+ .command('release')
73
+ .option('-r --remote <remote>', 'Remote name')
74
+ .description('Release all packages and generate changelogs')
75
+ .action(release_1.release);
76
+ program.command('commit-lint <gitParams>').description('Lint commit message').action(commitLint_1.commitLint);
77
+ program.on('command:*', function (_a) {
78
+ var _b = __read(_a, 1), cmd = _b[0];
79
+ program.outputHelp();
80
+ logger_1.default.error("\nUnknown command ".concat(cmd, ".\n"));
81
+ process.exitCode = 1;
82
+ });
83
+ program.parse();
@@ -1,43 +1,43 @@
1
- export declare const CWD: string;
2
- export declare const VARLET_CONFIG: string;
3
- export declare const SRC_DIR: string;
4
- export declare const ES_DIR: string;
5
- export declare const LIB_DIR: string;
6
- export declare const UMD_DIR: string;
7
- export declare const TYPES_DIR: string;
8
- export declare const ROOT_DOCS_DIR: string;
9
- export declare const ROOT_PAGES_DIR: string;
10
- export declare const ESLINT_EXTENSIONS: string[];
11
- export declare const VITE_RESOLVE_EXTENSIONS: string[];
12
- export declare const SCRIPTS_EXTENSIONS: string[];
13
- export declare const PUBLIC_DIR_INDEXES: string[];
14
- export declare const STYLE_DIR_NAME = "style";
15
- export declare const EXAMPLE_DIR_NAME = "example";
16
- export declare const LOCALE_DIR_NAME = "locale";
17
- export declare const DOCS_DIR_NAME = "docs";
18
- export declare const DIR_INDEX = "index.vue";
19
- export declare const TESTS_DIR_NAME = "__tests__";
20
- export declare const GENERATORS_DIR: string;
21
- export declare const UI_PACKAGE_JSON: string;
22
- export declare const CLI_PACKAGE_JSON: string;
23
- export declare const SITE: string;
24
- export declare const SITE_OUTPUT_PATH: string;
25
- export declare const SITE_PUBLIC_PATH: string;
26
- export declare const SITE_DIR: string;
27
- export declare const SITE_PC_DIR: string;
28
- export declare const SITE_PC_ROUTES: string;
29
- export declare const SITE_MOBILE_ROUTES: string;
30
- export declare const SITE_CONFIG: string;
31
- export declare const HL_COMPONENT_NAME_RE: RegExp;
32
- export declare const HL_API_RE: RegExp;
33
- export declare const HL_TITLE_ATTRIBUTES_RE: RegExp;
34
- export declare const HL_TITLE_EVENTS_RE: RegExp;
35
- export declare const HL_TITLE_SLOTS_RE: RegExp;
36
- export declare const HL_MD = "zh-CN.md";
37
- export declare const HL_DIR: string;
38
- export declare const HL_TAGS_JSON: string;
39
- export declare const HL_ATTRIBUTES_JSON: string;
40
- export declare const HL_WEB_TYPES_JSON: string;
41
- export declare const JEST_CONFIG: string;
42
- export declare const JEST_MEDIA_MOCK: string;
43
- export declare const JEST_STYLE_MOCK: string;
1
+ export declare const CWD: string;
2
+ export declare const VARLET_CONFIG: string;
3
+ export declare const SRC_DIR: string;
4
+ export declare const ES_DIR: string;
5
+ export declare const LIB_DIR: string;
6
+ export declare const UMD_DIR: string;
7
+ export declare const TYPES_DIR: string;
8
+ export declare const ROOT_DOCS_DIR: string;
9
+ export declare const ROOT_PAGES_DIR: string;
10
+ export declare const ESLINT_EXTENSIONS: string[];
11
+ export declare const VITE_RESOLVE_EXTENSIONS: string[];
12
+ export declare const SCRIPTS_EXTENSIONS: string[];
13
+ export declare const PUBLIC_DIR_INDEXES: string[];
14
+ export declare const STYLE_DIR_NAME = "style";
15
+ export declare const EXAMPLE_DIR_NAME = "example";
16
+ export declare const LOCALE_DIR_NAME = "locale";
17
+ export declare const DOCS_DIR_NAME = "docs";
18
+ export declare const DIR_INDEX = "index.vue";
19
+ export declare const TESTS_DIR_NAME = "__tests__";
20
+ export declare const GENERATORS_DIR: string;
21
+ export declare const UI_PACKAGE_JSON: string;
22
+ export declare const CLI_PACKAGE_JSON: string;
23
+ export declare const SITE: string;
24
+ export declare const SITE_OUTPUT_PATH: string;
25
+ export declare const SITE_PUBLIC_PATH: string;
26
+ export declare const SITE_DIR: string;
27
+ export declare const SITE_PC_DIR: string;
28
+ export declare const SITE_PC_ROUTES: string;
29
+ export declare const SITE_MOBILE_ROUTES: string;
30
+ export declare const SITE_CONFIG: string;
31
+ export declare const HL_COMPONENT_NAME_RE: RegExp;
32
+ export declare const HL_API_RE: RegExp;
33
+ export declare const HL_TITLE_ATTRIBUTES_RE: RegExp;
34
+ export declare const HL_TITLE_EVENTS_RE: RegExp;
35
+ export declare const HL_TITLE_SLOTS_RE: RegExp;
36
+ export declare const HL_MD = "zh-CN.md";
37
+ export declare const HL_DIR: string;
38
+ export declare const HL_TAGS_JSON: string;
39
+ export declare const HL_ATTRIBUTES_JSON: string;
40
+ export declare const HL_WEB_TYPES_JSON: string;
41
+ export declare const JEST_CONFIG: string;
42
+ export declare const JEST_MEDIA_MOCK: string;
43
+ export declare const JEST_STYLE_MOCK: string;