chore(cli): remove decamelize pkg for compatiblity issues

This commit is contained in:
陈嘉涵 2019-12-30 15:14:13 +08:00
parent 16cbfd2c85
commit 2b438f84cd
8 changed files with 23 additions and 39 deletions

View File

@ -72,7 +72,6 @@
"cross-env": "^6.0.3",
"css-loader": "^3.4.0",
"csso": "^4.0.2",
"decamelize": "^3.2.0",
"eslint": "^6.7.2",
"find-babel-config": "^1.2.0",
"gh-pages": "2.0.1",

View File

@ -20,6 +20,13 @@ function iframeReady(iframe, callback) {
const ua = navigator.userAgent.toLowerCase();
const isMobile = /ios|iphone|ipod|ipad|android/.test(ua);
export function decamelize(str, sep = '-') {
return str
.replace(/([a-z\d])([A-Z])/g, '$1' + sep + '$2')
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + sep + '$2')
.toLowerCase();
}
export {
isMobile,
iframeReady

View File

@ -1,7 +1,6 @@
import Vue from 'vue';
import VueRouter from 'vue-router';
import decamelize from 'decamelize';
import { isMobile } from '../common';
import { isMobile, decamelize } from '../common';
import { config, documents } from 'site-desktop-shared';
import { getLang, setDefaultLang } from '../common/locales';
import '../common/iframe-router';
@ -20,13 +19,13 @@ function parseName(name) {
const component = pairs.shift();
return {
component: `${decamelize(component, '-')}`,
component: `${decamelize(component)}`,
lang: pairs.join('-')
};
}
return {
component: `${decamelize(name, '-')}`,
component: `${decamelize(name)}`,
lang: ''
};
}

View File

@ -5,7 +5,7 @@
</template>
<script>
import decamelize from 'decamelize';
import { decamelize } from '../../common';
export default {
name: 'demo-section',
@ -14,7 +14,7 @@ export default {
demoName() {
const { meta } = this.$route || {};
if (meta && meta.name) {
return `demo-${decamelize(meta.name, '-')}`;
return `demo-${decamelize(meta.name)}`;
}
return '';

View File

@ -1,7 +1,7 @@
import Vue from 'vue';
import VueRouter from 'vue-router';
import decamelize from 'decamelize';
import DemoHome from './components/DemoHome';
import { decamelize } from '../common';
import { demos, config } from 'site-mobile-shared';
import { getLang, setDefaultLang } from '../common/locales';
import '../common/iframe-router';
@ -52,7 +52,7 @@ function getRoutes() {
}
names.forEach(name => {
const component = decamelize(name, '-');
const component = decamelize(name);
if (langs.length) {
langs.forEach(lang => {

View File

@ -1,4 +1,3 @@
import decamelize from 'decamelize';
import { join } from 'path';
import { execSync } from 'child_process';
import {
@ -85,6 +84,13 @@ export function pascalize(str: string): string {
);
}
export function decamelize(str: string, sep = '-') {
return str
.replace(/([a-z\d])([A-Z])/g, '$1' + sep + '$2')
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + sep + '$2')
.toLowerCase();
}
export function getWebpackConfig(): object {
if (existsSync(WEBPACK_CONFIG_FILE)) {
const config = require(WEBPACK_CONFIG_FILE);
@ -148,4 +154,4 @@ export function hasYarn() {
return hasYarnCache;
}
export { decamelize, getVantConfig };
export { getVantConfig };

View File

@ -42,7 +42,7 @@ function getSetName(demos: DemoItem[]) {
function genConfig(demos: DemoItem[]) {
const vantConfig = getVantConfig();
const demoNames = demos.map(item => decamelize(item.name, '-'));
const demoNames = demos.map(item => decamelize(item.name));
function demoFilter(nav: any[]) {
return nav.filter(group => {

View File

@ -842,14 +842,6 @@
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-typescript" "^7.7.4"
"@babel/runtime-corejs2@^7.2.0":
version "7.7.2"
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs2/-/runtime-corejs2-7.7.2.tgz#5a8c4e2f8688ce58adc9eb1d8320b6e7341f96ce"
integrity sha512-GfVnHchOBvIMsweQ13l4jd9lT4brkevnavnVOej5g2y7PpTRY+R4pcQlCjWMZoUla5rMLFzaS/Ll2s59cB1TqQ==
dependencies:
core-js "^2.6.5"
regenerator-runtime "^0.13.2"
"@babel/runtime@^7.0.0":
version "7.7.4"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.7.4.tgz#b23a856751e4bf099262f867767889c0e3fe175b"
@ -3555,11 +3547,6 @@ core-js-compat@^3.4.7:
browserslist "^4.8.2"
semver "^6.3.0"
core-js@^2.6.5:
version "2.6.10"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.10.tgz#8a5b8391f8cc7013da703411ce5b585706300d7f"
integrity sha512-I39t74+4t+zau64EN1fE5v2W31Adtc/REhzWN+gWRRXg6WH5qAsZm62DHpQ1+Yhe4047T55jvzz7MUqF/dBBlA==
core-util-is@1.0.2, core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.npm.taobao.org/core-util-is/download/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@ -3839,13 +3826,6 @@ decamelize@^1.1.0, decamelize@^1.1.2, decamelize@^1.2.0:
resolved "https://registry.npm.taobao.org/decamelize/download/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
decamelize@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-3.2.0.tgz#84b8e8f4f8c579f938e35e2cc7024907e0090851"
integrity sha512-4TgkVUsmmu7oCSyGBm5FvfMoACuoh9EOidm7V5/J2X2djAwwt57qb3F2KMP2ITqODTCSwb+YRV+0Zqrv18k/hw==
dependencies:
xregexp "^4.2.4"
decode-uri-component@^0.2.0:
version "0.2.0"
resolved "https://registry.npm.taobao.org/decode-uri-component/download/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
@ -11904,13 +11884,6 @@ xml-name-validator@^3.0.0:
resolved "https://registry.npm.taobao.org/xml-name-validator/download/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
integrity sha1-auc+Bt5NjG5H+fsYH3jWSK1FfGo=
xregexp@^4.2.4:
version "4.2.4"
resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.2.4.tgz#02a4aea056d65a42632c02f0233eab8e4d7e57ed"
integrity sha512-sO0bYdYeJAJBcJA8g7MJJX7UrOZIfJPd8U2SC7B2Dd/J24U0aQNoGp33shCaBSWeb0rD5rh6VBUIXOkGal1TZA==
dependencies:
"@babel/runtime-corejs2" "^7.2.0"
xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1:
version "4.0.2"
resolved "https://registry.npm.taobao.org/xtend/download/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"