auto-detect-component
Advanced tools
Comparing version 0.0.3 to 0.1.2
@@ -12,2 +12,6 @@ "use strict"; | ||
var _uppercamelcase = _interopRequireDefault(require("uppercamelcase")); | ||
var _uiMap = _interopRequireDefault(require("./config/ui-map")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -34,3 +38,3 @@ | ||
var appPath = _ref.appPath, | ||
compPrefix = _ref.compPrefix, | ||
uiName = _ref.uiName, | ||
_ref$fileExt = _ref.fileExt, | ||
@@ -42,6 +46,7 @@ fileExt = _ref$fileExt === void 0 ? '.vue' : _ref$fileExt; | ||
this.appPath = appPath; | ||
this.compPrefix = compPrefix; | ||
this.compReg = new RegExp("<".concat(compPrefix, "([a-zA-Z-]+)"), 'ig'); | ||
this.uiName = uiName; | ||
this.compFiles = []; | ||
this.fileExt = fileExt; | ||
this.compPrefix = _uiMap.default[uiName]; | ||
this.compReg = new RegExp("<".concat(this.compPrefix, "([a-zA-Z-]+)"), 'ig'); | ||
} | ||
@@ -84,3 +89,3 @@ | ||
var res = (content.toString().match(_this2.compReg) || []).map(function (item) { | ||
return item.replace('<', ''); | ||
return item.replace("<".concat(_this2.compPrefix), ''); | ||
}); | ||
@@ -92,4 +97,22 @@ | ||
useComps = Array.from(new Set(useComps)); | ||
return useComps; | ||
return useComps.map(function (c) { | ||
return (0, _uppercamelcase.default)(c); | ||
}); | ||
} | ||
}, { | ||
key: "createUIPlugin", | ||
value: function createUIPlugin(useComps) { | ||
var uiList = require("./comp-list/".concat(this.uiName)).default; | ||
var useStr = []; | ||
var shouldUseList = useComps.filter(function (c) { | ||
return uiList.indexOf(c) !== -1; | ||
}); | ||
var importStr = shouldUseList.join(', '); | ||
shouldUseList.forEach(function (item) { | ||
useStr.push("Vue.use(".concat(item, ");")); | ||
}); | ||
var pluginTpl = "\nimport {\n ".concat(importStr, "\n} from '").concat(this.uiName, "';\n\nconst UIPlugin = {};\n\nUIPlugin.install = (Vue) => {\n ").concat(useStr.join('\n '), "\n};\n\nexport default UIPlugin;\n "); | ||
return pluginTpl; | ||
} | ||
}]); | ||
@@ -96,0 +119,0 @@ |
{ | ||
"name": "auto-detect-component", | ||
"version": "0.0.3", | ||
"version": "0.1.2", | ||
"description": "Detect UI components used in your project automatically.", | ||
@@ -10,3 +10,4 @@ "bin": { | ||
"dist": "babel src -d dist", | ||
"test": "bin/adc -d demo -p 'a-' -e '.vue'" | ||
"test": "bin/adc -d demo -u 'ant-design-vue' -o plugin", | ||
"prepublish": "npm run dist" | ||
}, | ||
@@ -17,3 +18,4 @@ "author": "yugasun", | ||
"chalk": "^2.4.2", | ||
"commander": "^2.19.0" | ||
"commander": "^2.19.0", | ||
"uppercamelcase": "^3.0.0" | ||
}, | ||
@@ -20,0 +22,0 @@ "devDependencies": { |
# auto-detect-component | ||
<a href="https://www.npmjs.com/package/auto-detect-component"><img src="https://img.shields.io/npm/dm/auto-detect-component.svg" alt="Downloads"></a> | ||
<a href="https://www.npmjs.com/package/auto-detect-component"><img src="https://img.shields.io/npm/v/auto-detect-component.svg" alt="Version"></a> | ||
Detect UI components used in your project automatically. | ||
@@ -16,7 +19,16 @@ | ||
# demo is the project directory you need to detect | ||
adc -d demo -p 'a-' -e '.vue' | ||
adc -d demo -u 'element-ui' -o plugin | ||
``` | ||
Then use the created plugin file as [Vue plugin](https://vuejs.org/v2/guide/plugins.html): | ||
```js | ||
import Vue from 'vue'; | ||
import UIPlugin from './plugin/ui-plugin'; | ||
Vue.use(UIPlugin); | ||
``` | ||
## License | ||
[MIT](./LICENSE) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
107890
14
264
34
3
2
1
+ Addeduppercamelcase@^3.0.0
+ Addedcamelcase@4.1.0(transitive)
+ Addeduppercamelcase@3.0.0(transitive)