Get all relevant metadata for revalalbnles
This commit is contained in:
parent
a7b829fbf5
commit
db8763942f
2 changed files with 135 additions and 61 deletions
|
|
@ -5,12 +5,13 @@ import { Octokit } from '@octokit/core';
|
|||
import child_process from 'child_process';
|
||||
import nodeGlob from 'glob';
|
||||
import { PROJECT_PATH, SUBPACKAGE_PATH } from './get-metadata.js';
|
||||
import getItemSize from 'get-folder-size';
|
||||
|
||||
const exec = promisify(child_process.exec);
|
||||
const glob = promisify(nodeGlob);
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: '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',
|
||||
auth: '',
|
||||
});
|
||||
|
||||
export async function getLegaciesForSubproject(subproject) {
|
||||
|
|
@ -38,7 +39,9 @@ export async function getLegaciesForSubproject(subproject) {
|
|||
.slice(0, 2);
|
||||
|
||||
// Transform to legacy object
|
||||
const legacies = largestFiles.map((largeFile) => createLegacy(largeFile));
|
||||
const legacies = await Promise.all(
|
||||
largestFiles.map(async (largeFile) => await createLegacy(largeFile))
|
||||
);
|
||||
|
||||
// Return 2 highest line counts
|
||||
return legacies;
|
||||
|
|
@ -110,6 +113,8 @@ const createContributor = async (contrib) => {
|
|||
url: contrib.html_url,
|
||||
size: contrib.contributions,
|
||||
imageUrl: contrib.avatar_url,
|
||||
contents:
|
||||
'This is one of the main contributors to the overall repository and this part of the repository specifically. Below you can see the contributors latest commits and the button on the right will take you straight to the respective Github profile.',
|
||||
commits,
|
||||
};
|
||||
};
|
||||
|
|
@ -124,20 +129,26 @@ const createPackage = ({ name, version }) => {
|
|||
path,
|
||||
version,
|
||||
size,
|
||||
contents: '',
|
||||
contents: `This package is used throughout this part of the repository. Below you can see the version that is installed currently. If you want to take a look at the package documentation, past versions and much more, click the button in the lower right corner. It'll lead you to the npmjs website of the package.`,
|
||||
url: `https://www.npmjs.com/package/${name}`,
|
||||
};
|
||||
};
|
||||
|
||||
const createLegacy = ({ path, count }) => {
|
||||
const createLegacy = async ({ path, count }) => {
|
||||
const fileSize = await getItemSize(path);
|
||||
const rawFileContents = await readFile(path, 'utf-8');
|
||||
const projectPath = path.replace(PROJECT_PATH, '');
|
||||
|
||||
const fileContents = rawFileContents.replace(/\r\n/g, '\n').split('\n').slice(30, 40).join('\n');
|
||||
|
||||
return {
|
||||
type: 'LEGACY',
|
||||
name: basename(projectPath),
|
||||
path: projectPath,
|
||||
size: count,
|
||||
contents: '',
|
||||
contents: `This file seems pretty big compared to the other files in this part of the project. It's ${fileSize.size} bytes and has ${count} lines of code. That could make it hard to read for new contributors and people looking at the repository. You might want to look into a refactoring in order to keep it at a more readable size. What you could also do is contact one of the contributors to help in understanding what's going on. They must be hiding somewhere in this package as well, try to reveal them to access their Github profiles.`,
|
||||
fileContents,
|
||||
fileSize: fileSize.size,
|
||||
url: `https://github.com/ethereumjs/ethereumjs-monorepo/blob/master${projectPath}`,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Reference in a new issue