12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- const childProcess = require('child_process');
- const fs = require('fs-extra');
- const glob = require('glob');
- const path = require('path');
- const url = require('url');
- const basePath = path.resolve('..');
- const baseUrl = 'https://github.com/jupyterlab/jupyterlab/tree/master/packages';
- const packages = glob.sync(path.join(basePath, 'packages/*'));
- let text = ['digraph G {', 'node [shape=box];'];
- packages.forEach(function (packagePath) {
-
- const dataPath = path.join(packagePath, 'package.json');
- let data;
- try {
- data = require(dataPath);
- } catch (e) {
- return;
- }
- const name = data.name ?? 'UNKNOWN';
-
- if (data.private === true) {
- return;
- }
-
- if (!name.startsWith('@jupyterlab')) {
- return;
- }
-
-
- if (name.endsWith('-extension')) {
- return;
- }
-
- if (name === '@jupyterlab/metapackage') {
- return;
- }
- const shortName = name.split('/')[1];
- const urlLink = url.resolve(
- baseUrl,
- 'packages/' + path.basename(packagePath)
- );
-
- text.push(`"${shortName}" [URL="${urlLink}"];\n`);
- const deps = data.dependencies ?? [];
- for (let dep in deps) {
-
- if (dep.startsWith('@jupyterlab')) {
- text.push(`"${shortName}" -> "${dep.split('/')[1]}";\n`);
- }
- }
- });
- text.push('}');
- fs.writeFileSync('./dependencies.gv', text.join('\n'));
- childProcess.execSync(
- 'cat dependencies.gv | tred | dot -Tsvg -o dependency-graph.svg'
- );
- fs.unlinkSync('./dependencies.gv');
|