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

babel-plugin-veui

Package Overview
Dependencies
Maintainers
1
Versions
200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-veui - npm Package Compare versions

Comparing version 0.2.4 to 0.3.0

24

components.json

@@ -31,2 +31,6 @@ [

{
"name": "CheckButtonGroup",
"path": "CheckButtonGroup.vue"
},
{
"name": "Checkbox",

@@ -116,2 +120,6 @@ "path": "Checkbox.vue"

{
"name": "Progress",
"path": "Progress.vue"
},
{
"name": "PromptBox",

@@ -121,10 +129,14 @@ "path": "PromptBox.vue"

{
"name": "Radiobox",
"path": "Radiobox.vue"
"name": "Radio",
"path": "Radio.vue"
},
{
"name": "RadioboxGroup",
"path": "RadioboxGroup.vue"
"name": "RadioButtonGroup",
"path": "RadioButtonGroup.vue"
},
{
"name": "RadioGroup",
"path": "RadioGroup.vue"
},
{
"name": "RegionPicker",

@@ -154,2 +166,6 @@ "path": "RegionPicker.vue"

{
"name": "Sorter",
"path": "Sorter.vue"
},
{
"name": "Span",

@@ -156,0 +172,0 @@ "path": "Span.vue"

134

lib/index.js

@@ -19,8 +19,8 @@ 'use strict';

var node = path.node;
var src = node.source.value;
var src = (0, _utils.normalize)(node.source.value);
var resolvedComponentName = null;
if (src.indexOf(COMPONENTS_PATH) === 0) {
var componentPath = src.slice(COMPONENTS_PATH.length);
var normalizedPath = (0, _utils.normalize)(COMPONENTS_PATH + '/');
if (src.indexOf(normalizedPath) === 0) {
var componentPath = src.slice(normalizedPath.length);
resolvedComponentName = getComponentName(componentPath);

@@ -31,43 +31,47 @@ } else if (src !== 'veui') {

} else {
resolvedComponentName = resolveComponent(file.opts.filename, src);
}
resolvedComponentName = resolveComponent(file.opts.filename, src);
}
}
node.specifiers.map(function (_ref2) {
var type = _ref2.type,
imported = _ref2.imported;
var _opts$modules = opts.modules,
modules = _opts$modules === undefined ? [] : _opts$modules,
pack = opts.package,
_opts$path = opts.path,
packPath = _opts$path === undefined ? 'components' : _opts$path,
transform = opts.transform,
fileName = opts.fileName,
resolve = opts.resolve;
var name = void 0;
if (imported) {
name = imported.name === 'default' ? resolvedComponentName : isComponentName(imported.name) ? imported.name : null;
} else if (type === 'ImportDefaultSpecifier') {
name = resolvedComponentName;
}
return getPeerPath(getModuleName(name, opts.transform), opts.fileName);
}).filter(function (v) {
return v;
}).forEach(function (name) {
var pack = opts.package,
packPath = opts.path,
request = opts.request,
resolve = opts.resolve;
var modulePath = packPath ? pack + '/' + packPath + '/' + name : pack + '/' + name;
if (pack && fileName) {
modules.push({ package: pack, path: packPath, transform: transform, fileName: fileName });
}
if (resolveCache[modulePath] === false) {
return;
} else if (!(modulePath in resolveCache)) {
if (typeof resolve === 'function') {
try {
var moduleFile = resolve({}, process.cwd(), modulePath);
resolveCache[modulePath] = true;
} catch (e) {
resolveCache[modulePath] = false;
}
modules.forEach(function (_ref2) {
var pack = _ref2.package,
_ref2$path = _ref2.path,
packPath = _ref2$path === undefined ? 'components' : _ref2$path,
transform = _ref2.transform,
fileName = _ref2.fileName;
node.specifiers.map(function (_ref3) {
var type = _ref3.type,
imported = _ref3.imported;
var name = void 0;
if (imported) {
name = imported.name === 'default' ? resolvedComponentName : isComponentName(imported.name) ? imported.name : null;
} else if (type === 'ImportDefaultSpecifier') {
name = resolvedComponentName;
}
}
return getPeerPath(getModuleName(name, transform), fileName);
}).filter(function (v) {
return v;
}).forEach(function (name) {
var modulePath = (0, _path.join)(pack, packPath, name);
if (resolveCache[modulePath]) {
path.insertAfter(t.importDeclaration([], t.stringLiteral(modulePath)));
}
if (assurePath(modulePath, resolve)) {
path.insertAfter(t.importDeclaration([], t.stringLiteral(modulePath)));
}
});
});

@@ -96,6 +100,24 @@ }

var COMPONENTS = (0, _utils.getJSON)(_path2.default.resolve(__dirname, '../components.json'));
var COMPONENTS_PATH = 'veui/components/';
var COMPONENTS_DIRNAME = 'components';
var COMPONENTS_PATH = (0, _utils.normalize)('veui/' + COMPONENTS_DIRNAME);
var resolveCache = {};
function assurePath(modulePath, resolve) {
if (resolveCache[modulePath] === false) {
return;
} else if (!(modulePath in resolveCache)) {
if (typeof resolve === 'function') {
try {
resolve({}, process.cwd(), modulePath);
resolveCache[modulePath] = true;
} catch (e) {
resolveCache[modulePath] = false;
}
}
}
return resolveCache[modulePath];
}
function getPeerPath(name) {

@@ -110,2 +132,3 @@ var template = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '${module}.css';

function getModuleName(name) {

@@ -124,2 +147,3 @@ var transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'kebab-case';

return (0, _utils.pascalCase)(name);
case false:
default:

@@ -131,2 +155,6 @@ return name;

function resolveComponent(file, src) {
return getComponentName(resolveRelative(file, src, COMPONENTS_DIRNAME));
}
function resolveRelative(file, src, dir) {
var pkg = _pkgDir2.default.sync(file);

@@ -137,12 +165,16 @@ if (!pkg || (0, _utils.getJSON)(_path2.default.join(pkg, 'package.json')).name !== 'veui') {

var componentsPath = _path2.default.join(pkg, 'components');
if (!_fs2.default.existsSync(componentsPath)) {
componentsPath = _path2.default.join(pkg, 'src/components');
if (!_fs2.default.existsSync(componentsPath)) {
return;
var dirPath = _path2.default.join(pkg, dir);
if (!_fs2.default.existsSync(dirPath)) {
dirPath = _path2.default.join(pkg, 'src', dir);
if (!_fs2.default.existsSync(dirPath)) {
return null;
}
}
var relativePath = _path2.default.relative(componentsPath, _path2.default.resolve(_path2.default.dirname(file), src));
return getComponentName(relativePath);
var absPath = _path2.default.resolve(_path2.default.dirname(file), src);
if (absPath.indexOf((0, _utils.normalize)(dirPath + '/')) !== 0) {
return null;
}
return _path2.default.relative(dirPath, absPath);
}

@@ -154,4 +186,4 @@

}
var component = COMPONENTS.find(function (_ref3) {
var path = _ref3.path;
var component = COMPONENTS.find(function (_ref4) {
var path = _ref4.path;

@@ -165,7 +197,7 @@ return path === componentPath || path.split('.')[0] === componentPath;

function isComponentName(componentName) {
return !!COMPONENTS.find(function (_ref4) {
var name = _ref4.name;
return !!COMPONENTS.find(function (_ref5) {
var name = _ref5.name;
return name === componentName;
});
}
module.exports = exports['default'];
module.exports = exports['default'];

@@ -11,2 +11,3 @@ 'use strict';

exports.getJSON = getJSON;
exports.normalize = normalize;

@@ -17,2 +18,6 @@ var _fs = require('fs');

var _path = require('path');
var _path2 = _interopRequireDefault(_path);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -59,2 +64,6 @@

return JSON.parse(_fs2.default.readFileSync(path, 'utf8'));
}
function normalize(filePath) {
return filePath.replace(/[/\\]/g, _path2.default.sep);
}
{
"name": "babel-plugin-veui",
"version": "0.2.4",
"version": "0.3.0",
"description": "Import VEUI components with ease.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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