@varlet/cli 2.0.6 → 2.1.0-alpha.1667210582672

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 (124) hide show
  1. package/README.en-US.md +2 -2
  2. package/README.md +2 -2
  3. package/cjs/babel.config.cjs +29 -0
  4. package/cjs/babel.sfc.transform.cjs +18 -0
  5. package/cjs/jest.config.cjs +33 -0
  6. package/cjs/jest.media.mock.cjs +1 -0
  7. package/cjs/jest.style.mock.cjs +1 -0
  8. package/client.d.ts +1 -0
  9. package/client.js +1 -0
  10. package/lib/client/appType.d.ts +4 -0
  11. package/lib/client/appType.js +7 -0
  12. package/lib/client/index.d.ts +17 -0
  13. package/lib/client/index.js +106 -0
  14. package/lib/{bin.d.ts → node/bin.d.ts} +0 -0
  15. package/lib/node/bin.js +122 -0
  16. package/lib/{commands → node/commands}/build.d.ts +0 -0
  17. package/lib/node/commands/build.js +15 -0
  18. package/lib/{commands → node/commands}/changelog.d.ts +0 -0
  19. package/lib/node/commands/changelog.js +20 -0
  20. package/lib/{commands → node/commands}/commitLint.d.ts +0 -0
  21. package/lib/node/commands/commitLint.js +45 -0
  22. package/lib/{commands → node/commands}/compile.d.ts +0 -0
  23. package/lib/node/commands/compile.js +35 -0
  24. package/lib/{commands → node/commands}/create.d.ts +0 -0
  25. package/lib/node/commands/create.js +91 -0
  26. package/lib/{commands → node/commands}/dev.d.ts +0 -0
  27. package/lib/node/commands/dev.js +38 -0
  28. package/lib/{commands → node/commands}/gen.d.ts +0 -0
  29. package/lib/node/commands/gen.js +75 -0
  30. package/lib/{commands → node/commands}/jest.d.ts +0 -0
  31. package/lib/node/commands/jest.js +27 -0
  32. package/lib/{commands → node/commands}/lint.d.ts +0 -0
  33. package/lib/node/commands/lint.js +42 -0
  34. package/lib/{commands → node/commands}/preview.d.ts +0 -0
  35. package/lib/node/commands/preview.js +18 -0
  36. package/lib/{commands → node/commands}/release.d.ts +0 -0
  37. package/lib/node/commands/release.js +146 -0
  38. package/lib/{commands → node/commands}/vite.d.ts +0 -0
  39. package/lib/node/commands/vite.js +13 -0
  40. package/lib/{compiler → node/compiler}/compileModule.d.ts +0 -0
  41. package/lib/node/compiler/compileModule.js +74 -0
  42. package/lib/{compiler → node/compiler}/compileSFC.d.ts +0 -0
  43. package/lib/node/compiler/compileSFC.js +79 -0
  44. package/lib/{compiler → node/compiler}/compileScript.d.ts +1 -1
  45. package/lib/node/compiler/compileScript.js +141 -0
  46. package/lib/{compiler → node/compiler}/compileSiteEntry.d.ts +0 -0
  47. package/lib/node/compiler/compileSiteEntry.js +128 -0
  48. package/lib/{compiler → node/compiler}/compileStyle.d.ts +0 -0
  49. package/lib/node/compiler/compileStyle.js +39 -0
  50. package/lib/{compiler → node/compiler}/compileTemplateHighlight.d.ts +0 -0
  51. package/lib/node/compiler/compileTemplateHighlight.js +133 -0
  52. package/lib/{compiler → node/compiler}/compileTypes.d.ts +0 -0
  53. package/lib/node/compiler/compileTypes.js +45 -0
  54. package/lib/{config → node/config}/varlet.config.d.ts +5 -4
  55. package/lib/node/config/varlet.config.js +27 -0
  56. package/lib/node/config/varlet.default.config.d.ts +2 -0
  57. package/lib/node/config/varlet.default.config.js +264 -0
  58. package/lib/node/config/vite.config.d.ts +6 -0
  59. package/lib/node/config/vite.config.js +144 -0
  60. package/lib/node/index.d.ts +1 -0
  61. package/lib/node/index.js +1 -0
  62. package/lib/{shared → node/shared}/constant.d.ts +1 -2
  63. package/lib/node/shared/constant.js +47 -0
  64. package/lib/{shared → node/shared}/fsUtils.d.ts +1 -0
  65. package/lib/node/shared/fsUtils.js +48 -0
  66. package/lib/{shared → node/shared}/logger.d.ts +0 -0
  67. package/lib/node/shared/logger.js +18 -0
  68. package/package.json +22 -20
  69. package/{preset.js → preset.cjs} +1 -1
  70. package/site/components/code-example/CodeExample.vue +2 -1
  71. package/site/components/utils/components.ts +1 -4
  72. package/site/components/utils/elements.ts +1 -1
  73. package/site/mobile/App.vue +27 -26
  74. package/site/mobile/components/AppHome.vue +2 -1
  75. package/site/pc/App.vue +2 -1
  76. package/site/pc/Layout.vue +4 -3
  77. package/site/pc/components/AppHeader.vue +4 -2
  78. package/site/pc/pages/index/index.vue +8 -4
  79. package/site/useProgress.ts +2 -1
  80. package/site/utils.ts +6 -137
  81. package/template/create/index.ts.ejs +1 -1
  82. package/template/generators/config/default/base/{varlet.config.js → varlet.config.mjs} +2 -2
  83. package/template/generators/config/i18n/base/{varlet.config.js → varlet.config.mjs} +2 -2
  84. package/tsconfig.json +2 -9
  85. package/lib/bin.js +0 -102
  86. package/lib/commands/build.js +0 -67
  87. package/lib/commands/changelog.js +0 -27
  88. package/lib/commands/commitLint.js +0 -21
  89. package/lib/commands/compile.js +0 -119
  90. package/lib/commands/create.js +0 -166
  91. package/lib/commands/dev.js +0 -123
  92. package/lib/commands/gen.js +0 -138
  93. package/lib/commands/jest.js +0 -85
  94. package/lib/commands/lint.js +0 -123
  95. package/lib/commands/preview.js +0 -74
  96. package/lib/commands/release.js +0 -305
  97. package/lib/commands/vite.js +0 -69
  98. package/lib/compiler/compileModule.js +0 -190
  99. package/lib/compiler/compileSFC.js +0 -135
  100. package/lib/compiler/compileScript.js +0 -194
  101. package/lib/compiler/compileSiteEntry.js +0 -237
  102. package/lib/compiler/compileStyle.js +0 -91
  103. package/lib/compiler/compileTemplateHighlight.js +0 -193
  104. package/lib/compiler/compileTypes.js +0 -85
  105. package/lib/config/babel.config.d.ts +0 -2
  106. package/lib/config/babel.config.js +0 -31
  107. package/lib/config/babel.sfc.transform.d.ts +0 -1
  108. package/lib/config/babel.sfc.transform.js +0 -18
  109. package/lib/config/jest.config.d.ts +0 -1
  110. package/lib/config/jest.config.js +0 -37
  111. package/lib/config/jest.media.mock.d.ts +0 -0
  112. package/lib/config/jest.media.mock.js +0 -2
  113. package/lib/config/jest.style.mock.d.ts +0 -0
  114. package/lib/config/jest.style.mock.js +0 -2
  115. package/lib/config/varlet.config.js +0 -35
  116. package/lib/config/vite.config.d.ts +0 -5
  117. package/lib/config/vite.config.js +0 -162
  118. package/lib/index.d.ts +0 -1
  119. package/lib/index.js +0 -5
  120. package/lib/shared/constant.js +0 -50
  121. package/lib/shared/fsUtils.js +0 -108
  122. package/lib/shared/logger.js +0 -23
  123. package/site/mobile/components/AppType.vue +0 -22
  124. package/varlet.default.config.js +0 -267
package/site/utils.ts CHANGED
@@ -1,43 +1,5 @@
1
- import { onMounted, onUnmounted } from 'vue'
2
1
  import { get } from 'lodash-es'
3
- import { formatStyleVars } from './components/utils/elements'
4
- import config from '@config'
5
-
6
- export * from './components/utils/components'
7
- export * from './components/utils/elements'
8
-
9
- export type StyleVars = Record<string, string>
10
-
11
- const mountedVarKeys: string[] = []
12
-
13
- function StyleProvider(styleVars: StyleVars | null = {}) {
14
- mountedVarKeys.forEach((key) => document.documentElement.style.removeProperty(key))
15
- mountedVarKeys.length = 0
16
-
17
- const styles: StyleVars = formatStyleVars(styleVars)
18
- Object.entries(styles).forEach(([key, value]) => {
19
- document.documentElement.style.setProperty(key, value)
20
- mountedVarKeys.push(key)
21
- })
22
- }
23
-
24
- export interface PCLocationInfo {
25
- language: string
26
- menuName: string
27
- }
28
-
29
- export function getPCLocationInfo(): PCLocationInfo {
30
- const [, language, menuName] = window.location.hash.split('/')
31
-
32
- return {
33
- language,
34
- menuName,
35
- }
36
- }
37
-
38
- export function isPhone() {
39
- return /Android|webOS|iPhone|iPod|BlackBerry|Pad/i.test(navigator.userAgent)
40
- }
2
+ import { StyleProvider, type Theme, withSiteConfigNamespace } from '@varlet/cli/client'
41
3
 
42
4
  export interface Menu {
43
5
  doc: string
@@ -51,10 +13,6 @@ export enum MenuTypes {
51
13
  DOCUMENTATION = 3,
52
14
  }
53
15
 
54
- export function inIframe() {
55
- return window.self !== window.top
56
- }
57
-
58
16
  export function removeEmpty(object: Record<string, string> = {}) {
59
17
  return Object.keys(object).reduce((record: Record<string, string>, key) => {
60
18
  const value = object[key]
@@ -63,109 +21,20 @@ export function removeEmpty(object: Record<string, string> = {}) {
63
21
  }, {})
64
22
  }
65
23
 
66
- export function getHashSearch() {
67
- const { href } = window.location
68
- const hashSearch = href.slice(href.indexOf('?'))
69
-
70
- return new URLSearchParams(hashSearch)
71
- }
72
-
73
- export function watchLang(cb: (lang: string) => void, platform: 'pc' | 'mobile' = 'mobile') {
74
- const handleHashchange = () => {
75
- const language = platform === 'mobile' ? getHashSearch().get('language') ?? 'zh-CN' : getPCLocationInfo().language
76
-
77
- cb(language)
78
- }
79
-
80
- addRouteListener(handleHashchange)
81
-
82
- handleHashchange()
83
- }
84
-
85
- export function watchPlatform(cb: (platform: string) => void) {
86
- const handleHashchange = () => {
87
- const platform = getHashSearch().get('platform') ?? 'mobile'
88
- cb(platform)
89
- }
90
-
91
- addRouteListener(handleHashchange)
92
-
93
- handleHashchange()
94
- }
95
-
96
- export function watchTheme(
97
- cb: (theme: Theme, from: 'pc' | 'mobile' | 'default' | 'playground') => void,
98
- shouldUnmount = true
99
- ) {
100
- const handleThemeChange = (event: MessageEvent) => {
101
- const { data } = event
102
- if (data.action === 'theme-change') {
103
- cb(data.data, data.from)
104
- }
105
- }
106
-
107
- window.addEventListener('message', handleThemeChange)
108
-
109
- if (shouldUnmount) {
110
- onUnmounted(() => {
111
- window.removeEventListener('message', handleThemeChange)
112
- })
113
- }
114
-
115
- cb(getBrowserTheme(), 'default')
24
+ export function isPhone() {
25
+ return /Android|webOS|iPhone|iPod|BlackBerry|Pad/i.test(navigator.userAgent)
116
26
  }
117
27
 
118
- export function addRouteListener(cb: () => void) {
119
- onMounted(() => {
120
- window.addEventListener('hashchange', cb)
121
- window.addEventListener('popstate', cb)
122
- })
123
- onUnmounted(() => {
124
- window.removeEventListener('hashchange', cb)
125
- window.removeEventListener('popstate', cb)
126
- })
28
+ export function inIframe() {
29
+ return window.self !== window.top
127
30
  }
128
31
 
129
- export type Theme = 'lightTheme' | 'darkTheme'
130
-
131
32
  export function setTheme(config: Record<string, any>, name: Theme) {
132
- const themeConfig = get(config, name, {})
133
- const styleVars = Object.entries(themeConfig).reduce((styleVars, [key, value]) => {
134
- styleVars[`--site-config-${key}`] = value as string
135
- return styleVars
136
- }, {} as StyleVars)
33
+ const styleVars = withSiteConfigNamespace(get(config, name, {}))
137
34
 
138
35
  StyleProvider(styleVars)
139
36
  }
140
37
 
141
- export function getBrowserTheme(): Theme {
142
- const themeKey = get(config, 'themeKey')
143
- const darkThemeConfig = get(config, 'darkTheme')
144
-
145
- if (!darkThemeConfig) {
146
- return 'lightTheme'
147
- }
148
-
149
- const storageTheme = window.localStorage.getItem(themeKey) as Theme
150
-
151
- if (!storageTheme) {
152
- const preferTheme = window.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'darkTheme' : 'lightTheme'
153
- window.localStorage.setItem(themeKey, preferTheme)
154
-
155
- return preferTheme
156
- }
157
-
158
- return storageTheme
159
- }
160
-
161
- export function watchDarkMode(dark: StyleVars, cb?: (theme: Theme) => void) {
162
- watchTheme((theme) => {
163
- StyleProvider(theme === 'darkTheme' ? dark : null)
164
-
165
- cb?.(theme)
166
- })
167
- }
168
-
169
38
  export function utoa(data: string): string {
170
39
  return btoa(unescape(encodeURIComponent(data)))
171
40
  }
@@ -1,5 +1,5 @@
1
1
  // Component entry, the folder where the file exists will be exposed to the user
2
- import <%- bigCamelizeName %> from './<%- bigCamelizeName %>.vue'
2
+ import <%- bigCamelizeName %> from './<%- bigCamelizeName %><%- style === 'vue' ? '.vue' : '' %>'
3
3
  import type { App } from 'vue'
4
4
 
5
5
  <%- bigCamelizeName %>.install = function(app: App) {
@@ -1,6 +1,6 @@
1
- const { defineConfig } = require('@varlet/cli')
1
+ import { defineConfig } from '@varlet/cli'
2
2
 
3
- module.exports = defineConfig({
3
+ export default defineConfig({
4
4
  logo: './logo.svg',
5
5
  useMobile: true,
6
6
  pc: {
@@ -1,6 +1,6 @@
1
- const { defineConfig } = require('@varlet/cli')
1
+ import { defineConfig } from '@varlet/cli'
2
2
 
3
- module.exports = defineConfig({
3
+ export default defineConfig({
4
4
  logo: './logo.svg',
5
5
  useMobile: true,
6
6
  pc: {
package/tsconfig.json CHANGED
@@ -1,14 +1,7 @@
1
1
  {
2
+ "extends": "../../tsconfig.json",
2
3
  "compilerOptions": {
3
- "outDir": "./lib",
4
- "target": "es5",
5
- "strict": true,
6
- "downlevelIteration": true,
7
- "declaration": true,
8
- "skipLibCheck": true,
9
- "esModuleInterop": true,
10
- "jsx": "preserve",
11
- "lib": ["esnext", "dom"]
4
+ "outDir": "./lib"
12
5
  },
13
6
  "include": ["src/**/*"]
14
7
  }
package/lib/bin.js DELETED
@@ -1,102 +0,0 @@
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 vite_1 = require("./commands/vite");
28
- var compile_1 = require("./commands/compile");
29
- var create_1 = require("./commands/create");
30
- var jest_1 = require("./commands/jest");
31
- var lint_1 = require("./commands/lint");
32
- var gen_1 = require("./commands/gen");
33
- var preview_1 = require("./commands/preview");
34
- var changelog_1 = require("./commands/changelog");
35
- var release_1 = require("./commands/release");
36
- var commitLint_1 = require("./commands/commitLint");
37
- var program = new commander_1.Command();
38
- program.version("varlet-cli ".concat(require('../package.json').version)).usage('<command> [options]');
39
- program
40
- .command('dev')
41
- .option('-f --force', 'Force dep pre-optimization regardless of whether deps have changed')
42
- .description('Run varlet development environment')
43
- .action(dev_1.dev);
44
- program.command('build').description('Build varlet site for production').action(build_1.build);
45
- program
46
- .command('build:vite')
47
- .description('Use vite build app for production')
48
- .action(function () { return (0, vite_1.vite)('build'); });
49
- program
50
- .command('dev:vite')
51
- .description('Use vite start server for development')
52
- .action(function () { return (0, vite_1.vite)('dev'); });
53
- program.command('preview').description('Preview varlet site for production').action(preview_1.preview);
54
- program
55
- .command('compile')
56
- .description('Compile varlet components library code')
57
- .option('-nu, --noUmd', 'Do not compile umd target code')
58
- .action(compile_1.compile);
59
- program.command('lint').description('Lint code').action(lint_1.lint);
60
- program
61
- .command('create')
62
- .description('Create a component directory')
63
- .option('-n, --name <componentName>', 'Component name')
64
- .option('-s, --sfc', 'Generate files in sfc format')
65
- .option('-t, --tsx', 'Generate files in tsx format')
66
- .option('-l, --locale', 'Generator internationalized files')
67
- .action(create_1.create);
68
- program
69
- .command('jest')
70
- .description('Run Jest in work directory')
71
- .option('-w, --watch', 'Watch files for changes and rerun tests related to changed files')
72
- .option('-wa, --watchAll', 'Watch files for changes and rerun all tests when something changes')
73
- .option('-c, --component <componentName>', 'Test a specific component')
74
- .option('-cc --clearCache', 'Clear test cache')
75
- .action(jest_1.jest);
76
- program
77
- .command('gen')
78
- .description('Generate cli application')
79
- .option('-n, --name <applicationName>', 'Application name')
80
- .option('-s, --sfc', 'Generate files in sfc format')
81
- .option('-t, --tsx', 'Generate files in tsx format')
82
- .option('-l, --locale', 'Generator internationalized files')
83
- .action(gen_1.gen);
84
- program
85
- .command('changelog')
86
- .option('-rc --releaseCount <releaseCount>', 'Release count')
87
- .option('-f --file <file>', 'Changelog filename')
88
- .description('Generate changelog')
89
- .action(changelog_1.changelog);
90
- program
91
- .command('release')
92
- .option('-r --remote <remote>', 'Remote name')
93
- .description('Release all packages and generate changelogs')
94
- .action(release_1.release);
95
- program.command('commit-lint <gitParams>').description('Lint commit message').action(commitLint_1.commitLint);
96
- program.on('command:*', function (_a) {
97
- var _b = __read(_a, 1), cmd = _b[0];
98
- program.outputHelp();
99
- logger_1.default.error("\nUnknown command ".concat(cmd, ".\n"));
100
- process.exitCode = 1;
101
- });
102
- program.parse();
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.build = void 0;
40
- var fs_extra_1 = require("fs-extra");
41
- var constant_1 = require("../shared/constant");
42
- var vite_1 = require("vite");
43
- var vite_config_1 = require("../config/vite.config");
44
- var varlet_config_1 = require("../config/varlet.config");
45
- var compileSiteEntry_1 = require("../compiler/compileSiteEntry");
46
- function build() {
47
- return __awaiter(this, void 0, void 0, function () {
48
- var varletConfig, buildConfig;
49
- return __generator(this, function (_a) {
50
- switch (_a.label) {
51
- case 0:
52
- process.env.NODE_ENV = 'production';
53
- (0, fs_extra_1.ensureDirSync)(constant_1.SRC_DIR);
54
- return [4 /*yield*/, (0, compileSiteEntry_1.buildSiteEntry)()];
55
- case 1:
56
- _a.sent();
57
- varletConfig = (0, varlet_config_1.getVarletConfig)();
58
- buildConfig = (0, vite_config_1.getBuildConfig)(varletConfig);
59
- return [4 /*yield*/, (0, vite_1.build)(buildConfig)];
60
- case 2:
61
- _a.sent();
62
- return [2 /*return*/];
63
- }
64
- });
65
- });
66
- }
67
- exports.build = build;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.changelog = void 0;
7
- var ora_1 = __importDefault(require("ora"));
8
- var conventional_changelog_1 = __importDefault(require("conventional-changelog"));
9
- var fs_extra_1 = require("fs-extra");
10
- var path_1 = require("path");
11
- var constant_1 = require("../shared/constant");
12
- function changelog(_a) {
13
- var _b = _a === void 0 ? {} : _a, _c = _b.releaseCount, releaseCount = _c === void 0 ? 0 : _c, _d = _b.file, file = _d === void 0 ? 'CHANGELOG.md' : _d;
14
- var s = (0, ora_1.default)().start("Generating changelog");
15
- return new Promise(function (resolve) {
16
- (0, conventional_changelog_1.default)({
17
- preset: 'angular',
18
- releaseCount: releaseCount,
19
- })
20
- .pipe((0, fs_extra_1.createWriteStream)((0, path_1.resolve)(constant_1.CWD, file)))
21
- .on('close', function () {
22
- s.succeed("Changelog generated success!");
23
- resolve();
24
- });
25
- });
26
- }
27
- exports.changelog = changelog;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.commitLint = void 0;
7
- var logger_1 = __importDefault(require("../shared/logger"));
8
- var semver_1 = __importDefault(require("semver"));
9
- function isVersion(message) {
10
- return message.startsWith('v') && semver_1.default.valid(message.slice(1));
11
- }
12
- function commitLint(gitParams) {
13
- var message = require('fs').readFileSync(gitParams, 'utf-8').trim();
14
- var COMMIT_MESSAGE_RE = /^(revert|fix|feat|docs|perf|test|types|style|build|chore|release|refactor)(\(.+\))?!?: (.|\n)+/;
15
- if (!isVersion(message) && !COMMIT_MESSAGE_RE.test(message)) {
16
- logger_1.default.error("Commit message invalid");
17
- logger_1.default.warning("The rules for commit messages are as follows\n\nExample:\n\nfeat: add a new feature\nfeat(ui/button): add a new feature in the ui/button scope\n\nfix: fix a bug\nfix(ui/button): fix a bug in the ui/button scope\n\ndocs: fix an error in the documentation\ndocs(ui/button): fix a documentation error in the ui/button scope\n\nAllowed types:\n- fix\n- feat\n- docs\n- perf\n- test\n- types\n- style\n- build\n- chore\n- release\n- refactor\n- revert\n\nCommit message reference: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y\n\u53C2\u8003\u962E\u4E00\u5CF0Commit message\u7F16\u5199\u6307\u5357: https://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html");
18
- process.exit(1);
19
- }
20
- }
21
- exports.commitLint = commitLint;
@@ -1,119 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.compile = exports.runTask = exports.removeDir = void 0;
43
- var ora_1 = __importDefault(require("ora"));
44
- var logger_1 = __importDefault(require("../shared/logger"));
45
- var fs_extra_1 = require("fs-extra");
46
- var constant_1 = require("../shared/constant");
47
- var compileModule_1 = require("../compiler/compileModule");
48
- var compileTemplateHighlight_1 = require("../compiler/compileTemplateHighlight");
49
- var compileTypes_1 = require("../compiler/compileTypes");
50
- function removeDir() {
51
- return Promise.all([(0, fs_extra_1.remove)(constant_1.ES_DIR), (0, fs_extra_1.remove)(constant_1.LIB_DIR), (0, fs_extra_1.remove)(constant_1.HL_DIR), (0, fs_extra_1.remove)(constant_1.UMD_DIR)]);
52
- }
53
- exports.removeDir = removeDir;
54
- function runTask(taskName, task) {
55
- return __awaiter(this, void 0, void 0, function () {
56
- var s, e_1;
57
- return __generator(this, function (_a) {
58
- switch (_a.label) {
59
- case 0:
60
- s = (0, ora_1.default)().start("Compiling ".concat(taskName));
61
- _a.label = 1;
62
- case 1:
63
- _a.trys.push([1, 3, , 4]);
64
- return [4 /*yield*/, task()];
65
- case 2:
66
- _a.sent();
67
- s.succeed("Compilation ".concat(taskName, " completed!"));
68
- return [3 /*break*/, 4];
69
- case 3:
70
- e_1 = _a.sent();
71
- s.fail("Compilation ".concat(taskName, " failed!"));
72
- logger_1.default.error(e_1.toString());
73
- return [3 /*break*/, 4];
74
- case 4: return [2 /*return*/];
75
- }
76
- });
77
- });
78
- }
79
- exports.runTask = runTask;
80
- function compile(options) {
81
- return __awaiter(this, void 0, void 0, function () {
82
- var _a;
83
- return __generator(this, function (_b) {
84
- switch (_b.label) {
85
- case 0:
86
- process.env.NODE_ENV = 'compile';
87
- return [4 /*yield*/, removeDir()];
88
- case 1:
89
- _b.sent();
90
- return [4 /*yield*/, Promise.all([runTask('types', compileTypes_1.compileTypes), runTask('template highlight', compileTemplateHighlight_1.compileTemplateHighlight)])];
91
- case 2:
92
- _b.sent();
93
- process.env.TARGET_MODULE = 'module';
94
- return [4 /*yield*/, runTask('module', compileModule_1.compileModule)];
95
- case 3:
96
- _b.sent();
97
- process.env.TARGET_MODULE = 'esm-bundle';
98
- return [4 /*yield*/, runTask('esm bundle', function () { return (0, compileModule_1.compileModule)('esm-bundle'); })];
99
- case 4:
100
- _b.sent();
101
- process.env.TARGET_MODULE = 'commonjs';
102
- return [4 /*yield*/, runTask('commonjs', function () { return (0, compileModule_1.compileModule)('commonjs'); })];
103
- case 5:
104
- _b.sent();
105
- process.env.TARGET_MODULE = 'umd';
106
- _a = !options.noUmd;
107
- if (!_a) return [3 /*break*/, 7];
108
- return [4 /*yield*/, runTask('umd', function () { return (0, compileModule_1.compileModule)('umd'); })];
109
- case 6:
110
- _a = (_b.sent());
111
- _b.label = 7;
112
- case 7:
113
- _a;
114
- return [2 /*return*/];
115
- }
116
- });
117
- });
118
- }
119
- exports.compile = compile;