Socket
Socket
Sign inDemoInstall

vue-component-analyzer

Package Overview
Dependencies
54
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.4 to 0.1.5

test/cases/circular/aaa.js

3

package.json
{
"name": "vue-component-analyzer",
"description": "Analyze dependencies, inheritance and some other useful info of Vue components in static code.",
"version": "0.1.4",
"version": "0.1.5",
"author": "Rainfore <rainforest92@126.com>",

@@ -33,2 +33,3 @@ "scripts": {

"babel-plugin-syntax-dynamic-import": "^6.18.0",
"enhanced-resolve": "^4.1.0",
"eslint": "^5.12.0",

@@ -35,0 +36,0 @@ "eslint-config-vusion": "^3.0.1",

@@ -66,3 +66,3 @@ const fs = require('fs-extra');

importVueObject(fullPath, sourcePath, identifier) {
importVueObject(fullPath, sourcePath, identifier, stack) {
return new Promise((resolve, reject) => {

@@ -74,4 +74,9 @@ let importPath = this.resolve(sourcePath, path.dirname(fullPath));

importPath = importPath.replace(/dist\/index\.js$/, 'index.js');
const uuid = importPath + ' && ' + identifier;
if (stack.includes(uuid))
return reject('Circular import:\n' + stack);
stack.push(uuid);
return resolve(this.loadJSFile(importPath)
.then((jsFile) => this.findVueObject(jsFile, 'export', identifier, true)));
.then((jsFile) => this.findVueObject(jsFile, 'export', identifier, true, undefined, stack)));
});

@@ -106,3 +111,3 @@ }

*/
findVueObject(jsFile, from = 'export', identifier = 'default', recursive = false, beforeNode) {
findVueObject(jsFile, from = 'export', identifier = 'default', recursive = false, beforeNode, stack = []) {
if (identifier === 'USubnavDivider')

@@ -130,6 +135,7 @@ debugger;

identifier,
stack,
};
else if (exportDefault.declaration.type === 'Identifier') {
const exportDefaultName = exportDefault.declaration.name;
return this.findVueObject(jsFile, 'local', exportDefaultName, recursive);
return this.findVueObject(jsFile, 'local', exportDefaultName, recursive, undefined, stack);
} else

@@ -153,5 +159,5 @@ return null;

if (exportSpecifier && exportSpecifier.kind === 'external')
return this.importVueObject(jsFile.fullPath, exportSpecifier.source, identifier);
return this.importVueObject(jsFile.fullPath, exportSpecifier.source, identifier, stack);
else {
return Promise.all(externalAllSpecifiers.map((specifier) => this.importVueObject(jsFile.fullPath, specifier.source, identifier)))
return Promise.all(externalAllSpecifiers.map((specifier) => this.importVueObject(jsFile.fullPath, specifier.source, identifier, stack)))
.then((results) => results.find((result) => !!result));

@@ -174,3 +180,3 @@ }

if (importSpecifier)
return this.importVueObject(jsFile.fullPath, importsNode.source, importSpecifier.imported);
return this.importVueObject(jsFile.fullPath, importsNode.source, importSpecifier.imported, stack);
}

@@ -200,5 +206,6 @@

identifier,
stack,
};
} else if (declarator.init.type === 'Identifier')
return this.findVueObject(jsFile, 'local', declarator.init.name, recursive, node);
return this.findVueObject(jsFile, 'local', declarator.init.name, recursive, node, stack);
}

@@ -226,3 +233,3 @@ }

return this.findVueObject(vueResult.jsFile, 'local', extendsName, true, vueResult.objectDeclaration).then((extendsResult) => {
return this.findVueObject(vueResult.jsFile, 'local', extendsName, true, vueResult.objectDeclaration, vueResult.stack).then((extendsResult) => {
// this.loader.addDependency(vueResult.jsFile.fullPath);

@@ -229,0 +236,0 @@ if (!extendsResult || !extendsResult.objectExpression)

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc