forked from UIZE/UIZE-JavaScript-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_uize-site-build-sotu.js
122 lines (113 loc) · 4.43 KB
/
_uize-site-build-sotu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*** boilerplate setup code for WSH build scripts ***/
var _setupFile = new ActiveXObject ('Scripting.FileSystemObject').OpenTextFile ('_build-script-setup.js',1);
eval (_setupFile.ReadAll ()) ();
_setupFile.Close ();
Uize.module ({
required:[
'Uize.Wsh',
'Uize.Wsh.BuildUtils',
'Uize.Wsh.AutoScruncher',
'Uize.String',
'Uize.String.Lines',
'Uize.Data.Simple',
'UizeDotCom.BuildUtils'
],
builder:function () {
/*** Utility Functions ***/
function _getFirstTitleSegment (_title) {return _title.match (/^\s*(.*?)\s*\|/) [1]}
/*** Global Variables ***/
var
_sacredEmptyObject = {},
_sacredEmptyArray = []
;
/*** build up data records for table ***/
var
_moduleReferenceFiles = Uize.Wsh.BuildUtils.getHtmlFilesInfo ('reference',_getFirstTitleSegment),
_examplesByKeyword = UizeDotCom.BuildUtils.getExamplesByKeyword (),
_modules = []
;
for (
var _moduleReferenceFileNo = -1, _moduleReferenceFilesLength = _moduleReferenceFiles.length;
++_moduleReferenceFileNo < _moduleReferenceFilesLength;
) {
var
_moduleReferenceFile = _moduleReferenceFiles [_moduleReferenceFileNo],
_moduleName = _moduleReferenceFile.title,
_moduleInfo = {
name:_moduleName,
description:_moduleReferenceFile.description,
examples:(_examplesByKeyword [_moduleName] || _sacredEmptyArray).length
}
;
if (
(_moduleName == 'Uize' || Uize.String.startsWith (_moduleName,'Uize.')) &&
!Uize.String.startsWith (_moduleName,'Uize.Test.')
) {
/*** determine number of direct and nested submodules ***/
var
_directSubmodules = 0,
_nestedSubmodules = 0,
_moduleNamePlusDot = _moduleName + '.',
_moduleNamePlusDotLength = _moduleNamePlusDot.length
;
for (var _submoduleNo = _moduleReferenceFileNo; ++_submoduleNo < _moduleReferenceFilesLength;) {
var _submoduleName = _moduleReferenceFiles [_submoduleNo].title;
if (Uize.String.startsWith (_submoduleName,_moduleNamePlusDot)) {
_nestedSubmodules++;
_submoduleName.indexOf ('.',_moduleNamePlusDotLength) == -1 && _directSubmodules++;
}
}
_moduleInfo.directSubmodules = _directSubmodules;
_moduleInfo.nestedSubmodules = _nestedSubmodules;
/*** extract module meta data from module source ***/
var
_sourceFileText = Uize.Wsh.readFile (env.moduleFolderPath + '\\' + _moduleName + '.js'),
_metaDataCommentRegExp = /\/\*\s*Module\s*Meta\s*Data/i,
_metaDataCommentStartPos = _sourceFileText.search (_metaDataCommentRegExp),
_metaDataCommentEndPos = _sourceFileText.indexOf ('*/',_metaDataCommentStartPos),
_metaDataText = _metaDataCommentStartPos > -1
?
_sourceFileText.slice (_metaDataCommentStartPos,_metaDataCommentEndPos)
.replace (_metaDataCommentRegExp,'')
: '',
_metaData = _metaDataText
?
Uize.Data.Simple.parse ({
simple:Uize.String.Lines.normalizeIndent (_metaDataText),
collapseChildren:true
})
: _sacredEmptyObject
;
_moduleInfo.type = _metaData.type || 'Unknown';
_moduleInfo.importance = +_metaData.importance || 0;
_moduleInfo.codeCompleteness = +_metaData.codeCompleteness || 0;
_moduleInfo.docCompleteness = +_metaData.docCompleteness || 0;
_moduleInfo.testCompleteness = +_metaData.testCompleteness || 0;
_moduleInfo.keywords = _metaData.keywords || '';
/*** information derived from loading source and scrunched file text ***/
_moduleInfo.sourceFileSize = _sourceFileText.length;
_moduleInfo.scrunchedFileSize =
Uize.Wsh.readFile (
Uize.Wsh.AutoScruncher.getScrunchedFolderPath (
Uize.Wsh.getScriptFolderPath () + '\\' + env.moduleFolderPath,
env.buildFolderPath,
env.sourceFolderName
) + '\\' + _moduleName + '.js'
).length
;
_modules.push (_moduleInfo);
}
}
/*** process JavaScript template with modules data ***/
Uize.Wsh.BuildUtils.processJstFile ('appendixes\\sotu.html.jst',{modules:_modules});
/*
TO DO:
- nice-to-haves
- number of modules that require this module (ie. how shared is this module throughout framework, or is it more isolated)
- total number of modules (directly and indirectly) required by this module
- total scrunched size of all modules (directly and indirectly) required by this module
- creation date
- developers
*/
}
});