MCPcopy Create free account
hub / github.com/adobe/react-spectrum / verdaccioPkgSize

Function verdaccioPkgSize

scripts/verdaccioPkgSize.js:9–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7// Creates a file listing the tarball sizes of every Verdaccio published package
8// Assumes that the verdaccio db json exists and that the store for the packages is ~/.config/verdaccio/storage/
9function verdaccioPkgSize() {
10 let verdaccioStorePath = '/tmp/verdaccio-workspace/storage';
11
12 if (!fs.existsSync(verdaccioStorePath)) {
13 verdaccioStorePath = path.join(__dirname, '..', 'verdaccio', 'storage/');
14 }
15
16 let json = {};
17 let verdaccioDBPath = path.join('/tmp/verdaccio-workspace/storage', '.verdaccio-db.json');
18 let publishedPackages = JSON.parse(fs.readFileSync(verdaccioDBPath), 'utf').list;
19 for (let pkg of publishedPackages) {
20 let tarballPath = glob.sync(`**/${pkg}/*.tgz`, {cwd: verdaccioStorePath}).sort().at(-1);
21 let size = fs.statSync(path.join(verdaccioStorePath, tarballPath)).size / 1000;
22 json[pkg] = size;
23 }
24
25 fs.writeFileSync('publish.json', JSON.stringify(json, null, 2));
26}

Callers 1

Calls 3

atMethod · 0.65
sortMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected