source: Dev/branches/rest-dojo-ui/client/util/build/messages.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

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