| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 "use strict"; | |
| 6 | |
| 7 const fs = require('fs'); | |
| 8 const path = require('path'); | |
| 9 | |
| 10 const utils = require('../utils'); | |
| 11 | |
| 12 const FRONTEND_PATH = path.resolve(__dirname, '..', '..', 'front_end'); | |
| 13 const OUT = path.resolve(__dirname, 'out', 'dependencies.dot'); | |
| 14 | |
| 15 function main() { | |
| 16 const modules = new Set(); | |
| 17 const moduleToDependencyList = ['digraph dependencies {']; | |
| 18 moduleToDependencyList.push('fixedsize = true;') | |
| 19 fs.readdirSync(FRONTEND_PATH).forEach(function(file) { | |
| 20 const moduleJSONPath = path.join(FRONTEND_PATH, file, 'module.json'); | |
| 21 if (fs.statSync(path.join(FRONTEND_PATH, file)).isDirectory() && | |
| 22 utils.isFile(moduleJSONPath)) { | |
| 23 const module = file; | |
| 24 if (module === 'audits2_worker') | |
| 25 return; | |
| 26 modules.add(module); | |
| 27 const moduleJSON = require(moduleJSONPath); | |
| 28 let moduleSize = 0; | |
| 29 | |
| 30 let resources = (moduleJSON.scripts || []).concat((moduleJSON.resources ||
[])); | |
| 31 for (let script of resources) { | |
| 32 if (fs.existsSync(path.join(FRONTEND_PATH, module, script))) { | |
| 33 console.log(path.join(FRONTEND_PATH, module, script)); | |
| 34 moduleSize += fs.statSync(path.join(FRONTEND_PATH, module, script)).si
ze; | |
| 35 } | |
| 36 } | |
| 37 moduleSize /= 200000; | |
| 38 moduleSize = Math.max(0.5, moduleSize); | |
| 39 let fontSize = Math.max(moduleSize*14, 14); | |
| 40 | |
| 41 moduleToDependencyList.push(`${module} [width=${moduleSize}, height=${modu
leSize} fontsize=${fontSize}];`); | |
| 42 | |
| 43 if (moduleJSON.dependencies) { | |
| 44 for (let d of moduleJSON.dependencies) { | |
| 45 moduleToDependencyList.push(` ${module} -> ${d}`); | |
| 46 } | |
| 47 } | |
| 48 } | |
| 49 }); | |
| 50 moduleToDependencyList.push('}'); | |
| 51 const content = moduleToDependencyList.join('\n'); | |
| 52 fs.writeFileSync(OUT, content); | |
| 53 } | |
| 54 | |
| 55 if (require.main === module) | |
| 56 main(); | |
| OLD | NEW |