import axios from 'axios'; import { writeFileSync } from 'fs'; import * as packageLockJson from './package-lock.json'; import * as packageJson from './package.json'; // package; (async () => { const all = { ...packageJson.dependencies, ...packageJson.devDependencies }; let fullMd = `# Packages`; for (const packageName in all) { if (Object.prototype.hasOwnProperty.call(all, packageName)) { if (packageName.startsWith('@yourcause')) { continue; } const name = packageName as keyof typeof packageLockJson['dependencies']; const resolvedVersion = packageLockJson.dependencies[name]; const url = `https://registry.npmjs.org/${encodeURIComponent(packageName)}/${resolvedVersion.version}`; const result = await axios.get(url) .catch(e => { e; url; throw e; }); const packageData = result.data as typeof packageJson; if (!packageData.license) { packageData; } fullMd += ` ## ${packageData.name} (${packageData.version}) #### Licence: ${packageData.license} ###### Package description: ${packageData.description} #### Usage: --- `; } } writeFileSync('./package-info.md', fullMd); })();