| 1 |
define([ |
| 2 |
"require", |
| 3 |
"dojo/_base/lang", |
| 4 |
"./argv", |
| 5 |
"./fs", |
| 6 |
"./fileUtils", |
| 7 |
"./buildControlDefault", |
| 8 |
"./v1xProfiles", |
| 9 |
"./stringify", |
| 10 |
"./process", |
| 11 |
"./messages", |
| 12 |
"dojo/text!./help.txt" |
| 13 |
], function(require, lang, argv, fs, fileUtils, bc, v1xProfiles, stringify, process, messages, helpText){ |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
if(!isNaN(argv)){ |
| 24 |
|
| 25 |
bc.exitCode = argv; |
| 26 |
return bc; |
| 27 |
} |
| 28 |
|
| 29 |
eval(require.scopeify("./fs, ./fileUtils, ./v1xProfiles")); |
| 30 |
var |
| 31 |
isString = function(it){ |
| 32 |
return typeof it === "string"; |
| 33 |
}, |
| 34 |
|
| 35 |
isNonemptyString = function(it){ |
| 36 |
return isString(it) && it.length; |
| 37 |
}, |
| 38 |
|
| 39 |
isDefined = function(it){ |
| 40 |
return typeof it !="undefined"; |
| 41 |
}, |
| 42 |
|
| 43 |
cleanupFilenamePair = function(item, srcBasePath, destBasePath, hint){ |
| 44 |
var result; |
| 45 |
if(isString(item)){ |
| 46 |
result = [computePath(item, srcBasePath), computePath(item, destBasePath)]; |
| 47 |
}else{ |
| 48 |
result = [computePath(item[0], srcBasePath), computePath(item[1], destBasePath)].concat(item.slice(2)); |
| 49 |
} |
| 50 |
if(!isAbsolutePath(result[0]) || !isAbsolutePath(result[1])){ |
| 51 |
bc.log("inputInvalidPath", ["path", item, "hint", hint]); |
| 52 |
} |
| 53 |
return result; |
| 54 |
}, |
| 55 |
|
| 56 |
slashTerminate = function(path){ |
| 57 |
return path + /\/$/.test(path) ? "" : "/"; |
| 58 |
}, |
| 59 |
|
| 60 |
isEmpty = function(it){ |
| 61 |
for(var p in it) return false; |
| 62 |
return true; |
| 63 |
}, |
| 64 |
|
| 65 |
cleanDeprecated = function(o, inputFile){ |
| 66 |
var deprecated = []; |
| 67 |
for(var p in o){ |
| 68 |
if(/^(log|loader|xdDojoPath|scopeDjConfig|xdScopeArgs|xdDojoScopeName|expandProvide|buildLayers|query|removeDefaultNameSpaces|addGuards)$/.test(p)){ |
| 69 |
deprecated.push(p); |
| 70 |
bc.log("inputDeprecated", ["switch", p, inputFile]); |
| 71 |
} |
| 72 |
} |
| 73 |
deprecated.forEach(function(p){ |
| 74 |
delete o[p]; |
| 75 |
}); |
| 76 |
}, |
| 77 |
|
| 78 |
mix = function(dest, src){ |
| 79 |
dest = dest || {}; |
| 80 |
src = src || {}; |
| 81 |
for(var p in src) dest[p] = src[p]; |
| 82 |
return dest; |
| 83 |
}, |
| 84 |
|
| 85 |
mixPackage = function(packageInfo){ |
| 86 |
var name = packageInfo.name; |
| 87 |
bc.packageMap[name] = mix(bc.packageMap[name], packageInfo); |
| 88 |
}, |
| 89 |
|
| 90 |
|
| 91 |
mixProfileObject = function(src){ |
| 92 |
cleanDeprecated(src, src.selfFilename); |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
for(var p in src){ |
| 99 |
if(!/paths|plugins|messages|transforms|staticHasFeatures|packages|packagePaths|defaultConfig/.test(p)){ |
| 100 |
bc[p] = src[p]; |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
["paths","plugins","transforms","staticHasFeatures"].forEach(function(p){ |
| 106 |
bc[p] = mix(bc[p], src[p]); |
| 107 |
}); |
| 108 |
|
| 109 |
|
| 110 |
if(src.messageCategories){ |
| 111 |
for(p in src.messageCategories){ |
| 112 |
bc.addCategory(p, src.messageCategories[p]); |
| 113 |
} |
| 114 |
} |
| 115 |
(src.messages || []).forEach(function(item){bc.addMessage.apply(bc, item);}); |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
for(var base in src.packagePaths){ |
| 122 |
src.packagePaths[base].forEach(function(packageInfo){ |
| 123 |
if(isString(packageInfo)){ |
| 124 |
packageInfo = {name:packageInfo}; |
| 125 |
} |
| 126 |
packageInfo.location = catPath(base, packageInfo.name); |
| 127 |
mixPackage(packageInfo); |
| 128 |
}); |
| 129 |
} |
| 130 |
(src.packages || []).forEach(function(packageInfo){ |
| 131 |
if(isString(packageInfo)){ |
| 132 |
packageInfo = {name:packageInfo}; |
| 133 |
} |
| 134 |
mixPackage(packageInfo); |
| 135 |
}); |
| 136 |
|
| 137 |
|
| 138 |
for(p in src.defaultConfig){ |
| 139 |
if(p=="hasCache"){ |
| 140 |
mix(bc.defaultConfig.hasCache, src.defaultConfig.hasCache); |
| 141 |
}else{ |
| 142 |
bc.defaultConfig[p] = src.defaultConfig[p]; |
| 143 |
} |
| 144 |
} |
| 145 |
}; |
| 146 |
|
| 147 |
argv.args.profiles.forEach(function(item){ |
| 148 |
var temp = mix({}, item), |
| 149 |
build = item.build; |
| 150 |
delete temp.build; |
| 151 |
mixProfileObject(temp); |
| 152 |
build && mixProfileObject(build); |
| 153 |
}); |
| 154 |
|
| 155 |
cleanDeprecated(argv.args, "command line"); |
| 156 |
|
| 157 |
|
| 158 |
for(var argName in argv.args) if(argName!="profiles"){ |
| 159 |
bc[argName] = argv.args[argName]; |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
bc.basePath = computePath(bc.basePath, process.cwd()); |
| 164 |
var releaseDir = catPath(bc.releaseDir || "../release", bc.releaseName || ""); |
| 165 |
bc.destBasePath = computePath(releaseDir, bc.basePath); |
| 166 |
|
| 167 |
|
| 168 |
bc.copyright = isNonemptyString(bc.copyright) ? (maybeRead(computePath(bc.copyright, bc.basePath)) || bc.copyright) : ""; |
| 169 |
bc.copyrightLayers = !!bc.copyrightLayers; |
| 170 |
bc.copyrightNonlayers = !!bc.copyrightNonlayers; |
| 171 |
|
| 172 |
|
| 173 |
(function(){ |
| 174 |
for(var property in {files:1, dirs:1, trees:1}){ |
| 175 |
if(bc[property] instanceof Array){ |
| 176 |
bc[property] = bc[property].map(function(item){ |
| 177 |
return cleanupFilenamePair(item, bc.basePath, bc.destBasePath, property); |
| 178 |
}); |
| 179 |
} |
| 180 |
} |
| 181 |
})(); |
| 182 |
|
| 183 |
|
| 184 |
(function(){ |
| 185 |
var cleanSet = {}, src, dest; |
| 186 |
for(src in bc.replacements){ |
| 187 |
cleanSet[computePath(src, bc.basePath)] = bc.replacements[src]; |
| 188 |
} |
| 189 |
bc.replacements = cleanSet; |
| 190 |
})(); |
| 191 |
|
| 192 |
|
| 193 |
if(!("mini" in bc)){ |
| 194 |
bc.mini = true; |
| 195 |
} |
| 196 |
if(!("copyTests" in bc)){ |
| 197 |
bc.copyTests = !bc.mini; |
| 198 |
} |
| 199 |
if(isString(bc.copyTests)){ |
| 200 |
bc.copyTests = bc.copyTests.toLowerCase(); |
| 201 |
} |
| 202 |
if(bc.copyTests!="build"){ |
| 203 |
|
| 204 |
bc.copyTests = !!bc.copyTests; |
| 205 |
} |
| 206 |
|
| 207 |
function getDiscreteLocales(locale){ |
| 208 |
for(var locales = locale.split("-"), result = [], current = "", i = 0; i<locales.length; i++){ |
| 209 |
result.push(current += (i ? "-" : "") + locales[i]); |
| 210 |
} |
| 211 |
return result; |
| 212 |
} |
| 213 |
if(isString(bc.localeList)){ |
| 214 |
bc.localeList = bc.localeList.split(","); |
| 215 |
if(bc.localeList.length){ |
| 216 |
bc.localeList = bc.localeList.map(function(locale){ return lang.trim(locale); }); |
| 217 |
} |
| 218 |
} |
| 219 |
if(bc.localeList && bc.localeList.length){ |
| 220 |
if(bc.localeList.indexOf("ROOT")==-1){ |
| 221 |
bc.localeList.push("ROOT"); |
| 222 |
} |
| 223 |
var localeList = {}; |
| 224 |
bc.localeList.forEach(function(locale){ |
| 225 |
locale = lang.trim(locale); |
| 226 |
localeList[locale] = getDiscreteLocales(locale); |
| 227 |
}); |
| 228 |
bc.localeList.discreteLocales = localeList; |
| 229 |
}else{ |
| 230 |
bc.localeList = false; |
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
(function(){ |
| 235 |
function processPackage(pack){ |
| 236 |
var packName = pack.name, |
| 237 |
basePath = pack.basePath || bc.basePath; |
| 238 |
if(!pack.packageJson){ |
| 239 |
pack.packageJson = argv.readPackageJson(catPath(computePath(pack.location || ("./" + packName), basePath), "package.json"), "missingPackageJson"); |
| 240 |
} |
| 241 |
var packageJson = pack.packageJson; |
| 242 |
if(packageJson){ |
| 243 |
if(packageJson.version){ |
| 244 |
bc.log("packageVersion", ["package", packName, "version", packageJson.version]); |
| 245 |
|
| 246 |
|
| 247 |
if(typeof bc.version=="undefined" && packName=="dojo"){ |
| 248 |
bc.version = packageJson.version; |
| 249 |
} |
| 250 |
} |
| 251 |
if(packageJson.main && !pack.main){ |
| 252 |
pack.main= packageJson.main; |
| 253 |
} |
| 254 |
if(packageJson.directories && packageJson.directories.lib && !pack.location){ |
| 255 |
pack.location = catPath(getFilepath(packageJson.selfFilename), packageJson.directories.lib); |
| 256 |
} |
| 257 |
if("dojoBuild" in packageJson){ |
| 258 |
var defaultProfile = argv.readProfile("profile", catPath(getFilepath(packageJson.selfFilename), packageJson.dojoBuild)); |
| 259 |
for(var p in defaultProfile){ |
| 260 |
if(!(p in pack)){ |
| 261 |
pack[p] = defaultProfile[p]; |
| 262 |
}else if(p in {resourceTags:1}){ |
| 263 |
|
| 264 |
|
| 265 |
mix(pack[p], defaultProfile[p]); |
| 266 |
} |
| 267 |
} |
| 268 |
}else{ |
| 269 |
bc.log("missingProfile", ["package", packageJson.name]); |
| 270 |
} |
| 271 |
} |
| 272 |
|
| 273 |
|
| 274 |
pack.main = isString(pack.main) ? pack.main : "main"; |
| 275 |
if(pack.main.indexOf("./")===0){ |
| 276 |
pack.main = pack.main.substring(2); |
| 277 |
} |
| 278 |
if(pack.destMain && pack.destMain.indexOf("./")===0){ |
| 279 |
pack.destMain = pack.destMain.substring(2); |
| 280 |
} |
| 281 |
|
| 282 |
pack.location = computePath(pack.location || ("./" + packName), basePath); |
| 283 |
|
| 284 |
pack.copyright = isNonemptyString(pack.copyright) ? |
| 285 |
(maybeRead(computePath(pack.copyright, pack.location)) || maybeRead(computePath(pack.copyright, bc.basePath)) || pack.copyright) : |
| 286 |
(pack.copyright ? bc.copyright : ""); |
| 287 |
pack.copyrightLayers = isDefined(pack.copyrightLayers) ? !!pack.copyrightLayers : bc.copyrightLayers; |
| 288 |
pack.copyrightNonlayers = isDefined(pack.copyrightNonlayers) ? !!pack.copyrightNonlayers : bc.copyrightNonlayers; |
| 289 |
|
| 290 |
|
| 291 |
var destPack = bc.destPackages[packName] = { |
| 292 |
name:pack.destName || packName, |
| 293 |
main:pack.destMain || pack.main, |
| 294 |
location:computePath(pack.destLocation || ("./" + (pack.destName || packName)), bc.destBasePath) |
| 295 |
}; |
| 296 |
delete pack.destName; |
| 297 |
delete pack.destMain; |
| 298 |
delete pack.destLocation; |
| 299 |
|
| 300 |
|
| 301 |
if(!pack.trees){ |
| 302 |
|
| 303 |
pack.trees = [[pack.location, destPack.location, /(\/\.)|(^\.)|(~$)/]]; |
| 304 |
} |
| 305 |
|
| 306 |
|
| 307 |
for(var property in {files:1, dirs:1, trees:1}){ |
| 308 |
pack[property] = (pack[property] || []).map(function(item){ |
| 309 |
return cleanupFilenamePair(item, pack.location, destPack.location, property + " in package " + packName); |
| 310 |
}); |
| 311 |
} |
| 312 |
} |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
bc.packages = bc.packageMap; |
| 319 |
delete bc.packageMap; |
| 320 |
bc.destPackages = {}; |
| 321 |
for(var packageName in bc.packages){ |
| 322 |
var pack = bc.packages[packageName]; |
| 323 |
pack.name = pack.name || packageName; |
| 324 |
processPackage(pack); |
| 325 |
} |
| 326 |
|
| 327 |
|
| 328 |
if(bc.copyTests && !bc.packages.doh){ |
| 329 |
bc.packages.doh = { |
| 330 |
name:"doh", |
| 331 |
location:compactPath(bc.packages.dojo.location + "/../util/doh"), |
| 332 |
destLocation:"util/doh" |
| 333 |
}; |
| 334 |
processPackage(bc.packages.doh); |
| 335 |
} |
| 336 |
|
| 337 |
|
| 338 |
require.computeAliases(bc.aliases, (bc.aliasesMap = [])); |
| 339 |
require.computeMapProg(bc.paths, (bc.pathsMapProg = [])); |
| 340 |
|
| 341 |
bc.mapProgs = []; |
| 342 |
require.computeMapProg(bc.map, bc.mapProgs); |
| 343 |
bc.mapProgs.forEach(function(item){ |
| 344 |
item[1] = require.computeMapProg(item[1], []); |
| 345 |
if(item[0]=="*"){ |
| 346 |
bc.mapProgs.star = item; |
| 347 |
} |
| 348 |
}); |
| 349 |
|
| 350 |
|
| 351 |
bc.srcModules = {}; |
| 352 |
bc.destModules = {}; |
| 353 |
|
| 354 |
var trimLastChars = function(text, n){ |
| 355 |
return text.substring(0, text.length-n); |
| 356 |
}; |
| 357 |
|
| 358 |
bc.getSrcModuleInfo = function(mid, referenceModule, ignoreFileType){ |
| 359 |
if(ignoreFileType){ |
| 360 |
var result = require.getModuleInfo(mid+"/x", referenceModule, bc.packages, bc.srcModules, bc.basePath + "/", bc.mapProgs, bc.pathsMapProg, bc.aliasesMap, true); |
| 361 |
result.mid = trimLastChars(result.mid, 2); |
| 362 |
if(result.pid!==0){ |
| 363 |
|
| 364 |
result.url = trimLastChars(result.url, 5); |
| 365 |
} |
| 366 |
return result; |
| 367 |
}else{ |
| 368 |
return require.getModuleInfo(mid, referenceModule, bc.packages, bc.srcModules, bc.basePath + "/", bc.mapProgs, bc.pathsMapProg, bc.aliasesMap, true); |
| 369 |
} |
| 370 |
}; |
| 371 |
|
| 372 |
|
| 373 |
bc.getDestModuleInfo = function(mid, referenceModule, ignoreFileType){ |
| 374 |
|
| 375 |
if(ignoreFileType){ |
| 376 |
var result = require.getModuleInfo(mid+"/x", referenceModule, bc.destPackages, bc.destModules, bc.destBasePath + "/", [], [], [], true); |
| 377 |
result.mid = trimLastChars(result.mid, 2); |
| 378 |
if(result.pid!==0){ |
| 379 |
|
| 380 |
result.url = trimLastChars(result.url, 5); |
| 381 |
} |
| 382 |
return result; |
| 383 |
}else{ |
| 384 |
return require.getModuleInfo(mid, referenceModule, bc.destPackages, bc.destModules, bc.destBasePath + "/", [], [], [], true); |
| 385 |
} |
| 386 |
}; |
| 387 |
|
| 388 |
bc.getAmdModule = function( |
| 389 |
mid, |
| 390 |
referenceModule |
| 391 |
){ |
| 392 |
var match = mid.match(/^([^\!]+)\!(.*)$/); |
| 393 |
if(match){ |
| 394 |
var pluginModuleInfo = bc.getSrcModuleInfo(match[1], referenceModule), |
| 395 |
pluginModule = pluginModuleInfo && bc.amdResources[pluginModuleInfo.mid], |
| 396 |
pluginId = pluginModule && pluginModule.mid, |
| 397 |
pluginProc = bc.plugins[pluginId]; |
| 398 |
if(!pluginModule){ |
| 399 |
return 0; |
| 400 |
}else if(!pluginProc){ |
| 401 |
if(!pluginModule.noBuildResolver){ |
| 402 |
bc.log("missingPluginResolver", ["module", referenceModule.mid, "plugin", pluginId]); |
| 403 |
} |
| 404 |
return pluginModule; |
| 405 |
}else{ |
| 406 |
|
| 407 |
var modules = [].concat(pluginProc.start(match[2], referenceModule, bc)); |
| 408 |
return modules.concat.apply([], modules); |
| 409 |
} |
| 410 |
}else{ |
| 411 |
var moduleInfo = bc.getSrcModuleInfo(mid, referenceModule), |
| 412 |
module = moduleInfo && bc.amdResources[moduleInfo.mid]; |
| 413 |
return module; |
| 414 |
} |
| 415 |
}; |
| 416 |
|
| 417 |
})(); |
| 418 |
|
| 419 |
|
| 420 |
if(bc.selectorEngine && bc.defaultConfig && bc.defaultConfig.hasCache){ |
| 421 |
bc.defaultConfig.hasCache["config-selectorEngine"] = bc.selectorEngine; |
| 422 |
} |
| 423 |
|
| 424 |
(function(){ |
| 425 |
|
| 426 |
|
| 427 |
var layer, fixedLayers = {}; |
| 428 |
for(var mid in bc.layers){ |
| 429 |
layer = bc.layers[mid]; |
| 430 |
layer.exclude = layer.exclude || []; |
| 431 |
layer.include = layer.include || []; |
| 432 |
layer.boot = !!layer.boot; |
| 433 |
layer.discard = !!layer.discard; |
| 434 |
layer.compat = layer.compat!==undefined ? layer.compat : (bc.layerCompat ||""); |
| 435 |
layer.noref = !!(layer.noref!==undefined ? layer.noref : (layer.compat=="1.6" ? true : bc.noref)); |
| 436 |
|
| 437 |
var tlm = mid.split("/")[0], |
| 438 |
pack = bc.packages[tlm], |
| 439 |
packLocation = pack && pack.location, |
| 440 |
packCopyright = pack && pack.copyright, |
| 441 |
packCopyrightLayers = pack && pack.copyrightLayers; |
| 442 |
if(isNonemptyString(layer.copyright)){ |
| 443 |
|
| 444 |
layer.copyright = (packLocation && maybeRead(computePath(layer.copyright, packLocation))) || maybeRead(computePath(layer.copyright, bc.basePath)) || layer.copyright; |
| 445 |
}else if(isDefined(layer.copyright)){ |
| 446 |
|
| 447 |
layer.copyright = layer.copyright ? (packCopyright || bc.copyright) : ""; |
| 448 |
}else{ |
| 449 |
layer.copyright = pack ? (packCopyrightLayers && (packCopyright || bc.copyright)) : (bc.copyrightLayers && bc.copyright); |
| 450 |
} |
| 451 |
if(!layer.copyright){ |
| 452 |
layer.copyright = ""; |
| 453 |
} |
| 454 |
fixedLayers[mid] = layer; |
| 455 |
} |
| 456 |
bc.layers = fixedLayers; |
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
if(bc.packages.dojo){ |
| 461 |
if(!bc.layers["dojo/dojo"]){ |
| 462 |
bc.layers["dojo/dojo"] = {name:"dojo/dojo", copyright:bc.defaultCopyright + bc.defaultBuildNotice, include:["dojo/main"], exclude:[]}; |
| 463 |
} |
| 464 |
for(var p in bc.layers){ |
| 465 |
layer = bc.layers[p]; |
| 466 |
if(p=="dojo/dojo"){ |
| 467 |
if(!layer.customBase){ |
| 468 |
|
| 469 |
if(layer.include.indexOf("dojo/main")==-1){ |
| 470 |
layer.include.push("dojo/main"); |
| 471 |
} |
| 472 |
}else{ |
| 473 |
|
| 474 |
} |
| 475 |
}else{ |
| 476 |
if((layer.boot || !layer.customBase) && layer.exclude.indexOf("dojo/dojo")==-1){ |
| 477 |
|
| 478 |
layer.exclude.push("dojo/dojo"); |
| 479 |
} |
| 480 |
|
| 481 |
layer.customBase = layer.boot; |
| 482 |
} |
| 483 |
} |
| 484 |
} |
| 485 |
})(); |
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
var deleteStaticHasFlagSet = []; |
| 491 |
for(var p in bc.staticHasFeatures) if(bc.staticHasFeatures[p]==-1) deleteStaticHasFlagSet.push(p); |
| 492 |
deleteStaticHasFlagSet.forEach(function(flag){delete bc.staticHasFeatures[flag];}); |
| 493 |
|
| 494 |
if(bc.action){ |
| 495 |
bc.action.split(/\W|\s/).forEach(function(action){ |
| 496 |
action = action.match(/\s*(\S+)\s*/)[1]; |
| 497 |
switch(action){ |
| 498 |
case "check": |
| 499 |
bc.check = true; |
| 500 |
break; |
| 501 |
case "clean": |
| 502 |
bc.clean = true; |
| 503 |
break; |
| 504 |
case "release": |
| 505 |
bc.release = true; |
| 506 |
break; |
| 507 |
default: |
| 508 |
bc.log("inputUnknownAction", ["action", action]); |
| 509 |
} |
| 510 |
}); |
| 511 |
} |
| 512 |
|
| 513 |
if(bc.clean){ |
| 514 |
bc.log("cleanRemoved"); |
| 515 |
} |
| 516 |
|
| 517 |
|
| 518 |
var stripConsole = bc.stripConsole; |
| 519 |
if(!stripConsole || stripConsole=="none"){ |
| 520 |
stripConsole = false; |
| 521 |
}else if(stripConsole == "normal,warn"){ |
| 522 |
bc.log("inputDeprecatedStripConsole", ["deprecated", "normal,warn", "use", "warn"]); |
| 523 |
stripConsole = "warn"; |
| 524 |
}else if(stripConsole == "normal,error"){ |
| 525 |
bc.log("inputDeprecatedStripConsole", ["deprecated", "normal,error", "use", "all"]); |
| 526 |
stripConsole = "all"; |
| 527 |
}else if(!/normal|warn|all|none/.test(stripConsole)){ |
| 528 |
bc.log("inputUnknownStripConsole", ["value", stripConsole]); |
| 529 |
} |
| 530 |
bc.stripConsole = stripConsole; |
| 531 |
|
| 532 |
function fixupOptimize(value){ |
| 533 |
if(value){ |
| 534 |
value = value + ""; |
| 535 |
value = value.toLowerCase(); |
| 536 |
if(!/^(((comments|shrinksafe)(\.keeplines)?)|(closure(\.keeplines)?|uglify(\.keeplines)?))$/.test(value)){ |
| 537 |
bc.log("inputUnknownOptimize", ["value", value]); |
| 538 |
value = 0; |
| 539 |
}else{ |
| 540 |
if(/shrinksafe/.test(value) && stripConsole){ |
| 541 |
value+= "." + stripConsole; |
| 542 |
} |
| 543 |
} |
| 544 |
} |
| 545 |
return value; |
| 546 |
} |
| 547 |
bc.optimize = fixupOptimize(bc.optimize); |
| 548 |
bc.layerOptimize = fixupOptimize(bc.layerOptimize); |
| 549 |
|
| 550 |
if(/closure/.test(bc.optimize) || /closure/.test(bc.layerOptimize)){ |
| 551 |
bc.optimizeOptions = bc.optimizeOptions || {}; |
| 552 |
|
| 553 |
|
| 554 |
bc.optimizeOptions.languageIn = bc.optimizeOptions.languageIn || 'ECMASCRIPT_2017'; |
| 555 |
|
| 556 |
bc.optimizeOptions.languageOut = bc.optimizeOptions.languageOut || 'ECMASCRIPT3'; |
| 557 |
} |
| 558 |
|
| 559 |
(function(){ |
| 560 |
var fixedScopeMap = {dojo:"dojo", dijit:"dijit", dojox:"dojox"}; |
| 561 |
(bc.scopeMap || []).forEach(function(pair){ |
| 562 |
if(!pair[1]){ |
| 563 |
delete fixedScopeMap[pair[0]]; |
| 564 |
}else{ |
| 565 |
fixedScopeMap[pair[0]] = pair[1]; |
| 566 |
} |
| 567 |
}); |
| 568 |
bc.scopeMap = fixedScopeMap; |
| 569 |
|
| 570 |
bc.scopeNames = []; |
| 571 |
for(var p in fixedScopeMap){ |
| 572 |
bc.scopeNames.push(p); |
| 573 |
} |
| 574 |
})(); |
| 575 |
|
| 576 |
bc.internSkip = function(){return false;}; |
| 577 |
if(bc.internSkipList){ |
| 578 |
bc.internSkip = function(mid, referenceModule){ |
| 579 |
return bc.internSkipList.some(function(item){ |
| 580 |
var result = false; |
| 581 |
if(item instanceof RegExp){ |
| 582 |
result = item.test(mid); |
| 583 |
}else if(item instanceof Function){ |
| 584 |
result = item(mid, referenceModule); |
| 585 |
}else{ |
| 586 |
result = item==mid; |
| 587 |
} |
| 588 |
if(result){ |
| 589 |
bc.log("internStrings", ["module", referenceModule.mid, "skipping", mid]); |
| 590 |
} |
| 591 |
return result; |
| 592 |
}); |
| 593 |
}; |
| 594 |
} |
| 595 |
|
| 596 |
|
| 597 |
if(bc.check){ |
| 598 |
(function(){ |
| 599 |
var toDump = { |
| 600 |
aliases:1, |
| 601 |
basePath:1, |
| 602 |
buildReportDir:1, |
| 603 |
buildReportFilename:1, |
| 604 |
closureCompilerPath:1, |
| 605 |
copyright:1, |
| 606 |
copyrightLayers:1, |
| 607 |
copyrightNonlayers:1, |
| 608 |
copyTests:1, |
| 609 |
destBasePath:1, |
| 610 |
destModules:1, |
| 611 |
destPackages:1, |
| 612 |
destPathTransforms:1, |
| 613 |
dirs:1, |
| 614 |
discoveryProcs:1, |
| 615 |
files:1, |
| 616 |
insertAbsMids:1, |
| 617 |
internStringsSkipList:1, |
| 618 |
layers:1, |
| 619 |
localeList:1, |
| 620 |
includeLocales: 1, |
| 621 |
maxOptimizationProcesses:1, |
| 622 |
mini:1, |
| 623 |
optimize:1, |
| 624 |
layerOptimize:1, |
| 625 |
"package":1, |
| 626 |
packages:1, |
| 627 |
paths:1, |
| 628 |
pathsMapProg:1, |
| 629 |
plugins:1, |
| 630 |
replacements:1, |
| 631 |
startTimestamp:1, |
| 632 |
staticHasFeatures:1, |
| 633 |
stripConsole:1, |
| 634 |
trees:1, |
| 635 |
useSourceMaps:1 |
| 636 |
}; |
| 637 |
for(var p in toDump){ |
| 638 |
toDump[p] = bc[p]; |
| 639 |
} |
| 640 |
bc.log("pacify", stringify(toDump)); |
| 641 |
})(); |
| 642 |
bc.release = 0; |
| 643 |
} |
| 644 |
|
| 645 |
if(bc.writeProfile){ |
| 646 |
|
| 647 |
|
| 648 |
} |
| 649 |
|
| 650 |
if(bc.debugCheck){ |
| 651 |
(function(){ |
| 652 |
var toDump = {}; |
| 653 |
for(var p in bc){ |
| 654 |
if(bc[p]!==messages[p] && typeof bc[p]!="function"){ |
| 655 |
toDump[p] = bc[p]; |
| 656 |
} |
| 657 |
} |
| 658 |
console.log("profile:"); |
| 659 |
console.log(stringify(toDump)); |
| 660 |
toDump = {}; |
| 661 |
for(p in require){ |
| 662 |
if(p!="modules" && p!="module" && p!="rawConfig" && typeof require[p]!="function"){ |
| 663 |
toDump[p] = require[p]; |
| 664 |
} |
| 665 |
} |
| 666 |
console.log("require config:"); |
| 667 |
console.log(stringify(toDump)); |
| 668 |
})(); |
| 669 |
bc.release = 0; |
| 670 |
} |
| 671 |
|
| 672 |
|
| 673 |
(function(){ |
| 674 |
|
| 675 |
for(var gates = {}, i = 0; i<bc.gates.length; i++){ |
| 676 |
gates[bc.gates[i][1]] = i; |
| 677 |
} |
| 678 |
var |
| 679 |
transforms = bc.transforms, |
| 680 |
gateId; |
| 681 |
for(var transformId in transforms){ |
| 682 |
|
| 683 |
gateId = gates[transforms[transformId][1]]; |
| 684 |
if(typeof gateId == "undefined"){ |
| 685 |
bc.log("inputUnknownGate", ["transform", transformId, "gate", transforms[transformId][1]]); |
| 686 |
}else{ |
| 687 |
transforms[transformId][1] = gateId; |
| 688 |
} |
| 689 |
} |
| 690 |
})(); |
| 691 |
|
| 692 |
|
| 693 |
(function(){ |
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
var transforms = bc.transforms; |
| 698 |
bc.transformJobs.forEach(function(item){ |
| 699 |
|
| 700 |
var error = false; |
| 701 |
var tlist = item[1].map(function(id){ |
| 702 |
|
| 703 |
if(transforms[id]){ |
| 704 |
|
| 705 |
return [id, transforms[id][1]]; |
| 706 |
}else{ |
| 707 |
error = true; |
| 708 |
bc.log("inputUnknownTransform", ["transform", id]); |
| 709 |
return 0; |
| 710 |
} |
| 711 |
}); |
| 712 |
|
| 713 |
if(!error){ |
| 714 |
for(var i = 0, end = tlist.length - 1; i<end;){ |
| 715 |
if(tlist[i][1]>tlist[i+1][1]){ |
| 716 |
var t = tlist[i]; |
| 717 |
tlist[i] = tlist[i+1]; |
| 718 |
tlist[i+1] = t; |
| 719 |
i && i--; |
| 720 |
}else{ |
| 721 |
i++; |
| 722 |
} |
| 723 |
} |
| 724 |
|
| 725 |
item[1] = tlist; |
| 726 |
} |
| 727 |
}); |
| 728 |
})(); |
| 729 |
|
| 730 |
if(argv.args.unitTest=="dumpbc"){ |
| 731 |
console.log(stringify(bc) + "\n"); |
| 732 |
} |
| 733 |
|
| 734 |
if(bc.quiet){ |
| 735 |
(function(){ |
| 736 |
var delSet = {}; |
| 737 |
for(var p in bc.pacifySet){ |
| 738 |
if(bc.messageMap[p][1]>199){ |
| 739 |
delSet[p] = 1; |
| 740 |
} |
| 741 |
} |
| 742 |
for(p in delSet){ |
| 743 |
delete bc.pacifySet[p]; |
| 744 |
} |
| 745 |
})(); |
| 746 |
} |
| 747 |
|
| 748 |
if(bc.unitTestComputedProfile){ |
| 749 |
bc.unitTestComputedProfile(); |
| 750 |
|
| 751 |
bc.release = 0; |
| 752 |
} |
| 753 |
|
| 754 |
if(!bc.unitTestComputedProfile && !bc.check && !bc.debugCheck && !bc.clean && !bc.release){ |
| 755 |
bc.log("pacify", "Nothing to do; you must explicitly instruct the application to do something; use the option --help for help."); |
| 756 |
} |
| 757 |
|
| 758 |
return bc; |
| 759 |
}); |