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

Function main

scripts/verdaccio-seed.js:113–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111}
112
113async function main() {
114 const storagePath = path.resolve(
115 process.argv[2] || process.env.VERDACCIO_STORAGE_PATH || '/tmp/verdaccio-workspace/storage'
116 );
117 fs.mkdirSync(storagePath, {recursive: true});
118
119 const locations = await readWorkspaceLocations();
120 const start = Date.now();
121 const seeded = await pool(locations, loc => seedOne(storagePath, loc), CONCURRENCY);
122 const names = seeded.filter(Boolean);
123
124 const dbPath = path.join(storagePath, '.verdaccio-db.json');
125 let db = {list: [], secret: crypto.randomBytes(16).toString('hex')};
126 if (fs.existsSync(dbPath)) {
127 try {
128 db = JSON.parse(fs.readFileSync(dbPath, 'utf8'));
129 } catch (e) {
130 // corrupt/empty db, start fresh
131 }
132 }
133 db.list = Array.from(new Set([...(db.list || []), ...names]));
134 fs.writeFileSync(dbPath, JSON.stringify(db));
135
136 console.log(
137 `Seeded ${names.length} packages into ${storagePath} in ${((Date.now() - start) / 1000).toFixed(1)}s`
138 );
139}
140
141main().catch(err => {
142 console.error(err);

Callers 1

verdaccio-seed.jsFile · 0.70

Calls 6

readWorkspaceLocationsFunction · 0.85
poolFunction · 0.85
seedOneFunction · 0.85
filterMethod · 0.65
toStringMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected