New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

auto-detect-component

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auto-detect-component - npm Package Compare versions

Comparing version 0.0.3 to 0.1.2

dist/comp-list/ant-design-vue.js

33

dist/auto-detect.js

@@ -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 @@

8

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc