@varlet/cli 1.27.15 → 1.27.17

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.
@@ -38,6 +38,7 @@
38
38
  "@varlet/icons": "workspace:*",
39
39
  "@varlet/stylelint-config": "workspace:*",
40
40
  "@varlet/touch-emulator": "workspace:*",
41
+ "@varlet/shared": "workspace:*",
41
42
  "@vue/test-utils": "2.0.0-rc.6",
42
43
  "clipboard": "^2.0.6",
43
44
  "eslint": "^7.30.0",
@@ -38,6 +38,7 @@
38
38
  "@varlet/icons": "workspace:*",
39
39
  "@varlet/stylelint-config": "workspace:*",
40
40
  "@varlet/touch-emulator": "workspace:*",
41
+ "@varlet/shared": "workspace:*",
41
42
  "@vue/test-utils": "2.0.0-rc.6",
42
43
  "clipboard": "^2.0.6",
43
44
  "eslint": "^7.30.0",
@@ -66,7 +66,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
66
66
  Object.defineProperty(exports, "__esModule", { value: true });
67
67
  exports.create = void 0;
68
68
  var logger_1 = __importDefault(require("../shared/logger"));
69
- var fsUtils_1 = require("../shared/fsUtils");
69
+ var shared_1 = require("@varlet/shared");
70
70
  var fs_extra_1 = require("fs-extra");
71
71
  var path_1 = require("path");
72
72
  var constant_1 = require("../shared/constant");
@@ -80,8 +80,8 @@ function create(name, cmd) {
80
80
  case 0:
81
81
  i18nFiles = [];
82
82
  namespace = (0, lodash_1.get)((0, varlet_config_1.getVarletConfig)(), 'namespace');
83
- bigCamelizeName = (0, fsUtils_1.bigCamelize)(name);
84
- vueTemplate = "<template>\n <div class=\"".concat(namespace, "-").concat(name, "\"></div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue'\n\nexport default defineComponent({\n name: '").concat((0, fsUtils_1.bigCamelize)(namespace)).concat(bigCamelizeName, "'\n})\n</script>\n\n<style lang=\"less\">\n.").concat(namespace, "-").concat(name, " {\n display: flex;\n}\n</style>\n");
83
+ bigCamelizeName = (0, shared_1.bigCamelize)(name);
84
+ vueTemplate = "<template>\n <div class=\"".concat(namespace, "-").concat(name, "\"></div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue'\n\nexport default defineComponent({\n name: '").concat((0, shared_1.bigCamelize)(namespace)).concat(bigCamelizeName, "'\n})\n</script>\n\n<style lang=\"less\">\n.").concat(namespace, "-").concat(name, " {\n display: flex;\n}\n</style>\n");
85
85
  indexTemplate = "import ".concat(bigCamelizeName, " from './").concat(bigCamelizeName, ".vue'\nimport type { App } from 'vue'\n\n").concat(bigCamelizeName, ".install = function(app: App) {\n app.component(").concat(bigCamelizeName, ".name, ").concat(bigCamelizeName, ")\n}\n\nexport const _").concat(bigCamelizeName, "Component = ").concat(bigCamelizeName, "\n\nexport default ").concat(bigCamelizeName, "\n");
86
86
  testsTemplate = "import ".concat(bigCamelizeName, " from '..'\nimport { createApp } from 'vue'\nimport { mount } from '@vue/test-utils'\n\ntest('test ").concat(name, " use', () => {\n const app = createApp({}).use(").concat(bigCamelizeName, ")\n expect(app.component(").concat(bigCamelizeName, ".name)).toBeTruthy()\n})\n");
87
87
  exampleTemplate = "<script setup>\nimport ".concat(bigCamelizeName, " from '..'\nimport AppType from '@varlet/cli/site/mobile/components/AppType'\n</script>\n\n<template>\n <app-type></app-type>\n <").concat(namespace, "-").concat(name, "/>\n</template>\n");
@@ -38,6 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.compileCommonJSEntry = exports.compileESEntry = exports.compileScriptFile = exports.compileScript = exports.moduleCompatible = exports.replaceTSXExt = exports.replaceJSXExt = exports.replaceTSExt = exports.replaceVueExt = exports.REQUIRE_TSX_PATH_RE = exports.REQUIRE_JSX_PATH_RE = exports.REQUIRE_TS_PATH_RE = exports.REQUIRE_VUE_PATH_RE = exports.IMPORT_TSX_PATH_RE = exports.IMPORT_JSX_PATH_RE = exports.IMPORT_TS_PATH_RE = exports.IMPORT_VUE_PATH_RE = void 0;
40
40
  var core_1 = require("@babel/core");
41
+ var shared_1 = require("@varlet/shared");
41
42
  var fsUtils_1 = require("../shared/fsUtils");
42
43
  var fs_extra_1 = require("fs-extra");
43
44
  var compileStyle_1 = require("./compileStyle");
@@ -136,7 +137,7 @@ function compileESEntry(dir, publicDirs) {
136
137
  lessImports = [];
137
138
  publicComponents = [];
138
139
  publicDirs.forEach(function (dirname) {
139
- var publicComponent = (0, fsUtils_1.bigCamelize)(dirname);
140
+ var publicComponent = (0, shared_1.bigCamelize)(dirname);
140
141
  publicComponents.push(publicComponent);
141
142
  imports.push("import ".concat(publicComponent, ", * as ").concat(publicComponent, "Module from './").concat(dirname, "'"));
142
143
  constInternalComponents.push("export const _".concat(publicComponent, "Component = ").concat(publicComponent, "Module._").concat(publicComponent, "Component || {}"));
@@ -175,7 +176,7 @@ function compileCommonJSEntry(dir, publicDirs) {
175
176
  lessRequires = [];
176
177
  publicComponents = [];
177
178
  publicDirs.forEach(function (dirname) {
178
- var publicComponent = (0, fsUtils_1.bigCamelize)(dirname);
179
+ var publicComponent = (0, shared_1.bigCamelize)(dirname);
179
180
  publicComponents.push(publicComponent);
180
181
  requires.push("var ".concat(publicComponent, " = require('./").concat(dirname, "')['default']"));
181
182
  plugins.push("".concat(publicComponent, ".install && app.use(").concat(publicComponent, ")"));
@@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.compileTypes = exports.generateReference = void 0;
40
40
  var fs_extra_1 = require("fs-extra");
41
41
  var constant_1 = require("../shared/constant");
42
- var fsUtils_1 = require("../shared/fsUtils");
42
+ var shared_1 = require("@varlet/shared");
43
43
  var path_1 = require("path");
44
44
  var varlet_config_1 = require("../config/varlet.config");
45
45
  var lodash_1 = require("lodash");
@@ -69,7 +69,7 @@ function compileTypes() {
69
69
  var componentName = filename.slice(0, filename.indexOf('.d.ts'));
70
70
  exports.push("export * from './".concat(componentName, "'"));
71
71
  if (!componentName.startsWith(namespace)) {
72
- declares.push("".concat((0, fsUtils_1.bigCamelize)(namespace)).concat((0, fsUtils_1.bigCamelize)(componentName), ": typeof import('").concat(name, "')['_").concat((0, fsUtils_1.bigCamelize)(componentName), "Component']"));
72
+ declares.push("".concat((0, shared_1.bigCamelize)(namespace)).concat((0, shared_1.bigCamelize)(componentName), ": typeof import('").concat(name, "')['_").concat((0, shared_1.bigCamelize)(componentName), "Component']"));
73
73
  }
74
74
  });
75
75
  template = "import type { App } from 'vue'\n\nexport const install: (app: App) => void\n\n".concat(exports.join('\n'), "\n");
@@ -2,15 +2,11 @@ export declare function getPublicDirs(): Promise<string[]>;
2
2
  export declare const isMD: (file: string) => boolean;
3
3
  export declare const isDir: (file: string) => boolean;
4
4
  export declare const isSFC: (file: string) => boolean;
5
- export declare const isJSX: (file: string) => boolean;
6
- export declare const isTSX: (file: string) => boolean;
7
5
  export declare const isDTS: (file: string) => boolean;
8
6
  export declare const isScript: (file: string) => boolean;
9
7
  export declare const isLess: (file: string) => boolean;
10
8
  export declare const isPublicDir: (dir: string) => boolean;
11
9
  export declare const replaceExt: (file: string, ext: string) => string;
12
- export declare const bigCamelize: (s: string) => string;
13
- export declare const camelize: (s: string) => string;
14
10
  export declare function smartAppendFileSync(file: string, code: string): void;
15
11
  export declare function outputFileSyncOnChange(path: string, code: string): void;
16
12
  export declare function glob(pattern: string): Promise<string[]>;
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.glob = exports.outputFileSyncOnChange = exports.smartAppendFileSync = exports.camelize = exports.bigCamelize = exports.replaceExt = exports.isPublicDir = exports.isLess = exports.isScript = exports.isDTS = exports.isTSX = exports.isJSX = exports.isSFC = exports.isDir = exports.isMD = exports.getPublicDirs = void 0;
42
+ exports.glob = exports.outputFileSyncOnChange = exports.smartAppendFileSync = exports.replaceExt = exports.isPublicDir = exports.isLess = exports.isScript = exports.isDTS = exports.isSFC = exports.isDir = exports.isMD = exports.getPublicDirs = void 0;
43
43
  var path_1 = require("path");
44
44
  var fs_extra_1 = require("fs-extra");
45
45
  var constant_1 = require("./constant");
@@ -64,10 +64,6 @@ var isDir = function (file) { return (0, fs_extra_1.pathExistsSync)(file) && (0,
64
64
  exports.isDir = isDir;
65
65
  var isSFC = function (file) { return (0, fs_extra_1.pathExistsSync)(file) && (0, path_1.extname)(file) === '.vue'; };
66
66
  exports.isSFC = isSFC;
67
- var isJSX = function (file) { return (0, fs_extra_1.pathExistsSync)(file) && (0, path_1.extname)(file) === '.jsx'; };
68
- exports.isJSX = isJSX;
69
- var isTSX = function (file) { return (0, fs_extra_1.pathExistsSync)(file) && (0, path_1.extname)(file) === '.tsx'; };
70
- exports.isTSX = isTSX;
71
67
  var isDTS = function (file) { return (0, fs_extra_1.pathExistsSync)(file) && file.endsWith('.d.ts'); };
72
68
  exports.isDTS = isDTS;
73
69
  var isScript = function (file) { return (0, fs_extra_1.pathExistsSync)(file) && constant_1.SCRIPTS_EXTENSIONS.includes((0, path_1.extname)(file)); };
@@ -80,10 +76,6 @@ var isPublicDir = function (dir) {
80
76
  exports.isPublicDir = isPublicDir;
81
77
  var replaceExt = function (file, ext) { return file.replace((0, path_1.extname)(file), ext); };
82
78
  exports.replaceExt = replaceExt;
83
- var bigCamelize = function (s) { return (0, exports.camelize)(s).replace(s.charAt(0), s.charAt(0).toUpperCase()); };
84
- exports.bigCamelize = bigCamelize;
85
- var camelize = function (s) { return s.replace(/-(\w)/g, function (_, p) { return p.toUpperCase(); }); };
86
- exports.camelize = camelize;
87
79
  function smartAppendFileSync(file, code) {
88
80
  if ((0, fs_extra_1.pathExistsSync)(file)) {
89
81
  var content = (0, fs_extra_1.readFileSync)(file, 'utf-8');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "1.27.15",
3
+ "version": "1.27.17",
4
4
  "description": "cli of varlet",
5
5
  "bin": {
6
6
  "varlet-cli": "./lib/index.js"
@@ -28,10 +28,10 @@
28
28
  "url": "https://github.com/varletjs/varlet/issues"
29
29
  },
30
30
  "dependencies": {
31
- "@varlet/icons": "1.27.15",
32
- "@varlet/shared": "1.27.15",
33
- "@varlet/markdown-vite-plugin": "1.27.15",
34
- "@varlet/touch-emulator": "1.27.15",
31
+ "@varlet/icons": "1.27.17",
32
+ "@varlet/shared": "1.27.17",
33
+ "@varlet/markdown-vite-plugin": "1.27.17",
34
+ "@varlet/touch-emulator": "1.27.17",
35
35
  "@babel/core": "^7.14.8",
36
36
  "@babel/helper-plugin-utils": "^7.14.5",
37
37
  "@babel/preset-env": "^7.14.8",
@@ -76,7 +76,7 @@
76
76
  "@types/semver": "^7.3.9"
77
77
  },
78
78
  "peerDependencies": {
79
- "@varlet/touch-emulator": "1.27.15",
79
+ "@varlet/touch-emulator": "1.27.17",
80
80
  "@vue/test-utils": "^2.0.0-rc.6",
81
81
  "clipboard": "^2.0.6",
82
82
  "live-server": "^1.2.1",
@@ -21,7 +21,7 @@
21
21
 
22
22
  <script lang="ts">
23
23
  import { defineComponent, watch, ref, nextTick } from 'vue'
24
- import { isURL, toNumber } from '../utils/shared'
24
+ import { isURL, toNumber } from '@varlet/shared'
25
25
  import { toSizeUnit } from '../utils/elements'
26
26
  import { props } from './props'
27
27
  import type { Ref } from 'vue'
@@ -60,7 +60,7 @@
60
60
  <script lang="ts">
61
61
  import { defineComponent, computed } from 'vue'
62
62
  import { props } from './props'
63
- import { toNumber } from '../utils/shared'
63
+ import { toNumber } from '@varlet/shared'
64
64
 
65
65
  export default defineComponent({
66
66
  name: 'VarSiteProgress',
@@ -3,7 +3,7 @@ import VarSiteSnackbar from './Snackbar.vue'
3
3
  import context from '../context'
4
4
  import { reactive, TransitionGroup } from 'vue'
5
5
  import { mountInstance } from '../utils/components'
6
- import { isPlainObject, toNumber } from '../utils/shared'
6
+ import { isPlainObject, toNumber } from '@varlet/shared'
7
7
  import type { LoadingType, LoadingSize } from '../loading/props'
8
8
  import type { App, Component, TeleportProps } from 'vue'
9
9
 
@@ -1,4 +1,4 @@
1
- import { isNumber, isString, toNumber, kebabCase } from './shared'
1
+ import { isNumber, isString, toNumber, kebabCase } from '@varlet/shared'
2
2
  import type { StyleVars } from '../../utils'
3
3
 
4
4
  export function getLeft(element: HTMLElement): number {
@@ -76,7 +76,6 @@ import config from '@config'
76
76
  import { computed, ComputedRef, defineComponent, ref, Ref, watch } from 'vue'
77
77
  import { useRoute } from 'vue-router'
78
78
  import {
79
- bigCamelize,
80
79
  getBrowserThemes,
81
80
  inIframe,
82
81
  isPhone,
@@ -85,6 +84,7 @@ import {
85
84
  watchLang,
86
85
  watchThemes,
87
86
  } from '../utils'
87
+ import { bigCamelize } from '@varlet/shared'
88
88
  import { get } from 'lodash-es'
89
89
 
90
90
  export default defineComponent({
@@ -4,19 +4,19 @@ import config from '@config'
4
4
  import VarSiteButton from '../../../components/button'
5
5
  import VarSiteIcon from '../../../components/icon'
6
6
  import { get } from 'lodash-es'
7
- import { ref, watch } from 'vue'
7
+ import { ref, watch, computed } from 'vue'
8
8
  import { useRoute, useRouter } from 'vue-router'
9
9
  import { getBrowserThemes, setThemes } from '../../../utils'
10
10
  import { getPCLocationInfo, watchThemes } from '@varlet/cli/site/utils'
11
11
  import en_US from './locale/en-US'
12
12
  import zh_CN from './locale/zh-CN'
13
- import type { Ref } from 'vue'
13
+ import type { Ref, ComputedRef } from 'vue'
14
14
 
15
15
  const route = useRoute()
16
16
  const router = useRouter()
17
17
  const packs = {
18
18
  'zh-CN': zh_CN,
19
- 'en-US': en_US
19
+ 'en-US': en_US,
20
20
  } as any
21
21
 
22
22
  const github = get(config, 'pc.header.github')
@@ -24,16 +24,28 @@ const themesKey = get(config, 'themesKey')
24
24
  const currentThemes = ref(getBrowserThemes(themesKey))
25
25
  const darkMode: Ref<boolean> = ref(get(config, 'pc.header.darkMode'))
26
26
  const title: Ref<string> = ref(get(config, 'title'))
27
+ const language: Ref<string> = ref(get(config, 'defaultLanguage'))
27
28
  const languages: Ref<Record<string, string>> = ref(get(config, 'pc.header.i18n'))
28
29
  const pack: Ref<Record<string, string>> = ref({})
29
30
 
31
+ const description: ComputedRef<string> = computed(() => {
32
+ const { indexPage = {} } = get(config, 'pc')
33
+
34
+ return indexPage?.description?.[language.value] || pack.value.description
35
+ })
36
+
37
+ const started: ComputedRef<string> = computed(() => {
38
+ const { indexPage = {} } = get(config, 'pc')
39
+
40
+ return indexPage?.started?.[language.value] || pack.value.started
41
+ })
42
+
30
43
  const goGithub = () => {
31
44
  window.open(github)
32
45
  }
33
46
 
34
47
  const getStar = () => {
35
- const { language: lang } = getPCLocationInfo()
36
- router.push(`/${lang}/home`)
48
+ router.push(`/${language.value}/home`)
37
49
  }
38
50
 
39
51
  const getThemesMessage = () => ({ action: 'themesChange', from: 'pc', data: currentThemes.value })
@@ -54,6 +66,7 @@ const setLocale = () => {
54
66
  const { language: lang } = getPCLocationInfo()
55
67
  if (!lang) return
56
68
 
69
+ language.value = lang
57
70
  pack.value = packs[lang]
58
71
  document.title = get(config, 'pc.title')[lang] as string
59
72
  }
@@ -63,6 +76,8 @@ const toggleLanguages = () => {
63
76
 
64
77
  const { menuName } = getPCLocationInfo()
65
78
  const replaceStr = `/${lang === 'zh-CN' ? 'en-US' : 'zh-CN'}/${menuName}`
79
+
80
+ language.value = lang
66
81
  router.replace(replaceStr)
67
82
  }
68
83
 
@@ -90,13 +105,13 @@ watch(() => route.path, setLocale, { immediate: true })
90
105
  <animation-box class="logo" />
91
106
  <div class="base-title">{{ title }}</div>
92
107
  </div>
93
- <div class="base-description">{{ pack.description }}</div>
108
+ <div class="base-description">{{ description }}</div>
94
109
 
95
110
  <div class="button-group">
96
111
  <var-site-button class="common-button github-button" block @click="goGithub">
97
112
  <div class="block-button-content">
98
113
  <span>GITHUB</span>
99
- <var-site-icon style="margin-left: 10px;" name="github" size="24px" />
114
+ <var-site-icon style="margin-left: 10px" name="github" size="24px" />
100
115
  </div>
101
116
  </var-site-button>
102
117
  <var-site-button class="common-button extra-button margin-left" text v-if="darkMode" @click="toggleTheme">
@@ -107,11 +122,16 @@ watch(() => route.path, setLocale, { immediate: true })
107
122
  <div class="button-group">
108
123
  <var-site-button type="primary" class="common-button primary-button" block @click="getStar">
109
124
  <div class="block-button-content">
110
- <span>{{ pack.started }}</span>
125
+ <span>{{ started }}</span>
111
126
  <var-site-icon style="margin-left: 10px; transform: rotate(-90deg)" name="arrow-down" size="24px" />
112
127
  </div>
113
128
  </var-site-button>
114
- <var-site-button class="common-button extra-button margin-left" text v-if="languages" @click="toggleLanguages">
129
+ <var-site-button
130
+ class="common-button extra-button margin-left"
131
+ text
132
+ v-if="languages"
133
+ @click="toggleLanguages"
134
+ >
115
135
  <var-site-icon name="translate" size="24px" />
116
136
  </var-site-button>
117
137
  </div>
@@ -121,5 +141,5 @@ watch(() => route.path, setLocale, { immediate: true })
121
141
  </template>
122
142
 
123
143
  <style lang="less" scoped>
124
- @import "./index";
144
+ @import './index';
125
145
  </style>
package/site/utils.ts CHANGED
@@ -4,7 +4,6 @@ import { formatStyleVars } from './components/utils/elements'
4
4
 
5
5
  export * from './components/utils/components'
6
6
  export * from './components/utils/elements'
7
- export * from './components/utils/shared'
8
7
 
9
8
  export type StyleVars = Record<string, string>
10
9
 
@@ -21,14 +20,6 @@ function StyleProvider(styleVars: StyleVars | null = {}) {
21
20
  })
22
21
  }
23
22
 
24
- export function camelize(str: string): string {
25
- return str.replace(/-(\w)/g, (_: any, p: string) => p.toUpperCase())
26
- }
27
-
28
- export function bigCamelize(str: string): string {
29
- return camelize(str).replace(str.charAt(0), str.charAt(0).toUpperCase())
30
- }
31
-
32
23
  export interface PCLocationInfo {
33
24
  language: string
34
25
  menuName: string
@@ -1,29 +0,0 @@
1
- export const toNumber = (val: number | string | boolean | undefined | null): number => {
2
- if (val == null) return 0
3
-
4
- if (isString(val)) {
5
- val = parseFloat(val)
6
- val = Number.isNaN(val) ? 0 : val
7
- return val
8
- }
9
-
10
- if (isBool(val)) return Number(val)
11
-
12
- return val
13
- }
14
-
15
- export const isPlainObject = (val: unknown): val is Record<string, any> =>
16
- Object.prototype.toString.call(val) === '[object Object]'
17
-
18
- export function kebabCase(str: string): string {
19
- const ret = str.replace(/([A-Z])/g, ' $1').trim()
20
- return ret.split(' ').join('-').toLowerCase()
21
- }
22
-
23
- export const isString = (val: unknown): val is string => typeof val === 'string'
24
-
25
- export const isBool = (val: unknown): val is boolean => typeof val === 'boolean'
26
-
27
- export const isNumber = (val: unknown): val is number => typeof val === 'number'
28
-
29
- export const isURL = (val: string) => /^(http)|(\.*\/)/.test(val)