packages/build-tools/tasks/api-tasks/bolt-pkg-versions.js
async function generatePackageData() {
  boltPackages.forEach(async pkg => {
    if (pkg.version !== '0.0.0' && pkg.private !== true) {
      const name = pkg.name;
      try {
        const pkgInfo = await packageJson(name, {
          allVersions: true,
        });

        processedPackages.push(pkgInfo);
        numberOfPackagesProcessed += 1;
      } catch (err) {
        console.log(err);
      }
    } else {
      numberOfPackagesProcessed += 1;
    }

    if (numberOfPackagesProcessed === totalNumberOfPackages) {
      const config = await getConfig();
      const unformattedJSON = JSON.stringify(processedPackages);
      const formattedJSON = prettier.format(unformattedJSON, {
        parser: 'json',
      });

      fs.writeFile(
        path.join(config.dataDir, 'bolt-pkg-versions.json'),
        formattedJSON,
        'utf8',
        function(err) {
          if (err) {
            console.log('An error occured while writing JSON Object to File.');
            return console.log(err);
          }

          console.log('Bolt NPM pkg Data has been saved.');
        },
      );
    }
  });
}
async function generatePackageData() {
  boltPackages.forEach(async pkg => {
    if (pkg.version !== '0.0.0' && pkg.private !== true) {
      const name = pkg.name;
      try {
        const pkgInfo = await packageJson(name, {
          allVersions: true,
        });

        processedPackages.push(pkgInfo);
        numberOfPackagesProcessed += 1;
      } catch (err) {
        console.log(err);
      }
    } else {
      numberOfPackagesProcessed += 1;
    }

    if (numberOfPackagesProcessed === totalNumberOfPackages) {
      const config = await getConfig();
      const unformattedJSON = JSON.stringify(processedPackages);
      const formattedJSON = prettier.format(unformattedJSON, {
        parser: 'json',
      });

      fs.writeFile(
        path.join(config.dataDir, 'bolt-pkg-versions.json'),
        formattedJSON,
        'utf8',
        function(err) {
          if (err) {
            console.log('An error occured while writing JSON Object to File.');
            return console.log(err);
          }

          console.log('Bolt NPM pkg Data has been saved.');
        },
      );
    }
  });
}
async function generatePackageData ( ) { boltPackages . forEach ( async pkg => { if ( pkg . version !== '0.0.0' && pkg . private !== true ) { const name = pkg . name ; try { const pkgInfo = await packageJson ( name , { allVersions : true , } ) ; processedPackages . push ( pkgInfo ) ; numberOfPackagesProcessed += 1 ; } catch ( err ) { console . log ( err ) ; } } else { numberOfPackagesProcessed += 1 ; } if ( numberOfPackagesProcessed === totalNumberOfPackages ) { const config = await getConfig ( ) ; const unformattedJSON = JSON . stringify ( processedPackages ) ; const formattedJSON = prettier . format ( unformattedJSON , { parser : 'json' , } ) ; fs . writeFile ( path . join ( config . dataDir , 'bolt-pkg-versions.json' ) , formattedJSON , 'utf8' , function ( err ) { if ( err ) { console . log ( 'An error occured while writing JSON Object to File.' ) ; return console . log ( err ) ; } console . log ( 'Bolt NPM pkg Data has been saved.' ) ; } , ) ; } } ) ; }
iterator for forEach loop so we know when we're done
iterator for forEach loop so we know when we re done