Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "gulp-awspublish in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'gulp-awspublish' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

// Set headers
  var headers = {
    'Cache-Control': 'max-age=1800, public'
  }

  var version = require('./package').version
  var majorVersion = version.match(/^(\d).(\d).(\d)/)[1]

  var versionPath = './dist/cdn/**'

  console.warn('Uploading All files in:', versionPath)

  return gulp.src([versionPath])
    // Gzip
    .pipe(awspublish.gzip())
    // Publish files with headers
    .pipe(publisher.publish(headers))
    // Create a cache file to speed up consecutive uploads
    .pipe(publisher.cache())
    // Print upload updates to console
    .pipe(awspublish.reporter())
})
gulp.task('upload-vendor-file', function publishAWS() {
  if (existsSync(manifestPath)) {
    // eslint-disable-next-line global-require, import/no-dynamic-require
    manifestJSON = require(manifestPath);
  } else {
    log(`Manifest file not found: ${manifestPath}`);
    throw new Error(`Manifest file not found: ${manifestPath}`);
  }

  const publisher = awspublish.create({
    region: 'us-east-1',
    params: {
      Bucket: process.env.s3bucket
    }
  });

  const headers = {
    'Cache-Control': 'max-age=315360000, no-transform, public'
  };

  return gulp
    .src([
      `./dist/static/js/${manifestJSON['vendor.js']}`,
      `./dist/static/js/${manifestJSON['vendor.js.map']}`
    ])
    .pipe(
gulp.task("cdn", function(){

    var aws = JSON.parse(fs.readFileSync("./_s3.json"));

    // create a new publisher
    var publisher = awspublish.create(aws);
    gulp
        .src("./build/alpaca/**/*")
        .pipe(rename(function(x) {
            x.dirname = path.join("alpaca", pkg.version, x.dirname);
        }))
        .pipe(publisher.publish())
        //.pipe(publisher.sync())
        .pipe(awspublish.reporter());
});
gulp.task('deploy', function() {
  var cacheLife, publisher, headers;
  if (!process.env.AWS_KEY || !process.env.AWS_SECRET) {
    throw 'AWS credentials are required!';
  }
  cacheLife = (1000 * 60 * 60); // 1 hour (* 24 * 365)
  headers = {
    'Cache-Control': 'max-age=' + cacheLife + ', public'
  };
  publisher = aws.create({
    'accessKeyId': process.env.AWS_KEY,
    'secretAccessKey': process.env.AWS_SECRET,
    'params': {
      'Bucket': 'keen-js',
      'Expires': new Date(Date.now() + cacheLife)
    }
  });

  return gulp.src([
      './dist/' + pkg.name + '.js',
      './dist/' + pkg.name + '.min.js'
    ])
    .pipe(rename(function(path) {
      path.dirname += '/';
      var name = pkg.name + '-' + pkg.version;
      path.basename = (path.basename.indexOf('min') > -1) ? name + '.min' : name;
function deployS3(config) {
  if (!config.credentials.accessKeyId || !config.credentials.secretAccessKey) {
    gutil.log(
      gutil.colors.red('AWS S3 credentials missing, skipping upload...'),
    );
    return;
  }

  // create a new publisher
  const publisher = aws.create(config.credentials);

  // define custom headers
  const headers = {
    'Cache-Control': 'max-age=315360000, no-transform, public',
  };
  return (
    gulp
      .src(config.assetsPath)
      .pipe(
        rename(function(filepath) {
          filepath.dirname = path.join(config.dirname, filepath.dirname);
        }),
      )
      // gzip, Set Content-Encoding headers and add .gz extension
      .pipe(gulpIf(file => !file.path.match(/\.(mp4|ogg|webm|avi|mov|mkv)$/), aws.gzip()))
      // publisher will add Content-Length, Content-Type and headers specified above
gulp
      .src(config.assetsPath)
      .pipe(
        rename(function(filepath) {
          filepath.dirname = path.join(config.dirname, filepath.dirname);
        }),
      )
      // gzip, Set Content-Encoding headers and add .gz extension
      .pipe(gulpIf(file => !file.path.match(/\.(mp4|ogg|webm|avi|mov|mkv)$/), aws.gzip()))
      // publisher will add Content-Length, Content-Type and headers specified above
      // If not specified it will set x-amz-acl to public-read by default
      .pipe(publisher.publish(headers))
      // create a cache file to speed up consecutive uploads
      .pipe(publisher.cache())
      // print upload updates to console
      .pipe(aws.reporter())
  );
}
// define custom headers
    var headers = {
      'Cache-Control': 'max-age=315360000, no-transform, public'
    };

    var revAll = new RevAll({
      dontRenameFile: ['\.woff', '\.woff2', '\.svg', '\.ttf', '\.eot']
    });

    return gulp.src('./dist/app/**/*.*')
      .pipe(revAll.revision())
      .pipe(awspublish.gzip())
      .pipe(publisher.publish(headers))
      .pipe(publisher.cache())
      .pipe(awspublish.reporter())
      .pipe(cloudfront(aws));
  });
question: deline`You're about to publish this project to AWS
                            under the directory '${awsDirectory}'.
                            In the process, we'll also wipe out any
                            uploads to the test directory.
                            Are you sure you want to do this?`,
          input: '_key:y',
        }))
        .pipe(rename((filePath) => {
          // eslint-disable-next-line no-param-reassign
          filePath.dirname = awsDirectory + filePath.dirname.replace('.\\', '');
        }))
        .pipe(awspublishRouter(routes))
        .pipe(publisher.publish({}, { force: false }))
        .pipe(cloudfront(cfSettings))
        .pipe(publisher.cache())
        .pipe(awspublish.reporter())
        .on(
          'end',
          gutil.log.bind(
            gutil,
            // eslint-disable-next-line comma-dangle
            `Published at 'http://interactives.dallasnews.com/${awsDirectory}'.`
          )  // eslint-disable-line comma-dangle
        );
};

  return gulp
    .src([
      `./dist/static/js/${manifestJSON['vendor.js']}`,
      `./dist/static/js/${manifestJSON['vendor.js.map']}`
    ])
    .pipe(
      rename(function renamePlugin(path) {
        path.dirname = `/${vendor}/${path.dirname}`; // eslint-disable-line no-param-reassign
        return path;
      })
    )
    .pipe(awspublish.gzip())
    .pipe(publisher.publish(headers))
    .pipe(awspublish.reporter());
});
const headers = {
    'Cache-Control': 'max-age=315360000, no-transform, public'
  };

  return gulp
    .src([
      `./dist/static/js/${manifestJSON['vendor.js']}`,
      `./dist/static/js/${manifestJSON['vendor.js.map']}`
    ])
    .pipe(
      rename(function renamePlugin(path) {
        path.dirname = `/${vendor}/${path.dirname}`; // eslint-disable-line no-param-reassign
        return path;
      })
    )
    .pipe(awspublish.gzip())
    .pipe(publisher.publish(headers))
    .pipe(awspublish.reporter());
});

Is your System Free of Underlying Vulnerabilities?
Find Out Now