Commit 5238c6c8 authored by rockyl's avatar rockyl

适配scilla-engine

parent ce220d6a
...@@ -10,8 +10,8 @@ let _componentsSrcPath; ...@@ -10,8 +10,8 @@ let _componentsSrcPath;
let _projectPath; let _projectPath;
let _assetsPath; let _assetsPath;
let _filter; let _filter;
let _nodeModulesPathMap;
const scillaCorePrefix = 'node_modules/scilla/src';
const componentBaseClassNames = [ const componentBaseClassNames = [
'"scilla/core/Component".Component', '"scilla/core/Component".Component',
'"components/base/ScillaComponent".ScillaComponent', '"components/base/ScillaComponent".ScillaComponent',
...@@ -20,11 +20,12 @@ const componentBaseClassNames = [ ...@@ -20,11 +20,12 @@ const componentBaseClassNames = [
const showLog = false; const showLog = false;
const showVerboseLog = false; const showVerboseLog = false;
exports.generateDeclareMap = function(tsconfig, dependencies, file, componentsPath, projectPath, assetsPath, filter) { exports.generateDeclareMap = function(tsconfig, dependencies, file, componentsPath, projectPath, assetsPath, filter, nodeModulesPathMap) {
_componentsSrcPath = path.join(componentsPath, 'src'); _componentsSrcPath = path.join(componentsPath, 'src');
_projectPath = projectPath; _projectPath = projectPath;
_assetsPath = assetsPath; _assetsPath = assetsPath;
_filter = filter; _filter = filter;
_nodeModulesPathMap = nodeModulesPathMap;
const config = ts.parseJsonConfigFileContent(tsconfig, ts.sys, projectPath); const config = ts.parseJsonConfigFileContent(tsconfig, ts.sys, projectPath);
...@@ -54,18 +55,18 @@ exports.generateDeclareMap = function(tsconfig, dependencies, file, componentsPa ...@@ -54,18 +55,18 @@ exports.generateDeclareMap = function(tsconfig, dependencies, file, componentsPa
if(showLog) console.time('delint'); if(showLog) console.time('delint');
for(let sourceFile of sourceFiles){ for(let sourceFile of sourceFiles){
if (sourceFile.fileName.indexOf('.d.ts') < 0) { if (sourceFile.fileName.indexOf('.d.ts') < 0) {
if(!_filter || _filter(sourceFile)){ if (!_filter || _filter(sourceFile)) {
const fileName = sourceFile.fileName; const fileName = sourceFile.fileName;
if(sourceFile.resolvedModules){ if (sourceFile.resolvedModules) {
sourceFile.resolvedModules.forEach((item, key)=>{ sourceFile.resolvedModules.forEach((item, key) => {
if(!item){ if (!item) {
missingDependencies.push(key); missingDependencies.push(key);
} }
}); });
} }
if(showLog && showVerboseLog) console.time(fileName); if (showLog && showVerboseLog) console.time(fileName);
delint(checker, sourceFile); delint(checker, sourceFile);
if(showLog && showVerboseLog) console.timeEnd(fileName); if (showLog && showVerboseLog) console.timeEnd(fileName);
} }
} }
} }
...@@ -225,8 +226,19 @@ function getFullyQualifiedNameOfType(type, checker) { ...@@ -225,8 +226,19 @@ function getFullyQualifiedNameOfType(type, checker) {
if (fullClassName.indexOf('\"') >= 0) { if (fullClassName.indexOf('\"') >= 0) {
path = fullClassName.substring(1, fullClassName.lastIndexOf('.') - 1); path = fullClassName.substring(1, fullClassName.lastIndexOf('.') - 1);
className = fullClassName.substring(fullClassName.lastIndexOf('.') + 1); className = fullClassName.substring(fullClassName.lastIndexOf('.') + 1);
if (path.indexOf(scillaCorePrefix) >= 0) {
path = path.substr(path.indexOf(scillaCorePrefix)).replace(scillaCorePrefix, 'scilla'); let resolved = false;
if(_nodeModulesPathMap){
for(let key in _nodeModulesPathMap){
if (path.indexOf(key) >= 0) {
path = path.substr(path.indexOf(key)).replace(key, _nodeModulesPathMap[key]);
resolved = true;
break;
}
}
}
if (resolved) {
} else if (path.indexOf(_assetsPath) >= 0) { } else if (path.indexOf(_assetsPath) >= 0) {
path = path.replace(_assetsPath, '.') path = path.replace(_assetsPath, '.')
} else if(path.indexOf('src') === 0){ } else if(path.indexOf('src') === 0){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment