source: Dev/trunk/src/client/util/build/messages.js @ 529

Last change on this file since 529 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 13.4 KB
Line 
1define([], 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                // [order, numeric-id, symbolic-id, message]
11                // info 100-199
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                // warn 200-299
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
57                // error 300-399
58                [1, 300, "dojoHasMissingPlugin", "Missing dojo/has module."],
59                [1, 302, "dojoHasMissingMid", "Missing dojo/has plugin resource that was resolved at build-time."],
60                [1, 303, "amdMissingLayerIncludeModule", "Missing include module for layer."],
61                [1, 304, "amdMissingLayerExcludeModule", "Missing exclude module for layer."],
62                [1, 305, "amdMissingLayerModuleText", "Missing module text for layer."],
63                [1, 306, "legacyFailedEval", "Failed to evaluate legacy API application."],
64                [1, 307, "amdFailedEval", "Failed to evaluate module tagged as pure AMD (fell back to processing with regular expressions)."],
65                [1, 308, "amdFailedDefineEval", "Failed to evaluate AMD define function."],
66                [1, 309, "i18nNoRoot", "Missing root bundle for locale-specific legacy i18n bundle"],
67                [1, 310, "i18nImproperBundle", "Non-i18n module found in nls tree (copied only)."],
68                [1, 311, "amdMissingDependency", "Missing dependency."],
69                [1, 312, "optimizeFailedWrite", "Failed to write optimized file."],
70                [1, 313, "cssOptimizeFailed", "Failed to optimize CSS file."],
71                [1, 314, "execFailed", "(Rhino)External process threw."],
72                [1, 315, "inputInvalidPath", "Unable to compute absolute path."],
73                [1, 316, "inputUnknownAction", "Unknown action."],
74                [1, 317, "inputUnknownStripConsole", "Unknown strip console value."],
75                [1, 318, "inputUnknownLayerOptimize", "Unknown layer optimize value."],
76                [1, 319, "inputUnknownOptimize", "Unknown optimize value."],
77                [1, 320, "inputUnknownTransform", "Unknown transform."],
78                [1, 321, "inputUnknownGate", "Unknown gate."],
79                [1, 322, "inputNoLoaderForBoot", "Unable to find loader for boot layer."],
80                [1, 323, "failedReadAndEval", "failed to read and eval file."],
81                [1, 324, "transformFailed", "Error while transforming resource."],
82                [1, 325, "discoveryFailed", "Failed to discover any resources to transform. Nothing to do; terminating application"],
83                [1, 326, "overwrite", "Output intersects input"],
84                [1, 327, "outputCollide", "Multiple resources are destined for same filename."],
85                [1, 328, "noTransform", "No transform found for discovered resouce."],
86                [1, 329, "layerToMidFailed", "Failed to resolve layer name into a module identifier."],
87                [1, 330, "layerMissingDependency", "Failed to resolve layer dependency."],
88                [1, 331, "getDependencyListRemoved", "load(\"getDependencyList.js\") is no supported."],
89                [1, 332, "invalidMessageId", "Invalid message identifier."],
90                [1, 333, "legacyMissingDependency", "Missing dependency in legacy module."],
91                [1, 334, "amdCannotInstantiateLayer", "Cannot instantiate all modules in layer."],
92                [1, 335, "dojoPragmaEvalFail", "Failed to evaluate dojo pragma."],
93                [1, 336, "dojoPragmaInvalid", "Failed to find end marker for dojo pragma."],
94                [1, 337, "inputMissingPackageJson", "Missing or empty package.json file at location specified by package flag."],
95                [1, 337, "inputMalformedPackageJson", "Malformed package.json file."],
96                [1, 338, "inputProfileDoesNotExist", "Profile given for \"profile\" switch does not exist."],
97                [1, 339, "inputProfileFileDoesNotExist", "Profile file given for \"profileFile\" switch does not exist."],
98                [1, 340, "inputHTMLFileDoesNotExist", "HTML file given for \"htmlFiles\" switch does not exist."],
99                [1, 341, "inputHTMLDirDoesNotExist", "HTML directory given for \"htmlDir\" switch does not exist."],
100                [1, 342, "inputHTMLDirNoFiles","HTML directory given for \"htmlDir\" switch contains no HTML files."],
101                [1, 343, "inputIllegalCommandlineArg", "Illegal or missing argument for command line flag."],
102                [1, 344, "inputFileDoesNotExist", "File does not exist."],
103                [1, 345, "inputProcessingHtmlFileNotImplemented", "Pulling profiles from HTML files is not implemented."],
104                [1, 346, "inputFailedReadfile", "Failed to read input file."],
105                [1, 347, "inputFailedToEvalProfile", "Failed to evaluate profile file."],
106                [1, 348, "userError", "User error:"],
107                [1, 349, "missingPrefix", "Missing prefix for top-level module."],
108                [1, 350, "cannotDeduceModuleIdFrom16LayerName", "Cannot deduce module identifier from layer name"],
109                [1, 351, "cannotDeduceModuleIdFrom16LayerDependency", "Cannot deduce module identifier from layer dependency"],
110                [1, 352, "optimizerReportedErrors", "Optimizer reported errors; consult build report for details."],
111                [1, 352, "failedToReadLayerCopyrightFile", "Failed to read copyright file given with layer."],
112                [1, 353, "i18nUnevaluableBundle", "I18n bundle was not evaluable in the build environment; therefore it will not be included in the flattening computations."],
113                [1, 354, "missingL10n", "Root bundle indicates localized bundles that don't exist."],
114                [1, 355, "declarativeRequireFailed", "Unable to convert declarative require."],
115                [1, 356, "optimizeFailed", "The optimizer threw an exception; the module probably contains syntax errors."],
116                [1, 357, "cssOptimizeUnableToResolveURL", "While optimizing a CSS file, it was impossible to compute the destination location of a relative URL."],
117                [1, 358, "cssOptimizeImproperComment", "While optimizing a CSS file, an improper comment was encountered."],
118                [1, 359, "cssOptimizeIgnoredNoResource", "While optimizing a CSS file, an import directive was not expanded because the source for the import was not available to the builder."],
119
120                // reports 400-499
121                [1, 400, "hasReport", "Has Features Detected"],
122                [3, 499, "signoff", "Process completed normally:"]],
123
124                // 500-999, reserved by build programs
125                // 1000+, may be used by extension apps
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                                // nothing to decode
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                                //require.nodeRequire("assert").fail(1, 2, "here", "x");
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/.test(text)){
240                                // the google closure error format
241                                logOptimizerReportedErrors();
242                        }
243                        optimizerOutput+= text;
244                },
245
246                getOptimizerOutput = function(){
247                        return optimizerOutput;
248                },
249
250                getAllNonreportMessages = function(){
251                        var result = "";
252                        messages.forEach(function(item){
253                                if ((item[1]<400 || 499<item[1]) && item[4].length){
254                                        result+= getPrefix(item[1]) + " " + item[3] + "\n";
255                                        item[4].forEach(function(item){
256                                                result+= "\t" + getArgs(item) + "\n";
257                                        });
258                                }
259                        });
260                        return result;
261                },
262
263                getAllReportMessages = function(){
264                        var result = "";
265                        messages.forEach(function(item){
266                                if (400<=item[1] && item[1]<=499 && item[4].length){
267                                        result+= "\n\n" + item[3] + "\n";
268                                        item[4].forEach(function(item){
269                                                result+= "\t" + getArgs(item) + "\n";
270                                        });
271                                }
272                        });
273                        return result;
274                };
275
276        // sort the messages; maybe some added, maybe they are out of order above
277        var temp = messages;
278        messages = [];
279        temp.forEach(function(item){
280                addMessage(item[0], item[1], item[2], item[3]);
281
282                // by default, send all warnings and errors to the console
283                if(200<=item[1] && item[1]<=399){
284                        pacifySet[item[2]] = 1;
285                }
286        });
287
288        //also send this to the console
289        pacifySet.packageVersion = 1;
290        pacifySet.signoff = 1;
291
292        return {
293                stop:function(){stop = 1;},
294                messages:messages,
295                messageMap:messageMap,
296                pacifySet:pacifySet,
297                getNewMessageId:getNewMessageId,
298                addMessage:addMessage,
299                addCategory:addCategory,
300                log:log,
301                logOptimizerOutput:logOptimizerOutput,
302                getOptimizerOutput:getOptimizerOutput,
303                getAllNonreportMessages:getAllNonreportMessages,
304                getAllReportMessages:getAllReportMessages,
305                getWarnCount:function(){return warnCount;},
306                getErrorCount:function(){return errorCount;},
307                trace:function(message){log("userTrace", message);},
308                info:function(message){log("userInfo", message);},
309                warn:function(message){log("userWarn", message);},
310                error:function(message){log("userError", message);}
311        };
312});
Note: See TracBrowser for help on using the repository browser.