Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scilla-declare-generator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
scilla-declare-generator
Commits
11313198
Commit
11313198
authored
Apr 26, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改generate返回值,增加找不到依赖的列表
parent
54f66b5a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
14 deletions
+31
-14
cli.js
bin/cli.js
+11
-1
index.js
src/index.js
+20
-13
No files found.
bin/cli.js
View file @
11313198
...
...
@@ -15,6 +15,7 @@ program
.
description
(
'scilla declare generator'
)
.
option
(
'-i, --input [string]'
,
'input file'
)
.
option
(
'-o, --output [string]'
,
'output file'
)
.
option
(
'-v, --verbose [boolean]'
,
'verbose mode'
,
false
)
.
parse
(
process
.
argv
);
const
systemComponentsPath
=
path
.
join
(
os
.
homedir
(),
'.scilla'
,
'components'
);
...
...
@@ -39,4 +40,13 @@ const result = generateDeclareMap(
declareFilter
);
console
.
log
(
result
);
if
(
program
.
verbose
){
console
.
log
(
result
);
}
if
(
result
.
missingDependencies
.
length
>
0
){
process
.
exit
(
1
);
}
fs
.
ensureDirSync
(
path
.
dirname
(
program
.
output
));
fs
.
writeJsonSync
(
program
.
output
,
result
.
declareMap
);
src/index.js
View file @
11313198
...
...
@@ -4,7 +4,7 @@
const
ts
=
require
(
'typescript'
);
let
classD
eclareMap
;
let
d
eclareMap
;
let
_componentsPath
;
let
_projectPath
;
let
_assetsPath
;
...
...
@@ -28,16 +28,24 @@ exports.generateDeclareMap = function(tsconfig, file, componentsPath, projectPat
const
program
=
ts
.
createProgram
(
files
,
config
.
options
);
const
sourceFiles
=
program
.
getSourceFiles
();
classD
eclareMap
=
{};
d
eclareMap
=
{};
if
(
showLog
)
console
.
time
(
'getTypeChecker'
);
const
checker
=
program
.
getTypeChecker
();
if
(
showLog
)
console
.
timeEnd
(
'getTypeChecker'
);
if
(
showLog
)
console
.
time
(
'delint'
);
const
missingDependencies
=
[];
for
(
let
sourceFile
of
sourceFiles
){
if
(
sourceFile
.
fileName
.
indexOf
(
'.d.ts'
)
<
0
)
{
if
(
!
_filter
||
_filter
(
sourceFile
)){
if
(
sourceFile
.
resolvedModules
){
sourceFile
.
resolvedModules
.
forEach
((
item
,
key
)
=>
{
if
(
!
item
){
missingDependencies
.
push
(
key
);
}
});
}
if
(
showLog
&&
showVerboseLog
)
console
.
time
(
sourceFile
.
fileName
);
delint
(
checker
,
sourceFile
);
if
(
showLog
&&
showVerboseLog
)
console
.
timeEnd
(
sourceFile
.
fileName
);
...
...
@@ -46,11 +54,10 @@ exports.generateDeclareMap = function(tsconfig, file, componentsPath, projectPat
}
if
(
showLog
)
console
.
timeEnd
(
'delint'
);
/*for(let name in classDeclareMap){
transFullyDeclare(name);
}*/
return
classDeclareMap
;
return
{
declareMap
,
missingDependencies
,
};
};
function
delint
(
checker
,
sourceFile
)
{
...
...
@@ -63,10 +70,10 @@ function delint(checker, sourceFile) {
const
{
fullClassName
:
enumName
}
=
getFullyQualifiedNameOfType
(
checker
.
getTypeAtLocation
(
node
),
checker
);
let
members
;
if
(
enumName
in
classD
eclareMap
)
{
members
=
classD
eclareMap
[
enumName
];
if
(
enumName
in
d
eclareMap
)
{
members
=
d
eclareMap
[
enumName
];
}
else
{
classD
eclareMap
[
enumName
]
=
members
=
{
d
eclareMap
[
enumName
]
=
members
=
{
__type__
:
'enum'
,
map
:
{},
};
...
...
@@ -89,10 +96,10 @@ function delint(checker, sourceFile) {
const
{
fullClassName
,
path
,
className
}
=
getFullyQualifiedNameOfType
(
checker
.
getTypeAtLocation
(
node
),
checker
);
let
members
;
if
(
fullClassName
in
classD
eclareMap
)
{
members
=
classD
eclareMap
[
fullClassName
];
if
(
fullClassName
in
d
eclareMap
)
{
members
=
d
eclareMap
[
fullClassName
];
}
else
{
classD
eclareMap
[
fullClassName
]
=
members
=
{
properties
:
{},
methods
:
{}};
d
eclareMap
[
fullClassName
]
=
members
=
{
properties
:
{},
methods
:
{}};
}
getJsDoc
(
members
,
node
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment