libs/zip-files.js
/**
 *
 * @param {string} vrs The version of the docs the folder is in, v0.3, v1.1
 * @param {string} folder The folder that the tutorial is in.
 * @param {string} provider What provider are files packed for
 */
@param {string} vrs The version of the docs the folder is in, v0.3, v1.1
@param {string} folder The folder that the tutorial is in.
@param {string} provider What provider are files packed for
@param { string } vrs The version of the docs the folder is in v0 . 3 v1 . 1 @param { string } folder The folder that the tutorial is in . @param { string } provider What provider are files packed for
async function run(vrs, folder, provider) {
  console.log(provider);
  try {
    var zip = new JSZip();
    const configData = fs.readFileSync(
      'docs/airnode/' + vrs +'/grp-providers/tutorial/' +folder + '/src/config.json',
      'utf8'
    );
    const secretsData = fs.readFileSync(
      'docs/airnode/' + vrs + '/grp-providers/tutorial/' +folder + '/src/secrets.env',
      'utf8'
    );
    let awsData;
    if (provider === 'aws') {
      awsData = fs.readFileSync(
        'docs/airnode/' + vrs + '/grp-providers/tutorial/' + folder + '/src/aws.env',
        'utf8'
      );
    }
    zip
      .folder(folder)
      .folder('config')
      .file('config.json', configData)
      .file('secrets.env', secretsData);
    if (provider === 'aws') {
      zip.folder(folder).file('aws.env', awsData);
    }
    if (provider !== 'local') {
      zip.folder(folder).folder('output');
    }
    zip
      .generateNodeStream({ type: 'nodebuffer', streamFiles: true })
      .pipe(
        fs.createWriteStream(
          './docs/.vuepress/public/zip-files/' + folder + '-'+ vrs +'.zip'
        )
      )
      .on('finish', function () {
        console.log('zip file written.');
      });
  } catch (error) {
    process.stdout.write(colors.bold.red(error));
  }
}
async function run ( vrs , folder , provider ) { console . log ( provider ) ; try { var zip = new JSZip ( ) ; const configData = fs . readFileSync ( 'docs/airnode/' + vrs + '/grp-providers/tutorial/' + folder + '/src/config.json' , 'utf8' ) ; const secretsData = fs . readFileSync ( 'docs/airnode/' + vrs + '/grp-providers/tutorial/' + folder + '/src/secrets.env' , 'utf8' ) ; let awsData ; if ( provider === 'aws' ) { awsData = fs . readFileSync ( 'docs/airnode/' + vrs + '/grp-providers/tutorial/' + folder + '/src/aws.env' , 'utf8' ) ; } zip . folder ( folder ) . folder ( 'config' ) . file ( 'config.json' , configData ) . file ( 'secrets.env' , secretsData ) ; if ( provider === 'aws' ) { zip . folder ( folder ) . file ( 'aws.env' , awsData ) ; } if ( provider !== 'local' ) { zip . folder ( folder ) . folder ( 'output' ) ; } zip . generateNodeStream ( { type : 'nodebuffer' , streamFiles : true } ) . pipe ( fs . createWriteStream ( './docs/.vuepress/public/zip-files/' + folder + '-' + vrs + '.zip' ) ) . on ( 'finish' , function ( ) { console . log ( 'zip file written.' ) ; } ) ; } catch ( error ) { process . stdout . write ( colors . bold . red ( error ) ) ; } }
@param {string} vrs The version of the docs the folder is in, v0.3, v1.1
 @param {string} folder The folder that the tutorial is in.
@param { string } vrs The version of the docs the folder is in v0 . 3 v1 . 1 @param { string } folder The folder that the tutorial is in .
// prettier-ignore // prettier-ignore // prettier-ignore // prettier-ignore // JSZip generates a readable stream with a "end" event, // but is piped here in a writable stream which emits a "finish" event.