| 1 |
define([], function(){ |
| 2 |
var categories = { |
| 3 |
info:[[100, 199]], |
| 4 |
warn:[[200, 299]], |
| 5 |
error:[[300, 399]], |
| 6 |
report:[[400, 499]] |
| 7 |
}, |
| 8 |
|
| 9 |
messages = [ |
| 10 |
|
| 11 |
|
| 12 |
[1, 100, "legacyAssumed", "Assumed module uses legacy loader API."], |
| 13 |
[1, 101, "legacyUsingLoadInitPlug", "Using dojo/loadInit plugin for module."], |
| 14 |
[1, 102, "optimize", "Optimizing module"], |
| 15 |
[1, 103, "optimizeDone", "Optimizing module complete."], |
| 16 |
[1, 104, "optimizeMessages", "Optimizer messages."], |
| 17 |
[1, 105, "pacify", ""], |
| 18 |
[1, 106, "cssOptimize", "Optimizing CSS."], |
| 19 |
[1, 107, "packageVersion", "Package Version:"], |
| 20 |
[1, 108, "internStrings", "Interning strings."], |
| 21 |
[1, 109, "processHtmlFiles", "Processing HTML files."], |
| 22 |
[1, 110, "userTrace", "User trace:"], |
| 23 |
[1, 111, "userInfo", "User info:"], |
| 24 |
[1, 112, "cssOptimizeIgnored", "While optimizing a CSS file, an import directive was not expanded as instructed by the profile."], |
| 25 |
[1, 113, "cssOptimizeIgnoredMultiMediaTypes", "While optimizing a CSS file, an import directive was not expanded because it indicated multiple media types."], |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
[1, 200, "configUnresolvedValues", "Configuration contains unsolved values."], |
| 30 |
[1, 201, "amdCircularDependency", "Cycle detected in layer dependencies."], |
| 31 |
[1, 202, "amdInconsistentMid", "AMD module specified and absolute module identifier that is not consistent with the configuration and filename"], |
| 32 |
[1, 203, "amdPureContainedLegacyApi", "Module tagged as pure AMD yet it contains legacy loader API applications."], |
| 33 |
[1, 205, "amdNotPureContainedNoLegacyApi", "Module not tagged as pure AMD yet it contains AMD API applications."], |
| 34 |
[1, 206, "legacyMultipleProvides", "Module included multiple dojo.provide applications."], |
| 35 |
[1, 207, "legacyImproperProvide", "dojo.provide application identifier inconsistent with module identifier."], |
| 36 |
[1, 208, "inputDeprecatedProfileFile", "The \"profileFile\" switch has been deprecated; use \"profile\" instead."], |
| 37 |
[1, 209, "missingPackageJson", "Missing or empty package.json."], |
| 38 |
[1, 210, "inputDeprecatedStripConsole", "Given strip console value is deprecated."], |
| 39 |
[1, 211, "inputDeprecated", "Deprecated switch; ignored"], |
| 40 |
[1, 212, "oddDojoPath", "No profile.basePath provided, yet dojo path is relative and running build with the current working directory different than util/buildscripts"], |
| 41 |
[1, 213, "buildUsingDifferentDojo", "Dojo path specified in profile is different than the dojo being used for the build program"], |
| 42 |
[1, 214, "ignoringReleaseDirName", "DestBasePath given; ignoring releaseDir and releaseName."], |
| 43 |
[1, 215, "inputLoggerRemoved", "Logger has been removed; all calls ignored"], |
| 44 |
[1, 216, "dojoHasUnresolvedMid", "dojo/has plugin resource could not be resolved during build-time."], |
| 45 |
[1, 217, "cleanRemoved", "the clean action has been removed; use rm (*nix) or rmdir (Windows)"], |
| 46 |
[1, 218, "inputProfileFileDeprecated", "the command line switch profileFile is deprectated; use profile for both files and profiles"], |
| 47 |
[1, 219, "userWarn", "User warn:"], |
| 48 |
[1, 220, "outputToProfileFileDeprecated", "Writing htmlFiles- or htmlDirs-derived profile via the profileFile option is deprecated; use the writeProfile option instead"], |
| 49 |
[1, 221, "assumeLayerIsDojoModule", "Assumed layer is referencing a dojo module."], |
| 50 |
[1, 222, "assumeLayerDependencyIsDojoModule", "Assumed layer is referencing a dojo module."], |
| 51 |
[1, 223, "possibleLegacyModuleId", "Name in internStringsSkipList looks like a legacy module identifier."], |
| 52 |
[1, 224, "missingPluginResolver", "A plugin dependency was encountered but there was no build-time plugin resolver."], |
| 53 |
[1, 225, "missingDirDuringDiscovery", "A directory that was scheduled to be read during discovery did not exist."], |
| 54 |
[1, 226, "missingProfile", "A package without a profile could throw errors or warnings."], |
| 55 |
[1, 227, "symbolsLeak", "Inserting symbols (by setting the profile variable 'symbol') causes leaks in IE."], |
| 56 |
[1, 228, "cssOptimizeIgnoredNoResource", "While optimizing a CSS file, an import directive was not expanded because the source for the import was not available to the builder."], |
| 57 |
|
| 58 |
|
| 59 |
[1, 300, "dojoHasMissingPlugin", "Missing dojo/has module."], |
| 60 |
[1, 302, "dojoHasMissingMid", "Missing dojo/has plugin resource that was resolved at build-time."], |
| 61 |
[1, 303, "amdMissingLayerIncludeModule", "Missing include module for layer."], |
| 62 |
[1, 304, "amdMissingLayerExcludeModule", "Missing exclude module for layer."], |
| 63 |
[1, 305, "amdMissingLayerModuleText", "Missing module text for layer."], |
| 64 |
[1, 306, "legacyFailedEval", "Failed to evaluate legacy API application."], |
| 65 |
[1, 307, "amdFailedEval", "Failed to evaluate module tagged as pure AMD (fell back to processing with regular expressions)."], |
| 66 |
[1, 308, "amdFailedDefineEval", "Failed to evaluate AMD define function."], |
| 67 |
[1, 309, "i18nNoRoot", "Missing root bundle for locale-specific legacy i18n bundle"], |
| 68 |
[1, 310, "i18nImproperBundle", "Non-i18n module found in nls tree (copied only)."], |
| 69 |
[1, 311, "amdMissingDependency", "Missing dependency."], |
| 70 |
[1, 312, "optimizeFailedWrite", "Failed to write optimized file."], |
| 71 |
[1, 313, "cssOptimizeFailed", "Failed to optimize CSS file."], |
| 72 |
[1, 314, "execFailed", "(Rhino)External process threw."], |
| 73 |
[1, 315, "inputInvalidPath", "Unable to compute absolute path."], |
| 74 |
[1, 316, "inputUnknownAction", "Unknown action."], |
| 75 |
[1, 317, "inputUnknownStripConsole", "Unknown strip console value."], |
| 76 |
[1, 318, "inputUnknownLayerOptimize", "Unknown layer optimize value."], |
| 77 |
[1, 319, "inputUnknownOptimize", "Unknown optimize value."], |
| 78 |
[1, 320, "inputUnknownTransform", "Unknown transform."], |
| 79 |
[1, 321, "inputUnknownGate", "Unknown gate."], |
| 80 |
[1, 322, "inputNoLoaderForBoot", "Unable to find loader for boot layer."], |
| 81 |
[1, 323, "failedReadAndEval", "failed to read and eval file."], |
| 82 |
[1, 324, "transformFailed", "Error while transforming resource."], |
| 83 |
[1, 325, "discoveryFailed", "Failed to discover any resources to transform. Nothing to do; terminating application"], |
| 84 |
[1, 326, "overwrite", "Output intersects input"], |
| 85 |
[1, 327, "outputCollide", "Multiple resources are destined for same filename."], |
| 86 |
[1, 328, "noTransform", "No transform found for discovered resouce."], |
| 87 |
[1, 329, "layerToMidFailed", "Failed to resolve layer name into a module identifier."], |
| 88 |
[1, 330, "layerMissingDependency", "Failed to resolve layer dependency."], |
| 89 |
[1, 331, "getDependencyListRemoved", "load(\"getDependencyList.js\") is no supported."], |
| 90 |
[1, 332, "invalidMessageId", "Invalid message identifier."], |
| 91 |
[1, 333, "legacyMissingDependency", "Missing dependency in legacy module."], |
| 92 |
[1, 334, "amdCannotInstantiateLayer", "Cannot instantiate all modules in layer."], |
| 93 |
[1, 335, "dojoPragmaEvalFail", "Failed to evaluate dojo pragma."], |
| 94 |
[1, 336, "dojoPragmaInvalid", "Failed to find end marker for dojo pragma."], |
| 95 |
[1, 337, "inputMissingPackageJson", "Missing or empty package.json file at location specified by package flag."], |
| 96 |
[1, 337, "inputMalformedPackageJson", "Malformed package.json file."], |
| 97 |
[1, 338, "inputProfileDoesNotExist", "Profile given for \"profile\" switch does not exist."], |
| 98 |
[1, 339, "inputProfileFileDoesNotExist", "Profile file given for \"profileFile\" switch does not exist."], |
| 99 |
[1, 340, "inputHTMLFileDoesNotExist", "HTML file given for \"htmlFiles\" switch does not exist."], |
| 100 |
[1, 341, "inputHTMLDirDoesNotExist", "HTML directory given for \"htmlDir\" switch does not exist."], |
| 101 |
[1, 342, "inputHTMLDirNoFiles","HTML directory given for \"htmlDir\" switch contains no HTML files."], |
| 102 |
[1, 343, "inputIllegalCommandlineArg", "Illegal or missing argument for command line flag."], |
| 103 |
[1, 344, "inputFileDoesNotExist", "File does not exist."], |
| 104 |
[1, 345, "inputProcessingHtmlFileNotImplemented", "Pulling profiles from HTML files is not implemented."], |
| 105 |
[1, 346, "inputFailedReadfile", "Failed to read input file."], |
| 106 |
[1, 347, "inputFailedToEvalProfile", "Failed to evaluate profile file."], |
| 107 |
[1, 348, "userError", "User error:"], |
| 108 |
[1, 349, "missingPrefix", "Missing prefix for top-level module."], |
| 109 |
[1, 350, "cannotDeduceModuleIdFrom16LayerName", "Cannot deduce module identifier from layer name"], |
| 110 |
[1, 351, "cannotDeduceModuleIdFrom16LayerDependency", "Cannot deduce module identifier from layer dependency"], |
| 111 |
[1, 352, "optimizerReportedErrors", "Optimizer reported errors; consult build report for details."], |
| 112 |
[1, 352, "failedToReadLayerCopyrightFile", "Failed to read copyright file given with layer."], |
| 113 |
[1, 353, "i18nUnevaluableBundle", "I18n bundle was not evaluable in the build environment; therefore it will not be included in the flattening computations."], |
| 114 |
[1, 354, "missingL10n", "Root bundle indicates localized bundles that don't exist."], |
| 115 |
[1, 355, "declarativeRequireFailed", "Unable to convert declarative require."], |
| 116 |
[1, 356, "optimizeFailed", "The optimizer threw an exception; the module probably contains syntax errors."], |
| 117 |
[1, 357, "cssOptimizeUnableToResolveURL", "While optimizing a CSS file, it was impossible to compute the destination location of a relative URL."], |
| 118 |
[1, 358, "cssOptimizeImproperComment", "While optimizing a CSS file, an improper comment was encountered."], |
| 119 |
|
| 120 |
|
| 121 |
[1, 400, "hasReport", "Has Features Detected"], |
| 122 |
[3, 499, "signoff", "Process completed normally:"]], |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
lastReportId = 400, |
| 128 |
|
| 129 |
lastUserId = 500, |
| 130 |
|
| 131 |
warnCount = 0, |
| 132 |
|
| 133 |
errorCount = 0, |
| 134 |
|
| 135 |
messageMap = {}, |
| 136 |
|
| 137 |
pacifySet = {}, |
| 138 |
|
| 139 |
getNewMessageId = function(report){ |
| 140 |
return report ? ++lastReportId : ++lastUserId; |
| 141 |
}, |
| 142 |
|
| 143 |
addMessage = function(order, numericId, symbolicId, message, pacifyMessage){ |
| 144 |
for(var i= 0; i<messages.length; i++){ |
| 145 |
if(messages[i][0]>order){ |
| 146 |
break; |
| 147 |
} |
| 148 |
} |
| 149 |
messages.splice(i, 0, [order, numericId, symbolicId, message, []]); |
| 150 |
messageMap[symbolicId] = messages[i]; |
| 151 |
|
| 152 |
if(pacifyMessage){ |
| 153 |
pacifySet[symbolicId] = 1; |
| 154 |
} |
| 155 |
}, |
| 156 |
|
| 157 |
addCategory = function(name, range){ |
| 158 |
if(categories[name]){ |
| 159 |
categories[name].push(range); |
| 160 |
}else{ |
| 161 |
categories[name] = [range]; |
| 162 |
} |
| 163 |
}, |
| 164 |
|
| 165 |
getPrefix = function(id){ |
| 166 |
var result; |
| 167 |
for(var p in categories){ |
| 168 |
if(categories[p].some(function(range){ |
| 169 |
if(range[0]<=id && id<range[1]){ |
| 170 |
return result = p + "(" + id + ")"; |
| 171 |
} |
| 172 |
return 0; |
| 173 |
})){ |
| 174 |
return result; |
| 175 |
} |
| 176 |
} |
| 177 |
return "message-id(" + id + ")"; |
| 178 |
}, |
| 179 |
|
| 180 |
getArgs = function(args){ |
| 181 |
var result = ""; |
| 182 |
if(typeof args=="undefined"){ |
| 183 |
|
| 184 |
}else if(typeof args=="string"){ |
| 185 |
result+= args; |
| 186 |
}else if(args.length==1){ |
| 187 |
result+= args[0]; |
| 188 |
}else{ |
| 189 |
for(var i= 0; i<args.length;){ |
| 190 |
result+= args[i++]; |
| 191 |
if(i<args.length){ |
| 192 |
result+= ": " + args[i++]; |
| 193 |
} |
| 194 |
if(i<args.length){ |
| 195 |
result+= "; "; |
| 196 |
} |
| 197 |
} |
| 198 |
} |
| 199 |
return result; |
| 200 |
}, |
| 201 |
|
| 202 |
stop = 0, |
| 203 |
|
| 204 |
log = function(id, args){ |
| 205 |
if(stop){ |
| 206 |
return; |
| 207 |
} |
| 208 |
if(id=="pacify"){ |
| 209 |
console.log(args); |
| 210 |
}else if(id in messageMap){ |
| 211 |
var item = messageMap[id]; |
| 212 |
item[4].push(args); |
| 213 |
if(200<=item[1] && item[1]<=299){ |
| 214 |
warnCount++; |
| 215 |
}else if(300<=item[1] && item[1]<=399){ |
| 216 |
errorCount++; |
| 217 |
} |
| 218 |
if(id in pacifySet){ |
| 219 |
console.log(getPrefix(item[1]) + " " + item[3] + " " + getArgs(args)); |
| 220 |
} |
| 221 |
}else{ |
| 222 |
|
| 223 |
messageMap.invalidMessageId[4].push(["id", id].concat(args)); |
| 224 |
} |
| 225 |
}, |
| 226 |
|
| 227 |
optimizerReportedErrors = 0, |
| 228 |
|
| 229 |
logOptimizerReportedErrors = function(){ |
| 230 |
if(!optimizerReportedErrors){ |
| 231 |
log("optimizerReportedErrors"); |
| 232 |
optimizerReportedErrors = 1; |
| 233 |
} |
| 234 |
}, |
| 235 |
|
| 236 |
optimizerOutput= "", |
| 237 |
|
| 238 |
logOptimizerOutput = function(text){ |
| 239 |
if(/\sERROR\s-\s\[[^\]]+]\s/.test(text)){ |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
logOptimizerReportedErrors(); |
| 244 |
} |
| 245 |
optimizerOutput+= text; |
| 246 |
}, |
| 247 |
|
| 248 |
getOptimizerOutput = function(){ |
| 249 |
return optimizerOutput; |
| 250 |
}, |
| 251 |
|
| 252 |
getAllNonreportMessages = function(){ |
| 253 |
var result = ""; |
| 254 |
messages.forEach(function(item){ |
| 255 |
if ((item[1]<400 || 499<item[1]) && item[4].length){ |
| 256 |
result+= getPrefix(item[1]) + " " + item[3] + "\n"; |
| 257 |
item[4].forEach(function(item){ |
| 258 |
result+= "\t" + getArgs(item) + "\n"; |
| 259 |
}); |
| 260 |
} |
| 261 |
}); |
| 262 |
return result; |
| 263 |
}, |
| 264 |
|
| 265 |
getAllReportMessages = function(){ |
| 266 |
var result = ""; |
| 267 |
messages.forEach(function(item){ |
| 268 |
if (400<=item[1] && item[1]<=499 && item[4].length){ |
| 269 |
result+= "\n\n" + item[3] + "\n"; |
| 270 |
item[4].forEach(function(item){ |
| 271 |
result+= "\t" + getArgs(item) + "\n"; |
| 272 |
}); |
| 273 |
} |
| 274 |
}); |
| 275 |
return result; |
| 276 |
}; |
| 277 |
|
| 278 |
|
| 279 |
var temp = messages; |
| 280 |
messages = []; |
| 281 |
temp.forEach(function(item){ |
| 282 |
addMessage(item[0], item[1], item[2], item[3]); |
| 283 |
|
| 284 |
|
| 285 |
if(200<=item[1] && item[1]<=399){ |
| 286 |
pacifySet[item[2]] = 1; |
| 287 |
} |
| 288 |
}); |
| 289 |
|
| 290 |
|
| 291 |
pacifySet.packageVersion = 1; |
| 292 |
pacifySet.signoff = 1; |
| 293 |
|
| 294 |
return { |
| 295 |
stop:function(){stop = 1;}, |
| 296 |
messages:messages, |
| 297 |
messageMap:messageMap, |
| 298 |
pacifySet:pacifySet, |
| 299 |
getNewMessageId:getNewMessageId, |
| 300 |
addMessage:addMessage, |
| 301 |
addCategory:addCategory, |
| 302 |
log:log, |
| 303 |
logOptimizerOutput:logOptimizerOutput, |
| 304 |
getOptimizerOutput:getOptimizerOutput, |
| 305 |
getAllNonreportMessages:getAllNonreportMessages, |
| 306 |
getAllReportMessages:getAllReportMessages, |
| 307 |
getWarnCount:function(){return warnCount;}, |
| 308 |
getErrorCount:function(){return errorCount;}, |
| 309 |
trace:function(message){log("userTrace", message);}, |
| 310 |
info:function(message){log("userInfo", message);}, |
| 311 |
warn:function(message){log("userWarn", message);}, |
| 312 |
error:function(message){log("userError", message);} |
| 313 |
}; |
| 314 |
}); |