@varlet/cli 1.27.8-alpha.1651665460392 → 1.27.8

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.
@@ -64,7 +64,7 @@ function create(name) {
64
64
  componentDir = (0, path_1.resolve)(constant_1.SRC_DIR, name);
65
65
  testsDir = (0, path_1.resolve)(constant_1.SRC_DIR, name, constant_1.TESTS_DIR_NAME);
66
66
  exampleDir = (0, path_1.resolve)(constant_1.SRC_DIR, name, constant_1.EXAMPLE_DIR_NAME);
67
- exampleLocalDir = (0, path_1.resolve)(constant_1.SRC_DIR, name, constant_1.EXAMPLE_DIR_NAME, constant_1.EXAMPLE_LOCALE_DIR_NAME);
67
+ exampleLocalDir = (0, path_1.resolve)(constant_1.SRC_DIR, name, constant_1.EXAMPLE_DIR_NAME, constant_1.LOCALE_DIR_NAME);
68
68
  docsDir = (0, path_1.resolve)(constant_1.SRC_DIR, name, constant_1.DOCS_DIR_NAME);
69
69
  if ((0, fs_extra_1.pathExistsSync)(componentDir)) {
70
70
  logger_1.default.error('component directory is existed');
@@ -1,9 +1,12 @@
1
1
  export declare function getExampleRoutePath(examplePath: string): string;
2
2
  export declare function getComponentDocRoutePath(componentDocsPath: string): string;
3
3
  export declare function getRootDocRoutePath(rootDocsPath: string): string;
4
+ export declare function getRootRoutePath(rootLocalePath: string): string;
5
+ export declare function getRootFilePath(rootLocalePath: string): string;
4
6
  export declare function findExamples(): Promise<string[]>;
5
7
  export declare function findComponentDocs(): Promise<string[]>;
6
8
  export declare function findRootDocs(): Promise<string[]>;
9
+ export declare function findRootLocales(): Promise<string[]>;
7
10
  export declare function buildMobileSiteRoutes(): Promise<void>;
8
11
  export declare function buildPcSiteRoutes(): Promise<void>;
9
12
  export declare function buildSiteSource(): Promise<void>;
@@ -60,15 +60,21 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
60
60
  }
61
61
  return to.concat(ar || Array.prototype.slice.call(from));
62
62
  };
63
+ var __importDefault = (this && this.__importDefault) || function (mod) {
64
+ return (mod && mod.__esModule) ? mod : { "default": mod };
65
+ };
63
66
  Object.defineProperty(exports, "__esModule", { value: true });
64
- exports.buildSiteEntry = exports.buildSiteSource = exports.buildPcSiteRoutes = exports.buildMobileSiteRoutes = exports.findRootDocs = exports.findComponentDocs = exports.findExamples = exports.getRootDocRoutePath = exports.getComponentDocRoutePath = exports.getExampleRoutePath = void 0;
67
+ exports.buildSiteEntry = exports.buildSiteSource = exports.buildPcSiteRoutes = exports.buildMobileSiteRoutes = exports.findRootLocales = exports.findRootDocs = exports.findComponentDocs = exports.findExamples = exports.getRootFilePath = exports.getRootRoutePath = exports.getRootDocRoutePath = exports.getComponentDocRoutePath = exports.getExampleRoutePath = void 0;
65
68
  var constant_1 = require("../shared/constant");
66
69
  var fs_extra_1 = require("fs-extra");
70
+ var slash_1 = __importDefault(require("slash"));
67
71
  var fsUtils_1 = require("../shared/fsUtils");
68
72
  var varlet_config_1 = require("../config/varlet.config");
73
+ var lodash_1 = require("lodash");
69
74
  var EXAMPLE_COMPONENT_NAME_RE = /\/([-\w]+)\/example\/index.vue/;
70
75
  var COMPONENT_DOCS_RE = /\/([-\w]+)\/docs\/([-\w]+)\.md/;
71
76
  var ROOT_DOCS_RE = /\/docs\/([-\w]+)\.([-\w]+)\.md/;
77
+ var ROOT_LOCALE_RE = /\/pages\/([-\w]+)\/locale\/([-\w]+)\.ts/;
72
78
  function getExampleRoutePath(examplePath) {
73
79
  var _a;
74
80
  return '/' + ((_a = examplePath.match(EXAMPLE_COMPONENT_NAME_RE)) === null || _a === void 0 ? void 0 : _a[1]);
@@ -86,8 +92,18 @@ function getRootDocRoutePath(rootDocsPath) {
86
92
  return "/".concat(language, "/").concat(routePath);
87
93
  }
88
94
  exports.getRootDocRoutePath = getRootDocRoutePath;
95
+ function getRootRoutePath(rootLocalePath) {
96
+ var _a;
97
+ var _b = __read((_a = rootLocalePath.match(ROOT_LOCALE_RE)) !== null && _a !== void 0 ? _a : [], 3), routePath = _b[1], language = _b[2];
98
+ return "/".concat(language, "/").concat(routePath);
99
+ }
100
+ exports.getRootRoutePath = getRootRoutePath;
101
+ function getRootFilePath(rootLocalePath) {
102
+ return rootLocalePath.replace(/locale\/.+/, constant_1.DIR_INDEX);
103
+ }
104
+ exports.getRootFilePath = getRootFilePath;
89
105
  function findExamples() {
90
- return (0, fsUtils_1.glob)("".concat(constant_1.SRC_DIR, "/**/").concat(constant_1.EXAMPLE_DIR_NAME, "/").concat(constant_1.EXAMPLE_DIR_INDEX));
106
+ return (0, fsUtils_1.glob)("".concat(constant_1.SRC_DIR, "/**/").concat(constant_1.EXAMPLE_DIR_NAME, "/").concat(constant_1.DIR_INDEX));
91
107
  }
92
108
  exports.findExamples = findExamples;
93
109
  function findComponentDocs() {
@@ -98,6 +114,61 @@ function findRootDocs() {
98
114
  return (0, fsUtils_1.glob)("".concat(constant_1.ROOT_DOCS_DIR, "/*.md"));
99
115
  }
100
116
  exports.findRootDocs = findRootDocs;
117
+ function findRootLocales() {
118
+ return __awaiter(this, void 0, void 0, function () {
119
+ var defaultLanguage, userPages, baseLocales, userLocales, filterMap;
120
+ var _this = this;
121
+ return __generator(this, function (_a) {
122
+ switch (_a.label) {
123
+ case 0:
124
+ defaultLanguage = (0, lodash_1.get)((0, varlet_config_1.getVarletConfig)(), 'defaultLanguage');
125
+ return [4 /*yield*/, (0, fsUtils_1.glob)("".concat(constant_1.ROOT_PAGES_DIR, "/*"))];
126
+ case 1:
127
+ userPages = _a.sent();
128
+ return [4 /*yield*/, (0, fsUtils_1.glob)("".concat(constant_1.SITE, "/pc/pages/**/").concat(constant_1.LOCALE_DIR_NAME, "/*.ts"))];
129
+ case 2:
130
+ baseLocales = _a.sent();
131
+ return [4 /*yield*/, userPages.reduce(function (userLocales, page) { return __awaiter(_this, void 0, void 0, function () {
132
+ var locales;
133
+ var _a;
134
+ return __generator(this, function (_b) {
135
+ switch (_b.label) {
136
+ case 0:
137
+ if (!(0, fsUtils_1.isDir)(page)) return [3 /*break*/, 3];
138
+ return [4 /*yield*/, (0, fsUtils_1.glob)("".concat(page, "/").concat(constant_1.LOCALE_DIR_NAME, "/*.ts"))];
139
+ case 1:
140
+ locales = _b.sent();
141
+ if (!locales.length)
142
+ locales.push("".concat(page, "/").concat(constant_1.LOCALE_DIR_NAME, "/").concat(defaultLanguage, ".ts"));
143
+ return [4 /*yield*/, userLocales];
144
+ case 2:
145
+ (_a = (_b.sent())).push.apply(_a, __spreadArray([], __read(locales), false));
146
+ _b.label = 3;
147
+ case 3: return [2 /*return*/, userLocales];
148
+ }
149
+ });
150
+ }); }, Promise.resolve([]))
151
+ // filter
152
+ ];
153
+ case 3:
154
+ userLocales = _a.sent();
155
+ filterMap = new Map();
156
+ baseLocales.forEach(function (locale) {
157
+ var _a;
158
+ var _b = __read((_a = locale.match(ROOT_LOCALE_RE)) !== null && _a !== void 0 ? _a : [], 3), routePath = _b[1], language = _b[2];
159
+ filterMap.set(routePath + language, (0, slash_1.default)("".concat(constant_1.SITE_PC_DIR, "/pages/").concat(routePath, "/locale/").concat(language, ".ts")));
160
+ });
161
+ userLocales.forEach(function (locale) {
162
+ var _a;
163
+ var _b = __read((_a = locale.match(ROOT_LOCALE_RE)) !== null && _a !== void 0 ? _a : [], 3), routePath = _b[1], language = _b[2];
164
+ filterMap.set(routePath + language, locale);
165
+ });
166
+ return [2 /*return*/, Promise.resolve(Array.from(filterMap.values()))];
167
+ }
168
+ });
169
+ });
170
+ }
171
+ exports.findRootLocales = findRootLocales;
101
172
  function buildMobileSiteRoutes() {
102
173
  return __awaiter(this, void 0, void 0, function () {
103
174
  var examples, routes, source;
@@ -107,7 +178,7 @@ function buildMobileSiteRoutes() {
107
178
  case 1:
108
179
  examples = _a.sent();
109
180
  routes = examples.map(function (example) { return "\n {\n path: '".concat(getExampleRoutePath(example), "',\n // @ts-ignore\n component: () => import('").concat(example, "')\n }"); });
110
- source = "export default [ ".concat(routes.join(','), "\n]");
181
+ source = "export default [ ".concat(routes.join(','), "\n]");
111
182
  return [4 /*yield*/, (0, fsUtils_1.outputFileSyncOnChange)(constant_1.SITE_MOBILE_ROUTES, source)];
112
183
  case 2:
113
184
  _a.sent();
@@ -119,15 +190,21 @@ function buildMobileSiteRoutes() {
119
190
  exports.buildMobileSiteRoutes = buildMobileSiteRoutes;
120
191
  function buildPcSiteRoutes() {
121
192
  return __awaiter(this, void 0, void 0, function () {
122
- var _a, componentDocs, rootDocs, componentDocsRoutes, rootDocsRoutes, source;
193
+ var _a, componentDocs, rootDocs, rootLocales, rootPagesRoutes, componentDocsRoutes, rootDocsRoutes, layoutRoutes, source;
123
194
  return __generator(this, function (_b) {
124
195
  switch (_b.label) {
125
- case 0: return [4 /*yield*/, Promise.all([findComponentDocs(), findRootDocs()])];
196
+ case 0: return [4 /*yield*/, Promise.all([
197
+ findComponentDocs(),
198
+ findRootDocs(),
199
+ findRootLocales(),
200
+ ])];
126
201
  case 1:
127
- _a = __read.apply(void 0, [_b.sent(), 2]), componentDocs = _a[0], rootDocs = _a[1];
128
- componentDocsRoutes = componentDocs.map(function (componentDoc) { return "\n {\n path: '".concat(getComponentDocRoutePath(componentDoc), "',\n // @ts-ignore\n component: () => import('").concat(componentDoc, "')\n }"); });
129
- rootDocsRoutes = rootDocs.map(function (rootDoc) { return "\n {\n path: '".concat(getRootDocRoutePath(rootDoc), "',\n // @ts-ignore\n component: () => import('").concat(rootDoc, "')\n }"); });
130
- source = "export default [ ".concat(__spreadArray(__spreadArray([], __read(componentDocsRoutes), false), [rootDocsRoutes], false).join(','), "\n]");
202
+ _a = __read.apply(void 0, [_b.sent(), 3]), componentDocs = _a[0], rootDocs = _a[1], rootLocales = _a[2];
203
+ rootPagesRoutes = rootLocales.map(function (rootLocale) { return "\n {\n path: '".concat(getRootRoutePath(rootLocale), "',\n // @ts-ignore\n component: () => import('").concat(getRootFilePath(rootLocale), "')\n }"); });
204
+ componentDocsRoutes = componentDocs.map(function (componentDoc) { return "\n {\n path: '".concat(getComponentDocRoutePath(componentDoc), "',\n // @ts-ignore\n component: () => import('").concat(componentDoc, "')\n }"); });
205
+ rootDocsRoutes = rootDocs.map(function (rootDoc) { return "\n {\n path: '".concat(getRootDocRoutePath(rootDoc), "',\n // @ts-ignore\n component: () => import('").concat(rootDoc, "')\n }"); });
206
+ layoutRoutes = "{\n path: '/layout',\n // @ts-ignore\n component:()=> import('".concat((0, slash_1.default)(constant_1.SITE_PC_DIR), "/Layout.vue'),\n children: [\n ").concat(__spreadArray(__spreadArray([], __read(componentDocsRoutes), false), [rootDocsRoutes], false).join(','), ",\n ]\n }");
207
+ source = "export default [ ".concat(rootPagesRoutes.join(','), ",\n ").concat(layoutRoutes, "\n]");
131
208
  (0, fsUtils_1.outputFileSyncOnChange)(constant_1.SITE_PC_ROUTES, source);
132
209
  return [2 /*return*/];
133
210
  }
@@ -6,15 +6,16 @@ export declare const LIB_DIR: string;
6
6
  export declare const UMD_DIR: string;
7
7
  export declare const TYPES_DIR: string;
8
8
  export declare const ROOT_DOCS_DIR: string;
9
+ export declare const ROOT_PAGES_DIR: string;
9
10
  export declare const ESLINT_EXTENSIONS: string[];
10
11
  export declare const VITE_RESOLVE_EXTENSIONS: string[];
11
12
  export declare const SCRIPTS_EXTENSIONS: string[];
12
13
  export declare const PUBLIC_DIR_INDEXES: string[];
13
14
  export declare const STYLE_DIR_NAME = "style";
14
15
  export declare const EXAMPLE_DIR_NAME = "example";
15
- export declare const EXAMPLE_LOCALE_DIR_NAME = "locale";
16
+ export declare const LOCALE_DIR_NAME = "locale";
16
17
  export declare const DOCS_DIR_NAME = "docs";
17
- export declare const EXAMPLE_DIR_INDEX = "index.vue";
18
+ export declare const DIR_INDEX = "index.vue";
18
19
  export declare const TESTS_DIR_NAME = "__tests__";
19
20
  export declare const GENERATORS_DIR: string;
20
21
  export declare const UI_PACKAGE_JSON: string;
@@ -23,6 +24,7 @@ export declare const SITE: string;
23
24
  export declare const SITE_OUTPUT_PATH: string;
24
25
  export declare const SITE_PUBLIC_PATH: string;
25
26
  export declare const SITE_DIR: string;
27
+ export declare const SITE_PC_DIR: string;
26
28
  export declare const SITE_PC_ROUTES: string;
27
29
  export declare const SITE_MOBILE_ROUTES: string;
28
30
  export declare const SITE_CONFIG: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JEST_STYLE_MOCK = exports.JEST_MEDIA_MOCK = exports.JEST_CONFIG = exports.HL_WEB_TYPES_JSON = exports.HL_ATTRIBUTES_JSON = exports.HL_TAGS_JSON = exports.HL_DIR = exports.HL_MD = exports.HL_TITLE_SLOTS_RE = exports.HL_TITLE_EVENTS_RE = exports.HL_TITLE_ATTRIBUTES_RE = exports.HL_API_RE = exports.HL_COMPONENT_NAME_RE = exports.SITE_CONFIG = exports.SITE_MOBILE_ROUTES = exports.SITE_PC_ROUTES = exports.SITE_DIR = exports.SITE_PUBLIC_PATH = exports.SITE_OUTPUT_PATH = exports.SITE = exports.CLI_PACKAGE_JSON = exports.UI_PACKAGE_JSON = exports.GENERATORS_DIR = exports.TESTS_DIR_NAME = exports.EXAMPLE_DIR_INDEX = exports.DOCS_DIR_NAME = exports.EXAMPLE_LOCALE_DIR_NAME = exports.EXAMPLE_DIR_NAME = exports.STYLE_DIR_NAME = exports.PUBLIC_DIR_INDEXES = exports.SCRIPTS_EXTENSIONS = exports.VITE_RESOLVE_EXTENSIONS = exports.ESLINT_EXTENSIONS = exports.ROOT_DOCS_DIR = exports.TYPES_DIR = exports.UMD_DIR = exports.LIB_DIR = exports.ES_DIR = exports.SRC_DIR = exports.VARLET_CONFIG = exports.CWD = void 0;
3
+ exports.JEST_STYLE_MOCK = exports.JEST_MEDIA_MOCK = exports.JEST_CONFIG = exports.HL_WEB_TYPES_JSON = exports.HL_ATTRIBUTES_JSON = exports.HL_TAGS_JSON = exports.HL_DIR = exports.HL_MD = exports.HL_TITLE_SLOTS_RE = exports.HL_TITLE_EVENTS_RE = exports.HL_TITLE_ATTRIBUTES_RE = exports.HL_API_RE = exports.HL_COMPONENT_NAME_RE = exports.SITE_CONFIG = exports.SITE_MOBILE_ROUTES = exports.SITE_PC_ROUTES = exports.SITE_PC_DIR = exports.SITE_DIR = exports.SITE_PUBLIC_PATH = exports.SITE_OUTPUT_PATH = exports.SITE = exports.CLI_PACKAGE_JSON = exports.UI_PACKAGE_JSON = exports.GENERATORS_DIR = exports.TESTS_DIR_NAME = exports.DIR_INDEX = exports.DOCS_DIR_NAME = exports.LOCALE_DIR_NAME = exports.EXAMPLE_DIR_NAME = exports.STYLE_DIR_NAME = exports.PUBLIC_DIR_INDEXES = exports.SCRIPTS_EXTENSIONS = exports.VITE_RESOLVE_EXTENSIONS = exports.ESLINT_EXTENSIONS = exports.ROOT_PAGES_DIR = exports.ROOT_DOCS_DIR = exports.TYPES_DIR = exports.UMD_DIR = exports.LIB_DIR = exports.ES_DIR = exports.SRC_DIR = exports.VARLET_CONFIG = exports.CWD = void 0;
4
4
  var path_1 = require("path");
5
5
  exports.CWD = process.cwd();
6
6
  exports.VARLET_CONFIG = (0, path_1.resolve)(exports.CWD, 'varlet.config.js');
@@ -10,15 +10,16 @@ exports.LIB_DIR = (0, path_1.resolve)(exports.CWD, 'lib');
10
10
  exports.UMD_DIR = (0, path_1.resolve)(exports.CWD, 'umd');
11
11
  exports.TYPES_DIR = (0, path_1.resolve)(exports.CWD, 'types');
12
12
  exports.ROOT_DOCS_DIR = (0, path_1.resolve)(exports.CWD, 'docs');
13
+ exports.ROOT_PAGES_DIR = (0, path_1.resolve)(exports.CWD, 'pages');
13
14
  exports.ESLINT_EXTENSIONS = ['.vue', '.ts', '.js', '.mjs', '.tsx', '.jsx'];
14
15
  exports.VITE_RESOLVE_EXTENSIONS = ['.vue', '.tsx', '.ts', '.jsx', '.js', '.less', '.css'];
15
16
  exports.SCRIPTS_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js'];
16
17
  exports.PUBLIC_DIR_INDEXES = ['index.vue', 'index.tsx', 'index.ts', 'index.jsx', 'index.js'];
17
18
  exports.STYLE_DIR_NAME = 'style';
18
19
  exports.EXAMPLE_DIR_NAME = 'example';
19
- exports.EXAMPLE_LOCALE_DIR_NAME = 'locale';
20
+ exports.LOCALE_DIR_NAME = 'locale';
20
21
  exports.DOCS_DIR_NAME = 'docs';
21
- exports.EXAMPLE_DIR_INDEX = 'index.vue';
22
+ exports.DIR_INDEX = 'index.vue';
22
23
  exports.TESTS_DIR_NAME = '__tests__';
23
24
  exports.GENERATORS_DIR = (0, path_1.resolve)(__dirname, '../../generators');
24
25
  exports.UI_PACKAGE_JSON = (0, path_1.resolve)(exports.CWD, 'package.json');
@@ -28,6 +29,7 @@ exports.SITE = (0, path_1.resolve)(__dirname, '../../site');
28
29
  exports.SITE_OUTPUT_PATH = (0, path_1.resolve)(exports.CWD, 'site');
29
30
  exports.SITE_PUBLIC_PATH = (0, path_1.resolve)(exports.CWD, 'public');
30
31
  exports.SITE_DIR = (0, path_1.resolve)(exports.CWD, '.varlet/site');
32
+ exports.SITE_PC_DIR = (0, path_1.resolve)(exports.CWD, '.varlet/site/pc');
31
33
  exports.SITE_PC_ROUTES = (0, path_1.resolve)(exports.CWD, '.varlet/pc.routes.ts');
32
34
  exports.SITE_MOBILE_ROUTES = (0, path_1.resolve)(exports.CWD, '.varlet/mobile.routes.ts');
33
35
  exports.SITE_CONFIG = (0, path_1.resolve)(exports.CWD, '.varlet/site.config.json');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "1.27.8-alpha.1651665460392",
3
+ "version": "1.27.8",
4
4
  "description": "cli of varlet",
5
5
  "bin": {
6
6
  "varlet-cli": "./lib/index.js"
@@ -33,9 +33,9 @@
33
33
  "@babel/helper-plugin-utils": "^7.14.5",
34
34
  "@babel/preset-env": "^7.14.8",
35
35
  "@babel/preset-typescript": "^7.14.5",
36
- "@varlet/icons": "1.27.8-alpha.1651665460392",
37
- "@varlet/markdown-vite-plugin": "1.27.8-alpha.1651665460392",
38
- "@varlet/touch-emulator": "1.27.8-alpha.1651665460392",
36
+ "@varlet/icons": "1.27.8",
37
+ "@varlet/markdown-vite-plugin": "1.27.8",
38
+ "@varlet/touch-emulator": "1.27.8",
39
39
  "@vitejs/plugin-vue": "2.2.0",
40
40
  "@vitejs/plugin-vue-jsx": "1.3.5",
41
41
  "@vue/babel-plugin-jsx": "1.1.1",
@@ -75,7 +75,7 @@
75
75
  "@types/semver": "^7.3.9"
76
76
  },
77
77
  "peerDependencies": {
78
- "@varlet/touch-emulator": "1.27.8-alpha.1651665460392",
78
+ "@varlet/touch-emulator": "1.27.8",
79
79
  "@vue/test-utils": "^2.0.0-rc.6",
80
80
  "clipboard": "^2.0.6",
81
81
  "live-server": "^1.2.1",
@@ -7,7 +7,7 @@
7
7
  block ? 'var-site--flex var-site-button--block' : 'var-site--inline-flex',
8
8
  disabled ? 'var-site-button--disabled' : null,
9
9
  text ? `var-site-button--text-${type}` : `var-site-button--${type}`,
10
- text ? 'var-site-button--text' : 'var-elevation--1',
10
+ text ? 'var-site-button--text' : 'var-site-elevation--1',
11
11
  text && disabled ? 'var-site-button--text-disabled' : null,
12
12
  round ? 'var-site-button--round' : null,
13
13
  outline ? 'var-site-button--outline' : null,
package/site/index.html CHANGED
@@ -20,6 +20,14 @@
20
20
  font-style: normal;
21
21
  font-display: swap;
22
22
  }
23
+ body {
24
+ box-sizing: border-box;
25
+ margin: 0;
26
+ padding: 0px;
27
+ font-family: 'Roboto', sans-serif;
28
+ background: var(--site-config-color-body);
29
+ color: var(--site-config-color-text);
30
+ }
23
31
  </style>
24
32
  <script>
25
33
  if ('<%= baidu %>') {